-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #703 from OpenFn/release/next
release apollo
- Loading branch information
Showing
17 changed files
with
952 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,5 +32,8 @@ | |
"files": [ | ||
"dist", | ||
"README.md" | ||
] | ||
], | ||
"devDependencies": { | ||
"@types/koa": "^2.15.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
{ | ||
"api_key": "YOUR_OPENAI_KEY_HERE", | ||
"endpoint": "/facts", | ||
"model": "gpt3_turbo", | ||
"open_api_spec": { | ||
"openapi": "3.0.0", | ||
"info": { | ||
"title": "Cat Facts API", | ||
"version": "1.0" | ||
}, | ||
"paths": { | ||
"/breeds": { | ||
"get": { | ||
"tags": ["Breeds"], | ||
"summary": "Get a list of breeds", | ||
"description": "Returns a a list of breeds", | ||
"operationId": "getBreeds", | ||
"parameters": [ | ||
{ | ||
"name": "limit", | ||
"in": "query", | ||
"description": "limit the amount of results returned", | ||
"required": false, | ||
"schema": { | ||
"type": "integer", | ||
"format": "int64" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "successful operation", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/Breed" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/fact": { | ||
"get": { | ||
"tags": ["Facts"], | ||
"summary": "Get Random Fact", | ||
"description": "Returns a random fact", | ||
"operationId": "getRandomFact", | ||
"parameters": [ | ||
{ | ||
"name": "max_length", | ||
"in": "query", | ||
"description": "maximum length of returned fact", | ||
"required": false, | ||
"schema": { | ||
"type": "integer", | ||
"format": "int64" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "successful operation", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/CatFact" | ||
} | ||
} | ||
} | ||
}, | ||
"404": { | ||
"description": "Fact not found" | ||
} | ||
} | ||
} | ||
}, | ||
"/facts": { | ||
"get": { | ||
"tags": ["Facts"], | ||
"summary": "Get a list of facts", | ||
"description": "Returns a a list of facts", | ||
"operationId": "getFacts", | ||
"parameters": [ | ||
{ | ||
"name": "max_length", | ||
"in": "query", | ||
"description": "maximum length of returned fact", | ||
"required": false, | ||
"schema": { | ||
"type": "integer", | ||
"format": "int64" | ||
} | ||
}, | ||
{ | ||
"name": "limit", | ||
"in": "query", | ||
"description": "limit the amount of results returned", | ||
"required": false, | ||
"schema": { | ||
"type": "integer", | ||
"format": "int64" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "successful operation", | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/components/schemas/CatFact" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"Breed": { | ||
"title": "Breed model", | ||
"description": "Breed", | ||
"properties": { | ||
"breed": { | ||
"title": "Breed", | ||
"description": "Breed", | ||
"type": "string", | ||
"format": "string" | ||
}, | ||
"country": { | ||
"title": "Country", | ||
"description": "Country", | ||
"type": "string", | ||
"format": "string" | ||
}, | ||
"origin": { | ||
"title": "Origin", | ||
"description": "Origin", | ||
"type": "string", | ||
"format": "string" | ||
}, | ||
"coat": { | ||
"title": "Coat", | ||
"description": "Coat", | ||
"type": "string", | ||
"format": "string" | ||
}, | ||
"pattern": { | ||
"title": "Pattern", | ||
"description": "Pattern", | ||
"type": "string", | ||
"format": "string" | ||
} | ||
}, | ||
"type": "object" | ||
}, | ||
"CatFact": { | ||
"title": "CatFact model", | ||
"description": "CatFact", | ||
"properties": { | ||
"fact": { | ||
"title": "Fact", | ||
"description": "Fact", | ||
"type": "string", | ||
"format": "string" | ||
}, | ||
"length": { | ||
"title": "Length", | ||
"description": "Length", | ||
"type": "integer", | ||
"format": "int32" | ||
} | ||
}, | ||
"type": "object" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import yargs from 'yargs'; | ||
import * as o from '../options'; | ||
import type { Opts } from '../options'; | ||
import { build, ensure, override } from '../util/command-builders'; | ||
import { STAGING_URL } from './util'; | ||
|
||
export type ApolloOptions = Pick< | ||
Opts, | ||
'stateStdin' | 'log' | 'logJson' | 'apolloUrl' | 'outputPath' | 'outputStdout' | ||
> & { | ||
service: string; | ||
payload?: string; | ||
}; | ||
|
||
const options = [ | ||
o.apolloUrl, | ||
o.stateStdin, | ||
o.log, | ||
o.logJson, | ||
o.outputPath, | ||
override(o.outputStdout, { | ||
default: true, | ||
}), | ||
]; | ||
|
||
const desc = `Call services on the openfn apollo server. Set the local server location with OPENFN_APOLLO_SERVER. The staging server is set to ${STAGING_URL}`; | ||
|
||
export default { | ||
command: 'apollo <service> [payload]', | ||
desc, | ||
handler: ensure('apollo', options), | ||
builder: (yargs) => | ||
build(options, yargs) | ||
.example( | ||
'apollo echo path/to/json', | ||
'Call the echo service, which returns json back' | ||
) | ||
.example( | ||
'apollo adaptor_gen cat-facts.example.json --local', | ||
'Generate an adaptor template against a local server' | ||
), | ||
} as yargs.CommandModule<{}>; |
Oops, something went wrong.