sdk-aws-lambda 0.7.1 → 0.7.3

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.
Files changed (153) hide show
  1. package/dist/domain.objects/TrailCarrier.d.ts +17 -0
  2. package/dist/domain.objects/TrailCarrier.js +3 -0
  3. package/dist/domain.objects/TrailCarrier.js.map +1 -0
  4. package/dist/domain.objects/TrailExidHeader.d.ts +10 -0
  5. package/dist/domain.objects/TrailExidHeader.js +14 -0
  6. package/dist/domain.objects/TrailExidHeader.js.map +1 -0
  7. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.js +15 -1
  8. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.js.map +1 -1
  9. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.d.ts +50 -27
  10. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js +18 -61
  11. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js.map +1 -1
  12. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.d.ts +35 -0
  13. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.js +80 -0
  14. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.js.map +1 -0
  15. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.d.ts +37 -0
  16. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.js +70 -0
  17. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.js.map +1 -0
  18. package/dist/domain.operations/askLambdaEndpoint/invoke/executeHttpRequest.d.ts +17 -0
  19. package/dist/domain.operations/askLambdaEndpoint/invoke/executeHttpRequest.js +34 -0
  20. package/dist/domain.operations/askLambdaEndpoint/invoke/executeHttpRequest.js.map +1 -0
  21. package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.d.ts +31 -0
  22. package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.js +55 -0
  23. package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.js.map +1 -0
  24. package/dist/domain.operations/askLambdaEndpoint/serde/asHeadersRecord.d.ts +13 -0
  25. package/dist/domain.operations/askLambdaEndpoint/serde/asHeadersRecord.js +22 -0
  26. package/dist/domain.operations/askLambdaEndpoint/serde/asHeadersRecord.js.map +1 -0
  27. package/dist/domain.operations/askLambdaEndpoint/serde/asHttpMethod.d.ts +16 -0
  28. package/dist/domain.operations/askLambdaEndpoint/serde/asHttpMethod.js +22 -0
  29. package/dist/domain.operations/askLambdaEndpoint/serde/asHttpMethod.js.map +1 -0
  30. package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestBody.d.ts +17 -0
  31. package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestBody.js +28 -0
  32. package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestBody.js.map +1 -0
  33. package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestHeaders.d.ts +23 -0
  34. package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestHeaders.js +39 -0
  35. package/dist/domain.operations/askLambdaEndpoint/serde/asHttpRequestHeaders.js.map +1 -0
  36. package/dist/domain.operations/askLambdaEndpoint/serde/getOneBodyFromHttpText.d.ts +10 -0
  37. package/dist/domain.operations/askLambdaEndpoint/serde/getOneBodyFromHttpText.js +19 -0
  38. package/dist/domain.operations/askLambdaEndpoint/serde/getOneBodyFromHttpText.js.map +1 -0
  39. package/dist/domain.operations/askLambdaEndpoint/serde/getOneCorrelationIdFromBody.d.ts +11 -0
  40. package/dist/domain.operations/askLambdaEndpoint/serde/getOneCorrelationIdFromBody.js +19 -0
  41. package/dist/domain.operations/askLambdaEndpoint/serde/getOneCorrelationIdFromBody.js.map +1 -0
  42. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asCorsHeadersWithTrail.d.ts +12 -0
  43. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asCorsHeadersWithTrail.js +27 -0
  44. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asCorsHeadersWithTrail.js.map +1 -0
  45. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +3 -0
  46. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +32 -7
  47. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
  48. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayRequestEventNormalizationMiddleware.js +22 -0
  49. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayRequestEventNormalizationMiddleware.js.map +1 -1
  50. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js +13 -2
  51. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js.map +1 -1
  52. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.d.ts +14 -0
  53. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.js +20 -0
  54. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.js.map +1 -0
  55. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.d.ts +9 -0
  56. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.js +13 -0
  57. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.js.map +1 -0
  58. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.d.ts +10 -0
  59. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.js +11 -0
  60. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.js.map +1 -0
  61. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.d.ts +9 -3
  62. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js +40 -38
  63. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js.map +1 -1
  64. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.d.ts +12 -6
  65. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js +59 -35
  66. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js.map +1 -1
  67. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.d.ts +20 -7
  68. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js +21 -9
  69. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js.map +1 -1
  70. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.d.ts +19 -0
  71. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.js +22 -0
  72. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.js.map +1 -0
  73. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.d.ts +11 -0
  74. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.js +13 -0
  75. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.js.map +1 -0
  76. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.d.ts +11 -0
  77. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.js +18 -0
  78. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.js.map +1 -0
  79. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.d.ts +8 -0
  80. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.js +14 -0
  81. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.js.map +1 -0
  82. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.d.ts +15 -0
  83. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.js +22 -0
  84. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.js.map +1 -0
  85. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.d.ts +27 -0
  86. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.js +33 -0
  87. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.js.map +1 -0
  88. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.d.ts +6 -5
  89. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js +6 -5
  90. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js.map +1 -1
  91. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.d.ts +31 -0
  92. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js +46 -0
  93. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js.map +1 -0
  94. package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.d.ts +15 -8
  95. package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js +57 -12
  96. package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js.map +1 -1
  97. package/dist/domain.operations/lambdaEndpointWire/frame/asHeadersWithoutKey.d.ts +11 -0
  98. package/dist/domain.operations/lambdaEndpointWire/frame/asHeadersWithoutKey.js +13 -0
  99. package/dist/domain.operations/lambdaEndpointWire/frame/asHeadersWithoutKey.js.map +1 -0
  100. package/dist/domain.operations/lambdaEndpointWire/frame/asTrailExidHeaders.d.ts +23 -0
  101. package/dist/domain.operations/lambdaEndpointWire/frame/asTrailExidHeaders.js +32 -0
  102. package/dist/domain.operations/lambdaEndpointWire/frame/asTrailExidHeaders.js.map +1 -0
  103. package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfEvent.d.ts +20 -0
  104. package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfEvent.js +23 -0
  105. package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfEvent.js.map +1 -0
  106. package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfHandler.d.ts +9 -0
  107. package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfHandler.js +19 -0
  108. package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailCarrierOfHandler.js.map +1 -0
  109. package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailExidFromHeaders.d.ts +16 -0
  110. package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailExidFromHeaders.js +24 -0
  111. package/dist/domain.operations/lambdaEndpointWire/frame/getOneTrailExidFromHeaders.js.map +1 -0
  112. package/dist/domain.operations/lambdaEndpointWire/frame/isEventDeclaredAsApiGateway.d.ts +9 -0
  113. package/dist/domain.operations/lambdaEndpointWire/frame/isEventDeclaredAsApiGateway.js +15 -0
  114. package/dist/domain.operations/lambdaEndpointWire/frame/isEventDeclaredAsApiGateway.js.map +1 -0
  115. package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExid.d.ts +19 -0
  116. package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExid.js +27 -0
  117. package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExid.js.map +1 -0
  118. package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExidHeaderMalformed.d.ts +11 -0
  119. package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExidHeaderMalformed.js +21 -0
  120. package/dist/domain.operations/lambdaEndpointWire/frame/isTrailExidHeaderMalformed.js.map +1 -0
  121. package/dist/domain.operations/lambdaEndpointWire/frame/setEventDeclaredAsApiGateway.d.ts +21 -0
  122. package/dist/domain.operations/lambdaEndpointWire/frame/setEventDeclaredAsApiGateway.js +27 -0
  123. package/dist/domain.operations/lambdaEndpointWire/frame/setEventDeclaredAsApiGateway.js.map +1 -0
  124. package/dist/domain.operations/lambdaEndpointWire/frame/setHandlerTrailCarrier.d.ts +24 -0
  125. package/dist/domain.operations/lambdaEndpointWire/frame/setHandlerTrailCarrier.js +28 -0
  126. package/dist/domain.operations/lambdaEndpointWire/frame/setHandlerTrailCarrier.js.map +1 -0
  127. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.d.ts +6 -1
  128. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js +6 -1
  129. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js.map +1 -1
  130. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.d.ts +7 -0
  131. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js +18 -2
  132. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js.map +1 -1
  133. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js +43 -7
  134. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js.map +1 -1
  135. package/dist/domain.operations/runLambdaEndpoint/serde/asCarriedPayload.d.ts +35 -0
  136. package/dist/domain.operations/runLambdaEndpoint/serde/asCarriedPayload.js +81 -0
  137. package/dist/domain.operations/runLambdaEndpoint/serde/asCarriedPayload.js.map +1 -0
  138. package/dist/domain.operations/runLambdaEndpoint/serde/asErrorTypeOfErrorLike.d.ts +41 -0
  139. package/dist/domain.operations/runLambdaEndpoint/serde/asErrorTypeOfErrorLike.js +116 -0
  140. package/dist/domain.operations/runLambdaEndpoint/serde/asErrorTypeOfErrorLike.js.map +1 -0
  141. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js +52 -17
  142. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js.map +1 -1
  143. package/dist/domain.operations/runLambdaEndpoint/serde/getOneTrailWithExid.d.ts +14 -0
  144. package/dist/domain.operations/runLambdaEndpoint/serde/getOneTrailWithExid.js +18 -0
  145. package/dist/domain.operations/runLambdaEndpoint/serde/getOneTrailWithExid.js.map +1 -0
  146. package/dist/domain.operations/runLambdaEndpoint/serde/isEventWithHeaders.d.ts +17 -0
  147. package/dist/domain.operations/runLambdaEndpoint/serde/isEventWithHeaders.js +19 -0
  148. package/dist/domain.operations/runLambdaEndpoint/serde/isEventWithHeaders.js.map +1 -0
  149. package/dist/index.d.ts +8 -1
  150. package/dist/index.js +10 -2
  151. package/dist/index.js.map +1 -1
  152. package/package.json +6 -6
  153. package/readme.md +65 -4
