appwrite-utils-cli 1.5.2 → 1.6.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/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 +478 -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 +181 -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 +278 -1596
- 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
@@ -13,6 +13,7 @@ import { MessageFormatter } from "../../shared/messageFormatter.js";
|
|
13
13
|
import { ProgressManager } from "../../shared/progressManager.js";
|
14
14
|
import { tryAwaitWithRetry } from "../../utils/index.js";
|
15
15
|
import { updateOperation, findOrCreateOperation } from "../../shared/migrationHelpers.js";
|
16
|
+
import { LegacyAdapter } from "../../adapters/LegacyAdapter.js";
|
16
17
|
import { resolveAndUpdateRelationships } from "../relationships.js";
|
17
18
|
// Enhanced rate limiting configuration - now managed by RateLimitManager
|
18
19
|
/**
|
@@ -71,9 +72,6 @@ export class ImportOrchestrator {
|
|
71
72
|
}
|
72
73
|
let processedDatabase;
|
73
74
|
for (const db of databasesToProcess) {
|
74
|
-
if (!this.config.useMigrations && db.name.toLowerCase().trim().replace(" ", "") === "migrations") {
|
75
|
-
continue;
|
76
|
-
}
|
77
75
|
MessageFormatter.banner(`Starting import data for database: ${db.name}`, "Database Import");
|
78
76
|
if (!processedDatabase) {
|
79
77
|
processedDatabase = db;
|
@@ -149,10 +147,9 @@ export class ImportOrchestrator {
|
|
149
147
|
collection.$id = existingCollection.$id;
|
150
148
|
this.config.collections[index] = collectionConfig;
|
151
149
|
// Find or create an import operation for the collection
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
}
|
150
|
+
const adapter = new LegacyAdapter(this.database);
|
151
|
+
const collectionImportOperation = await findOrCreateOperation(adapter, dbId, "importData", collection.$id);
|
152
|
+
this.collectionImportOperations.set(this.getCollectionKey(collection.name), collectionImportOperation.$id);
|
156
153
|
// Initialize the collection in the import map
|
157
154
|
this.importMap.set(this.getCollectionKey(collection.name), {
|
158
155
|
collection: collection,
|
@@ -230,7 +227,7 @@ export class ImportOrchestrator {
|
|
230
227
|
const rawData = this.loadDataFromFile(importDef);
|
231
228
|
if (rawData.length === 0)
|
232
229
|
return;
|
233
|
-
await this.updateOperationStatus(collection, "ready", rawData.length);
|
230
|
+
await this.updateOperationStatus(db, collection, "ready", rawData.length);
|
234
231
|
const collectionData = this.importMap.get(this.getCollectionKey(collection.name));
|
235
232
|
if (!collectionData) {
|
236
233
|
logger.error(`No collection data found for ${collection.name}`);
|
@@ -284,7 +281,7 @@ export class ImportOrchestrator {
|
|
284
281
|
const rawData = this.loadDataFromFile(importDef);
|
285
282
|
if (rawData.length === 0)
|
286
283
|
return;
|
287
|
-
await this.updateOperationStatus(collection, "ready", rawData.length);
|
284
|
+
await this.updateOperationStatus(db, collection, "ready", rawData.length);
|
288
285
|
const collectionData = this.importMap.get(this.getCollectionKey(collection.name));
|
289
286
|
if (!collectionData)
|
290
287
|
return;
|
@@ -356,8 +353,9 @@ export class ImportOrchestrator {
|
|
356
353
|
}
|
357
354
|
logger.info(`Importing collection: ${collection.name} (${collectionData.data.length} items)`);
|
358
355
|
const operationId = this.collectionImportOperations.get(this.getCollectionKey(collection.name));
|
359
|
-
|
360
|
-
|
356
|
+
const adapter = new LegacyAdapter(this.database);
|
357
|
+
if (operationId) {
|
358
|
+
await updateOperation(adapter, db.$id, operationId, { status: "in_progress" });
|
361
359
|
}
|
362
360
|
// Create batches for processing
|
363
361
|
const batches = this.createBatches(collectionData.data, this.batchLimit);
|
@@ -373,13 +371,13 @@ export class ImportOrchestrator {
|
|
373
371
|
processedItems += successCount;
|
374
372
|
logger.info(`Batch ${i + 1} completed: ${successCount}/${batch.length} items imported`);
|
375
373
|
// Update operation progress
|
376
|
-
if (operationId
|
377
|
-
await updateOperation(
|
374
|
+
if (operationId) {
|
375
|
+
await updateOperation(adapter, db.$id, operationId, { progress: processedItems });
|
378
376
|
}
|
379
377
|
}
|
380
378
|
// Mark operation as completed
|
381
|
-
if (operationId
|
382
|
-
await updateOperation(
|
379
|
+
if (operationId) {
|
380
|
+
await updateOperation(adapter, db.$id, operationId, { status: "completed" });
|
383
381
|
}
|
384
382
|
logger.info(`Completed importing collection: ${collection.name} (${processedItems} items)`);
|
385
383
|
}
|
@@ -459,13 +457,12 @@ export class ImportOrchestrator {
|
|
459
457
|
return null;
|
460
458
|
}
|
461
459
|
}
|
462
|
-
async updateOperationStatus(collection, status, total) {
|
463
|
-
if (!this.config.useMigrations)
|
464
|
-
return;
|
460
|
+
async updateOperationStatus(db, collection, status, total) {
|
465
461
|
const operationId = this.collectionImportOperations.get(this.getCollectionKey(collection.name));
|
466
462
|
if (operationId) {
|
467
463
|
const updateData = total ? { status, total } : { status };
|
468
|
-
|
464
|
+
const adapter = new LegacyAdapter(this.database);
|
465
|
+
await updateOperation(adapter, db.$id, operationId, updateData);
|
469
466
|
}
|
470
467
|
}
|
471
468
|
async importUsersCollection() {
|
@@ -136,13 +136,13 @@ export const transferStorageLocalToRemote = async (localStorage, endpoint, proje
|
|
136
136
|
* @return {Promise<void>} A promise that resolves when the transfer is complete.
|
137
137
|
*/
|
138
138
|
export const transferDatabaseLocalToLocal = async (localDb, fromDbId, targetDbId) => {
|
139
|
-
|
139
|
+
MessageFormatter.info(`Starting database transfer from ${fromDbId} to ${targetDbId}`, { prefix: "Transfer" });
|
140
140
|
// Get all collections from source database
|
141
141
|
const sourceCollections = await fetchAllCollections(fromDbId, localDb);
|
142
|
-
|
142
|
+
MessageFormatter.info(`Found ${sourceCollections.length} collections in source database`, { prefix: "Transfer" });
|
143
143
|
// Process each collection
|
144
144
|
for (const collection of sourceCollections) {
|
145
|
-
|
145
|
+
MessageFormatter.processing(`Processing collection: ${collection.name} (${collection.$id})`, { prefix: "Transfer" });
|
146
146
|
try {
|
147
147
|
// Create or update collection in target
|
148
148
|
let targetCollection;
|
@@ -151,39 +151,39 @@ export const transferDatabaseLocalToLocal = async (localDb, fromDbId, targetDbId
|
|
151
151
|
]));
|
152
152
|
if (existingCollection.collections.length > 0) {
|
153
153
|
targetCollection = existingCollection.collections[0];
|
154
|
-
|
154
|
+
MessageFormatter.info(`Collection ${collection.name} exists in target database`, { prefix: "Transfer" });
|
155
155
|
// Update collection if needed
|
156
156
|
if (targetCollection.name !== collection.name ||
|
157
157
|
targetCollection.$permissions !== collection.$permissions ||
|
158
158
|
targetCollection.documentSecurity !== collection.documentSecurity ||
|
159
159
|
targetCollection.enabled !== collection.enabled) {
|
160
160
|
targetCollection = await tryAwaitWithRetry(async () => localDb.updateCollection(targetDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
|
161
|
-
|
161
|
+
MessageFormatter.success(`Collection ${collection.name} updated`, { prefix: "Transfer" });
|
162
162
|
}
|
163
163
|
}
|
164
164
|
else {
|
165
|
-
|
165
|
+
MessageFormatter.progress(`Creating collection ${collection.name} in target database...`, { prefix: "Transfer" });
|
166
166
|
targetCollection = await tryAwaitWithRetry(async () => localDb.createCollection(targetDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
|
167
167
|
}
|
168
168
|
// Handle attributes with enhanced status checking
|
169
|
-
|
169
|
+
MessageFormatter.info(`Creating attributes for collection ${collection.name} with enhanced monitoring...`, { prefix: "Transfer" });
|
170
170
|
const allAttributes = collection.attributes.map((attr) => parseAttribute(attr));
|
171
171
|
const attributeSuccess = await createUpdateCollectionAttributesWithStatusCheck(localDb, targetDbId, targetCollection, allAttributes);
|
172
172
|
if (!attributeSuccess) {
|
173
|
-
|
173
|
+
MessageFormatter.error(`Failed to create all attributes for collection ${collection.name}, skipping to next collection`, undefined, { prefix: "Transfer" });
|
174
174
|
continue;
|
175
175
|
}
|
176
|
-
|
176
|
+
MessageFormatter.success(`All attributes created successfully for collection ${collection.name}`, { prefix: "Transfer" });
|
177
177
|
// Handle indexes
|
178
178
|
const existingIndexes = await tryAwaitWithRetry(async () => await localDb.listIndexes(targetDbId, targetCollection.$id));
|
179
179
|
for (const index of collection.indexes) {
|
180
180
|
const existingIndex = existingIndexes.indexes.find((idx) => idx.key === index.key);
|
181
181
|
if (!existingIndex) {
|
182
182
|
await tryAwaitWithRetry(async () => createOrUpdateIndex(targetDbId, localDb, targetCollection.$id, index));
|
183
|
-
|
183
|
+
MessageFormatter.success(`Index ${index.key} created`, { prefix: "Transfer" });
|
184
184
|
}
|
185
185
|
else {
|
186
|
-
|
186
|
+
MessageFormatter.info(`Index ${index.key} exists, checking for updates...`, { prefix: "Transfer" });
|
187
187
|
await tryAwaitWithRetry(async () => createOrUpdateIndex(targetDbId, localDb, targetCollection.$id, index));
|
188
188
|
}
|
189
189
|
}
|
@@ -192,7 +192,7 @@ export const transferDatabaseLocalToLocal = async (localDb, fromDbId, targetDbId
|
|
192
192
|
await transferDocumentsBetweenDbsLocalToLocal(localDb, fromDbId, targetDbId, collection.$id, targetCollection.$id);
|
193
193
|
}
|
194
194
|
catch (error) {
|
195
|
-
|
195
|
+
MessageFormatter.error(`Error processing collection ${collection.name}`, error instanceof Error ? error : new Error(String(error)), { prefix: "Transfer" });
|
196
196
|
}
|
197
197
|
}
|
198
198
|
};
|
@@ -201,62 +201,62 @@ export const transferDatabaseLocalToRemote = async (localDb, endpoint, projectId
|
|
201
201
|
const remoteDb = new Databases(client);
|
202
202
|
// Get all collections from source database
|
203
203
|
const sourceCollections = await fetchAllCollections(fromDbId, localDb);
|
204
|
-
|
204
|
+
MessageFormatter.info(`Found ${sourceCollections.length} collections in source database`, { prefix: "Transfer" });
|
205
205
|
// Process each collection
|
206
206
|
for (const collection of sourceCollections) {
|
207
|
-
|
207
|
+
MessageFormatter.processing(`Processing collection: ${collection.name} (${collection.$id})`, { prefix: "Transfer" });
|
208
208
|
try {
|
209
209
|
// Create or update collection in target
|
210
210
|
let targetCollection;
|
211
211
|
const existingCollection = await tryAwaitWithRetry(async () => remoteDb.listCollections(toDbId, [Query.equal("$id", collection.$id)]));
|
212
212
|
if (existingCollection.collections.length > 0) {
|
213
213
|
targetCollection = existingCollection.collections[0];
|
214
|
-
|
214
|
+
MessageFormatter.info(`Collection ${collection.name} exists in remote database`, { prefix: "Transfer" });
|
215
215
|
// Update collection if needed
|
216
216
|
if (targetCollection.name !== collection.name ||
|
217
217
|
targetCollection.$permissions !== collection.$permissions ||
|
218
218
|
targetCollection.documentSecurity !== collection.documentSecurity ||
|
219
219
|
targetCollection.enabled !== collection.enabled) {
|
220
220
|
targetCollection = await tryAwaitWithRetry(async () => remoteDb.updateCollection(toDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
|
221
|
-
|
221
|
+
MessageFormatter.success(`Collection ${collection.name} updated`, { prefix: "Transfer" });
|
222
222
|
}
|
223
223
|
}
|
224
224
|
else {
|
225
|
-
|
225
|
+
MessageFormatter.progress(`Creating collection ${collection.name} in remote database...`, { prefix: "Transfer" });
|
226
226
|
targetCollection = await tryAwaitWithRetry(async () => remoteDb.createCollection(toDbId, collection.$id, collection.name, collection.$permissions, collection.documentSecurity, collection.enabled));
|
227
227
|
}
|
228
228
|
// Handle attributes with enhanced status checking
|
229
|
-
|
229
|
+
MessageFormatter.info(`Creating attributes for collection ${collection.name} with enhanced monitoring...`, { prefix: "Transfer" });
|
230
230
|
const attributesToCreate = collection.attributes.map((attr) => parseAttribute(attr));
|
231
231
|
const attributesSuccess = await createUpdateCollectionAttributesWithStatusCheck(remoteDb, toDbId, targetCollection, attributesToCreate);
|
232
232
|
if (!attributesSuccess) {
|
233
|
-
|
233
|
+
MessageFormatter.warning(`Failed to create some attributes for collection ${collection.name}`, { prefix: "Transfer" });
|
234
234
|
// Continue with the transfer even if some attributes failed
|
235
235
|
}
|
236
236
|
else {
|
237
|
-
|
237
|
+
MessageFormatter.success(`All attributes created successfully for collection ${collection.name}`, { prefix: "Transfer" });
|
238
238
|
}
|
239
239
|
// Handle indexes with enhanced status checking
|
240
|
-
|
240
|
+
MessageFormatter.info(`Creating indexes for collection ${collection.name} with enhanced monitoring...`, { prefix: "Transfer" });
|
241
241
|
const indexesSuccess = await createOrUpdateIndexesWithStatusCheck(toDbId, remoteDb, targetCollection.$id, targetCollection, collection.indexes);
|
242
242
|
if (!indexesSuccess) {
|
243
|
-
|
243
|
+
MessageFormatter.warning(`Failed to create some indexes for collection ${collection.name}`, { prefix: "Transfer" });
|
244
244
|
// Continue with the transfer even if some indexes failed
|
245
245
|
}
|
246
246
|
else {
|
247
|
-
|
247
|
+
MessageFormatter.success(`All indexes created successfully for collection ${collection.name}`, { prefix: "Transfer" });
|
248
248
|
}
|
249
249
|
// Transfer documents
|
250
250
|
const { transferDocumentsBetweenDbsLocalToRemote } = await import("../collections/methods.js");
|
251
251
|
await transferDocumentsBetweenDbsLocalToRemote(localDb, endpoint, projectId, apiKey, fromDbId, toDbId, collection.$id, targetCollection.$id);
|
252
252
|
}
|
253
253
|
catch (error) {
|
254
|
-
|
254
|
+
MessageFormatter.error(`Error processing collection ${collection.name}`, error instanceof Error ? error : new Error(String(error)), { prefix: "Transfer" });
|
255
255
|
}
|
256
256
|
}
|
257
257
|
};
|
258
258
|
export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId, apiKey) => {
|
259
|
-
|
259
|
+
MessageFormatter.info("Starting user transfer to remote instance...", { prefix: "Transfer" });
|
260
260
|
const client = getClient(endpoint, projectId, apiKey);
|
261
261
|
const remoteUsers = new Users(client);
|
262
262
|
let totalTransferred = 0;
|
@@ -278,18 +278,18 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
|
|
278
278
|
remoteUser = await tryAwaitWithRetry(async () => remoteUsers.get(user.$id));
|
279
279
|
// If user exists, update only the differences
|
280
280
|
if (remoteUser) {
|
281
|
-
|
281
|
+
MessageFormatter.info(`User ${user.$id} exists, checking for updates...`, { prefix: "Transfer" });
|
282
282
|
let hasUpdates = false;
|
283
283
|
// Update name if different
|
284
284
|
if (remoteUser.name !== user.name) {
|
285
285
|
await tryAwaitWithRetry(async () => remoteUsers.updateName(user.$id, user.name));
|
286
|
-
|
286
|
+
MessageFormatter.success(`Updated name for user ${user.$id}`, { prefix: "Transfer" });
|
287
287
|
hasUpdates = true;
|
288
288
|
}
|
289
289
|
// Update email if different
|
290
290
|
if (remoteUser.email !== user.email) {
|
291
291
|
await tryAwaitWithRetry(async () => remoteUsers.updateEmail(user.$id, user.email));
|
292
|
-
|
292
|
+
MessageFormatter.success(`Updated email for user ${user.$id}`, { prefix: "Transfer" });
|
293
293
|
hasUpdates = true;
|
294
294
|
}
|
295
295
|
// Update phone if different
|
@@ -300,45 +300,45 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
|
|
300
300
|
if (normalizedLocalPhone) {
|
301
301
|
await tryAwaitWithRetry(async () => remoteUsers.updatePhone(user.$id, normalizedLocalPhone));
|
302
302
|
}
|
303
|
-
|
303
|
+
MessageFormatter.success(`Updated phone for user ${user.$id}`, { prefix: "Transfer" });
|
304
304
|
hasUpdates = true;
|
305
305
|
}
|
306
306
|
// Update preferences if different
|
307
307
|
if (JSON.stringify(remoteUser.prefs) !== JSON.stringify(user.prefs)) {
|
308
308
|
await tryAwaitWithRetry(async () => remoteUsers.updatePrefs(user.$id, user.prefs));
|
309
|
-
|
309
|
+
MessageFormatter.success(`Updated preferences for user ${user.$id}`, { prefix: "Transfer" });
|
310
310
|
hasUpdates = true;
|
311
311
|
}
|
312
312
|
// Update labels if different
|
313
313
|
if (JSON.stringify(remoteUser.labels) !== JSON.stringify(user.labels)) {
|
314
314
|
await tryAwaitWithRetry(async () => remoteUsers.updateLabels(user.$id, user.labels));
|
315
|
-
|
315
|
+
MessageFormatter.success(`Updated labels for user ${user.$id}`, { prefix: "Transfer" });
|
316
316
|
hasUpdates = true;
|
317
317
|
}
|
318
318
|
// Update email verification if different
|
319
319
|
if (remoteUser.emailVerification !== user.emailVerification) {
|
320
320
|
await tryAwaitWithRetry(async () => remoteUsers.updateEmailVerification(user.$id, user.emailVerification));
|
321
|
-
|
321
|
+
MessageFormatter.success(`Updated email verification for user ${user.$id}`, { prefix: "Transfer" });
|
322
322
|
hasUpdates = true;
|
323
323
|
}
|
324
324
|
// Update phone verification if different
|
325
325
|
if (remoteUser.phoneVerification !== user.phoneVerification) {
|
326
326
|
await tryAwaitWithRetry(async () => remoteUsers.updatePhoneVerification(user.$id, user.phoneVerification));
|
327
|
-
|
327
|
+
MessageFormatter.success(`Updated phone verification for user ${user.$id}`, { prefix: "Transfer" });
|
328
328
|
hasUpdates = true;
|
329
329
|
}
|
330
330
|
// Update status if different
|
331
331
|
if (remoteUser.status !== user.status) {
|
332
332
|
await tryAwaitWithRetry(async () => remoteUsers.updateStatus(user.$id, user.status));
|
333
|
-
|
333
|
+
MessageFormatter.success(`Updated status for user ${user.$id}`, { prefix: "Transfer" });
|
334
334
|
hasUpdates = true;
|
335
335
|
}
|
336
336
|
if (!hasUpdates) {
|
337
|
-
|
337
|
+
MessageFormatter.info(`User ${user.$id} is already up to date, skipping...`, { prefix: "Transfer" });
|
338
338
|
}
|
339
339
|
else {
|
340
340
|
totalTransferred++;
|
341
|
-
|
341
|
+
MessageFormatter.success(`Updated user ${user.$id}`, { prefix: "Transfer" });
|
342
342
|
}
|
343
343
|
continue;
|
344
344
|
}
|
@@ -381,7 +381,7 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
|
|
381
381
|
// Warn if using default values due to missing hash options
|
382
382
|
if (!hashOptions.salt ||
|
383
383
|
typeof hashOptions.costCpu !== "number") {
|
384
|
-
|
384
|
+
MessageFormatter.warning(`User ${user.$id}: Using default Scrypt parameters due to missing hashOptions`, { prefix: "Transfer" });
|
385
385
|
}
|
386
386
|
await tryAwaitWithRetry(async () => remoteUsers.createScryptUser(user.$id, user.email, hashedPassword, salt, costCpu, costMemory, costParallel, length, user.name));
|
387
387
|
break;
|
@@ -398,7 +398,7 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
|
|
398
398
|
if (!hashOptions.salt ||
|
399
399
|
!hashOptions.saltSeparator ||
|
400
400
|
!hashOptions.signerKey) {
|
401
|
-
|
401
|
+
MessageFormatter.warning(`User ${user.$id}: Missing critical Scrypt Modified parameters in hashOptions`, { prefix: "Transfer" });
|
402
402
|
}
|
403
403
|
await tryAwaitWithRetry(async () => remoteUsers.createScryptModifiedUser(user.$id, user.email, hashedPassword, modSalt, saltSeparator, signerKey, user.name));
|
404
404
|
break;
|
@@ -428,17 +428,17 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
|
|
428
428
|
await tryAwaitWithRetry(async () => remoteUsers.createPHPassUser(user.$id, user.email, hashedPassword, user.name));
|
429
429
|
break;
|
430
430
|
default:
|
431
|
-
|
431
|
+
MessageFormatter.warning(`Unknown hash type '${hashType}' for user ${user.$id}, falling back to Argon2`, { prefix: "Transfer" });
|
432
432
|
await tryAwaitWithRetry(async () => remoteUsers.createArgon2User(user.$id, user.email, hashedPassword, user.name));
|
433
433
|
break;
|
434
434
|
}
|
435
|
-
|
435
|
+
MessageFormatter.success(`User ${user.$id} created with preserved ${hashType} password`, { prefix: "Transfer" });
|
436
436
|
}
|
437
437
|
catch (error) {
|
438
|
-
|
438
|
+
MessageFormatter.warning(`Failed to create user ${user.$id} with ${hashType} hash, trying with temporary password`, { prefix: "Transfer" });
|
439
439
|
// Fallback to creating user with temporary password
|
440
440
|
await tryAwaitWithRetry(async () => remoteUsers.create(user.$id, user.email, phone, `changeMe${user.email}`, user.name));
|
441
|
-
|
441
|
+
MessageFormatter.warning(`User ${user.$id} created with temporary password - password reset required`, { prefix: "Transfer" });
|
442
442
|
}
|
443
443
|
}
|
444
444
|
else {
|
@@ -446,7 +446,7 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
|
|
446
446
|
const tempPassword = user.password || `changeMe${user.email}`;
|
447
447
|
await tryAwaitWithRetry(async () => remoteUsers.create(user.$id, user.email, phone, tempPassword, user.name));
|
448
448
|
if (!user.password) {
|
449
|
-
|
449
|
+
MessageFormatter.warning(`User ${user.$id} created with temporary password - password reset required`, { prefix: "Transfer" });
|
450
450
|
}
|
451
451
|
}
|
452
452
|
// Update phone, labels, and other attributes for newly created users
|
@@ -471,10 +471,10 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
|
|
471
471
|
await tryAwaitWithRetry(async () => remoteUsers.updateStatus(user.$id, false));
|
472
472
|
}
|
473
473
|
totalTransferred++;
|
474
|
-
|
474
|
+
MessageFormatter.success(`Transferred user ${user.$id}`, { prefix: "Transfer" });
|
475
475
|
}
|
476
476
|
catch (error) {
|
477
|
-
|
477
|
+
MessageFormatter.error(`Failed to transfer user ${user.$id}`, error instanceof Error ? error : new Error(String(error)), { prefix: "Transfer" });
|
478
478
|
}
|
479
479
|
}
|
480
480
|
if (usersList.users.length < 100) {
|
@@ -482,5 +482,5 @@ export const transferUsersLocalToRemote = async (localUsers, endpoint, projectId
|
|
482
482
|
}
|
483
483
|
lastId = usersList.users[usersList.users.length - 1].$id;
|
484
484
|
}
|
485
|
-
|
485
|
+
MessageFormatter.success(`Successfully transferred ${totalTransferred} users`, { prefix: "Transfer" });
|
486
486
|
};
|
@@ -91,12 +91,14 @@ export declare class YamlImportConfigLoader {
|
|
91
91
|
/**
|
92
92
|
* Generates a template YAML import configuration.
|
93
93
|
* Useful for getting started with YAML-based imports.
|
94
|
+
* Supports both collection and table terminology.
|
94
95
|
*
|
95
96
|
* @param collectionName - Name of the collection
|
96
97
|
* @param sourceFile - Source data file name
|
98
|
+
* @param useTableTerminology - Whether to use table terminology
|
97
99
|
* @returns YAML configuration template
|
98
100
|
*/
|
99
|
-
generateTemplate(collectionName: string, sourceFile: string): string;
|
101
|
+
generateTemplate(collectionName: string, sourceFile: string, useTableTerminology?: boolean): string;
|
100
102
|
/**
|
101
103
|
* Creates the import directory structure if it doesn't exist.
|
102
104
|
* Sets up the recommended directory layout for YAML import configurations.
|
@@ -185,12 +185,15 @@ export class YamlImportConfigLoader {
|
|
185
185
|
/**
|
186
186
|
* Generates a template YAML import configuration.
|
187
187
|
* Useful for getting started with YAML-based imports.
|
188
|
+
* Supports both collection and table terminology.
|
188
189
|
*
|
189
190
|
* @param collectionName - Name of the collection
|
190
191
|
* @param sourceFile - Source data file name
|
192
|
+
* @param useTableTerminology - Whether to use table terminology
|
191
193
|
* @returns YAML configuration template
|
192
194
|
*/
|
193
|
-
generateTemplate(collectionName, sourceFile) {
|
195
|
+
generateTemplate(collectionName, sourceFile, useTableTerminology = false) {
|
196
|
+
const entityType = useTableTerminology ? 'table' : 'collection';
|
194
197
|
const template = {
|
195
198
|
source: {
|
196
199
|
file: `importData/${sourceFile}`,
|
@@ -198,7 +201,7 @@ export class YamlImportConfigLoader {
|
|
198
201
|
type: "json"
|
199
202
|
},
|
200
203
|
target: {
|
201
|
-
|
204
|
+
[entityType]: collectionName,
|
202
205
|
type: "create",
|
203
206
|
primaryKey: "id",
|
204
207
|
createUsers: false
|
@@ -240,7 +243,7 @@ export class YamlImportConfigLoader {
|
|
240
243
|
{
|
241
244
|
sourceField: "user_id",
|
242
245
|
targetField: "userId",
|
243
|
-
targetCollection: "Users"
|
246
|
+
[useTableTerminology ? 'targetTable' : 'targetCollection']: "Users"
|
244
247
|
}
|
245
248
|
]
|
246
249
|
},
|
@@ -43,19 +43,23 @@ export declare class YamlImportIntegration {
|
|
43
43
|
/**
|
44
44
|
* Generates a YAML import configuration from an existing ImportDef.
|
45
45
|
* Useful for migrating TypeScript configurations to YAML.
|
46
|
+
* Supports both collection and table terminology.
|
46
47
|
*
|
47
48
|
* @param importDef - Existing ImportDef to convert
|
48
49
|
* @param collectionName - Name of the collection
|
50
|
+
* @param useTableTerminology - Whether to use table terminology
|
49
51
|
* @returns YAML configuration string
|
50
52
|
*/
|
51
|
-
convertImportDefToYaml(importDef: ImportDef, collectionName: string): string;
|
53
|
+
convertImportDefToYaml(importDef: ImportDef, collectionName: string, useTableTerminology?: boolean): string;
|
52
54
|
/**
|
53
55
|
* Exports existing TypeScript import configurations to YAML files.
|
54
56
|
* Helps migrate from TypeScript to YAML-based configurations.
|
57
|
+
* Supports both collection and table terminology.
|
55
58
|
*
|
56
59
|
* @param collections - Collections with existing import definitions
|
60
|
+
* @param useTableTerminology - Whether to use table terminology
|
57
61
|
*/
|
58
|
-
exportToYaml(collections: CollectionCreate[]): Promise<void>;
|
62
|
+
exportToYaml(collections: CollectionCreate[], useTableTerminology?: boolean): Promise<void>;
|
59
63
|
/**
|
60
64
|
* Gets statistics about YAML import configurations.
|
61
65
|
*/
|
@@ -71,12 +75,14 @@ export declare class YamlImportIntegration {
|
|
71
75
|
}>;
|
72
76
|
/**
|
73
77
|
* Creates a new YAML import configuration from a template.
|
78
|
+
* Supports both collection and table terminology.
|
74
79
|
*
|
75
80
|
* @param collectionName - Name of the collection
|
76
81
|
* @param sourceFile - Source data file name
|
82
|
+
* @param useTableTerminology - Whether to use table terminology
|
77
83
|
* @param outputPath - Output file path (optional)
|
78
84
|
*/
|
79
|
-
createFromTemplate(collectionName: string, sourceFile: string, outputPath?: string): Promise<string>;
|
85
|
+
createFromTemplate(collectionName: string, sourceFile: string, useTableTerminology?: boolean, outputPath?: string): Promise<string>;
|
80
86
|
/**
|
81
87
|
* Checks if YAML import system is properly set up.
|
82
88
|
*/
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { YamlImportConfigLoader } from "./YamlImportConfigLoader.js";
|
2
2
|
import { createImportSchemas, createImportExamples } from "./generateImportSchemas.js";
|
3
3
|
import { logger } from "../../shared/logging.js";
|
4
|
+
import { normalizeYamlData, usesTableTerminology, convertTerminology } from "../../utils/yamlConverter.js";
|
4
5
|
import path from "path";
|
5
6
|
import fs from "fs";
|
6
7
|
/**
|
@@ -171,12 +172,14 @@ export class YamlImportIntegration {
|
|
171
172
|
/**
|
172
173
|
* Generates a YAML import configuration from an existing ImportDef.
|
173
174
|
* Useful for migrating TypeScript configurations to YAML.
|
175
|
+
* Supports both collection and table terminology.
|
174
176
|
*
|
175
177
|
* @param importDef - Existing ImportDef to convert
|
176
178
|
* @param collectionName - Name of the collection
|
179
|
+
* @param useTableTerminology - Whether to use table terminology
|
177
180
|
* @returns YAML configuration string
|
178
181
|
*/
|
179
|
-
convertImportDefToYaml(importDef, collectionName) {
|
182
|
+
convertImportDefToYaml(importDef, collectionName, useTableTerminology = false) {
|
180
183
|
const yamlConfig = {
|
181
184
|
source: {
|
182
185
|
file: importDef.filePath,
|
@@ -228,15 +231,18 @@ export class YamlImportIntegration {
|
|
228
231
|
lineWidth: 120,
|
229
232
|
sortKeys: false,
|
230
233
|
});
|
231
|
-
|
234
|
+
const entityType = useTableTerminology ? 'Table' : 'Collection';
|
235
|
+
return `# yaml-language-server: $schema=../.yaml_schemas/import-config.schema.json\n# Import Configuration for ${entityType}: ${collectionName}\n\n${yamlContent}`;
|
232
236
|
}
|
233
237
|
/**
|
234
238
|
* Exports existing TypeScript import configurations to YAML files.
|
235
239
|
* Helps migrate from TypeScript to YAML-based configurations.
|
240
|
+
* Supports both collection and table terminology.
|
236
241
|
*
|
237
242
|
* @param collections - Collections with existing import definitions
|
243
|
+
* @param useTableTerminology - Whether to use table terminology
|
238
244
|
*/
|
239
|
-
async exportToYaml(collections) {
|
245
|
+
async exportToYaml(collections, useTableTerminology = false) {
|
240
246
|
const exportDir = path.join(this.appwriteFolderPath, "import", "exported");
|
241
247
|
if (!fs.existsSync(exportDir)) {
|
242
248
|
fs.mkdirSync(exportDir, { recursive: true });
|
@@ -248,10 +254,11 @@ export class YamlImportIntegration {
|
|
248
254
|
}
|
249
255
|
for (let i = 0; i < collection.importDefs.length; i++) {
|
250
256
|
const importDef = collection.importDefs[i];
|
251
|
-
const yamlContent = this.convertImportDefToYaml(importDef, collection.name);
|
257
|
+
const yamlContent = this.convertImportDefToYaml(importDef, collection.name, useTableTerminology);
|
258
|
+
const entityType = useTableTerminology ? 'table' : 'collection';
|
252
259
|
const filename = collection.importDefs.length > 1
|
253
|
-
? `${collection.name}-${i + 1}.yaml`
|
254
|
-
: `${collection.name}.yaml`;
|
260
|
+
? `${collection.name}-${entityType}-${i + 1}.yaml`
|
261
|
+
: `${collection.name}-${entityType}.yaml`;
|
255
262
|
const filePath = path.join(exportDir, filename);
|
256
263
|
fs.writeFileSync(filePath, yamlContent);
|
257
264
|
exportedCount++;
|
@@ -290,18 +297,22 @@ export class YamlImportIntegration {
|
|
290
297
|
}
|
291
298
|
/**
|
292
299
|
* Creates a new YAML import configuration from a template.
|
300
|
+
* Supports both collection and table terminology.
|
293
301
|
*
|
294
302
|
* @param collectionName - Name of the collection
|
295
303
|
* @param sourceFile - Source data file name
|
304
|
+
* @param useTableTerminology - Whether to use table terminology
|
296
305
|
* @param outputPath - Output file path (optional)
|
297
306
|
*/
|
298
|
-
async createFromTemplate(collectionName, sourceFile, outputPath) {
|
299
|
-
const template = this.configLoader.generateTemplate(collectionName, sourceFile);
|
300
|
-
const
|
307
|
+
async createFromTemplate(collectionName, sourceFile, useTableTerminology = false, outputPath) {
|
308
|
+
const template = this.configLoader.generateTemplate(collectionName, sourceFile, useTableTerminology);
|
309
|
+
const entityType = useTableTerminology ? 'table' : 'collection';
|
310
|
+
const fileName = outputPath || `${collectionName.toLowerCase()}-${entityType}-import.yaml`;
|
301
311
|
const fullPath = path.join(this.appwriteFolderPath, "import", fileName);
|
302
|
-
// Add schema reference to template
|
312
|
+
// Add schema reference to template with entity type comment
|
303
313
|
const schemaHeader = "# yaml-language-server: $schema=../.yaml_schemas/import-config.schema.json\n";
|
304
|
-
const
|
314
|
+
const entityComment = `# Import Configuration for ${useTableTerminology ? 'Table' : 'Collection'}: ${collectionName}\n`;
|
315
|
+
const templateWithSchema = schemaHeader + entityComment + template;
|
305
316
|
fs.writeFileSync(fullPath, templateWithSchema);
|
306
317
|
logger.info(`Created YAML import configuration: ${fullPath}`);
|
307
318
|
return fullPath;
|
@@ -4,7 +4,20 @@
|
|
4
4
|
*/
|
5
5
|
export declare function generateImportConfigSchema(): any;
|
6
6
|
/**
|
7
|
-
*
|
7
|
+
* Generates JSON Schema for collection definitions (legacy Databases API)
|
8
|
+
*/
|
9
|
+
export declare function generateCollectionSchema(): any;
|
10
|
+
/**
|
11
|
+
* Generates JSON Schema for table definitions (new TablesDB API)
|
12
|
+
*/
|
13
|
+
export declare function generateTableSchema(): any;
|
14
|
+
/**
|
15
|
+
* Generates JSON Schema for main Appwrite configuration (YAML format)
|
16
|
+
* Matches the structure of YamlConfigSchema from yamlConfig.ts
|
17
|
+
*/
|
18
|
+
export declare function generateAppwriteConfigSchema(): any;
|
19
|
+
/**
|
20
|
+
* Creates all necessary schema files for YAML configurations.
|
8
21
|
*
|
9
22
|
* @param appwriteFolderPath - Path to the .appwrite directory
|
10
23
|
*/
|