import * as m3o from "@m3o/m3o-node"; export class FunctionService { private client: m3o.Client; constructor(token: string) { this.client = new m3o.Client({ token: token }); } // Call a function call(request: CallRequest): Promise { return this.client.call( "function", "Call", request ) as Promise; } // delete(request: DeleteRequest): Promise { return this.client.call( "function", "Delete", request ) as Promise; } // Deploy a group of functions deploy(request: DeployRequest): Promise { return this.client.call( "function", "Deploy", request ) as Promise; } // list(request: ListRequest): Promise { return this.client.call( "function", "List", request ) as Promise; } } export interface CallRequest { // Name of the function name?: string; // Request body that will be passed to the function request?: { [key: string]: any }; } export interface CallResponse { // Response body that the function returned response?: { [key: string]: any }; } export interface DeleteRequest { // The name of the function name?: string; // Optional project name project?: string; } export interface DeleteResponse {} export interface DeployRequest { // entry point, ie. handler name in the source code // if not provided, defaults to the name parameter entrypoint?: string; // function name name?: string; // project is used for namespacing your functions // optional. defaults to "default". project?: string; // github url to repo repo?: string; // optional subfolder path subfolder?: string; } export interface DeployResponse {} export interface Func { // name of handler in source code entrypoint?: string; // function name name?: string; // project of function, optional // defaults to literal "default" // used to namespace functions project?: string; // git repo address repo?: string; // subfolder path to entrypoint subfolder?: string; } export interface ListRequest { // optional project name project?: string; } export interface ListResponse { // List of functions deployed functions?: Func[]; }