sdk-aws-lambda 0.7.0 → 0.7.2
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/dist/domain.objects/TrailCarrier.d.ts +17 -0
- package/dist/domain.objects/TrailCarrier.js +3 -0
- package/dist/domain.objects/TrailCarrier.js.map +1 -0
- package/dist/domain.objects/TrailExidHeader.d.ts +10 -0
- package/dist/domain.objects/TrailExidHeader.js +14 -0
- package/dist/domain.objects/TrailExidHeader.js.map +1 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.js +15 -1
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.d.ts +50 -27
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js +18 -61
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.d.ts +35 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.js +80 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.d.ts +37 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.js +70 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeHttpRequest.d.ts +17 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeHttpRequest.js +34 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeHttpRequest.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.d.ts +31 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.js +55 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHeadersRecord.d.ts +13 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHeadersRecord.js +22 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHeadersRecord.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHttpMethod.d.ts +16 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHttpMethod.js +22 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHttpMethod.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestBody.d.ts +17 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestBody.js +28 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestBody.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestHeaders.d.ts +23 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestHeaders.js +39 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestHeaders.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getOneBodyFromHttpText.d.ts +10 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getOneBodyFromHttpText.js +19 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getOneBodyFromHttpText.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getOneCorrelationIdFromBody.d.ts +11 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getOneCorrelationIdFromBody.js +19 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getOneCorrelationIdFromBody.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/InvokeInputSuperset.d.ts +9 -6
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asCorsHeadersWithTrail.d.ts +12 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asCorsHeadersWithTrail.js +27 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asCorsHeadersWithTrail.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +4 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +32 -7
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayRequestEventNormalizationMiddleware.js +22 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayRequestEventNormalizationMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js +13 -2
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js +5 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js +5 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.d.ts +9 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js +10 -2
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.d.ts +15 -8
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js +57 -12
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsConstraintError.js +4 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsConstraintError.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsFrozenMutatorRefusal.d.ts +17 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsFrozenMutatorRefusal.js +32 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsFrozenMutatorRefusal.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.d.ts +19 -57
- package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.js +30 -78
- package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.js.map +1 -1
- package/dist/domain.operations/lambdaEndpointWire/frame/asHeadersWithoutKey.d.ts +11 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/asHeadersWithoutKey.js +13 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/asHeadersWithoutKey.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/asTrailExidHeaders.d.ts +23 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/asTrailExidHeaders.js +32 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/asTrailExidHeaders.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfEvent.d.ts +20 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfEvent.js +23 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfEvent.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfHandler.d.ts +9 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfHandler.js +19 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfHandler.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailExidFromHeaders.d.ts +16 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailExidFromHeaders.js +24 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailExidFromHeaders.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/isEventDeclaredAsApiGateway.d.ts +9 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/isEventDeclaredAsApiGateway.js +15 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/isEventDeclaredAsApiGateway.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExid.d.ts +19 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExid.js +27 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExid.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExidHeaderMalformed.d.ts +11 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExidHeaderMalformed.js +21 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExidHeaderMalformed.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/setEventDeclaredAsApiGateway.d.ts +21 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/setEventDeclaredAsApiGateway.js +27 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/setEventDeclaredAsApiGateway.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/setHandlerTrailCarrier.d.ts +24 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/setHandlerTrailCarrier.js +28 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/setHandlerTrailCarrier.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.d.ts +7 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js +18 -2
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js.map +1 -1
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js +43 -7
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js.map +1 -1
- package/dist/domain.operations/runLambdaEndpoint/serde/asCarriedPayload.d.ts +35 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asCarriedPayload.js +81 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asCarriedPayload.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/getOneTrailWithExid.d.ts +14 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/getOneTrailWithExid.js +18 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/getOneTrailWithExid.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/isEventWithHeaders.d.ts +17 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/isEventWithHeaders.js +19 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/isEventWithHeaders.js.map +1 -0
- package/dist/index.d.ts +14 -6
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
- package/readme.md +43 -1
|
@@ -1,35 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setEventFrozen = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const type_fns_1 = require("type-fns");
|
|
4
6
|
/**
|
|
5
|
-
* .what =
|
|
6
|
-
* .why = `Object.freeze` alone is shallow, so it would leave `event.headers` writable — and
|
|
7
|
-
* `headers` is exactly the object `@middy/http-cors` reads in its `after` hook
|
|
8
|
-
* (`@middy/http-cors/index.js:83`), after the handler has returned
|
|
9
|
-
*
|
|
10
|
-
* .why not `withImmute` = `domain-objects` ships a recursive helper whose name reads as this
|
|
11
|
-
* mechanism and is not it. measured in its dist (`withImmute.js:9-22,27-31`,
|
|
12
|
-
* domain-objects@0.33.0): it adds a `.clone()` — an affordance rather than an enforcement,
|
|
13
|
-
* so a write still succeeds — and it applies only where `isOfDomainObject(value)` holds,
|
|
14
|
-
* so on this plain-interface envelope it is a total no-op
|
|
15
|
-
*
|
|
16
|
-
* .note = in place, deliberately. a defensive copy would remove the same hazard and destroy the
|
|
17
|
-
* projection: `headers === event.headers` would stop to hold, and the bag could drift
|
|
18
|
-
* from the envelope it claims to project (`domain.terms/event.md`)
|
|
19
|
-
*/
|
|
20
|
-
const setFrozenDeep = (value, seen) => {
|
|
21
|
-
if (value === null || typeof value !== 'object')
|
|
22
|
-
return;
|
|
23
|
-
if (seen.has(value))
|
|
24
|
-
return;
|
|
25
|
-
seen.add(value);
|
|
26
|
-
Object.freeze(value);
|
|
27
|
-
// recurse over the OWN values only; a prototype belongs to whoever declared it
|
|
28
|
-
for (const nested of Object.values(value))
|
|
29
|
-
setFrozenDeep(nested, seen);
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* .what = seals the envelope before `invoke` receives it
|
|
7
|
+
* .what = seals the envelope before `invoke` receives it, in place, typed `FrozenDeep`
|
|
33
8
|
* .why = the envelope outlives the handler's turn, so a write through it corrupts a value
|
|
34
9
|
* somebody else reads after `invoke` returns — with no type error and no throw. the freeze
|
|
35
10
|
* makes that unrepresentable
|
|
@@ -42,62 +17,39 @@ const setFrozenDeep = (value, seen) => {
|
|
|
42
17
|
* property of today, so a rule keyed to one expires silently the first commit that adds a
|
|
43
18
|
* post-invoke read (`rule.require.frozen-invoke-inputs`)
|
|
44
19
|
*
|
|
45
|
-
* .why the
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* .where = the family root rather than inside `forApiGateway`, because two variants of one family
|
|
51
|
-
* reach for it. lifted on the second use (`rule.prefer.most-common-denominator`)
|
|
20
|
+
* .why type-fns' `asFrozenDeep` = the type and the runtime come from one package, so they cannot
|
|
21
|
+
* drift: what `FrozenDeep` refuses at compile time, `asFrozenDeep` refuses at run time. that
|
|
22
|
+
* includes the state a bare `Object.freeze` cannot reach — a `Date`, `Map`, `Set`, `WeakMap`,
|
|
23
|
+
* or `WeakSet` has its mutators replaced by throwers, and the walk reaches symbol keys and
|
|
24
|
+
* non-enumerable own props
|
|
52
25
|
*
|
|
26
|
+
* .note = in place, deliberately. `asFrozenDeep` returns the same reference, so
|
|
27
|
+
* `headers === event.headers` holds and the bag cannot drift from the envelope it projects
|
|
28
|
+
* (`domain.terms/event.md`). a defensive copy would remove the hazard and break the projection
|
|
53
29
|
* .note = the projections freeze with it, by design: `headers`, `payload`, and `records` are the
|
|
54
|
-
* envelope's own slots, so a handler mutates none
|
|
30
|
+
* envelope's own slots, so a handler mutates none
|
|
55
31
|
* .note = `forSqs.perBatch`'s harm is the sharpest, and `[case17]` walks it end to end: a handler
|
|
56
32
|
* that forges `event.records[n].id` would rewrite the set the unknown-id guard checks
|
|
57
|
-
* against, so
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* sqs -> `wire.Records[n]` is reachable as `event._.raw.Records[n]` and as
|
|
66
|
-
* `event.records[n]._.raw` (`asSqsEventDecoded.ts:37`,
|
|
67
|
-
* `asSqsRecordDecoded.ts:94`)
|
|
68
|
-
*
|
|
69
|
-
* it is not a cycle guard. no cycle is reachable from this event — `requestContext` is an
|
|
70
|
-
* explicit four-field copy of primitives and `headers` is a new object — though the set
|
|
71
|
-
* would terminate one a later author introduced
|
|
72
|
-
*
|
|
73
|
-
* .note = a frozen write throws in strict mode and no-ops in sloppy mode. every module this sdk
|
|
74
|
-
* ships is an es module, which is strict by construction, so the throw is the behavior a
|
|
75
|
-
* consumer meets (ecma-262 §11.2.2)
|
|
76
|
-
* .note = the throw's message is terse — node raises a bare `TypeError: Cannot assign to read
|
|
77
|
-
* only property …`, which names no cause and no remedy. `Object.freeze` accepts no
|
|
78
|
-
* message, and the only mechanism that could supply one is a `Proxy` — a different
|
|
79
|
-
* object, so `headers === event.headers` would stop to hold. the remedy is prevention
|
|
80
|
-
* instead: `FrozenDeep` refuses the write at compile time, so a type-checked consumer
|
|
81
|
-
* never reaches the message (`rule.prefer.prevent-over-correct`)
|
|
82
|
-
*
|
|
83
|
-
* .why it returns = the same reference, narrowed to `FrozenDeep`. it still freezes in place — the
|
|
84
|
-
* return is the type half of one act, so a caller receives the guarantee from the step
|
|
85
|
-
* that establishes it rather than asserts it by hand at the hand-off
|
|
33
|
+
* against, so sqs is answered with an `itemIdentifier` it cannot match
|
|
34
|
+
*
|
|
35
|
+
* .why a refusal is a `MalfunctionError` = `asFrozenDeep` refuses, all or none and before any
|
|
36
|
+
* freeze, a value it cannot seal: a typed array that holds bytes, a global or sticky
|
|
37
|
+
* `RegExp`. `JSON.parse` yields neither, so one reaches the envelope only when the handler's
|
|
38
|
+
* own schema builds it. that is a server fault, never the caller's, so it must not ride the
|
|
39
|
+
* caller-fault path a bare `ConstraintError` would take (`getIsConstraintError`). the
|
|
40
|
+
* type-fns refusal rides as `cause`, so its `path` and `hint` still name the fix
|
|
86
41
|
*/
|
|
87
42
|
const setEventFrozen = (input) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* .removal = drops if typescript ever proves a homomorphic mapped type against its own input
|
|
99
|
-
*/
|
|
100
|
-
return input.event;
|
|
43
|
+
try {
|
|
44
|
+
return (0, type_fns_1.asFrozenDeep)(input.event);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
// a non-error throw is no refusal of the walk; let it surface as-is
|
|
48
|
+
if (!(error instanceof Error))
|
|
49
|
+
throw error;
|
|
50
|
+
// a refusal: the handler's schema built a value the freeze cannot seal
|
|
51
|
+
throw new helpful_errors_1.MalfunctionError('the event holds a value the invoke freeze cannot seal — the handler schema built it', { cause: error });
|
|
52
|
+
}
|
|
101
53
|
};
|
|
102
54
|
exports.setEventFrozen = setEventFrozen;
|
|
103
55
|
//# sourceMappingURL=setEventFrozen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setEventFrozen.js","sourceRoot":"","sources":["../../../src/domain.operations/genLambdaEndpoint/setEventFrozen.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"setEventFrozen.js","sourceRoot":"","sources":["../../../src/domain.operations/genLambdaEndpoint/setEventFrozen.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAClD,uCAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACI,MAAM,cAAc,GAAG,CAAS,KAEtC,EAAsB,EAAE;IACvB,IAAI,CAAC;QACH,OAAO,IAAA,uBAAY,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,oEAAoE;QACpE,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAE3C,uEAAuE;QACvE,MAAM,IAAI,iCAAgB,CACxB,qFAAqF,EACrF,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAfW,QAAA,cAAc,kBAezB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = casts a headers bag into the same bag with every case variant of one key dropped
|
|
3
|
+
* .why = http field names are case-insensitive (rfc 9110 §5.1), so `X-Trail-Exid` and `x-trail-exid`
|
|
4
|
+
* are one header. a bag that holds both, merged into a `Headers`, joins them as `a, b`, and the
|
|
5
|
+
* endpoint reads the join as the exid. the caller's variant is dropped before the sdk writes its own,
|
|
6
|
+
* so the sdk's key is the only one on the wire
|
|
7
|
+
*/
|
|
8
|
+
export declare const asHeadersWithoutKey: <TValue>(input: {
|
|
9
|
+
headers: Record<string, TValue> | null | undefined;
|
|
10
|
+
key: string;
|
|
11
|
+
}) => Record<string, TValue>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asHeadersWithoutKey = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = casts a headers bag into the same bag with every case variant of one key dropped
|
|
6
|
+
* .why = http field names are case-insensitive (rfc 9110 §5.1), so `X-Trail-Exid` and `x-trail-exid`
|
|
7
|
+
* are one header. a bag that holds both, merged into a `Headers`, joins them as `a, b`, and the
|
|
8
|
+
* endpoint reads the join as the exid. the caller's variant is dropped before the sdk writes its own,
|
|
9
|
+
* so the sdk's key is the only one on the wire
|
|
10
|
+
*/
|
|
11
|
+
const asHeadersWithoutKey = (input) => Object.fromEntries(Object.entries(input.headers ?? {}).filter(([name]) => name.toLowerCase() !== input.key.toLowerCase()));
|
|
12
|
+
exports.asHeadersWithoutKey = asHeadersWithoutKey;
|
|
13
|
+
//# sourceMappingURL=asHeadersWithoutKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asHeadersWithoutKey.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/asHeadersWithoutKey.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACI,MAAM,mBAAmB,GAAG,CAAS,KAG3C,EAA0B,EAAE,CAC3B,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CACxC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,CAC3D,CACF,CAAC;AARS,QAAA,mBAAmB,uBAQ5B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TRAIL_EXID_HEADER } from '../../../domain.objects/TrailExidHeader';
|
|
2
|
+
/**
|
|
3
|
+
* .what = casts a trail into the http headers that opt a request into the contemp dialect
|
|
4
|
+
* .why = an api gateway event is built by aws, so no caller can wrap it in `{ event, trail }`.
|
|
5
|
+
* the opt-in rides the request's own `headers` instead. any http client spreads this in
|
|
6
|
+
* (`domain.terms/x-trail-exid.md`, `invariant.ancient-vs-contemp-callers.md`)
|
|
7
|
+
*
|
|
8
|
+
* .note = the sender always supplies a well-formed exid: 1 to 128 printable ascii characters. the
|
|
9
|
+
* endpoint reads any other value as ABSENT, so the request would silently stay ancient —
|
|
10
|
+
* refused here instead, loudly
|
|
11
|
+
*
|
|
12
|
+
* .usage = `fetch(url, { headers: { ...asTrailExidHeaders({ trail: { exid } }) } })`
|
|
13
|
+
*
|
|
14
|
+
* .note = the usage is prose on purpose. a docblock example tag is a promise the advertised-examples
|
|
15
|
+
* sweep runs verbatim, and a snippet that needs a live url cannot keep it
|
|
16
|
+
*/
|
|
17
|
+
export declare const asTrailExidHeaders: (input: {
|
|
18
|
+
trail: {
|
|
19
|
+
exid: string;
|
|
20
|
+
};
|
|
21
|
+
}) => {
|
|
22
|
+
[TRAIL_EXID_HEADER]: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asTrailExidHeaders = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const TrailExidHeader_1 = require("../../../domain.objects/TrailExidHeader");
|
|
6
|
+
const isTrailExid_1 = require("./isTrailExid");
|
|
7
|
+
/**
|
|
8
|
+
* .what = casts a trail into the http headers that opt a request into the contemp dialect
|
|
9
|
+
* .why = an api gateway event is built by aws, so no caller can wrap it in `{ event, trail }`.
|
|
10
|
+
* the opt-in rides the request's own `headers` instead. any http client spreads this in
|
|
11
|
+
* (`domain.terms/x-trail-exid.md`, `invariant.ancient-vs-contemp-callers.md`)
|
|
12
|
+
*
|
|
13
|
+
* .note = the sender always supplies a well-formed exid: 1 to 128 printable ascii characters. the
|
|
14
|
+
* endpoint reads any other value as ABSENT, so the request would silently stay ancient —
|
|
15
|
+
* refused here instead, loudly
|
|
16
|
+
*
|
|
17
|
+
* .usage = `fetch(url, { headers: { ...asTrailExidHeaders({ trail: { exid } }) } })`
|
|
18
|
+
*
|
|
19
|
+
* .note = the usage is prose on purpose. a docblock example tag is a promise the advertised-examples
|
|
20
|
+
* sweep runs verbatim, and a snippet that needs a live url cannot keep it
|
|
21
|
+
*/
|
|
22
|
+
const asTrailExidHeaders = (input) => {
|
|
23
|
+
// an exid the endpoint would read as absent would opt out in silence
|
|
24
|
+
if (!isTrailExid_1.isTrailExid.assess(input.trail.exid))
|
|
25
|
+
helpful_errors_1.ConstraintError.throw('trail.exid is not a well-formed exid, so the request would carry no opt-in', {
|
|
26
|
+
trail: input.trail,
|
|
27
|
+
hint: `supply the exid of the invoke that makes this call: 1 to ${isTrailExid_1.TRAIL_EXID_LENGTH_MAX} printable ascii characters`,
|
|
28
|
+
});
|
|
29
|
+
return { [TrailExidHeader_1.TRAIL_EXID_HEADER]: input.trail.exid };
|
|
30
|
+
};
|
|
31
|
+
exports.asTrailExidHeaders = asTrailExidHeaders;
|
|
32
|
+
//# sourceMappingURL=asTrailExidHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asTrailExidHeaders.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/asTrailExidHeaders.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD,6EAA4E;AAC5E,+CAAmE;AAEnE;;;;;;;;;;;;;;GAcG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAElC,EAAmC,EAAE;IACpC,qEAAqE;IACrE,IAAI,CAAC,yBAAW,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;QACvC,gCAAe,CAAC,KAAK,CACnB,4EAA4E,EAC5E;YACE,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,IAAI,EAAE,4DAA4D,mCAAqB,6BAA6B;SACrH,CACF,CAAC;IAEJ,OAAO,EAAE,CAAC,mCAAiB,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AACnD,CAAC,CAAC;AAdW,QAAA,kBAAkB,sBAc7B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TrailCarrier } from '../../../domain.objects/TrailCarrier';
|
|
2
|
+
/**
|
|
3
|
+
* .what = which carrier an event's caller must put its trail and contemp opt-in in
|
|
4
|
+
* .why = an event the builder declared as api gateway is built by aws in prod, so no caller can wrap
|
|
5
|
+
* it; its opt-in rides the request's `headers`. every other event keeps the `{ event, trail }`
|
|
6
|
+
* wrapper (`invariant.ancient-vs-contemp-callers.md`)
|
|
7
|
+
*
|
|
8
|
+
* .note = the declaration is the builder's alone. an event's own contents never choose its carrier:
|
|
9
|
+
* an event cannot know which family receives it, and a forwarded request that happens to hold
|
|
10
|
+
* an `x-trail-exid` header is a valid payload for a direct invoke
|
|
11
|
+
* .note = this is the fallback. where the runner holds the handler (`onReferenced`, and the local locus
|
|
12
|
+
* of `onSerialized`) the handler's own declaration decides first (`getOneTrailCarrierOfHandler`),
|
|
13
|
+
* so a copy of a built event is framed for the family that receives it. the event's mark is the
|
|
14
|
+
* only declaration at the cloud locus, which holds no handler
|
|
15
|
+
* .note = both run boundaries (`onReferenced`, and `onSerialized` at cloud) pick the carrier here, so
|
|
16
|
+
* the two cannot disagree. read it BEFORE the json strip, which drops the declaration
|
|
17
|
+
*/
|
|
18
|
+
export declare const getOneTrailCarrierOfEvent: (input: {
|
|
19
|
+
event: unknown;
|
|
20
|
+
}) => TrailCarrier;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOneTrailCarrierOfEvent = void 0;
|
|
4
|
+
const isEventDeclaredAsApiGateway_1 = require("./isEventDeclaredAsApiGateway");
|
|
5
|
+
/**
|
|
6
|
+
* .what = which carrier an event's caller must put its trail and contemp opt-in in
|
|
7
|
+
* .why = an event the builder declared as api gateway is built by aws in prod, so no caller can wrap
|
|
8
|
+
* it; its opt-in rides the request's `headers`. every other event keeps the `{ event, trail }`
|
|
9
|
+
* wrapper (`invariant.ancient-vs-contemp-callers.md`)
|
|
10
|
+
*
|
|
11
|
+
* .note = the declaration is the builder's alone. an event's own contents never choose its carrier:
|
|
12
|
+
* an event cannot know which family receives it, and a forwarded request that happens to hold
|
|
13
|
+
* an `x-trail-exid` header is a valid payload for a direct invoke
|
|
14
|
+
* .note = this is the fallback. where the runner holds the handler (`onReferenced`, and the local locus
|
|
15
|
+
* of `onSerialized`) the handler's own declaration decides first (`getOneTrailCarrierOfHandler`),
|
|
16
|
+
* so a copy of a built event is framed for the family that receives it. the event's mark is the
|
|
17
|
+
* only declaration at the cloud locus, which holds no handler
|
|
18
|
+
* .note = both run boundaries (`onReferenced`, and `onSerialized` at cloud) pick the carrier here, so
|
|
19
|
+
* the two cannot disagree. read it BEFORE the json strip, which drops the declaration
|
|
20
|
+
*/
|
|
21
|
+
const getOneTrailCarrierOfEvent = (input) => (0, isEventDeclaredAsApiGateway_1.isEventDeclaredAsApiGateway)({ event: input.event }) ? 'headers' : 'wrapper';
|
|
22
|
+
exports.getOneTrailCarrierOfEvent = getOneTrailCarrierOfEvent;
|
|
23
|
+
//# sourceMappingURL=getOneTrailCarrierOfEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOneTrailCarrierOfEvent.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfEvent.ts"],"names":[],"mappings":";;;AACA,+EAA4E;AAE5E;;;;;;;;;;;;;;;GAeG;AACI,MAAM,yBAAyB,GAAG,CAAC,KAEzC,EAAgB,EAAE,CACjB,IAAA,yDAA2B,EAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AAHjE,QAAA,yBAAyB,6BAGwC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TrailCarrier } from '../../../domain.objects/TrailCarrier';
|
|
2
|
+
/**
|
|
3
|
+
* .what = the carrier a handler declares, or null for a handler that declares none
|
|
4
|
+
* .why = a plain lambda handler (an unmigrated `createStandardHandler`) is built by no `genLambdaEndpoint`
|
|
5
|
+
* family, so it declares none, and the caller falls back to the event's own declaration
|
|
6
|
+
*/
|
|
7
|
+
export declare const getOneTrailCarrierOfHandler: (input: {
|
|
8
|
+
handler: unknown;
|
|
9
|
+
}) => TrailCarrier | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOneTrailCarrierOfHandler = void 0;
|
|
4
|
+
const setHandlerTrailCarrier_1 = require("./setHandlerTrailCarrier");
|
|
5
|
+
/**
|
|
6
|
+
* .what = the carrier a handler declares, or null for a handler that declares none
|
|
7
|
+
* .why = a plain lambda handler (an unmigrated `createStandardHandler`) is built by no `genLambdaEndpoint`
|
|
8
|
+
* family, so it declares none, and the caller falls back to the event's own declaration
|
|
9
|
+
*/
|
|
10
|
+
const getOneTrailCarrierOfHandler = (input) => {
|
|
11
|
+
if (typeof input.handler !== 'function')
|
|
12
|
+
return null;
|
|
13
|
+
const carrier = Reflect.get(input.handler, setHandlerTrailCarrier_1.HANDLER_TRAIL_CARRIER);
|
|
14
|
+
if (carrier === 'wrapper' || carrier === 'headers')
|
|
15
|
+
return carrier;
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
exports.getOneTrailCarrierOfHandler = getOneTrailCarrierOfHandler;
|
|
19
|
+
//# sourceMappingURL=getOneTrailCarrierOfHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOneTrailCarrierOfHandler.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfHandler.ts"],"names":[],"mappings":";;;AACA,qEAAiE;AAEjE;;;;GAIG;AACI,MAAM,2BAA2B,GAAG,CAAC,KAE3C,EAAuB,EAAE;IACxB,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACrD,MAAM,OAAO,GAAY,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,8CAAqB,CAAC,CAAC;IAC3E,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IACnE,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAPW,QAAA,2BAA2B,+BAOtC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = reads the caller's exid out of a headers bag, or null when the bag carries none
|
|
3
|
+
* .why = the exid's presence IS the contemp opt-in at an aws-delivered family
|
|
4
|
+
* (`invariant.ancient-vs-contemp-callers.md`)
|
|
5
|
+
*
|
|
6
|
+
* .note = a value that is not a well-formed exid (empty, past the length bound, or with a control
|
|
7
|
+
* character) reads as ABSENT, so a public caller cannot place unbounded or forged text in the
|
|
8
|
+
* sdk's logs and responses. the request then reads as ancient, with a fresh exid
|
|
9
|
+
* .note = exactly one key is read — no generic correlation header (`x-amzn-trace-id`, `traceparent`,
|
|
10
|
+
* `x-request-id`) ever opts a caller in, since a proxy that forwards one must not flip an
|
|
11
|
+
* error body (`domain.terms/x-trail-exid.md`)
|
|
12
|
+
* .note = the bag's keys are lowercase by now — event normalization folds them (`headers.md`)
|
|
13
|
+
*/
|
|
14
|
+
export declare const getOneTrailExidFromHeaders: (input: {
|
|
15
|
+
headers: Record<string, string | undefined> | null | undefined;
|
|
16
|
+
}) => string | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOneTrailExidFromHeaders = void 0;
|
|
4
|
+
const TrailExidHeader_1 = require("../../../domain.objects/TrailExidHeader");
|
|
5
|
+
const isTrailExid_1 = require("./isTrailExid");
|
|
6
|
+
/**
|
|
7
|
+
* .what = reads the caller's exid out of a headers bag, or null when the bag carries none
|
|
8
|
+
* .why = the exid's presence IS the contemp opt-in at an aws-delivered family
|
|
9
|
+
* (`invariant.ancient-vs-contemp-callers.md`)
|
|
10
|
+
*
|
|
11
|
+
* .note = a value that is not a well-formed exid (empty, past the length bound, or with a control
|
|
12
|
+
* character) reads as ABSENT, so a public caller cannot place unbounded or forged text in the
|
|
13
|
+
* sdk's logs and responses. the request then reads as ancient, with a fresh exid
|
|
14
|
+
* .note = exactly one key is read — no generic correlation header (`x-amzn-trace-id`, `traceparent`,
|
|
15
|
+
* `x-request-id`) ever opts a caller in, since a proxy that forwards one must not flip an
|
|
16
|
+
* error body (`domain.terms/x-trail-exid.md`)
|
|
17
|
+
* .note = the bag's keys are lowercase by now — event normalization folds them (`headers.md`)
|
|
18
|
+
*/
|
|
19
|
+
const getOneTrailExidFromHeaders = (input) => {
|
|
20
|
+
const value = input.headers?.[TrailExidHeader_1.TRAIL_EXID_HEADER];
|
|
21
|
+
return isTrailExid_1.isTrailExid.assess(value) ? value : null;
|
|
22
|
+
};
|
|
23
|
+
exports.getOneTrailExidFromHeaders = getOneTrailExidFromHeaders;
|
|
24
|
+
//# sourceMappingURL=getOneTrailExidFromHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOneTrailExidFromHeaders.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/getOneTrailExidFromHeaders.ts"],"names":[],"mappings":";;;AAAA,6EAA4E;AAC5E,+CAA4C;AAE5C;;;;;;;;;;;;GAYG;AACI,MAAM,0BAA0B,GAAG,CAAC,KAE1C,EAAiB,EAAE;IAClB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,mCAAiB,CAAC,CAAC;IACjD,OAAO,yBAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC,CAAC;AALW,QAAA,0BAA0B,8BAKrC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = whether an event carries the api gateway declaration
|
|
3
|
+
* .why = the carrier follows the declaration, never the event's shape
|
|
4
|
+
* (`invariant.ancient-vs-contemp-callers.md`). an event built by hand, or spread from a
|
|
5
|
+
* declared one, is undeclared and keeps the `{ event, trail }` wrapper
|
|
6
|
+
*/
|
|
7
|
+
export declare const isEventDeclaredAsApiGateway: (input: {
|
|
8
|
+
event: unknown;
|
|
9
|
+
}) => boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEventDeclaredAsApiGateway = void 0;
|
|
4
|
+
const setEventDeclaredAsApiGateway_1 = require("./setEventDeclaredAsApiGateway");
|
|
5
|
+
/**
|
|
6
|
+
* .what = whether an event carries the api gateway declaration
|
|
7
|
+
* .why = the carrier follows the declaration, never the event's shape
|
|
8
|
+
* (`invariant.ancient-vs-contemp-callers.md`). an event built by hand, or spread from a
|
|
9
|
+
* declared one, is undeclared and keeps the `{ event, trail }` wrapper
|
|
10
|
+
*/
|
|
11
|
+
const isEventDeclaredAsApiGateway = (input) => typeof input.event === 'object' &&
|
|
12
|
+
input.event !== null &&
|
|
13
|
+
Reflect.get(input.event, setEventDeclaredAsApiGateway_1.EVENT_DECLARED_AS_API_GATEWAY) === true;
|
|
14
|
+
exports.isEventDeclaredAsApiGateway = isEventDeclaredAsApiGateway;
|
|
15
|
+
//# sourceMappingURL=isEventDeclaredAsApiGateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEventDeclaredAsApiGateway.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/isEventDeclaredAsApiGateway.ts"],"names":[],"mappings":";;;AAAA,iFAA+E;AAE/E;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,CAAC,KAE3C,EAAW,EAAE,CACZ,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;IAC/B,KAAK,CAAC,KAAK,KAAK,IAAI;IACpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,4DAA6B,CAAC,KAAK,IAAI,CAAC;AALtD,QAAA,2BAA2B,+BAK2B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = the longest exid the sdk accepts from, or writes to, a header
|
|
3
|
+
* .why = an exid is a correlation key, not a payload. the form the sdk mints is `exid:<uuid>`, 41
|
|
4
|
+
* characters, so 128 leaves room for a request id or a prefixed trace without a header that
|
|
5
|
+
* can hold a page of text
|
|
6
|
+
*/
|
|
7
|
+
export declare const TRAIL_EXID_LENGTH_MAX = 128;
|
|
8
|
+
/**
|
|
9
|
+
* .what = whether a value is a well-formed trail exid: a string of 1 to 128 printable ascii characters
|
|
10
|
+
* .why = `x-trail-exid` is the first value a public caller can place in this sdk's logs, in every 500's
|
|
11
|
+
* `correlationId`, and in the trail of every downstream call. a caller who sends a page of text,
|
|
12
|
+
* or a control character, would write it all into those places. a bounded printable value cannot
|
|
13
|
+
* forge a log line or grow a header without limit (`domain.terms/x-trail-exid.md`)
|
|
14
|
+
*
|
|
15
|
+
* .note = printable ascii is U+0020 to U+007E. a space is allowed inside the value, never at an end: http
|
|
16
|
+
* trims the ends of a header value, so a padded exid would read differently at each side of the
|
|
17
|
+
* wire and the trace would not join. a tab, a newline, and every control character are not allowed
|
|
18
|
+
*/
|
|
19
|
+
export declare const isTrailExid: import("type-fns").AssessWithAssure<unknown, string>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTrailExid = exports.TRAIL_EXID_LENGTH_MAX = void 0;
|
|
4
|
+
const type_fns_1 = require("type-fns");
|
|
5
|
+
/**
|
|
6
|
+
* .what = the longest exid the sdk accepts from, or writes to, a header
|
|
7
|
+
* .why = an exid is a correlation key, not a payload. the form the sdk mints is `exid:<uuid>`, 41
|
|
8
|
+
* characters, so 128 leaves room for a request id or a prefixed trace without a header that
|
|
9
|
+
* can hold a page of text
|
|
10
|
+
*/
|
|
11
|
+
exports.TRAIL_EXID_LENGTH_MAX = 128;
|
|
12
|
+
/**
|
|
13
|
+
* .what = whether a value is a well-formed trail exid: a string of 1 to 128 printable ascii characters
|
|
14
|
+
* .why = `x-trail-exid` is the first value a public caller can place in this sdk's logs, in every 500's
|
|
15
|
+
* `correlationId`, and in the trail of every downstream call. a caller who sends a page of text,
|
|
16
|
+
* or a control character, would write it all into those places. a bounded printable value cannot
|
|
17
|
+
* forge a log line or grow a header without limit (`domain.terms/x-trail-exid.md`)
|
|
18
|
+
*
|
|
19
|
+
* .note = printable ascii is U+0020 to U+007E. a space is allowed inside the value, never at an end: http
|
|
20
|
+
* trims the ends of a header value, so a padded exid would read differently at each side of the
|
|
21
|
+
* wire and the trace would not join. a tab, a newline, and every control character are not allowed
|
|
22
|
+
*/
|
|
23
|
+
exports.isTrailExid = (0, type_fns_1.withAssure)((value) => typeof value === 'string' &&
|
|
24
|
+
value.length >= 1 &&
|
|
25
|
+
value.length <= exports.TRAIL_EXID_LENGTH_MAX &&
|
|
26
|
+
/^[\x21-\x7e]([\x20-\x7e]*[\x21-\x7e])?$/.test(value), { name: 'isTrailExid' });
|
|
27
|
+
//# sourceMappingURL=isTrailExid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isTrailExid.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/isTrailExid.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AAEtC;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,GAAG,CAAC;AAEzC;;;;;;;;;;GAUG;AACU,QAAA,WAAW,GAAG,IAAA,qBAAU,EACnC,CAAC,KAAc,EAAmB,EAAE,CAClC,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,CAAC,MAAM,IAAI,CAAC;IACjB,KAAK,CAAC,MAAM,IAAI,6BAAqB;IACrC,yCAAyC,CAAC,IAAI,CAAC,KAAK,CAAC,EACvD,EAAE,IAAI,EAAE,aAAa,EAAE,CACxB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = whether a headers bag holds an `x-trail-exid` a caller meant as the opt-in, which the endpoint
|
|
3
|
+
* reads as absent because the value is malformed
|
|
4
|
+
* .why = a malformed value opts a caller out in silence: the caller is answered ancient and its trace does
|
|
5
|
+
* not join. the endpoint logs this, with the length and never the text, so the drop leaves a signal
|
|
6
|
+
*
|
|
7
|
+
* .note = an empty value is absent, not malformed: a client that sends an empty header meant no opt-in
|
|
8
|
+
*/
|
|
9
|
+
export declare const isTrailExidHeaderMalformed: (input: {
|
|
10
|
+
headers: Record<string, string | undefined> | null | undefined;
|
|
11
|
+
}) => boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTrailExidHeaderMalformed = void 0;
|
|
4
|
+
const TrailExidHeader_1 = require("../../../domain.objects/TrailExidHeader");
|
|
5
|
+
const isTrailExid_1 = require("./isTrailExid");
|
|
6
|
+
/**
|
|
7
|
+
* .what = whether a headers bag holds an `x-trail-exid` a caller meant as the opt-in, which the endpoint
|
|
8
|
+
* reads as absent because the value is malformed
|
|
9
|
+
* .why = a malformed value opts a caller out in silence: the caller is answered ancient and its trace does
|
|
10
|
+
* not join. the endpoint logs this, with the length and never the text, so the drop leaves a signal
|
|
11
|
+
*
|
|
12
|
+
* .note = an empty value is absent, not malformed: a client that sends an empty header meant no opt-in
|
|
13
|
+
*/
|
|
14
|
+
const isTrailExidHeaderMalformed = (input) => {
|
|
15
|
+
const value = input.headers?.[TrailExidHeader_1.TRAIL_EXID_HEADER];
|
|
16
|
+
if (typeof value !== 'string' || value === '')
|
|
17
|
+
return false;
|
|
18
|
+
return !isTrailExid_1.isTrailExid.assess(value);
|
|
19
|
+
};
|
|
20
|
+
exports.isTrailExidHeaderMalformed = isTrailExidHeaderMalformed;
|
|
21
|
+
//# sourceMappingURL=isTrailExidHeaderMalformed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isTrailExidHeaderMalformed.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/isTrailExidHeaderMalformed.ts"],"names":[],"mappings":";;;AAAA,6EAA4E;AAC5E,+CAA4C;AAE5C;;;;;;;GAOG;AACI,MAAM,0BAA0B,GAAG,CAAC,KAE1C,EAAW,EAAE;IACZ,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,mCAAiB,CAAC,CAAC;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAC5D,OAAO,CAAC,yBAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC,CAAC;AANW,QAAA,0BAA0B,8BAMrC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = the mark `asLambdaEvent.fromApiGateway` leaves on an event it built
|
|
3
|
+
* .why = `runLambdaEndpoint` must pick the carrier — header or wrapper — and the sdk never sniffs an
|
|
4
|
+
* event's shape for it (`invariant.ancient-vs-contemp-callers.md`). the builder knows what it
|
|
5
|
+
* built, so it declares it
|
|
6
|
+
*
|
|
7
|
+
* .note = `Symbol.for`, so two copies of this package in one process still agree on the mark
|
|
8
|
+
*/
|
|
9
|
+
export declare const EVENT_DECLARED_AS_API_GATEWAY: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* .what = declares an event as an api gateway event, and returns the same event
|
|
12
|
+
* .why = the declaration travels WITH the event object, so a test author's event reaches
|
|
13
|
+
* `runLambdaEndpoint` still declared
|
|
14
|
+
*
|
|
15
|
+
* .note = non-enumerable, so it appears in no spread, no snapshot, no `toEqual`, and no json —
|
|
16
|
+
* `runLambdaEndpoint` reads it BEFORE its json strip, which would drop it
|
|
17
|
+
* .note = DELIBERATE MUTATION — of the fresh object the builder just made, never of a caller's
|
|
18
|
+
*/
|
|
19
|
+
export declare const setEventDeclaredAsApiGateway: <TEvent extends object>(input: {
|
|
20
|
+
event: TEvent;
|
|
21
|
+
}) => TEvent;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setEventDeclaredAsApiGateway = exports.EVENT_DECLARED_AS_API_GATEWAY = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = the mark `asLambdaEvent.fromApiGateway` leaves on an event it built
|
|
6
|
+
* .why = `runLambdaEndpoint` must pick the carrier — header or wrapper — and the sdk never sniffs an
|
|
7
|
+
* event's shape for it (`invariant.ancient-vs-contemp-callers.md`). the builder knows what it
|
|
8
|
+
* built, so it declares it
|
|
9
|
+
*
|
|
10
|
+
* .note = `Symbol.for`, so two copies of this package in one process still agree on the mark
|
|
11
|
+
*/
|
|
12
|
+
exports.EVENT_DECLARED_AS_API_GATEWAY = Symbol.for('sdk-aws-lambda.event.declaredAs.apiGateway');
|
|
13
|
+
/**
|
|
14
|
+
* .what = declares an event as an api gateway event, and returns the same event
|
|
15
|
+
* .why = the declaration travels WITH the event object, so a test author's event reaches
|
|
16
|
+
* `runLambdaEndpoint` still declared
|
|
17
|
+
*
|
|
18
|
+
* .note = non-enumerable, so it appears in no spread, no snapshot, no `toEqual`, and no json —
|
|
19
|
+
* `runLambdaEndpoint` reads it BEFORE its json strip, which would drop it
|
|
20
|
+
* .note = DELIBERATE MUTATION — of the fresh object the builder just made, never of a caller's
|
|
21
|
+
*/
|
|
22
|
+
const setEventDeclaredAsApiGateway = (input) => Object.defineProperty(input.event, exports.EVENT_DECLARED_AS_API_GATEWAY, {
|
|
23
|
+
value: true,
|
|
24
|
+
enumerable: false,
|
|
25
|
+
});
|
|
26
|
+
exports.setEventDeclaredAsApiGateway = setEventDeclaredAsApiGateway;
|
|
27
|
+
//# sourceMappingURL=setEventDeclaredAsApiGateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setEventDeclaredAsApiGateway.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/setEventDeclaredAsApiGateway.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACU,QAAA,6BAA6B,GAAG,MAAM,CAAC,GAAG,CACrD,4CAA4C,CAC7C,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,4BAA4B,GAAG,CAAwB,KAEnE,EAAU,EAAE,CACX,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,EAAE,qCAA6B,EAAE;IAChE,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,KAAK;CAClB,CAAC,CAAC;AANQ,QAAA,4BAA4B,gCAMpC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TrailCarrier } from '../../../domain.objects/TrailCarrier';
|
|
2
|
+
/**
|
|
3
|
+
* .what = the mark a `genLambdaEndpoint` builder leaves on the handler it returns, which names the
|
|
4
|
+
* carrier that family reads
|
|
5
|
+
* .why = the receiver owns the carrier, and the handler is the receiver. `runLambdaEndpoint` holds the
|
|
6
|
+
* handler at `onReferenced` and at the local locus of `onSerialized`, so it reads the carrier
|
|
7
|
+
* off the handler, and an event copied from a built one (a spread, a clone, a captured request)
|
|
8
|
+
* reaches the endpoint still framed for its family
|
|
9
|
+
*
|
|
10
|
+
* .note = `Symbol.for`, so two copies of this package in one process still agree on the mark
|
|
11
|
+
*/
|
|
12
|
+
export declare const HANDLER_TRAIL_CARRIER: unique symbol;
|
|
13
|
+
/**
|
|
14
|
+
* .what = declares the carrier a handler reads, and returns the same handler
|
|
15
|
+
* .why = each family states its carrier once, beside the `genTrailMiddleware({ carrier })` that reads
|
|
16
|
+
* it, so the endpoint and the runner cannot disagree
|
|
17
|
+
*
|
|
18
|
+
* .note = non-enumerable, so it appears in no spread and no snapshot of the handler
|
|
19
|
+
* .note = DELIBERATE MUTATION — of the fresh handler the builder just made, never of a caller's
|
|
20
|
+
*/
|
|
21
|
+
export declare const setHandlerTrailCarrier: <THandler extends object>(input: {
|
|
22
|
+
handler: THandler;
|
|
23
|
+
carrier: TrailCarrier;
|
|
24
|
+
}) => THandler;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setHandlerTrailCarrier = exports.HANDLER_TRAIL_CARRIER = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = the mark a `genLambdaEndpoint` builder leaves on the handler it returns, which names the
|
|
6
|
+
* carrier that family reads
|
|
7
|
+
* .why = the receiver owns the carrier, and the handler is the receiver. `runLambdaEndpoint` holds the
|
|
8
|
+
* handler at `onReferenced` and at the local locus of `onSerialized`, so it reads the carrier
|
|
9
|
+
* off the handler, and an event copied from a built one (a spread, a clone, a captured request)
|
|
10
|
+
* reaches the endpoint still framed for its family
|
|
11
|
+
*
|
|
12
|
+
* .note = `Symbol.for`, so two copies of this package in one process still agree on the mark
|
|
13
|
+
*/
|
|
14
|
+
exports.HANDLER_TRAIL_CARRIER = Symbol.for('sdk-aws-lambda.handler.trailCarrier');
|
|
15
|
+
/**
|
|
16
|
+
* .what = declares the carrier a handler reads, and returns the same handler
|
|
17
|
+
* .why = each family states its carrier once, beside the `genTrailMiddleware({ carrier })` that reads
|
|
18
|
+
* it, so the endpoint and the runner cannot disagree
|
|
19
|
+
*
|
|
20
|
+
* .note = non-enumerable, so it appears in no spread and no snapshot of the handler
|
|
21
|
+
* .note = DELIBERATE MUTATION — of the fresh handler the builder just made, never of a caller's
|
|
22
|
+
*/
|
|
23
|
+
const setHandlerTrailCarrier = (input) => Object.defineProperty(input.handler, exports.HANDLER_TRAIL_CARRIER, {
|
|
24
|
+
value: input.carrier,
|
|
25
|
+
enumerable: false,
|
|
26
|
+
});
|
|
27
|
+
exports.setHandlerTrailCarrier = setHandlerTrailCarrier;
|
|
28
|
+
//# sourceMappingURL=setHandlerTrailCarrier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setHandlerTrailCarrier.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/setHandlerTrailCarrier.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;GASG;AACU,QAAA,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAC7C,qCAAqC,CACtC,CAAC;AAEF;;;;;;;GAOG;AACI,MAAM,sBAAsB,GAAG,CAA0B,KAG/D,EAAY,EAAE,CACb,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,6BAAqB,EAAE;IAC1D,KAAK,EAAE,KAAK,CAAC,OAAO;IACpB,UAAU,EAAE,KAAK;CAClB,CAAC,CAAC;AAPQ,QAAA,sBAAsB,0BAO9B"}
|