magically-sdk
Version:
Official SDK for Magically - Build mobile apps with AI
46 lines (45 loc) • 1.53 kB
TypeScript
import { SDKConfig } from './types';
import { MagicallyAuth } from './MagicallyAuth';
export interface FunctionInvokeOptions {
headers?: Record<string, string>;
body?: any;
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
}
export interface FunctionResponse<T = any> {
data?: T;
error?: {
message: string;
code?: string;
};
headers?: Record<string, string>;
status?: number;
}
export declare class MagicallyFunctions {
private config;
private auth;
private apiClient;
private logger;
private projectId;
constructor(config: SDKConfig, auth: MagicallyAuth);
/**
* Invoke a Cloudflare Worker function
* @param functionName - The name of the function to invoke
* @param options - Options for the function invocation
*/
invoke<T = any>(functionName: string, options?: FunctionInvokeOptions): Promise<FunctionResponse<T>>;
/**
* Invoke a function with a specific path
* @param functionName - The name of the function to invoke
* @param path - The path to append to the function URL
* @param options - Options for the function invocation
*/
invokeWithPath<T = any>(functionName: string, path: string, options?: FunctionInvokeOptions): Promise<FunctionResponse<T>>;
/**
* Health check for a function
* @param functionName - The name of the function to check
*/
health(functionName: string): Promise<FunctionResponse<{
status: string;
timestamp: number;
}>>;
}