appwrite-utils-cli 1.7.9 → 1.8.2
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 +14 -199
- package/README.md +87 -30
- package/dist/adapters/AdapterFactory.js +5 -25
- package/dist/adapters/DatabaseAdapter.d.ts +17 -2
- package/dist/adapters/LegacyAdapter.d.ts +2 -1
- package/dist/adapters/LegacyAdapter.js +212 -16
- package/dist/adapters/TablesDBAdapter.d.ts +2 -12
- package/dist/adapters/TablesDBAdapter.js +261 -57
- package/dist/cli/commands/databaseCommands.js +4 -3
- package/dist/cli/commands/functionCommands.js +17 -8
- package/dist/collections/attributes.js +447 -125
- package/dist/collections/methods.js +197 -186
- package/dist/collections/tableOperations.d.ts +86 -0
- package/dist/collections/tableOperations.js +434 -0
- package/dist/collections/transferOperations.d.ts +3 -2
- package/dist/collections/transferOperations.js +93 -12
- package/dist/config/yamlConfig.d.ts +221 -88
- package/dist/examples/yamlTerminologyExample.d.ts +1 -1
- package/dist/examples/yamlTerminologyExample.js +6 -3
- package/dist/functions/fnConfigDiscovery.d.ts +3 -0
- package/dist/functions/fnConfigDiscovery.js +108 -0
- package/dist/interactiveCLI.js +18 -15
- package/dist/main.js +211 -73
- package/dist/migrations/appwriteToX.d.ts +88 -23
- package/dist/migrations/comprehensiveTransfer.d.ts +2 -0
- package/dist/migrations/comprehensiveTransfer.js +83 -6
- package/dist/migrations/dataLoader.d.ts +227 -69
- package/dist/migrations/dataLoader.js +3 -3
- package/dist/migrations/importController.js +3 -3
- package/dist/migrations/relationships.d.ts +8 -2
- package/dist/migrations/services/ImportOrchestrator.js +3 -3
- package/dist/migrations/transfer.js +159 -37
- package/dist/shared/attributeMapper.d.ts +20 -0
- package/dist/shared/attributeMapper.js +203 -0
- package/dist/shared/selectionDialogs.js +8 -4
- package/dist/storage/schemas.d.ts +354 -92
- package/dist/utils/configDiscovery.js +4 -3
- package/dist/utils/versionDetection.d.ts +0 -4
- package/dist/utils/versionDetection.js +41 -173
- package/dist/utils/yamlConverter.js +89 -16
- package/dist/utils/yamlLoader.d.ts +1 -1
- package/dist/utils/yamlLoader.js +6 -2
- package/dist/utilsController.js +56 -19
- package/package.json +4 -4
- package/src/adapters/AdapterFactory.ts +119 -143
- package/src/adapters/DatabaseAdapter.ts +18 -3
- package/src/adapters/LegacyAdapter.ts +236 -105
- package/src/adapters/TablesDBAdapter.ts +773 -643
- package/src/cli/commands/databaseCommands.ts +13 -12
- package/src/cli/commands/functionCommands.ts +23 -14
- package/src/collections/attributes.ts +2054 -1611
- package/src/collections/methods.ts +208 -293
- package/src/collections/tableOperations.ts +506 -0
- package/src/collections/transferOperations.ts +218 -144
- package/src/examples/yamlTerminologyExample.ts +10 -5
- package/src/functions/fnConfigDiscovery.ts +103 -0
- package/src/interactiveCLI.ts +25 -20
- package/src/main.ts +549 -194
- package/src/migrations/comprehensiveTransfer.ts +126 -50
- package/src/migrations/dataLoader.ts +3 -3
- package/src/migrations/importController.ts +3 -3
- package/src/migrations/services/ImportOrchestrator.ts +3 -3
- package/src/migrations/transfer.ts +148 -131
- package/src/shared/attributeMapper.ts +229 -0
- package/src/shared/selectionDialogs.ts +29 -25
- package/src/utils/configDiscovery.ts +9 -3
- package/src/utils/versionDetection.ts +74 -228
- package/src/utils/yamlConverter.ts +94 -17
- package/src/utils/yamlLoader.ts +11 -4
- package/src/utilsController.ts +80 -30
package/src/interactiveCLI.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
Compression,
|
|
11
11
|
Query,
|
|
12
12
|
Functions,
|
|
13
|
+
DatabaseType,
|
|
13
14
|
} from "node-appwrite";
|
|
14
15
|
import {
|
|
15
16
|
PermissionToAppwritePermission,
|
|
@@ -232,10 +233,10 @@ export class InteractiveCLI {
|
|
|
232
233
|
const configDatabases = this.getLocalDatabases();
|
|
233
234
|
const allDatabases = [...databases, ...configDatabases]
|
|
234
235
|
.reduce((acc, db) => {
|
|
235
|
-
// Local config takes precedence - if a database with same name exists, use local version
|
|
236
|
-
const existingIndex = acc.findIndex((d) => d.name === db.name);
|
|
236
|
+
// Local config takes precedence - if a database with same name or ID exists, use local version
|
|
237
|
+
const existingIndex = acc.findIndex((d) => d.name === db.name || d.$id === db.$id);
|
|
237
238
|
if (existingIndex >= 0) {
|
|
238
|
-
if (configDatabases.some((cdb) => cdb.name === db.name)) {
|
|
239
|
+
if (configDatabases.some((cdb) => cdb.name === db.name || cdb.$id === db.$id)) {
|
|
239
240
|
acc[existingIndex] = db; // Replace with local version
|
|
240
241
|
}
|
|
241
242
|
} else {
|
|
@@ -246,10 +247,10 @@ export class InteractiveCLI {
|
|
|
246
247
|
|
|
247
248
|
const hasLocalAndRemote =
|
|
248
249
|
allDatabases.some((db) =>
|
|
249
|
-
configDatabases.some((c) => c.name === db.name)
|
|
250
|
+
configDatabases.some((c) => c.name === db.name || c.$id === db.$id)
|
|
250
251
|
) &&
|
|
251
252
|
allDatabases.some(
|
|
252
|
-
(db) => !configDatabases.some((c) => c.name === db.name)
|
|
253
|
+
(db) => !configDatabases.some((c) => c.name === db.name || c.$id === db.$id)
|
|
253
254
|
);
|
|
254
255
|
|
|
255
256
|
const choices = allDatabases
|
|
@@ -258,7 +259,7 @@ export class InteractiveCLI {
|
|
|
258
259
|
name:
|
|
259
260
|
db.name +
|
|
260
261
|
(hasLocalAndRemote
|
|
261
|
-
? configDatabases.some((c) => c.name === db.name)
|
|
262
|
+
? configDatabases.some((c) => c.name === db.name || c.$id === db.$id)
|
|
262
263
|
? " (Local)"
|
|
263
264
|
: " (Remote)"
|
|
264
265
|
: ""),
|
|
@@ -311,7 +312,7 @@ export class InteractiveCLI {
|
|
|
311
312
|
let allCollections = preferLocal
|
|
312
313
|
? remoteCollections.reduce(
|
|
313
314
|
(acc, remoteCollection) => {
|
|
314
|
-
if (!acc.some((c) => c.name === remoteCollection.name)) {
|
|
315
|
+
if (!acc.some((c) => c.name === remoteCollection.name || c.$id === remoteCollection.$id)) {
|
|
315
316
|
acc.push(remoteCollection);
|
|
316
317
|
}
|
|
317
318
|
return acc;
|
|
@@ -321,7 +322,7 @@ export class InteractiveCLI {
|
|
|
321
322
|
: [
|
|
322
323
|
...remoteCollections,
|
|
323
324
|
...configCollections.filter(
|
|
324
|
-
(c) => !remoteCollections.some((rc) => rc.name === c.name)
|
|
325
|
+
(c) => !remoteCollections.some((rc) => rc.name === c.name || rc.$id === c.$id)
|
|
325
326
|
),
|
|
326
327
|
];
|
|
327
328
|
|
|
@@ -329,7 +330,7 @@ export class InteractiveCLI {
|
|
|
329
330
|
// Show collections that EITHER exist in the remote database OR have matching local databaseId metadata
|
|
330
331
|
allCollections = allCollections.filter((c: any) => {
|
|
331
332
|
// Include if it exists remotely in this database
|
|
332
|
-
const existsInRemoteDb = remoteCollections.some((rc) => rc.name === c.name);
|
|
333
|
+
const existsInRemoteDb = remoteCollections.some((rc) => rc.name === c.name || rc.$id === c.$id);
|
|
333
334
|
|
|
334
335
|
// Include if local metadata claims it belongs to this database
|
|
335
336
|
const hasMatchingLocalMetadata = c.databaseId === database.$id;
|
|
@@ -345,10 +346,10 @@ export class InteractiveCLI {
|
|
|
345
346
|
|
|
346
347
|
const hasLocalAndRemote =
|
|
347
348
|
allCollections.some((coll) =>
|
|
348
|
-
configCollections.some((c) => c.name === coll.name)
|
|
349
|
+
configCollections.some((c) => c.name === coll.name || c.$id === coll.$id)
|
|
349
350
|
) &&
|
|
350
351
|
allCollections.some(
|
|
351
|
-
(coll) => !configCollections.some((c) => c.name === coll.name)
|
|
352
|
+
(coll) => !configCollections.some((c) => c.name === coll.name || c.$id === coll.$id)
|
|
352
353
|
);
|
|
353
354
|
|
|
354
355
|
// Enhanced choice display with type indicators
|
|
@@ -365,7 +366,7 @@ export class InteractiveCLI {
|
|
|
365
366
|
return a.name.localeCompare(b.name);
|
|
366
367
|
})
|
|
367
368
|
.map((collection) => {
|
|
368
|
-
const localCollection = configCollections.find((c) => c.name === collection.name);
|
|
369
|
+
const localCollection = configCollections.find((c) => c.name === collection.name || c.$id === collection.$id);
|
|
369
370
|
const isLocal = !!localCollection;
|
|
370
371
|
const isTable = localCollection?._isFromTablesDir || (collection as any)._isFromTablesDir || false;
|
|
371
372
|
const sourceFolder = localCollection?._sourceFolder || (collection as any)._sourceFolder || 'collections';
|
|
@@ -447,12 +448,15 @@ export class InteractiveCLI {
|
|
|
447
448
|
MessageFormatter.info(`📊 ${tablesCount} tables available from tables/ folder`, { prefix: "Collections" });
|
|
448
449
|
}
|
|
449
450
|
|
|
450
|
-
//
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
451
|
+
// Show current database context clearly before view mode selection
|
|
452
|
+
MessageFormatter.info(`DB: ${database.name}`, { prefix: "Collections" });
|
|
453
|
+
|
|
454
|
+
// Ask user if they want to filter by database or show all
|
|
455
|
+
const { filterChoice } = await inquirer.prompt([
|
|
456
|
+
{
|
|
457
|
+
type: "list",
|
|
458
|
+
name: "filterChoice",
|
|
459
|
+
message: chalk.blue("How would you like to view collections/tables?"),
|
|
456
460
|
choices: [
|
|
457
461
|
{
|
|
458
462
|
name: `Show all available collections/tables (${totalCount} total) - You can push any collection to any database`,
|
|
@@ -629,7 +633,7 @@ export class InteractiveCLI {
|
|
|
629
633
|
const allFunctions = [
|
|
630
634
|
...localFunctions,
|
|
631
635
|
...remoteFunctions.functions.filter(
|
|
632
|
-
(rf: any) => !localFunctions.some((lf) => lf.name === rf.name)
|
|
636
|
+
(rf: any) => !localFunctions.some((lf) => lf.name === rf.name || lf.$id === rf.$id)
|
|
633
637
|
),
|
|
634
638
|
];
|
|
635
639
|
|
|
@@ -640,7 +644,7 @@ export class InteractiveCLI {
|
|
|
640
644
|
message,
|
|
641
645
|
choices: allFunctions.map((f) => ({
|
|
642
646
|
name: `${f.name} (${f.$id})${
|
|
643
|
-
localFunctions.some((lf) => lf.name === f.name)
|
|
647
|
+
localFunctions.some((lf) => lf.name === f.name || lf.$id === f.$id)
|
|
644
648
|
? " (Local)"
|
|
645
649
|
: " (Remote)"
|
|
646
650
|
}`,
|
|
@@ -980,6 +984,7 @@ export class InteractiveCLI {
|
|
|
980
984
|
$updatedAt: DateTime.now().toISO(),
|
|
981
985
|
name: db.name,
|
|
982
986
|
enabled: true,
|
|
987
|
+
type: "tablesdb" as DatabaseType,
|
|
983
988
|
}));
|
|
984
989
|
}
|
|
985
990
|
|