@zintrust/core 0.1.40 → 0.1.42
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/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +22 -1
- package/package.json +24 -4
- package/public/error-pages/404.html +2 -2
- package/src/auth/Auth.js +1 -1
- package/src/boot/Application.d.ts +1 -16
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +2 -290
- package/src/boot/Server.d.ts +1 -1
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/bootstrap.js +50 -16
- package/src/boot/registry/registerRoute.d.ts +6 -0
- package/src/boot/registry/registerRoute.d.ts.map +1 -0
- package/src/boot/registry/registerRoute.js +96 -0
- package/src/boot/registry/runtime.d.ts +15 -0
- package/src/boot/registry/runtime.d.ts.map +1 -0
- package/src/boot/registry/runtime.js +364 -0
- package/src/boot/registry/type.d.ts +25 -0
- package/src/boot/registry/type.d.ts.map +1 -0
- package/src/boot/registry/type.js +1 -0
- package/src/boot/registry/worker.d.ts +6 -0
- package/src/boot/registry/worker.d.ts.map +1 -0
- package/src/boot/registry/worker.js +35 -0
- package/src/cache/drivers/KVRemoteDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVRemoteDriver.js +14 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +94 -34
- package/src/cli/ErrorHandler.js +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/ConfigCommand.js +3 -5
- package/src/cli/commands/ContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/ContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerProxiesCommand.js +77 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerWorkersCommand.js +57 -0
- package/src/cli/commands/D1LearnCommand.d.ts +9 -0
- package/src/cli/commands/D1LearnCommand.d.ts.map +1 -0
- package/src/cli/commands/D1LearnCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +55 -16
- package/src/cli/commands/DeployCommand.d.ts +16 -0
- package/src/cli/commands/DeployCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployCommand.js +110 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerProxiesCommand.js +27 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerWorkersCommand.js +27 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts +3 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/DockerComposeCommandUtils.js +34 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts +5 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts.map +1 -0
- package/src/cli/commands/DoctorArchitectureCommand.js +54 -0
- package/src/cli/commands/InitContainerCommand.d.ts +5 -0
- package/src/cli/commands/InitContainerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitContainerCommand.js +231 -0
- package/src/cli/commands/InitEcosystemCommand.d.ts +6 -0
- package/src/cli/commands/InitEcosystemCommand.d.ts.map +1 -0
- package/src/cli/commands/InitEcosystemCommand.js +51 -0
- package/src/cli/commands/InitProducerCommand.d.ts +5 -0
- package/src/cli/commands/InitProducerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProducerCommand.js +47 -0
- package/src/cli/commands/InitProxyCommand.d.ts +5 -0
- package/src/cli/commands/InitProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProxyCommand.js +442 -0
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +78 -36
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateWorkerCommand.js +36 -2
- package/src/cli/commands/MongoDBProxyCommand.d.ts +5 -0
- package/src/cli/commands/MongoDBProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MongoDBProxyCommand.js +98 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts +6 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MySqlProxyCommand.js +32 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts +6 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/PostgresProxyCommand.js +32 -0
- package/src/cli/commands/ProxyCommand.d.ts +12 -0
- package/src/cli/commands/ProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommand.js +80 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts +6 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommandUtils.js +38 -0
- package/src/cli/commands/PutCommand.d.ts +6 -0
- package/src/cli/commands/PutCommand.d.ts.map +1 -0
- package/src/cli/commands/PutCommand.js +173 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts +6 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts.map +1 -0
- package/src/cli/commands/QueueRecoveryCommand.js +612 -0
- package/src/cli/commands/RedisProxyCommand.d.ts +6 -0
- package/src/cli/commands/RedisProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/RedisProxyCommand.js +53 -0
- package/src/cli/commands/ScheduleListCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleListCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleListCommand.js +62 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleRunCommand.js +32 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleStartCommand.js +40 -0
- package/src/cli/commands/SecretsCommand.d.ts.map +1 -1
- package/src/cli/commands/SecretsCommand.js +2 -2
- package/src/cli/commands/SmtpProxyCommand.d.ts +6 -0
- package/src/cli/commands/SmtpProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SmtpProxyCommand.js +56 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts +46 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/SqlProxyCommandUtils.js +48 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts +5 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SqlServerProxyCommand.js +85 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +132 -17
- package/src/cli/commands/WorkerCommands.d.ts +1 -0
- package/src/cli/commands/WorkerCommands.d.ts.map +1 -1
- package/src/cli/commands/WorkerCommands.js +140 -6
- package/src/cli/commands/index.d.ts +2 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +2 -0
- package/src/cli/commands/runner/index.d.ts +2 -2
- package/src/cli/commands/runner/index.d.ts.map +1 -1
- package/src/cli/commands/runner/index.js +15 -4
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts +6 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts.map +1 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.js +55 -0
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigManager.js +8 -1
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +14 -1
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -1
- package/src/cli/d1/WranglerConfig.js +34 -2
- package/src/cli/index.d.ts +4 -0
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +4 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +2 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +1 -0
- package/src/cli/services/VersionChecker.d.ts.map +1 -1
- package/src/cli/services/VersionChecker.js +5 -1
- package/src/cli/utils/DatabaseCliUtils.d.ts.map +1 -1
- package/src/cli/utils/DatabaseCliUtils.js +6 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/cli/utils/EnvFileLoader.js +35 -15
- package/src/cli/workers/QueueWorkRunner.js +1 -1
- package/src/cli.d.ts +5 -0
- package/src/cli.d.ts.map +1 -0
- package/src/cli.js +4 -0
- package/src/collections/index.d.ts +2 -2
- package/src/collections/index.d.ts.map +1 -1
- package/src/collections/index.js +1 -1
- package/src/common/HealthRoutes.d.ts.map +1 -1
- package/src/common/HealthRoutes.js +50 -2
- package/src/common/RemoteSignedJson.d.ts +1 -0
- package/src/common/RemoteSignedJson.d.ts.map +1 -1
- package/src/common/RemoteSignedJson.js +81 -29
- package/src/common/index.d.ts +1 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +12 -1
- package/src/common/utility.d.ts.map +1 -1
- package/src/common/utility.js +2 -6
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +21 -6
- package/src/config/app.d.ts +4 -0
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +4 -0
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +22 -2
- package/src/config/cloudflare.d.ts +5 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/cloudflare.js +67 -8
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +48 -13
- package/src/config/env.d.ts +87 -2
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +158 -19
- package/src/config/index.d.ts +1 -0
- package/src/config/index.d.ts.map +1 -1
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +16 -10
- package/src/config/middleware.d.ts +5 -0
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +19 -1
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +70 -9
- package/src/config/redis.d.ts.map +1 -1
- package/src/config/redis.js +48 -13
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +1 -0
- package/src/config/type.d.ts +18 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/workers.d.ts.map +1 -1
- package/src/config/workers.js +122 -16
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +55 -1
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/helper/index.d.ts +225 -0
- package/src/helper/index.d.ts.map +1 -0
- package/src/helper/index.js +347 -0
- package/src/http/FileUpload.d.ts +3 -2
- package/src/http/FileUpload.d.ts.map +1 -1
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +2 -1
- package/src/http/error-pages/ErrorPageRenderer.d.ts +4 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -1
- package/src/http/error-pages/ErrorPageRenderer.js +141 -1
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -1
- package/src/http/middleware/BodyParsingMiddleware.js +33 -6
- package/src/index.d.ts +26 -57
- package/src/index.d.ts.map +1 -1
- package/src/index.js +32 -18
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/microservices/ServiceAuthMiddleware.js +12 -4
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +30 -16
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -1
- package/src/middleware/ErrorHandlerMiddleware.js +2 -1
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -1
- package/src/migrations/MigrationDiscovery.js +2 -1
- package/src/migrations/MigrationLoader.js +1 -1
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
- package/src/migrations/schema/SchemaCompiler.js +6 -3
- 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 +1 -1
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/path.d.ts +1 -1
- package/src/node-singletons/path.d.ts.map +1 -1
- package/src/node-singletons/path.js +1 -1
- package/src/node-singletons/stream.d.ts +11 -0
- package/src/node-singletons/stream.d.ts.map +1 -0
- package/src/node-singletons/stream.js +8 -0
- package/src/observability/OpenTelemetry.d.ts +7 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -1
- package/src/observability/OpenTelemetry.js +49 -2
- package/src/orm/Database.d.ts +4 -0
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +80 -9
- package/src/orm/DatabaseAdapter.d.ts +1 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +2 -0
- package/src/orm/QueryBuilder.d.ts +1 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +33 -3
- package/src/orm/SchemaCompiler.d.ts.map +1 -1
- package/src/orm/SchemaCompiler.js +6 -3
- package/src/orm/SchemaStatemenWriter.d.ts +15 -0
- package/src/orm/SchemaStatemenWriter.d.ts.map +1 -0
- package/src/orm/SchemaStatemenWriter.js +78 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +52 -2
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +150 -89
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts +3 -0
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MongoDBProxyAdapter.js +128 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MySQLProxyAdapter.js +162 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.js +163 -0
- package/src/orm/adapters/ProxyCache.d.ts +9 -0
- package/src/orm/adapters/ProxyCache.d.ts.map +1 -0
- package/src/orm/adapters/ProxyCache.js +24 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts +11 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts.map +1 -0
- package/src/orm/adapters/ProxySignedRequest.js +30 -0
- package/src/orm/adapters/ProxySigningPath.d.ts +3 -0
- package/src/orm/adapters/ProxySigningPath.d.ts.map +1 -0
- package/src/orm/adapters/ProxySigningPath.js +25 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts +19 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.js +36 -0
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts +12 -0
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyRegistryMode.js +24 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts +6 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SqlServerProxyAdapter.js +154 -0
- package/src/orm/migrations/MigrationStore.js +1 -1
- package/src/performance/Optimizer.d.ts +1 -0
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +21 -8
- package/src/proxy/ErrorHandler.d.ts +11 -0
- package/src/proxy/ErrorHandler.d.ts.map +1 -0
- package/src/proxy/ErrorHandler.js +7 -0
- package/src/proxy/PoolManager.d.ts +8 -0
- package/src/proxy/PoolManager.d.ts.map +1 -0
- package/src/proxy/PoolManager.js +18 -0
- package/src/proxy/ProxyBackend.d.ts +18 -0
- package/src/proxy/ProxyBackend.d.ts.map +1 -0
- package/src/proxy/ProxyBackend.js +1 -0
- package/src/proxy/ProxyConfig.d.ts +12 -0
- package/src/proxy/ProxyConfig.d.ts.map +1 -0
- package/src/proxy/ProxyConfig.js +1 -0
- package/src/proxy/ProxyRegistry.d.ts +10 -0
- package/src/proxy/ProxyRegistry.d.ts.map +1 -0
- package/src/proxy/ProxyRegistry.js +11 -0
- package/src/proxy/ProxyRequestParsing.d.ts +9 -0
- package/src/proxy/ProxyRequestParsing.d.ts.map +1 -0
- package/src/proxy/ProxyRequestParsing.js +16 -0
- package/src/proxy/ProxyServer.d.ts +21 -0
- package/src/proxy/ProxyServer.d.ts.map +1 -0
- package/src/proxy/ProxyServer.js +84 -0
- package/src/proxy/ProxyServerUtils.d.ts +37 -0
- package/src/proxy/ProxyServerUtils.d.ts.map +1 -0
- package/src/proxy/ProxyServerUtils.js +42 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts +22 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts.map +1 -0
- package/src/proxy/ProxySigningConfigResolver.js +24 -0
- package/src/proxy/ProxySigningRequest.d.ts +12 -0
- package/src/proxy/ProxySigningRequest.d.ts.map +1 -0
- package/src/proxy/ProxySigningRequest.js +31 -0
- package/src/proxy/RequestValidator.d.ts +15 -0
- package/src/proxy/RequestValidator.d.ts.map +1 -0
- package/src/proxy/RequestValidator.js +26 -0
- package/src/proxy/SigningService.d.ts +39 -0
- package/src/proxy/SigningService.d.ts.map +1 -0
- package/src/proxy/SigningService.js +107 -0
- package/src/proxy/SqlPayloadValidator.d.ts +13 -0
- package/src/proxy/SqlPayloadValidator.d.ts.map +1 -0
- package/src/proxy/SqlPayloadValidator.js +14 -0
- package/src/proxy/SqlProxyDbOverrides.d.ts +17 -0
- package/src/proxy/SqlProxyDbOverrides.d.ts.map +1 -0
- package/src/proxy/SqlProxyDbOverrides.js +1 -0
- package/src/proxy/SqlProxyServerDeps.d.ts +12 -0
- package/src/proxy/SqlProxyServerDeps.d.ts.map +1 -0
- package/src/proxy/SqlProxyServerDeps.js +9 -0
- package/src/proxy/StatementPayloadValidator.d.ts +13 -0
- package/src/proxy/StatementPayloadValidator.d.ts.map +1 -0
- package/src/proxy/StatementPayloadValidator.js +18 -0
- package/src/proxy/StatementRegistryLoader.d.ts +2 -0
- package/src/proxy/StatementRegistryLoader.d.ts.map +1 -0
- package/src/proxy/StatementRegistryLoader.js +36 -0
- package/src/proxy/StatementRegistryResolver.d.ts +15 -0
- package/src/proxy/StatementRegistryResolver.d.ts.map +1 -0
- package/src/proxy/StatementRegistryResolver.js +34 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts +3 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -0
- package/src/proxy/d1/ZintrustD1Proxy.js +2 -0
- package/src/proxy/d1/register.d.ts +2 -0
- package/src/proxy/d1/register.d.ts.map +1 -0
- package/src/proxy/d1/register.js +5 -0
- package/src/proxy/isMutatingSql.d.ts +2 -0
- package/src/proxy/isMutatingSql.d.ts.map +1 -0
- package/src/proxy/isMutatingSql.js +12 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts +3 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -0
- package/src/proxy/kv/ZintrustKvProxy.js +2 -0
- package/src/proxy/kv/register.d.ts +2 -0
- package/src/proxy/kv/register.d.ts.map +1 -0
- package/src/proxy/kv/register.js +5 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts +33 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts.map +1 -0
- package/src/proxy/mongodb/MongoDBProxyServer.js +202 -0
- package/src/proxy/mongodb/register.d.ts +2 -0
- package/src/proxy/mongodb/register.d.ts.map +1 -0
- package/src/proxy/mongodb/register.js +5 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts +8 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -0
- package/src/proxy/mysql/MySqlProxyServer.js +202 -0
- package/src/proxy/mysql/register.d.ts +2 -0
- package/src/proxy/mysql/register.d.ts.map +1 -0
- package/src/proxy/mysql/register.js +5 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts +8 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -0
- package/src/proxy/postgres/PostgresProxyServer.js +178 -0
- package/src/proxy/postgres/register.d.ts +2 -0
- package/src/proxy/postgres/register.d.ts.map +1 -0
- package/src/proxy/postgres/register.js +5 -0
- package/src/proxy/redis/RedisProxyServer.d.ts +12 -0
- package/src/proxy/redis/RedisProxyServer.d.ts.map +1 -0
- package/src/proxy/redis/RedisProxyServer.js +192 -0
- package/src/proxy/redis/register.d.ts +2 -0
- package/src/proxy/redis/register.d.ts.map +1 -0
- package/src/proxy/redis/register.js +5 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts +19 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts.map +1 -0
- package/src/proxy/smtp/SmtpProxyServer.js +290 -0
- package/src/proxy/smtp/register.d.ts +2 -0
- package/src/proxy/smtp/register.d.ts.map +1 -0
- package/src/proxy/smtp/register.js +5 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts +8 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.js +203 -0
- package/src/proxy/sqlserver/register.d.ts +2 -0
- package/src/proxy/sqlserver/register.d.ts.map +1 -0
- package/src/proxy/sqlserver/register.js +5 -0
- package/src/proxy.d.ts +4 -0
- package/src/proxy.d.ts.map +1 -0
- package/src/proxy.js +3 -0
- package/src/routes/doc.d.ts.map +1 -1
- package/src/routes/doc.js +16 -2
- package/src/routes/error.d.ts +5 -4
- package/src/routes/error.d.ts.map +1 -1
- package/src/routes/error.js +15 -13
- package/src/routes/errorPages.d.ts +2 -0
- package/src/routes/errorPages.d.ts.map +1 -1
- package/src/routes/errorPages.js +144 -4
- package/src/runtime/PluginAutoImports.d.ts +1 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +94 -9
- package/src/runtime/RuntimeAdapter.d.ts +8 -9
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/RuntimeAdapter.js +120 -34
- package/src/runtime/RuntimeServices.d.ts +47 -0
- package/src/runtime/RuntimeServices.d.ts.map +1 -0
- package/src/runtime/RuntimeServices.js +164 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts +4 -4
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +12 -0
- package/src/runtime/WorkerAdapterImports.d.ts +5 -0
- package/src/runtime/WorkerAdapterImports.d.ts.map +1 -0
- package/src/runtime/WorkerAdapterImports.js +17 -0
- package/src/runtime/WorkersModule.d.ts +6 -0
- package/src/runtime/WorkersModule.d.ts.map +1 -0
- package/src/runtime/WorkersModule.js +278 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +19 -2
- package/src/runtime/adapters/DenoAdapter.js +1 -0
- package/src/runtime/adapters/FargateAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.js +1 -1
- package/src/runtime/detectRuntime.d.ts +10 -0
- package/src/runtime/detectRuntime.d.ts.map +1 -0
- package/src/runtime/detectRuntime.js +57 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -1
- package/src/runtime/useFileLoader.js +16 -0
- package/src/scheduler/Schedule.d.ts +36 -0
- package/src/scheduler/Schedule.d.ts.map +1 -0
- package/src/scheduler/Schedule.js +197 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts +8 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts.map +1 -0
- package/src/scheduler/ScheduleHttpGateway.js +196 -0
- package/src/scheduler/ScheduleRunner.d.ts +6 -0
- package/src/scheduler/ScheduleRunner.d.ts.map +1 -1
- package/src/scheduler/ScheduleRunner.js +166 -29
- package/src/scheduler/SchedulerRuntime.d.ts +15 -0
- package/src/scheduler/SchedulerRuntime.d.ts.map +1 -0
- package/src/scheduler/SchedulerRuntime.js +79 -0
- package/src/scheduler/cron/Cron.d.ts +19 -0
- package/src/scheduler/cron/Cron.d.ts.map +1 -0
- package/src/scheduler/cron/Cron.js +200 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts +14 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts.map +1 -0
- package/src/scheduler/leader/SchedulerLeader.js +187 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts +27 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts.map +1 -0
- package/src/scheduler/state/ScheduleStateStore.js +27 -0
- package/src/scheduler/types.d.ts +10 -0
- package/src/scheduler/types.d.ts.map +1 -1
- package/src/schedules/index.d.ts +1 -0
- package/src/schedules/index.d.ts.map +1 -1
- package/src/schedules/index.js +1 -0
- package/src/schedules/job-tracking-cleanup.d.ts +4 -0
- package/src/schedules/job-tracking-cleanup.d.ts.map +1 -0
- package/src/schedules/job-tracking-cleanup.js +116 -0
- package/src/schedules/log-cleanup.d.ts +1 -2
- package/src/schedules/log-cleanup.d.ts.map +1 -1
- package/src/schedules/log-cleanup.js +12 -15
- package/src/scripts/TemplateImportsCheck.js +2 -2
- package/src/scripts/TemplateSync.js +3 -4
- package/src/security/CsrfTokenManager.d.ts.map +1 -1
- package/src/security/CsrfTokenManager.js +12 -0
- package/src/security/Hash.d.ts +1 -1
- package/src/security/Hash.d.ts.map +1 -1
- package/src/security/Hash.js +31 -36
- package/src/security/Sanitizer.d.ts.map +1 -1
- package/src/security/Sanitizer.js +1 -9
- package/src/security/SignedRequest.d.ts.map +1 -1
- package/src/security/SignedRequest.js +2 -2
- package/src/seeders/SeederLoader.js +1 -1
- package/src/session/SessionManager.d.ts +3 -0
- package/src/session/SessionManager.d.ts.map +1 -1
- package/src/session/SessionManager.js +49 -10
- package/src/sockets/CloudflareSocket.d.ts +24 -0
- package/src/sockets/CloudflareSocket.d.ts.map +1 -0
- package/src/sockets/CloudflareSocket.js +259 -0
- package/src/start.d.ts.map +1 -1
- package/src/start.js +1 -8
- package/src/templates/docker/docker-compose.ecosystem.yml.tpl +301 -0
- package/src/templates/docker/docker-compose.schedules.yml.tpl +84 -0
- package/src/templates/project/basic/app/Schedules/index.ts.tpl +0 -0
- package/src/templates/project/basic/config/database.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
- package/src/toolkit/Secrets/Manifest.d.ts.map +1 -1
- package/src/toolkit/Secrets/Manifest.js +5 -7
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
- package/src/tools/mail/drivers/Smtp.js +229 -18
- package/src/tools/mail/index.d.ts.map +1 -1
- package/src/tools/mail/index.js +5 -4
- package/src/tools/mail/template-loader.d.ts.map +1 -1
- package/src/tools/mail/template-loader.js +197 -29
- package/src/tools/mail/templates/auth-password-reset.d.ts +3 -0
- package/src/tools/mail/templates/auth-password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-password-reset.js +231 -0
- package/src/tools/mail/templates/auth-welcome.d.ts +3 -0
- package/src/tools/mail/templates/auth-welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-welcome.js +236 -0
- package/src/tools/mail/templates/general.d.ts +3 -0
- package/src/tools/mail/templates/general.d.ts.map +1 -0
- package/src/tools/mail/templates/general.js +109 -0
- package/src/tools/mail/templates/index.js +2 -2
- package/src/tools/mail/templates/job-completed.d.ts +3 -0
- package/src/tools/mail/templates/job-completed.d.ts.map +1 -0
- package/src/tools/mail/templates/job-completed.js +188 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts +3 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts.map +1 -0
- package/src/tools/mail/templates/notifications-new-comment.js +228 -0
- package/src/tools/mail/templates/password-reset.d.ts +3 -0
- package/src/tools/mail/templates/password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/password-reset.js +221 -0
- package/src/tools/mail/templates/performance-report.d.ts +3 -0
- package/src/tools/mail/templates/performance-report.d.ts.map +1 -0
- package/src/tools/mail/templates/performance-report.js +258 -0
- package/src/tools/mail/templates/welcome.d.ts +3 -0
- package/src/tools/mail/templates/welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/welcome.js +187 -0
- package/src/tools/mail/templates/worker-alert.d.ts +3 -0
- package/src/tools/mail/templates/worker-alert.d.ts.map +1 -0
- package/src/tools/mail/templates/worker-alert.js +229 -0
- package/src/tools/notification/Notification.js +1 -1
- package/src/tools/notification/testingHelpers.js +6 -5
- package/src/tools/queue/AdvancedQueue.js +2 -6
- package/src/tools/queue/IdempotencyManager.d.ts +6 -0
- package/src/tools/queue/IdempotencyManager.d.ts.map +1 -0
- package/src/tools/queue/IdempotencyManager.js +36 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts +16 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts.map +1 -0
- package/src/tools/queue/JobHeartbeatStore.js +67 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts +16 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts.map +1 -0
- package/src/tools/queue/JobReconciliationRunner.js +56 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts +27 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts.map +1 -0
- package/src/tools/queue/JobRecoveryDaemon.js +303 -0
- package/src/tools/queue/JobStateTracker.d.ts +140 -0
- package/src/tools/queue/JobStateTracker.d.ts.map +1 -0
- package/src/tools/queue/JobStateTracker.js +409 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts +12 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts.map +1 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.js +239 -0
- package/src/tools/queue/Queue.d.ts.map +1 -1
- package/src/tools/queue/Queue.js +160 -16
- package/src/tools/queue/QueueDataRedactor.d.ts +6 -0
- package/src/tools/queue/QueueDataRedactor.d.ts.map +1 -0
- package/src/tools/queue/QueueDataRedactor.js +45 -0
- package/src/tools/queue/QueueExtensions.d.ts.map +1 -1
- package/src/tools/queue/QueueExtensions.js +2 -1
- package/src/tools/queue/QueueReliabilityMetrics.d.ts +38 -0
- package/src/tools/queue/QueueReliabilityMetrics.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityMetrics.js +131 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts +7 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.js +59 -0
- package/src/tools/queue/QueueRuntimeRegistration.d.ts +1 -9
- package/src/tools/queue/QueueRuntimeRegistration.d.ts.map +1 -1
- package/src/tools/queue/QueueRuntimeRegistration.js +75 -4
- package/src/tools/queue/QueueTracing.d.ts +32 -0
- package/src/tools/queue/QueueTracing.d.ts.map +1 -0
- package/src/tools/queue/QueueTracing.js +151 -0
- package/src/tools/queue/StalledJobMonitor.d.ts +5 -0
- package/src/tools/queue/StalledJobMonitor.d.ts.map +1 -0
- package/src/tools/queue/StalledJobMonitor.js +21 -0
- package/src/tools/queue/TimeoutManager.d.ts +14 -0
- package/src/tools/queue/TimeoutManager.d.ts.map +1 -0
- package/src/tools/queue/TimeoutManager.js +77 -0
- package/src/tools/queue/drivers/Redis.d.ts +1 -0
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -0
- package/src/tools/queue/index.d.ts +10 -0
- package/src/tools/queue/index.d.ts.map +1 -1
- package/src/tools/queue/index.js +10 -0
- package/src/tools/storage/drivers/R2.d.ts +13 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -1
- package/src/tools/storage/drivers/R2.js +29 -0
- package/src/zintrust.plugins.d.ts +9 -0
- package/src/zintrust.plugins.d.ts.map +1 -0
- package/src/zintrust.plugins.js +7 -0
- package/src/zintrust.plugins.wg.d.ts +9 -0
- package/src/zintrust.plugins.wg.d.ts.map +1 -0
- package/src/zintrust.plugins.wg.js +7 -0
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
-
import {
|
|
2
|
+
import { createDenoRunnerSource, createLambdaRunnerSource } from '../commands/runner/index.js';
|
|
3
3
|
import { EnvFileLoader } from '../utils/EnvFileLoader.js';
|
|
4
4
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
5
5
|
import { readEnvString } from '../../common/ExternalServiceUtils.js';
|
|
6
|
-
import
|
|
6
|
+
import * as Common from '../../common/index.js';
|
|
7
7
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
8
8
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from '../../node-singletons/fs.js';
|
|
9
9
|
import * as path from '../../node-singletons/path.js';
|
|
10
|
+
const resolveNpmPath = () => {
|
|
11
|
+
try {
|
|
12
|
+
return typeof Common.resolveNpmPath === 'function' ? Common.resolveNpmPath() : 'npm';
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return 'npm';
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const runFromSource = () => {
|
|
19
|
+
try {
|
|
20
|
+
return typeof Common.runFromSource === 'function' ? Common.runFromSource() : false;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
10
26
|
const isValidModeInput = (value) => value === 'development' ||
|
|
11
27
|
value === 'dev' ||
|
|
12
28
|
value === 'production' ||
|
|
13
29
|
value === 'pro' ||
|
|
14
30
|
value === 'prod' ||
|
|
15
|
-
value === 'testing'
|
|
31
|
+
value === 'testing' ||
|
|
32
|
+
value === 'split';
|
|
16
33
|
const normalizeMode = (value) => {
|
|
17
34
|
if (value === 'production' || value === 'pro' || value === 'prod')
|
|
18
35
|
return 'production';
|
|
19
36
|
if (value === 'testing')
|
|
20
37
|
return 'testing';
|
|
38
|
+
if (value === 'split')
|
|
39
|
+
return 'split';
|
|
21
40
|
return 'development';
|
|
22
41
|
};
|
|
23
42
|
const resolveModeFromAppMode = () => {
|
|
@@ -76,6 +95,28 @@ const resolveStartVariant = (options) => {
|
|
|
76
95
|
return 'lambda';
|
|
77
96
|
return 'node';
|
|
78
97
|
};
|
|
98
|
+
const getMySqlProxyHint = () => {
|
|
99
|
+
const connection = readEnvString('DB_CONNECTION', '').toLowerCase();
|
|
100
|
+
if (connection !== 'mysql')
|
|
101
|
+
return null;
|
|
102
|
+
const proxyUrl = readEnvString('MYSQL_PROXY_URL', '').trim();
|
|
103
|
+
if (proxyUrl !== '')
|
|
104
|
+
return null;
|
|
105
|
+
const host = readEnvString('MYSQL_PROXY_HOST', '127.0.0.1').trim() || '127.0.0.1';
|
|
106
|
+
const port = readEnvString('MYSQL_PROXY_PORT', '8789').trim() || '8789';
|
|
107
|
+
return {
|
|
108
|
+
command: `zin proxy:mysql --host ${host} --port ${port}`,
|
|
109
|
+
url: `http://${host}:${port}`,
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
const logMySqlProxyHint = (cmd) => {
|
|
113
|
+
const hint = getMySqlProxyHint();
|
|
114
|
+
if (!hint)
|
|
115
|
+
return;
|
|
116
|
+
cmd.warn('MySQL proxy not configured for Cloudflare Workers. Start it in another terminal:');
|
|
117
|
+
cmd.warn(hint.command);
|
|
118
|
+
cmd.warn(`Then set MYSQL_PROXY_URL=${hint.url}`);
|
|
119
|
+
};
|
|
79
120
|
const hasFlag = (flag) => process.argv.includes(flag);
|
|
80
121
|
const resolveWatchPreference = (options, mode) => {
|
|
81
122
|
const hasWatch = hasFlag('--watch');
|
|
@@ -134,6 +175,14 @@ const resolveBootstrapEntryTs = (cwd) => {
|
|
|
134
175
|
return 'src/boot/bootstrap.ts';
|
|
135
176
|
return undefined;
|
|
136
177
|
};
|
|
178
|
+
const resolveRuntimeStartModuleSpecifier = (cwd) => {
|
|
179
|
+
const localStart = path.join(cwd, 'src/start.ts');
|
|
180
|
+
if (existsSync(localStart)) {
|
|
181
|
+
// Runner files are created under `<cwd>/tmp`, so `../src/start.ts` is stable.
|
|
182
|
+
return '../src/start.ts';
|
|
183
|
+
}
|
|
184
|
+
return '@zintrust/core/start';
|
|
185
|
+
};
|
|
137
186
|
const resolveNodeDevCommand = (cwd, packageJson) => {
|
|
138
187
|
if (isFrameworkRepo(packageJson)) {
|
|
139
188
|
const bootstrap = resolveBootstrapEntryTs(cwd);
|
|
@@ -159,10 +208,8 @@ const resolveNodeDevCommand = (cwd, packageJson) => {
|
|
|
159
208
|
};
|
|
160
209
|
const resolveNodeProdCommand = (cwd) => {
|
|
161
210
|
const compiledBoot = path.join(cwd, 'dist/src/boot/bootstrap.js');
|
|
162
|
-
const runFromSourceEnv = process.env['ZINTRUST_RUN_FROM_SOURCE'] ?? '';
|
|
163
|
-
const runFromSource = runFromSourceEnv === '1' || runFromSourceEnv.toLowerCase() === 'true';
|
|
164
211
|
let compiled;
|
|
165
|
-
if (existsSync(compiledBoot) && !runFromSource) {
|
|
212
|
+
if (existsSync(compiledBoot) && !runFromSource()) {
|
|
166
213
|
compiled = 'dist/src/boot/bootstrap.js';
|
|
167
214
|
}
|
|
168
215
|
// If compiled app isn't available (or the env forces running from source),
|
|
@@ -180,7 +227,7 @@ const resolveNodeProdCommand = (cwd) => {
|
|
|
180
227
|
}
|
|
181
228
|
return { command: 'node', args: [compiled] };
|
|
182
229
|
};
|
|
183
|
-
const executeWranglerStart = async (cmd, cwd, port, runtime) => {
|
|
230
|
+
const executeWranglerStart = async (cmd, cwd, port, runtime, envName) => {
|
|
184
231
|
if (runtime !== undefined) {
|
|
185
232
|
throw ErrorFactory.createCliError('Error: --runtime is not supported with --wrangler (Wrangler controls Workers runtime).');
|
|
186
233
|
}
|
|
@@ -196,8 +243,16 @@ const executeWranglerStart = async (cmd, cwd, port, runtime) => {
|
|
|
196
243
|
if (typeof port === 'number') {
|
|
197
244
|
wranglerArgs.push('--port', String(port));
|
|
198
245
|
}
|
|
246
|
+
if (envName !== undefined && envName.trim() !== '') {
|
|
247
|
+
wranglerArgs.push('--env', envName.trim());
|
|
248
|
+
}
|
|
249
|
+
logMySqlProxyHint(cmd);
|
|
199
250
|
cmd.info('Starting in Wrangler dev mode...');
|
|
200
|
-
const exitCode = await SpawnUtil.spawnAndWait({
|
|
251
|
+
const exitCode = await SpawnUtil.spawnAndWait({
|
|
252
|
+
command: 'wrangler',
|
|
253
|
+
args: wranglerArgs,
|
|
254
|
+
env: process.env,
|
|
255
|
+
});
|
|
201
256
|
process.exit(exitCode);
|
|
202
257
|
};
|
|
203
258
|
const ensureTmpRunnerFile = (cwd, filename, content) => {
|
|
@@ -224,13 +279,14 @@ const executeDenoStart = async (cmd, cwd, mode, watchEnabled, _port, runtime) =>
|
|
|
224
279
|
if (mode === 'testing') {
|
|
225
280
|
throw ErrorFactory.createCliError('Error: Cannot start server in testing mode. Use development or production.');
|
|
226
281
|
}
|
|
227
|
-
const
|
|
282
|
+
const startModuleSpecifier = resolveRuntimeStartModuleSpecifier(cwd);
|
|
283
|
+
const denoRunner = ensureTmpRunnerFile(cwd, 'zin-start-deno.ts', createDenoRunnerSource(startModuleSpecifier));
|
|
228
284
|
const args = [];
|
|
229
285
|
if (mode === 'development' && watchEnabled)
|
|
230
286
|
args.push('watch');
|
|
231
287
|
args.push(denoRunner);
|
|
232
288
|
cmd.info('Starting in Deno adapter mode...');
|
|
233
|
-
const exitCode = await SpawnUtil.spawnAndWait({ command: 'tsx', args });
|
|
289
|
+
const exitCode = await SpawnUtil.spawnAndWait({ command: 'tsx', args, env: process.env });
|
|
234
290
|
process.exit(exitCode);
|
|
235
291
|
};
|
|
236
292
|
const executeLambdaStart = async (cmd, cwd, mode, watchEnabled, _port, runtime) => {
|
|
@@ -240,16 +296,17 @@ const executeLambdaStart = async (cmd, cwd, mode, watchEnabled, _port, runtime)
|
|
|
240
296
|
if (mode === 'testing') {
|
|
241
297
|
throw ErrorFactory.createCliError('Error: Cannot start server in testing mode. Use development or production.');
|
|
242
298
|
}
|
|
243
|
-
const
|
|
299
|
+
const startModuleSpecifier = resolveRuntimeStartModuleSpecifier(cwd);
|
|
300
|
+
const lambdaRunner = ensureTmpRunnerFile(cwd, 'zin-start-lambda.ts', createLambdaRunnerSource(startModuleSpecifier));
|
|
244
301
|
const args = [];
|
|
245
302
|
if (mode === 'development' && watchEnabled)
|
|
246
303
|
args.push('watch');
|
|
247
304
|
args.push(lambdaRunner);
|
|
248
305
|
cmd.info('Starting in Lambda adapter mode...');
|
|
249
|
-
const exitCode = await SpawnUtil.spawnAndWait({ command: 'tsx', args });
|
|
306
|
+
const exitCode = await SpawnUtil.spawnAndWait({ command: 'tsx', args, env: process.env });
|
|
250
307
|
process.exit(exitCode);
|
|
251
308
|
};
|
|
252
|
-
const executeNodeStart = async (cmd, cwd, mode, watchEnabled) => {
|
|
309
|
+
const executeNodeStart = async (cmd, cwd, mode, watchEnabled, _port) => {
|
|
253
310
|
if (mode === 'testing') {
|
|
254
311
|
throw ErrorFactory.createCliError('Error: Cannot start server in testing mode. Use --force to override (not supported).');
|
|
255
312
|
}
|
|
@@ -262,6 +319,7 @@ const executeNodeStart = async (cmd, cwd, mode, watchEnabled) => {
|
|
|
262
319
|
command: 'tsx',
|
|
263
320
|
args,
|
|
264
321
|
forwardSignals: false,
|
|
322
|
+
env: process.env,
|
|
265
323
|
});
|
|
266
324
|
process.exit(exitCode);
|
|
267
325
|
}
|
|
@@ -272,6 +330,7 @@ const executeNodeStart = async (cmd, cwd, mode, watchEnabled) => {
|
|
|
272
330
|
command: dev.command,
|
|
273
331
|
args: dev.args,
|
|
274
332
|
forwardSignals: false,
|
|
333
|
+
env: process.env,
|
|
275
334
|
});
|
|
276
335
|
process.exit(exitCode);
|
|
277
336
|
}
|
|
@@ -281,9 +340,56 @@ const executeNodeStart = async (cmd, cwd, mode, watchEnabled) => {
|
|
|
281
340
|
command: prod.command,
|
|
282
341
|
args: prod.args,
|
|
283
342
|
forwardSignals: false,
|
|
343
|
+
env: process.env,
|
|
284
344
|
});
|
|
285
345
|
process.exit(exitCode);
|
|
286
346
|
};
|
|
347
|
+
const executeSplitStart = async (cmd, cwd, _options) => {
|
|
348
|
+
cmd.info('🚀 Starting in split mode (Producer + Consumer)...');
|
|
349
|
+
const packageJson = readPackageJson(cwd);
|
|
350
|
+
const webDev = resolveNodeDevCommand(cwd, packageJson);
|
|
351
|
+
// Producer Environment
|
|
352
|
+
const producerEnv = {
|
|
353
|
+
...process.env,
|
|
354
|
+
WORKER_ENABLED: 'false',
|
|
355
|
+
QUEUE_ENABLED: 'true',
|
|
356
|
+
RUNTIME_MODE: 'node-server',
|
|
357
|
+
};
|
|
358
|
+
// Consumer Environment
|
|
359
|
+
const consumerEnv = {
|
|
360
|
+
...process.env,
|
|
361
|
+
WORKER_ENABLED: 'true',
|
|
362
|
+
QUEUE_ENABLED: 'true',
|
|
363
|
+
RUNTIME_MODE: 'containers',
|
|
364
|
+
WORKER_AUTO_START: 'true',
|
|
365
|
+
// Prevent consumer from binding to the web port
|
|
366
|
+
APP_PORT: '0',
|
|
367
|
+
PORT: '0',
|
|
368
|
+
};
|
|
369
|
+
// Resolve Consumer Command (zintrust worker:start-all)
|
|
370
|
+
// We try to use tsx against the source bin if possible
|
|
371
|
+
const workerArgs = existsSync(path.join(cwd, 'bin/zin.ts'))
|
|
372
|
+
? ['bin/zin.ts', 'worker:start-all']
|
|
373
|
+
: ['dist/bin/zin.js', 'worker:start-all'];
|
|
374
|
+
const workerCommand = existsSync(path.join(cwd, 'bin/zin.ts')) ? 'tsx' : 'node';
|
|
375
|
+
cmd.info('-------------------------------------------');
|
|
376
|
+
cmd.info('🔹 [Producer] Web Server starting...');
|
|
377
|
+
cmd.info('🔸 [Consumer] Worker Process starting...');
|
|
378
|
+
cmd.info('-------------------------------------------');
|
|
379
|
+
const pProducer = SpawnUtil.spawnAndWait({
|
|
380
|
+
command: webDev.command,
|
|
381
|
+
args: webDev.args,
|
|
382
|
+
env: producerEnv,
|
|
383
|
+
forwardSignals: true,
|
|
384
|
+
});
|
|
385
|
+
const pConsumer = SpawnUtil.spawnAndWait({
|
|
386
|
+
command: workerCommand,
|
|
387
|
+
args: workerArgs,
|
|
388
|
+
env: consumerEnv,
|
|
389
|
+
forwardSignals: true,
|
|
390
|
+
});
|
|
391
|
+
await Promise.all([pProducer, pConsumer]);
|
|
392
|
+
};
|
|
287
393
|
const executeStart = async (options, cmd) => {
|
|
288
394
|
const cwd = process.cwd();
|
|
289
395
|
EnvFileLoader.ensureLoaded();
|
|
@@ -291,16 +397,24 @@ const executeStart = async (options, cmd) => {
|
|
|
291
397
|
const port = resolvePort(options);
|
|
292
398
|
const runtime = resolveRuntime(options);
|
|
293
399
|
const variant = resolveStartVariant(options);
|
|
400
|
+
const envName = typeof options.env === 'string' ? options.env.trim() : '';
|
|
294
401
|
let effectiveRuntime = runtime;
|
|
295
402
|
if (variant === 'deno')
|
|
296
403
|
effectiveRuntime = 'deno';
|
|
297
404
|
if (variant === 'lambda')
|
|
298
405
|
effectiveRuntime = 'lambda';
|
|
406
|
+
if (mode === 'split') {
|
|
407
|
+
await executeSplitStart(cmd, cwd, options);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
299
410
|
EnvFileLoader.applyCliOverrides({ nodeEnv: mode, port, runtime: effectiveRuntime });
|
|
300
411
|
if (variant === 'wrangler') {
|
|
301
|
-
await executeWranglerStart(cmd, cwd, port, runtime);
|
|
412
|
+
await executeWranglerStart(cmd, cwd, port, runtime, envName === '' ? undefined : envName);
|
|
302
413
|
return;
|
|
303
414
|
}
|
|
415
|
+
if (envName !== '') {
|
|
416
|
+
throw ErrorFactory.createCliError('Error: --env is only supported with --wrangler/--wg.');
|
|
417
|
+
}
|
|
304
418
|
const watchEnabled = resolveWatchPreference(options, mode);
|
|
305
419
|
if (variant === 'deno') {
|
|
306
420
|
await executeDenoStart(cmd, cwd, mode, watchEnabled, port, runtime);
|
|
@@ -310,22 +424,23 @@ const executeStart = async (options, cmd) => {
|
|
|
310
424
|
await executeLambdaStart(cmd, cwd, mode, watchEnabled, port, runtime);
|
|
311
425
|
return;
|
|
312
426
|
}
|
|
313
|
-
await executeNodeStart(cmd, cwd, mode, watchEnabled);
|
|
427
|
+
await executeNodeStart(cmd, cwd, mode, watchEnabled, port);
|
|
314
428
|
};
|
|
315
429
|
export const StartCommand = Object.freeze({
|
|
316
430
|
create() {
|
|
317
431
|
const addOptions = (command) => {
|
|
318
432
|
command.alias('s');
|
|
319
433
|
command
|
|
320
|
-
.option('
|
|
434
|
+
.option('--wrangler', 'Start with Wrangler dev mode (Cloudflare Workers)')
|
|
321
435
|
.option('--wg', 'Alias for --wrangler')
|
|
322
436
|
.option('--deno', 'Start a local server using the Deno runtime adapter')
|
|
323
437
|
.option('--lambda', 'Start a local server using the AWS Lambda runtime adapter')
|
|
324
438
|
.option('--watch', 'Force watch mode (Node only)')
|
|
325
439
|
.option('--no-watch', 'Disable watch mode (Node only)')
|
|
326
440
|
.option('--mode <development|production|testing>', 'Override app mode')
|
|
441
|
+
.option('--env <name>', 'Wrangler environment name (Wrangler mode only)')
|
|
327
442
|
.option('--runtime <nodejs|cloudflare|lambda|deno|auto>', 'Set RUNTIME for spawned Node')
|
|
328
|
-
.option('--port <number>', 'Override server port');
|
|
443
|
+
.option('-p, --port <number>', 'Override server port');
|
|
329
444
|
};
|
|
330
445
|
const cmd = BaseCommand.create({
|
|
331
446
|
name: 'start',
|
|
@@ -10,6 +10,7 @@ export declare const WorkerCommands: {
|
|
|
10
10
|
createWorkerListCommand: () => IBaseCommand;
|
|
11
11
|
createWorkerStatusCommand: () => IBaseCommand;
|
|
12
12
|
createWorkerStartCommand: () => IBaseCommand;
|
|
13
|
+
createWorkerStartAllCommand: () => IBaseCommand;
|
|
13
14
|
createWorkerStopCommand: () => IBaseCommand;
|
|
14
15
|
createWorkerRestartCommand: () => IBaseCommand;
|
|
15
16
|
createWorkerSummaryCommand: () => IBaseCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkerCommands.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/WorkerCommands.ts"],"names":[],"mappings":"AACA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"WorkerCommands.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/WorkerCommands.ts"],"names":[],"mappings":"AACA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA2hBrD;;GAEG;AACH,eAAO,MAAM,cAAc;mCA/XS,YAAY;qCA4CV,YAAY;oCAiDb,YAAY;uCAkFT,YAAY;mCA0FhB,YAAY;sCAgCT,YAAY;sCAgCZ,YAAY;CA8DlD,CAAC"}
|
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
7
7
|
import { BaseCommand } from '../BaseCommand.js';
|
|
8
|
+
import { Env } from '../../config/env.js';
|
|
8
9
|
import { Logger } from '../../config/logger.js';
|
|
10
|
+
import { loadWorkersModule as loadWorkersRuntimeModule } from '../../runtime/WorkersModule.js';
|
|
9
11
|
// Lazy initialization to prevent temporal dead zone issues
|
|
10
12
|
let WorkerFactory;
|
|
11
13
|
let WorkerRegistry;
|
|
12
14
|
let HealthMonitor;
|
|
13
15
|
let ResourceMonitor;
|
|
14
|
-
let workersModulePromise;
|
|
15
16
|
const loadWorkersModule = async () => {
|
|
16
|
-
workersModulePromise ??= import('@zintrust/workers');
|
|
17
17
|
try {
|
|
18
|
-
return await
|
|
18
|
+
return (await loadWorkersRuntimeModule());
|
|
19
19
|
}
|
|
20
20
|
catch (error) {
|
|
21
21
|
Logger.error('Failed to load optional package "@zintrust/workers"; worker commands require this package.', error);
|
|
@@ -50,6 +50,31 @@ const getResourceMonitor = async () => {
|
|
|
50
50
|
}
|
|
51
51
|
return ResourceMonitor;
|
|
52
52
|
};
|
|
53
|
+
const extractStatus = (item) => {
|
|
54
|
+
const status = typeof item === 'object' && item !== null ? item.status : undefined;
|
|
55
|
+
if (status === 'healthy' ||
|
|
56
|
+
status === 'degraded' ||
|
|
57
|
+
status === 'unhealthy' ||
|
|
58
|
+
status === 'critical') {
|
|
59
|
+
return status;
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
};
|
|
63
|
+
const normalizeHealthStatuses = (summary) => {
|
|
64
|
+
let list;
|
|
65
|
+
if (Array.isArray(summary)) {
|
|
66
|
+
list = summary;
|
|
67
|
+
}
|
|
68
|
+
else if (typeof summary === 'object' && summary !== null) {
|
|
69
|
+
const details = summary.details;
|
|
70
|
+
if (Array.isArray(details)) {
|
|
71
|
+
list = details;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return (list ?? [])
|
|
75
|
+
.map(extractStatus)
|
|
76
|
+
.filter((status) => status !== undefined);
|
|
77
|
+
};
|
|
53
78
|
/**
|
|
54
79
|
* Helper: Format table output
|
|
55
80
|
*/
|
|
@@ -173,6 +198,113 @@ const createWorkerStartCommand = () => {
|
|
|
173
198
|
});
|
|
174
199
|
return cmd;
|
|
175
200
|
};
|
|
201
|
+
/**
|
|
202
|
+
* Helper: Poll for persisted workers in container mode
|
|
203
|
+
*/
|
|
204
|
+
const pollForPersistedWorkers = async (factory) => {
|
|
205
|
+
let workers = await factory.listPersisted();
|
|
206
|
+
if (workers.length === 0 && process.env['RUNTIME_MODE'] === 'containers') {
|
|
207
|
+
Logger.info('No persisted workers found. Waiting for workers to be registered... (Polling every 10s)');
|
|
208
|
+
while (workers.length === 0) {
|
|
209
|
+
// eslint-disable-next-line no-await-in-loop
|
|
210
|
+
await new Promise((resolve) => globalThis.setTimeout(resolve, 10000));
|
|
211
|
+
try {
|
|
212
|
+
// eslint-disable-next-line no-await-in-loop
|
|
213
|
+
workers = await factory.listPersisted();
|
|
214
|
+
if (workers.length > 0) {
|
|
215
|
+
Logger.info(`Found ${workers.length} workers. Proceeding to start.`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch (e) {
|
|
219
|
+
Logger.warn('Error checking for persisted workers (retrying in 10s):', e instanceof Error ? e.message : String(e));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return workers;
|
|
224
|
+
};
|
|
225
|
+
const isRegisteredWorkerRunning = async (workerLike) => {
|
|
226
|
+
if (typeof workerLike !== 'object' || workerLike === null)
|
|
227
|
+
return false;
|
|
228
|
+
const candidate = workerLike;
|
|
229
|
+
const runningFn = candidate.worker?.isRunning;
|
|
230
|
+
const pausedFn = candidate.worker?.isPaused;
|
|
231
|
+
const isRunning = typeof runningFn === 'function' ? await Promise.resolve(runningFn()) : false;
|
|
232
|
+
const isPaused = typeof pausedFn === 'function' ? pausedFn() : false;
|
|
233
|
+
return isRunning && !isPaused;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Worker Start All Command
|
|
237
|
+
*/
|
|
238
|
+
const createWorkerStartAllCommand = () => {
|
|
239
|
+
const ext = async () => {
|
|
240
|
+
try {
|
|
241
|
+
const globalAutoStart = Env.getBool('WORKER_AUTO_START', false);
|
|
242
|
+
if (!globalAutoStart) {
|
|
243
|
+
Logger.info('Skipping auto-start because WORKER_AUTO_START is false.');
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const factory = await getWorkerFactory();
|
|
247
|
+
const records = await factory.listPersistedRecords();
|
|
248
|
+
const autoStartRecords = records.filter((record) => record.activeStatus !== false && record.autoStart === true);
|
|
249
|
+
const workers = autoStartRecords.map((record) => record.name);
|
|
250
|
+
if (workers.length === 0) {
|
|
251
|
+
Logger.info('No auto-start eligible persisted workers found.');
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
const discoveredWorkers = await pollForPersistedWorkers(factory);
|
|
255
|
+
const eligibleWorkers = workers.filter((name) => discoveredWorkers.includes(name));
|
|
256
|
+
if (eligibleWorkers.length === 0) {
|
|
257
|
+
Logger.info('No auto-start eligible workers are currently persisted.');
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const results = await Promise.all(eligibleWorkers.map(async (name) => {
|
|
261
|
+
const existing = await factory.get(name);
|
|
262
|
+
if (existing !== null && existing !== undefined) {
|
|
263
|
+
const trulyRunning = await isRegisteredWorkerRunning(existing);
|
|
264
|
+
if (trulyRunning) {
|
|
265
|
+
return { name, status: 'skipped' };
|
|
266
|
+
}
|
|
267
|
+
Logger.warn(`Worker "${name}" is registered but not truly running. Restarting for crash recovery.`);
|
|
268
|
+
try {
|
|
269
|
+
await factory.restart(name);
|
|
270
|
+
return { name, status: 'started' };
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
Logger.warn(`Failed to restart stale worker "${name}"`, error);
|
|
274
|
+
return { name, status: 'failed' };
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
await factory.startFromPersisted(name);
|
|
279
|
+
return { name, status: 'started' };
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
Logger.warn(`Failed to start worker "${name}"`, error);
|
|
283
|
+
return { name, status: 'failed' };
|
|
284
|
+
}
|
|
285
|
+
}));
|
|
286
|
+
const started = results.filter((result) => result.status === 'started').length;
|
|
287
|
+
const skipped = results.filter((result) => result.status === 'skipped').length;
|
|
288
|
+
const failed = results.filter((result) => result.status === 'failed').length;
|
|
289
|
+
Logger.info('Worker start-all summary', {
|
|
290
|
+
total: eligibleWorkers.length,
|
|
291
|
+
started,
|
|
292
|
+
skipped,
|
|
293
|
+
failed,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
Logger.error('worker:start-all command failed', error);
|
|
298
|
+
process.exit(1);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
const cmd = BaseCommand.create({
|
|
302
|
+
name: 'worker:start-all',
|
|
303
|
+
description: 'Start all persisted workers',
|
|
304
|
+
execute: async () => ext(),
|
|
305
|
+
});
|
|
306
|
+
return cmd;
|
|
307
|
+
};
|
|
176
308
|
/**
|
|
177
309
|
* Worker Stop Command
|
|
178
310
|
*/
|
|
@@ -238,8 +370,9 @@ const createWorkerSummaryCommand = () => {
|
|
|
238
370
|
const ext = async () => {
|
|
239
371
|
try {
|
|
240
372
|
const workers = (await getWorkerFactory()).list();
|
|
241
|
-
const monitoringSummary = (await getHealthMonitor()).getSummary();
|
|
373
|
+
const monitoringSummary = await (await getHealthMonitor()).getSummary();
|
|
242
374
|
const resourceUsage = (await getResourceMonitor()).getCurrentUsage('system');
|
|
375
|
+
const statuses = normalizeHealthStatuses(monitoringSummary);
|
|
243
376
|
console.log(`\n=== Worker System Summary ===\n`);
|
|
244
377
|
console.log(`Total Workers: ${workers.length}`);
|
|
245
378
|
console.log(`\nHealth Overview:`);
|
|
@@ -249,8 +382,8 @@ const createWorkerSummaryCommand = () => {
|
|
|
249
382
|
unhealthy: 0,
|
|
250
383
|
critical: 0,
|
|
251
384
|
};
|
|
252
|
-
|
|
253
|
-
healthCounts[
|
|
385
|
+
statuses.forEach((status) => {
|
|
386
|
+
healthCounts[status]++;
|
|
254
387
|
});
|
|
255
388
|
console.log(` Healthy: ${healthCounts.healthy}`);
|
|
256
389
|
console.log(` Degraded: ${healthCounts.degraded}`);
|
|
@@ -282,6 +415,7 @@ export const WorkerCommands = {
|
|
|
282
415
|
createWorkerListCommand,
|
|
283
416
|
createWorkerStatusCommand,
|
|
284
417
|
createWorkerStartCommand,
|
|
418
|
+
createWorkerStartAllCommand,
|
|
285
419
|
createWorkerStopCommand,
|
|
286
420
|
createWorkerRestartCommand,
|
|
287
421
|
createWorkerSummaryCommand,
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export { AddCommand } from '../commands/AddCommand';
|
|
5
5
|
export { BroadcastWorkCommand } from '../commands/BroadcastWorkCommand';
|
|
6
6
|
export { ConfigCommand } from '../commands/ConfigCommand';
|
|
7
|
+
export { ContainerWorkersCommand } from '../commands/ContainerWorkersCommand';
|
|
7
8
|
export { AddMigrationCommand, CreateCommand, CreateMigrationCommand, } from '../commands/CreateCommand';
|
|
8
9
|
export { DebugCommand } from '../commands/DebugCommand';
|
|
9
10
|
export { JwtDevCommand } from '../commands/JwtDevCommand';
|
|
@@ -16,6 +17,7 @@ export { NewCommand } from '../commands/NewCommand';
|
|
|
16
17
|
export { NotificationWorkCommand } from '../commands/NotificationWorkCommand';
|
|
17
18
|
export { PrepareCommand } from '../commands/PrepareCommand';
|
|
18
19
|
export { QueueCommand } from '../commands/QueueCommand';
|
|
20
|
+
export { QueueRecoveryCommand } from '../commands/QueueRecoveryCommand';
|
|
19
21
|
export { ResourceControlCommand } from '../commands/ResourceControlCommand';
|
|
20
22
|
export { RoutesCommand } from '../commands/RoutesCommand';
|
|
21
23
|
export { SecretsCommand } from '../commands/SecretsCommand';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export { AddCommand } from '../commands/AddCommand.js';
|
|
5
5
|
export { BroadcastWorkCommand } from '../commands/BroadcastWorkCommand.js';
|
|
6
6
|
export { ConfigCommand } from '../commands/ConfigCommand.js';
|
|
7
|
+
export { ContainerWorkersCommand } from '../commands/ContainerWorkersCommand.js';
|
|
7
8
|
export { AddMigrationCommand, CreateCommand, CreateMigrationCommand, } from '../commands/CreateCommand.js';
|
|
8
9
|
export { DebugCommand } from '../commands/DebugCommand.js';
|
|
9
10
|
export { JwtDevCommand } from '../commands/JwtDevCommand.js';
|
|
@@ -16,6 +17,7 @@ export { NewCommand } from '../commands/NewCommand.js';
|
|
|
16
17
|
export { NotificationWorkCommand } from '../commands/NotificationWorkCommand.js';
|
|
17
18
|
export { PrepareCommand } from '../commands/PrepareCommand.js';
|
|
18
19
|
export { QueueCommand } from '../commands/QueueCommand.js';
|
|
20
|
+
export { QueueRecoveryCommand } from '../commands/QueueRecoveryCommand.js';
|
|
19
21
|
export { ResourceControlCommand } from '../commands/ResourceControlCommand.js';
|
|
20
22
|
export { RoutesCommand } from '../commands/RoutesCommand.js';
|
|
21
23
|
export { SecretsCommand } from '../commands/SecretsCommand.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const createDenoRunnerSource: (startModuleSpecifier: string) => string;
|
|
2
|
+
export declare const createLambdaRunnerSource: (startModuleSpecifier: string) => string;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/runner/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/runner/index.ts"],"names":[],"mappings":"AAoJA,eAAO,MAAM,sBAAsB,GAAI,sBAAsB,MAAM,KAAG,MAErE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,sBAAsB,MAAM,KAAG,MAEvE,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
const quote = (value) => JSON.stringify(value);
|
|
2
|
+
const START_MODULE_PLACEHOLDER = '__ZINTRUST_START_MODULE__';
|
|
3
|
+
const injectStartModuleSpecifier = (template, startModuleSpecifier) => {
|
|
4
|
+
return template.replaceAll(START_MODULE_PLACEHOLDER, quote(startModuleSpecifier));
|
|
5
|
+
};
|
|
6
|
+
const denoRunnerTemplate = [
|
|
2
7
|
"import http from 'node:http';",
|
|
3
|
-
|
|
8
|
+
`import { deno } from ${START_MODULE_PLACEHOLDER};`,
|
|
4
9
|
'',
|
|
5
10
|
"const port = Number.parseInt(process.env.PORT ?? '3000', 10) || 3000;",
|
|
6
11
|
"const host = process.env.HOST ?? 'localhost';",
|
|
@@ -55,9 +60,9 @@ export const DENO_RUNNER_SOURCE = [
|
|
|
55
60
|
'});',
|
|
56
61
|
'',
|
|
57
62
|
].join('\n');
|
|
58
|
-
|
|
63
|
+
const lambdaRunnerTemplate = [
|
|
59
64
|
"import http from 'node:http';",
|
|
60
|
-
|
|
65
|
+
`import { handler as lambdaHandler } from ${START_MODULE_PLACEHOLDER};`,
|
|
61
66
|
'',
|
|
62
67
|
"const port = Number.parseInt(process.env.PORT ?? '3000', 10) || 3000;",
|
|
63
68
|
"const host = process.env.HOST ?? 'localhost';",
|
|
@@ -137,3 +142,9 @@ export const LAMBDA_RUNNER_SOURCE = [
|
|
|
137
142
|
'});',
|
|
138
143
|
'',
|
|
139
144
|
].join('\n');
|
|
145
|
+
export const createDenoRunnerSource = (startModuleSpecifier) => {
|
|
146
|
+
return injectStartModuleSpecifier(denoRunnerTemplate, startModuleSpecifier);
|
|
147
|
+
};
|
|
148
|
+
export const createLambdaRunnerSource = (startModuleSpecifier) => {
|
|
149
|
+
return injectStartModuleSpecifier(lambdaRunnerTemplate, startModuleSpecifier);
|
|
150
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScheduleCliSupport.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/schedule/ScheduleCliSupport.ts"],"names":[],"mappings":"AAwDA,eAAO,MAAM,kBAAkB;mBACR,OAAO,CAAC,IAAI,CAAC;gCA1BG,OAAO,CAAC,IAAI,CAAC;EAmClD,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { databaseConfig } from '../../../config/database.js';
|
|
2
|
+
import { registerDatabasesFromRuntimeConfig } from '../../../orm/DatabaseRuntimeRegistration.js';
|
|
3
|
+
import { SchedulerRuntime } from '../../../scheduler/SchedulerRuntime.js';
|
|
4
|
+
const isSchedule = (value) => {
|
|
5
|
+
if (value === undefined || value === null || typeof value !== 'object')
|
|
6
|
+
return false;
|
|
7
|
+
return 'name' in value && typeof value.name === 'string';
|
|
8
|
+
};
|
|
9
|
+
const loadScheduleModules = async () => {
|
|
10
|
+
const coreSchedules = await import('../../../schedules/index.js');
|
|
11
|
+
let appSchedules = {};
|
|
12
|
+
try {
|
|
13
|
+
appSchedules = (await import('../../../../app/Schedules/index.js'));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
appSchedules = {};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
core: Object.values(coreSchedules).filter(isSchedule),
|
|
20
|
+
app: Object.values(appSchedules).filter(isSchedule),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const shutdownCliResources = async () => {
|
|
24
|
+
try {
|
|
25
|
+
const mod = await import('../../../orm/ConnectionManager.js');
|
|
26
|
+
await mod.ConnectionManager.shutdownIfInitialized();
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// best-effort
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const mod = await import('../../../orm/Database.js');
|
|
33
|
+
await mod.resetDatabase();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// best-effort
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const mod = (await import('../../../tools/queue/LockProvider.js'));
|
|
40
|
+
await mod.closeLockProvider?.();
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// best-effort
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export const ScheduleCliSupport = Object.freeze({
|
|
47
|
+
async registerAll() {
|
|
48
|
+
registerDatabasesFromRuntimeConfig(databaseConfig);
|
|
49
|
+
const modules = await loadScheduleModules();
|
|
50
|
+
SchedulerRuntime.registerMany(modules.core, 'core');
|
|
51
|
+
SchedulerRuntime.registerMany(modules.app, 'app');
|
|
52
|
+
},
|
|
53
|
+
shutdownCliResources,
|
|
54
|
+
});
|
|
55
|
+
export default ScheduleCliSupport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigManager.d.ts","sourceRoot":"","sources":["../../../../src/cli/config/ConfigManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ConfigManager.d.ts","sourceRoot":"","sources":["../../../../src/cli/config/ConfigManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAgB9D,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,SAAS,IAAI,aAAa,CAAC;IAC3B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,MAAM,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IAC7C,MAAM,IAAI,MAAM,CAAC;IACjB,UAAU,IAAI,MAAM,EAAE,CAAC;CACxB;AAqHD;;;;GAIG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;wBACgB,MAAM,GAAgC,cAAc;IAqCvE;;OAEG;6BAC4B,OAAO,CAAC,IAAI,CAAC;IAU5C;;OAEG;uBACsB,OAAO,CAAC,cAAc,CAAC;IAOhD;;OAEG;wBACuB,OAAO,CAAC,cAAc,CAAC;EAKjD,CAAC"}
|