UNPKG

magically-sdk

Version:

Official SDK for Magically - Build mobile apps with AI

59 lines (58 loc) 2.03 kB
import { SDKConfig, StandardFields } from './types'; import { MagicallyAuth } from './MagicallyAuth'; export declare class MagicallyData { private config; private auth; private apiClient; constructor(config: SDKConfig, auth: MagicallyAuth); /** * Check if a query is public (doesn't require authentication) */ private isPublicQuery; /** * Check if an aggregate pipeline is public (doesn't require authentication) */ private isPublicAggregate; /** * Check if a raw operation is public (read-only with isPublic filter) */ private isPublicRawOperation; /** * 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>; }