@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
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
2
|
+
/**
|
|
3
|
+
* PostgreSQL Proxy Adapter (HTTP)
|
|
4
|
+
*
|
|
5
|
+
* Used in Cloudflare Workers when POSTGRES_PROXY_URL is configured.
|
|
6
|
+
*/
|
|
7
|
+
import { Env } from '../../config/env.js';
|
|
8
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
9
|
+
import { AdaptersEnum } from '../../migrations/enum/index.js';
|
|
10
|
+
import { QueryBuilder } from '../QueryBuilder.js';
|
|
11
|
+
import { ensureSignedSettings, isRecord, requestSignedProxy, } from '../adapters/SqlProxyAdapterUtils.js';
|
|
12
|
+
const resolveBaseUrl = () => {
|
|
13
|
+
const explicit = Env.POSTGRES_PROXY_URL.trim();
|
|
14
|
+
if (explicit !== '')
|
|
15
|
+
return explicit;
|
|
16
|
+
const host = Env.POSTGRES_PROXY_HOST || '127.0.0.1';
|
|
17
|
+
const port = Env.POSTGRES_PROXY_PORT;
|
|
18
|
+
return `http://${host}:${port}`;
|
|
19
|
+
};
|
|
20
|
+
const buildProxySettings = () => {
|
|
21
|
+
const baseUrl = resolveBaseUrl();
|
|
22
|
+
const keyId = Env.POSTGRES_PROXY_KEY_ID ?? '';
|
|
23
|
+
const secret = Env.POSTGRES_PROXY_SECRET ?? '';
|
|
24
|
+
const timeoutMs = Env.POSTGRES_PROXY_TIMEOUT_MS;
|
|
25
|
+
return { baseUrl, keyId, secret, timeoutMs };
|
|
26
|
+
};
|
|
27
|
+
const buildSignedProxyConfig = (settings) => ({
|
|
28
|
+
settings,
|
|
29
|
+
missingUrlMessage: 'PostgreSQL proxy URL is missing (POSTGRES_PROXY_URL)',
|
|
30
|
+
missingCredentialsMessage: 'PostgreSQL proxy signing credentials are missing (POSTGRES_PROXY_KEY_ID / POSTGRES_PROXY_SECRET)',
|
|
31
|
+
messages: {
|
|
32
|
+
unauthorized: 'PostgreSQL proxy unauthorized',
|
|
33
|
+
forbidden: 'PostgreSQL proxy forbidden',
|
|
34
|
+
rateLimited: 'PostgreSQL proxy rate limited',
|
|
35
|
+
rejected: 'PostgreSQL proxy rejected request',
|
|
36
|
+
error: 'PostgreSQL proxy error',
|
|
37
|
+
timedOut: 'PostgreSQL proxy request timed out',
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const isQueryResponse = (value) => isRecord(value) && Array.isArray(value['rows']) && typeof value['rowCount'] === 'number';
|
|
41
|
+
const isQueryOneResponse = (value) => isRecord(value) && 'row' in value;
|
|
42
|
+
const normalizeLastInsertId = (value) => {
|
|
43
|
+
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'bigint') {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
};
|
|
48
|
+
const extractRowId = (row) => {
|
|
49
|
+
if (!isRecord(row))
|
|
50
|
+
return undefined;
|
|
51
|
+
return normalizeLastInsertId(row['id']);
|
|
52
|
+
};
|
|
53
|
+
const getExecMeta = (value) => {
|
|
54
|
+
if (!isRecord(value) || typeof value['ok'] !== 'boolean')
|
|
55
|
+
return { changes: 0 };
|
|
56
|
+
const meta = value['meta'];
|
|
57
|
+
if (!isRecord(meta))
|
|
58
|
+
return { changes: 0 };
|
|
59
|
+
const changes = typeof meta['changes'] === 'number' ? meta['changes'] : 0;
|
|
60
|
+
return { changes };
|
|
61
|
+
};
|
|
62
|
+
const toQueryResult = (out) => {
|
|
63
|
+
if (isQueryResponse(out)) {
|
|
64
|
+
return {
|
|
65
|
+
rows: out.rows,
|
|
66
|
+
rowCount: out.rowCount,
|
|
67
|
+
lastInsertId: extractRowId(out.rows[0]),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (isQueryOneResponse(out)) {
|
|
71
|
+
const row = out.row ?? null;
|
|
72
|
+
return {
|
|
73
|
+
rows: row ? [row] : [],
|
|
74
|
+
rowCount: row ? 1 : 0,
|
|
75
|
+
lastInsertId: extractRowId(row),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const meta = getExecMeta(out);
|
|
79
|
+
return { rows: [], rowCount: meta.changes };
|
|
80
|
+
};
|
|
81
|
+
const requestProxy = async (settings, path, payload) => {
|
|
82
|
+
return requestSignedProxy(buildSignedProxyConfig(settings), path, payload);
|
|
83
|
+
};
|
|
84
|
+
export const PostgreSQLProxyAdapter = Object.freeze({
|
|
85
|
+
create(_config) {
|
|
86
|
+
let connected = true;
|
|
87
|
+
const settings = buildProxySettings();
|
|
88
|
+
return {
|
|
89
|
+
async connect() {
|
|
90
|
+
ensureSignedSettings(buildSignedProxyConfig(settings));
|
|
91
|
+
connected = true;
|
|
92
|
+
},
|
|
93
|
+
async disconnect() {
|
|
94
|
+
connected = true;
|
|
95
|
+
},
|
|
96
|
+
async query(sql, parameters) {
|
|
97
|
+
if (!connected)
|
|
98
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
99
|
+
const out = await requestProxy(settings, '/zin/postgres/query', {
|
|
100
|
+
sql,
|
|
101
|
+
params: parameters,
|
|
102
|
+
});
|
|
103
|
+
return toQueryResult(out);
|
|
104
|
+
},
|
|
105
|
+
async queryOne(sql, parameters) {
|
|
106
|
+
if (!connected)
|
|
107
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
108
|
+
const out = await requestProxy(settings, '/zin/postgres/queryOne', {
|
|
109
|
+
sql,
|
|
110
|
+
params: parameters,
|
|
111
|
+
});
|
|
112
|
+
return out.row ?? null;
|
|
113
|
+
},
|
|
114
|
+
async ping() {
|
|
115
|
+
if (!connected)
|
|
116
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
117
|
+
await this.queryOne(QueryBuilder.create('').select('1').toSQL(), []);
|
|
118
|
+
},
|
|
119
|
+
async transaction(callback) {
|
|
120
|
+
if (!connected)
|
|
121
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
122
|
+
try {
|
|
123
|
+
return await callback(this);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
throw ErrorFactory.createTryCatchError('PostgreSQL proxy transaction failed', error);
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
async rawQuery(sql, parameters = []) {
|
|
130
|
+
if (!connected)
|
|
131
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
132
|
+
const out = await this.query(sql, parameters);
|
|
133
|
+
return out.rows;
|
|
134
|
+
},
|
|
135
|
+
getType() {
|
|
136
|
+
return AdaptersEnum.postgresql;
|
|
137
|
+
},
|
|
138
|
+
isConnected() {
|
|
139
|
+
return connected;
|
|
140
|
+
},
|
|
141
|
+
getPlaceholder(index) {
|
|
142
|
+
return `$${index}`;
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
export default PostgreSQLProxyAdapter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { QueryResult } from '../DatabaseAdapter';
|
|
2
|
+
export declare const ProxyCache: Readonly<{
|
|
3
|
+
create(): Readonly<{
|
|
4
|
+
get(key: string): QueryResult | null;
|
|
5
|
+
set(key: string, data: QueryResult): void;
|
|
6
|
+
clear(): void;
|
|
7
|
+
}>;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=ProxyCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyCache.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/ProxyCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASxD,eAAO,MAAM,UAAU;;iBAKR,MAAM,GAAG,WAAW,GAAG,IAAI;iBAU3B,MAAM,QAAQ,WAAW,GAAG,IAAI;iBAIhC,IAAI;;EAKjB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const CACHE_TTL_MS = 5000;
|
|
2
|
+
export const ProxyCache = Object.freeze({
|
|
3
|
+
create() {
|
|
4
|
+
const cache = new Map();
|
|
5
|
+
return Object.freeze({
|
|
6
|
+
get(key) {
|
|
7
|
+
const entry = cache.get(key);
|
|
8
|
+
if (!entry)
|
|
9
|
+
return null;
|
|
10
|
+
if (Date.now() - entry.timestamp > CACHE_TTL_MS) {
|
|
11
|
+
cache.delete(key);
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return entry.data;
|
|
15
|
+
},
|
|
16
|
+
set(key, data) {
|
|
17
|
+
cache.set(key, { data, timestamp: Date.now() });
|
|
18
|
+
},
|
|
19
|
+
clear() {
|
|
20
|
+
cache.clear();
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const createSignedProxyRequest: (input: {
|
|
2
|
+
url: string;
|
|
3
|
+
body: string;
|
|
4
|
+
keyId: string;
|
|
5
|
+
secret: string;
|
|
6
|
+
missingCredentialsMessage: string;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
headers: Record<string, string>;
|
|
9
|
+
body: string;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=ProxySignedRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxySignedRequest.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/ProxySignedRequest.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,wBAAwB,GAAU,OAAO;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB,EAAE,MAAM,CAAC;CACnC,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA4B5D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
2
|
+
import { normalizeSigningCredentials } from '../../proxy/SigningService.js';
|
|
3
|
+
import { SignedRequest } from '../../security/SignedRequest.js';
|
|
4
|
+
import { buildSigningUrl } from '../adapters/ProxySigningPath.js';
|
|
5
|
+
export const createSignedProxyRequest = async (input) => {
|
|
6
|
+
const creds = normalizeSigningCredentials({ keyId: input.keyId, secret: input.secret });
|
|
7
|
+
if (creds.keyId.trim() === '' || creds.secret.trim() === '') {
|
|
8
|
+
throw ErrorFactory.createConfigError(input.missingCredentialsMessage);
|
|
9
|
+
}
|
|
10
|
+
const urlObj = new URL(input.url);
|
|
11
|
+
const signingUrl = buildSigningUrl(urlObj, input.url);
|
|
12
|
+
const signResult = await SignedRequest.createHeaders({
|
|
13
|
+
method: 'POST',
|
|
14
|
+
url: signingUrl,
|
|
15
|
+
body: input.body,
|
|
16
|
+
keyId: creds.keyId,
|
|
17
|
+
secret: creds.secret,
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
headers: {
|
|
21
|
+
'content-type': 'application/json',
|
|
22
|
+
'x-zt-key-id': signResult['x-zt-key-id'],
|
|
23
|
+
'x-zt-timestamp': signResult['x-zt-timestamp'],
|
|
24
|
+
'x-zt-nonce': signResult['x-zt-nonce'],
|
|
25
|
+
'x-zt-body-sha256': signResult['x-zt-body-sha256'],
|
|
26
|
+
'x-zt-signature': signResult['x-zt-signature'],
|
|
27
|
+
},
|
|
28
|
+
body: input.body,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxySigningPath.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/ProxySigningPath.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,KAAG,MAAM,GAAG,SAU/D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,YAAY,GAAG,EAAE,SAAS,MAAM,KAAG,GAYlE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const resolveSigningPrefix = (baseUrl) => {
|
|
2
|
+
try {
|
|
3
|
+
const parsed = new URL(baseUrl);
|
|
4
|
+
const pathname = parsed.pathname;
|
|
5
|
+
const path = pathname.endsWith('/') ? pathname.slice(0, -1) : pathname;
|
|
6
|
+
if (path === '' || path === '/')
|
|
7
|
+
return undefined;
|
|
8
|
+
return path;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const buildSigningUrl = (requestUrl, baseUrl) => {
|
|
15
|
+
const prefix = resolveSigningPrefix(baseUrl);
|
|
16
|
+
if (typeof prefix !== 'string' || prefix.trim() === '')
|
|
17
|
+
return requestUrl;
|
|
18
|
+
if (requestUrl.pathname === prefix || requestUrl.pathname.startsWith(`${prefix}/`)) {
|
|
19
|
+
const signingUrl = new URL(requestUrl.toString());
|
|
20
|
+
const stripped = requestUrl.pathname.slice(prefix.length);
|
|
21
|
+
signingUrl.pathname = stripped.startsWith('/') ? stripped : `/${stripped}`;
|
|
22
|
+
return signingUrl;
|
|
23
|
+
}
|
|
24
|
+
return requestUrl;
|
|
25
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type RemoteSignedJsonSettings } from '../../common/RemoteSignedJson';
|
|
2
|
+
export type ProxySettings = {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
keyId?: string;
|
|
5
|
+
secret?: string;
|
|
6
|
+
timeoutMs: number;
|
|
7
|
+
signaturePathPrefixToStrip?: string;
|
|
8
|
+
};
|
|
9
|
+
export type SignedProxyConfig = {
|
|
10
|
+
settings: ProxySettings;
|
|
11
|
+
missingUrlMessage: string;
|
|
12
|
+
missingCredentialsMessage: string;
|
|
13
|
+
messages: RemoteSignedJsonSettings['messages'];
|
|
14
|
+
};
|
|
15
|
+
export declare const buildSignedSettings: (config: SignedProxyConfig) => RemoteSignedJsonSettings;
|
|
16
|
+
export declare const ensureSignedSettings: (config: SignedProxyConfig) => RemoteSignedJsonSettings;
|
|
17
|
+
export declare const requestSignedProxy: <T>(config: SignedProxyConfig, path: string, payload: Record<string, unknown>) => Promise<T>;
|
|
18
|
+
export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
|
|
19
|
+
//# sourceMappingURL=SqlProxyAdapterUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlProxyAdapterUtils.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SqlProxyAdapterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAK3F,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,aAAa,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yBAAyB,EAAE,MAAM,CAAC;IAClC,QAAQ,EAAE,wBAAwB,CAAC,UAAU,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,QAAQ,iBAAiB,KAAG,wBAiB/D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,iBAAiB,KAAG,wBAYhE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAU,CAAC,EACxC,QAAQ,iBAAiB,EACzB,MAAM,MAAM,EACZ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/B,OAAO,CAAC,CAAC,CAGX,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAC5B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RemoteSignedJson } from '../../common/RemoteSignedJson.js';
|
|
2
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
3
|
+
import { resolveSigningPrefix } from '../adapters/ProxySigningPath.js';
|
|
4
|
+
import { normalizeSigningCredentials } from '../../proxy/SigningService.js';
|
|
5
|
+
export const buildSignedSettings = (config) => {
|
|
6
|
+
const creds = normalizeSigningCredentials({
|
|
7
|
+
keyId: config.settings.keyId ?? '',
|
|
8
|
+
secret: config.settings.secret ?? '',
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
baseUrl: config.settings.baseUrl,
|
|
12
|
+
keyId: creds.keyId,
|
|
13
|
+
secret: creds.secret,
|
|
14
|
+
timeoutMs: config.settings.timeoutMs,
|
|
15
|
+
signaturePathPrefixToStrip: config.settings.signaturePathPrefixToStrip ?? resolveSigningPrefix(config.settings.baseUrl),
|
|
16
|
+
missingUrlMessage: config.missingUrlMessage,
|
|
17
|
+
missingCredentialsMessage: config.missingCredentialsMessage,
|
|
18
|
+
messages: config.messages,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const ensureSignedSettings = (config) => {
|
|
22
|
+
const signedSettings = buildSignedSettings(config);
|
|
23
|
+
if (signedSettings.baseUrl.trim() === '') {
|
|
24
|
+
throw ErrorFactory.createConfigError(config.missingUrlMessage);
|
|
25
|
+
}
|
|
26
|
+
if (signedSettings.keyId.trim() === '' || signedSettings.secret.trim() === '') {
|
|
27
|
+
throw ErrorFactory.createConfigError(config.missingCredentialsMessage);
|
|
28
|
+
}
|
|
29
|
+
return signedSettings;
|
|
30
|
+
};
|
|
31
|
+
export const requestSignedProxy = async (config, path, payload) => {
|
|
32
|
+
const signedSettings = ensureSignedSettings(config);
|
|
33
|
+
return RemoteSignedJson.request(signedSettings, path, payload);
|
|
34
|
+
};
|
|
35
|
+
export const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlServerProxyAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SqlServerProxyAdapter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAyF1E,wBAAgB,2BAA2B,IAAI,gBAAgB,CAsF9D"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Env } from '../../config/env.js';
|
|
2
|
+
import { Logger } from '../../config/logger.js';
|
|
3
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import { createSignedProxyRequest } from '../adapters/ProxySignedRequest.js';
|
|
5
|
+
const cache = new Map();
|
|
6
|
+
const CACHE_TTL_MS = 5000;
|
|
7
|
+
const getCacheKey = (sql, params) => {
|
|
8
|
+
return `${sql}:${JSON.stringify(params)}`;
|
|
9
|
+
};
|
|
10
|
+
const getCachedResult = (key) => {
|
|
11
|
+
const entry = cache.get(key);
|
|
12
|
+
if (!entry)
|
|
13
|
+
return null;
|
|
14
|
+
if (Date.now() - entry.timestamp > CACHE_TTL_MS) {
|
|
15
|
+
cache.delete(key);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return entry.data;
|
|
19
|
+
};
|
|
20
|
+
const setCachedResult = (key, data) => {
|
|
21
|
+
cache.set(key, { data, timestamp: Date.now() });
|
|
22
|
+
};
|
|
23
|
+
const resolveProxyUrl = () => {
|
|
24
|
+
const url = Env.get('SQLSERVER_PROXY_URL', '');
|
|
25
|
+
if (typeof url === 'string' && url.trim() !== '')
|
|
26
|
+
return url;
|
|
27
|
+
const host = Env.get('SQLSERVER_PROXY_HOST', '127.0.0.1');
|
|
28
|
+
const port = Env.getInt('SQLSERVER_PROXY_PORT', 8793);
|
|
29
|
+
return `http://${host}:${port}`;
|
|
30
|
+
};
|
|
31
|
+
const createSignedRequest = async (url, body) => {
|
|
32
|
+
return createSignedProxyRequest({
|
|
33
|
+
url,
|
|
34
|
+
body,
|
|
35
|
+
keyId: Env.get('SQLSERVER_PROXY_KEY_ID', ''),
|
|
36
|
+
secret: Env.get('SQLSERVER_PROXY_SECRET', ''),
|
|
37
|
+
missingCredentialsMessage: 'SQL Server proxy signing credentials are missing (SQLSERVER_PROXY_KEY_ID / SQLSERVER_PROXY_SECRET)',
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const sendQuery = async (sql, params) => {
|
|
41
|
+
const proxyUrl = resolveProxyUrl();
|
|
42
|
+
const payload = { sql, params };
|
|
43
|
+
const body = JSON.stringify(payload);
|
|
44
|
+
const { headers, body: signedBody } = await createSignedRequest(proxyUrl, body);
|
|
45
|
+
const timeout = Env.getInt('SQLSERVER_PROXY_TIMEOUT_MS', 30000);
|
|
46
|
+
const controller = new AbortController();
|
|
47
|
+
const timeoutId = globalThis.setTimeout(() => controller.abort(), timeout);
|
|
48
|
+
try {
|
|
49
|
+
const response = await fetch(proxyUrl, {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers,
|
|
52
|
+
body: signedBody,
|
|
53
|
+
signal: controller.signal,
|
|
54
|
+
});
|
|
55
|
+
clearTimeout(timeoutId);
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
const errorText = await response.text();
|
|
58
|
+
throw ErrorFactory.createDatabaseError(`SQL Server proxy error: ${errorText}`);
|
|
59
|
+
}
|
|
60
|
+
const result = (await response.json());
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
clearTimeout(timeoutId);
|
|
65
|
+
if (error.name === 'AbortError') {
|
|
66
|
+
throw ErrorFactory.createGeneralError('SQL Server proxy request timed out');
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export function createSqlServerProxyAdapter() {
|
|
72
|
+
let connected = false;
|
|
73
|
+
let inTransaction = false;
|
|
74
|
+
return {
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
76
|
+
async connect() {
|
|
77
|
+
const proxyUrl = resolveProxyUrl();
|
|
78
|
+
Logger.info(`Connecting to SQL Server via proxy: ${proxyUrl}`);
|
|
79
|
+
connected = true;
|
|
80
|
+
},
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
82
|
+
async disconnect() {
|
|
83
|
+
connected = false;
|
|
84
|
+
inTransaction = false;
|
|
85
|
+
cache.clear();
|
|
86
|
+
Logger.info('Disconnected from SQL Server proxy');
|
|
87
|
+
},
|
|
88
|
+
async query(sql, parameters) {
|
|
89
|
+
if (!connected) {
|
|
90
|
+
throw ErrorFactory.createConnectionError('Not connected to SQL Server proxy');
|
|
91
|
+
}
|
|
92
|
+
if (sql.trim().toUpperCase().startsWith('SELECT')) {
|
|
93
|
+
const cacheKey = getCacheKey(sql, parameters);
|
|
94
|
+
const cached = getCachedResult(cacheKey);
|
|
95
|
+
if (cached)
|
|
96
|
+
return cached;
|
|
97
|
+
const result = await sendQuery(sql, parameters);
|
|
98
|
+
setCachedResult(cacheKey, result);
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
return sendQuery(sql, parameters);
|
|
102
|
+
},
|
|
103
|
+
async queryOne(sql, parameters) {
|
|
104
|
+
const result = await this.query(sql, parameters);
|
|
105
|
+
return result.rows[0] ?? null;
|
|
106
|
+
},
|
|
107
|
+
async ping() {
|
|
108
|
+
if (!connected) {
|
|
109
|
+
throw ErrorFactory.createConnectionError('Not connected to SQL Server proxy');
|
|
110
|
+
}
|
|
111
|
+
await this.query('SELECT 1 AS ping', []);
|
|
112
|
+
},
|
|
113
|
+
async transaction(callback) {
|
|
114
|
+
if (inTransaction) {
|
|
115
|
+
throw ErrorFactory.createGeneralError('Transaction already in progress');
|
|
116
|
+
}
|
|
117
|
+
inTransaction = true;
|
|
118
|
+
try {
|
|
119
|
+
await this.query('BEGIN TRANSACTION', []);
|
|
120
|
+
const result = await callback(this);
|
|
121
|
+
await this.query('COMMIT', []);
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
await this.query('ROLLBACK', []);
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
inTransaction = false;
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
async rawQuery(sql, parameters) {
|
|
133
|
+
const result = await this.query(sql, parameters ?? []);
|
|
134
|
+
return result.rows;
|
|
135
|
+
},
|
|
136
|
+
getType() {
|
|
137
|
+
return 'sqlserver-proxy';
|
|
138
|
+
},
|
|
139
|
+
isConnected() {
|
|
140
|
+
return connected;
|
|
141
|
+
},
|
|
142
|
+
getPlaceholder(index) {
|
|
143
|
+
return `@param${index}`;
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Optimizer.d.ts","sourceRoot":"","sources":["../../../src/performance/Optimizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3E,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,QAAQ,IAAI,OAAO,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,CAAC,CAAC;CACJ;AAkDD;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC1B;;OAEG;sBAES,MAAM,UACT,MAAM,eACD,MAAM,GACjB,gBAAgB;EAUnB,CAAC;
|
|
1
|
+
{"version":3,"file":"Optimizer.d.ts","sourceRoot":"","sources":["../../../src/performance/Optimizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3E,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,IAAI,OAAO,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,CAAC,CAAC;CACJ;AAkDD;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC1B;;OAEG;sBAES,MAAM,UACT,MAAM,eACD,MAAM,GACjB,gBAAgB;EAUnB,CAAC;AAiXH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;cACO,WAAW;EAqCrB,CAAC;AAEH;;GAEG;AAEH;;GAEG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,UAAU,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EACnC,SAAS,GAAE,MAAU,GACpB,OAAO,CAAC,CAAC,EAAE,CAAC,CAcd;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAEjF;AAED,eAAO,MAAM,iBAAiB;;;EAG5B,CAAC;AAEH;;GAEG;AAEH;;GAEG;AAEH,wBAAgB,cAAc,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAC9D,EAAE,EAAE,CAAC,EACL,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/F,CAAC,CA+DH;AAED,eAAO,MAAM,OAAO;;EAElB,CAAC;AAEH,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,CAAC,CAAC,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,WAAW,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC5B,OAAO,CAAC,CAAC,CAAC,CAAC;IACd,kBAAkB,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7F,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,QAAQ,IAAI;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,WAAW,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC;KAC/C,CAAC;IACF,SAAS,IAAI,IAAI,CAAC;IAClB,KAAK,IAAI,IAAI,CAAC;CACf;AASD;;;GAGG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;OAEG;cACO,qBAAqB;EAoE/B,CAAC;AA2HH,eAAe,oBAAoB,CAAC"}
|
|
@@ -192,17 +192,16 @@ function createCacheInstance(state) {
|
|
|
192
192
|
* Clear cache (async)
|
|
193
193
|
*/
|
|
194
194
|
async clear() {
|
|
195
|
-
|
|
196
|
-
clearInterval(state.cleanupInterval);
|
|
197
|
-
state.cleanupInterval = undefined;
|
|
198
|
-
}
|
|
199
|
-
if (state.flushTimer) {
|
|
200
|
-
clearTimeout(state.flushTimer);
|
|
201
|
-
state.flushTimer = undefined;
|
|
202
|
-
}
|
|
195
|
+
stopCacheTimers(state);
|
|
203
196
|
state.pendingWrites.clear();
|
|
204
197
|
await clearCache(state);
|
|
205
198
|
},
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
200
|
+
async dispose() {
|
|
201
|
+
stopCacheTimers(state);
|
|
202
|
+
state.pendingWrites.clear();
|
|
203
|
+
state.cache.clear();
|
|
204
|
+
},
|
|
206
205
|
/**
|
|
207
206
|
* Get cache statistics (async)
|
|
208
207
|
*/
|
|
@@ -211,6 +210,16 @@ function createCacheInstance(state) {
|
|
|
211
210
|
},
|
|
212
211
|
};
|
|
213
212
|
}
|
|
213
|
+
function stopCacheTimers(state) {
|
|
214
|
+
if (state.cleanupInterval) {
|
|
215
|
+
clearInterval(state.cleanupInterval);
|
|
216
|
+
state.cleanupInterval = undefined;
|
|
217
|
+
}
|
|
218
|
+
if (state.flushTimer) {
|
|
219
|
+
clearTimeout(state.flushTimer);
|
|
220
|
+
state.flushTimer = undefined;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
214
223
|
function attachCacheStateForTests(instance, state) {
|
|
215
224
|
Object.defineProperty(instance, GENERATION_CACHE_STATE_SYMBOL, {
|
|
216
225
|
value: state,
|
|
@@ -222,6 +231,10 @@ function attachCacheStateForTests(instance, state) {
|
|
|
222
231
|
*/
|
|
223
232
|
async function saveCacheToDisk(state) {
|
|
224
233
|
try {
|
|
234
|
+
if (state.flushTimer !== undefined) {
|
|
235
|
+
clearTimeout(state.flushTimer);
|
|
236
|
+
state.flushTimer = undefined;
|
|
237
|
+
}
|
|
225
238
|
const flushedEnsured = await flushPendingWrites(state);
|
|
226
239
|
if (!flushedEnsured) {
|
|
227
240
|
await ensureCacheDir(state.cacheDir);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ProxyErrorResponse = Readonly<{
|
|
2
|
+
status: number;
|
|
3
|
+
body: {
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
}>;
|
|
8
|
+
export declare const ErrorHandler: Readonly<{
|
|
9
|
+
toProxyError: (status: number, code: string, message: string) => ProxyErrorResponse;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=ErrorHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorHandler.d.ts","sourceRoot":"","sources":["../../../src/proxy/ErrorHandler.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC,CAAC,CAAC;AAOH,eAAO,MAAM,YAAY;2BALK,MAAM,QAAQ,MAAM,WAAW,MAAM,KAAG,kBAAkB;EAOtF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type PoolFactory<T> = () => T;
|
|
2
|
+
export type PoolDisposer<T> = (pool: T) => Promise<void> | void;
|
|
3
|
+
export type PoolManager<T> = Readonly<{
|
|
4
|
+
get: () => T;
|
|
5
|
+
dispose: () => Promise<void>;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const createPoolManager: <T>(create: PoolFactory<T>, dispose: PoolDisposer<T>) => PoolManager<T>;
|
|
8
|
+
//# sourceMappingURL=PoolManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PoolManager.d.ts","sourceRoot":"","sources":["../../../src/proxy/PoolManager.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AACrC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEhE,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,QAAQ,CAAC;IACpC,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC,CAAC;AAEH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EACjC,QAAQ,WAAW,CAAC,CAAC,CAAC,EACtB,SAAS,YAAY,CAAC,CAAC,CAAC,KACvB,WAAW,CAAC,CAAC,CAmBf,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const createPoolManager = (create, dispose) => {
|
|
2
|
+
let pool = null;
|
|
3
|
+
const get = () => {
|
|
4
|
+
pool ??= create();
|
|
5
|
+
return pool;
|
|
6
|
+
};
|
|
7
|
+
const disposePool = async () => {
|
|
8
|
+
if (pool === null)
|
|
9
|
+
return;
|
|
10
|
+
const current = pool;
|
|
11
|
+
pool = null;
|
|
12
|
+
await Promise.resolve(dispose(current));
|
|
13
|
+
};
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
get,
|
|
16
|
+
dispose: disposePool,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ProxyRequest = Readonly<{
|
|
2
|
+
method: string;
|
|
3
|
+
path: string;
|
|
4
|
+
headers: Record<string, string | undefined>;
|
|
5
|
+
body: string;
|
|
6
|
+
}>;
|
|
7
|
+
export type ProxyResponse = Readonly<{
|
|
8
|
+
status: number;
|
|
9
|
+
body: unknown;
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
}>;
|
|
12
|
+
export type ProxyBackend = Readonly<{
|
|
13
|
+
name: string;
|
|
14
|
+
handle: (request: ProxyRequest) => Promise<ProxyResponse>;
|
|
15
|
+
health: () => Promise<ProxyResponse>;
|
|
16
|
+
shutdown?: () => Promise<void>;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=ProxyBackend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyBackend.d.ts","sourceRoot":"","sources":["../../../src/proxy/ProxyBackend.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1D,MAAM,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ProxySigningConfig = Readonly<{
|
|
2
|
+
keyId: string;
|
|
3
|
+
secret: string;
|
|
4
|
+
require: boolean;
|
|
5
|
+
windowMs: number;
|
|
6
|
+
}>;
|
|
7
|
+
export type ProxyServerConfig = Readonly<{
|
|
8
|
+
host: string;
|
|
9
|
+
port: number;
|
|
10
|
+
maxBodyBytes: number;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=ProxyConfig.d.ts.map
|