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
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # sdk-aws-lambda
2
2
 
3
- a simple and opinionated sdk for aws lambda. define endpoints, ask endpoints, auto-propagate trace-ids.
3
+ a simple and opinionated sdk for aws lambda. define endpoints, ask endpoints, trace calls across them.
4
4
 
5
5
  # installation
6
6
 
@@ -12,34 +12,165 @@ npm install --save sdk-aws-lambda
12
12
 
13
13
  ## define an endpoint
14
14
 
15
+ one family, one leaf per trigger:
16
+
17
+ | leaf | trigger |
18
+ |---|---|
19
+ | `genLambdaEndpoint.forAsk` | a direct invoke, e.g. via `askLambdaEndpoint` |
20
+ | `genLambdaEndpoint.forApiGateway` | http, via api gateway |
21
+ | `genLambdaEndpoint.forSqs.perRecord` | one queue message per invoke |
22
+ | `genLambdaEndpoint.forSqs.perBatch` | a whole queue batch per invoke |
23
+
24
+ ### genLambdaEndpoint.forAsk
25
+
26
+ a direct invoke, e.g. from `askLambdaEndpoint`.
27
+
15
28
  ```ts
16
29
  import { genLambdaEndpoint } from 'sdk-aws-lambda';
17
30
 
18
- export const handler = genLambdaEndpoint(
31
+ export const handler = genLambdaEndpoint.forAsk(
19
32
  {
20
33
  schema,
21
- invoke: async ({ event }, { log }) => {
22
- // log has trail context from caller
34
+ invoke: async ({ payload }, { log }) => {
35
+ // payload is the validated body; log has trail context from caller
23
36
  },
24
37
  },
25
38
  { log }, // optional, auto-generated otherwise
26
39
  );
27
40
  ```
28
41
 
