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
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllSqsIdsRetried = void 0;
4
+ /**
5
+ * .what = the ids sqs must retry: every delivered record neither claimed as a success nor refused
6
+ * .why = fail safe by construction — a record the handler did not vouch for is retried, never
7
+ * deleted. a record the schema refused is a caller fault, so it is acknowledged and left
8
+ * out (`invariant.constraint-errors-never-redrive-sqs`)
9
+ *
10
+ * .note = retry is the default for every record this does not exclude, so a server fault met at
11
+ * validation needs no list of its own — it is simply never excluded
12
+ * .note = deduped, since sqs reads each id once
13
+ */
14
+ const getAllSqsIdsRetried = (input) => {
15
+ const idsSucceeded = new Set(input.successes.map((success) => success.id));
16
+ const isRetried = (id) => !idsSucceeded.has(id) && !input.idsRefused.has(id);
17
+ return [
18
+ ...new Set(input.records.map((record) => record.id).filter(isRetried)),
19
+ ];
20
+ };
21
+ exports.getAllSqsIdsRetried = getAllSqsIdsRetried;
22
+ //# sourceMappingURL=getAllSqsIdsRetried.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllSqsIdsRetried.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAInC,EAAY,EAAE;IACb,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,CAAC,EAAU,EAAW,EAAE,CACxC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrD,OAAO;QACL,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;KACvE,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * .what = the ids a perBatch answer claims that the handler was never handed
3
+ * .why = a claim on a record outside the validated set — a forged id, or one drawn from
4
+ * `event.records` — would delete a message no handler served, so each must be refused
5
+ */
6
+ export declare const getAllSqsIdsUnclaimable: (input: {
7
+ successes: ReadonlyArray<{
8
+ id: string;
9
+ }>;
10
+ idsClaimable: ReadonlySet<string>;
11
+ }) => string[];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllSqsIdsUnclaimable = void 0;
4
+ /**
5
+ * .what = the ids a perBatch answer claims that the handler was never handed
6
+ * .why = a claim on a record outside the validated set — a forged id, or one drawn from
7
+ * `event.records` — would delete a message no handler served, so each must be refused
8
+ */
9
+ const getAllSqsIdsUnclaimable = (input) => input.successes
10
+ .map((success) => success.id)
11
+ .filter((id) => !input.idsClaimable.has(id));
12
+ exports.getAllSqsIdsUnclaimable = getAllSqsIdsUnclaimable;
13
+ //# sourceMappingURL=getAllSqsIdsUnclaimable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllSqsIdsUnclaimable.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAGvC,EAAY,EAAE,CACb,KAAK,CAAC,SAAS;KACZ,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KAC5B,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AANpC,QAAA,uBAAuB,2BAMa"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * .what = the entries of a perBatch answer that carry no string `id`, each with its position
3
+ * .why = sqs can delete only by id, so an entry without one is no success at all. the position
4
+ * lets the refusal name exactly which entries the handler got wrong
5
+ */
6
+ export declare const getAllSqsSuccessRefsMalformed: (input: {
7
+ successes: ReadonlyArray<unknown>;
8
+ }) => {
9
+ index: number;
10
+ got: string;
11
+ }[];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllSqsSuccessRefsMalformed = void 0;
4
+ const isSqsSuccessRef_1 = require("./isSqsSuccessRef");
5
+ /**
6
+ * .what = the entries of a perBatch answer that carry no string `id`, each with its position
7
+ * .why = sqs can delete only by id, so an entry without one is no success at all. the position
8
+ * lets the refusal name exactly which entries the handler got wrong
9
+ */
10
+ const getAllSqsSuccessRefsMalformed = (input) => input.successes
11
+ .map((success, index) => ({ index, success }))
12
+ .filter(({ success }) => !(0, isSqsSuccessRef_1.isSqsSuccessRef)(success))
13
+ .map(({ index, success }) => ({
14
+ index,
15
+ got: success === null ? 'null' : typeof success,
16
+ }));
17
+ exports.getAllSqsSuccessRefsMalformed = getAllSqsSuccessRefsMalformed;
18
+ //# sourceMappingURL=getAllSqsSuccessRefsMalformed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllSqsSuccessRefsMalformed.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAEpD;;;;GAIG;AACI,MAAM,6BAA6B,GAAG,CAAC,KAE7C,EAAoC,EAAE,CACrC,KAAK,CAAC,SAAS;KACZ,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;KAC7C,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,IAAA,iCAAe,EAAC,OAAO,CAAC,CAAC;KAClD,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAC5B,KAAK;IACL,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,OAAO;CAChD,CAAC,CAAC,CAAC;AATK,QAAA,6BAA6B,iCASlC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * .what = whether a value is one sqs can delete by: an object with a string `id`
3
+ * .why = a perBatch answer is read at runtime, so a js caller or an `any` site can hand over a
4
+ * bare id string, a `null`, or an object with no `id` — none of which names a message
5
+ */
6
+ export declare const isSqsSuccessRef: (value: unknown) => value is {
7
+ id: string;
8
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSqsSuccessRef = void 0;
4
+ /**
5
+ * .what = whether a value is one sqs can delete by: an object with a string `id`
6
+ * .why = a perBatch answer is read at runtime, so a js caller or an `any` site can hand over a
7
+ * bare id string, a `null`, or an object with no `id` — none of which names a message
8
+ */
9
+ const isSqsSuccessRef = (value) => typeof value === 'object' &&
10
+ value !== null &&
11
+ 'id' in value &&
12
+ typeof value.id === 'string';
13
+ exports.isSqsSuccessRef = isSqsSuccessRef;
14
+ //# sourceMappingURL=isSqsSuccessRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSqsSuccessRef.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAAC,KAAc,EAA2B,EAAE,CACzE,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,IAAI,IAAI,KAAK;IACb,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,CAAC;AAJlB,QAAA,eAAe,mBAIG"}
@@ -0,0 +1,15 @@
1
+ import type { ContextLogTrail } from 'sdk-logs';
2
+ /**
3
+ * .what = records that one sqs record met a fault of ours in validation, and is retried
4
+ * .why = the record redrives, so without a loud line a schema defect hides behind retries. this
5
+ * names the message, the class, the cause, and the stack, so an on-call engineer can find it
6
+ *
7
+ * .note = error, not warn: the fault is ours — a schema whose own callback threw — never the
8
+ * producer's. the peer `logSqsRecordRefused` is the warn for a caller fault
9
+ */
10
+ export declare const logSqsRecordInvalid: (input: {
11
+ id: string;
12
+ error: Error;
13
+ }, context: {
14
+ log: Pick<ContextLogTrail['log'], 'error'>;
15
+ }) => void;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logSqsRecordInvalid = void 0;
4
+ /**
5
+ * .what = records that one sqs record met a fault of ours in validation, and is retried
6
+ * .why = the record redrives, so without a loud line a schema defect hides behind retries. this
7
+ * names the message, the class, the cause, and the stack, so an on-call engineer can find it
8
+ *
9
+ * .note = error, not warn: the fault is ours — a schema whose own callback threw — never the
10
+ * producer's. the peer `logSqsRecordRefused` is the warn for a caller fault
11
+ */
12
+ const logSqsRecordInvalid = (input, context) => {
13
+ context.log.error('sqs.record.invalid', {
14
+ id: input.id,
15
+ class: input.error.constructor.name,
16
+ errorMessage: input.error.message,
17
+ stack: input.error.stack ?? null,
18
+ consequence: 'redriven — a fault of ours, so sqs redrives this record alone',
19
+ });
20
+ };
21
+ exports.logSqsRecordInvalid = logSqsRecordInvalid;
22
+ //# sourceMappingURL=logSqsRecordInvalid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSqsRecordInvalid.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACI,MAAM,mBAAmB,GAAG,CACjC,KAAmC,EACnC,OAAuD,EACjD,EAAE;IACR,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,EAAE;QACtC,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI;QACnC,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;QACjC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI;QAChC,WAAW,EACT,+DAA+D;KAClE,CAAC,CAAC;AACL,CAAC,CAAC;AAZW,QAAA,mBAAmB,uBAY9B"}
@@ -0,0 +1,27 @@
1
+ import type { SQSRecord } from 'aws-lambda';
2
+ import type { ContextLogTrail } from 'sdk-logs';
3
+ /**
4
+ * .what = records that one sqs message was refused as a caller fault, and acknowledged
5
+ * .why = an acknowledged message is deleted from the queue, so this line is the one durable trace
6
+ * of it. it names the message, the class, and the cause, so an operator can find the
7
+ * producer at fault, and it carries the full message as it arrived, so an operator can
8
+ * requeue it from the log alone
9
+ *
10
+ * .note = `message` is the untouched `SQSRecord` aws handed over (`record._.raw`), never the
11
+ * decoded record: validation writes parsed values back into the decoded record, so only
12
+ * the raw one still holds the wire body and the typed `messageAttributes` a requeue needs.
13
+ * its `attributes` carry the fifo `MessageGroupId` and `MessageDeduplicationId`, and its
14
+ * `eventSourceARN` names the queue to requeue into
15
+ * .note = `class` reads `constructor.name`, the in-process class, and differs from the wire's
16
+ * `errorType` (`.name`) on purpose: an operator searches for the class the author threw,
17
+ * and helpful-errors 1.7.3 leaves `.name` at `'Error'` for every refusal. the wire must
18
+ * match the aws runtime; this line must name the cause. neither should copy the other
19
+ * .note = warn, not error: the lambda ran as intended and the producer is at fault, so the invoke
20
+ * is a success, exactly as `simple-lambda-handlers`' `badRequestErrorMiddleware` treated it
21
+ */
22
+ export declare const logSqsRecordRefused: (input: {
23
+ message: SQSRecord;
24
+ error: Error;
25
+ }, context: {
26
+ log: Pick<ContextLogTrail['log'], 'warn'>;
27
+ }) => void;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logSqsRecordRefused = void 0;
4
+ /**
5
+ * .what = records that one sqs message was refused as a caller fault, and acknowledged
6
+ * .why = an acknowledged message is deleted from the queue, so this line is the one durable trace
7
+ * of it. it names the message, the class, and the cause, so an operator can find the
8
+ * producer at fault, and it carries the full message as it arrived, so an operator can
9
+ * requeue it from the log alone
10
+ *
11
+ * .note = `message` is the untouched `SQSRecord` aws handed over (`record._.raw`), never the
12
+ * decoded record: validation writes parsed values back into the decoded record, so only
13
+ * the raw one still holds the wire body and the typed `messageAttributes` a requeue needs.
14
+ * its `attributes` carry the fifo `MessageGroupId` and `MessageDeduplicationId`, and its
15
+ * `eventSourceARN` names the queue to requeue into
16
+ * .note = `class` reads `constructor.name`, the in-process class, and differs from the wire's
17
+ * `errorType` (`.name`) on purpose: an operator searches for the class the author threw,
18
+ * and helpful-errors 1.7.3 leaves `.name` at `'Error'` for every refusal. the wire must
19
+ * match the aws runtime; this line must name the cause. neither should copy the other
20
+ * .note = warn, not error: the lambda ran as intended and the producer is at fault, so the invoke
21
+ * is a success, exactly as `simple-lambda-handlers`' `badRequestErrorMiddleware` treated it
22
+ */
23
+ const logSqsRecordRefused = (input, context) => {
24
+ context.log.warn('sqs.record.refused', {
25
+ id: input.message.messageId,
26
+ class: input.error.constructor.name,
27
+ errorMessage: input.error.message,
28
+ consequence: 'deleted only if this invoke succeeds; redriven if it fails',
29
+ message: input.message,
30
+ });
31
+ };
32
+ exports.logSqsRecordRefused = logSqsRecordRefused;
33
+ //# sourceMappingURL=logSqsRecordRefused.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logSqsRecordRefused.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,mBAAmB,GAAG,CACjC,KAA2C,EAC3C,OAAsD,EAChD,EAAE;IACR,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE;QACrC,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS;QAC3B,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI;QACnC,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;QACjC,WAAW,EAAE,4DAA4D;QACzE,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC;AACL,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B"}
@@ -9,15 +9,16 @@ import type { SqsHeadersDeclared, SqsHeadersMerged, SqsRecordDecoded } from './S
9
9
  * the record stale, silently (`domain.terms/headers.md`)
10
10
  *
11
11
  * .why one transformer for both variants = they differ in what they do with a failure, never in
12
- * what counts as one. `perRecord` lets the throw escape, so the invoke fails and sqs
13
- * redrives the message; `perBatch` catches it and reports that id as a batch item failure.
14
- * a second implementation would let the two definitions of valid drift
12
+ * what counts as one. a refusal is a caller fault, so each variant acknowledges it:
13
+ * `perRecord` catches it around the whole serve and returns; `perBatch` catches it per
14
+ * record and leaves that id out of `batchItemFailures`. a second implementation would let
15
+ * the two definitions of valid drift
15
16
  * (`rule.forbid.parallel-codepaths`)
16
17
  *
17
18
  * .why it throws rather than returns a result = the validation error carries the zod issue
18
19
  * summary, and a `{ ok, error }` return would make every caller restate the throw.
19
- * `perBatch`, the one caller that must not propagate it, catches it at its own record
20
- * boundary — which is where the disposition belongs
20
+ * each caller catches it at its own boundary — the serve for `perRecord`, the record for
21
+ * `perBatch` — which is where the disposition belongs
21
22
  *
22
23
  * .defect = LIVE, NOT FIXED — `getValidationError`'s strict-headers hint names api gateway, and
23
24
  * one of its four clauses is false here: "api gateway injects keys you did not declare".
@@ -11,15 +11,16 @@ const getValidatedInput_1 = require("../middleware/getValidatedInput");
11
11
  * the record stale, silently (`domain.terms/headers.md`)
12
12
  *
13
13
  * .why one transformer for both variants = they differ in what they do with a failure, never in
14
- * what counts as one. `perRecord` lets the throw escape, so the invoke fails and sqs
15
- * redrives the message; `perBatch` catches it and reports that id as a batch item failure.
16
- * a second implementation would let the two definitions of valid drift
14
+ * what counts as one. a refusal is a caller fault, so each variant acknowledges it:
15
+ * `perRecord` catches it around the whole serve and returns; `perBatch` catches it per
16
+ * record and leaves that id out of `batchItemFailures`. a second implementation would let
17
+ * the two definitions of valid drift
17
18
  * (`rule.forbid.parallel-codepaths`)
18
19
  *
19
20
  * .why it throws rather than returns a result = the validation error carries the zod issue
20
21
  * summary, and a `{ ok, error }` return would make every caller restate the throw.
21
- * `perBatch`, the one caller that must not propagate it, catches it at its own record
22
- * boundary — which is where the disposition belongs
22
+ * each caller catches it at its own boundary — the serve for `perRecord`, the record for
23
+ * `perBatch` — which is where the disposition belongs
23
24
  *
24
25
  * .defect = LIVE, NOT FIXED — `getValidationError`'s strict-headers hint names api gateway, and
25
26
  * one of its four clauses is false here: "api gateway injects keys you did not declare".
@@ -1 +1 @@
1
- {"version":3,"file":"setSqsRecordValidated.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.ts"],"names":[],"mappings":";;;AAEA,uEAAoE;AAOpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACI,MAAM,qBAAqB,GAAG,CAGnC,KAGD,EAGE,EAAE;IACH,MAAM,UAAU,GAAG,IAAA,qCAAiB,EAAC;QACnC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;KACxE,CAAC,CAAC;IAEH;;;OAGG;IAEH;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;IAE1E;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IAE1C;;;;;;OAMG;IACH,OAAO,KAAK,CAAC,MAGX,CAAC;AACL,CAAC,CAAC;AAtDW,QAAA,qBAAqB,yBAsDhC"}
1
+ {"version":3,"file":"setSqsRecordValidated.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.ts"],"names":[],"mappings":";;;AAEA,uEAAoE;AAOpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACI,MAAM,qBAAqB,GAAG,CAGnC,KAGD,EAGE,EAAE;IACH,MAAM,UAAU,GAAG,IAAA,qCAAiB,EAAC;QACnC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;KACxE,CAAC,CAAC;IAEH;;;OAGG;IAEH;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;IAE1E;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IAE1C;;;;;;OAMG;IACH,OAAO,KAAK,CAAC,MAGX,CAAC;AACL,CAAC,CAAC;AAtDW,QAAA,qBAAqB,yBAsDhC"}
@@ -0,0 +1,31 @@
1
+ import type { ContextLogTrail } from 'sdk-logs';
2
+ import type { ZodSchema } from 'zod';
3
+ import type { SqsHeadersDeclared, SqsHeadersMerged, SqsRecordDecoded } from './SqsEventDecoded';
4
+ /**
5
+ * .what = validates each record of a batch, and sorts the ones that fail by whose fault it is
6
+ * .why = `perBatch` decides per record, so a refusal must be read where its id is in hand:
7
+ * - a caller fault is acknowledged — logged, and named in `idsRefused` so it stays out of
8
+ * `batchItemFailures` and sqs deletes it once (`invariant.constraint-errors-never-redrive-sqs`)
9
+ * - a server fault (a schema whose own callback throws) is logged loud and named in neither
10
+ * list, so that record alone is retried — one defect of ours never redrives the healthy
11
+ * records beside it
12
+ * - a throw that is not an `Error` carries no verdict on any record, so it escapes and the
13
+ * whole batch redrives
14
+ *
15
+ * .note = deliberate mutation — the two accumulators fill in one pass and are returned
16
+ */
17
+ export declare const setSqsRecordsValidated: <THeaders extends SqsHeadersDeclared, TPayload>(input: {
18
+ records: SqsRecordDecoded[];
19
+ schema: ZodSchema<{
20
+ headers?: THeaders;
21
+ payload: TPayload;
22
+ }>;
23
+ }, context: {
24
+ log: Pick<ContextLogTrail['log'], 'warn' | 'error'>;
25
+ }) => {
26
+ recordsValidated: SqsRecordDecoded<{
27
+ headers: SqsHeadersMerged<THeaders>;
28
+ payload: TPayload;
29
+ }>[];
30
+ idsRefused: Set<string>;
31
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setSqsRecordsValidated = void 0;
4
+ const asCallerFault_1 = require("./asCallerFault");
5
+ const logSqsRecordInvalid_1 = require("./logSqsRecordInvalid");
6
+ const logSqsRecordRefused_1 = require("./logSqsRecordRefused");
7
+ const setSqsRecordValidated_1 = require("./setSqsRecordValidated");
8
+ /**
9
+ * .what = validates each record of a batch, and sorts the ones that fail by whose fault it is
10
+ * .why = `perBatch` decides per record, so a refusal must be read where its id is in hand:
11
+ * - a caller fault is acknowledged — logged, and named in `idsRefused` so it stays out of
12
+ * `batchItemFailures` and sqs deletes it once (`invariant.constraint-errors-never-redrive-sqs`)
13
+ * - a server fault (a schema whose own callback throws) is logged loud and named in neither
14
+ * list, so that record alone is retried — one defect of ours never redrives the healthy
15
+ * records beside it
16
+ * - a throw that is not an `Error` carries no verdict on any record, so it escapes and the
17
+ * whole batch redrives
18
+ *
19
+ * .note = deliberate mutation — the two accumulators fill in one pass and are returned
20
+ */
21
+ const setSqsRecordsValidated = (input, context) => {
22
+ const recordsValidated = [];
23
+ const idsRefused = new Set();
24
+ for (const record of input.records) {
25
+ try {
26
+ recordsValidated.push((0, setSqsRecordValidated_1.setSqsRecordValidated)({ record, schema: input.schema }));
27
+ }
28
+ catch (error) {
29
+ // a caller fault: acknowledge it, by id
30
+ const callerFault = (0, asCallerFault_1.asCallerFault)({ error });
31
+ if (callerFault) {
32
+ (0, logSqsRecordRefused_1.logSqsRecordRefused)({ message: record._.raw, error: callerFault }, context);
33
+ idsRefused.add(record.id);
34
+ continue;
35
+ }
36
+ // a non-error throw is no verdict on this record; it escapes, and the batch redrives
37
+ if (!(error instanceof Error))
38
+ throw error;
39
+ // a server fault: logged loud; its omission from both lists IS its redrive, never a swallow
40
+ (0, logSqsRecordInvalid_1.logSqsRecordInvalid)({ id: record.id, error }, context);
41
+ }
42
+ }
43
+ return { recordsValidated, idsRefused };
44
+ };
45
+ exports.setSqsRecordsValidated = setSqsRecordsValidated;
46
+ //# sourceMappingURL=setSqsRecordsValidated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setSqsRecordsValidated.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.ts"],"names":[],"mappings":";;;AAGA,mDAAgD;AAChD,+DAA4D;AAC5D,+DAA4D;AAM5D,mEAAgE;AAEhE;;;;;;;;;;;;GAYG;AACI,MAAM,sBAAsB,GAAG,CAIpC,KAGC,EACD,OAAgE,EAOhE,EAAE;IACF,MAAM,gBAAgB,GAGf,EAAE,CAAC;IACV,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IAErC,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,gBAAgB,CAAC,IAAI,CACnB,IAAA,6CAAqB,EAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CACxD,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,wCAAwC;YACxC,MAAM,WAAW,GAAG,IAAA,6BAAa,EAAC,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7C,IAAI,WAAW,EAAE,CAAC;gBAChB,IAAA,yCAAmB,EACjB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,EAC7C,OAAO,CACR,CAAC;gBACF,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBAC1B,SAAS;YACX,CAAC;YAED,qFAAqF;YACrF,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;YAE3C,4FAA4F;YAC5F,IAAA,yCAAmB,EAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC;AAC1C,CAAC,CAAC;AAhDW,QAAA,sBAAsB,0BAgDjC"}
@@ -1,17 +1,24 @@
1
1
  import type middy from '@middy/core';
2
+ import type { TrailCarrier } from '../../../domain.objects/TrailCarrier';
2
3
  /**
3
4
  * .what = middleware that extracts or generates trail context and unwraps event
4
5
  * .why = enables request correlation via trail.exid across lambda invocations
5
6
  *
6
- * payload formats:
7
- * - wrapped: { event: X, trail: { exid } } → extracts trail, unwraps to X
8
- * - raw: X → generates trail, uses X as event
7
+ * | carrier | the caller's trail + opt-in ride | present → | absent → |
8
+ * |---------|----------------------------------|-----------|----------|
9
+ * | wrapper | `{ event: X, trail: { exid } }` | unwrap to X, contemp | event as is, ancient |
10
+ * | headers | `event.headers['x-trail-exid']` | event as is, contemp | event as is, ancient |
9
11
  *
10
- * .note = the wrapped arm is the only inbound source of an `exid`, and only `askLambdaEndpoint`
11
- * sends that shape. so an api-gateway or an sqs envelope cannot match it, and both
12
- * families mint a fresh id every invoke — a trace does not cross an http or a queue
13
- * boundary (`domain.terms/trail.md`)
12
+ * .note = `headers` reads the RECONCILED bag, so a family that carries it places this entry after
13
+ * its event normalization. a `{ event, trail }` wrapper is not honored there
14
+ *
15
+ * .note = `forSqs.*` keeps the `wrapper` carrier it ran before the headers carrier existed: a test
16
+ * runner frames one, and aws never sends one, so a deployed sqs endpoint reads no trail and
17
+ * mints a fresh id. the `messageAttributes` lift is recorded as next
18
+ * (`domain.terms/trail.md`, `invariant.ancient-vs-contemp-callers.md`)
14
19
  */
15
- export declare const genTrailMiddleware: () => {
20
+ export declare const genTrailMiddleware: (input: {
21
+ carrier: TrailCarrier;
22
+ }) => {
16
23
  before: middy.MiddlewareFn<any, any>;
17
24
  };
@@ -2,27 +2,65 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.genTrailMiddleware = void 0;
4
4
  const crypto_1 = require("crypto");
5
+ const helpful_errors_1 = require("helpful-errors");
5
6
  const sdk_logs_1 = require("sdk-logs");
7
+ const getOneTrailExidFromHeaders_1 = require("../../lambdaEndpointWire/frame/getOneTrailExidFromHeaders");
8
+ const isTrailExidHeaderMalformed_1 = require("../../lambdaEndpointWire/frame/isTrailExidHeaderMalformed");
6
9
  const getUnwrappedEventWithExid_1 = require("./getUnwrappedEventWithExid");
10
+ /**
11
+ * .what = reads the trail and the opt-in off a reconciled event's headers
12
+ * .why = the header's presence IS the contemp opt-in; the event itself is never rewrapped
13
+ */
14
+ const getTrailFromHeaders = (input) => {
15
+ const exidFromPayload = (0, getOneTrailExidFromHeaders_1.getOneTrailExidFromHeaders)({
16
+ headers: input.event?.headers,
17
+ });
18
+ return {
19
+ exidFromPayload,
20
+ unwrappedEvent: input.event,
21
+ isContempCaller: exidFromPayload !== null,
22
+ };
23
+ };
24
+ /**
25
+ * .what = reads the caller's trail, the opt-in, and the event, from the carrier a family declares
26
+ * .why = one place picks the read per carrier, so the middleware body stays one narrative
27
+ */
28
+ const getTrailFromCarrier = (input) => {
29
+ switch (input.carrier) {
30
+ case 'headers':
31
+ return getTrailFromHeaders({ event: input.event });
32
+ case 'wrapper':
33
+ return (0, getUnwrappedEventWithExid_1.getUnwrappedEventWithExid)({ payload: input.event });
34
+ default: {
35
+ // a carrier added to the type and not handled here fails to compile at this line
36
+ const carrierUnhandled = input.carrier;
37
+ return helpful_errors_1.MalfunctionError.throw('the trail carrier is not one this reads', {
38
+ carrier: carrierUnhandled,
39
+ });
40
+ }
41
+ }
42
+ };
7
43
  /**
8
44
  * .what = middleware that extracts or generates trail context and unwraps event
9
45
  * .why = enables request correlation via trail.exid across lambda invocations
10
46
  *
11
- * payload formats:
12
- * - wrapped: { event: X, trail: { exid } } → extracts trail, unwraps to X
13
- * - raw: X → generates trail, uses X as event
47
+ * | carrier | the caller's trail + opt-in ride | present → | absent → |
48
+ * |---------|----------------------------------|-----------|----------|
49
+ * | wrapper | `{ event: X, trail: { exid } }` | unwrap to X, contemp | event as is, ancient |
50
+ * | headers | `event.headers['x-trail-exid']` | event as is, contemp | event as is, ancient |
14
51
  *
15
- * .note = the wrapped arm is the only inbound source of an `exid`, and only `askLambdaEndpoint`
16
- * sends that shape. so an api-gateway or an sqs envelope cannot match it, and both
17
- * families mint a fresh id every invoke — a trace does not cross an http or a queue
18
- * boundary (`domain.terms/trail.md`)
52
+ * .note = `headers` reads the RECONCILED bag, so a family that carries it places this entry after
53
+ * its event normalization. a `{ event, trail }` wrapper is not honored there
54
+ *
55
+ * .note = `forSqs.*` keeps the `wrapper` carrier it ran before the headers carrier existed: a test
56
+ * runner frames one, and aws never sends one, so a deployed sqs endpoint reads no trail and
57
+ * mints a fresh id. the `messageAttributes` lift is recorded as next
58
+ * (`domain.terms/trail.md`, `invariant.ancient-vs-contemp-callers.md`)
19
59
  */
20
- const genTrailMiddleware = () => {
60
+ const genTrailMiddleware = (input) => {
21
61
  const before = async (request) => {
22
- // detect payload format and extract trail + event
23
- const { exidFromPayload, unwrappedEvent, isContempCaller } = (0, getUnwrappedEventWithExid_1.getUnwrappedEventWithExid)({
24
- payload: request.event,
25
- });
62
+ // read the caller's trail + event off the carrier the family declares
63
+ const { exidFromPayload, unwrappedEvent, isContempCaller } = getTrailFromCarrier({ carrier: input.carrier, event: request.event });
26
64
  // generate exid if not provided
27
65
  const exid = exidFromPayload ?? `exid:${(0, crypto_1.randomUUID)()}`;
28
66
  // create trail
@@ -35,6 +73,13 @@ const genTrailMiddleware = () => {
35
73
  trail,
36
74
  env: null,
37
75
  });
76
+ // a malformed opt-in header reads as absent, so say so: the caller is answered ancient and its trace
77
+ // does not join. the length is logged, never the text, since the value came from a public caller
78
+ if (input.carrier === 'headers' &&
79
+ (0, isTrailExidHeaderMalformed_1.isTrailExidHeaderMalformed)({ headers: request.event?.headers }))
80
+ contextLogTrail.log.debug('trail.exid.header.rejected', {
81
+ length: String(request.event?.headers?.['x-trail-exid']).length,
82
+ });
38
83
  // unwrap event (if wrapped format)
39
84
  // .note = DELIBERATE MUTATION — `request` is middy's only channel to hand a value onward
40
85
  request.event = unwrappedEvent;
@@ -1 +1 @@
1
- {"version":3,"file":"genTrailMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.ts"],"names":[],"mappings":";;;AACA,mCAAoC;AACpC,uCAIkB;AAElB,2EAAwE;AAExE;;;;;;;;;;;;GAYG;AACI,MAAM,kBAAkB,GAAG,GAEhC,EAAE;IACF,MAAM,MAAM,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC7D,kDAAkD;QAClD,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,GACxD,IAAA,qDAAyB,EAAC;YACxB,OAAO,EAAE,OAAO,CAAC,KAAK;SACvB,CAAC,CAAC;QAEL,gCAAgC;QAChC,MAAM,IAAI,GAAG,eAAe,IAAI,QAAQ,IAAA,mBAAU,GAAE,EAAE,CAAC;QAEvD,eAAe;QACf,MAAM,KAAK,GAAa;YACtB,IAAI;YACJ,KAAK,EAAE,EAAE;SACV,CAAC;QAEF,kCAAkC;QAClC,MAAM,eAAe,GAAG,IAAA,6BAAkB,EAAC;YACzC,KAAK;YACL,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;QAEH,mCAAmC;QACnC,yFAAyF;QACzF,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC;QAE/B,kDAAkD;QAClD;;;;;;;;;;;WAWG;QACH,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAG3C,CAAC;QACF,OAAO,CAAC,OAAO,GAAG;YAChB,GAAG,aAAa;YAChB,GAAG,EAAE,eAAe,CAAC,GAAG;YACxB,eAAe;SAE+B,CAAC;IACnD,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;AAvDW,QAAA,kBAAkB,sBAuD7B"}
1
+ {"version":3,"file":"genTrailMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.ts"],"names":[],"mappings":";;;AACA,mCAAoC;AACpC,mDAAkD;AAClD,uCAIkB;AAGlB,0GAAuG;AACvG,0GAAuG;AACvG,2EAAwE;AAExE;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAE1B,KAED,EAIC,EAAE;IACF,MAAM,eAAe,GAAG,IAAA,uDAA0B,EAAC;QACjD,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO;KAC9B,CAAC,CAAC;IACH,OAAO;QACL,eAAe;QACf,cAAc,EAAE,KAAK,CAAC,KAAK;QAC3B,eAAe,EAAE,eAAe,KAAK,IAAI;KAC1C,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAAC,KAG5B,EAIC,EAAE;IACF,QAAQ,KAAK,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,SAAS;YACZ,OAAO,mBAAmB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACrD,KAAK,SAAS;YACZ,OAAO,IAAA,qDAAyB,EAAC,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC7D,OAAO,CAAC,CAAC,CAAC;YACR,iFAAiF;YACjF,MAAM,gBAAgB,GAAU,KAAK,CAAC,OAAO,CAAC;YAC9C,OAAO,iCAAgB,CAAC,KAAK,CAAC,yCAAyC,EAAE;gBACvE,OAAO,EAAE,gBAAgB;aAC1B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAElC,EAEC,EAAE;IACF,MAAM,MAAM,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC7D,sEAAsE;QACtE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,GACxD,mBAAmB,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAExE,gCAAgC;QAChC,MAAM,IAAI,GAAG,eAAe,IAAI,QAAQ,IAAA,mBAAU,GAAE,EAAE,CAAC;QAEvD,eAAe;QACf,MAAM,KAAK,GAAa;YACtB,IAAI;YACJ,KAAK,EAAE,EAAE;SACV,CAAC;QAEF,kCAAkC;QAClC,MAAM,eAAe,GAAG,IAAA,6BAAkB,EAAC;YACzC,KAAK;YACL,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;QAEH,qGAAqG;QACrG,iGAAiG;QACjG,IACE,KAAK,CAAC,OAAO,KAAK,SAAS;YAC3B,IAAA,uDAA0B,EAAC,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;YAE/D,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE;gBACtD,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM;aAChE,CAAC,CAAC;QAEL,mCAAmC;QACnC,yFAAyF;QACzF,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC;QAE/B,kDAAkD;QAClD;;;;;;;;;;;WAWG;QACH,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAG3C,CAAC;QACF,OAAO,CAAC,OAAO,GAAG;YAChB,GAAG,aAAa;YAChB,GAAG,EAAE,eAAe,CAAC,GAAG;YACxB,eAAe;SAE+B,CAAC;IACnD,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;AAjEW,QAAA,kBAAkB,sBAiE7B"}
@@ -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"}