sdk-aws-lambda 0.6.0 → 0.7.0

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 (160) hide show
  1. package/dist/domain.objects/ApiGatewayRequestEventOnwire.d.ts +18 -0
  2. package/dist/domain.objects/ApiGatewayRequestEventOnwire.js +3 -0
  3. package/dist/domain.objects/ApiGatewayRequestEventOnwire.js.map +1 -0
  4. package/dist/domain.objects/ApiGatewayResponse.d.ts +17 -10
  5. package/dist/domain.objects/{ApiGatewayResponsePayload.d.ts → ApiGatewayResponseOnwire.d.ts} +8 -4
  6. package/dist/domain.objects/{ApiGatewayRequestPayload.js → ApiGatewayResponseOnwire.js} +1 -1
  7. package/dist/domain.objects/ApiGatewayResponseOnwire.js.map +1 -0
  8. package/dist/domain.operations/genLambdaEndpoint/InvokeInputSuperset.d.ts +125 -0
  9. package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.js → InvokeInputSuperset.js} +1 -1
  10. package/dist/domain.operations/genLambdaEndpoint/InvokeInputSuperset.js.map +1 -0
  11. package/dist/domain.operations/genLambdaEndpoint/TranslateLog.d.ts +0 -17
  12. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.d.ts +27 -0
  13. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/ApiGatewayRequestEventUnified.d.ts +100 -0
  14. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/ApiGatewayRequestEventUnified.js +3 -0
  15. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/ApiGatewayRequestEventUnified.js.map +1 -0
  16. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayRequestEventUnified.d.ts +34 -0
  17. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayRequestEventUnified.js +141 -0
  18. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayRequestEventUnified.js.map +1 -0
  19. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseOnwire.d.ts +22 -0
  20. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseOnwire.js +27 -0
  21. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseOnwire.js.map +1 -0
  22. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{asApiGatewayResponsePayloadJson.d.ts → asApiGatewayResponseOnwireJson.d.ts} +11 -11
  23. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{asApiGatewayResponsePayloadJson.js → asApiGatewayResponseOnwireJson.js} +12 -12
  24. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseOnwireJson.js.map +1 -0
  25. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.d.ts +15 -13
  26. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js +13 -11
  27. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js.map +1 -1
  28. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asHeaderKeysLowercased.d.ts +35 -0
  29. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asHeaderKeysLowercased.js +44 -0
  30. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asHeaderKeysLowercased.js.map +1 -0
  31. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +93 -56
  32. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +88 -62
  33. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
  34. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getAllWirePayloadKeysFound.d.ts → getAllResponseOnwireKeysFound.d.ts} +2 -2
  35. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllResponseOnwireKeysFound.js +43 -0
  36. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllResponseOnwireKeysFound.js.map +1 -0
  37. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getIsV1ApiGatewayEvent.d.ts → getIsV1ApiGatewayRequestEvent.d.ts} +1 -1
  38. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getIsV1ApiGatewayEvent.js → getIsV1ApiGatewayRequestEvent.js} +4 -4
  39. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV1ApiGatewayRequestEvent.js.map +1 -0
  40. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getIsV2ApiGatewayEvent.d.ts → getIsV2ApiGatewayRequestEvent.d.ts} +1 -1
  41. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getIsV2ApiGatewayEvent.js → getIsV2ApiGatewayRequestEvent.js} +4 -4
  42. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayRequestEvent.js.map +1 -0
  43. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/isApiGatewayResponse.d.ts +8 -5
  44. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/isApiGatewayResponse.js +11 -8
  45. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/isApiGatewayResponse.js.map +1 -1
  46. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/{genApiGatewayEventNormalizationMiddleware.d.ts → genApiGatewayRequestEventNormalizationMiddleware.d.ts} +3 -3
  47. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/{genApiGatewayEventNormalizationMiddleware.js → genApiGatewayRequestEventNormalizationMiddleware.js} +8 -8
  48. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayRequestEventNormalizationMiddleware.js.map +1 -0
  49. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genContentTypeCoherenceMiddleware.d.ts +4 -4
  50. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genContentTypeCoherenceMiddleware.js +5 -5
  51. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodInputValidationMiddleware.d.ts +36 -0
  52. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodInputValidationMiddleware.js +113 -0
  53. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodInputValidationMiddleware.js.map +1 -0
  54. package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts → genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.d.ts} +50 -14
  55. package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js → genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js} +31 -16
  56. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js.map +1 -0
  57. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genAskEventOnwireCaptureMiddleware.d.ts +18 -0
  58. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genAskEventOnwireCaptureMiddleware.js +29 -0
  59. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genAskEventOnwireCaptureMiddleware.js.map +1 -0
  60. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genZodEventValidationMiddleware.d.ts +23 -0
  61. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genZodEventValidationMiddleware.js +38 -0
  62. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genZodEventValidationMiddleware.js.map +1 -0
  63. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/SqsEventDecoded.d.ts +123 -0
  64. package/dist/{domain.objects/ApiGatewayResponsePayload.js → domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/SqsEventDecoded.js} +1 -1
  65. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/SqsEventDecoded.js.map +1 -0
  66. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsEventDecoded.d.ts +23 -0
  67. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsEventDecoded.js +33 -0
  68. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsEventDecoded.js.map +1 -0
  69. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsHeadersOnwire.d.ts +30 -0
  70. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsHeadersOnwire.js +38 -0
  71. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsHeadersOnwire.js.map +1 -0
  72. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordDecoded.d.ts +30 -0
  73. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordDecoded.js +86 -0
  74. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordDecoded.js.map +1 -0
  75. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.d.ts +26 -0
  76. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.js +32 -0
  77. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.js.map +1 -0
  78. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.d.ts +82 -0
  79. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js +108 -0
  80. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js.map +1 -0
  81. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.d.ts +121 -0
  82. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js +97 -0
  83. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js.map +1 -0
  84. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.d.ts +52 -0
  85. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js +68 -0
  86. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js.map +1 -0
  87. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getIsSqsEvent.d.ts +21 -0
  88. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getIsSqsEvent.js +36 -0
  89. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getIsSqsEvent.js.map +1 -0
  90. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.d.ts +46 -0
  91. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js +79 -0
  92. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js.map +1 -0
  93. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.js +31 -0
  94. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.js.map +1 -0
  95. package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.d.ts +8 -4
  96. package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.js.map +1 -1
  97. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.d.ts +10 -4
  98. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionInput.d.ts +12 -0
  99. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionInput.js +23 -0
  100. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionInput.js.map +1 -0
  101. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js +17 -6
  102. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js.map +1 -1
  103. package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.d.ts +16 -18
  104. package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js +16 -18
  105. package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js.map +1 -1
  106. package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.d.ts +5 -0
  107. package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js +5 -0
  108. package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js.map +1 -1
  109. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.d.ts +14 -14
  110. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js +15 -15
  111. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.d.ts +5 -8
  112. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js +5 -8
  113. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js.map +1 -1
  114. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.d.ts +9 -27
  115. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js +9 -27
  116. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js.map +1 -1
  117. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.d.ts +14 -0
  118. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js +48 -16
  119. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js.map +1 -1
  120. package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.d.ts +78 -0
  121. package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.js +103 -0
  122. package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.js.map +1 -0
  123. package/dist/domain.operations/genServiceSdk/gen.file/banner.d.ts +2 -3
  124. package/dist/domain.operations/genServiceSdk/gen.file/banner.js +2 -3
  125. package/dist/domain.operations/genServiceSdk/gen.file/banner.js.map +1 -1
  126. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.d.ts +7 -2
  127. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js +7 -2
  128. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js.map +1 -1
  129. package/dist/index.d.ts +38 -18
  130. package/dist/index.js +20 -14
  131. package/dist/index.js.map +1 -1
  132. package/package.json +5 -5
  133. package/readme.md +164 -93
  134. package/dist/domain.objects/ApiGatewayRequestPayload.d.ts +0 -12
  135. package/dist/domain.objects/ApiGatewayRequestPayload.js.map +0 -1
  136. package/dist/domain.objects/ApiGatewayResponsePayload.js.map +0 -1
  137. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.d.ts +0 -36
  138. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.js.map +0 -1
  139. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.d.ts +0 -19
  140. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.js +0 -24
  141. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.js.map +0 -1
  142. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayloadJson.js.map +0 -1
  143. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.d.ts +0 -27
  144. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.js +0 -118
  145. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.js.map +0 -1
  146. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllWirePayloadKeysFound.js +0 -34
  147. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllWirePayloadKeysFound.js.map +0 -1
  148. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV1ApiGatewayEvent.js.map +0 -1
  149. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayEvent.js.map +0 -1
  150. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js.map +0 -1
  151. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.d.ts +0 -27
  152. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js +0 -54
  153. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js.map +0 -1
  154. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +0 -1
  155. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.d.ts +0 -20
  156. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js +0 -31
  157. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js.map +0 -1
  158. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.d.ts +0 -5
  159. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.js +0 -16
  160. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.js.map +0 -1
