sdk-aws-lambda 0.4.2 → 0.6.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 (204) hide show
  1. package/dist/contract/cli/gen.js +18 -0
  2. package/dist/contract/cli/gen.js.map +1 -1
  3. package/dist/domain.objects/AwsIdentitySynthetic.d.ts +20 -0
  4. package/dist/domain.objects/AwsIdentitySynthetic.js +24 -0
  5. package/dist/domain.objects/AwsIdentitySynthetic.js.map +1 -0
  6. package/dist/domain.objects/LambdaEndpointDialect.d.ts +19 -0
  7. package/dist/domain.objects/LambdaEndpointDialect.js +3 -0
  8. package/dist/domain.objects/LambdaEndpointDialect.js.map +1 -0
  9. package/dist/domain.objects/LambdaEndpointErrorResponseBody.d.ts +70 -0
  10. package/dist/domain.objects/LambdaEndpointErrorResponseBody.js +41 -0
  11. package/dist/domain.objects/LambdaEndpointErrorResponseBody.js.map +1 -0
  12. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.asExampleUuid.d.ts +7 -0
  13. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.asExampleUuid.js +13 -0
  14. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.asExampleUuid.js.map +1 -0
  15. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.constants.d.ts +36 -0
  16. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.constants.js +88 -0
  17. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.constants.js.map +1 -0
  18. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.d.ts +81 -0
  19. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.d.ts +75 -0
  20. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.js +163 -0
  21. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.js.map +1 -0
  22. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromKinesis.d.ts +32 -0
  23. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromKinesis.js +55 -0
  24. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromKinesis.js.map +1 -0
  25. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromS3.d.ts +40 -0
  26. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromS3.js +71 -0
  27. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromS3.js.map +1 -0
  28. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSns.d.ts +27 -0
  29. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSns.js +51 -0
  30. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSns.js.map +1 -0
  31. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSqs.d.ts +35 -0
  32. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSqs.js +50 -0
  33. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSqs.js.map +1 -0
  34. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.js +59 -0
  35. package/dist/domain.operations/asLambdaEvent/asLambdaEvent.js.map +1 -0
  36. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.d.ts +2 -1
  37. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js +19 -18
  38. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js.map +1 -1
  39. package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js +1 -1
  40. package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js.map +1 -1
  41. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.d.ts +24 -0
  42. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js +24 -0
  43. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js.map +1 -1
  44. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +19 -0
  45. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
  46. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js +7 -7
  47. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js.map +1 -1
  48. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts +37 -10
  49. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js +3 -2
  50. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +1 -1
  51. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js +6 -6
  52. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js.map +1 -1
  53. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.d.ts +1 -1
  54. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js +19 -1
  55. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js.map +1 -1
  56. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.d.ts +0 -4
  57. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js +224 -3
  58. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js.map +1 -1
  59. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.d.ts +12 -4
  60. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js +12 -4
  61. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js.map +1 -1
  62. package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.d.ts +6 -19
  63. package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js +6 -1
  64. package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js.map +1 -1
  65. package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.d.ts +1 -1
  66. package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.js +1 -1
  67. package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.js.map +1 -1
  68. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.d.ts +22 -0
  69. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js +29 -0
  70. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js.map +1 -0
  71. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.d.ts +35 -0
  72. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js +58 -1
  73. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js.map +1 -1
  74. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.d.ts +1 -0
  75. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js +65 -9
  76. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js.map +1 -1
  77. package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.d.ts +20 -0
  78. package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.js +31 -2
  79. package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.js.map +1 -1
  80. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js +24 -19
  81. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js.map +1 -1
  82. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.d.ts +10 -3
  83. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js +10 -3
  84. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js.map +1 -1
  85. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js +9 -23
  86. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js.map +1 -1
  87. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js +11 -18
  88. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js.map +1 -1
  89. package/dist/domain.operations/genServiceSdk/getAllJsonSchemaNodes.d.ts +59 -0
  90. package/dist/domain.operations/genServiceSdk/getAllJsonSchemaNodes.js +87 -0
  91. package/dist/domain.operations/genServiceSdk/getAllJsonSchemaNodes.js.map +1 -0
  92. package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js +16 -35
  93. package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js.map +1 -1
  94. package/dist/domain.operations/lambdaEndpointWire/context/getExidFromContext.js.map +1 -0
  95. package/dist/domain.operations/lambdaEndpointWire/context/getLogForExidExtraction.js.map +1 -0
  96. package/dist/domain.operations/lambdaEndpointWire/context/getOneTrailExid.d.ts +36 -0
  97. package/dist/domain.operations/lambdaEndpointWire/context/getOneTrailExid.js +53 -0
  98. package/dist/domain.operations/lambdaEndpointWire/context/getOneTrailExid.js.map +1 -0
  99. package/dist/domain.operations/lambdaEndpointWire/error/getIsContempErrorTagged.d.ts +1 -0
  100. package/dist/domain.operations/lambdaEndpointWire/error/getIsContempErrorTagged.js +32 -0
  101. package/dist/domain.operations/lambdaEndpointWire/error/getIsContempErrorTagged.js.map +1 -0
  102. package/dist/domain.operations/lambdaEndpointWire/error/getIsLambdaErrorResponse.d.ts +63 -0
  103. package/dist/domain.operations/lambdaEndpointWire/error/getIsLambdaErrorResponse.js +39 -0
  104. package/dist/domain.operations/lambdaEndpointWire/error/getIsLambdaErrorResponse.js.map +1 -0
  105. package/dist/domain.operations/lambdaEndpointWire/error/getLambdaErrorMetadata.js.map +1 -0
  106. package/dist/domain.operations/lambdaEndpointWire/error/getStackTraceString.js.map +1 -0
  107. package/dist/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.d.ts +54 -0
  108. package/dist/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.js +107 -0
  109. package/dist/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.js.map +1 -0
  110. package/dist/domain.operations/{genLambdaEndpoint/middleware → lambdaEndpointWire/frame}/getIsWrappedPayload.d.ts +6 -0
  111. package/dist/domain.operations/lambdaEndpointWire/frame/getIsWrappedPayload.js.map +1 -0
  112. package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.d.ts +45 -0
  113. package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js +173 -0
  114. package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js.map +1 -0
  115. package/dist/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.d.ts +21 -0
  116. package/dist/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.js +33 -0
  117. package/dist/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.js.map +1 -0
  118. package/dist/domain.operations/lambdaEndpointWire/serde/getDecodedPayload.js.map +1 -0
  119. package/dist/domain.operations/lambdaEndpointWire/serde/getParsedJson.js.map +1 -0
  120. package/dist/domain.operations/runLambdaEndpoint/context/asLambdaContext.d.ts +24 -0
  121. package/dist/domain.operations/runLambdaEndpoint/context/asLambdaContext.js +70 -0
  122. package/dist/domain.operations/runLambdaEndpoint/context/asLambdaContext.js.map +1 -0
  123. package/dist/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.d.ts +67 -0
  124. package/dist/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.js +3 -0
  125. package/dist/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.js.map +1 -0
  126. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.d.ts +26 -0
  127. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.js +43 -0
  128. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.js.map +1 -0
  129. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.d.ts +47 -0
  130. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.js +89 -0
  131. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.js.map +1 -0
  132. package/dist/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.d.ts +73 -0
  133. package/dist/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.js +108 -0
  134. package/dist/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.js.map +1 -0
  135. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.d.ts +50 -0
  136. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js +55 -0
  137. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js.map +1 -0
  138. package/dist/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.d.ts +56 -0
  139. package/dist/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.js +57 -0
  140. package/dist/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.js.map +1 -0
  141. package/dist/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.d.ts +16 -0
  142. package/dist/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.js +71 -0
  143. package/dist/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.js.map +1 -0
  144. package/dist/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.d.ts +48 -0
  145. package/dist/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.js +57 -0
  146. package/dist/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.js.map +1 -0
  147. package/dist/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.d.ts +18 -0
  148. package/dist/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.js +239 -0
  149. package/dist/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.js.map +1 -0
  150. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.d.ts +82 -0
  151. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.js +67 -0
  152. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.js.map +1 -0
  153. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.d.ts +120 -0
  154. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js +119 -0
  155. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js.map +1 -0
  156. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.d.ts +98 -0
  157. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js +176 -0
  158. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js.map +1 -0
  159. package/dist/domain.operations/runLambdaEndpoint/serde/asFramedPayload.d.ts +41 -0
  160. package/dist/domain.operations/runLambdaEndpoint/serde/asFramedPayload.js +62 -0
  161. package/dist/domain.operations/runLambdaEndpoint/serde/asFramedPayload.js.map +1 -0
  162. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.d.ts +40 -0
  163. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js +68 -0
  164. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js.map +1 -0
  165. package/dist/domain.operations/runLambdaEndpoint/serde/asWirePayload.d.ts +34 -0
  166. package/dist/domain.operations/runLambdaEndpoint/serde/asWirePayload.js +39 -0
  167. package/dist/domain.operations/runLambdaEndpoint/serde/asWirePayload.js.map +1 -0
  168. package/dist/domain.operations/runLambdaEndpoint/serde/asWireStripped.d.ts +25 -0
  169. package/dist/domain.operations/runLambdaEndpoint/serde/asWireStripped.js +85 -0
  170. package/dist/domain.operations/runLambdaEndpoint/serde/asWireStripped.js.map +1 -0
  171. package/dist/index.d.ts +34 -0
  172. package/dist/index.js +50 -1
  173. package/dist/index.js.map +1 -1
  174. package/package.json +4 -3
  175. package/readme.md +188 -48
  176. package/dist/domain.operations/askLambdaEndpoint/context/getExidFromContext.js.map +0 -1
  177. package/dist/domain.operations/askLambdaEndpoint/context/getLogForExidExtraction.js.map +0 -1
  178. package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.d.ts +0 -42
  179. package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.js +0 -21
  180. package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.js.map +0 -1
  181. package/dist/domain.operations/askLambdaEndpoint/error/getLambdaErrorMetadata.js.map +0 -1
  182. package/dist/domain.operations/askLambdaEndpoint/error/getStackTraceString.js.map +0 -1
  183. package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.d.ts +0 -13
  184. package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js +0 -26
  185. package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js.map +0 -1
  186. package/dist/domain.operations/askLambdaEndpoint/serde/getDecodedPayload.js.map +0 -1
  187. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedJson.js.map +0 -1
  188. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.d.ts +0 -15
  189. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js +0 -100
  190. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js.map +0 -1
  191. package/dist/domain.operations/genLambdaEndpoint/middleware/getIsWrappedPayload.js.map +0 -1
  192. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getExidFromContext.d.ts +0 -0
  193. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getExidFromContext.js +0 -0
  194. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getLogForExidExtraction.d.ts +0 -0
  195. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getLogForExidExtraction.js +0 -0
  196. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getLambdaErrorMetadata.d.ts +0 -0
  197. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getLambdaErrorMetadata.js +0 -0
  198. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getStackTraceString.d.ts +0 -0
  199. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getStackTraceString.js +0 -0
  200. /package/dist/domain.operations/{genLambdaEndpoint/middleware → lambdaEndpointWire/frame}/getIsWrappedPayload.js +0 -0
  201. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getDecodedPayload.d.ts +0 -0
  202. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getDecodedPayload.js +0 -0
  203. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getParsedJson.d.ts +0 -0
  204. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getParsedJson.js +0 -0
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromApiGateway = void 0;
4
+ const AwsIdentitySynthetic_1 = require("../../domain.objects/AwsIdentitySynthetic");
5
+ const asLambdaEvent_constants_1 = require("./asLambdaEvent.constants");
6
+ /**
7
+ * .what = the requestContext api gateway sends on EVERY real request
8
+ * .why = `forApiGateway` normalizes a v1 event and reads `requestContext.requestId`
9
+ * while it does so. an event without one throws a `TypeError` before any
10
+ * schema runs.
11
+ *
12
+ * 🔴 BOTH time stamps are owed — aws sends `requestTimeEpoch` (a number) and
13
+ * `requestTime` (common log format) on every request. send the first alone and
14
+ * a handler that reads the human one sees `undefined` in a test and a value in
15
+ * production. `requestTime` is DERIVED from the same epoch, so the two cannot
16
+ * name two instants.
17
+ *
18
+ * .note = `connectionId` is ABSENT — a websocket-api field, and this builder makes
19
+ * a REST/HTTP v1 event.
20
+ */
21
+ const asRequestContext = (input) => ({
22
+ accountId: AwsIdentitySynthetic_1.AWS_ACCOUNT_SYNTHETIC,
23
+ apiId: 'example-api',
24
+ authorizer: null,
25
+ protocol: 'HTTP/1.1',
26
+ httpMethod: input.httpMethod,
27
+ identity: {
28
+ accessKey: null,
29
+ accountId: null,
30
+ apiKey: null,
31
+ apiKeyId: null,
32
+ caller: null,
33
+ clientCert: null,
34
+ cognitoAuthenticationProvider: null,
35
+ cognitoAuthenticationType: null,
36
+ cognitoIdentityId: null,
37
+ cognitoIdentityPoolId: null,
38
+ principalOrgId: null,
39
+ sourceIp: '127.0.0.1',
40
+ user: null,
41
+ userAgent: 'example-agent',
42
+ userArn: null,
43
+ },
44
+ path: input.path,
45
+ stage: 'test',
46
+ requestId: '00000000-0000-4000-8000-000000000000',
47
+ // aws sends BOTH — the epoch and its human twin. one literal, two views.
48
+ requestTimeEpoch: asLambdaEvent_constants_1.AWS_EVENT_AT_EPOCH_MS,
49
+ requestTime: asLambdaEvent_constants_1.AWS_EVENT_AT_CLF,
50
+ // aws stamps this on every request; absent it a handler that logs it reads undefined
51
+ extendedRequestId: 'example-extended-request-id',
52
+ resourceId: 'example-resource',
53
+ resourcePath: input.path,
54
+ });
55
+ /**
56
+ * .what = casts a single-value map into the multi-value twin api gateway sends beside it
57
+ * .why = api gateway delivers `headers` AND `multiValueHeaders`, and the same pair
58
+ * for query strings. a handler that reads the multi-value map (a `Set-Cookie`, a
59
+ * repeated `Accept`) would see `{}` where the wire delivers every header.
60
+ */
61
+ const asMultiValue = (input) => Object.fromEntries(Object.entries(input).map(([key, value]) => [key, [value]]));
62
+ /**
63
+ * .what = casts a body to what api gateway puts on the wire — a string, or
64
+ * `null` where the request carried none
65
+ * .why = a caller sends a STRING body; one who hands an object meant its json.
66
+ *
67
+ * 🔴 `null` and `undefined` must land on the SAME wire shape. an explicit
68
+ * `body: null` that falls through to `JSON.stringify(null)` yields the
69
+ * four-character string `'null'` — so a handler reads `'null'` in the test and
70
+ * `null` in production, the exact divergence this factory exists to remove. a
71
+ * GET or a preflight with an explicit `null` is the shape that meets it.
72
+ *
73
+ * .note = `?? null`, never a second `=== null` branch, so a third nullish sentinel
74
+ * cannot reintroduce the split.
75
+ */
76
+ const asWireBody = (input) => {
77
+ const bodyGiven = input.body ?? null;
78
+ if (bodyGiven === null)
79
+ return null;
80
+ if (typeof bodyGiven === 'string')
81
+ return bodyGiven;
82
+ return JSON.stringify(bodyGiven);
83
+ };
84
+ /**
85
+ * .what = casts a body into the api-gateway envelope aws delivers
86
+ * .why = an api-gateway handler receives `{ body, headers, httpMethod, path,
87
+ * requestContext, ... }`, and the payload lives at `body` as a JSON STRING
88
+ *
89
+ * 🔴 .the fixture must not manufacture the defect it is meant to expose
90
+ *
91
+ * the incumbent omits two fields aws always sends, and each breaks the handler:
92
+ *
93
+ * | omitted | the result |
94
+ * |---|---|
95
+ * | `requestContext` | `forApiGateway` derefs `requestContext.requestId` ⇒ `TypeError` ⇒ handler answers 500 ⇒ every assertion past the status check is unreachable |
96
+ * | `Accept` header | middy matches no response serializer ⇒ `body` comes back an OBJECT where api gateway needs a string ⇒ every `JSON.parse(result.body)` fails |
97
+ *
98
+ * ⚠️ three consumers have already forked a local repair (`ahbode/svc-gateway`,
99
+ * `svc-funnel-comms`, `svc-quotes`), and the svc-gateway fork names the
100
+ * upstream half: `ehmpathy/sdk-aws-lambda#18`. a fixture three consumers fork
101
+ * is a fixture whose CONTRACT is wrong, so this fixes it.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * const event = asLambdaEvent.fromApiGateway({ body: { slug }, httpMethod: 'POST' });
106
+ *
107
+ * // a test whose SUBJECT is the metadata sets it — the override wins
108
+ * const event = asLambdaEvent.fromApiGateway({
109
+ * body,
110
+ * requestContext: { identity: { sourceIp: '10.0.0.1' } },
111
+ * });
112
+ * ```
113
+ */
114
+ const fromApiGateway = (input) => {
115
+ const httpMethod = input.httpMethod ?? 'GET';
116
+ const path = input.path ?? '/';
117
+ const body = asWireBody({ body: input.body });
118
+ const headers = {
119
+ // 🔴 without this, middy matches no response serializer and hands back an
120
+ // object where api gateway requires a string
121
+ Accept: 'application/json',
122
+ 'Content-Type': 'application/json',
123
+ Host: 'example-api.execute-api.us-east-1.amazonaws.com',
124
+ 'User-Agent': 'example-agent',
125
+ ...input.headers,
126
+ };
127
+ const queryStringParameters = input.queryStringParameters ?? null;
128
+ return {
129
+ body,
130
+ headers,
131
+ // 🔴 DERIVED, never hardcoded — aws sends the multi-value twin of every header
132
+ // on every real request, so a `{}` here is an omission the wire never makes
133
+ multiValueHeaders: asMultiValue(headers),
134
+ httpMethod,
135
+ isBase64Encoded: input.isBase64Encoded ?? false,
136
+ path,
137
+ pathParameters: input.pathParameters ?? null,
138
+ queryStringParameters,
139
+ multiValueQueryStringParameters: queryStringParameters
140
+ ? asMultiValue(queryStringParameters)
141
+ : null,
142
+ stageVariables: null,
143
+ // 🔴 without this, forApiGateway derefs undefined and the handler answers 500
144
+ requestContext: (() => {
145
+ const base = asRequestContext({ httpMethod, path });
146
+ return {
147
+ ...base,
148
+ ...input.requestContext,
149
+ // 🔴 merged one level DEEPER than its peers — a shallow spread would
150
+ // REPLACE the whole object, so to name one field (a sourceIp, a
151
+ // userAgent) would silently drop the other fifteen and hand back an
152
+ // event LESS wire-faithful than the default
153
+ identity: {
154
+ ...base.identity,
155
+ ...input.requestContext?.identity,
156
+ },
157
+ };
158
+ })(),
159
+ resource: path,
160
+ };
161
+ };
162
+ exports.fromApiGateway = fromApiGateway;
163
+ //# sourceMappingURL=asLambdaEvent.fromApiGateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaEvent.fromApiGateway.js","sourceRoot":"","sources":["../../../src/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,32 @@
1
+ import type { KinesisStreamEvent, KinesisStreamRecord } from 'aws-lambda';
2
+ /**
3
+ * .what = casts payloads into the kinesis envelope aws delivers
4
+ * .why = a kinesis consumer receives `{ Records: [{ kinesis: { data, ... } }] }`,
5
+ * and the payload lives at `Records[].kinesis.data` — **base64 encoded**
6
+ * (define.lambda-event-source)
7
+ *
8
+ * ⚠️ **the base64 encode is done for you.** hand a plain string; the factory
9
+ * encodes it, because that is what the wire delivers and a hand-rolled
10
+ * fixture routinely forgets it.
11
+ *
12
+ * wire-faithful by default, per F10 — see `asLambdaEvent.fromSqs` for the argument.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const event = asLambdaEvent.fromKinesis({ records: [JSON.stringify(datum)] });
17
+ * ```
18
+ */
19
+ export declare const fromKinesis: (input: {
20
+ /**
21
+ * the record payloads, as plain strings. base64-encoded for you.
22
+ */
23
+ records: string[];
24
+ /**
25
+ * per-record overrides, applied to every record
26
+ */
27
+ record?: Partial<KinesisStreamRecord>;
28
+ /**
29
+ * the stream name the records came from
30
+ */
31
+ stream?: string;
32
+ }) => KinesisStreamEvent;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromKinesis = void 0;
4
+ const AwsIdentitySynthetic_1 = require("../../domain.objects/AwsIdentitySynthetic");
5
+ const asLambdaEvent_constants_1 = require("./asLambdaEvent.constants");
6
+ /**
7
+ * .what = casts payloads into the kinesis envelope aws delivers
8
+ * .why = a kinesis consumer receives `{ Records: [{ kinesis: { data, ... } }] }`,
9
+ * and the payload lives at `Records[].kinesis.data` — **base64 encoded**
10
+ * (define.lambda-event-source)
11
+ *
12
+ * ⚠️ **the base64 encode is done for you.** hand a plain string; the factory
13
+ * encodes it, because that is what the wire delivers and a hand-rolled
14
+ * fixture routinely forgets it.
15
+ *
16
+ * wire-faithful by default, per F10 — see `asLambdaEvent.fromSqs` for the argument.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const event = asLambdaEvent.fromKinesis({ records: [JSON.stringify(datum)] });
21
+ * ```
22
+ */
23
+ const fromKinesis = (input) => {
24
+ const stream = input.stream ?? 'example-stream';
25
+ const streamArn = `arn:aws:kinesis:${AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC}:${AwsIdentitySynthetic_1.AWS_ACCOUNT_SYNTHETIC}:stream/${stream}`;
26
+ return {
27
+ Records: input.records.map((data, index) => {
28
+ // the sequence number is said twice — once as itself, once embedded in the
29
+ // eventID, which aws forms as `${shardId}:${sequenceNumber}`. derived rather
30
+ // than written twice, so the two cannot drift out of that relation.
31
+ const sequenceNumber = `4959${String(index).padStart(52, '0')}`;
32
+ return {
33
+ kinesis: {
34
+ kinesisSchemaVersion: '1.0',
35
+ partitionKey: `partition-${index}`,
36
+ sequenceNumber,
37
+ // the wire delivers base64; a fixture that skips this teaches a false shape
38
+ data: Buffer.from(data, 'utf8').toString('base64'),
39
+ // ⚠️ kinesis stamps epoch SECONDS where sqs and api gateway stamp millis
40
+ approximateArrivalTimestamp: asLambdaEvent_constants_1.AWS_EVENT_AT_EPOCH_S,
41
+ },
42
+ eventSource: 'aws:kinesis',
43
+ eventVersion: '1.0',
44
+ eventID: `shardId-000000000000:${sequenceNumber}`,
45
+ eventName: 'aws:kinesis:record',
46
+ invokeIdentityArn: `arn:aws:iam::${AwsIdentitySynthetic_1.AWS_ACCOUNT_SYNTHETIC}:role/example-role`,
47
+ awsRegion: AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC,
48
+ eventSourceARN: streamArn,
49
+ ...input.record,
50
+ };
51
+ }),
52
+ };
53
+ };
54
+ exports.fromKinesis = fromKinesis;
55
+ //# sourceMappingURL=asLambdaEvent.fromKinesis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaEvent.fromKinesis.js","sourceRoot":"","sources":["../../../src/domain.operations/asLambdaEvent/asLambdaEvent.fromKinesis.ts"],"names":[],"mappings":";;;AAEA,oFAGmD;AACnD,uEAAiE;AAEjE;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,WAAW,GAAG,CAAC,KAe3B,EAAsB,EAAE;IACvB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,gBAAgB,CAAC;IAChD,MAAM,SAAS,GAAG,mBAAmB,2CAAoB,IAAI,4CAAqB,WAAW,MAAM,EAAE,CAAC;IAEtG,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACzC,2EAA2E;YAC3E,6EAA6E;YAC7E,oEAAoE;YACpE,MAAM,cAAc,GAAG,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC;YAEhE,OAAO;gBACL,OAAO,EAAE;oBACP,oBAAoB,EAAE,KAAK;oBAC3B,YAAY,EAAE,aAAa,KAAK,EAAE;oBAClC,cAAc;oBACd,4EAA4E;oBAC5E,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;oBAClD,yEAAyE;oBACzE,2BAA2B,EAAE,8CAAoB;iBAClD;gBACD,WAAW,EAAE,aAAa;gBAC1B,YAAY,EAAE,KAAK;gBACnB,OAAO,EAAE,wBAAwB,cAAc,EAAE;gBACjD,SAAS,EAAE,oBAAoB;gBAC/B,iBAAiB,EAAE,gBAAgB,4CAAqB,oBAAoB;gBAC5E,SAAS,EAAE,2CAAoB;gBAC/B,cAAc,EAAE,SAAS;gBACzB,GAAG,KAAK,CAAC,MAAM;aAChB,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC;AA/CW,QAAA,WAAW,eA+CtB"}
@@ -0,0 +1,40 @@
1
+ import type { S3Event, S3EventRecord } from 'aws-lambda';
2
+ /**
3
+ * .what = casts object references into the s3 envelope aws delivers
4
+ * .why = an s3 consumer receives `{ Records: [{ s3: { bucket, object } }] }`
5
+ *
6
+ * 🔴 **s3 carries NO payload — only a reference.** the handler is told an object
7
+ * changed, and must fetch it. so this factory takes bucket + key, never a body.
8
+ * that asymmetry is the source axis at work: `s3` is the one value of D6 where
9
+ * the payload is absent by nature (define.lambda-event-source).
10
+ *
11
+ * wire-faithful by default, per F10 — see `asLambdaEvent.fromSqs` for the argument.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const event = asLambdaEvent.fromS3({ objects: [{ bucket: 'photos', key: 'a.jpg' }] });
16
+ * ```
17
+ */
18
+ export declare const fromS3: (input: {
19
+ /**
20
+ * the objects that changed — a reference each, never a body
21
+ */
22
+ objects: {
23
+ bucket: string;
24
+ key: string;
25
+ size?: number;
26
+ }[];
27
+ /**
28
+ * the event name. an object-create by default.
29
+ *
30
+ * both spellings are taken — `ObjectCreated:Put` and `s3:ObjectCreated:Put`.
31
+ * aws documents the notification TYPE with the `s3:` prefix and delivers the
32
+ * event NAME without it, so an author who copies the documented string is
33
+ * right and their fixture would otherwise be wrong.
34
+ */
35
+ eventName?: string;
36
+ /**
37
+ * per-record overrides, applied to every record
38
+ */
39
+ record?: Partial<S3EventRecord>;
40
+ }) => S3Event;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromS3 = void 0;
4
+ const AwsIdentitySynthetic_1 = require("../../domain.objects/AwsIdentitySynthetic");
5
+ const asLambdaEvent_constants_1 = require("./asLambdaEvent.constants");
6
+ /**
7
+ * .what = casts object references into the s3 envelope aws delivers
8
+ * .why = an s3 consumer receives `{ Records: [{ s3: { bucket, object } }] }`
9
+ *
10
+ * 🔴 **s3 carries NO payload — only a reference.** the handler is told an object
11
+ * changed, and must fetch it. so this factory takes bucket + key, never a body.
12
+ * that asymmetry is the source axis at work: `s3` is the one value of D6 where
13
+ * the payload is absent by nature (define.lambda-event-source).
14
+ *
15
+ * wire-faithful by default, per F10 — see `asLambdaEvent.fromSqs` for the argument.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const event = asLambdaEvent.fromS3({ objects: [{ bucket: 'photos', key: 'a.jpg' }] });
20
+ * ```
21
+ */
22
+ const fromS3 = (input) => {
23
+ // 🔴 the prefix is stripped, never trusted. aws's own docs name the type
24
+ // `s3:ObjectCreated:Put` while the wire delivers `ObjectCreated:Put`, so a
25
+ // pass-through would hand back an event no real bucket ever sends — and it
26
+ // would type-check, which makes it the silent wrong-value this factory
27
+ // exists to prevent (F10).
28
+ //
29
+ // ✅ the incumbent strips it too (`createExampleS3Event.ts:46`), so this is
30
+ // parity rather than a new opinion — and that parity is the note worth
31
+ // keeping: a successor that "simplifies" the strip away reintroduces the
32
+ // exact defect, and no type check refuses it.
33
+ const eventName = (input.eventName ?? 'ObjectCreated:Put').replace(/^s3:/, '');
34
+ return {
35
+ Records: input.objects.map((object, index) => ({
36
+ eventVersion: '2.1',
37
+ eventSource: 'aws:s3',
38
+ awsRegion: AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC,
39
+ // ⚠️ the ISO representation, shared with sns and derived from the one
40
+ // constant — never hand-written here. the three factories say the same
41
+ // instant three ways (iso · millis · seconds), so a hand-edit to any
42
+ // one of them drifts it out of agreement with the other two.
43
+ eventTime: asLambdaEvent_constants_1.AWS_EVENT_AT_ISO,
44
+ eventName,
45
+ userIdentity: { principalId: 'EXAMPLE' },
46
+ requestParameters: { sourceIPAddress: '127.0.0.1' },
47
+ responseElements: {
48
+ 'x-amz-request-id': `EXAMPLE${index}`,
49
+ 'x-amz-id-2': `EXAMPLE${index}`,
50
+ },
51
+ s3: {
52
+ s3SchemaVersion: '1.0',
53
+ configurationId: 'example-config',
54
+ bucket: {
55
+ name: object.bucket,
56
+ ownerIdentity: { principalId: 'EXAMPLE' },
57
+ arn: `arn:aws:s3:::${object.bucket}`,
58
+ },
59
+ object: {
60
+ key: object.key,
61
+ size: object.size ?? 1024,
62
+ eTag: '00000000000000000000000000000000',
63
+ sequencer: `00${String(index).padStart(20, '0')}`,
64
+ },
65
+ },
66
+ ...input.record,
67
+ })),
68
+ };
69
+ };
70
+ exports.fromS3 = fromS3;
71
+ //# sourceMappingURL=asLambdaEvent.fromS3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaEvent.fromS3.js","sourceRoot":"","sources":["../../../src/domain.operations/asLambdaEvent/asLambdaEvent.fromS3.ts"],"names":[],"mappings":";;;AAEA,oFAAiF;AACjF,uEAA6D;AAE7D;;;;;;;;;;;;;;;GAeG;AACI,MAAM,MAAM,GAAG,CAAC,KAoBtB,EAAW,EAAE;IACZ,yEAAyE;IACzE,8EAA8E;IAC9E,8EAA8E;IAC9E,0EAA0E;IAC1E,8BAA8B;IAC9B,EAAE;IACF,8EAA8E;IAC9E,4EAA4E;IAC5E,8EAA8E;IAC9E,mDAAmD;IACnD,MAAM,SAAS,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,mBAAmB,CAAC,CAAC,OAAO,CAChE,MAAM,EACN,EAAE,CACH,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7C,YAAY,EAAE,KAAK;YACnB,WAAW,EAAE,QAAQ;YACrB,SAAS,EAAE,2CAAoB;YAC/B,sEAAsE;YACtE,0EAA0E;YAC1E,wEAAwE;YACxE,gEAAgE;YAChE,SAAS,EAAE,0CAAgB;YAC3B,SAAS;YACT,YAAY,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE;YACxC,iBAAiB,EAAE,EAAE,eAAe,EAAE,WAAW,EAAE;YACnD,gBAAgB,EAAE;gBAChB,kBAAkB,EAAE,UAAU,KAAK,EAAE;gBACrC,YAAY,EAAE,UAAU,KAAK,EAAE;aAChC;YACD,EAAE,EAAE;gBACF,eAAe,EAAE,KAAK;gBACtB,eAAe,EAAE,gBAAgB;gBACjC,MAAM,EAAE;oBACN,IAAI,EAAE,MAAM,CAAC,MAAM;oBACnB,aAAa,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE;oBACzC,GAAG,EAAE,gBAAgB,MAAM,CAAC,MAAM,EAAE;iBACrC;gBACD,MAAM,EAAE;oBACN,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI;oBACzB,IAAI,EAAE,kCAAkC;oBACxC,SAAS,EAAE,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE;iBAClD;aACF;YACD,GAAG,KAAK,CAAC,MAAM;SAChB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC;AAvEW,QAAA,MAAM,UAuEjB"}
@@ -0,0 +1,27 @@
1
+ import type { SNSEvent, SNSEventRecord } from 'aws-lambda';
2
+ /**
3
+ * .what = casts payloads into the sns envelope aws delivers
4
+ * .why = an sns consumer receives `{ Records: [{ Sns: { Message, ... } }] }`, and
5
+ * the payload lives at `Records[].Sns.Message` (define.lambda-event-source)
6
+ *
7
+ * wire-faithful by default — see `asLambdaEvent.fromSqs` for the argument.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const event = asLambdaEvent.fromSns({ messages: [JSON.stringify(notice)] });
12
+ * ```
13
+ */
14
+ export declare const fromSns: (input: {
15
+ /**
16
+ * the message bodies, as they arrive on the wire — json strings
17
+ */
18
+ messages: string[];
19
+ /**
20
+ * per-record overrides, applied to every record
21
+ */
22
+ record?: Partial<SNSEventRecord>;
23
+ /**
24
+ * the topic name the records came from
25
+ */
26
+ topic?: string;
27
+ }) => SNSEvent;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromSns = void 0;
4
+ const AwsIdentitySynthetic_1 = require("../../domain.objects/AwsIdentitySynthetic");
5
+ const asLambdaEvent_asExampleUuid_1 = require("./asLambdaEvent.asExampleUuid");
6
+ const asLambdaEvent_constants_1 = require("./asLambdaEvent.constants");
7
+ /**
8
+ * .what = casts payloads into the sns envelope aws delivers
9
+ * .why = an sns consumer receives `{ Records: [{ Sns: { Message, ... } }] }`, and
10
+ * the payload lives at `Records[].Sns.Message` (define.lambda-event-source)
11
+ *
12
+ * wire-faithful by default — see `asLambdaEvent.fromSqs` for the argument.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const event = asLambdaEvent.fromSns({ messages: [JSON.stringify(notice)] });
17
+ * ```
18
+ */
19
+ const fromSns = (input) => {
20
+ const topic = input.topic ?? 'example-topic';
21
+ const topicArn = `arn:aws:sns:${AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC}:${AwsIdentitySynthetic_1.AWS_ACCOUNT_SYNTHETIC}:${topic}`;
22
+ return {
23
+ Records: input.messages.map((message) => {
24
+ // one uuid per record — the arn suffix and the MessageId are the same id
25
+ const uuid = (0, asLambdaEvent_asExampleUuid_1.asExampleUuid)();
26
+ return {
27
+ EventVersion: '1.0',
28
+ EventSubscriptionArn: `${topicArn}:${uuid}`,
29
+ EventSource: 'aws:sns',
30
+ Sns: {
31
+ SignatureVersion: '1',
32
+ // ⚠️ an ISO string here; sqs sends millis, kinesis sends seconds. derived
33
+ // from the shared constant so a numeric-literal search reaches it.
34
+ Timestamp: asLambdaEvent_constants_1.AWS_EVENT_AT_ISO,
35
+ Signature: 'EXAMPLE',
36
+ SigningCertUrl: `https://sns.${AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC}.amazonaws.com/SimpleNotificationService-example.pem`,
37
+ MessageId: uuid,
38
+ Message: message,
39
+ MessageAttributes: {},
40
+ Type: 'Notification',
41
+ UnsubscribeUrl: `https://sns.${AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC}.amazonaws.com/?Action=Unsubscribe`,
42
+ TopicArn: topicArn,
43
+ Subject: '',
44
+ },
45
+ ...input.record,
46
+ };
47
+ }),
48
+ };
49
+ };
50
+ exports.fromSns = fromSns;
51
+ //# sourceMappingURL=asLambdaEvent.fromSns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaEvent.fromSns.js","sourceRoot":"","sources":["../../../src/domain.operations/asLambdaEvent/asLambdaEvent.fromSns.ts"],"names":[],"mappings":";;;AAEA,oFAGmD;AACnD,+EAA8D;AAC9D,uEAA6D;AAE7D;;;;;;;;;;;GAWG;AACI,MAAM,OAAO,GAAG,CAAC,KAevB,EAAY,EAAE;IACb,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,eAAe,CAAC;IAC7C,MAAM,QAAQ,GAAG,eAAe,2CAAoB,IAAI,4CAAqB,IAAI,KAAK,EAAE,CAAC;IAEzF,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACtC,yEAAyE;YACzE,MAAM,IAAI,GAAG,IAAA,2CAAa,GAAE,CAAC;YAE7B,OAAO;gBACL,YAAY,EAAE,KAAK;gBACnB,oBAAoB,EAAE,GAAG,QAAQ,IAAI,IAAI,EAAE;gBAC3C,WAAW,EAAE,SAAS;gBACtB,GAAG,EAAE;oBACH,gBAAgB,EAAE,GAAG;oBACrB,0EAA0E;oBAC1E,sEAAsE;oBACtE,SAAS,EAAE,0CAAgB;oBAC3B,SAAS,EAAE,SAAS;oBACpB,cAAc,EAAE,eAAe,2CAAoB,sDAAsD;oBACzG,SAAS,EAAE,IAAI;oBACf,OAAO,EAAE,OAAO;oBAChB,iBAAiB,EAAE,EAAE;oBACrB,IAAI,EAAE,cAAc;oBACpB,cAAc,EAAE,eAAe,2CAAoB,oCAAoC;oBACvF,QAAQ,EAAE,QAAQ;oBAClB,OAAO,EAAE,EAAE;iBACZ;gBACD,GAAG,KAAK,CAAC,MAAM;aAChB,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC;AA/CW,QAAA,OAAO,WA+ClB"}
@@ -0,0 +1,35 @@
1
+ import type { SQSEvent, SQSRecord } from 'aws-lambda';
2
+ /**
3
+ * .what = casts payloads into the sqs envelope aws delivers
4
+ * .why = an sqs consumer receives `{ Records: [{ body, ... }] }`, and the payload
5
+ * lives at `Records[].body` as a JSON STRING (define.lambda-event-source)
6
+ *
7
+ * 🔴 wire-faithful by default: every aws field carries what aws sends. a fixture
8
+ * that withholds metadata does not stop a handler from reading it — it hides
9
+ * that handler behind a `TypeError`. review catches it; a deref does not.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const event = asLambdaEvent.fromSqs({ messages: [JSON.stringify(task)] });
14
+ *
15
+ * // override only the field the test is actually about
16
+ * const event = asLambdaEvent.fromSqs({
17
+ * messages: [body],
18
+ * record: { eventSourceARN: 'arn:aws:sqs:us-east-1:123:my-queue' },
19
+ * });
20
+ * ```
21
+ */
22
+ export declare const fromSqs: (input: {
23
+ /**
24
+ * the message bodies, as they arrive on the wire — json strings
25
+ */
26
+ messages: string[];
27
+ /**
28
+ * per-field overrides, applied to every record
29
+ */
30
+ record?: Partial<SQSRecord>;
31
+ /**
32
+ * the queue name the records came from
33
+ */
34
+ queue?: string;
35
+ }) => SQSEvent;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromSqs = void 0;
4
+ const AwsIdentitySynthetic_1 = require("../../domain.objects/AwsIdentitySynthetic");
5
+ const asLambdaEvent_asExampleUuid_1 = require("./asLambdaEvent.asExampleUuid");
6
+ const asLambdaEvent_constants_1 = require("./asLambdaEvent.constants");
7
+ /**
8
+ * .what = casts payloads into the sqs envelope aws delivers
9
+ * .why = an sqs consumer receives `{ Records: [{ body, ... }] }`, and the payload
10
+ * lives at `Records[].body` as a JSON STRING (define.lambda-event-source)
11
+ *
12
+ * 🔴 wire-faithful by default: every aws field carries what aws sends. a fixture
13
+ * that withholds metadata does not stop a handler from reading it — it hides
14
+ * that handler behind a `TypeError`. review catches it; a deref does not.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const event = asLambdaEvent.fromSqs({ messages: [JSON.stringify(task)] });
19
+ *
20
+ * // override only the field the test is actually about
21
+ * const event = asLambdaEvent.fromSqs({
22
+ * messages: [body],
23
+ * record: { eventSourceARN: 'arn:aws:sqs:us-east-1:123:my-queue' },
24
+ * });
25
+ * ```
26
+ */
27
+ const fromSqs = (input) => {
28
+ const queue = input.queue ?? 'example-queue';
29
+ return {
30
+ Records: input.messages.map((body, index) => ({
31
+ messageId: (0, asLambdaEvent_asExampleUuid_1.asExampleUuid)(),
32
+ receiptHandle: `receipt-handle-${index}`,
33
+ body,
34
+ attributes: {
35
+ ApproximateReceiveCount: '1',
36
+ SentTimestamp: String(asLambdaEvent_constants_1.AWS_EVENT_AT_EPOCH_MS),
37
+ SenderId: `AIDA${String(index).padStart(17, '0')}`,
38
+ ApproximateFirstReceiveTimestamp: String(asLambdaEvent_constants_1.AWS_EVENT_AT_EPOCH_MS),
39
+ },
40
+ messageAttributes: {},
41
+ md5OfBody: '00000000000000000000000000000000',
42
+ eventSource: 'aws:sqs',
43
+ eventSourceARN: `arn:aws:sqs:${AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC}:${AwsIdentitySynthetic_1.AWS_ACCOUNT_SYNTHETIC}:${queue}`,
44
+ awsRegion: AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC,
45
+ ...input.record,
46
+ })),
47
+ };
48
+ };
49
+ exports.fromSqs = fromSqs;
50
+ //# sourceMappingURL=asLambdaEvent.fromSqs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaEvent.fromSqs.js","sourceRoot":"","sources":["../../../src/domain.operations/asLambdaEvent/asLambdaEvent.fromSqs.ts"],"names":[],"mappings":";;;AAEA,oFAGmD;AACnD,+EAA8D;AAC9D,uEAAkE;AAElE;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,OAAO,GAAG,CAAC,KAevB,EAAY,EAAE;IACb,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,eAAe,CAAC;IAE7C,OAAO;QACL,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YAC5C,SAAS,EAAE,IAAA,2CAAa,GAAE;YAC1B,aAAa,EAAE,kBAAkB,KAAK,EAAE;YACxC,IAAI;YACJ,UAAU,EAAE;gBACV,uBAAuB,EAAE,GAAG;gBAC5B,aAAa,EAAE,MAAM,CAAC,+CAAqB,CAAC;gBAC5C,QAAQ,EAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE;gBAClD,gCAAgC,EAAE,MAAM,CAAC,+CAAqB,CAAC;aAChE;YACD,iBAAiB,EAAE,EAAE;YACrB,SAAS,EAAE,kCAAkC;YAC7C,WAAW,EAAE,SAAS;YACtB,cAAc,EAAE,eAAe,2CAAoB,IAAI,4CAAqB,IAAI,KAAK,EAAE;YACvF,SAAS,EAAE,2CAAoB;YAC/B,GAAG,KAAK,CAAC,MAAM;SAChB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC;AArCW,QAAA,OAAO,WAqClB"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asLambdaEvent = void 0;
4
+ const asLambdaEvent_fromApiGateway_1 = require("./asLambdaEvent.fromApiGateway");
5
+ const asLambdaEvent_fromKinesis_1 = require("./asLambdaEvent.fromKinesis");
6
+ const asLambdaEvent_fromS3_1 = require("./asLambdaEvent.fromS3");
7
+ const asLambdaEvent_fromSns_1 = require("./asLambdaEvent.fromSns");
8
+ const asLambdaEvent_fromSqs_1 = require("./asLambdaEvent.fromSqs");
9
+ /**
10
+ * .what = casts a payload into the envelope its event source delivers
11
+ * .why = a lambda endpoint is woken by an EVENT SOURCE, and each source wraps the
12
+ * payload in its own envelope before the handler sees it. to run an
13
+ * endpoint against a source, a test must construct that envelope — and the
14
+ * envelope is aws-shaped, wide, and mostly irrelevant to the handler under
15
+ * test (define.lambda-event-source).
16
+ *
17
+ * | source | the envelope | the payload lives at |
18
+ * |--------|--------------|----------------------|
19
+ * | **ask** | none — the event IS the payload | the event itself |
20
+ * | **apiGateway** | `{ body, headers, httpMethod, requestContext, … }` | `body`, as a json string |
21
+ * | **sqs** | `{ Records: [{ body, … }] }` | `Records[].body`, as a json string |
22
+ * | **sns** | `{ Records: [{ Sns: { Message, … } }] }` | `Records[].Sns.Message` |
23
+ * | **kinesis** | `{ Records: [{ kinesis: { data, … } }] }` | `Records[].kinesis.data`, base64 |
24
+ * | **s3** | `{ Records: [{ s3: { bucket, object, … } }] }` | the object ref — there is no payload |
25
+ *
26
+ * ## the name
27
+ *
28
+ * **`as`, because it is a cast, never a construction.** the operation takes a
29
+ * payload and casts it into an envelope shape — no identity, no persistence, no
30
+ * findsert — so the transformer prefix applies (`rule.require.get-set-gen-verbs`).
31
+ *
32
+ * **`from`, because it names provenance.** the lambda event, as it arrives *from*
33
+ * sqs. ⚠️ `for` would invert the arrow: the event does not go to sqs, it comes
34
+ * from it.
35
+ *
36
+ * ⚠️ **`$Slug` is taken.** in `define.lambda-endpoint-ubiqlang`, `slug` is the
37
+ * endpoint's serialized key (`svc-invoice-prep-getInvoice`), so `from$Slug`
38
+ * would read as *"from the endpoint slug"* and invert the sense
39
+ * (`rule.forbid.term.addition.ambiguous`).
40
+ *
41
+ * ⚠️ **there is no `fromAsk`, deliberately.** the ask source wraps naught — the
42
+ * event IS the payload — so a factory for it would be an identity function.
43
+ * a member that constructs no envelope, on an object whose whole purpose is to
44
+ * construct envelopes, would imply one exists. pass the event directly.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const event = asLambdaEvent.fromSqs({ messages: [JSON.stringify(task)] });
49
+ * const event = asLambdaEvent.fromApiGateway({ body, httpMethod: 'POST' });
50
+ * ```
51
+ */
52
+ exports.asLambdaEvent = {
53
+ fromApiGateway: asLambdaEvent_fromApiGateway_1.fromApiGateway,
54
+ fromKinesis: asLambdaEvent_fromKinesis_1.fromKinesis,
55
+ fromS3: asLambdaEvent_fromS3_1.fromS3,
56
+ fromSns: asLambdaEvent_fromSns_1.fromSns,
57
+ fromSqs: asLambdaEvent_fromSqs_1.fromSqs,
58
+ };
59
+ //# sourceMappingURL=asLambdaEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaEvent.js","sourceRoot":"","sources":["../../../src/domain.operations/asLambdaEvent/asLambdaEvent.ts"],"names":[],"mappings":";;;AAAA,iFAAgE;AAChE,2EAA0D;AAC1D,iEAAgD;AAChD,mEAAkD;AAClD,mEAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACU,QAAA,aAAa,GAAG;IAC3B,cAAc,EAAd,6CAAc;IACd,WAAW,EAAX,uCAAW;IACX,MAAM,EAAN,6BAAM;IACN,OAAO,EAAP,+BAAO;IACP,OAAO,EAAP,+BAAO;CACR,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import type { SimpleInMemoryCache } from 'simple-in-memory-cache';
2
2
  import type { SimpleCache } from 'with-simple-cache';
3
3
  import type { ContextAwsLambdaCaller } from '../../domain.objects/ContextAwsLambdaCaller';
4
+ import type { LambdaEndpointDialect } from '../../domain.objects/LambdaEndpointDialect';
4
5
  /**
5
6
  * .what = invokes a lambda endpoint with trail propagation
6
7
  * .why = enables service-to-service calls with observability
@@ -24,7 +25,7 @@ export declare const askLambdaEndpoint: <TRequest, TResponse>(input: {
24
25
  * .why = ancient handlers don't understand wrapped { event, trail } structure
25
26
  * .default = 'contemp' (wrapped with trail)
26
27
  */
27
- payload?: 'ancient' | 'contemp';
28
+ payload?: LambdaEndpointDialect;
28
29
  };
29
30
  }, context: ContextAwsLambdaCaller & {
30
31
  cache?: {