appwrite-utils-cli 1.5.2 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +479 -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 +209 -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 +274 -1563
- 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
@@ -321,7 +321,723 @@ export function generateImportConfigSchema() {
|
|
321
321
|
};
|
322
322
|
}
|
323
323
|
/**
|
324
|
-
*
|
324
|
+
* Generates JSON Schema for collection definitions (legacy Databases API)
|
325
|
+
*/
|
326
|
+
export function generateCollectionSchema() {
|
327
|
+
return {
|
328
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
329
|
+
"$id": "https://appwrite-utils.dev/schemas/collection.schema.json",
|
330
|
+
"title": "Appwrite Collection Definition",
|
331
|
+
"description": "YAML configuration for Appwrite collection definitions (legacy Databases API)",
|
332
|
+
"type": "object",
|
333
|
+
"properties": {
|
334
|
+
"name": {
|
335
|
+
"type": "string",
|
336
|
+
"description": "Collection name",
|
337
|
+
"minLength": 1
|
338
|
+
},
|
339
|
+
"id": {
|
340
|
+
"type": "string",
|
341
|
+
"description": "Collection ID",
|
342
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9_-]*$"
|
343
|
+
},
|
344
|
+
"documentSecurity": {
|
345
|
+
"type": "boolean",
|
346
|
+
"description": "Enable document-level security",
|
347
|
+
"default": false
|
348
|
+
},
|
349
|
+
"enabled": {
|
350
|
+
"type": "boolean",
|
351
|
+
"description": "Whether the collection is enabled",
|
352
|
+
"default": true
|
353
|
+
},
|
354
|
+
"permissions": {
|
355
|
+
"type": "array",
|
356
|
+
"description": "Collection-level permissions",
|
357
|
+
"items": {
|
358
|
+
"$ref": "#/$defs/permission"
|
359
|
+
},
|
360
|
+
"default": []
|
361
|
+
},
|
362
|
+
"attributes": {
|
363
|
+
"type": "array",
|
364
|
+
"description": "Collection attributes (fields)",
|
365
|
+
"items": {
|
366
|
+
"$ref": "#/$defs/attribute"
|
367
|
+
},
|
368
|
+
"default": []
|
369
|
+
},
|
370
|
+
"indexes": {
|
371
|
+
"type": "array",
|
372
|
+
"description": "Collection indexes",
|
373
|
+
"items": {
|
374
|
+
"$ref": "#/$defs/index"
|
375
|
+
},
|
376
|
+
"default": []
|
377
|
+
},
|
378
|
+
"importDefs": {
|
379
|
+
"type": "array",
|
380
|
+
"description": "Import definitions for data migration",
|
381
|
+
"default": []
|
382
|
+
}
|
383
|
+
},
|
384
|
+
"required": ["name"],
|
385
|
+
"additionalProperties": false,
|
386
|
+
"$defs": {
|
387
|
+
"permission": {
|
388
|
+
"type": "object",
|
389
|
+
"properties": {
|
390
|
+
"permission": {
|
391
|
+
"type": "string",
|
392
|
+
"enum": ["read", "write", "create", "update", "delete"]
|
393
|
+
},
|
394
|
+
"target": {
|
395
|
+
"type": "string",
|
396
|
+
"description": "Permission target (e.g., 'users', 'guests', role:admin)"
|
397
|
+
}
|
398
|
+
},
|
399
|
+
"required": ["permission", "target"],
|
400
|
+
"additionalProperties": false
|
401
|
+
},
|
402
|
+
"attribute": {
|
403
|
+
"type": "object",
|
404
|
+
"properties": {
|
405
|
+
"key": {
|
406
|
+
"type": "string",
|
407
|
+
"description": "Attribute key/name",
|
408
|
+
"pattern": "^[a-zA-Z][a-zA-Z0-9_]*$"
|
409
|
+
},
|
410
|
+
"type": {
|
411
|
+
"type": "string",
|
412
|
+
"enum": ["string", "integer", "double", "boolean", "datetime", "email", "ip", "url", "enum", "relationship"]
|
413
|
+
},
|
414
|
+
"size": {
|
415
|
+
"type": "number",
|
416
|
+
"description": "Maximum size for string attributes"
|
417
|
+
},
|
418
|
+
"required": {
|
419
|
+
"type": "boolean",
|
420
|
+
"default": false
|
421
|
+
},
|
422
|
+
"array": {
|
423
|
+
"type": "boolean",
|
424
|
+
"default": false
|
425
|
+
},
|
426
|
+
"default": {
|
427
|
+
"description": "Default value for the attribute"
|
428
|
+
},
|
429
|
+
"min": {
|
430
|
+
"type": "number",
|
431
|
+
"description": "Minimum value for numeric attributes"
|
432
|
+
},
|
433
|
+
"max": {
|
434
|
+
"type": "number",
|
435
|
+
"description": "Maximum value for numeric attributes"
|
436
|
+
},
|
437
|
+
"elements": {
|
438
|
+
"type": "array",
|
439
|
+
"items": { "type": "string" },
|
440
|
+
"description": "Allowed values for enum attributes"
|
441
|
+
},
|
442
|
+
"relatedCollection": {
|
443
|
+
"type": "string",
|
444
|
+
"description": "Related collection for relationship attributes"
|
445
|
+
},
|
446
|
+
"relationType": {
|
447
|
+
"type": "string",
|
448
|
+
"enum": ["oneToOne", "oneToMany", "manyToOne", "manyToMany"]
|
449
|
+
},
|
450
|
+
"twoWay": {
|
451
|
+
"type": "boolean",
|
452
|
+
"description": "Enable two-way relationship"
|
453
|
+
},
|
454
|
+
"twoWayKey": {
|
455
|
+
"type": "string",
|
456
|
+
"description": "Key for the reverse relationship"
|
457
|
+
},
|
458
|
+
"onDelete": {
|
459
|
+
"type": "string",
|
460
|
+
"enum": ["cascade", "restrict", "setNull"]
|
461
|
+
},
|
462
|
+
"side": {
|
463
|
+
"type": "string",
|
464
|
+
"enum": ["parent", "child"]
|
465
|
+
}
|
466
|
+
},
|
467
|
+
"required": ["key", "type"],
|
468
|
+
"additionalProperties": false
|
469
|
+
},
|
470
|
+
"index": {
|
471
|
+
"type": "object",
|
472
|
+
"properties": {
|
473
|
+
"key": {
|
474
|
+
"type": "string",
|
475
|
+
"description": "Index key/name"
|
476
|
+
},
|
477
|
+
"type": {
|
478
|
+
"type": "string",
|
479
|
+
"enum": ["key", "fulltext", "unique"]
|
480
|
+
},
|
481
|
+
"attributes": {
|
482
|
+
"type": "array",
|
483
|
+
"items": { "type": "string" },
|
484
|
+
"description": "Attribute names to include in the index",
|
485
|
+
"minItems": 1
|
486
|
+
},
|
487
|
+
"orders": {
|
488
|
+
"type": "array",
|
489
|
+
"items": {
|
490
|
+
"type": "string",
|
491
|
+
"enum": ["asc", "desc"]
|
492
|
+
},
|
493
|
+
"description": "Sort orders for indexed attributes"
|
494
|
+
}
|
495
|
+
},
|
496
|
+
"required": ["key", "type", "attributes"],
|
497
|
+
"additionalProperties": false
|
498
|
+
}
|
499
|
+
}
|
500
|
+
};
|
501
|
+
}
|
502
|
+
/**
|
503
|
+
* Generates JSON Schema for table definitions (new TablesDB API)
|
504
|
+
*/
|
505
|
+
export function generateTableSchema() {
|
506
|
+
const collectionSchema = generateCollectionSchema();
|
507
|
+
// Clone and modify the collection schema for table terminology
|
508
|
+
const tableSchema = JSON.parse(JSON.stringify(collectionSchema));
|
509
|
+
// Update metadata
|
510
|
+
tableSchema.$id = "https://appwrite-utils.dev/schemas/table.schema.json";
|
511
|
+
tableSchema.title = "Appwrite Table Definition";
|
512
|
+
tableSchema.description = "YAML configuration for Appwrite table definitions (new TablesDB API)";
|
513
|
+
// Replace 'attributes' with 'columns'
|
514
|
+
delete tableSchema.properties.attributes;
|
515
|
+
tableSchema.properties.columns = {
|
516
|
+
"type": "array",
|
517
|
+
"description": "Table columns (fields)",
|
518
|
+
"items": {
|
519
|
+
"$ref": "#/$defs/column"
|
520
|
+
},
|
521
|
+
"default": []
|
522
|
+
};
|
523
|
+
// Update index definition to support both attributes and columns
|
524
|
+
tableSchema.$defs.index.properties.columns = {
|
525
|
+
"type": "array",
|
526
|
+
"items": { "type": "string" },
|
527
|
+
"description": "Column names to include in the index",
|
528
|
+
"minItems": 1
|
529
|
+
};
|
530
|
+
// Make index support either attributes or columns
|
531
|
+
tableSchema.$defs.index.oneOf = [
|
532
|
+
{ "required": ["key", "type", "attributes"] },
|
533
|
+
{ "required": ["key", "type", "columns"] }
|
534
|
+
];
|
535
|
+
delete tableSchema.$defs.index.required;
|
536
|
+
// Add column definition (similar to attribute but with table terminology)
|
537
|
+
tableSchema.$defs.column = JSON.parse(JSON.stringify(tableSchema.$defs.attribute));
|
538
|
+
tableSchema.$defs.column.properties.relatedTable = {
|
539
|
+
"type": "string",
|
540
|
+
"description": "Related table for relationship columns"
|
541
|
+
};
|
542
|
+
delete tableSchema.$defs.column.properties.relatedCollection;
|
543
|
+
return tableSchema;
|
544
|
+
}
|
545
|
+
/**
|
546
|
+
* Generates JSON Schema for main Appwrite configuration (YAML format)
|
547
|
+
* Matches the structure of YamlConfigSchema from yamlConfig.ts
|
548
|
+
*/
|
549
|
+
export function generateAppwriteConfigSchema() {
|
550
|
+
return {
|
551
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
552
|
+
"$id": "https://appwrite-utils.dev/schemas/appwrite-config.schema.json",
|
553
|
+
"title": "Appwrite Project Configuration",
|
554
|
+
"description": "Main YAML configuration file for Appwrite projects with dual API support (Collections API and TablesDB API)",
|
555
|
+
"type": "object",
|
556
|
+
"properties": {
|
557
|
+
"appwrite": {
|
558
|
+
"type": "object",
|
559
|
+
"description": "Appwrite connection and authentication settings",
|
560
|
+
"properties": {
|
561
|
+
"endpoint": {
|
562
|
+
"type": "string",
|
563
|
+
"format": "uri",
|
564
|
+
"default": "https://cloud.appwrite.io/v1",
|
565
|
+
"description": "Appwrite API endpoint"
|
566
|
+
},
|
567
|
+
"project": {
|
568
|
+
"type": "string",
|
569
|
+
"description": "Appwrite project ID"
|
570
|
+
},
|
571
|
+
"key": {
|
572
|
+
"type": "string",
|
573
|
+
"description": "Appwrite API key for authentication"
|
574
|
+
},
|
575
|
+
"sessionCookie": {
|
576
|
+
"type": "string",
|
577
|
+
"description": "Session cookie for authentication (alternative to API key)"
|
578
|
+
},
|
579
|
+
"authMethod": {
|
580
|
+
"type": "string",
|
581
|
+
"enum": ["session", "apikey", "auto"],
|
582
|
+
"default": "auto",
|
583
|
+
"description": "Authentication method: 'session' for session auth, 'apikey' for API key, 'auto' for automatic detection"
|
584
|
+
},
|
585
|
+
"sessionMetadata": {
|
586
|
+
"type": "object",
|
587
|
+
"description": "Metadata about the current session",
|
588
|
+
"properties": {
|
589
|
+
"email": {
|
590
|
+
"type": "string",
|
591
|
+
"description": "Email associated with the session"
|
592
|
+
},
|
593
|
+
"expiresAt": {
|
594
|
+
"type": "string",
|
595
|
+
"description": "Session expiration timestamp (ISO string)"
|
596
|
+
}
|
597
|
+
},
|
598
|
+
"additionalProperties": false
|
599
|
+
}
|
600
|
+
},
|
601
|
+
"required": ["endpoint", "project", "key"],
|
602
|
+
"additionalProperties": false
|
603
|
+
},
|
604
|
+
"logging": {
|
605
|
+
"type": "object",
|
606
|
+
"description": "Logging configuration",
|
607
|
+
"properties": {
|
608
|
+
"enabled": {
|
609
|
+
"type": "boolean",
|
610
|
+
"default": false,
|
611
|
+
"description": "Enable file logging"
|
612
|
+
},
|
613
|
+
"level": {
|
614
|
+
"type": "string",
|
615
|
+
"enum": ["error", "warn", "info", "debug"],
|
616
|
+
"default": "info",
|
617
|
+
"description": "Logging level"
|
618
|
+
},
|
619
|
+
"directory": {
|
620
|
+
"type": "string",
|
621
|
+
"description": "Custom log directory path (default: ./zlogs)"
|
622
|
+
},
|
623
|
+
"console": {
|
624
|
+
"type": "boolean",
|
625
|
+
"default": false,
|
626
|
+
"description": "Enable console logging"
|
627
|
+
}
|
628
|
+
},
|
629
|
+
"additionalProperties": false
|
630
|
+
},
|
631
|
+
"backups": {
|
632
|
+
"type": "object",
|
633
|
+
"description": "Backup configuration",
|
634
|
+
"properties": {
|
635
|
+
"enabled": {
|
636
|
+
"type": "boolean",
|
637
|
+
"default": true,
|
638
|
+
"description": "Enable backups"
|
639
|
+
},
|
640
|
+
"interval": {
|
641
|
+
"type": "number",
|
642
|
+
"default": 3600,
|
643
|
+
"description": "Backup interval in seconds"
|
644
|
+
},
|
645
|
+
"retention": {
|
646
|
+
"type": "number",
|
647
|
+
"default": 30,
|
648
|
+
"description": "Backup retention in days"
|
649
|
+
},
|
650
|
+
"cleanup": {
|
651
|
+
"type": "boolean",
|
652
|
+
"default": true,
|
653
|
+
"description": "Enable backup cleanup"
|
654
|
+
}
|
655
|
+
},
|
656
|
+
"additionalProperties": false
|
657
|
+
},
|
658
|
+
"data": {
|
659
|
+
"type": "object",
|
660
|
+
"description": "Data handling configuration",
|
661
|
+
"properties": {
|
662
|
+
"enableMockData": {
|
663
|
+
"type": "boolean",
|
664
|
+
"default": false,
|
665
|
+
"description": "Enable mock data generation"
|
666
|
+
},
|
667
|
+
"documentBucketId": {
|
668
|
+
"type": "string",
|
669
|
+
"default": "documents",
|
670
|
+
"description": "Documents bucket ID for imported documents"
|
671
|
+
},
|
672
|
+
"usersCollectionName": {
|
673
|
+
"type": "string",
|
674
|
+
"default": "Members",
|
675
|
+
"description": "Users collection name for any overflowing data associated with users"
|
676
|
+
},
|
677
|
+
"importDirectory": {
|
678
|
+
"type": "string",
|
679
|
+
"default": "importData",
|
680
|
+
"description": "Directory for import data files"
|
681
|
+
}
|
682
|
+
},
|
683
|
+
"additionalProperties": false
|
684
|
+
},
|
685
|
+
"schemas": {
|
686
|
+
"type": "object",
|
687
|
+
"description": "Schema and directory configuration",
|
688
|
+
"properties": {
|
689
|
+
"outputDirectory": {
|
690
|
+
"type": "string",
|
691
|
+
"default": "schemas",
|
692
|
+
"description": "Directory for generated TypeScript schemas"
|
693
|
+
},
|
694
|
+
"yamlSchemaDirectory": {
|
695
|
+
"type": "string",
|
696
|
+
"default": ".yaml_schemas",
|
697
|
+
"description": "Directory for JSON schemas used for YAML validation"
|
698
|
+
},
|
699
|
+
"collectionsDirectory": {
|
700
|
+
"type": "string",
|
701
|
+
"default": "collections",
|
702
|
+
"description": "Directory name for legacy collections definitions"
|
703
|
+
},
|
704
|
+
"tablesDirectory": {
|
705
|
+
"type": "string",
|
706
|
+
"default": "tables",
|
707
|
+
"description": "Directory name for TablesDB table definitions"
|
708
|
+
}
|
709
|
+
},
|
710
|
+
"additionalProperties": false
|
711
|
+
},
|
712
|
+
"migrations": {
|
713
|
+
"type": "object",
|
714
|
+
"description": "Migration configuration",
|
715
|
+
"properties": {
|
716
|
+
"enabled": {
|
717
|
+
"type": "boolean",
|
718
|
+
"default": true,
|
719
|
+
"description": "Enable migrations"
|
720
|
+
}
|
721
|
+
},
|
722
|
+
"additionalProperties": false
|
723
|
+
},
|
724
|
+
"databases": {
|
725
|
+
"type": "array",
|
726
|
+
"description": "Databases to create",
|
727
|
+
"items": {
|
728
|
+
"type": "object",
|
729
|
+
"properties": {
|
730
|
+
"id": {
|
731
|
+
"type": "string",
|
732
|
+
"description": "Database ID"
|
733
|
+
},
|
734
|
+
"name": {
|
735
|
+
"type": "string",
|
736
|
+
"description": "Database name"
|
737
|
+
},
|
738
|
+
"bucket": {
|
739
|
+
"type": "object",
|
740
|
+
"description": "Optional bucket configuration for this database",
|
741
|
+
"properties": {
|
742
|
+
"id": {
|
743
|
+
"type": "string",
|
744
|
+
"description": "Bucket ID"
|
745
|
+
},
|
746
|
+
"name": {
|
747
|
+
"type": "string",
|
748
|
+
"description": "Bucket name"
|
749
|
+
},
|
750
|
+
"permissions": {
|
751
|
+
"type": "array",
|
752
|
+
"description": "Bucket permissions",
|
753
|
+
"items": {
|
754
|
+
"$ref": "#/$defs/permission"
|
755
|
+
}
|
756
|
+
},
|
757
|
+
"fileSecurity": {
|
758
|
+
"type": "boolean",
|
759
|
+
"default": false,
|
760
|
+
"description": "Enable file-level security"
|
761
|
+
},
|
762
|
+
"enabled": {
|
763
|
+
"type": "boolean",
|
764
|
+
"default": true,
|
765
|
+
"description": "Enable the bucket"
|
766
|
+
},
|
767
|
+
"maximumFileSize": {
|
768
|
+
"type": "number",
|
769
|
+
"default": 30000000,
|
770
|
+
"description": "Maximum file size in bytes"
|
771
|
+
},
|
772
|
+
"allowedFileExtensions": {
|
773
|
+
"type": "array",
|
774
|
+
"items": { "type": "string" },
|
775
|
+
"default": [],
|
776
|
+
"description": "Allowed file extensions"
|
777
|
+
},
|
778
|
+
"compression": {
|
779
|
+
"type": "string",
|
780
|
+
"enum": ["none", "gzip", "zstd"],
|
781
|
+
"default": "none",
|
782
|
+
"description": "Compression algorithm"
|
783
|
+
},
|
784
|
+
"encryption": {
|
785
|
+
"type": "boolean",
|
786
|
+
"default": false,
|
787
|
+
"description": "Enable encryption"
|
788
|
+
},
|
789
|
+
"antivirus": {
|
790
|
+
"type": "boolean",
|
791
|
+
"default": false,
|
792
|
+
"description": "Enable antivirus scanning"
|
793
|
+
}
|
794
|
+
},
|
795
|
+
"required": ["id", "name"],
|
796
|
+
"additionalProperties": false
|
797
|
+
}
|
798
|
+
},
|
799
|
+
"required": ["id", "name"],
|
800
|
+
"additionalProperties": false
|
801
|
+
},
|
802
|
+
"default": [
|
803
|
+
{ "id": "dev", "name": "Development" },
|
804
|
+
{ "id": "main", "name": "Main" },
|
805
|
+
{ "id": "staging", "name": "Staging" }
|
806
|
+
]
|
807
|
+
},
|
808
|
+
"buckets": {
|
809
|
+
"type": "array",
|
810
|
+
"description": "Global buckets to create across all databases",
|
811
|
+
"items": {
|
812
|
+
"type": "object",
|
813
|
+
"properties": {
|
814
|
+
"id": {
|
815
|
+
"type": "string",
|
816
|
+
"description": "Bucket ID"
|
817
|
+
},
|
818
|
+
"name": {
|
819
|
+
"type": "string",
|
820
|
+
"description": "Bucket name"
|
821
|
+
},
|
822
|
+
"permissions": {
|
823
|
+
"type": "array",
|
824
|
+
"description": "Bucket permissions",
|
825
|
+
"items": {
|
826
|
+
"$ref": "#/$defs/permission"
|
827
|
+
}
|
828
|
+
},
|
829
|
+
"fileSecurity": {
|
830
|
+
"type": "boolean",
|
831
|
+
"default": false,
|
832
|
+
"description": "Enable file-level security"
|
833
|
+
},
|
834
|
+
"enabled": {
|
835
|
+
"type": "boolean",
|
836
|
+
"default": true,
|
837
|
+
"description": "Enable the bucket"
|
838
|
+
},
|
839
|
+
"maximumFileSize": {
|
840
|
+
"type": "number",
|
841
|
+
"default": 30000000,
|
842
|
+
"description": "Maximum file size in bytes"
|
843
|
+
},
|
844
|
+
"allowedFileExtensions": {
|
845
|
+
"type": "array",
|
846
|
+
"items": { "type": "string" },
|
847
|
+
"default": [],
|
848
|
+
"description": "Allowed file extensions"
|
849
|
+
},
|
850
|
+
"compression": {
|
851
|
+
"type": "string",
|
852
|
+
"enum": ["none", "gzip", "zstd"],
|
853
|
+
"default": "none",
|
854
|
+
"description": "Compression algorithm"
|
855
|
+
},
|
856
|
+
"encryption": {
|
857
|
+
"type": "boolean",
|
858
|
+
"default": false,
|
859
|
+
"description": "Enable encryption"
|
860
|
+
},
|
861
|
+
"antivirus": {
|
862
|
+
"type": "boolean",
|
863
|
+
"default": false,
|
864
|
+
"description": "Enable antivirus scanning"
|
865
|
+
}
|
866
|
+
},
|
867
|
+
"required": ["id", "name"],
|
868
|
+
"additionalProperties": false
|
869
|
+
},
|
870
|
+
"default": []
|
871
|
+
},
|
872
|
+
"functions": {
|
873
|
+
"type": "array",
|
874
|
+
"description": "Appwrite Functions to create",
|
875
|
+
"items": {
|
876
|
+
"type": "object",
|
877
|
+
"properties": {
|
878
|
+
"id": {
|
879
|
+
"type": "string",
|
880
|
+
"description": "Function ID"
|
881
|
+
},
|
882
|
+
"name": {
|
883
|
+
"type": "string",
|
884
|
+
"description": "Function name"
|
885
|
+
},
|
886
|
+
"runtime": {
|
887
|
+
"type": "string",
|
888
|
+
"description": "Runtime identifier (e.g., 'node-18.0', 'python-3.9')"
|
889
|
+
},
|
890
|
+
"execute": {
|
891
|
+
"type": "array",
|
892
|
+
"items": { "type": "string" },
|
893
|
+
"description": "Execution permissions"
|
894
|
+
},
|
895
|
+
"events": {
|
896
|
+
"type": "array",
|
897
|
+
"items": { "type": "string" },
|
898
|
+
"description": "Trigger events"
|
899
|
+
},
|
900
|
+
"schedule": {
|
901
|
+
"type": "string",
|
902
|
+
"description": "Cron schedule"
|
903
|
+
},
|
904
|
+
"timeout": {
|
905
|
+
"type": "number",
|
906
|
+
"default": 15,
|
907
|
+
"description": "Execution timeout in seconds"
|
908
|
+
},
|
909
|
+
"enabled": {
|
910
|
+
"type": "boolean",
|
911
|
+
"default": true,
|
912
|
+
"description": "Enable the function"
|
913
|
+
},
|
914
|
+
"logging": {
|
915
|
+
"type": "boolean",
|
916
|
+
"default": true,
|
917
|
+
"description": "Enable logging"
|
918
|
+
},
|
919
|
+
"entrypoint": {
|
920
|
+
"type": "string",
|
921
|
+
"description": "Function entrypoint file"
|
922
|
+
},
|
923
|
+
"commands": {
|
924
|
+
"type": "string",
|
925
|
+
"description": "Build commands"
|
926
|
+
},
|
927
|
+
"scopes": {
|
928
|
+
"type": "array",
|
929
|
+
"items": { "type": "string" },
|
930
|
+
"description": "Function scopes/permissions"
|
931
|
+
},
|
932
|
+
"installationId": {
|
933
|
+
"type": "string",
|
934
|
+
"description": "GitHub installation ID"
|
935
|
+
},
|
936
|
+
"providerRepositoryId": {
|
937
|
+
"type": "string",
|
938
|
+
"description": "Provider repository ID"
|
939
|
+
},
|
940
|
+
"providerBranch": {
|
941
|
+
"type": "string",
|
942
|
+
"description": "Provider branch"
|
943
|
+
},
|
944
|
+
"providerSilentMode": {
|
945
|
+
"type": "boolean",
|
946
|
+
"description": "Enable silent mode"
|
947
|
+
},
|
948
|
+
"providerRootDirectory": {
|
949
|
+
"type": "string",
|
950
|
+
"description": "Provider root directory"
|
951
|
+
},
|
952
|
+
"templateRepository": {
|
953
|
+
"type": "string",
|
954
|
+
"description": "Template repository"
|
955
|
+
},
|
956
|
+
"templateOwner": {
|
957
|
+
"type": "string",
|
958
|
+
"description": "Template owner"
|
959
|
+
},
|
960
|
+
"templateRootDirectory": {
|
961
|
+
"type": "string",
|
962
|
+
"description": "Template root directory"
|
963
|
+
},
|
964
|
+
"templateBranch": {
|
965
|
+
"type": "string",
|
966
|
+
"description": "Template branch"
|
967
|
+
},
|
968
|
+
"specification": {
|
969
|
+
"type": "string",
|
970
|
+
"default": "s-0.5vcpu-512mb",
|
971
|
+
"description": "Function specification"
|
972
|
+
},
|
973
|
+
"dirPath": {
|
974
|
+
"type": "string",
|
975
|
+
"description": "Local directory path for function code"
|
976
|
+
},
|
977
|
+
"predeployCommands": {
|
978
|
+
"type": "array",
|
979
|
+
"items": { "type": "string" },
|
980
|
+
"description": "Commands to run before deployment"
|
981
|
+
},
|
982
|
+
"deployDir": {
|
983
|
+
"type": "string",
|
984
|
+
"description": "Deployment directory"
|
985
|
+
},
|
986
|
+
"ignore": {
|
987
|
+
"type": "array",
|
988
|
+
"items": { "type": "string" },
|
989
|
+
"description": "Files to ignore during deployment"
|
990
|
+
},
|
991
|
+
"templateVersion": {
|
992
|
+
"type": "string",
|
993
|
+
"description": "Template version"
|
994
|
+
}
|
995
|
+
},
|
996
|
+
"required": ["id", "name", "runtime"],
|
997
|
+
"additionalProperties": false
|
998
|
+
},
|
999
|
+
"default": []
|
1000
|
+
},
|
1001
|
+
"collections": {
|
1002
|
+
"type": "array",
|
1003
|
+
"description": "Collections to create using the legacy Databases API (deprecated - use separate collection files)",
|
1004
|
+
"items": {
|
1005
|
+
"$ref": "./collection.schema.json"
|
1006
|
+
},
|
1007
|
+
"default": []
|
1008
|
+
},
|
1009
|
+
"tables": {
|
1010
|
+
"type": "array",
|
1011
|
+
"description": "Tables to create using the new TablesDB API (deprecated - use separate table files)",
|
1012
|
+
"items": {
|
1013
|
+
"$ref": "./table.schema.json"
|
1014
|
+
},
|
1015
|
+
"default": []
|
1016
|
+
}
|
1017
|
+
},
|
1018
|
+
"required": ["appwrite"],
|
1019
|
+
"additionalProperties": false,
|
1020
|
+
"$defs": {
|
1021
|
+
"permission": {
|
1022
|
+
"type": "object",
|
1023
|
+
"properties": {
|
1024
|
+
"permission": {
|
1025
|
+
"type": "string",
|
1026
|
+
"enum": ["read", "write", "create", "update", "delete"]
|
1027
|
+
},
|
1028
|
+
"target": {
|
1029
|
+
"type": "string",
|
1030
|
+
"description": "Permission target (e.g., 'users', 'guests', 'role:admin')"
|
1031
|
+
}
|
1032
|
+
},
|
1033
|
+
"required": ["permission", "target"],
|
1034
|
+
"additionalProperties": false
|
1035
|
+
}
|
1036
|
+
}
|
1037
|
+
};
|
1038
|
+
}
|
1039
|
+
/**
|
1040
|
+
* Creates all necessary schema files for YAML configurations.
|
325
1041
|
*
|
326
1042
|
* @param appwriteFolderPath - Path to the .appwrite directory
|
327
1043
|
*/
|
@@ -331,11 +1047,19 @@ export async function createImportSchemas(appwriteFolderPath) {
|
|
331
1047
|
if (!fs.existsSync(yamlSchemasDir)) {
|
332
1048
|
fs.mkdirSync(yamlSchemasDir, { recursive: true });
|
333
1049
|
}
|
334
|
-
// Generate and write
|
335
|
-
const
|
336
|
-
|
337
|
-
|
338
|
-
|
1050
|
+
// Generate and write all schemas
|
1051
|
+
const schemas = [
|
1052
|
+
{ name: "import-config.schema.json", generator: generateImportConfigSchema },
|
1053
|
+
{ name: "collection.schema.json", generator: generateCollectionSchema },
|
1054
|
+
{ name: "table.schema.json", generator: generateTableSchema },
|
1055
|
+
{ name: "appwrite-config.schema.json", generator: generateAppwriteConfigSchema }
|
1056
|
+
];
|
1057
|
+
for (const { name, generator } of schemas) {
|
1058
|
+
const schema = generator();
|
1059
|
+
const schemaPath = path.join(yamlSchemasDir, name);
|
1060
|
+
fs.writeFileSync(schemaPath, JSON.stringify(schema, null, 2));
|
1061
|
+
logger.info(`Created schema: ${schemaPath}`);
|
1062
|
+
}
|
339
1063
|
// Create schema index file for easy reference
|
340
1064
|
const schemaIndex = {
|
341
1065
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
@@ -350,7 +1074,12 @@ export async function createImportSchemas(appwriteFolderPath) {
|
|
350
1074
|
"collection": {
|
351
1075
|
"type": "string",
|
352
1076
|
"const": "./collection.schema.json",
|
353
|
-
"description": "Schema for collection definitions"
|
1077
|
+
"description": "Schema for collection definitions (legacy Databases API)"
|
1078
|
+
},
|
1079
|
+
"table": {
|
1080
|
+
"type": "string",
|
1081
|
+
"const": "./table.schema.json",
|
1082
|
+
"description": "Schema for table definitions (new TablesDB API)"
|
354
1083
|
},
|
355
1084
|
"appwriteConfig": {
|
356
1085
|
"type": "string",
|