@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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { appConfig } from '../../config/index.js';
|
|
2
|
+
import Logger from '../../config/logger.js';
|
|
3
|
+
import * as path from '../../node-singletons/path.js';
|
|
4
|
+
import { pathToFileURL } from '../../node-singletons/url.js';
|
|
5
|
+
import { detectRuntime } from '../../runtime/detectRuntime.js';
|
|
6
|
+
const isCloudflare = detectRuntime().isCloudflare;
|
|
7
|
+
export const isCompiledJsModule = () => {
|
|
8
|
+
// When running from dist, this module is compiled to .js and Node ESM resolution
|
|
9
|
+
// requires explicit file extensions for relative imports.
|
|
10
|
+
const metaUrl = typeof import.meta?.url === 'string' ? import.meta.url : '';
|
|
11
|
+
return metaUrl.endsWith('.js');
|
|
12
|
+
};
|
|
13
|
+
export const tryImportOptional = async (modulePath) => {
|
|
14
|
+
try {
|
|
15
|
+
return (await import(modulePath));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const tryImportOptionalR = async (modulePath) => {
|
|
22
|
+
try {
|
|
23
|
+
return (await import(modulePath));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
Logger.error(`Error importing module ${modulePath}:`, error);
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const tryImportRoutesFromAppBase = async (resolvedBasePath) => {
|
|
31
|
+
if (resolvedBasePath === '')
|
|
32
|
+
return undefined;
|
|
33
|
+
const routeCandidates = appConfig.isDevelopment()
|
|
34
|
+
? [
|
|
35
|
+
path.join(resolvedBasePath, 'routes', 'api.ts'),
|
|
36
|
+
path.join(resolvedBasePath, 'routes', 'api.js'),
|
|
37
|
+
]
|
|
38
|
+
: [
|
|
39
|
+
path.join(resolvedBasePath, 'routes', 'api.js'),
|
|
40
|
+
path.join(resolvedBasePath, 'dist', 'routes', 'api.js'),
|
|
41
|
+
path.join(resolvedBasePath, 'routes', 'api.ts'),
|
|
42
|
+
path.join(resolvedBasePath, 'dist', 'routes', 'api.ts'),
|
|
43
|
+
];
|
|
44
|
+
for (const routePath of routeCandidates) {
|
|
45
|
+
try {
|
|
46
|
+
const url = pathToFileURL(routePath).href;
|
|
47
|
+
// eslint-disable-next-line no-await-in-loop
|
|
48
|
+
return (await import(url));
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// try next candidate
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
};
|
|
56
|
+
const registerAppRoutes = async (resolvedBasePath, router) => {
|
|
57
|
+
const mod = await tryImportRoutesFromAppBase(resolvedBasePath);
|
|
58
|
+
if (mod && typeof mod.registerRoutes === 'function') {
|
|
59
|
+
mod.registerRoutes(router);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const registerFrameworkRoutes = async (resolvedBasePath, router) => {
|
|
63
|
+
const frameworkRoutes = await tryImportRoutesFromAppBase(resolvedBasePath);
|
|
64
|
+
if (frameworkRoutes && typeof frameworkRoutes.registerRoutes === 'function') {
|
|
65
|
+
frameworkRoutes.registerRoutes(router);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const registerGlobalRoutes = (router) => {
|
|
69
|
+
const globalRoutes = globalThis.__zintrustRoutes;
|
|
70
|
+
if (globalRoutes && typeof globalRoutes.registerRoutes === 'function') {
|
|
71
|
+
globalRoutes.registerRoutes(router);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
Logger.warn('No app routes found and framework routes are unavailable. Ensure routes/api.ts exists in the project.');
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
export const registerMasterRoutes = async (resolvedBasePath, router) => {
|
|
78
|
+
try {
|
|
79
|
+
if (isCloudflare) {
|
|
80
|
+
registerGlobalRoutes(router);
|
|
81
|
+
}
|
|
82
|
+
if (!isCloudflare) {
|
|
83
|
+
await registerAppRoutes(resolvedBasePath, router);
|
|
84
|
+
}
|
|
85
|
+
if (router.routes.length === 0) {
|
|
86
|
+
await registerFrameworkRoutes(resolvedBasePath, router);
|
|
87
|
+
}
|
|
88
|
+
// Always register core framework routes (health, metrics, doc) after app routes
|
|
89
|
+
// This ensures app can override but core routes always exist
|
|
90
|
+
const { registerCoreRoutes } = await import('../../routes/CoreRoutes.js');
|
|
91
|
+
registerCoreRoutes(router);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
Logger.error('Failed to register routes:', error);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IShutdownManager } from './type';
|
|
2
|
+
import type { IRouter } from '../../index.js';
|
|
3
|
+
export declare const registerFrameworkShutdownHooks: (shutdownManager: IShutdownManager) => void;
|
|
4
|
+
export declare const createLifecycle: (params: {
|
|
5
|
+
environment: string;
|
|
6
|
+
resolvedBasePath: string;
|
|
7
|
+
router: IRouter;
|
|
8
|
+
shutdownManager: IShutdownManager;
|
|
9
|
+
getBooted: () => boolean;
|
|
10
|
+
setBooted: (value: boolean) => void;
|
|
11
|
+
}) => {
|
|
12
|
+
boot: () => Promise<void>;
|
|
13
|
+
shutdown: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA+I9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA4BlF,CAAC;AAyLF,eAAO,MAAM,eAAe,GAAI,QAAQ;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,gBAAgB,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,KAAG;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAuE7D,CAAC"}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import * as RuntimeConfig from '../../config/index.js';
|
|
2
|
+
import { StartupHealthChecks } from '../../health/StartupHealthChecks.js';
|
|
3
|
+
import { loadQueueMonitorModule, loadWorkersModule } from '../../runtime/WorkersModule.js';
|
|
4
|
+
import { registerCachesFromRuntimeConfig } from '../../cache/CacheRuntimeRegistration.js';
|
|
5
|
+
import broadcastConfig from '../../config/broadcast.js';
|
|
6
|
+
import { Cloudflare } from '../../config/cloudflare.js';
|
|
7
|
+
import { FeatureFlags } from '../../config/features.js';
|
|
8
|
+
import { Logger } from '../../config/logger.js';
|
|
9
|
+
import notificationConfig from '../../config/notification.js';
|
|
10
|
+
import { StartupConfigValidator } from '../../config/StartupConfigValidator.js';
|
|
11
|
+
import { existsSync } from '../../node-singletons/fs.js';
|
|
12
|
+
import * as path from '../../node-singletons/path.js';
|
|
13
|
+
import { pathToFileURL } from '../../node-singletons/url.js';
|
|
14
|
+
import { registerDatabasesFromRuntimeConfig } from '../../orm/DatabaseRuntimeRegistration.js';
|
|
15
|
+
import { registerMasterRoutes, tryImportOptional } from './registerRoute.js';
|
|
16
|
+
import { registerWorkerShutdownHook } from './worker.js';
|
|
17
|
+
import { StartupConfigFile, StartupConfigFileRegistry } from '../../runtime/StartupConfigFileRegistry.js';
|
|
18
|
+
import { registerBroadcastersFromRuntimeConfig } from '../../tools/broadcast/BroadcastRuntimeRegistration.js';
|
|
19
|
+
import { registerNotificationChannelsFromRuntimeConfig } from '../../tools/notification/NotificationRuntimeRegistration.js';
|
|
20
|
+
import { registerQueuesFromRuntimeConfig } from '../../tools/queue/QueueRuntimeRegistration.js';
|
|
21
|
+
import { registerDisksFromRuntimeConfig } from '../../tools/storage/StorageRuntimeRegistration.js';
|
|
22
|
+
const loadRuntimeQueueConfig = async () => {
|
|
23
|
+
try {
|
|
24
|
+
const modulePath = '@runtime-config/queue';
|
|
25
|
+
const loaded = (await import(modulePath));
|
|
26
|
+
return loaded.default ?? queueConfig ?? undefined;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return queueConfig ?? undefined;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const readRuntimeConfig = (key, fallback) => {
|
|
33
|
+
try {
|
|
34
|
+
const value = RuntimeConfig[key];
|
|
35
|
+
return (value ?? fallback);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return fallback;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const appConfig = readRuntimeConfig('appConfig', { port: 7777, dockerWorker: false });
|
|
42
|
+
const cacheConfig = readRuntimeConfig('cacheConfig', RuntimeConfig.cacheConfig);
|
|
43
|
+
const databaseConfig = readRuntimeConfig('databaseConfig', {
|
|
44
|
+
default: 'sqlite',
|
|
45
|
+
connections: {},
|
|
46
|
+
});
|
|
47
|
+
const queueConfig = readRuntimeConfig('queueConfig', RuntimeConfig.queueConfig);
|
|
48
|
+
const storageConfig = readRuntimeConfig('storageConfig', RuntimeConfig.storageConfig);
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
50
|
+
const dbLoader = async () => {
|
|
51
|
+
registerDatabasesFromRuntimeConfig(databaseConfig);
|
|
52
|
+
};
|
|
53
|
+
const queuesLoader = async () => {
|
|
54
|
+
await registerQueuesFromRuntimeConfig(queueConfig);
|
|
55
|
+
};
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
57
|
+
const cachesLoader = async () => {
|
|
58
|
+
registerCachesFromRuntimeConfig(cacheConfig);
|
|
59
|
+
};
|
|
60
|
+
const registerFromRuntimeConfig = async () => {
|
|
61
|
+
await dbLoader();
|
|
62
|
+
await queuesLoader();
|
|
63
|
+
await cachesLoader();
|
|
64
|
+
registerBroadcastersFromRuntimeConfig({
|
|
65
|
+
default: broadcastConfig.default,
|
|
66
|
+
drivers: broadcastConfig.drivers,
|
|
67
|
+
});
|
|
68
|
+
registerDisksFromRuntimeConfig(storageConfig);
|
|
69
|
+
registerNotificationChannelsFromRuntimeConfig({
|
|
70
|
+
default: notificationConfig.default,
|
|
71
|
+
drivers: notificationConfig.drivers,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Helper: Register ConnectionManager shutdown hook
|
|
76
|
+
*/
|
|
77
|
+
const registerConnectionManagerHook = (shutdownManager) => {
|
|
78
|
+
shutdownManager.add(async () => {
|
|
79
|
+
try {
|
|
80
|
+
const mod = await import('../../orm/ConnectionManager.js');
|
|
81
|
+
await mod.ConnectionManager.shutdownIfInitialized();
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
/* ignore import failures in restrictive runtimes */
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Helper: Register Database reset hook
|
|
90
|
+
*/
|
|
91
|
+
const registerDatabaseResetHook = (shutdownManager) => {
|
|
92
|
+
shutdownManager.add(async () => {
|
|
93
|
+
try {
|
|
94
|
+
const mod = await import('../../orm/Database.js');
|
|
95
|
+
mod.resetDatabase();
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
/* ignore import failures in restrictive runtimes */
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Helper: Register generic reset hook for modules with reset() method
|
|
104
|
+
*/
|
|
105
|
+
const registerResetHook = (shutdownManager, modulePath, exportName) => {
|
|
106
|
+
shutdownManager.add(async () => {
|
|
107
|
+
try {
|
|
108
|
+
const mod = (await import(modulePath));
|
|
109
|
+
const resetModule = mod[exportName];
|
|
110
|
+
if (resetModule?.reset) {
|
|
111
|
+
resetModule.reset();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
/* ignore import failures in restrictive runtimes */
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Helper: Register FileLogWriter flush hook
|
|
121
|
+
*/
|
|
122
|
+
const registerFileLogFlushHook = (shutdownManager) => {
|
|
123
|
+
shutdownManager.add(async () => {
|
|
124
|
+
try {
|
|
125
|
+
const mod = await import('../../config/FileLogWriter.js');
|
|
126
|
+
mod.FileLogWriter.flush();
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
/* ignore import failures in restrictive runtimes */
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
export const registerFrameworkShutdownHooks = (shutdownManager) => {
|
|
134
|
+
// Register framework-level shutdown hooks for long-lived resources
|
|
135
|
+
registerConnectionManagerHook(shutdownManager);
|
|
136
|
+
// Ensure worker management system is asked to shutdown BEFORE databases are reset
|
|
137
|
+
registerWorkerShutdownHook(shutdownManager);
|
|
138
|
+
// Database and cache reset
|
|
139
|
+
registerDatabaseResetHook(shutdownManager);
|
|
140
|
+
registerResetHook(shutdownManager, '@cache/Cache', 'Cache');
|
|
141
|
+
// File logging
|
|
142
|
+
registerFileLogFlushHook(shutdownManager);
|
|
143
|
+
// Registry resets
|
|
144
|
+
registerResetHook(shutdownManager, '@broadcast/BroadcastRegistry', 'BroadcastRegistry');
|
|
145
|
+
registerResetHook(shutdownManager, '@storage/StorageDiskRegistry', 'StorageDiskRegistry');
|
|
146
|
+
registerResetHook(shutdownManager, '@notification/NotificationChannelRegistry', 'NotificationChannelRegistry');
|
|
147
|
+
registerResetHook(shutdownManager, '@mail/MailDriverRegistry', 'MailDriverRegistry');
|
|
148
|
+
registerResetHook(shutdownManager, '@tools/queue/Queue', 'Queue');
|
|
149
|
+
};
|
|
150
|
+
const initializeArtifactDirectories = async (resolvedBasePath) => {
|
|
151
|
+
if (resolvedBasePath === '')
|
|
152
|
+
return;
|
|
153
|
+
if (typeof process === 'undefined')
|
|
154
|
+
return;
|
|
155
|
+
const globalAny = globalThis;
|
|
156
|
+
if (globalAny.CF !== undefined)
|
|
157
|
+
return;
|
|
158
|
+
if (typeof globalAny.WebSocketPair === 'function')
|
|
159
|
+
return;
|
|
160
|
+
if (globalAny.caches !== undefined)
|
|
161
|
+
return;
|
|
162
|
+
let nodeFs;
|
|
163
|
+
try {
|
|
164
|
+
nodeFs = await import('../../node-singletons/fs.js');
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const dirs = ['logs', 'storage', 'tmp'];
|
|
170
|
+
for (const dir of dirs) {
|
|
171
|
+
const fullPath = path.join(resolvedBasePath, dir);
|
|
172
|
+
try {
|
|
173
|
+
if (!nodeFs.existsSync(fullPath)) {
|
|
174
|
+
nodeFs.mkdirSync(fullPath, { recursive: true });
|
|
175
|
+
Logger.info(`✓ Created directory: ${dir}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
Logger.warn(`Failed to create ${dir} directory`, error);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const extractRedisConfigFromQueueConfig = () => {
|
|
184
|
+
const redisConfig = queueConfig.drivers?.redis ?? {};
|
|
185
|
+
const redisHost = typeof redisConfig['host'] === 'string' ? redisConfig['host'] : '127.0.0.1';
|
|
186
|
+
const redisPort = typeof redisConfig['port'] === 'number' && Number.isFinite(redisConfig['port'])
|
|
187
|
+
? redisConfig['port']
|
|
188
|
+
: 6379;
|
|
189
|
+
const redisPassword = typeof redisConfig['password'] === 'string' ? redisConfig['password'] : '';
|
|
190
|
+
const redisDb = typeof redisConfig['database'] === 'number' && Number.isFinite(redisConfig['database'])
|
|
191
|
+
? redisConfig['database']
|
|
192
|
+
: 0;
|
|
193
|
+
return {
|
|
194
|
+
host: redisHost,
|
|
195
|
+
port: redisPort,
|
|
196
|
+
password: redisPassword,
|
|
197
|
+
db: redisDb,
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
const loadAndValidateQueueMonitorModule = async () => {
|
|
201
|
+
let workersModule;
|
|
202
|
+
try {
|
|
203
|
+
workersModule = (await loadQueueMonitorModule());
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
Logger.warn('Failed to load Queue Monitor module', error);
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
if (!workersModule || !('QueueMonitor' in workersModule)) {
|
|
210
|
+
Logger.warn('Queue Monitor module not available');
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
const queueMonitorModule = workersModule;
|
|
214
|
+
const { QueueMonitor } = queueMonitorModule;
|
|
215
|
+
if (QueueMonitor === undefined || typeof QueueMonitor.create !== 'function') {
|
|
216
|
+
Logger.warn('Queue Monitor module does not expose QueueMonitor.create');
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
return queueMonitorModule;
|
|
220
|
+
};
|
|
221
|
+
const initializeQueueMonitor = async (router) => {
|
|
222
|
+
const runQueueConfig = await loadRuntimeQueueConfig();
|
|
223
|
+
const monitorConfig = runQueueConfig?.monitor;
|
|
224
|
+
if (monitorConfig === undefined) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (monitorConfig.enabled === false) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const queueMonitorModule = await loadAndValidateQueueMonitorModule();
|
|
231
|
+
if (queueMonitorModule === null) {
|
|
232
|
+
Logger.debug('Queue Monitor is enabled in configuration but module failed to load or is invalid. Skipping Queue Monitor initialization.');
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const redisConfig = extractRedisConfigFromQueueConfig();
|
|
236
|
+
const { QueueMonitor } = queueMonitorModule;
|
|
237
|
+
const monitor = QueueMonitor.create({
|
|
238
|
+
...monitorConfig,
|
|
239
|
+
redis: redisConfig,
|
|
240
|
+
});
|
|
241
|
+
try {
|
|
242
|
+
monitor.registerRoutes(router);
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
Logger.error('Failed to register Queue Monitor routes', error);
|
|
246
|
+
}
|
|
247
|
+
Logger.info(`Queue Monitor routes registered at http://127.0.0.1:${appConfig.port}${monitorConfig.basePath ?? ''}`);
|
|
248
|
+
Logger.info(`Queue Monitor enqueue endpoint at http://127.0.0.1:${appConfig.port}/test/enqueue`);
|
|
249
|
+
};
|
|
250
|
+
const initializeWorkers = async (router) => {
|
|
251
|
+
const workers = await loadWorkersModule();
|
|
252
|
+
if (workers?.WorkerInit !== undefined && typeof workers.registerWorkerRoutes === 'function') {
|
|
253
|
+
workers.registerWorkerRoutes(router, undefined, { middleware: undefined });
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const resolveLocalQueueRedisEntry = () => {
|
|
257
|
+
if (typeof process === 'undefined' || typeof process.cwd !== 'function')
|
|
258
|
+
return null;
|
|
259
|
+
const cwd = process.cwd();
|
|
260
|
+
if (cwd.trim() === '')
|
|
261
|
+
return null;
|
|
262
|
+
const localEntry = path.join(cwd, 'dist', 'packages', 'queue-redis', 'src', 'index.js');
|
|
263
|
+
return existsSync(localEntry) ? localEntry : null;
|
|
264
|
+
};
|
|
265
|
+
const loadQueueHttpGatewayModule = async () => {
|
|
266
|
+
try {
|
|
267
|
+
return (await import('@zintrust/queue-redis'));
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
const localEntry = resolveLocalQueueRedisEntry();
|
|
271
|
+
if (localEntry === null)
|
|
272
|
+
return undefined;
|
|
273
|
+
const url = pathToFileURL(localEntry).href;
|
|
274
|
+
return (await import(url));
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
const initializeQueueHttpGateway = async (router) => {
|
|
278
|
+
try {
|
|
279
|
+
const module = await loadQueueHttpGatewayModule();
|
|
280
|
+
if (module === undefined) {
|
|
281
|
+
Logger.warn('Queue HTTP gateway module is unavailable (@zintrust/queue-redis not found)');
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (module.QueueHttpGateway === undefined ||
|
|
285
|
+
typeof module.QueueHttpGateway.create !== 'function') {
|
|
286
|
+
Logger.warn('Queue HTTP gateway module does not expose QueueHttpGateway.create');
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
module.QueueHttpGateway.create().registerRoutes(router);
|
|
290
|
+
Logger.info('Queue HTTP gateway route registered at /api/_sys/queue/rpc');
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
Logger.warn('Failed to register Queue HTTP gateway routes', error);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
const initializeScheduleHttpGateway = async (router) => {
|
|
297
|
+
try {
|
|
298
|
+
const { ScheduleHttpGateway } = await import('../../scheduler/ScheduleHttpGateway.js');
|
|
299
|
+
ScheduleHttpGateway.create().registerRoutes(router);
|
|
300
|
+
Logger.info('Schedule HTTP gateway route registered at /api/_sys/schedule/rpc');
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
Logger.warn('Failed to register Schedule HTTP gateway routes', error);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
export const createLifecycle = (params) => {
|
|
307
|
+
const boot = async () => {
|
|
308
|
+
if (params.getBooted())
|
|
309
|
+
return;
|
|
310
|
+
Logger.info(`🚀 Booting ZinTrust Application in ${params.environment} mode...`);
|
|
311
|
+
if (params.environment === 'development') {
|
|
312
|
+
// Clear config registry cache to ensure fresh config loading in watch mode
|
|
313
|
+
// This fixes the issue where config/middleware.ts changes are ignored in watch mode
|
|
314
|
+
StartupConfigFileRegistry.clear();
|
|
315
|
+
}
|
|
316
|
+
StartupConfigValidator.assertValid();
|
|
317
|
+
// Preload project-owned config overrides that must be available synchronously.
|
|
318
|
+
await StartupConfigFileRegistry.preload([
|
|
319
|
+
StartupConfigFile.Middleware,
|
|
320
|
+
StartupConfigFile.Cache,
|
|
321
|
+
StartupConfigFile.Database,
|
|
322
|
+
StartupConfigFile.Queue,
|
|
323
|
+
StartupConfigFile.Storage,
|
|
324
|
+
StartupConfigFile.Mail,
|
|
325
|
+
StartupConfigFile.Broadcast,
|
|
326
|
+
StartupConfigFile.Notification,
|
|
327
|
+
]);
|
|
328
|
+
FeatureFlags.initialize();
|
|
329
|
+
await StartupHealthChecks.assertHealthy();
|
|
330
|
+
await registerFromRuntimeConfig();
|
|
331
|
+
await initializeArtifactDirectories(params.resolvedBasePath);
|
|
332
|
+
await registerMasterRoutes(params.resolvedBasePath, params.router);
|
|
333
|
+
if (Cloudflare.getWorkersEnv() === null && appConfig.dockerWorker === false) {
|
|
334
|
+
await initializeWorkers(params.router);
|
|
335
|
+
await initializeQueueMonitor(params.router);
|
|
336
|
+
await initializeQueueHttpGateway(params.router);
|
|
337
|
+
await initializeScheduleHttpGateway(params.router);
|
|
338
|
+
}
|
|
339
|
+
// Register service providers
|
|
340
|
+
// Bootstrap services
|
|
341
|
+
Logger.info('✅ Application booted successfully');
|
|
342
|
+
params.setBooted(true);
|
|
343
|
+
};
|
|
344
|
+
const shutdown = async () => {
|
|
345
|
+
Logger.info('🛑 Shutting down application...');
|
|
346
|
+
try {
|
|
347
|
+
await params.shutdownManager.run();
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
Logger.error('Shutdown hook failed:', error);
|
|
351
|
+
}
|
|
352
|
+
// Ensure FileLogWriter.flush is attempted even if dynamic registration failed.
|
|
353
|
+
try {
|
|
354
|
+
const fileLogWriter = await tryImportOptional('@config/FileLogWriter');
|
|
355
|
+
fileLogWriter?.FileLogWriter?.flush?.();
|
|
356
|
+
}
|
|
357
|
+
catch {
|
|
358
|
+
/* best-effort */
|
|
359
|
+
}
|
|
360
|
+
params.setBooted(false);
|
|
361
|
+
Logger.info('✅ Application shut down successfully');
|
|
362
|
+
};
|
|
363
|
+
return { boot, shutdown };
|
|
364
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { IMiddlewareStack } from '../../middleware';
|
|
2
|
+
import type { IServiceContainer } from '../../container/ServiceContainer';
|
|
3
|
+
import type { IRouter } from '../../routes/Router';
|
|
4
|
+
export interface IApplication {
|
|
5
|
+
boot(): Promise<void>;
|
|
6
|
+
shutdown(): Promise<void>;
|
|
7
|
+
isBooted(): boolean;
|
|
8
|
+
isDevelopment(): boolean;
|
|
9
|
+
isProduction(): boolean;
|
|
10
|
+
isTesting(): boolean;
|
|
11
|
+
getEnvironment(): string;
|
|
12
|
+
getRouter(): IRouter;
|
|
13
|
+
getContainer(): IServiceContainer;
|
|
14
|
+
getMiddlewareStack(): IMiddlewareStack;
|
|
15
|
+
getBasePath(): string;
|
|
16
|
+
}
|
|
17
|
+
export type RoutesModule = {
|
|
18
|
+
registerRoutes?: (r: IRouter) => void;
|
|
19
|
+
};
|
|
20
|
+
export type ShutdownHook = () => void | Promise<void>;
|
|
21
|
+
export interface IShutdownManager {
|
|
22
|
+
add(hook: ShutdownHook): void;
|
|
23
|
+
run(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,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;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/worker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD;;GAEG;AACH,eAAO,MAAM,0BAA0B,GACrC,iBAAiB,gBAAgB,KAChC,OAAO,CAAC,IAAI,CA0Cd,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { appConfig } from '../../config/app.js';
|
|
2
|
+
import { Env } from '../../config/env.js';
|
|
3
|
+
import { loadWorkersModule } from '../../runtime/WorkersModule.js';
|
|
4
|
+
/**
|
|
5
|
+
* Helper: Register Worker management system shutdown hook
|
|
6
|
+
*/
|
|
7
|
+
export const registerWorkerShutdownHook = async (shutdownManager) => {
|
|
8
|
+
if (Env.getBool('WORKER_SHUTDOWN_ON_APP_EXIT', true) === false ||
|
|
9
|
+
appConfig.dockerWorker === true) {
|
|
10
|
+
return Promise.resolve(); // NOSONAR - Skip worker shutdown hook registration
|
|
11
|
+
}
|
|
12
|
+
// Ensure worker management system is asked to shutdown BEFORE databases are reset.
|
|
13
|
+
// This prevents workers from trying to access DB connections that have already
|
|
14
|
+
// been closed by subsequent shutdown hooks.
|
|
15
|
+
shutdownManager.add(async () => {
|
|
16
|
+
try {
|
|
17
|
+
const mod = (await loadWorkersModule());
|
|
18
|
+
const isShuttingDown = typeof mod.WorkerShutdown.isShuttingDown === 'function'
|
|
19
|
+
? mod.WorkerShutdown.isShuttingDown()
|
|
20
|
+
: (mod.WorkerShutdown.getShutdownState?.().isShuttingDown ?? false);
|
|
21
|
+
const completedAt = mod.WorkerShutdown.getShutdownState?.().completedAt ?? null;
|
|
22
|
+
if (isShuttingDown || completedAt !== null)
|
|
23
|
+
return;
|
|
24
|
+
await mod.WorkerShutdown.shutdown({
|
|
25
|
+
signal: 'APP_SHUTDOWN',
|
|
26
|
+
timeout: 5000,
|
|
27
|
+
forceExit: false,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
/* ignore import failures in restrictive runtimes */
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return Promise.resolve(); // NOSONAR
|
|
35
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KVRemoteDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVRemoteDriver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"KVRemoteDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVRemoteDriver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAiCtD,eAAO,MAAM,cAAc;cACf,WAAW;EAkErB,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -6,13 +6,25 @@
|
|
|
6
6
|
import { RemoteSignedJson } from '../../common/RemoteSignedJson.js';
|
|
7
7
|
import { Env } from '../../config/env.js';
|
|
8
8
|
import { Logger } from '../../config/logger.js';
|
|
9
|
+
const resolveSigningPrefix = (baseUrl) => {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = new URL(baseUrl);
|
|
12
|
+
const path = parsed.pathname.endsWith('/') ? parsed.pathname.slice(0, -1) : parsed.pathname;
|
|
13
|
+
if (path === '' || path === '/')
|
|
14
|
+
return undefined;
|
|
15
|
+
return path;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
9
21
|
const normalizeNamespace = (defaultNamespace) => defaultNamespace.trim() === '' ? undefined : defaultNamespace;
|
|
10
22
|
export const KVRemoteDriver = Object.freeze({
|
|
11
23
|
create() {
|
|
12
24
|
const settings = {
|
|
13
25
|
baseUrl: Env.get('KV_REMOTE_URL'),
|
|
14
26
|
keyId: Env.get('KV_REMOTE_KEY_ID'),
|
|
15
|
-
secret: Env.get('KV_REMOTE_SECRET'),
|
|
27
|
+
secret: Env.get('KV_REMOTE_SECRET', Env.APP_KEY),
|
|
16
28
|
defaultNamespace: Env.get('KV_REMOTE_NAMESPACE'),
|
|
17
29
|
timeoutMs: Env.getInt('ZT_PROXY_TIMEOUT_MS', Env.REQUEST_TIMEOUT),
|
|
18
30
|
};
|
|
@@ -21,6 +33,7 @@ export const KVRemoteDriver = Object.freeze({
|
|
|
21
33
|
keyId: settings.keyId,
|
|
22
34
|
secret: settings.secret,
|
|
23
35
|
timeoutMs: settings.timeoutMs,
|
|
36
|
+
signaturePathPrefixToStrip: resolveSigningPrefix(settings.baseUrl),
|
|
24
37
|
missingUrlMessage: 'KV remote proxy URL is missing (KV_REMOTE_URL)',
|
|
25
38
|
missingCredentialsMessage: 'KV remote signing credentials are missing (KV_REMOTE_KEY_ID / KV_REMOTE_SECRET)',
|
|
26
39
|
messages: {
|
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;AAiEH,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;AAuPD;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;cACJ,IAAI;EAed,CAAC"}
|