@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,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands as they cross to the native runtime, and replies as they come back:
|
|
3
|
+
* the encoding `encore_sdk_core::cache::wire` documents. A command marks which
|
|
4
|
+
* of its arguments are keys, which is what lets the runtime prefix them with
|
|
5
|
+
* the database's own.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
/** A command being built: the arguments in order, the keys among them marked. */
|
|
11
|
+
export class Cmd {
|
|
12
|
+
operation;
|
|
13
|
+
name;
|
|
14
|
+
write;
|
|
15
|
+
args = [];
|
|
16
|
+
/**
|
|
17
|
+
* Whether the app named the command itself, with `command()`: the runtime
|
|
18
|
+
* then checks it against Redis's command table before sending it.
|
|
19
|
+
*/
|
|
20
|
+
raw = false;
|
|
21
|
+
/** Whether it is sent through a handle that can only read. */
|
|
22
|
+
readOnly = false;
|
|
23
|
+
/** A command Redis calls `name`, traced as `operation`. */
|
|
24
|
+
constructor(operation, name, write) {
|
|
25
|
+
this.operation = operation;
|
|
26
|
+
this.name = name;
|
|
27
|
+
this.write = write;
|
|
28
|
+
}
|
|
29
|
+
/** Appends a key: an argument the database's key prefix applies to. */
|
|
30
|
+
key(key) {
|
|
31
|
+
this.args.push({ key: true, value: Buffer.from(key, 'utf8') });
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
/** Appends several keys. */
|
|
35
|
+
keys(keys) {
|
|
36
|
+
for (const key of keys)
|
|
37
|
+
this.key(key);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Appends keys preceded by how many there are, as the commands that take a
|
|
42
|
+
* variable number of keys before their other arguments want them.
|
|
43
|
+
*/
|
|
44
|
+
numkeys(keys) {
|
|
45
|
+
return this.arg(keys.length).keys(keys);
|
|
46
|
+
}
|
|
47
|
+
/** Appends an argument that is not a key. */
|
|
48
|
+
arg(value) {
|
|
49
|
+
this.args.push({ key: false, value: toArg(value, this.operation) });
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
/** Appends several arguments that are not keys. */
|
|
53
|
+
argsOf(values) {
|
|
54
|
+
for (const value of values)
|
|
55
|
+
this.arg(value);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/** Appends each key and its value: `MSET`'s. */
|
|
59
|
+
pairs(items) {
|
|
60
|
+
for (const [key, value] of entries(items))
|
|
61
|
+
this.key(key).arg(value);
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/** Appends each field and its value, neither a key. */
|
|
65
|
+
fields(items) {
|
|
66
|
+
for (const [field, value] of entries(items))
|
|
67
|
+
this.arg(field).arg(value);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/** Appends each member's score, then the member: `ZADD`'s. */
|
|
71
|
+
scores(items) {
|
|
72
|
+
for (const [member, score] of entries(items))
|
|
73
|
+
this.arg(score).arg(member);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
/** A copy, to append more arguments to. */
|
|
77
|
+
clone() {
|
|
78
|
+
const out = new Cmd(this.operation, this.name, this.write);
|
|
79
|
+
out.args.push(...this.args);
|
|
80
|
+
out.raw = this.raw;
|
|
81
|
+
out.readOnly = this.readOnly;
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function entries(items) {
|
|
86
|
+
return items instanceof Map ? items : Object.entries(items);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* `value` as the bytes Redis is sent. Bytes are copied: a queued command is
|
|
90
|
+
* encoded only when its batch runs, and must send what it was given.
|
|
91
|
+
*/
|
|
92
|
+
export function toArg(value, operation) {
|
|
93
|
+
if (typeof value === 'string')
|
|
94
|
+
return Buffer.from(value, 'utf8');
|
|
95
|
+
if (value instanceof Uint8Array)
|
|
96
|
+
return Buffer.from(value);
|
|
97
|
+
if (typeof value === 'bigint')
|
|
98
|
+
return Buffer.from(value.toString(), 'ascii');
|
|
99
|
+
if (typeof value === 'number') {
|
|
100
|
+
// Redis spells the infinities its own way, and has no NaN.
|
|
101
|
+
if (value === Infinity)
|
|
102
|
+
return Buffer.from('+inf');
|
|
103
|
+
if (value === -Infinity)
|
|
104
|
+
return Buffer.from('-inf');
|
|
105
|
+
if (Number.isNaN(value)) {
|
|
106
|
+
throw new TypeError(`redis: ${operation}: cannot send NaN as an argument`);
|
|
107
|
+
}
|
|
108
|
+
return Buffer.from(String(value), 'ascii');
|
|
109
|
+
}
|
|
110
|
+
throw new TypeError(`redis: ${operation}: cannot send ${describe(value)} as an argument: ` +
|
|
111
|
+
`give a string, a number, a bigint, or a Buffer`);
|
|
112
|
+
}
|
|
113
|
+
function describe(value) {
|
|
114
|
+
if (value === null)
|
|
115
|
+
return 'null';
|
|
116
|
+
if (Array.isArray(value))
|
|
117
|
+
return 'an array';
|
|
118
|
+
return `a ${typeof value}`;
|
|
119
|
+
}
|
|
120
|
+
/** Writes the encodings, sized ahead so that each is one allocation. */
|
|
121
|
+
class Writer {
|
|
122
|
+
buf;
|
|
123
|
+
at = 0;
|
|
124
|
+
constructor(size) {
|
|
125
|
+
this.buf = Buffer.allocUnsafe(size);
|
|
126
|
+
}
|
|
127
|
+
u8(n) {
|
|
128
|
+
this.buf.writeUInt8(n, this.at);
|
|
129
|
+
this.at += 1;
|
|
130
|
+
}
|
|
131
|
+
u32(n) {
|
|
132
|
+
this.buf.writeUInt32LE(n, this.at);
|
|
133
|
+
this.at += 4;
|
|
134
|
+
}
|
|
135
|
+
bytes(b) {
|
|
136
|
+
this.u32(b.length);
|
|
137
|
+
b.copy(this.buf, this.at);
|
|
138
|
+
this.at += b.length;
|
|
139
|
+
}
|
|
140
|
+
done() {
|
|
141
|
+
return this.buf;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function commandSize(cmd) {
|
|
145
|
+
let size = 1 +
|
|
146
|
+
4 +
|
|
147
|
+
Buffer.byteLength(cmd.operation) +
|
|
148
|
+
4 +
|
|
149
|
+
Buffer.byteLength(cmd.name) +
|
|
150
|
+
4;
|
|
151
|
+
for (const arg of cmd.args)
|
|
152
|
+
size += 1 + 4 + arg.value.length;
|
|
153
|
+
return size;
|
|
154
|
+
}
|
|
155
|
+
function writeCommand(w, cmd) {
|
|
156
|
+
w.u8((cmd.write ? 1 : 0) | (cmd.raw ? 2 : 0) | (cmd.readOnly ? 4 : 0));
|
|
157
|
+
w.bytes(Buffer.from(cmd.operation, 'utf8'));
|
|
158
|
+
w.bytes(Buffer.from(cmd.name, 'utf8'));
|
|
159
|
+
w.u32(cmd.args.length);
|
|
160
|
+
for (const arg of cmd.args) {
|
|
161
|
+
w.u8(arg.key ? 1 : 0);
|
|
162
|
+
w.bytes(arg.value);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/** The encoding of one command. */
|
|
166
|
+
export function encodeCommand(cmd) {
|
|
167
|
+
const w = new Writer(commandSize(cmd));
|
|
168
|
+
writeCommand(w, cmd);
|
|
169
|
+
return w.done();
|
|
170
|
+
}
|
|
171
|
+
/** The encoding of a batch of commands. */
|
|
172
|
+
export function encodeBatch(cmds) {
|
|
173
|
+
let size = 4;
|
|
174
|
+
for (const cmd of cmds)
|
|
175
|
+
size += commandSize(cmd);
|
|
176
|
+
const w = new Writer(size);
|
|
177
|
+
w.u32(cmds.length);
|
|
178
|
+
for (const cmd of cmds)
|
|
179
|
+
writeCommand(w, cmd);
|
|
180
|
+
return w.done();
|
|
181
|
+
}
|
|
182
|
+
/** The encoding of a list of keys or channels. */
|
|
183
|
+
export function encodeList(items) {
|
|
184
|
+
const bufs = items.map(item => Buffer.from(item, 'utf8'));
|
|
185
|
+
const w = new Writer(4 + bufs.reduce((n, b) => n + 4 + b.length, 0));
|
|
186
|
+
w.u32(bufs.length);
|
|
187
|
+
for (const b of bufs)
|
|
188
|
+
w.bytes(b);
|
|
189
|
+
return w.done();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The error a command the server rejected fails with.
|
|
193
|
+
*/
|
|
194
|
+
export class ServerError extends Error {
|
|
195
|
+
/**
|
|
196
|
+
* The server's message, as Redis spells it:
|
|
197
|
+
* `WRONGTYPE Operation against a key holding the wrong kind of value`.
|
|
198
|
+
*/
|
|
199
|
+
serverMessage;
|
|
200
|
+
constructor(message) {
|
|
201
|
+
super(`redis: ${message}`);
|
|
202
|
+
this.serverMessage = message;
|
|
203
|
+
Object.defineProperty(this, 'name', {
|
|
204
|
+
value: 'ServerError',
|
|
205
|
+
enumerable: false,
|
|
206
|
+
configurable: true,
|
|
207
|
+
});
|
|
208
|
+
Object.setPrototypeOf(this, ServerError.prototype);
|
|
209
|
+
}
|
|
210
|
+
/** The error's code: the first word of its message, `WRONGTYPE`. */
|
|
211
|
+
get code() {
|
|
212
|
+
const space = this.serverMessage.indexOf(' ');
|
|
213
|
+
return space < 0 ? this.serverMessage : this.serverMessage.slice(0, space);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/** A map reply, its keys and values in the order the server sent them. */
|
|
217
|
+
export class MapReply {
|
|
218
|
+
entries;
|
|
219
|
+
constructor(entries) {
|
|
220
|
+
this.entries = entries;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** A simple string reply, `OK` among them. */
|
|
224
|
+
export class Status {
|
|
225
|
+
text;
|
|
226
|
+
constructor(text) {
|
|
227
|
+
this.text = text;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const malformed = () => new Error('redis: malformed reply');
|
|
231
|
+
/** Decodes an encoded reply. */
|
|
232
|
+
export function decodeReply(buf) {
|
|
233
|
+
let at = 0;
|
|
234
|
+
const need = (n) => {
|
|
235
|
+
if (at + n > buf.length)
|
|
236
|
+
throw malformed();
|
|
237
|
+
};
|
|
238
|
+
const u32 = () => {
|
|
239
|
+
need(4);
|
|
240
|
+
const n = buf.readUInt32LE(at);
|
|
241
|
+
at += 4;
|
|
242
|
+
return n;
|
|
243
|
+
};
|
|
244
|
+
const bytes = () => {
|
|
245
|
+
const n = u32();
|
|
246
|
+
need(n);
|
|
247
|
+
// A copy: the reply's buffer is not the caller's to keep alive.
|
|
248
|
+
const out = Buffer.from(buf.subarray(at, at + n));
|
|
249
|
+
at += n;
|
|
250
|
+
return out;
|
|
251
|
+
};
|
|
252
|
+
const value = () => {
|
|
253
|
+
need(1);
|
|
254
|
+
const tag = buf.readUInt8(at);
|
|
255
|
+
at += 1;
|
|
256
|
+
switch (tag) {
|
|
257
|
+
case 0:
|
|
258
|
+
return null;
|
|
259
|
+
case 1: {
|
|
260
|
+
need(8);
|
|
261
|
+
const n = buf.readBigInt64LE(at);
|
|
262
|
+
at += 8;
|
|
263
|
+
return n;
|
|
264
|
+
}
|
|
265
|
+
case 2:
|
|
266
|
+
return bytes();
|
|
267
|
+
case 3:
|
|
268
|
+
return new Status(bytes().toString('utf8'));
|
|
269
|
+
case 4:
|
|
270
|
+
case 6: {
|
|
271
|
+
const n = u32();
|
|
272
|
+
const items = [];
|
|
273
|
+
for (let i = 0; i < n; i++)
|
|
274
|
+
items.push(value());
|
|
275
|
+
return items;
|
|
276
|
+
}
|
|
277
|
+
case 5: {
|
|
278
|
+
const n = u32();
|
|
279
|
+
const pairs = [];
|
|
280
|
+
for (let i = 0; i < n; i++)
|
|
281
|
+
pairs.push([value(), value()]);
|
|
282
|
+
return new MapReply(pairs);
|
|
283
|
+
}
|
|
284
|
+
case 7: {
|
|
285
|
+
need(8);
|
|
286
|
+
const n = buf.readDoubleLE(at);
|
|
287
|
+
at += 8;
|
|
288
|
+
return n;
|
|
289
|
+
}
|
|
290
|
+
case 8: {
|
|
291
|
+
need(1);
|
|
292
|
+
const b = buf.readUInt8(at) !== 0;
|
|
293
|
+
at += 1;
|
|
294
|
+
return b;
|
|
295
|
+
}
|
|
296
|
+
case 9:
|
|
297
|
+
return new ServerError(bytes().toString('utf8'));
|
|
298
|
+
case 10:
|
|
299
|
+
return BigInt(bytes().toString('ascii'));
|
|
300
|
+
default:
|
|
301
|
+
throw malformed();
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
const out = value();
|
|
305
|
+
if (at !== buf.length)
|
|
306
|
+
throw malformed();
|
|
307
|
+
return out;
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=wire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../storage/redis/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,iFAAiF;AACjF,MAAM,OAAO,GAAG;IAYH;IACA;IACA;IAbF,IAAI,GAAU,EAAE,CAAC;IAC1B;;;OAGG;IACH,GAAG,GAAG,KAAK,CAAC;IACZ,8DAA8D;IAC9D,QAAQ,GAAG,KAAK,CAAC;IAEjB,2DAA2D;IAC3D,YACW,SAAiB,EACjB,IAAY,EACZ,KAAc;QAFd,cAAS,GAAT,SAAS,CAAQ;QACjB,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAS;IACtB,CAAC;IAEJ,uEAAuE;IACvE,GAAG,CAAC,GAAW;QACb,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,EAAC,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4BAA4B;IAC5B,IAAI,CAAC,IAAuB;QAC1B,KAAK,MAAM,GAAG,IAAI,IAAI;YAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,IAAuB;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,6CAA6C;IAC7C,GAAG,CAAC,KAAe;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,E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1 @@
|
|
|
1
|
+
{"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../../testing/bun.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-test infrastructure under `bun test`: `[test] preload =
|
|
3
|
+
* ["@encore.dev/sdk/testing/bun"]` in `bunfig.toml`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import '../internal/testing/runner.js';
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- an error in the build only, without bun's types
|
|
9
|
+
// @ts-ignore: bun's own module, there when bun runs this.
|
|
10
|
+
import { afterAll, afterEach, beforeEach } from 'bun:test';
|
|
11
|
+
import { setup } from './mod.js';
|
|
12
|
+
setup({ beforeEach, afterEach, afterAll });
|
|
13
|
+
//# sourceMappingURL=bun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun.js","sourceRoot":"","sources":["../../testing/bun.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,4BAA4B,CAAC;AACpC,gHAAgH;AAChH,0DAA0D;AAC1D,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AACzD,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAC;AAE5B,KAAK,CAAC,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../../testing/jest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-test infrastructure under jest: `setupFilesAfterEnv:
|
|
3
|
+
* ["@encore.dev/sdk/testing/jest"]` in the jest config.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import '../internal/testing/runner.js';
|
|
8
|
+
import { setup } from './mod.js';
|
|
9
|
+
// jest's hooks are globals.
|
|
10
|
+
setup(globalThis);
|
|
11
|
+
//# sourceMappingURL=jest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.js","sourceRoot":"","sources":["../../testing/jest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAC,KAAK,EAAa,MAAM,OAAO,CAAC;AAExC,4BAA4B;AAC5B,KAAK,CAAC,UAA8B,CAAC,CAAC"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests of an Encore app. Each test gets infrastructure of its own —
|
|
3
|
+
* databases, buckets, Redis databases and topics no other test sees — with
|
|
4
|
+
* nothing to set up but one line of runner config:
|
|
5
|
+
*
|
|
6
|
+
* | Runner | Config |
|
|
7
|
+
* |-----------|---------------------------------------------------------------------|
|
|
8
|
+
* | vitest | `test.setupFiles: ["@encore.dev/sdk/testing/vitest"]` |
|
|
9
|
+
* | jest | `setupFilesAfterEnv: ["@encore.dev/sdk/testing/jest"]` |
|
|
10
|
+
* | bun | `bunfig.toml`: `[test] preload = ["@encore.dev/sdk/testing/bun"]` |
|
|
11
|
+
* | node:test | `import "@encore.dev/sdk/testing/node"` at the top of each test file |
|
|
12
|
+
*
|
|
13
|
+
* The tests run with `encore test`, or with the runner itself (`vitest`,
|
|
14
|
+
* `bun test`, an editor's test button): Encore finds the app the tests are in,
|
|
15
|
+
* and starts its daemon if it is not running. `ENCORE_TEST=0` turns this off,
|
|
16
|
+
* and `ENCORE_TEST=1` turns it on for a runner Encore does not recognize.
|
|
17
|
+
*
|
|
18
|
+
* Nothing runs by itself in a test: what a test publishes is recorded, for it
|
|
19
|
+
* to read back with {@link published} and hand to a subscription with
|
|
20
|
+
* {@link deliver}.
|
|
21
|
+
*
|
|
22
|
+
* The tests of a system test suite, a directory with an
|
|
23
|
+
* `encore.systest.json`, run against the whole app instead: see
|
|
24
|
+
* {@link system}.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* import {deliver, published} from "@encore.dev/sdk/testing";
|
|
28
|
+
*
|
|
29
|
+
* test("signup sends a welcome", async () => {
|
|
30
|
+
* await signup("ada");
|
|
31
|
+
* expect(published(signups)).toHaveLength(1);
|
|
32
|
+
* expect(await deliver(sendWelcome)).toBe(1);
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* @module
|
|
36
|
+
*/
|
|
37
|
+
import type { AnySecret } from '../config/secrets.js';
|
|
38
|
+
import { type Config } from '../config/config.js';
|
|
39
|
+
import type { Message } from '../pubsub/subscription.js';
|
|
40
|
+
import { Subscription } from '../pubsub/subscription.js';
|
|
41
|
+
import type { OrderedTopic, Topic } from '../pubsub/topic.js';
|
|
42
|
+
import { type Hooks } from '../internal/testing/scope.js';
|
|
43
|
+
export type { Hooks } from '../internal/testing/scope.js';
|
|
44
|
+
export * as system from './system.js';
|
|
45
|
+
/** The options of {@link setup} and {@link scoped}. */
|
|
46
|
+
export interface ScopeOptions {
|
|
47
|
+
/**
|
|
48
|
+
* What each test starts from: a {@link Fixture}, or `null` for the
|
|
49
|
+
* resources' initial state, whatever {@link useFixture} says.
|
|
50
|
+
*/
|
|
51
|
+
fixture?: Fixture | null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Registers per-test infrastructure with a runner's hooks: each test begins
|
|
55
|
+
* with resources of its own, released after it. The per-runner entry points
|
|
56
|
+
* (`@encore.dev/sdk/testing/vitest` and the others) call this for you.
|
|
57
|
+
*
|
|
58
|
+
* Once it has, a resource used outside any test — in a `beforeAll`, or at
|
|
59
|
+
* module level — throws: no test would see what it does. Set up what each
|
|
60
|
+
* test needs in `beforeEach`, or in a {@link fixture}.
|
|
61
|
+
*
|
|
62
|
+
* Outside test mode it registers nothing, so a test file still runs.
|
|
63
|
+
*/
|
|
64
|
+
export declare function setup(hooks: Hooks, options?: ScopeOptions): void;
|
|
65
|
+
/**
|
|
66
|
+
* Wraps a test body to run in a scope of its own: for concurrent tests,
|
|
67
|
+
* which the runner's hooks cannot tell apart, or a runner without hooks.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* test.concurrent("x", scoped(async () => { ... }));
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* The test starts from `options.fixture` if given, else from the fixture
|
|
74
|
+
* {@link useFixture} chose for it, where the runner hands the test its
|
|
75
|
+
* context (vitest, node:test). Outside test mode it runs `fn` as it is.
|
|
76
|
+
*
|
|
77
|
+
* A system test wrapped in it says how it ended in any runner, and prints
|
|
78
|
+
* what it caused in the app when it fails: see {@link system}.
|
|
79
|
+
*/
|
|
80
|
+
export declare function scoped<A extends unknown[], R>(fn: (...args: A) => Promise<R> | R, options?: ScopeOptions): (...args: A) => Promise<R>;
|
|
81
|
+
/**
|
|
82
|
+
* What the current test has published to `topic`, in the order it was
|
|
83
|
+
* published: by the test itself, and by the code it called. Nothing handles
|
|
84
|
+
* it otherwise: hand it to a subscription with {@link deliver}.
|
|
85
|
+
*
|
|
86
|
+
* Each message's `data` is what was published: decoded from JSON, or the
|
|
87
|
+
* bytes published as bytes.
|
|
88
|
+
*
|
|
89
|
+
* Not in a system test, where what a test publishes is sent.
|
|
90
|
+
*/
|
|
91
|
+
export declare function published<T>(topic: Topic<T> | OrderedTopic<T>): Message<T>[];
|
|
92
|
+
/**
|
|
93
|
+
* Runs `subscription`'s handler on each message the current test — or the
|
|
94
|
+
* code it called — published to its topic that the subscription has not
|
|
95
|
+
* handled yet, one at a time, in the order they were published, as part of
|
|
96
|
+
* the test. Resolves to how many it handled.
|
|
97
|
+
*
|
|
98
|
+
* As in a real delivery, the handler gets a message only if the
|
|
99
|
+
* subscription's filter matches it, decoded as the subscription says, with
|
|
100
|
+
* the Request Context fields it was published with, and `deliveryAttempt` 1
|
|
101
|
+
* the first time. What the handler publishes to the topic in turn is handed
|
|
102
|
+
* over in the same call.
|
|
103
|
+
*
|
|
104
|
+
* It stops at the first message the handler fails, and rejects with its
|
|
105
|
+
* error. That message stays unhandled: the next call hands it over again,
|
|
106
|
+
* its `deliveryAttempt` one more. Retry policies, ack deadlines and dead
|
|
107
|
+
* letters play no part.
|
|
108
|
+
*
|
|
109
|
+
* Not in a system test, where the subscriptions run on their own: wait for
|
|
110
|
+
* them with `system.settled()`.
|
|
111
|
+
*/
|
|
112
|
+
export declare function deliver<T>(subscription: Subscription<T>): Promise<number>;
|
|
113
|
+
/**
|
|
114
|
+
* Gives `secret` a value for the current test, in place of the app's. No
|
|
115
|
+
* other test sees it, and it is gone when the test ends.
|
|
116
|
+
*
|
|
117
|
+
* Not in a system test, whose services read their own values: give the
|
|
118
|
+
* secret its value for tests in `secrets.test.toml` instead.
|
|
119
|
+
*/
|
|
120
|
+
export declare function setSecret(secret: AnySecret, value: string | Uint8Array): void;
|
|
121
|
+
/**
|
|
122
|
+
* Gives `config` a value for the current test, in place of the app's: what
|
|
123
|
+
* calling the config returns in the test from then on. No other test sees
|
|
124
|
+
* it, and it is gone when the test ends. Throws if the value does not
|
|
125
|
+
* satisfy the config's schema.
|
|
126
|
+
*
|
|
127
|
+
* Not in a system test, whose services read their own values: give the
|
|
128
|
+
* config its value for tests in its `test` config file instead.
|
|
129
|
+
*/
|
|
130
|
+
export declare function setConfig<T>(config: Config<T>, value: T): void;
|
|
131
|
+
/**
|
|
132
|
+
* A saved state for tests to start from, in place of the app's freshly
|
|
133
|
+
* provisioned one: the rows a setup inserted, say. Declare one with
|
|
134
|
+
* {@link fixture}.
|
|
135
|
+
*/
|
|
136
|
+
export interface Fixture {
|
|
137
|
+
/** The fixture's name, which identifies it across the app's test files. */
|
|
138
|
+
readonly name: string;
|
|
139
|
+
/** The fixture it extends: its setup starts from what that one saved. */
|
|
140
|
+
readonly parent?: Fixture;
|
|
141
|
+
/**
|
|
142
|
+
* Makes the current test start from the fixture, building it first if no
|
|
143
|
+
* test of the run has yet. Call it before the test first uses a resource:
|
|
144
|
+
* a test that has used one already cannot change what it started from.
|
|
145
|
+
*/
|
|
146
|
+
load(): Promise<void>;
|
|
147
|
+
}
|
|
148
|
+
/** The options of {@link fixture}. */
|
|
149
|
+
export interface FixtureOptions {
|
|
150
|
+
/** A fixture to build on: the setup starts from what it saved. */
|
|
151
|
+
extends?: Fixture;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Declares a fixture: a state `setup` leaves the app's resources in,
|
|
155
|
+
* built once per test run and copied for each test that starts from it.
|
|
156
|
+
*
|
|
157
|
+
* ```ts
|
|
158
|
+
* const seeded = fixture("users.seeded", async () => {
|
|
159
|
+
* await db.exec`INSERT INTO users (name) VALUES ('ada'), ('grace')`;
|
|
160
|
+
* });
|
|
161
|
+
* useFixture(seeded);
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* The setup is ordinary app code: its resources are the fixture's while it
|
|
165
|
+
* runs. It runs the first time a test loads the fixture, however many test
|
|
166
|
+
* files and workers load it. What it leaves in each database, bucket and
|
|
167
|
+
* Redis database it touched is saved; each test that loads the fixture gets
|
|
168
|
+
* a copy of its own. Other kinds of resource start each test from their
|
|
169
|
+
* initial state.
|
|
170
|
+
*
|
|
171
|
+
* The name identifies the fixture across the app's test files: two fixtures
|
|
172
|
+
* of one name are one fixture, built by whichever is loaded first.
|
|
173
|
+
*/
|
|
174
|
+
export declare function fixture(name: string, setup: () => Promise<void> | void, options?: FixtureOptions): Fixture;
|
|
175
|
+
/**
|
|
176
|
+
* Makes `f` what every test after this call in the file — or, called in a
|
|
177
|
+
* `describe` block, in the block — starts from; `null` for the resources'
|
|
178
|
+
* initial state. A {@link scoped} test starts from it too, unless told
|
|
179
|
+
* otherwise. Needs the runner adapter (or {@link setup}), whose hooks it
|
|
180
|
+
* adds to. Outside test mode it does nothing.
|
|
181
|
+
*/
|
|
182
|
+
export declare function useFixture(f: Fixture | null): void;
|
|
183
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../testing/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAe,KAAK,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAC,YAAY,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAYL,KAAK,KAAK,EACX,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAC,KAAK,EAAC,MAAM,2BAA2B,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1B;AAKD;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAOhE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAC3C,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAClC,OAAO,CAAC,EAAE,YAAY,GACrB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAwB5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK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