package/readme.md CHANGED
@@ -152,10 +152,24 @@ export const handler = genLambdaEndpoint.forSqs.perBatch({
152
152
  });
153
153
  ```
154
154
 
155
- `perBatch` fails safe: any record not returned in `successes` is retried, and an answer the sdk
156
- cannot read retries the whole batch. its event source must declare
155
+ `perBatch` fails safe: any record neither returned in `successes` nor refused by the schema is
156
+ retried, and an answer the sdk cannot read retries the whole batch. its event source must declare
157
157
  `functionResponseTypes: ['ReportBatchItemFailures']`.
158
158
 
159
+ a caller fault is never retried. a message the schema refuses, or a `ConstraintError` (or
160
+ `BadRequestError`) a `perRecord` handler throws, logs `sqs.record.refused` at warn and is deleted,
161
+ with no dead-letter entry. to retry a fault, throw a `MalfunctionError`; every other throw redrives.
162
+
163
+ - `sqs.record.refused` carries the full message as delivered (`message`: body, attributes, queue
164
+ arn), so an operator can requeue it from the log. alarm on its volume: a schema bug of ours
165
+ deletes messages, and no dead-letter queue holds them
166
+ - `sqs.record.invalid` (error) marks a schema callback that threw a fault of ours; that record retries
167
+ - a `perBatch` handler throw redrives the whole batch, refused records too. to drop a record, return
168
+ it in `successes`, and log it yourself. when the schema refuses every record, the handler gets
169
+ `records: []`
170
+ - to test a refusal: the invoke succeeds with no answer, so assert the handler did not run and spy
171
+ `console.warn` for `sqs.record.refused`
172
+
159
173
  ⇒ zoom in: [records](./.agent/repo=.this/role=any/briefs/domain.terms/records.md)
160
174
 
161
175
  ## ask an endpoint
@@ -171,6 +185,33 @@ const result = await askLambdaEndpoint<TRequest, TResponse>(
171
185
 
172
186
  the caller's `trail.exid` rides along, so logs correlate across the call.
173
187
 
188
+ ### ask an api gateway endpoint, over http
189
+
190
+ ```ts
191
+ import { askLambdaEndpoint } from 'sdk-aws-lambda';
192
+
193
+ const { status, body } = await askLambdaEndpoint.viaApiGateway<TResponse>(
194
+ { url: 'https://api.example.com/jobs', method: 'POST', body: { uuid } },
195
+ { log },
196
+ );
197
+ ```
198
+
199
+ takes the standard http request: `{ url, method, headers, body }`. an object `body` is sent as json.
200
+
201
+ it resolves `{ status, headers, text, body }`. a 4xx throws a `ConstraintError`; a 5xx throws a
202
+ `MalfunctionError` that carries the `correlationId`. your trail rides the request, so the endpoint's
203
+ logs join yours.
204
+
205
+ any other http caller spreads the `x-trail-exid` header in to send the trail. the header also opts the
206
+ caller in to the contemp error body (`{ error: { class, … } }`); without it the endpoint answers the flat
207
+ `{ errorMessage, errorType }`:
208
+
209
+ ```ts
210
+ import { asTrailExidHeaders } from 'sdk-aws-lambda';
211
+
212
+ await fetch(url, { headers: { ...asTrailExidHeaders({ trail: { exid } }) } });
213
+ ```
214
+
174
215
  ## run an endpoint, in a test
175
216
 
176
217
  | you call | you hold | a caller fault arrives as |
@@ -208,6 +249,11 @@ await expect(
208
249
 
209
250
  a malfunction throws on both. the util adds no `catch`.
210
251
 
252
+ `'local'` labels an escaped throw by its `.name`, as the aws runtime does. a `forAsk` or
253
+ `forApiGateway` endpoint answers a `ConstraintError` by class, so its caller reads a caller fault on
254
+ both loci. a raw handler's throw reads as its `.name` says: helpful-errors 1.7.3's `ConstraintError`
255
+ reads `'Error'`, so it arrives as a server fault, locally and on the cloud (cure: helpful-errors#47).
256
+
211
257
  the return is a union — `TOutput | Envelope` — so read either arm through a narrow:
212
258
 
213
259
  ```ts
