@tspvivek/baasix-sdk 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +942 -0
- package/dist/client-CzF9B60b.d.ts +614 -0
- package/dist/client-aXK_gEyr.d.cts +614 -0
- package/dist/index.cjs +4159 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1498 -0
- package/dist/index.d.ts +1498 -0
- package/dist/index.js +4135 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/auth.cjs +651 -0
- package/dist/modules/auth.cjs.map +1 -0
- package/dist/modules/auth.d.cts +384 -0
- package/dist/modules/auth.d.ts +384 -0
- package/dist/modules/auth.js +649 -0
- package/dist/modules/auth.js.map +1 -0
- package/dist/modules/files.cjs +266 -0
- package/dist/modules/files.cjs.map +1 -0
- package/dist/modules/files.d.cts +187 -0
- package/dist/modules/files.d.ts +187 -0
- package/dist/modules/files.js +264 -0
- package/dist/modules/files.js.map +1 -0
- package/dist/modules/items.cjs +654 -0
- package/dist/modules/items.cjs.map +1 -0
- package/dist/modules/items.d.cts +472 -0
- package/dist/modules/items.d.ts +472 -0
- package/dist/modules/items.js +651 -0
- package/dist/modules/items.js.map +1 -0
- package/dist/modules/schemas.cjs +269 -0
- package/dist/modules/schemas.cjs.map +1 -0
- package/dist/modules/schemas.d.cts +239 -0
- package/dist/modules/schemas.d.ts +239 -0
- package/dist/modules/schemas.js +267 -0
- package/dist/modules/schemas.js.map +1 -0
- package/dist/storage/index.cjs +162 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.cts +96 -0
- package/dist/storage/index.d.ts +96 -0
- package/dist/storage/index.js +157 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types-BdjsGANq.d.cts +40 -0
- package/dist/types-BdjsGANq.d.ts +40 -0
- package/package.json +107 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/modules/items.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AAA,CAAK,MAAA,CAAO,IAAA,CAAK,aAAA,EAAe;AAAA,QACpC,YAAY,IAAA,CAAK,UAAA;AAAA,QACjB,IAAA,EAAM,WAAW,CAAC,CAAA;AAAA,QAClB,EAAA,EAAI,UAAA,CAAW,CAAA,GAAI,CAAC;AAAA,OACrB,CAAA;AAAA,IACH;AAAA,EACF;AACF","file":"items.js","sourcesContent":["import type { HttpClient } from \"../client\";\nimport type {\n BaseItem,\n BulkResponse,\n DeleteResponse,\n Filter,\n MutationResponse,\n PaginatedResponse,\n QueryParams,\n SingleResponse,\n Sort,\n} from \"../types\";\n\nexport interface ItemsModuleConfig {\n client: HttpClient;\n}\n\n/**\n * Query builder for constructing type-safe queries\n */\nexport class QueryBuilder<T extends BaseItem = BaseItem> {\n private collection: string;\n private client: HttpClient;\n private queryParams: QueryParams = {};\n\n constructor(collection: string, client: HttpClient) {\n this.collection = collection;\n this.client = client;\n }\n\n /**\n * Select specific fields to return\n *\n * @example\n * ```typescript\n * items.select(['id', 'name', 'author.*'])\n * items.select('*', 'category.name')\n * ```\n */\n select(...fields: string[] | [string[]]): this {\n const flatFields = fields.length === 1 && Array.isArray(fields[0])\n ? fields[0]\n : (fields as string[]);\n this.queryParams.fields = flatFields;\n return this;\n }\n\n /**\n * Alias for select()\n */\n fields(...fields: string[] | [string[]]): this {\n return this.select(...fields);\n }\n\n /**\n * Add filter conditions\n *\n * @example\n * ```typescript\n * // Simple equality\n * items.filter({ status: { eq: 'active' } })\n *\n * // Multiple conditions\n * items.filter({\n * AND: [\n * { status: { eq: 'active' } },\n * { price: { gte: 100 } }\n * ]\n * })\n *\n * // Relation filtering\n * items.filter({ 'author.name': { like: 'John' } })\n * ```\n */\n filter(filter: Filter): this {\n this.queryParams.filter = filter;\n return this;\n }\n\n /**\n * Alias for filter()\n */\n where(filter: Filter): this {\n return this.filter(filter);\n }\n\n /**\n * Sort results\n *\n * @example\n * ```typescript\n * // Object notation\n * items.sort({ createdAt: 'desc', name: 'asc' })\n *\n * // Array notation with prefix\n * items.sort(['-createdAt', 'name'])\n *\n * // String shorthand\n * items.sort('createdAt:desc')\n * ```\n */\n sort(sort: Sort): this {\n this.queryParams.sort = sort;\n return this;\n }\n\n /**\n * Alias for sort()\n */\n orderBy(sort: Sort): this {\n return this.sort(sort);\n }\n\n /**\n * Limit number of results\n *\n * @example\n * ```typescript\n * items.limit(20)\n * items.limit(-1) // All results\n * ```\n */\n limit(limit: number): this {\n this.queryParams.limit = limit;\n return this;\n }\n\n /**\n * Set page number (1-indexed)\n *\n * @example\n * ```typescript\n * items.page(2).limit(20)\n * ```\n */\n page(page: number): this {\n this.queryParams.page = page;\n return this;\n }\n\n /**\n * Skip a number of results\n *\n * @example\n * ```typescript\n * items.offset(20)\n * ```\n */\n offset(offset: number): this {\n this.queryParams.offset = offset;\n return this;\n }\n\n /**\n * Full-text search\n *\n * @example\n * ```typescript\n * items.search('keyword', ['title', 'description'])\n * ```\n */\n search(query: string, fields?: string[]): this {\n this.queryParams.search = query;\n if (fields) {\n this.queryParams.searchFields = fields;\n }\n return this;\n }\n\n /**\n * Include soft-deleted items\n *\n * @example\n * ```typescript\n * items.withDeleted()\n * ```\n */\n withDeleted(): this {\n this.queryParams.paranoid = false;\n return this;\n }\n\n /**\n * Filter related items in O2M/M2M relations\n *\n * @example\n * ```typescript\n * // Only show approved comments\n * items.relFilter({\n * comments: { approved: { eq: true } }\n * })\n * ```\n */\n relFilter(conditions: Record<string, Filter>): this {\n this.queryParams.relConditions = conditions;\n return this;\n }\n\n /**\n * Get the built query parameters\n */\n getQuery(): QueryParams {\n return { ...this.queryParams };\n }\n\n /**\n * Execute the query and return results\n *\n * @example\n * ```typescript\n * const { data, totalCount } = await items\n * .filter({ status: { eq: 'active' } })\n * .sort({ createdAt: 'desc' })\n * .limit(10)\n * .get();\n * ```\n */\n async get(): Promise<PaginatedResponse<T>> {\n return this.client.get<PaginatedResponse<T>>(`/items/${this.collection}`, {\n params: this.buildParams(),\n });\n }\n\n /**\n * Execute the query and return the first result\n *\n * @example\n * ```typescript\n * const item = await items\n * .filter({ slug: { eq: 'my-post' } })\n * .first();\n * ```\n */\n async first(): Promise<T | null> {\n const result = await this.limit(1).get();\n return result.data[0] || null;\n }\n\n /**\n * Count matching items\n *\n * @example\n * ```typescript\n * const count = await items.filter({ status: { eq: 'active' } }).count();\n * ```\n */\n async count(): Promise<number> {\n const result = await this.client.get<PaginatedResponse<T>>(\n `/items/${this.collection}`,\n {\n params: {\n ...this.buildParams(),\n limit: 0,\n },\n }\n );\n return result.totalCount || 0;\n }\n\n /**\n * Build query parameters for the request\n */\n private buildParams(): Record<string, unknown> {\n const params: Record<string, unknown> = {};\n\n if (this.queryParams.fields) {\n params.fields = this.queryParams.fields;\n }\n if (this.queryParams.filter) {\n params.filter = this.queryParams.filter;\n }\n if (this.queryParams.sort) {\n params.sort = this.queryParams.sort;\n }\n if (this.queryParams.limit !== undefined) {\n params.limit = this.queryParams.limit;\n }\n if (this.queryParams.page !== undefined) {\n params.page = this.queryParams.page;\n }\n if (this.queryParams.offset !== undefined) {\n params.offset = this.queryParams.offset;\n }\n if (this.queryParams.search) {\n params.search = this.queryParams.search;\n }\n if (this.queryParams.searchFields) {\n params.searchFields = this.queryParams.searchFields;\n }\n if (this.queryParams.paranoid !== undefined) {\n params.paranoid = this.queryParams.paranoid;\n }\n if (this.queryParams.relConditions) {\n params.relConditions = this.queryParams.relConditions;\n }\n if (this.queryParams.aggregate) {\n params.aggregate = this.queryParams.aggregate;\n }\n if (this.queryParams.groupBy) {\n params.groupBy = this.queryParams.groupBy;\n }\n\n return params;\n }\n}\n\n/**\n * Items module for CRUD operations on collections.\n *\n * @example\n * ```typescript\n * const items = baasix.items('products');\n *\n * // List items\n * const products = await items.find({ filter: { status: { eq: 'active' } } });\n *\n * // Get single item\n * const product = await items.findOne('product-id');\n *\n * // Create item\n * const newProduct = await items.create({ name: 'Widget', price: 29.99 });\n *\n * // Update item\n * await items.update('product-id', { price: 24.99 });\n *\n * // Delete item\n * await items.delete('product-id');\n * ```\n */\nexport class ItemsModule<T extends BaseItem = BaseItem> {\n private collection: string;\n private client: HttpClient;\n\n constructor(collection: string, config: ItemsModuleConfig) {\n this.collection = collection;\n this.client = config.client;\n }\n\n /**\n * Create a query builder for fluent query construction\n *\n * @example\n * ```typescript\n * const results = await baasix.items('posts')\n * .query()\n * .select('*', 'author.*')\n * .filter({ status: { eq: 'published' } })\n * .sort({ createdAt: 'desc' })\n * .limit(10)\n * .get();\n * ```\n */\n query(): QueryBuilder<T> {\n return new QueryBuilder<T>(this.collection, this.client);\n }\n\n /**\n * Find items with optional query parameters\n *\n * @example\n * ```typescript\n * // Simple query\n * const { data } = await items.find();\n *\n * // With parameters\n * const { data, totalCount } = await items.find({\n * filter: { status: { eq: 'active' } },\n * sort: { createdAt: 'desc' },\n * limit: 20,\n * page: 1,\n * fields: ['id', 'name', 'price']\n * });\n * ```\n */\n async find(params?: QueryParams): Promise<PaginatedResponse<T>> {\n return this.client.get<PaginatedResponse<T>>(`/items/${this.collection}`, {\n params: params as Record<string, unknown>,\n });\n }\n\n /**\n * Alias for find()\n */\n async findMany(params?: QueryParams): Promise<PaginatedResponse<T>> {\n return this.find(params);\n }\n\n /**\n * Find a single item by ID\n *\n * @example\n * ```typescript\n * const product = await items.findOne('product-uuid');\n *\n * // With specific fields\n * const product = await items.findOne('product-uuid', {\n * fields: ['id', 'name', 'category.*']\n * });\n * ```\n */\n async findOne(\n id: string,\n params?: Pick<QueryParams, \"fields\">\n ): Promise<T> {\n const response = await this.client.get<SingleResponse<T>>(\n `/items/${this.collection}/${id}`,\n { params: params as Record<string, unknown> }\n );\n return response.data;\n }\n\n /**\n * Alias for findOne()\n */\n async get(id: string, params?: Pick<QueryParams, \"fields\">): Promise<T> {\n return this.findOne(id, params);\n }\n\n /**\n * Create a new item\n *\n * @example\n * ```typescript\n * const id = await items.create({\n * name: 'New Product',\n * price: 29.99,\n * status: 'draft'\n * });\n * ```\n */\n async create(data: Partial<T>): Promise<string> {\n const response = await this.client.post<MutationResponse<string>>(\n `/items/${this.collection}`,\n data\n );\n return response.data;\n }\n\n /**\n * Alias for create()\n */\n async insert(data: Partial<T>): Promise<string> {\n return this.create(data);\n }\n\n /**\n * Create multiple items at once\n *\n * @example\n * ```typescript\n * const ids = await items.createMany([\n * { name: 'Product 1', price: 10 },\n * { name: 'Product 2', price: 20 }\n * ]);\n * ```\n */\n async createMany(data: Partial<T>[]): Promise<string[]> {\n const response = await this.client.post<BulkResponse<string[]>>(\n `/items/${this.collection}/bulk`,\n data\n );\n return response.data;\n }\n\n /**\n * Alias for createMany()\n */\n async insertMany(data: Partial<T>[]): Promise<string[]> {\n return this.createMany(data);\n }\n\n /**\n * Update an existing item\n *\n * @example\n * ```typescript\n * await items.update('product-uuid', {\n * price: 24.99,\n * status: 'published'\n * });\n * ```\n */\n async update(id: string, data: Partial<T>): Promise<string> {\n const response = await this.client.patch<MutationResponse<string>>(\n `/items/${this.collection}/${id}`,\n data\n );\n return response.data;\n }\n\n /**\n * Update multiple items at once\n *\n * @example\n * ```typescript\n * // Update by IDs\n * await items.updateMany(['id1', 'id2'], { status: 'archived' });\n * ```\n */\n async updateMany(ids: string[], data: Partial<T>): Promise<string[]> {\n const response = await this.client.patch<BulkResponse<string[]>>(\n `/items/${this.collection}/bulk`,\n { ids, data }\n );\n return response.data;\n }\n\n /**\n * Upsert an item (create if not exists, update if exists)\n *\n * @example\n * ```typescript\n * const id = await items.upsert(\n * { sku: 'WIDGET-001' },\n * { name: 'Widget', price: 29.99, sku: 'WIDGET-001' }\n * );\n * ```\n */\n async upsert(\n filter: Filter,\n data: Partial<T>\n ): Promise<string> {\n // Try to find existing\n const existing = await this.find({ filter, limit: 1 });\n if (existing.data.length > 0) {\n return this.update(existing.data[0].id, data);\n }\n return this.create(data);\n }\n\n /**\n * Delete an item by ID\n *\n * @example\n * ```typescript\n * await items.delete('product-uuid');\n * ```\n */\n async delete(id: string): Promise<void> {\n await this.client.delete<DeleteResponse>(`/items/${this.collection}/${id}`);\n }\n\n /**\n * Delete multiple items\n *\n * @example\n * ```typescript\n * await items.deleteMany(['id1', 'id2', 'id3']);\n * ```\n */\n async deleteMany(ids: string[]): Promise<void> {\n await this.client.delete<DeleteResponse>(`/items/${this.collection}/bulk`, {\n params: { ids },\n });\n }\n\n /**\n * Soft delete an item (if paranoid mode is enabled)\n *\n * @example\n * ```typescript\n * await items.softDelete('product-uuid');\n * ```\n */\n async softDelete(id: string): Promise<void> {\n await this.update(id, { deletedAt: new Date().toISOString() } as unknown as Partial<T>);\n }\n\n /**\n * Restore a soft-deleted item\n *\n * @example\n * ```typescript\n * await items.restore('product-uuid');\n * ```\n */\n async restore(id: string): Promise<void> {\n await this.update(id, { deletedAt: null } as unknown as Partial<T>);\n }\n\n /**\n * Aggregate data with grouping\n *\n * @example\n * ```typescript\n * const results = await items.aggregate({\n * aggregate: {\n * total: { function: 'sum', field: 'amount' },\n * count: { function: 'count', field: 'id' },\n * avgPrice: { function: 'avg', field: 'price' }\n * },\n * groupBy: ['category', 'status'],\n * filter: { createdAt: { gte: '$NOW-DAYS_30' } }\n * });\n * ```\n */\n async aggregate(\n params: Pick<QueryParams, \"aggregate\" | \"groupBy\" | \"filter\">\n ): Promise<Record<string, unknown>[]> {\n const response = await this.client.get<PaginatedResponse<Record<string, unknown>>>(\n `/items/${this.collection}`,\n { params: params as Record<string, unknown> }\n );\n return response.data;\n }\n\n // ===================\n // Import Operations\n // ===================\n\n /**\n * Import items from a CSV file\n *\n * @example\n * ```typescript\n * // Browser\n * const fileInput = document.querySelector('input[type=\"file\"]');\n * const file = fileInput.files[0];\n * \n * const result = await baasix.items('products').importCSV(file, {\n * delimiter: ',',\n * skipFirstRow: true\n * });\n * \n * console.log(`Imported ${result.created} items`);\n * ```\n */\n async importCSV(\n file: File | { uri: string; name: string; type: string },\n options?: {\n delimiter?: string;\n skipFirstRow?: boolean;\n dateFormat?: string;\n fieldMapping?: Record<string, string>;\n }\n ): Promise<ImportResult> {\n const formData = new FormData();\n \n if (file instanceof File) {\n formData.append(\"file\", file);\n } else {\n // React Native style file\n formData.append(\"file\", file as any);\n }\n\n if (options?.delimiter) {\n formData.append(\"delimiter\", options.delimiter);\n }\n if (options?.skipFirstRow !== undefined) {\n formData.append(\"skipFirstRow\", String(options.skipFirstRow));\n }\n if (options?.dateFormat) {\n formData.append(\"dateFormat\", options.dateFormat);\n }\n if (options?.fieldMapping) {\n formData.append(\"fieldMapping\", JSON.stringify(options.fieldMapping));\n }\n\n const response = await this.client.post<{ data: ImportResult }>(\n `/items/${this.collection}/import/csv`,\n formData\n );\n return response.data;\n }\n\n /**\n * Import items from a JSON file\n *\n * @example\n * ```typescript\n * const file = fileInput.files[0]; // JSON file\n * const result = await baasix.items('products').importJSON(file);\n * \n * console.log(`Imported ${result.created} items`);\n * ```\n */\n async importJSON(\n file: File | { uri: string; name: string; type: string },\n options?: {\n fieldMapping?: Record<string, string>;\n }\n ): Promise<ImportResult> {\n const formData = new FormData();\n \n if (file instanceof File) {\n formData.append(\"file\", file);\n } else {\n formData.append(\"file\", file as any);\n }\n\n if (options?.fieldMapping) {\n formData.append(\"fieldMapping\", JSON.stringify(options.fieldMapping));\n }\n\n const response = await this.client.post<{ data: ImportResult }>(\n `/items/${this.collection}/import/json`,\n formData\n );\n return response.data;\n }\n\n /**\n * Import items from an array of objects\n *\n * @example\n * ```typescript\n * const data = [\n * { name: 'Product 1', price: 29.99 },\n * { name: 'Product 2', price: 39.99 }\n * ];\n * \n * const result = await baasix.items('products').importData(data);\n * ```\n */\n async importData(data: Partial<T>[]): Promise<BulkResponse> {\n const response = await this.client.post<BulkResponse>(\n `/items/${this.collection}/bulk`,\n data\n );\n return response;\n }\n\n // ===================\n // Sort Operations\n // ===================\n\n /**\n * Sort/reorder items (move item before another)\n *\n * @example\n * ```typescript\n * // Move item1 before item2\n * await baasix.items('products').sortItem('item1-uuid', 'item2-uuid');\n * ```\n */\n async sortItem(itemId: string, beforeItemId: string): Promise<void> {\n await this.client.post(\"/utils/sort\", {\n collection: this.collection,\n item: itemId,\n to: beforeItemId,\n });\n }\n\n /**\n * Reorder multiple items\n *\n * @example\n * ```typescript\n * // Set explicit order\n * await baasix.items('products').reorder([\n * 'item3-uuid',\n * 'item1-uuid',\n * 'item2-uuid'\n * ]);\n * ```\n */\n async reorder(orderedIds: string[]): Promise<void> {\n // Sort items one by one to achieve the desired order\n for (let i = 1; i < orderedIds.length; i++) {\n await this.client.post(\"/utils/sort\", {\n collection: this.collection,\n item: orderedIds[i],\n to: orderedIds[i - 1],\n });\n }\n }\n}\n\nexport interface ImportResult {\n created: number;\n updated: number;\n skipped: number;\n errors: Array<{ row: number; error: string }>;\n}\n\n// Re-export types from types.ts\nexport type {\n BaseItem,\n BulkResponse,\n DeleteResponse,\n Filter,\n MutationResponse,\n PaginatedResponse,\n QueryParams,\n SingleResponse,\n Sort,\n};\n"]}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/modules/schemas.ts
|
|
4
|
+
var SchemasModule = class {
|
|
5
|
+
client;
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.client = config.client;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* List all schemas
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const { data } = await baasix.schemas.find();
|
|
15
|
+
* console.log(data.map(s => s.collectionName));
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
async find() {
|
|
19
|
+
return this.client.get("/schemas");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get schema for a specific collection
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const schema = await baasix.schemas.findOne('products');
|
|
27
|
+
* console.log(schema.fields);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
async findOne(collection) {
|
|
31
|
+
const response = await this.client.get(
|
|
32
|
+
`/schemas/${collection}`
|
|
33
|
+
);
|
|
34
|
+
return response.data;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a new collection/schema
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* await baasix.schemas.create({
|
|
42
|
+
* collectionName: 'orders',
|
|
43
|
+
* schema: {
|
|
44
|
+
* name: 'Order',
|
|
45
|
+
* timestamps: true,
|
|
46
|
+
* paranoid: true,
|
|
47
|
+
* fields: {
|
|
48
|
+
* id: {
|
|
49
|
+
* type: 'UUID',
|
|
50
|
+
* primaryKey: true,
|
|
51
|
+
* defaultValue: { type: 'UUIDV4' }
|
|
52
|
+
* },
|
|
53
|
+
* orderNumber: {
|
|
54
|
+
* type: 'String',
|
|
55
|
+
* allowNull: false,
|
|
56
|
+
* unique: true
|
|
57
|
+
* },
|
|
58
|
+
* total: {
|
|
59
|
+
* type: 'Decimal',
|
|
60
|
+
* values: { precision: 10, scale: 2 },
|
|
61
|
+
* allowNull: false,
|
|
62
|
+
* defaultValue: 0
|
|
63
|
+
* },
|
|
64
|
+
* status: {
|
|
65
|
+
* type: 'String',
|
|
66
|
+
* allowNull: false,
|
|
67
|
+
* defaultValue: 'pending'
|
|
68
|
+
* },
|
|
69
|
+
* items: {
|
|
70
|
+
* type: 'JSONB',
|
|
71
|
+
* allowNull: true,
|
|
72
|
+
* defaultValue: []
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
async create(data) {
|
|
80
|
+
const response = await this.client.post(
|
|
81
|
+
"/schemas",
|
|
82
|
+
data
|
|
83
|
+
);
|
|
84
|
+
return response.data;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Update an existing schema
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* await baasix.schemas.update('products', {
|
|
92
|
+
* schema: {
|
|
93
|
+
* name: 'Product',
|
|
94
|
+
* timestamps: true,
|
|
95
|
+
* fields: {
|
|
96
|
+
* // Updated fields
|
|
97
|
+
* description: { type: 'Text', allowNull: true }
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
async update(collection, data) {
|
|
104
|
+
const response = await this.client.patch(
|
|
105
|
+
`/schemas/${collection}`,
|
|
106
|
+
data
|
|
107
|
+
);
|
|
108
|
+
return response.data;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Delete a schema (drops the table)
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* await baasix.schemas.delete('old_collection');
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
async delete(collection) {
|
|
119
|
+
await this.client.delete(`/schemas/${collection}`);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create a relationship between collections
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* // Many-to-One (BelongsTo)
|
|
127
|
+
* await baasix.schemas.createRelationship('posts', {
|
|
128
|
+
* type: 'M2O',
|
|
129
|
+
* target: 'baasix_User',
|
|
130
|
+
* name: 'author',
|
|
131
|
+
* alias: 'posts'
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* // Many-to-Many
|
|
135
|
+
* await baasix.schemas.createRelationship('posts', {
|
|
136
|
+
* type: 'M2M',
|
|
137
|
+
* target: 'tags',
|
|
138
|
+
* name: 'tags',
|
|
139
|
+
* alias: 'posts'
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
async createRelationship(collection, relationship) {
|
|
144
|
+
await this.client.post(
|
|
145
|
+
`/schemas/${collection}/relationships`,
|
|
146
|
+
relationship
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Delete a relationship
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* await baasix.schemas.deleteRelationship('posts', 'author');
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
async deleteRelationship(collection, relationshipName) {
|
|
158
|
+
await this.client.delete(
|
|
159
|
+
`/schemas/${collection}/relationships/${relationshipName}`
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Create an index on a collection
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* // Unique index
|
|
168
|
+
* await baasix.schemas.createIndex('users', {
|
|
169
|
+
* name: 'idx_users_email',
|
|
170
|
+
* fields: ['email'],
|
|
171
|
+
* unique: true
|
|
172
|
+
* });
|
|
173
|
+
*
|
|
174
|
+
* // Composite index
|
|
175
|
+
* await baasix.schemas.createIndex('orders', {
|
|
176
|
+
* name: 'idx_orders_status_created',
|
|
177
|
+
* fields: ['status', 'createdAt']
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
async createIndex(collection, index) {
|
|
182
|
+
await this.client.post(`/schemas/${collection}/indexes`, index);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Delete an index
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* await baasix.schemas.deleteIndex('users', 'idx_users_email');
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
async deleteIndex(collection, indexName) {
|
|
193
|
+
await this.client.delete(`/schemas/${collection}/indexes/${indexName}`);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Add a field to an existing schema
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* await baasix.schemas.addField('products', 'rating', {
|
|
201
|
+
* type: 'Decimal',
|
|
202
|
+
* values: { precision: 3, scale: 2 },
|
|
203
|
+
* allowNull: true,
|
|
204
|
+
* defaultValue: 0
|
|
205
|
+
* });
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
async addField(collection, fieldName, fieldDefinition) {
|
|
209
|
+
const currentSchema = await this.findOne(collection);
|
|
210
|
+
const updatedFields = {
|
|
211
|
+
...currentSchema.schema.fields,
|
|
212
|
+
[fieldName]: fieldDefinition
|
|
213
|
+
};
|
|
214
|
+
return this.update(collection, {
|
|
215
|
+
schema: {
|
|
216
|
+
...currentSchema.schema,
|
|
217
|
+
fields: updatedFields
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Remove a field from a schema
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* await baasix.schemas.removeField('products', 'deprecated_field');
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
async removeField(collection, fieldName) {
|
|
230
|
+
const currentSchema = await this.findOne(collection);
|
|
231
|
+
const { [fieldName]: _, ...remainingFields } = currentSchema.schema.fields;
|
|
232
|
+
return this.update(collection, {
|
|
233
|
+
schema: {
|
|
234
|
+
...currentSchema.schema,
|
|
235
|
+
fields: remainingFields
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Export all schemas as JSON
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* const schemas = await baasix.schemas.export();
|
|
245
|
+
* // Save to file for backup
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
async export() {
|
|
249
|
+
const response = await this.client.get(
|
|
250
|
+
"/schemas/export"
|
|
251
|
+
);
|
|
252
|
+
return response.data;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Import schemas from JSON
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* await baasix.schemas.import(savedSchemas);
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
async import(schemas) {
|
|
263
|
+
await this.client.post("/schemas/import", { schemas });
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
exports.SchemasModule = SchemasModule;
|
|
268
|
+
//# sourceMappingURL=schemas.cjs.map
|
|
269
|
+
//# sourceMappingURL=schemas.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/modules/schemas.ts"],"names":[],"mappings":";;;AAyCO,IAAM,gBAAN,MAAoB;AAAA,EACjB,MAAA;AAAA,EAER,YAAY,MAAA,EAA6B;AACvC,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,IAAA,GAA+C;AACnD,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,GAAA,CAAmC,UAAU,CAAA;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,QAAQ,UAAA,EAAyC;AACrD,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA;AAAA,MACjC,YAAY,UAAU,CAAA;AAAA,KACxB;AACA,IAAA,OAAO,QAAA,CAAS,IAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6CA,MAAM,OAAO,IAAA,EAGW;AACtB,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,MAAA,CAAO,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EAAY;AAAA,MAC7B,MAAA,EAAQ;AAAA,QACN,GAAG,aAAA,CAAc,MAAA;AAAA,QACjB,MAAA,EAAQ;AAAA;AACV,KACD,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,MAAA,GAAgC;AACpC,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,MAAA,CAAO,GAAA;AAAA,MACjC;AAAA,KACF;AACA,IAAA,OAAO,QAAA,CAAS,IAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,OAAO,OAAA,EAAsC;AACjD,IAAA,MAAM,KAAK,MAAA,CAAO,IAAA,CAAK,iBAAA,EAAmB,EAAE,SAAS,CAAA;AAAA,EACvD;AACF","file":"schemas.cjs","sourcesContent":["import type { HttpClient } from \"../client\";\nimport type {\n IndexDefinition,\n PaginatedResponse,\n RelationshipDefinition,\n SchemaDefinition,\n SchemaInfo,\n} from \"../types\";\n\nexport interface SchemasModuleConfig {\n client: HttpClient;\n}\n\n/**\n * Schemas module for managing database schemas, relationships, and indexes.\n *\n * @example\n * ```typescript\n * // Create a new collection\n * await baasix.schemas.create({\n * collectionName: 'products',\n * schema: {\n * name: 'Product',\n * timestamps: true,\n * fields: {\n * id: { type: 'UUID', primaryKey: true, defaultValue: { type: 'UUIDV4' } },\n * name: { type: 'String', allowNull: false },\n * price: { type: 'Decimal', values: { precision: 10, scale: 2 } }\n * }\n * }\n * });\n *\n * // Add a relationship\n * await baasix.schemas.createRelationship('products', {\n * type: 'M2O',\n * target: 'categories',\n * name: 'category',\n * alias: 'products'\n * });\n * ```\n */\nexport class SchemasModule {\n private client: HttpClient;\n\n constructor(config: SchemasModuleConfig) {\n this.client = config.client;\n }\n\n /**\n * List all schemas\n *\n * @example\n * ```typescript\n * const { data } = await baasix.schemas.find();\n * console.log(data.map(s => s.collectionName));\n * ```\n */\n async find(): Promise<PaginatedResponse<SchemaInfo>> {\n return this.client.get<PaginatedResponse<SchemaInfo>>(\"/schemas\");\n }\n\n /**\n * Get schema for a specific collection\n *\n * @example\n * ```typescript\n * const schema = await baasix.schemas.findOne('products');\n * console.log(schema.fields);\n * ```\n */\n async findOne(collection: string): Promise<SchemaInfo> {\n const response = await this.client.get<{ data: SchemaInfo }>(\n `/schemas/${collection}`\n );\n return response.data;\n }\n\n /**\n * Create a new collection/schema\n *\n * @example\n * ```typescript\n * await baasix.schemas.create({\n * collectionName: 'orders',\n * schema: {\n * name: 'Order',\n * timestamps: true,\n * paranoid: true,\n * fields: {\n * id: {\n * type: 'UUID',\n * primaryKey: true,\n * defaultValue: { type: 'UUIDV4' }\n * },\n * orderNumber: {\n * type: 'String',\n * allowNull: false,\n * unique: true\n * },\n * total: {\n * type: 'Decimal',\n * values: { precision: 10, scale: 2 },\n * allowNull: false,\n * defaultValue: 0\n * },\n * status: {\n * type: 'String',\n * allowNull: false,\n * defaultValue: 'pending'\n * },\n * items: {\n * type: 'JSONB',\n * allowNull: true,\n * defaultValue: []\n * }\n * }\n * }\n * });\n * ```\n */\n async create(data: {\n collectionName: string;\n schema: SchemaDefinition;\n }): Promise<SchemaInfo> {\n const response = await this.client.post<{ data: SchemaInfo }>(\n \"/schemas\",\n data\n );\n return response.data;\n }\n\n /**\n * Update an existing schema\n *\n * @example\n * ```typescript\n * await baasix.schemas.update('products', {\n * schema: {\n * name: 'Product',\n * timestamps: true,\n * fields: {\n * // Updated fields\n * description: { type: 'Text', allowNull: true }\n * }\n * }\n * });\n * ```\n */\n async update(\n collection: string,\n data: { schema: Partial<SchemaDefinition> }\n ): Promise<SchemaInfo> {\n const response = await this.client.patch<{ data: SchemaInfo }>(\n `/schemas/${collection}`,\n data\n );\n return response.data;\n }\n\n /**\n * Delete a schema (drops the table)\n *\n * @example\n * ```typescript\n * await baasix.schemas.delete('old_collection');\n * ```\n */\n async delete(collection: string): Promise<void> {\n await this.client.delete(`/schemas/${collection}`);\n }\n\n /**\n * Create a relationship between collections\n *\n * @example\n * ```typescript\n * // Many-to-One (BelongsTo)\n * await baasix.schemas.createRelationship('posts', {\n * type: 'M2O',\n * target: 'baasix_User',\n * name: 'author',\n * alias: 'posts'\n * });\n *\n * // Many-to-Many\n * await baasix.schemas.createRelationship('posts', {\n * type: 'M2M',\n * target: 'tags',\n * name: 'tags',\n * alias: 'posts'\n * });\n * ```\n */\n async createRelationship(\n collection: string,\n relationship: RelationshipDefinition\n ): Promise<void> {\n await this.client.post(\n `/schemas/${collection}/relationships`,\n relationship\n );\n }\n\n /**\n * Delete a relationship\n *\n * @example\n * ```typescript\n * await baasix.schemas.deleteRelationship('posts', 'author');\n * ```\n */\n async deleteRelationship(\n collection: string,\n relationshipName: string\n ): Promise<void> {\n await this.client.delete(\n `/schemas/${collection}/relationships/${relationshipName}`\n );\n }\n\n /**\n * Create an index on a collection\n *\n * @example\n * ```typescript\n * // Unique index\n * await baasix.schemas.createIndex('users', {\n * name: 'idx_users_email',\n * fields: ['email'],\n * unique: true\n * });\n *\n * // Composite index\n * await baasix.schemas.createIndex('orders', {\n * name: 'idx_orders_status_created',\n * fields: ['status', 'createdAt']\n * });\n * ```\n */\n async createIndex(\n collection: string,\n index: IndexDefinition\n ): Promise<void> {\n await this.client.post(`/schemas/${collection}/indexes`, index);\n }\n\n /**\n * Delete an index\n *\n * @example\n * ```typescript\n * await baasix.schemas.deleteIndex('users', 'idx_users_email');\n * ```\n */\n async deleteIndex(collection: string, indexName: string): Promise<void> {\n await this.client.delete(`/schemas/${collection}/indexes/${indexName}`);\n }\n\n /**\n * Add a field to an existing schema\n *\n * @example\n * ```typescript\n * await baasix.schemas.addField('products', 'rating', {\n * type: 'Decimal',\n * values: { precision: 3, scale: 2 },\n * allowNull: true,\n * defaultValue: 0\n * });\n * ```\n */\n async addField(\n collection: string,\n fieldName: string,\n fieldDefinition: SchemaDefinition[\"fields\"][string]\n ): Promise<SchemaInfo> {\n const currentSchema = await this.findOne(collection);\n const updatedFields = {\n ...currentSchema.schema.fields,\n [fieldName]: fieldDefinition,\n };\n\n return this.update(collection, {\n schema: {\n ...currentSchema.schema,\n fields: updatedFields,\n },\n });\n }\n\n /**\n * Remove a field from a schema\n *\n * @example\n * ```typescript\n * await baasix.schemas.removeField('products', 'deprecated_field');\n * ```\n */\n async removeField(\n collection: string,\n fieldName: string\n ): Promise<SchemaInfo> {\n const currentSchema = await this.findOne(collection);\n const { [fieldName]: _, ...remainingFields } = currentSchema.schema.fields;\n\n return this.update(collection, {\n schema: {\n ...currentSchema.schema,\n fields: remainingFields,\n },\n });\n }\n\n /**\n * Export all schemas as JSON\n *\n * @example\n * ```typescript\n * const schemas = await baasix.schemas.export();\n * // Save to file for backup\n * ```\n */\n async export(): Promise<SchemaInfo[]> {\n const response = await this.client.get<{ data: SchemaInfo[] }>(\n \"/schemas/export\"\n );\n return response.data;\n }\n\n /**\n * Import schemas from JSON\n *\n * @example\n * ```typescript\n * await baasix.schemas.import(savedSchemas);\n * ```\n */\n async import(schemas: SchemaInfo[]): Promise<void> {\n await this.client.post(\"/schemas/import\", { schemas });\n }\n}\n\n// Re-export types\nexport type {\n IndexDefinition,\n RelationshipDefinition,\n SchemaDefinition,\n SchemaInfo,\n};\n"]}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { H as HttpClient, e as PaginatedResponse, l as SchemaInfo, m as SchemaDefinition, n as RelationshipDefinition, I as IndexDefinition } from '../client-aXK_gEyr.cjs';
|
|
2
|
+
import '../types-BdjsGANq.cjs';
|
|
3
|
+
|
|
4
|
+
interface SchemasModuleConfig {
|
|
5
|
+
client: HttpClient;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Schemas module for managing database schemas, relationships, and indexes.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Create a new collection
|
|
13
|
+
* await baasix.schemas.create({
|
|
14
|
+
* collectionName: 'products',
|
|
15
|
+
* schema: {
|
|
16
|
+
* name: 'Product',
|
|
17
|
+
* timestamps: true,
|
|
18
|
+
* fields: {
|
|
19
|
+
* id: { type: 'UUID', primaryKey: true, defaultValue: { type: 'UUIDV4' } },
|
|
20
|
+
* name: { type: 'String', allowNull: false },
|
|
21
|
+
* price: { type: 'Decimal', values: { precision: 10, scale: 2 } }
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Add a relationship
|
|
27
|
+
* await baasix.schemas.createRelationship('products', {
|
|
28
|
+
* type: 'M2O',
|
|
29
|
+
* target: 'categories',
|
|
30
|
+
* name: 'category',
|
|
31
|
+
* alias: 'products'
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare class SchemasModule {
|
|
36
|
+
private client;
|
|
37
|
+
constructor(config: SchemasModuleConfig);
|
|
38
|
+
/**
|
|
39
|
+
* List all schemas
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const { data } = await baasix.schemas.find();
|
|
44
|
+
* console.log(data.map(s => s.collectionName));
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
find(): Promise<PaginatedResponse<SchemaInfo>>;
|
|
48
|
+
/**
|
|
49
|
+
* Get schema for a specific collection
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const schema = await baasix.schemas.findOne('products');
|
|
54
|
+
* console.log(schema.fields);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
findOne(collection: string): Promise<SchemaInfo>;
|
|
58
|
+
/**
|
|
59
|
+
* Create a new collection/schema
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* await baasix.schemas.create({
|
|
64
|
+
* collectionName: 'orders',
|
|
65
|
+
* schema: {
|
|
66
|
+
* name: 'Order',
|
|
67
|
+
* timestamps: true,
|
|
68
|
+
* paranoid: true,
|
|
69
|
+
* fields: {
|
|
70
|
+
* id: {
|
|
71
|
+
* type: 'UUID',
|
|
72
|
+
* primaryKey: true,
|
|
73
|
+
* defaultValue: { type: 'UUIDV4' }
|
|
74
|
+
* },
|
|
75
|
+
* orderNumber: {
|
|
76
|
+
* type: 'String',
|
|
77
|
+
* allowNull: false,
|
|
78
|
+
* unique: true
|
|
79
|
+
* },
|
|
80
|
+
* total: {
|
|
81
|
+
* type: 'Decimal',
|
|
82
|
+
* values: { precision: 10, scale: 2 },
|
|
83
|
+
* allowNull: false,
|
|
84
|
+
* defaultValue: 0
|
|
85
|
+
* },
|
|
86
|
+
* status: {
|
|
87
|
+
* type: 'String',
|
|
88
|
+
* allowNull: false,
|
|
89
|
+
* defaultValue: 'pending'
|
|
90
|
+
* },
|
|
91
|
+
* items: {
|
|
92
|
+
* type: 'JSONB',
|
|
93
|
+
* allowNull: true,
|
|
94
|
+
* defaultValue: []
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
* }
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
create(data: {
|
|
102
|
+
collectionName: string;
|
|
103
|
+
schema: SchemaDefinition;
|
|
104
|
+
}): Promise<SchemaInfo>;
|
|
105
|
+
/**
|
|
106
|
+
* Update an existing schema
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* await baasix.schemas.update('products', {
|
|
111
|
+
* schema: {
|
|
112
|
+
* name: 'Product',
|
|
113
|
+
* timestamps: true,
|
|
114
|
+
* fields: {
|
|
115
|
+
* // Updated fields
|
|
116
|
+
* description: { type: 'Text', allowNull: true }
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
update(collection: string, data: {
|
|
123
|
+
schema: Partial<SchemaDefinition>;
|
|
124
|
+
}): Promise<SchemaInfo>;
|
|
125
|
+
/**
|
|
126
|
+
* Delete a schema (drops the table)
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* await baasix.schemas.delete('old_collection');
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
delete(collection: string): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Create a relationship between collections
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* // Many-to-One (BelongsTo)
|
|
140
|
+
* await baasix.schemas.createRelationship('posts', {
|
|
141
|
+
* type: 'M2O',
|
|
142
|
+
* target: 'baasix_User',
|
|
143
|
+
* name: 'author',
|
|
144
|
+
* alias: 'posts'
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* // Many-to-Many
|
|
148
|
+
* await baasix.schemas.createRelationship('posts', {
|
|
149
|
+
* type: 'M2M',
|
|
150
|
+
* target: 'tags',
|
|
151
|
+
* name: 'tags',
|
|
152
|
+
* alias: 'posts'
|
|
153
|
+
* });
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
createRelationship(collection: string, relationship: RelationshipDefinition): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Delete a relationship
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* await baasix.schemas.deleteRelationship('posts', 'author');
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
deleteRelationship(collection: string, relationshipName: string): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Create an index on a collection
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* // Unique index
|
|
172
|
+
* await baasix.schemas.createIndex('users', {
|
|
173
|
+
* name: 'idx_users_email',
|
|
174
|
+
* fields: ['email'],
|
|
175
|
+
* unique: true
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* // Composite index
|
|
179
|
+
* await baasix.schemas.createIndex('orders', {
|
|
180
|
+
* name: 'idx_orders_status_created',
|
|
181
|
+
* fields: ['status', 'createdAt']
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
createIndex(collection: string, index: IndexDefinition): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Delete an index
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* await baasix.schemas.deleteIndex('users', 'idx_users_email');
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
deleteIndex(collection: string, indexName: string): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Add a field to an existing schema
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* await baasix.schemas.addField('products', 'rating', {
|
|
201
|
+
* type: 'Decimal',
|
|
202
|
+
* values: { precision: 3, scale: 2 },
|
|
203
|
+
* allowNull: true,
|
|
204
|
+
* defaultValue: 0
|
|
205
|
+
* });
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
addField(collection: string, fieldName: string, fieldDefinition: SchemaDefinition["fields"][string]): Promise<SchemaInfo>;
|
|
209
|
+
/**
|
|
210
|
+
* Remove a field from a schema
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* await baasix.schemas.removeField('products', 'deprecated_field');
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
removeField(collection: string, fieldName: string): Promise<SchemaInfo>;
|
|
218
|
+
/**
|
|
219
|
+
* Export all schemas as JSON
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const schemas = await baasix.schemas.export();
|
|
224
|
+
* // Save to file for backup
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
export(): Promise<SchemaInfo[]>;
|
|
228
|
+
/**
|
|
229
|
+
* Import schemas from JSON
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* await baasix.schemas.import(savedSchemas);
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
import(schemas: SchemaInfo[]): Promise<void>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export { IndexDefinition, RelationshipDefinition, SchemaDefinition, SchemaInfo, SchemasModule, type SchemasModuleConfig };
|