appwrite-utils-cli 1.5.2 → 1.6.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 (233) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/README.md +251 -29
  3. package/dist/adapters/AdapterFactory.d.ts +10 -3
  4. package/dist/adapters/AdapterFactory.js +213 -17
  5. package/dist/adapters/TablesDBAdapter.js +60 -17
  6. package/dist/backups/operations/bucketBackup.d.ts +19 -0
  7. package/dist/backups/operations/bucketBackup.js +197 -0
  8. package/dist/backups/operations/collectionBackup.d.ts +30 -0
  9. package/dist/backups/operations/collectionBackup.js +201 -0
  10. package/dist/backups/operations/comprehensiveBackup.d.ts +25 -0
  11. package/dist/backups/operations/comprehensiveBackup.js +238 -0
  12. package/dist/backups/schemas/bucketManifest.d.ts +93 -0
  13. package/dist/backups/schemas/bucketManifest.js +33 -0
  14. package/dist/backups/schemas/comprehensiveManifest.d.ts +108 -0
  15. package/dist/backups/schemas/comprehensiveManifest.js +32 -0
  16. package/dist/backups/tracking/centralizedTracking.d.ts +34 -0
  17. package/dist/backups/tracking/centralizedTracking.js +274 -0
  18. package/dist/cli/commands/configCommands.d.ts +8 -0
  19. package/dist/cli/commands/configCommands.js +160 -0
  20. package/dist/cli/commands/databaseCommands.d.ts +13 -0
  21. package/dist/cli/commands/databaseCommands.js +478 -0
  22. package/dist/cli/commands/functionCommands.d.ts +7 -0
  23. package/dist/cli/commands/functionCommands.js +289 -0
  24. package/dist/cli/commands/schemaCommands.d.ts +7 -0
  25. package/dist/cli/commands/schemaCommands.js +134 -0
  26. package/dist/cli/commands/transferCommands.d.ts +5 -0
  27. package/dist/cli/commands/transferCommands.js +384 -0
  28. package/dist/collections/attributes.d.ts +5 -4
  29. package/dist/collections/attributes.js +539 -246
  30. package/dist/collections/indexes.js +39 -37
  31. package/dist/collections/methods.d.ts +2 -16
  32. package/dist/collections/methods.js +90 -538
  33. package/dist/collections/transferOperations.d.ts +7 -0
  34. package/dist/collections/transferOperations.js +331 -0
  35. package/dist/collections/wipeOperations.d.ts +16 -0
  36. package/dist/collections/wipeOperations.js +328 -0
  37. package/dist/config/configMigration.d.ts +87 -0
  38. package/dist/config/configMigration.js +390 -0
  39. package/dist/config/configValidation.d.ts +66 -0
  40. package/dist/config/configValidation.js +358 -0
  41. package/dist/config/yamlConfig.d.ts +455 -1
  42. package/dist/config/yamlConfig.js +145 -52
  43. package/dist/databases/methods.js +3 -2
  44. package/dist/databases/setup.d.ts +1 -2
  45. package/dist/databases/setup.js +9 -87
  46. package/dist/examples/yamlTerminologyExample.d.ts +42 -0
  47. package/dist/examples/yamlTerminologyExample.js +269 -0
  48. package/dist/functions/deployments.js +11 -10
  49. package/dist/functions/methods.d.ts +1 -1
  50. package/dist/functions/methods.js +5 -4
  51. package/dist/init.js +9 -9
  52. package/dist/interactiveCLI.d.ts +8 -17
  53. package/dist/interactiveCLI.js +181 -1172
  54. package/dist/main.js +364 -21
  55. package/dist/migrations/afterImportActions.js +22 -30
  56. package/dist/migrations/appwriteToX.js +71 -25
  57. package/dist/migrations/dataLoader.js +35 -26
  58. package/dist/migrations/importController.js +29 -30
  59. package/dist/migrations/relationships.js +13 -12
  60. package/dist/migrations/services/ImportOrchestrator.js +16 -19
  61. package/dist/migrations/transfer.js +46 -46
  62. package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +3 -1
  63. package/dist/migrations/yaml/YamlImportConfigLoader.js +6 -3
  64. package/dist/migrations/yaml/YamlImportIntegration.d.ts +9 -3
  65. package/dist/migrations/yaml/YamlImportIntegration.js +22 -11
  66. package/dist/migrations/yaml/generateImportSchemas.d.ts +14 -1
  67. package/dist/migrations/yaml/generateImportSchemas.js +736 -7
  68. package/dist/schemas/authUser.d.ts +1 -1
  69. package/dist/setupController.js +3 -2
  70. package/dist/shared/backupMetadataSchema.d.ts +94 -0
  71. package/dist/shared/backupMetadataSchema.js +38 -0
  72. package/dist/shared/backupTracking.d.ts +18 -0
  73. package/dist/shared/backupTracking.js +176 -0
  74. package/dist/shared/confirmationDialogs.js +15 -15
  75. package/dist/shared/errorUtils.d.ts +54 -0
  76. package/dist/shared/errorUtils.js +95 -0
  77. package/dist/shared/functionManager.js +20 -19
  78. package/dist/shared/indexManager.js +12 -11
  79. package/dist/shared/jsonSchemaGenerator.js +10 -26
  80. package/dist/shared/logging.d.ts +51 -0
  81. package/dist/shared/logging.js +70 -0
  82. package/dist/shared/messageFormatter.d.ts +2 -0
  83. package/dist/shared/messageFormatter.js +10 -0
  84. package/dist/shared/migrationHelpers.d.ts +6 -16
  85. package/dist/shared/migrationHelpers.js +24 -21
  86. package/dist/shared/operationLogger.d.ts +8 -1
  87. package/dist/shared/operationLogger.js +11 -24
  88. package/dist/shared/operationQueue.d.ts +28 -1
  89. package/dist/shared/operationQueue.js +268 -66
  90. package/dist/shared/operationsTable.d.ts +26 -0
  91. package/dist/shared/operationsTable.js +286 -0
  92. package/dist/shared/operationsTableSchema.d.ts +48 -0
  93. package/dist/shared/operationsTableSchema.js +35 -0
  94. package/dist/shared/relationshipExtractor.d.ts +56 -0
  95. package/dist/shared/relationshipExtractor.js +138 -0
  96. package/dist/shared/schemaGenerator.d.ts +19 -1
  97. package/dist/shared/schemaGenerator.js +56 -75
  98. package/dist/storage/backupCompression.d.ts +20 -0
  99. package/dist/storage/backupCompression.js +67 -0
  100. package/dist/storage/methods.d.ts +16 -2
  101. package/dist/storage/methods.js +98 -14
  102. package/dist/users/methods.js +9 -8
  103. package/dist/utils/configDiscovery.d.ts +78 -0
  104. package/dist/utils/configDiscovery.js +430 -0
  105. package/dist/utils/directoryUtils.d.ts +22 -0
  106. package/dist/utils/directoryUtils.js +59 -0
  107. package/dist/utils/getClientFromConfig.d.ts +17 -8
  108. package/dist/utils/getClientFromConfig.js +162 -17
  109. package/dist/utils/helperFunctions.d.ts +16 -2
  110. package/dist/utils/helperFunctions.js +19 -5
  111. package/dist/utils/loadConfigs.d.ts +34 -9
  112. package/dist/utils/loadConfigs.js +236 -316
  113. package/dist/utils/pathResolvers.d.ts +53 -0
  114. package/dist/utils/pathResolvers.js +72 -0
  115. package/dist/utils/projectConfig.d.ts +119 -0
  116. package/dist/utils/projectConfig.js +171 -0
  117. package/dist/utils/retryFailedPromises.js +4 -2
  118. package/dist/utils/sessionAuth.d.ts +48 -0
  119. package/dist/utils/sessionAuth.js +164 -0
  120. package/dist/utils/sessionPreservationExample.d.ts +1666 -0
  121. package/dist/utils/sessionPreservationExample.js +101 -0
  122. package/dist/utils/setupFiles.js +301 -41
  123. package/dist/utils/typeGuards.d.ts +35 -0
  124. package/dist/utils/typeGuards.js +57 -0
  125. package/dist/utils/versionDetection.js +145 -9
  126. package/dist/utils/yamlConverter.d.ts +53 -3
  127. package/dist/utils/yamlConverter.js +232 -13
  128. package/dist/utils/yamlLoader.d.ts +70 -0
  129. package/dist/utils/yamlLoader.js +263 -0
  130. package/dist/utilsController.d.ts +36 -3
  131. package/dist/utilsController.js +186 -56
  132. package/package.json +12 -2
  133. package/src/adapters/AdapterFactory.ts +263 -35
  134. package/src/adapters/TablesDBAdapter.ts +225 -36
  135. package/src/backups/operations/bucketBackup.ts +277 -0
  136. package/src/backups/operations/collectionBackup.ts +310 -0
  137. package/src/backups/operations/comprehensiveBackup.ts +342 -0
  138. package/src/backups/schemas/bucketManifest.ts +78 -0
  139. package/src/backups/schemas/comprehensiveManifest.ts +76 -0
  140. package/src/backups/tracking/centralizedTracking.ts +352 -0
  141. package/src/cli/commands/configCommands.ts +194 -0
  142. package/src/cli/commands/databaseCommands.ts +635 -0
  143. package/src/cli/commands/functionCommands.ts +379 -0
  144. package/src/cli/commands/schemaCommands.ts +163 -0
  145. package/src/cli/commands/transferCommands.ts +457 -0
  146. package/src/collections/attributes.ts +900 -621
  147. package/src/collections/attributes.ts.backup +1555 -0
  148. package/src/collections/indexes.ts +116 -114
  149. package/src/collections/methods.ts +295 -968
  150. package/src/collections/transferOperations.ts +516 -0
  151. package/src/collections/wipeOperations.ts +501 -0
  152. package/src/config/README.md +274 -0
  153. package/src/config/configMigration.ts +575 -0
  154. package/src/config/configValidation.ts +445 -0
  155. package/src/config/yamlConfig.ts +168 -55
  156. package/src/databases/methods.ts +3 -2
  157. package/src/databases/setup.ts +11 -138
  158. package/src/examples/yamlTerminologyExample.ts +341 -0
  159. package/src/functions/deployments.ts +14 -12
  160. package/src/functions/methods.ts +11 -11
  161. package/src/functions/templates/hono-typescript/README.md +286 -0
  162. package/src/functions/templates/hono-typescript/package.json +26 -0
  163. package/src/functions/templates/hono-typescript/src/adapters/request.ts +74 -0
  164. package/src/functions/templates/hono-typescript/src/adapters/response.ts +106 -0
  165. package/src/functions/templates/hono-typescript/src/app.ts +180 -0
  166. package/src/functions/templates/hono-typescript/src/context.ts +103 -0
  167. package/src/functions/templates/hono-typescript/src/index.ts +54 -0
  168. package/src/functions/templates/hono-typescript/src/middleware/appwrite.ts +119 -0
  169. package/src/functions/templates/hono-typescript/tsconfig.json +20 -0
  170. package/src/functions/templates/typescript-node/package.json +2 -1
  171. package/src/functions/templates/typescript-node/src/context.ts +103 -0
  172. package/src/functions/templates/typescript-node/src/index.ts +18 -12
  173. package/src/functions/templates/uv/pyproject.toml +1 -0
  174. package/src/functions/templates/uv/src/context.py +125 -0
  175. package/src/functions/templates/uv/src/index.py +35 -5
  176. package/src/init.ts +9 -11
  177. package/src/interactiveCLI.ts +278 -1596
  178. package/src/main.ts +418 -24
  179. package/src/migrations/afterImportActions.ts +71 -44
  180. package/src/migrations/appwriteToX.ts +100 -34
  181. package/src/migrations/dataLoader.ts +48 -34
  182. package/src/migrations/importController.ts +44 -39
  183. package/src/migrations/relationships.ts +28 -18
  184. package/src/migrations/services/ImportOrchestrator.ts +24 -27
  185. package/src/migrations/transfer.ts +159 -121
  186. package/src/migrations/yaml/YamlImportConfigLoader.ts +11 -4
  187. package/src/migrations/yaml/YamlImportIntegration.ts +47 -20
  188. package/src/migrations/yaml/generateImportSchemas.ts +751 -12
  189. package/src/setupController.ts +3 -2
  190. package/src/shared/backupMetadataSchema.ts +93 -0
  191. package/src/shared/backupTracking.ts +211 -0
  192. package/src/shared/confirmationDialogs.ts +19 -19
  193. package/src/shared/errorUtils.ts +110 -0
  194. package/src/shared/functionManager.ts +21 -20
  195. package/src/shared/indexManager.ts +12 -11
  196. package/src/shared/jsonSchemaGenerator.ts +38 -52
  197. package/src/shared/logging.ts +75 -0
  198. package/src/shared/messageFormatter.ts +14 -1
  199. package/src/shared/migrationHelpers.ts +45 -38
  200. package/src/shared/operationLogger.ts +11 -36
  201. package/src/shared/operationQueue.ts +322 -93
  202. package/src/shared/operationsTable.ts +338 -0
  203. package/src/shared/operationsTableSchema.ts +60 -0
  204. package/src/shared/relationshipExtractor.ts +214 -0
  205. package/src/shared/schemaGenerator.ts +179 -219
  206. package/src/storage/backupCompression.ts +88 -0
  207. package/src/storage/methods.ts +131 -34
  208. package/src/users/methods.ts +11 -9
  209. package/src/utils/configDiscovery.ts +502 -0
  210. package/src/utils/directoryUtils.ts +61 -0
  211. package/src/utils/getClientFromConfig.ts +205 -22
  212. package/src/utils/helperFunctions.ts +23 -5
  213. package/src/utils/loadConfigs.ts +313 -345
  214. package/src/utils/pathResolvers.ts +81 -0
  215. package/src/utils/projectConfig.ts +299 -0
  216. package/src/utils/retryFailedPromises.ts +4 -2
  217. package/src/utils/sessionAuth.ts +230 -0
  218. package/src/utils/setupFiles.ts +322 -54
  219. package/src/utils/typeGuards.ts +65 -0
  220. package/src/utils/versionDetection.ts +218 -64
  221. package/src/utils/yamlConverter.ts +296 -13
  222. package/src/utils/yamlLoader.ts +364 -0
  223. package/src/utilsController.ts +314 -110
  224. package/tests/README.md +497 -0
  225. package/tests/adapters/AdapterFactory.test.ts +277 -0
  226. package/tests/integration/syncOperations.test.ts +463 -0
  227. package/tests/jest.config.js +25 -0
  228. package/tests/migration/configMigration.test.ts +546 -0
  229. package/tests/setup.ts +62 -0
  230. package/tests/testUtils.ts +340 -0
  231. package/tests/utils/loadConfigs.test.ts +350 -0
  232. package/tests/validation/configValidation.test.ts +412 -0
  233. package/src/utils/schemaStrings.ts +0 -517