@@ -234,12 +280,27 @@ await runLambdaEndpoint.onReferenced({
234
280
 
235
281
  | dialect | your handler receives | your handler answers |
236
282
  |---|---|---|
237
- | `contemp` (default) | `{ event, trail }` | the nested `{ error: { class, … } }` |
283
+ | `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
284
  | `ancient` | the event, untouched | the flat `{ errorMessage, errorType }` |
239
285
 
240
286
  a `genLambdaEndpoint` handler never notices — its middleware unwraps the frame first. a plain
241
287
  handler does: under the contemp default it reads its own fields off a wrapper and finds them absent.
242
288
 
289
+ an api gateway endpoint is the exception: aws delivers its event unwrapped, so `runLambdaEndpoint`
290
+ carries the contemp opt-in in the event's `x-trail-exid` header instead of a wrapper. the endpoint a
291
+ `genLambdaEndpoint` builder returned declares which carrier it reads, so any event you hand it is
292
+ framed right: a built event, a spread copy, a hand-built or captured request.
293
+
294
+ the one road that holds no endpoint is `runLambdaEndpoint.onSerialized({ at: 'cloud' })`: it reads a
295
+ mark `asLambdaEvent.fromApiGateway` leaves on the event, so send the event as built. a copy (spread,
296
+ `structuredClone`, a json round trip) loses the mark and fails loud with the fix: pass the change to
297
+ `asLambdaEvent.fromApiGateway` (`headers`, `requestContext`, `path`, …) rather than a copy. a raw event
298
+ captured from aws goes through `struct: { payload: 'ancient' }` and arrives as sent, with any
299
+ `x-trail-exid` header it holds.
300
+
301
+ a `forApiGateway` endpoint adds `x-trail-exid` to its cors `allow-headers`, since a browser caller
302
+ that sends it triggers a preflight.
303
+
243
304
  ## build an event for a source
244
305
 
245
306
  `asLambdaEvent` casts a payload into the envelope aws actually delivers, wire-faithful by default:
@@ -328,7 +389,7 @@ schema: {
328
389
  a value that fails the domain object's own constructor **fails loud at the border** and never reaches
329
390
  `invoke` half-built.
330
391
 
331
- what a caller of your generated cross-service client sees is the **wire** shape —
392
+ what a caller of your generated cross-service sdk sees is the **wire** shape —
332
393
  `{ surfer: { uuid, name } }` — never the instance. the two differ by design: the wire is what
333
394
  crosses, the instance is what you hold once through.
334
395