UNPKG

buildx-connect

Version:

Official JavaScript/TypeScript SDK for Buildx low-code platform

91 lines (90 loc) 3.24 kB
import { Collection, Document, QueryOptions, ErrorResponse, SuccessResponse, ImportMapping, BuildxConfig } from "../types/index"; /** * Collections service for Buildx * Handles collection management, documents, and queries * * @example * ```typescript * const collections = buildx.collections(); * * // Get all collections * const collectionsList = await collections.list(); * * // Get collection schema * const schema = await collections.getSchema('collection-id'); * * // Query documents * const docs = await collections.query('collection-id', { * filter: { status: 'active' }, * limit: 10 * }); * ``` */ export declare class Collections { private baseService; constructor(config: BuildxConfig); updateConfig(config: BuildxConfig): void; /** * List all collections in a project */ list(projectId?: string, withStats?: boolean, withBuildx?: boolean): Promise<Collection[] | ErrorResponse>; /** * Get collection schema */ getSchema(collectionId: string, projectId?: string, depth?: number): Promise<Collection | ErrorResponse>; /** * Create or update collection */ set(collectionData: Partial<Collection>, projectId?: string): Promise<Collection | ErrorResponse>; /** * Delete collection */ deleteCollection(collectionId: string, projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * Query documents in a collection */ query(collectionId: string, options?: QueryOptions, projectId?: string): Promise<Document[] | ErrorResponse>; /** * Get lookup data for a collection (for dropdowns/autocomplete) */ lookup(collectionId: string, options?: QueryOptions, projectId?: string): Promise<Array<{ value: string; label: string; }> | ErrorResponse>; /** * Get single document by ID */ getDocument(collectionId: string, documentId: string, populate?: string[], projectId?: string): Promise<Document | ErrorResponse>; /** * Create new document */ createDocument(collectionId: string, data: any, projectId?: string): Promise<Document | ErrorResponse>; /** * Update document */ updateDocument(collectionId: string, documentId: string, data: any, projectId?: string): Promise<Document | ErrorResponse>; /** * Delete document */ deleteDocument(collectionId: string, documentId: string, projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * Delete documents by filter */ deleteByFilter(collectionId: string, filter: any, projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * Import data to collection */ import(collectionId: string, file: File, mapping: ImportMapping, projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * Get collection data types */ getDataTypes(projectId?: string): Promise<any | ErrorResponse>; /** * Validate collection data */ validate(collectionId: string, projectId?: string): Promise<SuccessResponse | ErrorResponse>; /** * Migrate collection data */ migrate(collectionId: string, projectId?: string): Promise<SuccessResponse | ErrorResponse>; }