appwrite-utils-cli 1.5.2 → 1.6.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.
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 +479 -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 +209 -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 +274 -1563
  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
@@ -258,23 +258,22 @@ export const transferDatabaseLocalToLocal = async (
258
258
  fromDbId: string,
259
259
  targetDbId: string
260
260
  ) => {
261
- console.log(
262
- chalk.blue(`Starting database transfer from ${fromDbId} to ${targetDbId}`)
261
+ MessageFormatter.info(
262
+ `Starting database transfer from ${fromDbId} to ${targetDbId}`,
263
+ { prefix: "Transfer" }
263
264
  );
264
265
  // Get all collections from source database
265
266
  const sourceCollections = await fetchAllCollections(fromDbId, localDb);
266
- console.log(
267
- chalk.blue(
268
- `Found ${sourceCollections.length} collections in source database`
269
- )
267
+ MessageFormatter.info(
268
+ `Found ${sourceCollections.length} collections in source database`,
269
+ { prefix: "Transfer" }
270
270
  );
271
271
 
272
272
  // Process each collection
273
273
  for (const collection of sourceCollections) {
274
- console.log(
275
- chalk.yellow(
276
- `Processing collection: ${collection.name} (${collection.$id})`
277
- )
274
+ MessageFormatter.processing(
275
+ `Processing collection: ${collection.name} (${collection.$id})`,
276
+ { prefix: "Transfer" }
278
277
  );
279
278
 
280
279
  try {
@@ -288,8 +287,9 @@ export const transferDatabaseLocalToLocal = async (
288
287
 
289
288
  if (existingCollection.collections.length > 0) {
290
289
  targetCollection = existingCollection.collections[0];
291
- console.log(
292
- chalk.green(`Collection ${collection.name} exists in target database`)
290
+ MessageFormatter.info(
291
+ `Collection ${collection.name} exists in target database`,
292
+ { prefix: "Transfer" }
293
293
  );
294
294
 
295
295
  // Update collection if needed
@@ -309,13 +309,15 @@ export const transferDatabaseLocalToLocal = async (
309
309
  collection.enabled
310
310
  )
311
311
  );
312
- console.log(chalk.green(`Collection ${collection.name} updated`));
312
+ MessageFormatter.success(
313
+ `Collection ${collection.name} updated`,
314
+ { prefix: "Transfer" }
315
+ );
313
316
  }
314
317
  } else {
315
- console.log(
316
- chalk.yellow(
317
- `Creating collection ${collection.name} in target database...`
318
- )
318
+ MessageFormatter.progress(
319
+ `Creating collection ${collection.name} in target database...`,
320
+ { prefix: "Transfer" }
319
321
  );
320
322
  targetCollection = await tryAwaitWithRetry(async () =>
321
323
  localDb.createCollection(
@@ -330,10 +332,9 @@ export const transferDatabaseLocalToLocal = async (
330
332
  }
331
333
 
332
334
  // Handle attributes with enhanced status checking
333
- console.log(
334
- chalk.blue(
335
- `Creating attributes for collection ${collection.name} with enhanced monitoring...`
336
- )
335
+ MessageFormatter.info(
336
+ `Creating attributes for collection ${collection.name} with enhanced monitoring...`,
337
+ { prefix: "Transfer" }
337
338
  );
338
339
 
339
340
  const allAttributes = collection.attributes.map((attr) =>
@@ -348,18 +349,17 @@ export const transferDatabaseLocalToLocal = async (
348
349
  );
349
350
 
350
351
  if (!attributeSuccess) {
351
- console.log(
352
- chalk.red(
353
- `❌ Failed to create all attributes for collection ${collection.name}, skipping to next collection`
354
- )
352
+ MessageFormatter.error(
353
+ `Failed to create all attributes for collection ${collection.name}, skipping to next collection`,
354
+ undefined,
355
+ { prefix: "Transfer" }
355
356
  );
356
357
  continue;
357
358
  }
358
359
 
359
- console.log(
360
- chalk.green(
361
- `✅ All attributes created successfully for collection ${collection.name}`
362
- )
360
+ MessageFormatter.success(
361
+ `All attributes created successfully for collection ${collection.name}`,
362
+ { prefix: "Transfer" }
363
363
  );
364
364
 
365
365
  // Handle indexes
@@ -381,10 +381,14 @@ export const transferDatabaseLocalToLocal = async (
381
381
  index as any
382
382
  )
383
383
  );
384
- console.log(chalk.green(`Index ${index.key} created`));
384
+ MessageFormatter.success(
385
+ `Index ${index.key} created`,
386
+ { prefix: "Transfer" }
387
+ );
385
388
  } else {
386
- console.log(
387
- chalk.blue(`Index ${index.key} exists, checking for updates...`)
389
+ MessageFormatter.info(
390
+ `Index ${index.key} exists, checking for updates...`,
391
+ { prefix: "Transfer" }
388
392
  );
389
393
  await tryAwaitWithRetry(async () =>
390
394
  createOrUpdateIndex(
@@ -409,9 +413,10 @@ export const transferDatabaseLocalToLocal = async (
409
413
  targetCollection.$id
410
414
  );
411
415
  } catch (error) {
412
- console.error(
413
- chalk.red(`Error processing collection ${collection.name}:`),
414
- error
416
+ MessageFormatter.error(
417
+ `Error processing collection ${collection.name}`,
418
+ error instanceof Error ? error : new Error(String(error)),
419
+ { prefix: "Transfer" }
415
420
  );
416
421
  }
417
422
  }
@@ -430,18 +435,16 @@ export const transferDatabaseLocalToRemote = async (
430
435
 
431
436
  // Get all collections from source database
432
437
  const sourceCollections = await fetchAllCollections(fromDbId, localDb);
433
- console.log(
434
- chalk.blue(
435
- `Found ${sourceCollections.length} collections in source database`
436
- )
438
+ MessageFormatter.info(
439
+ `Found ${sourceCollections.length} collections in source database`,
440
+ { prefix: "Transfer" }
437
441
  );
438
442
 
439
443
  // Process each collection
440
444
  for (const collection of sourceCollections) {
441
- console.log(
442
- chalk.yellow(
443
- `Processing collection: ${collection.name} (${collection.$id})`
444
- )
445
+ MessageFormatter.processing(
446
+ `Processing collection: ${collection.name} (${collection.$id})`,
447
+ { prefix: "Transfer" }
445
448
  );
446
449
 
447
450
  try {
@@ -453,8 +456,9 @@ export const transferDatabaseLocalToRemote = async (
453
456
 
454
457
  if (existingCollection.collections.length > 0) {
455
458
  targetCollection = existingCollection.collections[0];
456
- console.log(
457
- chalk.green(`Collection ${collection.name} exists in remote database`)
459
+ MessageFormatter.info(
460
+ `Collection ${collection.name} exists in remote database`,
461
+ { prefix: "Transfer" }
458
462
  );
459
463
 
460
464
  // Update collection if needed
@@ -474,13 +478,15 @@ export const transferDatabaseLocalToRemote = async (
474
478
  collection.enabled
475
479
  )
476
480
  );
477
- console.log(chalk.green(`Collection ${collection.name} updated`));
481
+ MessageFormatter.success(
482
+ `Collection ${collection.name} updated`,
483
+ { prefix: "Transfer" }
484
+ );
478
485
  }
479
486
  } else {
480
- console.log(
481
- chalk.yellow(
482
- `Creating collection ${collection.name} in remote database...`
483
- )
487
+ MessageFormatter.progress(
488
+ `Creating collection ${collection.name} in remote database...`,
489
+ { prefix: "Transfer" }
484
490
  );
485
491
  targetCollection = await tryAwaitWithRetry(async () =>
486
492
  remoteDb.createCollection(
@@ -495,10 +501,9 @@ export const transferDatabaseLocalToRemote = async (
495
501
  }
496
502
 
497
503
  // Handle attributes with enhanced status checking
498
- console.log(
499
- chalk.blue(
500
- `Creating attributes for collection ${collection.name} with enhanced monitoring...`
501
- )
504
+ MessageFormatter.info(
505
+ `Creating attributes for collection ${collection.name} with enhanced monitoring...`,
506
+ { prefix: "Transfer" }
502
507
  );
503
508
 
504
509
  const attributesToCreate = collection.attributes.map((attr) =>
@@ -514,25 +519,22 @@ export const transferDatabaseLocalToRemote = async (
514
519
  );
515
520
 
516
521
  if (!attributesSuccess) {
517
- console.log(
518
- chalk.red(
519
- `Failed to create some attributes for collection ${collection.name}`
520
- )
522
+ MessageFormatter.warning(
523
+ `Failed to create some attributes for collection ${collection.name}`,
524
+ { prefix: "Transfer" }
521
525
  );
522
526
  // Continue with the transfer even if some attributes failed
523
527
  } else {
524
- console.log(
525
- chalk.green(
526
- `All attributes created successfully for collection ${collection.name}`
527
- )
528
+ MessageFormatter.success(
529
+ `All attributes created successfully for collection ${collection.name}`,
530
+ { prefix: "Transfer" }
528
531
  );
529
532
  }
530
533
 
531
534
  // Handle indexes with enhanced status checking
532
- console.log(
533
- chalk.blue(
534
- `Creating indexes for collection ${collection.name} with enhanced monitoring...`
535
- )
535
+ MessageFormatter.info(
536
+ `Creating indexes for collection ${collection.name} with enhanced monitoring...`,
537
+ { prefix: "Transfer" }
536
538
  );
537
539
 
538
540
  const indexesSuccess = await createOrUpdateIndexesWithStatusCheck(
@@ -544,17 +546,15 @@ export const transferDatabaseLocalToRemote = async (
544
546
  );
545
547
 
546
548
  if (!indexesSuccess) {
547
- console.log(
548
- chalk.red(
549
- `Failed to create some indexes for collection ${collection.name}`
550
- )
549
+ MessageFormatter.warning(
550
+ `Failed to create some indexes for collection ${collection.name}`,
551
+ { prefix: "Transfer" }
551
552
  );
552
553
  // Continue with the transfer even if some indexes failed
553
554
  } else {
554
- console.log(
555
- chalk.green(
556
- `All indexes created successfully for collection ${collection.name}`
557
- )
555
+ MessageFormatter.success(
556
+ `All indexes created successfully for collection ${collection.name}`,
557
+ { prefix: "Transfer" }
558
558
  );
559
559
  }
560
560
 
@@ -573,9 +573,10 @@ export const transferDatabaseLocalToRemote = async (
573
573
  targetCollection.$id
574
574
  );
575
575
  } catch (error) {
576
- console.error(
577
- chalk.red(`Error processing collection ${collection.name}:`),
578
- error
576
+ MessageFormatter.error(
577
+ `Error processing collection ${collection.name}`,
578
+ error instanceof Error ? error : new Error(String(error)),
579
+ { prefix: "Transfer" }
579
580
  );
580
581
  }
581
582
  }
@@ -587,7 +588,10 @@ export const transferUsersLocalToRemote = async (
587
588
  projectId: string,
588
589
  apiKey: string
589
590
  ) => {
590
- console.log(chalk.blue("Starting user transfer to remote instance..."));
591
+ MessageFormatter.info(
592
+ "Starting user transfer to remote instance...",
593
+ { prefix: "Transfer" }
594
+ );
591
595
 
592
596
  const client = getClient(endpoint, projectId, apiKey);
593
597
  const remoteUsers = new Users(client);
@@ -620,7 +624,10 @@ export const transferUsersLocalToRemote = async (
620
624
 
621
625
  // If user exists, update only the differences
622
626
  if (remoteUser) {
623
- console.log(chalk.blue(`User ${user.$id} exists, checking for updates...`));
627
+ MessageFormatter.info(
628
+ `User ${user.$id} exists, checking for updates...`,
629
+ { prefix: "Transfer" }
630
+ );
624
631
  let hasUpdates = false;
625
632
 
626
633
  // Update name if different
@@ -628,7 +635,10 @@ export const transferUsersLocalToRemote = async (
628
635
  await tryAwaitWithRetry(async () =>
629
636
  remoteUsers.updateName(user.$id, user.name)
630
637
  );
631
- console.log(chalk.green(`Updated name for user ${user.$id}`));
638
+ MessageFormatter.success(
639
+ `Updated name for user ${user.$id}`,
640
+ { prefix: "Transfer" }
641
+ );
632
642
  hasUpdates = true;
633
643
  }
634
644
 
@@ -637,7 +647,10 @@ export const transferUsersLocalToRemote = async (
637
647
  await tryAwaitWithRetry(async () =>
638
648
  remoteUsers.updateEmail(user.$id, user.email)
639
649
  );
640
- console.log(chalk.green(`Updated email for user ${user.$id}`));
650
+ MessageFormatter.success(
651
+ `Updated email for user ${user.$id}`,
652
+ { prefix: "Transfer" }
653
+ );
641
654
  hasUpdates = true;
642
655
  }
643
656
 
@@ -651,7 +664,10 @@ export const transferUsersLocalToRemote = async (
651
664
  remoteUsers.updatePhone(user.$id, normalizedLocalPhone)
652
665
  );
653
666
  }
654
- console.log(chalk.green(`Updated phone for user ${user.$id}`));
667
+ MessageFormatter.success(
668
+ `Updated phone for user ${user.$id}`,
669
+ { prefix: "Transfer" }
670
+ );
655
671
  hasUpdates = true;
656
672
  }
657
673
 
@@ -660,7 +676,10 @@ export const transferUsersLocalToRemote = async (
660
676
  await tryAwaitWithRetry(async () =>
661
677
  remoteUsers.updatePrefs(user.$id, user.prefs)
662
678
  );
663
- console.log(chalk.green(`Updated preferences for user ${user.$id}`));
679
+ MessageFormatter.success(
680
+ `Updated preferences for user ${user.$id}`,
681
+ { prefix: "Transfer" }
682
+ );
664
683
  hasUpdates = true;
665
684
  }
666
685
 
@@ -669,7 +688,10 @@ export const transferUsersLocalToRemote = async (
669
688
  await tryAwaitWithRetry(async () =>
670
689
  remoteUsers.updateLabels(user.$id, user.labels)
671
690
  );
672
- console.log(chalk.green(`Updated labels for user ${user.$id}`));
691
+ MessageFormatter.success(
692
+ `Updated labels for user ${user.$id}`,
693
+ { prefix: "Transfer" }
694
+ );
673
695
  hasUpdates = true;
674
696
  }
675
697
 
@@ -678,7 +700,10 @@ export const transferUsersLocalToRemote = async (
678
700
  await tryAwaitWithRetry(async () =>
679
701
  remoteUsers.updateEmailVerification(user.$id, user.emailVerification)
680
702
  );
681
- console.log(chalk.green(`Updated email verification for user ${user.$id}`));
703
+ MessageFormatter.success(
704
+ `Updated email verification for user ${user.$id}`,
705
+ { prefix: "Transfer" }
706
+ );
682
707
  hasUpdates = true;
683
708
  }
684
709
 
@@ -687,7 +712,10 @@ export const transferUsersLocalToRemote = async (
687
712
  await tryAwaitWithRetry(async () =>
688
713
  remoteUsers.updatePhoneVerification(user.$id, user.phoneVerification)
689
714
  );
690
- console.log(chalk.green(`Updated phone verification for user ${user.$id}`));
715
+ MessageFormatter.success(
716
+ `Updated phone verification for user ${user.$id}`,
717
+ { prefix: "Transfer" }
718
+ );
691
719
  hasUpdates = true;
692
720
  }
693
721
 
@@ -696,15 +724,24 @@ export const transferUsersLocalToRemote = async (
696
724
  await tryAwaitWithRetry(async () =>
697
725
  remoteUsers.updateStatus(user.$id, user.status)
698
726
  );
699
- console.log(chalk.green(`Updated status for user ${user.$id}`));
727
+ MessageFormatter.success(
728
+ `Updated status for user ${user.$id}`,
729
+ { prefix: "Transfer" }
730
+ );
700
731
  hasUpdates = true;
701
732
  }
702
733
 
703
734
  if (!hasUpdates) {
704
- console.log(chalk.yellow(`User ${user.$id} is already up to date, skipping...`));
735
+ MessageFormatter.info(
736
+ `User ${user.$id} is already up to date, skipping...`,
737
+ { prefix: "Transfer" }
738
+ );
705
739
  } else {
706
740
  totalTransferred++;
707
- console.log(chalk.green(`Updated user ${user.$id}`));
741
+ MessageFormatter.success(
742
+ `Updated user ${user.$id}`,
743
+ { prefix: "Transfer" }
744
+ );
708
745
  }
709
746
  continue;
710
747
  }
@@ -773,10 +810,9 @@ export const transferUsersLocalToRemote = async (
773
810
  !hashOptions.salt ||
774
811
  typeof hashOptions.costCpu !== "number"
775
812
  ) {
776
- console.log(
777
- chalk.yellow(
778
- `User ${user.$id}: Using default Scrypt parameters due to missing hashOptions`
779
- )
813
+ MessageFormatter.warning(
814
+ `User ${user.$id}: Using default Scrypt parameters due to missing hashOptions`,
815
+ { prefix: "Transfer" }
780
816
  );
781
817
  }
782
818
 
@@ -814,10 +850,9 @@ export const transferUsersLocalToRemote = async (
814
850
  !hashOptions.saltSeparator ||
815
851
  !hashOptions.signerKey
816
852
  ) {
817
- console.log(
818
- chalk.yellow(
819
- `User ${user.$id}: Missing critical Scrypt Modified parameters in hashOptions`
820
- )
853
+ MessageFormatter.warning(
854
+ `User ${user.$id}: Missing critical Scrypt Modified parameters in hashOptions`,
855
+ { prefix: "Transfer" }
821
856
  );
822
857
  }
823
858
 
@@ -886,10 +921,9 @@ export const transferUsersLocalToRemote = async (
886
921
  break;
887
922
 
888
923
  default:
889
- console.log(
890
- chalk.yellow(
891
- `Unknown hash type '${hashType}' for user ${user.$id}, falling back to Argon2`
892
- )
924
+ MessageFormatter.warning(
925
+ `Unknown hash type '${hashType}' for user ${user.$id}, falling back to Argon2`,
926
+ { prefix: "Transfer" }
893
927
  );
894
928
  await tryAwaitWithRetry(async () =>
895
929
  remoteUsers.createArgon2User(
@@ -902,16 +936,14 @@ export const transferUsersLocalToRemote = async (
902
936
  break;
903
937
  }
904
938
 
905
- console.log(
906
- chalk.green(
907
- `User ${user.$id} created with preserved ${hashType} password`
908
- )
939
+ MessageFormatter.success(
940
+ `User ${user.$id} created with preserved ${hashType} password`,
941
+ { prefix: "Transfer" }
909
942
  );
910
943
  } catch (error) {
911
- console.log(
912
- chalk.yellow(
913
- `Failed to create user ${user.$id} with ${hashType} hash, trying with temporary password`
914
- )
944
+ MessageFormatter.warning(
945
+ `Failed to create user ${user.$id} with ${hashType} hash, trying with temporary password`,
946
+ { prefix: "Transfer" }
915
947
  );
916
948
 
917
949
  // Fallback to creating user with temporary password
@@ -925,10 +957,9 @@ export const transferUsersLocalToRemote = async (
925
957
  )
926
958
  );
927
959
 
928
- console.log(
929
- chalk.yellow(
930
- `User ${user.$id} created with temporary password - password reset required`
931
- )
960
+ MessageFormatter.warning(
961
+ `User ${user.$id} created with temporary password - password reset required`,
962
+ { prefix: "Transfer" }
932
963
  );
933
964
  }
934
965
  } else {
@@ -946,10 +977,9 @@ export const transferUsersLocalToRemote = async (
946
977
  );
947
978
 
948
979
  if (!user.password) {
949
- console.log(
950
- chalk.yellow(
951
- `User ${user.$id} created with temporary password - password reset required`
952
- )
980
+ MessageFormatter.warning(
981
+ `User ${user.$id} created with temporary password - password reset required`,
982
+ { prefix: "Transfer" }
953
983
  );
954
984
  }
955
985
  }
@@ -995,9 +1025,16 @@ export const transferUsersLocalToRemote = async (
995
1025
  }
996
1026
 
997
1027
  totalTransferred++;
998
- console.log(chalk.green(`Transferred user ${user.$id}`));
1028
+ MessageFormatter.success(
1029
+ `Transferred user ${user.$id}`,
1030
+ { prefix: "Transfer" }
1031
+ );
999
1032
  } catch (error) {
1000
- console.error(chalk.red(`Failed to transfer user ${user.$id}:`), error);
1033
+ MessageFormatter.error(
1034
+ `Failed to transfer user ${user.$id}`,
1035
+ error instanceof Error ? error : new Error(String(error)),
1036
+ { prefix: "Transfer" }
1037
+ );
1001
1038
  }
1002
1039
  }
1003
1040
 
@@ -1007,7 +1044,8 @@ export const transferUsersLocalToRemote = async (
1007
1044
  lastId = usersList.users[usersList.users.length - 1].$id;
1008
1045
  }
1009
1046
 
1010
- console.log(
1011
- chalk.green(`Successfully transferred ${totalTransferred} users`)
1047
+ MessageFormatter.success(
1048
+ `Successfully transferred ${totalTransferred} users`,
1049
+ { prefix: "Transfer" }
1012
1050
  );
1013
1051
  };
@@ -215,12 +215,19 @@ export class YamlImportConfigLoader {
215
215
  /**
216
216
  * Generates a template YAML import configuration.
217
217
  * Useful for getting started with YAML-based imports.
218
- *
218
+ * Supports both collection and table terminology.
219
+ *
219
220
  * @param collectionName - Name of the collection
220
221
  * @param sourceFile - Source data file name
222
+ * @param useTableTerminology - Whether to use table terminology
221
223
  * @returns YAML configuration template
222
224
  */
223
- generateTemplate(collectionName: string, sourceFile: string): string {
225
+ generateTemplate(
226
+ collectionName: string,
227
+ sourceFile: string,
228
+ useTableTerminology = false
229
+ ): string {
230
+ const entityType = useTableTerminology ? 'table' : 'collection';
224
231
  const template = {
225
232
  source: {
226
233
  file: `importData/${sourceFile}`,
@@ -228,7 +235,7 @@ export class YamlImportConfigLoader {
228
235
  type: "json"
229
236
  },
230
237
  target: {
231
- collection: collectionName,
238
+ [entityType]: collectionName,
232
239
  type: "create",
233
240
  primaryKey: "id",
234
241
  createUsers: false
@@ -270,7 +277,7 @@ export class YamlImportConfigLoader {
270
277
  {
271
278
  sourceField: "user_id",
272
279
  targetField: "userId",
273
- targetCollection: "Users"
280
+ [useTableTerminology ? 'targetTable' : 'targetCollection']: "Users"
274
281
  }
275
282
  ]
276
283
  },