@zintrust/core 0.1.1 → 0.1.2
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 +3 -3
- package/bin/zintrust.d.ts.map +1 -1
- package/bin/zintrust.js +18 -1
- package/package.json +1 -1
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +46 -3
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +3 -4
- package/src/boot/bootstrap.js +77 -6
- package/src/builder/BundleOptimizer.d.ts.map +1 -1
- package/src/builder/BundleOptimizer.js +6 -4
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.js +6 -6
- package/src/cache/drivers/RedisDriver.js +1 -1
- package/src/cli/BaseCommand.d.ts +2 -2
- package/src/cli/BaseCommand.d.ts.map +1 -1
- package/src/cli/BaseCommand.js +2 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +11 -4
- package/src/cli/commands/AddCommand.js +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/ConfigCommand.js +34 -4
- package/src/cli/commands/D1MigrateCommand.d.ts +4 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +4 -3
- package/src/cli/commands/FixCommand.d.ts.map +1 -1
- package/src/cli/commands/FixCommand.js +3 -16
- package/src/cli/commands/LogsCleanupCommand.d.ts +6 -0
- package/src/cli/commands/LogsCleanupCommand.d.ts.map +1 -0
- package/src/cli/commands/LogsCleanupCommand.js +20 -0
- package/src/cli/commands/LogsCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.js +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.d.ts +10 -0
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -0
- package/src/cli/commands/MakeMailTemplateCommand.js +74 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +10 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.js +113 -0
- package/src/cli/commands/NewCommand.d.ts +4 -0
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +33 -20
- package/src/cli/commands/PluginCommand.d.ts.map +1 -1
- package/src/cli/commands/PluginCommand.js +8 -4
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.js +1 -1
- package/src/cli/commands/QACommand.d.ts.map +1 -1
- package/src/cli/commands/QACommand.js +11 -20
- package/src/cli/commands/SecretsCommand.d.ts +16 -0
- package/src/cli/commands/SecretsCommand.d.ts.map +1 -0
- package/src/cli/commands/SecretsCommand.js +91 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +2 -2
- package/src/cli/commands/TemplatesCommand.d.ts +3 -0
- package/src/cli/commands/TemplatesCommand.d.ts.map +1 -0
- package/src/cli/commands/TemplatesCommand.js +65 -0
- package/src/cli/commands/index.d.ts +5 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +5 -0
- package/src/cli/config/ConfigManager.js +1 -1
- package/src/cli/index.d.ts +2 -1
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +2 -1
- package/src/cli/scaffolding/ControllerGenerator.js +1 -1
- package/src/cli/scaffolding/FeatureScaffolder.js +4 -4
- package/src/cli/scaffolding/FileGenerator.js +1 -1
- package/src/cli/scaffolding/ModelGenerator.js +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +61 -11
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ResponseFactoryGenerator.js +3 -2
- package/src/cli/scaffolding/RouteGenerator.js +1 -1
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +2 -2
- package/src/cli/scaffolding/TemplateGenerator.d.ts +40 -0
- package/src/cli/scaffolding/TemplateGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/TemplateGenerator.js +172 -0
- package/src/cli/scaffolding/index.d.ts +1 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -1
- package/src/cli/scaffolding/index.js +1 -0
- package/src/cli/utils/spawn.js +1 -1
- package/src/common/AwsSigV4.d.ts +41 -0
- package/src/common/AwsSigV4.d.ts.map +1 -0
- package/src/common/AwsSigV4.js +69 -0
- package/src/common/index.d.ts +39 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +101 -8
- package/src/common/uuid.d.ts +3 -0
- package/src/common/uuid.d.ts.map +1 -0
- package/src/common/uuid.js +30 -0
- package/src/config/FileLogWriter.d.ts +22 -0
- package/src/config/FileLogWriter.d.ts.map +1 -0
- package/src/config/FileLogWriter.js +192 -0
- package/src/config/SecretsManager.d.ts.map +1 -1
- package/src/config/SecretsManager.js +37 -11
- package/src/config/StartupConfigValidator.d.ts +15 -0
- package/src/config/StartupConfigValidator.d.ts.map +1 -0
- package/src/config/StartupConfigValidator.js +86 -0
- package/src/config/app.d.ts +2 -1
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +65 -15
- package/src/config/broadcast.d.ts +47 -0
- package/src/config/broadcast.d.ts.map +1 -0
- package/src/config/broadcast.js +54 -0
- package/src/config/cache.d.ts +13 -17
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +9 -11
- package/src/config/cloudflare.d.ts +26 -0
- package/src/config/cloudflare.d.ts.map +1 -0
- package/src/config/cloudflare.js +38 -0
- package/src/config/env.d.ts +6 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +6 -0
- package/src/config/index.d.ts +52 -28
- package/src/config/index.d.ts.map +1 -1
- package/src/config/index.js +3 -0
- package/src/config/logger.d.ts +2 -0
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +270 -11
- package/src/config/logging/HttpLogger.d.ts +23 -0
- package/src/config/logging/HttpLogger.d.ts.map +1 -0
- package/src/config/logging/HttpLogger.js +93 -0
- package/src/config/logging/KvLogger.d.ts +22 -0
- package/src/config/logging/KvLogger.d.ts.map +1 -0
- package/src/config/logging/KvLogger.js +143 -0
- package/src/config/logging/SlackLogger.d.ts +23 -0
- package/src/config/logging/SlackLogger.d.ts.map +1 -0
- package/src/config/logging/SlackLogger.js +119 -0
- package/src/config/mail.d.ts +81 -0
- package/src/config/mail.d.ts.map +1 -0
- package/src/config/mail.js +73 -0
- package/src/config/middleware.d.ts +8 -0
- package/src/config/middleware.d.ts.map +1 -0
- package/src/config/middleware.js +18 -0
- package/src/config/notification.d.ts +62 -0
- package/src/config/notification.d.ts.map +1 -0
- package/src/config/notification.js +43 -0
- package/src/config/security.d.ts.map +1 -1
- package/src/config/security.js +2 -2
- package/src/config/startup.d.ts +23 -0
- package/src/config/startup.d.ts.map +1 -0
- package/src/config/startup.js +15 -0
- package/src/config/storage.d.ts +21 -35
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +57 -37
- package/src/database/migrations/index.d.ts +1 -1
- package/src/database/migrations/index.d.ts.map +1 -1
- package/src/database/migrations/index.js +2 -1
- package/src/features/Queue.js +1 -25
- package/src/health/RuntimeHealthProbes.d.ts +13 -0
- package/src/health/RuntimeHealthProbes.d.ts.map +1 -0
- package/src/health/RuntimeHealthProbes.js +62 -0
- package/src/health/StartupHealthChecks.d.ts +26 -0
- package/src/health/StartupHealthChecks.d.ts.map +1 -0
- package/src/health/StartupHealthChecks.js +124 -0
- package/src/http/ErrorResponse.d.ts +28 -0
- package/src/http/ErrorResponse.d.ts.map +1 -0
- package/src/http/ErrorResponse.js +42 -0
- package/src/http/Kernel.d.ts +5 -0
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +96 -30
- package/src/http/RequestContext.d.ts +20 -0
- package/src/http/RequestContext.d.ts.map +1 -0
- package/src/http/RequestContext.js +77 -0
- package/src/index.d.ts +9 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +8 -2
- package/src/microservices/MicroserviceManager.d.ts.map +1 -1
- package/src/microservices/MicroserviceManager.js +9 -6
- package/src/microservices/PostgresAdapter.d.ts.map +1 -1
- package/src/microservices/PostgresAdapter.js +3 -1
- package/src/microservices/ServiceBundler.d.ts.map +1 -1
- package/src/microservices/ServiceBundler.js +6 -4
- package/src/microservices/ServiceHealthMonitor.js +2 -2
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +2 -19
- package/src/middleware/ErrorHandlerMiddleware.d.ts +6 -0
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -0
- package/src/middleware/ErrorHandlerMiddleware.js +33 -0
- package/src/middleware/LoggingMiddleware.d.ts +9 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -0
- package/src/middleware/LoggingMiddleware.js +36 -0
- package/src/middleware/index.d.ts +2 -0
- package/src/middleware/index.d.ts.map +1 -1
- package/src/middleware/index.js +2 -0
- package/src/node-singletons/async_hooks.d.ts +9 -0
- package/src/node-singletons/async_hooks.d.ts.map +1 -0
- package/src/node-singletons/async_hooks.js +8 -0
- 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 +2 -2
- package/src/node-singletons/http.d.ts +1 -1
- package/src/node-singletons/http.d.ts.map +1 -1
- package/src/node-singletons/http.js +1 -1
- package/src/node-singletons/index.d.ts +4 -0
- package/src/node-singletons/index.d.ts.map +1 -1
- package/src/node-singletons/index.js +4 -0
- package/src/node-singletons/net.d.ts +9 -0
- package/src/node-singletons/net.d.ts.map +1 -0
- package/src/node-singletons/net.js +8 -0
- package/src/node-singletons/os.d.ts +3 -3
- package/src/node-singletons/os.d.ts.map +1 -1
- package/src/node-singletons/os.js +3 -4
- package/src/node-singletons/path.d.ts +3 -1
- package/src/node-singletons/path.d.ts.map +1 -1
- package/src/node-singletons/path.js +3 -1
- package/src/node-singletons/perf-hooks.d.ts +3 -1
- package/src/node-singletons/perf-hooks.d.ts.map +1 -1
- package/src/node-singletons/perf-hooks.js +3 -1
- package/src/node-singletons/process.d.ts +23 -0
- package/src/node-singletons/process.d.ts.map +1 -0
- package/src/node-singletons/process.js +8 -0
- package/src/node-singletons/readline.d.ts +3 -3
- package/src/node-singletons/readline.d.ts.map +1 -1
- package/src/node-singletons/readline.js +3 -4
- package/src/node-singletons/tls.d.ts +9 -0
- package/src/node-singletons/tls.d.ts.map +1 -0
- package/src/node-singletons/tls.js +8 -0
- package/src/node-singletons/url.d.ts +3 -1
- package/src/node-singletons/url.d.ts.map +1 -1
- package/src/node-singletons/url.js +3 -1
- package/src/orm/ConnectionManager.d.ts +6 -1
- package/src/orm/ConnectionManager.d.ts.map +1 -1
- package/src/orm/ConnectionManager.js +14 -0
- package/src/orm/DatabaseAdapter.d.ts +6 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/QueryBuilder.d.ts +8 -1
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +188 -28
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +18 -12
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +4 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +4 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLServerAdapter.js +4 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +4 -0
- package/src/performance/CodeGenerationBenchmark.js +3 -3
- package/src/performance/Optimizer.d.ts +1 -1
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +150 -75
- package/src/performance/establish-baseline.js +3 -3
- package/src/runtime/PluginManager.d.ts +3 -1
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +124 -28
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/RuntimeDetector.js +47 -6
- package/src/runtime/adapters/CloudflareAdapter.js +2 -2
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/FargateAdapter.js +2 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +4 -2
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/NodeServerAdapter.js +2 -1
- package/src/scheduler/ScheduleRunner.d.ts +18 -0
- package/src/scheduler/ScheduleRunner.d.ts.map +1 -0
- package/src/scheduler/ScheduleRunner.js +155 -0
- package/src/scheduler/index.d.ts +3 -0
- package/src/scheduler/index.d.ts.map +1 -0
- package/src/scheduler/index.js +1 -0
- package/src/scheduler/types.d.ts +16 -0
- package/src/scheduler/types.d.ts.map +1 -0
- package/src/scheduler/types.js +4 -0
- package/src/schedules/index.d.ts +2 -0
- package/src/schedules/index.d.ts.map +1 -0
- package/src/schedules/index.js +1 -0
- package/src/schedules/log-cleanup.d.ts +4 -0
- package/src/schedules/log-cleanup.d.ts.map +1 -0
- package/src/schedules/log-cleanup.js +18 -0
- package/src/scripts/GenerateEnvArtifacts.d.ts +13 -0
- package/src/scripts/GenerateEnvArtifacts.d.ts.map +1 -0
- package/src/scripts/GenerateEnvArtifacts.js +171 -0
- package/src/scripts/TemplateSync.js +109 -70
- package/src/security/CsrfTokenManager.js +1 -1
- package/src/security/Encryptor.js +1 -1
- package/src/security/Hash.d.ts +14 -0
- package/src/security/Hash.d.ts.map +1 -0
- package/src/security/Hash.js +81 -0
- package/src/security/StartupSecretValidation.d.ts +20 -0
- package/src/security/StartupSecretValidation.d.ts.map +1 -0
- package/src/security/StartupSecretValidation.js +61 -0
- package/src/security/UrlValidator.d.ts +0 -1
- package/src/security/UrlValidator.d.ts.map +1 -1
- package/src/security/UrlValidator.js +1 -2
- package/src/security/Xss.d.ts +14 -0
- package/src/security/Xss.d.ts.map +1 -0
- package/src/security/Xss.js +57 -0
- package/src/security/XssProtection.d.ts.map +1 -1
- package/src/security/XssProtection.js +150 -16
- package/src/templates/adapters/MySQLAdapter.ts.tpl +5 -0
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +5 -0
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -0
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +5 -0
- package/src/templates/features/Queue.ts.tpl +1 -29
- package/src/templates/project/basic/.env.example.tpl +48 -0
- package/src/templates/project/basic/.env.tpl +89 -94
- package/src/templates/project/basic/app/Toolkit/Broadcast/sendBroadcast.ts.tpl +7 -0
- package/src/templates/project/basic/app/Toolkit/Mail/sendWelcomeEmail.ts.tpl +30 -0
- package/src/templates/project/basic/app/Toolkit/Notification/sendSlackNotification.ts.tpl +10 -0
- package/src/templates/project/basic/app/Toolkit/Notification/sendSms.ts.tpl +13 -0
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +240 -0
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +44 -21
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +151 -0
- package/src/templates/project/basic/config/app.ts.tpl +84 -15
- package/src/templates/project/basic/config/broadcast.ts.tpl +97 -0
- package/src/templates/project/basic/config/cache.ts.tpl +19 -23
- package/src/templates/project/basic/config/cloudflare.ts.tpl +57 -0
- package/src/templates/project/basic/config/env.ts.tpl +7 -1
- package/src/templates/project/basic/config/index.ts.tpl +3 -0
- package/src/templates/project/basic/config/logger.ts.tpl +301 -11
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +121 -0
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +181 -0
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +156 -0
- package/src/templates/project/basic/config/mail.ts.tpl +141 -0
- package/src/templates/project/basic/config/middleware.ts.tpl +27 -0
- package/src/templates/project/basic/config/notification.ts.tpl +86 -0
- package/src/templates/project/basic/config/security.ts.tpl +4 -5
- package/src/templates/project/basic/config/startup.ts.tpl +27 -0
- package/src/templates/project/basic/config/storage.ts.tpl +77 -42
- package/src/templates/project/basic/database/migrations/index.ts.tpl +1 -1
- package/src/templates/project/basic/package.json.tpl +1 -1
- package/src/templates/project/basic/routes/api.ts.tpl +9 -37
- package/src/templates/project/basic/routes/broadcast.ts.tpl +32 -0
- package/src/templates/project/basic/routes/health.ts.tpl +134 -0
- package/src/templates/project/basic/src/index.ts.tpl +38 -11
- package/src/templates/project/basic/template.json +3 -0
- package/src/toolkit/Secrets/EnvFile.d.ts +15 -0
- package/src/toolkit/Secrets/EnvFile.d.ts.map +1 -0
- package/src/toolkit/Secrets/EnvFile.js +63 -0
- package/src/toolkit/Secrets/Manifest.d.ts +24 -0
- package/src/toolkit/Secrets/Manifest.d.ts.map +1 -0
- package/src/toolkit/Secrets/Manifest.js +71 -0
- package/src/toolkit/Secrets/index.d.ts +42 -0
- package/src/toolkit/Secrets/index.d.ts.map +1 -0
- package/src/toolkit/Secrets/index.js +119 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts +14 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +131 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts +9 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.js +73 -0
- package/src/tools/broadcast/Broadcast.d.ts +7 -0
- package/src/tools/broadcast/Broadcast.d.ts.map +1 -0
- package/src/tools/broadcast/Broadcast.js +37 -0
- package/src/tools/broadcast/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/broadcast/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/BaseDriver.js +8 -0
- package/src/tools/broadcast/drivers/InMemory.d.ts +18 -0
- package/src/tools/broadcast/drivers/InMemory.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/InMemory.js +16 -0
- package/src/tools/broadcast/drivers/Pusher.d.ts +8 -0
- package/src/tools/broadcast/drivers/Pusher.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/Pusher.js +75 -0
- package/src/tools/broadcast/drivers/Redis.d.ts +19 -0
- package/src/tools/broadcast/drivers/Redis.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/Redis.js +73 -0
- package/src/tools/broadcast/drivers/RedisHttps.d.ts +14 -0
- package/src/tools/broadcast/drivers/RedisHttps.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/RedisHttps.js +50 -0
- package/src/tools/broadcast/index.d.ts +7 -0
- package/src/tools/broadcast/index.d.ts.map +1 -0
- package/src/tools/broadcast/index.js +6 -0
- package/src/tools/http/Http.d.ts +51 -0
- package/src/tools/http/Http.d.ts.map +1 -0
- package/src/tools/http/Http.js +171 -0
- package/src/tools/http/HttpResponse.d.ts +32 -0
- package/src/tools/http/HttpResponse.d.ts.map +1 -0
- package/src/tools/http/HttpResponse.js +80 -0
- package/src/tools/http/index.d.ts +15 -0
- package/src/tools/http/index.d.ts.map +1 -0
- package/src/tools/http/index.js +9 -0
- package/src/tools/mail/Mail.d.ts +22 -0
- package/src/tools/mail/Mail.d.ts.map +1 -0
- package/src/tools/mail/Mail.js +105 -0
- package/src/tools/mail/attachments.d.ts +23 -0
- package/src/tools/mail/attachments.d.ts.map +1 -0
- package/src/tools/mail/attachments.js +26 -0
- package/src/tools/mail/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/mail/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/mail/drivers/BaseDriver.js +8 -0
- package/src/tools/mail/drivers/Mailgun.d.ts +31 -0
- package/src/tools/mail/drivers/Mailgun.d.ts.map +1 -0
- package/src/tools/mail/drivers/Mailgun.js +81 -0
- package/src/tools/mail/drivers/SendGrid.d.ts +29 -0
- package/src/tools/mail/drivers/SendGrid.d.ts.map +1 -0
- package/src/tools/mail/drivers/SendGrid.js +57 -0
- package/src/tools/mail/drivers/Ses.d.ts +24 -0
- package/src/tools/mail/drivers/Ses.d.ts.map +1 -0
- package/src/tools/mail/drivers/Ses.js +116 -0
- package/src/tools/mail/drivers/Smtp.d.ts +38 -0
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -0
- package/src/tools/mail/drivers/Smtp.js +327 -0
- package/src/tools/mail/templates/index.d.ts +27 -0
- package/src/tools/mail/templates/index.d.ts.map +1 -0
- package/src/tools/mail/templates/index.js +35 -0
- package/src/tools/mail/templates/markdown/index.d.ts +17 -0
- package/src/tools/mail/templates/markdown/index.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/index.js +49 -0
- package/src/tools/mail/templates/markdown/registry.d.ts +15 -0
- package/src/tools/mail/templates/markdown/registry.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/registry.js +34 -0
- package/src/tools/mail/templates/markdown/validator.d.ts +16 -0
- package/src/tools/mail/templates/markdown/validator.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/validator.js +24 -0
- package/src/tools/mail/testing.d.ts +41 -0
- package/src/tools/mail/testing.d.ts.map +1 -0
- package/src/tools/mail/testing.js +34 -0
- package/src/tools/notification/Driver.d.ts +11 -0
- package/src/tools/notification/Driver.d.ts.map +1 -0
- package/src/tools/notification/Driver.js +1 -0
- package/src/tools/notification/Notification.d.ts +11 -0
- package/src/tools/notification/Notification.d.ts.map +1 -0
- package/src/tools/notification/Notification.js +11 -0
- package/src/tools/notification/Registry.d.ts +10 -0
- package/src/tools/notification/Registry.d.ts.map +1 -0
- package/src/tools/notification/Registry.js +22 -0
- package/src/tools/notification/Service.d.ts +6 -0
- package/src/tools/notification/Service.d.ts.map +1 -0
- package/src/tools/notification/Service.js +18 -0
- package/src/tools/notification/config.d.ts +5 -0
- package/src/tools/notification/config.d.ts.map +1 -0
- package/src/tools/notification/config.js +5 -0
- package/src/tools/notification/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/notification/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/notification/drivers/BaseDriver.js +8 -0
- package/src/tools/notification/drivers/Console.d.ts +7 -0
- package/src/tools/notification/drivers/Console.d.ts.map +1 -0
- package/src/tools/notification/drivers/Console.js +13 -0
- package/src/tools/notification/drivers/Slack.d.ts +16 -0
- package/src/tools/notification/drivers/Slack.d.ts.map +1 -0
- package/src/tools/notification/drivers/Slack.js +24 -0
- package/src/tools/notification/drivers/Termii.d.ts +10 -0
- package/src/tools/notification/drivers/Termii.d.ts.map +1 -0
- package/src/tools/notification/drivers/Termii.js +47 -0
- package/src/tools/notification/drivers/Twilio.d.ts +21 -0
- package/src/tools/notification/drivers/Twilio.d.ts.map +1 -0
- package/src/tools/notification/drivers/Twilio.js +48 -0
- package/src/tools/notification/templates/markdown/index.d.ts +15 -0
- package/src/tools/notification/templates/markdown/index.d.ts.map +1 -0
- package/src/tools/notification/templates/markdown/index.js +38 -0
- package/src/tools/notification/templates/markdown/registry.d.ts +15 -0
- package/src/tools/notification/templates/markdown/registry.d.ts.map +1 -0
- package/src/tools/notification/templates/markdown/registry.js +36 -0
- package/src/tools/notification/testing.d.ts +19 -0
- package/src/tools/notification/testing.d.ts.map +1 -0
- package/src/tools/notification/testing.js +35 -0
- package/src/tools/notification/testingHelpers.d.ts +12 -0
- package/src/tools/notification/testingHelpers.d.ts.map +1 -0
- package/src/tools/notification/testingHelpers.js +32 -0
- package/src/tools/queue/Queue.d.ts +23 -0
- package/src/tools/queue/Queue.d.ts.map +1 -0
- package/src/tools/queue/Queue.js +38 -0
- package/src/tools/queue/drivers/InMemory.d.ts +10 -0
- package/src/tools/queue/drivers/InMemory.d.ts.map +1 -0
- package/src/tools/queue/drivers/InMemory.js +55 -0
- package/src/tools/queue/drivers/Redis.d.ts +10 -0
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -0
- package/src/tools/queue/drivers/Redis.js +91 -0
- package/src/tools/storage/drivers/Gcs.d.ts +20 -0
- package/src/tools/storage/drivers/Gcs.d.ts.map +1 -0
- package/src/tools/storage/drivers/Gcs.js +152 -0
- package/src/tools/storage/drivers/Local.d.ts +17 -0
- package/src/tools/storage/drivers/Local.d.ts.map +1 -0
- package/src/tools/storage/drivers/Local.js +63 -0
- package/src/tools/storage/drivers/R2.d.ts +20 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -0
- package/src/tools/storage/drivers/R2.js +73 -0
- package/src/tools/storage/drivers/S3.d.ts +26 -0
- package/src/tools/storage/drivers/S3.d.ts.map +1 -0
- package/src/tools/storage/drivers/S3.js +258 -0
- package/src/tools/storage/index.d.ts +24 -0
- package/src/tools/storage/index.d.ts.map +1 -0
- package/src/tools/storage/index.js +112 -0
- package/src/tools/storage/testing.d.ts +23 -0
- package/src/tools/storage/testing.d.ts.map +1 -0
- package/src/tools/storage/testing.js +52 -0
- package/src/tools/templates/MarkdownRenderer.d.ts +14 -0
- package/src/tools/templates/MarkdownRenderer.d.ts.map +1 -0
- package/src/tools/templates/MarkdownRenderer.js +300 -0
- package/src/tools/templates/index.d.ts +5 -0
- package/src/tools/templates/index.d.ts.map +1 -0
- package/src/tools/templates/index.js +4 -0
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ cd my-app
|
|
|
16
16
|
npm run dev
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Your API is now running at `http://localhost:
|
|
19
|
+
Your API is now running at `http://localhost:7777`
|
|
20
20
|
|
|
21
21
|
## What is Zintrust?
|
|
22
22
|
|
|
@@ -159,10 +159,10 @@ Test it:
|
|
|
159
159
|
|
|
160
160
|
```bash
|
|
161
161
|
# Get all users
|
|
162
|
-
curl http://localhost:
|
|
162
|
+
curl http://localhost:7777/api/users
|
|
163
163
|
|
|
164
164
|
# Create a user
|
|
165
|
-
curl -X POST http://localhost:
|
|
165
|
+
curl -X POST http://localhost:7777/api/users \
|
|
166
166
|
-H "Content-Type: application/json" \
|
|
167
167
|
-d '{"name":"John","email":"john@example.com"}'
|
|
168
168
|
```
|
package/bin/zintrust.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust.d.ts","sourceRoot":"","sources":["../../bin/zintrust.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"zintrust.d.ts","sourceRoot":"","sources":["../../bin/zintrust.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAmEH,OAAO,EAAE,CAAC"}
|
package/bin/zintrust.js
CHANGED
|
@@ -11,7 +11,24 @@ async function main() {
|
|
|
11
11
|
EnvFileLoader.ensureLoaded();
|
|
12
12
|
const { CLI } = await import('../src/cli/CLI');
|
|
13
13
|
const cli = CLI.create();
|
|
14
|
-
|
|
14
|
+
// When executing via tsx (e.g. `npx tsx bin/zin.ts ...`), the script path can
|
|
15
|
+
// appear as the first element of `process.argv.slice(2)`. Commander expects
|
|
16
|
+
// args to start at the command name, so we strip a leading script path if present.
|
|
17
|
+
const rawArgs = process.argv.slice(2);
|
|
18
|
+
if (process.env['ZINTRUST_CLI_DEBUG_ARGS'] === '1') {
|
|
19
|
+
try {
|
|
20
|
+
process.stderr.write(`[zintrust-cli] process.argv=${JSON.stringify(process.argv)}\n`);
|
|
21
|
+
process.stderr.write(`[zintrust-cli] rawArgs=${JSON.stringify(rawArgs)}\n`);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// ignore
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const args = rawArgs.length > 0 &&
|
|
28
|
+
(rawArgs[0]?.endsWith('.ts') === true || rawArgs[0]?.endsWith('.js') === true)
|
|
29
|
+
? rawArgs.slice(1)
|
|
30
|
+
: rawArgs;
|
|
31
|
+
await cli.run(args);
|
|
15
32
|
}
|
|
16
33
|
catch (error) {
|
|
17
34
|
try {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../../src/boot/Application.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../../src/boot/Application.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAoB,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAmB,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,kBAAkB,CAAC;AAOxD,MAAM,WAAW,YAAY;IAC3B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,QAAQ,IAAI,OAAO,CAAC;IACpB,aAAa,IAAI,OAAO,CAAC;IACzB,YAAY,IAAI,OAAO,CAAC;IACxB,SAAS,IAAI,OAAO,CAAC;IACrB,cAAc,IAAI,MAAM,CAAC;IACzB,SAAS,IAAI,OAAO,CAAC;IACrB,YAAY,IAAI,iBAAiB,CAAC;IAClC,kBAAkB,IAAI,gBAAgB,CAAC;IACvC,WAAW,IAAI,MAAM,CAAC;CACvB;AA2LD;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;sBACe,MAAM,GAAG,YAAY;EAmDvC,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
package/src/boot/Application.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
* Application - Framework core entry point
|
|
3
3
|
* Handles application lifecycle, booting, and environment
|
|
4
4
|
*/
|
|
5
|
+
import { appConfig } from '../config';
|
|
5
6
|
import { ServiceContainer } from '../container/ServiceContainer';
|
|
7
|
+
import { StartupHealthChecks } from '../health/StartupHealthChecks';
|
|
6
8
|
import { MiddlewareStack } from '../middleware/MiddlewareStack';
|
|
7
9
|
import { Router } from '../routing/Router';
|
|
8
|
-
import {
|
|
10
|
+
import { FeatureFlags } from '../config/features';
|
|
9
11
|
import { Logger } from '../config/logger';
|
|
12
|
+
import { StartupConfigValidator } from '../config/StartupConfigValidator';
|
|
10
13
|
import * as path from '../node-singletons/path';
|
|
11
14
|
import { pathToFileURL } from '../node-singletons/url';
|
|
12
15
|
const ShutdownManager = Object.freeze({
|
|
@@ -89,11 +92,41 @@ const registerRoutes = async (resolvedBasePath, router) => {
|
|
|
89
92
|
Logger.error('Failed to register routes:', error);
|
|
90
93
|
}
|
|
91
94
|
};
|
|
95
|
+
const initializeArtifactDirectories = async (resolvedBasePath) => {
|
|
96
|
+
if (resolvedBasePath === '')
|
|
97
|
+
return;
|
|
98
|
+
if (typeof process === 'undefined')
|
|
99
|
+
return;
|
|
100
|
+
let nodeFs;
|
|
101
|
+
try {
|
|
102
|
+
nodeFs = await import('../node-singletons/fs');
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const dirs = ['logs', 'storage', 'tmp'];
|
|
108
|
+
for (const dir of dirs) {
|
|
109
|
+
const fullPath = path.join(resolvedBasePath, dir);
|
|
110
|
+
try {
|
|
111
|
+
if (!nodeFs.existsSync(fullPath)) {
|
|
112
|
+
nodeFs.mkdirSync(fullPath, { recursive: true });
|
|
113
|
+
Logger.info(`✓ Created directory: ${dir}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
Logger.warn(`Failed to create ${dir} directory`, error);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
92
121
|
const createLifecycle = (params) => {
|
|
93
122
|
const boot = async () => {
|
|
94
123
|
if (params.getBooted())
|
|
95
124
|
return;
|
|
96
125
|
Logger.info(`🚀 Booting Zintrust Application in ${params.environment} mode...`);
|
|
126
|
+
StartupConfigValidator.assertValid();
|
|
127
|
+
FeatureFlags.initialize();
|
|
128
|
+
await StartupHealthChecks.assertHealthy();
|
|
129
|
+
await initializeArtifactDirectories(params.resolvedBasePath);
|
|
97
130
|
await registerRoutes(params.resolvedBasePath, params.router);
|
|
98
131
|
// Register service providers
|
|
99
132
|
// Bootstrap services
|
|
@@ -123,7 +156,7 @@ export const Application = Object.freeze({
|
|
|
123
156
|
create(basePath) {
|
|
124
157
|
const resolvedBasePath = resolveBasePath(basePath);
|
|
125
158
|
const joinFromBase = makeJoinFromBase(resolvedBasePath);
|
|
126
|
-
const environment =
|
|
159
|
+
const environment = appConfig.environment;
|
|
127
160
|
const container = ServiceContainer.create();
|
|
128
161
|
const router = Router.createRouter();
|
|
129
162
|
const middlewareStack = MiddlewareStack.create();
|
|
@@ -131,6 +164,16 @@ export const Application = Object.freeze({
|
|
|
131
164
|
let booted = false;
|
|
132
165
|
registerCorePaths(container, resolvedBasePath, joinFromBase);
|
|
133
166
|
registerCoreInstances({ container, environment, router, middlewareStack, shutdownManager });
|
|
167
|
+
// Register framework-level shutdown hooks for long-lived resources
|
|
168
|
+
// ConnectionManager may not be initialized; shutdownIfInitialized is safe
|
|
169
|
+
// Use dynamic import without top-level await to avoid transforming the module into an async module
|
|
170
|
+
import('../orm/ConnectionManager')
|
|
171
|
+
.then(({ ConnectionManager }) => {
|
|
172
|
+
shutdownManager.add(async () => ConnectionManager.shutdownIfInitialized());
|
|
173
|
+
})
|
|
174
|
+
.catch(() => {
|
|
175
|
+
/* ignore import failures in restrictive runtimes */
|
|
176
|
+
});
|
|
134
177
|
const { boot, shutdown } = createLifecycle({
|
|
135
178
|
environment,
|
|
136
179
|
resolvedBasePath,
|
|
@@ -147,7 +190,7 @@ export const Application = Object.freeze({
|
|
|
147
190
|
isBooted: () => booted,
|
|
148
191
|
isDevelopment: () => environment === 'development',
|
|
149
192
|
isProduction: () => environment === 'production',
|
|
150
|
-
isTesting: () => environment === 'testing'
|
|
193
|
+
isTesting: () => environment === 'testing',
|
|
151
194
|
getEnvironment: () => environment,
|
|
152
195
|
getRouter: () => router,
|
|
153
196
|
getContainer: () => container,
|
package/src/boot/Server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/boot/Server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Server.d.ts","sourceRoot":"","sources":["../../../src/boot/Server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAI9C,MAAM,WAAW,OAAO;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC;CAC9B;AA2ND;;;GAGG;AACH,eAAO,MAAM,MAAM;IACjB;;OAEG;gBACS,YAAY,SAAS,MAAM,SAAS,MAAM,GAAG,OAAO;EA8BhE,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/src/boot/Server.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Server - HTTP Server implementation
|
|
3
3
|
* Uses Node.js built-in HTTP server with no external dependencies
|
|
4
4
|
*/
|
|
5
|
+
import { esmDirname } from '../common/index';
|
|
5
6
|
import { appConfig } from '../config/app';
|
|
6
7
|
import { HTTP_HEADERS, MIME_TYPES } from '../config/constants';
|
|
7
8
|
import { Logger } from '../config/logger';
|
|
@@ -11,7 +12,6 @@ import { Response } from '../http/Response';
|
|
|
11
12
|
import * as fs from '../node-singletons/fs';
|
|
12
13
|
import * as http from '../node-singletons/http';
|
|
13
14
|
import * as path from '../node-singletons/path';
|
|
14
|
-
import { fileURLToPath } from '../node-singletons/url';
|
|
15
15
|
import { Router } from '../routing/Router';
|
|
16
16
|
const MIME_TYPES_MAP = {
|
|
17
17
|
'.html': MIME_TYPES.HTML,
|
|
@@ -43,8 +43,7 @@ const findPackageRoot = (startDir) => {
|
|
|
43
43
|
return startDir;
|
|
44
44
|
};
|
|
45
45
|
const getFrameworkPublicRoots = () => {
|
|
46
|
-
const
|
|
47
|
-
const thisDir = path.dirname(thisFile);
|
|
46
|
+
const thisDir = esmDirname(import.meta.url);
|
|
48
47
|
const packageRoot = findPackageRoot(thisDir);
|
|
49
48
|
return [
|
|
50
49
|
path.join(packageRoot, 'dist/public'),
|
|
@@ -53,7 +52,7 @@ const getFrameworkPublicRoots = () => {
|
|
|
53
52
|
];
|
|
54
53
|
};
|
|
55
54
|
const getDocsPublicRoot = () => {
|
|
56
|
-
const isProduction =
|
|
55
|
+
const isProduction = appConfig.isProduction();
|
|
57
56
|
// First try app-local roots (developer app override), then fall back to framework-shipped assets.
|
|
58
57
|
const appRoots = isProduction
|
|
59
58
|
? [path.join(process.cwd(), 'public')]
|
package/src/boot/bootstrap.js
CHANGED
|
@@ -8,6 +8,48 @@ import { Server } from './Server';
|
|
|
8
8
|
import { Env } from '../config/env';
|
|
9
9
|
import { Logger } from '../config/logger';
|
|
10
10
|
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
11
|
+
let appInstance;
|
|
12
|
+
let serverInstance;
|
|
13
|
+
let isShuttingDown = false;
|
|
14
|
+
const withTimeout = async (promise, timeoutMs, label) => {
|
|
15
|
+
if (timeoutMs <= 0)
|
|
16
|
+
return promise;
|
|
17
|
+
let timeoutId;
|
|
18
|
+
try {
|
|
19
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
20
|
+
timeoutId = globalThis.setTimeout(() => {
|
|
21
|
+
reject(ErrorFactory.createGeneralError(label, { timeoutMs }));
|
|
22
|
+
}, timeoutMs);
|
|
23
|
+
});
|
|
24
|
+
return await Promise.race([promise, timeoutPromise]);
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
if (timeoutId !== undefined)
|
|
28
|
+
globalThis.clearTimeout(timeoutId);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const gracefulShutdown = async (signal) => {
|
|
32
|
+
if (isShuttingDown)
|
|
33
|
+
return;
|
|
34
|
+
isShuttingDown = true;
|
|
35
|
+
const timeoutMs = Number(Env.SHUTDOWN_TIMEOUT);
|
|
36
|
+
Logger.info(`${signal} received, shutting down gracefully...`);
|
|
37
|
+
try {
|
|
38
|
+
await withTimeout((async () => {
|
|
39
|
+
if (serverInstance !== undefined) {
|
|
40
|
+
await serverInstance.close();
|
|
41
|
+
}
|
|
42
|
+
if (appInstance !== undefined) {
|
|
43
|
+
await appInstance.shutdown();
|
|
44
|
+
}
|
|
45
|
+
})(), timeoutMs, 'Graceful shutdown timed out');
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
Logger.error('Graceful shutdown failed:', error);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
11
53
|
/**
|
|
12
54
|
* Bootstrap implementation
|
|
13
55
|
*/
|
|
@@ -19,6 +61,7 @@ const BootstrapFunctions = Object.freeze({
|
|
|
19
61
|
try {
|
|
20
62
|
// Create application instance
|
|
21
63
|
const app = Application.create();
|
|
64
|
+
appInstance = app;
|
|
22
65
|
// Boot application
|
|
23
66
|
await app.boot();
|
|
24
67
|
// Get port and host from environment
|
|
@@ -26,9 +69,39 @@ const BootstrapFunctions = Object.freeze({
|
|
|
26
69
|
const host = Env.get('HOST', 'localhost');
|
|
27
70
|
// Create and start server
|
|
28
71
|
const server = Server.create(app, port, host);
|
|
72
|
+
serverInstance = server;
|
|
29
73
|
// Start listening
|
|
30
74
|
await server.listen();
|
|
31
75
|
Logger.info(`Server running at http://${host}:${port}`);
|
|
76
|
+
// Start schedules for long-running runtimes (Node.js / Fargate)
|
|
77
|
+
try {
|
|
78
|
+
const runtime = (await import('../runtime/RuntimeDetector')).RuntimeDetector.detectRuntime();
|
|
79
|
+
if (runtime === 'nodejs' || runtime === 'fargate') {
|
|
80
|
+
const { create: createScheduleRunner } = await import('../scheduler/ScheduleRunner');
|
|
81
|
+
const schedules = await import('../schedules');
|
|
82
|
+
const runner = createScheduleRunner();
|
|
83
|
+
for (const schedule of Object.values(schedules)) {
|
|
84
|
+
// Each schedule is expected to export a default ISchedule
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
runner.register(schedule);
|
|
87
|
+
}
|
|
88
|
+
runner.start();
|
|
89
|
+
// Add shutdown hook to stop schedules gracefully
|
|
90
|
+
const shutdownManager = app.getContainer().get('shutdownManager');
|
|
91
|
+
if ((typeof shutdownManager === 'object' || typeof shutdownManager === 'function') &&
|
|
92
|
+
shutdownManager !== null &&
|
|
93
|
+
'add' in shutdownManager &&
|
|
94
|
+
typeof shutdownManager.add === 'function') {
|
|
95
|
+
shutdownManager.add(async () => {
|
|
96
|
+
const scheduleTimeoutMs = Env.getInt('SCHEDULE_SHUTDOWN_TIMEOUT_MS', 30000);
|
|
97
|
+
await runner.stop(scheduleTimeoutMs);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
Logger.warn('Failed to start schedules:', err);
|
|
104
|
+
}
|
|
32
105
|
}
|
|
33
106
|
catch (error) {
|
|
34
107
|
Logger.error('Failed to bootstrap application:', error);
|
|
@@ -40,13 +113,11 @@ const BootstrapFunctions = Object.freeze({
|
|
|
40
113
|
* Handle graceful shutdown
|
|
41
114
|
*/
|
|
42
115
|
setupShutdownHandler() {
|
|
43
|
-
process.on('SIGTERM', () => {
|
|
44
|
-
|
|
45
|
-
process.exit(0);
|
|
116
|
+
process.on('SIGTERM', async () => {
|
|
117
|
+
await gracefulShutdown('SIGTERM');
|
|
46
118
|
});
|
|
47
|
-
process.on('SIGINT', () => {
|
|
48
|
-
|
|
49
|
-
process.exit(0);
|
|
119
|
+
process.on('SIGINT', async () => {
|
|
120
|
+
await gracefulShutdown('SIGINT');
|
|
50
121
|
});
|
|
51
122
|
},
|
|
52
123
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BundleOptimizer.d.ts","sourceRoot":"","sources":["../../../src/builder/BundleOptimizer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;CACrC;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC1B;;OAEG;oBACa,mBAAmB,GAAG,gBAAgB;EA0CtD,CAAC;
|
|
1
|
+
{"version":3,"file":"BundleOptimizer.d.ts","sourceRoot":"","sources":["../../../src/builder/BundleOptimizer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;CACrC;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC1B;;OAEG;oBACa,mBAAmB,GAAG,gBAAgB;EA0CtD,CAAC;AA4XH;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAclD"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Logger } from '../config/logger';
|
|
10
10
|
import fs from '../node-singletons/fs';
|
|
11
|
-
import * as path from 'node
|
|
11
|
+
import * as path from '../node-singletons/path';
|
|
12
12
|
/**
|
|
13
13
|
* Bundle optimizer - reduces deployed package size
|
|
14
14
|
* Sealed namespace for immutability
|
|
@@ -125,17 +125,19 @@ function printAnalysis(analysis) {
|
|
|
125
125
|
*/
|
|
126
126
|
async function analyze(distDir, options) {
|
|
127
127
|
const files = await getFilesRecursive(distDir);
|
|
128
|
-
|
|
128
|
+
// Collect sizes concurrently but avoid shared mutable state by computing sizes
|
|
129
|
+
// and then reducing the total afterwards to avoid race conditions.
|
|
129
130
|
const fileAnalysis = await Promise.all(files.map(async (file) => {
|
|
130
131
|
const stats = await fs.promises.stat(file);
|
|
131
132
|
const size = stats.size;
|
|
132
|
-
totalSize += size;
|
|
133
133
|
return {
|
|
134
134
|
path: path.relative(distDir, file),
|
|
135
135
|
size,
|
|
136
136
|
percentage: 0,
|
|
137
137
|
};
|
|
138
138
|
}));
|
|
139
|
+
// Compute total size in a single pass (no shared mutation)
|
|
140
|
+
const totalSize = fileAnalysis.reduce((acc, f) => acc + f.size, 0);
|
|
139
141
|
// Calculate percentages
|
|
140
142
|
fileAnalysis.forEach((f) => {
|
|
141
143
|
f.percentage = totalSize > 0 ? (f.size / totalSize) * 100 : 0;
|
|
@@ -198,12 +200,12 @@ async function removeDevDependencies(distDir, options) {
|
|
|
198
200
|
/**
|
|
199
201
|
* Minify JavaScript files
|
|
200
202
|
*/
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
201
204
|
async function minifyJavaScript(_aggressive = false) {
|
|
202
205
|
Logger.info(' → Minifying JavaScript...');
|
|
203
206
|
// In production, would use esbuild or terser
|
|
204
207
|
// This is a placeholder showing the pattern
|
|
205
208
|
Logger.info(' ✓ JavaScript minified');
|
|
206
|
-
return Promise.resolve();
|
|
207
209
|
}
|
|
208
210
|
/**
|
|
209
211
|
* Remove a specific module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KVDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"KVDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAoDjD;;GAEG;AACH,eAAO,MAAM,QAAQ;kBAhDF,WAAW;EAkD5B,CAAC"}
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
* Cloudflare KV Cache Driver
|
|
3
3
|
* Interfaces with the native KV binding in Cloudflare Workers
|
|
4
4
|
*/
|
|
5
|
+
import { Cloudflare } from '../../config/cloudflare';
|
|
5
6
|
import { Logger } from '../../config/logger';
|
|
6
7
|
/**
|
|
7
8
|
* Create a new KV driver instance
|
|
8
9
|
*/
|
|
9
10
|
const create = () => {
|
|
10
11
|
// In Cloudflare Workers, the KV namespace is usually bound to a variable in the environment
|
|
11
|
-
const
|
|
12
|
-
const kv = env === undefined ? undefined : env['CACHE'];
|
|
12
|
+
const kv = Cloudflare.getKVBinding('CACHE');
|
|
13
13
|
return {
|
|
14
14
|
async get(key) {
|
|
15
|
-
if (kv ===
|
|
15
|
+
if (kv === null)
|
|
16
16
|
return null;
|
|
17
17
|
const value = await kv.get(key, { type: 'json' });
|
|
18
18
|
return value ?? null;
|
|
19
19
|
},
|
|
20
20
|
async set(key, value, ttl) {
|
|
21
|
-
if (kv ===
|
|
21
|
+
if (kv === null) {
|
|
22
22
|
Logger.warn('KV binding "CACHE" not found. Cache set ignored.');
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -30,7 +30,7 @@ const create = () => {
|
|
|
30
30
|
await kv.put(key, JSON.stringify(value), options);
|
|
31
31
|
},
|
|
32
32
|
async delete(key) {
|
|
33
|
-
if (kv ===
|
|
33
|
+
if (kv === null)
|
|
34
34
|
return;
|
|
35
35
|
await kv.delete(key);
|
|
36
36
|
},
|
|
@@ -40,7 +40,7 @@ const create = () => {
|
|
|
40
40
|
await Promise.resolve();
|
|
41
41
|
},
|
|
42
42
|
async has(key) {
|
|
43
|
-
if (kv ===
|
|
43
|
+
if (kv === null)
|
|
44
44
|
return false;
|
|
45
45
|
const value = await kv.get(key);
|
|
46
46
|
return value !== null;
|
package/src/cli/BaseCommand.d.ts
CHANGED
|
@@ -29,11 +29,11 @@ export declare const BaseCommand: Readonly<{
|
|
|
29
29
|
/**
|
|
30
30
|
* Create a command instance with common logic
|
|
31
31
|
*/
|
|
32
|
-
create(config: {
|
|
32
|
+
create<T extends IBaseCommand = IBaseCommand>(config: {
|
|
33
33
|
name: string;
|
|
34
34
|
description: string;
|
|
35
35
|
addOptions?: (command: Command) => void;
|
|
36
36
|
execute: (options: CommandOptions) => void | Promise<void>;
|
|
37
|
-
}):
|
|
37
|
+
}): T;
|
|
38
38
|
}>;
|
|
39
39
|
//# sourceMappingURL=BaseCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCommand.d.ts","sourceRoot":"","sources":["../../../src/cli/BaseCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,IAAI,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;
|
|
1
|
+
{"version":3,"file":"BaseCommand.d.ts","sourceRoot":"","sources":["../../../src/cli/BaseCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,IAAI,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;WACI,CAAC,SAAS,YAAY,yBAAyB;QACpD,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;QACxC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC5D,GAAG,CAAC;EAiDL,CAAC"}
|
package/src/cli/BaseCommand.js
CHANGED
|
@@ -42,7 +42,7 @@ export const BaseCommand = Object.freeze({
|
|
|
42
42
|
});
|
|
43
43
|
return command;
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
const base = {
|
|
46
46
|
name: config.name,
|
|
47
47
|
description: config.description,
|
|
48
48
|
verbose: false,
|
|
@@ -54,5 +54,6 @@ export const BaseCommand = Object.freeze({
|
|
|
54
54
|
warn: (msg) => ErrorHandler.warn(msg),
|
|
55
55
|
debug: (msg) => ErrorHandler.debug(msg, true),
|
|
56
56
|
};
|
|
57
|
+
return base;
|
|
57
58
|
},
|
|
58
59
|
});
|
package/src/cli/CLI.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyBH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AAqLD;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;cACJ,IAAI;EAed,CAAC"}
|
package/src/cli/CLI.js
CHANGED
|
@@ -8,22 +8,25 @@ import { D1MigrateCommand } from './commands/D1MigrateCommand';
|
|
|
8
8
|
import { DebugCommand } from './commands/DebugCommand';
|
|
9
9
|
import { FixCommand } from './commands/FixCommand';
|
|
10
10
|
import { KeyGenerateCommand } from './commands/KeyGenerateCommand';
|
|
11
|
+
import { MakeMailTemplateCommand } from './commands/MakeMailTemplateCommand';
|
|
12
|
+
import { MakeNotificationTemplateCommand } from './commands/MakeNotificationTemplateCommand';
|
|
11
13
|
import { MigrateCommand } from './commands/MigrateCommand';
|
|
12
14
|
import { NewCommand } from './commands/NewCommand';
|
|
13
15
|
import { PluginCommand } from './commands/PluginCommand';
|
|
14
16
|
import { PrepareCommand } from './commands/PrepareCommand';
|
|
15
17
|
import { QACommand } from './commands/QACommand';
|
|
18
|
+
import { SecretsCommand } from './commands/SecretsCommand';
|
|
16
19
|
import { SimulateCommand } from './commands/SimulateCommand';
|
|
17
20
|
import { StartCommand } from './commands/StartCommand';
|
|
21
|
+
import { TemplatesCommand } from './commands/TemplatesCommand';
|
|
18
22
|
import { ErrorHandler } from './ErrorHandler';
|
|
23
|
+
import { esmDirname } from '../common/index';
|
|
19
24
|
import { Logger } from '../config/logger';
|
|
20
25
|
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
21
26
|
import { readFileSync } from '../node-singletons/fs';
|
|
22
|
-
import {
|
|
23
|
-
import { fileURLToPath } from '../node-singletons/url';
|
|
27
|
+
import { join } from '../node-singletons/path';
|
|
24
28
|
import { Command } from 'commander';
|
|
25
|
-
const
|
|
26
|
-
const __dirname = dirname(__filename);
|
|
29
|
+
const __dirname = esmDirname(import.meta.url);
|
|
27
30
|
/**
|
|
28
31
|
* CLI - Main CLI Class
|
|
29
32
|
* Orchestrates all CLI commands using Commander
|
|
@@ -68,12 +71,16 @@ const registerCommands = (program) => {
|
|
|
68
71
|
MigrateCommand.create(),
|
|
69
72
|
D1MigrateCommand.create(),
|
|
70
73
|
DebugCommand.create(),
|
|
74
|
+
SecretsCommand.create(),
|
|
71
75
|
ConfigCommand.create(),
|
|
72
76
|
PluginCommand.create(),
|
|
73
77
|
QACommand(),
|
|
74
78
|
FixCommand.create(),
|
|
75
79
|
KeyGenerateCommand.create(),
|
|
76
80
|
SimulateCommand,
|
|
81
|
+
TemplatesCommand,
|
|
82
|
+
MakeMailTemplateCommand.create(),
|
|
83
|
+
MakeNotificationTemplateCommand.create(),
|
|
77
84
|
];
|
|
78
85
|
for (const command of commands) {
|
|
79
86
|
program.addCommand(command.getCommand());
|
|
@@ -16,8 +16,8 @@ import { ServiceScaffolder } from '../scaffolding/ServiceScaffolder';
|
|
|
16
16
|
import { WorkflowGenerator } from '../scaffolding/WorkflowGenerator';
|
|
17
17
|
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
18
18
|
import fs from '../../node-singletons/fs';
|
|
19
|
+
import * as path from '../../node-singletons/path';
|
|
19
20
|
import inquirer from 'inquirer';
|
|
20
|
-
import * as path from 'node:path';
|
|
21
21
|
const addOptions = (command) => {
|
|
22
22
|
command
|
|
23
23
|
.argument('<type>', 'What to add: service, feature, migration, model, controller, routes, factory, seeder, requestfactory, responsefactory, or workflow')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ConfigCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfigCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ConfigCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiV7E;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;cACO,YAAY;EAsEtB,CAAC"}
|
|
@@ -19,6 +19,26 @@ const addOptions = (command) => {
|
|
|
19
19
|
};
|
|
20
20
|
const getGlobalConfigManager = async () => ConfigManager.getGlobalConfig();
|
|
21
21
|
const getProjectConfigManager = async () => ConfigManager.getProjectConfig();
|
|
22
|
+
const toDisplayString = (value) => {
|
|
23
|
+
if (value === undefined || value === null)
|
|
24
|
+
return 'null';
|
|
25
|
+
if (typeof value === 'string')
|
|
26
|
+
return value;
|
|
27
|
+
if (typeof value === 'number' || typeof value === 'bigint')
|
|
28
|
+
return value.toString();
|
|
29
|
+
if (typeof value === 'boolean')
|
|
30
|
+
return value ? 'true' : 'false';
|
|
31
|
+
if (typeof value === 'symbol')
|
|
32
|
+
return value.toString();
|
|
33
|
+
if (typeof value === 'function')
|
|
34
|
+
return '[Function]';
|
|
35
|
+
try {
|
|
36
|
+
return JSON.stringify(value, null, 2);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return '[Unserializable]';
|
|
40
|
+
}
|
|
41
|
+
};
|
|
22
42
|
const formatConfigValue = (value) => {
|
|
23
43
|
if (value === undefined || value === null)
|
|
24
44
|
return chalk.gray('null');
|
|
@@ -28,7 +48,15 @@ const formatConfigValue = (value) => {
|
|
|
28
48
|
return value ? chalk.green('true') : chalk.red('false');
|
|
29
49
|
if (typeof value === 'number')
|
|
30
50
|
return chalk.yellow(value.toString());
|
|
31
|
-
|
|
51
|
+
if (typeof value === 'string')
|
|
52
|
+
return value;
|
|
53
|
+
if (typeof value === 'bigint')
|
|
54
|
+
return chalk.yellow(value.toString());
|
|
55
|
+
if (typeof value === 'symbol')
|
|
56
|
+
return chalk.gray(value.toString());
|
|
57
|
+
if (typeof value === 'function')
|
|
58
|
+
return chalk.gray('[Function]');
|
|
59
|
+
return chalk.gray(toDisplayString(value));
|
|
32
60
|
};
|
|
33
61
|
const parseConfigValue = (value) => {
|
|
34
62
|
if (value === undefined)
|
|
@@ -67,8 +95,8 @@ const displayValidationStatus = (cmd, config) => {
|
|
|
67
95
|
cmd.info(chalk.red(` ❌ Configuration has ${errors.length} errors:`));
|
|
68
96
|
for (const error of errors) {
|
|
69
97
|
const message = error !== null && typeof error === 'object' && 'message' in error
|
|
70
|
-
?
|
|
71
|
-
:
|
|
98
|
+
? toDisplayString(error.message)
|
|
99
|
+
: toDisplayString(error);
|
|
72
100
|
cmd.info(chalk.red(` - ${message}`));
|
|
73
101
|
}
|
|
74
102
|
};
|
|
@@ -151,7 +179,9 @@ const editSingleConfig = async (cmd, manager, selectedKey) => {
|
|
|
151
179
|
let defaultValue = '';
|
|
152
180
|
if (currentValue !== undefined) {
|
|
153
181
|
defaultValue =
|
|
154
|
-
typeof currentValue === 'object'
|
|
182
|
+
typeof currentValue === 'object'
|
|
183
|
+
? JSON.stringify(currentValue)
|
|
184
|
+
: toDisplayString(currentValue);
|
|
155
185
|
}
|
|
156
186
|
const newValue = await PromptHelper.textInput(`Enter new value for "${selectedKey}":`, defaultValue);
|
|
157
187
|
if (newValue === undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1MigrateCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"D1MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAsD7E;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;cACO,YAAY;EAqBtB,CAAC"}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* D1 Migrate Command
|
|
3
3
|
* Run Cloudflare D1 migrations using Wrangler
|
|
4
4
|
*/
|
|
5
|
-
import { resolveNpmPath } from '../../common';
|
|
6
|
-
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
7
5
|
import { BaseCommand } from '../BaseCommand';
|
|
6
|
+
import { resolveNpmPath } from '../../common/index';
|
|
8
7
|
import { appConfig } from '../../config/app';
|
|
9
8
|
import { Logger } from '../../config/logger';
|
|
9
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
10
10
|
import { execFileSync } from '../../node-singletons/child-process';
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
11
12
|
const runWrangler = async (cmd, args) => {
|
|
12
13
|
const npmPath = resolveNpmPath();
|
|
13
14
|
cmd.debug(`Executing: npm exec --yes -- wrangler ${args.join(' ')}`);
|
|
@@ -16,7 +17,7 @@ const runWrangler = async (cmd, args) => {
|
|
|
16
17
|
encoding: 'utf8',
|
|
17
18
|
env: appConfig.getSafeEnv(),
|
|
18
19
|
});
|
|
19
|
-
return
|
|
20
|
+
return result;
|
|
20
21
|
};
|
|
21
22
|
const executeD1Migrate = async (cmd, options) => {
|
|
22
23
|
const isLocal = options['local'] === true || options['remote'] !== true;
|