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,18 @@
1
+ import type { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from 'aws-lambda';
2
+ /**
3
+ * .what = the wire form 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
+ * `ApiGatewayResponseOnwire` — request/response, each qualified by `Onwire` to mark
10
+ * it as the form on the wire
11
+ *
12
+ * .note = `Onwire` replaced a `Payload` suffix here. `payload` is http's word for a message
13
+ * BODY (rfc 9110, "payload body"), and this value is the whole message — so the
14
+ * old suffix claimed the wrong level inside an http family. `Onwire` qualifies a
15
+ * POSITION, exactly as `Unified` does, so no later step can falsify it
16
+ * (`domain.terms/payload.md`)
17
+ */
18
+ export type ApiGatewayRequestEventOnwire = APIGatewayProxyEvent | APIGatewayProxyEventV2;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ApiGatewayRequestEventOnwire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiGatewayRequestEventOnwire.js","sourceRoot":"","sources":["../../src/domain.objects/ApiGatewayRequestEventOnwire.ts"],"names":[],"mappings":""}
@@ -7,24 +7,31 @@ import type { PickAny } from 'type-fns';
7
7
  * would reach middy's `normalizeHttpResponse` and pick up `statusCode ??= 500` — a
8
8
  * silent server-fault on the wire for code that returned success
9
9
  */
10
- export type ApiGatewayResponse<TBody> = PickAny<{
10
+ export type ApiGatewayResponse<TPayload> = PickAny<{
11
11
  /** .note = omit for 200 */
12
12
  status: number;
13
13
  /**
14
14
  * .note = set `Content-Type` to take the body verbatim; the serializer skips a response that
15
15
  * already declares one. omit it and the body is json-encoded for you
16
16
  *
17
- * ⚠️ .note = ONE VALUE PER HEADER, so a header that must repeat (`Set-Cookie`) cannot be
18
- * expressed — a `Record` key is unique, and js drops the earlier value with no
19
- * warn. aws carries repeats in `multiValueHeaders` (v1) / `cookies` (v2); this
20
- * contract declares neither, and `getAllWirePayloadKeysFound` REFUSES both loudly
21
- * so the attempt fails fast. deferred, not denied — each is one additive key (F7)
17
+ * .note = one value per header, so a header that must repeat (`Set-Cookie`) cannot be
18
+ * expressed — a `Record` key is unique, and js drops the earlier value with no warn.
19
+ * aws carries repeats in `multiValueHeaders` (v1) / `cookies` (v2); this contract
20
+ * declares neither, and `getAllResponseOnwireKeysFound` refuses both loudly so the
21
+ * attempt fails fast. deferred, not denied — each is one additive key
22
22
  */
23
23
  headers: Record<string, string>;
24
24
  /**
25
- * ⚠️ .note = OMIT the key for no body. an explicit `body: ''` is a different value — a real
26
- * two-byte json `""` under `application/json`, which is coherent but is not
27
- * body-less. `[case10]` of `local.wireResponse.acceptance.test.ts` pins both
25
+ * .what = the response body, in the handler's own terms — json-encoded for you unless the
26
+ * response declares its own `Content-Type`
27
+ * .why `payload` and not `body` = one word per concept, in both directions. the inbound
28
+ * envelope's body is `payload` (`domain.terms/payload.md`), and a response whose body
29
+ * answered to a second word would make the sdk speak two languages across one
30
+ * round-trip. `ApiGatewayResponseOnwire.body` keeps `body` because that key is aws's
31
+ *
32
+ * .note = omit the key for no body. an explicit `payload: ''` is a different value — a real
33
+ * two-byte json `""` under `application/json`, which is coherent but is not
34
+ * body-less. `[case10]` of `local.httpResponse.acceptance.test.ts` pins both
28
35
  */
29
- body: TBody;
36
+ payload: TPayload;
30
37
  }>;
@@ -1,6 +1,6 @@
1
1
  import type { APIGatewayProxyResult } from 'aws-lambda';
2
2
  /**
3
- * .what = the wire payload api gateway receives back
3
+ * .what = the wire form api gateway receives back
4
4
  * .why = names the `outputAfter` point — what lands on the wire, after the output
5
5
  * translator has run. by here the body is a `string`, whatever domain type it
6
6
  * held before, so its contents are opaque
@@ -18,13 +18,17 @@ import type { APIGatewayProxyResult } from 'aws-lambda';
18
18
  * .note = `TBody` is PARAMETERIZED because the body is encoded one step later than the
19
19
  * output translator runs, so this shape occurs twice in the chain:
20
20
  *
21
- * ApiGatewayResponsePayload<TBody> <- `outputAfter`, what the translator yields
21
+ * ApiGatewayResponseOnwire<TBody> <- `outputAfter`, what the translator yields
22
22
  * ↓ the response serializer — an sdk-internal step, not a model point
23
- * ApiGatewayResponsePayload <- what aws receives; the body is bytes
23
+ * ApiGatewayResponseOnwire <- what aws receives; the body is bytes
24
24
  *
25
25
  * it defaults to `string` so the bare name reads as the wire shape. the serializer
26
26
  * sits OUTSIDE the four points, mirror to the trail read which sits before them
27
+ *
28
+ * .note = `Onwire` replaced a `Payload` suffix here, for the reason its request peer records
29
+ * (`ApiGatewayRequestEventOnwire`): `payload` is http's word for a BODY, and this is the
30
+ * whole message
27
31
  */
28
- export type ApiGatewayResponsePayload<TBody = string> = Omit<APIGatewayProxyResult, 'body'> & {
32
+ export type ApiGatewayResponseOnwire<TBody = string> = Omit<APIGatewayProxyResult, 'body'> & {
29
33
  body?: TBody;
30
34
  };
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ApiGatewayRequestPayload.js.map
3
+ //# sourceMappingURL=ApiGatewayResponseOnwire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiGatewayResponseOnwire.js","sourceRoot":"","sources":["../../src/domain.objects/ApiGatewayResponseOnwire.ts"],"names":[],"mappings":""}
@@ -0,0 +1,125 @@
1
+ import type { FrozenDeep } from './setEventFrozen';
2
+ /**
3
+ * .what = the shapes one family binds into the superset — its own types, per slot
4
+ * .why = the superset must be checkable against a variant that carries real types, never against
5
+ * `unknown`. a superset of `unknown` slots accepts every shape, so it would clamp the
6
+ * names and let the shapes diverge — half the rule, read as all of it
7
+ * (`rule.require.measure-the-value-you-emit`)
8
+ *
9
+ * .note = a family binds `never` for a slot it excludes. the excluded slot is then unreachable
10
+ * rather than merely absent, so a later author who lifts it cannot bind a shape by
11
+ * accident and must state one
12
+ */
13
+ export interface InvokeShapes {
14
+ /** the metadata bag the transport carried beside the body */
15
+ headers: unknown;
16
+ /** the body, parsed and validated */
17
+ payload: unknown;
18
+ /** the whole object that arrived */
19
+ event: unknown;
20
+ /** one message of a batch, for a family whose trigger delivers many */
21
+ record: unknown;
22
+ }
23
+ /**
24
+ * .what = the superset every `genLambdaEndpoint.for*` variant's `invoke` input is a subset of
25
+ * .why = one family, one vocabulary. a variant may carry fewer slots than this names; it may
26
+ * never carry a slot this does not name, nor the same slot under a different shape
27
+ * (`rule.require.consistent-variant-contracts`)
28
+ *
29
+ * .why a superset and not a base type every variant extends = a variant that extends a base
30
+ * inherits every slot, so an exclusion becomes unexpressible and each family would owe a
31
+ * `never`-typed slot it does not have. the subset direction is what makes "exclusions
32
+ * allowed" and "divergences forbidden" one rule rather than two
33
+ *
34
+ * .note = `trail` is absent, deliberately and permanently. the lineage is ambient, so it rides
35
+ * `context.log.trail` — an `input.trail` slot is forbidden in every family, so the
36
+ * superset must not name one (`domain.terms/trail.md`)
37
+ *
38
+ * .note = every slot is `FrozenDeep`, because every value handed to an `invoke` is deep-frozen
39
+ * in every family (`rule.require.frozen-invoke-inputs`)
40
+ * .note = the freeze is NOT clampable from here, measured: typescript ignores the `readonly`
41
+ * modifier in assignability, in both directions — `{ to: string }` is assignable to
42
+ * `{ readonly to: string }` and back. so a variant that drops `FrozenDeep` from a slot
43
+ * still satisfies this superset, and a bite check written for it goes TS2578 rather than
44
+ * red (`InvokeInputSuperset.test.ts [case2][t1]`). the freeze is held by each variant's
45
+ * own `@ts-expect-error` depth arm instead; this superset clamps a slot's NAME and its
46
+ * VALUE TYPE, and naught else
47
+ */
48
+ export type InvokeInputSuperset<TShapes extends InvokeShapes> = {
49
+ /** the metadata bag — lowercased at http, verbatim at sqs; the case is the transport's */
50
+ headers: FrozenDeep<TShapes['headers']>;
51
+ /** the body, parsed and validated against `schema.input`'s `payload` half */
52
+ payload: FrozenDeep<TShapes['payload']>;
53
+ /** the whole object that arrived — the one slot every family carries */
54
+ event: FrozenDeep<TShapes['event']>;
55
+ /** the messages that passed validation, for a batch-grained family */
56
+ records: FrozenDeep<TShapes['record'][]>;
57
+ };
58
+ /**
59
+ * .what = the shape `event` must hold in every family — an envelope that CARRIES the body
60
+ * .why = `event` means the whole object that arrived, and the body is one slot of it: at
61
+ * `event.payload` for a family with one message, at `event.records[i].payload` for a
62
+ * family with many (`domain.terms/event.md`). a value with neither is the body itself
63
+ * under the envelope's name, which is the one-word-two-senses defect the rule forbids
64
+ */
65
+ export type InvokeEventEnvelope = {
66
+ readonly payload: unknown;
67
+ } | {
68
+ readonly records: readonly {
69
+ readonly payload: unknown;
70
+ }[];
71
+ };
72
+ /**
73
+ * .what = the body an envelope carries — the single message's, or one record's
74
+ */
75
+ type BodyOfEnvelope<TEvent> = TEvent extends {
76
+ readonly payload: infer P;
77
+ } ? P : TEvent extends {
78
+ readonly records: readonly (infer R)[];
79
+ } ? R extends {
80
+ readonly payload: infer P;
81
+ } ? P : never : never;
82
+ /**
83
+ * .what = the SENSE half of the verdict: `event` is an envelope, and a lifted `payload` is its body
84
+ * .why = conditions 1 and 2 compare a variant against shapes the caller of the gate SUPPLIES, so
85
+ * a variant that bound `event` to its body passed them both — the caller simply supplied the
86
+ * body as the event shape. this condition reads the contract's own input and needs no
87
+ * supplied shape, so it cannot be satisfied by a wrong bind
88
+ */
89
+ type SatisfiesInvokeInputSense<TInput> = 'event' extends keyof TInput ? TInput['event' & keyof TInput] extends InvokeEventEnvelope ? 'payload' extends keyof TInput ? [TInput['payload' & keyof TInput]] extends [
90
+ BodyOfEnvelope<TInput['event' & keyof TInput]>
91
+ ] ? true : {
92
+ ERROR: 'the lifted `payload` is not the body `event` carries — lift `event.payload` (or that of one of `event.records`), never a second value';
93
+ got: TInput['payload' & keyof TInput];
94
+ want: BodyOfEnvelope<TInput['event' & keyof TInput]>;
95
+ } : true : {
96
+ ERROR: '`event` DIVERGES in sense — it must be the whole object that arrived, with the body at `event.payload` or `event.records[i].payload`. hand the body as `payload`';
97
+ got: TInput['event' & keyof TInput];
98
+ } : true;
99
+ /**
100
+ * .what = the compile-time verdict on one variant: is its `invoke` input a subset of the
101
+ * superset, in name, shape, and sense?
102
+ * .why = it resolves to `true` when the variant conforms and to a named error object when it does
103
+ * not — so the failure reads as the sentence the rule states rather than as a bare
104
+ * `TS2322: 'false' is not assignable to 'true'` (`rule.require.errors-name-the-fix`)
105
+ *
106
+ * .how = three conditions, in the order a reader should check them:
107
+ * 1. terminology — every key it carries is a key the superset names
108
+ * 2. shape — its value at each shared key is the superset's value at that key
109
+ * 3. sense — `event` is an envelope that carries the body, and a lifted `payload` is
110
+ * that body (`SatisfiesInvokeInputSense`)
111
+ *
112
+ * .note = condition 2 is checked over `keyof TInput` alone, never over the whole superset. that
113
+ * is what makes an exclusion legal: a slot the variant omits is never compared
114
+ * .note = condition 3 cannot tell a body that happens to hold a `payload` key from an envelope.
115
+ * the per-family `payload === event.payload` identity cases close that at runtime
116
+ */
117
+ export type SatisfiesInvokeInputSuperset<TInput, TShapes extends InvokeShapes> = keyof TInput extends keyof InvokeInputSuperset<TShapes> ? TInput extends Pick<InvokeInputSuperset<TShapes>, keyof TInput & keyof InvokeInputSuperset<TShapes>> ? SatisfiesInvokeInputSense<TInput> : {
118
+ ERROR: 'a slot DIVERGES in shape from the superset — rename it, or correct its type';
119
+ got: TInput;
120
+ want: Pick<InvokeInputSuperset<TShapes>, keyof TInput & keyof InvokeInputSuperset<TShapes>>;
121
+ } : {
122
+ ERROR: 'a slot DIVERGES in name — the superset does not name it. add it there, or reuse the extant word';
123
+ excess: Exclude<keyof TInput, keyof InvokeInputSuperset<TShapes>>;
124
+ };
125
+ export {};
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=UnifiedApiGatewayEvent.js.map
3
+ //# sourceMappingURL=InvokeInputSuperset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvokeInputSuperset.js","sourceRoot":"","sources":["../../../src/domain.operations/genLambdaEndpoint/InvokeInputSuperset.ts"],"names":[],"mappings":""}
@@ -5,23 +5,6 @@
5
5
  *
6
6
  * .note = these are untyped on purpose. a log projection runs over whatever the chain holds
7
7
  * at that moment, which for an error path is neither of the declared output shapes
8
- *
9
- * .note = this type once sat in a `Translate.ts` beside a `Translate<TShapes>` interface, a
10
- * `LambdaEndpointShapes` bag, and a `Translator<TFrom, TInto>` alias — a config
11
- * namespace for the four translator boundaries an endpoint has. those three shipped
12
- * with ZERO production consumers, because the input-side translator they existed to
13
- * type never landed: its home in the middy chain is unresolved (`request.event` is
14
- * read by `@middy/http-cors` in its `after` hook, so the natural seam starves cors).
15
- * so they were dead declarations, below the rule of three
16
- * (rule.prefer.wet-over-dry), and they are deleted rather than shipped.
17
- *
18
- * the DESIGN is not lost — the four points (`inputBefore` / `inputAfter` /
19
- * `outputBefore` / `outputAfter`), the tri-state (absent = default, `false` =
20
- * disarmed, function = yours), and the structural-bind rationale are recorded in
21
- * `1.vision.yield.md`. a term costs one line to restore from there; a dead
22
- * declaration costs every reader who meets it. `TranslateLog` stays because it is
23
- * the one member with real consumers — `logTranslate` on both endpoint families and
24
- * on `genIoLoggerMiddleware`, plus a public export.
25
8
  */
26
9
  export interface TranslateLog {
27
10
  input?: (payload: unknown) => unknown;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * .what = the `genLambdaEndpoint` family — every variant, reachable under one name
3
+ * .why = a family's name must belong to the family, never to one of its variants
4
+ * (`rule.forbid.unqualified-variant-exports`). a variant that takes the family name
5
+ * leaves its peers with none to qualify, so the next peer ships bare and preposition-led
6
+ *
7
+ * genLambdaEndpoint.forAsk({ … }) // a direct invoke
8
+ * genLambdaEndpoint.forApiGateway({ … }) // http, via api gateway
9
+ * genLambdaEndpoint.forSqs.perRecord({ … }) // one queue message per invoke
10
+ * genLambdaEndpoint.forSqs.perBatch({ … }) // the whole batch per invoke
11
+ *
12
+ * .note = a plain object, with no callable default: one call form per variant, so a caller
13
+ * always names the trigger it serves
14
+ *
15
+ * .note = `forSqs` is a sub-family rather than a variant, because the sqs trigger forces a
16
+ * cardinality choice no other trigger does — an invoke carries N messages. so the
17
+ * trigger names an object and the cardinality names its leaves
18
+ * (`genLambdaEndpoint.forSqs.ts`)
19
+ */
20
+ export declare const genLambdaEndpoint: {
21
+ forAsk: <TInput, TOutput, TInputBefore = TInput>(input: import("./genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk").GenLambdaEndpointInput<TInput, TOutput, TInputBefore>, context?: import("../..").ContextAwsLambdaServer | undefined) => import("@middy/core").MiddyfiedHandler<import("./genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk").LambdaHandlerInput<TInputBefore>, TOutput, Error, import("aws-lambda").Context>;
22
+ forApiGateway: <THeaders extends import("./genLambdaEndpoint.forApiGateway/ApiGatewayRequestEventUnified").ApiGatewayHeadersDeclared, TPayload, TBody>(config: import("./genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway").ForApiGatewayInput<THeaders, TPayload, TBody>, context?: import("../..").ContextAwsLambdaServer | undefined) => import("@middy/core").MiddyfiedHandler<import("../..").ApiGatewayRequestEventOnwire, import("../..").ApiGatewayResponseOnwire, Error, import("aws-lambda").Context>;
23
+ forSqs: {
24
+ perRecord: <THeaders_1 extends import("./genLambdaEndpoint.forSqs/SqsEventDecoded").SqsHeadersDeclared, TPayload_1>(config: import("./genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord").ForSqsPerRecordInput<THeaders_1, TPayload_1>, context?: import("../..").ContextAwsLambdaServer | undefined) => import("@middy/core").MiddyfiedHandler<import("aws-lambda").SQSEvent, void, Error, import("aws-lambda").Context>;
25
+ perBatch: <THeaders_2 extends import("./genLambdaEndpoint.forSqs/SqsEventDecoded").SqsHeadersDeclared, TPayload_2>(config: import("./genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch").ForSqsPerBatchInput<THeaders_2, TPayload_2>, context?: import("../..").ContextAwsLambdaServer | undefined) => import("@middy/core").MiddyfiedHandler<import("aws-lambda").SQSEvent, import("aws-lambda").SQSBatchResponse, Error, import("aws-lambda").Context>;
26
+ };
27
+ };
@@ -0,0 +1,100 @@
1
+ import type { ApiGatewayRequestEventOnwire } from '../../../domain.objects/ApiGatewayRequestEventOnwire';
2
+ /**
3
+ * .what = the header bag as the wire carries it — every key api gateway delivered
4
+ * .why = one named shape for seven sites (two envelope slots, two `asHeaderKeysLowercased`
5
+ * signatures, three type-parameter bounds), so the compiler keeps them in sync.
6
+ * `| undefined` forces a check at every index, since an unsent key reads as absent
7
+ */
8
+ export type ApiGatewayHeadersOnwire = Record<string, string | undefined>;
9
+ /**
10
+ * .what = the shape an author's `schema.input.headers` may name — the wire bag, or absent
11
+ * .why = absent denotes "constrain no header", the status quo for extant handlers.
12
+ * bound to a record because the validator spreads the result back over the wire bag:
13
+ * an unbound `headers: z.string()` would spread `{ 0: 'a', 1: 'b', … }` into the slot
14
+ * `@middy/http-cors` reads. clamped by `forApiGateway.test.ts [case20]`
15
+ */
16
+ export type ApiGatewayHeadersDeclared = ApiGatewayHeadersOnwire | undefined;
17
+ /**
18
+ * .what = the two slots a caller may constrain on an api-gateway event
19
+ * .why = the validator writes validated values back into the envelope, so the envelope's types
20
+ * must follow the caller's schema — else `event.payload` is `unknown` and the hand-off
21
+ * owes an `as`-cast
22
+ * .note = headers and body only: the two slots the family lifts onto `invoke`'s input; the rest
23
+ * of the envelope is reconciled, never validated
24
+ */
25
+ export interface ApiGatewayRequestEventUnifiedShape {
26
+ headers: ApiGatewayHeadersOnwire;
27
+ payload: unknown;
28
+ }
29
+ /**
30
+ * .what = the header bag a handler receives — the declared keys, beside every other wire key
31
+ * .why = `genZodInputValidationMiddleware` merges rather than replaces, because
32
+ * `@middy/http-cors` reads `origin` and `@middy/http-response-serializer` reads `accept`
33
+ * from this slot. so `headers['x-forwarded-for']` must still compile after a schema
34
+ * .why a conditional = `undefined & Record<…>` reduces to `never`, which would erase a state the
35
+ * bound declares legal. `forApiGateway` infers a union that distributes past it; a hand
36
+ * written `ApiGatewayHeadersMerged<undefined>` would not
37
+ * .note = clamped in the type checker: `[case18]` (both halves) and `[case23]` (the direct read)
38
+ */
39
+ export type ApiGatewayHeadersMerged<THeadersDeclared extends ApiGatewayHeadersDeclared> = THeadersDeclared extends undefined ? ApiGatewayHeadersOnwire : ApiGatewayHeadersOnwire & THeadersDeclared;
40
+ /**
41
+ * .what = an api-gateway request with v1/v2 differences reconciled
42
+ * .why = v1 puts the method at `httpMethod`, v2 at `requestContext.http.method`; a handler that
43
+ * reads either is version-locked. the raw union is `ApiGatewayRequestEventOnwire`
44
+ *
45
+ * .note = the handler's `headers` and `payload` are this shape's own slots — `headers ===
46
+ * event.headers`, `payload === event.payload` — because the validator writes back
47
+ * rather than parse beside (`domain.terms/headers.md`)
48
+ *
49
+ * .the vendor keys = this object sits in middy's `request.event`, where `@middy/http-cors`
50
+ * picks a method reader by `request.event.version ?? '1.0'` and then reads
51
+ * `event.httpMethod` (`@middy/http-cors/index.js:38,64-67,106-109`):
52
+ * - `httpMethod` is CARRIED — on the object, off this interface, written beside `method`
53
+ * by the reconcile. do not delete it as rename residue
54
+ * - `version` is FORBIDDEN — `'2.0'` routes cors to `requestContext.http.method`, which
55
+ * this shape lacks, and every cors success becomes a 500. clamped by `[case3]`,
56
+ * `[case18]`, `[case19][t2]`
57
+ */
58
+ export interface ApiGatewayRequestEventUnified<TShape extends ApiGatewayRequestEventUnifiedShape = ApiGatewayRequestEventUnifiedShape> {
59
+ /**
60
+ * .what = the http method — `GET`, `POST`, …
61
+ * .why `method` = the type already says api gateway; `httpMethod` is aws's v1 wire name
62
+ */
63
+ method: string;
64
+ /**
65
+ * .what = the request headers, keys lowercased
66
+ * .why = rfc 9110 §5.1: field names are case-insensitive, so `Authorization` and
67
+ * `authorization` must not be two keys
68
+ * .note = validated against `schema.input.headers` where declared; otherwise unconstrained
69
+ */
70
+ headers: TShape['headers'];
71
+ /**
72
+ * .what = the body — parsed, and validated by the time `logic` runs
73
+ * .note = no unvalidated parsed body sits beside it (`domain.terms/payload.md`). the untouched
74
+ * wire string is at `_.raw.body`, for a handler that must hash the exact bytes
75
+ */
76
+ payload: TShape['payload'];
77
+ /**
78
+ * .what = how the body arrived on the wire
79
+ * .why a bag = a second codec fact (charset, compression) lands as a key, not a loose field
80
+ */
81
+ codec: {
82
+ base64: boolean;
83
+ };
84
+ /**
85
+ * .what = the two parameter bags api gateway extracted from the url
86
+ * .note = the url path string is not carried; a handler is bound to its route, and `_.raw`
87
+ * holds it
88
+ */
89
+ params: {
90
+ path: Record<string, string | undefined> | null;
91
+ query: Record<string, string | undefined> | null;
92
+ };
93
+ /**
94
+ * .what = the ejection route — the wire form before reconcile
95
+ * .why = `_` marks the version-locked escape hatch; every field above is version-agnostic
96
+ */
97
+ _: {
98
+ raw: ApiGatewayRequestEventOnwire;
99
+ };
100
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ApiGatewayRequestEventUnified.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiGatewayRequestEventUnified.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/ApiGatewayRequestEventUnified.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import type { ApiGatewayRequestEventOnwire } from '../../../domain.objects/ApiGatewayRequestEventOnwire';
2
+ import type { ApiGatewayRequestEventUnified } from './ApiGatewayRequestEventUnified';
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 payload = json is the common case, and a caller who wants the raw string opts out by
7
+ * value: `deserialize: { payload: false }`
8
+ */
9
+ export declare const DESERIALIZE_DEFAULT: {
10
+ payload: boolean;
11
+ };
12
+ /**
13
+ * .what = reconciles either api-gateway wire 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 `ApiGatewayRequestEventUnified`
16
+ *
17
+ * .why the input is `wire` and not `payload` = it holds the whole message, and `payload` names
18
+ * the request body and naught else (`domain.terms/payload.md`). named `payload`, this
19
+ * reads `asApiGatewayRequestEventUnified({ payload }).payload` — one word, two senses,
20
+ * one expression
21
+ *
22
+ * .note = a named transformer rather than middleware-local logic, so one implementation serves
23
+ * both entry points — `genApiGatewayRequestEventNormalizationMiddleware` delegates here
24
+ * (rule.forbid.parallel-codepaths)
25
+ */
26
+ export declare const asApiGatewayRequestEventUnified: (input: {
27
+ wire: ApiGatewayRequestEventOnwire;
28
+ }, options?: {
29
+ deserialize: {
30
+ payload: boolean;
31
+ };
32
+ }) => ApiGatewayRequestEventUnified & {
33
+ httpMethod: string;
34
+ };
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asApiGatewayRequestEventUnified = exports.DESERIALIZE_DEFAULT = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const asHeaderKeysLowercased_1 = require("./asHeaderKeysLowercased");
6
+ const getIsV1ApiGatewayRequestEvent_1 = require("./getIsV1ApiGatewayRequestEvent");
7
+ const getIsV2ApiGatewayRequestEvent_1 = require("./getIsV2ApiGatewayRequestEvent");
8
+ /**
9
+ * .what = parses a json body string into an object, base64-decoded first when flagged
10
+ * .why = api gateway hands the body over as a string; most handlers want the object
11
+ *
12
+ * .note = a body that is not json is returned as the decoded string rather than refused —
13
+ * a form-encoded twilio webhook is a legitimate caller, and its own schema (or
14
+ * `z.any()`) is where that shape gets judged
15
+ */
16
+ const asParsedApiGatewayBody = (input) => {
17
+ if (!input.body)
18
+ return null;
19
+ const decoded = input.isBase64Encoded
20
+ ? Buffer.from(input.body, 'base64').toString('utf-8')
21
+ : input.body;
22
+ try {
23
+ return JSON.parse(decoded);
24
+ }
25
+ catch (error) {
26
+ /**
27
+ * .what = allowlists the ONE error a non-json body can raise, and rethrows every other
28
+ * .why = a bare `catch` would swallow a TypeError from a real defect, and the swallowed
29
+ * value would reach the handler as plain text (rule.forbid.failhide). `SyntaxError`
30
+ * is the only class `JSON.parse` throws for malformed input, per ecma-262 §25.5.1,
31
+ * so the allowlist is exhaustive rather than a guess
32
+ */
33
+ if (!(error instanceof SyntaxError))
34
+ throw error;
35
+ return decoded;
36
+ }
37
+ };
38
+ /**
39
+ * .what = reconciles either wire version into the unified shape, given the one value the
40
+ * versions disagree about at this point
41
+ * .why = of the fields this shape carries, only the method sits at a different path — top level
42
+ * on v1, under `requestContext.http` on v2. every other field sits at the same path on
43
+ * both, so one function serves both and the unified shape gains a new field in one place
44
+ *
45
+ * .note = "at this point" is the whole qualifier. a second field differs — `version`, the
46
+ * discriminant — and it is already spent by the caller below
47
+ * (`getIsV2ApiGatewayRequestEvent`) to pick which arm calls this. so "one" is true of
48
+ * this function and false of the wire contract
49
+ * .note = two more differ in value rather than position — v1 sends `null` for an absent body
50
+ * and path params where v2 sends `undefined` — and the `??` arms below absorb both,
51
+ * which is why neither earns a branch
52
+ * .note = the url path is a v1/v2 divergence this shape does not reconcile, since it carries no
53
+ * url path string at all
54
+ *
55
+ * .note = the disputed value is handed in as a plain string rather than read through a
56
+ * per-version extractor, which would restore the duplication in a less legible form
57
+ */
58
+ const asEventUnified = (input) => ({
59
+ method: input.method,
60
+ /**
61
+ * .what = the compat key `@middy/http-cors` reads by name (`index.js:38,65,106`) — absent
62
+ * from `ApiGatewayRequestEventUnified`, present on the object
63
+ * .why = this object is written into middy's own `request.event` slot, so the slot is not ours
64
+ * alone. drop the key and cors throws `'[http-cors] Unknown http event format'` from its
65
+ * `after` hook, on every cors-configured handler
66
+ * .why not fork the two objects = `request.event` IS the handler's envelope, by reference, and
67
+ * that identity is what makes `headers === event.headers` true. a second object would
68
+ * buy one clean key and cost the projection
69
+ * (`rule.require.read-the-slot-a-dependency-reads`)
70
+ */
71
+ httpMethod: input.method,
72
+ /**
73
+ * .what = the case-fold, on both arms — rfc 9110 §5.1
74
+ * .note = it also absorbs the absent bag v2 declares optional, so this line owes no `as`-cast
75
+ */
76
+ headers: (0, asHeaderKeysLowercased_1.asHeaderKeysLowercased)({ headers: input.wire.headers }),
77
+ /**
78
+ * .what = the body, parsed. validated later, in place — `genZodInputValidationMiddleware`
79
+ * replaces this slot with the schema's output before `logic` runs
80
+ * .why = so `event.payload` is the validated value at the only moment a handler can read
81
+ * it, which is what lets its type state the caller's shape rather than `unknown`
82
+ */
83
+ payload: input.deserialize.payload
84
+ ? asParsedApiGatewayBody({
85
+ body: input.wire.body,
86
+ isBase64Encoded: input.wire.isBase64Encoded,
87
+ })
88
+ : input.wire.body,
89
+ codec: { base64: input.wire.isBase64Encoded },
90
+ params: {
91
+ path: input.wire.pathParameters ?? null,
92
+ query: input.wire.queryStringParameters ?? null,
93
+ },
94
+ _: { raw: input.wire },
95
+ });
96
+ /**
97
+ * .what = what `deserialize` means when a caller declares none — one declaration, read by both
98
+ * this transformer and `forApiGateway`'s config (rule.forbid.parallel-codepaths)
99
+ * .why payload = json is the common case, and a caller who wants the raw string opts out by
100
+ * value: `deserialize: { payload: false }`
101
+ */
102
+ exports.DESERIALIZE_DEFAULT = { payload: true };
103
+ /**
104
+ * .what = reconciles either api-gateway wire version into one shape
105
+ * .why = the chain must read one shape whichever version the trigger delivered, so this runs
106
+ * first and every step after it reads `ApiGatewayRequestEventUnified`
107
+ *
108
+ * .why the input is `wire` and not `payload` = it holds the whole message, and `payload` names
109
+ * the request body and naught else (`domain.terms/payload.md`). named `payload`, this
110
+ * reads `asApiGatewayRequestEventUnified({ payload }).payload` — one word, two senses,
111
+ * one expression
112
+ *
113
+ * .note = a named transformer rather than middleware-local logic, so one implementation serves
114
+ * both entry points — `genApiGatewayRequestEventNormalizationMiddleware` delegates here
115
+ * (rule.forbid.parallel-codepaths)
116
+ */
117
+ const asApiGatewayRequestEventUnified = (input, options) => {
118
+ const deserialize = options?.deserialize ?? exports.DESERIALIZE_DEFAULT;
119
+ // v2 http-api: the method lives under `requestContext.http`
120
+ if ((0, getIsV2ApiGatewayRequestEvent_1.getIsV2ApiGatewayRequestEvent)(input.wire)) {
121
+ const wire = input.wire;
122
+ return asEventUnified({
123
+ wire,
124
+ method: wire.requestContext.http.method,
125
+ deserialize,
126
+ });
127
+ }
128
+ // v1 rest-api: the method lives at the top level
129
+ if ((0, getIsV1ApiGatewayRequestEvent_1.getIsV1ApiGatewayRequestEvent)(input.wire)) {
130
+ const wire = input.wire;
131
+ return asEventUnified({
132
+ wire,
133
+ method: wire.httpMethod,
134
+ deserialize,
135
+ });
136
+ }
137
+ // fail loud rather than hand a handler a shape neither branch produced
138
+ return helpful_errors_1.MalfunctionError.throw('wire is neither v1 nor v2 api gateway event shaped', { wire: input.wire });
139
+ };
140
+ exports.asApiGatewayRequestEventUnified = asApiGatewayRequestEventUnified;
141
+ //# sourceMappingURL=asApiGatewayRequestEventUnified.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asApiGatewayRequestEventUnified.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayRequestEventUnified.ts"],"names":[],"mappings":";;;AACA,mDAAkD;AAIlD,qEAAkE;AAClE,mFAAgF;AAChF,mFAAgF;AAEhF;;;;;;;GAOG;AACH,MAAM,sBAAsB,GAAG,CAAC,KAG/B,EAAW,EAAE;IACZ,IAAI,CAAC,KAAK,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAE7B,MAAM,OAAO,GAAG,KAAK,CAAC,eAAe;QACnC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;QACrD,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IAEf,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf;;;;;;WAMG;QACH,IAAI,CAAC,CAAC,KAAK,YAAY,WAAW,CAAC;YAAE,MAAM,KAAK,CAAC;QAEjD,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,cAAc,GAAG,CAAC,KAIvB,EAA0D,EAAE,CAAC,CAAC;IAC7D,MAAM,EAAE,KAAK,CAAC,MAAM;IAEpB;;;;;;;;;;OAUG;IACH,UAAU,EAAE,KAAK,CAAC,MAAM;IAExB;;;OAGG;IACH,OAAO,EAAE,IAAA,+CAAsB,EAAC,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IAEhE;;;;;OAKG;IACH,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,OAAO;QAChC,CAAC,CAAC,sBAAsB,CAAC;YACrB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI;YACrB,eAAe,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe;SAC5C,CAAC;QACJ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI;IAEnB,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,EAAE;IAC7C,MAAM,EAAE;QACN,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI;QACvC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,qBAAqB,IAAI,IAAI;KAChD;IACD,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE;CACvB,CAAC,CAAC;AAEH;;;;;GAKG;AACU,QAAA,mBAAmB,GAAyB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAE3E;;;;;;;;;;;;;GAaG;AACI,MAAM,+BAA+B,GAAG,CAC7C,KAA6C,EAC7C,OAA+C,EACS,EAAE;IAC1D,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,2BAAmB,CAAC;IAEhE,4DAA4D;IAC5D,IAAI,IAAA,6DAA6B,EAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAExB,OAAO,cAAc,CAAC;YACpB,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM;YACvC,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED,iDAAiD;IACjD,IAAI,IAAA,6DAA6B,EAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAExB,OAAO,cAAc,CAAC;YACpB,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,UAAU;YACvB,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED,uEAAuE;IACvE,OAAO,iCAAgB,CAAC,KAAK,CAC3B,oDAAoD,EACpD,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CACrB,CAAC;AACJ,CAAC,CAAC;AAjCW,QAAA,+BAA+B,mCAiC1C"}
@@ -0,0 +1,22 @@
1
+ import type { ApiGatewayResponse } from '../../../domain.objects/ApiGatewayResponse';
2
+ import type { ApiGatewayResponseOnwire } from '../../../domain.objects/ApiGatewayResponseOnwire';
3
+ /**
4
+ * .what = the default output translator: what `invoke` returns becomes the response wire
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 = this is the one line where the body changes its name. `payload` is the sdk's word for
11
+ * a body in both directions; `body` is aws's key on the wire result. the rename happens
12
+ * here and nowhere else, so no other file holds both senses at once
13
+ *
14
+ * .note = the body is omitted, never `''` — the serializer would encode `''` into `'""'`. it is
15
+ * left as the domain value for the serializer to encode one step later, which is what
16
+ * lets a handler's own `Content-Type` carry bytes through untouched. the omission holds
17
+ * at the wire rather than mid-chain: the serializer re-adds `body` as an own key with
18
+ * value `undefined`, which is benign and visible in the unit snapshots
19
+ */
20
+ export declare const asApiGatewayResponseOnwire: <TPayload>(input: {
21
+ response: ApiGatewayResponse<TPayload>;
22
+ }) => ApiGatewayResponseOnwire<TPayload>;