appwrite-utils-cli 0.9.5 → 0.9.51
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/README.md +1 -0
- package/dist/interactiveCLI.js +28 -14
- package/dist/migrations/transfer.js +86 -52
- package/package.json +53 -53
- package/src/interactiveCLI.ts +41 -15
- package/src/migrations/transfer.ts +160 -95
- package/zlogs/announcements.json +397 -0
- package/zlogs/announcementscomments.json +36 -0
- package/zlogs/articles.json +138 -0
- package/zlogs/articlescomments.json +4 -0
- package/zlogs/businesscategories.json +7097 -0
- package/zlogs/contacts.json +517063 -0
- package/zlogs/contactscouncils.json +61905 -0
- package/zlogs/contactssociallinks.json +13776 -0
- package/zlogs/councils.json +5076 -0
- package/zlogs/documents.json +917 -0
- package/zlogs/emails.json +4 -0
- package/zlogs/events.json +132625 -0
- package/zlogs/knowledgebase.json +333 -0
- package/zlogs/knowledgebasecomments.json +4 -0
- package/zlogs/linkcategories.json +180 -0
- package/zlogs/links.json +4364 -0
- package/zlogs/memberrequests.json +83 -0
- package/zlogs/memberrequestscomments.json +65 -0
- package/zlogs/mergedUserMap.json +56 -0
- package/zlogs/oldIdToNewIdPerCollectionMap.json +27663 -0
- package/zlogs/regions.json +145 -0
- package/zlogs/testimonials.json +335 -0
- package/zlogs/users.json +25516 -0
package/README.md
CHANGED
@@ -124,6 +124,7 @@ This updated CLI ensures that developers have robust tools at their fingertips t
|
|
124
124
|
|
125
125
|
## Changelog
|
126
126
|
|
127
|
+
- 0.9.51: Fix transfer databases, remove "ensure duplicates" check
|
127
128
|
- 0.9.5: Fixed not checking for storage bucket for each database (checking the creation status) when importing data
|
128
129
|
- 0.9.4: Fixed migrations database ensuring it has the required collections
|
129
130
|
- 0.9.3: Fixed deployment error && fix lack of existing `appwriteConfig.ts` file from causing error (you want to be able to setup yeah? haha)
|
package/dist/interactiveCLI.js
CHANGED
@@ -416,14 +416,14 @@ export class InteractiveCLI {
|
|
416
416
|
default: false,
|
417
417
|
},
|
418
418
|
]);
|
419
|
-
const { checkDuplicates } = await inquirer.prompt([
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
]);
|
419
|
+
// const { checkDuplicates } = await inquirer.prompt([
|
420
|
+
// {
|
421
|
+
// type: "confirm",
|
422
|
+
// name: "checkDuplicates",
|
423
|
+
// message: "Do you want to check for duplicates during import?",
|
424
|
+
// default: true,
|
425
|
+
// },
|
426
|
+
// ]);
|
427
427
|
console.log("Importing data...");
|
428
428
|
await this.controller.importData({
|
429
429
|
databases: selectedDatabases,
|
@@ -431,7 +431,8 @@ export class InteractiveCLI {
|
|
431
431
|
? selectedCollections.map((c) => c.$id)
|
432
432
|
: undefined,
|
433
433
|
shouldWriteFile,
|
434
|
-
checkDuplicates,
|
434
|
+
checkDuplicates: false,
|
435
|
+
// checkDuplicates,
|
435
436
|
});
|
436
437
|
}
|
437
438
|
async transferData() {
|
@@ -476,10 +477,21 @@ export class InteractiveCLI {
|
|
476
477
|
}
|
477
478
|
else {
|
478
479
|
targetClient = sourceClient;
|
479
|
-
|
480
|
+
const allDatabases = await fetchAllDatabases(sourceClient);
|
481
|
+
sourceDatabases = targetDatabases = allDatabases;
|
482
|
+
}
|
483
|
+
const fromDbs = await this.selectDatabases(sourceDatabases, "Select the source database:", false);
|
484
|
+
console.log(fromDbs);
|
485
|
+
const fromDb = fromDbs;
|
486
|
+
if (!fromDb) {
|
487
|
+
throw new Error("No source database selected");
|
488
|
+
}
|
489
|
+
const availableDbs = targetDatabases.filter((db) => db.$id !== fromDb.$id);
|
490
|
+
const targetDbs = await this.selectDatabases(availableDbs, "Select the target database:", false);
|
491
|
+
const targetDb = targetDbs;
|
492
|
+
if (!targetDb) {
|
493
|
+
throw new Error("No target database selected");
|
480
494
|
}
|
481
|
-
const [fromDb] = await this.selectDatabases(sourceDatabases, "Select the source database:", false);
|
482
|
-
const [targetDb] = await this.selectDatabases(targetDatabases.filter((db) => db.$id !== fromDb.$id), "Select the target database:", false);
|
483
495
|
const selectedCollections = await this.selectCollections(fromDb, sourceClient, "Select collections to transfer):");
|
484
496
|
const { transferStorage } = await inquirer.prompt([
|
485
497
|
{
|
@@ -499,8 +511,10 @@ export class InteractiveCLI {
|
|
499
511
|
const targetBuckets = isRemote
|
500
512
|
? await listBuckets(targetStorage)
|
501
513
|
: sourceBuckets;
|
502
|
-
|
503
|
-
|
514
|
+
const sourceBucketPicked = await this.selectBuckets(sourceBuckets.buckets, "Select the source bucket:", false);
|
515
|
+
const targetBucketPicked = await this.selectBuckets(targetBuckets.buckets, "Select the target bucket:", false);
|
516
|
+
sourceBucket = sourceBucketPicked;
|
517
|
+
targetBucket = targetBucketPicked;
|
504
518
|
}
|
505
519
|
let transferOptions = {
|
506
520
|
fromDb,
|
@@ -100,14 +100,26 @@ export const transferStorageLocalToRemote = async (localStorage, endpoint, proje
|
|
100
100
|
* within the same Appwrite Project
|
101
101
|
*/
|
102
102
|
export const transferDocumentsBetweenDbsLocalToLocal = async (db, fromDbId, toDbId, fromCollId, toCollId) => {
|
103
|
-
let fromCollDocs = await tryAwaitWithRetry(async () => db.listDocuments(fromDbId, fromCollId, [Query.limit(50)]));
|
104
103
|
let totalDocumentsTransferred = 0;
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
let lastDocumentId;
|
105
|
+
let hasMoreDocuments = true;
|
106
|
+
while (hasMoreDocuments) {
|
107
|
+
const queryParams = [Query.limit(50)];
|
108
|
+
if (lastDocumentId) {
|
109
|
+
queryParams.push(Query.cursorAfter(lastDocumentId));
|
110
|
+
}
|
111
|
+
const fromCollDocs = await tryAwaitWithRetry(async () => db.listDocuments(fromDbId, fromCollId, queryParams));
|
112
|
+
if (fromCollDocs.documents.length === 0) {
|
113
|
+
if (totalDocumentsTransferred === 0) {
|
114
|
+
console.log(`No documents found in collection ${fromCollId}`);
|
115
|
+
}
|
116
|
+
break;
|
117
|
+
}
|
118
|
+
const allDocsToCreateCheck = await tryAwaitWithRetry(async () => await db.listDocuments(toDbId, toCollId, [
|
119
|
+
Query.equal("$id", fromCollDocs.documents.map((doc) => doc.$id)),
|
120
|
+
]));
|
121
|
+
const docsToCreate = fromCollDocs.documents.filter((doc) => !allDocsToCreateCheck.documents.some((d) => d.$id === doc.$id));
|
122
|
+
const batchedPromises = docsToCreate.map((doc) => {
|
111
123
|
const toCreateObject = {
|
112
124
|
...doc,
|
113
125
|
};
|
@@ -120,42 +132,13 @@ export const transferDocumentsBetweenDbsLocalToLocal = async (db, fromDbId, toDb
|
|
120
132
|
return tryAwaitWithRetry(async () => await db.createDocument(toDbId, toCollId, doc.$id, toCreateObject, doc.$permissions));
|
121
133
|
});
|
122
134
|
await Promise.all(batchedPromises);
|
123
|
-
totalDocumentsTransferred +=
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
delete toCreateObject.$databaseId;
|
131
|
-
delete toCreateObject.$collectionId;
|
132
|
-
delete toCreateObject.$createdAt;
|
133
|
-
delete toCreateObject.$updatedAt;
|
134
|
-
delete toCreateObject.$id;
|
135
|
-
delete toCreateObject.$permissions;
|
136
|
-
return tryAwaitWithRetry(async () => db.createDocument(toDbId, toCollId, doc.$id, toCreateObject, doc.$permissions));
|
137
|
-
});
|
138
|
-
await Promise.all(batchedPromises);
|
139
|
-
totalDocumentsTransferred += fromCollDocs.documents.length;
|
140
|
-
while (fromCollDocs.documents.length === 50) {
|
141
|
-
fromCollDocs = await tryAwaitWithRetry(async () => await db.listDocuments(fromDbId, fromCollId, [
|
142
|
-
Query.limit(50),
|
143
|
-
Query.cursorAfter(fromCollDocs.documents[fromCollDocs.documents.length - 1].$id),
|
144
|
-
]));
|
145
|
-
const batchedPromises = fromCollDocs.documents.map((doc) => {
|
146
|
-
const toCreateObject = {
|
147
|
-
...doc,
|
148
|
-
};
|
149
|
-
delete toCreateObject.$databaseId;
|
150
|
-
delete toCreateObject.$collectionId;
|
151
|
-
delete toCreateObject.$createdAt;
|
152
|
-
delete toCreateObject.$updatedAt;
|
153
|
-
delete toCreateObject.$id;
|
154
|
-
delete toCreateObject.$permissions;
|
155
|
-
return tryAwaitWithRetry(async () => await db.createDocument(toDbId, toCollId, doc.$id, toCreateObject, doc.$permissions));
|
156
|
-
});
|
157
|
-
await Promise.all(batchedPromises);
|
158
|
-
totalDocumentsTransferred += fromCollDocs.documents.length;
|
135
|
+
totalDocumentsTransferred += docsToCreate.length;
|
136
|
+
if (fromCollDocs.documents.length < 50) {
|
137
|
+
hasMoreDocuments = false;
|
138
|
+
}
|
139
|
+
else {
|
140
|
+
lastDocumentId =
|
141
|
+
fromCollDocs.documents[fromCollDocs.documents.length - 1].$id;
|
159
142
|
}
|
160
143
|
}
|
161
144
|
console.log(`Transferred ${totalDocumentsTransferred} documents from database ${fromDbId} to database ${toDbId} -- collection ${fromCollId} to collection ${toCollId}`);
|
@@ -173,7 +156,11 @@ export const transferDocumentsBetweenDbsLocalToRemote = async (localDb, endpoint
|
|
173
156
|
return;
|
174
157
|
}
|
175
158
|
else if (fromCollDocs.documents.length < 50) {
|
176
|
-
const
|
159
|
+
const allDocsToCreateCheck = await tryAwaitWithRetry(async () => await remoteDb.listDocuments(toDbId, toCollId, [
|
160
|
+
Query.equal("$id", fromCollDocs.documents.map((doc) => doc.$id)),
|
161
|
+
]));
|
162
|
+
const docsToCreate = fromCollDocs.documents.filter((doc) => !allDocsToCreateCheck.documents.some((d) => d.$id === doc.$id));
|
163
|
+
const batchedPromises = docsToCreate.map((doc) => {
|
177
164
|
const toCreateObject = {
|
178
165
|
...doc,
|
179
166
|
};
|
@@ -189,7 +176,11 @@ export const transferDocumentsBetweenDbsLocalToRemote = async (localDb, endpoint
|
|
189
176
|
totalDocumentsTransferred += fromCollDocs.documents.length;
|
190
177
|
}
|
191
178
|
else {
|
192
|
-
const
|
179
|
+
const allDocsToCreateCheck = await tryAwaitWithRetry(async () => await remoteDb.listDocuments(toDbId, toCollId, [
|
180
|
+
Query.equal("$id", fromCollDocs.documents.map((doc) => doc.$id)),
|
181
|
+
]));
|
182
|
+
const docsToCreate = fromCollDocs.documents.filter((doc) => !allDocsToCreateCheck.documents.some((d) => d.$id === doc.$id));
|
183
|
+
const batchedPromises = docsToCreate.map((doc) => {
|
193
184
|
const toCreateObject = {
|
194
185
|
...doc,
|
195
186
|
};
|
@@ -305,9 +296,7 @@ export const transferDatabaseLocalToRemote = async (localDb, endpoint, projectId
|
|
305
296
|
let lastCollectionId;
|
306
297
|
let fromCollections = await tryAwaitWithRetry(async () => await localDb.listCollections(fromDbId, [Query.limit(50)]));
|
307
298
|
const allFromCollections = fromCollections.collections;
|
308
|
-
if (fromCollections.collections.length
|
309
|
-
}
|
310
|
-
else {
|
299
|
+
if (fromCollections.collections.length >= 50) {
|
311
300
|
lastCollectionId =
|
312
301
|
fromCollections.collections[fromCollections.collections.length - 1].$id;
|
313
302
|
while (lastCollectionId) {
|
@@ -324,13 +313,58 @@ export const transferDatabaseLocalToRemote = async (localDb, endpoint, projectId
|
|
324
313
|
}
|
325
314
|
}
|
326
315
|
for (const collection of allFromCollections) {
|
327
|
-
|
328
|
-
|
316
|
+
let toCollection;
|
317
|
+
const toCollectionExists = await tryAwaitWithRetry(async () => await remoteDb.listCollections(toDbId, [
|
318
|
+
Query.equal("$id", collection.$id),
|
319
|
+
]));
|
320
|
+
if (toCollectionExists.collections.length > 0) {
|
321
|
+
console.log(`Collection ${collection.name} already exists. Updating...`);
|
322
|
+
toCollection = toCollectionExists.collections[0];
|
323
|
+
// Update collection if needed
|
324
|
+
if (toCollection.name !== collection.name ||
|
325
|
+
toCollection.$permissions !== collection.$permissions ||
|
326
|
+
toCollection.documentSecurity !== collection.documentSecurity ||
|
327
|
+
toCollection.enabled !== collection.enabled) {
|
328
|
+
toCollection = await tryAwaitWithRetry(async () => await remoteDb.updateCollection(toDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
|
329
|
+
console.log(`Collection ${toCollection.name} updated`);
|
330
|
+
}
|
331
|
+
}
|
332
|
+
else {
|
333
|
+
toCollection = await tryAwaitWithRetry(async () => await remoteDb.createCollection(toDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
|
334
|
+
console.log(`Collection ${toCollection.name} created`);
|
335
|
+
}
|
336
|
+
// Check and update attributes
|
337
|
+
const existingAttributes = await tryAwaitWithRetry(async () => await remoteDb.listAttributes(toDbId, toCollection.$id));
|
329
338
|
for (const attribute of collection.attributes) {
|
330
|
-
|
339
|
+
const parsedAttribute = parseAttribute(attribute);
|
340
|
+
const existingAttribute = existingAttributes.attributes.find(
|
341
|
+
// @ts-expect-error
|
342
|
+
(attr) => attr.key === parsedAttribute.key);
|
343
|
+
if (!existingAttribute) {
|
344
|
+
await tryAwaitWithRetry(async () => await createOrUpdateAttribute(remoteDb, toDbId, toCollection, parsedAttribute));
|
345
|
+
console.log(`Attribute ${parsedAttribute.key} created`);
|
346
|
+
}
|
347
|
+
else {
|
348
|
+
// Check if attribute needs updating
|
349
|
+
// Note: Appwrite doesn't allow updating most attribute properties
|
350
|
+
// You might need to delete and recreate the attribute if significant changes are needed
|
351
|
+
console.log(`Attribute ${parsedAttribute.key} already exists`);
|
352
|
+
}
|
331
353
|
}
|
354
|
+
// Check and update indexes
|
355
|
+
const existingIndexes = await tryAwaitWithRetry(async () => await remoteDb.listIndexes(toDbId, toCollection.$id));
|
332
356
|
for (const index of collection.indexes) {
|
333
|
-
|
357
|
+
const existingIndex = existingIndexes.indexes.find((idx) => idx.key === index.key);
|
358
|
+
if (!existingIndex) {
|
359
|
+
await tryAwaitWithRetry(async () => await remoteDb.createIndex(toDbId, toCollection.$id, index.key, index.type, index.attributes, index.orders));
|
360
|
+
console.log(`Index ${index.key} created`);
|
361
|
+
}
|
362
|
+
else {
|
363
|
+
// Check if index needs updating
|
364
|
+
// Note: Appwrite doesn't allow updating indexes
|
365
|
+
// You might need to delete and recreate the index if changes are needed
|
366
|
+
console.log(`Index ${index.key} already exists`);
|
367
|
+
}
|
334
368
|
}
|
335
369
|
await transferDocumentsBetweenDbsLocalToRemote(localDb, endpoint, projectId, apiKey, fromDbId, toDbId, collection.$id, toCollection.$id);
|
336
370
|
}
|
package/package.json
CHANGED
@@ -1,53 +1,53 @@
|
|
1
|
-
{
|
2
|
-
"name": "appwrite-utils-cli",
|
3
|
-
"description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
|
4
|
-
"version": "0.9.
|
5
|
-
"main": "src/main.ts",
|
6
|
-
"type": "module",
|
7
|
-
"repository": {
|
8
|
-
"type": "git",
|
9
|
-
"url": "https://github.com/zachhandley/AppwriteUtils"
|
10
|
-
},
|
11
|
-
"author": "Zach Handley <zach@blackleafdigital.com> (https://zachhandley.com)",
|
12
|
-
"keywords": [
|
13
|
-
"appwrite",
|
14
|
-
"cli",
|
15
|
-
"utils",
|
16
|
-
"migrations",
|
17
|
-
"data",
|
18
|
-
"database",
|
19
|
-
"import",
|
20
|
-
"migration",
|
21
|
-
"utility"
|
22
|
-
],
|
23
|
-
"bin": {
|
24
|
-
"appwrite-migrate": "./dist/main.js"
|
25
|
-
},
|
26
|
-
"scripts": {
|
27
|
-
"build": "bun run tsc",
|
28
|
-
"start": "tsx --no-cache src/main.ts",
|
29
|
-
"deploy": "bun run build && npm publish --access public",
|
30
|
-
"postinstall": "echo 'This package is intended for CLI use only and should not be added as a dependency in other projects.'"
|
31
|
-
},
|
32
|
-
"dependencies": {
|
33
|
-
"@types/inquirer": "^9.0.7",
|
34
|
-
"appwrite-utils": "^0.3.8",
|
35
|
-
"commander": "^12.1.0",
|
36
|
-
"inquirer": "^9.3.6",
|
37
|
-
"js-yaml": "^4.1.0",
|
38
|
-
"lodash": "^4.17.21",
|
39
|
-
"luxon": "^3.5.0",
|
40
|
-
"nanostores": "^0.10.3",
|
41
|
-
"node-appwrite": "^13.0.0",
|
42
|
-
"tsx": "^4.17.0",
|
43
|
-
"ulidx": "^2.4.0",
|
44
|
-
"winston": "^3.14.
|
45
|
-
"zod": "^3.23.8"
|
46
|
-
},
|
47
|
-
"devDependencies": {
|
48
|
-
"@types/js-yaml": "^4.0.9",
|
49
|
-
"@types/lodash": "^4.17.7",
|
50
|
-
"@types/luxon": "^3.4.2",
|
51
|
-
"typescript": "^5.5.4"
|
52
|
-
}
|
53
|
-
}
|
1
|
+
{
|
2
|
+
"name": "appwrite-utils-cli",
|
3
|
+
"description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
|
4
|
+
"version": "0.9.51",
|
5
|
+
"main": "src/main.ts",
|
6
|
+
"type": "module",
|
7
|
+
"repository": {
|
8
|
+
"type": "git",
|
9
|
+
"url": "https://github.com/zachhandley/AppwriteUtils"
|
10
|
+
},
|
11
|
+
"author": "Zach Handley <zach@blackleafdigital.com> (https://zachhandley.com)",
|
12
|
+
"keywords": [
|
13
|
+
"appwrite",
|
14
|
+
"cli",
|
15
|
+
"utils",
|
16
|
+
"migrations",
|
17
|
+
"data",
|
18
|
+
"database",
|
19
|
+
"import",
|
20
|
+
"migration",
|
21
|
+
"utility"
|
22
|
+
],
|
23
|
+
"bin": {
|
24
|
+
"appwrite-migrate": "./dist/main.js"
|
25
|
+
},
|
26
|
+
"scripts": {
|
27
|
+
"build": "bun run tsc",
|
28
|
+
"start": "tsx --no-cache src/main.ts",
|
29
|
+
"deploy": "bun run build && npm publish --access public",
|
30
|
+
"postinstall": "echo 'This package is intended for CLI use only and should not be added as a dependency in other projects.'"
|
31
|
+
},
|
32
|
+
"dependencies": {
|
33
|
+
"@types/inquirer": "^9.0.7",
|
34
|
+
"appwrite-utils": "^0.3.8",
|
35
|
+
"commander": "^12.1.0",
|
36
|
+
"inquirer": "^9.3.6",
|
37
|
+
"js-yaml": "^4.1.0",
|
38
|
+
"lodash": "^4.17.21",
|
39
|
+
"luxon": "^3.5.0",
|
40
|
+
"nanostores": "^0.10.3",
|
41
|
+
"node-appwrite": "^13.0.0",
|
42
|
+
"tsx": "^4.17.0",
|
43
|
+
"ulidx": "^2.4.0",
|
44
|
+
"winston": "^3.14.2",
|
45
|
+
"zod": "^3.23.8"
|
46
|
+
},
|
47
|
+
"devDependencies": {
|
48
|
+
"@types/js-yaml": "^4.0.9",
|
49
|
+
"@types/lodash": "^4.17.7",
|
50
|
+
"@types/luxon": "^3.4.2",
|
51
|
+
"typescript": "^5.5.4"
|
52
|
+
}
|
53
|
+
}
|
package/src/interactiveCLI.ts
CHANGED
@@ -558,14 +558,14 @@ export class InteractiveCLI {
|
|
558
558
|
},
|
559
559
|
]);
|
560
560
|
|
561
|
-
const { checkDuplicates } = await inquirer.prompt([
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
]);
|
561
|
+
// const { checkDuplicates } = await inquirer.prompt([
|
562
|
+
// {
|
563
|
+
// type: "confirm",
|
564
|
+
// name: "checkDuplicates",
|
565
|
+
// message: "Do you want to check for duplicates during import?",
|
566
|
+
// default: true,
|
567
|
+
// },
|
568
|
+
// ]);
|
569
569
|
|
570
570
|
console.log("Importing data...");
|
571
571
|
await this.controller!.importData({
|
@@ -575,7 +575,8 @@ export class InteractiveCLI {
|
|
575
575
|
? selectedCollections.map((c) => c.$id)
|
576
576
|
: undefined,
|
577
577
|
shouldWriteFile,
|
578
|
-
checkDuplicates,
|
578
|
+
checkDuplicates: false,
|
579
|
+
// checkDuplicates,
|
579
580
|
});
|
580
581
|
}
|
581
582
|
|
@@ -637,19 +638,42 @@ export class InteractiveCLI {
|
|
637
638
|
targetDatabases = await fetchAllDatabases(targetClient);
|
638
639
|
} else {
|
639
640
|
targetClient = sourceClient;
|
640
|
-
|
641
|
+
const allDatabases = await fetchAllDatabases(sourceClient);
|
642
|
+
sourceDatabases = targetDatabases = allDatabases;
|
641
643
|
}
|
642
644
|
|
643
|
-
const
|
645
|
+
const fromDbs = await this.selectDatabases(
|
644
646
|
sourceDatabases,
|
645
647
|
"Select the source database:",
|
646
648
|
false
|
647
649
|
);
|
648
|
-
|
649
|
-
|
650
|
+
console.log(fromDbs);
|
651
|
+
const fromDb = fromDbs as unknown as {
|
652
|
+
$id: string;
|
653
|
+
name: string;
|
654
|
+
$createdAt: string;
|
655
|
+
$updatedAt: string;
|
656
|
+
enabled: boolean;
|
657
|
+
};
|
658
|
+
if (!fromDb) {
|
659
|
+
throw new Error("No source database selected");
|
660
|
+
}
|
661
|
+
const availableDbs = targetDatabases.filter((db) => db.$id !== fromDb.$id);
|
662
|
+
const targetDbs = await this.selectDatabases(
|
663
|
+
availableDbs,
|
650
664
|
"Select the target database:",
|
651
665
|
false
|
652
666
|
);
|
667
|
+
const targetDb = targetDbs as unknown as {
|
668
|
+
$id: string;
|
669
|
+
name: string;
|
670
|
+
$createdAt: string;
|
671
|
+
$updatedAt: string;
|
672
|
+
enabled: boolean;
|
673
|
+
};
|
674
|
+
if (!targetDb) {
|
675
|
+
throw new Error("No target database selected");
|
676
|
+
}
|
653
677
|
|
654
678
|
const selectedCollections = await this.selectCollections(
|
655
679
|
fromDb,
|
@@ -685,16 +709,18 @@ export class InteractiveCLI {
|
|
685
709
|
? await listBuckets(targetStorage)
|
686
710
|
: sourceBuckets;
|
687
711
|
|
688
|
-
|
712
|
+
const sourceBucketPicked = await this.selectBuckets(
|
689
713
|
sourceBuckets.buckets,
|
690
714
|
"Select the source bucket:",
|
691
715
|
false
|
692
716
|
);
|
693
|
-
|
717
|
+
const targetBucketPicked = await this.selectBuckets(
|
694
718
|
targetBuckets.buckets,
|
695
719
|
"Select the target bucket:",
|
696
720
|
false
|
697
721
|
);
|
722
|
+
sourceBucket = sourceBucketPicked as unknown as Models.Bucket;
|
723
|
+
targetBucket = targetBucketPicked as unknown as Models.Bucket;
|
698
724
|
}
|
699
725
|
|
700
726
|
let transferOptions: TransferOptions = {
|