@encore.dev/sdk 2.0.0-beta.6 → 2.0.0-beta.8
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 +55 -0
- package/app_meta.ts +8 -0
- package/config/config.test.ts +10 -3
- package/config/config.ts +75 -21
- package/config/mod.ts +4 -3
- package/config/secrets.ts +72 -55
- package/cron/mod.ts +32 -0
- package/dist/app_meta.d.ts +7 -0
- package/dist/app_meta.d.ts.map +1 -0
- package/dist/app_meta.js +1 -0
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +44 -18
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +43 -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 +62 -39
- package/dist/config/secrets.d.ts.map +1 -0
- package/dist/config/secrets.js +21 -37
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +1 -0
- package/dist/config/value.d.ts.map +1 -0
- package/dist/cron/mod.d.ts +31 -0
- package/dist/cron/mod.d.ts.map +1 -0
- package/dist/cron/mod.js +23 -0
- package/dist/cron/mod.js.map +1 -1
- 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 +129 -0
- package/dist/gateway/mod.d.ts.map +1 -0
- package/dist/gateway/mod.js +187 -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/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 +54 -0
- package/dist/internal/fetch.d.ts.map +1 -0
- package/dist/internal/fetch.js +240 -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/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 +1 -0
- package/dist/internal/otel/provider.d.ts.map +1 -0
- package/dist/internal/otel/span.d.ts +4 -0
- package/dist/internal/otel/span.d.ts.map +1 -0
- package/dist/internal/otel/span.js +5 -0
- 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 +150 -0
- package/dist/internal/reqfields.d.ts.map +1 -0
- package/dist/internal/reqfields.js +312 -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 +160 -16
- package/dist/internal/runtime/napi/napi.d.cts +474 -29
- 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/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 +81 -0
- package/dist/internal/testing/scope.d.ts.map +1 -0
- package/dist/internal/testing/scope.js +237 -0
- package/dist/internal/testing/scope.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 +1 -2
- 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 +4 -3
- 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 +104 -10
- 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 +87 -23
- package/dist/pubsub/topic.d.ts.map +1 -0
- package/dist/pubsub/topic.js +143 -40
- package/dist/pubsub/topic.js.map +1 -1
- package/dist/reqctx/mod.d.ts +191 -0
- package/dist/reqctx/mod.d.ts.map +1 -0
- package/dist/reqctx/mod.js +160 -0
- package/dist/reqctx/mod.js.map +1 -0
- package/dist/services/index.d.ts +145 -4
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +155 -8
- 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 +312 -7
- package/dist/storage/objects/bucket.d.ts.map +1 -0
- package/dist/storage/objects/bucket.js +305 -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 +81 -25
- package/dist/storage/postgres/database.d.ts.map +1 -0
- package/dist/storage/postgres/database.js +125 -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 +160 -0
- package/dist/testing/mod.d.ts.map +1 -0
- package/dist/testing/mod.js +227 -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/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/mod.d.ts +19 -0
- package/dist/tracing/mod.d.ts.map +1 -0
- package/dist/tracing/mod.js +46 -0
- package/dist/tracing/mod.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/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 +210 -0
- package/gateway/request.ts +578 -0
- package/gateway/serve.ts +738 -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 +276 -0
- package/internal/otel/index.ts +1 -7
- package/internal/otel/span.ts +6 -0
- package/internal/otel/tracer.test.ts +43 -15
- package/internal/otel/tracer.ts +12 -5
- package/internal/reqfields.ts +390 -0
- package/internal/runtime/mod.ts +41 -2
- package/internal/runtime/napi/napi.cjs +160 -16
- package/internal/runtime/napi/napi.d.cts +474 -29
- package/internal/runtime/shutdown.ts +11 -1
- package/internal/testing/runner.ts +10 -0
- package/internal/testing/scope.ts +273 -0
- package/metrics/mod.test.ts +13 -16
- package/metrics/mod.ts +57 -226
- package/mod.ts +0 -8
- package/otel.test.ts +13 -6
- package/package.json +67 -15
- package/pubsub/encoding.ts +11 -1
- package/pubsub/mod.ts +10 -3
- package/pubsub/pubsub.test.ts +232 -14
- package/pubsub/refs.ts +16 -0
- package/pubsub/subscription.ts +194 -16
- package/pubsub/topic.test.ts +26 -0
- package/pubsub/topic.ts +220 -25
- package/reqctx/mod.ts +284 -0
- package/reqctx/reqctx.test.ts +193 -0
- package/scripts/postprocess-docs.test.ts +48 -0
- package/services/index.test.ts +341 -1
- package/services/index.ts +183 -8
- package/storage/objects/bucket.test.ts +573 -0
- package/storage/objects/bucket.ts +649 -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 +202 -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 +337 -0
- package/testing/node.ts +12 -0
- package/testing/vitest.ts +13 -0
- package/tracing/mod.ts +82 -0
- package/tracing/native.test.ts +170 -0
- package/tracing/tracing.test.ts +317 -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/dist/config/config.js
CHANGED
|
@@ -1,30 +1,49 @@
|
|
|
1
1
|
import * as runtime from '../internal/runtime/mod.js';
|
|
2
|
+
import { lookupScope, testMode } from '../internal/testing/scope.js';
|
|
2
3
|
import { secretOfField } from './secrets.js';
|
|
3
4
|
import { build } from './value.js';
|
|
4
5
|
export { Duration } from './value.js';
|
|
5
6
|
/**
|
|
6
|
-
* config declares a {@link Config} belonging to the service that
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* config declares a {@link Config}, by default belonging to the service that
|
|
8
|
+
* declares it (see {@link ConfigOptions.scope}). The declaration is a
|
|
9
|
+
* module-level `export const`, with the name a string literal.
|
|
10
|
+
*
|
|
11
|
+
* @example a config several services read
|
|
12
|
+
* export const flags = config<Flags>("flags", {scope: "shared"});
|
|
10
13
|
*/
|
|
11
|
-
export function config(name
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export function sharedConfig(name) {
|
|
20
|
-
return makeConfig(name, runtime.RT.sharedConfig(name));
|
|
14
|
+
export function config(name,
|
|
15
|
+
// The options are Encore's parser's to read: a config is read by name
|
|
16
|
+
// whatever its scope, a name having one scope across the app.
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
|
+
opts) {
|
|
19
|
+
const handle = makeConfig(name, runtime.RT.config(name));
|
|
20
|
+
names.set(handle, name);
|
|
21
|
+
return handle;
|
|
21
22
|
}
|
|
23
|
+
/** The name of the config each handle reads. */
|
|
24
|
+
const names = new WeakMap();
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
26
|
+
* Gives `cfg` the value `value` for the test `scope`, once the core has
|
|
27
|
+
* checked it against the config's schema: reading the config in the test
|
|
28
|
+
* returns it from then on. For `@encore.dev/sdk/testing`.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
25
31
|
*/
|
|
26
|
-
export function
|
|
27
|
-
|
|
32
|
+
export function setTestValue(scope, cfg, value) {
|
|
33
|
+
const name = names.get(cfg);
|
|
34
|
+
if (name === undefined) {
|
|
35
|
+
throw new TypeError('setConfig takes a config declared with `config()`');
|
|
36
|
+
}
|
|
37
|
+
const json = JSON.stringify(value);
|
|
38
|
+
if (json === undefined) {
|
|
39
|
+
throw new TypeError(`config ${name}: the value has no JSON form`);
|
|
40
|
+
}
|
|
41
|
+
const prepared = JSON.parse(scope.native.setConfig(name, json));
|
|
42
|
+
const impl = runtime.RT.config(name);
|
|
43
|
+
const built = impl === null
|
|
44
|
+
? prepared
|
|
45
|
+
: build(JSON.parse(impl.schema()), prepared, secretOfField);
|
|
46
|
+
scope.configs.set(name, built);
|
|
28
47
|
}
|
|
29
48
|
/**
|
|
30
49
|
* The native watches not yet stopped. A watch stops when it is collected, and
|
|
@@ -49,6 +68,12 @@ function makeConfig(name, impl) {
|
|
|
49
68
|
return value;
|
|
50
69
|
};
|
|
51
70
|
const read = () => {
|
|
71
|
+
if (testMode) {
|
|
72
|
+
// The value the current test gave it, if it did.
|
|
73
|
+
const configs = lookupScope()?.configs;
|
|
74
|
+
if (configs?.has(name))
|
|
75
|
+
return configs.get(name);
|
|
76
|
+
}
|
|
52
77
|
if (impl === null) {
|
|
53
78
|
// No value at all: every field takes its default, which in TypeScript is
|
|
54
79
|
// none. The runtime config has every config the app declares, so this
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAC;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,yBAA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AI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QAC1C,CAAC,CAAC;IACJ,CAAC,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/config/mod.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export type { Secret, AnySecret } from './secrets.js';
|
|
2
|
-
export { secret
|
|
3
|
-
export type { Config, Min, Max, Int, MinLen, MaxLen, Pattern, MinItems, MaxItems, } from './config.js';
|
|
4
|
-
export { config,
|
|
1
|
+
export type { Secret, AnySecret, SecretOptions } from './secrets.js';
|
|
2
|
+
export { secret } from './secrets.js';
|
|
3
|
+
export type { Config, ConfigOptions, Min, Max, Int, MinLen, MaxLen, Pattern, MinItems, MaxItems, } from './config.js';
|
|
4
|
+
export { config, Duration } from './config.js';
|
|
5
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../config/mod.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,WAAW,CAAC;AAChE,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,YAAY,EACV,MAAM,EACN,aAAa,EACb,GAAG,EACH,GAAG,EACH,GAAG,EACH,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAC"}
|
package/dist/config/mod.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { secret
|
|
2
|
-
export { config,
|
|
1
|
+
export { secret } from './secrets.js';
|
|
2
|
+
export { config, Duration } from './config.js';
|
|
3
3
|
//# sourceMappingURL=mod.js.map
|
package/dist/config/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../config/mod.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../config/mod.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAajC,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAC"}
|
package/dist/config/secrets.d.ts
CHANGED
|
@@ -7,22 +7,25 @@ import { StringLiteral } from '../internal/utils/constraints.js';
|
|
|
7
7
|
* You can use {@link AnySecret} to represent any secret without knowing
|
|
8
8
|
* it's name.
|
|
9
9
|
*
|
|
10
|
+
* `T` is the type of the secret's value. Only `string` is supported.
|
|
11
|
+
*
|
|
10
12
|
* @example
|
|
11
13
|
*
|
|
12
14
|
* function doFoo(s: Secret<"foo">): void {
|
|
13
15
|
* const foo = s();
|
|
14
16
|
* }
|
|
15
17
|
*/
|
|
16
|
-
export interface Secret<Name extends string> {
|
|
18
|
+
export interface Secret<Name extends string, T extends string = string> {
|
|
17
19
|
/**
|
|
18
|
-
* Returns the
|
|
20
|
+
* Returns the value of the secret.
|
|
21
|
+
*
|
|
22
|
+
* The value is read once per process and does not change while it runs:
|
|
23
|
+
* a new value reaches a service when it restarts.
|
|
19
24
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* minutes. If you need to ensure you have the latest value, use
|
|
23
|
-
* `latest`.
|
|
25
|
+
* Throws an `Error` naming the secret when it has no value, in every
|
|
26
|
+
* environment, local development too.
|
|
24
27
|
*/
|
|
25
|
-
():
|
|
28
|
+
(): T;
|
|
26
29
|
/**
|
|
27
30
|
* The name of the secret.
|
|
28
31
|
*/
|
|
@@ -33,9 +36,8 @@ export interface Secret<Name extends string> {
|
|
|
33
36
|
*
|
|
34
37
|
* As a field of a config's type, `apiKey: Secret<"StripeKey">` reads the
|
|
35
38
|
* secret of that name in the config's own scope: the declaring service's
|
|
36
|
-
* own for
|
|
37
|
-
*
|
|
38
|
-
* {@link sharedSecret} or {@link globalSecret}.
|
|
39
|
+
* own for a service config, the app's for a shared or global one. The
|
|
40
|
+
* secret is declared as any other is, with {@link secret}.
|
|
39
41
|
*/
|
|
40
42
|
readonly '~encore.secret'?: true;
|
|
41
43
|
}
|
|
@@ -45,43 +47,63 @@ export interface Secret<Name extends string> {
|
|
|
45
47
|
*/
|
|
46
48
|
export type AnySecret = Secret<string>;
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
* The options a secret is declared with. Read by Encore's parser, so the
|
|
51
|
+
* values must be literals.
|
|
52
|
+
*/
|
|
53
|
+
export interface SecretOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Who the secret belongs to, written as a string literal for Encore to
|
|
56
|
+
* read:
|
|
57
|
+
*
|
|
58
|
+
* - `"service"`, the default: the service that declares it. Two services
|
|
59
|
+
* may each declare a secret of the same name and hold different values
|
|
60
|
+
* in them, so adding a secret to one service can never collide with, or
|
|
61
|
+
* silently reuse, a name another service already took. The declaration
|
|
62
|
+
* must therefore live inside a service; Encore reports an error
|
|
63
|
+
* otherwise.
|
|
64
|
+
* - `"shared"`: the whole app, readable from any service, each that reads
|
|
65
|
+
* it recorded as using it. It may be declared outside a service. Use it
|
|
66
|
+
* only for a value several services genuinely share: a shared secret
|
|
67
|
+
* couples every service that reads it, and widening a secret's scope
|
|
68
|
+
* later is easier than narrowing it.
|
|
69
|
+
* - `"global"`: the whole app, with one value available to every service
|
|
70
|
+
* without being granted. It may be declared outside a service.
|
|
71
|
+
*/
|
|
72
|
+
scope?: 'service' | 'shared' | 'global';
|
|
73
|
+
/**
|
|
74
|
+
* What the secret is, who issues it and how to rotate it, shown wherever its
|
|
75
|
+
* values are managed. The declaration's doc comment wins when there is one.
|
|
76
|
+
*/
|
|
77
|
+
description?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Tags that classify the secret, for policies to read: written out as
|
|
80
|
+
* string literals, as in `{data: "pci"}`. Keys and values are lowercase
|
|
81
|
+
* letters, digits, `_` and `-`, at most 63 characters; a key starts with a
|
|
82
|
+
* letter, and not with `encore`, which is reserved. At most 32 tags.
|
|
83
|
+
*/
|
|
84
|
+
tags?: Record<string, string>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* secret declares a {@link Secret}, by default belonging to the service that
|
|
88
|
+
* declares it. See {@link SecretOptions.scope} for a secret of the whole app.
|
|
54
89
|
*
|
|
55
|
-
*
|
|
90
|
+
* A doc comment on the declaration, or a `description` option, is shown
|
|
91
|
+
* wherever the secret's values are managed.
|
|
56
92
|
*
|
|
57
93
|
* @example loading a single secret
|
|
58
94
|
* import {secret} from "@encore.dev/sdk/config";
|
|
59
95
|
* const foo = secret("foo");
|
|
60
|
-
*/
|
|
61
|
-
export declare function secret<Name extends string>(name: StringLiteral<Name>): Secret<Name>;
|
|
62
|
-
/**
|
|
63
|
-
* sharedSecret declares a {@link Secret} shared by the whole app, readable from
|
|
64
|
-
* any service. Unlike {@link secret} it may be declared outside a service.
|
|
65
|
-
*
|
|
66
|
-
* Use it only for a value several services genuinely share: a shared secret
|
|
67
|
-
* couples every service that reads it, and widening a secret's scope later is
|
|
68
|
-
* easier than narrowing it.
|
|
69
96
|
*
|
|
70
|
-
* @example
|
|
71
|
-
* import {
|
|
72
|
-
* const signingKey =
|
|
73
|
-
*/
|
|
74
|
-
export declare function sharedSecret<Name extends string>(name: StringLiteral<Name>): Secret<Name>;
|
|
75
|
-
/**
|
|
76
|
-
* globalSecret declares a {@link Secret} with one value for the whole app,
|
|
77
|
-
* available to every service without being granted. Like
|
|
78
|
-
* {@link sharedSecret} it may be declared outside a service.
|
|
97
|
+
* @example a secret several services share
|
|
98
|
+
* import {secret} from "@encore.dev/sdk/config";
|
|
99
|
+
* const signingKey = secret("SigningKey", {scope: "shared"});
|
|
79
100
|
*
|
|
80
|
-
* @example
|
|
81
|
-
*
|
|
82
|
-
*
|
|
101
|
+
* @example documenting it
|
|
102
|
+
* const apiKey = secret("ApiKey", {
|
|
103
|
+
* description: "Issued by Acme Pay. Rotate it in their portal under Settings → API.",
|
|
104
|
+
* });
|
|
83
105
|
*/
|
|
84
|
-
export declare function
|
|
106
|
+
export declare function secret<Name extends string>(name: StringLiteral<Name>, opts?: SecretOptions): Secret<Name>;
|
|
85
107
|
/**
|
|
86
108
|
* The secret a config's secret field reads: what the runtime's placeholder
|
|
87
109
|
* for the field stands for. A secret name has one scope across the app, so it
|
|
@@ -90,3 +112,4 @@ export declare function globalSecret<Name extends string>(name: StringLiteral<Na
|
|
|
90
112
|
* @internal
|
|
91
113
|
*/
|
|
92
114
|
export declare function secretOfField(name: string): AnySecret;
|
|
115
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../config/secrets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAE5D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM;IACpE;;;;;;;;OAQG;IACH,IAAI,CAAC,CAAC;IAEN;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAEpB;;;;;;;;OAQG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAExC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,MAAM,EACxC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,EAIzB,IAAI,CAAC,EAAE,aAAa,GACnB,MAAM,CAAC,IAAI,CAAC,CAEd;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAErD"}
|
package/dist/config/secrets.js
CHANGED
|
@@ -1,46 +1,30 @@
|
|
|
1
1
|
import * as runtime from '../internal/runtime/mod.js';
|
|
2
|
+
import { lookupScope, testMode } from '../internal/testing/scope.js';
|
|
2
3
|
/**
|
|
3
|
-
* secret declares a {@link Secret} belonging to the service that
|
|
4
|
+
* secret declares a {@link Secret}, by default belonging to the service that
|
|
5
|
+
* declares it. See {@link SecretOptions.scope} for a secret of the whole app.
|
|
4
6
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* silently reuse — a name another service already took. The declaration must
|
|
8
|
-
* therefore live inside a service; Encore reports an error otherwise.
|
|
9
|
-
*
|
|
10
|
-
* For a value several services genuinely share, use {@link sharedSecret}.
|
|
7
|
+
* A doc comment on the declaration, or a `description` option, is shown
|
|
8
|
+
* wherever the secret's values are managed.
|
|
11
9
|
*
|
|
12
10
|
* @example loading a single secret
|
|
13
11
|
* import {secret} from "@encore.dev/sdk/config";
|
|
14
12
|
* const foo = secret("foo");
|
|
15
|
-
*/
|
|
16
|
-
export function secret(name) {
|
|
17
|
-
return makeSecret(name, runtime.RT.secret(name));
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* sharedSecret declares a {@link Secret} shared by the whole app, readable from
|
|
21
|
-
* any service. Unlike {@link secret} it may be declared outside a service.
|
|
22
|
-
*
|
|
23
|
-
* Use it only for a value several services genuinely share: a shared secret
|
|
24
|
-
* couples every service that reads it, and widening a secret's scope later is
|
|
25
|
-
* easier than narrowing it.
|
|
26
13
|
*
|
|
27
|
-
* @example
|
|
28
|
-
* import {
|
|
29
|
-
* const signingKey =
|
|
30
|
-
*/
|
|
31
|
-
export function sharedSecret(name) {
|
|
32
|
-
return makeSecret(name, runtime.RT.secret(name));
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* globalSecret declares a {@link Secret} with one value for the whole app,
|
|
36
|
-
* available to every service without being granted. Like
|
|
37
|
-
* {@link sharedSecret} it may be declared outside a service.
|
|
14
|
+
* @example a secret several services share
|
|
15
|
+
* import {secret} from "@encore.dev/sdk/config";
|
|
16
|
+
* const signingKey = secret("SigningKey", {scope: "shared"});
|
|
38
17
|
*
|
|
39
|
-
* @example
|
|
40
|
-
*
|
|
41
|
-
*
|
|
18
|
+
* @example documenting it
|
|
19
|
+
* const apiKey = secret("ApiKey", {
|
|
20
|
+
* description: "Issued by Acme Pay. Rotate it in their portal under Settings → API.",
|
|
21
|
+
* });
|
|
42
22
|
*/
|
|
43
|
-
export function
|
|
23
|
+
export function secret(name,
|
|
24
|
+
// The options are Encore's parser's to read: a secret is read by name
|
|
25
|
+
// whatever its scope, a name having one scope across the app.
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
+
opts) {
|
|
44
28
|
return makeSecret(name, runtime.RT.secret(name));
|
|
45
29
|
}
|
|
46
30
|
/**
|
|
@@ -59,11 +43,11 @@ export function secretOfField(name) {
|
|
|
59
43
|
*/
|
|
60
44
|
function makeSecret(name, impl) {
|
|
61
45
|
const secretObj = () => {
|
|
46
|
+
// The value the current test gave it, if it did.
|
|
47
|
+
const override = testMode ? lookupScope()?.native.secret(name) : null;
|
|
48
|
+
if (override != null)
|
|
49
|
+
return override.toString('utf8');
|
|
62
50
|
if (impl === null) {
|
|
63
|
-
// During local development we don't consider missing secrets a fatal error.
|
|
64
|
-
if (runtime.RT.appMeta().environment.cloud === runtime.CloudProvider.Local) {
|
|
65
|
-
return '';
|
|
66
|
-
}
|
|
67
51
|
throw new Error(`secret ${name} is not set`);
|
|
68
52
|
}
|
|
69
53
|
return impl.cached();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../config/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../config/secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AA8FhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,MAAM,CACpB,IAAyB;AACzB,sEAAsE;AACtE,8DAA8D;AAC9D,6DAA6D;AAC7D,IAAoB;IAEpB,OAAO,UAAU,CAAe,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,UAAU,CAAY,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CACjB,IAAY,EACZ,IAA0C;IAE1C,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,iDAAiD;QACjD,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACtE,IAAI,QAAQ,IAAI,IAAI;YAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CA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,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC;AAErE,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAElC;;;;;GAKG;AACH,wBAAgB,KAAK,CACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAET"}
|
package/dist/cron/mod.d.ts
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import { DurationString } from '../types/mod.js';
|
|
2
|
+
/**
|
|
3
|
+
* The header with a run's idempotency key: an id that is the same each time
|
|
4
|
+
* Encore sends the run, as when it sends it again after a failure. A job
|
|
5
|
+
* that must not do its work twice can check whether it has seen the key
|
|
6
|
+
* before:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* app.post('/internal/cleanup', (req, res) => {
|
|
10
|
+
* const key = req.get(IDEMPOTENCY_KEY_HEADER);
|
|
11
|
+
* // ...
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Only Encore sends it: a gateway removes it from the requests it takes from
|
|
16
|
+
* clients. `encore cron trigger <name>` runs a job locally, as Encore runs it
|
|
17
|
+
* when it is due.
|
|
18
|
+
*/
|
|
19
|
+
export declare const IDEMPOTENCY_KEY_HEADER = "x-encore-cron-execution";
|
|
20
|
+
/**
|
|
21
|
+
* The header that says why a job runs: `scheduled`, when it was due, or
|
|
22
|
+
* `manual`, when someone asked for it to run now.
|
|
23
|
+
*/
|
|
24
|
+
export declare const TRIGGER_HEADER = "x-encore-cron-trigger";
|
|
2
25
|
export declare class CronJob {
|
|
3
26
|
readonly name: string;
|
|
4
27
|
readonly cfg: CronJobConfig;
|
|
@@ -15,8 +38,16 @@ export type CronJobConfig = {
|
|
|
15
38
|
/** The path the job requests of its service, starting with `/`. */
|
|
16
39
|
path: string;
|
|
17
40
|
title?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Tags that classify the cron job, for policies to read: written out as
|
|
43
|
+
* string literals, as in `{data: "pci"}`. Keys and values are lowercase
|
|
44
|
+
* letters, digits, `_` and `-`, at most 63 characters; a key starts with a
|
|
45
|
+
* letter, and not with `encore`, which is reserved. At most 32 tags.
|
|
46
|
+
*/
|
|
47
|
+
tags?: Record<string, string>;
|
|
18
48
|
} & ({
|
|
19
49
|
every: DurationString;
|
|
20
50
|
} | {
|
|
21
51
|
schedule: string;
|
|
22
52
|
});
|
|
53
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../cron/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAE5C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,cAAc,0BAA0B,CAAC;AAEtD,qBAAa,OAAO;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;gBAChB,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa;CAI7C;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B,GAAG,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAC,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC,CAAC"}
|
package/dist/cron/mod.js
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The header with a run's idempotency key: an id that is the same each time
|
|
3
|
+
* Encore sends the run, as when it sends it again after a failure. A job
|
|
4
|
+
* that must not do its work twice can check whether it has seen the key
|
|
5
|
+
* before:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* app.post('/internal/cleanup', (req, res) => {
|
|
9
|
+
* const key = req.get(IDEMPOTENCY_KEY_HEADER);
|
|
10
|
+
* // ...
|
|
11
|
+
* });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Only Encore sends it: a gateway removes it from the requests it takes from
|
|
15
|
+
* clients. `encore cron trigger <name>` runs a job locally, as Encore runs it
|
|
16
|
+
* when it is due.
|
|
17
|
+
*/
|
|
18
|
+
export const IDEMPOTENCY_KEY_HEADER = 'x-encore-cron-execution';
|
|
19
|
+
/**
|
|
20
|
+
* The header that says why a job runs: `scheduled`, when it was due, or
|
|
21
|
+
* `manual`, when someone asked for it to run now.
|
|
22
|
+
*/
|
|
23
|
+
export const TRIGGER_HEADER = 'x-encore-cron-trigger';
|
|
1
24
|
export class CronJob {
|
|
2
25
|
name;
|
|
3
26
|
cfg;
|
package/dist/cron/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../cron/mod.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,OAAO;IACT,IAAI,CAAS;IACb,GAAG,CAAgB;IAC5B,YAAY,IAAY,EAAE,GAAkB;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../cron/mod.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAEtD,MAAM,OAAO,OAAO;IACT,IAAI,CAAS;IACb,GAAG,CAAgB;IAC5B,YAAY,IAAY,EAAE,GAAkB;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The code of an Encore error, which a {@link reject}ion answers with: what
|
|
3
|
+
* went wrong, as Encore's clients read it, and the HTTP status the answer
|
|
4
|
+
* has. They are the codes a service's errors answer with.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ErrCode {
|
|
7
|
+
/** 499. */
|
|
8
|
+
Canceled = "canceled",
|
|
9
|
+
/** 500. */
|
|
10
|
+
Unknown = "unknown",
|
|
11
|
+
/** 400. */
|
|
12
|
+
InvalidArgument = "invalid_argument",
|
|
13
|
+
/** 504. */
|
|
14
|
+
DeadlineExceeded = "deadline_exceeded",
|
|
15
|
+
/** 404. */
|
|
16
|
+
NotFound = "not_found",
|
|
17
|
+
/** 409. */
|
|
18
|
+
AlreadyExists = "already_exists",
|
|
19
|
+
/** 403. */
|
|
20
|
+
PermissionDenied = "permission_denied",
|
|
21
|
+
/** 429. */
|
|
22
|
+
ResourceExhausted = "resource_exhausted",
|
|
23
|
+
/** 400. */
|
|
24
|
+
FailedPrecondition = "failed_precondition",
|
|
25
|
+
/** 409. */
|
|
26
|
+
Aborted = "aborted",
|
|
27
|
+
/** 400. */
|
|
28
|
+
OutOfRange = "out_of_range",
|
|
29
|
+
/** 501. */
|
|
30
|
+
Unimplemented = "unimplemented",
|
|
31
|
+
/** 500. */
|
|
32
|
+
Internal = "internal",
|
|
33
|
+
/** 503. */
|
|
34
|
+
Unavailable = "unavailable",
|
|
35
|
+
/** 500. */
|
|
36
|
+
DataLoss = "data_loss",
|
|
37
|
+
/** 401. */
|
|
38
|
+
Unauthenticated = "unauthenticated"
|
|
39
|
+
}
|
|
40
|
+
/** The HTTP status an answer with `code` has: 401 for
|
|
41
|
+
* {@link ErrCode.Unauthenticated}, 404 for {@link ErrCode.NotFound}, and so
|
|
42
|
+
* on. */
|
|
43
|
+
export declare function httpStatus(code: ErrCode): number;
|
|
44
|
+
/** Response headers: a record, or pairs for a header sent more than once. */
|
|
45
|
+
export type Headers = Record<string, string> | ReadonlyArray<[string, string]>;
|
|
46
|
+
/**
|
|
47
|
+
* A Middleware's answer to a request it does not let through: `onRequest`
|
|
48
|
+
* returns or throws one, and the gateway writes it to the client, with the
|
|
49
|
+
* gateway's CORS headers, rather than forwarding the request.
|
|
50
|
+
*
|
|
51
|
+
* {@link reject} answers as a service answers with an Encore error, which
|
|
52
|
+
* Encore's clients read as one; {@link respond} answers with any response,
|
|
53
|
+
* such as a redirect.
|
|
54
|
+
*/
|
|
55
|
+
export declare class Rejection extends Error {
|
|
56
|
+
name: string;
|
|
57
|
+
/** The HTTP status the request is answered with. */
|
|
58
|
+
readonly status: number;
|
|
59
|
+
/** The Encore error code, for a {@link reject}; undefined for a
|
|
60
|
+
* {@link respond}. */
|
|
61
|
+
readonly code: ErrCode | undefined;
|
|
62
|
+
/** What went wrong, for a {@link reject}; empty for a {@link respond}. */
|
|
63
|
+
readonly errorMessage: string;
|
|
64
|
+
/** The response's headers, as name and value pairs. */
|
|
65
|
+
readonly headers: Array<[string, string]>;
|
|
66
|
+
/** The response's body, for a {@link respond}. */
|
|
67
|
+
readonly body: Uint8Array | undefined;
|
|
68
|
+
/** @internal Made by {@link reject} and {@link respond}. */
|
|
69
|
+
constructor(status: number, code: ErrCode | undefined, message: string, headers: Array<[string, string]>, body: Uint8Array | undefined);
|
|
70
|
+
/** Adds a header to the response, as `Retry-After` to a 429, and returns
|
|
71
|
+
* the rejection. */
|
|
72
|
+
withHeader(name: string, value: string): this;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Answers a request with an Encore error with `code` and `message`, and the
|
|
76
|
+
* HTTP status of the code: 401 for {@link ErrCode.Unauthenticated}, 403 for
|
|
77
|
+
* {@link ErrCode.PermissionDenied}, 429 for
|
|
78
|
+
* {@link ErrCode.ResourceExhausted}, and so on.
|
|
79
|
+
*
|
|
80
|
+
* ```typescript
|
|
81
|
+
* return gateway.reject(ErrCode.Unauthenticated, "missing token");
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function reject(code: ErrCode, message: string): Rejection;
|
|
85
|
+
/**
|
|
86
|
+
* Answers a request with `status`, `headers` and `body` as they are, as a
|
|
87
|
+
* redirect to sign in:
|
|
88
|
+
*
|
|
89
|
+
* ```typescript
|
|
90
|
+
* return gateway.respond(302, { location: "/login" });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function respond(status: number, headers?: Headers, body?: Uint8Array | string): Rejection;
|
|
94
|
+
/**
|
|
95
|
+
* The gateway cannot be served: a Middleware is invalid, the process is not
|
|
96
|
+
* a gateway program Encore runs, or the gateway is already served.
|
|
97
|
+
*/
|
|
98
|
+
export declare class GatewayError extends Error {
|
|
99
|
+
name: string;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../gateway/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,OAAO;IACjB,WAAW;IACX,QAAQ,aAAa;IACrB,WAAW;IACX,OAAO,YAAY;IACnB,WAAW;IACX,eAAe,qBAAqB;IACpC,WAAW;IACX,gBAAgB,sBAAsB;IACtC,WAAW;IACX,QAAQ,cAAc;IACtB,WAAW;IACX,aAAa,mBAAmB;IAChC,WAAW;IACX,gBAAgB,sBAAsB;IACtC,WAAW;IACX,iBAAiB,uBAAuB;IACxC,WAAW;IACX,kBAAkB,wBAAwB;IAC1C,WAAW;IACX,OAAO,YAAY;IACnB,WAAW;IACX,UAAU,iBAAiB;IAC3B,WAAW;IACX,aAAa,kBAAkB;IAC/B,WAAW;IACX,QAAQ,aAAa;IACrB,WAAW;IACX,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