@encore.dev/sdk 2.0.0-beta.7 → 2.0.0-beta.9
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/README.md +109 -0
- package/app_meta.test.ts +25 -5
- package/app_meta.ts +51 -12
- package/config/config.test.ts +18 -15
- package/config/config.ts +89 -31
- package/config/mod.ts +4 -3
- package/config/secrets.ts +79 -53
- package/config/value.ts +13 -17
- package/cron/mod.test.ts +52 -0
- package/cron/mod.ts +41 -2
- package/dist/app_meta.d.ts +44 -12
- package/dist/app_meta.d.ts.map +1 -0
- package/dist/app_meta.js +2 -0
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +58 -28
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +46 -18
- package/dist/config/config.js.map +1 -1
- package/dist/config/mod.d.ts +5 -4
- package/dist/config/mod.d.ts.map +1 -0
- package/dist/config/mod.js +2 -2
- package/dist/config/mod.js.map +1 -1
- package/dist/config/secrets.d.ts +71 -39
- package/dist/config/secrets.d.ts.map +1 -0
- package/dist/config/secrets.js +31 -38
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +8 -5
- package/dist/config/value.d.ts.map +1 -0
- package/dist/config/value.js +10 -7
- package/dist/config/value.js.map +1 -1
- package/dist/cron/mod.d.ts +36 -1
- package/dist/cron/mod.d.ts.map +1 -0
- package/dist/cron/mod.js +31 -1
- package/dist/cron/mod.js.map +1 -1
- 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 +147 -0
- package/dist/internal/clients/call.d.ts.map +1 -0
- package/dist/internal/clients/call.js +274 -0
- package/dist/internal/clients/call.js.map +1 -0
- package/dist/internal/clients/grpc.d.ts +90 -0
- package/dist/internal/clients/grpc.d.ts.map +1 -0
- package/dist/internal/clients/grpc.js +355 -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 +58 -0
- package/dist/internal/fetch.d.ts.map +1 -0
- package/dist/internal/fetch.js +251 -0
- package/dist/internal/fetch.js.map +1 -0
- package/dist/internal/otel/backend.d.ts +2 -0
- package/dist/internal/otel/backend.d.ts.map +1 -0
- package/dist/internal/otel/context.d.ts +1 -0
- package/dist/internal/otel/context.d.ts.map +1 -0
- package/dist/internal/otel/context_manager.d.ts +1 -0
- package/dist/internal/otel/context_manager.d.ts.map +1 -0
- package/dist/internal/otel/encode.d.ts +2 -0
- package/dist/internal/otel/encode.d.ts.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 +64 -0
- package/dist/internal/otel/http.js.map +1 -0
- package/dist/internal/otel/index.d.ts +2 -2
- package/dist/internal/otel/index.d.ts.map +1 -0
- package/dist/internal/otel/index.js +1 -2
- package/dist/internal/otel/index.js.map +1 -1
- package/dist/internal/otel/meter.d.ts +1 -0
- package/dist/internal/otel/meter.d.ts.map +1 -0
- package/dist/internal/otel/propagator.d.ts +1 -0
- package/dist/internal/otel/propagator.d.ts.map +1 -0
- package/dist/internal/otel/provider.d.ts +4 -0
- package/dist/internal/otel/provider.d.ts.map +1 -0
- package/dist/internal/otel/provider.js +3 -0
- package/dist/internal/otel/provider.js.map +1 -1
- package/dist/internal/otel/span.d.ts +15 -1
- package/dist/internal/otel/span.d.ts.map +1 -0
- package/dist/internal/otel/span.js +30 -2
- package/dist/internal/otel/span.js.map +1 -1
- package/dist/internal/otel/tracer.d.ts +1 -0
- package/dist/internal/otel/tracer.d.ts.map +1 -0
- package/dist/internal/otel/tracer.js +11 -5
- package/dist/internal/otel/tracer.js.map +1 -1
- 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 +1 -0
- package/dist/internal/runtime/meter.d.ts.map +1 -0
- package/dist/internal/runtime/mod.d.ts +6 -0
- package/dist/internal/runtime/mod.d.ts.map +1 -0
- package/dist/internal/runtime/mod.js +32 -2
- package/dist/internal/runtime/mod.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +192 -16
- package/dist/internal/runtime/napi/napi.d.cts +573 -33
- package/dist/internal/runtime/shutdown.d.ts +5 -0
- package/dist/internal/runtime/shutdown.d.ts.map +1 -0
- package/dist/internal/runtime/shutdown.js +9 -1
- package/dist/internal/runtime/shutdown.js.map +1 -1
- 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 +109 -0
- package/dist/internal/testing/scope.d.ts.map +1 -0
- package/dist/internal/testing/scope.js +335 -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 +1 -0
- package/dist/internal/utils/constraints.d.ts.map +1 -0
- package/dist/log/index.d.ts +1 -0
- package/dist/log/index.d.ts.map +1 -0
- package/dist/log/logger.d.ts +2 -0
- package/dist/log/logger.d.ts.map +1 -0
- package/dist/log/runtime.d.ts +2 -0
- package/dist/log/runtime.d.ts.map +1 -0
- package/dist/log/stderr.d.ts +1 -0
- package/dist/log/stderr.d.ts.map +1 -0
- package/dist/metrics/mod.d.ts +45 -118
- package/dist/metrics/mod.d.ts.map +1 -0
- package/dist/metrics/mod.js +44 -179
- package/dist/metrics/mod.js.map +1 -1
- package/dist/mod.d.ts +2 -3
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +0 -1
- package/dist/mod.js.map +1 -1
- package/dist/otel.d.ts +1 -0
- package/dist/otel.d.ts.map +1 -0
- package/dist/pubsub/encoding.d.ts +5 -0
- package/dist/pubsub/encoding.d.ts.map +1 -0
- package/dist/pubsub/encoding.js +10 -2
- package/dist/pubsub/encoding.js.map +1 -1
- package/dist/pubsub/mod.d.ts +5 -4
- package/dist/pubsub/mod.d.ts.map +1 -0
- package/dist/pubsub/mod.js +2 -2
- package/dist/pubsub/mod.js.map +1 -1
- package/dist/pubsub/refs.d.ts +8 -0
- package/dist/pubsub/refs.d.ts.map +1 -0
- package/dist/pubsub/refs.js.map +1 -1
- package/dist/pubsub/subscription.d.ts +110 -15
- package/dist/pubsub/subscription.d.ts.map +1 -0
- package/dist/pubsub/subscription.js +98 -16
- package/dist/pubsub/subscription.js.map +1 -1
- package/dist/pubsub/topic.d.ts +101 -31
- package/dist/pubsub/topic.d.ts.map +1 -0
- package/dist/pubsub/topic.js +168 -51
- package/dist/pubsub/topic.js.map +1 -1
- 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 +147 -5
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +157 -9
- package/dist/services/index.js.map +1 -1
- package/dist/shutdown/mod.d.ts +1 -0
- package/dist/shutdown/mod.d.ts.map +1 -0
- package/dist/storage/objects/bucket.d.ts +313 -7
- package/dist/storage/objects/bucket.d.ts.map +1 -0
- package/dist/storage/objects/bucket.js +306 -15
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/objects/error.d.ts +10 -0
- package/dist/storage/objects/error.d.ts.map +1 -0
- package/dist/storage/objects/error.js +25 -1
- package/dist/storage/objects/error.js.map +1 -1
- package/dist/storage/objects/mod.d.ts +4 -3
- package/dist/storage/objects/mod.d.ts.map +1 -0
- package/dist/storage/objects/mod.js +1 -1
- package/dist/storage/objects/mod.js.map +1 -1
- package/dist/storage/objects/refs.d.ts +20 -4
- package/dist/storage/objects/refs.d.ts.map +1 -0
- package/dist/storage/objects/refs.js +6 -0
- package/dist/storage/objects/refs.js.map +1 -1
- package/dist/storage/postgres/database.d.ts +85 -25
- package/dist/storage/postgres/database.d.ts.map +1 -0
- package/dist/storage/postgres/database.js +129 -37
- package/dist/storage/postgres/database.js.map +1 -1
- 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 +4 -1
- package/dist/storage/postgres/mod.d.ts.map +1 -0
- package/dist/storage/postgres/mod.js +2 -0
- package/dist/storage/postgres/mod.js.map +1 -1
- 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 +223 -139
- package/dist/storage/redis/commands.d.ts.map +1 -0
- package/dist/storage/redis/commands.js +128 -6
- package/dist/storage/redis/commands.js.map +1 -1
- package/dist/storage/redis/database.d.ts +56 -22
- package/dist/storage/redis/database.d.ts.map +1 -0
- package/dist/storage/redis/database.js +62 -0
- package/dist/storage/redis/database.js.map +1 -1
- package/dist/storage/redis/mod.d.ts +31 -4
- package/dist/storage/redis/mod.d.ts.map +1 -0
- package/dist/storage/redis/mod.js +26 -1
- package/dist/storage/redis/mod.js.map +1 -1
- package/dist/storage/redis/native.d.ts +8 -0
- package/dist/storage/redis/native.d.ts.map +1 -0
- package/dist/storage/redis/native.js +10 -0
- package/dist/storage/redis/native.js.map +1 -1
- package/dist/storage/redis/options.d.ts +1 -0
- package/dist/storage/redis/options.d.ts.map +1 -0
- package/dist/storage/redis/pubsub.d.ts +2 -0
- package/dist/storage/redis/pubsub.d.ts.map +1 -0
- package/dist/storage/redis/reply.d.ts +34 -0
- package/dist/storage/redis/reply.d.ts.map +1 -0
- package/dist/storage/redis/reply.js +40 -1
- package/dist/storage/redis/reply.js.map +1 -1
- package/dist/storage/redis/scan.d.ts +1 -0
- package/dist/storage/redis/scan.d.ts.map +1 -0
- package/dist/storage/redis/script.d.ts +1 -0
- package/dist/storage/redis/script.d.ts.map +1 -0
- package/dist/storage/redis/target.d.ts +5 -3
- package/dist/storage/redis/target.d.ts.map +1 -0
- package/dist/storage/redis/target.js +39 -28
- package/dist/storage/redis/target.js.map +1 -1
- package/dist/storage/redis/wire.d.ts +7 -10
- package/dist/storage/redis/wire.d.ts.map +1 -0
- package/dist/storage/redis/wire.js +8 -32
- package/dist/storage/redis/wire.js.map +1 -1
- 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 -1
- package/dist/types/mod.d.ts +1 -0
- package/dist/types/mod.d.ts.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 +389 -0
- package/internal/clients/grpc.test.ts +368 -0
- package/internal/clients/grpc.ts +485 -0
- package/internal/clients/mod.test.ts +464 -0
- package/internal/clients/mod.ts +337 -0
- package/internal/fetch.ts +287 -0
- package/internal/otel/http.ts +91 -0
- package/internal/otel/index.ts +1 -7
- package/internal/otel/provider.ts +3 -0
- package/internal/otel/span.ts +31 -2
- package/internal/otel/tracer.test.ts +43 -15
- package/internal/otel/tracer.ts +12 -5
- package/internal/reqfields.ts +423 -0
- package/internal/runtime/mod.ts +41 -2
- package/internal/runtime/napi/napi.cjs +192 -16
- package/internal/runtime/napi/napi.d.cts +573 -33
- package/internal/runtime/shutdown.ts +11 -1
- 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 +372 -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/metrics/mod.test.ts +13 -16
- package/metrics/mod.ts +57 -226
- package/mod.ts +1 -8
- package/otel.test.ts +13 -6
- package/package.json +92 -15
- package/pubsub/encoding.ts +11 -1
- package/pubsub/mod.ts +16 -4
- package/pubsub/pubsub.test.ts +233 -14
- package/pubsub/refs.ts +16 -0
- package/pubsub/subscription.ts +200 -21
- package/pubsub/topic.test.ts +26 -0
- package/pubsub/topic.ts +255 -36
- 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 +341 -1
- package/services/index.ts +185 -9
- package/storage/objects/bucket.test.ts +573 -0
- package/storage/objects/bucket.ts +650 -20
- package/storage/objects/error.ts +28 -1
- package/storage/objects/mod.ts +15 -0
- package/storage/objects/refs.ts +51 -3
- package/storage/postgres/database.integration.test.ts +275 -0
- package/storage/postgres/database.test.ts +193 -6
- package/storage/postgres/database.ts +206 -55
- 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 +4 -0
- package/storage/redis/bitfield.ts +162 -0
- package/storage/redis/command.ts +84 -0
- package/storage/redis/commands.ts +271 -21
- package/storage/redis/database.ts +77 -23
- package/storage/redis/mod.ts +38 -2
- package/storage/redis/native.ts +11 -0
- package/storage/redis/redis.test.ts +170 -10
- package/storage/redis/reply.ts +76 -1
- package/storage/redis/runtime.test.ts +15 -0
- package/storage/redis/target.ts +47 -44
- package/storage/redis/wire.ts +8 -32
- 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 +267 -0
- package/tracing/node.ts +176 -0
- package/tracing/tracing.test.ts +953 -0
- package/dist/internal/otel/request_context.d.ts +0 -11
- package/dist/internal/otel/request_context.js +0 -20
- package/dist/internal/otel/request_context.js.map +0 -1
- package/dist/internal/reqtrack/mod.d.ts +0 -6
- package/dist/internal/reqtrack/mod.js +0 -28
- package/dist/internal/reqtrack/mod.js.map +0 -1
- package/dist/req_meta.d.ts +0 -47
- package/dist/req_meta.js +0 -26
- package/dist/req_meta.js.map +0 -1
- package/internal/otel/request_context.ts +0 -32
- package/internal/reqtrack/mod.ts +0 -39
- package/req_meta.ts +0 -75
package/config/secrets.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as runtime from '../internal/runtime/mod';
|
|
2
|
+
import {lookupScope, testMode} from '../internal/testing/scope';
|
|
2
3
|
import {StringLiteral} from '../internal/utils/constraints';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -9,22 +10,25 @@ import {StringLiteral} from '../internal/utils/constraints';
|
|
|
9
10
|
* You can use {@link AnySecret} to represent any secret without knowing
|
|
10
11
|
* it's name.
|
|
11
12
|
*
|
|
13
|
+
* `T` is the type of the secret's value. Only `string` is supported.
|
|
14
|
+
*
|
|
12
15
|
* @example
|
|
13
16
|
*
|
|
14
17
|
* function doFoo(s: Secret<"foo">): void {
|
|
15
18
|
* const foo = s();
|
|
16
19
|
* }
|
|
17
20
|
*/
|
|
18
|
-
export interface Secret<Name extends string> {
|
|
21
|
+
export interface Secret<Name extends string, T extends string = string> {
|
|
19
22
|
/**
|
|
20
|
-
* Returns the
|
|
23
|
+
* Returns the value of the secret.
|
|
24
|
+
*
|
|
25
|
+
* The value is read once per process and does not change while it runs:
|
|
26
|
+
* a new value reaches a service when it restarts.
|
|
21
27
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* minutes. If you need to ensure you have the latest value, use
|
|
25
|
-
* `latest`.
|
|
28
|
+
* Throws an `Error` naming the secret when it has no value, in every
|
|
29
|
+
* environment, local development too.
|
|
26
30
|
*/
|
|
27
|
-
():
|
|
31
|
+
(): T;
|
|
28
32
|
|
|
29
33
|
/**
|
|
30
34
|
* The name of the secret.
|
|
@@ -37,9 +41,8 @@ export interface Secret<Name extends string> {
|
|
|
37
41
|
*
|
|
38
42
|
* As a field of a config's type, `apiKey: Secret<"StripeKey">` reads the
|
|
39
43
|
* secret of that name in the config's own scope: the declaring service's
|
|
40
|
-
* own for
|
|
41
|
-
*
|
|
42
|
-
* {@link sharedSecret} or {@link globalSecret}.
|
|
44
|
+
* own for a service config, the app's for a shared or global one. The
|
|
45
|
+
* secret is declared as any other is, with {@link secret}.
|
|
43
46
|
*/
|
|
44
47
|
readonly '~encore.secret'?: true;
|
|
45
48
|
}
|
|
@@ -51,54 +54,80 @@ export interface Secret<Name extends string> {
|
|
|
51
54
|
export type AnySecret = Secret<string>;
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* Two services may each declare a secret of the same name and hold different
|
|
57
|
-
* values in them, so adding a secret to one service can never collide with — or
|
|
58
|
-
* silently reuse — a name another service already took. The declaration must
|
|
59
|
-
* therefore live inside a service; Encore reports an error otherwise.
|
|
60
|
-
*
|
|
61
|
-
* For a value several services genuinely share, use {@link sharedSecret}.
|
|
62
|
-
*
|
|
63
|
-
* @example loading a single secret
|
|
64
|
-
* import {secret} from "@encore.dev/sdk/config";
|
|
65
|
-
* const foo = secret("foo");
|
|
57
|
+
* The options a secret is declared with. Read by Encore's parser, so the
|
|
58
|
+
* values must be literals.
|
|
66
59
|
*/
|
|
67
|
-
export
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
export interface SecretOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Who the secret belongs to, written as a string literal for Encore to
|
|
63
|
+
* read:
|
|
64
|
+
*
|
|
65
|
+
* - `"service"`, the default: the service that declares it. Two services
|
|
66
|
+
* may each declare a secret of the same name and hold different values
|
|
67
|
+
* in them, so adding a secret to one service can never collide with, or
|
|
68
|
+
* silently reuse, a name another service already took. The declaration
|
|
69
|
+
* must therefore live inside a service; Encore reports an error
|
|
70
|
+
* otherwise.
|
|
71
|
+
* - `"shared"`: the whole app, readable from any service, each that reads
|
|
72
|
+
* it recorded as using it. It may be declared outside a service. Use it
|
|
73
|
+
* only for a value several services genuinely share: a shared secret
|
|
74
|
+
* couples every service that reads it, and widening a secret's scope
|
|
75
|
+
* later is easier than narrowing it.
|
|
76
|
+
* - `"global"`: the whole app, with one value available to every service
|
|
77
|
+
* without being granted. It may be declared outside a service.
|
|
78
|
+
*/
|
|
79
|
+
scope?: 'service' | 'shared' | 'global';
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* What the secret is, who issues it and how to rotate it, shown wherever its
|
|
83
|
+
* values are managed. The declaration's doc comment wins when there is one.
|
|
84
|
+
*/
|
|
85
|
+
description?: string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Tags that classify the secret, for policies to read: written out as
|
|
89
|
+
* string literals, as in `{data: "pci"}`. Keys and values are lowercase
|
|
90
|
+
* letters, digits, `_` and `-`, at most 63 characters; a key starts with a
|
|
91
|
+
* letter, and not with `encore`, which is reserved. At most 32 tags.
|
|
92
|
+
*/
|
|
93
|
+
tags?: Record<string, string>;
|
|
71
94
|
}
|
|
72
95
|
|
|
73
96
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
97
|
+
* secret declares a {@link Secret}, by default belonging to the service that
|
|
98
|
+
* declares it. See {@link SecretOptions.scope} for a secret of the whole app.
|
|
76
99
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* easier than narrowing it.
|
|
100
|
+
* A doc comment on the declaration, or a `description` option, is shown
|
|
101
|
+
* wherever the secret's values are managed.
|
|
80
102
|
*
|
|
81
103
|
* @example
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
): Secret<Name> {
|
|
88
|
-
return makeSecret<Secret<Name>>(name, runtime.RT.secret(name));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* globalSecret declares a {@link Secret} with one value for the whole app,
|
|
93
|
-
* available to every service without being granted. Like
|
|
94
|
-
* {@link sharedSecret} it may be declared outside a service.
|
|
104
|
+
* ```ts
|
|
105
|
+
* // Loading a single secret.
|
|
106
|
+
* import {secret} from "@encore.dev/sdk/config";
|
|
107
|
+
* const foo = secret("foo");
|
|
108
|
+
* ```
|
|
95
109
|
*
|
|
96
110
|
* @example
|
|
97
|
-
*
|
|
98
|
-
*
|
|
111
|
+
* ```ts
|
|
112
|
+
* // A secret several services share.
|
|
113
|
+
* import {secret} from "@encore.dev/sdk/config";
|
|
114
|
+
* const signingKey = secret("SigningKey", {scope: "shared"});
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* // Documenting it.
|
|
120
|
+
* const apiKey = secret("ApiKey", {
|
|
121
|
+
* description: "Issued by Acme Pay. Rotate it in their portal under Settings → API.",
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
99
124
|
*/
|
|
100
|
-
export function
|
|
125
|
+
export function secret<Name extends string>(
|
|
101
126
|
name: StringLiteral<Name>,
|
|
127
|
+
// The options are Encore's parser's to read: a secret is read by name
|
|
128
|
+
// whatever its scope, a name having one scope across the app.
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
130
|
+
opts?: SecretOptions,
|
|
102
131
|
): Secret<Name> {
|
|
103
132
|
return makeSecret<Secret<Name>>(name, runtime.RT.secret(name));
|
|
104
133
|
}
|
|
@@ -123,13 +152,10 @@ function makeSecret<S extends AnySecret>(
|
|
|
123
152
|
impl: ReturnType<typeof runtime.RT.secret>,
|
|
124
153
|
): S {
|
|
125
154
|
const secretObj = () => {
|
|
155
|
+
// The value the current test gave it, if it did.
|
|
156
|
+
const override = testMode ? lookupScope()?.native.secret(name) : null;
|
|
157
|
+
if (override != null) return override.toString('utf8');
|
|
126
158
|
if (impl === null) {
|
|
127
|
-
// During local development we don't consider missing secrets a fatal error.
|
|
128
|
-
if (
|
|
129
|
-
runtime.RT.appMeta().environment.cloud === runtime.CloudProvider.Local
|
|
130
|
-
) {
|
|
131
|
-
return '';
|
|
132
|
-
}
|
|
133
159
|
throw new Error(`secret ${name} is not set`);
|
|
134
160
|
}
|
|
135
161
|
return impl.cached();
|
package/config/value.ts
CHANGED
|
@@ -103,14 +103,15 @@ export class Duration {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* The key of the runtime's placeholder for a secret field:
|
|
108
|
+
* `{"$encore_secret": "<name>"}`. The name alone says which secret it is: a
|
|
109
|
+
* secret's name has one scope across the app.
|
|
110
|
+
*/
|
|
107
111
|
export const PLACEHOLDER_KEY = '$encore_secret';
|
|
108
112
|
|
|
109
|
-
/**
|
|
110
|
-
export type
|
|
111
|
-
|
|
112
|
-
/** Builds the secret a placeholder stands for. */
|
|
113
|
-
export type SecretOf = (name: string, scope: SecretScope) => unknown;
|
|
113
|
+
/** Builds the secret a placeholder stands for, by its name. */
|
|
114
|
+
export type SecretOf = (name: string) => unknown;
|
|
114
115
|
|
|
115
116
|
type Schema = Record<string, any>;
|
|
116
117
|
|
|
@@ -154,19 +155,16 @@ function convert(
|
|
|
154
155
|
|
|
155
156
|
// Only a field the schema says reads a secret is one: anywhere else, a
|
|
156
157
|
// value shaped like a placeholder is just data, and must not reach a secret.
|
|
158
|
+
// The keyword is the secret's name: its scope is the config's.
|
|
157
159
|
const secret = schema['x-encore-secret'];
|
|
158
|
-
if (secret) {
|
|
159
|
-
if (
|
|
160
|
-
!isPlaceholder(value) ||
|
|
161
|
-
value[PLACEHOLDER_KEY].name !== secret.name ||
|
|
162
|
-
value[PLACEHOLDER_KEY].scope !== secret.scope
|
|
163
|
-
) {
|
|
160
|
+
if (typeof secret === 'string') {
|
|
161
|
+
if (!isPlaceholder(value) || value[PLACEHOLDER_KEY] !== secret) {
|
|
164
162
|
// Never say what the value is: it may be a pasted secret.
|
|
165
163
|
throw new Error(
|
|
166
|
-
`a secret field reads the secret ${secret
|
|
164
|
+
`a secret field reads the secret ${secret}, and is not set in config`,
|
|
167
165
|
);
|
|
168
166
|
}
|
|
169
|
-
return secretOf(secret
|
|
167
|
+
return secretOf(secret);
|
|
170
168
|
}
|
|
171
169
|
|
|
172
170
|
if (schema['x-encore-format'] === 'duration' && typeof value === 'string') {
|
|
@@ -233,9 +231,7 @@ function branchOf(
|
|
|
233
231
|
return undefined;
|
|
234
232
|
}
|
|
235
233
|
|
|
236
|
-
function isPlaceholder(
|
|
237
|
-
value: unknown,
|
|
238
|
-
): value is {[PLACEHOLDER_KEY]: {name: string; scope: SecretScope}} {
|
|
234
|
+
function isPlaceholder(value: unknown): value is {[PLACEHOLDER_KEY]: string} {
|
|
239
235
|
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
240
236
|
return false;
|
|
241
237
|
const keys = Object.keys(value);
|
package/cron/mod.test.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {describe, expect, test} from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import {CronJob} from './mod';
|
|
4
|
+
|
|
5
|
+
describe('CronJob', () => {
|
|
6
|
+
test('reads as it was declared', () => {
|
|
7
|
+
const job = new CronJob('cleanup', {
|
|
8
|
+
title: 'Nightly cleanup',
|
|
9
|
+
every: '24h',
|
|
10
|
+
path: '/internal/cleanup',
|
|
11
|
+
});
|
|
12
|
+
expect(job.name).toBe('cleanup');
|
|
13
|
+
expect(job.cfg).toEqual({
|
|
14
|
+
title: 'Nightly cleanup',
|
|
15
|
+
every: '24h',
|
|
16
|
+
path: '/internal/cleanup',
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Encore requests the declared path: a route from a changed one would
|
|
21
|
+
// never be called. `tsc` refuses the writes (below); an app run without it
|
|
22
|
+
// has them throw.
|
|
23
|
+
test('cannot be changed', () => {
|
|
24
|
+
const cfg = {every: '24h' as const, path: '/internal/cleanup'};
|
|
25
|
+
const job = new CronJob('cleanup', cfg);
|
|
26
|
+
const writable = job as unknown as {name: string; cfg: {path: string}};
|
|
27
|
+
expect(() => {
|
|
28
|
+
writable.cfg.path = '/other';
|
|
29
|
+
}).toThrow(TypeError);
|
|
30
|
+
expect(() => {
|
|
31
|
+
writable.cfg = {path: '/other'};
|
|
32
|
+
}).toThrow(TypeError);
|
|
33
|
+
expect(() => {
|
|
34
|
+
writable.name = 'other';
|
|
35
|
+
}).toThrow(TypeError);
|
|
36
|
+
expect(job.cfg.path).toBe('/internal/cleanup');
|
|
37
|
+
// The declaration's own object is the app's, and is left as it was.
|
|
38
|
+
expect(Object.isFrozen(cfg)).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Compile-only: `tsc` checks that a job's config can be read but not changed.
|
|
43
|
+
// Never called.
|
|
44
|
+
function _cfgTyping(job: CronJob) {
|
|
45
|
+
const path: string = job.cfg.path;
|
|
46
|
+
void path;
|
|
47
|
+
// @ts-expect-error Encore requests the declared path, not a changed one
|
|
48
|
+
job.cfg.path = '/other';
|
|
49
|
+
// @ts-expect-error the title is read from the source, too
|
|
50
|
+
job.cfg.title = 'Other';
|
|
51
|
+
}
|
|
52
|
+
void _cfgTyping;
|
package/cron/mod.ts
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
import {DurationString} from '../types/mod';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* The header with a run's idempotency key: an id that is the same each time
|
|
5
|
+
* Encore sends the run, as when it sends it again after a failure. A job
|
|
6
|
+
* that must not do its work twice can check whether it has seen the key
|
|
7
|
+
* before:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* app.post('/internal/cleanup', (req, res) => {
|
|
11
|
+
* const key = req.get(IDEMPOTENCY_KEY_HEADER);
|
|
12
|
+
* // ...
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Only Encore sends it: a gateway removes it from the requests it takes from
|
|
17
|
+
* clients. `encore cron trigger <name>` runs a job locally, as Encore runs it
|
|
18
|
+
* when it is due.
|
|
19
|
+
*/
|
|
20
|
+
export const IDEMPOTENCY_KEY_HEADER = 'x-encore-cron-execution';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The header that says why a job runs: `scheduled`, when it was due, or
|
|
24
|
+
* `manual`, when someone asked for it to run now.
|
|
25
|
+
*/
|
|
26
|
+
export const TRIGGER_HEADER = 'x-encore-cron-trigger';
|
|
27
|
+
|
|
3
28
|
export class CronJob {
|
|
4
29
|
readonly name: string;
|
|
5
|
-
|
|
30
|
+
/**
|
|
31
|
+
* What the job was declared with. Read-only: Encore schedules the job from
|
|
32
|
+
* the declaration in the source, so a changed path would not be requested.
|
|
33
|
+
*/
|
|
34
|
+
readonly cfg: Readonly<CronJobConfig>;
|
|
6
35
|
constructor(name: string, cfg: CronJobConfig) {
|
|
7
36
|
this.name = name;
|
|
8
|
-
|
|
37
|
+
// Frozen as well as typed `readonly`, so a write throws in an app that
|
|
38
|
+
// runs without `tsc` checking it.
|
|
39
|
+
this.cfg = Object.freeze({...cfg});
|
|
40
|
+
Object.freeze(this);
|
|
9
41
|
}
|
|
10
42
|
}
|
|
11
43
|
|
|
@@ -20,4 +52,11 @@ export type CronJobConfig = {
|
|
|
20
52
|
/** The path the job requests of its service, starting with `/`. */
|
|
21
53
|
path: string;
|
|
22
54
|
title?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Tags that classify the cron job, for policies to read: written out as
|
|
57
|
+
* string literals, as in `{data: "pci"}`. Keys and values are lowercase
|
|
58
|
+
* letters, digits, `_` and `-`, at most 63 characters; a key starts with a
|
|
59
|
+
* letter, and not with `encore`, which is reserved. At most 32 tags.
|
|
60
|
+
*/
|
|
61
|
+
tags?: Record<string, string>;
|
|
23
62
|
} & ({every: DurationString} | {schedule: string});
|
package/dist/app_meta.d.ts
CHANGED
|
@@ -15,14 +15,23 @@ export interface AppMeta {
|
|
|
15
15
|
*/
|
|
16
16
|
appSlug: string;
|
|
17
17
|
/**
|
|
18
|
-
* The API gateways
|
|
18
|
+
* The API gateways of this application this service is given, keyed by
|
|
19
|
+
* gateway name: those its code looks up the URL of, and the one it hosts.
|
|
19
20
|
*
|
|
20
21
|
* An application can declare several gateways, so there is no single base URL for
|
|
21
|
-
* the API — look up the gateway you mean by name.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* the API — look up the gateway you mean by name. A service's processes, its
|
|
23
|
+
* Workers' included, list the gateways its code names (`url("api")` from
|
|
24
|
+
* `@encore.dev/sdk/gateways`) and the one it hosts, and no other, the default
|
|
25
|
+
* included; one told of none, as under `encore test`, reports an empty object.
|
|
24
26
|
*/
|
|
25
27
|
gateways: Record<string, GatewayMeta>;
|
|
28
|
+
/**
|
|
29
|
+
* The frontends of this application this service is given — those its code
|
|
30
|
+
* looks up the URL of (`url("web")` from `@encore.dev/sdk/frontends`), and
|
|
31
|
+
* the one it hosts — keyed by name, with where each is reached. One the
|
|
32
|
+
* environment gives no origins is left out.
|
|
33
|
+
*/
|
|
34
|
+
frontends: Record<string, FrontendMeta>;
|
|
26
35
|
/** Information about the environment the app is running in. */
|
|
27
36
|
environment: EnvironmentMeta;
|
|
28
37
|
/** Information about the build. */
|
|
@@ -35,15 +44,31 @@ export interface GatewayMeta {
|
|
|
35
44
|
/** The name of the gateway, as declared by the application. */
|
|
36
45
|
name: string;
|
|
37
46
|
/**
|
|
38
|
-
* The
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*
|
|
47
|
+
* The URL the API of this running application is called at through this
|
|
48
|
+
* gateway: the first of its origins. Empty when the environment gives the
|
|
49
|
+
* gateway no origins.
|
|
50
|
+
*/
|
|
51
|
+
url: string;
|
|
52
|
+
/**
|
|
53
|
+
* Every origin the gateway is reached at in this environment
|
|
54
|
+
* (`scheme://host[:port]`), the first its URL. After the first, an entry may
|
|
55
|
+
* be a pattern of one, `https://*.example.com`, or `*`, which makes the
|
|
56
|
+
* gateway the one serving requests no other origin matches.
|
|
45
57
|
*/
|
|
46
|
-
|
|
58
|
+
origins: string[];
|
|
59
|
+
}
|
|
60
|
+
/** Describes a frontend of the application, and where it is reached. */
|
|
61
|
+
export interface FrontendMeta {
|
|
62
|
+
/** The name of the frontend: for one a service hosts, the service's. */
|
|
63
|
+
name: string;
|
|
64
|
+
/** The URL the frontend is reached at: the first of its origins. */
|
|
65
|
+
url: string;
|
|
66
|
+
/**
|
|
67
|
+
* Every origin the frontend is reached at in this environment, the first its
|
|
68
|
+
* URL; after the first, an entry may be a pattern of one,
|
|
69
|
+
* `https://*.example.com`.
|
|
70
|
+
*/
|
|
71
|
+
origins: string[];
|
|
47
72
|
}
|
|
48
73
|
/** Describes the environment the Encore application is running in. */
|
|
49
74
|
export interface EnvironmentMeta {
|
|
@@ -80,6 +105,12 @@ export interface DeployMeta {
|
|
|
80
105
|
time: Date;
|
|
81
106
|
/** The services hosted by this deployment, keyed by the service name. */
|
|
82
107
|
hostedServices: Record<string, HostedService>;
|
|
108
|
+
/**
|
|
109
|
+
* The Worker of its service this process runs: a long-running process of
|
|
110
|
+
* the service that serves no requests, declared in the `workers` section of
|
|
111
|
+
* its `encore.service.json`. Undefined for the service's main process.
|
|
112
|
+
*/
|
|
113
|
+
worker?: string;
|
|
83
114
|
}
|
|
84
115
|
export interface HostedService {
|
|
85
116
|
/** The name of the service */
|
|
@@ -92,3 +123,4 @@ export interface HostedService {
|
|
|
92
123
|
* and therefore must not be modified by the caller.
|
|
93
124
|
*/
|
|
94
125
|
export declare function appMeta(): AppMeta;
|
|
126
|
+
//# sourceMappingURL=app_meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app_meta.d.ts","sourceRoot":"","sources":["../app_meta.ts"],"names":[],"mappings":"AAEA,gDAAgD;AAChD,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;OASG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAEtC;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAExC,+DAA+D;IAC/D,WAAW,EAAE,eAAe,CAAC;IAE7B,mCAAmC;IACnC,KAAK,EAAE,SAAS,CAAC;IAEjB,wCAAwC;IACxC,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;;OAKG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IAEb,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,EAAE,eAAe,CAAC;IAEtB;;;OAGG;IACH,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAEvB,YAAY,GAEZ,aAAa,GAEb,WAAW,GAEX,MAAM,CAAC;AAEX,mEAAmE;AACnE,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,KAAK,GACL,OAAO,GACP,QAAQ,GACR,OAAO,CAAC;AAEZ,uEAAuE;AACvE,MAAM,WAAW,SAAS;IACxB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mEAAmE;AACnE,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACzE,EAAE,EAAE,MAAM,CAAC;IAEX,2EAA2E;IAC3E,IAAI,EAAE,IAAI,CAAC;IAEX,yEAAyE;IACzE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAE9C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,OAAO,CA2BjC"}
|
package/dist/app_meta.js
CHANGED
|
@@ -13,6 +13,7 @@ export function appMeta() {
|
|
|
13
13
|
appId: rt.appId,
|
|
14
14
|
appSlug: rt.appSlug,
|
|
15
15
|
gateways: rt.gateways,
|
|
16
|
+
frontends: rt.frontends,
|
|
16
17
|
environment: {
|
|
17
18
|
name: rt.environment.name,
|
|
18
19
|
type: envType(rt.environment.type),
|
|
@@ -25,6 +26,7 @@ export function appMeta() {
|
|
|
25
26
|
id: rt.deploy.id,
|
|
26
27
|
time: new Date(rt.deploy.deployTime),
|
|
27
28
|
hostedServices: rt.deploy.hostedServices,
|
|
29
|
+
worker: rt.deploy.worker ?? undefined,
|
|
28
30
|
},
|
|
29
31
|
};
|
|
30
32
|
}
|
package/dist/app_meta.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app_meta.js","sourceRoot":"","sources":["../app_meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"app_meta.js","sourceRoot":"","sources":["../app_meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AA6JlD;;;;;GAKG;AACH,MAAM,UAAU,OAAO;IACrB,qCAAqC;IACrC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;QAChC,MAAM,GAAG;YACP,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,OAAO,EAAE,EAAE,CAAC,OAAO;YACnB,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,SAAS,EAAE,EAAE,CAAC,SAAS;YACvB,WAAW,EAAE;gBACX,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI;gBACzB,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;gBAClC,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;aAC3C;YACD,KAAK,EAAE;gBACL,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ;aAC5B;YACD,MAAM,EAAE;gBACN,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE;gBAChB,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;gBACpC,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc;gBACxC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,SAAS;aACtC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,MAA+B;IAC9C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,OAAO,CAAC,eAAe,CAAC,UAAU;YACrC,OAAO,YAAY,CAAC;QACtB,KAAK,OAAO,CAAC,eAAe,CAAC,WAAW;YACtC,OAAO,aAAa,CAAC;QACvB,KAAK,OAAO,CAAC,eAAe,CAAC,SAAS;YACpC,OAAO,WAAW,CAAC;QACrB,KAAK,OAAO,CAAC,eAAe,CAAC,IAAI;YAC/B,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,aAAa,CAAC;IACzB,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,MAA6B;IAClD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,OAAO,CAAC,aAAa,CAAC,GAAG;YAC5B,OAAO,KAAK,CAAC;QACf,KAAK,OAAO,CAAC,aAAa,CAAC,GAAG;YAC5B,OAAO,KAAK,CAAC;QACf,KAAK,OAAO,CAAC,aAAa,CAAC,KAAK;YAC9B,OAAO,OAAO,CAAC;QACjB,KAAK,OAAO,CAAC,aAAa,CAAC,MAAM;YAC/B,OAAO,QAAQ,CAAC;QAClB,KAAK,OAAO,CAAC,aAAa,CAAC,KAAK;YAC9B,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED,6CAA6C;AAC7C,IAAI,MAAM,GAAmB,IAAI,CAAC"}
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
+
import { type Scope } from '../internal/testing/scope.js';
|
|
1
2
|
export { Duration } from './value.js';
|
|
2
3
|
/**
|
|
3
4
|
* A config: a typed value a service reads, written in files beside the code
|
|
4
5
|
* and changed while the app runs. Calling it reads the value now.
|
|
5
6
|
*
|
|
6
|
-
* Declare one with {@link config},
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* against it before the value reaches the code.
|
|
7
|
+
* Declare one with {@link config}, giving the value's type as the type
|
|
8
|
+
* argument. Encore reads that type to know what the config's files may hold,
|
|
9
|
+
* and checks them against it before the value reaches the code.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { config, type Min, type Max, type Duration } from "@encore.dev/sdk/config";
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* interface Checkout {
|
|
15
|
+
* // Most items one order may hold.
|
|
16
|
+
* maxItems: number & Int & Min<1> & Max<500>;
|
|
17
|
+
* currencies?: string[];
|
|
18
|
+
* paymentTimeout: Duration;
|
|
19
|
+
* }
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* export const checkout = config<Checkout>("checkout");
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* if (items.length > checkout().maxItems) { ... }
|
|
24
|
+
* ```
|
|
24
25
|
*
|
|
25
26
|
* # Values
|
|
26
27
|
*
|
|
@@ -49,24 +50,52 @@ export interface Config<T> {
|
|
|
49
50
|
*/
|
|
50
51
|
onChange(listener: (value: T) => void): () => void;
|
|
51
52
|
}
|
|
53
|
+
/** The options a config is declared with. */
|
|
54
|
+
export interface ConfigOptions {
|
|
55
|
+
/**
|
|
56
|
+
* Who the config belongs to, written as a string literal for Encore to
|
|
57
|
+
* read:
|
|
58
|
+
*
|
|
59
|
+
* - `"service"`, the default: the service that declares it, which holds
|
|
60
|
+
* its own value for it. Two services may each declare a config of the
|
|
61
|
+
* same name. The declaration must live inside a service.
|
|
62
|
+
* - `"shared"`: the whole app, with one value. A service that reads it is
|
|
63
|
+
* recorded as using it. It may be declared outside a service.
|
|
64
|
+
* - `"global"`: the whole app, with one value available to every service
|
|
65
|
+
* without being recorded as used. It may be declared outside a service.
|
|
66
|
+
*
|
|
67
|
+
* A config name has one scope across the app, as a secret's has: a name
|
|
68
|
+
* declared shared or global can't also be a service's own.
|
|
69
|
+
*/
|
|
70
|
+
scope?: 'service' | 'shared' | 'global';
|
|
71
|
+
/**
|
|
72
|
+
* Tags that classify the config, for policies to read: written out as
|
|
73
|
+
* string literals, as in `{data: "pci"}`. Keys and values are lowercase
|
|
74
|
+
* letters, digits, `_` and `-`, at most 63 characters; a key starts with a
|
|
75
|
+
* letter, and not with `encore`, which is reserved. At most 32 tags.
|
|
76
|
+
*/
|
|
77
|
+
tags?: Record<string, string>;
|
|
78
|
+
}
|
|
52
79
|
/**
|
|
53
|
-
* config declares a {@link Config} belonging to the service that
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* be declared outside a service.
|
|
80
|
+
* config declares a {@link Config}, by default belonging to the service that
|
|
81
|
+
* declares it (see {@link ConfigOptions.scope}). The declaration is a
|
|
82
|
+
* module-level `export const`, with the name a string literal.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* // A config several services read.
|
|
87
|
+
* export const flags = config<Flags>("flags", {scope: "shared"});
|
|
88
|
+
* ```
|
|
63
89
|
*/
|
|
64
|
-
export declare function
|
|
90
|
+
export declare function config<T>(name: string, opts?: ConfigOptions): Config<T>;
|
|
65
91
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
92
|
+
* Gives `cfg` the value `value` for the test `scope`, once the core has
|
|
93
|
+
* checked it against the config's schema: reading the config in the test
|
|
94
|
+
* returns it from then on. For `@encore.dev/sdk/testing`.
|
|
95
|
+
*
|
|
96
|
+
* @internal
|
|
68
97
|
*/
|
|
69
|
-
export declare function
|
|
98
|
+
export declare function setTestValue<T>(scope: Scope, cfg: Config<T>, value: T): void;
|
|
70
99
|
/**
|
|
71
100
|
* The value is at least `N`. A constraint on a `number` field of a config's
|
|
72
101
|
* type, written as an intersection: `number & Min<1>`. Encore checks the
|
|
@@ -103,3 +132,4 @@ export type MinItems<N extends number> = {
|
|
|
103
132
|
export type MaxItems<N extends number> = {
|
|
104
133
|
readonly '~encore.max_items'?: N;
|
|
105
134
|
};
|
|
135
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,KAAK,EAAC,MAAM,2BAA2B,CAAC;AAI5E,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,8BAA8B;IAC9B,IAAI,CAAC,CAAC;IAEN,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACpD;AAED,6CAA6C;AAC7C,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAExC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,IAAI,EAAE,MAAM,EAIZ,IAAI,CAAC,EAAE,aAAa,GACnB,MAAM,CAAC,CAAC,CAAC,CAIX;AAKD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAgB5E;AAwED;;;;GAIG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC;AAEjE,sEAAsE;AACtE,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC;AAEjE,oEAAoE;AACpE,MAAM,MAAM,GAAG,GAAG;IAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,IAAI,CAAA;CAAC,CAAC;AAElD,wEAAwE;AACxE,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC;AAExE,wEAAwE;AACxE,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC;AAExE,qFAAqF;AACrF,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC;AAEzE,kEAAkE;AAClE,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC;AAE5E,kEAAkE;AAClE,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC"}
|