@zintrust/core 0.1.19 → 0.1.21
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/README.md +10 -10
- package/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +9 -0
- package/package.json +3 -2
- package/public/error-pages/404.html +145 -0
- package/public/error-pages/500.html +266 -0
- package/public/error-pages/error.css +628 -0
- package/public/error-pages/error.js +428 -0
- package/public/zintrust.svg +30 -0
- package/routes/api.d.ts.map +1 -1
- package/routes/api.js +41 -17
- package/routes/metrics.d.ts +9 -0
- package/routes/metrics.d.ts.map +1 -0
- package/routes/metrics.js +20 -0
- package/routes/openapi.d.ts +9 -0
- package/routes/openapi.d.ts.map +1 -0
- package/routes/openapi.js +76 -0
- package/src/boot/Application.d.ts +2 -2
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +66 -13
- package/src/boot/Server.d.ts +3 -2
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +39 -165
- package/src/boot/bootstrap.js +2 -0
- package/src/cache/Cache.d.ts +1 -1
- package/src/cache/Cache.d.ts.map +1 -1
- package/src/cache/CacheDriver.d.ts +4 -0
- package/src/cache/CacheDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.d.ts +1 -1
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts +1 -1
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.js +16 -0
- package/src/cache/drivers/MongoDriver.d.ts +1 -1
- package/src/cache/drivers/MongoDriver.d.ts.map +1 -1
- package/src/cache/drivers/RedisDriver.d.ts +1 -1
- package/src/cache/drivers/RedisDriver.d.ts.map +1 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +10 -4
- package/src/cli/commands/AddCommand.d.ts +2 -2
- package/src/cli/commands/AddCommand.d.ts.map +1 -1
- package/src/cli/commands/AddCommand.js +135 -58
- package/src/cli/commands/ConfigCommand.d.ts +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/CreateCommand.d.ts +15 -0
- package/src/cli/commands/CreateCommand.d.ts.map +1 -0
- package/src/cli/commands/CreateCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts +1 -1
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +16 -20
- package/src/cli/commands/DbSeedCommand.d.ts +9 -0
- package/src/cli/commands/DbSeedCommand.d.ts.map +1 -0
- package/src/cli/commands/DbSeedCommand.js +171 -0
- package/src/cli/commands/DebugCommand.d.ts +1 -1
- package/src/cli/commands/DebugCommand.d.ts.map +1 -1
- package/src/cli/commands/FixCommand.d.ts +1 -1
- package/src/cli/commands/FixCommand.d.ts.map +1 -1
- package/src/cli/commands/JwtDevCommand.d.ts +8 -0
- package/src/cli/commands/JwtDevCommand.d.ts.map +1 -0
- package/src/cli/commands/JwtDevCommand.js +114 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts +1 -1
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.d.ts +2 -2
- package/src/cli/commands/LogsCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.js +36 -2
- package/src/cli/commands/MakeMailTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +1 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.d.ts +1 -1
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +324 -35
- package/src/cli/commands/NewCommand.d.ts +1 -1
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +12 -4
- package/src/cli/commands/PluginCommand.d.ts +1 -1
- package/src/cli/commands/PluginCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.d.ts +1 -1
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/QACommand.d.ts +2 -2
- package/src/cli/commands/QACommand.d.ts.map +1 -1
- package/src/cli/commands/RoutesCommand.d.ts +10 -0
- package/src/cli/commands/RoutesCommand.d.ts.map +1 -0
- package/src/cli/commands/RoutesCommand.js +242 -0
- package/src/cli/commands/SimulateCommand.d.ts +1 -1
- package/src/cli/commands/SimulateCommand.d.ts.map +1 -1
- package/src/cli/commands/index.d.ts +3 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +3 -0
- package/src/cli/config/ConfigManager.d.ts +1 -1
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.d.ts +1 -1
- package/src/cli/config/ConfigValidator.d.ts.map +1 -1
- package/src/cli/config/ConfigValidator.js +1 -1
- package/src/cli/d1/D1SqlMigrations.d.ts +20 -0
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -0
- package/src/cli/d1/D1SqlMigrations.js +229 -0
- package/src/cli/d1/WranglerConfig.d.ts +4 -0
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -0
- package/src/cli/d1/WranglerConfig.js +122 -0
- package/src/cli/d1/WranglerD1.d.ts +11 -0
- package/src/cli/d1/WranglerD1.d.ts.map +1 -0
- package/src/cli/d1/WranglerD1.js +16 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ControllerGenerator.js +76 -26
- package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/FactoryGenerator.js +3 -1
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts +23 -0
- package/src/cli/scaffolding/GovernanceScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/GovernanceScaffolder.js +327 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts +10 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/MigrationGenerator.js +137 -51
- package/src/cli/scaffolding/ModelGenerator.js +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +36 -4
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/RouteGenerator.js +79 -43
- package/src/cli/scaffolding/SeederGenerator.d.ts +5 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/SeederGenerator.js +63 -15
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +28 -7
- package/src/cli/scaffolding/index.d.ts +2 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -1
- package/src/cli/scaffolding/index.js +1 -0
- package/src/common/index.d.ts +8 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +28 -0
- package/src/common/utility.d.ts +38 -0
- package/src/common/utility.d.ts.map +1 -0
- package/src/common/utility.js +101 -0
- package/src/config/FileLogWriter.d.ts +2 -1
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +83 -2
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +3 -1
- package/src/config/broadcast.d.ts +14 -28
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/broadcast.js +69 -35
- package/src/config/cache.d.ts +13 -45
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +69 -25
- package/src/config/cloudflare.d.ts +1 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/database.d.ts +22 -64
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +191 -37
- package/src/config/env.d.ts +12 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +14 -0
- package/src/config/index.d.ts +33 -137
- package/src/config/index.d.ts.map +1 -1
- package/src/config/logging/KvLogger.js +1 -1
- package/src/config/logging/SlackLogger.js +2 -2
- package/src/config/mail.d.ts +19 -55
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +63 -21
- package/src/config/middleware.d.ts +44 -1
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +157 -5
- package/src/config/notification.d.ts +14 -27
- package/src/config/notification.d.ts.map +1 -1
- package/src/config/notification.js +82 -36
- package/src/config/queue.d.ts +21 -51
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +72 -27
- package/src/config/security.d.ts +1 -1
- package/src/config/security.js +1 -1
- package/src/config/storage.d.ts +27 -34
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +97 -56
- package/src/config/type.d.ts +13 -2
- package/src/config/type.d.ts.map +1 -1
- package/src/events/EventDispatcher.d.ts.map +1 -1
- package/src/events/EventDispatcher.js +6 -4
- package/src/exceptions/ZintrustError.d.ts +7 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -1
- package/src/exceptions/ZintrustError.js +56 -0
- package/src/features/Auth.d.ts +1 -1
- package/src/features/Auth.d.ts.map +1 -1
- package/src/features/Auth.js +3 -3
- package/src/features/Queue.js +1 -1
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +3 -14
- package/src/functions/deno.d.ts.map +1 -1
- package/src/functions/deno.js +3 -14
- package/src/functions/lambda.d.ts.map +1 -1
- package/src/functions/lambda.js +3 -14
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/http/Controller.d.ts +2 -2
- package/src/http/Controller.d.ts.map +1 -1
- package/src/http/FileUpload.d.ts +68 -0
- package/src/http/FileUpload.d.ts.map +1 -0
- package/src/http/FileUpload.js +120 -0
- package/src/http/Kernel.d.ts +5 -5
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +139 -23
- package/src/http/Request.d.ts +20 -1
- package/src/http/Request.d.ts.map +1 -1
- package/src/http/Request.js +23 -0
- package/src/http/RequestContext.d.ts +6 -0
- package/src/http/RequestContext.d.ts.map +1 -1
- package/src/http/RequestContext.js +77 -1
- package/src/http/Response.d.ts +1 -1
- package/src/http/Response.d.ts.map +1 -1
- package/src/http/ValidationHelper.d.ts +78 -0
- package/src/http/ValidationHelper.d.ts.map +1 -0
- package/src/http/ValidationHelper.js +121 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts +17 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -0
- package/src/http/error-pages/ErrorPageRenderer.js +88 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts +12 -0
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -0
- package/src/http/middleware/BodyParsingMiddleware.js +251 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts +12 -0
- package/src/http/middleware/FileUploadMiddleware.d.ts.map +1 -0
- package/src/http/middleware/FileUploadMiddleware.js +74 -0
- package/src/http/parsers/BodyParsers.d.ts +32 -0
- package/src/http/parsers/BodyParsers.d.ts.map +1 -0
- package/src/http/parsers/BodyParsers.js +159 -0
- package/src/http/parsers/MultipartParser.d.ts +33 -0
- package/src/http/parsers/MultipartParser.d.ts.map +1 -0
- package/src/http/parsers/MultipartParser.js +156 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts +34 -0
- package/src/http/parsers/MultipartParserRegistry.d.ts.map +1 -0
- package/src/http/parsers/MultipartParserRegistry.js +20 -0
- package/src/http/validated.d.ts +12 -0
- package/src/http/validated.d.ts.map +1 -0
- package/src/http/validated.js +41 -0
- package/src/index.d.ts +73 -12
- package/src/index.d.ts.map +1 -1
- package/src/index.js +60 -5
- package/src/microservices/PostgresAdapter.d.ts.map +1 -1
- package/src/microservices/PostgresAdapter.js +0 -1
- package/src/microservices/RequestTracingMiddleware.d.ts +2 -2
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -1
- package/src/microservices/RequestTracingMiddleware.js +3 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts +2 -2
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/middleware/AuthMiddleware.d.ts +10 -0
- package/src/middleware/AuthMiddleware.d.ts.map +1 -0
- package/src/middleware/AuthMiddleware.js +16 -0
- package/src/middleware/CsrfMiddleware.d.ts +11 -1
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +33 -0
- package/src/middleware/JwtAuthMiddleware.d.ts +11 -0
- package/src/middleware/JwtAuthMiddleware.d.ts.map +1 -0
- package/src/middleware/JwtAuthMiddleware.js +73 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -1
- package/src/middleware/LoggingMiddleware.js +8 -3
- package/src/middleware/MiddlewareStack.d.ts +2 -2
- package/src/middleware/MiddlewareStack.d.ts.map +1 -1
- package/src/middleware/RateLimiter.d.ts +2 -2
- package/src/middleware/RateLimiter.d.ts.map +1 -1
- package/src/middleware/SanitizeBodyMiddleware.d.ts +12 -0
- package/src/middleware/SanitizeBodyMiddleware.d.ts.map +1 -0
- package/src/middleware/SanitizeBodyMiddleware.js +31 -0
- package/src/middleware/SecurityMiddleware.d.ts +1 -1
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -1
- package/src/middleware/SessionMiddleware.d.ts +1 -1
- package/src/middleware/SessionMiddleware.d.ts.map +1 -1
- package/src/middleware/ValidationMiddleware.d.ts +25 -0
- package/src/middleware/ValidationMiddleware.d.ts.map +1 -0
- package/src/middleware/ValidationMiddleware.js +251 -0
- package/src/migrations/MigrationDiscovery.d.ts +5 -0
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -0
- package/src/migrations/MigrationDiscovery.js +16 -0
- package/src/migrations/MigrationLoader.d.ts +5 -0
- package/src/migrations/MigrationLoader.d.ts.map +1 -0
- package/src/migrations/MigrationLoader.js +43 -0
- package/src/migrations/MigrationLock.d.ts +4 -0
- package/src/migrations/MigrationLock.d.ts.map +1 -0
- package/src/migrations/MigrationLock.js +33 -0
- package/src/migrations/Migrator.d.ts +23 -0
- package/src/migrations/Migrator.d.ts.map +1 -0
- package/src/migrations/Migrator.js +4 -0
- package/src/migrations/MigratorFactory.d.ts +25 -0
- package/src/migrations/MigratorFactory.d.ts.map +1 -0
- package/src/migrations/MigratorFactory.js +339 -0
- package/src/migrations/schema/Blueprint.d.ts +5 -0
- package/src/migrations/schema/Blueprint.d.ts.map +1 -0
- package/src/migrations/schema/Blueprint.js +189 -0
- package/src/migrations/schema/Schema.d.ts +8 -0
- package/src/migrations/schema/Schema.d.ts.map +1 -0
- package/src/migrations/schema/Schema.js +141 -0
- package/src/migrations/schema/SchemaCompiler.d.ts +20 -0
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -0
- package/src/migrations/schema/SchemaCompiler.js +262 -0
- package/src/migrations/schema/index.d.ts +5 -0
- package/src/migrations/schema/index.d.ts.map +1 -0
- package/src/migrations/schema/index.js +3 -0
- package/src/migrations/schema/types.d.ts +86 -0
- package/src/migrations/schema/types.d.ts.map +1 -0
- package/src/migrations/schema/types.js +1 -0
- package/src/migrations/types.d.ts +45 -0
- package/src/migrations/types.d.ts.map +1 -0
- package/src/migrations/types.js +1 -0
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/fs.d.ts +2 -2
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/fs.js +1 -1
- package/src/node-singletons/util.d.ts +6 -0
- package/src/node-singletons/util.d.ts.map +1 -0
- package/src/node-singletons/util.js +5 -0
- package/src/node.d.ts +3 -1
- package/src/node.d.ts.map +1 -1
- package/src/node.js +6 -2
- package/src/observability/OpenTelemetry.d.ts +62 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -0
- package/src/observability/OpenTelemetry.js +167 -0
- package/src/observability/PrometheusMetrics.d.ts +25 -0
- package/src/observability/PrometheusMetrics.d.ts.map +1 -0
- package/src/observability/PrometheusMetrics.js +114 -0
- package/src/openapi/OpenApiGenerator.d.ts +68 -0
- package/src/openapi/OpenApiGenerator.d.ts.map +1 -0
- package/src/openapi/OpenApiGenerator.js +287 -0
- package/src/orm/Database.d.ts +5 -2
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +219 -63
- package/src/orm/DatabaseAdapter.d.ts +14 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.d.ts.map +1 -1
- package/src/orm/DatabaseAdapterRegistry.js +3 -1
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +12 -0
- package/src/orm/Model.d.ts +30 -2
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +255 -62
- package/src/orm/QueryBuilder.d.ts +22 -1
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +406 -99
- package/src/orm/Relationships.d.ts +7 -1
- package/src/orm/Relationships.d.ts.map +1 -1
- package/src/orm/Relationships.js +18 -0
- package/src/orm/SchemaCompiler.d.ts +9 -0
- package/src/orm/SchemaCompiler.d.ts.map +1 -0
- package/src/orm/SchemaCompiler.js +145 -0
- package/src/orm/adapters/D1Adapter.d.ts +1 -1
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts +1 -1
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +88 -69
- package/src/orm/adapters/PostgreSQLAdapter.d.ts +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +88 -69
- package/src/orm/adapters/SQLServerAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts +1 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +59 -3
- package/src/orm/maintenance/SqliteMaintenance.d.ts +5 -0
- package/src/orm/maintenance/SqliteMaintenance.d.ts.map +1 -0
- package/src/orm/maintenance/SqliteMaintenance.js +14 -0
- package/src/orm/migrations/MigrationStore.d.ts +38 -0
- package/src/orm/migrations/MigrationStore.d.ts.map +1 -0
- package/src/orm/migrations/MigrationStore.js +157 -0
- package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -1
- package/src/performance/Optimizer.d.ts +7 -6
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +170 -55
- package/src/profiling/MemoryProfiler.d.ts +1 -1
- package/src/profiling/MemoryProfiler.d.ts.map +1 -1
- package/src/profiling/N1Detector.d.ts +1 -1
- package/src/profiling/N1Detector.d.ts.map +1 -1
- package/src/profiling/QueryLogger.d.ts +1 -1
- package/src/profiling/QueryLogger.d.ts.map +1 -1
- package/src/profiling/RequestProfiler.d.ts +3 -3
- package/src/profiling/RequestProfiler.d.ts.map +1 -1
- package/src/routes/metrics.d.ts +2 -0
- package/src/routes/metrics.d.ts.map +1 -0
- package/src/routes/metrics.js +1 -0
- package/src/routing/CoreRoutes.d.ts +12 -0
- package/src/routing/CoreRoutes.d.ts.map +1 -0
- package/src/routing/CoreRoutes.js +151 -0
- package/src/routing/RouteRegistry.d.ts +39 -0
- package/src/routing/RouteRegistry.d.ts.map +1 -0
- package/src/routing/RouteRegistry.js +44 -0
- package/src/routing/Router.d.ts +26 -9
- package/src/routing/Router.d.ts.map +1 -1
- package/src/routing/Router.js +79 -35
- package/src/routing/common.d.ts +15 -0
- package/src/routing/common.d.ts.map +1 -0
- package/src/routing/common.js +47 -0
- package/src/routing/doc.d.ts +27 -0
- package/src/routing/doc.d.ts.map +1 -0
- package/src/routing/doc.js +110 -0
- package/src/routing/error.d.ts +21 -0
- package/src/routing/error.d.ts.map +1 -0
- package/src/routing/error.js +126 -0
- package/src/routing/errorPages.d.ts +14 -0
- package/src/routing/errorPages.d.ts.map +1 -0
- package/src/routing/errorPages.js +103 -0
- package/src/routing/publicRoot.d.ts +27 -0
- package/src/routing/publicRoot.d.ts.map +1 -0
- package/src/routing/publicRoot.js +110 -0
- package/src/runtime/PluginAutoImports.d.ts +21 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -0
- package/src/runtime/PluginAutoImports.js +59 -0
- package/src/runtime/PluginManager.d.ts +1 -5
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +25 -18
- package/src/runtime/RuntimeDetector.d.ts +1 -1
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.d.ts +20 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -0
- package/src/runtime/StartupConfigFileRegistry.js +44 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts +1 -1
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/DenoAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts +1 -1
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
- package/src/runtime/getKernel.d.ts +9 -0
- package/src/runtime/getKernel.d.ts.map +1 -0
- package/src/runtime/getKernel.js +27 -0
- package/src/runtime/useFileLoader.d.ts +26 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -0
- package/src/runtime/useFileLoader.js +188 -0
- package/src/scripts/TemplateImportsCheck.js +40 -0
- package/src/scripts/TemplateSync.js +90 -24
- package/src/security/Encryptor.d.ts.map +1 -1
- package/src/security/Encryptor.js +64 -7
- package/src/security/JwtManager.d.ts +1 -0
- package/src/security/JwtManager.d.ts.map +1 -1
- package/src/security/JwtManager.js +33 -0
- package/src/security/Sanitizer.d.ts +76 -0
- package/src/security/Sanitizer.d.ts.map +1 -0
- package/src/security/Sanitizer.js +412 -0
- package/src/security/TokenRevocation.d.ts +7 -0
- package/src/security/TokenRevocation.d.ts.map +1 -0
- package/src/security/TokenRevocation.js +57 -0
- package/src/security/XssProtection.d.ts.map +1 -1
- package/src/security/XssProtection.js +62 -14
- package/src/seeders/SeederDiscovery.d.ts +5 -0
- package/src/seeders/SeederDiscovery.d.ts.map +1 -0
- package/src/seeders/SeederDiscovery.js +21 -0
- package/src/seeders/SeederLoader.d.ts +5 -0
- package/src/seeders/SeederLoader.d.ts.map +1 -0
- package/src/seeders/SeederLoader.js +60 -0
- package/src/seeders/types.d.ts +18 -0
- package/src/seeders/types.d.ts.map +1 -0
- package/src/seeders/types.js +1 -0
- package/src/session/SessionManager.js +1 -1
- package/src/templates/adapters/MySQLAdapter.ts.tpl +109 -85
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +129 -88
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -9
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +78 -11
- package/src/templates/features/Queue.ts.tpl +3 -2
- package/src/templates/project/basic/app/Controllers/AuthController.ts.tpl +217 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +1 -12
- package/src/templates/project/basic/app/Types/controller.ts.tpl +46 -0
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +5 -236
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +10 -447
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +9 -268
- package/src/templates/project/basic/config/app.ts.tpl +13 -153
- package/src/templates/project/basic/config/broadcast.ts.tpl +29 -126
- package/src/templates/project/basic/config/cache.ts.tpl +12 -70
- package/src/templates/project/basic/config/cloudflare.ts.tpl +4 -39
- package/src/templates/project/basic/config/constants.ts.tpl +9 -65
- package/src/templates/project/basic/config/database.ts.tpl +66 -123
- package/src/templates/project/basic/config/env.ts.tpl +5 -169
- package/src/templates/project/basic/config/features.ts.tpl +6 -54
- package/src/templates/project/basic/config/index.ts.tpl +8 -23
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +7 -114
- package/src/templates/project/basic/config/mail.ts.tpl +9 -62
- package/src/templates/project/basic/config/microservices.ts.tpl +11 -97
- package/src/templates/project/basic/config/middleware.ts.tpl +25 -43
- package/src/templates/project/basic/config/notification.ts.tpl +13 -114
- package/src/templates/project/basic/config/queue.ts.tpl +9 -40
- package/src/templates/project/basic/config/security.ts.tpl +11 -163
- package/src/templates/project/basic/config/startup.ts.tpl +10 -21
- package/src/templates/project/basic/config/storage.ts.tpl +57 -137
- package/src/templates/project/basic/config/type.ts.tpl +32 -451
- package/src/templates/project/basic/database/factories/UserFactory.ts.tpl +80 -0
- package/src/templates/project/basic/database/migrations/create_tasks_table.ts.tpl +28 -0
- package/src/templates/project/basic/database/migrations/create_users_table.ts.tpl +29 -0
- package/src/templates/project/basic/database/seeders/DatabaseSeeder.ts.tpl +19 -0
- package/src/templates/project/basic/database/seeders/UserSeeder.ts.tpl +18 -0
- package/src/templates/project/basic/database/seeders/index.ts.tpl +2 -0
- package/src/templates/project/basic/routes/api.ts.tpl +71 -33
- package/src/templates/project/basic/routes/metrics.ts.tpl +22 -0
- package/src/templates/project/basic/src/index.ts.tpl +3 -0
- package/src/templates/project/basic/tsconfig.json.tpl +12 -11
- package/src/testing/TestEnvironment.d.ts +40 -0
- package/src/testing/TestEnvironment.d.ts.map +1 -0
- package/src/testing/TestEnvironment.js +141 -0
- package/src/testing/TestHttp.d.ts +29 -0
- package/src/testing/TestHttp.d.ts.map +1 -0
- package/src/testing/TestHttp.js +96 -0
- package/src/testing/index.d.ts +5 -0
- package/src/testing/index.d.ts.map +1 -0
- package/src/testing/index.js +2 -0
- package/src/time/DateTime.d.ts +181 -0
- package/src/time/DateTime.d.ts.map +1 -0
- package/src/time/DateTime.js +300 -0
- package/src/time/index.d.ts +7 -0
- package/src/time/index.d.ts.map +1 -0
- package/src/time/index.js +5 -0
- package/src/tools/http/Http.d.ts.map +1 -1
- package/src/tools/http/Http.js +4 -0
- package/src/tools/mail/drivers/Smtp.js +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts +1 -1
- package/src/tools/queue/drivers/InMemory.d.ts.map +1 -1
- package/src/tools/queue/drivers/InMemory.js +1 -1
- package/src/tools/queue/drivers/Redis.d.ts +1 -1
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -1
- package/src/validation/ValidationError.d.ts.map +1 -1
- package/src/validation/ValidationError.js +4 -2
- package/src/validation/Validator.d.ts +49 -16
- package/src/validation/Validator.d.ts.map +1 -1
- package/src/validation/Validator.js +307 -5
- package/src/common/uuid.d.ts +0 -3
- package/src/common/uuid.d.ts.map +0 -1
- package/src/common/uuid.js +0 -30
- package/src/templates/project/basic/.env.example.tpl +0 -74
- package/src/templates/project/basic/.env.tpl +0 -166
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +0 -181
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +0 -156
- package/src/templates/project/basic/database/migrations/index.ts.tpl +0 -2
package/src/cli/CLI.js
CHANGED
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
import { AddCommand } from './commands/AddCommand.js';
|
|
6
6
|
import { BroadcastWorkCommand } from './commands/BroadcastWorkCommand.js';
|
|
7
7
|
import { ConfigCommand } from './commands/ConfigCommand.js';
|
|
8
|
+
import { AddMigrationCommand, CreateCommand, CreateMigrationCommand, } from './commands/CreateCommand.js';
|
|
8
9
|
import { D1MigrateCommand } from './commands/D1MigrateCommand.js';
|
|
10
|
+
import { DbSeedCommand } from './commands/DbSeedCommand.js';
|
|
9
11
|
import { DebugCommand } from './commands/DebugCommand.js';
|
|
10
12
|
import { FixCommand } from './commands/FixCommand.js';
|
|
13
|
+
import { JwtDevCommand } from './commands/JwtDevCommand.js';
|
|
11
14
|
import { KeyGenerateCommand } from './commands/KeyGenerateCommand.js';
|
|
12
15
|
import { MakeMailTemplateCommand } from './commands/MakeMailTemplateCommand.js';
|
|
13
16
|
import { MakeNotificationTemplateCommand } from './commands/MakeNotificationTemplateCommand.js';
|
|
@@ -18,6 +21,7 @@ import { PluginCommand } from './commands/PluginCommand.js';
|
|
|
18
21
|
import { PrepareCommand } from './commands/PrepareCommand.js';
|
|
19
22
|
import { QACommand } from './commands/QACommand.js';
|
|
20
23
|
import { QueueCommand } from './commands/QueueCommand.js';
|
|
24
|
+
import { RoutesCommand } from './commands/RoutesCommand.js';
|
|
21
25
|
import { SecretsCommand } from './commands/SecretsCommand.js';
|
|
22
26
|
import { SimulateCommand } from './commands/SimulateCommand.js';
|
|
23
27
|
import { StartCommand } from './commands/StartCommand.js';
|
|
@@ -31,10 +35,6 @@ import { readFileSync } from '../node-singletons/fs.js';
|
|
|
31
35
|
import { join } from '../node-singletons/path.js';
|
|
32
36
|
import { Command } from 'commander';
|
|
33
37
|
const __dirname = esmDirname(import.meta.url);
|
|
34
|
-
/**
|
|
35
|
-
* CLI - Main CLI Class
|
|
36
|
-
* Orchestrates all CLI commands using Commander
|
|
37
|
-
*/
|
|
38
38
|
/**
|
|
39
39
|
* Load version from package.json
|
|
40
40
|
*/
|
|
@@ -72,11 +72,15 @@ const registerCommands = (program) => {
|
|
|
72
72
|
UpgradeCommand.create(),
|
|
73
73
|
PrepareCommand,
|
|
74
74
|
AddCommand.create(),
|
|
75
|
+
CreateCommand.create(),
|
|
76
|
+
CreateMigrationCommand.create(),
|
|
77
|
+
AddMigrationCommand.create(),
|
|
75
78
|
StartCommand.create(),
|
|
76
79
|
QueueCommand.create(),
|
|
77
80
|
BroadcastWorkCommand.create(),
|
|
78
81
|
NotificationWorkCommand.create(),
|
|
79
82
|
MigrateCommand.create(),
|
|
83
|
+
DbSeedCommand.create(),
|
|
80
84
|
D1MigrateCommand.create(),
|
|
81
85
|
DebugCommand.create(),
|
|
82
86
|
SecretsCommand.create(),
|
|
@@ -89,6 +93,8 @@ const registerCommands = (program) => {
|
|
|
89
93
|
TemplatesCommand,
|
|
90
94
|
MakeMailTemplateCommand.create(),
|
|
91
95
|
MakeNotificationTemplateCommand.create(),
|
|
96
|
+
RoutesCommand.create(),
|
|
97
|
+
JwtDevCommand,
|
|
92
98
|
];
|
|
93
99
|
for (const command of commands) {
|
|
94
100
|
program.addCommand(command.getCommand());
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Add Command - Phase 4 Integration
|
|
3
3
|
* Add services and features to existing Zintrust project
|
|
4
4
|
*/
|
|
5
|
-
import { IBaseCommand } from '../BaseCommand';
|
|
6
|
-
import { ResponseField } from '../scaffolding/ResponseFactoryGenerator';
|
|
5
|
+
import type { IBaseCommand } from '../BaseCommand';
|
|
6
|
+
import type { ResponseField } from '../scaffolding/ResponseFactoryGenerator';
|
|
7
7
|
interface ServicePromptAnswers {
|
|
8
8
|
name: string;
|
|
9
9
|
domain: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/AddCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"AddCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/AddCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAarE,OAAO,KAAK,EAEV,aAAa,EAAC,MAAM,2CAA2C,CAAC;AA0ClE,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAAC;IAChC,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;CAC7C;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,2BAA2B;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,4BAA4B;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAsmCD;;GAEG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;cACO,YAAY;IAWtB;;;OAGG;;2CAnlC2C,MAAM,KAAG,OAAO,CAAC,oBAAoB,CAAC;mCA2EhD,OAAO,CAAC,oBAAoB,CAAC;qCA8D3B,OAAO,CAAC,sBAAsB,CAAC;iCAwGnC,OAAO,CAAC,kBAAkB,CAAC;sCA4DtB,OAAO,CAAC,uBAAuB,CAAC;kCAwDpC,OAAO,CAAC,mBAAmB,CAAC;mCAkE3B,OAAO,CAAC,oBAAoB,CAAC;kCA8I9B,OAAO,CAAC,mBAAmB,CAAC;0CAiHpB,OAAO,CAAC,2BAA2B,CAAC;yCAwFrC,OAAO,CAAC,MAAM,CAAC;2DAkBpC,MAAM,KAC1B,OAAO,CAAC,4BAA4B,CAAC;4CAoHzB,MAAM,KAClB,OAAO,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,KAAK,CAAA;SAAE,CAAC;iDAlE5C,MAAM,KAAG,aAAa,EAAE;;EA+RtE,CAAC"}
|
|
@@ -6,14 +6,17 @@ import { BaseCommand } from '../BaseCommand.js';
|
|
|
6
6
|
import { ControllerGenerator } from '../scaffolding/ControllerGenerator.js';
|
|
7
7
|
import { FactoryGenerator } from '../scaffolding/FactoryGenerator.js';
|
|
8
8
|
import { FeatureScaffolder } from '../scaffolding/FeatureScaffolder.js';
|
|
9
|
+
import { FileGenerator } from '../scaffolding/FileGenerator.js';
|
|
10
|
+
import { GovernanceScaffolder } from '../scaffolding/GovernanceScaffolder.js';
|
|
9
11
|
import { MigrationGenerator } from '../scaffolding/MigrationGenerator.js';
|
|
10
12
|
import { ModelGenerator } from '../scaffolding/ModelGenerator.js';
|
|
11
13
|
import { RequestFactoryGenerator } from '../scaffolding/RequestFactoryGenerator.js';
|
|
12
|
-
import { ResponseFactoryGenerator
|
|
14
|
+
import { ResponseFactoryGenerator } from '../scaffolding/ResponseFactoryGenerator.js';
|
|
13
15
|
import { RouteGenerator } from '../scaffolding/RouteGenerator.js';
|
|
14
16
|
import { SeederGenerator } from '../scaffolding/SeederGenerator.js';
|
|
15
17
|
import { ServiceScaffolder } from '../scaffolding/ServiceScaffolder.js';
|
|
16
18
|
import { WorkflowGenerator } from '../scaffolding/WorkflowGenerator.js';
|
|
19
|
+
import { CommonUtils } from '../../common/index.js';
|
|
17
20
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
18
21
|
import fs from '../../node-singletons/fs.js';
|
|
19
22
|
import * as path from '../../node-singletons/path.js';
|
|
@@ -21,12 +24,14 @@ import { PluginManager } from '../../runtime/PluginManager.js';
|
|
|
21
24
|
import inquirer from 'inquirer';
|
|
22
25
|
const addOptions = (command) => {
|
|
23
26
|
command
|
|
24
|
-
.argument('<type>', 'What to add: service, feature, migration, model, controller, routes, factory, seeder, requestfactory, responsefactory, or
|
|
25
|
-
.argument('[name]', 'Name of service/feature/migration/model/controller/factory/seeder/requestfactory/responsefactory/workflow')
|
|
27
|
+
.argument('<type>', 'What to add: service, feature, migration, model, controller, routes, factory, seeder, requestfactory, responsefactory, workflow, or governance')
|
|
28
|
+
.argument('[name]', 'Name of service/feature/migration/model/controller/factory/seeder/requestfactory/responsefactory/workflow (governance takes no name)')
|
|
26
29
|
.option('--package-manager <pm>', 'Specify package manager to use when installing plugins (npm|yarn|pnpm)')
|
|
30
|
+
.option('--domain <name>', 'Service domain (e.g., ecommerce, payments) - for services')
|
|
27
31
|
.option('--database <type>', 'Database (shared|isolated) - for services')
|
|
28
32
|
.option('--auth <strategy>', 'Auth strategy (api-key|jwt|none|custom) - for services')
|
|
29
33
|
.option('--port <number>', 'Service port - for services')
|
|
34
|
+
.option('--service <path>', 'Service path (relative to project root) - for features')
|
|
30
35
|
.option('--with-test', 'Generate test files - for features')
|
|
31
36
|
.option('--controller-type <type>', 'Controller type: crud, resource, api, graphql, websocket, webhook - for controllers')
|
|
32
37
|
.option('--soft-delete', 'Add soft delete to model')
|
|
@@ -172,9 +177,31 @@ const promptMigrationConfig = async () => {
|
|
|
172
177
|
},
|
|
173
178
|
]);
|
|
174
179
|
};
|
|
175
|
-
const
|
|
180
|
+
const pluralize = (snake) => (snake.endsWith('s') ? snake : `${snake}s`);
|
|
181
|
+
const findMigrationBySuffix = (migrationsPath, suffix) => {
|
|
182
|
+
const files = FileGenerator.listFiles(migrationsPath, false);
|
|
183
|
+
for (const file of files) {
|
|
184
|
+
if (path.basename(file).endsWith(suffix))
|
|
185
|
+
return file;
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
};
|
|
189
|
+
const buildCreateTableMigrationName = (model) => {
|
|
190
|
+
const modelSnake = CommonUtils.toSnakeCase(model).replaceAll(/[^a-z0-9_]+/g, '_');
|
|
191
|
+
const tablePlural = pluralize(modelSnake);
|
|
192
|
+
return `create_${tablePlural}_table`;
|
|
193
|
+
};
|
|
194
|
+
const buildAddColumnMigrationName = (column, model) => {
|
|
195
|
+
const colSnake = CommonUtils.toSnakeCase(column).replaceAll(/[^a-z0-9_]+/g, '_');
|
|
196
|
+
const modelSnake = CommonUtils.toSnakeCase(model).replaceAll(/[^a-z0-9_]+/g, '_');
|
|
197
|
+
const tablePlural = pluralize(modelSnake);
|
|
198
|
+
return `add_${colSnake}_${tablePlural}_table`;
|
|
199
|
+
};
|
|
200
|
+
const addMigration = async (cmd, migrationArgs, opts) => {
|
|
176
201
|
const projectRoot = process.cwd();
|
|
177
|
-
let name =
|
|
202
|
+
let name = migrationArgs[0] ?? '';
|
|
203
|
+
let table;
|
|
204
|
+
let column;
|
|
178
205
|
if (name === '' && opts.noInteractive !== true) {
|
|
179
206
|
const answers = await promptMigrationConfig();
|
|
180
207
|
name = answers.name;
|
|
@@ -184,11 +211,32 @@ const addMigration = async (cmd, migrationName, opts) => {
|
|
|
184
211
|
throw ErrorFactory.createValidationError('Migration name is required');
|
|
185
212
|
}
|
|
186
213
|
const migrationsPath = path.join(projectRoot, 'database', 'migrations');
|
|
214
|
+
// New shorthand semantics:
|
|
215
|
+
// `zin add migration <column> <model>` => add_<column>_<models>_table
|
|
216
|
+
if (migrationArgs.length >= 2) {
|
|
217
|
+
const columnArg = migrationArgs[0] ?? '';
|
|
218
|
+
const modelArg = migrationArgs[1] ?? '';
|
|
219
|
+
if (columnArg === '' || modelArg === '') {
|
|
220
|
+
throw ErrorFactory.createValidationError('Usage: zin add migration <column> <model>');
|
|
221
|
+
}
|
|
222
|
+
const createName = buildCreateTableMigrationName(modelArg);
|
|
223
|
+
const createSuffix = `_${createName}.ts`;
|
|
224
|
+
const existingCreate = findMigrationBySuffix(migrationsPath, createSuffix);
|
|
225
|
+
if (existingCreate === undefined) {
|
|
226
|
+
throw ErrorFactory.createCliError(`Missing required create migration for model '${modelArg}'. Create it first: zin create migration ${modelArg}`);
|
|
227
|
+
}
|
|
228
|
+
name = buildAddColumnMigrationName(columnArg, modelArg);
|
|
229
|
+
table = pluralize(CommonUtils.toSnakeCase(modelArg).replaceAll(/[^a-z0-9_]+/g, '_'));
|
|
230
|
+
// Store the normalized column name for generator placeholder.
|
|
231
|
+
column = CommonUtils.toSnakeCase(columnArg).replaceAll(/[^a-z0-9_]+/g, '_');
|
|
232
|
+
}
|
|
187
233
|
cmd.info(`Creating migration: ${name}...`);
|
|
188
234
|
const result = await MigrationGenerator.generateMigration({
|
|
189
235
|
name,
|
|
190
236
|
migrationsPath,
|
|
191
|
-
type:
|
|
237
|
+
type: opts.type ?? undefined,
|
|
238
|
+
table,
|
|
239
|
+
column,
|
|
192
240
|
});
|
|
193
241
|
if (result.success === false)
|
|
194
242
|
throw ErrorFactory.createCliError(result.message);
|
|
@@ -386,6 +434,7 @@ const addFactory = async (cmd, factoryName, opts) => {
|
|
|
386
434
|
throw ErrorFactory.createValidationError('Model name is required for factory generation');
|
|
387
435
|
}
|
|
388
436
|
const factoriesPath = path.join(projectRoot, 'database', 'factories');
|
|
437
|
+
ensureDirectoryExists(factoriesPath);
|
|
389
438
|
cmd.info(`Creating factory: ${config.name} for model ${config.modelName}...`);
|
|
390
439
|
const result = await FactoryGenerator.generateFactory({
|
|
391
440
|
factoryName: config.name,
|
|
@@ -426,6 +475,11 @@ const displaySeederSuccess = (cmd, name, count, filePath, states, relationships)
|
|
|
426
475
|
}
|
|
427
476
|
cmd.info(`\nOther methods:\n await ${name}.reset() // Truncate table\n await ${name}.runWithTruncate() // Reset and seed`);
|
|
428
477
|
};
|
|
478
|
+
const displayDatabaseSeederSuccess = (cmd, filePath) => {
|
|
479
|
+
cmd.success(`Seeder 'DatabaseSeeder' created successfully!`);
|
|
480
|
+
cmd.info(`File: ${path.basename(filePath)}`);
|
|
481
|
+
cmd.info(`\nNext steps:\n • Add additional seeders into this directory\n • Run: zin db:seed`);
|
|
482
|
+
};
|
|
429
483
|
const promptSeederConfig = async () => {
|
|
430
484
|
return inquirer.prompt([
|
|
431
485
|
{
|
|
@@ -438,6 +492,7 @@ const promptSeederConfig = async () => {
|
|
|
438
492
|
type: 'input',
|
|
439
493
|
name: 'model',
|
|
440
494
|
message: 'Model name (e.g., User, Post):',
|
|
495
|
+
when: (ans) => ans.name !== 'DatabaseSeeder',
|
|
441
496
|
validate: (v) => /^[A-Z][a-zA-Z\d]*$/.test(v) || 'Must be PascalCase',
|
|
442
497
|
},
|
|
443
498
|
{
|
|
@@ -445,6 +500,7 @@ const promptSeederConfig = async () => {
|
|
|
445
500
|
name: 'count',
|
|
446
501
|
message: 'Number of records to seed (1-100,000):',
|
|
447
502
|
default: '100',
|
|
503
|
+
when: (ans) => ans.name !== 'DatabaseSeeder',
|
|
448
504
|
validate: (v) => {
|
|
449
505
|
const num = Number.parseInt(v, 10);
|
|
450
506
|
return (num >= 1 && num <= 100000) || 'Must be between 1 and 100,000';
|
|
@@ -455,18 +511,21 @@ const promptSeederConfig = async () => {
|
|
|
455
511
|
name: 'states',
|
|
456
512
|
message: 'Use state distribution (50% active, 30% inactive, 20% deleted)?',
|
|
457
513
|
default: false,
|
|
514
|
+
when: (ans) => ans.name !== 'DatabaseSeeder',
|
|
458
515
|
},
|
|
459
516
|
{
|
|
460
517
|
type: 'confirm',
|
|
461
518
|
name: 'relationships',
|
|
462
519
|
message: 'Seed with relationships?',
|
|
463
520
|
default: false,
|
|
521
|
+
when: (ans) => ans.name !== 'DatabaseSeeder',
|
|
464
522
|
},
|
|
465
523
|
{
|
|
466
524
|
type: 'confirm',
|
|
467
525
|
name: 'truncate',
|
|
468
526
|
message: 'Truncate table before seeding?',
|
|
469
527
|
default: true,
|
|
528
|
+
when: (ans) => ans.name !== 'DatabaseSeeder',
|
|
470
529
|
},
|
|
471
530
|
]);
|
|
472
531
|
};
|
|
@@ -487,11 +546,19 @@ const addSeeder = async (cmd, seederName, opts) => {
|
|
|
487
546
|
else if (config.name === '') {
|
|
488
547
|
throw ErrorFactory.createValidationError('Seeder name is required');
|
|
489
548
|
}
|
|
549
|
+
const seedersPath = path.join(projectRoot, 'database', 'seeders');
|
|
550
|
+
ensureDirectoryExists(seedersPath);
|
|
551
|
+
if (config.name === 'DatabaseSeeder') {
|
|
552
|
+
cmd.info('Creating seeder: DatabaseSeeder...');
|
|
553
|
+
const result = await SeederGenerator.generateDatabaseSeeder({ seedersPath });
|
|
554
|
+
if (result.success === false)
|
|
555
|
+
throw ErrorFactory.createCliError(result.message);
|
|
556
|
+
displayDatabaseSeederSuccess(cmd, result.filePath);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
490
559
|
if (config.modelName === '') {
|
|
491
560
|
throw ErrorFactory.createValidationError('Model name is required for seeder generation');
|
|
492
561
|
}
|
|
493
|
-
const seedersPath = path.join(projectRoot, 'database', 'seeders');
|
|
494
|
-
ensureDirectoryExists(seedersPath);
|
|
495
562
|
cmd.info(`Creating seeder: ${config.name} for model ${config.modelName}...`);
|
|
496
563
|
const result = await SeederGenerator.generateSeeder({
|
|
497
564
|
seederName: config.name,
|
|
@@ -739,48 +806,65 @@ const addWorkflow = async (cmd, workflowName, opts) => {
|
|
|
739
806
|
throw ErrorFactory.createCliError(result.message);
|
|
740
807
|
cmd.success(result.message);
|
|
741
808
|
};
|
|
809
|
+
const addGovernance = async (cmd, name, opts) => {
|
|
810
|
+
if (typeof name === 'string' && name.trim() !== '') {
|
|
811
|
+
throw ErrorFactory.createValidationError('governance does not take a name argument. Usage: zin add governance');
|
|
812
|
+
}
|
|
813
|
+
const projectRoot = process.cwd();
|
|
814
|
+
cmd.info('Installing governance tooling (ESLint + architecture tests)...');
|
|
815
|
+
const result = await GovernanceScaffolder.scaffold(projectRoot, {
|
|
816
|
+
writeEslintConfig: true,
|
|
817
|
+
writeArchTests: true,
|
|
818
|
+
install: true,
|
|
819
|
+
packageManager: opts.packageManager,
|
|
820
|
+
});
|
|
821
|
+
if (result.success === false) {
|
|
822
|
+
throw ErrorFactory.createCliError(result.message ?? 'Governance installation failed', result);
|
|
823
|
+
}
|
|
824
|
+
cmd.success('Governance installed successfully!');
|
|
825
|
+
if (result.filesCreated.length > 0) {
|
|
826
|
+
cmd.info(`Files created: ${result.filesCreated.length}`);
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
const TYPE_HANDLERS = {
|
|
830
|
+
service: addService,
|
|
831
|
+
feature: addFeature,
|
|
832
|
+
migration: async (cmd, name, opts) => addMigration(cmd, typeof name === 'string' && name.length > 0 ? [name] : [], opts),
|
|
833
|
+
model: addModel,
|
|
834
|
+
controller: addController,
|
|
835
|
+
routes: addRoutes,
|
|
836
|
+
factory: addFactory,
|
|
837
|
+
seeder: addSeeder,
|
|
838
|
+
requestfactory: addRequestFactory,
|
|
839
|
+
'request-factory': addRequestFactory,
|
|
840
|
+
responsefactory: addResponseFactory,
|
|
841
|
+
'response-factory': addResponseFactory,
|
|
842
|
+
workflow: addWorkflow,
|
|
843
|
+
governance: addGovernance,
|
|
844
|
+
};
|
|
742
845
|
const handleType = async (cmd, type, name, opts) => {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
break;
|
|
747
|
-
case 'feature':
|
|
748
|
-
await addFeature(cmd, name, opts);
|
|
749
|
-
break;
|
|
750
|
-
case 'migration':
|
|
751
|
-
await addMigration(cmd, name, opts);
|
|
752
|
-
break;
|
|
753
|
-
case 'model':
|
|
754
|
-
await addModel(cmd, name, opts);
|
|
755
|
-
break;
|
|
756
|
-
case 'controller':
|
|
757
|
-
await addController(cmd, name, opts);
|
|
758
|
-
break;
|
|
759
|
-
case 'routes':
|
|
760
|
-
await addRoutes(cmd, name, opts);
|
|
761
|
-
break;
|
|
762
|
-
case 'factory':
|
|
763
|
-
await addFactory(cmd, name, opts);
|
|
764
|
-
break;
|
|
765
|
-
case 'seeder':
|
|
766
|
-
await addSeeder(cmd, name, opts);
|
|
767
|
-
break;
|
|
768
|
-
case 'requestfactory':
|
|
769
|
-
case 'request-factory':
|
|
770
|
-
await addRequestFactory(cmd, name, opts);
|
|
771
|
-
break;
|
|
772
|
-
case 'responsefactory':
|
|
773
|
-
case 'response-factory':
|
|
774
|
-
await addResponseFactory(cmd, name, opts);
|
|
775
|
-
break;
|
|
776
|
-
case 'workflow':
|
|
777
|
-
await addWorkflow(cmd, name, opts);
|
|
778
|
-
break;
|
|
779
|
-
default:
|
|
780
|
-
throw ErrorFactory.createCliError(`Unknown type "${type}". Use: service, feature, migration, model, controller, routes, factory, seeder, requestfactory, responsefactory, or workflow`);
|
|
846
|
+
const handler = TYPE_HANDLERS[type];
|
|
847
|
+
if (handler === undefined) {
|
|
848
|
+
throw ErrorFactory.createCliError(`Unknown type "${type}". Use: service, feature, migration, model, controller, routes, factory, seeder, requestfactory, responsefactory, workflow, or governance`);
|
|
781
849
|
}
|
|
850
|
+
await handler(cmd, name, opts);
|
|
782
851
|
};
|
|
783
852
|
const getArgs = (args) => Array.isArray(args) ? args : undefined;
|
|
853
|
+
const installPlugin = async (cmd, type, name, addOpts) => {
|
|
854
|
+
const normalizedType = type.toLowerCase();
|
|
855
|
+
if (name !== undefined && name.length > 0) {
|
|
856
|
+
throw ErrorFactory.createCliError(`"${type}" looks like a plugin id. Run: zin add ${type} (without a name argument).`);
|
|
857
|
+
}
|
|
858
|
+
cmd.info(`Installing plugin: ${normalizedType}...`);
|
|
859
|
+
const pm = typeof addOpts.packageManager === 'string' ? addOpts.packageManager : undefined;
|
|
860
|
+
if (pm === undefined) {
|
|
861
|
+
await PluginManager.install(normalizedType);
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
await PluginManager.install(normalizedType, { packageManager: pm });
|
|
865
|
+
}
|
|
866
|
+
cmd.success(`Plugin '${normalizedType}' installed successfully!`);
|
|
867
|
+
};
|
|
784
868
|
const executeAdd = async (cmd, options) => {
|
|
785
869
|
const command = cmd.getCommand();
|
|
786
870
|
const args = getArgs(options.args) ?? getArgs(command.args) ?? [];
|
|
@@ -795,18 +879,11 @@ const executeAdd = async (cmd, options) => {
|
|
|
795
879
|
// Planned modular adapter syntax: `zin add db:sqlite` (delegate to plugin installer)
|
|
796
880
|
const normalizedType = type.toLowerCase();
|
|
797
881
|
if (normalizedType.includes(':')) {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
if (pm === undefined) {
|
|
804
|
-
await PluginManager.install(normalizedType);
|
|
805
|
-
}
|
|
806
|
-
else {
|
|
807
|
-
await PluginManager.install(normalizedType, { packageManager: pm });
|
|
808
|
-
}
|
|
809
|
-
cmd.success(`Plugin '${normalizedType}' installed successfully!`);
|
|
882
|
+
await installPlugin(cmd, type, name, addOpts);
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
if (normalizedType === 'migration') {
|
|
886
|
+
await addMigration(cmd, args.slice(1), addOpts);
|
|
810
887
|
return;
|
|
811
888
|
}
|
|
812
889
|
await handleType(cmd, normalizedType, name, addOpts);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Config Command - Configuration management CLI command
|
|
3
3
|
* Handles configuration operations: get, set, list, reset, edit, export
|
|
4
4
|
*/
|
|
5
|
-
import { IBaseCommand } from '../BaseCommand';
|
|
5
|
+
import type { IBaseCommand } from '../BaseCommand';
|
|
6
6
|
/**
|
|
7
7
|
* Config Command Factory
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ConfigCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"ConfigCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ConfigCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmVrE;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;cACO,YAAY;EAsEtB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Command
|
|
3
|
+
* Shortcuts for common scaffolding tasks.
|
|
4
|
+
*/
|
|
5
|
+
import { type IBaseCommand } from '../BaseCommand';
|
|
6
|
+
export declare const CreateCommand: Readonly<{
|
|
7
|
+
create(): IBaseCommand;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const CreateMigrationCommand: Readonly<{
|
|
10
|
+
create(): IBaseCommand;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const AddMigrationCommand: Readonly<{
|
|
13
|
+
create(): IBaseCommand;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=CreateCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/CreateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA+HvF,eAAO,MAAM,aAAa;cACd,YAAY;EAUtB,CAAC;AAEH,eAAO,MAAM,sBAAsB;cACvB,YAAY;EAatB,CAAC;AAEH,eAAO,MAAM,mBAAmB;cACpB,YAAY;EActB,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create Command
|
|
3
|
+
* Shortcuts for common scaffolding tasks.
|
|
4
|
+
*/
|
|
5
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
6
|
+
import { FileGenerator } from '../scaffolding/FileGenerator.js';
|
|
7
|
+
import { MigrationGenerator } from '../scaffolding/MigrationGenerator.js';
|
|
8
|
+
import { CommonUtils } from '../../common/index.js';
|
|
9
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
10
|
+
import * as path from '../../node-singletons/path.js';
|
|
11
|
+
const pluralize = (snake) => (snake.endsWith('s') ? snake : `${snake}s`);
|
|
12
|
+
const buildCreateTableMigrationName = (model) => {
|
|
13
|
+
const modelSnake = CommonUtils.toSnakeCase(model).replaceAll(/[^a-z0-9_]+/g, '_');
|
|
14
|
+
const tablePlural = pluralize(modelSnake);
|
|
15
|
+
return `create_${tablePlural}_table`;
|
|
16
|
+
};
|
|
17
|
+
const buildAddColumnMigrationName = (column, model) => {
|
|
18
|
+
const colSnake = CommonUtils.toSnakeCase(column).replaceAll(/[^a-z0-9_]+/g, '_');
|
|
19
|
+
const modelSnake = CommonUtils.toSnakeCase(model).replaceAll(/[^a-z0-9_]+/g, '_');
|
|
20
|
+
const tablePlural = pluralize(modelSnake);
|
|
21
|
+
return `add_${colSnake}_${tablePlural}_table`;
|
|
22
|
+
};
|
|
23
|
+
const findMigrationBySuffix = (migrationsPath, suffix) => {
|
|
24
|
+
const files = FileGenerator.listFiles(migrationsPath, false);
|
|
25
|
+
for (const file of files) {
|
|
26
|
+
if (path.basename(file).endsWith(suffix))
|
|
27
|
+
return file;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
};
|
|
31
|
+
const addOptions = (command) => {
|
|
32
|
+
command
|
|
33
|
+
.argument('<type>', 'What to create (currently: migration)')
|
|
34
|
+
.argument('<name>', 'Name (for migration: model name like "user")');
|
|
35
|
+
// Accepted for consistency with other CLI commands.
|
|
36
|
+
command.option('--no-interactive', 'Skip interactive prompts');
|
|
37
|
+
};
|
|
38
|
+
const executeCreate = async (cmd, options) => {
|
|
39
|
+
const args = Array.isArray(options.args) ? options.args : [];
|
|
40
|
+
const type = args[0];
|
|
41
|
+
const name = args[1];
|
|
42
|
+
if (type !== 'migration') {
|
|
43
|
+
throw ErrorFactory.createCliError('Usage: zin create migration <model>');
|
|
44
|
+
}
|
|
45
|
+
if (typeof name !== 'string' || name.trim() === '') {
|
|
46
|
+
throw ErrorFactory.createValidationError('Model name is required');
|
|
47
|
+
}
|
|
48
|
+
const projectRoot = process.cwd();
|
|
49
|
+
const migrationsPath = path.join(projectRoot, 'database', 'migrations');
|
|
50
|
+
const migrationName = buildCreateTableMigrationName(name);
|
|
51
|
+
const tableName = pluralize(CommonUtils.toSnakeCase(name).replaceAll(/[^a-z0-9_]+/g, '_'));
|
|
52
|
+
cmd.info(`Creating migration: ${migrationName}...`);
|
|
53
|
+
const result = await MigrationGenerator.generateMigration({
|
|
54
|
+
name: migrationName,
|
|
55
|
+
migrationsPath,
|
|
56
|
+
type: 'create',
|
|
57
|
+
table: tableName,
|
|
58
|
+
});
|
|
59
|
+
if (result.success === false)
|
|
60
|
+
throw ErrorFactory.createCliError(result.message);
|
|
61
|
+
cmd.success('Migration created successfully!');
|
|
62
|
+
cmd.info(`File: ${path.basename(result.filePath)}`);
|
|
63
|
+
};
|
|
64
|
+
const executeCm = async (cmd, options) => {
|
|
65
|
+
const args = Array.isArray(options.args) ? options.args : [];
|
|
66
|
+
const model = args[0];
|
|
67
|
+
if (typeof model !== 'string' || model.trim() === '') {
|
|
68
|
+
throw ErrorFactory.createCliError('Usage: zin cm <model>');
|
|
69
|
+
}
|
|
70
|
+
await executeCreate(cmd, { ...options, args: ['migration', model] });
|
|
71
|
+
};
|
|
72
|
+
const executeAm = async (cmd, options) => {
|
|
73
|
+
const args = Array.isArray(options.args) ? options.args : [];
|
|
74
|
+
const column = args[0];
|
|
75
|
+
const model = args[1];
|
|
76
|
+
if (typeof column !== 'string' ||
|
|
77
|
+
column.trim() === '' ||
|
|
78
|
+
typeof model !== 'string' ||
|
|
79
|
+
model.trim() === '') {
|
|
80
|
+
throw ErrorFactory.createCliError('Usage: zin am <column> <model>');
|
|
81
|
+
}
|
|
82
|
+
const projectRoot = process.cwd();
|
|
83
|
+
const migrationsPath = path.join(projectRoot, 'database', 'migrations');
|
|
84
|
+
const tableName = pluralize(CommonUtils.toSnakeCase(model).replaceAll(/[^a-z0-9_]+/g, '_'));
|
|
85
|
+
const createName = buildCreateTableMigrationName(model);
|
|
86
|
+
const existingCreate = findMigrationBySuffix(migrationsPath, `_${createName}.ts`);
|
|
87
|
+
if (existingCreate === undefined) {
|
|
88
|
+
throw ErrorFactory.createCliError(`Missing required create migration for model '${model}'. Create it first: zin cm ${model}`);
|
|
89
|
+
}
|
|
90
|
+
const migrationName = buildAddColumnMigrationName(column, model);
|
|
91
|
+
cmd.info(`Creating migration: ${migrationName}...`);
|
|
92
|
+
const result = await MigrationGenerator.generateMigration({
|
|
93
|
+
name: migrationName,
|
|
94
|
+
migrationsPath,
|
|
95
|
+
// Let generator infer type from name (add_* => alter)
|
|
96
|
+
table: tableName,
|
|
97
|
+
column: CommonUtils.toSnakeCase(column).replaceAll(/[^a-z0-9_]+/g, '_'),
|
|
98
|
+
});
|
|
99
|
+
if (result.success === false)
|
|
100
|
+
throw ErrorFactory.createCliError(result.message);
|
|
101
|
+
cmd.success('Migration created successfully!');
|
|
102
|
+
cmd.info(`File: ${path.basename(result.filePath)}`);
|
|
103
|
+
};
|
|
104
|
+
export const CreateCommand = Object.freeze({
|
|
105
|
+
create() {
|
|
106
|
+
const cmd = BaseCommand.create({
|
|
107
|
+
name: 'create',
|
|
108
|
+
description: 'Create resources (e.g. migrations) with opinionated naming',
|
|
109
|
+
addOptions,
|
|
110
|
+
execute: async (options) => executeCreate(cmd, options),
|
|
111
|
+
});
|
|
112
|
+
return cmd;
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
export const CreateMigrationCommand = Object.freeze({
|
|
116
|
+
create() {
|
|
117
|
+
const cmd = BaseCommand.create({
|
|
118
|
+
name: 'cm',
|
|
119
|
+
description: 'Shortcut: create migration for a model (create_<models>_table)',
|
|
120
|
+
addOptions: (command) => {
|
|
121
|
+
command.argument('<model>', 'Model name (e.g. user)');
|
|
122
|
+
command.option('--no-interactive', 'Skip interactive prompts');
|
|
123
|
+
},
|
|
124
|
+
execute: async (options) => executeCm(cmd, options),
|
|
125
|
+
});
|
|
126
|
+
return cmd;
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
export const AddMigrationCommand = Object.freeze({
|
|
130
|
+
create() {
|
|
131
|
+
const cmd = BaseCommand.create({
|
|
132
|
+
name: 'am',
|
|
133
|
+
description: 'Shortcut: add column migration for a model (add_<col>_<models>_table)',
|
|
134
|
+
addOptions: (command) => {
|
|
135
|
+
command.argument('<column>', 'Column name (e.g. bio)');
|
|
136
|
+
command.argument('<model>', 'Model name (e.g. user)');
|
|
137
|
+
command.option('--no-interactive', 'Skip interactive prompts');
|
|
138
|
+
},
|
|
139
|
+
execute: async (options) => executeAm(cmd, options),
|
|
140
|
+
});
|
|
141
|
+
return cmd;
|
|
142
|
+
},
|
|
143
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"D1MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAyDrE;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;cACO,YAAY;EAwBtB,CAAC"}
|
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* D1 Migrate Command
|
|
3
|
-
* Run Cloudflare D1 migrations using Wrangler
|
|
4
|
-
*/
|
|
5
1
|
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { WranglerD1 } from '../d1/WranglerD1.js';
|
|
6
3
|
import { resolveNpmPath } from '../../common/index.js';
|
|
7
4
|
import { appConfig } from '../../config/app.js';
|
|
8
5
|
import { Logger } from '../../config/logger.js';
|
|
9
6
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
7
|
+
const RESOLVED_VOID = Promise.resolve();
|
|
12
8
|
const runWrangler = async (cmd, args) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
return result;
|
|
9
|
+
// Back-compat entrypoint for tests; we only use this for D1 migrations apply.
|
|
10
|
+
const dbName = args[3];
|
|
11
|
+
const mode = args[4];
|
|
12
|
+
const isLocal = mode === '--local';
|
|
13
|
+
await RESOLVED_VOID;
|
|
14
|
+
return WranglerD1.applyMigrations({ cmd, dbName, isLocal });
|
|
21
15
|
};
|
|
22
16
|
const executeD1Migrate = async (cmd, options) => {
|
|
23
17
|
const isLocal = options['local'] === true || options['remote'] !== true;
|
|
24
|
-
const dbName = typeof options['database'] === 'string'
|
|
25
|
-
|
|
18
|
+
const dbName = typeof options['database'] === 'string' && options['database'].trim() !== ''
|
|
19
|
+
? options['database']
|
|
20
|
+
: 'zintrust_db';
|
|
26
21
|
cmd.info(`Running D1 migrations for ${dbName} (${isLocal ? 'local' : 'remote'})...`);
|
|
22
|
+
await RESOLVED_VOID;
|
|
27
23
|
try {
|
|
28
|
-
const output =
|
|
24
|
+
const output = WranglerD1.applyMigrations({ cmd, dbName, isLocal });
|
|
29
25
|
if (output !== '')
|
|
30
26
|
cmd.info(output);
|
|
31
27
|
cmd.info('✓ D1 migrations completed successfully');
|
|
@@ -57,9 +53,9 @@ export const D1MigrateCommand = Object.freeze({
|
|
|
57
53
|
create() {
|
|
58
54
|
const addOptions = (command) => {
|
|
59
55
|
command
|
|
60
|
-
.option('--local', 'Run
|
|
61
|
-
.option('--remote', 'Run
|
|
62
|
-
.option('--database <name>', 'D1 database name
|
|
56
|
+
.option('--local', 'Run against local D1 database (via wrangler dev)')
|
|
57
|
+
.option('--remote', 'Run against remote D1 database (production)')
|
|
58
|
+
.option('--database <name>', 'Wrangler D1 database binding name (from wrangler.toml). Defaults to "zintrust_db"');
|
|
63
59
|
};
|
|
64
60
|
const cmd = BaseCommand.create({
|
|
65
61
|
name: 'd1:migrate',
|