42
+ ### genLambdaEndpoint.forApiGateway
43
+
44
+ http, via api gateway.
45
+
46
+ ```ts
47
+ import { genLambdaEndpoint, asApiGatewayResponseSchema } from 'sdk-aws-lambda';
48
+
49
+ export const handler = genLambdaEndpoint.forApiGateway({
50
+ schema: {
51
+ input: z.object({
52
+ headers: z.object({ authorization: z.string() }), // optional key — omit to validate no header
53
+ payload: z.object({ to: z.string() }),
54
+ }),
55
+ output: asApiGatewayResponseSchema({ body: z.object({ sent: z.boolean() }) }),
56
+ },
57
+ invoke: async ({ headers, payload }, context) => ({
58
+ body: await sendMessage({ to: payload.to, authorization: headers.authorization }, context),
59
+ }),
60
+ });
61
+ ```
62
+
63
+ `headers` keys are lowercased. `event` carries six keys:
64
+
65
+ | key | holds |
66
+ |---|---|
67
+ | `method` | the http method |
68
+ | `headers` | the request headers |
69
+ | `payload` | the body |
70
+ | `codec` | `{ base64 }` — how the body arrived |
71
+ | `params` | `{ path, query }` — the url parameter bags |
72
+ | `_` | `{ raw }` — the wire event before reconciliation |
73
+
74
+ ⇒ zoom in: [headers](./.agent/repo=.this/role=any/briefs/domain.terms/headers.md) ·
75
+ [event](./.agent/repo=.this/role=any/briefs/domain.terms/event.md)
76
+
77
+ #### the wire response
78
+
79
+ a handler owns its **exact wire response** — any status, any headers, any body, or none at all.
80
+ return an `ApiGatewayResponse`, and it reaches the wire as written.
81
+
82
+ ```ts
83
+ export const handler = genLambdaEndpoint.forApiGateway({
84
+ schema: {
85
+ input: z.any(), // a twilio form blob
86
+ output: asApiGatewayResponseSchema({ body: z.undefined() }), // carries no body
87
+ },
88
+ invoke: async () => ({ status: 204 }), // 204, no body
89
+ });
90
+ ```
91
+
92
+ | return | wire |
93
+ |---|---|
94
+ | `{ body: x }` | 200 + json — the convenient default |
95
+ | `{ status: 204 }` | 204, no body, **no `content-type`** |
96
+ | `{ status: 308, headers: { Location } }` | a redirect |
97
+ | `{ headers: { 'Content-Type': 'text/xml' }, body: xml }` | your bytes, verbatim |
98
+ | `{}` | ⛔ a **compile error** — at least one key is required |
99
+
100
+ set a `Content-Type` yourself and the serializer stands aside, so xml/text reach the wire
101
+ byte-identical. omit it with a body and you get `application/json`.
102
+
103
+ #### the body-less response
104
+
105
+ `schema.output` describes what `invoke` **returns** (the envelope), so
106
+ `asApiGatewayResponseSchema({ body })` wraps a body schema into it.
107
+
108
+ for a response that carries **no body at all** — a 204, a redirect — declare the body
109
+ `z.undefined()`:
110
+
111
+ <!-- prettier-ignore -->
112
+ | you declare | the published `body` slot | reads as |
113
+ |---|---|---|
114
+ | `z.undefined()` · `z.void()` · `z.never()` | `{ "not": {} }` | **"no body is ever carried"** |
115
+ | `z.any()` · `z.unknown()` | `{}` | ⛔ the rubber-stamp — every value reads as valid |
116
+ | `z.null()` | `{ "type": "null" }` | ⛔ claims the wire carries the four bytes `null` |
117
+
118
+ all of them behave identically at **runtime**: each accepts `{ status: 204 }` and each still refuses
119
+ an accidental `{ body: 'oops' }`. only the published contract differs, which is why the wrong choice
120
+ ships green.
121
+
122
+ ### genLambdaEndpoint.forSqs
123
+
124
+ a queue, one leaf per cardinality.
125
+
126
+ ```ts
127
+ // one message per invoke — requires batchSize: 1
128
+ export const handler = genLambdaEndpoint.forSqs.perRecord({
129
+ schema: {
130
+ input: z.object({
131
+ headers: z.object({ source: z.string().optional() }), // message attributes
132
+ payload: z.object({ orderId: z.string() }),
133
+ }),
134
+ },
135
+ invoke: async ({ payload, headers }, context) =>
136
+ fulfilOrder({ orderId: payload.orderId, source: headers.source ?? null }, context),
137
+ });
138
+
139
+ // a whole batch per invoke — name the records that succeeded
140
+ export const handler = genLambdaEndpoint.forSqs.perBatch({
141
+ schema: { input: z.object({ payload: z.object({ orderId: z.string() }) }) },
142
+ invoke: async ({ records }, context) => {
143
+ const succeeded = [];
144
+ for (const record of records) {
145
+ await fulfilOrder({ orderId: record.payload.orderId, source: null }, context).then(
146
+ () => succeeded.push(record),
147
+ () => null, // unreported, so sqs retries it
148
+ );
149
+ }
150
+ return { successes: succeeded };
151
+ },
152
+ });
153
+ ```
154
+
155
+ `perBatch` fails safe: any record not returned in `successes` is retried, and an answer the sdk
156
+ cannot read retries the whole batch. its event source must declare
157
+ `functionResponseTypes: ['ReportBatchItemFailures']`.
158
+
159
+ ⇒ zoom in: [records](./.agent/repo=.this/role=any/briefs/domain.terms/records.md)
160
+
29
161
  ## ask an endpoint
30
162
 
31
163
  ```ts
32
164
  import { askLambdaEndpoint } from 'sdk-aws-lambda';
33
165
 
34
166
  const result = await askLambdaEndpoint<TRequest, TResponse>(
35
- {
36
- which: { service: 'svc-jobs', function: 'getJobByUuid' },
37
- event: { uuid },
38
- },
39
- { log, env: { access: 'prep' } }, // access completes the slug; trail auto-propagates
167
+ { which: { service: 'svc-jobs', function: 'getJobByUuid' }, event: { uuid } },
168
+ { log, env: { access: 'prep' } },
40
169
  );
41
170
  ```
42
171
 
172
+ the caller's `trail.exid` rides along, so logs correlate across the call.
173
+
43
174
  ## run an endpoint, in a test
44
175
 
45
176
  | you call | you hold | a caller fault arrives as |
