@zintrust/core 0.1.40 → 0.1.41
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 +8 -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 +23 -5
- 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 +353 -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 +82 -34
- package/src/cli/ErrorHandler.js +1 -1
- 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/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 +216 -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/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/QueueRecoveryCommand.d.ts +6 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts.map +1 -0
- package/src/cli/commands/QueueRecoveryCommand.js +513 -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/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/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +3 -0
- 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/utils/EnvFileLoader.js +16 -15
- package/src/cli/workers/QueueWorkRunner.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 +39 -13
- 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/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 +48 -0
- 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 +156 -17
- 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/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 +25 -53
- package/src/index.d.ts.map +1 -1
- package/src/index.js +30 -14
- 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/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/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/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +14 -1
- 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 +143 -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 +147 -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 +35 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts +3 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SqlServerProxyAdapter.js +146 -0
- 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/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 +25 -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/d1/ZintrustD1Proxy.d.ts +2 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -0
- package/src/proxy/d1/ZintrustD1Proxy.js +1 -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/kv/ZintrustKvProxy.d.ts +2 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -0
- package/src/proxy/kv/ZintrustKvProxy.js +1 -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 +14 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -0
- package/src/proxy/mysql/MySqlProxyServer.js +169 -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 +14 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -0
- package/src/proxy/postgres/PostgresProxyServer.js +140 -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 +289 -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 +14 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.js +168 -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/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/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/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/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
- package/src/tools/mail/drivers/Smtp.js +223 -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 +88 -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 +205 -0
- package/src/tools/queue/JobStateTracker.d.ts +131 -0
- package/src/tools/queue/JobStateTracker.d.ts.map +1 -0
- package/src/tools/queue/JobStateTracker.js +387 -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 +148 -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,80 @@
|
|
|
1
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { SpawnUtil } from '../utils/spawn.js';
|
|
3
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import * as path from '../../node-singletons/path.js';
|
|
5
|
+
import { ProxyRegistry } from '../../proxy/ProxyRegistry.js';
|
|
6
|
+
import '../../proxy/d1/register.js';
|
|
7
|
+
import '../../proxy/kv/register.js';
|
|
8
|
+
import '../../proxy/mysql/register.js';
|
|
9
|
+
import '../../proxy/postgres/register.js';
|
|
10
|
+
import '../../proxy/redis/register.js';
|
|
11
|
+
import '../../proxy/smtp/register.js';
|
|
12
|
+
const PROXY_TARGET_MAP = Object.freeze({
|
|
13
|
+
mysql: 'proxy:mysql',
|
|
14
|
+
my: 'proxy:mysql',
|
|
15
|
+
postgres: 'proxy:postgres',
|
|
16
|
+
postgresql: 'proxy:postgres',
|
|
17
|
+
pg: 'proxy:postgres',
|
|
18
|
+
redis: 'proxy:redis',
|
|
19
|
+
smtp: 'proxy:smtp',
|
|
20
|
+
mail: 'proxy:smtp',
|
|
21
|
+
mongodb: 'proxy:mongodb',
|
|
22
|
+
mongo: 'proxy:mongodb',
|
|
23
|
+
sqlserver: 'proxy:sqlserver',
|
|
24
|
+
mssql: 'proxy:sqlserver',
|
|
25
|
+
});
|
|
26
|
+
const addOptions = (command) => {
|
|
27
|
+
command.argument('[target]', 'Proxy target (e.g. postgres, mysql, redis, smtp)');
|
|
28
|
+
};
|
|
29
|
+
const parseForwardArgs = () => {
|
|
30
|
+
const argv = process.argv.slice(2);
|
|
31
|
+
const proxyIndex = argv.indexOf('proxy');
|
|
32
|
+
if (proxyIndex < 0) {
|
|
33
|
+
return { target: null, extra: [] };
|
|
34
|
+
}
|
|
35
|
+
const target = argv[proxyIndex + 1] ?? null;
|
|
36
|
+
const extra = argv.slice(proxyIndex + 2);
|
|
37
|
+
return { target, extra };
|
|
38
|
+
};
|
|
39
|
+
const dispatchProxyTarget = async (targetRaw) => {
|
|
40
|
+
const target = targetRaw.trim().toLowerCase();
|
|
41
|
+
const mapped = PROXY_TARGET_MAP[target];
|
|
42
|
+
if (!mapped) {
|
|
43
|
+
throw ErrorFactory.createCliError(`Unknown proxy target '${targetRaw}'. Use one of: ${Object.keys(PROXY_TARGET_MAP).join(', ')}`);
|
|
44
|
+
}
|
|
45
|
+
const { extra } = parseForwardArgs();
|
|
46
|
+
const exitCode = await SpawnUtil.spawnAndWait({
|
|
47
|
+
command: 'tsx',
|
|
48
|
+
args: [path.join('bin', 'zin.ts'), mapped, ...extra],
|
|
49
|
+
env: {
|
|
50
|
+
...process.env,
|
|
51
|
+
},
|
|
52
|
+
forwardSignals: false,
|
|
53
|
+
});
|
|
54
|
+
process.exit(exitCode);
|
|
55
|
+
};
|
|
56
|
+
export const ProxyCommand = Object.freeze({
|
|
57
|
+
create() {
|
|
58
|
+
const cmd = BaseCommand.create({
|
|
59
|
+
name: 'proxy',
|
|
60
|
+
description: 'List available proxy servers',
|
|
61
|
+
addOptions,
|
|
62
|
+
execute: async (options) => {
|
|
63
|
+
const firstArg = Array.isArray(options.args) ? options.args[0] : undefined;
|
|
64
|
+
if (typeof firstArg === 'string' && firstArg.trim() !== '') {
|
|
65
|
+
await dispatchProxyTarget(firstArg);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const list = ProxyRegistry.list();
|
|
69
|
+
if (list.length === 0) {
|
|
70
|
+
throw ErrorFactory.createCliError('No proxies registered');
|
|
71
|
+
}
|
|
72
|
+
for (const proxy of list) {
|
|
73
|
+
cmd.info(`${proxy.name}: ${proxy.description}`);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
return cmd;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
export default ProxyCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type NumberExpectation = 'positive' | 'non-negative';
|
|
2
|
+
export declare const parseIntOption: (raw: string | undefined, name: string, expectation?: NumberExpectation) => number | undefined;
|
|
3
|
+
export declare const trimOption: (value: string | undefined) => string | undefined;
|
|
4
|
+
export declare const maybeRunProxyWatchMode: (watch: boolean | undefined) => Promise<void>;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=ProxyCommandUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ProxyCommandUtils.ts"],"names":[],"mappings":"AAIA,KAAK,iBAAiB,GAAG,UAAU,GAAG,cAAc,CAAC;AAErD,eAAO,MAAM,cAAc,GACzB,KAAK,MAAM,GAAG,SAAS,EACvB,MAAM,MAAM,EACZ,cAAa,iBAA8B,KAC1C,MAAM,GAAG,SAeX,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAA0B,CAAC;AAU3F,eAAO,MAAM,sBAAsB,GAAU,OAAO,OAAO,GAAG,SAAS,KAAG,OAAO,CAAC,IAAI,CAerF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SpawnUtil } from '../utils/spawn.js';
|
|
2
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
3
|
+
import * as path from '../../node-singletons/path.js';
|
|
4
|
+
export const parseIntOption = (raw, name, expectation = 'positive') => {
|
|
5
|
+
if (raw === undefined)
|
|
6
|
+
return undefined;
|
|
7
|
+
const parsed = Number.parseInt(raw, 10);
|
|
8
|
+
const isValid = expectation === 'non-negative'
|
|
9
|
+
? Number.isFinite(parsed) && parsed >= 0
|
|
10
|
+
: Number.isFinite(parsed) && parsed > 0;
|
|
11
|
+
if (!isValid) {
|
|
12
|
+
const expected = expectation === 'non-negative' ? 'a non-negative number' : 'a positive number';
|
|
13
|
+
throw ErrorFactory.createCliError(`Invalid --${name} '${raw}'. Expected ${expected}.`);
|
|
14
|
+
}
|
|
15
|
+
return parsed;
|
|
16
|
+
};
|
|
17
|
+
export const trimOption = (value) => value?.trim();
|
|
18
|
+
const isWatchChild = () => process.env['ZINTRUST_PROXY_WATCH_CHILD'] === '1';
|
|
19
|
+
const buildWatchArgs = () => {
|
|
20
|
+
const rawArgs = process.argv.slice(2);
|
|
21
|
+
const filtered = rawArgs.filter((arg) => arg !== '--watch');
|
|
22
|
+
return ['watch', path.join('bin', 'zin.ts'), ...filtered];
|
|
23
|
+
};
|
|
24
|
+
export const maybeRunProxyWatchMode = async (watch) => {
|
|
25
|
+
if (watch !== true || isWatchChild())
|
|
26
|
+
return;
|
|
27
|
+
const args = buildWatchArgs();
|
|
28
|
+
const exitCode = await SpawnUtil.spawnAndWait({
|
|
29
|
+
command: 'tsx',
|
|
30
|
+
args,
|
|
31
|
+
env: {
|
|
32
|
+
...process.env,
|
|
33
|
+
ZINTRUST_PROXY_WATCH_CHILD: '1',
|
|
34
|
+
},
|
|
35
|
+
forwardSignals: false,
|
|
36
|
+
});
|
|
37
|
+
process.exit(exitCode);
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueueRecoveryCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/QueueRecoveryCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAwoBrE,eAAO,MAAM,oBAAoB;cACrB,YAAY;EAsBtB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { Logger } from '../../config/logger.js';
|
|
3
|
+
import { queueConfig } from '../../config/queue.js';
|
|
4
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
5
|
+
import { useDatabase } from '../../orm/Database.js';
|
|
6
|
+
import { JobRecoveryDaemon } from '../../tools/queue/JobRecoveryDaemon.js';
|
|
7
|
+
import { JobStateTracker } from '../../tools/queue/JobStateTracker.js';
|
|
8
|
+
import { Queue } from '../../tools/queue/Queue.js';
|
|
9
|
+
import { QueueReliabilityOrchestrator } from '../../tools/queue/QueueReliabilityOrchestrator.js';
|
|
10
|
+
import { registerQueuesFromRuntimeConfig } from '../../tools/queue/QueueRuntimeRegistration.js';
|
|
11
|
+
const toSafeObject = (value) => {
|
|
12
|
+
if (value !== null && value !== undefined && typeof value === 'object') {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
return {};
|
|
16
|
+
};
|
|
17
|
+
const parseJson = (value) => {
|
|
18
|
+
if (typeof value !== 'string')
|
|
19
|
+
return value;
|
|
20
|
+
const trimmed = value.trim();
|
|
21
|
+
if (trimmed === '')
|
|
22
|
+
return undefined;
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(trimmed);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const toAttempts = (value) => {
|
|
31
|
+
const parsed = Number(value);
|
|
32
|
+
if (Number.isFinite(parsed))
|
|
33
|
+
return Math.max(0, parsed);
|
|
34
|
+
return 0;
|
|
35
|
+
};
|
|
36
|
+
const toMaxAttempts = (value) => {
|
|
37
|
+
const parsed = Number(value);
|
|
38
|
+
if (Number.isFinite(parsed) && parsed > 0)
|
|
39
|
+
return Math.floor(parsed);
|
|
40
|
+
return undefined;
|
|
41
|
+
};
|
|
42
|
+
const toOptionalString = (value) => {
|
|
43
|
+
if (typeof value !== 'string')
|
|
44
|
+
return undefined;
|
|
45
|
+
return value;
|
|
46
|
+
};
|
|
47
|
+
const toCreatedAt = (value) => {
|
|
48
|
+
const parsed = toOptionalString(value);
|
|
49
|
+
return parsed ?? new Date().toISOString();
|
|
50
|
+
};
|
|
51
|
+
const toUpdatedAt = (value, createdAt) => {
|
|
52
|
+
const parsed = toOptionalString(value);
|
|
53
|
+
return parsed ?? createdAt;
|
|
54
|
+
};
|
|
55
|
+
const normalizeStatus = (value) => {
|
|
56
|
+
const normalized = (value ?? '').trim().toLowerCase();
|
|
57
|
+
const statuses = [
|
|
58
|
+
'pending',
|
|
59
|
+
'active',
|
|
60
|
+
'completed',
|
|
61
|
+
'failed',
|
|
62
|
+
'stalled',
|
|
63
|
+
'timeout',
|
|
64
|
+
'pending_recovery',
|
|
65
|
+
'dead_letter',
|
|
66
|
+
'manual_review',
|
|
67
|
+
'delayed',
|
|
68
|
+
];
|
|
69
|
+
const matched = statuses.find((entry) => entry === normalized);
|
|
70
|
+
return matched ?? 'pending_recovery';
|
|
71
|
+
};
|
|
72
|
+
const toRecordFromPersisted = (row) => {
|
|
73
|
+
const createdAt = toCreatedAt(row.created_at);
|
|
74
|
+
const updatedAt = toUpdatedAt(row.updated_at, createdAt);
|
|
75
|
+
return {
|
|
76
|
+
queueName: row.queue_name,
|
|
77
|
+
jobId: row.job_id,
|
|
78
|
+
status: normalizeStatus(row.status),
|
|
79
|
+
attempts: toAttempts(row.attempts),
|
|
80
|
+
maxAttempts: toMaxAttempts(row.max_attempts),
|
|
81
|
+
payload: parseJson(row.payload_json),
|
|
82
|
+
result: parseJson(row.result_json),
|
|
83
|
+
lastError: toOptionalString(row.last_error),
|
|
84
|
+
lastErrorCode: toOptionalString(row.last_error_code),
|
|
85
|
+
retryAt: toOptionalString(row.retry_at),
|
|
86
|
+
timeoutAt: toOptionalString(row.timeout_at),
|
|
87
|
+
expectedCompletionAt: toOptionalString(row.expected_completion_at),
|
|
88
|
+
workerName: toOptionalString(row.worker_name),
|
|
89
|
+
workerInstanceId: toOptionalString(row.worker_instance_id),
|
|
90
|
+
workerRegion: toOptionalString(row.worker_region),
|
|
91
|
+
workerVersion: toOptionalString(row.worker_version),
|
|
92
|
+
recoveredAt: toOptionalString(row.recovered_at),
|
|
93
|
+
idempotencyKey: toOptionalString(row.idempotency_key),
|
|
94
|
+
createdAt,
|
|
95
|
+
startedAt: toOptionalString(row.started_at),
|
|
96
|
+
completedAt: toOptionalString(row.completed_at),
|
|
97
|
+
updatedAt,
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const getRecoverableStatuses = () => {
|
|
101
|
+
return new Set([
|
|
102
|
+
'pending_recovery',
|
|
103
|
+
'timeout',
|
|
104
|
+
'stalled',
|
|
105
|
+
'dead_letter',
|
|
106
|
+
]);
|
|
107
|
+
};
|
|
108
|
+
const getAllStatuses = () => {
|
|
109
|
+
return new Set([
|
|
110
|
+
'pending',
|
|
111
|
+
'active',
|
|
112
|
+
'completed',
|
|
113
|
+
'failed',
|
|
114
|
+
'stalled',
|
|
115
|
+
'timeout',
|
|
116
|
+
'pending_recovery',
|
|
117
|
+
'dead_letter',
|
|
118
|
+
'manual_review',
|
|
119
|
+
'delayed',
|
|
120
|
+
]);
|
|
121
|
+
};
|
|
122
|
+
const parseLimit = (raw) => {
|
|
123
|
+
if (raw === undefined)
|
|
124
|
+
return 50;
|
|
125
|
+
const parsed = Number.parseInt(raw, 10);
|
|
126
|
+
if (Number.isFinite(parsed) && parsed > 0) {
|
|
127
|
+
return Math.min(5000, parsed);
|
|
128
|
+
}
|
|
129
|
+
throw ErrorFactory.createConfigError(`Invalid --limit value: ${raw}`);
|
|
130
|
+
};
|
|
131
|
+
const parseStatus = (raw) => {
|
|
132
|
+
if (raw === undefined || raw.trim().length === 0)
|
|
133
|
+
return undefined;
|
|
134
|
+
const normalized = raw.trim().toLowerCase();
|
|
135
|
+
if (getAllStatuses().has(normalized))
|
|
136
|
+
return normalized;
|
|
137
|
+
throw ErrorFactory.createConfigError(`Invalid --status value: ${raw}`);
|
|
138
|
+
};
|
|
139
|
+
const formatRows = (headers, rows) => {
|
|
140
|
+
const widths = headers.map((header, index) => {
|
|
141
|
+
const maxRow = Math.max(...rows.map((row) => (row[index] ?? '').length), 0);
|
|
142
|
+
return Math.max(header.length, maxRow);
|
|
143
|
+
});
|
|
144
|
+
const line = (values) => values.map((value, index) => value.padEnd(widths[index] ?? value.length)).join(' | ');
|
|
145
|
+
const divider = widths.map((width) => '-'.repeat(width)).join('-+-');
|
|
146
|
+
return [line(headers), divider, ...rows.map((row) => line(row))].join('\n');
|
|
147
|
+
};
|
|
148
|
+
const listFromMemory = (input) => {
|
|
149
|
+
return JobStateTracker.list({
|
|
150
|
+
queueName: input.queueName,
|
|
151
|
+
status: input.status,
|
|
152
|
+
limit: input.limit,
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const toRecordFromUnknown = (raw) => {
|
|
156
|
+
if (raw === null || raw === undefined || typeof raw !== 'object')
|
|
157
|
+
return null;
|
|
158
|
+
const row = raw;
|
|
159
|
+
const queueName = typeof row['queueName'] === 'string' ? row['queueName'] : '';
|
|
160
|
+
const jobId = typeof row['jobId'] === 'string' ? row['jobId'] : '';
|
|
161
|
+
if (queueName.trim().length === 0 || jobId.trim().length === 0)
|
|
162
|
+
return null;
|
|
163
|
+
const attemptsRaw = row['attempts'];
|
|
164
|
+
const attempts = typeof attemptsRaw === 'number' && Number.isFinite(attemptsRaw) ? Math.max(0, attemptsRaw) : 0;
|
|
165
|
+
return {
|
|
166
|
+
queueName,
|
|
167
|
+
jobId,
|
|
168
|
+
status: normalizeStatus(typeof row['status'] === 'string' ? row['status'] : undefined),
|
|
169
|
+
attempts,
|
|
170
|
+
maxAttempts: toMaxAttempts(row['maxAttempts']),
|
|
171
|
+
payload: row['payload'],
|
|
172
|
+
result: row['result'],
|
|
173
|
+
lastError: toOptionalString(row['lastError']),
|
|
174
|
+
lastErrorCode: toOptionalString(row['lastErrorCode']),
|
|
175
|
+
retryAt: toOptionalString(row['retryAt']),
|
|
176
|
+
timeoutAt: toOptionalString(row['timeoutAt']),
|
|
177
|
+
expectedCompletionAt: toOptionalString(row['expectedCompletionAt']),
|
|
178
|
+
workerName: toOptionalString(row['workerName']),
|
|
179
|
+
workerInstanceId: toOptionalString(row['workerInstanceId']),
|
|
180
|
+
workerRegion: toOptionalString(row['workerRegion']),
|
|
181
|
+
workerVersion: toOptionalString(row['workerVersion']),
|
|
182
|
+
recoveredAt: toOptionalString(row['recoveredAt']),
|
|
183
|
+
idempotencyKey: toOptionalString(row['idempotencyKey']),
|
|
184
|
+
createdAt: toCreatedAt(row['createdAt']),
|
|
185
|
+
startedAt: toOptionalString(row['startedAt']),
|
|
186
|
+
completedAt: toOptionalString(row['completedAt']),
|
|
187
|
+
updatedAt: toUpdatedAt(row['updatedAt'], toCreatedAt(row['createdAt'])),
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
const resolveTrackerApiBaseUrl = () => {
|
|
191
|
+
const explicit = (process.env['QUEUE_TRACKER_API_URL'] ?? '').trim();
|
|
192
|
+
if (explicit.length > 0)
|
|
193
|
+
return explicit;
|
|
194
|
+
const appUrl = (process.env['APP_URL'] ?? '').trim();
|
|
195
|
+
if (appUrl.length > 0)
|
|
196
|
+
return appUrl;
|
|
197
|
+
return 'http://127.0.0.1:7777';
|
|
198
|
+
};
|
|
199
|
+
const listFromServer = async (input) => {
|
|
200
|
+
const baseUrl = resolveTrackerApiBaseUrl();
|
|
201
|
+
const url = new URL('/_debug/queue/tracker', baseUrl);
|
|
202
|
+
url.searchParams.set('limit', String(input.limit));
|
|
203
|
+
if (input.queueName !== undefined && input.queueName.trim().length > 0) {
|
|
204
|
+
url.searchParams.set('queue', input.queueName.trim());
|
|
205
|
+
}
|
|
206
|
+
if (input.status !== undefined) {
|
|
207
|
+
url.searchParams.set('status', input.status);
|
|
208
|
+
}
|
|
209
|
+
const response = await fetch(url.toString(), {
|
|
210
|
+
method: 'GET',
|
|
211
|
+
});
|
|
212
|
+
if (!response.ok) {
|
|
213
|
+
throw ErrorFactory.createConnectionError(`Tracker API returned HTTP ${response.status}`, {
|
|
214
|
+
status: response.status,
|
|
215
|
+
url: url.toString(),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
const json = (await response.json());
|
|
219
|
+
const rawRecords = Array.isArray(json.records) ? json.records : [];
|
|
220
|
+
return rawRecords
|
|
221
|
+
.map(toRecordFromUnknown)
|
|
222
|
+
.filter((row) => row !== null);
|
|
223
|
+
};
|
|
224
|
+
const listFromPersistence = async (input) => {
|
|
225
|
+
const db = useDatabase(undefined, process.env['JOB_TRACKING_DB_CONNECTION'] ?? 'default');
|
|
226
|
+
let query = db
|
|
227
|
+
.table(process.env['JOB_TRACKING_DB_TABLE'] ?? 'zintrust_jobs')
|
|
228
|
+
.orderBy('updated_at', 'DESC')
|
|
229
|
+
.limit(input.limit);
|
|
230
|
+
if (input.queueName !== undefined && input.queueName.trim().length > 0) {
|
|
231
|
+
query = query.where('queue_name', '=', input.queueName.trim());
|
|
232
|
+
}
|
|
233
|
+
if (input.status !== undefined) {
|
|
234
|
+
query = query.where('status', '=', input.status);
|
|
235
|
+
}
|
|
236
|
+
const rows = await query.get();
|
|
237
|
+
return (rows ?? []).map(toRecordFromPersisted);
|
|
238
|
+
};
|
|
239
|
+
const printJobList = (rows, asJson) => {
|
|
240
|
+
if (asJson) {
|
|
241
|
+
Logger.info(JSON.stringify(rows, null, 2));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (rows.length === 0) {
|
|
245
|
+
Logger.info('No jobs found for the provided filters');
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const table = formatRows(['Job ID', 'Queue', 'Status', 'Attempts', 'Updated'], rows.map((row) => [row.jobId, row.queueName, row.status, String(row.attempts), row.updatedAt]));
|
|
249
|
+
Logger.info(`\n${table}`);
|
|
250
|
+
};
|
|
251
|
+
const runListJobs = async (options) => {
|
|
252
|
+
const memoryRows = listFromMemory({
|
|
253
|
+
queueName: options.queueName,
|
|
254
|
+
status: options.status,
|
|
255
|
+
limit: options.limit,
|
|
256
|
+
});
|
|
257
|
+
if (options.source === 'memory') {
|
|
258
|
+
printJobList(memoryRows, options.asJson);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (options.source === 'db') {
|
|
262
|
+
const rows = await listFromPersistence({
|
|
263
|
+
queueName: options.queueName,
|
|
264
|
+
status: options.status,
|
|
265
|
+
limit: options.limit,
|
|
266
|
+
});
|
|
267
|
+
printJobList(rows, options.asJson);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (options.source === 'server') {
|
|
271
|
+
const rows = await listFromServer({
|
|
272
|
+
queueName: options.queueName,
|
|
273
|
+
status: options.status,
|
|
274
|
+
limit: options.limit,
|
|
275
|
+
});
|
|
276
|
+
printJobList(rows, options.asJson);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (memoryRows.length > 0) {
|
|
280
|
+
printJobList(memoryRows, options.asJson);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const isTestRuntime = (process.env['NODE_ENV'] ?? '').trim().toLowerCase() === 'test' ||
|
|
284
|
+
Boolean(process.env['VITEST']);
|
|
285
|
+
if (isTestRuntime) {
|
|
286
|
+
printJobList(memoryRows, options.asJson);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
const serverRows = await listFromServer({
|
|
291
|
+
queueName: options.queueName,
|
|
292
|
+
status: options.status,
|
|
293
|
+
limit: options.limit,
|
|
294
|
+
});
|
|
295
|
+
if (serverRows.length > 0) {
|
|
296
|
+
Logger.info('Tracker list sourced from running app process memory');
|
|
297
|
+
printJobList(serverRows, options.asJson);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
Logger.warn('Failed to fetch tracker list from running app', {
|
|
303
|
+
error: error instanceof Error ? error.message : String(error),
|
|
304
|
+
trackerApiUrl: resolveTrackerApiBaseUrl(),
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
printJobList(memoryRows, options.asJson);
|
|
308
|
+
};
|
|
309
|
+
const loadFromPersistence = async (jobId, queueName) => {
|
|
310
|
+
const db = useDatabase(undefined, process.env['JOB_TRACKING_DB_CONNECTION'] ?? 'default');
|
|
311
|
+
let query = db
|
|
312
|
+
.table(process.env['JOB_TRACKING_DB_TABLE'] ?? 'zintrust_jobs')
|
|
313
|
+
.where('job_id', '=', jobId);
|
|
314
|
+
if (queueName !== undefined && queueName.trim().length > 0) {
|
|
315
|
+
query = query.where('queue_name', '=', queueName.trim());
|
|
316
|
+
}
|
|
317
|
+
const row = await query.orderBy('updated_at', 'DESC').first();
|
|
318
|
+
if (row === null || row === undefined)
|
|
319
|
+
return null;
|
|
320
|
+
return toRecordFromPersisted(row);
|
|
321
|
+
};
|
|
322
|
+
const findRecord = async (jobId, queueName, allowDbLookup) => {
|
|
323
|
+
const normalizedQueue = queueName?.trim();
|
|
324
|
+
if (normalizedQueue !== undefined && normalizedQueue.length > 0) {
|
|
325
|
+
const exact = JobStateTracker.get(normalizedQueue, jobId);
|
|
326
|
+
if (exact)
|
|
327
|
+
return exact;
|
|
328
|
+
}
|
|
329
|
+
const memoryMatches = JobStateTracker.list({ limit: 50000 }).filter((row) => {
|
|
330
|
+
if (row.jobId !== jobId)
|
|
331
|
+
return false;
|
|
332
|
+
if (normalizedQueue !== undefined && normalizedQueue.length > 0) {
|
|
333
|
+
return row.queueName === normalizedQueue;
|
|
334
|
+
}
|
|
335
|
+
return true;
|
|
336
|
+
});
|
|
337
|
+
if (memoryMatches.length > 0) {
|
|
338
|
+
return memoryMatches[0] ?? null;
|
|
339
|
+
}
|
|
340
|
+
if (!allowDbLookup)
|
|
341
|
+
return null;
|
|
342
|
+
try {
|
|
343
|
+
return await loadFromPersistence(jobId, normalizedQueue);
|
|
344
|
+
}
|
|
345
|
+
catch (error) {
|
|
346
|
+
Logger.warn('Failed to load job from persistence', {
|
|
347
|
+
jobId,
|
|
348
|
+
queueName: normalizedQueue,
|
|
349
|
+
error,
|
|
350
|
+
});
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const runRecoveryOnce = async () => {
|
|
355
|
+
const result = await JobRecoveryDaemon.runOnce();
|
|
356
|
+
Logger.info('Queue recovery run completed', result);
|
|
357
|
+
};
|
|
358
|
+
const runPushForJob = async (record, options) => {
|
|
359
|
+
const payload = toSafeObject(record.payload);
|
|
360
|
+
if (options.dryRun) {
|
|
361
|
+
Logger.info('Dry-run: skipping enqueue for target job', {
|
|
362
|
+
jobId: record.jobId,
|
|
363
|
+
queueName: record.queueName,
|
|
364
|
+
status: record.status,
|
|
365
|
+
});
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const replayJobId = await Queue.enqueue(record.queueName, payload);
|
|
369
|
+
await JobStateTracker.markedRecovered({
|
|
370
|
+
queueName: record.queueName,
|
|
371
|
+
jobId: record.jobId,
|
|
372
|
+
reason: `CLI pushed job as ${replayJobId}`,
|
|
373
|
+
retryAt: new Date().toISOString(),
|
|
374
|
+
});
|
|
375
|
+
Logger.info('Target job pushed to queue', {
|
|
376
|
+
originalJobId: record.jobId,
|
|
377
|
+
replayJobId,
|
|
378
|
+
queueName: record.queueName,
|
|
379
|
+
});
|
|
380
|
+
};
|
|
381
|
+
const runRecoverOneForJob = async (record, options) => {
|
|
382
|
+
if (options.dryRun) {
|
|
383
|
+
Logger.info('Dry-run: skipping policy recovery for target job', {
|
|
384
|
+
jobId: record.jobId,
|
|
385
|
+
queueName: record.queueName,
|
|
386
|
+
status: record.status,
|
|
387
|
+
attempts: record.attempts,
|
|
388
|
+
maxAttempts: record.maxAttempts,
|
|
389
|
+
});
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const outcome = await JobRecoveryDaemon.recoverOne(record);
|
|
393
|
+
Logger.info('Target job recovery completed', {
|
|
394
|
+
jobId: record.jobId,
|
|
395
|
+
queueName: record.queueName,
|
|
396
|
+
outcome,
|
|
397
|
+
});
|
|
398
|
+
};
|
|
399
|
+
const resolveExecutionOptions = (options) => {
|
|
400
|
+
const jobIdRaw = typeof options.jobId === 'string' ? options.jobId.trim() : '';
|
|
401
|
+
const hasJobId = jobIdRaw.length > 0;
|
|
402
|
+
const sourceRaw = (options.source ?? 'auto').trim().toLowerCase();
|
|
403
|
+
let source = 'auto';
|
|
404
|
+
if (sourceRaw === 'db') {
|
|
405
|
+
source = 'db';
|
|
406
|
+
}
|
|
407
|
+
else if (sourceRaw === 'server') {
|
|
408
|
+
source = 'server';
|
|
409
|
+
}
|
|
410
|
+
else if (sourceRaw === 'memory') {
|
|
411
|
+
source = 'memory';
|
|
412
|
+
}
|
|
413
|
+
if (options.source !== undefined &&
|
|
414
|
+
sourceRaw !== 'memory' &&
|
|
415
|
+
sourceRaw !== 'db' &&
|
|
416
|
+
sourceRaw !== 'server' &&
|
|
417
|
+
sourceRaw !== 'auto') {
|
|
418
|
+
throw ErrorFactory.createConfigError(`Invalid --source value: ${options.source}`);
|
|
419
|
+
}
|
|
420
|
+
return {
|
|
421
|
+
list: options.list === true,
|
|
422
|
+
runOnce: options.once === true,
|
|
423
|
+
start: options.start === true,
|
|
424
|
+
hasJobId,
|
|
425
|
+
jobId: hasJobId ? jobIdRaw : undefined,
|
|
426
|
+
queueName: typeof options.queue === 'string' ? options.queue.trim() : undefined,
|
|
427
|
+
status: parseStatus(options.status),
|
|
428
|
+
limit: parseLimit(options.limit),
|
|
429
|
+
source,
|
|
430
|
+
asJson: options.json === true,
|
|
431
|
+
dryRun: options.dryRun === true,
|
|
432
|
+
push: options.push === true,
|
|
433
|
+
allowDbLookup: options.dbLookup !== false,
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
const maybeRunListMode = async (resolved) => {
|
|
437
|
+
if (!resolved.list)
|
|
438
|
+
return false;
|
|
439
|
+
await runListJobs({
|
|
440
|
+
queueName: resolved.queueName,
|
|
441
|
+
status: resolved.status,
|
|
442
|
+
limit: resolved.limit,
|
|
443
|
+
source: resolved.source,
|
|
444
|
+
asJson: resolved.asJson,
|
|
445
|
+
});
|
|
446
|
+
return true;
|
|
447
|
+
};
|
|
448
|
+
const maybeRunDefaultRecovery = async (resolved) => {
|
|
449
|
+
if (resolved.runOnce || resolved.start || resolved.hasJobId)
|
|
450
|
+
return false;
|
|
451
|
+
await runRecoveryOnce();
|
|
452
|
+
return true;
|
|
453
|
+
};
|
|
454
|
+
const runTargetedRecovery = async (resolved) => {
|
|
455
|
+
if (!resolved.hasJobId || resolved.jobId === undefined)
|
|
456
|
+
return;
|
|
457
|
+
const record = await findRecord(resolved.jobId, resolved.queueName, resolved.allowDbLookup);
|
|
458
|
+
if (record === null) {
|
|
459
|
+
throw ErrorFactory.createConfigError(`Job not found in tracker${resolved.allowDbLookup ? ' or persistence store' : ''}: ${resolved.jobId}`);
|
|
460
|
+
}
|
|
461
|
+
if (!resolved.push && !getRecoverableStatuses().has(record.status)) {
|
|
462
|
+
throw ErrorFactory.createConfigError(`Job status is not recoverable via policy runner: ${record.status}. Use --push to force requeue.`);
|
|
463
|
+
}
|
|
464
|
+
if (resolved.push) {
|
|
465
|
+
await runPushForJob(record, { dryRun: resolved.dryRun });
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
await runRecoverOneForJob(record, { dryRun: resolved.dryRun });
|
|
469
|
+
};
|
|
470
|
+
const finalizeRecoveryExecution = async (resolved) => {
|
|
471
|
+
if (resolved.runOnce) {
|
|
472
|
+
await runRecoveryOnce();
|
|
473
|
+
}
|
|
474
|
+
if (resolved.start) {
|
|
475
|
+
QueueReliabilityOrchestrator.start();
|
|
476
|
+
Logger.info('Queue reliability orchestrator is running');
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
const executeQueueRecovery = async (options) => {
|
|
480
|
+
const resolved = resolveExecutionOptions(options);
|
|
481
|
+
if (await maybeRunListMode(resolved))
|
|
482
|
+
return;
|
|
483
|
+
await registerQueuesFromRuntimeConfig(queueConfig);
|
|
484
|
+
if (await maybeRunDefaultRecovery(resolved))
|
|
485
|
+
return;
|
|
486
|
+
await runTargetedRecovery(resolved);
|
|
487
|
+
await finalizeRecoveryExecution(resolved);
|
|
488
|
+
};
|
|
489
|
+
export const QueueRecoveryCommand = Object.freeze({
|
|
490
|
+
create() {
|
|
491
|
+
return BaseCommand.create({
|
|
492
|
+
name: 'queue:recovery',
|
|
493
|
+
description: 'Run queue recovery once, start orchestrator, or recover/push a specific job',
|
|
494
|
+
addOptions: (command) => {
|
|
495
|
+
command
|
|
496
|
+
.option('--list', 'List tracked jobs')
|
|
497
|
+
.option('--once', 'Run recovery daemon one time')
|
|
498
|
+
.option('--start', 'Start queue reliability orchestrator intervals')
|
|
499
|
+
.option('--job-id <id>', 'Target specific job id')
|
|
500
|
+
.option('--queue <name>', 'Queue name for targeted job lookup')
|
|
501
|
+
.option('--status <status>', 'Filter listed jobs by status')
|
|
502
|
+
.option('--limit <count>', 'Limit listed jobs (default: 50, max: 5000)')
|
|
503
|
+
.option('--source <source>', 'List source: auto|memory|server|db (default: auto)')
|
|
504
|
+
.option('--json', 'Render list output as JSON')
|
|
505
|
+
.option('--push', 'Force direct requeue of target job payload')
|
|
506
|
+
.option('--dry-run', 'Log actions without enqueueing/recovering')
|
|
507
|
+
.option('--no-db-lookup', 'Disable fallback DB lookup for target job');
|
|
508
|
+
},
|
|
509
|
+
execute: executeQueueRecovery,
|
|
510
|
+
});
|
|
511
|
+
},
|
|
512
|
+
});
|
|
513
|
+
export default QueueRecoveryCommand;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedisProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/RedisProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmDrE,eAAO,MAAM,iBAAiB;cAClB,YAAY;EAoCtB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|