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