appwrite-utils-cli 1.3.4 → 1.4.0

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.
Files changed (116) hide show
  1. package/dist/adapters/AdapterFactory.d.ts +87 -0
  2. package/dist/adapters/AdapterFactory.js +217 -0
  3. package/dist/adapters/DatabaseAdapter.d.ts +217 -0
  4. package/dist/adapters/DatabaseAdapter.js +50 -0
  5. package/dist/adapters/LegacyAdapter.d.ts +49 -0
  6. package/dist/adapters/LegacyAdapter.js +382 -0
  7. package/dist/adapters/TablesDBAdapter.d.ts +55 -0
  8. package/dist/adapters/TablesDBAdapter.js +302 -0
  9. package/dist/adapters/index.d.ts +11 -0
  10. package/dist/adapters/index.js +12 -0
  11. package/dist/collections/attributes.js +43 -24
  12. package/dist/collections/methods.d.ts +4 -3
  13. package/dist/collections/methods.js +34 -14
  14. package/dist/config/yamlConfig.d.ts +40 -437
  15. package/dist/config/yamlConfig.js +8 -2
  16. package/dist/databases/setup.js +2 -2
  17. package/dist/main.js +0 -0
  18. package/dist/migrations/appwriteToX.d.ts +26 -37
  19. package/dist/migrations/comprehensiveTransfer.js +4 -4
  20. package/dist/migrations/dataLoader.d.ts +124 -1484
  21. package/dist/migrations/dataLoader.js +2 -1
  22. package/dist/migrations/relationships.d.ts +2 -3
  23. package/dist/migrations/relationships.js +1 -1
  24. package/dist/migrations/services/UserMappingService.js +1 -1
  25. package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +24 -279
  26. package/dist/migrations/yaml/YamlImportConfigLoader.js +7 -2
  27. package/dist/schemas/authUser.d.ts +7 -47
  28. package/dist/schemas/authUser.js +1 -1
  29. package/dist/shared/jsonSchemaGenerator.d.ts +0 -2
  30. package/dist/shared/jsonSchemaGenerator.js +4 -17
  31. package/dist/shared/migrationHelpers.d.ts +17 -119
  32. package/dist/shared/operationQueue.js +16 -7
  33. package/dist/shared/schemaGenerator.js +2 -17
  34. package/dist/storage/schemas.d.ts +149 -296
  35. package/dist/users/methods.d.ts +2 -2
  36. package/dist/utils/configMigration.js +0 -1
  37. package/dist/utils/getClientFromConfig.d.ts +26 -0
  38. package/dist/utils/getClientFromConfig.js +37 -0
  39. package/dist/utils/loadConfigs.js +0 -2
  40. package/dist/utils/schemaStrings.js +2 -17
  41. package/dist/utils/setupFiles.js +2 -0
  42. package/dist/utils/versionDetection.d.ts +56 -0
  43. package/dist/utils/versionDetection.js +217 -0
  44. package/dist/utils/yamlConverter.d.ts +0 -1
  45. package/dist/utils/yamlConverter.js +0 -2
  46. package/dist/utilsController.js +2 -0
  47. package/package.json +3 -2
  48. package/src/adapters/AdapterFactory.ts +296 -0
  49. package/src/adapters/DatabaseAdapter.ts +290 -0
  50. package/src/adapters/LegacyAdapter.ts +667 -0
  51. package/src/adapters/TablesDBAdapter.ts +429 -0
  52. package/src/adapters/index.ts +37 -0
  53. package/src/collections/attributes.ts +351 -157
  54. package/src/collections/methods.ts +43 -28
  55. package/src/config/yamlConfig.ts +8 -2
  56. package/src/databases/setup.ts +2 -2
  57. package/src/migrations/afterImportActions.ts +2 -2
  58. package/src/migrations/comprehensiveTransfer.ts +4 -0
  59. package/src/migrations/dataLoader.ts +2 -1
  60. package/src/migrations/relationships.ts +1 -1
  61. package/src/migrations/services/UserMappingService.ts +1 -1
  62. package/src/migrations/yaml/YamlImportConfigLoader.ts +7 -2
  63. package/src/schemas/authUser.ts +1 -1
  64. package/src/shared/jsonSchemaGenerator.ts +4 -19
  65. package/src/shared/operationQueue.ts +20 -13
  66. package/src/shared/schemaGenerator.ts +2 -16
  67. package/src/types/node-appwrite-tablesdb.d.ts +44 -0
  68. package/src/users/methods.ts +2 -2
  69. package/src/utils/configMigration.ts +0 -1
  70. package/src/utils/getClientFromConfig.ts +56 -0
  71. package/src/utils/loadConfigs.ts +0 -2
  72. package/src/utils/schemaStrings.ts +2 -16
  73. package/src/utils/setupFiles.ts +2 -0
  74. package/src/utils/versionDetection.ts +265 -0
  75. package/src/utils/yamlConverter.ts +0 -2
  76. package/src/utilsController.ts +2 -0
  77. package/dist/functions/openapi.d.ts +0 -4
  78. package/dist/functions/openapi.js +0 -60
  79. package/dist/migrations/attributes.d.ts +0 -4
  80. package/dist/migrations/attributes.js +0 -301
  81. package/dist/migrations/backup.d.ts +0 -687
  82. package/dist/migrations/backup.js +0 -175
  83. package/dist/migrations/collections.d.ts +0 -22
  84. package/dist/migrations/collections.js +0 -347
  85. package/dist/migrations/converters.d.ts +0 -46
  86. package/dist/migrations/converters.js +0 -139
  87. package/dist/migrations/databases.d.ts +0 -2
  88. package/dist/migrations/databases.js +0 -28
  89. package/dist/migrations/dbHelpers.d.ts +0 -5
  90. package/dist/migrations/dbHelpers.js +0 -57
  91. package/dist/migrations/helper.d.ts +0 -3
  92. package/dist/migrations/helper.js +0 -21
  93. package/dist/migrations/indexes.d.ts +0 -4
  94. package/dist/migrations/indexes.js +0 -19
  95. package/dist/migrations/logging.d.ts +0 -10
  96. package/dist/migrations/logging.js +0 -46
  97. package/dist/migrations/migrationHelper.d.ts +0 -173
  98. package/dist/migrations/migrationHelper.js +0 -130
  99. package/dist/migrations/openapi.d.ts +0 -4
  100. package/dist/migrations/openapi.js +0 -60
  101. package/dist/migrations/queue.d.ts +0 -13
  102. package/dist/migrations/queue.js +0 -79
  103. package/dist/migrations/schemaStrings.d.ts +0 -14
  104. package/dist/migrations/schemaStrings.js +0 -478
  105. package/dist/migrations/setupDatabase.d.ts +0 -6
  106. package/dist/migrations/setupDatabase.js +0 -115
  107. package/dist/migrations/storage.d.ts +0 -10
  108. package/dist/migrations/storage.js +0 -340
  109. package/dist/migrations/users.d.ts +0 -16
  110. package/dist/migrations/users.js +0 -276
  111. package/dist/migrations/validationRules.d.ts +0 -43
  112. package/dist/migrations/validationRules.js +0 -42
  113. package/dist/shared/attributeManager.d.ts +0 -17
  114. package/dist/shared/attributeManager.js +0 -272
  115. package/src/functions/openapi.ts +0 -83
  116. package/src/shared/attributeManager.ts +0 -428
