@zintrust/core 0.1.39 → 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 -262
- package/src/boot/Server.d.ts +1 -1
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/bootstrap.js +23 -9
- 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 +145 -18
- 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.d.ts +2 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/cli/utils/EnvFileLoader.js +22 -21
- package/src/cli/utils/spawn.d.ts.map +1 -1
- package/src/cli/utils/spawn.js +17 -10
- package/src/cli/workers/QueueWorkRunner.js +1 -1
- package/src/common/ExternalServiceUtils.d.ts.map +1 -1
- package/src/common/ExternalServiceUtils.js +7 -2
- 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 +90 -2
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +160 -18
- package/src/config/index.d.ts +1 -0
- package/src/config/index.d.ts.map +1 -1
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +60 -16
- 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 +19 -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 +39 -10
- 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 +18 -9
- package/src/security/CsrfTokenManager.d.ts.map +1 -1
- package/src/security/CsrfTokenManager.js +204 -11
- 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/app/Middleware/index.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +4 -2
- 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/redis/RedisKeyManager.d.ts +3 -0
- package/src/tools/redis/RedisKeyManager.d.ts.map +1 -1
- package/src/tools/redis/RedisKeyManager.js +15 -0
- package/src/tools/storage/drivers/R2.d.ts +13 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -1
- package/src/tools/storage/drivers/R2.js +29 -0
- package/src/zintrust.plugins.d.ts +9 -0
- package/src/zintrust.plugins.d.ts.map +1 -0
- package/src/zintrust.plugins.js +7 -0
- package/src/zintrust.plugins.wg.d.ts +9 -0
- package/src/zintrust.plugins.wg.d.ts.map +1 -0
- package/src/zintrust.plugins.wg.js +7 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pathToFileURL } from '../node-singletons/url.js';
|
|
2
2
|
import { readEnvString } from '../common/ExternalServiceUtils.js';
|
|
3
3
|
import { Logger } from '../config/logger.js';
|
|
4
|
-
import { existsSync } from '../node-singletons/fs.js';
|
|
4
|
+
import { existsSync, readFile } from '../node-singletons/fs.js';
|
|
5
5
|
import * as path from '../node-singletons/path.js';
|
|
6
6
|
const getProjectCwd = () => process.cwd();
|
|
7
7
|
const getProjectRootEnv = () => readEnvString('ZINTRUST_PROJECT_ROOT');
|
|
@@ -22,6 +22,77 @@ const getCandidates = (projectRoot) => {
|
|
|
22
22
|
path.join(projectRoot, 'src', 'zintrust.plugins.js'),
|
|
23
23
|
];
|
|
24
24
|
};
|
|
25
|
+
const extractImportSpecifiers = (raw) => {
|
|
26
|
+
const specifiers = [];
|
|
27
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
28
|
+
const match = /^\s*import\s+['"]([^'"]+)['"];?\s*$/.exec(line);
|
|
29
|
+
if (match?.[1] !== null && match?.[1] !== undefined) {
|
|
30
|
+
specifiers.push(match[1]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return specifiers;
|
|
34
|
+
};
|
|
35
|
+
const readImportSpecifiersFromFiles = async (files) => {
|
|
36
|
+
const importSpecifiers = [];
|
|
37
|
+
// Read all files in parallel
|
|
38
|
+
const fileReadPromises = files.map(async (filePath) => {
|
|
39
|
+
try {
|
|
40
|
+
const raw = await readFile(filePath, 'utf-8');
|
|
41
|
+
return { filePath, specifiers: extractImportSpecifiers(raw), success: true };
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
Logger.debug('[plugins] Failed to read auto-import file for fallback', {
|
|
45
|
+
filePath,
|
|
46
|
+
error: error instanceof Error ? error.message : String(error),
|
|
47
|
+
});
|
|
48
|
+
return { filePath, specifiers: [], success: false };
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const results = await Promise.all(fileReadPromises);
|
|
52
|
+
// Collect all successful specifiers
|
|
53
|
+
for (const { filePath, specifiers } of results) {
|
|
54
|
+
for (const specifier of specifiers) {
|
|
55
|
+
importSpecifiers.push({ specifier, filePath });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return importSpecifiers;
|
|
59
|
+
};
|
|
60
|
+
const resolveRelativeSpecifier = (entry) => {
|
|
61
|
+
const baseDir = path.dirname(entry.filePath);
|
|
62
|
+
const basePath = path.resolve(baseDir, entry.specifier);
|
|
63
|
+
const candidates = [
|
|
64
|
+
basePath,
|
|
65
|
+
`${basePath}.js`,
|
|
66
|
+
`${basePath}.ts`,
|
|
67
|
+
path.join(basePath, 'index.js'),
|
|
68
|
+
path.join(basePath, 'index.ts'),
|
|
69
|
+
];
|
|
70
|
+
const resolved = candidates.find((candidate) => existsSync(candidate)) ?? basePath;
|
|
71
|
+
return pathToFileURL(resolved).href;
|
|
72
|
+
};
|
|
73
|
+
const importSpecifiers = async (specifiers) => {
|
|
74
|
+
// Import all specifiers in parallel
|
|
75
|
+
const importPromises = Array.from(specifiers).map(async (entry) => {
|
|
76
|
+
const target = entry.specifier.startsWith('.')
|
|
77
|
+
? resolveRelativeSpecifier(entry)
|
|
78
|
+
: entry.specifier;
|
|
79
|
+
try {
|
|
80
|
+
await import(target);
|
|
81
|
+
Logger.debug('[plugins] Loaded auto-import specifier', { specifier: entry.specifier });
|
|
82
|
+
return { specifier: entry.specifier, success: true };
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
Logger.debug('[plugins] Failed auto-import specifier', {
|
|
86
|
+
specifier: entry.specifier,
|
|
87
|
+
error: error instanceof Error ? error.message : String(error),
|
|
88
|
+
});
|
|
89
|
+
return { specifier: entry.specifier, success: false };
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const results = await Promise.allSettled(importPromises);
|
|
93
|
+
// Count successful imports
|
|
94
|
+
return results.filter((result) => result.status === 'fulfilled' && result.value.success).length;
|
|
95
|
+
};
|
|
25
96
|
export const PluginAutoImports = Object.freeze({
|
|
26
97
|
/**
|
|
27
98
|
* Best-effort import of a project's `src/zintrust.plugins.ts` file.
|
|
@@ -39,8 +110,7 @@ export const PluginAutoImports = Object.freeze({
|
|
|
39
110
|
Logger.debug('[plugins] No plugin auto-imports file found', { projectRoot, candidates });
|
|
40
111
|
return { ok: false, reason: 'not-found' };
|
|
41
112
|
}
|
|
42
|
-
|
|
43
|
-
const importPromises = existingCandidates.map(async (candidate) => {
|
|
113
|
+
const tryImportCandidate = async (candidate) => {
|
|
44
114
|
try {
|
|
45
115
|
const url = pathToFileURL(candidate).href;
|
|
46
116
|
await import(url);
|
|
@@ -55,7 +125,9 @@ export const PluginAutoImports = Object.freeze({
|
|
|
55
125
|
errorMessage,
|
|
56
126
|
};
|
|
57
127
|
}
|
|
58
|
-
}
|
|
128
|
+
};
|
|
129
|
+
// Try all existing candidates in parallel
|
|
130
|
+
const importPromises = existingCandidates.map(async (candidate) => tryImportCandidate(candidate));
|
|
59
131
|
// Return the first successful import, or the first failure if none succeed
|
|
60
132
|
try {
|
|
61
133
|
const results = await Promise.allSettled(importPromises);
|
|
@@ -65,15 +137,28 @@ export const PluginAutoImports = Object.freeze({
|
|
|
65
137
|
}
|
|
66
138
|
// Return the first failed result if no success
|
|
67
139
|
const firstFailedResult = results.find((result) => result.status === 'fulfilled' && !result.value.ok);
|
|
68
|
-
|
|
69
|
-
ok: false,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
140
|
+
const failed = firstFailedResult?.value ??
|
|
141
|
+
{ ok: false, reason: 'import-failed', errorMessage: 'All candidates failed' };
|
|
142
|
+
Logger.debug('[plugins] Auto-import file failed, attempting per-import fallback', failed);
|
|
143
|
+
const fallbackResult = await this.tryImportFromFileContents(existingCandidates);
|
|
144
|
+
if (fallbackResult.ok)
|
|
145
|
+
return fallbackResult;
|
|
146
|
+
return failed;
|
|
73
147
|
}
|
|
74
148
|
catch (error) {
|
|
75
149
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
76
150
|
return { ok: false, reason: 'import-failed', errorMessage };
|
|
77
151
|
}
|
|
78
152
|
},
|
|
153
|
+
async tryImportFromFileContents(files) {
|
|
154
|
+
const specifiers = await readImportSpecifiersFromFiles(files);
|
|
155
|
+
if (specifiers.length === 0) {
|
|
156
|
+
return { ok: false, reason: 'import-failed', errorMessage: 'No import specifiers found' };
|
|
157
|
+
}
|
|
158
|
+
const loaded = await importSpecifiers(specifiers);
|
|
159
|
+
if (loaded > 0) {
|
|
160
|
+
return { ok: true, loadedPath: 'manual-imports' };
|
|
161
|
+
}
|
|
162
|
+
return { ok: false, reason: 'import-failed', errorMessage: 'All specifier imports failed' };
|
|
163
|
+
},
|
|
79
164
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from '../node-singletons/http';
|
|
2
|
-
type Tbody = string | Buffer | null;
|
|
2
|
+
type Tbody = string | Buffer | ReadableStream<Uint8Array> | null;
|
|
3
3
|
/**
|
|
4
4
|
* Request body type for handlers
|
|
5
5
|
*/
|
|
@@ -14,6 +14,7 @@ export interface PlatformRequest {
|
|
|
14
14
|
body?: Tbody;
|
|
15
15
|
query?: Record<string, string | string[]>;
|
|
16
16
|
remoteAddr?: string;
|
|
17
|
+
signal?: AbortSignal;
|
|
17
18
|
}
|
|
18
19
|
export interface PlatformResponse {
|
|
19
20
|
statusCode: number;
|
|
@@ -110,17 +111,15 @@ export declare const HttpResponse: Readonly<{
|
|
|
110
111
|
export declare const ErrorResponse: Readonly<{
|
|
111
112
|
create(statusCode: number, message: string, details?: unknown): IHttpResponse;
|
|
112
113
|
}>;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
type ResData = {
|
|
115
|
+
statusCode: number;
|
|
116
|
+
headers: Record<string, string | string[]>;
|
|
117
|
+
body: Tbody;
|
|
118
|
+
};
|
|
116
119
|
export declare function createMockHttpObjects(request: PlatformRequest): {
|
|
117
120
|
req: Record<string, unknown>;
|
|
118
121
|
res: Record<string, unknown>;
|
|
119
|
-
responseData:
|
|
120
|
-
statusCode: number;
|
|
121
|
-
headers: Record<string, string | string[]>;
|
|
122
|
-
body: Tbody;
|
|
123
|
-
};
|
|
122
|
+
responseData: ResData;
|
|
124
123
|
};
|
|
125
124
|
export {};
|
|
126
125
|
//# sourceMappingURL=RuntimeAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/RuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"RuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/RuntimeAdapter.ts"],"names":[],"mappings":"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"}
|
|
@@ -85,45 +85,79 @@ export const ErrorResponse = Object.freeze({
|
|
|
85
85
|
/**
|
|
86
86
|
* Create mock Node.js request/response objects for platform compatibility
|
|
87
87
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
const coerceFirstForwardedFor = (value) => {
|
|
89
|
+
if (Array.isArray(value)) {
|
|
90
|
+
const first = value[0];
|
|
91
|
+
return typeof first === 'string' && first.trim() !== '' ? first.trim() : undefined;
|
|
92
|
+
}
|
|
93
|
+
if (typeof value === 'string' && value.trim() !== '')
|
|
94
|
+
return value.trim();
|
|
95
|
+
return undefined;
|
|
96
|
+
};
|
|
97
|
+
const resolveRemoteAddress = (request) => {
|
|
98
98
|
const forwardedFor = coerceFirstForwardedFor(request.headers?.['x-forwarded-for']);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
99
|
+
if (typeof request.remoteAddr === 'string' && request.remoteAddr.trim() !== '') {
|
|
100
|
+
return request.remoteAddr.trim();
|
|
101
|
+
}
|
|
102
|
+
return (forwardedFor?.split(',')[0]?.trim() ?? '') || '0.0.0.0';
|
|
103
|
+
};
|
|
104
|
+
const createResponseData = () => ({
|
|
105
|
+
statusCode: 200,
|
|
106
|
+
headers: { 'content-type': 'application/json' },
|
|
107
|
+
body: null,
|
|
108
|
+
});
|
|
109
|
+
const createMockRequest = (request, remoteAddress) => ({
|
|
110
|
+
method: request.method,
|
|
111
|
+
url: request.path,
|
|
112
|
+
headers: request.headers,
|
|
113
|
+
body: request.body ?? undefined,
|
|
114
|
+
remoteAddress,
|
|
115
|
+
socket: {
|
|
112
116
|
remoteAddress,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
},
|
|
118
|
+
connection: {
|
|
119
|
+
remoteAddress,
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
const applyWriteHead = (responseData, statusCode, headers) => {
|
|
123
|
+
responseData.statusCode = statusCode;
|
|
124
|
+
if (headers) {
|
|
125
|
+
const normalizedHeaders = {};
|
|
126
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
127
|
+
normalizedHeaders[key.toLowerCase()] = value;
|
|
128
|
+
}
|
|
129
|
+
responseData.headers = { ...responseData.headers, ...normalizedHeaders };
|
|
130
|
+
}
|
|
131
|
+
if (responseData.headers['content-type'] === 'text/event-stream') {
|
|
132
|
+
// @ts-ignore - ReadableStream/TransformStream might not be in all TS envs type definitions
|
|
133
|
+
if (typeof TransformStream !== 'undefined') {
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
const stream = new TransformStream();
|
|
136
|
+
responseData.body = stream.readable;
|
|
137
|
+
return stream.writable.getWriter();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
};
|
|
142
|
+
const resData = (responseData, request) => {
|
|
143
|
+
return {
|
|
121
144
|
statusCode: 200,
|
|
122
145
|
headers: responseData.headers,
|
|
123
146
|
writeHead: function (statusCode, headers) {
|
|
124
|
-
|
|
125
|
-
if
|
|
126
|
-
|
|
147
|
+
this._writer = applyWriteHead(responseData, statusCode, headers);
|
|
148
|
+
// Handle abortion if signal is present
|
|
149
|
+
if (request.signal && this._writer) {
|
|
150
|
+
request.signal.addEventListener('abort', () => {
|
|
151
|
+
if (this._writer) {
|
|
152
|
+
try {
|
|
153
|
+
this._writer.close();
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// Ignore close errors
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
this.emit('close');
|
|
160
|
+
});
|
|
127
161
|
}
|
|
128
162
|
return this;
|
|
129
163
|
},
|
|
@@ -132,15 +166,67 @@ export function createMockHttpObjects(request) {
|
|
|
132
166
|
return this;
|
|
133
167
|
},
|
|
134
168
|
end: function (chunk) {
|
|
169
|
+
if (this._writer) {
|
|
170
|
+
if (chunk !== undefined && chunk !== null) {
|
|
171
|
+
this._writer.write(new TextEncoder().encode(String(chunk)));
|
|
172
|
+
}
|
|
173
|
+
this._writer.close();
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
135
176
|
if (chunk !== undefined) {
|
|
136
177
|
responseData.body = chunk;
|
|
137
178
|
}
|
|
179
|
+
this.emit('finish');
|
|
138
180
|
return this;
|
|
139
181
|
},
|
|
140
182
|
write: function (chunk) {
|
|
183
|
+
if (this._writer) {
|
|
184
|
+
try {
|
|
185
|
+
this._writer.write(new TextEncoder().encode(String(chunk)));
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
141
192
|
responseData.body = chunk;
|
|
142
193
|
return true;
|
|
143
194
|
},
|
|
195
|
+
on: function (event, listener) {
|
|
196
|
+
this._listeners ??= {};
|
|
197
|
+
this._listeners[event] ??= [];
|
|
198
|
+
this._listeners[event].push(listener);
|
|
199
|
+
return this;
|
|
200
|
+
},
|
|
201
|
+
once: function (event, listener) {
|
|
202
|
+
const wrapper = (...args) => {
|
|
203
|
+
this.removeListener(event, wrapper);
|
|
204
|
+
listener(...args);
|
|
205
|
+
};
|
|
206
|
+
return this.on(event, wrapper);
|
|
207
|
+
},
|
|
208
|
+
removeListener: function (event, listener) {
|
|
209
|
+
if (this._listeners?.[event] !== undefined) {
|
|
210
|
+
this._listeners[event] = this._listeners[event].filter((l) => l !== listener);
|
|
211
|
+
}
|
|
212
|
+
return this;
|
|
213
|
+
},
|
|
214
|
+
emit: function (event, ...args) {
|
|
215
|
+
if (this._listeners?.[event] !== undefined) {
|
|
216
|
+
// Create a copy to avoid issues if listeners remove themselves
|
|
217
|
+
[...this._listeners[event]].forEach((fn) => {
|
|
218
|
+
fn(...args);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
_writer: null,
|
|
223
|
+
_listeners: {},
|
|
144
224
|
};
|
|
225
|
+
};
|
|
226
|
+
export function createMockHttpObjects(request) {
|
|
227
|
+
const remoteAddress = resolveRemoteAddress(request);
|
|
228
|
+
const responseData = createResponseData();
|
|
229
|
+
const req = createMockRequest(request, remoteAddress);
|
|
230
|
+
const res = resData(responseData, request);
|
|
145
231
|
return { req, res, responseData };
|
|
146
232
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Services
|
|
3
|
+
* Adapter layer for env/crypto/timers/fs/fetch across Node and Workers
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
export type RuntimePlatform = 'nodejs' | 'lambda' | 'fargate' | 'cloudflare' | 'deno';
|
|
7
|
+
export type RuntimeEnvReader = {
|
|
8
|
+
get: (key: string, defaultValue?: string) => string;
|
|
9
|
+
getInt: (key: string, defaultValue?: number) => number;
|
|
10
|
+
getFloat: (key: string, defaultValue?: number) => number;
|
|
11
|
+
getBool: (key: string, defaultValue?: boolean) => boolean;
|
|
12
|
+
};
|
|
13
|
+
export type RandomValuesArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | BigInt64Array | BigUint64Array;
|
|
14
|
+
export type RuntimeCrypto = {
|
|
15
|
+
subtle: SubtleCrypto;
|
|
16
|
+
getRandomValues: <T extends RandomValuesArray>(array: T) => T;
|
|
17
|
+
randomUUID: () => string;
|
|
18
|
+
randomBytes?: (size: number) => Uint8Array;
|
|
19
|
+
};
|
|
20
|
+
export type RuntimeTimers = {
|
|
21
|
+
setTimeout: typeof setTimeout;
|
|
22
|
+
clearTimeout: typeof clearTimeout;
|
|
23
|
+
setInterval: typeof setInterval;
|
|
24
|
+
clearInterval: typeof clearInterval;
|
|
25
|
+
};
|
|
26
|
+
export type RuntimeFs = {
|
|
27
|
+
supported: boolean;
|
|
28
|
+
readFileSync: (path: string, encoding?: BufferEncoding) => string | Buffer;
|
|
29
|
+
readdirSync: (path: string) => string[];
|
|
30
|
+
existsSync: (path: string) => boolean;
|
|
31
|
+
};
|
|
32
|
+
export type RuntimeServices = {
|
|
33
|
+
platform: RuntimePlatform;
|
|
34
|
+
env: RuntimeEnvReader;
|
|
35
|
+
crypto: RuntimeCrypto;
|
|
36
|
+
timers: RuntimeTimers;
|
|
37
|
+
fs: RuntimeFs;
|
|
38
|
+
fetch: typeof fetch;
|
|
39
|
+
};
|
|
40
|
+
export declare const detectCloudflareWorkers: () => boolean;
|
|
41
|
+
export declare const detectRuntimePlatform: () => RuntimePlatform;
|
|
42
|
+
export declare const RUNTIME_PLATFORM: RuntimePlatform;
|
|
43
|
+
export declare const RuntimeServices: Readonly<{
|
|
44
|
+
create(platform: RuntimePlatform): RuntimeServices;
|
|
45
|
+
}>;
|
|
46
|
+
export default RuntimeServices;
|
|
47
|
+
//# sourceMappingURL=RuntimeServices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeServices.d.ts","sourceRoot":"","sources":["../../../src/runtime/RuntimeServices.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,CAAC;AAEtF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACpD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACvD,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACzD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,iBAAiB,GACjB,WAAW,GACX,WAAW,GACX,SAAS,GACT,UAAU,GACV,UAAU,GACV,aAAa,GACb,cAAc,CAAC;AAEnB,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,YAAY,CAAC;IACrB,eAAe,EAAE,CAAC,CAAC,SAAS,iBAAiB,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9D,UAAU,EAAE,MAAM,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,aAAa,EAAE,OAAO,aAAa,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,KAAK,MAAM,GAAG,MAAM,CAAC;IAC3E,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACxC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,eAAe,CAAC;IAC1B,GAAG,EAAE,gBAAgB,CAAC;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,EAAE,EAAE,SAAS,CAAC;IACd,KAAK,EAAE,OAAO,KAAK,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,uBAAuB,QAAO,OAE1C,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAO,eAGxC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,eAAyC,CAAC;AAwIzE,eAAO,MAAM,eAAe;qBACT,eAAe,GAAG,eAAe;EAqBlD,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Services
|
|
3
|
+
* Adapter layer for env/crypto/timers/fs/fetch across Node and Workers
|
|
4
|
+
* Sealed namespace for immutability
|
|
5
|
+
*/
|
|
6
|
+
import { Cloudflare } from '../config/cloudflare.js';
|
|
7
|
+
import { Env } from '../config/env.js';
|
|
8
|
+
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
9
|
+
import { randomUUID as nodeRandomUUID, randomBytes } from '../node-singletons/crypto.js';
|
|
10
|
+
import * as nodeFs from '../node-singletons/fs.js';
|
|
11
|
+
export const detectCloudflareWorkers = () => {
|
|
12
|
+
return Cloudflare.getWorkersEnv() !== null;
|
|
13
|
+
};
|
|
14
|
+
export const detectRuntimePlatform = () => {
|
|
15
|
+
if (detectCloudflareWorkers())
|
|
16
|
+
return 'cloudflare';
|
|
17
|
+
return 'nodejs';
|
|
18
|
+
};
|
|
19
|
+
export const RUNTIME_PLATFORM = detectRuntimePlatform();
|
|
20
|
+
const normalizeEnvValue = (value) => {
|
|
21
|
+
if (value === null || value === undefined)
|
|
22
|
+
return '';
|
|
23
|
+
if (typeof value === 'string')
|
|
24
|
+
return value;
|
|
25
|
+
if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
|
|
26
|
+
return String(value);
|
|
27
|
+
}
|
|
28
|
+
return '';
|
|
29
|
+
};
|
|
30
|
+
const readEnvFromRecord = (record, key) => {
|
|
31
|
+
return normalizeEnvValue(record[key]);
|
|
32
|
+
};
|
|
33
|
+
const createWorkersEnvReader = () => {
|
|
34
|
+
return {
|
|
35
|
+
get(key, defaultValue = '') {
|
|
36
|
+
const env = Cloudflare.getWorkersEnv() ?? {};
|
|
37
|
+
const value = readEnvFromRecord(env, key);
|
|
38
|
+
return value === '' ? defaultValue : value;
|
|
39
|
+
},
|
|
40
|
+
getInt(key, defaultValue = 0) {
|
|
41
|
+
const raw = this.get(key, String(defaultValue));
|
|
42
|
+
const parsed = Number.parseInt(raw, 10);
|
|
43
|
+
return Number.isFinite(parsed) ? parsed : defaultValue;
|
|
44
|
+
},
|
|
45
|
+
getFloat(key, defaultValue = 0) {
|
|
46
|
+
const raw = this.get(key, String(defaultValue));
|
|
47
|
+
const parsed = Number.parseFloat(raw);
|
|
48
|
+
return Number.isFinite(parsed) ? parsed : defaultValue;
|
|
49
|
+
},
|
|
50
|
+
getBool(key, defaultValue = false) {
|
|
51
|
+
const raw = this.get(key, defaultValue ? 'true' : 'false').toLowerCase();
|
|
52
|
+
if (raw === '')
|
|
53
|
+
return defaultValue;
|
|
54
|
+
return raw === 'true' || raw === '1';
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const createNodeEnvReader = () => {
|
|
59
|
+
return {
|
|
60
|
+
get: (key, defaultValue) => Env.get(key, defaultValue),
|
|
61
|
+
getInt: (key, defaultValue) => Env.getInt(key, defaultValue ?? 0),
|
|
62
|
+
getFloat: (key, defaultValue) => Env.getFloat(key, defaultValue ?? 0),
|
|
63
|
+
getBool: (key, defaultValue) => Env.getBool(key, defaultValue),
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const getWebCrypto = () => {
|
|
67
|
+
if (globalThis.crypto === undefined) {
|
|
68
|
+
throw ErrorFactory.createConfigError('WebCrypto is not available in this runtime');
|
|
69
|
+
}
|
|
70
|
+
return globalThis.crypto;
|
|
71
|
+
};
|
|
72
|
+
const fillRandomValues = (webCrypto, array) => {
|
|
73
|
+
if (typeof webCrypto.getRandomValues === 'function') {
|
|
74
|
+
return webCrypto.getRandomValues(array);
|
|
75
|
+
}
|
|
76
|
+
if (array instanceof BigInt64Array || array instanceof BigUint64Array) {
|
|
77
|
+
throw ErrorFactory.createConfigError('BigInt typed arrays require WebCrypto support');
|
|
78
|
+
}
|
|
79
|
+
const bytes = randomBytes(array.byteLength);
|
|
80
|
+
const view = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
81
|
+
view.set(bytes);
|
|
82
|
+
return array;
|
|
83
|
+
};
|
|
84
|
+
const createNodeCrypto = () => {
|
|
85
|
+
const webCrypto = getWebCrypto();
|
|
86
|
+
if (webCrypto.subtle === undefined) {
|
|
87
|
+
throw ErrorFactory.createConfigError('WebCrypto subtle is not available in Node runtime');
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
subtle: webCrypto.subtle,
|
|
91
|
+
getRandomValues: (array) => {
|
|
92
|
+
return fillRandomValues(webCrypto, array);
|
|
93
|
+
},
|
|
94
|
+
randomUUID: () => {
|
|
95
|
+
if (typeof webCrypto.randomUUID === 'function')
|
|
96
|
+
return webCrypto.randomUUID();
|
|
97
|
+
return nodeRandomUUID();
|
|
98
|
+
},
|
|
99
|
+
randomBytes: (size) => randomBytes(size),
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
const createWorkersCrypto = () => {
|
|
103
|
+
const webCrypto = getWebCrypto();
|
|
104
|
+
if (webCrypto.subtle === undefined) {
|
|
105
|
+
throw ErrorFactory.createConfigError('WebCrypto subtle is not available in Workers runtime');
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
subtle: webCrypto.subtle,
|
|
109
|
+
getRandomValues: (array) => webCrypto.getRandomValues(array),
|
|
110
|
+
randomUUID: () => {
|
|
111
|
+
if (typeof webCrypto.randomUUID === 'function')
|
|
112
|
+
return webCrypto.randomUUID();
|
|
113
|
+
return nodeRandomUUID();
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
const createNodeFs = () => {
|
|
118
|
+
return {
|
|
119
|
+
supported: true,
|
|
120
|
+
readFileSync: (path, encoding) => nodeFs.readFileSync(path, encoding),
|
|
121
|
+
readdirSync: (path) => nodeFs.readdirSync(path),
|
|
122
|
+
existsSync: (path) => nodeFs.existsSync(path),
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
const createWorkersFs = () => {
|
|
126
|
+
const unsupported = () => {
|
|
127
|
+
throw ErrorFactory.createConfigError('Filesystem access is not supported in Workers runtime');
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
supported: false,
|
|
131
|
+
readFileSync: () => unsupported(),
|
|
132
|
+
readdirSync: () => unsupported(),
|
|
133
|
+
existsSync: () => false,
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
const createTimers = () => ({
|
|
137
|
+
setTimeout: globalThis.setTimeout.bind(globalThis),
|
|
138
|
+
clearTimeout: globalThis.clearTimeout.bind(globalThis),
|
|
139
|
+
setInterval: globalThis.setInterval.bind(globalThis),
|
|
140
|
+
clearInterval: globalThis.clearInterval.bind(globalThis),
|
|
141
|
+
});
|
|
142
|
+
export const RuntimeServices = Object.freeze({
|
|
143
|
+
create(platform) {
|
|
144
|
+
if (platform === 'cloudflare') {
|
|
145
|
+
return {
|
|
146
|
+
platform,
|
|
147
|
+
env: createWorkersEnvReader(),
|
|
148
|
+
crypto: createWorkersCrypto(),
|
|
149
|
+
timers: createTimers(),
|
|
150
|
+
fs: createWorkersFs(),
|
|
151
|
+
fetch: globalThis.fetch.bind(globalThis),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
platform,
|
|
156
|
+
env: createNodeEnvReader(),
|
|
157
|
+
crypto: createNodeCrypto(),
|
|
158
|
+
timers: createTimers(),
|
|
159
|
+
fs: createNodeFs(),
|
|
160
|
+
fetch: globalThis.fetch.bind(globalThis),
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
export default RuntimeServices;
|
|
@@ -9,12 +9,12 @@ export declare const StartupConfigFile: {
|
|
|
9
9
|
readonly Storage: "config/storage.ts";
|
|
10
10
|
readonly Workers: "config/workers.ts";
|
|
11
11
|
};
|
|
12
|
-
export type
|
|
12
|
+
export type StartupConfigFileTypes = typeof StartupConfigFile.Broadcast | typeof StartupConfigFile.Cache | typeof StartupConfigFile.Database | typeof StartupConfigFile.Mail | typeof StartupConfigFile.Middleware | typeof StartupConfigFile.Notification | typeof StartupConfigFile.Queue | typeof StartupConfigFile.Storage | typeof StartupConfigFile.Workers;
|
|
13
13
|
export declare const StartupConfigFileRegistry: Readonly<{
|
|
14
|
-
preload(files: readonly
|
|
14
|
+
preload(files: readonly StartupConfigFileTypes[]): Promise<void>;
|
|
15
15
|
isPreloaded(): boolean;
|
|
16
|
-
get<T>(file:
|
|
17
|
-
has(file:
|
|
16
|
+
get<T>(file: StartupConfigFileTypes): T | undefined;
|
|
17
|
+
has(file: StartupConfigFileTypes): boolean;
|
|
18
18
|
/** Intended for tests only. */
|
|
19
19
|
clear(): void;
|
|
20
20
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartupConfigFileRegistry.d.ts","sourceRoot":"","sources":["../../../src/runtime/StartupConfigFileRegistry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StartupConfigFileRegistry.d.ts","sourceRoot":"","sources":["../../../src/runtime/StartupConfigFileRegistry.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB;;;;;;;;;;CAUpB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAC9B,OAAO,iBAAiB,CAAC,SAAS,GAClC,OAAO,iBAAiB,CAAC,KAAK,GAC9B,OAAO,iBAAiB,CAAC,QAAQ,GACjC,OAAO,iBAAiB,CAAC,IAAI,GAC7B,OAAO,iBAAiB,CAAC,UAAU,GACnC,OAAO,iBAAiB,CAAC,YAAY,GACrC,OAAO,iBAAiB,CAAC,KAAK,GAC9B,OAAO,iBAAiB,CAAC,OAAO,GAChC,OAAO,iBAAiB,CAAC,OAAO,CAAC;AAarC,eAAO,MAAM,yBAAyB;mBACf,SAAS,sBAAsB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;mBAqBvD,OAAO;QAIlB,CAAC,QAAQ,sBAAsB,GAAG,CAAC,GAAG,SAAS;cAIzC,sBAAsB,GAAG,OAAO;IAI1C,+BAA+B;aACtB,IAAI;EAIb,CAAC;AAEH,eAAe,yBAAyB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import useFileLoader from './useFileLoader.js';
|
|
2
|
+
// NOTE runtime config loader
|
|
2
3
|
export const StartupConfigFile = {
|
|
3
4
|
Broadcast: 'config/broadcast.ts',
|
|
4
5
|
Cache: 'config/cache.ts',
|
|
@@ -12,9 +13,20 @@ export const StartupConfigFile = {
|
|
|
12
13
|
};
|
|
13
14
|
const cache = new Map();
|
|
14
15
|
let preloaded = false;
|
|
16
|
+
const getWorkersStartupOverrides = () => {
|
|
17
|
+
if (typeof globalThis === 'undefined')
|
|
18
|
+
return undefined;
|
|
19
|
+
const globalAny = globalThis;
|
|
20
|
+
return globalAny.__zintrustStartupConfigOverrides;
|
|
21
|
+
};
|
|
15
22
|
export const StartupConfigFileRegistry = Object.freeze({
|
|
16
23
|
async preload(files) {
|
|
17
24
|
const tasks = files.map(async (file) => {
|
|
25
|
+
const overrides = getWorkersStartupOverrides();
|
|
26
|
+
if (overrides?.has(file) === true) {
|
|
27
|
+
cache.set(file, overrides.get(file));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
18
30
|
const loader = useFileLoader(file);
|
|
19
31
|
if (!loader.exists()) {
|
|
20
32
|
cache.delete(file);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerAdapterImports.d.ts","sourceRoot":"","sources":["../../../src/runtime/WorkerAdapterImports.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,oBAAoB;;;EAG/B,CAAC"}
|