appwrite-utils-cli 0.10.86 → 1.0.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/.appwrite/.yaml_schemas/appwrite-config.schema.json +380 -0
- package/.appwrite/.yaml_schemas/collection.schema.json +255 -0
- package/.appwrite/collections/Categories.yaml +182 -0
- package/.appwrite/collections/ExampleCollection.yaml +36 -0
- package/.appwrite/collections/Posts.yaml +227 -0
- package/.appwrite/collections/Users.yaml +149 -0
- package/.appwrite/config.yaml +109 -0
- package/.appwrite/import/README.md +148 -0
- package/.appwrite/import/categories-import.yaml +129 -0
- package/.appwrite/import/posts-import.yaml +208 -0
- package/.appwrite/import/users-import.yaml +130 -0
- package/.appwrite/importData/categories.json +194 -0
- package/.appwrite/importData/posts.json +270 -0
- package/.appwrite/importData/users.json +220 -0
- package/.appwrite/schemas/categories.json +128 -0
- package/.appwrite/schemas/exampleCollection.json +52 -0
- package/.appwrite/schemas/posts.json +173 -0
- package/.appwrite/schemas/users.json +125 -0
- package/README.md +260 -33
- package/dist/collections/attributes.js +3 -2
- package/dist/collections/methods.js +56 -38
- package/dist/config/yamlConfig.d.ts +501 -0
- package/dist/config/yamlConfig.js +452 -0
- package/dist/databases/setup.d.ts +6 -0
- package/dist/databases/setup.js +119 -0
- package/dist/functions/methods.d.ts +1 -1
- package/dist/functions/methods.js +5 -2
- package/dist/functions/openapi.d.ts +4 -0
- package/dist/functions/openapi.js +60 -0
- package/dist/interactiveCLI.d.ts +5 -0
- package/dist/interactiveCLI.js +194 -49
- package/dist/main.js +91 -30
- package/dist/migrations/afterImportActions.js +2 -2
- package/dist/migrations/appwriteToX.d.ts +10 -0
- package/dist/migrations/appwriteToX.js +15 -4
- package/dist/migrations/backup.d.ts +16 -16
- package/dist/migrations/dataLoader.d.ts +83 -1
- package/dist/migrations/dataLoader.js +4 -4
- package/dist/migrations/importController.js +25 -18
- package/dist/migrations/importDataActions.js +2 -2
- package/dist/migrations/logging.d.ts +9 -1
- package/dist/migrations/logging.js +41 -22
- package/dist/migrations/migrationHelper.d.ts +4 -4
- package/dist/migrations/relationships.js +1 -1
- package/dist/migrations/services/DataTransformationService.d.ts +55 -0
- package/dist/migrations/services/DataTransformationService.js +158 -0
- package/dist/migrations/services/FileHandlerService.d.ts +75 -0
- package/dist/migrations/services/FileHandlerService.js +236 -0
- package/dist/migrations/services/ImportOrchestrator.d.ts +97 -0
- package/dist/migrations/services/ImportOrchestrator.js +488 -0
- package/dist/migrations/services/RateLimitManager.d.ts +138 -0
- package/dist/migrations/services/RateLimitManager.js +279 -0
- package/dist/migrations/services/RelationshipResolver.d.ts +120 -0
- package/dist/migrations/services/RelationshipResolver.js +332 -0
- package/dist/migrations/services/UserMappingService.d.ts +109 -0
- package/dist/migrations/services/UserMappingService.js +277 -0
- package/dist/migrations/services/ValidationService.d.ts +74 -0
- package/dist/migrations/services/ValidationService.js +260 -0
- package/dist/migrations/transfer.d.ts +0 -6
- package/dist/migrations/transfer.js +16 -132
- package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +384 -0
- package/dist/migrations/yaml/YamlImportConfigLoader.js +375 -0
- package/dist/migrations/yaml/YamlImportIntegration.d.ts +87 -0
- package/dist/migrations/yaml/YamlImportIntegration.js +330 -0
- package/dist/migrations/yaml/generateImportSchemas.d.ts +17 -0
- package/dist/migrations/yaml/generateImportSchemas.js +575 -0
- package/dist/schemas/authUser.d.ts +9 -9
- package/dist/shared/attributeManager.d.ts +17 -0
- package/dist/shared/attributeManager.js +273 -0
- package/dist/shared/confirmationDialogs.d.ts +75 -0
- package/dist/shared/confirmationDialogs.js +236 -0
- package/dist/shared/functionManager.d.ts +48 -0
- package/dist/shared/functionManager.js +322 -0
- package/dist/shared/indexManager.d.ts +24 -0
- package/dist/shared/indexManager.js +150 -0
- package/dist/shared/jsonSchemaGenerator.d.ts +51 -0
- package/dist/shared/jsonSchemaGenerator.js +313 -0
- package/dist/shared/logging.d.ts +10 -0
- package/dist/shared/logging.js +46 -0
- package/dist/shared/messageFormatter.d.ts +37 -0
- package/dist/shared/messageFormatter.js +152 -0
- package/dist/shared/migrationHelpers.d.ts +173 -0
- package/dist/shared/migrationHelpers.js +142 -0
- package/dist/shared/operationLogger.d.ts +3 -0
- package/dist/shared/operationLogger.js +25 -0
- package/dist/shared/operationQueue.d.ts +13 -0
- package/dist/shared/operationQueue.js +79 -0
- package/dist/shared/progressManager.d.ts +62 -0
- package/dist/shared/progressManager.js +215 -0
- package/dist/shared/schemaGenerator.d.ts +18 -0
- package/dist/shared/schemaGenerator.js +523 -0
- package/dist/storage/methods.d.ts +3 -1
- package/dist/storage/methods.js +144 -55
- package/dist/storage/schemas.d.ts +56 -16
- package/dist/types.d.ts +2 -2
- package/dist/types.js +1 -1
- package/dist/users/methods.d.ts +16 -0
- package/dist/users/methods.js +276 -0
- package/dist/utils/configMigration.d.ts +1 -0
- package/dist/utils/configMigration.js +156 -0
- package/dist/utils/dataConverters.d.ts +46 -0
- package/dist/utils/dataConverters.js +139 -0
- package/dist/utils/loadConfigs.d.ts +15 -4
- package/dist/utils/loadConfigs.js +377 -51
- package/dist/utils/schemaStrings.js +2 -1
- package/dist/utils/setupFiles.d.ts +2 -1
- package/dist/utils/setupFiles.js +723 -28
- package/dist/utils/validationRules.d.ts +43 -0
- package/dist/utils/validationRules.js +42 -0
- package/dist/utils/yamlConverter.d.ts +48 -0
- package/dist/utils/yamlConverter.js +98 -0
- package/dist/utilsController.js +65 -43
- package/package.json +19 -15
- package/src/collections/attributes.ts +3 -2
- package/src/collections/methods.ts +85 -51
- package/src/config/yamlConfig.ts +488 -0
- package/src/{migrations/setupDatabase.ts → databases/setup.ts} +11 -5
- package/src/functions/methods.ts +8 -4
- package/src/functions/templates/count-docs-in-collection/package.json +25 -0
- package/src/functions/templates/count-docs-in-collection/tsconfig.json +28 -0
- package/src/functions/templates/typescript-node/package.json +24 -0
- package/src/functions/templates/typescript-node/tsconfig.json +28 -0
- package/src/functions/templates/uv/README.md +31 -0
- package/src/functions/templates/uv/pyproject.toml +29 -0
- package/src/interactiveCLI.ts +226 -61
- package/src/main.ts +111 -37
- package/src/migrations/afterImportActions.ts +2 -2
- package/src/migrations/appwriteToX.ts +17 -4
- package/src/migrations/dataLoader.ts +4 -4
- package/src/migrations/importController.ts +30 -22
- package/src/migrations/importDataActions.ts +2 -2
- package/src/migrations/relationships.ts +1 -1
- package/src/migrations/services/DataTransformationService.ts +196 -0
- package/src/migrations/services/FileHandlerService.ts +311 -0
- package/src/migrations/services/ImportOrchestrator.ts +669 -0
- package/src/migrations/services/RateLimitManager.ts +363 -0
- package/src/migrations/services/RelationshipResolver.ts +461 -0
- package/src/migrations/services/UserMappingService.ts +345 -0
- package/src/migrations/services/ValidationService.ts +349 -0
- package/src/migrations/transfer.ts +22 -228
- package/src/migrations/yaml/YamlImportConfigLoader.ts +427 -0
- package/src/migrations/yaml/YamlImportIntegration.ts +419 -0
- package/src/migrations/yaml/generateImportSchemas.ts +589 -0
- package/src/shared/attributeManager.ts +429 -0
- package/src/shared/confirmationDialogs.ts +327 -0
- package/src/shared/functionManager.ts +515 -0
- package/src/shared/indexManager.ts +253 -0
- package/src/shared/jsonSchemaGenerator.ts +403 -0
- package/src/shared/logging.ts +74 -0
- package/src/shared/messageFormatter.ts +195 -0
- package/src/{migrations/migrationHelper.ts → shared/migrationHelpers.ts} +22 -4
- package/src/{migrations/helper.ts → shared/operationLogger.ts} +7 -2
- package/src/{migrations/queue.ts → shared/operationQueue.ts} +1 -1
- package/src/shared/progressManager.ts +278 -0
- package/src/{migrations/schemaStrings.ts → shared/schemaGenerator.ts} +71 -17
- package/src/storage/methods.ts +199 -78
- package/src/types.ts +2 -2
- package/src/{migrations/users.ts → users/methods.ts} +2 -2
- package/src/utils/configMigration.ts +212 -0
- package/src/utils/loadConfigs.ts +414 -52
- package/src/utils/schemaStrings.ts +2 -1
- package/src/utils/setupFiles.ts +742 -40
- package/src/{migrations → utils}/validationRules.ts +1 -1
- package/src/utils/yamlConverter.ts +131 -0
- package/src/utilsController.ts +75 -54
- package/src/functions/templates/poetry/README.md +0 -30
- package/src/functions/templates/poetry/pyproject.toml +0 -16
- package/src/migrations/attributes.ts +0 -561
- package/src/migrations/backup.ts +0 -205
- package/src/migrations/databases.ts +0 -39
- package/src/migrations/dbHelpers.ts +0 -92
- package/src/migrations/indexes.ts +0 -40
- package/src/migrations/logging.ts +0 -29
- package/src/migrations/storage.ts +0 -538
- /package/src/{migrations → functions}/openapi.ts +0 -0
- /package/src/functions/templates/{poetry → uv}/src/__init__.py +0 -0
- /package/src/functions/templates/{poetry → uv}/src/index.py +0 -0
- /package/src/{migrations/converters.ts → utils/dataConverters.ts} +0 -0
@@ -7,10 +7,10 @@ import {
|
|
7
7
|
type Models,
|
8
8
|
} from "node-appwrite";
|
9
9
|
import type { AppwriteConfig, CollectionCreate, Indexes } from "appwrite-utils";
|
10
|
-
import { nameToIdMapping, processQueue } from "../
|
10
|
+
import { nameToIdMapping, processQueue } from "../shared/operationQueue.js";
|
11
11
|
import { createUpdateCollectionAttributes } from "./attributes.js";
|
12
12
|
import { createOrUpdateIndexes } from "./indexes.js";
|
13
|
-
import { SchemaGenerator } from "../
|
13
|
+
import { SchemaGenerator } from "../shared/schemaGenerator.js";
|
14
14
|
import {
|
15
15
|
isNull,
|
16
16
|
isUndefined,
|
@@ -21,6 +21,8 @@ import {
|
|
21
21
|
chunk,
|
22
22
|
} from "es-toolkit";
|
23
23
|
import { delay, tryAwaitWithRetry } from "../utils/helperFunctions.js";
|
24
|
+
import { MessageFormatter } from "../shared/messageFormatter.js";
|
25
|
+
import { ProgressManager } from "../shared/progressManager.js";
|
24
26
|
|
25
27
|
export const documentExists = async (
|
26
28
|
db: Databases,
|
@@ -88,20 +90,20 @@ export const checkForCollection = async (
|
|
88
90
|
collection: Partial<CollectionCreate>
|
89
91
|
): Promise<Models.Collection | null> => {
|
90
92
|
try {
|
91
|
-
|
93
|
+
MessageFormatter.progress(`Checking for collection with name: ${collection.name}`, { prefix: "Collections" });
|
92
94
|
const response = await tryAwaitWithRetry(
|
93
95
|
async () =>
|
94
96
|
await db.listCollections(dbId, [Query.equal("name", collection.name!)])
|
95
97
|
);
|
96
98
|
if (response.collections.length > 0) {
|
97
|
-
|
99
|
+
MessageFormatter.info(`Collection found: ${response.collections[0].$id}`, { prefix: "Collections" });
|
98
100
|
return { ...collection, ...response.collections[0] };
|
99
101
|
} else {
|
100
|
-
|
102
|
+
MessageFormatter.info(`No collection found with name: ${collection.name}`, { prefix: "Collections" });
|
101
103
|
return null;
|
102
104
|
}
|
103
105
|
} catch (error) {
|
104
|
-
|
106
|
+
MessageFormatter.error(`Error checking for collection: ${collection.name}`, error instanceof Error ? error : new Error(String(error)), { prefix: "Collections" });
|
105
107
|
return null;
|
106
108
|
}
|
107
109
|
};
|
@@ -114,23 +116,23 @@ export const fetchAndCacheCollectionByName = async (
|
|
114
116
|
): Promise<Models.Collection | undefined> => {
|
115
117
|
if (nameToIdMapping.has(collectionName)) {
|
116
118
|
const collectionId = nameToIdMapping.get(collectionName);
|
117
|
-
|
119
|
+
MessageFormatter.debug(`Collection found in cache: ${collectionId}`, undefined, { prefix: "Collections" });
|
118
120
|
return await tryAwaitWithRetry(
|
119
121
|
async () => await db.getCollection(dbId, collectionId!)
|
120
122
|
);
|
121
123
|
} else {
|
122
|
-
|
124
|
+
MessageFormatter.progress(`Fetching collection by name: ${collectionName}`, { prefix: "Collections" });
|
123
125
|
const collectionsPulled = await tryAwaitWithRetry(
|
124
126
|
async () =>
|
125
127
|
await db.listCollections(dbId, [Query.equal("name", collectionName)])
|
126
128
|
);
|
127
129
|
if (collectionsPulled.total > 0) {
|
128
130
|
const collection = collectionsPulled.collections[0];
|
129
|
-
|
131
|
+
MessageFormatter.info(`Collection found: ${collection.$id}`, { prefix: "Collections" });
|
130
132
|
nameToIdMapping.set(collectionName, collection.$id);
|
131
133
|
return collection;
|
132
134
|
} else {
|
133
|
-
|
135
|
+
MessageFormatter.warning(`Collection not found by name: ${collectionName}`, { prefix: "Collections" });
|
134
136
|
return undefined;
|
135
137
|
}
|
136
138
|
}
|
@@ -167,15 +169,27 @@ async function wipeDocumentsFromCollection(
|
|
167
169
|
? docsResponse.documents[docsResponse.documents.length - 1].$id
|
168
170
|
: undefined;
|
169
171
|
if (totalDocuments % 10000 === 0) {
|
170
|
-
|
172
|
+
MessageFormatter.progress(`Found ${totalDocuments} documents...`, { prefix: "Wipe" });
|
171
173
|
}
|
172
174
|
}
|
173
175
|
|
174
|
-
|
176
|
+
MessageFormatter.info(`Found ${totalDocuments} documents to delete`, { prefix: "Wipe" });
|
177
|
+
|
178
|
+
if (totalDocuments === 0) {
|
179
|
+
MessageFormatter.info("No documents to delete", { prefix: "Wipe" });
|
180
|
+
return;
|
181
|
+
}
|
182
|
+
|
183
|
+
// Create progress tracker for deletion
|
184
|
+
const progress = ProgressManager.create(
|
185
|
+
`delete-${collectionId}`,
|
186
|
+
totalDocuments,
|
187
|
+
{ title: "Deleting documents" }
|
188
|
+
);
|
175
189
|
|
176
190
|
const maxStackSize = 50; // Reduced batch size
|
177
191
|
const docBatches = chunk(documents, maxStackSize);
|
178
|
-
|
192
|
+
let documentsProcessed = 0;
|
179
193
|
|
180
194
|
for (let i = 0; i < docBatches.length; i++) {
|
181
195
|
const batch = docBatches[i];
|
@@ -184,6 +198,8 @@ async function wipeDocumentsFromCollection(
|
|
184
198
|
await tryAwaitWithRetry(async () =>
|
185
199
|
database.deleteDocument(databaseId, collectionId, doc.$id)
|
186
200
|
);
|
201
|
+
documentsProcessed++;
|
202
|
+
progress.update(documentsProcessed);
|
187
203
|
} catch (error: any) {
|
188
204
|
// Skip if document doesn't exist or other non-critical errors
|
189
205
|
if (
|
@@ -191,37 +207,33 @@ async function wipeDocumentsFromCollection(
|
|
191
207
|
"Document with the requested ID could not be found"
|
192
208
|
)
|
193
209
|
) {
|
194
|
-
|
195
|
-
`Failed to delete document ${doc.$id}
|
196
|
-
error.message
|
210
|
+
MessageFormatter.error(
|
211
|
+
`Failed to delete document ${doc.$id}`,
|
212
|
+
error.message,
|
213
|
+
{ prefix: "Wipe" }
|
197
214
|
);
|
198
215
|
}
|
216
|
+
documentsProcessed++;
|
217
|
+
progress.update(documentsProcessed);
|
199
218
|
}
|
200
219
|
});
|
201
220
|
|
202
221
|
await Promise.all(deletePromises);
|
203
222
|
await delay(50); // Increased delay between batches
|
204
223
|
|
205
|
-
//
|
206
|
-
if ((i + 1) % quarterBatchSize === 0 || i === docBatches.length - 1) {
|
207
|
-
const percentComplete = Math.round(((i + 1) / docBatches.length) * 100);
|
208
|
-
const documentsProcessed = Math.min(
|
209
|
-
(i + 1) * maxStackSize,
|
210
|
-
totalDocuments
|
211
|
-
);
|
212
|
-
console.log(
|
213
|
-
`Deleted ${documentsProcessed} documents (${percentComplete}% complete)`
|
214
|
-
);
|
215
|
-
}
|
224
|
+
// Progress is now handled by ProgressManager automatically
|
216
225
|
}
|
217
226
|
|
218
|
-
|
219
|
-
|
227
|
+
progress.stop();
|
228
|
+
MessageFormatter.success(
|
229
|
+
`Completed deletion of ${totalDocuments} documents from collection ${collectionId}`,
|
230
|
+
{ prefix: "Wipe" }
|
220
231
|
);
|
221
232
|
} catch (error) {
|
222
|
-
|
223
|
-
`Error wiping documents from collection ${collectionId}
|
224
|
-
error
|
233
|
+
MessageFormatter.error(
|
234
|
+
`Error wiping documents from collection ${collectionId}`,
|
235
|
+
error instanceof Error ? error : new Error(String(error)),
|
236
|
+
{ prefix: "Wipe" }
|
225
237
|
);
|
226
238
|
throw error;
|
227
239
|
}
|
@@ -231,12 +243,25 @@ export const wipeDatabase = async (
|
|
231
243
|
database: Databases,
|
232
244
|
databaseId: string
|
233
245
|
): Promise<{ collectionId: string; collectionName: string }[]> => {
|
234
|
-
|
246
|
+
MessageFormatter.info(`Wiping database: ${databaseId}`, { prefix: "Wipe" });
|
235
247
|
const existingCollections = await fetchAllCollections(databaseId, database);
|
236
248
|
let collectionsDeleted: { collectionId: string; collectionName: string }[] =
|
237
249
|
[];
|
250
|
+
|
251
|
+
if (existingCollections.length === 0) {
|
252
|
+
MessageFormatter.info("No collections to delete", { prefix: "Wipe" });
|
253
|
+
return collectionsDeleted;
|
254
|
+
}
|
255
|
+
|
256
|
+
const progress = ProgressManager.create(
|
257
|
+
`wipe-db-${databaseId}`,
|
258
|
+
existingCollections.length,
|
259
|
+
{ title: "Deleting collections" }
|
260
|
+
);
|
261
|
+
|
262
|
+
let processed = 0;
|
238
263
|
for (const { $id: collectionId, name: name } of existingCollections) {
|
239
|
-
|
264
|
+
MessageFormatter.progress(`Deleting collection: ${collectionId}`, { prefix: "Wipe" });
|
240
265
|
collectionsDeleted.push({
|
241
266
|
collectionId: collectionId,
|
242
267
|
collectionName: name,
|
@@ -244,8 +269,13 @@ export const wipeDatabase = async (
|
|
244
269
|
tryAwaitWithRetry(
|
245
270
|
async () => await database.deleteCollection(databaseId, collectionId)
|
246
271
|
); // Try to delete the collection and ignore errors if it doesn't exist or if it's already being deleted
|
272
|
+
processed++;
|
273
|
+
progress.update(processed);
|
247
274
|
await delay(100);
|
248
275
|
}
|
276
|
+
|
277
|
+
progress.stop();
|
278
|
+
MessageFormatter.success(`Deleted ${collectionsDeleted.length} collections from database`, { prefix: "Wipe" });
|
249
279
|
return collectionsDeleted;
|
250
280
|
};
|
251
281
|
|
@@ -258,7 +288,7 @@ export const wipeCollection = async (
|
|
258
288
|
Query.equal("$id", collectionId),
|
259
289
|
]);
|
260
290
|
if (collections.total === 0) {
|
261
|
-
|
291
|
+
MessageFormatter.warning(`Collection ${collectionId} not found`, { prefix: "Wipe" });
|
262
292
|
return;
|
263
293
|
}
|
264
294
|
const collection = collections.collections[0];
|
@@ -314,7 +344,7 @@ export const createOrUpdateCollections = async (
|
|
314
344
|
permissions.push(Permission.write(permission.target));
|
315
345
|
break;
|
316
346
|
default:
|
317
|
-
|
347
|
+
MessageFormatter.warning(`Unknown permission: ${permission.permission}`, { prefix: "Collections" });
|
318
348
|
break;
|
319
349
|
}
|
320
350
|
}
|
@@ -335,7 +365,7 @@ export const createOrUpdateCollections = async (
|
|
335
365
|
// Determine the correct ID for the collection
|
336
366
|
let collectionId: string;
|
337
367
|
if (!collectionToUse) {
|
338
|
-
|
368
|
+
MessageFormatter.info(`Creating collection: ${collectionData.name}`, { prefix: "Collections" });
|
339
369
|
let foundColl = deletedCollections?.find(
|
340
370
|
(coll) =>
|
341
371
|
coll.collectionName.toLowerCase().trim().replace(" ", "") ===
|
@@ -368,13 +398,15 @@ export const createOrUpdateCollections = async (
|
|
368
398
|
collectionData.$id = collectionToUse!.$id;
|
369
399
|
nameToIdMapping.set(collectionData.name, collectionToUse!.$id);
|
370
400
|
} catch (error) {
|
371
|
-
|
372
|
-
`Failed to create collection ${collectionData.name} with ID ${collectionId}
|
401
|
+
MessageFormatter.error(
|
402
|
+
`Failed to create collection ${collectionData.name} with ID ${collectionId}`,
|
403
|
+
error instanceof Error ? error : new Error(String(error)),
|
404
|
+
{ prefix: "Collections" }
|
373
405
|
);
|
374
406
|
continue;
|
375
407
|
}
|
376
408
|
} else {
|
377
|
-
|
409
|
+
MessageFormatter.info(`Collection ${collectionData.name} exists, updating it`, { prefix: "Collections" });
|
378
410
|
await tryAwaitWithRetry(
|
379
411
|
async () =>
|
380
412
|
await database.updateCollection(
|
@@ -392,7 +424,7 @@ export const createOrUpdateCollections = async (
|
|
392
424
|
await delay(250);
|
393
425
|
|
394
426
|
// Update attributes and indexes for the collection
|
395
|
-
|
427
|
+
MessageFormatter.progress("Creating Attributes", { prefix: "Collections" });
|
396
428
|
await createUpdateCollectionAttributes(
|
397
429
|
database,
|
398
430
|
databaseId,
|
@@ -410,7 +442,7 @@ export const createOrUpdateCollections = async (
|
|
410
442
|
: config.collections?.find((c) => c.$id === collectionToUse!.$id)
|
411
443
|
?.indexes ?? [];
|
412
444
|
|
413
|
-
|
445
|
+
MessageFormatter.progress("Creating Indexes", { prefix: "Collections" });
|
414
446
|
await createOrUpdateIndexes(
|
415
447
|
databaseId,
|
416
448
|
database,
|
@@ -432,7 +464,7 @@ export const generateMockData = async (
|
|
432
464
|
): Promise<void> => {
|
433
465
|
for (const { collection, mockFunction } of configCollections) {
|
434
466
|
if (mockFunction) {
|
435
|
-
|
467
|
+
MessageFormatter.progress(`Generating mock data for collection: ${collection.name}`, { prefix: "Mock Data" });
|
436
468
|
const mockData = mockFunction();
|
437
469
|
for (const data of mockData) {
|
438
470
|
await database.createDocument(
|
@@ -450,7 +482,7 @@ export const fetchAllCollections = async (
|
|
450
482
|
dbId: string,
|
451
483
|
database: Databases
|
452
484
|
): Promise<Models.Collection[]> => {
|
453
|
-
|
485
|
+
MessageFormatter.progress(`Fetching all collections for database ID: ${dbId}`, { prefix: "Collections" });
|
454
486
|
let collections: Models.Collection[] = [];
|
455
487
|
let moreCollections = true;
|
456
488
|
let lastCollectionId: string | undefined;
|
@@ -471,7 +503,7 @@ export const fetchAllCollections = async (
|
|
471
503
|
}
|
472
504
|
}
|
473
505
|
|
474
|
-
|
506
|
+
MessageFormatter.success(`Fetched a total of ${collections.length} collections`, { prefix: "Collections" });
|
475
507
|
return collections;
|
476
508
|
};
|
477
509
|
|
@@ -492,7 +524,7 @@ export const transferDocumentsBetweenDbsLocalToLocal = async (
|
|
492
524
|
let totalDocumentsTransferred = 0;
|
493
525
|
|
494
526
|
if (fromCollDocs.documents.length === 0) {
|
495
|
-
|
527
|
+
MessageFormatter.info(`No documents found in collection ${fromCollId}`, { prefix: "Transfer" });
|
496
528
|
return;
|
497
529
|
} else if (fromCollDocs.documents.length < 50) {
|
498
530
|
const batchedPromises = fromCollDocs.documents.map((doc) => {
|
@@ -577,8 +609,9 @@ export const transferDocumentsBetweenDbsLocalToLocal = async (
|
|
577
609
|
}
|
578
610
|
}
|
579
611
|
|
580
|
-
|
581
|
-
`Transferred ${totalDocumentsTransferred} documents from database ${fromDbId} to database ${toDbId} -- collection ${fromCollId} to collection ${toCollId}
|
612
|
+
MessageFormatter.success(
|
613
|
+
`Transferred ${totalDocumentsTransferred} documents from database ${fromDbId} to database ${toDbId} -- collection ${fromCollId} to collection ${toCollId}`,
|
614
|
+
{ prefix: "Transfer" }
|
582
615
|
);
|
583
616
|
};
|
584
617
|
|
@@ -603,7 +636,7 @@ export const transferDocumentsBetweenDbsLocalToRemote = async (
|
|
603
636
|
);
|
604
637
|
|
605
638
|
if (fromCollDocs.documents.length === 0) {
|
606
|
-
|
639
|
+
MessageFormatter.info(`No documents found in collection ${fromCollId}`, { prefix: "Transfer" });
|
607
640
|
return;
|
608
641
|
} else if (fromCollDocs.documents.length < 50) {
|
609
642
|
const batchedPromises = fromCollDocs.documents.map((doc) => {
|
@@ -684,7 +717,8 @@ export const transferDocumentsBetweenDbsLocalToRemote = async (
|
|
684
717
|
totalDocumentsTransferred += fromCollDocs.documents.length;
|
685
718
|
}
|
686
719
|
}
|
687
|
-
|
688
|
-
`Total documents transferred from database ${fromDbId} to database ${toDbId} -- collection ${fromCollId} to collection ${toCollId}: ${totalDocumentsTransferred}
|
720
|
+
MessageFormatter.success(
|
721
|
+
`Total documents transferred from database ${fromDbId} to database ${toDbId} -- collection ${fromCollId} to collection ${toCollId}: ${totalDocumentsTransferred}`,
|
722
|
+
{ prefix: "Transfer" }
|
689
723
|
);
|
690
724
|
};
|