@@ -68,7 +199,7 @@ await expect(
68
199
  {
69
200
  which: { service: 'svc-jobs', function: 'getJobByUuid' },
70
201
  event: { uuid: 'bad' },
71
- at: 'cloud', // or 'local' — resolve the handler from serverless.yml
202
+ at: 'cloud', // or 'local' — look up the handler in serverless.yml
72
203
  },
73
204
  { log, env: { access: 'prep' } },
74
205
  ),
@@ -129,30 +260,29 @@ const event = asLambdaEvent.fromApiGateway({
129
260
 
130
261
  ## introspection
131
262
 
132
- endpoints with zod schemas expose their schema at runtime:
263
+ in `prep`, an endpoint returns its json-schema when asked with `{ introspect: 'schema' }`; in prod
264
+ it throws a `ConstraintError`. `getOneLambdaContract` and `getAllLambdaContracts` collect them for
265
+ sdk generation:
133
266
 
134
267
  ```ts
135
- const schema = await askLambdaEndpoint(
136
- {
137
- which: { service: 'svc-user', function: 'getUser' },
138
- event: { introspect: 'schema' },
139
- },
140
- { log, env: { access: 'prep' } },
268
+ import { getAllLambdaContracts } from 'sdk-aws-lambda';
269
+
270
+ const contracts = await getAllLambdaContracts(
271
+ { which: { service: 'svc-user' } },
272
+ { env: { access: 'prep', region: 'us-east-1' } },
141
273
  );
142
- // returns: { input: {...jsonSchema}, output: {...jsonSchema} }
274
+ // { getUser: {...schema}, getSettings: {...schema} }
143
275
  ```
144
276
 
145
- requires `env.access === 'prep'`. in prod, it throws a `ConstraintError`.
146
-
147
277
  ## validate the input only
148
278
 
149
279
  `schema.output` is required. for an endpoint that returns no value, declare `z.void()`:
150
280
 
151
281
  ```ts
152
- export const handler = genLambdaEndpoint(
282
+ export const handler = genLambdaEndpoint.forAsk(
153
283
  {
154
284
  schema: { input: inputSchema, output: z.void() },
155
- invoke: async ({ event }) => { await doTheWork(event); },
285
+ invoke: async ({ payload }, context) => { await doTheWork({ job: payload }, context); },
156
286
  },
157
287
  { env: { access: 'prep' } },
158
288
  );
@@ -169,10 +299,11 @@ zod yields. no `as` cast, no per-field rebuild:
169
299
  ```ts
170
300
  import { Surfer } from './domain.objects/Surfer';
171
301
 
172
- export const handler = genLambdaEndpoint(
302
+ export const handler = genLambdaEndpoint.forAsk(
173
303
  {
174
304
  schema: { input: z.object({ surfer: Surfer.contract() }), output: z.void() },
175
- invoke: async ({ event }) => bookSurfLesson(event.surfer), // event.surfer instanceof Surfer
305
+ invoke: async ({ payload }, context) =>
306
+ bookSurfLesson({ surfer: payload.surfer }, context), // payload.surfer instanceof Surfer
176
307
  },
177
308
  { env: { access: 'prep' } },
178
309
  );
@@ -211,75 +342,13 @@ static schema = z.object({ replies: z.array(z.lazy(() => Comment.contract())) })
211
342
  z.object({ rider: Surfer.contract().ref('primary') }).optional()
212
343
  ```
213
344
 
214
- ## contract discovery
215
-
216
- ```ts
217
- import { getAllLambdaContracts, getOneLambdaContract } from 'sdk-aws-lambda';
218
-
219
- const contract = await getOneLambdaContract(
220
- { which: { service: 'svc-user', function: 'getUser' } },
221
- { env: { access: 'prep', region: 'us-east-1' } },
222
- );
223
-
224
- const contracts = await getAllLambdaContracts(
225
- { which: { service: 'svc-user' } },
226
- { env: { access: 'prep', region: 'us-east-1' } },
227
- );
228
- // returns: { getUser: {...schema}, getSettings: {...schema} }
229
- ```
230
-
231
- # the http wire response
232
-
233
- `forApiGateway()` handlers own their **exact wire response** — any status, any headers, any body, or
234
- none at all. return an `ApiGatewayResponse`, and it reaches the wire as written.
235
-
236
- ```ts
237
- import { forApiGateway, asApiGatewayResponseSchema } from 'sdk-aws-lambda';
238
-
239
- export const handler = forApiGateway({
240
- schema: {
241
- input: z.any(), // a twilio form blob
242
- output: asApiGatewayResponseSchema({ body: z.undefined() }), // carries no body
243
- },
244
- invoke: async ({ event }) => ({ status: 204 }), // 204, no body
245
- });
246
- ```
247
-
248
- | return | wire |
249
- |---|---|
250
- | `{ body: x }` | 200 + json — the convenient default |
251
- | `{ status: 204 }` | 204, no body, **no `content-type`** |
252
- | `{ status: 308, headers: { Location } }` | a redirect |
253
- | `{ headers: { 'Content-Type': 'text/xml' }, body: xml }` | your bytes, verbatim |
254
- | `{}` | ⛔ a **compile error** — at least one key is required |
255
-
256
- set a `Content-Type` yourself and the serializer stands aside, so xml/text reach the wire
257
- byte-identical. omit it with a body and you get `application/json`.
258
-
259
- ### the body-less response
260
-
261
- `schema.output` describes what `invoke` **returns** (the envelope), so
262
- `asApiGatewayResponseSchema({ body })` wraps a body schema into it.
263
-
264
- for a response that carries **no body at all** — a 204, a redirect — declare the body
265
- `z.undefined()`:
266
-
267
- <!-- prettier-ignore -->
268
- | you declare | the published `body` slot | reads as |
269
- |---|---|---|
270
- | `z.undefined()` · `z.void()` · `z.never()` | `{ "not": {} }` | **"no body is ever carried"** |
271
- | `z.any()` · `z.unknown()` | `{}` | ⛔ the rubber-stamp — every value reads as valid |
272
- | `z.null()` | `{ "type": "null" }` | ⛔ claims the wire carries the four bytes `null` |
273
-
274
- all of them behave identically at **runtime**: each accepts `{ status: 204 }` and each still refuses
275
- an accidental `{ body: 'oops' }`. only the published contract differs, which is why the wrong choice
276
- ships green.
277
-
278
345
  # features
279
346
 
280
347
  - **genLambdaEndpoint** — define endpoints with validation, log capture, error classification
281
- - `genLambdaEndpoint()` — direct invoke (default)
282
- - `forApiGateway()` — http via api gateway, with full wire-response control (above)
348
+ - `genLambdaEndpoint.forAsk()` — direct invoke
349
+ - `genLambdaEndpoint.forApiGateway()` — http via api gateway, with full wire-response control
350
+ - `genLambdaEndpoint.forSqs.perRecord()` — one queue message per invoke
351
+ - `genLambdaEndpoint.forSqs.perBatch()` — a whole queue batch per invoke, fail-safe
283
352
  - **domain objects at the border** — `X.contract()` in a schema hands `invoke` real instances, at
284
353
  every depth, with no `as` cast (above)
285
354
  - **askLambdaEndpoint** — ask another lambda with typed request/response, automatic trail propagation
@@ -288,14 +357,16 @@ ships green.
288
357
  - `onSerialized()` — you hold the slug; a caller fault **throws**. `at: 'cloud' | 'local'`
289
358
  - **asLambdaEvent** — cast a payload into the envelope aws delivers, wire-faithful by default
290
359
  - `fromApiGateway()`, `fromSqs()`, `fromSns()`, `fromKinesis()`, `fromS3()`
291
- - **trace-id propagation** — pass `log`, and `trail.exid` threads through the call chain
292
- - **introspection** — expose json-schema via `{ introspect: 'schema' }` (prep only)
293
- - **contract discovery** — `getOneLambdaContract`, `getAllLambdaContracts` for sdk generation
360
+ - **trace-id propagation** — pass `log`, and `trail.exid` threads through the lambda-to-lambda call
361
+ chain. http and sqs triggers mint a fresh `exid` per invoke
362
+ - **introspection** — expose json-schema via `{ introspect: 'schema' }` (prep only), collected by
363
+ `getOneLambdaContract` / `getAllLambdaContracts` for sdk generation
294
364
 
295
365
  # docs
296
366
 
297
367
  design records, on github only — they ship in no tarball.
298
368
 
369
+ - [domain terms](./.agent/repo=.this/role=any/briefs/domain.terms/.readme.md) — `payload`, `headers`, `event`, `records`, `trail`, and the edge cases of each
299
370
  - [run boundary](./.agent/repo=.this/role=any/briefs/define.lambda-endpoint-run-boundary.md) — serialized vs referenced, and why the error stance inverts
300
371
  - [event source](./.agent/repo=.this/role=any/briefs/define.lambda-event-source.md) — which envelope each aws source wraps a payload in
301
372
  - [wire response](./.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md) — how the api-gateway response contract was shaped
@@ -1,12 +0,0 @@
1
- import type { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from 'aws-lambda';
2
- /**
3
- * .what = the wire payload an api-gateway trigger delivers, either version
4
- * .why = api gateway ships two incompatible request shapes (rest/v1, http/v2), and a
5
- * handler must be able to name the shape as it LANDS, before any translate runs
6
- *
7
- * .note = this is the `inputBefore` point: the untouched bytes-as-parsed, before the
8
- * input translator. its peer at the other end of the pipeline is
9
- * `ApiGatewayResponsePayload` — request/response, each qualified by `Payload`
10
- * to mark it as the wire form
11
- */
12
- export type ApiGatewayRequestPayload = APIGatewayProxyEvent | APIGatewayProxyEventV2;
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApiGatewayRequestPayload.js","sourceRoot":"","sources":["../../src/domain.objects/ApiGatewayRequestPayload.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApiGatewayResponsePayload.js","sourceRoot":"","sources":["../../src/domain.objects/ApiGatewayResponsePayload.ts"],"names":[],"mappings":""}
@@ -1,36 +0,0 @@
1
- import type { ApiGatewayRequestPayload } from '../../../domain.objects/ApiGatewayRequestPayload';
2
- /**
3
- * .what = an api-gateway request with v1/v2 differences reconciled
4
- * .why = v1 puts the method at `httpMethod` and v2 at `requestContext.http.method`. a
5
- * handler that reads either directly is version-locked, so the sdk reconciles them
6
- * once and hands over one shape
7
- *
8
- * .note = `Unified` carries weight, never decoration: this is NOT the wire shape. the wire
9
- * shape is `ApiGatewayRequestPayload`, the raw v1|v2 union. this is a step the
10
- * default input translator takes on the way to `inputAfter`
11
- */
12
- export interface UnifiedApiGatewayEvent {
13
- httpMethod: string;
14
- path: string;
15
- headers: Record<string, string | undefined>;
16
- queryStringParameters: Record<string, string | undefined> | null;
17
- pathParameters: Record<string, string | undefined> | null;
18
- body: unknown;
19
- rawBody: string | null;
20
- isBase64Encoded: boolean;
21
- requestContext: {
22
- requestId: string;
23
- stage: string;
24
- domainName?: string;
25
- accountId?: string;
26
- };
27
- /**
28
- * .what = the ejection route — the wire payload, before this shape reconciled it
29
- * .why = `_` marks it as an escape hatch rather than a paved path. every field above is
30
- * version-agnostic; reach in here and you are version-locked again, so a reader who
31
- * sees `_` knows they have left the supported surface
32
- */
33
- _: {
34
- raw: ApiGatewayRequestPayload;
35
- };
36
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"UnifiedApiGatewayEvent.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.ts"],"names":[],"mappings":""}
@@ -1,19 +0,0 @@
1
- import type { ApiGatewayResponse } from '../../../domain.objects/ApiGatewayResponse';
2
- import type { ApiGatewayResponsePayload } from '../../../domain.objects/ApiGatewayResponsePayload';
3
- /**
4
- * .what = the default output translator: what `invoke` returns becomes the wire payload
5
- *
6
- * .note = `status` defaults HERE, ahead of every middleware — middy's `normalizeHttpResponse`
7
- * applies `statusCode ??= 500`, so a later default would put a server-fault on the wire
8
- * for a handler that meant 200
9
- *
10
- * .note = `body` is OMITTED, never `''` — the serializer would encode `''` into `'""'`. it is
11
- * left as the DOMAIN value for the serializer to encode one step later, which is what
12
- * lets a handler's own `Content-Type` carry bytes through untouched
13
- *
14
- * ⚠️ the omission holds at the WIRE, not mid-chain: the serializer re-adds `body` as an
15
- * own key with value `undefined`. benign, and visible in the unit snapshots
16
- */
17
- export declare const asApiGatewayResponsePayload: <TBody>(input: {
18
- response: ApiGatewayResponse<TBody>;
19
- }) => ApiGatewayResponsePayload<TBody>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asApiGatewayResponsePayload = void 0;
4
- /**
5
- * .what = the default output translator: what `invoke` returns becomes the wire payload
6
- *
7
- * .note = `status` defaults HERE, ahead of every middleware — middy's `normalizeHttpResponse`
8
- * applies `statusCode ??= 500`, so a later default would put a server-fault on the wire
9
- * for a handler that meant 200
10
- *
11
- * .note = `body` is OMITTED, never `''` — the serializer would encode `''` into `'""'`. it is
12
- * left as the DOMAIN value for the serializer to encode one step later, which is what
13
- * lets a handler's own `Content-Type` carry bytes through untouched
14
- *
15
- * ⚠️ the omission holds at the WIRE, not mid-chain: the serializer re-adds `body` as an
16
- * own key with value `undefined`. benign, and visible in the unit snapshots
17
- */
18
- const asApiGatewayResponsePayload = (input) => ({
19
- statusCode: input.response.status ?? 200,
20
- ...(input.response.headers ? { headers: input.response.headers } : {}),
21
- ...('body' in input.response ? { body: input.response.body } : {}),
22
- });
23
- exports.asApiGatewayResponsePayload = asApiGatewayResponsePayload;
24
- //# sourceMappingURL=asApiGatewayResponsePayload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"asApiGatewayResponsePayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;GAaG;AACI,MAAM,2BAA2B,GAAG,CAAQ,KAElD,EAAoC,EAAE,CAAC,CAAC;IACvC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG;IACxC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CACnE,CAAC,CAAC;AANU,QAAA,2BAA2B,+BAMrC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"asApiGatewayResponsePayloadJson.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayloadJson.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,+BAA+B,GAAG,CAAC,KAG/C,EAA6B,EAAE,CAAC,CAAC;IAChC,UAAU,EAAE,KAAK,CAAC,MAAM;IACxB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;CAChD,CAAC,CAAC;AAPU,QAAA,+BAA+B,mCAOzC"}
@@ -1,27 +0,0 @@
1
- import type { ApiGatewayRequestPayload } from '../../../domain.objects/ApiGatewayRequestPayload';
2
- import type { UnifiedApiGatewayEvent } from './UnifiedApiGatewayEvent';
3
- /**
4
- * .what = what `deserialize` means when a caller declares none — ONE declaration, read by both
5
- * this transformer and `forApiGateway`'s config (rule.forbid.parallel-codepaths)
6
- * .why body = json is the common case, and a caller who wants the raw string opts out by value:
7
- * `deserialize: { body: false }`
8
- */
9
- export declare const DESERIALIZE_DEFAULT: {
10
- body: boolean;
11
- };
12
- /**
13
- * .what = reconciles either api-gateway payload version into one shape
14
- * .why = the chain must read one shape whichever version the trigger delivered, so this runs
15
- * first and every step after it reads `UnifiedApiGatewayEvent`
16
- *
17
- * .note = a named transformer rather than middleware-local logic, so ONE implementation serves
18
- * both entry points — `genApiGatewayEventNormalizationMiddleware` delegates here
19
- * (rule.forbid.parallel-codepaths)
20
- */
21
- export declare const asUnifiedApiGatewayEvent: (input: {
22
- payload: ApiGatewayRequestPayload;
23
- }, options?: {
24
- deserialize: {
25
- body: boolean;
26
- };
27
- }) => UnifiedApiGatewayEvent;
@@ -1,118 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asUnifiedApiGatewayEvent = exports.DESERIALIZE_DEFAULT = void 0;
4
- const helpful_errors_1 = require("helpful-errors");
5
- const getIsV1ApiGatewayEvent_1 = require("./getIsV1ApiGatewayEvent");
6
- const getIsV2ApiGatewayEvent_1 = require("./getIsV2ApiGatewayEvent");
7
- /**
8
- * .what = parses a json body string into an object, base64-decoded first when flagged
9
- * .why = api gateway hands the body over as a string; most handlers want the object
10
- *
11
- * .note = a body that is not json is returned as the decoded string rather than refused —
12
- * a form-encoded twilio webhook is a legitimate caller, and its own schema (or
13
- * `z.any()`) is where that shape gets judged
14
- */
15
- const asParsedApiGatewayBody = (input) => {
16
- if (!input.body)
17
- return null;
18
- const decoded = input.isBase64Encoded
19
- ? Buffer.from(input.body, 'base64').toString('utf-8')
20
- : input.body;
21
- try {
22
- return JSON.parse(decoded);
23
- }
24
- catch (error) {
25
- /**
26
- * .what = allowlists the ONE error a non-json body can raise, and rethrows every other
27
- * .why = a bare `catch` would swallow a TypeError from a real defect, and the swallowed
28
- * value would reach the handler as plain text (rule.forbid.failhide). `SyntaxError`
29
- * is the only class `JSON.parse` throws for malformed input, per ecma-262 §25.5.1,
30
- * so the allowlist is exhaustive rather than a guess
31
- */
32
- if (!(error instanceof SyntaxError))
33
- throw error;
34
- return decoded;
35
- }
36
- };
37
- /**
38
- * .what = reconciles either payload version into the unified shape, given the TWO values the
39
- * versions disagree about
40
- * .why = v1 and v2 differ in exactly two places — the method and path, top-level on v1 and
41
- * under `requestContext.http` on v2. every OTHER field sits at the same path on both, so
42
- * one function serves both and the unified shape gains a new field in ONE place
43
- *
44
- * .note = the two disputed values are handed in as plain strings rather than read through a
45
- * per-version extractor, which would restore the duplication in a less legible form
46
- */
47
- const asUnifiedEvent = (input) => ({
48
- httpMethod: input.httpMethod,
49
- path: input.path,
50
- /**
51
- * .as = v1 declares `headers` REQUIRED and v2 declares it optional, so the union's member is
52
- * `… | undefined`, which the unified shape does not carry
53
- * .removal = drops once `UnifiedApiGatewayEvent.headers` is itself optional. left because
54
- * every consumer reads `event.headers[x]`, and `@middy/http-cors` reads this slot too
55
- * (rule.require.read-the-slot-a-dependency-reads) — so the change is not local
56
- */
57
- headers: input.payload.headers,
58
- queryStringParameters: input.payload.queryStringParameters ?? null,
59
- pathParameters: input.payload.pathParameters ?? null,
60
- body: input.deserialize.body
61
- ? asParsedApiGatewayBody({
62
- body: input.payload.body,
63
- isBase64Encoded: input.payload.isBase64Encoded,
64
- })
65
- : input.payload.body,
66
- rawBody: input.payload.body ?? null,
67
- isBase64Encoded: input.payload.isBase64Encoded,
68
- requestContext: {
69
- requestId: input.payload.requestContext.requestId,
70
- stage: input.payload.requestContext.stage,
71
- domainName: input.payload.requestContext.domainName,
72
- accountId: input.payload.requestContext.accountId,
73
- },
74
- _: { raw: input.payload },
75
- });
76
- /**
77
- * .what = what `deserialize` means when a caller declares none — ONE declaration, read by both
78
- * this transformer and `forApiGateway`'s config (rule.forbid.parallel-codepaths)
79
- * .why body = json is the common case, and a caller who wants the raw string opts out by value:
80
- * `deserialize: { body: false }`
81
- */
82
- exports.DESERIALIZE_DEFAULT = { body: true };
83
- /**
84
- * .what = reconciles either api-gateway payload version into one shape
85
- * .why = the chain must read one shape whichever version the trigger delivered, so this runs
86
- * first and every step after it reads `UnifiedApiGatewayEvent`
87
- *
88
- * .note = a named transformer rather than middleware-local logic, so ONE implementation serves
89
- * both entry points — `genApiGatewayEventNormalizationMiddleware` delegates here
90
- * (rule.forbid.parallel-codepaths)
91
- */
92
- const asUnifiedApiGatewayEvent = (input, options) => {
93
- const deserialize = options?.deserialize ?? exports.DESERIALIZE_DEFAULT;
94
- // v2 http-api: the method and path live under `requestContext.http`
95
- if ((0, getIsV2ApiGatewayEvent_1.getIsV2ApiGatewayEvent)(input.payload)) {
96
- const payload = input.payload;
97
- return asUnifiedEvent({
98
- payload,
99
- httpMethod: payload.requestContext.http.method,
100
- path: payload.requestContext.http.path,
101
- deserialize,
102
- });
103
- }
104
- // v1 rest-api: the method and path live at the top level
105
- if ((0, getIsV1ApiGatewayEvent_1.getIsV1ApiGatewayEvent)(input.payload)) {
106
- const payload = input.payload;
107
- return asUnifiedEvent({
108
- payload,
109
- httpMethod: payload.httpMethod,
110
- path: payload.path,
111
- deserialize,
112
- });
113
- }
114
- // fail loud rather than hand a handler a shape neither branch produced
115
- return helpful_errors_1.MalfunctionError.throw('payload is neither v1 nor v2 api gateway event shaped', { payload: input.payload });
116
- };
117
- exports.asUnifiedApiGatewayEvent = asUnifiedApiGatewayEvent;
118
- //# sourceMappingURL=asUnifiedApiGatewayEvent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"asUnifiedApiGatewayEvent.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.ts"],"names":[],"mappings":"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"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAllWirePayloadKeysFound = void 0;
4
- /**
5
- * .what = the wire keys a mid-migration consumer writes from habit, every one of which the
6
- * encode would drop without a word
7
- *
8
- * .note = `statusCode` is the severe one — the one field whose name changed (`status`), so
9
- * `status ?? 200` replaces a caller's 404 with a 200 AND double-encodes the body they
10
- * already stringified. the rest are deferred keys (F7), quieter but equally silent
11
- *
12
- * .note = a `Record<K, true>` rather than a `string[]`, so the compiler holds it EXHAUSTIVE: a
13
- * list proves each entry is real and says not one word about one being ABSENT, which is
14
- * the drift that matters. clamp proven to bite — drop a key and tsc raises TS2741
15
- */
16
- const IS_KEY_OF_WIRE_PAYLOAD_UNREAD = {
17
- statusCode: true,
18
- multiValueHeaders: true,
19
- isBase64Encoded: true,
20
- cookies: true,
21
- };
22
- /**
23
- * .what = the same list, as keys
24
- * .why = one source of truth, so the exhaustive map and the iterated list cannot drift apart
25
- */
26
- const KEYS_OF_WIRE_PAYLOAD = Object.keys(IS_KEY_OF_WIRE_PAYLOAD_UNREAD);
27
- /**
28
- * .what = lists which aws wire-payload keys a handler's response carries
29
- * .why = one detector, so the public type-check and the handler-side guard cannot drift. the
30
- * check needs a boolean; the guard needs the key NAMES to tell the author the fix
31
- */
32
- const getAllWirePayloadKeysFound = (input) => KEYS_OF_WIRE_PAYLOAD.filter((key) => key in input.response);
33
- exports.getAllWirePayloadKeysFound = getAllWirePayloadKeysFound;
34
- //# sourceMappingURL=getAllWirePayloadKeysFound.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getAllWirePayloadKeysFound.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllWirePayloadKeysFound.ts"],"names":[],"mappings":";;;AAgBA;;;;;;;;;;;GAWG;AACH,MAAM,6BAA6B,GAAyC;IAC1E,UAAU,EAAE,IAAI;IAChB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,IAAI;IACrB,OAAO,EAAE,IAAI;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,oBAAoB,GAAa,MAAM,CAAC,IAAI,CAChD,6BAA6B,CAC9B,CAAC;AAEF;;;;GAIG;AACI,MAAM,0BAA0B,GAAG,CAAC,KAE1C,EAAY,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;AAF/D,QAAA,0BAA0B,8BAEqC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getIsV1ApiGatewayEvent.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV1ApiGatewayEvent.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,sBAAsB,GAAG,CACpC,KAAc,EACiB,EAAE;IACjC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,GAAG,GAAG,KAAgC,CAAC;IAE7C,iEAAiE;IACjE,OAAO,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,CAAC;AAC5C,CAAC,CAAC;AARW,QAAA,sBAAsB,0BAQjC"}