UNPKG

magically-sdk

Version:

Official SDK for Magically - Build mobile apps with AI

51 lines (50 loc) 1.79 kB
import { SDKConfig, StandardFields } from './types'; import { MagicallyAuth } from './MagicallyAuth'; export declare class MagicallyData { private config; private auth; constructor(config: SDKConfig, auth: MagicallyAuth); /** * Query data from a collection with type safety * @param collection - Collection name * @param filter - MongoDB filter object (optional) * @param options - Query options (sort, limit, skip) */ query<T extends StandardFields>(collection: string, filter?: Record<string, any>, options?: { sort?: Record<string, number>; limit?: number; skip?: number; }): Promise<{ data: T[]; total: number; }>; /** * Insert data into a collection with type safety */ insert<T extends StandardFields>(collection: string, data: Omit<T, keyof StandardFields>, options?: { upsert?: boolean; }): Promise<T>; /** * Update existing data in a collection (fails if not found) */ update<T extends StandardFields>(collection: string, filter: Record<string, any>, data: Partial<Omit<T, keyof StandardFields>>): Promise<T>; /** * Delete data from a collection */ delete(collection: string, filter: Record<string, any>): Promise<{ deletedCount: number; }>; /** * Run aggregation query with type safety */ aggregate<T = any>(collection: string, pipeline: any[]): Promise<T[]>; /** * Run raw MongoDB operations with type safety and validation */ raw<T = any>(collection: string, operation: string, options?: Record<string, any>): Promise<T>; /** * Handle API errors with structured error information for AI debugging */ private handleAPIError; private getApiUrl; }