@encore.dev/sdk 0.0.0 → 2.0.0-beta.11
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/LICENSE +362 -0
- package/README.md +245 -2
- package/app_meta.test.ts +154 -0
- package/app_meta.ts +226 -0
- package/config/config.test.ts +384 -0
- package/config/config.ts +236 -0
- package/config/mod.ts +15 -0
- package/config/secrets.ts +173 -0
- package/config/value.ts +239 -0
- package/cron/mod.test.ts +52 -0
- package/cron/mod.ts +62 -0
- package/dist/app_meta.d.ts +126 -0
- package/dist/app_meta.d.ts.map +1 -0
- package/dist/app_meta.js +67 -0
- package/dist/app_meta.js.map +1 -0
- package/dist/config/config.d.ts +135 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +115 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/mod.d.ts +5 -0
- package/dist/config/mod.d.ts.map +1 -0
- package/dist/config/mod.js +3 -0
- package/dist/config/mod.js.map +1 -0
- package/dist/config/secrets.d.ts +124 -0
- package/dist/config/secrets.d.ts.map +1 -0
- package/dist/config/secrets.js +73 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/config/value.d.ts +54 -0
- package/dist/config/value.d.ts.map +1 -0
- package/dist/config/value.js +181 -0
- package/dist/config/value.js.map +1 -0
- package/dist/cron/mod.d.ts +57 -0
- package/dist/cron/mod.d.ts.map +1 -0
- package/dist/cron/mod.js +39 -0
- package/dist/cron/mod.js.map +1 -0
- package/dist/frontends/mod.d.ts +39 -0
- package/dist/frontends/mod.d.ts.map +1 -0
- package/dist/frontends/mod.js +47 -0
- package/dist/frontends/mod.js.map +1 -0
- package/dist/gateway/errors.d.ts +101 -0
- package/dist/gateway/errors.d.ts.map +1 -0
- package/dist/gateway/errors.js +146 -0
- package/dist/gateway/errors.js.map +1 -0
- package/dist/gateway/match.d.ts +127 -0
- package/dist/gateway/match.d.ts.map +1 -0
- package/dist/gateway/match.js +206 -0
- package/dist/gateway/match.js.map +1 -0
- package/dist/gateway/middleware.d.ts +108 -0
- package/dist/gateway/middleware.d.ts.map +1 -0
- package/dist/gateway/middleware.js +9 -0
- package/dist/gateway/middleware.js.map +1 -0
- package/dist/gateway/mod.d.ts +130 -0
- package/dist/gateway/mod.d.ts.map +1 -0
- package/dist/gateway/mod.js +188 -0
- package/dist/gateway/mod.js.map +1 -0
- package/dist/gateway/request.d.ts +304 -0
- package/dist/gateway/request.d.ts.map +1 -0
- package/dist/gateway/request.js +403 -0
- package/dist/gateway/request.js.map +1 -0
- package/dist/gateway/serve.d.ts +114 -0
- package/dist/gateway/serve.d.ts.map +1 -0
- package/dist/gateway/serve.js +510 -0
- package/dist/gateway/serve.js.map +1 -0
- package/dist/gateways/mod.d.ts +42 -0
- package/dist/gateways/mod.d.ts.map +1 -0
- package/dist/gateways/mod.js +55 -0
- package/dist/gateways/mod.js.map +1 -0
- package/dist/internal/clients/call.d.ts +171 -0
- package/dist/internal/clients/call.d.ts.map +1 -0
- package/dist/internal/clients/call.js +284 -0
- package/dist/internal/clients/call.js.map +1 -0
- package/dist/internal/clients/grpc.d.ts +108 -0
- package/dist/internal/clients/grpc.d.ts.map +1 -0
- package/dist/internal/clients/grpc.js +349 -0
- package/dist/internal/clients/grpc.js.map +1 -0
- package/dist/internal/clients/mod.d.ts +81 -0
- package/dist/internal/clients/mod.d.ts.map +1 -0
- package/dist/internal/clients/mod.js +237 -0
- package/dist/internal/clients/mod.js.map +1 -0
- package/dist/internal/fetch.d.ts +67 -0
- package/dist/internal/fetch.d.ts.map +1 -0
- package/dist/internal/fetch.js +271 -0
- package/dist/internal/fetch.js.map +1 -0
- package/dist/internal/otel/backend.d.ts +52 -0
- package/dist/internal/otel/backend.d.ts.map +1 -0
- package/dist/internal/otel/backend.js +2 -0
- package/dist/internal/otel/backend.js.map +1 -0
- package/dist/internal/otel/context.d.ts +11 -0
- package/dist/internal/otel/context.d.ts.map +1 -0
- package/dist/internal/otel/context.js +34 -0
- package/dist/internal/otel/context.js.map +1 -0
- package/dist/internal/otel/context_manager.d.ts +23 -0
- package/dist/internal/otel/context_manager.d.ts.map +1 -0
- package/dist/internal/otel/context_manager.js +120 -0
- package/dist/internal/otel/context_manager.js.map +1 -0
- package/dist/internal/otel/encode.d.ts +114 -0
- package/dist/internal/otel/encode.d.ts.map +1 -0
- package/dist/internal/otel/encode.js +290 -0
- package/dist/internal/otel/encode.js.map +1 -0
- package/dist/internal/otel/http.d.ts +11 -0
- package/dist/internal/otel/http.d.ts.map +1 -0
- package/dist/internal/otel/http.js +65 -0
- package/dist/internal/otel/http.js.map +1 -0
- package/dist/internal/otel/index.d.ts +9 -0
- package/dist/internal/otel/index.d.ts.map +1 -0
- package/dist/internal/otel/index.js +8 -0
- package/dist/internal/otel/index.js.map +1 -0
- package/dist/internal/otel/meter.d.ts +74 -0
- package/dist/internal/otel/meter.d.ts.map +1 -0
- package/dist/internal/otel/meter.js +265 -0
- package/dist/internal/otel/meter.js.map +1 -0
- package/dist/internal/otel/propagator.d.ts +15 -0
- package/dist/internal/otel/propagator.d.ts.map +1 -0
- package/dist/internal/otel/propagator.js +61 -0
- package/dist/internal/otel/propagator.js.map +1 -0
- package/dist/internal/otel/provider.d.ts +13 -0
- package/dist/internal/otel/provider.d.ts.map +1 -0
- package/dist/internal/otel/provider.js +22 -0
- package/dist/internal/otel/provider.js.map +1 -0
- package/dist/internal/otel/span.d.ts +75 -0
- package/dist/internal/otel/span.d.ts.map +1 -0
- package/dist/internal/otel/span.js +234 -0
- package/dist/internal/otel/span.js.map +1 -0
- package/dist/internal/otel/tracer.d.ts +16 -0
- package/dist/internal/otel/tracer.d.ts.map +1 -0
- package/dist/internal/otel/tracer.js +71 -0
- package/dist/internal/otel/tracer.js.map +1 -0
- package/dist/internal/reqfields.d.ts +170 -0
- package/dist/internal/reqfields.d.ts.map +1 -0
- package/dist/internal/reqfields.js +349 -0
- package/dist/internal/reqfields.js.map +1 -0
- package/dist/internal/runtime/meter.d.ts +12 -0
- package/dist/internal/runtime/meter.d.ts.map +1 -0
- package/dist/internal/runtime/meter.js +22 -0
- package/dist/internal/runtime/meter.js.map +1 -0
- package/dist/internal/runtime/mod.d.ts +18 -0
- package/dist/internal/runtime/mod.d.ts.map +1 -0
- package/dist/internal/runtime/mod.js +59 -0
- package/dist/internal/runtime/mod.js.map +1 -0
- package/dist/internal/runtime/napi/napi.cjs +308 -0
- package/dist/internal/runtime/napi/napi.d.cts +1249 -0
- package/dist/internal/runtime/shutdown.d.ts +91 -0
- package/dist/internal/runtime/shutdown.d.ts.map +1 -0
- package/dist/internal/runtime/shutdown.js +299 -0
- package/dist/internal/runtime/shutdown.js.map +1 -0
- package/dist/internal/testing/carry.d.ts +49 -0
- package/dist/internal/testing/carry.d.ts.map +1 -0
- package/dist/internal/testing/carry.js +77 -0
- package/dist/internal/testing/carry.js.map +1 -0
- package/dist/internal/testing/runner.d.ts +2 -0
- package/dist/internal/testing/runner.d.ts.map +1 -0
- package/dist/internal/testing/runner.js +10 -0
- package/dist/internal/testing/runner.js.map +1 -0
- package/dist/internal/testing/scope.d.ts +112 -0
- package/dist/internal/testing/scope.d.ts.map +1 -0
- package/dist/internal/testing/scope.js +346 -0
- package/dist/internal/testing/scope.js.map +1 -0
- package/dist/internal/testing/steps.d.ts +55 -0
- package/dist/internal/testing/steps.d.ts.map +1 -0
- package/dist/internal/testing/steps.js +295 -0
- package/dist/internal/testing/steps.js.map +1 -0
- package/dist/internal/testing/telemetry.d.ts +305 -0
- package/dist/internal/testing/telemetry.d.ts.map +1 -0
- package/dist/internal/testing/telemetry.js +188 -0
- package/dist/internal/testing/telemetry.js.map +1 -0
- package/dist/internal/utils/constraints.d.ts +10 -0
- package/dist/internal/utils/constraints.d.ts.map +1 -0
- package/dist/internal/utils/constraints.js +2 -0
- package/dist/internal/utils/constraints.js.map +1 -0
- package/dist/log/index.d.ts +40 -0
- package/dist/log/index.d.ts.map +1 -0
- package/dist/log/index.js +44 -0
- package/dist/log/index.js.map +1 -0
- package/dist/log/logger.d.ts +125 -0
- package/dist/log/logger.d.ts.map +1 -0
- package/dist/log/logger.js +203 -0
- package/dist/log/logger.js.map +1 -0
- package/dist/log/runtime.d.ts +21 -0
- package/dist/log/runtime.d.ts.map +1 -0
- package/dist/log/runtime.js +22 -0
- package/dist/log/runtime.js.map +1 -0
- package/dist/log/stderr.d.ts +10 -0
- package/dist/log/stderr.d.ts.map +1 -0
- package/dist/log/stderr.js +25 -0
- package/dist/log/stderr.js.map +1 -0
- package/dist/metrics/mod.d.ts +242 -0
- package/dist/metrics/mod.d.ts.map +1 -0
- package/dist/metrics/mod.js +353 -0
- package/dist/metrics/mod.js.map +1 -0
- package/dist/mod.d.ts +5 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +3 -0
- package/dist/mod.js.map +1 -0
- package/dist/otel.d.ts +10 -0
- package/dist/otel.d.ts.map +1 -0
- package/dist/otel.js +13 -0
- package/dist/otel.js.map +1 -0
- package/dist/pubsub/encoding.d.ts +8 -0
- package/dist/pubsub/encoding.d.ts.map +1 -0
- package/dist/pubsub/encoding.js +18 -0
- package/dist/pubsub/encoding.js.map +1 -0
- package/dist/pubsub/mod.d.ts +7 -0
- package/dist/pubsub/mod.d.ts.map +1 -0
- package/dist/pubsub/mod.js +3 -0
- package/dist/pubsub/mod.js.map +1 -0
- package/dist/pubsub/refs.d.ts +20 -0
- package/dist/pubsub/refs.d.ts.map +1 -0
- package/dist/pubsub/refs.js +11 -0
- package/dist/pubsub/refs.js.map +1 -0
- package/dist/pubsub/subscription.d.ts +223 -0
- package/dist/pubsub/subscription.d.ts.map +1 -0
- package/dist/pubsub/subscription.js +121 -0
- package/dist/pubsub/subscription.js.map +1 -0
- package/dist/pubsub/topic.d.ts +218 -0
- package/dist/pubsub/topic.d.ts.map +1 -0
- package/dist/pubsub/topic.js +281 -0
- package/dist/pubsub/topic.js.map +1 -0
- package/dist/reqctx/mod.d.ts +174 -0
- package/dist/reqctx/mod.d.ts.map +1 -0
- package/dist/reqctx/mod.js +144 -0
- package/dist/reqctx/mod.js.map +1 -0
- package/dist/services/index.d.ts +171 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +187 -0
- package/dist/services/index.js.map +1 -0
- package/dist/shutdown/mod.d.ts +60 -0
- package/dist/shutdown/mod.d.ts.map +1 -0
- package/dist/shutdown/mod.js +59 -0
- package/dist/shutdown/mod.js.map +1 -0
- package/dist/storage/clickhouse/database.d.ts +262 -0
- package/dist/storage/clickhouse/database.d.ts.map +1 -0
- package/dist/storage/clickhouse/database.js +362 -0
- package/dist/storage/clickhouse/database.js.map +1 -0
- package/dist/storage/clickhouse/errors.d.ts +67 -0
- package/dist/storage/clickhouse/errors.d.ts.map +1 -0
- package/dist/storage/clickhouse/errors.js +91 -0
- package/dist/storage/clickhouse/errors.js.map +1 -0
- package/dist/storage/clickhouse/mod.d.ts +31 -0
- package/dist/storage/clickhouse/mod.d.ts.map +1 -0
- package/dist/storage/clickhouse/mod.js +29 -0
- package/dist/storage/clickhouse/mod.js.map +1 -0
- package/dist/storage/objects/bucket.d.ts +522 -0
- package/dist/storage/objects/bucket.d.ts.map +1 -0
- package/dist/storage/objects/bucket.js +414 -0
- package/dist/storage/objects/bucket.js.map +1 -0
- package/dist/storage/objects/error.d.ts +24 -0
- package/dist/storage/objects/error.d.ts.map +1 -0
- package/dist/storage/objects/error.js +105 -0
- package/dist/storage/objects/error.js.map +1 -0
- package/dist/storage/objects/mod.d.ts +5 -0
- package/dist/storage/objects/mod.d.ts.map +1 -0
- package/dist/storage/objects/mod.js +3 -0
- package/dist/storage/objects/mod.js.map +1 -0
- package/dist/storage/objects/refs.d.ts +47 -0
- package/dist/storage/objects/refs.d.ts.map +1 -0
- package/dist/storage/objects/refs.js +26 -0
- package/dist/storage/objects/refs.js.map +1 -0
- package/dist/storage/postgres/database.d.ts +365 -0
- package/dist/storage/postgres/database.d.ts.map +1 -0
- package/dist/storage/postgres/database.js +480 -0
- package/dist/storage/postgres/database.js.map +1 -0
- package/dist/storage/postgres/errors.d.ts +120 -0
- package/dist/storage/postgres/errors.d.ts.map +1 -0
- package/dist/storage/postgres/errors.js +162 -0
- package/dist/storage/postgres/errors.js.map +1 -0
- package/dist/storage/postgres/interval.d.ts +44 -0
- package/dist/storage/postgres/interval.d.ts.map +1 -0
- package/dist/storage/postgres/interval.js +153 -0
- package/dist/storage/postgres/interval.js.map +1 -0
- package/dist/storage/postgres/mod.d.ts +5 -0
- package/dist/storage/postgres/mod.d.ts.map +1 -0
- package/dist/storage/postgres/mod.js +4 -0
- package/dist/storage/postgres/mod.js.map +1 -0
- package/dist/storage/redis/bitfield.d.ts +67 -0
- package/dist/storage/redis/bitfield.d.ts.map +1 -0
- package/dist/storage/redis/bitfield.js +114 -0
- package/dist/storage/redis/bitfield.js.map +1 -0
- package/dist/storage/redis/command.d.ts +45 -0
- package/dist/storage/redis/command.d.ts.map +1 -0
- package/dist/storage/redis/command.js +78 -0
- package/dist/storage/redis/command.js.map +1 -0
- package/dist/storage/redis/commands.d.ts +657 -0
- package/dist/storage/redis/commands.d.ts.map +1 -0
- package/dist/storage/redis/commands.js +759 -0
- package/dist/storage/redis/commands.js.map +1 -0
- package/dist/storage/redis/database.d.ts +336 -0
- package/dist/storage/redis/database.d.ts.map +1 -0
- package/dist/storage/redis/database.js +398 -0
- package/dist/storage/redis/database.js.map +1 -0
- package/dist/storage/redis/mod.d.ts +115 -0
- package/dist/storage/redis/mod.d.ts.map +1 -0
- package/dist/storage/redis/mod.js +109 -0
- package/dist/storage/redis/mod.js.map +1 -0
- package/dist/storage/redis/native.d.ts +16 -0
- package/dist/storage/redis/native.d.ts.map +1 -0
- package/dist/storage/redis/native.js +21 -0
- package/dist/storage/redis/native.js.map +1 -0
- package/dist/storage/redis/options.d.ts +90 -0
- package/dist/storage/redis/options.d.ts.map +1 -0
- package/dist/storage/redis/options.js +53 -0
- package/dist/storage/redis/options.js.map +1 -0
- package/dist/storage/redis/pubsub.d.ts +55 -0
- package/dist/storage/redis/pubsub.d.ts.map +1 -0
- package/dist/storage/redis/pubsub.js +88 -0
- package/dist/storage/redis/pubsub.js.map +1 -0
- package/dist/storage/redis/reply.d.ts +290 -0
- package/dist/storage/redis/reply.d.ts.map +1 -0
- package/dist/storage/redis/reply.js +611 -0
- package/dist/storage/redis/reply.js.map +1 -0
- package/dist/storage/redis/scan.d.ts +12 -0
- package/dist/storage/redis/scan.d.ts.map +1 -0
- package/dist/storage/redis/scan.js +76 -0
- package/dist/storage/redis/scan.js.map +1 -0
- package/dist/storage/redis/script.d.ts +92 -0
- package/dist/storage/redis/script.d.ts.map +1 -0
- package/dist/storage/redis/script.js +143 -0
- package/dist/storage/redis/script.js.map +1 -0
- package/dist/storage/redis/target.d.ts +49 -0
- package/dist/storage/redis/target.d.ts.map +1 -0
- package/dist/storage/redis/target.js +93 -0
- package/dist/storage/redis/target.js.map +1 -0
- package/dist/storage/redis/wire.d.ts +102 -0
- package/dist/storage/redis/wire.d.ts.map +1 -0
- package/dist/storage/redis/wire.js +309 -0
- package/dist/storage/redis/wire.js.map +1 -0
- package/dist/testing/bun.d.ts +8 -0
- package/dist/testing/bun.d.ts.map +1 -0
- package/dist/testing/bun.js +13 -0
- package/dist/testing/bun.js.map +1 -0
- package/dist/testing/jest.d.ts +8 -0
- package/dist/testing/jest.d.ts.map +1 -0
- package/dist/testing/jest.js +11 -0
- package/dist/testing/jest.js.map +1 -0
- package/dist/testing/mod.d.ts +183 -0
- package/dist/testing/mod.d.ts.map +1 -0
- package/dist/testing/mod.js +271 -0
- package/dist/testing/mod.js.map +1 -0
- package/dist/testing/node.d.ts +9 -0
- package/dist/testing/node.d.ts.map +1 -0
- package/dist/testing/node.js +12 -0
- package/dist/testing/node.js.map +1 -0
- package/dist/testing/playwright.d.ts +93 -0
- package/dist/testing/playwright.d.ts.map +1 -0
- package/dist/testing/playwright.js +164 -0
- package/dist/testing/playwright.js.map +1 -0
- package/dist/testing/puppeteer.d.ts +36 -0
- package/dist/testing/puppeteer.d.ts.map +1 -0
- package/dist/testing/puppeteer.js +70 -0
- package/dist/testing/puppeteer.js.map +1 -0
- package/dist/testing/system.d.ts +181 -0
- package/dist/testing/system.d.ts.map +1 -0
- package/dist/testing/system.js +255 -0
- package/dist/testing/system.js.map +1 -0
- package/dist/testing/vitest.d.ts +8 -0
- package/dist/testing/vitest.d.ts.map +1 -0
- package/dist/testing/vitest.js +13 -0
- package/dist/testing/vitest.js.map +1 -0
- package/dist/tracing/http.d.ts +11 -0
- package/dist/tracing/http.d.ts.map +1 -0
- package/dist/tracing/http.js +34 -0
- package/dist/tracing/http.js.map +1 -0
- package/dist/tracing/mod.d.ts +20 -0
- package/dist/tracing/mod.d.ts.map +1 -0
- package/dist/tracing/mod.js +47 -0
- package/dist/tracing/mod.js.map +1 -0
- package/dist/tracing/node.d.ts +10 -0
- package/dist/tracing/node.d.ts.map +1 -0
- package/dist/tracing/node.js +142 -0
- package/dist/tracing/node.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/mod.d.ts +43 -0
- package/dist/types/mod.d.ts.map +1 -0
- package/dist/types/mod.js +65 -0
- package/dist/types/mod.js.map +1 -0
- package/frontends/mod.test.ts +51 -0
- package/frontends/mod.ts +50 -0
- package/gateway/errors.ts +172 -0
- package/gateway/gateway.e2e.test.ts +297 -0
- package/gateway/gateway.test.ts +891 -0
- package/gateway/match.ts +239 -0
- package/gateway/middleware.ts +134 -0
- package/gateway/mod.ts +211 -0
- package/gateway/request.ts +578 -0
- package/gateway/serve.ts +738 -0
- package/gateways/mod.ts +60 -0
- package/internal/clients/call.ts +418 -0
- package/internal/clients/grpc.test.ts +664 -0
- package/internal/clients/grpc.ts +485 -0
- package/internal/clients/mod.test.ts +481 -0
- package/internal/clients/mod.ts +337 -0
- package/internal/fetch.ts +320 -0
- package/internal/otel/backend.ts +60 -0
- package/internal/otel/context.test.ts +70 -0
- package/internal/otel/context.ts +48 -0
- package/internal/otel/context_manager.test.ts +154 -0
- package/internal/otel/context_manager.ts +141 -0
- package/internal/otel/encode.test.ts +266 -0
- package/internal/otel/encode.ts +408 -0
- package/internal/otel/http.ts +92 -0
- package/internal/otel/index.ts +14 -0
- package/internal/otel/meter.test.ts +231 -0
- package/internal/otel/meter.ts +332 -0
- package/internal/otel/propagator.test.ts +105 -0
- package/internal/otel/propagator.ts +68 -0
- package/internal/otel/provider.ts +26 -0
- package/internal/otel/span.ts +281 -0
- package/internal/otel/tracer.test.ts +380 -0
- package/internal/otel/tracer.ts +111 -0
- package/internal/reqfields.ts +423 -0
- package/internal/runtime/meter.ts +26 -0
- package/internal/runtime/mod.ts +81 -0
- package/internal/runtime/napi/napi.cjs +308 -0
- package/internal/runtime/napi/napi.d.cts +1249 -0
- package/internal/runtime/shutdown.test.ts +464 -0
- package/internal/runtime/shutdown.ts +350 -0
- package/internal/testing/carry.test.ts +242 -0
- package/internal/testing/carry.ts +101 -0
- package/internal/testing/runner.ts +10 -0
- package/internal/testing/scope.ts +384 -0
- package/internal/testing/steps.test.ts +152 -0
- package/internal/testing/steps.ts +342 -0
- package/internal/testing/telemetry.test.ts +210 -0
- package/internal/testing/telemetry.ts +466 -0
- package/internal/utils/constraints.ts +12 -0
- package/log/index.ts +107 -0
- package/log/logger.test.ts +194 -0
- package/log/logger.ts +308 -0
- package/log/runtime.test.ts +65 -0
- package/log/runtime.ts +40 -0
- package/log/stderr.test.ts +23 -0
- package/log/stderr.ts +24 -0
- package/metrics/export.test.ts +341 -0
- package/metrics/mod.test.ts +177 -0
- package/metrics/mod.ts +450 -0
- package/mod.ts +15 -0
- package/otel.test.ts +98 -0
- package/otel.ts +17 -0
- package/package.json +208 -5
- package/pubsub/encoding.ts +18 -0
- package/pubsub/mod.ts +26 -0
- package/pubsub/pubsub.test.ts +405 -0
- package/pubsub/refs.ts +38 -0
- package/pubsub/subscription.ts +359 -0
- package/pubsub/topic.test.ts +147 -0
- package/pubsub/topic.ts +431 -0
- package/reqctx/mod.ts +267 -0
- package/reqctx/reqctx.test.ts +216 -0
- package/scripts/postprocess-docs.test.ts +58 -0
- package/services/index.test.ts +393 -0
- package/services/index.ts +215 -0
- package/shutdown/mod.ts +78 -0
- package/storage/clickhouse/database.integration.test.ts +337 -0
- package/storage/clickhouse/database.test.ts +279 -0
- package/storage/clickhouse/database.ts +586 -0
- package/storage/clickhouse/errors.ts +130 -0
- package/storage/clickhouse/mod.ts +37 -0
- package/storage/objects/bucket.test.ts +573 -0
- package/storage/objects/bucket.ts +968 -0
- package/storage/objects/error.ts +121 -0
- package/storage/objects/mod.ts +50 -0
- package/storage/objects/refs.ts +117 -0
- package/storage/postgres/database.integration.test.ts +450 -0
- package/storage/postgres/database.test.ts +428 -0
- package/storage/postgres/database.ts +658 -0
- package/storage/postgres/errors.ts +186 -0
- package/storage/postgres/interval.test.ts +72 -0
- package/storage/postgres/interval.ts +170 -0
- package/storage/postgres/mod.ts +19 -0
- package/storage/redis/bitfield.ts +162 -0
- package/storage/redis/command.ts +84 -0
- package/storage/redis/commands.ts +1471 -0
- package/storage/redis/database.ts +520 -0
- package/storage/redis/mod.ts +171 -0
- package/storage/redis/native.ts +22 -0
- package/storage/redis/options.ts +119 -0
- package/storage/redis/pubsub.ts +92 -0
- package/storage/redis/redis.test.ts +866 -0
- package/storage/redis/reply.ts +780 -0
- package/storage/redis/runtime.test.ts +248 -0
- package/storage/redis/scan.ts +125 -0
- package/storage/redis/script.ts +162 -0
- package/storage/redis/target.ts +134 -0
- package/storage/redis/wire.ts +345 -0
- package/testing/bun.ts +13 -0
- package/testing/jest.ts +11 -0
- package/testing/mod.ts +393 -0
- package/testing/node.ts +12 -0
- package/testing/playwright.ts +247 -0
- package/testing/puppeteer.ts +101 -0
- package/testing/system.test.ts +108 -0
- package/testing/system.ts +373 -0
- package/testing/vitest.ts +13 -0
- package/tracing/http.ts +49 -0
- package/tracing/mod.ts +83 -0
- package/tracing/native.test.ts +276 -0
- package/tracing/node.ts +176 -0
- package/tracing/tracing.test.ts +953 -0
- package/types/mod.ts +92 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import {beforeEach, expect, mock, test} from 'bun:test';
|
|
2
|
+
|
|
3
|
+
const ClickHouseAccess = {Read: 0, Write: 1, Admin: 2};
|
|
4
|
+
|
|
5
|
+
let batches: Record<string, unknown>[][];
|
|
6
|
+
let closes: number;
|
|
7
|
+
let nextArgs: (number | undefined)[];
|
|
8
|
+
let calls: {
|
|
9
|
+
method: string;
|
|
10
|
+
access: number;
|
|
11
|
+
sql?: string;
|
|
12
|
+
params?: Params;
|
|
13
|
+
settings?: Record<string, string>;
|
|
14
|
+
queryId?: string;
|
|
15
|
+
}[];
|
|
16
|
+
let failWith: Error | undefined;
|
|
17
|
+
|
|
18
|
+
class Params {
|
|
19
|
+
constructor(
|
|
20
|
+
public names: string[],
|
|
21
|
+
public values: unknown[],
|
|
22
|
+
) {}
|
|
23
|
+
types(): string[] {
|
|
24
|
+
return this.values.map(v =>
|
|
25
|
+
v !== null &&
|
|
26
|
+
typeof v === 'object' &&
|
|
27
|
+
'__encore_clickhouse_type' in (v as object)
|
|
28
|
+
? (v as {type: string}).type
|
|
29
|
+
: typeof v === 'number'
|
|
30
|
+
? 'Int64'
|
|
31
|
+
: 'String',
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const database = {
|
|
37
|
+
connectionString: (access: number) => `http://access-${access}/db`,
|
|
38
|
+
async query(
|
|
39
|
+
access: number,
|
|
40
|
+
sql: string,
|
|
41
|
+
params: Params,
|
|
42
|
+
settings?: Record<string, string>,
|
|
43
|
+
queryId?: string,
|
|
44
|
+
) {
|
|
45
|
+
calls.push({method: 'query', access, sql, params, settings, queryId});
|
|
46
|
+
if (failWith !== undefined) throw failWith;
|
|
47
|
+
let i = 0;
|
|
48
|
+
return {
|
|
49
|
+
queryId: 'q',
|
|
50
|
+
async next(max?: number) {
|
|
51
|
+
nextArgs.push(max);
|
|
52
|
+
return i < batches.length ? batches[i++] : null;
|
|
53
|
+
},
|
|
54
|
+
async close() {
|
|
55
|
+
closes++;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
async exec(
|
|
60
|
+
access: number,
|
|
61
|
+
sql: string,
|
|
62
|
+
params: Params,
|
|
63
|
+
settings?: Record<string, string>,
|
|
64
|
+
queryId?: string,
|
|
65
|
+
) {
|
|
66
|
+
calls.push({method: 'exec', access, sql, params, settings, queryId});
|
|
67
|
+
return {
|
|
68
|
+
queryId: queryId ?? 'generated',
|
|
69
|
+
rowsRead: 1,
|
|
70
|
+
bytesRead: 2,
|
|
71
|
+
rowsWritten: 3,
|
|
72
|
+
bytesWritten: 4,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
async insert(
|
|
76
|
+
access: number,
|
|
77
|
+
table: string,
|
|
78
|
+
rows: {rows: unknown[]},
|
|
79
|
+
settings?: Record<string, string>,
|
|
80
|
+
queryId?: string,
|
|
81
|
+
) {
|
|
82
|
+
calls.push({
|
|
83
|
+
method: 'insert',
|
|
84
|
+
access,
|
|
85
|
+
sql: table,
|
|
86
|
+
params: new Params([], rows.rows),
|
|
87
|
+
settings,
|
|
88
|
+
queryId,
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
queryId: 'i',
|
|
92
|
+
rowsRead: 0,
|
|
93
|
+
bytesRead: 0,
|
|
94
|
+
rowsWritten: rows.rows.length,
|
|
95
|
+
bytesWritten: 10,
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
mock.module('../../internal/runtime/mod', () => ({
|
|
101
|
+
RT: {clickhouseDatabase: () => database},
|
|
102
|
+
ClickHouseAccess,
|
|
103
|
+
ClickHouseParams: Params,
|
|
104
|
+
ClickHouseInsertRows: class {
|
|
105
|
+
constructor(public rows: unknown[]) {}
|
|
106
|
+
},
|
|
107
|
+
Decimal: class {
|
|
108
|
+
constructor(private readonly text: string) {}
|
|
109
|
+
toString() {
|
|
110
|
+
return this.text;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
}));
|
|
114
|
+
mock.module('../../internal/otel/index', () => ({
|
|
115
|
+
activeCtxBytes: () => undefined,
|
|
116
|
+
}));
|
|
117
|
+
const {
|
|
118
|
+
Database,
|
|
119
|
+
DatabaseError,
|
|
120
|
+
DatabaseRef,
|
|
121
|
+
Queryable,
|
|
122
|
+
TooManyRowsError,
|
|
123
|
+
Typed,
|
|
124
|
+
typed,
|
|
125
|
+
} = await import('./mod');
|
|
126
|
+
const {Decimal} = await import('../../types/mod');
|
|
127
|
+
const {fromNative} = await import('./errors');
|
|
128
|
+
|
|
129
|
+
beforeEach(() => {
|
|
130
|
+
batches = [];
|
|
131
|
+
closes = 0;
|
|
132
|
+
nextArgs = [];
|
|
133
|
+
calls = [];
|
|
134
|
+
failWith = undefined;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('access handles are queryable with their access; declarations are not', async () => {
|
|
138
|
+
const db = new Database('events');
|
|
139
|
+
expect(db instanceof Queryable).toBe(false);
|
|
140
|
+
expect(db.read()).toBe(db.read());
|
|
141
|
+
const handles = [db, db.read(), db.write(), db.admin()];
|
|
142
|
+
for (const handle of handles.slice(1)) {
|
|
143
|
+
expect(handle instanceof DatabaseRef).toBe(true);
|
|
144
|
+
expect(handle instanceof Queryable).toBe(true);
|
|
145
|
+
}
|
|
146
|
+
for (const handle of handles) await handle.rawQueryAll('SELECT 1');
|
|
147
|
+
expect(calls.map(c => c.access)).toEqual([1, 0, 1, 2]);
|
|
148
|
+
expect(db.connectionString).toBe('http://access-1/db');
|
|
149
|
+
expect(db.read().connectionString).toBe('http://access-0/db');
|
|
150
|
+
expect(db.admin().connectionString).toBe('http://access-2/db');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('tagged templates bind each value as a typed placeholder', async () => {
|
|
154
|
+
const db = new Database('events');
|
|
155
|
+
await db.queryAll`SELECT * FROM t WHERE id = ${5} AND name = ${'x'} AND u = ${typed('abc', 'UUID')}`;
|
|
156
|
+
expect(calls[0].sql).toBe(
|
|
157
|
+
'SELECT * FROM t WHERE id = {p0:Int64} AND name = {p1:String} AND u = {p2:UUID}',
|
|
158
|
+
);
|
|
159
|
+
expect(calls[0].params!.names).toEqual(['p0', 'p1', 'p2']);
|
|
160
|
+
expect(calls[0].params!.values[2]).toBeInstanceOf(Typed);
|
|
161
|
+
|
|
162
|
+
await db.exec`INSERT INTO t VALUES (${new Decimal('12.300')}, ${[new Decimal('1')]})`;
|
|
163
|
+
expect(calls[1].sql).toBe(
|
|
164
|
+
'INSERT INTO t VALUES ({p0:Decimal(76, 3)}, {p1:String})',
|
|
165
|
+
);
|
|
166
|
+
const [dec, decs] = calls[1].params!.values as [
|
|
167
|
+
{value: string; type: string},
|
|
168
|
+
{value: string; type: string}[],
|
|
169
|
+
];
|
|
170
|
+
expect([dec.value, dec.type]).toEqual(['12.300', 'Decimal(76, 3)']);
|
|
171
|
+
expect([decs[0].value, decs[0].type]).toEqual(['1', 'Decimal(76, 0)']);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('raw forms pass named parameters, settings as text, and the query id', async () => {
|
|
175
|
+
const db = new Database('events');
|
|
176
|
+
const res = await db.rawExec(
|
|
177
|
+
'SELECT {id:UInt64}',
|
|
178
|
+
{id: 5},
|
|
179
|
+
{
|
|
180
|
+
settings: {readonly: 2, async_insert: true, wait: false, mode: 'x'},
|
|
181
|
+
queryId: 'mine',
|
|
182
|
+
},
|
|
183
|
+
);
|
|
184
|
+
expect(calls[0].params!.names).toEqual(['id']);
|
|
185
|
+
expect(calls[0].settings).toEqual({
|
|
186
|
+
readonly: '2',
|
|
187
|
+
async_insert: '1',
|
|
188
|
+
wait: '0',
|
|
189
|
+
mode: 'x',
|
|
190
|
+
});
|
|
191
|
+
expect(calls[0].queryId).toBe('mine');
|
|
192
|
+
expect(res).toEqual({
|
|
193
|
+
rowsWritten: 3,
|
|
194
|
+
bytesWritten: 4,
|
|
195
|
+
rowsRead: 1,
|
|
196
|
+
queryId: 'mine',
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test('rows stream in batches, and the cursor is closed however iteration ends', async () => {
|
|
201
|
+
const db = new Database('events');
|
|
202
|
+
batches = [[{n: 1}, {n: 2}], [{n: 3}]];
|
|
203
|
+
expect(await db.rawQueryAll('SELECT n')).toEqual([{n: 1}, {n: 2}, {n: 3}]);
|
|
204
|
+
expect(closes).toBe(1);
|
|
205
|
+
|
|
206
|
+
batches = [[{n: 1}, {n: 2}], [{n: 3}]];
|
|
207
|
+
for await (const row of db.rawQuery('SELECT n')) {
|
|
208
|
+
expect(row).toEqual({n: 1});
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
expect(closes).toBe(2);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test('queryRow returns null for no rows and throws for more than one', async () => {
|
|
215
|
+
const db = new Database('events');
|
|
216
|
+
expect(await db.queryRow`SELECT 1`).toBeNull();
|
|
217
|
+
batches = [[{n: 1}]];
|
|
218
|
+
expect(await db.rawQueryRow('SELECT 1')).toEqual({n: 1});
|
|
219
|
+
batches = [[{n: 1}], [{n: 2}]];
|
|
220
|
+
const err = await db.rawQueryRow('SELECT 1').catch(e => e);
|
|
221
|
+
expect(err).toBeInstanceOf(TooManyRowsError);
|
|
222
|
+
expect(err).toBeInstanceOf(DatabaseError);
|
|
223
|
+
expect(err.kind).toBe('too_many_rows');
|
|
224
|
+
expect(err.name).toBe('TooManyRowsError');
|
|
225
|
+
expect(nextArgs.every(max => max === 2)).toBe(true);
|
|
226
|
+
expect(closes).toBe(3);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test('native errors become DatabaseErrors; others pass through', async () => {
|
|
230
|
+
const db = new Database('events');
|
|
231
|
+
failWith = new Error(
|
|
232
|
+
'encore:clickhouse.DatabaseError:' +
|
|
233
|
+
JSON.stringify({
|
|
234
|
+
message: 'Code: 60. DB::Exception: nope (UNKNOWN_TABLE)',
|
|
235
|
+
kind: 'server',
|
|
236
|
+
code: 60,
|
|
237
|
+
codeName: 'UNKNOWN_TABLE',
|
|
238
|
+
}),
|
|
239
|
+
);
|
|
240
|
+
const err = await db.rawQueryAll('SELECT * FROM nope').catch(e => e);
|
|
241
|
+
expect(err).toBeInstanceOf(DatabaseError);
|
|
242
|
+
expect(err.name).toBe('DatabaseError');
|
|
243
|
+
expect([err.kind, err.code, err.codeName]).toEqual([
|
|
244
|
+
'server',
|
|
245
|
+
60,
|
|
246
|
+
'UNKNOWN_TABLE',
|
|
247
|
+
]);
|
|
248
|
+
expect(err.message).toBe('Code: 60. DB::Exception: nope (UNKNOWN_TABLE)');
|
|
249
|
+
|
|
250
|
+
const plain = new Error('something else');
|
|
251
|
+
expect(fromNative(plain)).toBe(plain);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test('insert sends the rows, and an empty insert sends nothing', async () => {
|
|
255
|
+
const db = new Database('events');
|
|
256
|
+
expect(await db.insert('t', [])).toEqual({
|
|
257
|
+
rowsWritten: 0,
|
|
258
|
+
bytesWritten: 0,
|
|
259
|
+
rowsRead: 0,
|
|
260
|
+
queryId: '',
|
|
261
|
+
});
|
|
262
|
+
expect(calls).toHaveLength(0);
|
|
263
|
+
const res = await db
|
|
264
|
+
.write()
|
|
265
|
+
.insert('t', [{a: 1, d: new Decimal('1.5')}, new Map([['b', 2]])], {
|
|
266
|
+
settings: {async_insert: true},
|
|
267
|
+
});
|
|
268
|
+
expect(res.rowsWritten).toBe(2);
|
|
269
|
+
expect(calls[0].access).toBe(1);
|
|
270
|
+
expect(calls[0].settings).toEqual({async_insert: '1'});
|
|
271
|
+
const [first, second] = calls[0].params!.values as [
|
|
272
|
+
{a: number; d: {value: string; type: string}},
|
|
273
|
+
Map<string, number>,
|
|
274
|
+
];
|
|
275
|
+
expect(first.a).toBe(1);
|
|
276
|
+
expect([first.d.value, first.d.type]).toEqual(['1.5', 'Decimal(76, 1)']);
|
|
277
|
+
expect(second).toBeInstanceOf(Map);
|
|
278
|
+
expect(second.get('b')).toBe(2);
|
|
279
|
+
});
|