@zintrust/core 0.1.40 → 0.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +22 -1
- package/package.json +24 -4
- package/public/error-pages/404.html +2 -2
- package/src/auth/Auth.js +1 -1
- package/src/boot/Application.d.ts +1 -16
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +2 -290
- package/src/boot/Server.d.ts +1 -1
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/bootstrap.js +50 -16
- package/src/boot/registry/registerRoute.d.ts +6 -0
- package/src/boot/registry/registerRoute.d.ts.map +1 -0
- package/src/boot/registry/registerRoute.js +96 -0
- package/src/boot/registry/runtime.d.ts +15 -0
- package/src/boot/registry/runtime.d.ts.map +1 -0
- package/src/boot/registry/runtime.js +364 -0
- package/src/boot/registry/type.d.ts +25 -0
- package/src/boot/registry/type.d.ts.map +1 -0
- package/src/boot/registry/type.js +1 -0
- package/src/boot/registry/worker.d.ts +6 -0
- package/src/boot/registry/worker.d.ts.map +1 -0
- package/src/boot/registry/worker.js +35 -0
- package/src/cache/drivers/KVRemoteDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVRemoteDriver.js +14 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +94 -34
- package/src/cli/ErrorHandler.js +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/ConfigCommand.js +3 -5
- package/src/cli/commands/ContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/ContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerProxiesCommand.js +77 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerWorkersCommand.js +57 -0
- package/src/cli/commands/D1LearnCommand.d.ts +9 -0
- package/src/cli/commands/D1LearnCommand.d.ts.map +1 -0
- package/src/cli/commands/D1LearnCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +55 -16
- package/src/cli/commands/DeployCommand.d.ts +16 -0
- package/src/cli/commands/DeployCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployCommand.js +110 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerProxiesCommand.js +27 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerWorkersCommand.js +27 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts +3 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/DockerComposeCommandUtils.js +34 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts +5 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts.map +1 -0
- package/src/cli/commands/DoctorArchitectureCommand.js +54 -0
- package/src/cli/commands/InitContainerCommand.d.ts +5 -0
- package/src/cli/commands/InitContainerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitContainerCommand.js +231 -0
- package/src/cli/commands/InitEcosystemCommand.d.ts +6 -0
- package/src/cli/commands/InitEcosystemCommand.d.ts.map +1 -0
- package/src/cli/commands/InitEcosystemCommand.js +51 -0
- package/src/cli/commands/InitProducerCommand.d.ts +5 -0
- package/src/cli/commands/InitProducerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProducerCommand.js +47 -0
- package/src/cli/commands/InitProxyCommand.d.ts +5 -0
- package/src/cli/commands/InitProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProxyCommand.js +442 -0
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +78 -36
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateWorkerCommand.js +36 -2
- package/src/cli/commands/MongoDBProxyCommand.d.ts +5 -0
- package/src/cli/commands/MongoDBProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MongoDBProxyCommand.js +98 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts +6 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MySqlProxyCommand.js +32 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts +6 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/PostgresProxyCommand.js +32 -0
- package/src/cli/commands/ProxyCommand.d.ts +12 -0
- package/src/cli/commands/ProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommand.js +80 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts +6 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommandUtils.js +38 -0
- package/src/cli/commands/PutCommand.d.ts +6 -0
- package/src/cli/commands/PutCommand.d.ts.map +1 -0
- package/src/cli/commands/PutCommand.js +173 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts +6 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts.map +1 -0
- package/src/cli/commands/QueueRecoveryCommand.js +612 -0
- package/src/cli/commands/RedisProxyCommand.d.ts +6 -0
- package/src/cli/commands/RedisProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/RedisProxyCommand.js +53 -0
- package/src/cli/commands/ScheduleListCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleListCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleListCommand.js +62 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleRunCommand.js +32 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleStartCommand.js +40 -0
- package/src/cli/commands/SecretsCommand.d.ts.map +1 -1
- package/src/cli/commands/SecretsCommand.js +2 -2
- package/src/cli/commands/SmtpProxyCommand.d.ts +6 -0
- package/src/cli/commands/SmtpProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SmtpProxyCommand.js +56 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts +46 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/SqlProxyCommandUtils.js +48 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts +5 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SqlServerProxyCommand.js +85 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +132 -17
- package/src/cli/commands/WorkerCommands.d.ts +1 -0
- package/src/cli/commands/WorkerCommands.d.ts.map +1 -1
- package/src/cli/commands/WorkerCommands.js +140 -6
- package/src/cli/commands/index.d.ts +2 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +2 -0
- package/src/cli/commands/runner/index.d.ts +2 -2
- package/src/cli/commands/runner/index.d.ts.map +1 -1
- package/src/cli/commands/runner/index.js +15 -4
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts +6 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts.map +1 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.js +55 -0
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigManager.js +8 -1
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +14 -1
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -1
- package/src/cli/d1/WranglerConfig.js +34 -2
- package/src/cli/index.d.ts +4 -0
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +4 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +2 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +1 -0
- package/src/cli/services/VersionChecker.d.ts.map +1 -1
- package/src/cli/services/VersionChecker.js +5 -1
- package/src/cli/utils/DatabaseCliUtils.d.ts.map +1 -1
- package/src/cli/utils/DatabaseCliUtils.js +6 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/cli/utils/EnvFileLoader.js +35 -15
- package/src/cli/workers/QueueWorkRunner.js +1 -1
- package/src/cli.d.ts +5 -0
- package/src/cli.d.ts.map +1 -0
- package/src/cli.js +4 -0
- package/src/collections/index.d.ts +2 -2
- package/src/collections/index.d.ts.map +1 -1
- package/src/collections/index.js +1 -1
- package/src/common/HealthRoutes.d.ts.map +1 -1
- package/src/common/HealthRoutes.js +50 -2
- package/src/common/RemoteSignedJson.d.ts +1 -0
- package/src/common/RemoteSignedJson.d.ts.map +1 -1
- package/src/common/RemoteSignedJson.js +81 -29
- package/src/common/index.d.ts +1 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +12 -1
- package/src/common/utility.d.ts.map +1 -1
- package/src/common/utility.js +2 -6
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +21 -6
- package/src/config/app.d.ts +4 -0
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +4 -0
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +22 -2
- package/src/config/cloudflare.d.ts +5 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/cloudflare.js +67 -8
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +48 -13
- package/src/config/env.d.ts +87 -2
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +158 -19
- package/src/config/index.d.ts +1 -0
- package/src/config/index.d.ts.map +1 -1
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +16 -10
- package/src/config/middleware.d.ts +5 -0
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +19 -1
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +70 -9
- package/src/config/redis.d.ts.map +1 -1
- package/src/config/redis.js +48 -13
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +1 -0
- package/src/config/type.d.ts +18 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/workers.d.ts.map +1 -1
- package/src/config/workers.js +122 -16
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +55 -1
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/helper/index.d.ts +225 -0
- package/src/helper/index.d.ts.map +1 -0
- package/src/helper/index.js +347 -0
- package/src/http/FileUpload.d.ts +3 -2
- package/src/http/FileUpload.d.ts.map +1 -1
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +2 -1
- package/src/http/error-pages/ErrorPageRenderer.d.ts +4 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -1
- package/src/http/error-pages/ErrorPageRenderer.js +141 -1
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -1
- package/src/http/middleware/BodyParsingMiddleware.js +33 -6
- package/src/index.d.ts +26 -57
- package/src/index.d.ts.map +1 -1
- package/src/index.js +32 -18
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/microservices/ServiceAuthMiddleware.js +12 -4
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +30 -16
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -1
- package/src/middleware/ErrorHandlerMiddleware.js +2 -1
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -1
- package/src/migrations/MigrationDiscovery.js +2 -1
- package/src/migrations/MigrationLoader.js +1 -1
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
- package/src/migrations/schema/SchemaCompiler.js +6 -3
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/fs.d.ts +1 -1
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/path.d.ts +1 -1
- package/src/node-singletons/path.d.ts.map +1 -1
- package/src/node-singletons/path.js +1 -1
- package/src/node-singletons/stream.d.ts +11 -0
- package/src/node-singletons/stream.d.ts.map +1 -0
- package/src/node-singletons/stream.js +8 -0
- package/src/observability/OpenTelemetry.d.ts +7 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -1
- package/src/observability/OpenTelemetry.js +49 -2
- package/src/orm/Database.d.ts +4 -0
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +80 -9
- package/src/orm/DatabaseAdapter.d.ts +1 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +2 -0
- package/src/orm/QueryBuilder.d.ts +1 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +33 -3
- package/src/orm/SchemaCompiler.d.ts.map +1 -1
- package/src/orm/SchemaCompiler.js +6 -3
- package/src/orm/SchemaStatemenWriter.d.ts +15 -0
- package/src/orm/SchemaStatemenWriter.d.ts.map +1 -0
- package/src/orm/SchemaStatemenWriter.js +78 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +52 -2
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +150 -89
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts +3 -0
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MongoDBProxyAdapter.js +128 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MySQLProxyAdapter.js +162 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.js +163 -0
- package/src/orm/adapters/ProxyCache.d.ts +9 -0
- package/src/orm/adapters/ProxyCache.d.ts.map +1 -0
- package/src/orm/adapters/ProxyCache.js +24 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts +11 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts.map +1 -0
- package/src/orm/adapters/ProxySignedRequest.js +30 -0
- package/src/orm/adapters/ProxySigningPath.d.ts +3 -0
- package/src/orm/adapters/ProxySigningPath.d.ts.map +1 -0
- package/src/orm/adapters/ProxySigningPath.js +25 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts +19 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.js +36 -0
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts +12 -0
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyRegistryMode.js +24 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts +6 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SqlServerProxyAdapter.js +154 -0
- package/src/orm/migrations/MigrationStore.js +1 -1
- package/src/performance/Optimizer.d.ts +1 -0
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +21 -8
- package/src/proxy/ErrorHandler.d.ts +11 -0
- package/src/proxy/ErrorHandler.d.ts.map +1 -0
- package/src/proxy/ErrorHandler.js +7 -0
- package/src/proxy/PoolManager.d.ts +8 -0
- package/src/proxy/PoolManager.d.ts.map +1 -0
- package/src/proxy/PoolManager.js +18 -0
- package/src/proxy/ProxyBackend.d.ts +18 -0
- package/src/proxy/ProxyBackend.d.ts.map +1 -0
- package/src/proxy/ProxyBackend.js +1 -0
- package/src/proxy/ProxyConfig.d.ts +12 -0
- package/src/proxy/ProxyConfig.d.ts.map +1 -0
- package/src/proxy/ProxyConfig.js +1 -0
- package/src/proxy/ProxyRegistry.d.ts +10 -0
- package/src/proxy/ProxyRegistry.d.ts.map +1 -0
- package/src/proxy/ProxyRegistry.js +11 -0
- package/src/proxy/ProxyRequestParsing.d.ts +9 -0
- package/src/proxy/ProxyRequestParsing.d.ts.map +1 -0
- package/src/proxy/ProxyRequestParsing.js +16 -0
- package/src/proxy/ProxyServer.d.ts +21 -0
- package/src/proxy/ProxyServer.d.ts.map +1 -0
- package/src/proxy/ProxyServer.js +84 -0
- package/src/proxy/ProxyServerUtils.d.ts +37 -0
- package/src/proxy/ProxyServerUtils.d.ts.map +1 -0
- package/src/proxy/ProxyServerUtils.js +42 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts +22 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts.map +1 -0
- package/src/proxy/ProxySigningConfigResolver.js +24 -0
- package/src/proxy/ProxySigningRequest.d.ts +12 -0
- package/src/proxy/ProxySigningRequest.d.ts.map +1 -0
- package/src/proxy/ProxySigningRequest.js +31 -0
- package/src/proxy/RequestValidator.d.ts +15 -0
- package/src/proxy/RequestValidator.d.ts.map +1 -0
- package/src/proxy/RequestValidator.js +26 -0
- package/src/proxy/SigningService.d.ts +39 -0
- package/src/proxy/SigningService.d.ts.map +1 -0
- package/src/proxy/SigningService.js +107 -0
- package/src/proxy/SqlPayloadValidator.d.ts +13 -0
- package/src/proxy/SqlPayloadValidator.d.ts.map +1 -0
- package/src/proxy/SqlPayloadValidator.js +14 -0
- package/src/proxy/SqlProxyDbOverrides.d.ts +17 -0
- package/src/proxy/SqlProxyDbOverrides.d.ts.map +1 -0
- package/src/proxy/SqlProxyDbOverrides.js +1 -0
- package/src/proxy/SqlProxyServerDeps.d.ts +12 -0
- package/src/proxy/SqlProxyServerDeps.d.ts.map +1 -0
- package/src/proxy/SqlProxyServerDeps.js +9 -0
- package/src/proxy/StatementPayloadValidator.d.ts +13 -0
- package/src/proxy/StatementPayloadValidator.d.ts.map +1 -0
- package/src/proxy/StatementPayloadValidator.js +18 -0
- package/src/proxy/StatementRegistryLoader.d.ts +2 -0
- package/src/proxy/StatementRegistryLoader.d.ts.map +1 -0
- package/src/proxy/StatementRegistryLoader.js +36 -0
- package/src/proxy/StatementRegistryResolver.d.ts +15 -0
- package/src/proxy/StatementRegistryResolver.d.ts.map +1 -0
- package/src/proxy/StatementRegistryResolver.js +34 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts +3 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -0
- package/src/proxy/d1/ZintrustD1Proxy.js +2 -0
- package/src/proxy/d1/register.d.ts +2 -0
- package/src/proxy/d1/register.d.ts.map +1 -0
- package/src/proxy/d1/register.js +5 -0
- package/src/proxy/isMutatingSql.d.ts +2 -0
- package/src/proxy/isMutatingSql.d.ts.map +1 -0
- package/src/proxy/isMutatingSql.js +12 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts +3 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -0
- package/src/proxy/kv/ZintrustKvProxy.js +2 -0
- package/src/proxy/kv/register.d.ts +2 -0
- package/src/proxy/kv/register.d.ts.map +1 -0
- package/src/proxy/kv/register.js +5 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts +33 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts.map +1 -0
- package/src/proxy/mongodb/MongoDBProxyServer.js +202 -0
- package/src/proxy/mongodb/register.d.ts +2 -0
- package/src/proxy/mongodb/register.d.ts.map +1 -0
- package/src/proxy/mongodb/register.js +5 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts +8 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -0
- package/src/proxy/mysql/MySqlProxyServer.js +202 -0
- package/src/proxy/mysql/register.d.ts +2 -0
- package/src/proxy/mysql/register.d.ts.map +1 -0
- package/src/proxy/mysql/register.js +5 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts +8 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -0
- package/src/proxy/postgres/PostgresProxyServer.js +178 -0
- package/src/proxy/postgres/register.d.ts +2 -0
- package/src/proxy/postgres/register.d.ts.map +1 -0
- package/src/proxy/postgres/register.js +5 -0
- package/src/proxy/redis/RedisProxyServer.d.ts +12 -0
- package/src/proxy/redis/RedisProxyServer.d.ts.map +1 -0
- package/src/proxy/redis/RedisProxyServer.js +192 -0
- package/src/proxy/redis/register.d.ts +2 -0
- package/src/proxy/redis/register.d.ts.map +1 -0
- package/src/proxy/redis/register.js +5 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts +19 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts.map +1 -0
- package/src/proxy/smtp/SmtpProxyServer.js +290 -0
- package/src/proxy/smtp/register.d.ts +2 -0
- package/src/proxy/smtp/register.d.ts.map +1 -0
- package/src/proxy/smtp/register.js +5 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts +8 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.js +203 -0
- package/src/proxy/sqlserver/register.d.ts +2 -0
- package/src/proxy/sqlserver/register.d.ts.map +1 -0
- package/src/proxy/sqlserver/register.js +5 -0
- package/src/proxy.d.ts +4 -0
- package/src/proxy.d.ts.map +1 -0
- package/src/proxy.js +3 -0
- package/src/routes/doc.d.ts.map +1 -1
- package/src/routes/doc.js +16 -2
- package/src/routes/error.d.ts +5 -4
- package/src/routes/error.d.ts.map +1 -1
- package/src/routes/error.js +15 -13
- package/src/routes/errorPages.d.ts +2 -0
- package/src/routes/errorPages.d.ts.map +1 -1
- package/src/routes/errorPages.js +144 -4
- package/src/runtime/PluginAutoImports.d.ts +1 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +94 -9
- package/src/runtime/RuntimeAdapter.d.ts +8 -9
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/RuntimeAdapter.js +120 -34
- package/src/runtime/RuntimeServices.d.ts +47 -0
- package/src/runtime/RuntimeServices.d.ts.map +1 -0
- package/src/runtime/RuntimeServices.js +164 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts +4 -4
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +12 -0
- package/src/runtime/WorkerAdapterImports.d.ts +5 -0
- package/src/runtime/WorkerAdapterImports.d.ts.map +1 -0
- package/src/runtime/WorkerAdapterImports.js +17 -0
- package/src/runtime/WorkersModule.d.ts +6 -0
- package/src/runtime/WorkersModule.d.ts.map +1 -0
- package/src/runtime/WorkersModule.js +278 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +19 -2
- package/src/runtime/adapters/DenoAdapter.js +1 -0
- package/src/runtime/adapters/FargateAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.js +1 -1
- package/src/runtime/detectRuntime.d.ts +10 -0
- package/src/runtime/detectRuntime.d.ts.map +1 -0
- package/src/runtime/detectRuntime.js +57 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -1
- package/src/runtime/useFileLoader.js +16 -0
- package/src/scheduler/Schedule.d.ts +36 -0
- package/src/scheduler/Schedule.d.ts.map +1 -0
- package/src/scheduler/Schedule.js +197 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts +8 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts.map +1 -0
- package/src/scheduler/ScheduleHttpGateway.js +196 -0
- package/src/scheduler/ScheduleRunner.d.ts +6 -0
- package/src/scheduler/ScheduleRunner.d.ts.map +1 -1
- package/src/scheduler/ScheduleRunner.js +166 -29
- package/src/scheduler/SchedulerRuntime.d.ts +15 -0
- package/src/scheduler/SchedulerRuntime.d.ts.map +1 -0
- package/src/scheduler/SchedulerRuntime.js +79 -0
- package/src/scheduler/cron/Cron.d.ts +19 -0
- package/src/scheduler/cron/Cron.d.ts.map +1 -0
- package/src/scheduler/cron/Cron.js +200 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts +14 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts.map +1 -0
- package/src/scheduler/leader/SchedulerLeader.js +187 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts +27 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts.map +1 -0
- package/src/scheduler/state/ScheduleStateStore.js +27 -0
- package/src/scheduler/types.d.ts +10 -0
- package/src/scheduler/types.d.ts.map +1 -1
- package/src/schedules/index.d.ts +1 -0
- package/src/schedules/index.d.ts.map +1 -1
- package/src/schedules/index.js +1 -0
- package/src/schedules/job-tracking-cleanup.d.ts +4 -0
- package/src/schedules/job-tracking-cleanup.d.ts.map +1 -0
- package/src/schedules/job-tracking-cleanup.js +116 -0
- package/src/schedules/log-cleanup.d.ts +1 -2
- package/src/schedules/log-cleanup.d.ts.map +1 -1
- package/src/schedules/log-cleanup.js +12 -15
- package/src/scripts/TemplateImportsCheck.js +2 -2
- package/src/scripts/TemplateSync.js +3 -4
- package/src/security/CsrfTokenManager.d.ts.map +1 -1
- package/src/security/CsrfTokenManager.js +12 -0
- package/src/security/Hash.d.ts +1 -1
- package/src/security/Hash.d.ts.map +1 -1
- package/src/security/Hash.js +31 -36
- package/src/security/Sanitizer.d.ts.map +1 -1
- package/src/security/Sanitizer.js +1 -9
- package/src/security/SignedRequest.d.ts.map +1 -1
- package/src/security/SignedRequest.js +2 -2
- package/src/seeders/SeederLoader.js +1 -1
- package/src/session/SessionManager.d.ts +3 -0
- package/src/session/SessionManager.d.ts.map +1 -1
- package/src/session/SessionManager.js +49 -10
- package/src/sockets/CloudflareSocket.d.ts +24 -0
- package/src/sockets/CloudflareSocket.d.ts.map +1 -0
- package/src/sockets/CloudflareSocket.js +259 -0
- package/src/start.d.ts.map +1 -1
- package/src/start.js +1 -8
- package/src/templates/docker/docker-compose.ecosystem.yml.tpl +301 -0
- package/src/templates/docker/docker-compose.schedules.yml.tpl +84 -0
- package/src/templates/project/basic/app/Schedules/index.ts.tpl +0 -0
- package/src/templates/project/basic/config/database.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
- package/src/toolkit/Secrets/Manifest.d.ts.map +1 -1
- package/src/toolkit/Secrets/Manifest.js +5 -7
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
- package/src/tools/mail/drivers/Smtp.js +229 -18
- package/src/tools/mail/index.d.ts.map +1 -1
- package/src/tools/mail/index.js +5 -4
- package/src/tools/mail/template-loader.d.ts.map +1 -1
- package/src/tools/mail/template-loader.js +197 -29
- package/src/tools/mail/templates/auth-password-reset.d.ts +3 -0
- package/src/tools/mail/templates/auth-password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-password-reset.js +231 -0
- package/src/tools/mail/templates/auth-welcome.d.ts +3 -0
- package/src/tools/mail/templates/auth-welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-welcome.js +236 -0
- package/src/tools/mail/templates/general.d.ts +3 -0
- package/src/tools/mail/templates/general.d.ts.map +1 -0
- package/src/tools/mail/templates/general.js +109 -0
- package/src/tools/mail/templates/index.js +2 -2
- package/src/tools/mail/templates/job-completed.d.ts +3 -0
- package/src/tools/mail/templates/job-completed.d.ts.map +1 -0
- package/src/tools/mail/templates/job-completed.js +188 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts +3 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts.map +1 -0
- package/src/tools/mail/templates/notifications-new-comment.js +228 -0
- package/src/tools/mail/templates/password-reset.d.ts +3 -0
- package/src/tools/mail/templates/password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/password-reset.js +221 -0
- package/src/tools/mail/templates/performance-report.d.ts +3 -0
- package/src/tools/mail/templates/performance-report.d.ts.map +1 -0
- package/src/tools/mail/templates/performance-report.js +258 -0
- package/src/tools/mail/templates/welcome.d.ts +3 -0
- package/src/tools/mail/templates/welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/welcome.js +187 -0
- package/src/tools/mail/templates/worker-alert.d.ts +3 -0
- package/src/tools/mail/templates/worker-alert.d.ts.map +1 -0
- package/src/tools/mail/templates/worker-alert.js +229 -0
- package/src/tools/notification/Notification.js +1 -1
- package/src/tools/notification/testingHelpers.js +6 -5
- package/src/tools/queue/AdvancedQueue.js +2 -6
- package/src/tools/queue/IdempotencyManager.d.ts +6 -0
- package/src/tools/queue/IdempotencyManager.d.ts.map +1 -0
- package/src/tools/queue/IdempotencyManager.js +36 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts +16 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts.map +1 -0
- package/src/tools/queue/JobHeartbeatStore.js +67 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts +16 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts.map +1 -0
- package/src/tools/queue/JobReconciliationRunner.js +56 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts +27 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts.map +1 -0
- package/src/tools/queue/JobRecoveryDaemon.js +303 -0
- package/src/tools/queue/JobStateTracker.d.ts +140 -0
- package/src/tools/queue/JobStateTracker.d.ts.map +1 -0
- package/src/tools/queue/JobStateTracker.js +409 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts +12 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts.map +1 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.js +239 -0
- package/src/tools/queue/Queue.d.ts.map +1 -1
- package/src/tools/queue/Queue.js +160 -16
- package/src/tools/queue/QueueDataRedactor.d.ts +6 -0
- package/src/tools/queue/QueueDataRedactor.d.ts.map +1 -0
- package/src/tools/queue/QueueDataRedactor.js +45 -0
- package/src/tools/queue/QueueExtensions.d.ts.map +1 -1
- package/src/tools/queue/QueueExtensions.js +2 -1
- package/src/tools/queue/QueueReliabilityMetrics.d.ts +38 -0
- package/src/tools/queue/QueueReliabilityMetrics.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityMetrics.js +131 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts +7 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.js +59 -0
- package/src/tools/queue/QueueRuntimeRegistration.d.ts +1 -9
- package/src/tools/queue/QueueRuntimeRegistration.d.ts.map +1 -1
- package/src/tools/queue/QueueRuntimeRegistration.js +75 -4
- package/src/tools/queue/QueueTracing.d.ts +32 -0
- package/src/tools/queue/QueueTracing.d.ts.map +1 -0
- package/src/tools/queue/QueueTracing.js +151 -0
- package/src/tools/queue/StalledJobMonitor.d.ts +5 -0
- package/src/tools/queue/StalledJobMonitor.d.ts.map +1 -0
- package/src/tools/queue/StalledJobMonitor.js +21 -0
- package/src/tools/queue/TimeoutManager.d.ts +14 -0
- package/src/tools/queue/TimeoutManager.d.ts.map +1 -0
- package/src/tools/queue/TimeoutManager.js +77 -0
- package/src/tools/queue/drivers/Redis.d.ts +1 -0
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -0
- package/src/tools/queue/index.d.ts +10 -0
- package/src/tools/queue/index.d.ts.map +1 -1
- package/src/tools/queue/index.js +10 -0
- package/src/tools/storage/drivers/R2.d.ts +13 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -1
- package/src/tools/storage/drivers/R2.js +29 -0
- package/src/zintrust.plugins.d.ts +9 -0
- package/src/zintrust.plugins.d.ts.map +1 -0
- package/src/zintrust.plugins.js +7 -0
- package/src/zintrust.plugins.wg.d.ts +9 -0
- package/src/zintrust.plugins.wg.d.ts.map +1 -0
- package/src/zintrust.plugins.wg.js +7 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type SqlProxyMode = 'sql' | 'registry';
|
|
2
|
+
export declare const resolveSqlProxyMode: (envKey: string) => SqlProxyMode;
|
|
3
|
+
export declare const createStatementId: (sql: string) => Promise<string>;
|
|
4
|
+
export declare const createStatementPayload: (sql: string, parameters: unknown[]) => Promise<{
|
|
5
|
+
statementId: string;
|
|
6
|
+
params: unknown[];
|
|
7
|
+
}>;
|
|
8
|
+
export declare const getExecMetaWithLastRowId: (value: unknown) => {
|
|
9
|
+
changes: number;
|
|
10
|
+
lastRowId?: number | string | bigint;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=SqlProxyRegistryMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlProxyRegistryMode.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SqlProxyRegistryMode.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,UAAU,CAAC;AAE9C,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,KAAG,YAGpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,CAEnE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,KAAK,MAAM,EACX,YAAY,OAAO,EAAE,KACpB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CAGpD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,OAAO,OAAO,KACb;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;CAOzD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Env } from '../../config/env.js';
|
|
2
|
+
import { isRecord } from '../adapters/SqlProxyAdapterUtils.js';
|
|
3
|
+
import { SignedRequest } from '../../security/SignedRequest.js';
|
|
4
|
+
export const resolveSqlProxyMode = (envKey) => {
|
|
5
|
+
const raw = Env.get(envKey, 'sql').trim().toLowerCase();
|
|
6
|
+
return raw === 'registry' ? 'registry' : 'sql';
|
|
7
|
+
};
|
|
8
|
+
export const createStatementId = async (sql) => {
|
|
9
|
+
return SignedRequest.sha256Hex(sql);
|
|
10
|
+
};
|
|
11
|
+
export const createStatementPayload = async (sql, parameters) => {
|
|
12
|
+
const statementId = await createStatementId(sql);
|
|
13
|
+
return { statementId, params: parameters };
|
|
14
|
+
};
|
|
15
|
+
export const getExecMetaWithLastRowId = (value) => {
|
|
16
|
+
if (!isRecord(value) || typeof value['ok'] !== 'boolean')
|
|
17
|
+
return { changes: 0 };
|
|
18
|
+
const meta = value['meta'];
|
|
19
|
+
if (!isRecord(meta))
|
|
20
|
+
return { changes: 0 };
|
|
21
|
+
const changes = typeof meta['changes'] === 'number' ? meta['changes'] : 0;
|
|
22
|
+
const lastRowId = meta['lastRowId'];
|
|
23
|
+
return { changes, lastRowId: lastRowId };
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlServerProxyAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SqlServerProxyAdapter.ts"],"names":[],"mappings":"AACA;;GAEG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAwO1E,wBAAgB,2BAA2B,IAAI,gBAAgB,CAI9D"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
2
|
+
/**
|
|
3
|
+
* SQL Server Proxy Adapter (HTTP)
|
|
4
|
+
*/
|
|
5
|
+
import { Env } from '../../config/env.js';
|
|
6
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
7
|
+
import { AdaptersEnum } from '../../migrations/enum/index.js';
|
|
8
|
+
import { QueryBuilder } from '../QueryBuilder.js';
|
|
9
|
+
import { ensureSignedSettings, isRecord, requestSignedProxy, } from '../adapters/SqlProxyAdapterUtils.js';
|
|
10
|
+
import { createStatementPayload, getExecMetaWithLastRowId, resolveSqlProxyMode, } from '../adapters/SqlProxyRegistryMode.js';
|
|
11
|
+
const resolveProxyMode = () => {
|
|
12
|
+
return resolveSqlProxyMode('SQLSERVER_PROXY_MODE');
|
|
13
|
+
};
|
|
14
|
+
const resolveBaseUrl = () => {
|
|
15
|
+
const explicit = Env.get('SQLSERVER_PROXY_URL', '').trim();
|
|
16
|
+
if (explicit !== '')
|
|
17
|
+
return explicit;
|
|
18
|
+
const host = Env.get('SQLSERVER_PROXY_HOST', '127.0.0.1');
|
|
19
|
+
const port = Env.getInt('SQLSERVER_PROXY_PORT', 8793);
|
|
20
|
+
return `http://${host}:${port}`;
|
|
21
|
+
};
|
|
22
|
+
const buildProxySettings = () => {
|
|
23
|
+
const baseUrl = resolveBaseUrl();
|
|
24
|
+
const keyId = Env.get('SQLSERVER_PROXY_KEY_ID', '');
|
|
25
|
+
const secret = Env.get('SQLSERVER_PROXY_SECRET', '');
|
|
26
|
+
const timeoutMs = Env.getInt('SQLSERVER_PROXY_TIMEOUT_MS', Env.ZT_PROXY_TIMEOUT_MS ?? 30000);
|
|
27
|
+
return { baseUrl, keyId, secret, timeoutMs };
|
|
28
|
+
};
|
|
29
|
+
const buildSignedProxyConfig = (settings) => ({
|
|
30
|
+
settings,
|
|
31
|
+
missingUrlMessage: 'SQL Server proxy URL is missing (SQLSERVER_PROXY_URL)',
|
|
32
|
+
missingCredentialsMessage: 'SQL Server proxy signing credentials are missing (SQLSERVER_PROXY_KEY_ID / SQLSERVER_PROXY_SECRET)',
|
|
33
|
+
messages: {
|
|
34
|
+
unauthorized: 'SQL Server proxy unauthorized',
|
|
35
|
+
forbidden: 'SQL Server proxy forbidden',
|
|
36
|
+
rateLimited: 'SQL Server proxy rate limited',
|
|
37
|
+
rejected: 'SQL Server proxy rejected request',
|
|
38
|
+
error: 'SQL Server proxy error',
|
|
39
|
+
timedOut: 'SQL Server proxy request timed out',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const isQueryResponse = (value) => isRecord(value) && Array.isArray(value['rows']) && typeof value['rowCount'] === 'number';
|
|
43
|
+
const isQueryOneResponse = (value) => isRecord(value) && 'row' in value;
|
|
44
|
+
const requestProxy = async (settings, path, payload) => requestSignedProxy(buildSignedProxyConfig(settings), path, payload);
|
|
45
|
+
const requireConnected = (state) => {
|
|
46
|
+
if (!state.connected)
|
|
47
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
48
|
+
};
|
|
49
|
+
const toQueryResult = (out) => {
|
|
50
|
+
if (isQueryResponse(out)) {
|
|
51
|
+
return { rows: out.rows, rowCount: out.rowCount };
|
|
52
|
+
}
|
|
53
|
+
if (isQueryOneResponse(out)) {
|
|
54
|
+
const row = out.row ?? null;
|
|
55
|
+
return { rows: row ? [row] : [], rowCount: row ? 1 : 0 };
|
|
56
|
+
}
|
|
57
|
+
const meta = getExecMetaWithLastRowId(out);
|
|
58
|
+
return { rows: [], rowCount: meta.changes, lastInsertId: meta.lastRowId };
|
|
59
|
+
};
|
|
60
|
+
const createQuery = (state) => async (sql, parameters) => {
|
|
61
|
+
requireConnected(state);
|
|
62
|
+
const mode = resolveProxyMode();
|
|
63
|
+
const out = mode === 'registry'
|
|
64
|
+
? await requestProxy(state.settings, '/zin/sqlserver/statement', await createStatementPayload(sql, parameters))
|
|
65
|
+
: await requestProxy(state.settings, '/zin/sqlserver/query', {
|
|
66
|
+
sql,
|
|
67
|
+
params: parameters,
|
|
68
|
+
});
|
|
69
|
+
return toQueryResult(out);
|
|
70
|
+
};
|
|
71
|
+
const createQueryOne = (state) => async (sql, parameters) => {
|
|
72
|
+
requireConnected(state);
|
|
73
|
+
const mode = resolveProxyMode();
|
|
74
|
+
if (mode !== 'registry') {
|
|
75
|
+
const out = await requestProxy(state.settings, '/zin/sqlserver/queryOne', {
|
|
76
|
+
sql,
|
|
77
|
+
params: parameters,
|
|
78
|
+
});
|
|
79
|
+
return out.row ?? null;
|
|
80
|
+
}
|
|
81
|
+
const out = await requestProxy(state.settings, '/zin/sqlserver/statement', await createStatementPayload(sql, parameters));
|
|
82
|
+
if (isQueryOneResponse(out))
|
|
83
|
+
return out.row ?? null;
|
|
84
|
+
if (isQueryResponse(out))
|
|
85
|
+
return out.rows[0] ?? null;
|
|
86
|
+
return null;
|
|
87
|
+
};
|
|
88
|
+
const createPing = (query) => async () => {
|
|
89
|
+
await query(QueryBuilder.create('').select('1').toSQL(), []);
|
|
90
|
+
};
|
|
91
|
+
const createTransaction = (state, getAdapter) => async (callback) => {
|
|
92
|
+
if (state.inTransaction) {
|
|
93
|
+
throw ErrorFactory.createGeneralError('Transaction already in progress');
|
|
94
|
+
}
|
|
95
|
+
requireConnected(state);
|
|
96
|
+
state.inTransaction = true;
|
|
97
|
+
try {
|
|
98
|
+
const adapter = getAdapter();
|
|
99
|
+
await adapter.query('BEGIN TRANSACTION', []);
|
|
100
|
+
const result = await callback(adapter);
|
|
101
|
+
await adapter.query('COMMIT', []);
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
try {
|
|
106
|
+
await getAdapter().query('ROLLBACK', []);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
void 0;
|
|
110
|
+
}
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
state.inTransaction = false;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const createRawQuery = (query) => async (sql, parameters) => {
|
|
118
|
+
const result = await query(sql, parameters ?? []);
|
|
119
|
+
return result.rows;
|
|
120
|
+
};
|
|
121
|
+
const createAdapter = (state) => {
|
|
122
|
+
const query = createQuery(state);
|
|
123
|
+
const queryOne = createQueryOne(state);
|
|
124
|
+
const adapter = {
|
|
125
|
+
async connect() {
|
|
126
|
+
ensureSignedSettings(buildSignedProxyConfig(state.settings));
|
|
127
|
+
state.connected = true;
|
|
128
|
+
},
|
|
129
|
+
async disconnect() {
|
|
130
|
+
state.connected = false;
|
|
131
|
+
state.inTransaction = false;
|
|
132
|
+
},
|
|
133
|
+
query,
|
|
134
|
+
queryOne,
|
|
135
|
+
ping: createPing(query),
|
|
136
|
+
transaction: createTransaction(state, () => adapter),
|
|
137
|
+
rawQuery: createRawQuery(query),
|
|
138
|
+
getType() {
|
|
139
|
+
return AdaptersEnum.sqlserver;
|
|
140
|
+
},
|
|
141
|
+
isConnected() {
|
|
142
|
+
return state.connected;
|
|
143
|
+
},
|
|
144
|
+
getPlaceholder(index) {
|
|
145
|
+
return `@param${index}`;
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
return adapter;
|
|
149
|
+
};
|
|
150
|
+
export function createSqlServerProxyAdapter() {
|
|
151
|
+
const settings = buildProxySettings();
|
|
152
|
+
const state = { connected: false, inTransaction: false, settings };
|
|
153
|
+
return createAdapter(state);
|
|
154
|
+
}
|
|
@@ -12,7 +12,7 @@ const toSafeService = (service) => {
|
|
|
12
12
|
};
|
|
13
13
|
const assertDbSupportsMigrations = (db) => {
|
|
14
14
|
const t = db.getType();
|
|
15
|
-
if (t === 'd1'
|
|
15
|
+
if (t === 'd1') {
|
|
16
16
|
throw ErrorFactory.createCliError('This project is configured for D1. Use `zin d1:migrate --local|--remote` for now.');
|
|
17
17
|
}
|
|
18
18
|
};
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyConfig.d.ts","sourceRoot":"","sources":["../../../src/proxy/ProxyConfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ProxyRegistration = Readonly<{
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const ProxyRegistry: Readonly<{
|
|
6
|
+
register: (proxy: ProxyRegistration) => void;
|
|
7
|
+
get: (name: string) => ProxyRegistration | undefined;
|
|
8
|
+
list: () => ProxyRegistration[];
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=ProxyRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyRegistry.d.ts","sourceRoot":"","sources":["../../../src/proxy/ProxyRegistry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAYH,eAAO,MAAM,aAAa;sBARD,iBAAiB,KAAG,IAAI;gBAI9B,MAAM,KAAG,iBAAiB,GAAG,SAAS;gBAExC,iBAAiB,EAAE;EAMlC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const registry = new Map();
|
|
2
|
+
const register = (proxy) => {
|
|
3
|
+
registry.set(proxy.name, proxy);
|
|
4
|
+
};
|
|
5
|
+
const get = (name) => registry.get(name);
|
|
6
|
+
const list = () => Array.from(registry.values());
|
|
7
|
+
export const ProxyRegistry = Object.freeze({
|
|
8
|
+
register,
|
|
9
|
+
get,
|
|
10
|
+
list,
|
|
11
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProxyResponse } from './ProxyBackend';
|
|
2
|
+
export declare const validateProxyRequest: (request: {
|
|
3
|
+
method: string;
|
|
4
|
+
}) => ProxyResponse | null;
|
|
5
|
+
export declare const parseJsonBody: (body: string) => {
|
|
6
|
+
ok: true;
|
|
7
|
+
value: Record<string, unknown>;
|
|
8
|
+
} | ProxyResponse;
|
|
9
|
+
//# sourceMappingURL=ProxyRequestParsing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyRequestParsing.d.ts","sourceRoot":"","sources":["../../../src/proxy/ProxyRequestParsing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,eAAO,MAAM,oBAAoB,GAAI,SAAS;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,KAAG,aAAa,GAAG,IAMlF,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,KACX;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,aAMjD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ErrorHandler } from './ErrorHandler.js';
|
|
2
|
+
import { RequestValidator } from './RequestValidator.js';
|
|
3
|
+
export const validateProxyRequest = (request) => {
|
|
4
|
+
const methodError = RequestValidator.requirePost(request.method);
|
|
5
|
+
if (methodError) {
|
|
6
|
+
return ErrorHandler.toProxyError(405, methodError.code, methodError.message);
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
export const parseJsonBody = (body) => {
|
|
11
|
+
const parsed = RequestValidator.parseJson(body);
|
|
12
|
+
if (!parsed.ok) {
|
|
13
|
+
return ErrorHandler.toProxyError(400, parsed.error.code, parsed.error.message);
|
|
14
|
+
}
|
|
15
|
+
return { ok: true, value: parsed.value };
|
|
16
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IncomingMessage, type Server } from '../node-singletons/http';
|
|
2
|
+
import type { ProxyBackend } from './ProxyBackend';
|
|
3
|
+
export type ProxyServerOptions = Readonly<{
|
|
4
|
+
host: string;
|
|
5
|
+
port: number;
|
|
6
|
+
maxBodyBytes: number;
|
|
7
|
+
backend: ProxyBackend;
|
|
8
|
+
verify?: (req: IncomingMessage, body: string) => Promise<{
|
|
9
|
+
ok: true;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
status: number;
|
|
13
|
+
message: string;
|
|
14
|
+
}>;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const createProxyServer: (options: ProxyServerOptions) => Readonly<{
|
|
17
|
+
start: () => Promise<void>;
|
|
18
|
+
stop: () => Promise<void>;
|
|
19
|
+
server: Server;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=ProxyServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyServer.d.ts","sourceRoot":"","sources":["../../../src/proxy/ProxyServer.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,MAAM,EAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAA+B,MAAM,qBAAqB,CAAC;AAErF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,CACP,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC;QAAE,EAAE,EAAE,IAAI,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7E,CAAC,CAAC;AA0CH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,kBAAkB,KAC1B,QAAQ,CAAC;IACV,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,CAsDA,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
2
|
+
import { createServer, } from '../node-singletons/http.js';
|
|
3
|
+
const readBody = async (req, maxBodyBytes) => {
|
|
4
|
+
const chunks = [];
|
|
5
|
+
let size = 0;
|
|
6
|
+
for await (const chunk of req) {
|
|
7
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
8
|
+
size += buffer.length;
|
|
9
|
+
if (size > maxBodyBytes) {
|
|
10
|
+
throw ErrorFactory.createValidationError('Body too large');
|
|
11
|
+
}
|
|
12
|
+
chunks.push(buffer);
|
|
13
|
+
}
|
|
14
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
15
|
+
};
|
|
16
|
+
const respond = (res, response) => {
|
|
17
|
+
res.writeHead(response.status, {
|
|
18
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
19
|
+
'Cache-Control': 'no-store',
|
|
20
|
+
...response.headers,
|
|
21
|
+
});
|
|
22
|
+
res.end(JSON.stringify(response.body));
|
|
23
|
+
};
|
|
24
|
+
const toProxyRequest = (req, body) => {
|
|
25
|
+
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
|
|
26
|
+
const headers = {};
|
|
27
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
28
|
+
headers[key.toLowerCase()] = Array.isArray(value) ? value.join(',') : value;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
method: req.method ?? 'POST',
|
|
32
|
+
path: url.pathname,
|
|
33
|
+
headers,
|
|
34
|
+
body,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export const createProxyServer = (options) => {
|
|
38
|
+
const server = createServer(async (req, res) => {
|
|
39
|
+
try {
|
|
40
|
+
const body = await readBody(req, options.maxBodyBytes);
|
|
41
|
+
if ((req.url ?? '').startsWith('/health')) {
|
|
42
|
+
const response = await options.backend.health();
|
|
43
|
+
respond(res, response);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (options.verify) {
|
|
47
|
+
const verified = await options.verify(req, body);
|
|
48
|
+
if (!verified.ok) {
|
|
49
|
+
respond(res, {
|
|
50
|
+
status: verified.status,
|
|
51
|
+
body: { code: 'UNAUTHORIZED', message: verified.message },
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const request = toProxyRequest(req, body);
|
|
57
|
+
const response = await options.backend.handle(request);
|
|
58
|
+
respond(res, response);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
respond(res, {
|
|
62
|
+
status: 500,
|
|
63
|
+
body: { code: 'PROXY_ERROR', message: String(error) },
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const start = async () => new Promise((resolve) => {
|
|
68
|
+
server.listen(options.port, options.host, () => resolve());
|
|
69
|
+
});
|
|
70
|
+
const stop = async () => new Promise((resolve, reject) => {
|
|
71
|
+
server.close((error) => {
|
|
72
|
+
if (error) {
|
|
73
|
+
reject(error);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
resolve();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return Object.freeze({
|
|
80
|
+
start,
|
|
81
|
+
stop,
|
|
82
|
+
server,
|
|
83
|
+
});
|
|
84
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IncomingMessage } from '../node-singletons/http';
|
|
2
|
+
import type { ProxySigningConfig } from './ProxyConfig';
|
|
3
|
+
export type BaseProxyConfig = {
|
|
4
|
+
host: string;
|
|
5
|
+
port: number;
|
|
6
|
+
maxBodyBytes: number;
|
|
7
|
+
};
|
|
8
|
+
export type BaseProxyOverrides = Partial<{
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
maxBodyBytes: number;
|
|
12
|
+
requireSigning: boolean;
|
|
13
|
+
keyId: string;
|
|
14
|
+
secret: string;
|
|
15
|
+
signingWindowMs: number;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const resolveBaseConfig: (overrides: BaseProxyOverrides, prefix: string, defaults?: {
|
|
18
|
+
host?: string;
|
|
19
|
+
port?: number;
|
|
20
|
+
maxBodyBytes?: number;
|
|
21
|
+
}) => BaseProxyConfig;
|
|
22
|
+
export declare const resolveBaseSigningConfig: (overrides: BaseProxyOverrides, prefix: string) => {
|
|
23
|
+
keyId: string;
|
|
24
|
+
secret: string;
|
|
25
|
+
requireSigning: boolean;
|
|
26
|
+
signingWindowMs: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const verifyRequestSignature: (req: IncomingMessage, body: string, config: {
|
|
29
|
+
signing: ProxySigningConfig;
|
|
30
|
+
}, serviceName: string) => Promise<{
|
|
31
|
+
ok: boolean;
|
|
32
|
+
error?: {
|
|
33
|
+
status: number;
|
|
34
|
+
message: string;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
//# sourceMappingURL=ProxyServerUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyServerUtils.d.ts","sourceRoot":"","sources":["../../../src/proxy/ProxyServerUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAI7D,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAEH,eAAO,MAAM,iBAAiB,GAC5B,WAAW,kBAAkB,EAC7B,QAAQ,MAAM,EACd,WAAW;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,KACjE,eAUF,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,WAAW,kBAAkB,EAC7B,QAAQ,MAAM,KACb;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CAOtB,CAAC;AAEL,eAAO,MAAM,sBAAsB,GACjC,KAAK,eAAe,EACpB,MAAM,MAAM,EACZ,QAAQ;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,EACvC,aAAa,MAAM,KAClB,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CA8BtE,CAAC"}
|