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.
- package/CHANGELOG.md +199 -0
- package/README.md +251 -29
- package/dist/adapters/AdapterFactory.d.ts +10 -3
- package/dist/adapters/AdapterFactory.js +213 -17
- package/dist/adapters/TablesDBAdapter.js +60 -17
- package/dist/backups/operations/bucketBackup.d.ts +19 -0
- package/dist/backups/operations/bucketBackup.js +197 -0
- package/dist/backups/operations/collectionBackup.d.ts +30 -0
- package/dist/backups/operations/collectionBackup.js +201 -0
- package/dist/backups/operations/comprehensiveBackup.d.ts +25 -0
- package/dist/backups/operations/comprehensiveBackup.js +238 -0
- package/dist/backups/schemas/bucketManifest.d.ts +93 -0
- package/dist/backups/schemas/bucketManifest.js +33 -0
- package/dist/backups/schemas/comprehensiveManifest.d.ts +108 -0
- package/dist/backups/schemas/comprehensiveManifest.js +32 -0
- package/dist/backups/tracking/centralizedTracking.d.ts +34 -0
- package/dist/backups/tracking/centralizedTracking.js +274 -0
- package/dist/cli/commands/configCommands.d.ts +8 -0
- package/dist/cli/commands/configCommands.js +160 -0
- package/dist/cli/commands/databaseCommands.d.ts +13 -0
- package/dist/cli/commands/databaseCommands.js +479 -0
- package/dist/cli/commands/functionCommands.d.ts +7 -0
- package/dist/cli/commands/functionCommands.js +289 -0
- package/dist/cli/commands/schemaCommands.d.ts +7 -0
- package/dist/cli/commands/schemaCommands.js +134 -0
- package/dist/cli/commands/transferCommands.d.ts +5 -0
- package/dist/cli/commands/transferCommands.js +384 -0
- package/dist/collections/attributes.d.ts +5 -4
- package/dist/collections/attributes.js +539 -246
- package/dist/collections/indexes.js +39 -37
- package/dist/collections/methods.d.ts +2 -16
- package/dist/collections/methods.js +90 -538
- package/dist/collections/transferOperations.d.ts +7 -0
- package/dist/collections/transferOperations.js +331 -0
- package/dist/collections/wipeOperations.d.ts +16 -0
- package/dist/collections/wipeOperations.js +328 -0
- package/dist/config/configMigration.d.ts +87 -0
- package/dist/config/configMigration.js +390 -0
- package/dist/config/configValidation.d.ts +66 -0
- package/dist/config/configValidation.js +358 -0
- package/dist/config/yamlConfig.d.ts +455 -1
- package/dist/config/yamlConfig.js +145 -52
- package/dist/databases/methods.js +3 -2
- package/dist/databases/setup.d.ts +1 -2
- package/dist/databases/setup.js +9 -87
- package/dist/examples/yamlTerminologyExample.d.ts +42 -0
- package/dist/examples/yamlTerminologyExample.js +269 -0
- package/dist/functions/deployments.js +11 -10
- package/dist/functions/methods.d.ts +1 -1
- package/dist/functions/methods.js +5 -4
- package/dist/init.js +9 -9
- package/dist/interactiveCLI.d.ts +8 -17
- package/dist/interactiveCLI.js +209 -1172
- package/dist/main.js +364 -21
- package/dist/migrations/afterImportActions.js +22 -30
- package/dist/migrations/appwriteToX.js +71 -25
- package/dist/migrations/dataLoader.js +35 -26
- package/dist/migrations/importController.js +29 -30
- package/dist/migrations/relationships.js +13 -12
- package/dist/migrations/services/ImportOrchestrator.js +16 -19
- package/dist/migrations/transfer.js +46 -46
- package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +3 -1
- package/dist/migrations/yaml/YamlImportConfigLoader.js +6 -3
- package/dist/migrations/yaml/YamlImportIntegration.d.ts +9 -3
- package/dist/migrations/yaml/YamlImportIntegration.js +22 -11
- package/dist/migrations/yaml/generateImportSchemas.d.ts +14 -1
- package/dist/migrations/yaml/generateImportSchemas.js +736 -7
- package/dist/schemas/authUser.d.ts +1 -1
- package/dist/setupController.js +3 -2
- package/dist/shared/backupMetadataSchema.d.ts +94 -0
- package/dist/shared/backupMetadataSchema.js +38 -0
- package/dist/shared/backupTracking.d.ts +18 -0
- package/dist/shared/backupTracking.js +176 -0
- package/dist/shared/confirmationDialogs.js +15 -15
- package/dist/shared/errorUtils.d.ts +54 -0
- package/dist/shared/errorUtils.js +95 -0
- package/dist/shared/functionManager.js +20 -19
- package/dist/shared/indexManager.js +12 -11
- package/dist/shared/jsonSchemaGenerator.js +10 -26
- package/dist/shared/logging.d.ts +51 -0
- package/dist/shared/logging.js +70 -0
- package/dist/shared/messageFormatter.d.ts +2 -0
- package/dist/shared/messageFormatter.js +10 -0
- package/dist/shared/migrationHelpers.d.ts +6 -16
- package/dist/shared/migrationHelpers.js +24 -21
- package/dist/shared/operationLogger.d.ts +8 -1
- package/dist/shared/operationLogger.js +11 -24
- package/dist/shared/operationQueue.d.ts +28 -1
- package/dist/shared/operationQueue.js +268 -66
- package/dist/shared/operationsTable.d.ts +26 -0
- package/dist/shared/operationsTable.js +286 -0
- package/dist/shared/operationsTableSchema.d.ts +48 -0
- package/dist/shared/operationsTableSchema.js +35 -0
- package/dist/shared/relationshipExtractor.d.ts +56 -0
- package/dist/shared/relationshipExtractor.js +138 -0
- package/dist/shared/schemaGenerator.d.ts +19 -1
- package/dist/shared/schemaGenerator.js +56 -75
- package/dist/storage/backupCompression.d.ts +20 -0
- package/dist/storage/backupCompression.js +67 -0
- package/dist/storage/methods.d.ts +16 -2
- package/dist/storage/methods.js +98 -14
- package/dist/users/methods.js +9 -8
- package/dist/utils/configDiscovery.d.ts +78 -0
- package/dist/utils/configDiscovery.js +430 -0
- package/dist/utils/directoryUtils.d.ts +22 -0
- package/dist/utils/directoryUtils.js +59 -0
- package/dist/utils/getClientFromConfig.d.ts +17 -8
- package/dist/utils/getClientFromConfig.js +162 -17
- package/dist/utils/helperFunctions.d.ts +16 -2
- package/dist/utils/helperFunctions.js +19 -5
- package/dist/utils/loadConfigs.d.ts +34 -9
- package/dist/utils/loadConfigs.js +236 -316
- package/dist/utils/pathResolvers.d.ts +53 -0
- package/dist/utils/pathResolvers.js +72 -0
- package/dist/utils/projectConfig.d.ts +119 -0
- package/dist/utils/projectConfig.js +171 -0
- package/dist/utils/retryFailedPromises.js +4 -2
- package/dist/utils/sessionAuth.d.ts +48 -0
- package/dist/utils/sessionAuth.js +164 -0
- package/dist/utils/sessionPreservationExample.d.ts +1666 -0
- package/dist/utils/sessionPreservationExample.js +101 -0
- package/dist/utils/setupFiles.js +301 -41
- package/dist/utils/typeGuards.d.ts +35 -0
- package/dist/utils/typeGuards.js +57 -0
- package/dist/utils/versionDetection.js +145 -9
- package/dist/utils/yamlConverter.d.ts +53 -3
- package/dist/utils/yamlConverter.js +232 -13
- package/dist/utils/yamlLoader.d.ts +70 -0
- package/dist/utils/yamlLoader.js +263 -0
- package/dist/utilsController.d.ts +36 -3
- package/dist/utilsController.js +186 -56
- package/package.json +12 -2
- package/src/adapters/AdapterFactory.ts +263 -35
- package/src/adapters/TablesDBAdapter.ts +225 -36
- package/src/backups/operations/bucketBackup.ts +277 -0
- package/src/backups/operations/collectionBackup.ts +310 -0
- package/src/backups/operations/comprehensiveBackup.ts +342 -0
- package/src/backups/schemas/bucketManifest.ts +78 -0
- package/src/backups/schemas/comprehensiveManifest.ts +76 -0
- package/src/backups/tracking/centralizedTracking.ts +352 -0
- package/src/cli/commands/configCommands.ts +194 -0
- package/src/cli/commands/databaseCommands.ts +635 -0
- package/src/cli/commands/functionCommands.ts +379 -0
- package/src/cli/commands/schemaCommands.ts +163 -0
- package/src/cli/commands/transferCommands.ts +457 -0
- package/src/collections/attributes.ts +900 -621
- package/src/collections/attributes.ts.backup +1555 -0
- package/src/collections/indexes.ts +116 -114
- package/src/collections/methods.ts +295 -968
- package/src/collections/transferOperations.ts +516 -0
- package/src/collections/wipeOperations.ts +501 -0
- package/src/config/README.md +274 -0
- package/src/config/configMigration.ts +575 -0
- package/src/config/configValidation.ts +445 -0
- package/src/config/yamlConfig.ts +168 -55
- package/src/databases/methods.ts +3 -2
- package/src/databases/setup.ts +11 -138
- package/src/examples/yamlTerminologyExample.ts +341 -0
- package/src/functions/deployments.ts +14 -12
- package/src/functions/methods.ts +11 -11
- package/src/functions/templates/hono-typescript/README.md +286 -0
- package/src/functions/templates/hono-typescript/package.json +26 -0
- package/src/functions/templates/hono-typescript/src/adapters/request.ts +74 -0
- package/src/functions/templates/hono-typescript/src/adapters/response.ts +106 -0
- package/src/functions/templates/hono-typescript/src/app.ts +180 -0
- package/src/functions/templates/hono-typescript/src/context.ts +103 -0
- package/src/functions/templates/hono-typescript/src/index.ts +54 -0
- package/src/functions/templates/hono-typescript/src/middleware/appwrite.ts +119 -0
- package/src/functions/templates/hono-typescript/tsconfig.json +20 -0
- package/src/functions/templates/typescript-node/package.json +2 -1
- package/src/functions/templates/typescript-node/src/context.ts +103 -0
- package/src/functions/templates/typescript-node/src/index.ts +18 -12
- package/src/functions/templates/uv/pyproject.toml +1 -0
- package/src/functions/templates/uv/src/context.py +125 -0
- package/src/functions/templates/uv/src/index.py +35 -5
- package/src/init.ts +9 -11
- package/src/interactiveCLI.ts +274 -1563
- package/src/main.ts +418 -24
- package/src/migrations/afterImportActions.ts +71 -44
- package/src/migrations/appwriteToX.ts +100 -34
- package/src/migrations/dataLoader.ts +48 -34
- package/src/migrations/importController.ts +44 -39
- package/src/migrations/relationships.ts +28 -18
- package/src/migrations/services/ImportOrchestrator.ts +24 -27
- package/src/migrations/transfer.ts +159 -121
- package/src/migrations/yaml/YamlImportConfigLoader.ts +11 -4
- package/src/migrations/yaml/YamlImportIntegration.ts +47 -20
- package/src/migrations/yaml/generateImportSchemas.ts +751 -12
- package/src/setupController.ts +3 -2
- package/src/shared/backupMetadataSchema.ts +93 -0
- package/src/shared/backupTracking.ts +211 -0
- package/src/shared/confirmationDialogs.ts +19 -19
- package/src/shared/errorUtils.ts +110 -0
- package/src/shared/functionManager.ts +21 -20
- package/src/shared/indexManager.ts +12 -11
- package/src/shared/jsonSchemaGenerator.ts +38 -52
- package/src/shared/logging.ts +75 -0
- package/src/shared/messageFormatter.ts +14 -1
- package/src/shared/migrationHelpers.ts +45 -38
- package/src/shared/operationLogger.ts +11 -36
- package/src/shared/operationQueue.ts +322 -93
- package/src/shared/operationsTable.ts +338 -0
- package/src/shared/operationsTableSchema.ts +60 -0
- package/src/shared/relationshipExtractor.ts +214 -0
- package/src/shared/schemaGenerator.ts +179 -219
- package/src/storage/backupCompression.ts +88 -0
- package/src/storage/methods.ts +131 -34
- package/src/users/methods.ts +11 -9
- package/src/utils/configDiscovery.ts +502 -0
- package/src/utils/directoryUtils.ts +61 -0
- package/src/utils/getClientFromConfig.ts +205 -22
- package/src/utils/helperFunctions.ts +23 -5
- package/src/utils/loadConfigs.ts +313 -345
- package/src/utils/pathResolvers.ts +81 -0
- package/src/utils/projectConfig.ts +299 -0
- package/src/utils/retryFailedPromises.ts +4 -2
- package/src/utils/sessionAuth.ts +230 -0
- package/src/utils/setupFiles.ts +322 -54
- package/src/utils/typeGuards.ts +65 -0
- package/src/utils/versionDetection.ts +218 -64
- package/src/utils/yamlConverter.ts +296 -13
- package/src/utils/yamlLoader.ts +364 -0
- package/src/utilsController.ts +314 -110
- package/tests/README.md +497 -0
- package/tests/adapters/AdapterFactory.test.ts +277 -0
- package/tests/integration/syncOperations.test.ts +463 -0
- package/tests/jest.config.js +25 -0
- package/tests/migration/configMigration.test.ts +546 -0
- package/tests/setup.ts +62 -0
- package/tests/testUtils.ts +340 -0
- package/tests/utils/loadConfigs.test.ts +350 -0
- package/tests/validation/configValidation.test.ts +412 -0
- 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
|
-
|
262
|
-
|
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
|
-
|
267
|
-
|
268
|
-
|
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
|
-
|
275
|
-
|
276
|
-
|
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
|
-
|
292
|
-
|
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
|
-
|
312
|
+
MessageFormatter.success(
|
313
|
+
`Collection ${collection.name} updated`,
|
314
|
+
{ prefix: "Transfer" }
|
315
|
+
);
|
313
316
|
}
|
314
317
|
} else {
|
315
|
-
|
316
|
-
|
317
|
-
|
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
|
-
|
334
|
-
|
335
|
-
|
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
|
-
|
352
|
-
|
353
|
-
|
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
|
-
|
360
|
-
|
361
|
-
|
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
|
-
|
384
|
+
MessageFormatter.success(
|
385
|
+
`Index ${index.key} created`,
|
386
|
+
{ prefix: "Transfer" }
|
387
|
+
);
|
385
388
|
} else {
|
386
|
-
|
387
|
-
|
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
|
-
|
413
|
-
|
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
|
-
|
434
|
-
|
435
|
-
|
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
|
-
|
442
|
-
|
443
|
-
|
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
|
-
|
457
|
-
|
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
|
-
|
481
|
+
MessageFormatter.success(
|
482
|
+
`Collection ${collection.name} updated`,
|
483
|
+
{ prefix: "Transfer" }
|
484
|
+
);
|
478
485
|
}
|
479
486
|
} else {
|
480
|
-
|
481
|
-
|
482
|
-
|
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
|
-
|
499
|
-
|
500
|
-
|
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
|
-
|
518
|
-
|
519
|
-
|
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
|
-
|
525
|
-
|
526
|
-
|
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
|
-
|
533
|
-
|
534
|
-
|
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
|
-
|
548
|
-
|
549
|
-
|
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
|
-
|
555
|
-
|
556
|
-
|
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
|
-
|
577
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
735
|
+
MessageFormatter.info(
|
736
|
+
`User ${user.$id} is already up to date, skipping...`,
|
737
|
+
{ prefix: "Transfer" }
|
738
|
+
);
|
705
739
|
} else {
|
706
740
|
totalTransferred++;
|
707
|
-
|
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
|
-
|
777
|
-
|
778
|
-
|
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
|
-
|
818
|
-
|
819
|
-
|
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
|
-
|
890
|
-
|
891
|
-
|
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
|
-
|
906
|
-
|
907
|
-
|
908
|
-
)
|
939
|
+
MessageFormatter.success(
|
940
|
+
`User ${user.$id} created with preserved ${hashType} password`,
|
941
|
+
{ prefix: "Transfer" }
|
909
942
|
);
|
910
943
|
} catch (error) {
|
911
|
-
|
912
|
-
|
913
|
-
|
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
|
-
|
929
|
-
|
930
|
-
|
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
|
-
|
950
|
-
|
951
|
-
|
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
|
-
|
1028
|
+
MessageFormatter.success(
|
1029
|
+
`Transferred user ${user.$id}`,
|
1030
|
+
{ prefix: "Transfer" }
|
1031
|
+
);
|
999
1032
|
} catch (error) {
|
1000
|
-
|
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
|
-
|
1011
|
-
|
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(
|
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
|
-
|
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
|
},
|