@@ -13,6 +13,7 @@ import { MessageFormatter } from "../../shared/messageFormatter.js";
13
13
  import { ProgressManager } from "../../shared/progressManager.js";
14
14
  import { tryAwaitWithRetry } from "../../utils/index.js";
15
15
  import { updateOperation, findOrCreateOperation } from "../../shared/migrationHelpers.js";
16
+ import { LegacyAdapter } from "../../adapters/LegacyAdapter.js";
16
17
  import { resolveAndUpdateRelationships } from "../relationships.js";
17
18
  // Enhanced rate limiting configuration - now managed by RateLimitManager
18
19
  /**
@@ -71,9 +72,6 @@ export class ImportOrchestrator {
71
72
  }
72
73
  let processedDatabase;
73
74
  for (const db of databasesToProcess) {
74
- if (!this.config.useMigrations && db.name.toLowerCase().trim().replace(" ", "") === "migrations") {
75
- continue;
76
- }
77
75
  MessageFormatter.banner(`Starting import data for database: ${db.name}`, "Database Import");
78
76
  if (!processedDatabase) {
79
77
  processedDatabase = db;
@@ -149,10 +147,9 @@ export class ImportOrchestrator {
149
147
  collection.$id = existingCollection.$id;
150
148
  this.config.collections[index] = collectionConfig;
151
149
  // Find or create an import operation for the collection
152
- if (this.config.useMigrations) {
153
- const collectionImportOperation = await findOrCreateOperation(this.database, collection.$id, "importData");
154
- this.collectionImportOperations.set(this.getCollectionKey(collection.name), collectionImportOperation.$id);
155
- }
150
+ const adapter = new LegacyAdapter(this.database);
151
+ const collectionImportOperation = await findOrCreateOperation(adapter, dbId, "importData", collection.$id);
152
+ this.collectionImportOperations.set(this.getCollectionKey(collection.name), collectionImportOperation.$id);
156
153
  // Initialize the collection in the import map
157
154
  this.importMap.set(this.getCollectionKey(collection.name), {
158
155
  collection: collection,
@@ -230,7 +227,7 @@ export class ImportOrchestrator {
230
227
  const rawData = this.loadDataFromFile(importDef);
231
228
  if (rawData.length === 0)
232
229
  return;
233
- await this.updateOperationStatus(collection, "ready", rawData.length);
230
+ await this.updateOperationStatus(db, collection, "ready", rawData.length);
234
231
  const collectionData = this.importMap.get(this.getCollectionKey(collection.name));
235
232
  if (!collectionData) {
236
233
  logger.error(`No collection data found for ${collection.name}`);
@@ -284,7 +281,7 @@ export class ImportOrchestrator {
284
281
  const rawData = this.loadDataFromFile(importDef);
285
282
  if (rawData.length === 0)
286
283
  return;
287
- await this.updateOperationStatus(collection, "ready", rawData.length);
284
+ await this.updateOperationStatus(db, collection, "ready", rawData.length);
288
285
  const collectionData = this.importMap.get(this.getCollectionKey(collection.name));
289
286
  if (!collectionData)
290
287
  return;
@@ -356,8 +353,9 @@ export class ImportOrchestrator {
356
353
  }
357
354
  logger.info(`Importing collection: ${collection.name} (${collectionData.data.length} items)`);
358
355
  const operationId = this.collectionImportOperations.get(this.getCollectionKey(collection.name));
359
- if (operationId && this.config.useMigrations) {
360
- await updateOperation(this.database, operationId, { status: "in_progress" }, this.config.useMigrations);
356
+ const adapter = new LegacyAdapter(this.database);
357
+ if (operationId) {
358
+ await updateOperation(adapter, db.$id, operationId, { status: "in_progress" });
361
359
  }
362
360
  // Create batches for processing
363
361
  const batches = this.createBatches(collectionData.data, this.batchLimit);
@@ -373,13 +371,13 @@ export class ImportOrchestrator {
373
371
  processedItems += successCount;
374
372
  logger.info(`Batch ${i + 1} completed: ${successCount}/${batch.length} items imported`);
375
373
  // Update operation progress
376
- if (operationId && this.config.useMigrations) {
377
- await updateOperation(this.database, operationId, { progress: processedItems }, this.config.useMigrations);
374
+ if (operationId) {
375
+ await updateOperation(adapter, db.$id, operationId, { progress: processedItems });
378
376
  }
379
377
  }
380
378
  // Mark operation as completed
381
- if (operationId && this.config.useMigrations) {
382
- await updateOperation(this.database, operationId, { status: "completed" }, this.config.useMigrations);
379
+ if (operationId) {
380
+ await updateOperation(adapter, db.$id, operationId, { status: "completed" });
383
381
  }
384
382
  logger.info(`Completed importing collection: ${collection.name} (${processedItems} items)`);
385
383
  }
@@ -459,13 +457,12 @@ export class ImportOrchestrator {
459
457
  return null;
460
458
  }
461
459
  }
462
- async updateOperationStatus(collection, status, total) {
463
- if (!this.config.useMigrations)
464
- return;
460
+ async updateOperationStatus(db, collection, status, total) {
465
461
  const operationId = this.collectionImportOperations.get(this.getCollectionKey(collection.name));
466
462
  if (operationId) {
467
463
  const updateData = total ? { status, total } : { status };
468
- await updateOperation(this.database, operationId, updateData, this.config.useMigrations);
464
+ const adapter = new LegacyAdapter(this.database);
465
+ await updateOperation(adapter, db.$id, operationId, updateData);
469
466
  }
470
467
  }
471
468
  async importUsersCollection() {
@@ -136,13 +136,13 @@ export const transferStorageLocalToRemote = async (localStorage, endpoint, proje
136
136
  * @return {Promise<void>} A promise that resolves when the transfer is complete.
137
137
  */