@@ -0,0 +1,382 @@
1
+ /**
2
+ * LegacyAdapter - Translation Layer for Legacy Appwrite API
3
+ *
4
+ * This adapter translates TablesDB-style calls (object notation) to legacy
5
+ * Appwrite Databases API calls (positional parameters). It ensures all internal
6
+ * code can use modern TablesDB patterns while maintaining compatibility with
7
+ * older Appwrite instances.
8
+ */
9
+ import { BaseAdapter, AdapterError, UnsupportedOperationError } from './DatabaseAdapter.js';
10
+ /**
11
+ * LegacyAdapter - Translates TablesDB calls to legacy Databases API
12
+ */
13
+ export class LegacyAdapter extends BaseAdapter {
14
+ databases;
15
+ constructor(client) {
16
+ super(client, 'legacy');
17
+ // Assuming Databases service is available on the client
18
+ this.databases = client;
19
+ }
20
+ // Row (Document) Operations - Translate object notation to positional parameters
21
+ async listRows(params) {
22
+ try {
23
+ // TablesDB: listRows({ databaseId, tableId, queries })
24
+ // Legacy: listDocuments(databaseId, collectionId, queries)
25
+ const result = await this.databases.listDocuments(params.databaseId, params.tableId, // Maps tableId to collectionId
26
+ params.queries || []);
27
+ return {
28
+ data: result.documents,
29
+ rows: result.documents, // Alias for TablesDB compatibility
30
+ documents: result.documents, // Legacy format
31
+ total: result.total
32
+ };
33
+ }
34
+ catch (error) {
35
+ throw new AdapterError(`Failed to list rows (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'LIST_ROWS_FAILED', error instanceof Error ? error : undefined);
36
+ }
37
+ }
38
+ async createRow(params) {
39
+ try {
40
+ // TablesDB: createRow({ databaseId, tableId, id, data, permissions })
41
+ // Legacy: createDocument(databaseId, collectionId, id, data, permissions)
42
+ const result = await this.databases.createDocument(params.databaseId, params.tableId, // Maps to collectionId
43
+ params.id, params.data, params.permissions || []);
44
+ return {
45
+ data: result,
46
+ rows: [result],
47
+ documents: [result] // Legacy compatibility
48
+ };
49
+ }
50
+ catch (error) {
51
+ throw new AdapterError(`Failed to create row (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'CREATE_ROW_FAILED', error instanceof Error ? error : undefined);
52
+ }
53
+ }
54
+ async updateRow(params) {
55
+ try {
56
+ // TablesDB: updateRow({ databaseId, tableId, id, data, permissions })
57
+ // Legacy: updateDocument(databaseId, collectionId, id, data, permissions)
58
+ const result = await this.databases.updateDocument(params.databaseId, params.tableId, params.id, params.data, params.permissions || []);
59
+ return {
60
+ data: result,
61
+ rows: [result],
62
+ documents: [result]
63
+ };
64
+ }
65
+ catch (error) {
66
+ throw new AdapterError(`Failed to update row (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'UPDATE_ROW_FAILED', error instanceof Error ? error : undefined);
67
+ }
68
+ }
69
+ async deleteRow(params) {
70
+ try {
71
+ // TablesDB: deleteRow({ databaseId, tableId, id })
72
+ // Legacy: deleteDocument(databaseId, collectionId, id)
73
+ const result = await this.databases.deleteDocument(params.databaseId, params.tableId, params.id);
74
+ return { data: result };
75
+ }
76
+ catch (error) {
77
+ throw new AdapterError(`Failed to delete row (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'DELETE_ROW_FAILED', error instanceof Error ? error : undefined);
78
+ }
79
+ }
80
+ async getRow(params) {
81
+ try {
82
+ // TablesDB: getRow({ databaseId, tableId, id })
83
+ // Legacy: getDocument(databaseId, collectionId, id)
84
+ const result = await this.databases.getDocument(params.databaseId, params.tableId, params.id);
85
+ return {
86
+ data: result,
87
+ rows: [result],
88
+ documents: [result]
89
+ };
90
+ }
91
+ catch (error) {
92
+ throw new AdapterError(`Failed to get row (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'GET_ROW_FAILED', error instanceof Error ? error : undefined);
93
+ }
94
+ }
95
+ // Table (Collection) Operations
96
+ async listTables(params) {
97
+ try {
98
+ // TablesDB: listTables({ databaseId, queries })
99
+ // Legacy: listCollections(databaseId, queries)
100
+ const result = await this.databases.listCollections(params.databaseId, params.queries || []);
101
+ return {
102
+ data: result.collections,
103
+ tables: result.collections, // Alias for TablesDB compatibility
104
+ collections: result.collections, // Legacy format
105
+ total: result.total
106
+ };
107
+ }
108
+ catch (error) {
109
+ throw new AdapterError(`Failed to list tables (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'LIST_TABLES_FAILED', error instanceof Error ? error : undefined);
110
+ }
111
+ }
112
+ async createTable(params) {
113
+ try {
114
+ // TablesDB: createTable({ databaseId, id, name, permissions, documentSecurity, enabled })
115
+ // Legacy: createCollection(databaseId, id, name, permissions, documentSecurity, enabled)
116
+ const result = await this.databases.createCollection(params.databaseId, params.id, params.name, params.permissions || [], params.documentSecurity ?? false, params.enabled ?? true);
117
+ return {
118
+ data: result,
119
+ tables: [result],
120
+ collections: [result]
121
+ };
122
+ }
123
+ catch (error) {
124
+ throw new AdapterError(`Failed to create table (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'CREATE_TABLE_FAILED', error instanceof Error ? error : undefined);
125
+ }
126
+ }
127
+ async updateTable(params) {
128
+ try {
129
+ // TablesDB: updateTable({ databaseId, id, name, permissions, documentSecurity, enabled })
130
+ // Legacy: updateCollection(databaseId, id, name, permissions, documentSecurity, enabled)
131
+ const result = await this.databases.updateCollection(params.databaseId, params.id, params.name, params.permissions || [], params.documentSecurity ?? false, params.enabled ?? true);
132
+ return {
133
+ data: result,
134
+ tables: [result],
135
+ collections: [result]
136
+ };
137
+ }
138
+ catch (error) {
139
+ throw new AdapterError(`Failed to update table (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'UPDATE_TABLE_FAILED', error instanceof Error ? error : undefined);
140
+ }
141
+ }
142
+ async deleteTable(params) {
143
+ try {
144
+ // TablesDB: deleteTable({ databaseId, tableId })
145
+ // Legacy: deleteCollection(databaseId, collectionId)
146
+ const result = await this.databases.deleteCollection(params.databaseId, params.tableId);
147
+ return { data: result };
148
+ }
149
+ catch (error) {
150
+ throw new AdapterError(`Failed to delete table (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'DELETE_TABLE_FAILED', error instanceof Error ? error : undefined);
151
+ }
152
+ }
153
+ async getTable(params) {
154
+ try {
155
+ // TablesDB: getTable({ databaseId, tableId })
156
+ // Legacy: getCollection(databaseId, collectionId)
157
+ const result = await this.databases.getCollection(params.databaseId, params.tableId);
158
+ return {
159
+ data: result,
160
+ tables: [result],
161
+ collections: [result]
162
+ };
163
+ }
164
+ catch (error) {
165
+ throw new AdapterError(`Failed to get table (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'GET_TABLE_FAILED', error instanceof Error ? error : undefined);
166
+ }
167
+ }
168
+ // Index Operations
169
+ async listIndexes(params) {
170
+ try {
171
+ // TablesDB: listIndexes({ databaseId, tableId, queries })
172
+ // Legacy: listIndexes(databaseId, collectionId, queries)
173
+ const result = await this.databases.listIndexes(params.databaseId, params.tableId, params.queries || []);
174
+ return {
175
+ data: result.indexes,
176
+ total: result.total
177
+ };
178
+ }
179
+ catch (error) {
180
+ throw new AdapterError(`Failed to list indexes (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'LIST_INDEXES_FAILED', error instanceof Error ? error : undefined);
181
+ }
182
+ }
183
+ async createIndex(params) {
184
+ try {
185
+ // TablesDB: createIndex({ databaseId, tableId, key, type, attributes, orders })
186
+ // Legacy: createIndex(databaseId, collectionId, key, type, attributes, orders)
187
+ const result = await this.databases.createIndex(params.databaseId, params.tableId, params.key, params.type, params.attributes, params.orders || []);
188
+ return { data: result };
189
+ }
190
+ catch (error) {
191
+ throw new AdapterError(`Failed to create index (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'CREATE_INDEX_FAILED', error instanceof Error ? error : undefined);
192
+ }
193
+ }
194
+ async deleteIndex(params) {
195
+ try {
196
+ // TablesDB: deleteIndex({ databaseId, tableId, key })
197
+ // Legacy: deleteIndex(databaseId, collectionId, key)
198
+ const result = await this.databases.deleteIndex(params.databaseId, params.tableId, params.key);
199
+ return { data: result };
200
+ }
201
+ catch (error) {
202
+ throw new AdapterError(`Failed to delete index (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'DELETE_INDEX_FAILED', error instanceof Error ? error : undefined);
203
+ }
204
+ }
205
+ // Attribute Operations
206
+ async createAttribute(params) {
207
+ try {
208
+ // Legacy attribute creation varies by type, need to map different methods
209
+ let result;
210
+ switch (params.type.toLowerCase()) {
211
+ case 'string':
212
+ result = await this.databases.createStringAttribute(params.databaseId, params.tableId, params.key, params.size || 255, params.required ?? false, params.default, params.array ?? false, params.encrypt ?? false);
213
+ break;
214
+ case 'integer':
215
+ result = await this.databases.createIntegerAttribute(params.databaseId, params.tableId, params.key, params.required ?? false, params.min, params.max, params.default, params.array ?? false);
216
+ break;
217
+ case 'float':
218
+ case 'double':
219
+ result = await this.databases.createFloatAttribute(params.databaseId, params.tableId, params.key, params.required ?? false, params.min, params.max, params.default, params.array ?? false);
220
+ break;
221
+ case 'boolean':
222
+ result = await this.databases.createBooleanAttribute(params.databaseId, params.tableId, params.key, params.required ?? false, params.default, params.array ?? false);
223
+ break;
224
+ case 'datetime':
225
+ result = await this.databases.createDatetimeAttribute(params.databaseId, params.tableId, params.key, params.required ?? false, params.default, params.array ?? false);
226
+ break;
227
+ case 'email':
228
+ result = await this.databases.createEmailAttribute(params.databaseId, params.tableId, params.key, params.required ?? false, params.default, params.array ?? false);
229
+ break;
230
+ case 'enum':
231
+ result = await this.databases.createEnumAttribute(params.databaseId, params.tableId, params.key, params.elements || [], params.required ?? false, params.default, params.array ?? false);
232
+ break;
233
+ case 'ip':
234
+ result = await this.databases.createIpAttribute(params.databaseId, params.tableId, params.key, params.required ?? false, params.default, params.array ?? false);
235
+ break;
236
+ case 'url':
237
+ result = await this.databases.createUrlAttribute(params.databaseId, params.tableId, params.key, params.required ?? false, params.default, params.array ?? false);
238
+ break;
239
+ case 'relationship':
240
+ result = await this.databases.createRelationshipAttribute(params.databaseId, params.tableId, params.key, params.relatedCollection || '', params.type || 'oneToOne', params.twoWay ?? false, params.onDelete || 'restrict');
241
+ break;
242
+ default:
243
+ throw new AdapterError(`Unsupported attribute type: ${params.type}`, 'UNSUPPORTED_ATTRIBUTE_TYPE');
244
+ }
245
+ return { data: result };
246
+ }
247
+ catch (error) {
248
+ throw new AdapterError(`Failed to create attribute (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'CREATE_ATTRIBUTE_FAILED', error instanceof Error ? error : undefined);
249
+ }
250
+ }
251
+ async updateAttribute(params) {
252
+ try {
253
+ // TablesDB: updateAttribute({ databaseId, tableId, key, required, default })
254
+ // Legacy: updateStringAttribute, updateIntegerAttribute, etc.
255
+ // Note: Legacy API has type-specific update methods
256
+ const result = await this.databases.updateStringAttribute(params.databaseId, params.tableId, params.key, params.required ?? false, params.default);
257
+ return { data: result };
258
+ }
259
+ catch (error) {
260
+ throw new AdapterError(`Failed to update attribute (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'UPDATE_ATTRIBUTE_FAILED', error instanceof Error ? error : undefined);
261
+ }
262
+ }
263
+ async deleteAttribute(params) {
264
+ try {
265
+ // TablesDB: deleteAttribute({ databaseId, tableId, key })
266
+ // Legacy: deleteAttribute(databaseId, collectionId, key)
267
+ const result = await this.databases.deleteAttribute(params.databaseId, params.tableId, params.key);
268
+ return { data: result };
269
+ }
270
+ catch (error) {
271
+ throw new AdapterError(`Failed to delete attribute (legacy): ${error instanceof Error ? error.message : 'Unknown error'}`, 'DELETE_ATTRIBUTE_FAILED', error instanceof Error ? error : undefined);
272
+ }
273
+ }
274
+ // Bulk Operations - Not natively supported in legacy, provide fallback
275
+ async bulkCreateRows(params) {
276
+ // Legacy doesn't support bulk operations, fallback to individual creates
277
+ const results = [];
278
+ const errors = [];
279
+ for (const row of params.rows) {
280
+ try {
281
+ const result = await this.createRow({
282
+ databaseId: params.databaseId,
283
+ tableId: params.tableId,
284
+ id: row.$id || 'unique()', // Generate unique ID if not provided
285
+ data: row,
286
+ permissions: row.$permissions
287
+ });
288
+ results.push(result.data);
289
+ }
290
+ catch (error) {
291
+ errors.push({
292
+ row,
293
+ error: error instanceof Error ? error.message : 'Unknown error'
294
+ });
295
+ }
296
+ }
297
+ if (errors.length > 0) {
298
+ console.warn(`Bulk create had ${errors.length} failures out of ${params.rows.length} total rows`);
299
+ }
300
+ return {
301
+ data: results,
302
+ rows: results,
303
+ total: results.length,
304
+ errors: errors.length > 0 ? errors : undefined
305
+ };
306
+ }
307
+ async bulkUpsertRows(params) {
308
+ throw new UnsupportedOperationError('bulkUpsertRows', 'legacy');
309
+ }
310
+ async bulkDeleteRows(params) {
311
+ // Legacy doesn't support bulk operations, fallback to individual deletes
312
+ const results = [];
313
+ const errors = [];
314
+ for (const rowId of params.rowIds) {
315
+ try {
316
+ await this.deleteRow({
317
+ databaseId: params.databaseId,
318
+ tableId: params.tableId,
319
+ id: rowId
320
+ });
321
+ results.push({ id: rowId, deleted: true });
322
+ }
323
+ catch (error) {
324
+ errors.push({
325
+ rowId,
326
+ error: error instanceof Error ? error.message : 'Unknown error'
327
+ });
328
+ }
329
+ }
330
+ return {
331
+ data: results,
332
+ total: results.length,
333
+ errors: errors.length > 0 ? errors : undefined
334
+ };
335
+ }
336
+ // Metadata and Capabilities
337
+ getMetadata() {
338
+ return {
339
+ apiMode: 'legacy',
340
+ terminology: {
341
+ container: 'collection',
342
+ item: 'document',
343
+ service: 'Databases'
344
+ },
345
+ capabilities: {
346
+ bulkOperations: false, // Legacy doesn't support native bulk ops
347
+ advancedQueries: true,
348
+ realtime: true,
349
+ transactions: false
350
+ }
351
+ };
352
+ }
353
+ supportsBulkOperations() {
354
+ return false; // Legacy uses individual operation fallbacks
355
+ }
356
+ // Legacy-specific helper methods
357
+ /**
358
+ * Check if endpoint supports bulk operations via HTTP (for cloud instances)
359
+ */
360
+ supportsHttpBulkOperations(endpoint) {
361
+ return endpoint.includes('cloud.appwrite.io');
362
+ }
363
+ /**
364
+ * Normalize response format to be consistent with TablesDB
365
+ */
366
+ normalizeResponse(response, type) {
367
+ if (type === 'row') {
368
+ return {
369
+ data: response,
370
+ rows: Array.isArray(response) ? response : [response],
371
+ documents: Array.isArray(response) ? response : [response]
372
+ };
373
+ }
374
+ else {
375
+ return {
376
+ data: response,
377
+ tables: Array.isArray(response) ? response : [response],
378
+ collections: Array.isArray(response) ? response : [response]
379
+ };
380
+ }
381
+ }
382
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * TablesDBAdapter - Native TablesDB API Implementation
3
+ *
4
+ * This adapter provides direct access to the new Appwrite TablesDB API
5
+ * without any translation layer. It uses object notation parameters
6
+ * and returns Models.Row instead of Models.Document.
7
+ */
8
+ import { BaseAdapter, type CreateRowParams, type UpdateRowParams, type ListRowsParams, type DeleteRowParams, type CreateTableParams, type UpdateTableParams, type ListTablesParams, type DeleteTableParams, type GetTableParams, type BulkCreateRowsParams, type BulkUpsertRowsParams, type BulkDeleteRowsParams, type CreateIndexParams, type ListIndexesParams, type DeleteIndexParams, type CreateAttributeParams, type UpdateAttributeParams, type DeleteAttributeParams, type ApiResponse, type AdapterMetadata } from './DatabaseAdapter.js';
9
+ /**
10
+ * TablesDBAdapter implementation for native TablesDB API
11
+ */
12
+ export declare class TablesDBAdapter extends BaseAdapter {
13
+ private tablesDB;
14
+ constructor(client: any);
15
+ listRows(params: ListRowsParams): Promise<ApiResponse>;
16
+ createRow(params: CreateRowParams): Promise<ApiResponse>;
17
+ updateRow(params: UpdateRowParams): Promise<ApiResponse>;
18
+ deleteRow(params: DeleteRowParams): Promise<ApiResponse>;
19
+ getRow(params: {
20
+ databaseId: string;
21
+ tableId: string;
22
+ id: string;
23
+ }): Promise<ApiResponse>;
24
+ listTables(params: ListTablesParams): Promise<ApiResponse>;
25
+ createTable(params: CreateTableParams): Promise<ApiResponse>;
26
+ updateTable(params: UpdateTableParams): Promise<ApiResponse>;
27
+ deleteTable(params: DeleteTableParams): Promise<ApiResponse>;
28
+ getTable(params: GetTableParams): Promise<ApiResponse>;
29
+ listIndexes(params: ListIndexesParams): Promise<ApiResponse>;
30
+ createIndex(params: CreateIndexParams): Promise<ApiResponse>;
31
+ deleteIndex(params: DeleteIndexParams): Promise<ApiResponse>;
32
+ createAttribute(params: CreateAttributeParams): Promise<ApiResponse>;
33
+ updateAttribute(params: UpdateAttributeParams): Promise<ApiResponse>;
34
+ deleteAttribute(params: DeleteAttributeParams): Promise<ApiResponse>;
35
+ bulkCreateRows(params: BulkCreateRowsParams): Promise<ApiResponse>;
36
+ bulkUpsertRows(params: BulkUpsertRowsParams): Promise<ApiResponse>;
37
+ bulkDeleteRows(params: BulkDeleteRowsParams): Promise<ApiResponse>;
38
+ getMetadata(): AdapterMetadata;
39
+ supportsBulkOperations(): boolean;
40
+ /**
41
+ * Execute a transaction (if supported by TablesDB)
42
+ */
43
+ executeTransaction(operations: Array<() => Promise<any>>): Promise<ApiResponse>;
44
+ /**
45
+ * Subscribe to real-time updates (if supported)
46
+ */
47
+ subscribeToTable(params: {
48
+ databaseId: string;
49
+ tableId: string;
50
+ }, callback: (data: any) => void): () => void;
51
+ /**
52
+ * Get table statistics (if available in TablesDB)
53
+ */
54
+ getTableStats(params: GetTableParams): Promise<ApiResponse>;
55
+ }