// Global declarations for vanilla JS usage (script tag) declare global { const SuperLeapSDK: typeof SuperLeapSDKClass; const createSuperLeapSDK: ( options?: SuperLeapSDKOptions ) => SuperLeapSDKClass; const DataType: typeof DataTypeEnum; const RelationshipType: typeof RelationshipTypeEnum; const CacheManager: typeof CacheManagerClass; const CacheEntry: typeof CacheEntryClass; // Also available on window object interface Window { SuperLeapSDK: typeof SuperLeapSDKClass; createSuperLeapSDK: (options?: SuperLeapSDKOptions) => SuperLeapSDKClass; DataType: typeof DataTypeEnum; RelationshipType: typeof RelationshipTypeEnum; CacheManager: typeof CacheManagerClass; CacheEntry: typeof CacheEntryClass; sdk?: SuperLeapSDKClass; } } // Type definitions for SDK options interface SuperLeapSDKOptions { apiKey?: string; baseUrl?: string; clientId?: string; clientSecret?: string; cache?: { enabled?: boolean; maxSize?: number; defaultTTL?: number; ttl?: { schema?: number; records?: number; count?: number; user?: number; }; }; } // Data types enum declare const DataTypeEnum: { Int: 1; Varchar: 5; Checkbox: 6; DateTime: 7; Date: 8; SecondsSinceMidnight: 9; Email: 11; Text: 14; SingleSelect: 15; MultiSelect: 16; Url: 17; FileUpload: 20; PhoneNumber: 21; Rating: 22; Decimal: 4; Currency: 23; Stage: 24; Location: 18; Region: 27; MultiFileUpload: 29; }; // Relationship types enum declare const RelationshipTypeEnum: { OneToOne: 1; OneToMany: 2; ManyToOne: 3; Restricted: 6; }; // Cache entry class declare class CacheEntryClass { value: any; createdAt: number; ttl: number | null; constructor(value: any, ttl?: number | null); isExpired(): boolean; getValue(): any; } // Cache manager class declare class CacheManagerClass { enabled: boolean; maxSize: number; defaultTTL: number; storage: Map; stats: { hits: number; misses: number; sets: number; deletes: number; evictions: number; }; constructor(options?: { enabled?: boolean; maxSize?: number; defaultTTL?: number; }); get(key: string): any; set(key: string, value: any, ttl?: number): void; delete(key: string): boolean; clear(): void; getStats(): { hits: number; misses: number; sets: number; deletes: number; evictions: number; size: number; maxSize: number; hitRate: string; }; cleanExpired(): number; } declare class SuperLeapSDKClass { apiKey: string | null; baseUrl: string; clientId: string; clientSecret: string; cache: CacheManagerClass; cacheTTL: { schema: number; records: number; count: number; user: number; }; constructor(options?: SuperLeapSDKOptions); getCurrentUserData(): Promise; getCurrentUser(): Promise; getModel(objectSlug: string): Model; model(objectSlug: string): Model; getObjectSchema(objectSlug: string): Promise; setApiKey(apiKey: string): void; setClientCredentials(clientId: string, clientSecret: string): void; request( endpoint: string, options?: { method?: string; headers?: Record; body?: any; cache?: { useCache?: boolean; ttl?: number; key?: string; }; } ): Promise; getRecords( objectSlug: string, filtersData?: any, options?: { useCache?: boolean; cacheTTL?: number } ): Promise; getRecordById(objectSlug: string, id: string): Promise; createRecord(objectSlug: string, createData: any): Promise; updateRecord(objectSlug: string, id: string, updateData: any): Promise; deleteRecord(objectSlug: string, id: string): Promise; deleteRecords(objectSlug: string, recordIds: string[]): Promise; getRecordsCount( objectSlug: string, filtersData?: any, options?: { useCache?: boolean; cacheTTL?: number } ): Promise; bulkUpsert( objectSlug: string, records: any[], ignoreDuplicates?: boolean, disablePartialUpsert?: boolean, disableCreate?: boolean ): Promise; transactionalBulkCreate( records: Array<{ object_slug: string; record: any }>, partialUpsert?: boolean ): Promise; transactionalBulkUpdate( records: Array<{ object_slug: string; record: any }>, partialUpsert?: boolean ): Promise; transactionalBulkUpsert( records: Array<{ object_slug: string; record: any }>, partialUpsert?: boolean ): Promise; // Cache management methods setCacheEnabled(enabled: boolean): void; clearCache(): void; getCacheStats(): { hits: number; misses: number; sets: number; deletes: number; evictions: number; size: number; maxSize: number; hitRate: string; }; invalidateCache(objectSlug?: string): void; cleanExpiredCache(): number; } declare class Model { objectSlug: string; constructor(objectSlug: string, sdk: SuperLeapSDKClass); getSchema(): Promise; getField(fieldSlug: string): Promise; getFields(): Promise; select(...fields: string[]): QueryBuilder; selectAll(): QueryBuilder; create(data: any): Promise; get(id: string): Promise; update(id: string, data: any): Promise; delete(id: string): Promise; deleteMany(ids: string[]): Promise; getOrCreate( filters: any, defaults?: any ): Promise<{ record: RecordInstance; created: boolean }>; updateOrCreate( filters: any, defaults?: any ): Promise<{ record: RecordInstance; created: boolean }>; bulkCreate( records: any[], ignoreDuplicates?: boolean, disablePartialUpsert?: boolean ): Promise; bulkUpdate( records: any[], ignoreDuplicates?: boolean, disablePartialUpsert?: boolean ): Promise; } declare class QueryBuilder { constructor(objectSlug: string, sdk: SuperLeapSDKClass); // Thenable methods for lazy execution then( onFulfilled?: (value: RecordInstance[]) => T | Promise, onRejected?: (reason: any) => T | Promise ): Promise; catch(onRejected?: (reason: any) => T | Promise): Promise; finally(onFinally?: () => void): Promise; select(...fields: string[]): QueryBuilder; selectAll(): QueryBuilder; where(conditions: any): QueryBuilder; whereAnd(callback: (q: QueryBuilder) => void): QueryBuilder; whereOr(callback: (q: QueryBuilder) => void): QueryBuilder; filter(field: string, operator: string, value: any): QueryBuilder; exact(field: string, value: any): QueryBuilder; iexact(field: string, value: any): QueryBuilder; notexact(field: string, value: any): QueryBuilder; notiexact(field: string, value: any): QueryBuilder; contains(field: string, value: any): QueryBuilder; icontains(field: string, value: any): QueryBuilder; startswith(field: string, value: any): QueryBuilder; endswith(field: string, value: any): QueryBuilder; in(field: string, values: any[]): QueryBuilder; notin(field: string, values: any[]): QueryBuilder; gt(field: string, value: any): QueryBuilder; gte(field: string, value: any): QueryBuilder; lt(field: string, value: any): QueryBuilder; lte(field: string, value: any): QueryBuilder; between(field: string, value: any): QueryBuilder; notcontains(field: string, value: any): QueryBuilder; isempty(field: string): QueryBuilder; isnotempty(field: string): QueryBuilder; exists(field: string): QueryBuilder; notexists(field: string): QueryBuilder; like(field: string, value: any): QueryBuilder; ilike(field: string, value: any): QueryBuilder; isnull(field: string): QueryBuilder; isnotnull(field: string): QueryBuilder; orderBy(...fields: string[]): QueryBuilder; limit(limit: number): QueryBuilder; page(page: number): QueryBuilder; offset(offset: number): QueryBuilder; // Cache control methods cacheOptions(options?: { useCache?: boolean; cacheTTL?: number; }): QueryBuilder; noCache(): QueryBuilder; cacheTTL(ttl: number): QueryBuilder; first(): Promise; count(): Promise; exists(): Promise; } declare class RecordInstance { data: any; id: string; model: Model; constructor(data: any, model: Model); get(field: string): any; set(field: string, value: any): void; update(updateData: any): Promise; delete(): Promise; refresh(): Promise; toJSON(): any; } // Module exports for React/ES6 imports export { CacheEntryClass as CacheEntry, CacheManagerClass as CacheManager, DataTypeEnum as DataType, Model, QueryBuilder, RecordInstance, RelationshipTypeEnum as RelationshipType, SuperLeapSDKClass as SuperLeapSDK, }; export function createSuperLeapSDK( options?: SuperLeapSDKOptions ): SuperLeapSDKClass; export default SuperLeapSDKClass; // Module declaration for mobile export declare module "superleap-sdk/mobile" { export { CacheEntryClass as CacheEntry, CacheManagerClass as CacheManager, DataTypeEnum as DataType, Model, QueryBuilder, RecordInstance, RelationshipTypeEnum as RelationshipType, SuperLeapSDKClass as SuperLeapSDK, }; export function createSuperLeapSDK( options?: SuperLeapSDKOptions ): SuperLeapSDKClass; export default SuperLeapSDKClass; } // Module declaration for web export (explicit) declare module "superleap-sdk/web" { export { CacheEntryClass as CacheEntry, CacheManagerClass as CacheManager, DataTypeEnum as DataType, Model, QueryBuilder, RecordInstance, RelationshipTypeEnum as RelationshipType, SuperLeapSDKClass as SuperLeapSDK, }; export function createSuperLeapSDK( options?: SuperLeapSDKOptions ): SuperLeapSDKClass; export default SuperLeapSDKClass; }