138
138
  export const transferDatabaseLocalToLocal = async (localDb, fromDbId, targetDbId) => {
139
- console.log(chalk.blue(`Starting database transfer from ${fromDbId} to ${targetDbId}`));
139
+ MessageFormatter.info(`Starting database transfer from ${fromDbId} to ${targetDbId}`, { prefix: "Transfer" });
140
140
  // Get all collections from source database
141
141
  const sourceCollections = await fetchAllCollections(fromDbId, localDb);
142
- console.log(chalk.blue(`Found ${sourceCollections.length} collections in source database`));
142
+ MessageFormatter.info(`Found ${sourceCollections.length} collections in source database`, { prefix: "Transfer" });
143
143
  // Process each collection
144
144
  for (const collection of sourceCollections) {
145
- console.log(chalk.yellow(`Processing collection: ${collection.name} (${collection.$id})`));
145
+ MessageFormatter.processing(`Processing collection: ${collection.name} (${collection.$id})`, { prefix: "Transfer" });
146
146
  try {
147
147
  // Create or update collection in target
148
148
  let targetCollection;
@@ -151,39 +151,39 @@ export const transferDatabaseLocalToLocal = async (localDb, fromDbId, targetDbId
151
151
  ]));
152
152
  if (existingCollection.collections.length > 0) {
153
153
  targetCollection = existingCollection.collections[0];
154
- console.log(chalk.green(`Collection ${collection.name} exists in target database`));
154
+ MessageFormatter.info(`Collection ${collection.name} exists in target database`, { prefix: "Transfer" });
155
155
  // Update collection if needed
156
156
  if (targetCollection.name !== collection.name ||
157
157
  targetCollection.$permissions !== collection.$permissions ||
158
158
  targetCollection.documentSecurity !== collection.documentSecurity ||
159
159
  targetCollection.enabled !== collection.enabled) {
160
160
  targetCollection = await tryAwaitWithRetry(async () => localDb.updateCollection(targetDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
161
- console.log(chalk.green(`Collection ${collection.name} updated`));
161
+ MessageFormatter.success(`Collection ${collection.name} updated`, { prefix: "Transfer" });
162
162
  }
163
163
  }
164
164
  else {
165
- console.log(chalk.yellow(`Creating collection ${collection.name} in target database...`));
165
+ MessageFormatter.progress(`Creating collection ${collection.name} in target database...`, { prefix: "Transfer" });
166
166
  targetCollection = await tryAwaitWithRetry(async () => localDb.createCollection(targetDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
167
167
  }
168
168
  // Handle attributes with enhanced status checking
169
- console.log(chalk.blue(`Creating attributes for collection ${collection.name} with enhanced monitoring...`));
169
+ MessageFormatter.info(`Creating attributes for collection ${collection.name} with enhanced monitoring...`, { prefix: "Transfer" });
170
170
  const allAttributes = collection.attributes.map((attr) => parseAttribute(attr));
171
171
  const attributeSuccess = await createUpdateCollectionAttributesWithStatusCheck(localDb, targetDbId, targetCollection, allAttributes);
172
172
  if (!attributeSuccess) {
173
- console.log(chalk.red(`❌ Failed to create all attributes for collection ${collection.name}, skipping to next collection`));
173
+ MessageFormatter.error(`Failed to create all attributes for collection ${collection.name}, skipping to next collection`, undefined, { prefix: "Transfer" });
174
174
  continue;
175
175
  }
176
- console.log(chalk.green(`✅ All attributes created successfully for collection ${collection.name}`));
176
+ MessageFormatter.success(`All attributes created successfully for collection ${collection.name}`, { prefix: "Transfer" });
177
177
  // Handle indexes
178
178
  const existingIndexes = await tryAwaitWithRetry(async () => await localDb.listIndexes(targetDbId, targetCollection.$id));
179
179
  for (const index of collection.indexes) {
180
180
  const existingIndex = existingIndexes.indexes.find((idx) => idx.key === index.key);
181
181
  if (!existingIndex) {
182
182
  await tryAwaitWithRetry(async () => createOrUpdateIndex(targetDbId, localDb, targetCollection.$id, index));
183
- console.log(chalk.green(`Index ${index.key} created`));
183
+ MessageFormatter.success(`Index ${index.key} created`, { prefix: "Transfer" });
184
184
  }
185
185
  else {
186
- console.log(chalk.blue(`Index ${index.key} exists, checking for updates...`));
186
+ MessageFormatter.info(`Index ${index.key} exists, checking for updates...`, { prefix: "Transfer" });
187
187
  await tryAwaitWithRetry(async () => createOrUpdateIndex(targetDbId, localDb, targetCollection.$id, index));
188
188
  }
189
189
  }
@@ -192,7 +192,7 @@ export const transferDatabaseLocalToLocal = async (localDb, fromDbId, targetDbId
192
192
  await transferDocumentsBetweenDbsLocalToLocal(localDb, fromDbId, targetDbId, collection.$id, targetCollection.$id);
193
193
  }
194
194
  catch (error) {
195
- console.error(chalk.red(`Error processing collection ${collection.name}:`), error);
195
+ MessageFormatter.error(`Error processing collection ${collection.name}`, error instanceof Error ? error : new Error(String(error)), { prefix: "Transfer" });
196
196
  }
197
197
  }
198
198
  };
@@ -201,62 +201,62 @@ export const transferDatabaseLocalToRemote = async (localDb, endpoint, projectId
201
201
  const remoteDb = new Databases(client);
202
202
  // Get all collections from source database
203
203
  const sourceCollections = await fetchAllCollections(fromDbId, localDb);
204
- console.log(chalk.blue(`Found ${sourceCollections.length} collections in source database`));
204
+ MessageFormatter.info(`Found ${sourceCollections.length} collections in source database`, { prefix: "Transfer" });
205
205
  // Process each collection
206
206
  for (const collection of sourceCollections) {
207
- console.log(chalk.yellow(`Processing collection: ${collection.name} (${collection.$id})`));
207
+ MessageFormatter.processing(`Processing collection: ${collection.name} (${collection.$id})`, { prefix: "Transfer" });
208
208
  try {
209
209
  // Create or update collection in target
210
210
  let targetCollection;
211
211
  const existingCollection = await tryAwaitWithRetry(async () => remoteDb.listCollections(toDbId, [Query.equal("$id", collection.$id)]));
212
212
  if (existingCollection.collections.length > 0) {
213
213
  targetCollection = existingCollection.collections[0];
214
- console.log(chalk.green(`Collection ${collection.name} exists in remote database`));
214
+ MessageFormatter.info(`Collection ${collection.name} exists in remote database`, { prefix: "Transfer" });
215
215
  // Update collection if needed
216
216
  if (targetCollection.name !== collection.name ||
217
217
  targetCollection.$permissions !== collection.$permissions ||
218
218
  targetCollection.documentSecurity !== collection.documentSecurity ||
219
219
  targetCollection.enabled !== collection.enabled) {
220
220
  targetCollection = await tryAwaitWithRetry(async () => remoteDb.updateCollection(toDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
221
- console.log(chalk.green(`Collection ${collection.name} updated`));
221
+ MessageFormatter.success(`Collection ${collection.name} updated`, { prefix: "Transfer" });
222
222
  }
223
223
  }
224
224
  else {
225
- console.log(chalk.yellow(`Creating collection ${collection.name} in remote database...`));
225
+ MessageFormatter.progress(`Creating collection ${collection.name} in remote database...`, { prefix: "Transfer" });
226
226
  targetCollection = await tryAwaitWithRetry(async () => remoteDb.createCollection(toDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
227
227
  }
228
228
  // Handle attributes with enhanced status checking
229
- console.log(chalk.blue(`Creating attributes for collection ${collection.name} with enhanced monitoring...`));
229
+ MessageFormatter.info(`Creating attributes for collection ${collection.name} with enhanced monitoring...`, { prefix: "Transfer" });
230
230
  const attributesToCreate = collection.attributes.map((attr) => parseAttribute(attr));
231
231
  const attributesSuccess = await createUpdateCollectionAttributesWithStatusCheck(remoteDb, toDbId, targetCollection, attributesToCreate);
232
232
  if (!attributesSuccess) {
233
- console.log(chalk.red(`Failed to create some attributes for collection ${collection.name}`));
233
+ MessageFormatter.warning(`Failed to create some attributes for collection ${collection.name}`, { prefix: "Transfer" });
234
234
  // Continue with the transfer even if some attributes failed
235
235
  }
236
236
  else {
237
- console.log(chalk.green(`All attributes created successfully for collection ${collection.name}`));
237
+ MessageFormatter.success(`All attributes created successfully for collection ${collection.name}`, { prefix: "Transfer" });
238
238
  }
239
239
  // Handle indexes with enhanced status checking
240
- console.log(chalk.blue(`Creating indexes for collection ${collection.name} with enhanced monitoring...`));
240
+ MessageFormatter.info(`Creating indexes for collection ${collection.name} with enhanced monitoring...`, { prefix: "Transfer" });
241
241
  const indexesSuccess = await createOrUpdateIndexesWithStatusCheck(toDbId, remoteDb, targetCollection.$id, targetCollection, collection.indexes);
242
242
  if (!indexesSuccess) {
243
- console.log(chalk.red(`Failed to create some indexes for collection ${collection.name}`));
243
+ MessageFormatter.warning(`Failed to create some indexes for collection ${collection.name}`, { prefix: "Transfer" });
244
244
  // Continue with the transfer even if some indexes failed
245
245
  }
246
246
  else {
247
- console.log(chalk.green(`All indexes created successfully for collection ${collection.name}`));
247
+ MessageFormatter.success(`All indexes created successfully for collection ${collection.name}`, { prefix: "Transfer" });
248
248
  }
249
249
  // Transfer documents
250
250
  const { transferDocumentsBetweenDbsLocalToRemote } = await import("../collections/methods.js");
251
251
  await transferDocumentsBetweenDbsLocalToRemote(localDb, endpoint, projectId, apiKey, fromDbId, toDbId, collection.$id, targetCollection.$id);
252
252
  }
253
253
  catch (error) {
254
- console.error(chalk.red(`Error processing collection ${collection.name}:`), error);
254
+ MessageFormatter.error(`Error processing collection ${collection.name}`, error instanceof Error ? error : new Error(String(error)), { prefix: "Transfer" });
255
255
  }
256
256
  }
257
257
  };
258
258
  export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId, apiKey) => {
259
- console.log(chalk.blue("Starting user transfer to remote instance..."));
259
+ MessageFormatter.info("Starting user transfer to remote instance...", { prefix: "Transfer" });
260
260
  const client = getClient(endpoint, projectId, apiKey);
261
261
  const remoteUsers = new Users(client);
262
262
  let totalTransferred = 0;
@@ -278,18 +278,18 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
278
278
  remoteUser = await tryAwaitWithRetry(async () => remoteUsers.get(user.$id));
279
279
  // If user exists, update only the differences
280
280
  if (remoteUser) {
281
- console.log(chalk.blue(`User ${user.$id} exists, checking for updates...`));
281
+ MessageFormatter.info(`User ${user.$id} exists, checking for updates...`, { prefix: "Transfer" });
282
282
  let hasUpdates = false;
283
283
  // Update name if different
284
284
  if (remoteUser.name !== user.name) {
285
285
  await tryAwaitWithRetry(async () => remoteUsers.updateName(user.$id, user.name));
286
- console.log(chalk.green(`Updated name for user ${user.$id}`));
286
+ MessageFormatter.success(`Updated name for user ${user.$id}`, { prefix: "Transfer" });
287
287
  hasUpdates = true;
288
288
  }
289
289
  // Update email if different
290
290
  if (remoteUser.email !== user.email) {
291
291
  await tryAwaitWithRetry(async () => remoteUsers.updateEmail(user.$id, user.email));
292
- console.log(chalk.green(`Updated email for user ${user.$id}`));
292
+ MessageFormatter.success(`Updated email for user ${user.$id}`, { prefix: "Transfer" });
293
293
  hasUpdates = true;
294
294
  }
295
295
  // Update phone if different
@@ -300,45 +300,45 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
300
300
  if (normalizedLocalPhone) {
301
301
  await tryAwaitWithRetry(async () => remoteUsers.updatePhone(user.$id, normalizedLocalPhone));
302
302
  }
303
- console.log(chalk.green(`Updated phone for user ${user.$id}`));
303
+ MessageFormatter.success(`Updated phone for user ${user.$id}`, { prefix: "Transfer" });
304
304
  hasUpdates = true;
305
305
  }
306
306
  // Update preferences if different
307
307
  if (JSON.stringify(remoteUser.prefs) !== JSON.stringify(user.prefs)) {
308
308
  await tryAwaitWithRetry(async () => remoteUsers.updatePrefs(user.$id, user.prefs));
309
- console.log(chalk.green(`Updated preferences for user ${user.$id}`));
309
+ MessageFormatter.success(`Updated preferences for user ${user.$id}`, { prefix: "Transfer" });
310
310
  hasUpdates = true;
311
311
  }
312
312
  // Update labels if different
313
313
  if (JSON.stringify(remoteUser.labels) !== JSON.stringify(user.labels)) {
314
314
  await tryAwaitWithRetry(async () => remoteUsers.updateLabels(user.$id, user.labels));
315
- console.log(chalk.green(`Updated labels for user ${user.$id}`));
315
+ MessageFormatter.success(`Updated labels for user ${user.$id}`, { prefix: "Transfer" });
316
316
  hasUpdates = true;
317
317
  }
318
318
  // Update email verification if different
319
319
  if (remoteUser.emailVerification !== user.emailVerification) {
320
320
  await tryAwaitWithRetry(async () => remoteUsers.updateEmailVerification(user.$id, user.emailVerification));
321
- console.log(chalk.green(`Updated email verification for user ${user.$id}`));
321
+ MessageFormatter.success(`Updated email verification for user ${user.$id}`, { prefix: "Transfer" });
322
322
  hasUpdates = true;
323
323
  }
324
324
  // Update phone verification if different
325
325
  if (remoteUser.phoneVerification !== user.phoneVerification) {
326
326
  await tryAwaitWithRetry(async () => remoteUsers.updatePhoneVerification(user.$id, user.phoneVerification));
327
- console.log(chalk.green(`Updated phone verification for user ${user.$id}`));
327
+ MessageFormatter.success(`Updated phone verification for user ${user.$id}`, { prefix: "Transfer" });
328
328
  hasUpdates = true;
329
329
  }
330
330
  // Update status if different
331
331
  if (remoteUser.status !== user.status) {
332
332
  await tryAwaitWithRetry(async () => remoteUsers.updateStatus(user.$id, user.status));
333
- console.log(chalk.green(`Updated status for user ${user.$id}`));
333
+ MessageFormatter.success(`Updated status for user ${user.$id}`, { prefix: "Transfer" });
334
334
  hasUpdates = true;
335
335
  }
336
336
  if (!hasUpdates) {
337
- console.log(chalk.yellow(`User ${user.$id} is already up to date, skipping...`));
337
+ MessageFormatter.info(`User ${user.$id} is already up to date, skipping...`, { prefix: "Transfer" });
338
338
  }
339
339
  else {
340
340
  totalTransferred++;
341
- console.log(chalk.green(`Updated user ${user.$id}`));
341
+ MessageFormatter.success(`Updated user ${user.$id}`, { prefix: "Transfer" });
342
342
  }
343
343
  continue;
344
344
  }
@@ -381,7 +381,7 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
381
381
  // Warn if using default values due to missing hash options
382
382
  if (!hashOptions.salt ||
383
383
  typeof hashOptions.costCpu !== "number") {
384
- console.log(chalk.yellow(`User ${user.$id}: Using default Scrypt parameters due to missing hashOptions`));
384
+ MessageFormatter.warning(`User ${user.$id}: Using default Scrypt parameters due to missing hashOptions`, { prefix: "Transfer" });
385
385
  }
386
386
  await tryAwaitWithRetry(async () => remoteUsers.createScryptUser(user.$id, user.email, hashedPassword, salt, costCpu, costMemory, costParallel, length, user.name));
387
387
  break;
@@ -398,7 +398,7 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
398
398
  if (!hashOptions.salt ||
399
399
  !hashOptions.saltSeparator ||
400
400
  !hashOptions.signerKey) {
401
- console.log(chalk.yellow(`User ${user.$id}: Missing critical Scrypt Modified parameters in hashOptions`));
401
+ MessageFormatter.warning(`User ${user.$id}: Missing critical Scrypt Modified parameters in hashOptions`, { prefix: "Transfer" });
402
402
  }
403
403
  await tryAwaitWithRetry(async () => remoteUsers.createScryptModifiedUser(user.$id, user.email, hashedPassword, modSalt, saltSeparator, signerKey, user.name));
404
404
  break;
@@ -428,17 +428,17 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
428
428
  await tryAwaitWithRetry(async () => remoteUsers.createPHPassUser(user.$id, user.email, hashedPassword, user.name));
429
429
  break;
430
430
  default:
431
- console.log(chalk.yellow(`Unknown hash type '${hashType}' for user ${user.$id}, falling back to Argon2`));
431
+ MessageFormatter.warning(`Unknown hash type '${hashType}' for user ${user.$id}, falling back to Argon2`, { prefix: "Transfer" });
432
432
  await tryAwaitWithRetry(async () => remoteUsers.createArgon2User(user.$id, user.email, hashedPassword, user.name));
433
433
  break;
434
434
  }
435
- console.log(chalk.green(`User ${user.$id} created with preserved ${hashType} password`));
435
+ MessageFormatter.success(`User ${user.$id} created with preserved ${hashType} password`, { prefix: "Transfer" });
436
436
  }
437
437
  catch (error) {
438
- console.log(chalk.yellow(`Failed to create user ${user.$id} with ${hashType} hash, trying with temporary password`));
438
+ MessageFormatter.warning(`Failed to create user ${user.$id} with ${hashType} hash, trying with temporary password`, { prefix: "Transfer" });
439
439
  // Fallback to creating user with temporary password
440
440
  await tryAwaitWithRetry(async () => remoteUsers.create(user.$id, user.email, phone, `changeMe${user.email}`, user.name));
441
- console.log(chalk.yellow(`User ${user.$id} created with temporary password - password reset required`));
441
+ MessageFormatter.warning(`User ${user.$id} created with temporary password - password reset required`, { prefix: "Transfer" });
442
442
  }
443
443
  }
444
444
  else {
@@ -446,7 +446,7 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
446
446
  const tempPassword = user.password || `changeMe${user.email}`;
447
447
  await tryAwaitWithRetry(async () => remoteUsers.create(user.$id, user.email, phone, tempPassword, user.name));
448
448
  if (!user.password) {
449
- console.log(chalk.yellow(`User ${user.$id} created with temporary password - password reset required`));
449
+ MessageFormatter.warning(`User ${user.$id} created with temporary password - password reset required`, { prefix: "Transfer" });
450
450
  }
451
451
  }
452
452
  // Update phone, labels, and other attributes for newly created users
@@ -471,10 +471,10 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
471
471
  await tryAwaitWithRetry(async () => remoteUsers.updateStatus(user.$id, false));
472
472
  }
473
473
  totalTransferred++;
474
- console.log(chalk.green(`Transferred user ${user.$id}`));
474
+ MessageFormatter.success(`Transferred user ${user.$id}`, { prefix: "Transfer" });
475
475
  }
476
476
  catch (error) {
477
- console.error(chalk.red(`Failed to transfer user ${user.$id}:`), error);
477
+ MessageFormatter.error(`Failed to transfer user ${user.$id}`, error instanceof Error ? error : new Error(String(error)), { prefix: "Transfer" });
478
478
  }
479
479
  }
