UNPKG

@aicippy/functions-js

Version:

AiCippy Functions JavaScript client for serverless edge functions

60 lines 2.19 kB
export interface AiCippyFunctionsOptions { url: string; headers?: Record<string, string>; } export interface FunctionInvokeOptions { headers?: Record<string, string>; body?: any; method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; } export interface FunctionResponse<T = any> { data: T | null; error: FunctionsError | null; } export interface FunctionsError extends Error { status?: number; context?: any; } export declare class AiCippyFunctions { protected url: string; protected headers: Record<string, string>; constructor(options: AiCippyFunctionsOptions); /** * Invoke a serverless function */ invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<FunctionResponse<T>>; /** * Invoke a function with GET method */ get<T = any>(functionName: string, options?: Omit<FunctionInvokeOptions, 'method' | 'body'>): Promise<FunctionResponse<T>>; /** * Invoke a function with POST method */ post<T = any>(functionName: string, body?: any, options?: Omit<FunctionInvokeOptions, 'method' | 'body'>): Promise<FunctionResponse<T>>; /** * Invoke a function with PUT method */ put<T = any>(functionName: string, body?: any, options?: Omit<FunctionInvokeOptions, 'method' | 'body'>): Promise<FunctionResponse<T>>; /** * Invoke a function with DELETE method */ delete<T = any>(functionName: string, options?: Omit<FunctionInvokeOptions, 'method' | 'body'>): Promise<FunctionResponse<T>>; /** * Invoke a function with PATCH method */ patch<T = any>(functionName: string, body?: any, options?: Omit<FunctionInvokeOptions, 'method' | 'body'>): Promise<FunctionResponse<T>>; /** * Create a streaming connection to a function */ stream(functionName: string, options?: FunctionInvokeOptions): Promise<ReadableStream | null>; /** * List available functions */ list(): Promise<FunctionResponse<string[]>>; /** * Get function metadata */ getFunction(functionName: string): Promise<FunctionResponse<any>>; } export default AiCippyFunctions; //# sourceMappingURL=index.d.ts.map