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
|
@@ -44,6 +44,13 @@ export type LambdaEndpointHandlerReferenced<TEvent, TOutput> = (event: TEvent, c
|
|
|
44
44
|
* reads `event.uuid` off the wrapper, finds `undefined`, and takes its own reject
|
|
45
45
|
* branch — a rejection envelope on the success case, with no type error anywhere.
|
|
46
46
|
*
|
|
47
|
+
* ⚠️ an event built by `asLambdaEvent.fromApiGateway` is the one exception to the wrapper: aws builds
|
|
48
|
+
* that envelope and no caller can wrap it, so contemp rides the `x-trail-exid` request header
|
|
49
|
+
* instead, and the event is never wrapped. `ancient` sends it raw, with no header. a hand-built
|
|
50
|
+
* api gateway object carries no declaration, so it gets the wrapper and an api gateway endpoint
|
|
51
|
+
* refuses it — build it with `asLambdaEvent.fromApiGateway`
|
|
52
|
+
* (`invariant.ancient-vs-contemp-callers.md`).
|
|
53
|
+
*
|
|
47
54
|
* ⇒ so a legacy `createStandardHandler` handler needs `struct: { payload: 'ancient' }`.
|
|
48
55
|
* the frame is DERIVED from `struct.payload`, never from `trail`, so the two
|
|
49
56
|
* cannot disagree.
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.onReferenced = void 0;
|
|
4
|
+
const getOneTrailCarrierOfEvent_1 = require("../lambdaEndpointWire/frame/getOneTrailCarrierOfEvent");
|
|
5
|
+
const getOneTrailCarrierOfHandler_1 = require("../lambdaEndpointWire/frame/getOneTrailCarrierOfHandler");
|
|
4
6
|
const asLambdaContext_1 = require("./context/asLambdaContext");
|
|
5
7
|
const asLambdaEndpointDialect_1 = require("./dialect/asLambdaEndpointDialect");
|
|
6
8
|
const assertEventIsGiven_1 = require("./guard/assertEventIsGiven");
|
|
7
9
|
const assertHandlerIsRunnable_1 = require("./guard/assertHandlerIsRunnable");
|
|
8
|
-
const
|
|
10
|
+
const asCarriedPayload_1 = require("./serde/asCarriedPayload");
|
|
9
11
|
const asWireStripped_1 = require("./serde/asWireStripped");
|
|
10
12
|
/**
|
|
11
13
|
* .what = runs a lambda endpoint you hold a REFERENCE to — the handler function
|
|
@@ -42,6 +44,13 @@ const asWireStripped_1 = require("./serde/asWireStripped");
|
|
|
42
44
|
* reads `event.uuid` off the wrapper, finds `undefined`, and takes its own reject
|
|
43
45
|
* branch — a rejection envelope on the success case, with no type error anywhere.
|
|
44
46
|
*
|
|
47
|
+
* ⚠️ an event built by `asLambdaEvent.fromApiGateway` is the one exception to the wrapper: aws builds
|
|
48
|
+
* that envelope and no caller can wrap it, so contemp rides the `x-trail-exid` request header
|
|
49
|
+
* instead, and the event is never wrapped. `ancient` sends it raw, with no header. a hand-built
|
|
50
|
+
* api gateway object carries no declaration, so it gets the wrapper and an api gateway endpoint
|
|
51
|
+
* refuses it — build it with `asLambdaEvent.fromApiGateway`
|
|
52
|
+
* (`invariant.ancient-vs-contemp-callers.md`).
|
|
53
|
+
*
|
|
45
54
|
* ⇒ so a legacy `createStandardHandler` handler needs `struct: { payload: 'ancient' }`.
|
|
46
55
|
* the frame is DERIVED from `struct.payload`, never from `trail`, so the two
|
|
47
56
|
* cannot disagree.
|
|
@@ -89,14 +98,21 @@ const onReferenced = async (input) => {
|
|
|
89
98
|
const dialect = (0, asLambdaEndpointDialect_1.asLambdaEndpointDialect)({
|
|
90
99
|
declared: input.struct?.payload,
|
|
91
100
|
});
|
|
101
|
+
// the carrier is the receiver's: a handler a `genLambdaEndpoint` builder returned declares it, so a
|
|
102
|
+
// copy of a built event still reaches its family framed right. a plain handler declares none, and
|
|
103
|
+
// the event's own declaration decides, read BEFORE the strip — it is a non-enumerable mark, and the
|
|
104
|
+
// json strip would drop it
|
|
105
|
+
const carrier = (0, getOneTrailCarrierOfHandler_1.getOneTrailCarrierOfHandler)({ handler: input.handler }) ??
|
|
106
|
+
(0, getOneTrailCarrierOfEvent_1.getOneTrailCarrierOfEvent)({ event: input.event });
|
|
92
107
|
// strip inbound, so no live object reaches the handler that the wire could not deliver
|
|
93
108
|
// `of: 'event'` — a refusal here is the CALLER's payload, so it raises a ConstraintError
|
|
94
109
|
const eventStripped = (0, asWireStripped_1.asWireStripped)({ value: input.event, of: 'event' });
|
|
95
110
|
// frame the payload, so the endpoint reads the dialect the caller declared
|
|
96
|
-
const payload = (0,
|
|
111
|
+
const payload = (0, asCarriedPayload_1.asCarriedPayload)({
|
|
97
112
|
event: eventStripped,
|
|
98
113
|
trail: input.trail ?? null,
|
|
99
114
|
dialect,
|
|
115
|
+
carrier,
|
|
100
116
|
});
|
|
101
117
|
const context = (0, asLambdaContext_1.asLambdaContext)(input.context);
|
|
102
118
|
// shared with the serialized boundary, which needs it ahead of its delegation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runLambdaEndpoint.onReferenced.js","sourceRoot":"","sources":["../../../src/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.ts"],"names":[],"mappings":";;;AAGA,+DAA4D;AAC5D,+EAA4E;AAE5E,mEAAgE;AAChE,6EAA0E;AAC1E
|
|
1
|
+
{"version":3,"file":"runLambdaEndpoint.onReferenced.js","sourceRoot":"","sources":["../../../src/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.ts"],"names":[],"mappings":";;;AAGA,qGAAkG;AAClG,yGAAsG;AACtG,+DAA4D;AAC5D,+EAA4E;AAE5E,mEAAgE;AAChE,6EAA0E;AAC1E,+DAA4D;AAC5D,2DAAwD;AAcxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACI,MAAM,YAAY,GAAG,KAAK,EAI/B,KAyCD,EAAuD,EAAE;IACxD,6EAA6E;IAC7E,2EAA2E;IAC3E,6EAA6E;IAC7E,EAAE;IACF,2EAA2E;IAC3E,8EAA8E;IAC9E,2DAA2D;IAC3D,kCAAkC;IAClC,IAAA,uCAAkB,EAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAE3D,4EAA4E;IAC5E,kDAAkD;IAClD,MAAM,OAAO,GAA0B,IAAA,iDAAuB,EAAC;QAC7D,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;KAChC,CAAC,CAAC;IAEH,oGAAoG;IACpG,kGAAkG;IAClG,oGAAoG;IACpG,2BAA2B;IAC3B,MAAM,OAAO,GACX,IAAA,yDAA2B,EAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QACvD,IAAA,qDAAyB,EAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAEpD,uFAAuF;IACvF,yFAAyF;IACzF,MAAM,aAAa,GAAG,IAAA,+BAAc,EAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAE1E,2EAA2E;IAC3E,MAAM,OAAO,GAAG,IAAA,mCAAgB,EAAC;QAC/B,KAAK,EAAE,aAAa;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI;QAC1B,OAAO;QACP,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAA,iCAAe,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAE/C,8EAA8E;IAC9E,IAAA,iDAAuB,EAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEpD,+EAA+E;IAC/E,kEAAkE;IAClE,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAErD,mFAAmF;IACnF,6EAA6E;IAC7E,EAAE;IACF,gFAAgF;IAChF,4EAA4E;IAC5E,2DAA2D;IAC3D,OAAO,IAAA,+BAAc,EAAC;QACpB,KAAK,EAAE,MAAM;QACb,EAAE,EAAE,QAAQ;KACb,CAA+C,CAAC;AACnD,CAAC,CAAC;AArGW,QAAA,YAAY,gBAqGvB"}
|
|
@@ -6,6 +6,7 @@ const askLambdaEndpoint_1 = require("../askLambdaEndpoint/askLambdaEndpoint");
|
|
|
6
6
|
const asLambdaEndpoint_1 = require("../asLambdaEndpoint/asLambdaEndpoint");
|
|
7
7
|
const getOneTrailExid_1 = require("../lambdaEndpointWire/context/getOneTrailExid");
|
|
8
8
|
const throwIfCredentialsError_1 = require("../lambdaEndpointWire/error/throwIfCredentialsError");
|
|
9
|
+
const getOneTrailCarrierOfEvent_1 = require("../lambdaEndpointWire/frame/getOneTrailCarrierOfEvent");
|
|
9
10
|
const getParsedResponse_1 = require("../lambdaEndpointWire/getParsedResponse");
|
|
10
11
|
const asLambdaEndpointDialect_1 = require("./dialect/asLambdaEndpointDialect");
|
|
11
12
|
const assertEventIsGiven_1 = require("./guard/assertEventIsGiven");
|
|
@@ -13,6 +14,7 @@ const assertHandlerIsRunnable_1 = require("./guard/assertHandlerIsRunnable");
|
|
|
13
14
|
const asLocalRunIdentity_1 = require("./local/asLocalRunIdentity");
|
|
14
15
|
const getOneHandlerFromServerlessYml_1 = require("./local/getOneHandlerFromServerlessYml");
|
|
15
16
|
const runLambdaEndpoint_onReferenced_1 = require("./runLambdaEndpoint.onReferenced");
|
|
17
|
+
const asCarriedPayload_1 = require("./serde/asCarriedPayload");
|
|
16
18
|
const asWireFunctionErrorPayload_1 = require("./serde/asWireFunctionErrorPayload");
|
|
17
19
|
const asWirePayload_1 = require("./serde/asWirePayload");
|
|
18
20
|
/**
|
|
@@ -110,12 +112,12 @@ const onSerialized = async (input, context) => {
|
|
|
110
112
|
// `LambdaCredentialsAbsentError extends ConstraintError` ⇒ caller fault, NO
|
|
111
113
|
// ALARM. to map it on the runtime path would suppress the prod alarm that
|
|
112
114
|
// names a broken role (`invariant.badrequesterror-not-lambda-error`).
|
|
113
|
-
if (at === 'cloud')
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
if (at === 'cloud') {
|
|
116
|
+
/**
|
|
117
|
+
* .what = names an absent-credentials fault for a developer at a terminal
|
|
118
|
+
* .why = both calls below reach aws, so both owe the same diagnosis
|
|
119
|
+
*/
|
|
120
|
+
const asCredentialsFault = (error) => (0, throwIfCredentialsError_1.throwIfCredentialsError)({
|
|
119
121
|
error,
|
|
120
122
|
message: 'aws credentials are absent or expired, so the deployed endpoint cannot be invoked',
|
|
121
123
|
access: context.env.access,
|
|
@@ -124,7 +126,41 @@ const onSerialized = async (input, context) => {
|
|
|
124
126
|
access: context.env.access,
|
|
125
127
|
at,
|
|
126
128
|
},
|
|
127
|
-
})
|
|
129
|
+
});
|
|
130
|
+
// 🔴 an event the builder declared as api gateway carries the opt-in in its `headers`,
|
|
131
|
+
// since aws builds that envelope and a deployed `forApiGateway` endpoint refuses a
|
|
132
|
+
// `{ event, trail }` wrapper. `askLambdaEndpoint` sends the event as is on the ancient
|
|
133
|
+
// struct, so the carried event goes with that struct — the DIALECT is still the caller's
|
|
134
|
+
// declaration, carried by the header rather than the frame
|
|
135
|
+
const carrier = (0, getOneTrailCarrierOfEvent_1.getOneTrailCarrierOfEvent)({ event: input.event });
|
|
136
|
+
if (carrier === 'headers') {
|
|
137
|
+
// 🔴 the exid is minted ONCE, here, and pinned onto the context `askLambdaEndpoint` reads
|
|
138
|
+
// its own from. two mints would put one exid in the header and another in the call's
|
|
139
|
+
// log and errors (`getOneTrailExid` states the parity this keeps)
|
|
140
|
+
const exid = (0, getOneTrailExid_1.getOneTrailExid)({ log: context.log });
|
|
141
|
+
return (0, askLambdaEndpoint_1.askLambdaEndpoint)({
|
|
142
|
+
which: input.which,
|
|
143
|
+
event: (0, asCarriedPayload_1.asCarriedPayload)({
|
|
144
|
+
event: input.event,
|
|
145
|
+
trail: { exid },
|
|
146
|
+
dialect: dialectValidated,
|
|
147
|
+
carrier,
|
|
148
|
+
}),
|
|
149
|
+
struct: { payload: 'ancient' },
|
|
150
|
+
}, {
|
|
151
|
+
...context,
|
|
152
|
+
log: {
|
|
153
|
+
...context.log,
|
|
154
|
+
trail: { exid, stack: context.log.trail?.stack ?? [] },
|
|
155
|
+
},
|
|
156
|
+
}).catch(asCredentialsFault);
|
|
157
|
+
}
|
|
158
|
+
return (0, askLambdaEndpoint_1.askLambdaEndpoint)({
|
|
159
|
+
which: input.which,
|
|
160
|
+
event: input.event,
|
|
161
|
+
struct: structValidated,
|
|
162
|
+
}, context).catch(asCredentialsFault);
|
|
163
|
+
}
|
|
128
164
|
// the local locus: look the handler up, run it, then hydrate exactly as the wire does
|
|
129
165
|
const endpoint = (0, asLambdaEndpoint_1.asLambdaEndpoint)({
|
|
130
166
|
service: input.which.service,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runLambdaEndpoint.onSerialized.js","sourceRoot":"","sources":["../../../src/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAIjD,8EAA2E;AAC3E,2EAAwE;AACxE,mFAAgF;AAChF,iGAA8F;AAC9F,+EAA4E;AAC5E,+EAA4E;AAE5E,mEAAgE;AAChE,6EAA0E;AAC1E,mEAAgE;AAChE,2FAAwF;AACxF,qFAAgE;AAChE,mFAAgF;AAChF,yDAAsD;AAWtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACI,MAAM,YAAY,GAAG,KAAK,EAC/B,KAiCC,EACD,OAA+B,EACE,EAAE;IACnC,gFAAgF;IAChF,yEAAyE;IACzE,iFAAiF;IACjF,IAAA,uCAAkB,EAAC;QACjB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,OAAO,EAAE;KAC1D,CAAC,CAAC;IAEH,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,IAAI,OAAO,CAAC;IAE/B,+EAA+E;IAC/E,4EAA4E;IAC5E,+EAA+E;IAC/E,0EAA0E;IAC1E,0DAA0D;IAC1D,IAAI,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,OAAO;QAClC,OAAO,gCAAe,CAAC,KAAK,CAC1B,8CAA8C,EAC9C;YACE,EAAE;YACF,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;YAC3B,IAAI,EAAE,uLAAuL;SAC9L,CACF,CAAC;IAEJ,+EAA+E;IAC/E,8EAA8E;IAC9E,8EAA8E;IAC9E,wEAAwE;IACxE,MAAM,gBAAgB,GAAG,IAAA,iDAAuB,EAAC;QAC/C,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;KAChC,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAEtD,+EAA+E;IAC/E,4EAA4E;IAC5E,8CAA8C;IAC9C,EAAE;IACF,iEAAiE;IACjE,8DAA8D;IAC9D,EAAE;IACF,2DAA2D;IAC3D,mBAAmB;IACnB,kHAAkH;IAClH,qGAAqG;IACrG,EAAE;IACF,+EAA+E;IAC/E,6EAA6E;IAC7E,yEAAyE;IACzE,IAAI,EAAE,KAAK,OAAO;
|
|
1
|
+
{"version":3,"file":"runLambdaEndpoint.onSerialized.js","sourceRoot":"","sources":["../../../src/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAIjD,8EAA2E;AAC3E,2EAAwE;AACxE,mFAAgF;AAChF,iGAA8F;AAC9F,qGAAkG;AAClG,+EAA4E;AAC5E,+EAA4E;AAE5E,mEAAgE;AAChE,6EAA0E;AAC1E,mEAAgE;AAChE,2FAAwF;AACxF,qFAAgE;AAChE,+DAA4D;AAC5D,mFAAgF;AAChF,yDAAsD;AAWtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACI,MAAM,YAAY,GAAG,KAAK,EAC/B,KAiCC,EACD,OAA+B,EACE,EAAE;IACnC,gFAAgF;IAChF,yEAAyE;IACzE,iFAAiF;IACjF,IAAA,uCAAkB,EAAC;QACjB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,OAAO,EAAE;KAC1D,CAAC,C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35 @@
|
|
|
1
|
+
import type { LambdaEndpointDialect } from '../../../domain.objects/LambdaEndpointDialect';
|
|
2
|
+
import type { TrailCarrier } from '../../../domain.objects/TrailCarrier';
|
|
3
|
+
/**
|
|
4
|
+
* .what = casts an event into the payload its endpoint's carrier reads, in the dialect declared
|
|
5
|
+
* .why = a direct invoke reads a `{ event, trail }` wrapper; an api gateway event is built by aws
|
|
6
|
+
* and carries the opt-in in its own `headers`. the dialect is still derived from
|
|
7
|
+
* `struct.payload` alone, so the two knobs cannot disagree
|
|
8
|
+
* (`invariant.ancient-vs-contemp-callers.md`)
|
|
9
|
+
*
|
|
10
|
+
* | carrier | contemp | ancient |
|
|
11
|
+
* |---------|---------|---------|
|
|
12
|
+
* | wrapper | `{ event, trail }` | the event, untouched |
|
|
13
|
+
* | headers | the event + `x-trail-exid` | the event, untouched: the sdk adds no opt-in |
|
|
14
|
+
*
|
|
15
|
+
* .note = the `wrapper` arm is `asFramedPayload`, unchanged. this adds the second carrier and
|
|
16
|
+
* owns no copy of the first (rule.forbid.parallel-codepaths)
|
|
17
|
+
* .note = the `headers` arm owes an exid, since a header that holds no value holds no opt-in: it takes
|
|
18
|
+
* the caller's trail, else a well-formed one the event already holds in its header, else a
|
|
19
|
+
* generated one (`getOneTrailWithExid`)
|
|
20
|
+
* .note = the `headers` arm merges the key into `multiValueHeaders` too when the event holds that
|
|
21
|
+
* twin, so a v1 event stays wire-faithful, and drops every case variant of the key first,
|
|
22
|
+
* so the sdk's key is the only one the endpoint reads. a hand-built v1 event that holds
|
|
23
|
+
* `X-Trail-Exid` loses that variant and gains the lowercase one; every other key keeps its
|
|
24
|
+
* author's case
|
|
25
|
+
* .note = `ancient` leaves the event as it is, so an event that already holds the key (a request
|
|
26
|
+
* captured off a real wire) keeps the opt-in its caller placed there
|
|
27
|
+
*/
|
|
28
|
+
export declare const asCarriedPayload: (input: {
|
|
29
|
+
event: unknown;
|
|
30
|
+
trail: {
|
|
31
|
+
exid?: string;
|
|
32
|
+
} | null;
|
|
33
|
+
dialect: LambdaEndpointDialect;
|
|
34
|
+
carrier: TrailCarrier;
|
|
35
|
+
}) => unknown;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asCarriedPayload = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const TrailExidHeader_1 = require("../../../domain.objects/TrailExidHeader");
|
|
6
|
+
const asHeadersWithoutKey_1 = require("../../lambdaEndpointWire/frame/asHeadersWithoutKey");
|
|
7
|
+
const asTrailExidHeaders_1 = require("../../lambdaEndpointWire/frame/asTrailExidHeaders");
|
|
8
|
+
const getOneTrailExidFromHeaders_1 = require("../../lambdaEndpointWire/frame/getOneTrailExidFromHeaders");
|
|
9
|
+
const asFramedPayload_1 = require("./asFramedPayload");
|
|
10
|
+
const getOneTrailWithExid_1 = require("./getOneTrailWithExid");
|
|
11
|
+
const isEventWithHeaders_1 = require("./isEventWithHeaders");
|
|
12
|
+
/**
|
|
13
|
+
* .what = casts an event into the payload its endpoint's carrier reads, in the dialect declared
|
|
14
|
+
* .why = a direct invoke reads a `{ event, trail }` wrapper; an api gateway event is built by aws
|
|
15
|
+
* and carries the opt-in in its own `headers`. the dialect is still derived from
|
|
16
|
+
* `struct.payload` alone, so the two knobs cannot disagree
|
|
17
|
+
* (`invariant.ancient-vs-contemp-callers.md`)
|
|
18
|
+
*
|
|
19
|
+
* | carrier | contemp | ancient |
|
|
20
|
+
* |---------|---------|---------|
|
|
21
|
+
* | wrapper | `{ event, trail }` | the event, untouched |
|
|
22
|
+
* | headers | the event + `x-trail-exid` | the event, untouched: the sdk adds no opt-in |
|
|
23
|
+
*
|
|
24
|
+
* .note = the `wrapper` arm is `asFramedPayload`, unchanged. this adds the second carrier and
|
|
25
|
+
* owns no copy of the first (rule.forbid.parallel-codepaths)
|
|
26
|
+
* .note = the `headers` arm owes an exid, since a header that holds no value holds no opt-in: it takes
|
|
27
|
+
* the caller's trail, else a well-formed one the event already holds in its header, else a
|
|
28
|
+
* generated one (`getOneTrailWithExid`)
|
|
29
|
+
* .note = the `headers` arm merges the key into `multiValueHeaders` too when the event holds that
|
|
30
|
+
* twin, so a v1 event stays wire-faithful, and drops every case variant of the key first,
|
|
31
|
+
* so the sdk's key is the only one the endpoint reads. a hand-built v1 event that holds
|
|
32
|
+
* `X-Trail-Exid` loses that variant and gains the lowercase one; every other key keeps its
|
|
33
|
+
* author's case
|
|
34
|
+
* .note = `ancient` leaves the event as it is, so an event that already holds the key (a request
|
|
35
|
+
* captured off a real wire) keeps the opt-in its caller placed there
|
|
36
|
+
*/
|
|
37
|
+
const asCarriedPayload = (input) => {
|
|
38
|
+
// the carrier is exhaustive: a third one added to the type fails to compile until it is handled here
|
|
39
|
+
if (input.carrier !== 'wrapper' && input.carrier !== 'headers')
|
|
40
|
+
return helpful_errors_1.MalfunctionError.throw('the trail carrier is not one this writes', {
|
|
41
|
+
carrier: input.carrier,
|
|
42
|
+
});
|
|
43
|
+
if (input.carrier === 'wrapper')
|
|
44
|
+
return (0, asFramedPayload_1.asFramedPayload)(input);
|
|
45
|
+
// ancient: the sdk adds no opt-in, exactly as a browser's request carries none
|
|
46
|
+
if (input.dialect === 'ancient')
|
|
47
|
+
return input.event;
|
|
48
|
+
// `input.event` is `unknown` because this operation serves every carrier; the header bags are
|
|
49
|
+
// checked here, at run time, rather than asserted
|
|
50
|
+
const event = isEventWithHeaders_1.isEventWithHeaders.assure(input.event);
|
|
51
|
+
const headersCarried = (0, asTrailExidHeaders_1.asTrailExidHeaders)({
|
|
52
|
+
trail: (0, getOneTrailWithExid_1.getOneTrailWithExid)({
|
|
53
|
+
trail: input.trail ?? {
|
|
54
|
+
exid: (0, getOneTrailExidFromHeaders_1.getOneTrailExidFromHeaders)({ headers: event.headers }),
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
...event,
|
|
60
|
+
headers: {
|
|
61
|
+
...(0, asHeadersWithoutKey_1.asHeadersWithoutKey)({
|
|
62
|
+
headers: event.headers,
|
|
63
|
+
key: TrailExidHeader_1.TRAIL_EXID_HEADER,
|
|
64
|
+
}),
|
|
65
|
+
...headersCarried,
|
|
66
|
+
},
|
|
67
|
+
...(event.multiValueHeaders
|
|
68
|
+
? {
|
|
69
|
+
multiValueHeaders: {
|
|
70
|
+
...(0, asHeadersWithoutKey_1.asHeadersWithoutKey)({
|
|
71
|
+
headers: event.multiValueHeaders,
|
|
72
|
+
key: TrailExidHeader_1.TRAIL_EXID_HEADER,
|
|
73
|
+
}),
|
|
74
|
+
[TrailExidHeader_1.TRAIL_EXID_HEADER]: [headersCarried[TrailExidHeader_1.TRAIL_EXID_HEADER]],
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
: {}),
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
exports.asCarriedPayload = asCarriedPayload;
|
|
81
|
+
//# sourceMappingURL=asCarriedPayload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asCarriedPayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/serde/asCarriedPayload.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAIlD,6EAA4E;AAC5E,4FAAyF;AACzF,0FAAuF;AACvF,0GAAuG;AACvG,uDAAoD;AACpD,+DAA4D;AAC5D,6DAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,gBAAgB,GAAG,CAAC,KAKhC,EAAW,EAAE;IACZ,qGAAqG;IACrG,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAC5D,OAAO,iCAAgB,CAAC,KAAK,CAAC,0CAA0C,EAAE;YACxE,OAAO,EAAE,KAAK,CAAC,OAAuB;SACvC,CAAC,CAAC;IACL,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,IAAA,iCAAe,EAAC,KAAK,CAAC,CAAC;IAE/D,+EAA+E;IAC/E,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC;IAEpD,8FAA8F;IAC9F,kDAAkD;IAClD,MAAM,KAAK,GAAG,uCAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,IAAA,uCAAkB,EAAC;QACxC,KAAK,EAAE,IAAA,yCAAmB,EAAC;YACzB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI;gBACpB,IAAI,EAAE,IAAA,uDAA0B,EAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;aAC7D;SACF,CAAC;KACH,CAAC,CAAC;IACH,OAAO;QACL,GAAG,KAAK;QACR,OAAO,EAAE;YACP,GAAG,IAAA,yCAAmB,EAAC;gBACrB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,GAAG,EAAE,mCAAiB;aACvB,CAAC;YACF,GAAG,cAAc;SAClB;QACD,GAAG,CAAC,KAAK,CAAC,iBAAiB;YACzB,CAAC,CAAC;gBACE,iBAAiB,EAAE;oBACjB,GAAG,IAAA,yCAAmB,EAAC;wBACrB,OAAO,EAAE,KAAK,CAAC,iBAAiB;wBAChC,GAAG,EAAE,mCAAiB;qBACvB,CAAC;oBACF,CAAC,mCAAiB,CAAC,EAAE,CAAC,cAAc,CAAC,mCAAiB,CAAC,CAAC;iBACzD;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC,CAAC;AA/CW,QAAA,gBAAgB,oBA+C3B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = the caller's trail, with an exid guaranteed — the caller's own, or a generated one
|
|
3
|
+
* .why = the `x-trail-exid` header carries a value or carries no opt-in, so a request that
|
|
4
|
+
* opts in owes an exid. a wrapper may go without one; a header may not
|
|
5
|
+
*
|
|
6
|
+
* .note = an absent, null, or empty exid all read as "none" by `getExidFromContext`, which generates
|
|
7
|
+
*/
|
|
8
|
+
export declare const getOneTrailWithExid: (input: {
|
|
9
|
+
trail: {
|
|
10
|
+
exid?: string | null;
|
|
11
|
+
} | null | undefined;
|
|
12
|
+
}) => {
|
|
13
|
+
exid: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOneTrailWithExid = void 0;
|
|
4
|
+
const getExidFromContext_1 = require("../../lambdaEndpointWire/context/getExidFromContext");
|
|
5
|
+
/**
|
|
6
|
+
* .what = the caller's trail, with an exid guaranteed — the caller's own, or a generated one
|
|
7
|
+
* .why = the `x-trail-exid` header carries a value or carries no opt-in, so a request that
|
|
8
|
+
* opts in owes an exid. a wrapper may go without one; a header may not
|
|
9
|
+
*
|
|
10
|
+
* .note = an absent, null, or empty exid all read as "none" by `getExidFromContext`, which generates
|
|
11
|
+
*/
|
|
12
|
+
const getOneTrailWithExid = (input) => ({
|
|
13
|
+
exid: (0, getExidFromContext_1.getExidFromContext)({
|
|
14
|
+
log: { trail: { exid: input.trail?.exid ?? null } },
|
|
15
|
+
}).exid,
|
|
16
|
+
});
|
|
17
|
+
exports.getOneTrailWithExid = getOneTrailWithExid;
|
|
18
|
+
//# sourceMappingURL=getOneTrailWithExid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOneTrailWithExid.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/serde/getOneTrailWithExid.ts"],"names":[],"mappings":";;;AAAA,4FAAyF;AAEzF;;;;;;GAMG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAEnC,EAAoB,EAAE,CAAC,CAAC;IACvB,IAAI,EAAE,IAAA,uCAAkB,EAAC;QACvB,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI,EAAE,EAAE;KACpD,CAAC,CAAC,IAAI;CACR,CAAC,CAAC;AANU,QAAA,mBAAmB,uBAM7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = the two header bags an api gateway event may hold: `headers` on every version, and its
|
|
3
|
+
* multi-value twin on v1
|
|
4
|
+
* .why = the `headers` carrier writes the opt-in into both, so it must know their shape
|
|
5
|
+
*/
|
|
6
|
+
export type EventWithHeaders = {
|
|
7
|
+
headers?: Record<string, string> | null;
|
|
8
|
+
multiValueHeaders?: Record<string, string[]> | null;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* .what = whether a value is an object whose header bags, where present, are objects or null
|
|
12
|
+
* .why = the carrier reads an `unknown` event, and a type guard checks the shape at run time where
|
|
13
|
+
* an `as` cast would only assert it (`rule.forbid.as-cast`, `rule.require.assure-via-type-checks`)
|
|
14
|
+
*
|
|
15
|
+
* .note = `.assure` narrows and throws a helpful error; `.assess` narrows in an `if`
|
|
16
|
+
*/
|
|
17
|
+
export declare const isEventWithHeaders: import("type-fns").AssessWithAssure<unknown, EventWithHeaders>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEventWithHeaders = void 0;
|
|
4
|
+
const type_fns_1 = require("type-fns");
|
|
5
|
+
/**
|
|
6
|
+
* .what = whether a value is an object whose header bags, where present, are objects or null
|
|
7
|
+
* .why = the carrier reads an `unknown` event, and a type guard checks the shape at run time where
|
|
8
|
+
* an `as` cast would only assert it (`rule.forbid.as-cast`, `rule.require.assure-via-type-checks`)
|
|
9
|
+
*
|
|
10
|
+
* .note = `.assure` narrows and throws a helpful error; `.assess` narrows in an `if`
|
|
11
|
+
*/
|
|
12
|
+
exports.isEventWithHeaders = (0, type_fns_1.withAssure)((value) => {
|
|
13
|
+
if (typeof value !== 'object' || value === null)
|
|
14
|
+
return false;
|
|
15
|
+
const isBagOrAbsent = (bag) => bag === undefined || bag === null || typeof bag === 'object';
|
|
16
|
+
return (isBagOrAbsent(Reflect.get(value, 'headers')) &&
|
|
17
|
+
isBagOrAbsent(Reflect.get(value, 'multiValueHeaders')));
|
|
18
|
+
}, { name: 'isEventWithHeaders' });
|
|
19
|
+
//# sourceMappingURL=isEventWithHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEventWithHeaders.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/serde/isEventWithHeaders.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AAYtC;;;;;;GAMG;AACU,QAAA,kBAAkB,GAAG,IAAA,qBAAU,EAC1C,CAAC,KAAc,EAA6B,EAAE;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,aAAa,GAAG,CAAC,GAAY,EAAW,EAAE,CAC9C,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC;IAC/D,OAAO,CACL,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC5C,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC,CACvD,CAAC;AACJ,CAAC,EACD,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAC/B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,17 @@
|
|
|
4
4
|
* define endpoints, ask endpoints, auto-propagate trace-ids.
|
|
5
5
|
*
|
|
6
6
|
* .note = the trace-id propagates lambda to lambda, via the `{ event, trail }` wrapper
|
|
7
|
-
* `askLambdaEndpoint` sends
|
|
7
|
+
* `askLambdaEndpoint` sends, and across http, via the `x-trail-exid` header
|
|
8
|
+
* `askLambdaEndpoint.viaApiGateway` sends. it does not yet cross a queue boundary — those
|
|
8
9
|
* triggers mint a fresh `exid` per invoke (`domain.terms/trail.md`)
|
|
9
10
|
*/
|
|
10
11
|
export { BadRequestError } from 'helpful-errors';
|
|
12
|
+
/**
|
|
13
|
+
* .what = the type of every value a `genLambdaEndpoint.for*` variant hands its `invoke`
|
|
14
|
+
* .why = a consumer who declares a handler apart from the call site must be able to name it
|
|
15
|
+
* .note = `FrozenDeep` is type-fns' own, re-exported so no consumer import changes
|
|
16
|
+
*/
|
|
17
|
+
export type { FrozenDeep } from 'type-fns';
|
|
11
18
|
/**
|
|
12
19
|
* .what = releases every LambdaClient this sdk memoized on the caller's behalf
|
|
13
20
|
* .why = `askLambdaEndpoint` findserts a client per region and holds it for the process, so
|
|
@@ -107,11 +114,6 @@ export { getValidatedInput } from './domain.operations/genLambdaEndpoint/middlew
|
|
|
107
114
|
export { getValidatedOutput, type OutputValidationErrorMetadata, } from './domain.operations/genLambdaEndpoint/middleware/getValidatedOutput';
|
|
108
115
|
export type { ValidationErrorMetadata } from './domain.operations/genLambdaEndpoint/middleware/getValidationError';
|
|
109
116
|
export type { ZodIssueSummary } from './domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary';
|
|
110
|
-
/**
|
|
111
|
-
* .what = types reachable from the public `ForApiGatewayInput` signature
|
|
112
|
-
* .why = a consumer who declares a handler apart from the call site must be able to name them
|
|
113
|
-
*/
|
|
114
|
-
export type { FrozenDeep } from './domain.operations/genLambdaEndpoint/setEventFrozen';
|
|
115
117
|
/**
|
|
116
118
|
* .what = the `logTranslate` config type
|
|
117
119
|
* .note = `TranslateLog` is public because `logTranslate` accepts it, and it replaces the
|
|
@@ -125,6 +127,12 @@ export { genServiceSdk } from './domain.operations/genServiceSdk/genServiceSdk';
|
|
|
125
127
|
export { type GetAllLambdaContractsContext, type GetAllLambdaContractsInput, getAllLambdaContracts, } from './domain.operations/getAllLambdaContracts/getAllLambdaContracts';
|
|
126
128
|
export { getAllLambdaFunctionsByPrefix } from './domain.operations/getAllLambdaContracts/lambdaFunction/getAllLambdaFunctionsByPrefix';
|
|
127
129
|
export { type GetOneLambdaContractContext, type GetOneLambdaContractInput, getOneLambdaContract, } from './domain.operations/getOneLambdaContract/getOneLambdaContract';
|
|
130
|
+
/**
|
|
131
|
+
* .what = the headers that opt an http request into the contemp dialect, and carry its trail
|
|
132
|
+
* .why = any http client (fetch, axios, ky) spreads this into its request
|
|
133
|
+
* (`domain.terms/x-trail-exid.md`)
|
|
134
|
+
*/
|
|
135
|
+
export { asTrailExidHeaders } from './domain.operations/lambdaEndpointWire/frame/asTrailExidHeaders';
|
|
128
136
|
export { asLambdaContext } from './domain.operations/runLambdaEndpoint/context/asLambdaContext';
|
|
129
137
|
export { asLambdaEndpointOutput } from './domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput';
|
|
130
138
|
export { asLambdaEndpointErrorEnvelopeAncient, asLambdaEndpointErrorEnvelopeContemp, isLambdaEndpointErrorEnvelopeAncient, isLambdaEndpointErrorEnvelopeContemp, } from './domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope';
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* define endpoints, ask endpoints, auto-propagate trace-ids.
|
|
6
6
|
*
|
|
7
7
|
* .note = the trace-id propagates lambda to lambda, via the `{ event, trail }` wrapper
|
|
8
|
-
* `askLambdaEndpoint` sends
|
|
8
|
+
* `askLambdaEndpoint` sends, and across http, via the `x-trail-exid` header
|
|
9
|
+
* `askLambdaEndpoint.viaApiGateway` sends. it does not yet cross a queue boundary — those
|
|
9
10
|
* triggers mint a fresh `exid` per invoke (`domain.terms/trail.md`)
|
|
10
11
|
*/
|
|
11
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.runLambdaEndpoint = exports.isLambdaEndpointErrorEnvelopeContemp = exports.isLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointErrorEnvelopeContemp = exports.asLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointOutput = exports.asLambdaContext = exports.getOneLambdaContract = exports.getAllLambdaFunctionsByPrefix = exports.getAllLambdaContracts = exports.genServiceSdk = exports.getValidatedOutput = exports.getValidatedInput = exports.genZodOutputValidationMiddleware = exports.genTrailMiddleware = exports.genIoLoggerMiddleware = exports.genIntrospectionMiddleware = exports.genInternalServiceErrorMiddleware = exports.genConstraintErrorMiddleware = exports.asContextTrailed = exports.genZodEventValidationMiddleware = exports.genZodInputValidationMiddleware = exports.genContentTypeCoherenceMiddleware = exports.genApiGatewayRequestEventNormalizationMiddleware = exports.isApiGatewayResponse = exports.asApiGatewayResponseSchema = exports.genLambdaEndpoint = exports.asLambdaEvent = exports.asLambdaEndpoint = exports.getAskLambdaCacheKey = exports.asCacheWithoutSet = exports.askLambdaEndpoint = exports.LambdaServiceNotFoundError = exports.LambdaIntrospectionNotSupportedError = exports.LambdaIntrospectionBlockedError = exports.LambdaFunctionNotFoundError = exports.LambdaEndpointError = exports.LambdaEndpoint = exports.LambdaDomainObjectRefUnbindableError = exports.LambdaDomainObjectNotCapturableError = exports.LambdaCredentialsAbsentError = exports.HttpStatusCode = exports.GeneratedFile = exports.delLambdaSdks = exports.BadRequestError = void 0;
|
|
13
|
+
exports.runLambdaEndpoint = exports.isLambdaEndpointErrorEnvelopeContemp = exports.isLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointErrorEnvelopeContemp = exports.asLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointOutput = exports.asLambdaContext = exports.asTrailExidHeaders = exports.getOneLambdaContract = exports.getAllLambdaFunctionsByPrefix = exports.getAllLambdaContracts = exports.genServiceSdk = exports.getValidatedOutput = exports.getValidatedInput = exports.genZodOutputValidationMiddleware = exports.genTrailMiddleware = exports.genIoLoggerMiddleware = exports.genIntrospectionMiddleware = exports.genInternalServiceErrorMiddleware = exports.genConstraintErrorMiddleware = exports.asContextTrailed = exports.genZodEventValidationMiddleware = exports.genZodInputValidationMiddleware = exports.genContentTypeCoherenceMiddleware = exports.genApiGatewayRequestEventNormalizationMiddleware = exports.isApiGatewayResponse = exports.asApiGatewayResponseSchema = exports.genLambdaEndpoint = exports.asLambdaEvent = exports.asLambdaEndpoint = exports.getAskLambdaCacheKey = exports.asCacheWithoutSet = exports.askLambdaEndpoint = exports.LambdaServiceNotFoundError = exports.LambdaIntrospectionNotSupportedError = exports.LambdaIntrospectionBlockedError = exports.LambdaFunctionNotFoundError = exports.LambdaEndpointError = exports.LambdaEndpoint = exports.LambdaDomainObjectRefUnbindableError = exports.LambdaDomainObjectNotCapturableError = exports.LambdaCredentialsAbsentError = exports.HttpStatusCode = exports.GeneratedFile = exports.delLambdaSdks = exports.BadRequestError = void 0;
|
|
13
14
|
// re-export from helpful-errors for convenience
|
|
14
15
|
var helpful_errors_1 = require("helpful-errors");
|
|
15
16
|
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return helpful_errors_1.BadRequestError; } });
|
|
@@ -132,6 +133,13 @@ var getAllLambdaFunctionsByPrefix_1 = require("./domain.operations/getAllLambdaC
|
|
|
132
133
|
Object.defineProperty(exports, "getAllLambdaFunctionsByPrefix", { enumerable: true, get: function () { return getAllLambdaFunctionsByPrefix_1.getAllLambdaFunctionsByPrefix; } });
|
|
133
134
|
var getOneLambdaContract_1 = require("./domain.operations/getOneLambdaContract/getOneLambdaContract");
|
|
134
135
|
Object.defineProperty(exports, "getOneLambdaContract", { enumerable: true, get: function () { return getOneLambdaContract_1.getOneLambdaContract; } });
|
|
136
|
+
/**
|
|
137
|
+
* .what = the headers that opt an http request into the contemp dialect, and carry its trail
|
|
138
|
+
* .why = any http client (fetch, axios, ky) spreads this into its request
|
|
139
|
+
* (`domain.terms/x-trail-exid.md`)
|
|
140
|
+
*/
|
|
141
|
+
var asTrailExidHeaders_1 = require("./domain.operations/lambdaEndpointWire/frame/asTrailExidHeaders");
|
|
142
|
+
Object.defineProperty(exports, "asTrailExidHeaders", { enumerable: true, get: function () { return asTrailExidHeaders_1.asTrailExidHeaders; } });
|
|
135
143
|
// test utils — the run boundary axis (run an endpoint by reference, or by slug)
|
|
136
144
|
var asLambdaContext_1 = require("./domain.operations/runLambdaEndpoint/context/asLambdaContext");
|
|
137
145
|
Object.defineProperty(exports, "asLambdaContext", { enumerable: true, get: function () { return asLambdaContext_1.asLambdaContext; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,gDAAgD;AAChD,iDAAiD;AAAxC,iHAAA,eAAe,OAAA;AAQxB;;;;;GAKG;AACH,kEAAkE;AAAzD,6GAAA,aAAa,OAAA;AAWtB,gEAA+D;AAAtD,8GAAA,aAAa,OAAA;AACtB,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AACvB,8FAA6F;AAApF,4IAAA,4BAA4B,OAAA;AACrC,8GAA6G;AAApG,4JAAA,oCAAoC,OAAA;AAC7C,8GAA6G;AAApG,4JAAA,oCAAoC,OAAA;AAC7C,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AAEvB,4EAA2E;AAAlE,0HAAA,mBAAmB,OAAA;AAE5B,4BAA4B;AAC5B,4FAA2F;AAAlF,0IAAA,2BAA2B,OAAA;AACpC,oGAAmG;AAA1F,kJAAA,+BAA+B,OAAA;AACxC,8GAA6G;AAApG,4JAAA,oCAAoC,OAAA;AAC7C,0FAAyF;AAAhF,wIAAA,0BAA0B,OAAA;AAKnC,oBAAoB;AACpB,6FAA4F;AAAnF,sHAAA,iBAAiB,OAAA;AAC1B,mGAAkG;AAAzF,sHAAA,iBAAiB,OAAA;AAC1B,yGAAwG;AAA/F,4HAAA,oBAAoB,OAAA;AAC7B,eAAe;AACf,0FAAyF;A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C/E,4EAA4E;AAC5E,4CAA4C;AAC5C,+GAA8G;AAArG,gIAAA,sBAAsB,OAAA;AAC/B,iFAAiF;AACjF,gFAAgF;AAChF,8EAA8E;AAC9E,0CAA0C;AAC1C,6HAKqF;AAJnF,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AAMtC,6FAA4F;AAAnF,sHAAA,iBAAiB,OAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "sdk-aws-lambda",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "a simple and opinionated sdk for aws lambda. define endpoints, ask endpoints, auto-propagate trace-ids.",
|
|
5
|
-
"version": "0.7.
|
|
5
|
+
"version": "0.7.2",
|
|
6
6
|
"repository": "ehmpathy/sdk-aws-lambda",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/sdk-aws-lambda",
|
|
8
8
|
"keywords": [
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"sdk-environment": "0.1.5",
|
|
74
74
|
"sdk-logs": "0.9.0",
|
|
75
75
|
"simple-in-memory-cache": "0.4.0",
|
|
76
|
-
"type-fns": "1.21.
|
|
76
|
+
"type-fns": "1.21.5",
|
|
77
77
|
"with-simple-cache": "0.15.3",
|
|
78
78
|
"yaml": "2.9.0",
|
|
79
79
|
"zod": "4.4.3"
|
|
@@ -100,14 +100,16 @@
|
|
|
100
100
|
"esbuild": "0.28.1",
|
|
101
101
|
"esbuild-register": "3.6.0",
|
|
102
102
|
"husky": "8.0.3",
|
|
103
|
+
"iso-time": "1.11.7",
|
|
103
104
|
"jest": "30.2.0",
|
|
104
|
-
"rhachet": "1.
|
|
105
|
+
"rhachet": "1.49.2",
|
|
105
106
|
"rhachet-brains-anthropic": "0.4.3",
|
|
106
107
|
"rhachet-brains-fireworksai": "0.2.3",
|
|
108
|
+
"rhachet-brains-openrouter": "0.1.3",
|
|
107
109
|
"rhachet-brains-xai": "0.3.3",
|
|
108
|
-
"rhachet-roles-bhrain": "0.
|
|
109
|
-
"rhachet-roles-bhuild": "0.
|
|
110
|
-
"rhachet-roles-ehmpathy": "1.39.
|
|
110
|
+
"rhachet-roles-bhrain": "0.39.3",
|
|
111
|
+
"rhachet-roles-bhuild": "0.23.2",
|
|
112
|
+
"rhachet-roles-ehmpathy": "1.39.5",
|
|
111
113
|
"rhachet-roles-rhachet": "0.1.7",
|
|
112
114
|
"test-fns": "1.15.8",
|
|
113
115
|
"tsc-alias": "1.8.10",
|
package/readme.md
CHANGED
|
@@ -171,6 +171,33 @@ const result = await askLambdaEndpoint<TRequest, TResponse>(
|
|
|
171
171
|
|
|
172
172
|
the caller's `trail.exid` rides along, so logs correlate across the call.
|
|
173
173
|
|
|
174
|
+
### ask an api gateway endpoint, over http
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
import { askLambdaEndpoint } from 'sdk-aws-lambda';
|
|
178
|
+
|
|
179
|
+
const { status, body } = await askLambdaEndpoint.viaApiGateway<TResponse>(
|
|
180
|
+
{ url: 'https://api.example.com/jobs', method: 'POST', body: { uuid } },
|
|
181
|
+
{ log },
|
|
182
|
+
);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
takes the standard http request: `{ url, method, headers, body }`. an object `body` is sent as json.
|
|
186
|
+
|
|
187
|
+
it resolves `{ status, headers, text, body }`. a 4xx throws a `ConstraintError`; a 5xx throws a
|
|
188
|
+
`MalfunctionError` that carries the `correlationId`. your trail rides the request, so the endpoint's
|
|
189
|
+
logs join yours.
|
|
190
|
+
|
|
191
|
+
any other http client spreads the `x-trail-exid` header in to send the trail. the header also opts the
|
|
192
|
+
caller in to the contemp error body (`{ error: { class, … } }`); without it the endpoint answers the flat
|
|
193
|
+
`{ errorMessage, errorType }`:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { asTrailExidHeaders } from 'sdk-aws-lambda';
|
|
197
|
+
|
|
198
|
+
await fetch(url, { headers: { ...asTrailExidHeaders({ trail: { exid } }) } });
|
|
199
|
+
```
|
|
200
|
+
|
|
174
201
|
## run an endpoint, in a test
|
|
175
202
|
|
|
176
203
|
| you call | you hold | a caller fault arrives as |
|
|
@@ -234,12 +261,27 @@ await runLambdaEndpoint.onReferenced({
|
|
|
234
261
|
|
|
235
262
|
| dialect | your handler receives | your handler answers |
|
|
236
263
|
|---|---|---|
|
|
237
|
-
| `contemp` (default) | `{ event, trail }` | the nested `{ error: { class, … } }` |
|
|
264
|
+
| `contemp` (default) | `{ event, trail }` — for an event built with `asLambdaEvent.fromApiGateway`, the event itself with an `x-trail-exid` header | the nested `{ error: { class, … } }` |
|
|
238
265
|
| `ancient` | the event, untouched | the flat `{ errorMessage, errorType }` |
|
|
239
266
|
|
|
240
267
|
a `genLambdaEndpoint` handler never notices — its middleware unwraps the frame first. a plain
|
|
241
268
|
handler does: under the contemp default it reads its own fields off a wrapper and finds them absent.
|
|
242
269
|
|
|
270
|
+
an api gateway endpoint is the exception: aws delivers its event unwrapped, so `runLambdaEndpoint`
|
|
271
|
+
carries the contemp opt-in in the event's `x-trail-exid` header instead of a wrapper. the endpoint a
|
|
272
|
+
`genLambdaEndpoint` builder returned declares which carrier it reads, so any event you hand it is
|
|
273
|
+
framed right: a built event, a spread copy, a hand-built or captured request.
|
|
274
|
+
|
|
275
|
+
the one road that holds no endpoint is `runLambdaEndpoint.onSerialized({ at: 'cloud' })`: it reads a
|
|
276
|
+
mark `asLambdaEvent.fromApiGateway` leaves on the event, so send the event as built. a copy (spread,
|
|
277
|
+
`structuredClone`, a json round trip) loses the mark and fails loud with the fix: pass the change to
|
|
278
|
+
`asLambdaEvent.fromApiGateway` (`headers`, `requestContext`, `path`, …) rather than a copy. a raw event
|
|
279
|
+
captured from aws goes through `struct: { payload: 'ancient' }` and arrives as sent, with any
|
|
280
|
+
`x-trail-exid` header it holds.
|
|
281
|
+
|
|
282
|
+
a `forApiGateway` endpoint adds `x-trail-exid` to its cors `allow-headers`, since a browser caller
|
|
283
|
+
that sends it triggers a preflight.
|
|
284
|
+
|
|
243
285
|
## build an event for a source
|
|
244
286
|
|
|
245
287
|
`asLambdaEvent` casts a payload into the envelope aws actually delivers, wire-faithful by default:
|