480
480
  if (usersList.users.length < 100) {
@@ -482,5 +482,5 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
482
482
  }
483
483
  lastId = usersList.users[usersList.users.length - 1].$id;
484
484
  }
485
- console.log(chalk.green(`Successfully transferred ${totalTransferred} users`));
485
+ MessageFormatter.success(`Successfully transferred ${totalTransferred} users`, { prefix: "Transfer" });
486
486
  };
@@ -91,12 +91,14 @@ export declare class YamlImportConfigLoader {
91
91
  /**
92
92
  * Generates a template YAML import configuration.
93
93
  * Useful for getting started with YAML-based imports.
94
+ * Supports both collection and table terminology.
94
95
  *
95
96
  * @param collectionName - Name of the collection
96
97
  * @param sourceFile - Source data file name
98
+ * @param useTableTerminology - Whether to use table terminology
97
99
  * @returns YAML configuration template
98
100
  */
99
- generateTemplate(collectionName: string, sourceFile: string): string;
101
+ generateTemplate(collectionName: string, sourceFile: string, useTableTerminology?: boolean): string;
100
102
  /**
101
103
  * Creates the import directory structure if it doesn't exist.
102
104
  * Sets up the recommended directory layout for YAML import configurations.
@@ -185,12 +185,15 @@ export class YamlImportConfigLoader {
185
185
  /**
186
186
  * Generates a template YAML import configuration.
187
187
  * Useful for getting started with YAML-based imports.
188
+ * Supports both collection and table terminology.
188
189
  *
189
190
  * @param collectionName - Name of the collection
190
191
  * @param sourceFile - Source data file name
192
+ * @param useTableTerminology - Whether to use table terminology
191
193
  * @returns YAML configuration template
192
194
  */
193
- generateTemplate(collectionName, sourceFile) {
195
+ generateTemplate(collectionName, sourceFile, useTableTerminology = false) {
196
+ const entityType = useTableTerminology ? 'table' : 'collection';
194
197
  const template = {
195
198
  source: {
196
199
  file: `importData/${sourceFile}`,
@@ -198,7 +201,7 @@ export class YamlImportConfigLoader {
198
201
  type: "json"
199
202
  },
200
203
  target: {
201
- collection: collectionName,
204
+ [entityType]: collectionName,
202
205
  type: "create",
203
206
  primaryKey: "id",
204
207
  createUsers: false
@@ -240,7 +243,7 @@ export class YamlImportConfigLoader {
240
243
  {
241
244
  sourceField: "user_id",
242
245
  targetField: "userId",
243
- targetCollection: "Users"
246
+ [useTableTerminology ? 'targetTable' : 'targetCollection']: "Users"
244
247
  }
245
248
  ]
246
249
  },
@@ -43,19 +43,23 @@ export declare class YamlImportIntegration {
43
43
  /**
44
44
  * Generates a YAML import configuration from an existing ImportDef.
45
45
  * Useful for migrating TypeScript configurations to YAML.
46
+ * Supports both collection and table terminology.
46
47
  *
47
48
  * @param importDef - Existing ImportDef to convert
48
49
  * @param collectionName - Name of the collection
50
+ * @param useTableTerminology - Whether to use table terminology
49
51
  * @returns YAML configuration string
50
52
  */
51
- convertImportDefToYaml(importDef: ImportDef, collectionName: string): string;
53
+ convertImportDefToYaml(importDef: ImportDef, collectionName: string, useTableTerminology?: boolean): string;
52
54
  /**
53
55
  * Exports existing TypeScript import configurations to YAML files.
54
56
  * Helps migrate from TypeScript to YAML-based configurations.
57
+ * Supports both collection and table terminology.
55
58
  *
56
59
  * @param collections - Collections with existing import definitions
60
+ * @param useTableTerminology - Whether to use table terminology
57
61
  */
58
- exportToYaml(collections: CollectionCreate[]): Promise<void>;
62
+ exportToYaml(collections: CollectionCreate[], useTableTerminology?: boolean): Promise<void>;
59
63
  /**
60
64
  * Gets statistics about YAML import configurations.
61
65
  */
@@ -71,12 +75,14 @@ export declare class YamlImportIntegration {
71
75
  }>;
72
76
  /**
73
77
  * Creates a new YAML import configuration from a template.
78
+ * Supports both collection and table terminology.
74
79
  *
75
80
  * @param collectionName - Name of the collection
76
81
  * @param sourceFile - Source data file name
82
+ * @param useTableTerminology - Whether to use table terminology
77
83
  * @param outputPath - Output file path (optional)
78
84
  */
79
- createFromTemplate(collectionName: string, sourceFile: string, outputPath?: string): Promise<string>;
85
+ createFromTemplate(collectionName: string, sourceFile: string, useTableTerminology?: boolean, outputPath?: string): Promise<string>;
80
86
  /**
81
87
  * Checks if YAML import system is properly set up.
82
88
  */
@@ -1,6 +1,7 @@
1
1
  import { YamlImportConfigLoader } from "./YamlImportConfigLoader.js";
2
2
  import { createImportSchemas, createImportExamples } from "./generateImportSchemas.js";
3
3
  import { logger } from "../../shared/logging.js";
4
+ import { normalizeYamlData, usesTableTerminology, convertTerminology } from "../../utils/yamlConverter.js";
4
5
  import path from "path";
5
6
  import fs from "fs";
6
7
  /**
@@ -171,12 +172,14 @@ export class YamlImportIntegration {
171
172
  /**
172
173
  * Generates a YAML import configuration from an existing ImportDef.
173
174
  * Useful for migrating TypeScript configurations to YAML.
175
+ * Supports both collection and table terminology.
174
176
  *
175
177
  * @param importDef - Existing ImportDef to convert
176
178
  * @param collectionName - Name of the collection
179
+ * @param useTableTerminology - Whether to use table terminology
177
180
  * @returns YAML configuration string
178
181
  */
179
- convertImportDefToYaml(importDef, collectionName) {
182
+ convertImportDefToYaml(importDef, collectionName, useTableTerminology = false) {
180
183
  const yamlConfig = {
181
184
  source: {
182
185
  file: importDef.filePath,
@@ -228,15 +231,18 @@ export class YamlImportIntegration {
228
231
  lineWidth: 120,
229
232
  sortKeys: false,
230
233
  });
231
- return `# yaml-language-server: $schema=../.yaml_schemas/import-config.schema.json\n# Import Configuration for ${collectionName}\n\n${yamlContent}`;
234
+ const entityType = useTableTerminology ? 'Table' : 'Collection';
235
+ return `# yaml-language-server: $schema=../.yaml_schemas/import-config.schema.json\n# Import Configuration for ${entityType}: ${collectionName}\n\n${yamlContent}`;
232
236
  }
233
237
  /**
234
238
  * Exports existing TypeScript import configurations to YAML files.
235
239
  * Helps migrate from TypeScript to YAML-based configurations.
240
+ * Supports both collection and table terminology.
236
241
  *
237
242
  * @param collections - Collections with existing import definitions
243
+ * @param useTableTerminology - Whether to use table terminology
238
244
  */
239
- async exportToYaml(collections) {
245
+ async exportToYaml(collections, useTableTerminology = false) {
240
246
  const exportDir = path.join(this.appwriteFolderPath, "import", "exported");
241
247
  if (!fs.existsSync(exportDir)) {
242
248
  fs.mkdirSync(exportDir, { recursive: true });
@@ -248,10 +254,11 @@ export class YamlImportIntegration {
248
254
  }
249
255
  for (let i = 0; i < collection.importDefs.length; i++) {
250
256
  const importDef = collection.importDefs[i];
251
- const yamlContent = this.convertImportDefToYaml(importDef, collection.name);
257
+ const yamlContent = this.convertImportDefToYaml(importDef, collection.name, useTableTerminology);
258
+ const entityType = useTableTerminology ? 'table' : 'collection';
252
259
  const filename = collection.importDefs.length > 1
253
- ? `${collection.name}-${i + 1}.yaml`
254
- : `${collection.name}.yaml`;
260
+ ? `${collection.name}-${entityType}-${i + 1}.yaml`
261
+ : `${collection.name}-${entityType}.yaml`;
255
262
  const filePath = path.join(exportDir, filename);
256
263
  fs.writeFileSync(filePath, yamlContent);
257
264
  exportedCount++;
@@ -290,18 +297,22 @@ export class YamlImportIntegration {
290
297
  }
291
298
  /**
292
299
  * Creates a new YAML import configuration from a template.
300
+ * Supports both collection and table terminology.
293
301
  *
294
302
  * @param collectionName - Name of the collection
295
303
  * @param sourceFile - Source data file name
304
+ * @param useTableTerminology - Whether to use table terminology
296
305
  * @param outputPath - Output file path (optional)
297
306
  */
298
- async createFromTemplate(collectionName, sourceFile, outputPath) {
299
- const template = this.configLoader.generateTemplate(collectionName, sourceFile);
300
- const fileName = outputPath || `${collectionName.toLowerCase()}-import.yaml`;
307
+ async createFromTemplate(collectionName, sourceFile, useTableTerminology = false, outputPath) {
308
+ const template = this.configLoader.generateTemplate(collectionName, sourceFile, useTableTerminology);
309
+ const entityType = useTableTerminology ? 'table' : 'collection';
310
+ const fileName = outputPath || `${collectionName.toLowerCase()}-${entityType}-import.yaml`;
301
311
  const fullPath = path.join(this.appwriteFolderPath, "import", fileName);
302
- // Add schema reference to template
312
+ // Add schema reference to template with entity type comment
303
313
  const schemaHeader = "# yaml-language-server: $schema=../.yaml_schemas/import-config.schema.json\n";
304
- const templateWithSchema = schemaHeader + template;
314
+ const entityComment = `# Import Configuration for ${useTableTerminology ? 'Table' : 'Collection'}: ${collectionName}\n`;
315
+ const templateWithSchema = schemaHeader + entityComment + template;
305
316
  fs.writeFileSync(fullPath, templateWithSchema);
306
317
  logger.info(`Created YAML import configuration: ${fullPath}`);
307
318
  return fullPath;
@@ -4,7 +4,20 @@
4
4
  */
5
5
  export declare function generateImportConfigSchema(): any;
6
6
  /**
7
- * Creates all necessary schema files for YAML import configurations.
7
+ * Generates JSON Schema for collection definitions (legacy Databases API)
8
+ */
9
+ export declare function generateCollectionSchema(): any;
10
+ /**
11
+ * Generates JSON Schema for table definitions (new TablesDB API)
12
+ */
13
+ export declare function generateTableSchema(): any;
14
+ /**
15
+ * Generates JSON Schema for main Appwrite configuration (YAML format)
16
+ * Matches the structure of YamlConfigSchema from yamlConfig.ts
17
+ */
18
+ export declare function generateAppwriteConfigSchema(): any;
19
+ /**
20
+ * Creates all necessary schema files for YAML configurations.
8
21
  *
9
22
  * @param appwriteFolderPath - Path to the .appwrite directory
10
23
  */