@encore.dev/sdk 2.0.0-beta.15 → 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 +111 -101
- package/app_meta.ts +56 -54
- package/config/config.ts +60 -57
- package/config/secrets.ts +45 -52
- package/config/value.ts +23 -26
- package/cron/mod.ts +28 -29
- 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 -52
- package/dist/config/secrets.d.ts.map +1 -1
- package/dist/config/secrets.js +8 -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 +26 -27
- package/dist/cron/mod.d.ts.map +1 -1
- package/dist/cron/mod.js +13 -14
- 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/runtime/napi/napi.cjs +1 -1
- package/dist/internal/runtime/napi/napi.d.cts +10 -3
- 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/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 +196 -225
- package/dist/storage/objects/bucket.d.ts.map +1 -1
- package/dist/storage/objects/bucket.js +71 -84
- 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/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/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/runtime/napi/napi.cjs +1 -1
- package/internal/runtime/napi/napi.d.cts +10 -3
- 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 +1 -1
- package/pubsub/subscription.ts +93 -123
- package/pubsub/topic.ts +96 -130
- 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.ts +209 -239
- package/storage/objects/error.ts +4 -4
- 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/dist/pubsub/topic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topic.js","sourceRoot":"","sources":["../../pubsub/topic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,GAET,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAEL,iBAAiB,EAEjB,UAAU,GACX,MAAM,QAAQ,CAAC;AAEhB,
|
|
1
|
+
{"version":3,"file":"topic.js","sourceRoot":"","sources":["../../pubsub/topic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,GAET,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EA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iBAAiB,CACzB,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CACf,CAAC,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,CAAC,EAAE,KAAK,IAAI;QACjC,CAAC,CAAC,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAC;QACZ,CAAC,CAAC,EAAC,KAAK,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,2BAA2B,CAAC,EAAC,CAC/D,CACF,CAAC;AACJ,CAAC"}
|
package/dist/reqctx/mod.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Request Context: typed fields that
|
|
3
|
-
* it reaches, such as the user
|
|
2
|
+
* Request Context: typed fields that propagate with a request across every
|
|
3
|
+
* service it reaches, such as the authenticated user.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* and
|
|
7
|
-
* name must be a string literal:
|
|
5
|
+
* Declare each field once in the app as a module-level `const` with a
|
|
6
|
+
* string-literal name and a value type so Encore's parser can inspect it:
|
|
8
7
|
*
|
|
9
8
|
* ```ts
|
|
10
9
|
* import {Field} from '@encore.dev/sdk/reqctx';
|
|
@@ -17,157 +16,155 @@
|
|
|
17
16
|
* export const currentUser = new Field<User>('user', {pubsub: true});
|
|
18
17
|
* ```
|
|
19
18
|
*
|
|
20
|
-
* Gateway
|
|
21
|
-
* `req.set(currentUser, user)` (`@encore.dev/sdk/gateway`), and
|
|
22
|
-
*
|
|
19
|
+
* Gateway middleware populates fields on incoming requests using
|
|
20
|
+
* `req.set(currentUser, user)` (`@encore.dev/sdk/gateway`), and services read
|
|
21
|
+
* them while handling requests:
|
|
23
22
|
*
|
|
24
23
|
* ```ts
|
|
25
24
|
* const user = currentUser.get();
|
|
26
25
|
* if (user === undefined) throw new Error('not signed in');
|
|
27
26
|
* ```
|
|
28
27
|
*
|
|
29
|
-
*
|
|
28
|
+
* Services can also set or clear fields for a scoped block and any downstream
|
|
30
29
|
* calls it makes:
|
|
31
30
|
*
|
|
32
31
|
* ```ts
|
|
33
32
|
* await currentUser.with({id: 'system', email: ''}, () => fetchInvoices());
|
|
34
33
|
* ```
|
|
35
34
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* Other services (including those written in another language) can bind to a
|
|
36
|
+
* field by name with `Field.named<User>('user')`.
|
|
38
37
|
*
|
|
39
|
-
* ##
|
|
38
|
+
* ## Propagation
|
|
40
39
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* without a global context manager
|
|
40
|
+
* Fields are stored in the OpenTelemetry context alongside trace state, so they
|
|
41
|
+
* automatically follow async execution across `await`, timers, and callbacks
|
|
42
|
+
* (even without a global OpenTelemetry context manager).
|
|
44
43
|
*
|
|
45
|
-
* ##
|
|
44
|
+
* ## Security
|
|
46
45
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* services.
|
|
46
|
+
* External clients cannot forge Request Context fields: Encore strips these
|
|
47
|
+
* headers at application ingress and signs them between services, so services
|
|
48
|
+
* can trust values they read as much as they trust other services in the app.
|
|
51
49
|
*
|
|
52
50
|
* ## Receiving and sending fields
|
|
53
51
|
*
|
|
54
|
-
* {@link extract}
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* services
|
|
59
|
-
*
|
|
60
|
-
*
|
|
52
|
+
* {@link extract} reads Request Context headers from an incoming request into a
|
|
53
|
+
* context, and {@link Propagator} (composed into the global propagator) handles
|
|
54
|
+
* this automatically for instrumented servers. {@link inject} writes context
|
|
55
|
+
* fields onto outgoing request headers — use it only for calls to other Encore
|
|
56
|
+
* services so internal context is never leaked to third parties. Pub/Sub
|
|
57
|
+
* messages automatically carry any set fields declared with `pubsub: true` into
|
|
58
|
+
* subscriber handlers.
|
|
61
59
|
*
|
|
62
|
-
* ##
|
|
60
|
+
* ## Size limits
|
|
63
61
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* that set it, rather than the request failing some hops later.
|
|
62
|
+
* Each field is serialized as base64url-encoded JSON in its own header and must
|
|
63
|
+
* stay small: at most 4 KiB per field (1 KiB for fields with `pubsub: true`)
|
|
64
|
+
* and 8 KiB across all fields on a request. Exceeding these limits throws
|
|
65
|
+
* immediately when setting the value rather than failing downstream.
|
|
69
66
|
*
|
|
70
67
|
* @module
|
|
71
68
|
*/
|
|
72
69
|
import type { Context } from '@opentelemetry/api';
|
|
73
70
|
import * as reqfields from '../internal/reqfields.js';
|
|
74
71
|
export type { HeaderSink, HeaderSource, HeadersLike, } from '../internal/reqfields.js';
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
72
|
+
/**
|
|
73
|
+
* Propagation and metadata options for a {@link Field}. Boolean and tag values
|
|
74
|
+
* must be literals so Encore's parser can inspect them statically.
|
|
75
|
+
*/
|
|
77
76
|
export interface FieldConfig {
|
|
78
77
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
78
|
+
* Propagate this field on Pub/Sub messages published while it is set, making
|
|
79
|
+
* it available in subscriber handlers. Limits the encoded value to 1 KiB
|
|
80
|
+
* (matching GCP Pub/Sub attribute limits).
|
|
82
81
|
*/
|
|
83
82
|
pubsub?: boolean;
|
|
84
83
|
/**
|
|
85
|
-
*
|
|
86
|
-
* `encore.ctx.<name
|
|
87
|
-
*
|
|
84
|
+
* Attach this field's JSON value to spans started while it is set, under the
|
|
85
|
+
* attribute `encore.ctx.<name>`. Useful for searchable identifiers such as
|
|
86
|
+
* tenant IDs — never enable this for secrets.
|
|
88
87
|
*/
|
|
89
88
|
trace?: boolean;
|
|
90
89
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
90
|
+
* Static string-literal tags that classify the field for policy checks
|
|
91
|
+
* (e.g. `{data: "pci"}`). Keys and values may contain lowercase letters,
|
|
92
|
+
* digits, `_`, and `-`, up to 63 characters. Keys must start with a letter
|
|
93
|
+
* and cannot start with the reserved prefix `encore`. At most 32 tags.
|
|
95
94
|
*/
|
|
96
95
|
tags?: Record<string, string>;
|
|
97
96
|
}
|
|
98
97
|
/**
|
|
99
|
-
* A Request Context field holding a JSON value of type `T`.
|
|
98
|
+
* A typed Request Context field holding a JSON-serializable value of type `T`.
|
|
100
99
|
*
|
|
101
|
-
* Declare
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
100
|
+
* Declare fields at module level (`new Field<User>("user")`). Encore extracts a
|
|
101
|
+
* schema from `T` and validates cross-service `Field.named` bindings against
|
|
102
|
+
* it. At runtime, values are decoded directly from JSON without custom
|
|
103
|
+
* deserializers.
|
|
105
104
|
*/
|
|
106
105
|
export declare class Field<T> {
|
|
107
|
-
/** The name
|
|
106
|
+
/** The name this field was declared with. */
|
|
108
107
|
readonly name: string;
|
|
109
108
|
/**
|
|
110
|
-
*
|
|
109
|
+
* Declares a Request Context field.
|
|
111
110
|
*
|
|
112
|
-
* @param name -
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* @param cfg -
|
|
111
|
+
* @param name - Unique kebab-case field name (lowercase letters, digits, and
|
|
112
|
+
* hyphens, starting with a letter and ending with a letter or digit). Must be
|
|
113
|
+
* a string literal for Encore's parser.
|
|
114
|
+
* @param cfg - Propagation and classification options.
|
|
116
115
|
*/
|
|
117
116
|
constructor(name: string, cfg?: FieldConfig);
|
|
118
117
|
/**
|
|
119
|
-
*
|
|
120
|
-
* language.
|
|
121
|
-
* declaration's
|
|
122
|
-
* declaration says: carried on Pub/Sub messages, and put on spans, as
|
|
123
|
-
* declared.
|
|
118
|
+
* Binds to a field declared elsewhere in the app (including in another
|
|
119
|
+
* language). Encore validates `T` against the declaration, and the bound
|
|
120
|
+
* field inherits the declaration's `pubsub` and `trace` settings.
|
|
124
121
|
*/
|
|
125
122
|
static named<T>(name: string): Field<T>;
|
|
126
123
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
124
|
+
* Returns this field's value from `ctx` (or the active context if omitted),
|
|
125
|
+
* or `undefined` if unset.
|
|
129
126
|
*
|
|
130
|
-
* Each call
|
|
131
|
-
*
|
|
127
|
+
* Each call returns a freshly decoded value that the caller may safely
|
|
128
|
+
* mutate. Invalid JSON values are treated as unset and logged once.
|
|
132
129
|
*/
|
|
133
130
|
get(ctx?: Context): T | undefined;
|
|
134
131
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
132
|
+
* Runs `fn` with this field set to `value` in the active context and returns
|
|
133
|
+
* its result (or promise for async functions).
|
|
137
134
|
*
|
|
138
|
-
* @throws TypeError
|
|
139
|
-
* `undefined
|
|
140
|
-
* @throws RangeError
|
|
141
|
-
* or 1 KiB
|
|
142
|
-
*
|
|
135
|
+
* @throws TypeError If `value` cannot be serialized to JSON (e.g. contains a
|
|
136
|
+
* `bigint`, circular reference, or is `undefined`).
|
|
137
|
+
* @throws RangeError If the encoded value exceeds the per-field limit (4 KiB,
|
|
138
|
+
* or 1 KiB when `pubsub` is enabled) or pushes total request fields past
|
|
139
|
+
* 8 KiB.
|
|
143
140
|
*/
|
|
144
141
|
with<R>(value: T, fn: () => R): R;
|
|
145
|
-
/**
|
|
146
|
-
* makes. */
|
|
142
|
+
/** Runs `fn` with this field cleared from the active context. */
|
|
147
143
|
without<R>(fn: () => R): R;
|
|
148
144
|
/**
|
|
149
|
-
*
|
|
150
|
-
* `value
|
|
151
|
-
* {@link Field.with}
|
|
145
|
+
* Returns a copy of `ctx` (or the active context) with this field set to
|
|
146
|
+
* `value`, for code passing OpenTelemetry contexts explicitly. Throws the
|
|
147
|
+
* same errors as {@link Field.with}.
|
|
152
148
|
*/
|
|
153
149
|
context(value: T, ctx?: Context): Context;
|
|
154
|
-
/**
|
|
150
|
+
/** Returns a copy of `ctx` (or the active context) with this field removed. */
|
|
155
151
|
contextWithout(ctx?: Context): Context;
|
|
156
|
-
/** `Field("name")`. */
|
|
152
|
+
/** Returns `Field("name")`. */
|
|
157
153
|
toString(): string;
|
|
158
154
|
}
|
|
159
155
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
156
|
+
* Extracts Request Context fields from incoming request `headers` into a copy
|
|
157
|
+
* of `ctx` (or the active context), replacing any previously held fields.
|
|
158
|
+
* Reads the first value of each field header case-insensitively. Returns the
|
|
159
|
+
* base context unchanged if no fields are present.
|
|
163
160
|
*/
|
|
164
161
|
export declare function extract(headers: reqfields.HeaderSource, ctx?: Context): Context;
|
|
165
162
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
163
|
+
* Writes the Request Context fields from `ctx` (or the active context) onto
|
|
164
|
+
* outgoing request `headers`, replacing any existing field headers.
|
|
168
165
|
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
166
|
+
* Only call this for requests to other Encore services in the same app so
|
|
167
|
+
* internal context is not sent to third parties.
|
|
171
168
|
*/
|
|
172
169
|
export declare function inject(headers: reqfields.HeaderSink, ctx?: Context): void;
|
|
173
170
|
export { Propagator } from '../internal/reqfields.js';
|
package/dist/reqctx/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../reqctx/mod.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../reqctx/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAGhD,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAEnD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CA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.js
CHANGED
|
@@ -2,23 +2,23 @@ import log from '../log/index.js';
|
|
|
2
2
|
import { activeContext, withContext } from '../internal/otel/context.js';
|
|
3
3
|
import * as reqfields from '../internal/reqfields.js';
|
|
4
4
|
/**
|
|
5
|
-
* A Request Context field holding a JSON value of type `T`.
|
|
5
|
+
* A typed Request Context field holding a JSON-serializable value of type `T`.
|
|
6
6
|
*
|
|
7
|
-
* Declare
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Declare fields at module level (`new Field<User>("user")`). Encore extracts a
|
|
8
|
+
* schema from `T` and validates cross-service `Field.named` bindings against
|
|
9
|
+
* it. At runtime, values are decoded directly from JSON without custom
|
|
10
|
+
* deserializers.
|
|
11
11
|
*/
|
|
12
12
|
export class Field {
|
|
13
|
-
/** The name
|
|
13
|
+
/** The name this field was declared with. */
|
|
14
14
|
name;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Declares a Request Context field.
|
|
17
17
|
*
|
|
18
|
-
* @param name -
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @param cfg -
|
|
18
|
+
* @param name - Unique kebab-case field name (lowercase letters, digits, and
|
|
19
|
+
* hyphens, starting with a letter and ending with a letter or digit). Must be
|
|
20
|
+
* a string literal for Encore's parser.
|
|
21
|
+
* @param cfg - Propagation and classification options.
|
|
22
22
|
*/
|
|
23
23
|
constructor(name, cfg) {
|
|
24
24
|
this.name = name;
|
|
@@ -28,11 +28,9 @@ export class Field {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
32
|
-
* language.
|
|
33
|
-
* declaration's
|
|
34
|
-
* declaration says: carried on Pub/Sub messages, and put on spans, as
|
|
35
|
-
* declared.
|
|
31
|
+
* Binds to a field declared elsewhere in the app (including in another
|
|
32
|
+
* language). Encore validates `T` against the declaration, and the bound
|
|
33
|
+
* field inherits the declaration's `pubsub` and `trace` settings.
|
|
36
34
|
*/
|
|
37
35
|
static named(name) {
|
|
38
36
|
const field = Object.create(Field.prototype);
|
|
@@ -43,11 +41,11 @@ export class Field {
|
|
|
43
41
|
return field;
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
44
|
+
* Returns this field's value from `ctx` (or the active context if omitted),
|
|
45
|
+
* or `undefined` if unset.
|
|
48
46
|
*
|
|
49
|
-
* Each call
|
|
50
|
-
*
|
|
47
|
+
* Each call returns a freshly decoded value that the caller may safely
|
|
48
|
+
* mutate. Invalid JSON values are treated as unset and logged once.
|
|
51
49
|
*/
|
|
52
50
|
get(ctx) {
|
|
53
51
|
const value = reqfields.current(ctx ?? activeContext())[this.name];
|
|
@@ -62,27 +60,26 @@ export class Field {
|
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
63
|
+
* Runs `fn` with this field set to `value` in the active context and returns
|
|
64
|
+
* its result (or promise for async functions).
|
|
67
65
|
*
|
|
68
|
-
* @throws TypeError
|
|
69
|
-
* `undefined
|
|
70
|
-
* @throws RangeError
|
|
71
|
-
* or 1 KiB
|
|
72
|
-
*
|
|
66
|
+
* @throws TypeError If `value` cannot be serialized to JSON (e.g. contains a
|
|
67
|
+
* `bigint`, circular reference, or is `undefined`).
|
|
68
|
+
* @throws RangeError If the encoded value exceeds the per-field limit (4 KiB,
|
|
69
|
+
* or 1 KiB when `pubsub` is enabled) or pushes total request fields past
|
|
70
|
+
* 8 KiB.
|
|
73
71
|
*/
|
|
74
72
|
with(value, fn) {
|
|
75
73
|
return withContext(this.context(value), fn);
|
|
76
74
|
}
|
|
77
|
-
/**
|
|
78
|
-
* makes. */
|
|
75
|
+
/** Runs `fn` with this field cleared from the active context. */
|
|
79
76
|
without(fn) {
|
|
80
77
|
return withContext(this.contextWithout(), fn);
|
|
81
78
|
}
|
|
82
79
|
/**
|
|
83
|
-
*
|
|
84
|
-
* `value
|
|
85
|
-
* {@link Field.with}
|
|
80
|
+
* Returns a copy of `ctx` (or the active context) with this field set to
|
|
81
|
+
* `value`, for code passing OpenTelemetry contexts explicitly. Throws the
|
|
82
|
+
* same errors as {@link Field.with}.
|
|
86
83
|
*/
|
|
87
84
|
context(value, ctx) {
|
|
88
85
|
let encoded;
|
|
@@ -99,19 +96,20 @@ export class Field {
|
|
|
99
96
|
throw new RangeError(`reqctx: field ${JSON.stringify(this.name)}: the value ${messageOf(err)}`, { cause: err });
|
|
100
97
|
}
|
|
101
98
|
}
|
|
102
|
-
/**
|
|
99
|
+
/** Returns a copy of `ctx` (or the active context) with this field removed. */
|
|
103
100
|
contextWithout(ctx) {
|
|
104
101
|
return reqfields.without(this.name, ctx ?? activeContext());
|
|
105
102
|
}
|
|
106
|
-
/** `Field("name")`. */
|
|
103
|
+
/** Returns `Field("name")`. */
|
|
107
104
|
toString() {
|
|
108
105
|
return `Field(${JSON.stringify(this.name)})`;
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
109
|
+
* Extracts Request Context fields from incoming request `headers` into a copy
|
|
110
|
+
* of `ctx` (or the active context), replacing any previously held fields.
|
|
111
|
+
* Reads the first value of each field header case-insensitively. Returns the
|
|
112
|
+
* base context unchanged if no fields are present.
|
|
115
113
|
*/
|
|
116
114
|
export function extract(headers, ctx) {
|
|
117
115
|
const base = ctx ?? activeContext();
|
|
@@ -121,11 +119,11 @@ export function extract(headers, ctx) {
|
|
|
121
119
|
: reqfields.withFields(fields, base);
|
|
122
120
|
}
|
|
123
121
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
122
|
+
* Writes the Request Context fields from `ctx` (or the active context) onto
|
|
123
|
+
* outgoing request `headers`, replacing any existing field headers.
|
|
126
124
|
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
125
|
+
* Only call this for requests to other Encore services in the same app so
|
|
126
|
+
* internal context is not sent to third parties.
|
|
129
127
|
*/
|
|
130
128
|
export function inject(headers, ctx) {
|
|
131
129
|
reqfields.toHeaders(headers, ctx ?? activeContext());
|
package/dist/reqctx/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../reqctx/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../reqctx/mod.ts"],"names":[],"mappings":"AAqEA,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAkCnD;;;;;;;GAOG;AACH,MAAM,OAAO,KAAK;IAChB,6CAA6C;IACpC,IAAI,CAAS;IAEtB;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,GAAiB;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE;YACtB,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI;YAC5B,KAAK,EAAE,GAAG,EAAE,KAAK,KAAK,IAAI;SAC3B,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAI,IAAY;QAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAa,CAAC;QACzD,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE;YACnC,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,GAAa;QACf,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnE,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO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