@encore.dev/sdk 2.0.0-beta.14 → 2.0.0-beta.16
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 +144 -90
- package/app_meta.ts +56 -54
- package/config/config.test.ts +47 -13
- package/config/config.ts +60 -57
- package/config/secrets.ts +47 -50
- package/config/value.ts +23 -26
- package/cron/mod.test.ts +12 -0
- package/cron/mod.ts +37 -22
- package/dist/app_meta.d.ts +52 -50
- package/dist/app_meta.d.ts.map +1 -1
- package/dist/app_meta.js +2 -2
- package/dist/app_meta.js.map +1 -1
- package/dist/config/config.d.ts +58 -55
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +8 -9
- package/dist/config/config.js.map +1 -1
- package/dist/config/secrets.d.ts +45 -50
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +11 -9
- package/dist/config/secrets.js.map +1 -1
- package/dist/config/value.d.ts +20 -23
- package/dist/config/value.d.ts.map +1 -1
- package/dist/config/value.js +20 -23
- package/dist/config/value.js.map +1 -1
- package/dist/cron/mod.d.ts +34 -20
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +13 -13
- package/dist/cron/mod.js.map +1 -1
- package/dist/frontends/mod.d.ts +20 -19
- package/dist/frontends/mod.d.ts.map +1 -1
- package/dist/frontends/mod.js +20 -19
- package/dist/frontends/mod.js.map +1 -1
- package/dist/gateway/errors.d.ts +28 -30
- package/dist/gateway/errors.d.ts.map +1 -1
- package/dist/gateway/errors.js +29 -31
- package/dist/gateway/errors.js.map +1 -1
- package/dist/gateway/match.d.ts +54 -54
- package/dist/gateway/match.d.ts.map +1 -1
- package/dist/gateway/match.js +56 -56
- package/dist/gateway/match.js.map +1 -1
- package/dist/gateway/middleware.d.ts +62 -64
- package/dist/gateway/middleware.d.ts.map +1 -1
- package/dist/gateway/middleware.js +1 -1
- package/dist/gateway/middleware.js.map +1 -1
- package/dist/gateway/mod.d.ts +64 -67
- package/dist/gateway/mod.d.ts.map +1 -1
- package/dist/gateway/mod.js +72 -76
- package/dist/gateway/mod.js.map +1 -1
- package/dist/gateway/request.d.ts +138 -134
- package/dist/gateway/request.d.ts.map +1 -1
- package/dist/gateway/request.js +117 -108
- package/dist/gateway/request.js.map +1 -1
- package/dist/gateway/serve.d.ts +29 -34
- package/dist/gateway/serve.d.ts.map +1 -1
- package/dist/gateway/serve.js +51 -56
- package/dist/gateway/serve.js.map +1 -1
- package/dist/gateways/mod.d.ts +23 -21
- package/dist/gateways/mod.d.ts.map +1 -1
- package/dist/gateways/mod.js +25 -23
- package/dist/gateways/mod.js.map +1 -1
- package/dist/internal/otel/http.d.ts +4 -2
- package/dist/internal/otel/http.d.ts.map +1 -1
- package/dist/internal/otel/http.js +32 -5
- package/dist/internal/otel/http.js.map +1 -1
- package/dist/internal/runtime/napi/napi.cjs +6 -5
- package/dist/internal/runtime/napi/napi.d.cts +58 -16
- package/dist/internal/runtime/shutdown.d.ts +75 -57
- package/dist/internal/runtime/shutdown.d.ts.map +1 -1
- package/dist/internal/runtime/shutdown.js +88 -84
- package/dist/internal/runtime/shutdown.js.map +1 -1
- package/dist/log/logger.d.ts +43 -37
- package/dist/log/logger.d.ts.map +1 -1
- package/dist/log/logger.js +26 -25
- package/dist/log/logger.js.map +1 -1
- package/dist/metrics/mod.d.ts +133 -114
- package/dist/metrics/mod.d.ts.map +1 -1
- package/dist/metrics/mod.js +109 -101
- package/dist/metrics/mod.js.map +1 -1
- package/dist/otel.d.ts +6 -3
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +6 -3
- package/dist/otel.js.map +1 -1
- package/dist/pubsub/subscription.d.ts +88 -116
- package/dist/pubsub/subscription.d.ts.map +1 -1
- package/dist/pubsub/subscription.js +14 -17
- package/dist/pubsub/subscription.js.map +1 -1
- package/dist/pubsub/topic.d.ts +86 -113
- package/dist/pubsub/topic.d.ts.map +1 -1
- package/dist/pubsub/topic.js +68 -82
- package/dist/pubsub/topic.js.map +1 -1
- package/dist/redaction/mod.d.ts +62 -0
- package/dist/redaction/mod.d.ts.map +1 -0
- package/dist/redaction/mod.js +102 -0
- package/dist/redaction/mod.js.map +1 -0
- package/dist/reqctx/mod.d.ts +83 -86
- package/dist/reqctx/mod.d.ts.map +1 -1
- package/dist/reqctx/mod.js +39 -41
- package/dist/reqctx/mod.js.map +1 -1
- package/dist/services/index.d.ts +76 -75
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +73 -71
- package/dist/services/index.js.map +1 -1
- package/dist/shutdown/mod.d.ts +26 -25
- package/dist/shutdown/mod.d.ts.map +1 -1
- package/dist/shutdown/mod.js +26 -25
- package/dist/shutdown/mod.js.map +1 -1
- package/dist/storage/clickhouse/database.d.ts +113 -115
- package/dist/storage/clickhouse/database.d.ts.map +1 -1
- package/dist/storage/clickhouse/database.js +65 -79
- package/dist/storage/clickhouse/database.js.map +1 -1
- package/dist/storage/clickhouse/errors.d.ts +25 -26
- package/dist/storage/clickhouse/errors.d.ts.map +1 -1
- package/dist/storage/clickhouse/errors.js +15 -17
- package/dist/storage/clickhouse/errors.js.map +1 -1
- package/dist/storage/clickhouse/mod.d.ts +10 -10
- package/dist/storage/clickhouse/mod.js +10 -10
- package/dist/storage/objects/bucket.d.ts +230 -203
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +146 -106
- package/dist/storage/objects/bucket.js.map +1 -1
- package/dist/storage/objects/error.d.ts +4 -4
- package/dist/storage/objects/error.js +4 -4
- package/dist/storage/objects/mod.d.ts +1 -1
- package/dist/storage/objects/mod.d.ts.map +1 -1
- package/dist/storage/objects/mod.js.map +1 -1
- package/dist/storage/objects/refs.d.ts +2 -5
- package/dist/storage/objects/refs.d.ts.map +1 -1
- package/dist/storage/objects/refs.js.map +1 -1
- package/dist/storage/postgres/database.d.ts +124 -149
- package/dist/storage/postgres/database.d.ts.map +1 -1
- package/dist/storage/postgres/database.js +98 -135
- package/dist/storage/postgres/database.js.map +1 -1
- package/dist/storage/postgres/errors.d.ts +42 -48
- package/dist/storage/postgres/errors.d.ts.map +1 -1
- package/dist/storage/postgres/errors.js +44 -51
- package/dist/storage/postgres/errors.js.map +1 -1
- package/dist/storage/postgres/interval.d.ts +19 -19
- package/dist/storage/postgres/interval.d.ts.map +1 -1
- package/dist/storage/postgres/interval.js +21 -21
- package/dist/storage/postgres/interval.js.map +1 -1
- package/dist/storage/redis/bitfield.d.ts +48 -23
- package/dist/storage/redis/bitfield.d.ts.map +1 -1
- package/dist/storage/redis/bitfield.js +38 -19
- package/dist/storage/redis/bitfield.js.map +1 -1
- package/dist/storage/redis/command.d.ts +16 -12
- package/dist/storage/redis/command.d.ts.map +1 -1
- package/dist/storage/redis/command.js +16 -12
- package/dist/storage/redis/command.js.map +1 -1
- package/dist/storage/redis/commands.d.ts +99 -100
- package/dist/storage/redis/commands.d.ts.map +1 -1
- package/dist/storage/redis/commands.js +84 -85
- package/dist/storage/redis/commands.js.map +1 -1
- package/dist/storage/redis/database.d.ts +138 -122
- package/dist/storage/redis/database.d.ts.map +1 -1
- package/dist/storage/redis/database.js +120 -101
- package/dist/storage/redis/database.js.map +1 -1
- package/dist/storage/redis/mod.d.ts +52 -48
- package/dist/storage/redis/mod.d.ts.map +1 -1
- package/dist/storage/redis/mod.js +52 -48
- package/dist/storage/redis/mod.js.map +1 -1
- package/dist/storage/redis/options.d.ts +26 -24
- package/dist/storage/redis/options.d.ts.map +1 -1
- package/dist/storage/redis/options.js.map +1 -1
- package/dist/storage/redis/pubsub.d.ts +16 -16
- package/dist/storage/redis/pubsub.d.ts.map +1 -1
- package/dist/storage/redis/pubsub.js +14 -14
- package/dist/storage/redis/pubsub.js.map +1 -1
- package/dist/storage/redis/reply.d.ts +80 -72
- package/dist/storage/redis/reply.d.ts.map +1 -1
- package/dist/storage/redis/reply.js +53 -46
- package/dist/storage/redis/reply.js.map +1 -1
- package/dist/storage/redis/scan.d.ts +4 -4
- package/dist/storage/redis/scan.d.ts.map +1 -1
- package/dist/storage/redis/scan.js +6 -6
- package/dist/storage/redis/scan.js.map +1 -1
- package/dist/storage/redis/script.d.ts +28 -21
- package/dist/storage/redis/script.d.ts.map +1 -1
- package/dist/storage/redis/script.js +29 -22
- package/dist/storage/redis/script.js.map +1 -1
- package/dist/storage/redis/target.d.ts +17 -1
- package/dist/storage/redis/target.d.ts.map +1 -1
- package/dist/storage/redis/target.js +30 -1
- package/dist/storage/redis/target.js.map +1 -1
- package/dist/storage/redis/wire.d.ts +6 -6
- package/dist/storage/redis/wire.d.ts.map +1 -1
- package/dist/storage/redis/wire.js +6 -6
- package/dist/storage/redis/wire.js.map +1 -1
- package/dist/testing/mod.d.ts +83 -88
- package/dist/testing/mod.d.ts.map +1 -1
- package/dist/testing/mod.js +75 -81
- package/dist/testing/mod.js.map +1 -1
- package/dist/testing/playwright.d.ts +28 -32
- package/dist/testing/playwright.d.ts.map +1 -1
- package/dist/testing/playwright.js +22 -27
- package/dist/testing/playwright.js.map +1 -1
- package/dist/testing/puppeteer.d.ts +11 -12
- package/dist/testing/puppeteer.d.ts.map +1 -1
- package/dist/testing/puppeteer.js +17 -18
- package/dist/testing/puppeteer.js.map +1 -1
- package/dist/testing/system.d.ts +72 -90
- package/dist/testing/system.d.ts.map +1 -1
- package/dist/testing/system.js +90 -107
- package/dist/testing/system.js.map +1 -1
- package/dist/tracing/http.d.ts +2 -1
- package/dist/tracing/http.d.ts.map +1 -1
- package/dist/tracing/http.js +2 -1
- package/dist/tracing/http.js.map +1 -1
- package/dist/tracing/node.d.ts.map +1 -1
- package/dist/tracing/node.js +1 -1
- package/dist/tracing/node.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/frontends/mod.test.ts +6 -2
- package/frontends/mod.ts +20 -19
- package/gateway/errors.ts +30 -32
- package/gateway/match.ts +61 -57
- package/gateway/middleware.ts +62 -64
- package/gateway/mod.ts +73 -76
- package/gateway/request.ts +143 -140
- package/gateway/serve.ts +58 -63
- package/gateways/mod.ts +25 -23
- package/internal/otel/http.test.ts +50 -0
- package/internal/otel/http.ts +40 -5
- package/internal/runtime/napi/napi.cjs +6 -5
- package/internal/runtime/napi/napi.d.cts +58 -16
- package/internal/runtime/shutdown.ts +113 -101
- package/log/logger.test.ts +8 -0
- package/log/logger.ts +48 -45
- package/metrics/mod.ts +138 -122
- package/otel.ts +6 -3
- package/package.json +6 -1
- package/pubsub/subscription.ts +93 -123
- package/pubsub/topic.ts +96 -130
- package/redaction/bridge.test.ts +99 -0
- package/redaction/mod.test.ts +188 -0
- package/redaction/mod.ts +226 -0
- package/reqctx/mod.ts +83 -86
- package/services/index.ts +78 -78
- package/shutdown/mod.ts +26 -25
- package/storage/clickhouse/database.ts +115 -129
- package/storage/clickhouse/errors.ts +27 -29
- package/storage/clickhouse/mod.ts +10 -10
- package/storage/objects/bucket.test.ts +168 -16
- package/storage/objects/bucket.ts +336 -247
- package/storage/objects/error.ts +4 -4
- package/storage/objects/mod.ts +1 -0
- package/storage/objects/refs.ts +2 -5
- package/storage/postgres/database.ts +131 -164
- package/storage/postgres/errors.ts +45 -52
- package/storage/postgres/interval.ts +21 -21
- package/storage/redis/bitfield.ts +51 -26
- package/storage/redis/command.ts +16 -12
- package/storage/redis/commands.ts +99 -100
- package/storage/redis/database.ts +145 -123
- package/storage/redis/mod.ts +52 -48
- package/storage/redis/options.ts +26 -24
- package/storage/redis/pubsub.ts +14 -14
- package/storage/redis/redis.test.ts +17 -2
- package/storage/redis/reply.ts +85 -77
- package/storage/redis/scan.ts +6 -6
- package/storage/redis/script.ts +29 -22
- package/storage/redis/target.ts +34 -1
- package/storage/redis/wire.ts +8 -8
- package/testing/mod.ts +99 -105
- package/testing/playwright.ts +32 -37
- package/testing/puppeteer.ts +22 -23
- package/testing/system.ts +117 -133
- package/tracing/http.ts +2 -1
- package/tracing/native.test.ts +158 -8
- package/tracing/node.ts +1 -0
package/dist/config/secrets.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { StringLiteral } from '../internal/utils/constraints.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* so that you can write functions which expect a specific one.
|
|
3
|
+
* Represents a single secret loaded into the application. It is strongly typed
|
|
4
|
+
* to its secret name so functions can require a specific secret.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
* it's name.
|
|
6
|
+
* Use {@link AnySecret} to accept any secret regardless of its name.
|
|
9
7
|
*
|
|
10
|
-
* `T` is the
|
|
8
|
+
* `T` is the secret's value type (only `string` is supported).
|
|
11
9
|
*
|
|
12
10
|
* @example
|
|
13
11
|
*
|
|
@@ -19,11 +17,12 @@ export interface Secret<Name extends string, T extends string = string> {
|
|
|
19
17
|
/**
|
|
20
18
|
* Returns the value of the secret.
|
|
21
19
|
*
|
|
22
|
-
* The value is
|
|
23
|
-
*
|
|
20
|
+
* The value is loaded once per process and does not change while it is
|
|
21
|
+
* running; updated values take effect when the service restarts.
|
|
24
22
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* Locally (`encore run`, `encore test`), an unset secret returns `""` so
|
|
24
|
+
* checks like `if (!apiKey())` can skip unconfigured integrations. In all
|
|
25
|
+
* other environments, reading an unset secret throws an `Error` naming it.
|
|
27
26
|
*/
|
|
28
27
|
(): T;
|
|
29
28
|
/**
|
|
@@ -31,64 +30,61 @@ export interface Secret<Name extends string, T extends string = string> {
|
|
|
31
30
|
*/
|
|
32
31
|
readonly name: Name;
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* Type brand used by Encore's parser to detect secret fields inside a config
|
|
34
|
+
* type. Never set at runtime.
|
|
36
35
|
*
|
|
37
|
-
*
|
|
38
|
-
* secret
|
|
39
|
-
*
|
|
40
|
-
*
|
|
36
|
+
* When used in a config interface, `apiKey: Secret<"StripeKey">` references
|
|
37
|
+
* the secret with that name in the config's scope (the declaring service for
|
|
38
|
+
* a service config, or the app for a shared or global config). The secret
|
|
39
|
+
* itself must still be declared with {@link secret}.
|
|
41
40
|
*/
|
|
42
41
|
readonly '~encore.secret'?: true;
|
|
43
42
|
}
|
|
44
43
|
/**
|
|
45
|
-
*
|
|
46
|
-
* without knowing its name.
|
|
44
|
+
* Represents any {@link Secret} without requiring a specific name.
|
|
47
45
|
*/
|
|
48
46
|
export type AnySecret = Secret<string>;
|
|
49
47
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
48
|
+
* Options for declaring a secret with {@link secret}. Values must be literals
|
|
49
|
+
* so Encore's parser can inspect them statically.
|
|
52
50
|
*/
|
|
53
51
|
export interface SecretOptions {
|
|
54
52
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
53
|
+
* Controls which services own and can read the secret. Must be a string
|
|
54
|
+
* literal so Encore can resolve it statically:
|
|
57
55
|
*
|
|
58
|
-
* - `"service"
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
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.
|
|
56
|
+
* - `"service"` (default): scoped to the declaring service. Two services may
|
|
57
|
+
* declare secrets with the same name and hold independent values, avoiding
|
|
58
|
+
* accidental collisions or silent reuse. Must be declared inside a
|
|
59
|
+
* service; Encore reports an error otherwise.
|
|
60
|
+
* - `"shared"`: app-wide and readable from any service, with each reading
|
|
61
|
+
* service recorded as a consumer. May be declared outside a service. Use
|
|
62
|
+
* this only when multiple services genuinely share a value — widening a
|
|
63
|
+
* secret's scope later is easier than narrowing it.
|
|
64
|
+
* - `"global"`: app-wide with a single value available to every service
|
|
65
|
+
* without requiring per-service grants. May be declared outside a service.
|
|
71
66
|
*/
|
|
72
67
|
scope?: 'service' | 'shared' | 'global';
|
|
73
68
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
69
|
+
* Human-readable description of the secret (what it is, who issues it, and
|
|
70
|
+
* how to rotate it), displayed wherever secret values are managed. A doc
|
|
71
|
+
* comment on the declaration takes precedence if both are present.
|
|
76
72
|
*/
|
|
77
73
|
description?: string;
|
|
78
74
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
75
|
+
* Static string-literal tags that classify the secret for policy checks
|
|
76
|
+
* (e.g. `{data: "pci"}`). Keys and values may contain lowercase letters,
|
|
77
|
+
* digits, `_`, and `-`, up to 63 characters. Keys must start with a letter
|
|
78
|
+
* and cannot start with the reserved prefix `encore`. At most 32 tags.
|
|
83
79
|
*/
|
|
84
80
|
tags?: Record<string, string>;
|
|
85
81
|
}
|
|
86
82
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
83
|
+
* Declares a {@link Secret}, scoped by default to the declaring service. See
|
|
84
|
+
* {@link SecretOptions.scope} for app-wide secrets.
|
|
89
85
|
*
|
|
90
|
-
* A doc comment on the declaration
|
|
91
|
-
* wherever
|
|
86
|
+
* A doc comment on the declaration (or the `description` option) is shown
|
|
87
|
+
* wherever secret values are managed.
|
|
92
88
|
*
|
|
93
89
|
* @example
|
|
94
90
|
* ```ts
|
|
@@ -99,14 +95,14 @@ export interface SecretOptions {
|
|
|
99
95
|
*
|
|
100
96
|
* @example
|
|
101
97
|
* ```ts
|
|
102
|
-
* // A secret several services
|
|
98
|
+
* // A secret shared by several services.
|
|
103
99
|
* import {secret} from "@encore.dev/sdk/config";
|
|
104
100
|
* const signingKey = secret("SigningKey", {scope: "shared"});
|
|
105
101
|
* ```
|
|
106
102
|
*
|
|
107
103
|
* @example
|
|
108
104
|
* ```ts
|
|
109
|
-
* // Documenting
|
|
105
|
+
* // Documenting a secret.
|
|
110
106
|
* const apiKey = secret("ApiKey", {
|
|
111
107
|
* description: "Issued by Acme Pay. Rotate it in their portal under Settings → API.",
|
|
112
108
|
* });
|
|
@@ -114,9 +110,8 @@ export interface SecretOptions {
|
|
|
114
110
|
*/
|
|
115
111
|
export declare function secret<Name extends string>(name: StringLiteral<Name>, opts?: SecretOptions): Secret<Name>;
|
|
116
112
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* is read by name whatever the config's scope. Internal to the config module.
|
|
113
|
+
* Returns the secret handle referenced by a config's secret field placeholder.
|
|
114
|
+
* Internal to the config module.
|
|
120
115
|
*
|
|
121
116
|
* @internal
|
|
122
117
|
*/
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../config/secrets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM;IACpE;;;;;;;;;OASG;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;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAExC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;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;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAErD"}
|
package/dist/config/secrets.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as runtime from '../internal/runtime/mod.js';
|
|
2
2
|
import { lookupScope, testMode } from '../internal/testing/scope.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Declares a {@link Secret}, scoped by default to the declaring service. See
|
|
5
|
+
* {@link SecretOptions.scope} for app-wide secrets.
|
|
6
6
|
*
|
|
7
|
-
* A doc comment on the declaration
|
|
8
|
-
* wherever
|
|
7
|
+
* A doc comment on the declaration (or the `description` option) is shown
|
|
8
|
+
* wherever secret values are managed.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
@@ -16,14 +16,14 @@ import { lookupScope, testMode } from '../internal/testing/scope.js';
|
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
|
19
|
-
* // A secret several services
|
|
19
|
+
* // A secret shared by several services.
|
|
20
20
|
* import {secret} from "@encore.dev/sdk/config";
|
|
21
21
|
* const signingKey = secret("SigningKey", {scope: "shared"});
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
25
|
* ```ts
|
|
26
|
-
* // Documenting
|
|
26
|
+
* // Documenting a secret.
|
|
27
27
|
* const apiKey = secret("ApiKey", {
|
|
28
28
|
* description: "Issued by Acme Pay. Rotate it in their portal under Settings → API.",
|
|
29
29
|
* });
|
|
@@ -37,9 +37,8 @@ opts) {
|
|
|
37
37
|
return makeSecret(name, runtime.RT.secret(name));
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* is read by name whatever the config's scope. Internal to the config module.
|
|
40
|
+
* Returns the secret handle referenced by a config's secret field placeholder.
|
|
41
|
+
* Internal to the config module.
|
|
43
42
|
*
|
|
44
43
|
* @internal
|
|
45
44
|
*/
|
|
@@ -57,6 +56,9 @@ function makeSecret(name, impl) {
|
|
|
57
56
|
if (override != null)
|
|
58
57
|
return override.toString('utf8');
|
|
59
58
|
if (impl === null) {
|
|
59
|
+
// Unset locally: it reads as one set empty.
|
|
60
|
+
if (runtime.RT.unsetSecretsReadEmpty())
|
|
61
|
+
return '';
|
|
60
62
|
throw new Error(`secret ${name} is not set`);
|
|
61
63
|
}
|
|
62
64
|
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;AACnD,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,2BAA2B,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;AA0FhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;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;;;;;GAKG;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,4CAA4C;YAC5C,IAAI,OAAO,CAAC,EAAE,CAAC,qBAAqB,EAAE;gBAAE,OAAO,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,aAAa,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC,CAAC;IAEF,SAAS,CAAC,QAAQ,GAAG,GAAG,EAAE;QACxB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,OAAO,UAAU,IAAI,YAAY,CAAC;QACpC,CAAC;QACD,OAAO,UAAU,IAAI,cAAc,CAAC;IACtC,CAAC,CAAC;IACF,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;IAExD,OAAO,SAAyB,CAAC;AACnC,CAAC"}
|
package/dist/config/value.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* can be tested without one.
|
|
2
|
+
* Converts raw config JSON from the runtime into typed values using the
|
|
3
|
+
* config's JSON Schema: duration strings become {@link Duration} instances and
|
|
4
|
+
* secret placeholders become secret handles. Kept separate from the runtime so
|
|
5
|
+
* it can be unit-tested standalone.
|
|
7
6
|
*/
|
|
8
7
|
/**
|
|
9
|
-
* A length of time, written in config files as
|
|
10
|
-
*
|
|
11
|
-
* `
|
|
8
|
+
* A non-negative length of time, written in config files as one or more
|
|
9
|
+
* number-and-unit pairs such as `"30s"`, `"250ms"`, or `"1h30m"`. Supported
|
|
10
|
+
* units are `ns`, `us`, `ms`, `s`, `m`, and `h` (matching Go's
|
|
11
|
+
* `time.ParseDuration`, without a leading sign).
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* interface Checkout { paymentTimeout: Duration }
|
|
@@ -16,38 +16,35 @@
|
|
|
16
16
|
*/
|
|
17
17
|
export declare class Duration {
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Type brand used by Encore's parser to identify duration fields in a config
|
|
20
|
+
* type. Never set at runtime.
|
|
21
21
|
*/
|
|
22
22
|
readonly '~encore.duration'?: true;
|
|
23
23
|
private readonly ms;
|
|
24
24
|
private constructor();
|
|
25
|
-
/**
|
|
25
|
+
/** Parses a duration string and throws if the format is invalid. */
|
|
26
26
|
static parse(text: string): Duration;
|
|
27
|
-
/**
|
|
27
|
+
/** Creates a duration of `ms` milliseconds. */
|
|
28
28
|
static ofMilliseconds(ms: number): Duration;
|
|
29
|
-
/**
|
|
29
|
+
/** Returns the duration in milliseconds (suitable for `setTimeout`). */
|
|
30
30
|
get milliseconds(): number;
|
|
31
|
-
/**
|
|
31
|
+
/** Returns the duration in seconds. */
|
|
32
32
|
get seconds(): number;
|
|
33
|
-
/**
|
|
33
|
+
/** Formats the duration in config-file syntax (e.g. `"1h30m"`, `"250ms"`, `"0s"`). */
|
|
34
34
|
toString(): string;
|
|
35
35
|
toJSON(): string;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
* `{"$encore_secret": "<name>"}`. The name alone says which secret it is: a
|
|
40
|
-
* secret's name has one scope across the app.
|
|
38
|
+
* Property key used in runtime secret placeholders (`{"$encore_secret": "<name>"}`).
|
|
41
39
|
*/
|
|
42
40
|
export declare const PLACEHOLDER_KEY = "$encore_secret";
|
|
43
|
-
/**
|
|
41
|
+
/** Resolves a secret placeholder's name into a secret handle. */
|
|
44
42
|
export type SecretOf = (name: string) => unknown;
|
|
45
43
|
type Schema = Record<string, any>;
|
|
46
44
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* `secretOf` builds.
|
|
45
|
+
* Converts a raw JSON config `value` according to `schema`, turning duration
|
|
46
|
+
* strings into {@link Duration} instances and secret placeholders into handles
|
|
47
|
+
* via `secretOf`.
|
|
51
48
|
*/
|
|
52
49
|
export declare function build(schema: Schema, value: unknown, secretOf: SecretOf): unknown;
|
|
53
50
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../config/value.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../config/value.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH;;;;;;;;;GASG;AACH,qBAAa,QAAQ;IACnB;;;OAGG;IACH,SAAiB,kBAAkB,CAAC,EAAE,IAAI,CAAC;IAE3C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;IAE5B,OAAO;IAIP,oEAAoE;IACpE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;IAgBpC,+CAA+C;IAC/C,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ;IAO3C,wEAAwE;IACxE,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,uCAAuC;IACvC,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,sFAAsF;IACtF,QAAQ,IAAI,MAAM;IAsBlB,MAAM,IAAI,MAAM;CAGjB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAEhD,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAEjD,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAElC;;;;GAIG;AACH,wBAAgB,KAAK,CACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAET"}
|
package/dist/config/value.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* can be tested without one.
|
|
2
|
+
* Converts raw config JSON from the runtime into typed values using the
|
|
3
|
+
* config's JSON Schema: duration strings become {@link Duration} instances and
|
|
4
|
+
* secret placeholders become secret handles. Kept separate from the runtime so
|
|
5
|
+
* it can be unit-tested standalone.
|
|
7
6
|
*/
|
|
8
|
-
/**
|
|
7
|
+
/** Matches a non-negative duration string (one or more number+unit segments). */
|
|
9
8
|
const DURATION = /^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$/;
|
|
10
9
|
const UNIT_MS = {
|
|
11
10
|
ns: 1e-6,
|
|
@@ -17,9 +16,10 @@ const UNIT_MS = {
|
|
|
17
16
|
h: 3600000,
|
|
18
17
|
};
|
|
19
18
|
/**
|
|
20
|
-
* A length of time, written in config files as
|
|
21
|
-
*
|
|
22
|
-
* `
|
|
19
|
+
* A non-negative length of time, written in config files as one or more
|
|
20
|
+
* number-and-unit pairs such as `"30s"`, `"250ms"`, or `"1h30m"`. Supported
|
|
21
|
+
* units are `ns`, `us`, `ms`, `s`, `m`, and `h` (matching Go's
|
|
22
|
+
* `time.ParseDuration`, without a leading sign).
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
25
|
* interface Checkout { paymentTimeout: Duration }
|
|
@@ -30,10 +30,10 @@ export class Duration {
|
|
|
30
30
|
constructor(ms) {
|
|
31
31
|
this.ms = ms;
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
33
|
+
/** Parses a duration string and throws if the format is invalid. */
|
|
34
34
|
static parse(text) {
|
|
35
35
|
if (!DURATION.test(text)) {
|
|
36
|
-
throw new Error(`${JSON.stringify(text)} is not a duration
|
|
36
|
+
throw new Error(`${JSON.stringify(text)} is not a valid duration (expected e.g. "30s", "250ms", or "1h30m")`);
|
|
37
37
|
}
|
|
38
38
|
let ms = 0;
|
|
39
39
|
for (const m of text.matchAll(/([0-9]+(?:\.[0-9]+)?)(ns|us|µs|ms|s|m|h)/g)) {
|
|
@@ -42,22 +42,22 @@ export class Duration {
|
|
|
42
42
|
// Whole nanoseconds, so that "0.1s" is 100ms rather than 100.00000000000001.
|
|
43
43
|
return new Duration(Math.round(ms * 1e6) / 1e6);
|
|
44
44
|
}
|
|
45
|
-
/**
|
|
45
|
+
/** Creates a duration of `ms` milliseconds. */
|
|
46
46
|
static ofMilliseconds(ms) {
|
|
47
47
|
if (!(ms >= 0)) {
|
|
48
|
-
throw new Error('
|
|
48
|
+
throw new Error('duration must not be negative');
|
|
49
49
|
}
|
|
50
50
|
return new Duration(ms);
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
52
|
+
/** Returns the duration in milliseconds (suitable for `setTimeout`). */
|
|
53
53
|
get milliseconds() {
|
|
54
54
|
return this.ms;
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
56
|
+
/** Returns the duration in seconds. */
|
|
57
57
|
get seconds() {
|
|
58
58
|
return this.ms / 1000;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
60
|
+
/** Formats the duration in config-file syntax (e.g. `"1h30m"`, `"250ms"`, `"0s"`). */
|
|
61
61
|
toString() {
|
|
62
62
|
let ms = this.ms;
|
|
63
63
|
if (ms === 0)
|
|
@@ -85,16 +85,13 @@ export class Duration {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
89
|
-
* `{"$encore_secret": "<name>"}`. The name alone says which secret it is: a
|
|
90
|
-
* secret's name has one scope across the app.
|
|
88
|
+
* Property key used in runtime secret placeholders (`{"$encore_secret": "<name>"}`).
|
|
91
89
|
*/
|
|
92
90
|
export const PLACEHOLDER_KEY = '$encore_secret';
|
|
93
91
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* `secretOf` builds.
|
|
92
|
+
* Converts a raw JSON config `value` according to `schema`, turning duration
|
|
93
|
+
* strings into {@link Duration} instances and secret placeholders into handles
|
|
94
|
+
* via `secretOf`.
|
|
98
95
|
*/
|
|
99
96
|
export function build(schema, value, secretOf) {
|
|
100
97
|
return convert(schema, schema, value, secretOf, 0);
|
package/dist/config/value.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../config/value.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../config/value.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iFAAiF;AACjF,MAAM,QAAQ,GAAG,2CAA2C,CAAC;AAC7D,MAAM,OAAO,GAA2B;IACtC,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,CAAC;IACL,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,KAAM;IACT,CAAC,EAAE,OAAS;CACb,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,OAAO,QAAQ;IAOF,EAAE,CAAS;IAE5B,YAAoB,EAAU;QAC5B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,oEAAoE;IACpE,MAAM,CAAC,KAAK,CAAC,IAAY;QACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,qEAAqE,C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e,CAAC;AAC1D,CAAC"}
|
package/dist/cron/mod.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { DurationString } from '../types/mod.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* before:
|
|
3
|
+
* Header containing a cron run's idempotency key. The value stays the same
|
|
4
|
+
* across retries of the same execution, so a job that must not run its side
|
|
5
|
+
* effects twice can deduplicate using this key:
|
|
7
6
|
*
|
|
8
7
|
* ```ts
|
|
9
8
|
* app.post('/internal/cleanup', (req, res) => {
|
|
@@ -12,46 +11,61 @@ import { DurationString } from '../types/mod.js';
|
|
|
12
11
|
* });
|
|
13
12
|
* ```
|
|
14
13
|
*
|
|
15
|
-
* Only Encore
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* Only Encore sets this header; gateways strip it from external client
|
|
15
|
+
* requests. Run `encore cron trigger <name>` to execute a job immediately
|
|
16
|
+
* during local development. Jobs declared with `runIn: {local: true}` also run
|
|
17
|
+
* on schedule while a local session is active.
|
|
18
18
|
*/
|
|
19
19
|
export declare const IDEMPOTENCY_KEY_HEADER = "x-encore-cron-execution";
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* Header indicating what triggered a cron run: `"scheduled"` when the job ran
|
|
22
|
+
* on its schedule, or `"manual"` when triggered manually.
|
|
23
23
|
*/
|
|
24
24
|
export declare const TRIGGER_HEADER = "x-encore-cron-trigger";
|
|
25
25
|
export declare class CronJob {
|
|
26
26
|
readonly name: string;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* The cron job configuration as declared in source code. Read-only because
|
|
29
|
+
* Encore reads the schedule and target path statically from the declaration.
|
|
30
30
|
*/
|
|
31
31
|
readonly cfg: Readonly<CronJobConfig>;
|
|
32
32
|
constructor(name: string, cfg: CronJobConfig);
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Configuration for a cron job: the endpoint path to call and its schedule.
|
|
36
36
|
*
|
|
37
|
-
* When the job is due, Encore sends a `POST` request
|
|
38
|
-
* that declares the job.
|
|
39
|
-
*
|
|
37
|
+
* When the job is due, Encore sends a `POST` request to `path` on the service
|
|
38
|
+
* that declares the job. All configuration fields must be string/boolean
|
|
39
|
+
* literals because Encore parses them statically from source code.
|
|
40
40
|
*/
|
|
41
41
|
export type CronJobConfig = {
|
|
42
|
-
/** The path the
|
|
42
|
+
/** The endpoint path on the declaring service to `POST` to, starting with `/`. */
|
|
43
43
|
path: string;
|
|
44
44
|
title?: string;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
46
|
+
* Classification tags for policies, written as string literals (for example,
|
|
47
|
+
* `{data: "pci"}`). Keys and values may contain lowercase letters, digits,
|
|
48
|
+
* `_`, and `-`, up to 63 characters. Keys must start with a letter and cannot
|
|
49
|
+
* start with `encore` (which is reserved). At most 32 tags are allowed.
|
|
50
50
|
*/
|
|
51
51
|
tags?: Record<string, string>;
|
|
52
|
+
/** Controls which environment types run this job on schedule. */
|
|
53
|
+
runIn?: CronJobRunIn;
|
|
52
54
|
} & ({
|
|
53
55
|
every: DurationString;
|
|
54
56
|
} | {
|
|
55
57
|
schedule: string;
|
|
56
58
|
});
|
|
59
|
+
/**
|
|
60
|
+
* Controls which environment types run a cron job on schedule. Cron jobs always
|
|
61
|
+
* run in deployed environments; locally they only run when `local` is `true`.
|
|
62
|
+
*/
|
|
63
|
+
export type CronJobRunIn = {
|
|
64
|
+
/**
|
|
65
|
+
* Whether the job also runs on schedule during local development (for example
|
|
66
|
+
* while `encore run` is active). Defaults to `false`, and developers can
|
|
67
|
+
* override it per local checkout.
|
|
68
|
+
*/
|
|
69
|
+
local?: boolean;
|
|
70
|
+
};
|
|
57
71
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/cron/mod.d.ts.map
CHANGED
|
@@ -1 +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;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;gBAC1B,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa;CAO7C;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,
|
|
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;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;gBAC1B,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa;CAO7C;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,iEAAiE;IACjE,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,GAAG,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAC,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC"}
|
package/dist/cron/mod.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* before:
|
|
2
|
+
* Header containing a cron run's idempotency key. The value stays the same
|
|
3
|
+
* across retries of the same execution, so a job that must not run its side
|
|
4
|
+
* effects twice can deduplicate using this key:
|
|
6
5
|
*
|
|
7
6
|
* ```ts
|
|
8
7
|
* app.post('/internal/cleanup', (req, res) => {
|
|
@@ -11,27 +10,28 @@
|
|
|
11
10
|
* });
|
|
12
11
|
* ```
|
|
13
12
|
*
|
|
14
|
-
* Only Encore
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* Only Encore sets this header; gateways strip it from external client
|
|
14
|
+
* requests. Run `encore cron trigger <name>` to execute a job immediately
|
|
15
|
+
* during local development. Jobs declared with `runIn: {local: true}` also run
|
|
16
|
+
* on schedule while a local session is active.
|
|
17
17
|
*/
|
|
18
18
|
export const IDEMPOTENCY_KEY_HEADER = 'x-encore-cron-execution';
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* Header indicating what triggered a cron run: `"scheduled"` when the job ran
|
|
21
|
+
* on its schedule, or `"manual"` when triggered manually.
|
|
22
22
|
*/
|
|
23
23
|
export const TRIGGER_HEADER = 'x-encore-cron-trigger';
|
|
24
24
|
export class CronJob {
|
|
25
25
|
name;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* The cron job configuration as declared in source code. Read-only because
|
|
28
|
+
* Encore reads the schedule and target path statically from the declaration.
|
|
29
29
|
*/
|
|
30
30
|
cfg;
|
|
31
31
|
constructor(name, cfg) {
|
|
32
32
|
this.name = name;
|
|
33
|
-
// Frozen as well as typed `readonly`, so
|
|
34
|
-
//
|
|
33
|
+
// Frozen at runtime as well as typed `readonly`, so mutations throw even
|
|
34
|
+
// when running without TypeScript type checking.
|
|
35
35
|
this.cfg = Object.freeze({ ...cfg });
|
|
36
36
|
Object.freeze(this);
|
|
37
37
|
}
|
package/dist/cron/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;IACtB;;;OAGG;IACM,GAAG,CAA0B;IACtC,YAAY,IAAY,EAAE,GAAkB;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,
|
|
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;IACtB;;;OAGG;IACM,GAAG,CAA0B;IACtC,YAAY,IAAY,EAAE,GAAkB;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,yEAAyE;QACzE,iDAAiD;QACjD,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,EAAC,GAAG,GAAG,EAAC,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;CACF"}
|