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,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getParsedResponse = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const LambdaEndpointError_1 = require("../../domain.objects/LambdaEndpointError");
6
+ const getIsLambdaErrorResponse_1 = require("./error/getIsLambdaErrorResponse");
7
+ const getLambdaErrorMetadata_1 = require("./error/getLambdaErrorMetadata");
8
+ const getStackTraceString_1 = require("./error/getStackTraceString");
9
+ const asUnprefixedErrorMessage_1 = require("./serde/asUnprefixedErrorMessage");
10
+ const getDecodedPayload_1 = require("./serde/getDecodedPayload");
11
+ const getParsedJson_1 = require("./serde/getParsedJson");
12
+ /**
13
+ * .what = reads a lambda's raw wire response, and throws whatever fault it carries
14
+ * .why = this is the SERIALIZED boundary's hydration step β€” the one place a
15
+ * returned error envelope becomes a thrown error, which is what makes a
16
+ * caller's experience differ from the host's
17
+ * (`define.lambda-endpoint-run-boundary`)
18
+ *
19
+ * πŸ”΄ **the branch order IS the contract, and it is precedence rather than a
20
+ * sequence of independent checks.** each branch wins over the ones below it:
21
+ *
22
+ * | # | when | it throws |
23
+ * |---|---|---|
24
+ * | 1 | the payload is absent or is not json | `LambdaEndpointError` |
25
+ * | 2 | a CONTEMP envelope β€” `{ error: { _serde, class, … } }` | `ConstraintError` when `class` is one; else `LambdaEndpointError` |
26
+ * | 3 | an ANCIENT envelope β€” `{ errorMessage, … }` | `ConstraintError` when `errorType` is `ConstraintError` **or** `BadRequestError`; else `LambdaEndpointError` |
27
+ * | 4 | aws reported a `functionError` and no shape above matched | `LambdaEndpointError`, with the payload in `details` |
28
+ * | 5 | none of the above | returns the payload as `TResponse` |
29
+ *
30
+ * ⚠️ **rows 2 and 3 split on the same question and answer it differently**, which
31
+ * is deliberate: a caller's bad request is not a lambda failure, so it
32
+ * hydrates to `ConstraintError` rather than to an invocation error
33
+ * (`invariant.badrequesterror-not-lambda-error`). the ancient arm accepts
34
+ * `BadRequestError` too, because that is the name the legacy family emits for
35
+ * the same fact (`invariant.ancient-vs-contemp-callers`).
36
+ *
37
+ * ⚠️ **row 4 reads aws's own verdict, and it only ever NARROWS** β€” the block at
38
+ * its site carries the argument.
39
+ *
40
+ * 🟑 **row 3 is LOOSER than its run-side peer by design** β€” it admits an envelope
41
+ * with no `errorType`, because a lambda that exceeds its duration answers
42
+ * exactly that shape. `getIsLambdaErrorResponse.ts` carries the argument.
43
+ *
44
+ * .note = three fulcrums cite this operation β€” **F16** (it was lifted here, so
45
+ * both callers share one serde), **F19/F20** (whether its two detectors should
46
+ * share one implementation with the run-side third), and **F17** (why the
47
+ * raw-wire test fixture must NOT route through it: this hydration is precisely
48
+ * what that instrument exists to observe from the outside).
49
+ */
50
+ const getParsedResponse = (input) => {
51
+ // validate payload exists
52
+ if (!input.payload) {
53
+ throw new LambdaEndpointError_1.LambdaEndpointError('lambda returned empty payload', {
54
+ endpoint: input.endpoint,
55
+ exid: input.exid,
56
+ });
57
+ }
58
+ // decode payload to string
59
+ const payloadString = (0, getDecodedPayload_1.getDecodedPayload)({ payload: input.payload });
60
+ // parse json
61
+ const parseResult = (0, getParsedJson_1.getParsedJson)({ json: payloadString });
62
+ if (!parseResult.success) {
63
+ throw new LambdaEndpointError_1.LambdaEndpointError('lambda returned invalid json', {
64
+ endpoint: input.endpoint,
65
+ exid: input.exid,
66
+ cause: parseResult.error,
67
+ });
68
+ }
69
+ const parsed = parseResult.data;
70
+ // detect contemp error response (preferred, check first)
71
+ if ((0, getIsLambdaErrorResponse_1.getIsContempErrorResponse)(parsed)) {
72
+ const err = parsed.error;
73
+ // ConstraintError = caller's fault, not lambda error (lambda succeeded)
74
+ if (err.class === 'ConstraintError') {
75
+ // strip prefix to avoid double prefix (handler already prefixed the message)
76
+ const message = (0, asUnprefixedErrorMessage_1.asUnprefixedErrorMessage)({ message: err.message });
77
+ throw new helpful_errors_1.ConstraintError(message, {
78
+ endpoint: input.endpoint,
79
+ exid: input.exid,
80
+ causeMessage: err.cause,
81
+ details: err.details,
82
+ });
83
+ }
84
+ // all other error classes = lambda invocation error
85
+ throw new LambdaEndpointError_1.LambdaEndpointError(err.message, {
86
+ endpoint: input.endpoint,
87
+ exid: input.exid,
88
+ errorType: err.class,
89
+ causeMessage: err.cause,
90
+ details: err.details,
91
+ });
92
+ }
93
+ // detect ancient error response (backwards compat)
94
+ if ((0, getIsLambdaErrorResponse_1.getIsAncientErrorResponse)(parsed)) {
95
+ const stackTrace = (0, getStackTraceString_1.getStackTraceString)({ stackTrace: parsed.stackTrace });
96
+ const errorMeta = (0, getLambdaErrorMetadata_1.getLambdaErrorMetadata)({ errorResponse: parsed });
97
+ // ConstraintError/BadRequestError = caller's fault, not lambda error (lambda succeeded)
98
+ // .note = check both for backwards compat with handlers that use old error types
99
+ if (parsed.errorType === 'ConstraintError' ||
100
+ parsed.errorType === 'BadRequestError') {
101
+ // strip prefix to avoid double prefix (handler already prefixed the message)
102
+ const message = (0, asUnprefixedErrorMessage_1.asUnprefixedErrorMessage)({
103
+ message: parsed.errorMessage,
104
+ });
105
+ throw new helpful_errors_1.ConstraintError(message, {
106
+ endpoint: input.endpoint,
107
+ exid: input.exid,
108
+ stackTrace,
109
+ ...errorMeta,
110
+ });
111
+ }
112
+ // all other error types = lambda invocation error
113
+ throw new LambdaEndpointError_1.LambdaEndpointError(parsed.errorMessage, {
114
+ endpoint: input.endpoint,
115
+ exid: input.exid,
116
+ errorType: parsed.errorType,
117
+ stackTrace,
118
+ ...errorMeta,
119
+ });
120
+ }
121
+ /**
122
+ * πŸ”΄ the LAST WORD goes to aws, because every branch above only GUESSES.
123
+ *
124
+ * `functionError` is aws's own verdict β€” `'Unhandled'` or `'Handled'` β€” and it
125
+ * arrives from `sdkLambdaInvoke.ts:38` via `executeLambdaInvocation.ts:86`.
126
+ * every branch above re-derives *"is this an error"* from the payload's SHAPE,
127
+ * which is an inference; this one reads the ground truth.
128
+ *
129
+ * ⚠️ **without it, a fault aws reported whose payload matched neither envelope
130
+ * shape reaches the caller as a SUCCESS** β€” `rule.forbid.failhide` on a wire
131
+ * boundary, with the answer left unread in the input.
132
+ *
133
+ * β‡’ it only ever NARROWS, which is what makes it safe beside the shape branches:
134
+ *
135
+ * | aws said | shape matched | absent this check | with it |
136
+ * |---|---|---|---|
137
+ * | fault | yes | throws, richly classified | **the same** β€” the branches above win |
138
+ * | fault | no | πŸ”΄ returned as success | throws |
139
+ * | no fault | β€” | returns | **returns** |
140
+ *
141
+ * it converts no throw into a return, so it cannot commit the inverse
142
+ * failhide that F20's branch A risks.
143
+ *
144
+ * 🟑 **and it does NOT fail open on the local locus.** `onSerialized.ts` passes
145
+ * `functionError: undefined` because there is no aws to ask, and `undefined`
146
+ * reads here as *"no verdict β€” trust the shapes"*. β‡’ aws is consulted where
147
+ * it spoke, never assumed silent where it could not.
148
+ *
149
+ * .note = `functionError` is a declared parameter, so it must be READ. a
150
+ * signature that accepts a verdict and never consults it advertises a check
151
+ * it does not perform, which is the shape a reader trusts and should not.
152
+ */
153
+ if (input.functionError)
154
+ throw new LambdaEndpointError_1.LambdaEndpointError(
155
+ // rule.require.errors-name-the-fix β€” the metadata shape carries no `hint`
156
+ // field, so the fix rides in the message, which is what a human reads off
157
+ // a stack trace first. `details.payload` carries the shape itself.
158
+ 'aws reported a function error, and the payload matched neither error envelope β€” read details.payload for what the handler actually emitted', {
159
+ endpoint: input.endpoint,
160
+ exid: input.exid,
161
+ errorType: input.functionError,
162
+ details: { payload: parsed },
163
+ });
164
+ /**
165
+ * .cast = TResponse
166
+ * .why = caller specifies expected response type via generic; runtime validation
167
+ * occurs at endpoint via zod schema, not here
168
+ * .removal = add runtime schema validation to askLambdaEndpoint when needed
169
+ */
170
+ return parsed;
171
+ };
172
+ exports.getParsedResponse = getParsedResponse;
173
+ //# sourceMappingURL=getParsedResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getParsedResponse.js","sourceRoot":"","sources":["../../../src/domain.operations/lambdaEndpointWire/getParsedResponse.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * .what = strips a helpful-errors class prefix from an error message
3
+ * .why = prevents a double prefix when an error crosses the lambda boundary.
4
+ * the handler's error already carries one, and the caller constructs a
5
+ * fresh error from that message β€” so an unstripped prefix compounds.
6
+ *
7
+ * πŸ”΄ the emoji is OPTIONAL β€” `helpful-errors` emits `{emoji} {Name}: ` only where
8
+ * the class declares a static emoji, and exactly TWO do (`ConstraintError`
9
+ * `βœ‹`, `MalfunctionError` `πŸ’₯`). every other subclass emits a bare
10
+ * `{Name}: `, so a pattern anchored on one emoji misses the majority β€”
11
+ * `BadRequestError` among them, which is the ancient path's own class.
12
+ *
13
+ * ⚠️ the class name must end in `Error`, and that bound is what keeps the
14
+ * pattern safe: a bare `^\w+:\s*` would strip the caller's own text, so
15
+ * `field: uuid must be a uuid` would lose `field: `.
16
+ *
17
+ * .note = the `\d*` admits bundler deduplication suffixes (`ConstraintError5`).
18
+ */
19
+ export declare const asUnprefixedErrorMessage: (input: {
20
+ message: string;
21
+ }) => string;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asUnprefixedErrorMessage = void 0;
4
+ /**
5
+ * .what = strips a helpful-errors class prefix from an error message
6
+ * .why = prevents a double prefix when an error crosses the lambda boundary.
7
+ * the handler's error already carries one, and the caller constructs a
8
+ * fresh error from that message β€” so an unstripped prefix compounds.
9
+ *
10
+ * πŸ”΄ the emoji is OPTIONAL β€” `helpful-errors` emits `{emoji} {Name}: ` only where
11
+ * the class declares a static emoji, and exactly TWO do (`ConstraintError`
12
+ * `βœ‹`, `MalfunctionError` `πŸ’₯`). every other subclass emits a bare
13
+ * `{Name}: `, so a pattern anchored on one emoji misses the majority β€”
14
+ * `BadRequestError` among them, which is the ancient path's own class.
15
+ *
16
+ * ⚠️ the class name must end in `Error`, and that bound is what keeps the
17
+ * pattern safe: a bare `^\w+:\s*` would strip the caller's own text, so
18
+ * `field: uuid must be a uuid` would lose `field: `.
19
+ *
20
+ * .note = the `\d*` admits bundler deduplication suffixes (`ConstraintError5`).
21
+ */
22
+ const asUnprefixedErrorMessage = (input) => {
23
+ // match "{emoji}? {ClassName}Error{digits}?: {rest}"
24
+ const prefixPattern = /^(?:\S+\s+)?\w*Error\d*:\s*/;
25
+ const match = input.message.match(prefixPattern);
26
+ if (!match) {
27
+ return input.message;
28
+ }
29
+ // strip the prefix
30
+ return input.message.slice(match[0].length);
31
+ };
32
+ exports.asUnprefixedErrorMessage = asUnprefixedErrorMessage;
33
+ //# sourceMappingURL=asUnprefixedErrorMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asUnprefixedErrorMessage.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,wBAAwB,GAAG,CAAC,KAExC,EAAU,EAAE;IACX,qDAAqD;IACrD,MAAM,aAAa,GAAG,6BAA6B,CAAC;IACpD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAEjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,mBAAmB;IACnB,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,CAAC;AAbW,QAAA,wBAAwB,4BAanC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDecodedPayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/serde/getDecodedPayload.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAA8B,EAAU,EAAE;IAC1E,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getParsedJson.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/serde/getParsedJson.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACI,MAAM,aAAa,GAAG,CAAC,KAAuB,EAAoB,EAAE;IACzE,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACnC,CAAC;QACD,yCAAyC;QACzC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,aAAa,iBAWxB"}
@@ -0,0 +1,24 @@
1
+ import type { Context } from 'aws-lambda';
2
+ /**
3
+ * .what = casts a partial aws lambda context into a whole one, with defaults
4
+ * .why = a handler receives a `Context` from the runtime. off the runtime, one
5
+ * must be supplied, and every field the author does not care about is
6
+ * noise in their test.
7
+ *
8
+ * πŸ”΄ .jest-free, deliberately
9
+ *
10
+ * this is the shipped twin of `__test_assets__/createTestContext`. that file's
11
+ * peer export `createMockLog` calls `jest.fn()`, and `jest` is a devDependency
12
+ * (`package.json`), so a shipped module that reached it would break a consumer's
13
+ * install while this repo's own suite stayed green β€” the defect is invisible
14
+ * from here.
15
+ *
16
+ * β‡’ so the pure half ships and the jest-bound half stays private. this file
17
+ * imports no test runner, and none of its transitive imports may either.
18
+ *
19
+ * βœ… **the root-barrel export is DELIBERATE public surface, not a leak** (F6 β€”
20
+ * *"the lambda `Context` is overridable, and partial"*). an author who wants a
21
+ * bare `Context` without a full `onReferenced` run reaches for this directly;
22
+ * the `Partial<Context>` override is the whole point of the export.
23
+ */
24
+ export declare const asLambdaContext: (overrides?: Partial<Context>) => Context;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asLambdaContext = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const AwsIdentitySynthetic_1 = require("../../../domain.objects/AwsIdentitySynthetic");
6
+ /**
7
+ * .what = the legacy callback signals, each a LOUD refusal
8
+ * .why = πŸ”΄ **a no-op stub here is a failhide.** `context.fail(error)` is how a
9
+ * callback-style handler reports a fault, so `fail: () => {}` swallows
10
+ * that fault and the run answers `undefined` as though the handler had
11
+ * succeeded (`rule.forbid.failhide`). `done(error)` swallows the same
12
+ * way, and `succeed(result)` drops the handler's whole output.
13
+ *
14
+ * .note = this util takes handlers that return a promise, and only those β€” the
15
+ * contract F8 declares, on measured evidence that every handler in the
16
+ * population is middy-wrapped and so returns one.
17
+ *
18
+ * πŸ”΄ **F8 named its own weak spot, and this closes it.** an `any`-typed
19
+ * callback handler was to get a promise that never settles β€” a hang to test
20
+ * timeout, which teaches the author naught. now the first legacy signal it
21
+ * sends throws with the fix in the message.
22
+ *
23
+ * β‡’ `rule.prefer.prevent-over-correct`, rung 3 rather than rung 4: caught at
24
+ * the boundary, before harm, by an error that names the fix.
25
+ *
26
+ * .note = a consumer who genuinely wants the no-op keeps it β€” `overrides` spread
27
+ * last, so `asLambdaContext({ fail: () => {} })` restores the old shape.
28
+ */
29
+ const refuseTheLegacyCallbackApi = () => helpful_errors_1.ConstraintError.throw('the handler signalled through the legacy callback api, which runLambdaEndpoint does not support', {
30
+ hint: 'return a promise from the handler instead. a middy-wrapped handler already does; a raw `(event, context, callback) => …` handler must be converted first.',
31
+ });
32
+ /**
33
+ * .what = casts a partial aws lambda context into a whole one, with defaults
34
+ * .why = a handler receives a `Context` from the runtime. off the runtime, one
35
+ * must be supplied, and every field the author does not care about is
36
+ * noise in their test.
37
+ *
38
+ * πŸ”΄ .jest-free, deliberately
39
+ *
40
+ * this is the shipped twin of `__test_assets__/createTestContext`. that file's
41
+ * peer export `createMockLog` calls `jest.fn()`, and `jest` is a devDependency
42
+ * (`package.json`), so a shipped module that reached it would break a consumer's
43
+ * install while this repo's own suite stayed green β€” the defect is invisible
44
+ * from here.
45
+ *
46
+ * β‡’ so the pure half ships and the jest-bound half stays private. this file
47
+ * imports no test runner, and none of its transitive imports may either.
48
+ *
49
+ * βœ… **the root-barrel export is DELIBERATE public surface, not a leak** (F6 β€”
50
+ * *"the lambda `Context` is overridable, and partial"*). an author who wants a
51
+ * bare `Context` without a full `onReferenced` run reaches for this directly;
52
+ * the `Partial<Context>` override is the whole point of the export.
53
+ */
54
+ const asLambdaContext = (overrides) => ({
55
+ callbackWaitsForEmptyEventLoop: true,
56
+ functionName: 'run-lambda-endpoint',
57
+ functionVersion: '1',
58
+ invokedFunctionArn: `arn:aws:lambda:${AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC}:${AwsIdentitySynthetic_1.AWS_ACCOUNT_SYNTHETIC}:function:run-lambda-endpoint`,
59
+ memoryLimitInMB: '128',
60
+ awsRequestId: '00000000-0000-4000-8000-000000000000',
61
+ logGroupName: '/aws/lambda/run-lambda-endpoint',
62
+ logStreamName: 'run-lambda-endpoint',
63
+ getRemainingTimeInMillis: () => 30000,
64
+ done: refuseTheLegacyCallbackApi,
65
+ fail: refuseTheLegacyCallbackApi,
66
+ succeed: refuseTheLegacyCallbackApi,
67
+ ...overrides,
68
+ });
69
+ exports.asLambdaContext = asLambdaContext;
70
+ //# sourceMappingURL=asLambdaContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaContext.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/context/asLambdaContext.ts"],"names":[],"mappings":";;;AACA,mDAAiD;AAEjD,uFAGsD;AAEtD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,0BAA0B,GAAG,GAAU,EAAE,CAC7C,gCAAe,CAAC,KAAK,CACnB,iGAAiG,EACjG;IACE,IAAI,EAAE,2JAA2J;CAClK,CACF,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,MAAM,eAAe,GAAG,CAAC,SAA4B,EAAW,EAAE,CAAC,CAAC;IACzE,8BAA8B,EAAE,IAAI;IACpC,YAAY,EAAE,qBAAqB;IACnC,eAAe,EAAE,GAAG;IACpB,kBAAkB,EAAE,kBAAkB,2CAAoB,IAAI,4CAAqB,+BAA+B;IAClH,eAAe,EAAE,KAAK;IACtB,YAAY,EAAE,sCAAsC;IACpD,YAAY,EAAE,iCAAiC;IAC/C,aAAa,EAAE,qBAAqB;IACpC,wBAAwB,EAAE,GAAG,EAAE,CAAC,KAAM;IACtC,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE,0BAA0B;IAChC,OAAO,EAAE,0BAA0B;IACnC,GAAG,SAAS;CACb,CAAC,CAAC;AAdU,QAAA,eAAe,mBAczB"}
@@ -0,0 +1,67 @@
1
+ import type { LambdaEndpointDialect } from '../../../domain.objects/LambdaEndpointDialect';
2
+ import type { LambdaEndpointErrorResponseBodyAncient, LambdaEndpointErrorResponseBodyContemp } from '../../../domain.objects/LambdaEndpointErrorResponseBody';
3
+ /**
4
+ * .what = the constraint envelope a given dialect returns
5
+ * .why = puts the envelope SHAPE in the return type, so a cross-dialect field
6
+ * access does not compile β€” rung 1 of rule.prefer.prevent-over-correct, where a
7
+ * runtime reader would be rung 4.
8
+ *
9
+ * πŸ”΄ the BARE `TDialect extends` form is deliberate: it DISTRIBUTES, so
10
+ * `…Envelope<LambdaEndpointDialect>` resolves to `Ancient | Contemp` and
11
+ * `asLambdaEndpointOutput`'s `Exclude` subtracts BOTH arms. wrap either side in
12
+ * a tuple β€” the usual non-distributive idiom β€” and it subtracts contemp only,
13
+ * so an ancient run's success narrow still holds the envelope.
14
+ *
15
+ * ⚠️ no runtime test can see that; the predicate reads the VALUE, so the break
16
+ * is purely ergonomic and surfaces first at a consumer's type gate. clamped
17
+ * in `LambdaEndpointRunOutput.test.ts`.
18
+ */
19
+ export type LambdaEndpointErrorEnvelope<TDialect extends LambdaEndpointDialect> = TDialect extends 'ancient' ? LambdaEndpointErrorResponseBodyAncient : LambdaEndpointErrorResponseBodyContemp;
20
+ /**
21
+ * .what = the type a value HAS after it crosses the json wire
22
+ * .why = the util json-strips what a handler returns, so `{ scheduledAt: Date }`
23
+ * yields a `string`. without this type the run output carries the HANDLER's
24
+ * declaration and `out.scheduledAt.toISOString()` compiles, then throws β€” an
25
+ * unsound public type is the compile-time twin of rule.forbid.failhide.
26
+ *
27
+ * ⚠️ .the BOUND = it models `Date` β†’ iso string, and recurses arrays + objects.
28
+ * it does NOT model the two key-DROP cases (a required key valued `undefined`,
29
+ * a function value), because both need a key-remap that turns the type into an
30
+ * intersection β€” which then renders in every consumer's error messages.
31
+ */
32
+ export type WireStripped<T> = T extends Date ? string : T extends (infer TItem)[] ? WireStripped<TItem>[] : T extends object ? {
33
+ [K in keyof T]: WireStripped<T[K]>;
34
+ } : T;
35
+ /**
36
+ * .what = the type a value HAS after aws DELIVERS it β€” the wire strip, plus the
37
+ * one divergence a wire has that an in-process strip does not
38
+ * .why = πŸ”΄ the two boundaries disagree about a VOID handler, and both are right.
39
+ * `onReferenced` is HOST-faithful and answers `undefined` (what the function
40
+ * returned); `onSerialized` is WIRE-faithful and answers `null` (what aws
41
+ * delivers). so one type cannot serve both, and this is the serialized half.
42
+ *
43
+ * πŸ”΄ not an edge case β€” it is the sqs and sns consumer shape, so a migrant who
44
+ * tests one handler on both boundaries meets it on their first pair of tests.
45
+ *
46
+ * .note = the TUPLE form is deliberate. a bare `T extends void` distributes, so
47
+ * `void | { found }` would map arm-by-arm to `null | { found }` where the wire
48
+ * delivers one or the other. `[T] extends [void]` asks of the whole type.
49
+ */
50
+ export type WireDelivered<T> = [T] extends [void] ? null : WireStripped<T>;
51
+ /**
52
+ * .what = what a run of an endpoint answers: the output, or the constraint envelope
53
+ * .why = a constraint error is RETURNED on the referenced boundary β€” the lambda
54
+ * succeeded, it just told the caller their request was invalid
55
+ * (invariant.badrequesterror-not-lambda-error). so the union is the honest
56
+ * return type, and a test that expects only `TOutput` gets a compile error.
57
+ *
58
+ * .note = why these live in the operation rather than `domain.objects/` β€” and the
59
+ * answer differs per type, so a blanket lift would be wrong:
60
+ *
61
+ * | type | why here |
62
+ * |---|---|
63
+ * | `WireStripped` / `WireDelivered` | type-level MAPPERS over one boundary's lossiness. not nouns the domain holds |
64
+ * | `LambdaEndpointRunOutput` | an operation's RETURN CONTRACT (rule.forbid.io-as-domain-objects) |
65
+ * | `LambdaEndpointErrorEnvelope` | 🟑 the one real candidate. its only consumers are the lines below it, so a lift buys naught |
66
+ */
67
+ export type LambdaEndpointRunOutput<TOutput, TDialect extends LambdaEndpointDialect> = WireStripped<TOutput> | LambdaEndpointErrorEnvelope<TDialect>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LambdaEndpointRunOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LambdaEndpointRunOutput.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import type { LambdaEndpointDialect } from '../../../domain.objects/LambdaEndpointDialect';
2
+ /**
3
+ * .what = casts a declared `struct.payload` into a dialect, and refuses any value
4
+ * that is not one
5
+ * .why = the branch that reads the dialect is `if (dialect === 'contemp') … else
6
+ * ancient`, so a typo, a stale config value, or an `as any` call site falls
7
+ * through to ancient β€” the event goes FLAT, the endpoint answers
8
+ * `{ errorMessage, errorType }`, and the run SUCCEEDS in the wrong dialect while
9
+ * the author's contemp assertions fail for a reason that names neither.
10
+ *
11
+ * ⚠️ the type does not cover a js consumer, an `as any` call site, or a
12
+ * data-driven dialect. a published sdk boundary is validated at runtime or it
13
+ * is not validated (rule.forbid.unexpected-defaults) β€” the same argument the
14
+ * `at` guard makes on its peer field.
15
+ *
16
+ * .note = a THROW here, and a silent fall to ancient on `askLambdaEndpoint` β€” the
17
+ * production caller keeps the fall so a live deploy that passes a bad value
18
+ * today does not break (rule.require.contemp-must-self-identify: an
19
+ * unrecognized value is ancient, never contemp). tracked at
20
+ * `.dream/v2026_09_11.repair.one-dialect-two-validation-philosophies.md`.
21
+ *
22
+ * .note = it lives in `dialect/` because BOTH boundaries need it.
23
+ */
24
+ export declare const asLambdaEndpointDialect: (input: {
25
+ declared?: unknown;
26
+ }) => LambdaEndpointDialect;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asLambdaEndpointDialect = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = casts a declared `struct.payload` into a dialect, and refuses any value
7
+ * that is not one
8
+ * .why = the branch that reads the dialect is `if (dialect === 'contemp') … else
9
+ * ancient`, so a typo, a stale config value, or an `as any` call site falls
10
+ * through to ancient β€” the event goes FLAT, the endpoint answers
11
+ * `{ errorMessage, errorType }`, and the run SUCCEEDS in the wrong dialect while
12
+ * the author's contemp assertions fail for a reason that names neither.
13
+ *
14
+ * ⚠️ the type does not cover a js consumer, an `as any` call site, or a
15
+ * data-driven dialect. a published sdk boundary is validated at runtime or it
16
+ * is not validated (rule.forbid.unexpected-defaults) β€” the same argument the
17
+ * `at` guard makes on its peer field.
18
+ *
19
+ * .note = a THROW here, and a silent fall to ancient on `askLambdaEndpoint` β€” the
20
+ * production caller keeps the fall so a live deploy that passes a bad value
21
+ * today does not break (rule.require.contemp-must-self-identify: an
22
+ * unrecognized value is ancient, never contemp). tracked at
23
+ * `.dream/v2026_09_11.repair.one-dialect-two-validation-philosophies.md`.
24
+ *
25
+ * .note = it lives in `dialect/` because BOTH boundaries need it.
26
+ */
27
+ const asLambdaEndpointDialect = (input) => {
28
+ // absent is legal, and contemp is the default
29
+ // (rule.require.contemp-contracts-default)
30
+ if (input.declared === undefined || input.declared === null)
31
+ return 'contemp';
32
+ if (input.declared === 'contemp')
33
+ return 'contemp';
34
+ if (input.declared === 'ancient')
35
+ return 'ancient';
36
+ return helpful_errors_1.ConstraintError.throw('the payload dialect given is not one this util can send', {
37
+ declared: input.declared,
38
+ options: ['contemp', 'ancient'],
39
+ hint: "pass `struct: { payload: 'contemp' }` for the `{ event, trail }` wrapper and a `{ error: { class, message } }` envelope, or `struct: { payload: 'ancient' }` for a flat event and an `{ errorMessage, errorType }` envelope. omit `struct` for the 'contemp' default.",
40
+ });
41
+ };
42
+ exports.asLambdaEndpointDialect = asLambdaEndpointDialect;
43
+ //# sourceMappingURL=asLambdaEndpointDialect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaEndpointDialect.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAIjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAEvC,EAAyB,EAAE;IAC1B,8CAA8C;IAC9C,2CAA2C;IAC3C,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAE9E,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACnD,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAEnD,OAAO,gCAAe,CAAC,KAAK,CAC1B,yDAAyD,EACzD;QACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;QAC/B,IAAI,EAAE,uQAAuQ;KAC9Q,CACF,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,uBAAuB,2BAkBlC"}
@@ -0,0 +1,47 @@
1
+ import type { LambdaEndpointDialect } from '../../../domain.objects/LambdaEndpointDialect';
2
+ import type { LambdaEndpointErrorEnvelope } from './LambdaEndpointRunOutput';
3
+ /**
4
+ * .what = asserts a run output IS the handler's output, and narrows it
5
+ * .why = the union refuses a field read on EITHER arm, so the SUCCESS path needs
6
+ * a narrow exactly as the error path does.
7
+ *
8
+ * πŸ”΄ **the SUCCESS arm is not privileged, and it is the majority case.** a reader
9
+ * who knows the error arm needs `asLambdaEndpointErrorEnvelopeContemp` will
10
+ * assume a bare `res.field` works on the other side. it does not β€” typescript
11
+ * refuses a field that is not on every arm:
12
+ *
13
+ * TS2339: Property 'scheduledAt' does not exist on type
14
+ * 'LambdaEndpointRunOutput<{ scheduledAt: string; }, "contemp">'.
15
+ * Property 'scheduledAt' does not exist on type
16
+ * 'LambdaEndpointErrorResponseBodyContemp'.
17
+ *
18
+ * ⚠️ **and this repo's own suite cannot catch its absence, by construction.** every
19
+ * test here asserts with a WHOLE-OBJECT `toEqual({ … })`, which takes `unknown`
20
+ * and so exercises no field read at all. β‡’ a green suite is no evidence that
21
+ * this narrow exists or works; only a sample run through the type gate is.
22
+ *
23
+ * .note = the dialect needs no declaration here, unlike its error-side twin.
24
+ * `Exclude` distributes over the union and subtracts the envelope arm, so
25
+ * `TRun` survives inference. the asymmetry is a property of `Exclude`, never a
26
+ * design preference β€” the NAME pair stays symmetric.
27
+ *
28
+ * βœ… **the narrowed type states the outbound strip β€” fulcrum F13, closed.**
29
+ * `TOutput` is the type the HANDLER declares, and the util JSON-strips what
30
+ * it returns, so the two disagree. `LambdaEndpointRunOutput` carries
31
+ * `WireStripped<TOutput>` rather than `TOutput`, and the narrow inherits it:
32
+ * a handler typed `{ scheduledAt: Date }` narrows to `{ scheduledAt: string }`.
33
+ *
34
+ * const out = asLambdaEndpointOutput(res);
35
+ * out.scheduledAt.toISOString(); // πŸ’₯ no longer compiles β€” TS2339
36
+ *
37
+ * clamped in `advertisedExamples.test.ts` `[case8][t2]` and in
38
+ * `LambdaEndpointRunOutput.test.ts`, which asserts the `Date` β†’ `string`
39
+ * map directly rather than through a run.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const res = await runLambdaEndpoint.onReferenced({ event, handler });
44
+ * expect(asLambdaEndpointOutput(res).scheduledAt).toEqual('2026-09-03T14:00:00.000Z');
45
+ * ```
46
+ */
47
+ export declare const asLambdaEndpointOutput: <TRun>(output: TRun) => Exclude<TRun, LambdaEndpointErrorEnvelope<LambdaEndpointDialect>>;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asLambdaEndpointOutput = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const isLambdaEndpointErrorEnvelope_1 = require("./isLambdaEndpointErrorEnvelope");
6
+ /**
7
+ * .what = the predicate half of the narrow below
8
+ * .why = `asLambdaEndpointOutput` needs a type guard to return from. a consumer
9
+ * needs the assert form only β€” a bare boolean read on this union serves
10
+ * naught that `!isLambdaEndpointErrorEnvelopeAnyDialect(x)` does not already.
11
+ *
12
+ * πŸ”΄ **it subtracts BOTH dialects' envelopes**, because the success arm is what
13
+ * remains once every constraint envelope is removed β€” and a run's dialect is
14
+ * not known here (the value carries no dialect; the caller declared one on the
15
+ * call). so it reads the any-dialect guard, which is contemp-tag OR
16
+ * ancient-shape. F22 split the two public narrows by dialect; this private one
17
+ * stays over both, because that is the honest complement of "the output".
18
+ *
19
+ * πŸ”΄ **it is private, so every fact a CONSUMER must hold belongs on the export
20
+ * below.** typescript emits a `.d.ts` entry only for what is exported, and a
21
+ * comment travels with the declaration it annotates β€” probed against the
22
+ * emitted `.d.ts`, a note parked here reaches no consumer at all.
23
+ */
24
+ const isLambdaEndpointOutput = (output) => !(0, isLambdaEndpointErrorEnvelope_1.isLambdaEndpointErrorEnvelopeAnyDialect)(output);
25
+ /**
26
+ * .what = asserts a run output IS the handler's output, and narrows it
27
+ * .why = the union refuses a field read on EITHER arm, so the SUCCESS path needs
28
+ * a narrow exactly as the error path does.
29
+ *
30
+ * πŸ”΄ **the SUCCESS arm is not privileged, and it is the majority case.** a reader
31
+ * who knows the error arm needs `asLambdaEndpointErrorEnvelopeContemp` will
32
+ * assume a bare `res.field` works on the other side. it does not β€” typescript
33
+ * refuses a field that is not on every arm:
34
+ *
35
+ * TS2339: Property 'scheduledAt' does not exist on type
36
+ * 'LambdaEndpointRunOutput<{ scheduledAt: string; }, "contemp">'.
37
+ * Property 'scheduledAt' does not exist on type
38
+ * 'LambdaEndpointErrorResponseBodyContemp'.
39
+ *
40
+ * ⚠️ **and this repo's own suite cannot catch its absence, by construction.** every
41
+ * test here asserts with a WHOLE-OBJECT `toEqual({ … })`, which takes `unknown`
42
+ * and so exercises no field read at all. β‡’ a green suite is no evidence that
43
+ * this narrow exists or works; only a sample run through the type gate is.
44
+ *
45
+ * .note = the dialect needs no declaration here, unlike its error-side twin.
46
+ * `Exclude` distributes over the union and subtracts the envelope arm, so
47
+ * `TRun` survives inference. the asymmetry is a property of `Exclude`, never a
48
+ * design preference β€” the NAME pair stays symmetric.
49
+ *
50
+ * βœ… **the narrowed type states the outbound strip β€” fulcrum F13, closed.**
51
+ * `TOutput` is the type the HANDLER declares, and the util JSON-strips what
52
+ * it returns, so the two disagree. `LambdaEndpointRunOutput` carries
53
+ * `WireStripped<TOutput>` rather than `TOutput`, and the narrow inherits it:
54
+ * a handler typed `{ scheduledAt: Date }` narrows to `{ scheduledAt: string }`.
55
+ *
56
+ * const out = asLambdaEndpointOutput(res);
57
+ * out.scheduledAt.toISOString(); // πŸ’₯ no longer compiles β€” TS2339
58
+ *
59
+ * clamped in `advertisedExamples.test.ts` `[case8][t2]` and in
60
+ * `LambdaEndpointRunOutput.test.ts`, which asserts the `Date` β†’ `string`
61
+ * map directly rather than through a run.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const res = await runLambdaEndpoint.onReferenced({ event, handler });
66
+ * expect(asLambdaEndpointOutput(res).scheduledAt).toEqual('2026-09-03T14:00:00.000Z');
67
+ * ```
68
+ */
69
+ const asLambdaEndpointOutput = (output) => {
70
+ if (isLambdaEndpointOutput(output))
71
+ return output;
72
+ // 🟑 the hint names the LIKELY cause AND the one case where it is wrong.
73
+ //
74
+ // πŸ”΄ this narrow cannot know the run's declared dialect, so it reads the
75
+ // ANY-dialect guard β€” `contemp-tag OR ancient-shape`. the ancient arm (a
76
+ // flat `{ errorMessage, errorType }` pair) therefore runs on every call,
77
+ // and a handler whose legitimate SUCCESS output carries those two string
78
+ // keys reads as an envelope on EITHER dialect.
79
+ //
80
+ // β‡’ a confident wrong *"the handler rejected this event"* sends an author to
81
+ // search for a rejection that never happened, so the hint states the
82
+ // ambiguity (`rule.require.errors-name-the-fix`).
83
+ throw new helpful_errors_1.ConstraintError('the endpoint answered with a constraint envelope, never an output', {
84
+ output,
85
+ hint: 'the handler rejected this event. assert on the envelope via asLambdaEndpointErrorEnvelopeContemp (or …Ancient if you declared the ancient dialect), or send an event the schema accepts. β€” on EITHER dialect, one other cause is possible: this success narrow subtracts both envelope shapes, so the flat { errorMessage: string, errorType: string } pair reads as an envelope even under contemp. if that is your success output shape, read it directly rather than through this narrow.',
86
+ });
87
+ };
88
+ exports.asLambdaEndpointOutput = asLambdaEndpointOutput;
89
+ //# sourceMappingURL=asLambdaEndpointOutput.js.map