@@ -0,0 +1,23 @@
1
+ import type { SQSEvent } from 'aws-lambda';
2
+ import type { SqsEventDecoded } from './SqsEventDecoded';
3
+ /**
4
+ * .what = decodes an sqs invoke into the shape both `forSqs` variants read
5
+ * .why = the chain must read one shape, so this runs first and every step after it reads
6
+ * `SqsEventDecoded`
7
+ *
8
+ * .why the input is `wire` and not `payload` = it holds the whole message, and `payload` names
9
+ * the message body and naught else (`domain.terms/payload.md`)
10
+ *
11
+ * .note = an empty batch decodes to `{ records: [] }` rather than throws. it is a legitimate sqs
12
+ * shape, and each variant states what it does with it: `perRecord` refuses it, since it
13
+ * has no record to serve, and `perBatch` returns no failures
14
+ * .note = a named transformer rather than middleware-local logic, so one implementation serves
15
+ * both variants' entry points (`rule.forbid.parallel-codepaths`)
16
+ */
17
+ export declare const asSqsEventDecoded: (input: {
18
+ wire: SQSEvent;
19
+ }, options?: {
20
+ deserialize: {
21
+ payload: boolean;
22
+ };
23
+ }) => SqsEventDecoded;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asSqsEventDecoded = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const asSqsRecordDecoded_1 = require("./asSqsRecordDecoded");
6
+ const getIsSqsEvent_1 = require("./getIsSqsEvent");
7
+ /**
8
+ * .what = decodes an sqs invoke into the shape both `forSqs` variants read
9
+ * .why = the chain must read one shape, so this runs first and every step after it reads
10
+ * `SqsEventDecoded`
11
+ *
12
+ * .why the input is `wire` and not `payload` = it holds the whole message, and `payload` names
13
+ * the message body and naught else (`domain.terms/payload.md`)
14
+ *
15
+ * .note = an empty batch decodes to `{ records: [] }` rather than throws. it is a legitimate sqs
16
+ * shape, and each variant states what it does with it: `perRecord` refuses it, since it
17
+ * has no record to serve, and `perBatch` returns no failures
18
+ * .note = a named transformer rather than middleware-local logic, so one implementation serves
19
+ * both variants' entry points (`rule.forbid.parallel-codepaths`)
20
+ */
21
+ const asSqsEventDecoded = (input, options) => {
22
+ // fail loud rather than hand a handler a shape this transformer did not produce
23
+ if (!(0, getIsSqsEvent_1.getIsSqsEvent)(input.wire))
24
+ return helpful_errors_1.MalfunctionError.throw('wire is not an sqs event shape', {
25
+ wire: input.wire,
26
+ });
27
+ return {
28
+ records: input.wire.Records.map((record) => (0, asSqsRecordDecoded_1.asSqsRecordDecoded)({ wire: record }, options)),
29
+ _: { raw: input.wire },
30
+ };
31
+ };
32
+ exports.asSqsEventDecoded = asSqsEventDecoded;
33
+ //# sourceMappingURL=asSqsEventDecoded.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asSqsEventDecoded.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsEventDecoded.ts"],"names":[],"mappings":";;;AACA,mDAAkD;AAElD,6DAA0D;AAC1D,mDAAgD;AAGhD;;;;;;;;;;;;;GAaG;AACI,MAAM,iBAAiB,GAAG,CAC/B,KAAyB,EACzB,OAA+C,EAC9B,EAAE;IACnB,gFAAgF;IAChF,IAAI,CAAC,IAAA,6BAAa,EAAC,KAAK,CAAC,IAAI,CAAC;QAC5B,OAAO,iCAAgB,CAAC,KAAK,CAAC,gCAAgC,EAAE;YAC9D,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC;IAEL,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACzC,IAAA,uCAAkB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,CAC9C;QACD,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE;KACvB,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,iBAAiB,qBAgB5B"}
@@ -0,0 +1,30 @@
1
+ import type { SQSMessageAttributes } from 'aws-lambda';
2
+ import type { SqsHeadersOnwire } from './SqsEventDecoded';
3
+ /**
4
+ * .what = flattens sqs's per-value message-attribute wrapper into one name per value
5
+ * .why = `headers` means "one name, one value" in every family this sdk serves, so an
6
+ * api-gateway handler and an sqs handler index the bag the same way. aws wraps each value
7
+ * in `{ stringValue?, binaryValue?, dataType }`, which is a codec detail rather than a
8
+ * second dimension of the bag (`domain.terms/headers.md`)
9
+ *
10
+ * .why `stringValue ?? binaryValue` and not `stringValue` alone = a `Binary` attribute carries
11
+ * its value at `binaryValue`, as aws's base64 string. to read only `stringValue` would
12
+ * make every binary attribute read as absent — a value the sender set, silently gone
13
+ * (`rule.forbid.failhide`)
14
+ *
15
+ * .why the keys are not lowercased, where the api-gateway twin folds them = rfc 9110 §5.1 makes
16
+ * http field names case-insensitive; sqs attribute names are case-sensitive, so `OrderId`
17
+ * and `orderId` are two distinct attributes a sender may set together, and a fold would
18
+ * merge them and drop one (`rule.forbid.defended-exceptions` — an axis of the protocol)
19
+ *
20
+ * .note = the base64 is handed over undecoded. this bag's value type is `string | undefined`, and
21
+ * a decoded binary is bytes; to decode here would widen every header value to
22
+ * `string | Buffer` or lose the bytes to a lossy utf-8 round-trip. the caller decodes what
23
+ * they know is binary, and `dataType` says which — at `_.raw.messageAttributes`
24
+ * .note = it also absorbs the absent bag. `SQSRecord.messageAttributes` is declared required, yet
25
+ * a hand-built fixture or a future vendor shape may omit it, and a transformer that
26
+ * returns a bag either way deletes the guard from its caller
27
+ */
28
+ export declare const asSqsHeadersOnwire: (input: {
29
+ messageAttributes: SQSMessageAttributes | undefined;
30
+ }) => SqsHeadersOnwire;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asSqsHeadersOnwire = void 0;
4
+ /**
5
+ * .what = flattens sqs's per-value message-attribute wrapper into one name per value
6
+ * .why = `headers` means "one name, one value" in every family this sdk serves, so an
7
+ * api-gateway handler and an sqs handler index the bag the same way. aws wraps each value
8
+ * in `{ stringValue?, binaryValue?, dataType }`, which is a codec detail rather than a
9
+ * second dimension of the bag (`domain.terms/headers.md`)
10
+ *
11
+ * .why `stringValue ?? binaryValue` and not `stringValue` alone = a `Binary` attribute carries
12
+ * its value at `binaryValue`, as aws's base64 string. to read only `stringValue` would
13
+ * make every binary attribute read as absent — a value the sender set, silently gone
14
+ * (`rule.forbid.failhide`)
15
+ *
16
+ * .why the keys are not lowercased, where the api-gateway twin folds them = rfc 9110 §5.1 makes
17
+ * http field names case-insensitive; sqs attribute names are case-sensitive, so `OrderId`
18
+ * and `orderId` are two distinct attributes a sender may set together, and a fold would
19
+ * merge them and drop one (`rule.forbid.defended-exceptions` — an axis of the protocol)
20
+ *
21
+ * .note = the base64 is handed over undecoded. this bag's value type is `string | undefined`, and
22
+ * a decoded binary is bytes; to decode here would widen every header value to
23
+ * `string | Buffer` or lose the bytes to a lossy utf-8 round-trip. the caller decodes what
24
+ * they know is binary, and `dataType` says which — at `_.raw.messageAttributes`
25
+ * .note = it also absorbs the absent bag. `SQSRecord.messageAttributes` is declared required, yet
26
+ * a hand-built fixture or a future vendor shape may omit it, and a transformer that
27
+ * returns a bag either way deletes the guard from its caller
28
+ */
29
+ const asSqsHeadersOnwire = (input) => {
30
+ if (!input.messageAttributes)
31
+ return {};
32
+ return Object.fromEntries(Object.entries(input.messageAttributes).map(([name, attribute]) => [
33
+ name,
34
+ attribute.stringValue ?? attribute.binaryValue,
35
+ ]));
36
+ };
37
+ exports.asSqsHeadersOnwire = asSqsHeadersOnwire;
38
+ //# sourceMappingURL=asSqsHeadersOnwire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asSqsHeadersOnwire.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsHeadersOnwire.ts"],"names":[],"mappings":";;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAElC,EAAoB,EAAE;IACrB,IAAI,CAAC,KAAK,CAAC,iBAAiB;QAAE,OAAO,EAAE,CAAC;IAExC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC;QACjE,IAAI;QACJ,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,WAAW;KAC/C,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B"}
@@ -0,0 +1,30 @@
1
+ import type { SQSRecord } from 'aws-lambda';
2
+ import type { SqsRecordDecoded } from './SqsEventDecoded';
3
+ /**
4
+ * .what = what `deserialize` means when a caller declares none — one declaration, read by this
5
+ * transformer and by both `forSqs` variants' config
6
+ * (`rule.forbid.parallel-codepaths`)
7
+ * .why payload = json is the common case, and a caller who wants the raw string opts out by
8
+ * value: `deserialize: { payload: false }`
9
+ *
10
+ * .why a second declaration, where the api-gateway family already exports one = to import that
11
+ * one would bind this family's default to a peer family's. the two agree today and
12
+ * neither owes the other that agreement forever — a shared constant would make a
13
+ * divergence a break rather than an edit (`rule.prefer.wet-over-dry`)
14
+ */
15
+ export declare const DESERIALIZE_DEFAULT: {
16
+ payload: boolean;
17
+ };
18
+ /**
19
+ * .what = decodes one sqs message into the shape a handler reads
20
+ * .why = the two variants differ in how they hand over records, never in how a record is decoded,
21
+ * so one transformer serves both and a new slot lands in one place
22
+ * (`rule.forbid.parallel-codepaths`)
23
+ */
24
+ export declare const asSqsRecordDecoded: (input: {
25
+ wire: SQSRecord;
26
+ }, options?: {
27
+ deserialize: {
28
+ payload: boolean;
29
+ };
30
+ }) => SqsRecordDecoded;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asSqsRecordDecoded = exports.DESERIALIZE_DEFAULT = void 0;
4
+ const asSqsHeadersOnwire_1 = require("./asSqsHeadersOnwire");
5
+ /**
6
+ * .what = parses a json message body into an object
7
+ * .why = sqs hands the body over as a string; most handlers want the object
8
+ *
9
+ * .note = a body that is not json is returned as the string rather than refused — a plain-text
10
+ * or csv producer is a legitimate sender, and its own schema (or `z.any()`) is where
11
+ * that shape gets judged. the same call the api-gateway twin makes, for the same reason
12
+ *
13
+ * .why no base64 arm, where the api-gateway twin has one = sqs carries no `isBase64Encoded` flag
14
+ * and its body is always a utf-8 string; binary rides in a message attribute, with its own
15
+ * `dataType`. the arm is absent because the wire fact it reads is absent
16
+ * (`rule.forbid.defended-exceptions`)
17
+ *
18
+ * .why this is not shared with the api-gateway twin's parser = two usages, and the signatures
19
+ * differ by the base64 flag above. that is below the rule of three, and an abstraction
20
+ * that takes an always-false flag from one of its two callers is a worse shape than the
21
+ * duplicate (`rule.prefer.wet-over-dry`). a third transport earns the lift
22
+ */
23
+ const asParsedSqsBody = (input) => {
24
+ if (!input.body)
25
+ return null;
26
+ try {
27
+ return JSON.parse(input.body);
28
+ }
29
+ catch (error) {
30
+ /**
31
+ * .what = allowlists the ONE error a non-json body can raise, and rethrows every other
32
+ * .why = a bare `catch` would swallow a TypeError from a real defect, and the swallowed
33
+ * value would reach the handler as plain text (`rule.forbid.failhide`).
34
+ * `SyntaxError` is the only class `JSON.parse` throws for malformed input, per
35
+ * ecma-262 §25.5.1, so the allowlist is exhaustive rather than a guess
36
+ */
37
+ if (!(error instanceof SyntaxError))
38
+ throw error;
39
+ return input.body;
40
+ }
41
+ };
42
+ /**
43
+ * .what = what `deserialize` means when a caller declares none — one declaration, read by this
44
+ * transformer and by both `forSqs` variants' config
45
+ * (`rule.forbid.parallel-codepaths`)
46
+ * .why payload = json is the common case, and a caller who wants the raw string opts out by
47
+ * value: `deserialize: { payload: false }`
48
+ *
49
+ * .why a second declaration, where the api-gateway family already exports one = to import that
50
+ * one would bind this family's default to a peer family's. the two agree today and
51
+ * neither owes the other that agreement forever — a shared constant would make a
52
+ * divergence a break rather than an edit (`rule.prefer.wet-over-dry`)
53
+ */
54
+ exports.DESERIALIZE_DEFAULT = { payload: true };
55
+ /**
56
+ * .what = decodes one sqs message into the shape a handler reads
57
+ * .why = the two variants differ in how they hand over records, never in how a record is decoded,
58
+ * so one transformer serves both and a new slot lands in one place
59
+ * (`rule.forbid.parallel-codepaths`)
60
+ */
61
+ const asSqsRecordDecoded = (input, options) => {
62
+ const deserialize = options?.deserialize ?? exports.DESERIALIZE_DEFAULT;
63
+ return {
64
+ id: input.wire.messageId,
65
+ /**
66
+ * .what = the attributes the sender set, one name per value, keys VERBATIM
67
+ * .note = sqs attribute names are case-sensitive, so the api-gateway case-fold does not
68
+ * travel here — see `asSqsHeadersOnwire`
69
+ */
70
+ headers: (0, asSqsHeadersOnwire_1.asSqsHeadersOnwire)({
71
+ messageAttributes: input.wire.messageAttributes,
72
+ }),
73
+ /**
74
+ * .what = the body, parsed. VALIDATED later, in place — the input validator replaces this
75
+ * slot with the schema's output before `logic` runs
76
+ * .why = so `payload` is the validated value at the only moment a handler can read it,
77
+ * which is what lets its type state the caller's shape over `unknown`
78
+ */
79
+ payload: deserialize.payload
80
+ ? asParsedSqsBody({ body: input.wire.body })
81
+ : input.wire.body,
82
+ _: { raw: input.wire },
83
+ };
84
+ };
85
+ exports.asSqsRecordDecoded = asSqsRecordDecoded;
86
+ //# sourceMappingURL=asSqsRecordDecoded.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asSqsRecordDecoded.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordDecoded.ts"],"names":[],"mappings":";;;AAEA,6DAA0D;AAG1D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,eAAe,GAAG,CAAC,KAExB,EAAW,EAAE;IACZ,IAAI,CAAC,KAAK,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAE7B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf;;;;;;WAMG;QACH,IAAI,CAAC,CAAC,KAAK,YAAY,WAAW,CAAC;YAAE,MAAM,KAAK,CAAC;QAEjD,OAAO,KAAK,CAAC,IAAI,CAAC;IACpB,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACU,QAAA,mBAAmB,GAAyB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAE3E;;;;;GAKG;AACI,MAAM,kBAAkB,GAAG,CAChC,KAA0B,EAC1B,OAA+C,EAC7B,EAAE;IACpB,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,2BAAmB,CAAC;IAEhE,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS;QAExB;;;;WAIG;QACH,OAAO,EAAE,IAAA,uCAAkB,EAAC;YAC1B,iBAAiB,EAAE,KAAK,CAAC,IAAI,CAAC,iBAAiB;SAChD,CAAC;QAEF;;;;;WAKG;QACH,OAAO,EAAE,WAAW,CAAC,OAAO;YAC1B,CAAC,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5C,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;QAEnB,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE;KACvB,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,kBAAkB,sBA8B7B"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * .what = the `forSqs` sub-family — both cardinality variants, under one name
3
+ *
4
+ * genLambdaEndpoint.forSqs.perRecord({ … }) // one message per invoke
5
+ * genLambdaEndpoint.forSqs.perBatch({ … }) // the whole batch per invoke
6
+ *
7
+ * .why two variants and not one widened contract = they make different guarantees, which is the
8
+ * one case `rule.require.widen-before-parallel` names as a real peer:
9
+ *
10
+ * | variant | guarantee |
11
+ * |---|---|
12
+ * | `perRecord` | cardinality 1 — refuses a batch of more than one, loudly, so no message is silently dropped |
13
+ * | `perBatch` | partial failure — reports failed ids, so one poison pill does not redrive nine healthy messages |
14
+ *
15
+ * neither can be expressed as the other plus a flag: `perRecord`'s refusal is what makes
16
+ * its `payload` mean one message, and `perBatch`'s failure report is what makes a bulk
17
+ * handler safe (`domain.terms/event.md`)
18
+ *
19
+ * .note = neither variant is exported bare from `src/index.ts`, and neither is this object. a
20
+ * caller reaches them through `genLambdaEndpoint.forSqs.`, so autocomplete on the family
21
+ * enumerates the whole set
22
+ */
23
+ export declare const forSqs: {
24
+ perRecord: <THeaders extends import("./SqsEventDecoded").SqsHeadersDeclared, TPayload>(config: import("./genLambdaEndpoint.forSqs.perRecord").ForSqsPerRecordInput<THeaders, TPayload>, context?: import("../../..").ContextAwsLambdaServer | undefined) => import("@middy/core").MiddyfiedHandler<import("aws-lambda").SQSEvent, void, Error, import("aws-lambda").Context>;
25
+ perBatch: <THeaders_1 extends import("./SqsEventDecoded").SqsHeadersDeclared, TPayload_1>(config: import("./genLambdaEndpoint.forSqs.perBatch").ForSqsPerBatchInput<THeaders_1, TPayload_1>, context?: import("../../..").ContextAwsLambdaServer | undefined) => import("@middy/core").MiddyfiedHandler<import("aws-lambda").SQSEvent, import("aws-lambda").SQSBatchResponse, Error, import("aws-lambda").Context>;
26
+ };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.forSqs = void 0;
4
+ const genLambdaEndpoint_forSqs_perBatch_1 = require("./genLambdaEndpoint.forSqs.perBatch");
5
+ const genLambdaEndpoint_forSqs_perRecord_1 = require("./genLambdaEndpoint.forSqs.perRecord");
6
+ /**
7
+ * .what = the `forSqs` sub-family — both cardinality variants, under one name
8
+ *
9
+ * genLambdaEndpoint.forSqs.perRecord({ … }) // one message per invoke
10
+ * genLambdaEndpoint.forSqs.perBatch({ … }) // the whole batch per invoke
11
+ *
12
+ * .why two variants and not one widened contract = they make different guarantees, which is the
13
+ * one case `rule.require.widen-before-parallel` names as a real peer:
14
+ *
15
+ * | variant | guarantee |
16
+ * |---|---|
17
+ * | `perRecord` | cardinality 1 — refuses a batch of more than one, loudly, so no message is silently dropped |
18
+ * | `perBatch` | partial failure — reports failed ids, so one poison pill does not redrive nine healthy messages |
19
+ *
20
+ * neither can be expressed as the other plus a flag: `perRecord`'s refusal is what makes
21
+ * its `payload` mean one message, and `perBatch`'s failure report is what makes a bulk
22
+ * handler safe (`domain.terms/event.md`)
23
+ *
24
+ * .note = neither variant is exported bare from `src/index.ts`, and neither is this object. a
25
+ * caller reaches them through `genLambdaEndpoint.forSqs.`, so autocomplete on the family
26
+ * enumerates the whole set
27
+ */
28
+ exports.forSqs = {
29
+ perRecord: genLambdaEndpoint_forSqs_perRecord_1.perRecord,
30
+ perBatch: genLambdaEndpoint_forSqs_perBatch_1.perBatch,
31
+ };
32
+ //# sourceMappingURL=genLambdaEndpoint.forSqs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genLambdaEndpoint.forSqs.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.ts"],"names":[],"mappings":";;;AAAA,2FAA+D;AAC/D,6FAAiE;AAEjE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACU,QAAA,MAAM,GAAG;IACpB,SAAS,EAAT,8CAAS;IACT,QAAQ,EAAR,4CAAQ;CACT,CAAC"}
@@ -0,0 +1,82 @@
1
+ import middy from '@middy/core';
2
+ import type { Context, SQSBatchResponse, SQSEvent } from 'aws-lambda';
3
+ import type { ContextLogTrail } from 'sdk-logs';
4
+ import type { ZodSchema } from 'zod';
5
+ import type { ContextAwsLambdaServer } from '../../../domain.objects/ContextAwsLambdaServer';
6
+ import { type FrozenDeep } from '../setEventFrozen';
7
+ import type { TranslateLog } from '../TranslateLog';
8
+ import type { SqsEventDecoded, SqsHeadersDeclared, SqsHeadersMerged, SqsRecordDecoded } from './SqsEventDecoded';
9
+ /**
10
+ * .what = the one fact sqs needs to delete a message: its `id`
11
+ * .why = a record carries its `id`, so `return { successes: recordsThatSucceeded }` needs no
12
+ * re-shape. `id`, never aws's wire name `itemIdentifier` (`domain.terms/.readme.md`)
13
+ */
14
+ export interface SqsRecordSuccessRef {
15
+ id: string;
16
+ }
17
+ /**
18
+ * .what = sdk contract type for `genLambdaEndpoint.forSqs.perBatch`
19
+ * .why = exported for consumer type inference
20
+ */
21
+ export type ForSqsPerBatchInput<THeaders extends SqsHeadersDeclared, TPayload> = {
22
+ schema: {
23
+ /**
24
+ * .what = the pair one message carries — `{ headers?, payload }`, applied per record
25
+ * .note = a record this refuses never reaches `invoke`, and is retried
26
+ */
27
+ input: ZodSchema<{
28
+ headers?: THeaders;
29
+ payload: TPayload;
30
+ }>;
31
+ };
32
+ invoke: (input: {
33
+ /**
34
+ * .what = the messages that passed validation — a filter over `event.records`, never a
35
+ * copy (`domain.terms/records.md`)
36
+ */
37
+ records: FrozenDeep<SqsRecordDecoded<{
38
+ headers: SqsHeadersMerged<THeaders>;
39
+ payload: TPayload;
40
+ }>[]>;
41
+ /**
42
+ * .what = the whole object that arrived — every record, valid or not
43
+ * (`domain.terms/event.md`)
44
+ */
45
+ event: FrozenDeep<SqsEventDecoded<{
46
+ headers: SqsHeadersMerged<THeaders>;
47
+ payload: TPayload;
48
+ }>>;
49
+ },
50
+ /**
51
+ * .what = the ambient bag; the lineage rides `context.log.trail`, one per invoke
52
+ * (`domain.terms/trail.md`)
53
+ */
54
+ context: ContextLogTrail) => Promise<{
55
+ /**
56
+ * .what = the records this handler processed, so sqs may delete them
57
+ * .why = fail safe. a record not named here is retried, so a forgotten record redrives rather
58
+ * than vanishes (`rule.forbid.failhide`)
59
+ */
60
+ successes: readonly FrozenDeep<SqsRecordSuccessRef>[];
61
+ }>;
62
+ logTranslate?: TranslateLog;
63
+ deserialize?: {
64
+ /**
65
+ * .what = whether to parse each json body into its `payload`
66
+ * .note = `false` hands `payload` to your schema as a string, so pair it with `z.string()`
67
+ * (`rule.require.explicit-optout`)
68
+ */
69
+ payload: boolean;
70
+ };
71
+ };
72
+ /**
73
+ * .what = generates an sqs lambda handler that serves a whole batch per invoke
74
+ * .why = a handler that acts on many messages at once cannot be expressed one record at a time,
75
+ * and a partial-batch response lets one poison message fail alone
76
+ *
77
+ * .note = fail safe by construction: every record not reported as a success is retried, and an
78
+ * answer the sdk cannot read throws, which retries the whole batch
79
+ * .note = deploy precondition: the event source must declare
80
+ * `functionResponseTypes: ['ReportBatchItemFailures']`, or sqs deletes every message
81
+ */
82
+ export declare const perBatch: <THeaders extends SqsHeadersDeclared, TPayload>(config: ForSqsPerBatchInput<THeaders, TPayload>, context?: ContextAwsLambdaServer) => middy.MiddyfiedHandler<SQSEvent, SQSBatchResponse, Error, Context>;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.perBatch = void 0;
7
+ const core_1 = __importDefault(require("@middy/core"));
8
+ const helpful_errors_1 = require("helpful-errors");
9
+ const asContextLogTrail_1 = require("../asContextLogTrail");
10
+ const setEventFrozen_1 = require("../setEventFrozen");
11
+ const asSqsEventDecoded_1 = require("./asSqsEventDecoded");
12
+ const asSqsRecordDecoded_1 = require("./asSqsRecordDecoded");
13
+ const genSqsEndpointMiddlewares_1 = require("./genSqsEndpointMiddlewares");
14
+ const setSqsRecordValidated_1 = require("./setSqsRecordValidated");
15
+ /**
16
+ * .what = generates an sqs lambda handler that serves a whole batch per invoke
17
+ * .why = a handler that acts on many messages at once cannot be expressed one record at a time,
18
+ * and a partial-batch response lets one poison message fail alone
19
+ *
20
+ * .note = fail safe by construction: every record not reported as a success is retried, and an
21
+ * answer the sdk cannot read throws, which retries the whole batch
22
+ * .note = deploy precondition: the event source must declare
23
+ * `functionResponseTypes: ['ReportBatchItemFailures']`, or sqs deletes every message
24
+ */
25
+ const perBatch = (config, context) => {
26
+ // the env context this family declares for symmetry; no step of its chain reads one yet
27
+ void context;
28
+ const deserialize = config.deserialize ?? asSqsRecordDecoded_1.DESERIALIZE_DEFAULT;
29
+ /**
30
+ * .what = decode, validate each, invoke, report every record not claimed as a success
31
+ * .why = the chain has produced the trail log by here, so this reads as narrative
32
+ */
33
+ const logic = async (event, lambdaContext) => {
34
+ // read the trail log `genTrailMiddleware` wrote
35
+ const { log } = (0, asContextLogTrail_1.asContextLogTrail)({ context: lambdaContext });
36
+ const decoded = (0, asSqsEventDecoded_1.asSqsEventDecoded)({ wire: event }, { deserialize });
37
+ // validate each record; a refusal is logged and left out, so it is retried alone
38
+ const recordsValidated = [];
39
+ for (const record of decoded.records) {
40
+ try {
41
+ recordsValidated.push((0, setSqsRecordValidated_1.setSqsRecordValidated)({ record, schema: config.schema.input }));
42
+ }
43
+ catch (error) {
44
+ if (!(error instanceof Error))
45
+ throw error;
46
+ log.warn('sqs.record.invalid', {
47
+ id: record.id,
48
+ errorMessage: error.message,
49
+ });
50
+ }
51
+ }
52
+ // the only ids a handler may claim; read before its turn, so no write it makes can widen them
53
+ const idsClaimable = new Set(recordsValidated.map((record) => record.id));
54
+ /**
55
+ * .what = seals the envelope before the handler's turn (`rule.require.frozen-invoke-inputs`)
56
+ * .where = after validation, since the validator writes parsed values back into each record
57
+ * .as = the envelope now carries the validated values, a fact typescript cannot track from a
58
+ * mutation. drops when the decode is parameterized on the schema's output types
59
+ */
60
+ const frozen = (0, setEventFrozen_1.setEventFrozen)({
61
+ event: {
62
+ records: recordsValidated,
63
+ event: decoded,
64
+ },
65
+ });
66
+ const answer = await config.invoke({ records: frozen.records, event: frozen.event }, { log });
67
+ // refuse an answer with no `successes` array; the throw retries the whole batch
68
+ if (!Array.isArray(answer?.successes))
69
+ helpful_errors_1.MalfunctionError.throw('forSqs.perBatch handler answered without a `successes` array', {
70
+ got: answer === undefined ? 'undefined' : typeof answer,
71
+ keys: answer ? Object.keys(answer) : [],
72
+ fix: 'return `{ successes: recordsThatSucceeded }` — the records themselves. none succeeded? `{ successes: [] }`',
73
+ });
74
+ // refuse an entry with no string `id`; the throw retries the whole batch
75
+ const refsMalformed = answer.successes
76
+ .map((success, index) => ({ index, success }))
77
+ .filter(({ success }) => typeof success?.id !== 'string');
78
+ if (refsMalformed.length)
79
+ helpful_errors_1.MalfunctionError.throw('forSqs.perBatch handler answered with a success that carries no `id`', {
80
+ indexes: refsMalformed.map(({ index }) => index),
81
+ got: refsMalformed.map(({ success }) => success === null ? 'null' : typeof success),
82
+ fix: 'return the records themselves — `return { successes: recordsThatSucceeded }` — rather than bare id strings',
83
+ });
84
+ // refuse a claim on a record the handler was not handed; the throw retries the whole batch
85
+ const idsUnclaimable = answer.successes
86
+ .map((success) => success.id)
87
+ .filter((id) => !idsClaimable.has(id));
88
+ if (idsUnclaimable.length)
89
+ helpful_errors_1.MalfunctionError.throw('forSqs.perBatch handler claimed a success for a record it was not handed', {
90
+ idsUnclaimable,
91
+ idsClaimable: [...idsClaimable],
92
+ fix: 'return the records themselves — `return { successes: recordsThatSucceeded }` — drawn from `records`, never from `event.records` or a hand-written id',
93
+ });
94
+ // every record not claimed as a success is retried; deduped, since sqs reads each id once
95
+ const idsSucceeded = new Set(answer.successes.map((success) => success.id));
96
+ const idsFailed = [
97
+ ...new Set(decoded.records
98
+ .map((record) => record.id)
99
+ .filter((id) => !idsSucceeded.has(id))),
100
+ ];
101
+ return {
102
+ batchItemFailures: idsFailed.map((id) => ({ itemIdentifier: id })),
103
+ };
104
+ };
105
+ return (0, core_1.default)(logic).use((0, genSqsEndpointMiddlewares_1.genSqsEndpointMiddlewares)({ logTranslate: config.logTranslate }));
106
+ };
107
+ exports.perBatch = perBatch;
108
+ //# sourceMappingURL=genLambdaEndpoint.forSqs.perBatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genLambdaEndpoint.forSqs.perBatch.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,121 @@
1
+ import middy from '@middy/core';
2
+ import type { Context, SQSEvent } from 'aws-lambda';
3
+ import type { ContextLogTrail } from 'sdk-logs';
4
+ import type { ZodSchema } from 'zod';
5
+ import type { ContextAwsLambdaServer } from '../../../domain.objects/ContextAwsLambdaServer';
6
+ import { type FrozenDeep } from '../setEventFrozen';
7
+ import type { TranslateLog } from '../TranslateLog';
8
+ import type { SqsEventDecoded, SqsHeadersDeclared, SqsHeadersMerged } from './SqsEventDecoded';
9
+ /**
10
+ * .what = sdk contract type for `genLambdaEndpoint.forSqs.perRecord`
11
+ * .why = exported for consumer type inference
12
+ *
13
+ * .why `THeaders` is bound = the validator spreads the validated headers back over the wire bag,
14
+ * so a `THeaders` that is not a record spreads as one: `{ ...'abc' }` yields
15
+ * `{ 0: 'a', 1: 'b', 2: 'c' }`. unbound, that compiles clean and throws naught at run time
16
+ * (`rule.require.illegal-states-unrepresentable`)
17
+ */
18
+ export type ForSqsPerRecordInput<THeaders extends SqsHeadersDeclared, TPayload> = {
19
+ schema: {
20
+ /**
21
+ * .what = describes the pair `invoke` receives for one message — `{ headers?, payload }`
22
+ * .why = a message with the wrong shape is refused before the handler runs, and the refusal
23
+ * fails the invoke, so sqs redrives it and eventually dead-letters it rather than
24
+ * delete it
25
+ *
26
+ * .note = `payload` is required and `headers` is optional. an absent `headers` key constrains
27
+ * naught, so header enforcement is opt-in (`rule.require.explicit-optout`)
28
+ * .note = there is no `schema.output`. an sqs handler answers no one — `perRecord` returns no
29
+ * value, and sqs reads the invocation's success or failure and naught else
30
+ */
31
+ input: ZodSchema<{
32
+ headers?: THeaders;
33
+ payload: TPayload;
34
+ }>;
35
+ };
36
+ invoke: (input: {
37
+ /**
38
+ * .what = the message body, parsed and validated against `schema.input.payload`
39
+ * .note = this is `event.records[0].payload` — one object, two access paths
40
+ * .note = frozen, because it is a slot of the envelope rather than a value beside it
41
+ */
42
+ payload: FrozenDeep<TPayload>;
43
+ /**
44
+ * .what = the sender's message attributes, one name per value, keys verbatim
45
+ * .note = sqs attribute names are case-sensitive, so the api-gateway lowercase fold does
46
+ * not travel here — see `asSqsHeadersOnwire`
47
+ * .note = this is `event.records[0].headers` — one object, two access paths
48
+ * .note = frozen, for the same reason its peer is
49
+ */
50
+ headers: FrozenDeep<SqsHeadersMerged<THeaders>>;
51
+ /**
52
+ * .what = the whole object that arrived — the batch, with every record decoded
53
+ * .why = `event` names what arrived, in every family. an sqs invoke arrives as a batch even
54
+ * where this variant serves exactly one message of it (`domain.terms/event.md`)
55
+ *
56
+ * .note = `event.records` has exactly one element here, and the batch-size refusal below is
57
+ * what makes that true
58
+ * .note = frozen, though this variant reads no value after `invoke`. its twin does, and the
59
+ * envelope both hand over is one shape — a guarantee that holds on one variant and
60
+ * not its peer is a trap for an author who moves between them
61
+ * (`rule.forbid.parallel-codepaths`)
62
+ */
63
+ event: FrozenDeep<SqsEventDecoded<{
64
+ headers: SqsHeadersMerged<THeaders>;
65
+ payload: TPayload;
66
+ }>>;
67
+ },
68
+ /**
69
+ * .what = the ambient bag, which carries the observability lineage
70
+ * .why `trail` rides here and never in `input` = it is ambient runtime rather than part of
71
+ * the request, so an `input.trail` slot is forbidden in every family
72
+ * (`rule.require.env-access-in-context`, `domain.terms/trail.md`). read it at
73
+ * `context.log.trail`:
74
+ *
75
+ * invoke: async ({ payload, headers, event }, { log }) => log.trail.exid
76
+ *
77
+ * .note = this family mints its own `exid`. no producer propagates a correlation id into a
78
+ * queue, so `trail.exid` is a fresh uuid rather than the caller's; a
79
+ * `messageAttribute`-sourced trail is unbuilt work
80
+ */
81
+ context: ContextLogTrail) => Promise<void>;
82
+ logTranslate?: TranslateLog;
83
+ deserialize?: {
84
+ /**
85
+ * .what = whether to parse the json body into `payload`
86
+ * .note = set `false` for a raw string body — a caller who must verify a signature over the
87
+ * exact bytes reads the string (`rule.require.explicit-optout`)
88
+ * .note = `false` hands `payload` to your schema as a string, so it must be set with the
89
+ * schema's payload half. a mis-pair is a total outage rather than one bad message:
90
+ * the config is per handler, so every message meets the same mismatch and the queue
91
+ * drains to its dead-letter, while the sender's `SendMessage` reports success.
92
+ * clamped by `[case15]`
93
+ *
94
+ * deserialize.payload | the schema's payload half
95
+ * --------------------|--------------------------
96
+ * absent / true | z.object({ … })
97
+ * false | z.string()
98
+ */
99
+ payload: boolean;
100
+ };
101
+ };
102
+ /**
103
+ * .what = generates an sqs lambda handler that serves one message per invoke
104
+ * .why = a handler written against one message is the common case, and it is the shape every
105
+ * other family already hands over. this variant restores cardinality 1 so `payload` and
106
+ * `headers` mean what they mean everywhere else (`domain.terms/event.md`)
107
+ *
108
+ * .why it refuses a batch of more than one = `batchSize` is trigger config, set on the event
109
+ * source and invisible at gen time. under `batchSize: 10` a silent `records[0]` would
110
+ * process one message and drop nine — and sqs, on a successful invoke, deletes all ten.
111
+ * so the mismatch fails loud instead, with the fix named
112
+ * (`rule.forbid.failhide`, `rule.require.errors-name-the-fix`)
113
+ *
114
+ * .why a MalfunctionError and not a ConstraintError = the deployer misconfigured the trigger,
115
+ * never the producer who sent the message
116
+ *
117
+ * .note = a leaf of the `genLambdaEndpoint` family, never exported bare from `src/index.ts` — a
118
+ * consumer reaches it as `genLambdaEndpoint.forSqs.perRecord`
119
+ * (`rule.forbid.unqualified-variant-exports`)
120
+ */
121
+ export declare const perRecord: <THeaders extends SqsHeadersDeclared, TPayload>(config: ForSqsPerRecordInput<THeaders, TPayload>, context?: ContextAwsLambdaServer) => middy.MiddyfiedHandler<SQSEvent, void, Error, Context>;