appwrite-utils-cli 1.11.0 → 1.12.0
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/{src/adapters/index.ts → dist/adapters/index.d.ts} +0 -1
- package/dist/adapters/index.js +10 -0
- 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 +210 -0
- package/dist/cli/commands/databaseCommands.d.ts +14 -0
- package/dist/cli/commands/databaseCommands.js +696 -0
- package/dist/cli/commands/functionCommands.d.ts +7 -0
- package/dist/cli/commands/functionCommands.js +330 -0
- package/dist/cli/commands/importFileCommands.d.ts +7 -0
- package/dist/cli/commands/importFileCommands.js +674 -0
- package/dist/cli/commands/schemaCommands.d.ts +7 -0
- package/dist/cli/commands/schemaCommands.js +169 -0
- package/dist/cli/commands/storageCommands.d.ts +5 -0
- package/dist/cli/commands/storageCommands.js +142 -0
- package/dist/cli/commands/transferCommands.d.ts +5 -0
- package/dist/cli/commands/transferCommands.js +382 -0
- package/dist/collections/columns.d.ts +13 -0
- package/dist/collections/columns.js +1339 -0
- package/dist/collections/indexes.d.ts +12 -0
- package/dist/collections/indexes.js +215 -0
- package/dist/collections/methods.d.ts +19 -0
- package/dist/collections/methods.js +605 -0
- package/dist/collections/tableOperations.d.ts +87 -0
- package/dist/collections/tableOperations.js +466 -0
- package/dist/collections/transferOperations.d.ts +8 -0
- package/dist/collections/transferOperations.js +411 -0
- package/dist/collections/wipeOperations.d.ts +17 -0
- package/dist/collections/wipeOperations.js +306 -0
- package/dist/databases/methods.d.ts +6 -0
- package/dist/databases/methods.js +35 -0
- package/dist/databases/setup.d.ts +5 -0
- package/dist/databases/setup.js +45 -0
- package/dist/examples/yamlTerminologyExample.d.ts +42 -0
- package/dist/examples/yamlTerminologyExample.js +272 -0
- package/dist/functions/deployments.d.ts +4 -0
- package/dist/functions/deployments.js +146 -0
- package/dist/functions/fnConfigDiscovery.d.ts +3 -0
- package/dist/functions/fnConfigDiscovery.js +108 -0
- package/dist/functions/methods.d.ts +16 -0
- package/dist/functions/methods.js +174 -0
- package/dist/init.d.ts +2 -0
- package/dist/init.js +57 -0
- package/dist/interactiveCLI.d.ts +36 -0
- package/dist/interactiveCLI.js +952 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +1125 -0
- package/dist/migrations/afterImportActions.d.ts +17 -0
- package/dist/migrations/afterImportActions.js +305 -0
- package/dist/migrations/appwriteToX.d.ts +211 -0
- package/dist/migrations/appwriteToX.js +493 -0
- package/dist/migrations/comprehensiveTransfer.d.ts +147 -0
- package/dist/migrations/comprehensiveTransfer.js +1315 -0
- package/dist/migrations/dataLoader.d.ts +755 -0
- package/dist/migrations/dataLoader.js +1272 -0
- package/dist/migrations/importController.d.ts +25 -0
- package/dist/migrations/importController.js +283 -0
- package/dist/migrations/importDataActions.d.ts +50 -0
- package/dist/migrations/importDataActions.js +230 -0
- package/dist/migrations/relationships.d.ts +29 -0
- package/dist/migrations/relationships.js +203 -0
- 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 +99 -0
- package/dist/migrations/services/ImportOrchestrator.js +493 -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 +30 -0
- package/dist/migrations/transfer.js +661 -0
- package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +131 -0
- package/dist/migrations/yaml/YamlImportConfigLoader.js +383 -0
- package/dist/migrations/yaml/YamlImportIntegration.d.ts +93 -0
- package/dist/migrations/yaml/YamlImportIntegration.js +341 -0
- package/dist/migrations/yaml/generateImportSchemas.d.ts +30 -0
- package/dist/migrations/yaml/generateImportSchemas.js +1327 -0
- package/dist/schemas/authUser.d.ts +24 -0
- package/dist/schemas/authUser.js +17 -0
- package/dist/setup.d.ts +2 -0
- package/{src/setup.ts → dist/setup.js} +0 -3
- package/dist/setupCommands.d.ts +58 -0
- package/dist/setupCommands.js +489 -0
- package/dist/setupController.d.ts +9 -0
- package/dist/setupController.js +34 -0
- 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.d.ts +75 -0
- package/dist/shared/confirmationDialogs.js +236 -0
- package/dist/shared/migrationHelpers.d.ts +61 -0
- package/dist/shared/migrationHelpers.js +145 -0
- package/{src/shared/operationLogger.ts → dist/shared/operationLogger.d.ts} +1 -11
- package/dist/shared/operationLogger.js +12 -0
- package/dist/shared/operationQueue.d.ts +40 -0
- package/dist/shared/operationQueue.js +310 -0
- package/dist/shared/operationsTable.d.ts +26 -0
- package/dist/shared/operationsTable.js +287 -0
- package/dist/shared/operationsTableSchema.d.ts +48 -0
- package/dist/shared/operationsTableSchema.js +35 -0
- package/dist/shared/progressManager.d.ts +62 -0
- package/dist/shared/progressManager.js +215 -0
- package/dist/shared/relationshipExtractor.d.ts +56 -0
- package/dist/shared/relationshipExtractor.js +138 -0
- package/dist/shared/selectionDialogs.d.ts +220 -0
- package/dist/shared/selectionDialogs.js +588 -0
- package/dist/storage/backupCompression.d.ts +20 -0
- package/dist/storage/backupCompression.js +67 -0
- package/dist/storage/methods.d.ts +44 -0
- package/dist/storage/methods.js +475 -0
- package/dist/storage/schemas.d.ts +842 -0
- package/dist/storage/schemas.js +175 -0
- package/dist/tables/indexManager.d.ts +65 -0
- package/dist/tables/indexManager.js +294 -0
- package/{src/types.ts → dist/types.d.ts} +1 -6
- package/dist/types.js +3 -0
- 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 +261 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/loadConfigs.d.ts +50 -0
- package/dist/utils/loadConfigs.js +357 -0
- package/dist/utils/setupFiles.d.ts +4 -0
- package/dist/utils/setupFiles.js +1190 -0
- package/dist/utilsController.d.ts +114 -0
- package/dist/utilsController.js +898 -0
- package/package.json +6 -3
- package/CHANGELOG.md +0 -35
- package/CONFIG_TODO.md +0 -1189
- package/SELECTION_DIALOGS.md +0 -146
- package/SERVICE_IMPLEMENTATION_REPORT.md +0 -462
- package/scripts/copy-templates.ts +0 -23
- package/src/backups/operations/bucketBackup.ts +0 -277
- package/src/backups/operations/collectionBackup.ts +0 -310
- package/src/backups/operations/comprehensiveBackup.ts +0 -342
- package/src/backups/schemas/bucketManifest.ts +0 -78
- package/src/backups/schemas/comprehensiveManifest.ts +0 -76
- package/src/backups/tracking/centralizedTracking.ts +0 -352
- package/src/cli/commands/configCommands.ts +0 -265
- package/src/cli/commands/databaseCommands.ts +0 -931
- package/src/cli/commands/functionCommands.ts +0 -419
- package/src/cli/commands/importFileCommands.ts +0 -815
- package/src/cli/commands/schemaCommands.ts +0 -200
- package/src/cli/commands/storageCommands.ts +0 -151
- package/src/cli/commands/transferCommands.ts +0 -454
- package/src/collections/attributes.ts.backup +0 -1555
- package/src/collections/columns.ts +0 -2025
- package/src/collections/indexes.ts +0 -350
- package/src/collections/methods.ts +0 -714
- package/src/collections/tableOperations.ts +0 -542
- package/src/collections/transferOperations.ts +0 -589
- package/src/collections/wipeOperations.ts +0 -449
- package/src/databases/methods.ts +0 -49
- package/src/databases/setup.ts +0 -77
- package/src/examples/yamlTerminologyExample.ts +0 -346
- package/src/functions/deployments.ts +0 -221
- package/src/functions/fnConfigDiscovery.ts +0 -103
- package/src/functions/methods.ts +0 -284
- package/src/init.ts +0 -62
- package/src/interactiveCLI.ts +0 -1201
- package/src/main.ts +0 -1517
- package/src/migrations/afterImportActions.ts +0 -579
- package/src/migrations/appwriteToX.ts +0 -668
- package/src/migrations/comprehensiveTransfer.ts +0 -2285
- package/src/migrations/dataLoader.ts +0 -1729
- package/src/migrations/importController.ts +0 -440
- package/src/migrations/importDataActions.ts +0 -315
- package/src/migrations/relationships.ts +0 -333
- package/src/migrations/services/DataTransformationService.ts +0 -196
- package/src/migrations/services/FileHandlerService.ts +0 -311
- package/src/migrations/services/ImportOrchestrator.ts +0 -675
- package/src/migrations/services/RateLimitManager.ts +0 -363
- package/src/migrations/services/RelationshipResolver.ts +0 -461
- package/src/migrations/services/UserMappingService.ts +0 -345
- package/src/migrations/services/ValidationService.ts +0 -349
- package/src/migrations/transfer.ts +0 -1113
- package/src/migrations/yaml/YamlImportConfigLoader.ts +0 -439
- package/src/migrations/yaml/YamlImportIntegration.ts +0 -446
- package/src/migrations/yaml/generateImportSchemas.ts +0 -1354
- package/src/schemas/authUser.ts +0 -23
- package/src/setupCommands.ts +0 -602
- package/src/setupController.ts +0 -43
- package/src/shared/backupMetadataSchema.ts +0 -93
- package/src/shared/backupTracking.ts +0 -211
- package/src/shared/confirmationDialogs.ts +0 -327
- package/src/shared/migrationHelpers.ts +0 -232
- package/src/shared/operationQueue.ts +0 -376
- package/src/shared/operationsTable.ts +0 -338
- package/src/shared/operationsTableSchema.ts +0 -60
- package/src/shared/progressManager.ts +0 -278
- package/src/shared/relationshipExtractor.ts +0 -214
- package/src/shared/selectionDialogs.ts +0 -802
- package/src/storage/backupCompression.ts +0 -88
- package/src/storage/methods.ts +0 -711
- package/src/storage/schemas.ts +0 -205
- package/src/tables/indexManager.ts +0 -409
- package/src/types/node-appwrite-tablesdb.d.ts +0 -44
- package/src/users/methods.ts +0 -358
- package/src/utils/configMigration.ts +0 -348
- package/src/utils/loadConfigs.ts +0 -457
- package/src/utils/setupFiles.ts +0 -1236
- package/src/utilsController.ts +0 -1263
- package/tests/README.md +0 -497
- package/tests/adapters/AdapterFactory.test.ts +0 -277
- package/tests/integration/syncOperations.test.ts +0 -463
- package/tests/jest.config.js +0 -25
- package/tests/migration/configMigration.test.ts +0 -546
- package/tests/setup.ts +0 -62
- package/tests/testUtils.ts +0 -340
- package/tests/utils/loadConfigs.test.ts +0 -350
- package/tests/validation/configValidation.test.ts +0 -412
- package/tsconfig.json +0 -44
- /package/{src → dist}/functions/templates/count-docs-in-collection/README.md +0 -0
- /package/{src → dist}/functions/templates/count-docs-in-collection/src/main.ts +0 -0
- /package/{src → dist}/functions/templates/count-docs-in-collection/src/request.ts +0 -0
- /package/{src → dist}/functions/templates/hono-typescript/README.md +0 -0
- /package/{src → dist}/functions/templates/hono-typescript/src/adapters/request.ts +0 -0
- /package/{src → dist}/functions/templates/hono-typescript/src/adapters/response.ts +0 -0
- /package/{src → dist}/functions/templates/hono-typescript/src/app.ts +0 -0
- /package/{src → dist}/functions/templates/hono-typescript/src/context.ts +0 -0
- /package/{src → dist}/functions/templates/hono-typescript/src/main.ts +0 -0
- /package/{src → dist}/functions/templates/hono-typescript/src/middleware/appwrite.ts +0 -0
- /package/{src → dist}/functions/templates/typescript-node/README.md +0 -0
- /package/{src → dist}/functions/templates/typescript-node/src/context.ts +0 -0
- /package/{src → dist}/functions/templates/typescript-node/src/main.ts +0 -0
- /package/{src → dist}/functions/templates/uv/README.md +0 -0
- /package/{src → dist}/functions/templates/uv/pyproject.toml +0 -0
- /package/{src → dist}/functions/templates/uv/src/__init__.py +0 -0
- /package/{src → dist}/functions/templates/uv/src/context.py +0 -0
- /package/{src → dist}/functions/templates/uv/src/main.py +0 -0
- /package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to resolve collection name from ID or name
|
|
3
|
+
* @param config - Appwrite configuration containing collections
|
|
4
|
+
* @param idOrName - Collection ID or name to resolve
|
|
5
|
+
* @returns Resolved collection name, or the original input if not found
|
|
6
|
+
*/
|
|
7
|
+
export function resolveCollectionName(config, idOrName) {
|
|
8
|
+
const col = config.collections?.find((c) => c.$id === idOrName || c.name === idOrName);
|
|
9
|
+
return col?.name ?? idOrName;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Determines if a relationship type results in an array
|
|
13
|
+
* @param relationType - The type of relationship (oneToOne, oneToMany, manyToOne, manyToMany)
|
|
14
|
+
* @returns true if the relationship results in an array
|
|
15
|
+
*/
|
|
16
|
+
export function isArrayRelationship(relationType) {
|
|
17
|
+
return relationType === "oneToMany" || relationType === "manyToMany";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Extracts two-way relationship details from collections for Zod schema generation
|
|
21
|
+
* This handles complex bidirectional relationships with parent-child tracking
|
|
22
|
+
*
|
|
23
|
+
* @param config - Appwrite configuration containing collections
|
|
24
|
+
* @returns Map of collection names to their relationship details
|
|
25
|
+
*/
|
|
26
|
+
export function extractTwoWayRelationships(config) {
|
|
27
|
+
const relationshipMap = new Map();
|
|
28
|
+
if (!config.collections) {
|
|
29
|
+
return relationshipMap;
|
|
30
|
+
}
|
|
31
|
+
config.collections.forEach((collection) => {
|
|
32
|
+
if (!collection.attributes) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
collection.attributes.forEach((attr) => {
|
|
36
|
+
if (attr.type === "relationship" && attr.twoWay && attr.twoWayKey) {
|
|
37
|
+
const relationshipAttr = attr;
|
|
38
|
+
let isArrayParent = false;
|
|
39
|
+
let isArrayChild = false;
|
|
40
|
+
switch (relationshipAttr.relationType) {
|
|
41
|
+
case "oneToMany":
|
|
42
|
+
isArrayParent = true;
|
|
43
|
+
isArrayChild = false;
|
|
44
|
+
break;
|
|
45
|
+
case "manyToMany":
|
|
46
|
+
isArrayParent = true;
|
|
47
|
+
isArrayChild = true;
|
|
48
|
+
break;
|
|
49
|
+
case "oneToOne":
|
|
50
|
+
isArrayParent = false;
|
|
51
|
+
isArrayChild = false;
|
|
52
|
+
break;
|
|
53
|
+
case "manyToOne":
|
|
54
|
+
isArrayParent = false;
|
|
55
|
+
isArrayChild = true;
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
const relatedCollectionName = resolveCollectionName(config, relationshipAttr.relatedCollection);
|
|
61
|
+
addTwoWayRelationship(relationshipMap, collection.name, relatedCollectionName, attr.key, relationshipAttr.twoWayKey, isArrayParent, isArrayChild);
|
|
62
|
+
console.log(`Extracted relationship: ${attr.key}\n\t${collection.name} -> ${relationshipAttr.relatedCollection}, databaseId: ${collection.databaseId}`);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
return relationshipMap;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Helper to add two-way relationship details to both parent and child collections
|
|
70
|
+
* @param relationshipMap - The map to add relationships to
|
|
71
|
+
* @param parentCollection - Parent collection name
|
|
72
|
+
* @param childCollection - Child collection name
|
|
73
|
+
* @param parentKey - Attribute key in parent collection
|
|
74
|
+
* @param childKey - Attribute key in child collection
|
|
75
|
+
* @param isArrayParent - Whether parent side is an array
|
|
76
|
+
* @param isArrayChild - Whether child side is an array
|
|
77
|
+
*/
|
|
78
|
+
function addTwoWayRelationship(relationshipMap, parentCollection, childCollection, parentKey, childKey, isArrayParent, isArrayChild) {
|
|
79
|
+
const relationshipsChild = relationshipMap.get(childCollection) || [];
|
|
80
|
+
const relationshipsParent = relationshipMap.get(parentCollection) || [];
|
|
81
|
+
relationshipsParent.push({
|
|
82
|
+
parentCollection,
|
|
83
|
+
childCollection,
|
|
84
|
+
parentKey,
|
|
85
|
+
childKey,
|
|
86
|
+
isArray: isArrayParent,
|
|
87
|
+
isChild: false,
|
|
88
|
+
});
|
|
89
|
+
relationshipsChild.push({
|
|
90
|
+
parentCollection,
|
|
91
|
+
childCollection,
|
|
92
|
+
parentKey,
|
|
93
|
+
childKey,
|
|
94
|
+
isArray: isArrayChild,
|
|
95
|
+
isChild: true,
|
|
96
|
+
});
|
|
97
|
+
relationshipMap.set(childCollection, relationshipsChild);
|
|
98
|
+
relationshipMap.set(parentCollection, relationshipsParent);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Extracts simple relationship information from collections for JSON schema generation
|
|
102
|
+
* This handles one-way and basic relationship tracking
|
|
103
|
+
*
|
|
104
|
+
* @param config - Appwrite configuration containing collections
|
|
105
|
+
* @returns Map of collection names to their simple relationships
|
|
106
|
+
*/
|
|
107
|
+
export function extractSimpleRelationships(config) {
|
|
108
|
+
const relationshipMap = new Map();
|
|
109
|
+
if (!config.collections) {
|
|
110
|
+
return relationshipMap;
|
|
111
|
+
}
|
|
112
|
+
config.collections.forEach((collection) => {
|
|
113
|
+
if (!collection.attributes) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
collection.attributes.forEach((attr) => {
|
|
117
|
+
if (attr.type === "relationship" && attr.relatedCollection) {
|
|
118
|
+
const relationships = relationshipMap.get(collection.name) || [];
|
|
119
|
+
relationships.push({
|
|
120
|
+
attributeKey: attr.key,
|
|
121
|
+
relatedCollection: resolveCollectionName(config, attr.relatedCollection),
|
|
122
|
+
relationType: attr.relationType || "oneToOne",
|
|
123
|
+
isArray: isArrayRelationship(attr.relationType || "oneToOne")
|
|
124
|
+
});
|
|
125
|
+
relationshipMap.set(collection.name, relationships);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
return relationshipMap;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Extracts all relationship attributes from a collection's attributes
|
|
133
|
+
* @param attributes - Array of collection attributes
|
|
134
|
+
* @returns Array of relationship attributes only
|
|
135
|
+
*/
|
|
136
|
+
export function filterRelationshipAttributes(attributes) {
|
|
137
|
+
return attributes.filter((attr) => attr.type === "relationship");
|
|
138
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import type { Models } from "node-appwrite";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for sync selection summary
|
|
4
|
+
*/
|
|
5
|
+
export interface SyncSelectionSummary {
|
|
6
|
+
databases: DatabaseSelection[];
|
|
7
|
+
buckets: BucketSelection[];
|
|
8
|
+
totalDatabases: number;
|
|
9
|
+
totalTables: number;
|
|
10
|
+
totalBuckets: number;
|
|
11
|
+
newItems: {
|
|
12
|
+
databases: number;
|
|
13
|
+
tables: number;
|
|
14
|
+
buckets: number;
|
|
15
|
+
};
|
|
16
|
+
existingItems: {
|
|
17
|
+
databases: number;
|
|
18
|
+
tables: number;
|
|
19
|
+
buckets: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Database selection with associated tables
|
|
24
|
+
*/
|
|
25
|
+
export interface DatabaseSelection {
|
|
26
|
+
databaseId: string;
|
|
27
|
+
databaseName: string;
|
|
28
|
+
tableIds: string[];
|
|
29
|
+
tableNames: string[];
|
|
30
|
+
isNew: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Bucket selection with associated database
|
|
34
|
+
*/
|
|
35
|
+
export interface BucketSelection {
|
|
36
|
+
bucketId: string;
|
|
37
|
+
bucketName: string;
|
|
38
|
+
databaseId?: string;
|
|
39
|
+
databaseName?: string;
|
|
40
|
+
isNew: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Options for database selection
|
|
44
|
+
*/
|
|
45
|
+
export interface DatabaseSelectionOptions {
|
|
46
|
+
showSelectAll?: boolean;
|
|
47
|
+
allowNewOnly?: boolean;
|
|
48
|
+
defaultSelected?: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Options for table selection
|
|
52
|
+
*/
|
|
53
|
+
export interface TableSelectionOptions {
|
|
54
|
+
showSelectAll?: boolean;
|
|
55
|
+
allowNewOnly?: boolean;
|
|
56
|
+
defaultSelected?: string[];
|
|
57
|
+
showDatabaseContext?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Options for bucket selection
|
|
61
|
+
*/
|
|
62
|
+
export interface BucketSelectionOptions {
|
|
63
|
+
showSelectAll?: boolean;
|
|
64
|
+
allowNewOnly?: boolean;
|
|
65
|
+
defaultSelected?: string[];
|
|
66
|
+
groupByDatabase?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Response from existing config prompt
|
|
70
|
+
*/
|
|
71
|
+
export interface ExistingConfigResponse {
|
|
72
|
+
syncExisting: boolean;
|
|
73
|
+
modifyConfiguration: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Comprehensive selection dialog system for enhanced sync flow
|
|
77
|
+
*
|
|
78
|
+
* This class provides interactive dialogs for selecting databases, tables/collections,
|
|
79
|
+
* and storage buckets during sync operations. It supports both new and existing
|
|
80
|
+
* configurations with visual indicators and comprehensive confirmation flows.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import { SelectionDialogs } from './shared/selectionDialogs.js';
|
|
85
|
+
* import type { Models } from 'node-appwrite';
|
|
86
|
+
*
|
|
87
|
+
* // Example usage in a sync command
|
|
88
|
+
* const availableDatabases: Models.Database[] = await getAvailableDatabases();
|
|
89
|
+
* const configuredDatabases = config.databases || [];
|
|
90
|
+
*
|
|
91
|
+
* // Prompt about existing configuration
|
|
92
|
+
* const { syncExisting, modifyConfiguration } = await SelectionDialogs.promptForExistingConfig(configuredDatabases);
|
|
93
|
+
*
|
|
94
|
+
* if (modifyConfiguration) {
|
|
95
|
+
* // Select databases
|
|
96
|
+
* const selectedDatabaseIds = await SelectionDialogs.selectDatabases(
|
|
97
|
+
* availableDatabases,
|
|
98
|
+
* configuredDatabases,
|
|
99
|
+
* { showSelectAll: true, allowNewOnly: !syncExisting }
|
|
100
|
+
* );
|
|
101
|
+
*
|
|
102
|
+
* // For each database, select tables
|
|
103
|
+
* const tableSelectionsMap = new Map<string, string[]>();
|
|
104
|
+
* const availableTablesMap = new Map<string, any[]>();
|
|
105
|
+
*
|
|
106
|
+
* for (const databaseId of selectedDatabaseIds) {
|
|
107
|
+
* const database = availableDatabases.find(db => db.$id === databaseId)!;
|
|
108
|
+
* const availableTables = await getTablesForDatabase(databaseId);
|
|
109
|
+
* const configuredTables = getConfiguredTablesForDatabase(databaseId);
|
|
110
|
+
*
|
|
111
|
+
* availableTablesMap.set(databaseId, availableTables);
|
|
112
|
+
*
|
|
113
|
+
* const selectedTableIds = await SelectionDialogs.selectTablesForDatabase(
|
|
114
|
+
* databaseId,
|
|
115
|
+
* database.name,
|
|
116
|
+
* availableTables,
|
|
117
|
+
* configuredTables,
|
|
118
|
+
* { showSelectAll: true, allowNewOnly: !syncExisting }
|
|
119
|
+
* );
|
|
120
|
+
*
|
|
121
|
+
* tableSelectionsMap.set(databaseId, selectedTableIds);
|
|
122
|
+
* }
|
|
123
|
+
*
|
|
124
|
+
* // Select buckets
|
|
125
|
+
* const availableBuckets = await getAvailableBuckets();
|
|
126
|
+
* const configuredBuckets = config.buckets || [];
|
|
127
|
+
* const selectedBucketIds = await SelectionDialogs.selectBucketsForDatabases(
|
|
128
|
+
* selectedDatabaseIds,
|
|
129
|
+
* availableBuckets,
|
|
130
|
+
* configuredBuckets,
|
|
131
|
+
* { showSelectAll: true, groupByDatabase: true }
|
|
132
|
+
* );
|
|
133
|
+
*
|
|
134
|
+
* // Create selection objects
|
|
135
|
+
* const databaseSelections = SelectionDialogs.createDatabaseSelection(
|
|
136
|
+
* selectedDatabaseIds,
|
|
137
|
+
* availableDatabases,
|
|
138
|
+
* tableSelectionsMap,
|
|
139
|
+
* configuredDatabases,
|
|
140
|
+
* availableTablesMap
|
|
141
|
+
* );
|
|
142
|
+
*
|
|
143
|
+
* const bucketSelections = SelectionDialogs.createBucketSelection(
|
|
144
|
+
* selectedBucketIds,
|
|
145
|
+
* availableBuckets,
|
|
146
|
+
* configuredBuckets,
|
|
147
|
+
* availableDatabases
|
|
148
|
+
* );
|
|
149
|
+
*
|
|
150
|
+
* // Show final confirmation
|
|
151
|
+
* const selectionSummary = SelectionDialogs.createSyncSelectionSummary(
|
|
152
|
+
* databaseSelections,
|
|
153
|
+
* bucketSelections
|
|
154
|
+
* );
|
|
155
|
+
*
|
|
156
|
+
* const confirmed = await SelectionDialogs.confirmSyncSelection(selectionSummary);
|
|
157
|
+
*
|
|
158
|
+
* if (confirmed) {
|
|
159
|
+
* // Proceed with sync operation
|
|
160
|
+
* await performSync(databaseSelections, bucketSelections);
|
|
161
|
+
* }
|
|
162
|
+
* }
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare class SelectionDialogs {
|
|
166
|
+
/**
|
|
167
|
+
* Prompts user about existing configuration
|
|
168
|
+
*/
|
|
169
|
+
static promptForExistingConfig(configuredItems: any[]): Promise<ExistingConfigResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Shows database selection dialog with indicators for configured vs new databases
|
|
172
|
+
*/
|
|
173
|
+
static selectDatabases(availableDatabases: Models.Database[], configuredDatabases: any[], options?: DatabaseSelectionOptions): Promise<string[]>;
|
|
174
|
+
/**
|
|
175
|
+
* Shows table/collection selection dialog for a specific database
|
|
176
|
+
*/
|
|
177
|
+
static selectTablesForDatabase(databaseId: string, databaseName: string, availableTables: any[], configuredTables: any[], options?: TableSelectionOptions): Promise<string[]>;
|
|
178
|
+
/**
|
|
179
|
+
* Shows bucket selection dialog for selected databases
|
|
180
|
+
*/
|
|
181
|
+
static selectBucketsForDatabases(selectedDatabaseIds: string[], availableBuckets: any[], configuredBuckets: any[], options?: BucketSelectionOptions): Promise<string[]>;
|
|
182
|
+
/**
|
|
183
|
+
* Shows bucket selection for push operations with merged local+remote buckets.
|
|
184
|
+
* Unlike selectBucketsForDatabases, this shows all buckets as a flat list
|
|
185
|
+
* with source indicators (Local only, Remote only, Configured).
|
|
186
|
+
*/
|
|
187
|
+
static selectBucketsForPush(mergedBuckets: any[], configuredBuckets: any[], options?: BucketSelectionOptions): Promise<string[]>;
|
|
188
|
+
/**
|
|
189
|
+
* Shows final confirmation dialog with sync selection summary
|
|
190
|
+
*/
|
|
191
|
+
static confirmSyncSelection(selectionSummary: SyncSelectionSummary, operationType?: 'push' | 'pull' | 'sync'): Promise<boolean>;
|
|
192
|
+
/**
|
|
193
|
+
* Creates a sync selection summary from selected items
|
|
194
|
+
*/
|
|
195
|
+
static createSyncSelectionSummary(databaseSelections: DatabaseSelection[], bucketSelections: BucketSelection[]): SyncSelectionSummary;
|
|
196
|
+
/**
|
|
197
|
+
* Helper method to create database selection objects
|
|
198
|
+
*/
|
|
199
|
+
static createDatabaseSelection(selectedDatabaseIds: string[], availableDatabases: Models.Database[], tableSelectionsMap: Map<string, string[]>, configuredDatabases: any[], availableTablesMap?: Map<string, any[]>): DatabaseSelection[];
|
|
200
|
+
/**
|
|
201
|
+
* Helper method to create bucket selection objects
|
|
202
|
+
*/
|
|
203
|
+
static createBucketSelection(selectedBucketIds: string[], availableBuckets: any[], configuredBuckets: any[], availableDatabases: Models.Database[]): BucketSelection[];
|
|
204
|
+
/**
|
|
205
|
+
* Shows a progress message during selection operations
|
|
206
|
+
*/
|
|
207
|
+
static showProgress(message: string): void;
|
|
208
|
+
/**
|
|
209
|
+
* Shows an error message and handles graceful cancellation
|
|
210
|
+
*/
|
|
211
|
+
static showError(message: string, error?: Error): void;
|
|
212
|
+
/**
|
|
213
|
+
* Shows a warning message
|
|
214
|
+
*/
|
|
215
|
+
static showWarning(message: string): void;
|
|
216
|
+
/**
|
|
217
|
+
* Shows a success message
|
|
218
|
+
*/
|
|
219
|
+
static showSuccess(message: string): void;
|
|
220
|
+
}
|