appwrite-utils-cli 1.9.7 → 1.11.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/CONFIG_TODO.md +1189 -1189
- package/README.md +1004 -1004
- package/SELECTION_DIALOGS.md +145 -145
- package/SERVICE_IMPLEMENTATION_REPORT.md +462 -462
- package/package.json +6 -3
- package/scripts/copy-templates.ts +23 -23
- package/src/adapters/index.ts +11 -37
- package/src/backups/operations/bucketBackup.ts +277 -277
- package/src/backups/operations/collectionBackup.ts +310 -310
- package/src/backups/operations/comprehensiveBackup.ts +342 -342
- package/src/backups/schemas/bucketManifest.ts +78 -78
- package/src/backups/schemas/comprehensiveManifest.ts +76 -76
- package/src/backups/tracking/centralizedTracking.ts +352 -352
- package/src/cli/commands/configCommands.ts +265 -201
- package/src/cli/commands/databaseCommands.ts +931 -879
- package/src/cli/commands/functionCommands.ts +333 -332
- package/src/cli/commands/importFileCommands.ts +815 -0
- package/src/cli/commands/schemaCommands.ts +141 -141
- package/src/cli/commands/storageCommands.ts +2 -3
- package/src/cli/commands/transferCommands.ts +454 -457
- package/src/collections/attributes.ts.backup +1555 -1555
- package/src/collections/{attributes.ts → columns.ts} +15 -10
- package/src/collections/indexes.ts +350 -352
- package/src/collections/methods.ts +714 -700
- package/src/collections/tableOperations.ts +29 -8
- package/src/collections/transferOperations.ts +376 -377
- package/src/collections/wipeOperations.ts +449 -346
- package/src/databases/methods.ts +49 -49
- package/src/databases/setup.ts +77 -77
- package/src/examples/yamlTerminologyExample.ts +346 -346
- package/src/functions/deployments.ts +221 -220
- package/src/functions/fnConfigDiscovery.ts +2 -2
- package/src/functions/methods.ts +284 -284
- package/src/functions/templates/count-docs-in-collection/README.md +53 -53
- package/src/functions/templates/count-docs-in-collection/src/main.ts +159 -159
- package/src/functions/templates/count-docs-in-collection/src/request.ts +8 -8
- package/src/functions/templates/hono-typescript/README.md +285 -285
- package/src/functions/templates/hono-typescript/src/adapters/request.ts +73 -73
- package/src/functions/templates/hono-typescript/src/adapters/response.ts +105 -105
- package/src/functions/templates/hono-typescript/src/app.ts +179 -179
- package/src/functions/templates/hono-typescript/src/context.ts +102 -102
- package/src/functions/templates/hono-typescript/src/{index.ts → main.ts} +53 -53
- package/src/functions/templates/hono-typescript/src/middleware/appwrite.ts +118 -118
- package/src/functions/templates/typescript-node/README.md +31 -31
- package/src/functions/templates/typescript-node/src/context.ts +102 -102
- package/src/functions/templates/typescript-node/src/{index.ts → main.ts} +29 -29
- package/src/functions/templates/uv/README.md +30 -30
- package/src/functions/templates/uv/pyproject.toml +29 -29
- package/src/functions/templates/uv/src/context.py +124 -124
- package/src/functions/templates/uv/src/{index.py → main.py} +45 -45
- package/src/init.ts +62 -62
- package/src/interactiveCLI.ts +1095 -1030
- package/src/main.ts +1517 -1670
- package/src/migrations/afterImportActions.ts +579 -580
- package/src/migrations/appwriteToX.ts +634 -630
- package/src/migrations/comprehensiveTransfer.ts +2149 -2149
- package/src/migrations/dataLoader.ts +1729 -1702
- package/src/migrations/importController.ts +440 -428
- package/src/migrations/importDataActions.ts +315 -315
- package/src/migrations/relationships.ts +333 -334
- package/src/migrations/services/DataTransformationService.ts +195 -195
- package/src/migrations/services/FileHandlerService.ts +310 -310
- package/src/migrations/services/ImportOrchestrator.ts +674 -665
- package/src/migrations/services/RateLimitManager.ts +362 -362
- package/src/migrations/services/RelationshipResolver.ts +460 -460
- package/src/migrations/services/UserMappingService.ts +344 -344
- package/src/migrations/services/ValidationService.ts +333 -333
- package/src/migrations/transfer.ts +987 -942
- package/src/migrations/yaml/YamlImportConfigLoader.ts +438 -438
- package/src/migrations/yaml/YamlImportIntegration.ts +438 -438
- package/src/migrations/yaml/generateImportSchemas.ts +1347 -1347
- package/src/schemas/authUser.ts +23 -23
- package/src/setup.ts +8 -8
- package/src/setupCommands.ts +5 -6
- package/src/setupController.ts +42 -42
- package/src/shared/backupMetadataSchema.ts +93 -93
- package/src/shared/backupTracking.ts +211 -211
- package/src/shared/confirmationDialogs.ts +326 -326
- package/src/shared/migrationHelpers.ts +232 -232
- package/src/shared/operationLogger.ts +20 -20
- package/src/shared/operationQueue.ts +326 -327
- package/src/shared/operationsTable.ts +338 -338
- package/src/shared/operationsTableSchema.ts +60 -60
- package/src/shared/progressManager.ts +277 -277
- package/src/shared/relationshipExtractor.ts +214 -214
- package/src/shared/selectionDialogs.ts +775 -722
- package/src/storage/backupCompression.ts +88 -88
- package/src/storage/methods.ts +695 -682
- package/src/storage/schemas.ts +205 -205
- package/src/tables/indexManager.ts +408 -408
- package/src/types/node-appwrite-tablesdb.d.ts +43 -43
- package/src/types.ts +9 -9
- package/src/users/methods.ts +358 -359
- package/src/utils/configMigration.ts +347 -347
- package/src/utils/index.ts +2 -2
- package/src/utils/loadConfigs.ts +457 -449
- package/src/utils/setupFiles.ts +1236 -1238
- package/src/utilsController.ts +1263 -1213
- package/tests/README.md +496 -496
- package/tests/adapters/AdapterFactory.test.ts +276 -276
- package/tests/integration/syncOperations.test.ts +462 -462
- package/tests/jest.config.js +24 -24
- package/tests/migration/configMigration.test.ts +545 -545
- package/tests/setup.ts +61 -61
- package/tests/testUtils.ts +339 -339
- package/tests/utils/loadConfigs.test.ts +349 -349
- package/tests/validation/configValidation.test.ts +411 -411
- package/tsconfig.json +44 -44
- package/.appwrite/.yaml_schemas/appwrite-config.schema.json +0 -380
- package/.appwrite/.yaml_schemas/collection.schema.json +0 -255
- package/.appwrite/collections/Categories.yaml +0 -182
- package/.appwrite/collections/ExampleCollection.yaml +0 -36
- package/.appwrite/collections/Posts.yaml +0 -227
- package/.appwrite/collections/Users.yaml +0 -149
- package/.appwrite/config.yaml +0 -109
- package/.appwrite/import/README.md +0 -148
- package/.appwrite/import/categories-import.yaml +0 -129
- package/.appwrite/import/posts-import.yaml +0 -208
- package/.appwrite/import/users-import.yaml +0 -130
- package/.appwrite/importData/categories.json +0 -194
- package/.appwrite/importData/posts.json +0 -270
- package/.appwrite/importData/users.json +0 -220
- package/.appwrite/schemas/categories.json +0 -128
- package/.appwrite/schemas/exampleCollection.json +0 -52
- package/.appwrite/schemas/posts.json +0 -173
- package/.appwrite/schemas/users.json +0 -125
- package/dist/adapters/AdapterFactory.d.ts +0 -94
- package/dist/adapters/AdapterFactory.js +0 -420
- package/dist/adapters/DatabaseAdapter.d.ts +0 -243
- package/dist/adapters/DatabaseAdapter.js +0 -50
- package/dist/adapters/LegacyAdapter.d.ts +0 -50
- package/dist/adapters/LegacyAdapter.js +0 -615
- package/dist/adapters/TablesDBAdapter.d.ts +0 -45
- package/dist/adapters/TablesDBAdapter.js +0 -611
- package/dist/adapters/index.d.ts +0 -11
- package/dist/adapters/index.js +0 -12
- package/dist/backups/operations/bucketBackup.d.ts +0 -19
- package/dist/backups/operations/bucketBackup.js +0 -197
- package/dist/backups/operations/collectionBackup.d.ts +0 -30
- package/dist/backups/operations/collectionBackup.js +0 -201
- package/dist/backups/operations/comprehensiveBackup.d.ts +0 -25
- package/dist/backups/operations/comprehensiveBackup.js +0 -238
- package/dist/backups/schemas/bucketManifest.d.ts +0 -93
- package/dist/backups/schemas/bucketManifest.js +0 -33
- package/dist/backups/schemas/comprehensiveManifest.d.ts +0 -108
- package/dist/backups/schemas/comprehensiveManifest.js +0 -32
- package/dist/backups/tracking/centralizedTracking.d.ts +0 -34
- package/dist/backups/tracking/centralizedTracking.js +0 -274
- package/dist/cli/commands/configCommands.d.ts +0 -8
- package/dist/cli/commands/configCommands.js +0 -166
- package/dist/cli/commands/databaseCommands.d.ts +0 -14
- package/dist/cli/commands/databaseCommands.js +0 -644
- package/dist/cli/commands/functionCommands.d.ts +0 -7
- package/dist/cli/commands/functionCommands.js +0 -330
- package/dist/cli/commands/schemaCommands.d.ts +0 -7
- package/dist/cli/commands/schemaCommands.js +0 -169
- package/dist/cli/commands/storageCommands.d.ts +0 -5
- package/dist/cli/commands/storageCommands.js +0 -143
- package/dist/cli/commands/transferCommands.d.ts +0 -5
- package/dist/cli/commands/transferCommands.js +0 -384
- package/dist/collections/attributes.d.ts +0 -13
- package/dist/collections/attributes.js +0 -1333
- package/dist/collections/indexes.d.ts +0 -12
- package/dist/collections/indexes.js +0 -217
- package/dist/collections/methods.d.ts +0 -19
- package/dist/collections/methods.js +0 -587
- package/dist/collections/tableOperations.d.ts +0 -86
- package/dist/collections/tableOperations.js +0 -447
- package/dist/collections/transferOperations.d.ts +0 -8
- package/dist/collections/transferOperations.js +0 -412
- package/dist/collections/wipeOperations.d.ts +0 -16
- package/dist/collections/wipeOperations.js +0 -233
- package/dist/config/ConfigManager.d.ts +0 -450
- package/dist/config/ConfigManager.js +0 -650
- package/dist/config/configMigration.d.ts +0 -87
- package/dist/config/configMigration.js +0 -390
- package/dist/config/configValidation.d.ts +0 -66
- package/dist/config/configValidation.js +0 -358
- package/dist/config/index.d.ts +0 -8
- package/dist/config/index.js +0 -7
- package/dist/config/services/ConfigDiscoveryService.d.ts +0 -122
- package/dist/config/services/ConfigDiscoveryService.js +0 -322
- package/dist/config/services/ConfigLoaderService.d.ts +0 -129
- package/dist/config/services/ConfigLoaderService.js +0 -535
- package/dist/config/services/ConfigMergeService.d.ts +0 -208
- package/dist/config/services/ConfigMergeService.js +0 -308
- package/dist/config/services/ConfigValidationService.d.ts +0 -214
- package/dist/config/services/ConfigValidationService.js +0 -310
- package/dist/config/services/SessionAuthService.d.ts +0 -225
- package/dist/config/services/SessionAuthService.js +0 -456
- package/dist/config/services/__tests__/ConfigMergeService.test.d.ts +0 -1
- package/dist/config/services/__tests__/ConfigMergeService.test.js +0 -271
- package/dist/config/services/index.d.ts +0 -13
- package/dist/config/services/index.js +0 -10
- package/dist/config/yamlConfig.d.ts +0 -722
- package/dist/config/yamlConfig.js +0 -702
- package/dist/databases/methods.d.ts +0 -6
- package/dist/databases/methods.js +0 -35
- package/dist/databases/setup.d.ts +0 -5
- package/dist/databases/setup.js +0 -45
- package/dist/examples/yamlTerminologyExample.d.ts +0 -42
- package/dist/examples/yamlTerminologyExample.js +0 -272
- package/dist/functions/deployments.d.ts +0 -4
- package/dist/functions/deployments.js +0 -146
- package/dist/functions/fnConfigDiscovery.d.ts +0 -3
- package/dist/functions/fnConfigDiscovery.js +0 -108
- package/dist/functions/methods.d.ts +0 -16
- package/dist/functions/methods.js +0 -174
- package/dist/functions/pathResolution.d.ts +0 -37
- package/dist/functions/pathResolution.js +0 -185
- package/dist/functions/templates/count-docs-in-collection/README.md +0 -54
- package/dist/functions/templates/count-docs-in-collection/package.json +0 -25
- package/dist/functions/templates/count-docs-in-collection/src/main.ts +0 -159
- package/dist/functions/templates/count-docs-in-collection/src/request.ts +0 -9
- package/dist/functions/templates/count-docs-in-collection/tsconfig.json +0 -28
- package/dist/functions/templates/hono-typescript/README.md +0 -286
- package/dist/functions/templates/hono-typescript/package.json +0 -26
- package/dist/functions/templates/hono-typescript/src/adapters/request.ts +0 -74
- package/dist/functions/templates/hono-typescript/src/adapters/response.ts +0 -106
- package/dist/functions/templates/hono-typescript/src/app.ts +0 -180
- package/dist/functions/templates/hono-typescript/src/context.ts +0 -103
- package/dist/functions/templates/hono-typescript/src/index.ts +0 -54
- package/dist/functions/templates/hono-typescript/src/middleware/appwrite.ts +0 -119
- package/dist/functions/templates/hono-typescript/tsconfig.json +0 -20
- package/dist/functions/templates/typescript-node/README.md +0 -32
- package/dist/functions/templates/typescript-node/package.json +0 -25
- package/dist/functions/templates/typescript-node/src/context.ts +0 -103
- package/dist/functions/templates/typescript-node/src/index.ts +0 -29
- package/dist/functions/templates/typescript-node/tsconfig.json +0 -28
- package/dist/functions/templates/uv/README.md +0 -31
- package/dist/functions/templates/uv/pyproject.toml +0 -30
- package/dist/functions/templates/uv/src/__init__.py +0 -0
- package/dist/functions/templates/uv/src/context.py +0 -125
- package/dist/functions/templates/uv/src/index.py +0 -46
- package/dist/init.d.ts +0 -2
- package/dist/init.js +0 -57
- package/dist/interactiveCLI.d.ts +0 -31
- package/dist/interactiveCLI.js +0 -898
- package/dist/main.d.ts +0 -2
- package/dist/main.js +0 -1180
- package/dist/migrations/afterImportActions.d.ts +0 -17
- package/dist/migrations/afterImportActions.js +0 -306
- package/dist/migrations/appwriteToX.d.ts +0 -211
- package/dist/migrations/appwriteToX.js +0 -491
- package/dist/migrations/comprehensiveTransfer.d.ts +0 -147
- package/dist/migrations/comprehensiveTransfer.js +0 -1317
- package/dist/migrations/dataLoader.d.ts +0 -753
- package/dist/migrations/dataLoader.js +0 -1250
- package/dist/migrations/importController.d.ts +0 -23
- package/dist/migrations/importController.js +0 -268
- package/dist/migrations/importDataActions.d.ts +0 -50
- package/dist/migrations/importDataActions.js +0 -230
- package/dist/migrations/relationships.d.ts +0 -29
- package/dist/migrations/relationships.js +0 -204
- package/dist/migrations/services/DataTransformationService.d.ts +0 -55
- package/dist/migrations/services/DataTransformationService.js +0 -158
- package/dist/migrations/services/FileHandlerService.d.ts +0 -75
- package/dist/migrations/services/FileHandlerService.js +0 -236
- package/dist/migrations/services/ImportOrchestrator.d.ts +0 -97
- package/dist/migrations/services/ImportOrchestrator.js +0 -485
- package/dist/migrations/services/RateLimitManager.d.ts +0 -138
- package/dist/migrations/services/RateLimitManager.js +0 -279
- package/dist/migrations/services/RelationshipResolver.d.ts +0 -120
- package/dist/migrations/services/RelationshipResolver.js +0 -332
- package/dist/migrations/services/UserMappingService.d.ts +0 -109
- package/dist/migrations/services/UserMappingService.js +0 -277
- package/dist/migrations/services/ValidationService.d.ts +0 -74
- package/dist/migrations/services/ValidationService.js +0 -260
- package/dist/migrations/transfer.d.ts +0 -26
- package/dist/migrations/transfer.js +0 -608
- package/dist/migrations/yaml/YamlImportConfigLoader.d.ts +0 -131
- package/dist/migrations/yaml/YamlImportConfigLoader.js +0 -383
- package/dist/migrations/yaml/YamlImportIntegration.d.ts +0 -93
- package/dist/migrations/yaml/YamlImportIntegration.js +0 -341
- package/dist/migrations/yaml/generateImportSchemas.d.ts +0 -30
- package/dist/migrations/yaml/generateImportSchemas.js +0 -1327
- package/dist/schemas/authUser.d.ts +0 -24
- package/dist/schemas/authUser.js +0 -17
- package/dist/setup.d.ts +0 -2
- package/dist/setup.js +0 -5
- package/dist/setupCommands.d.ts +0 -58
- package/dist/setupCommands.js +0 -490
- package/dist/setupController.d.ts +0 -9
- package/dist/setupController.js +0 -34
- package/dist/shared/attributeMapper.d.ts +0 -20
- package/dist/shared/attributeMapper.js +0 -203
- package/dist/shared/backupMetadataSchema.d.ts +0 -94
- package/dist/shared/backupMetadataSchema.js +0 -38
- package/dist/shared/backupTracking.d.ts +0 -18
- package/dist/shared/backupTracking.js +0 -176
- package/dist/shared/confirmationDialogs.d.ts +0 -75
- package/dist/shared/confirmationDialogs.js +0 -236
- package/dist/shared/errorUtils.d.ts +0 -54
- package/dist/shared/errorUtils.js +0 -95
- package/dist/shared/functionManager.d.ts +0 -48
- package/dist/shared/functionManager.js +0 -348
- package/dist/shared/jsonSchemaGenerator.d.ts +0 -50
- package/dist/shared/jsonSchemaGenerator.js +0 -290
- package/dist/shared/logging.d.ts +0 -61
- package/dist/shared/logging.js +0 -116
- package/dist/shared/messageFormatter.d.ts +0 -39
- package/dist/shared/messageFormatter.js +0 -162
- package/dist/shared/migrationHelpers.d.ts +0 -61
- package/dist/shared/migrationHelpers.js +0 -145
- package/dist/shared/operationLogger.d.ts +0 -10
- package/dist/shared/operationLogger.js +0 -12
- package/dist/shared/operationQueue.d.ts +0 -40
- package/dist/shared/operationQueue.js +0 -311
- package/dist/shared/operationsTable.d.ts +0 -26
- package/dist/shared/operationsTable.js +0 -286
- package/dist/shared/operationsTableSchema.d.ts +0 -48
- package/dist/shared/operationsTableSchema.js +0 -35
- package/dist/shared/progressManager.d.ts +0 -62
- package/dist/shared/progressManager.js +0 -215
- package/dist/shared/pydanticModelGenerator.d.ts +0 -17
- package/dist/shared/pydanticModelGenerator.js +0 -615
- package/dist/shared/relationshipExtractor.d.ts +0 -56
- package/dist/shared/relationshipExtractor.js +0 -138
- package/dist/shared/schemaGenerator.d.ts +0 -40
- package/dist/shared/schemaGenerator.js +0 -556
- package/dist/shared/selectionDialogs.d.ts +0 -214
- package/dist/shared/selectionDialogs.js +0 -544
- package/dist/storage/backupCompression.d.ts +0 -20
- package/dist/storage/backupCompression.js +0 -67
- package/dist/storage/methods.d.ts +0 -32
- package/dist/storage/methods.js +0 -472
- package/dist/storage/schemas.d.ts +0 -842
- package/dist/storage/schemas.js +0 -175
- package/dist/tables/indexManager.d.ts +0 -65
- package/dist/tables/indexManager.js +0 -294
- package/dist/types.d.ts +0 -4
- package/dist/types.js +0 -3
- package/dist/users/methods.d.ts +0 -16
- package/dist/users/methods.js +0 -277
- package/dist/utils/ClientFactory.d.ts +0 -87
- package/dist/utils/ClientFactory.js +0 -212
- package/dist/utils/configDiscovery.d.ts +0 -78
- package/dist/utils/configDiscovery.js +0 -472
- package/dist/utils/configMigration.d.ts +0 -1
- package/dist/utils/configMigration.js +0 -261
- package/dist/utils/constantsGenerator.d.ts +0 -31
- package/dist/utils/constantsGenerator.js +0 -321
- package/dist/utils/dataConverters.d.ts +0 -46
- package/dist/utils/dataConverters.js +0 -139
- package/dist/utils/directoryUtils.d.ts +0 -22
- package/dist/utils/directoryUtils.js +0 -59
- package/dist/utils/getClientFromConfig.d.ts +0 -39
- package/dist/utils/getClientFromConfig.js +0 -199
- package/dist/utils/helperFunctions.d.ts +0 -63
- package/dist/utils/helperFunctions.js +0 -156
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -2
- package/dist/utils/loadConfigs.d.ts +0 -50
- package/dist/utils/loadConfigs.js +0 -358
- package/dist/utils/pathResolvers.d.ts +0 -53
- package/dist/utils/pathResolvers.js +0 -72
- package/dist/utils/projectConfig.d.ts +0 -122
- package/dist/utils/projectConfig.js +0 -206
- package/dist/utils/retryFailedPromises.d.ts +0 -2
- package/dist/utils/retryFailedPromises.js +0 -23
- package/dist/utils/sessionAuth.d.ts +0 -48
- package/dist/utils/sessionAuth.js +0 -164
- package/dist/utils/setupFiles.d.ts +0 -4
- package/dist/utils/setupFiles.js +0 -1192
- package/dist/utils/typeGuards.d.ts +0 -35
- package/dist/utils/typeGuards.js +0 -57
- package/dist/utils/validationRules.d.ts +0 -43
- package/dist/utils/validationRules.js +0 -42
- package/dist/utils/versionDetection.d.ts +0 -58
- package/dist/utils/versionDetection.js +0 -251
- package/dist/utils/yamlConverter.d.ts +0 -100
- package/dist/utils/yamlConverter.js +0 -428
- package/dist/utils/yamlLoader.d.ts +0 -70
- package/dist/utils/yamlLoader.js +0 -267
- package/dist/utilsController.d.ts +0 -107
- package/dist/utilsController.js +0 -873
- package/src/adapters/AdapterFactory.ts +0 -529
- package/src/adapters/DatabaseAdapter.ts +0 -319
- package/src/adapters/LegacyAdapter.ts +0 -844
- package/src/adapters/TablesDBAdapter.ts +0 -823
- package/src/config/ConfigManager.ts +0 -849
- package/src/config/README.md +0 -274
- package/src/config/configMigration.ts +0 -575
- package/src/config/configValidation.ts +0 -445
- package/src/config/index.ts +0 -10
- package/src/config/services/ConfigDiscoveryService.ts +0 -410
- package/src/config/services/ConfigLoaderService.ts +0 -732
- package/src/config/services/ConfigMergeService.ts +0 -388
- package/src/config/services/ConfigValidationService.ts +0 -394
- package/src/config/services/SessionAuthService.ts +0 -565
- package/src/config/services/__tests__/ConfigMergeService.test.ts +0 -351
- package/src/config/services/index.ts +0 -29
- package/src/config/yamlConfig.ts +0 -761
- package/src/functions/pathResolution.ts +0 -227
- package/src/functions/templates/count-docs-in-collection/package.json +0 -25
- package/src/functions/templates/count-docs-in-collection/tsconfig.json +0 -28
- package/src/functions/templates/hono-typescript/package.json +0 -26
- package/src/functions/templates/hono-typescript/tsconfig.json +0 -20
- package/src/functions/templates/typescript-node/package.json +0 -25
- package/src/functions/templates/typescript-node/tsconfig.json +0 -28
- package/src/shared/attributeMapper.ts +0 -229
- package/src/shared/errorUtils.ts +0 -110
- package/src/shared/functionManager.ts +0 -537
- package/src/shared/jsonSchemaGenerator.ts +0 -383
- package/src/shared/logging.ts +0 -149
- package/src/shared/messageFormatter.ts +0 -208
- package/src/shared/pydanticModelGenerator.ts +0 -618
- package/src/shared/schemaGenerator.ts +0 -644
- package/src/utils/ClientFactory.ts +0 -240
- package/src/utils/configDiscovery.ts +0 -557
- package/src/utils/constantsGenerator.ts +0 -369
- package/src/utils/dataConverters.ts +0 -159
- package/src/utils/directoryUtils.ts +0 -61
- package/src/utils/getClientFromConfig.ts +0 -257
- package/src/utils/helperFunctions.ts +0 -228
- package/src/utils/pathResolvers.ts +0 -81
- package/src/utils/projectConfig.ts +0 -340
- package/src/utils/retryFailedPromises.ts +0 -29
- package/src/utils/sessionAuth.ts +0 -230
- package/src/utils/typeGuards.ts +0 -65
- package/src/utils/validationRules.ts +0 -88
- package/src/utils/versionDetection.ts +0 -292
- package/src/utils/yamlConverter.ts +0 -542
- package/src/utils/yamlLoader.ts +0 -371
- package/tmp-sync-test/.appwrite/collections/TestCollection.yaml +0 -7
package/src/utils/setupFiles.ts
CHANGED
|
@@ -1,1238 +1,1236 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync, existsSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import type { AppwriteConfig } from "appwrite-utils";
|
|
4
|
-
import { findAppwriteConfig } from "./loadConfigs.js";
|
|
5
|
-
import { loadYamlConfig } from "
|
|
6
|
-
import { fetchServerVersion, isVersionAtLeast } from
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
{ permission: '
|
|
101
|
-
{ permission: '
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
export const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
- permission:
|
|
180
|
-
target:
|
|
181
|
-
- permission:
|
|
182
|
-
target: users
|
|
183
|
-
- permission:
|
|
184
|
-
target: users
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
#
|
|
189
|
-
#
|
|
190
|
-
#
|
|
191
|
-
#
|
|
192
|
-
#
|
|
193
|
-
|
|
194
|
-
#
|
|
195
|
-
|
|
196
|
-
#
|
|
197
|
-
#
|
|
198
|
-
#
|
|
199
|
-
#
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
{ permission: '
|
|
219
|
-
{ permission: '
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
);
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
useTables
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
MessageFormatter.info(`
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
- permission:
|
|
388
|
-
target:
|
|
389
|
-
- permission:
|
|
390
|
-
target: users
|
|
391
|
-
- permission:
|
|
392
|
-
target: users
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
"
|
|
431
|
-
"
|
|
432
|
-
"
|
|
433
|
-
"
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
"
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
"
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
"
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
"
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
"
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
"
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
"
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
"
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
"
|
|
493
|
-
"
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
"
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
"
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
"
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
"
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
"
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
"
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
"
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
"
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
"
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
"
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
"
|
|
636
|
-
|
|
637
|
-
"
|
|
638
|
-
"
|
|
639
|
-
"
|
|
640
|
-
"
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
"
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
"
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
"
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
"
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
"
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
"
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
"
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
"
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
"
|
|
700
|
-
"
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
"
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
"
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
"
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
"
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
"
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
"
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
"
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
"
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
"
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
"
|
|
852
|
-
"
|
|
853
|
-
"
|
|
854
|
-
"
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
"
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
"
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
"
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
"
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
"
|
|
889
|
-
"
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
"
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
"
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
"
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
"
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
"
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
"
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
"
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
"
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
"
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
"
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
"
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
"
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
"
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
"
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
"
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
"
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
"
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
"
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
"
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
"
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
"
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
"
|
|
1045
|
-
"
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
"
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
"
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
"
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
"
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
"
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
"
|
|
1112
|
-
"
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
"
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
"
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
"
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
"
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
"
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
"
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
MessageFormatter.info("
|
|
1223
|
-
MessageFormatter.info(
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
MessageFormatter.info("
|
|
1231
|
-
MessageFormatter.info("
|
|
1232
|
-
MessageFormatter.info("
|
|
1233
|
-
MessageFormatter.info("
|
|
1234
|
-
MessageFormatter.info("
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1
|
+
import { mkdirSync, writeFileSync, existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import type { AppwriteConfig } from "appwrite-utils";
|
|
4
|
+
import { findAppwriteConfig } from "./loadConfigs.js";
|
|
5
|
+
import { loadYamlConfig, findYamlConfig, generateYamlConfigTemplate } from "appwrite-utils-helpers";
|
|
6
|
+
import { fetchServerVersion, isVersionAtLeast } from 'appwrite-utils-helpers';
|
|
7
|
+
import { ID } from "node-appwrite";
|
|
8
|
+
import { ulid } from "ulidx";
|
|
9
|
+
import { loadAppwriteProjectConfig, findAppwriteProjectConfig, getProjectDirectoryName, isTablesDBProject } from 'appwrite-utils-helpers';
|
|
10
|
+
import { hasSessionAuth, getSessionAuth } from 'appwrite-utils-helpers';
|
|
11
|
+
import { MessageFormatter } from "appwrite-utils-helpers";
|
|
12
|
+
|
|
13
|
+
// Example base configuration using types from appwrite-utils
|
|
14
|
+
const baseConfig: AppwriteConfig = {
|
|
15
|
+
appwriteEndpoint: "https://cloud.appwrite.io/v1",
|
|
16
|
+
appwriteProject: "YOUR_PROJECT_ID",
|
|
17
|
+
appwriteKey: "YOUR_API_KEY",
|
|
18
|
+
appwriteClient: null,
|
|
19
|
+
apiMode: "auto", // Enable dual API support - auto-detect TablesDB vs legacy
|
|
20
|
+
authMethod: "auto", // Default to auto-detect authentication method
|
|
21
|
+
logging: {
|
|
22
|
+
enabled: false,
|
|
23
|
+
level: "info",
|
|
24
|
+
console: false,
|
|
25
|
+
},
|
|
26
|
+
enableBackups: true,
|
|
27
|
+
backupInterval: 3600,
|
|
28
|
+
backupRetention: 30,
|
|
29
|
+
enableBackupCleanup: true,
|
|
30
|
+
enableMockData: false,
|
|
31
|
+
documentBucketId: "documents",
|
|
32
|
+
usersCollectionName: "Members",
|
|
33
|
+
databases: [
|
|
34
|
+
{
|
|
35
|
+
$id: "main",
|
|
36
|
+
name: "Main",
|
|
37
|
+
bucket: {
|
|
38
|
+
$id: "main_bucket",
|
|
39
|
+
name: "Main Bucket",
|
|
40
|
+
enabled: true,
|
|
41
|
+
maximumFileSize: 30000000,
|
|
42
|
+
allowedFileExtensions: [],
|
|
43
|
+
encryption: true,
|
|
44
|
+
antivirus: true,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
$id: "staging",
|
|
49
|
+
name: "Staging",
|
|
50
|
+
bucket: {
|
|
51
|
+
$id: "staging_bucket",
|
|
52
|
+
name: "Staging Bucket",
|
|
53
|
+
enabled: true,
|
|
54
|
+
maximumFileSize: 30000000,
|
|
55
|
+
allowedFileExtensions: [],
|
|
56
|
+
encryption: true,
|
|
57
|
+
antivirus: true,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
$id: "dev",
|
|
62
|
+
name: "Development",
|
|
63
|
+
bucket: {
|
|
64
|
+
$id: "dev_bucket",
|
|
65
|
+
name: "Development Bucket",
|
|
66
|
+
enabled: true,
|
|
67
|
+
maximumFileSize: 30000000,
|
|
68
|
+
allowedFileExtensions: [],
|
|
69
|
+
encryption: true,
|
|
70
|
+
antivirus: true,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
buckets: [
|
|
75
|
+
{
|
|
76
|
+
$id: "global_bucket",
|
|
77
|
+
name: "Global Bucket",
|
|
78
|
+
enabled: true,
|
|
79
|
+
maximumFileSize: 30000000,
|
|
80
|
+
allowedFileExtensions: [],
|
|
81
|
+
encryption: true,
|
|
82
|
+
antivirus: true,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const collectionsConfig: { name: string; content: string }[] = [
|
|
88
|
+
{
|
|
89
|
+
name: "ExampleCollection",
|
|
90
|
+
content: `import type { CollectionCreate } from "appwrite-utils";
|
|
91
|
+
|
|
92
|
+
const ExampleCollection: Partial<CollectionCreate> = {
|
|
93
|
+
name: 'ExampleCollection',
|
|
94
|
+
$id: '${ulid()}',
|
|
95
|
+
documentSecurity: false,
|
|
96
|
+
enabled: true,
|
|
97
|
+
$permissions: [
|
|
98
|
+
{ permission: 'read', target: 'any' },
|
|
99
|
+
{ permission: 'create', target: 'users' },
|
|
100
|
+
{ permission: 'update', target: 'users' },
|
|
101
|
+
{ permission: 'delete', target: 'users' }
|
|
102
|
+
],
|
|
103
|
+
attributes: [
|
|
104
|
+
{ key: 'alterEgoName', type: 'string', size: 255, required: false },
|
|
105
|
+
// Add more attributes here
|
|
106
|
+
],
|
|
107
|
+
indexes: [
|
|
108
|
+
{ key: 'alterEgoName_search', type: 'fulltext', attributes: ['alterEgoName'] }
|
|
109
|
+
],
|
|
110
|
+
importDefs: [
|
|
111
|
+
// Define import definitions here
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default ExampleCollection;`,
|
|
116
|
+
},
|
|
117
|
+
// Add more collections here
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
// Define our YAML files
|
|
121
|
+
// Define our YAML files
|
|
122
|
+
const configFileExample = `d`;
|
|
123
|
+
|
|
124
|
+
export const customDefinitionsFile = `import type { ConverterFunctions, ValidationRules, AfterImportActions } from "appwrite-utils";
|
|
125
|
+
|
|
126
|
+
export const customConverterFunctions: ConverterFunctions = {
|
|
127
|
+
// Add your custom converter functions here
|
|
128
|
+
}
|
|
129
|
+
export const customValidationRules: ValidationRules = {
|
|
130
|
+
// Add your custom validation rules here
|
|
131
|
+
}
|
|
132
|
+
export const customAfterImportActions: AfterImportActions = {
|
|
133
|
+
// Add your custom after import actions here
|
|
134
|
+
}`;
|
|
135
|
+
|
|
136
|
+
export const createEmptyCollection = (collectionName: string) => {
|
|
137
|
+
const currentDir = process.cwd();
|
|
138
|
+
|
|
139
|
+
// Check for YAML config first (preferred)
|
|
140
|
+
const yamlConfigPath = findYamlConfig(currentDir);
|
|
141
|
+
const tsConfigPath = findAppwriteConfig(currentDir);
|
|
142
|
+
|
|
143
|
+
let configDir: string;
|
|
144
|
+
let isYamlProject = false;
|
|
145
|
+
|
|
146
|
+
if (yamlConfigPath) {
|
|
147
|
+
configDir = path.dirname(yamlConfigPath);
|
|
148
|
+
isYamlProject = true;
|
|
149
|
+
} else if (tsConfigPath) {
|
|
150
|
+
configDir = path.dirname(tsConfigPath);
|
|
151
|
+
isYamlProject = false;
|
|
152
|
+
} else {
|
|
153
|
+
// No config found - assume .appwrite directory and use YAML as default
|
|
154
|
+
configDir = path.join(currentDir, ".appwrite");
|
|
155
|
+
isYamlProject = true;
|
|
156
|
+
|
|
157
|
+
// Create .appwrite directory if it doesn't exist
|
|
158
|
+
if (!existsSync(configDir)) {
|
|
159
|
+
mkdirSync(configDir, { recursive: true });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const collectionsFolder = path.join(configDir, "collections");
|
|
164
|
+
if (!existsSync(collectionsFolder)) {
|
|
165
|
+
mkdirSync(collectionsFolder, { recursive: true });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (isYamlProject) {
|
|
169
|
+
// Create YAML collection
|
|
170
|
+
const yamlCollection = `# yaml-language-server: $schema=../.yaml_schemas/collection.schema.json
|
|
171
|
+
# Collection Definition: ${collectionName}
|
|
172
|
+
name: ${collectionName}
|
|
173
|
+
id: ${ulid()}
|
|
174
|
+
documentSecurity: false
|
|
175
|
+
enabled: true
|
|
176
|
+
permissions:
|
|
177
|
+
- permission: read
|
|
178
|
+
target: any
|
|
179
|
+
- permission: create
|
|
180
|
+
target: users
|
|
181
|
+
- permission: update
|
|
182
|
+
target: users
|
|
183
|
+
- permission: delete
|
|
184
|
+
target: users
|
|
185
|
+
attributes:
|
|
186
|
+
# Add your attributes here
|
|
187
|
+
# Example:
|
|
188
|
+
# - key: title
|
|
189
|
+
# type: string
|
|
190
|
+
# size: 255
|
|
191
|
+
# required: true
|
|
192
|
+
# description: "The title of the item"
|
|
193
|
+
indexes:
|
|
194
|
+
# Add your indexes here
|
|
195
|
+
# Example:
|
|
196
|
+
# - key: title_search
|
|
197
|
+
# type: fulltext
|
|
198
|
+
# attributes:
|
|
199
|
+
# - title
|
|
200
|
+
importDefs: []
|
|
201
|
+
`;
|
|
202
|
+
|
|
203
|
+
const collectionFilePath = path.join(collectionsFolder, `${collectionName}.yaml`);
|
|
204
|
+
writeFileSync(collectionFilePath, yamlCollection);
|
|
205
|
+
MessageFormatter.success(`Created YAML collection: ${collectionFilePath}`, { prefix: "Setup" });
|
|
206
|
+
} else {
|
|
207
|
+
// Create TypeScript collection
|
|
208
|
+
const emptyCollection = `import type { CollectionCreate } from "appwrite-utils";
|
|
209
|
+
|
|
210
|
+
const ${collectionName}: Partial<CollectionCreate> = {
|
|
211
|
+
$id: '${ulid()}',
|
|
212
|
+
documentSecurity: false,
|
|
213
|
+
enabled: true,
|
|
214
|
+
name: '${collectionName}',
|
|
215
|
+
$permissions: [
|
|
216
|
+
{ permission: 'read', target: 'any' },
|
|
217
|
+
{ permission: 'create', target: 'users' },
|
|
218
|
+
{ permission: 'update', target: 'users' },
|
|
219
|
+
{ permission: 'delete', target: 'users' }
|
|
220
|
+
],
|
|
221
|
+
attributes: [
|
|
222
|
+
// Add more attributes here
|
|
223
|
+
],
|
|
224
|
+
indexes: [
|
|
225
|
+
// Add more indexes here
|
|
226
|
+
],
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export default ${collectionName};`;
|
|
230
|
+
|
|
231
|
+
const collectionFilePath = path.join(collectionsFolder, `${collectionName}.ts`);
|
|
232
|
+
writeFileSync(collectionFilePath, emptyCollection);
|
|
233
|
+
MessageFormatter.success(`Created TypeScript collection: ${collectionFilePath}`, { prefix: "Setup" });
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const generateYamlConfig = (currentDir?: string, useAppwriteDir: boolean = true) => {
|
|
238
|
+
const basePath = currentDir || process.cwd();
|
|
239
|
+
const configDir = useAppwriteDir ? path.join(basePath, ".appwrite") : basePath;
|
|
240
|
+
|
|
241
|
+
if (!existsSync(configDir)) {
|
|
242
|
+
mkdirSync(configDir, { recursive: true });
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const configPath = path.join(configDir, "config.yaml");
|
|
246
|
+
generateYamlConfigTemplate(configPath);
|
|
247
|
+
|
|
248
|
+
MessageFormatter.success(`Generated YAML config template at: ${configPath}`, { prefix: "Setup" });
|
|
249
|
+
MessageFormatter.info("Please update the configuration with your Appwrite project details.", { prefix: "Setup" });
|
|
250
|
+
|
|
251
|
+
return configPath;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export const setupDirsFiles = async (
|
|
255
|
+
example: boolean = false,
|
|
256
|
+
currentDir?: string,
|
|
257
|
+
useYaml: boolean = true
|
|
258
|
+
) => {
|
|
259
|
+
const basePath = currentDir || process.cwd();
|
|
260
|
+
|
|
261
|
+
// Create .appwrite folder directly in project root
|
|
262
|
+
const appwriteFolder = path.join(basePath, ".appwrite");
|
|
263
|
+
const appwriteConfigFile = path.join(appwriteFolder, "appwriteConfig.ts");
|
|
264
|
+
const appwriteCustomDefsFile = path.join(
|
|
265
|
+
appwriteFolder,
|
|
266
|
+
"customDefinitions.ts"
|
|
267
|
+
);
|
|
268
|
+
const appwriteSchemaFolder = path.join(appwriteFolder, "schemas");
|
|
269
|
+
const appwriteYamlSchemaFolder = path.join(appwriteFolder, ".yaml_schemas");
|
|
270
|
+
const appwriteDataFolder = path.join(appwriteFolder, "importData");
|
|
271
|
+
// Enhanced version detection with multiple sources
|
|
272
|
+
let useTables = false;
|
|
273
|
+
let detectionSource = "default";
|
|
274
|
+
|
|
275
|
+
try {
|
|
276
|
+
// Priority 1: Check for existing appwrite.json project config
|
|
277
|
+
const projectConfigPath = findAppwriteProjectConfig(basePath);
|
|
278
|
+
if (projectConfigPath) {
|
|
279
|
+
const projectConfig = loadAppwriteProjectConfig(projectConfigPath);
|
|
280
|
+
if (projectConfig) {
|
|
281
|
+
useTables = isTablesDBProject(projectConfig);
|
|
282
|
+
detectionSource = "appwrite.json";
|
|
283
|
+
MessageFormatter.info(`Detected ${useTables ? 'TablesDB' : 'Collections'} project from ${projectConfigPath}`, { prefix: "Setup" });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Priority 2: Try reading existing YAML config for version detection
|
|
288
|
+
if (!useTables && detectionSource === "default") {
|
|
289
|
+
const yamlPath = findYamlConfig(basePath);
|
|
290
|
+
if (yamlPath) {
|
|
291
|
+
const cfg = await loadYamlConfig(yamlPath);
|
|
292
|
+
if (cfg) {
|
|
293
|
+
// Try session auth first, then API key for version detection
|
|
294
|
+
let endpoint = cfg.appwriteEndpoint;
|
|
295
|
+
let projectId = cfg.appwriteProject;
|
|
296
|
+
|
|
297
|
+
if (hasSessionAuth(endpoint, projectId)) {
|
|
298
|
+
MessageFormatter.info("Using session authentication for version detection", { prefix: "Setup" });
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const ver = await fetchServerVersion(endpoint);
|
|
302
|
+
if (isVersionAtLeast(ver || undefined, '1.8.0')) {
|
|
303
|
+
useTables = true;
|
|
304
|
+
detectionSource = "server-version";
|
|
305
|
+
MessageFormatter.info(`Detected TablesDB support (Appwrite ${ver})`, { prefix: "Setup" });
|
|
306
|
+
} else {
|
|
307
|
+
MessageFormatter.info(`Using Collections API (Appwrite ${ver || 'unknown'})`, { prefix: "Setup" });
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
} catch (error) {
|
|
313
|
+
MessageFormatter.warning(`Version detection failed, defaulting to Collections API: ${error instanceof Error ? error.message : String(error)}`, { prefix: "Setup" });
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const targetFolderName = useTables ? "tables" : "collections";
|
|
317
|
+
const collectionsFolder = path.join(appwriteFolder, targetFolderName);
|
|
318
|
+
|
|
319
|
+
// Create directory structure
|
|
320
|
+
if (!existsSync(appwriteFolder)) {
|
|
321
|
+
mkdirSync(appwriteFolder, { recursive: true });
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (!existsSync(collectionsFolder)) {
|
|
325
|
+
mkdirSync(collectionsFolder, { recursive: true });
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Handle configuration file creation - YAML is now default
|
|
329
|
+
if (useYaml) {
|
|
330
|
+
// Generate YAML config in .appwrite directory
|
|
331
|
+
const configPath = path.join(appwriteFolder, "config.yaml");
|
|
332
|
+
generateYamlConfigTemplate(configPath);
|
|
333
|
+
} else if (!existsSync(appwriteConfigFile)) {
|
|
334
|
+
if (example) {
|
|
335
|
+
writeFileSync(appwriteConfigFile, configFileExample);
|
|
336
|
+
} else {
|
|
337
|
+
const baseConfigContent = `import { type AppwriteConfig } from "appwrite-utils";
|
|
338
|
+
|
|
339
|
+
const appwriteConfig: AppwriteConfig = ${JSON.stringify(baseConfig, null, 2)};
|
|
340
|
+
|
|
341
|
+
export default appwriteConfig;
|
|
342
|
+
`;
|
|
343
|
+
writeFileSync(appwriteConfigFile, baseConfigContent);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Create TypeScript files for each collection only if not using YAML
|
|
348
|
+
if (!useYaml) {
|
|
349
|
+
collectionsConfig.forEach((collection) => {
|
|
350
|
+
const collectionFilePath = path.join(
|
|
351
|
+
collectionsFolder,
|
|
352
|
+
`${collection.name}.ts`
|
|
353
|
+
);
|
|
354
|
+
writeFileSync(collectionFilePath, collection.content);
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Create YAML collection/table example if using YAML config
|
|
359
|
+
if (useYaml) {
|
|
360
|
+
const terminology = useTables
|
|
361
|
+
? {
|
|
362
|
+
container: "table",
|
|
363
|
+
fields: "columns",
|
|
364
|
+
security: "rowSecurity",
|
|
365
|
+
schemaRef: "table.schema.json",
|
|
366
|
+
containerName: "Table",
|
|
367
|
+
fieldName: "Column"
|
|
368
|
+
}
|
|
369
|
+
: {
|
|
370
|
+
container: "collection",
|
|
371
|
+
fields: "attributes",
|
|
372
|
+
security: "documentSecurity",
|
|
373
|
+
schemaRef: "collection.schema.json",
|
|
374
|
+
containerName: "Collection",
|
|
375
|
+
fieldName: "Attribute"
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const yamlExample = `# yaml-language-server: $schema=../.yaml_schemas/${terminology.schemaRef}
|
|
379
|
+
# Example ${terminology.containerName} Definition
|
|
380
|
+
name: Example${terminology.containerName}
|
|
381
|
+
id: example_${terminology.container}_${Date.now()}
|
|
382
|
+
${terminology.security}: false
|
|
383
|
+
enabled: true
|
|
384
|
+
permissions:
|
|
385
|
+
- permission: read
|
|
386
|
+
target: any
|
|
387
|
+
- permission: create
|
|
388
|
+
target: users
|
|
389
|
+
- permission: update
|
|
390
|
+
target: users
|
|
391
|
+
- permission: delete
|
|
392
|
+
target: users
|
|
393
|
+
${terminology.fields}:
|
|
394
|
+
- key: title
|
|
395
|
+
type: string
|
|
396
|
+
size: 255
|
|
397
|
+
required: true
|
|
398
|
+
description: "The title of the item"
|
|
399
|
+
- key: description
|
|
400
|
+
type: string
|
|
401
|
+
size: 1000
|
|
402
|
+
required: false
|
|
403
|
+
description: "A longer description"
|
|
404
|
+
- key: isActive
|
|
405
|
+
type: boolean
|
|
406
|
+
required: false
|
|
407
|
+
default: true${useTables ? `
|
|
408
|
+
- key: uniqueCode
|
|
409
|
+
type: string
|
|
410
|
+
size: 50
|
|
411
|
+
required: false
|
|
412
|
+
unique: true
|
|
413
|
+
description: "Unique identifier code (TablesDB feature)"` : ''}
|
|
414
|
+
indexes:
|
|
415
|
+
- key: title_search
|
|
416
|
+
type: fulltext
|
|
417
|
+
attributes:
|
|
418
|
+
- title
|
|
419
|
+
importDefs: []
|
|
420
|
+
`;
|
|
421
|
+
const yamlExamplePath = path.join(collectionsFolder, `Example${terminology.containerName}.yaml`);
|
|
422
|
+
writeFileSync(yamlExamplePath, yamlExample);
|
|
423
|
+
|
|
424
|
+
MessageFormatter.info(`Created example ${terminology.container} definition with ${terminology.fields} terminology`, { prefix: "Setup" });
|
|
425
|
+
|
|
426
|
+
// Create JSON schema for collection/table definitions
|
|
427
|
+
const containerJsonSchema = useTables ? {
|
|
428
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
429
|
+
"$id": "https://appwrite-utils.dev/schemas/table.schema.json",
|
|
430
|
+
"title": "Appwrite Table Definition",
|
|
431
|
+
"description": "Schema for defining Appwrite tables in YAML (TablesDB API)",
|
|
432
|
+
"type": "object",
|
|
433
|
+
"properties": {
|
|
434
|
+
"name": {
|
|
435
|
+
"type": "string",
|
|
436
|
+
"description": "The name of the table"
|
|
437
|
+
},
|
|
438
|
+
"id": {
|
|
439
|
+
"type": "string",
|
|
440
|
+
"description": "The ID of the table (optional, auto-generated if not provided)",
|
|
441
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,35}$"
|
|
442
|
+
},
|
|
443
|
+
"rowSecurity": {
|
|
444
|
+
"type": "boolean",
|
|
445
|
+
"default": false,
|
|
446
|
+
"description": "Enable row-level permissions"
|
|
447
|
+
},
|
|
448
|
+
"enabled": {
|
|
449
|
+
"type": "boolean",
|
|
450
|
+
"default": true,
|
|
451
|
+
"description": "Whether the table is enabled"
|
|
452
|
+
},
|
|
453
|
+
"permissions": {
|
|
454
|
+
"type": "array",
|
|
455
|
+
"description": "Table-level permissions",
|
|
456
|
+
"items": {
|
|
457
|
+
"type": "object",
|
|
458
|
+
"properties": {
|
|
459
|
+
"permission": {
|
|
460
|
+
"type": "string",
|
|
461
|
+
"enum": ["read", "create", "update", "delete"],
|
|
462
|
+
"description": "The permission type"
|
|
463
|
+
},
|
|
464
|
+
"target": {
|
|
465
|
+
"type": "string",
|
|
466
|
+
"description": "Permission target (e.g., 'any', 'users', 'users/verified', 'label:admin')"
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
"required": ["permission", "target"],
|
|
470
|
+
"additionalProperties": false
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
"columns": {
|
|
474
|
+
"type": "array",
|
|
475
|
+
"description": "Table columns (fields)",
|
|
476
|
+
"items": {
|
|
477
|
+
"type": "object",
|
|
478
|
+
"properties": {
|
|
479
|
+
"key": {
|
|
480
|
+
"type": "string",
|
|
481
|
+
"description": "Column name",
|
|
482
|
+
"pattern": "^[a-zA-Z][a-zA-Z0-9]*$"
|
|
483
|
+
},
|
|
484
|
+
"type": {
|
|
485
|
+
"type": "string",
|
|
486
|
+
"enum": ["string", "integer", "double", "boolean", "datetime", "email", "ip", "url", "enum", "relationship"],
|
|
487
|
+
"description": "Column data type"
|
|
488
|
+
},
|
|
489
|
+
"size": {
|
|
490
|
+
"type": "number",
|
|
491
|
+
"description": "Maximum size for string columns",
|
|
492
|
+
"minimum": 1,
|
|
493
|
+
"maximum": 1073741824
|
|
494
|
+
},
|
|
495
|
+
"required": {
|
|
496
|
+
"type": "boolean",
|
|
497
|
+
"default": false,
|
|
498
|
+
"description": "Whether the column is required"
|
|
499
|
+
},
|
|
500
|
+
"array": {
|
|
501
|
+
"type": "boolean",
|
|
502
|
+
"default": false,
|
|
503
|
+
"description": "Whether the column is an array"
|
|
504
|
+
},
|
|
505
|
+
"unique": {
|
|
506
|
+
"type": "boolean",
|
|
507
|
+
"default": false,
|
|
508
|
+
"description": "Whether the column values must be unique (TablesDB feature)"
|
|
509
|
+
},
|
|
510
|
+
"default": {
|
|
511
|
+
"description": "Default value for the column"
|
|
512
|
+
},
|
|
513
|
+
"description": {
|
|
514
|
+
"type": "string",
|
|
515
|
+
"description": "Column description"
|
|
516
|
+
},
|
|
517
|
+
"encrypt": {
|
|
518
|
+
"type": "boolean",
|
|
519
|
+
"description": "Whether the column should be encrypted"
|
|
520
|
+
},
|
|
521
|
+
"format": {
|
|
522
|
+
"type": "string",
|
|
523
|
+
"description": "Format for string columns"
|
|
524
|
+
},
|
|
525
|
+
"min": {
|
|
526
|
+
"type": "number",
|
|
527
|
+
"description": "Minimum value for numeric columns"
|
|
528
|
+
},
|
|
529
|
+
"max": {
|
|
530
|
+
"type": "number",
|
|
531
|
+
"description": "Maximum value for numeric columns"
|
|
532
|
+
},
|
|
533
|
+
"elements": {
|
|
534
|
+
"type": "array",
|
|
535
|
+
"items": {
|
|
536
|
+
"type": "string"
|
|
537
|
+
},
|
|
538
|
+
"description": "Allowed values for enum columns"
|
|
539
|
+
},
|
|
540
|
+
"relatedCollection": {
|
|
541
|
+
"type": "string",
|
|
542
|
+
"description": "Related table name for relationship columns"
|
|
543
|
+
},
|
|
544
|
+
"relationType": {
|
|
545
|
+
"type": "string",
|
|
546
|
+
"enum": ["oneToOne", "oneToMany", "manyToOne", "manyToMany"],
|
|
547
|
+
"description": "Type of relationship"
|
|
548
|
+
},
|
|
549
|
+
"twoWay": {
|
|
550
|
+
"type": "boolean",
|
|
551
|
+
"description": "Whether the relationship is bidirectional"
|
|
552
|
+
},
|
|
553
|
+
"twoWayKey": {
|
|
554
|
+
"type": "string",
|
|
555
|
+
"description": "Key name for the reverse relationship"
|
|
556
|
+
},
|
|
557
|
+
"onDelete": {
|
|
558
|
+
"type": "string",
|
|
559
|
+
"enum": ["cascade", "restrict", "setNull"],
|
|
560
|
+
"description": "Action to take when related row is deleted"
|
|
561
|
+
},
|
|
562
|
+
"side": {
|
|
563
|
+
"type": "string",
|
|
564
|
+
"enum": ["parent", "child"],
|
|
565
|
+
"description": "Side of the relationship"
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
"required": ["key", "type"],
|
|
569
|
+
"additionalProperties": false,
|
|
570
|
+
"allOf": [
|
|
571
|
+
{
|
|
572
|
+
"if": {
|
|
573
|
+
"properties": { "type": { "const": "enum" } }
|
|
574
|
+
},
|
|
575
|
+
"then": {
|
|
576
|
+
"required": ["elements"]
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
"if": {
|
|
581
|
+
"properties": { "type": { "const": "relationship" } }
|
|
582
|
+
},
|
|
583
|
+
"then": {
|
|
584
|
+
"required": ["relatedCollection", "relationType"]
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
]
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
"indexes": {
|
|
591
|
+
"type": "array",
|
|
592
|
+
"description": "Database indexes for the table",
|
|
593
|
+
"items": {
|
|
594
|
+
"type": "object",
|
|
595
|
+
"properties": {
|
|
596
|
+
"key": {
|
|
597
|
+
"type": "string",
|
|
598
|
+
"description": "Index name"
|
|
599
|
+
},
|
|
600
|
+
"type": {
|
|
601
|
+
"type": "string",
|
|
602
|
+
"enum": ["key", "fulltext", "unique"],
|
|
603
|
+
"description": "Index type"
|
|
604
|
+
},
|
|
605
|
+
"attributes": {
|
|
606
|
+
"type": "array",
|
|
607
|
+
"items": {
|
|
608
|
+
"type": "string"
|
|
609
|
+
},
|
|
610
|
+
"description": "Columns to index",
|
|
611
|
+
"minItems": 1
|
|
612
|
+
},
|
|
613
|
+
"orders": {
|
|
614
|
+
"type": "array",
|
|
615
|
+
"items": {
|
|
616
|
+
"type": "string",
|
|
617
|
+
"enum": ["ASC", "DESC"]
|
|
618
|
+
},
|
|
619
|
+
"description": "Sort order for each column"
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
"required": ["key", "type", "attributes"],
|
|
623
|
+
"additionalProperties": false
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
"importDefs": {
|
|
627
|
+
"type": "array",
|
|
628
|
+
"description": "Import definitions for data migration",
|
|
629
|
+
"default": []
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
"required": ["name"],
|
|
633
|
+
"additionalProperties": false
|
|
634
|
+
} : {
|
|
635
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
636
|
+
"$id": "https://appwrite-utils.dev/schemas/collection.schema.json",
|
|
637
|
+
"title": "Appwrite Collection Definition",
|
|
638
|
+
"description": "Schema for defining Appwrite collections in YAML",
|
|
639
|
+
"type": "object",
|
|
640
|
+
"properties": {
|
|
641
|
+
"name": {
|
|
642
|
+
"type": "string",
|
|
643
|
+
"description": "The name of the collection"
|
|
644
|
+
},
|
|
645
|
+
"id": {
|
|
646
|
+
"type": "string",
|
|
647
|
+
"description": "The ID of the collection (optional, auto-generated if not provided)",
|
|
648
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,35}$"
|
|
649
|
+
},
|
|
650
|
+
"documentSecurity": {
|
|
651
|
+
"type": "boolean",
|
|
652
|
+
"default": false,
|
|
653
|
+
"description": "Enable document-level permissions"
|
|
654
|
+
},
|
|
655
|
+
"enabled": {
|
|
656
|
+
"type": "boolean",
|
|
657
|
+
"default": true,
|
|
658
|
+
"description": "Whether the collection is enabled"
|
|
659
|
+
},
|
|
660
|
+
"permissions": {
|
|
661
|
+
"type": "array",
|
|
662
|
+
"description": "Collection-level permissions",
|
|
663
|
+
"items": {
|
|
664
|
+
"type": "object",
|
|
665
|
+
"properties": {
|
|
666
|
+
"permission": {
|
|
667
|
+
"type": "string",
|
|
668
|
+
"enum": ["read", "create", "update", "delete"],
|
|
669
|
+
"description": "The permission type"
|
|
670
|
+
},
|
|
671
|
+
"target": {
|
|
672
|
+
"type": "string",
|
|
673
|
+
"description": "Permission target (e.g., 'any', 'users', 'users/verified', 'label:admin')"
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
"required": ["permission", "target"],
|
|
677
|
+
"additionalProperties": false
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
"attributes": {
|
|
681
|
+
"type": "array",
|
|
682
|
+
"description": "Collection attributes (fields)",
|
|
683
|
+
"items": {
|
|
684
|
+
"type": "object",
|
|
685
|
+
"properties": {
|
|
686
|
+
"key": {
|
|
687
|
+
"type": "string",
|
|
688
|
+
"description": "Attribute name",
|
|
689
|
+
"pattern": "^[a-zA-Z][a-zA-Z0-9]*$"
|
|
690
|
+
},
|
|
691
|
+
"type": {
|
|
692
|
+
"type": "string",
|
|
693
|
+
"enum": ["string", "integer", "double", "boolean", "datetime", "email", "ip", "url", "enum", "relationship"],
|
|
694
|
+
"description": "Attribute data type"
|
|
695
|
+
},
|
|
696
|
+
"size": {
|
|
697
|
+
"type": "number",
|
|
698
|
+
"description": "Maximum size for string attributes",
|
|
699
|
+
"minimum": 1,
|
|
700
|
+
"maximum": 1073741824
|
|
701
|
+
},
|
|
702
|
+
"required": {
|
|
703
|
+
"type": "boolean",
|
|
704
|
+
"default": false,
|
|
705
|
+
"description": "Whether the attribute is required"
|
|
706
|
+
},
|
|
707
|
+
"array": {
|
|
708
|
+
"type": "boolean",
|
|
709
|
+
"default": false,
|
|
710
|
+
"description": "Whether the attribute is an array"
|
|
711
|
+
},
|
|
712
|
+
"default": {
|
|
713
|
+
"description": "Default value for the attribute"
|
|
714
|
+
},
|
|
715
|
+
"description": {
|
|
716
|
+
"type": "string",
|
|
717
|
+
"description": "Attribute description"
|
|
718
|
+
},
|
|
719
|
+
"encrypt": {
|
|
720
|
+
"type": "boolean",
|
|
721
|
+
"description": "Whether the attribute should be encrypted"
|
|
722
|
+
},
|
|
723
|
+
"format": {
|
|
724
|
+
"type": "string",
|
|
725
|
+
"description": "Format for string attributes"
|
|
726
|
+
},
|
|
727
|
+
"min": {
|
|
728
|
+
"type": "number",
|
|
729
|
+
"description": "Minimum value for numeric attributes"
|
|
730
|
+
},
|
|
731
|
+
"max": {
|
|
732
|
+
"type": "number",
|
|
733
|
+
"description": "Maximum value for numeric attributes"
|
|
734
|
+
},
|
|
735
|
+
"elements": {
|
|
736
|
+
"type": "array",
|
|
737
|
+
"items": {
|
|
738
|
+
"type": "string"
|
|
739
|
+
},
|
|
740
|
+
"description": "Allowed values for enum attributes"
|
|
741
|
+
},
|
|
742
|
+
"relatedCollection": {
|
|
743
|
+
"type": "string",
|
|
744
|
+
"description": "Related collection name for relationship attributes"
|
|
745
|
+
},
|
|
746
|
+
"relationType": {
|
|
747
|
+
"type": "string",
|
|
748
|
+
"enum": ["oneToOne", "oneToMany", "manyToOne", "manyToMany"],
|
|
749
|
+
"description": "Type of relationship"
|
|
750
|
+
},
|
|
751
|
+
"twoWay": {
|
|
752
|
+
"type": "boolean",
|
|
753
|
+
"description": "Whether the relationship is bidirectional"
|
|
754
|
+
},
|
|
755
|
+
"twoWayKey": {
|
|
756
|
+
"type": "string",
|
|
757
|
+
"description": "Key name for the reverse relationship"
|
|
758
|
+
},
|
|
759
|
+
"onDelete": {
|
|
760
|
+
"type": "string",
|
|
761
|
+
"enum": ["cascade", "restrict", "setNull"],
|
|
762
|
+
"description": "Action to take when related document is deleted"
|
|
763
|
+
},
|
|
764
|
+
"side": {
|
|
765
|
+
"type": "string",
|
|
766
|
+
"enum": ["parent", "child"],
|
|
767
|
+
"description": "Side of the relationship"
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
"required": ["key", "type"],
|
|
771
|
+
"additionalProperties": false,
|
|
772
|
+
"allOf": [
|
|
773
|
+
{
|
|
774
|
+
"if": {
|
|
775
|
+
"properties": { "type": { "const": "enum" } }
|
|
776
|
+
},
|
|
777
|
+
"then": {
|
|
778
|
+
"required": ["elements"]
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"if": {
|
|
783
|
+
"properties": { "type": { "const": "relationship" } }
|
|
784
|
+
},
|
|
785
|
+
"then": {
|
|
786
|
+
"required": ["relatedCollection", "relationType"]
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
]
|
|
790
|
+
}
|
|
791
|
+
},
|
|
792
|
+
"indexes": {
|
|
793
|
+
"type": "array",
|
|
794
|
+
"description": "Database indexes for the collection",
|
|
795
|
+
"items": {
|
|
796
|
+
"type": "object",
|
|
797
|
+
"properties": {
|
|
798
|
+
"key": {
|
|
799
|
+
"type": "string",
|
|
800
|
+
"description": "Index name"
|
|
801
|
+
},
|
|
802
|
+
"type": {
|
|
803
|
+
"type": "string",
|
|
804
|
+
"enum": ["key", "fulltext", "unique"],
|
|
805
|
+
"description": "Index type"
|
|
806
|
+
},
|
|
807
|
+
"attributes": {
|
|
808
|
+
"type": "array",
|
|
809
|
+
"items": {
|
|
810
|
+
"type": "string"
|
|
811
|
+
},
|
|
812
|
+
"description": "Attributes to index",
|
|
813
|
+
"minItems": 1
|
|
814
|
+
},
|
|
815
|
+
"orders": {
|
|
816
|
+
"type": "array",
|
|
817
|
+
"items": {
|
|
818
|
+
"type": "string",
|
|
819
|
+
"enum": ["ASC", "DESC"]
|
|
820
|
+
},
|
|
821
|
+
"description": "Sort order for each attribute"
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
"required": ["key", "type", "attributes"],
|
|
825
|
+
"additionalProperties": false
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
"importDefs": {
|
|
829
|
+
"type": "array",
|
|
830
|
+
"description": "Import definitions for data migration",
|
|
831
|
+
"default": []
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
"required": ["name"],
|
|
835
|
+
"additionalProperties": false
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// Ensure YAML schemas directory exists before writing schema
|
|
839
|
+
if (!existsSync(appwriteYamlSchemaFolder)) {
|
|
840
|
+
mkdirSync(appwriteYamlSchemaFolder, { recursive: true });
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
const schemaFileName = useTables ? "table.schema.json" : "collection.schema.json";
|
|
844
|
+
const containerSchemaPath = path.join(appwriteYamlSchemaFolder, schemaFileName);
|
|
845
|
+
writeFileSync(containerSchemaPath, JSON.stringify(containerJsonSchema, null, 2));
|
|
846
|
+
|
|
847
|
+
// Create JSON schema for appwriteConfig.yaml
|
|
848
|
+
const configJsonSchema = {
|
|
849
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
850
|
+
"$id": "https://appwrite-utils.dev/schemas/appwrite-config.schema.json",
|
|
851
|
+
"title": "Appwrite Configuration",
|
|
852
|
+
"description": "Schema for Appwrite project configuration in YAML",
|
|
853
|
+
"type": "object",
|
|
854
|
+
"properties": {
|
|
855
|
+
"appwrite": {
|
|
856
|
+
"type": "object",
|
|
857
|
+
"description": "Appwrite connection settings",
|
|
858
|
+
"properties": {
|
|
859
|
+
"endpoint": {
|
|
860
|
+
"type": "string",
|
|
861
|
+
"default": "https://cloud.appwrite.io/v1",
|
|
862
|
+
"description": "Appwrite server endpoint URL"
|
|
863
|
+
},
|
|
864
|
+
"project": {
|
|
865
|
+
"type": "string",
|
|
866
|
+
"description": "Appwrite project ID"
|
|
867
|
+
},
|
|
868
|
+
"key": {
|
|
869
|
+
"type": "string",
|
|
870
|
+
"description": "Appwrite API key with appropriate permissions"
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
"required": ["project", "key"],
|
|
874
|
+
"additionalProperties": false
|
|
875
|
+
},
|
|
876
|
+
"logging": {
|
|
877
|
+
"type": "object",
|
|
878
|
+
"description": "Logging configuration",
|
|
879
|
+
"properties": {
|
|
880
|
+
"enabled": {
|
|
881
|
+
"type": "boolean",
|
|
882
|
+
"default": false,
|
|
883
|
+
"description": "Enable file logging"
|
|
884
|
+
},
|
|
885
|
+
"level": {
|
|
886
|
+
"type": "string",
|
|
887
|
+
"enum": ["error", "warn", "info", "debug"],
|
|
888
|
+
"default": "info",
|
|
889
|
+
"description": "Logging level"
|
|
890
|
+
},
|
|
891
|
+
"directory": {
|
|
892
|
+
"type": "string",
|
|
893
|
+
"description": "Custom log directory path (optional)"
|
|
894
|
+
},
|
|
895
|
+
"console": {
|
|
896
|
+
"type": "boolean",
|
|
897
|
+
"default": false,
|
|
898
|
+
"description": "Enable console logging"
|
|
899
|
+
}
|
|
900
|
+
},
|
|
901
|
+
"additionalProperties": false
|
|
902
|
+
},
|
|
903
|
+
"backups": {
|
|
904
|
+
"type": "object",
|
|
905
|
+
"description": "Backup configuration",
|
|
906
|
+
"properties": {
|
|
907
|
+
"enabled": {
|
|
908
|
+
"type": "boolean",
|
|
909
|
+
"default": true,
|
|
910
|
+
"description": "Enable automatic backups"
|
|
911
|
+
},
|
|
912
|
+
"interval": {
|
|
913
|
+
"type": "number",
|
|
914
|
+
"default": 3600,
|
|
915
|
+
"description": "Backup interval in seconds"
|
|
916
|
+
},
|
|
917
|
+
"retention": {
|
|
918
|
+
"type": "number",
|
|
919
|
+
"default": 30,
|
|
920
|
+
"description": "Backup retention in days"
|
|
921
|
+
},
|
|
922
|
+
"cleanup": {
|
|
923
|
+
"type": "boolean",
|
|
924
|
+
"default": true,
|
|
925
|
+
"description": "Enable automatic backup cleanup"
|
|
926
|
+
}
|
|
927
|
+
},
|
|
928
|
+
"additionalProperties": false
|
|
929
|
+
},
|
|
930
|
+
"data": {
|
|
931
|
+
"type": "object",
|
|
932
|
+
"description": "Data management settings",
|
|
933
|
+
"properties": {
|
|
934
|
+
"enableMockData": {
|
|
935
|
+
"type": "boolean",
|
|
936
|
+
"default": false,
|
|
937
|
+
"description": "Enable mock data generation"
|
|
938
|
+
},
|
|
939
|
+
"documentBucketId": {
|
|
940
|
+
"type": "string",
|
|
941
|
+
"default": "documents",
|
|
942
|
+
"description": "Default bucket ID for document attachments"
|
|
943
|
+
},
|
|
944
|
+
"usersCollectionName": {
|
|
945
|
+
"type": "string",
|
|
946
|
+
"default": "Members",
|
|
947
|
+
"description": "Name of the users/members collection"
|
|
948
|
+
},
|
|
949
|
+
"importDirectory": {
|
|
950
|
+
"type": "string",
|
|
951
|
+
"default": "importData",
|
|
952
|
+
"description": "Directory containing import data files"
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
"additionalProperties": false
|
|
956
|
+
},
|
|
957
|
+
"schemas": {
|
|
958
|
+
"type": "object",
|
|
959
|
+
"description": "Schema generation settings",
|
|
960
|
+
"properties": {
|
|
961
|
+
"outputDirectory": {
|
|
962
|
+
"type": "string",
|
|
963
|
+
"default": "schemas",
|
|
964
|
+
"description": "Directory where generated schemas are saved"
|
|
965
|
+
},
|
|
966
|
+
"yamlSchemaDirectory": {
|
|
967
|
+
"type": "string",
|
|
968
|
+
"default": ".yaml_schemas",
|
|
969
|
+
"description": "Directory containing YAML validation schemas"
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
"additionalProperties": false
|
|
973
|
+
},
|
|
974
|
+
"migrations": {
|
|
975
|
+
"type": "object",
|
|
976
|
+
"description": "Migration settings",
|
|
977
|
+
"properties": {
|
|
978
|
+
"enabled": {
|
|
979
|
+
"type": "boolean",
|
|
980
|
+
"default": true,
|
|
981
|
+
"description": "Enable migration tracking database"
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
"additionalProperties": false
|
|
985
|
+
},
|
|
986
|
+
"databases": {
|
|
987
|
+
"type": "array",
|
|
988
|
+
"description": "Database configurations",
|
|
989
|
+
"items": {
|
|
990
|
+
"type": "object",
|
|
991
|
+
"properties": {
|
|
992
|
+
"id": {
|
|
993
|
+
"type": "string",
|
|
994
|
+
"description": "Database ID",
|
|
995
|
+
"pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,35}$"
|
|
996
|
+
},
|
|
997
|
+
"name": {
|
|
998
|
+
"type": "string",
|
|
999
|
+
"description": "Database display name"
|
|
1000
|
+
},
|
|
1001
|
+
"bucket": {
|
|
1002
|
+
"type": "object",
|
|
1003
|
+
"description": "Associated storage bucket",
|
|
1004
|
+
"properties": {
|
|
1005
|
+
"id": {
|
|
1006
|
+
"type": "string",
|
|
1007
|
+
"description": "Bucket ID"
|
|
1008
|
+
},
|
|
1009
|
+
"name": {
|
|
1010
|
+
"type": "string",
|
|
1011
|
+
"description": "Bucket display name"
|
|
1012
|
+
},
|
|
1013
|
+
"permissions": {
|
|
1014
|
+
"type": "array",
|
|
1015
|
+
"items": {
|
|
1016
|
+
"type": "string"
|
|
1017
|
+
},
|
|
1018
|
+
"description": "Bucket permissions"
|
|
1019
|
+
},
|
|
1020
|
+
"fileSecurity": {
|
|
1021
|
+
"type": "boolean",
|
|
1022
|
+
"description": "Enable file-level security"
|
|
1023
|
+
},
|
|
1024
|
+
"enabled": {
|
|
1025
|
+
"type": "boolean",
|
|
1026
|
+
"default": true,
|
|
1027
|
+
"description": "Enable the bucket"
|
|
1028
|
+
},
|
|
1029
|
+
"maximumFileSize": {
|
|
1030
|
+
"type": "number",
|
|
1031
|
+
"default": 30000000,
|
|
1032
|
+
"description": "Maximum file size in bytes"
|
|
1033
|
+
},
|
|
1034
|
+
"allowedFileExtensions": {
|
|
1035
|
+
"type": "array",
|
|
1036
|
+
"items": {
|
|
1037
|
+
"type": "string"
|
|
1038
|
+
},
|
|
1039
|
+
"description": "Allowed file extensions (empty = all allowed)"
|
|
1040
|
+
},
|
|
1041
|
+
"compression": {
|
|
1042
|
+
"type": "string",
|
|
1043
|
+
"enum": ["none", "gzip", "zstd"],
|
|
1044
|
+
"default": "none",
|
|
1045
|
+
"description": "Compression algorithm"
|
|
1046
|
+
},
|
|
1047
|
+
"encryption": {
|
|
1048
|
+
"type": "boolean",
|
|
1049
|
+
"default": false,
|
|
1050
|
+
"description": "Enable file encryption"
|
|
1051
|
+
},
|
|
1052
|
+
"antivirus": {
|
|
1053
|
+
"type": "boolean",
|
|
1054
|
+
"default": false,
|
|
1055
|
+
"description": "Enable antivirus scanning"
|
|
1056
|
+
}
|
|
1057
|
+
},
|
|
1058
|
+
"required": ["id", "name"],
|
|
1059
|
+
"additionalProperties": false
|
|
1060
|
+
}
|
|
1061
|
+
},
|
|
1062
|
+
"required": ["id", "name"],
|
|
1063
|
+
"additionalProperties": false
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
"buckets": {
|
|
1067
|
+
"type": "array",
|
|
1068
|
+
"description": "Global storage buckets",
|
|
1069
|
+
"items": {
|
|
1070
|
+
"type": "object",
|
|
1071
|
+
"properties": {
|
|
1072
|
+
"id": {
|
|
1073
|
+
"type": "string",
|
|
1074
|
+
"description": "Bucket ID"
|
|
1075
|
+
},
|
|
1076
|
+
"name": {
|
|
1077
|
+
"type": "string",
|
|
1078
|
+
"description": "Bucket display name"
|
|
1079
|
+
},
|
|
1080
|
+
"permissions": {
|
|
1081
|
+
"type": "array",
|
|
1082
|
+
"items": {
|
|
1083
|
+
"type": "string"
|
|
1084
|
+
},
|
|
1085
|
+
"description": "Bucket permissions"
|
|
1086
|
+
},
|
|
1087
|
+
"fileSecurity": {
|
|
1088
|
+
"type": "boolean",
|
|
1089
|
+
"description": "Enable file-level security"
|
|
1090
|
+
},
|
|
1091
|
+
"enabled": {
|
|
1092
|
+
"type": "boolean",
|
|
1093
|
+
"default": true,
|
|
1094
|
+
"description": "Enable the bucket"
|
|
1095
|
+
},
|
|
1096
|
+
"maximumFileSize": {
|
|
1097
|
+
"type": "number",
|
|
1098
|
+
"default": 30000000,
|
|
1099
|
+
"description": "Maximum file size in bytes"
|
|
1100
|
+
},
|
|
1101
|
+
"allowedFileExtensions": {
|
|
1102
|
+
"type": "array",
|
|
1103
|
+
"items": {
|
|
1104
|
+
"type": "string"
|
|
1105
|
+
},
|
|
1106
|
+
"description": "Allowed file extensions (empty = all allowed)"
|
|
1107
|
+
},
|
|
1108
|
+
"compression": {
|
|
1109
|
+
"type": "string",
|
|
1110
|
+
"enum": ["none", "gzip", "zstd"],
|
|
1111
|
+
"default": "none",
|
|
1112
|
+
"description": "Compression algorithm"
|
|
1113
|
+
},
|
|
1114
|
+
"encryption": {
|
|
1115
|
+
"type": "boolean",
|
|
1116
|
+
"default": false,
|
|
1117
|
+
"description": "Enable file encryption"
|
|
1118
|
+
},
|
|
1119
|
+
"antivirus": {
|
|
1120
|
+
"type": "boolean",
|
|
1121
|
+
"default": false,
|
|
1122
|
+
"description": "Enable antivirus scanning"
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
"required": ["id", "name"],
|
|
1126
|
+
"additionalProperties": false
|
|
1127
|
+
}
|
|
1128
|
+
},
|
|
1129
|
+
"functions": {
|
|
1130
|
+
"type": "array",
|
|
1131
|
+
"description": "Appwrite Functions",
|
|
1132
|
+
"items": {
|
|
1133
|
+
"type": "object",
|
|
1134
|
+
"properties": {
|
|
1135
|
+
"id": {
|
|
1136
|
+
"type": "string",
|
|
1137
|
+
"description": "Function ID"
|
|
1138
|
+
},
|
|
1139
|
+
"name": {
|
|
1140
|
+
"type": "string",
|
|
1141
|
+
"description": "Function name"
|
|
1142
|
+
},
|
|
1143
|
+
"runtime": {
|
|
1144
|
+
"type": "string",
|
|
1145
|
+
"description": "Runtime environment"
|
|
1146
|
+
},
|
|
1147
|
+
"execute": {
|
|
1148
|
+
"type": "array",
|
|
1149
|
+
"items": {
|
|
1150
|
+
"type": "string"
|
|
1151
|
+
},
|
|
1152
|
+
"description": "Execution permissions"
|
|
1153
|
+
},
|
|
1154
|
+
"events": {
|
|
1155
|
+
"type": "array",
|
|
1156
|
+
"items": {
|
|
1157
|
+
"type": "string"
|
|
1158
|
+
},
|
|
1159
|
+
"description": "Event triggers"
|
|
1160
|
+
},
|
|
1161
|
+
"schedule": {
|
|
1162
|
+
"type": "string",
|
|
1163
|
+
"description": "Cron schedule"
|
|
1164
|
+
},
|
|
1165
|
+
"timeout": {
|
|
1166
|
+
"type": "number",
|
|
1167
|
+
"default": 15,
|
|
1168
|
+
"description": "Execution timeout in seconds"
|
|
1169
|
+
},
|
|
1170
|
+
"enabled": {
|
|
1171
|
+
"type": "boolean",
|
|
1172
|
+
"default": true,
|
|
1173
|
+
"description": "Enable the function"
|
|
1174
|
+
},
|
|
1175
|
+
"logging": {
|
|
1176
|
+
"type": "boolean",
|
|
1177
|
+
"default": true,
|
|
1178
|
+
"description": "Enable function logging"
|
|
1179
|
+
},
|
|
1180
|
+
"entrypoint": {
|
|
1181
|
+
"type": "string",
|
|
1182
|
+
"description": "Function entrypoint file"
|
|
1183
|
+
},
|
|
1184
|
+
"commands": {
|
|
1185
|
+
"type": "string",
|
|
1186
|
+
"description": "Build commands"
|
|
1187
|
+
}
|
|
1188
|
+
},
|
|
1189
|
+
"required": ["id", "name", "runtime"],
|
|
1190
|
+
"additionalProperties": false
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
},
|
|
1194
|
+
"required": ["appwrite"],
|
|
1195
|
+
"additionalProperties": false
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
const configSchemaPath = path.join(appwriteYamlSchemaFolder, "appwrite-config.schema.json");
|
|
1199
|
+
writeFileSync(configSchemaPath, JSON.stringify(configJsonSchema, null, 2));
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
if (!existsSync(appwriteSchemaFolder)) {
|
|
1203
|
+
mkdirSync(appwriteSchemaFolder, { recursive: true });
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
if (!existsSync(appwriteDataFolder)) {
|
|
1207
|
+
mkdirSync(appwriteDataFolder, { recursive: true });
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
// Remove the nested .appwrite folder creation since we're using .appwrite as the main folder
|
|
1211
|
+
|
|
1212
|
+
const configType = useYaml ? "YAML" : "TypeScript";
|
|
1213
|
+
const terminology = useTables ? "tables" : "collections";
|
|
1214
|
+
const containerType = useTables ? "TablesDB" : "Collections";
|
|
1215
|
+
|
|
1216
|
+
MessageFormatter.success(`Created ${configType} config and setup files/directories in .appwrite/ folder.`, { prefix: "Setup" });
|
|
1217
|
+
MessageFormatter.info(`Project configured for ${containerType} API (${detectionSource} detection)`, { prefix: "Setup" });
|
|
1218
|
+
|
|
1219
|
+
if (useYaml) {
|
|
1220
|
+
MessageFormatter.info("You can now configure your project in .appwrite/config.yaml", { prefix: "Setup" });
|
|
1221
|
+
MessageFormatter.info(`${useTables ? 'Tables' : 'Collections'} can be defined in .appwrite/${terminology}/ as .ts or .yaml files`, { prefix: "Setup" });
|
|
1222
|
+
MessageFormatter.info("Schemas will be generated in .appwrite/schemas/", { prefix: "Setup" });
|
|
1223
|
+
MessageFormatter.info("Import data can be placed in .appwrite/importData/", { prefix: "Setup" });
|
|
1224
|
+
if (useTables) {
|
|
1225
|
+
MessageFormatter.info("TablesDB features: unique constraints, enhanced performance, row-level security", { prefix: "Setup" });
|
|
1226
|
+
}
|
|
1227
|
+
} else {
|
|
1228
|
+
MessageFormatter.info("You can now configure logging in your .appwrite/appwriteConfig.ts file:", { prefix: "Setup" });
|
|
1229
|
+
MessageFormatter.info(" logging: {", { prefix: "Setup" });
|
|
1230
|
+
MessageFormatter.info(" enabled: true,", { prefix: "Setup" });
|
|
1231
|
+
MessageFormatter.info(" level: 'info',", { prefix: "Setup" });
|
|
1232
|
+
MessageFormatter.info(" console: true,", { prefix: "Setup" });
|
|
1233
|
+
MessageFormatter.info(" logDirectory: './logs' // optional custom directory", { prefix: "Setup" });
|
|
1234
|
+
MessageFormatter.info(" }", { prefix: "Setup" });
|
|
1235
|
+
}
|
|
1236
|
+
};
|