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,98 @@
1
+ import type { ContextAwsLambdaCaller } from '../../domain.objects/ContextAwsLambdaCaller';
2
+ import type { LambdaEndpointDialect } from '../../domain.objects/LambdaEndpointDialect';
3
+ import type { WireDelivered } from './dialect/LambdaEndpointRunOutput';
4
+ /**
5
+ * .what = where the endpoint runs, once you address it by slug
6
+ * .why = a slug points either at the real wire or at this repo's own
7
+ * serverless.yml. both cross the SERIALIZED boundary, so both take caller
8
+ * semantics — the locus changes where, never what
9
+ * (define.lambda-endpoint-run-boundary)
10
+ */
11
+ export type LambdaEndpointLocus = 'cloud' | 'local';
12
+ /**
13
+ * .what = runs a lambda endpoint you hold the SLUG of — `{ service, function }`
14
+ * plus the ambient access
15
+ * .why = shapes cross this boundary as json, so you are the endpoint's CALLER
16
+ * rather than its host — and a caller gets caller semantics
17
+ *
18
+ * ## 🔴 the error stance INVERTS, and that is the whole reason for the split
19
+ *
20
+ * | boundary | a constraint error arrives as | because |
21
+ * |----------|-------------------------------|---------|
22
+ * | `onReferenced` | a **returned** envelope | you hold the handler, so you are the HOST |
23
+ * | `onSerialized` | a **thrown** `ConstraintError` | you named the endpoint, so you are a CALLER |
24
+ *
25
+ * ⚠️ `at` does NOT cleave this — `'local'` and `'cloud'` both throw. a constraint
26
+ * fault is RETURNED by the handler and reaches the shared hydration by itself;
27
+ * a malfunction is THROWN, so `asWireFunctionErrorPayload` casts it into the
28
+ * payload aws would have sent. one hydration, both loci, both outcome families.
29
+ *
30
+ * ⚠️ the type does not catch a move across the boundary — a rejected `Promise<T>`
31
+ * is well-typed, so an author who comes from `onReferenced` and still expects a
32
+ * returned envelope gets a runtime surprise. the subdomain names are the cue.
33
+ *
34
+ * ## the two loci cannot drift
35
+ *
36
+ * `'local'` runs the handler in-process, then hands its output through the SAME
37
+ * hydration the wire uses (`getParsedResponse`). one hydration, not two.
38
+ *
39
+ * ## 🔴 what the move off the incumbent buys
40
+ *
41
+ * the incumbent reaches aws through `simple-lambda-client`, which pulls aws-sdk v2
42
+ * — no sso-profile support, so it hangs on IMDS. measured at **90s per invoke** on
43
+ * `ahbode/svc-home-services` PR #30 until credentials were exported to env vars.
44
+ * this sdk is on `@aws-sdk/client-lambda` v3, which reads an sso profile natively.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * // the deployed function, over the real wire
49
+ * const out = await runLambdaEndpoint.onSerialized(
50
+ * { which: { service: 'svc-home-services', function: 'getServiceBySlug' },
51
+ * event: { slug: 'surf-lesson' }, at: 'cloud' },
52
+ * { log, env: { access: 'prep' } },
53
+ * );
54
+ *
55
+ * // the same endpoint, run from this repo's serverless.yml
56
+ * const out = await runLambdaEndpoint.onSerialized({ …, at: 'local' }, { log, env });
57
+ *
58
+ * // a caller fault THROWS here, on either locus
59
+ * await expect(
60
+ * runLambdaEndpoint.onSerialized({ …, event: { slug: '' } }, ctx),
61
+ * ).rejects.toThrow(ConstraintError);
62
+ * ```
63
+ */
64
+ export declare const onSerialized: <TEvent, TOutput>(input: {
65
+ /**
66
+ * the endpoint's business identity. the ambient `context.env.access`
67
+ * completes the slug (rule.require.env-access-in-context).
68
+ */
69
+ which: {
70
+ service: string;
71
+ function: string;
72
+ };
73
+ /**
74
+ * the event to send
75
+ */
76
+ event: TEvent;
77
+ /**
78
+ * where the slug is looked up. cloud by default — the deployed function.
79
+ */
80
+ at?: LambdaEndpointLocus;
81
+ /**
82
+ * which error dialect to send in. contemp by default.
83
+ *
84
+ * 🔴 .note = a plain input here, NEVER a type parameter — unlike
85
+ * `onReferenced<…, TDialect>`. a type-level dialect needs an envelope in the
86
+ * return to guard, and this boundary has none: a caller fault is THROWN, and
87
+ * both dialects hydrate to the same error. so the dialect changes what goes
88
+ * over the WIRE and no shape the author can read; a `TDialect` here would
89
+ * advertise a guarantee with no arm to guard.
90
+ */
91
+ struct?: {
92
+ payload: LambdaEndpointDialect;
93
+ };
94
+ /**
95
+ * where to search for serverless.yml, when `at: 'local'`. cwd by default.
96
+ */
97
+ from?: string;
98
+ }, context: ContextAwsLambdaCaller) => Promise<WireDelivered<TOutput>>;
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onSerialized = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const askLambdaEndpoint_1 = require("../askLambdaEndpoint/askLambdaEndpoint");
6
+ const asLambdaEndpoint_1 = require("../asLambdaEndpoint/asLambdaEndpoint");
7
+ const getOneTrailExid_1 = require("../lambdaEndpointWire/context/getOneTrailExid");
8
+ const throwIfCredentialsError_1 = require("../lambdaEndpointWire/error/throwIfCredentialsError");
9
+ const getParsedResponse_1 = require("../lambdaEndpointWire/getParsedResponse");
10
+ const asLambdaEndpointDialect_1 = require("./dialect/asLambdaEndpointDialect");
11
+ const assertEventIsGiven_1 = require("./guard/assertEventIsGiven");
12
+ const assertHandlerIsRunnable_1 = require("./guard/assertHandlerIsRunnable");
13
+ const asLocalRunIdentity_1 = require("./local/asLocalRunIdentity");
14
+ const getOneHandlerFromServerlessYml_1 = require("./local/getOneHandlerFromServerlessYml");
15
+ const runLambdaEndpoint_onReferenced_1 = require("./runLambdaEndpoint.onReferenced");
16
+ const asWireFunctionErrorPayload_1 = require("./serde/asWireFunctionErrorPayload");
17
+ const asWirePayload_1 = require("./serde/asWirePayload");
18
+ /**
19
+ * .what = runs a lambda endpoint you hold the SLUG of — `{ service, function }`
20
+ * plus the ambient access
21
+ * .why = shapes cross this boundary as json, so you are the endpoint's CALLER
22
+ * rather than its host — and a caller gets caller semantics
23
+ *
24
+ * ## 🔴 the error stance INVERTS, and that is the whole reason for the split
25
+ *
26
+ * | boundary | a constraint error arrives as | because |
27
+ * |----------|-------------------------------|---------|
28
+ * | `onReferenced` | a **returned** envelope | you hold the handler, so you are the HOST |
29
+ * | `onSerialized` | a **thrown** `ConstraintError` | you named the endpoint, so you are a CALLER |
30
+ *
31
+ * ⚠️ `at` does NOT cleave this — `'local'` and `'cloud'` both throw. a constraint
32
+ * fault is RETURNED by the handler and reaches the shared hydration by itself;
33
+ * a malfunction is THROWN, so `asWireFunctionErrorPayload` casts it into the
34
+ * payload aws would have sent. one hydration, both loci, both outcome families.
35
+ *
36
+ * ⚠️ the type does not catch a move across the boundary — a rejected `Promise<T>`
37
+ * is well-typed, so an author who comes from `onReferenced` and still expects a
38
+ * returned envelope gets a runtime surprise. the subdomain names are the cue.
39
+ *
40
+ * ## the two loci cannot drift
41
+ *
42
+ * `'local'` runs the handler in-process, then hands its output through the SAME
43
+ * hydration the wire uses (`getParsedResponse`). one hydration, not two.
44
+ *
45
+ * ## 🔴 what the move off the incumbent buys
46
+ *
47
+ * the incumbent reaches aws through `simple-lambda-client`, which pulls aws-sdk v2
48
+ * — no sso-profile support, so it hangs on IMDS. measured at **90s per invoke** on
49
+ * `ahbode/svc-home-services` PR #30 until credentials were exported to env vars.
50
+ * this sdk is on `@aws-sdk/client-lambda` v3, which reads an sso profile natively.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * // the deployed function, over the real wire
55
+ * const out = await runLambdaEndpoint.onSerialized(
56
+ * { which: { service: 'svc-home-services', function: 'getServiceBySlug' },
57
+ * event: { slug: 'surf-lesson' }, at: 'cloud' },
58
+ * { log, env: { access: 'prep' } },
59
+ * );
60
+ *
61
+ * // the same endpoint, run from this repo's serverless.yml
62
+ * const out = await runLambdaEndpoint.onSerialized({ …, at: 'local' }, { log, env });
63
+ *
64
+ * // a caller fault THROWS here, on either locus
65
+ * await expect(
66
+ * runLambdaEndpoint.onSerialized({ …, event: { slug: '' } }, ctx),
67
+ * ).rejects.toThrow(ConstraintError);
68
+ * ```
69
+ */
70
+ const onSerialized = async (input, context) => {
71
+ // an ABSENT event is refused HERE TOO, before the locus branch — the referenced
72
+ // twin's guard would answer the cloud locus 90s late and the local locus
73
+ // stripped of its hint. both halves measured; see `guard/assertEventIsGiven.ts`.
74
+ (0, assertEventIsGiven_1.assertEventIsGiven)({
75
+ event: input.event,
76
+ metadata: { which: input.which, at: input.at ?? 'cloud' },
77
+ });
78
+ const at = input.at ?? 'cloud';
79
+ // 🔴 an UNKNOWN locus is refused. the branch below reads `if (at === 'cloud')`
80
+ // and lets every other value fall to LOCAL, so `'CLOUD'` or an `at` read
81
+ // from config runs in-process while the caller believes they hit a deployed
82
+ // lambda — and a fall to local LOOKS LIKE A PASS where a fall to cloud
83
+ // would fail loud (`rule.forbid.unexpected-defaults`).
84
+ if (at !== 'cloud' && at !== 'local')
85
+ return helpful_errors_1.ConstraintError.throw('the locus given is not one this util can run', {
86
+ at,
87
+ options: ['cloud', 'local'],
88
+ hint: "pass `at: 'cloud'` to invoke the deployed lambda over the wire, or `at: 'local'` to resolve the handler from serverless.yml and run it in-process. omit `at` for the 'cloud' default.",
89
+ });
90
+ // 🔴 an UNKNOWN dialect is refused HERE, before either locus forwards it — the
91
+ // CLOUD half is what needs it, since local would be caught downstream. the
92
+ // result is BOUND and forwarded rather than discarded, so a delete of this
93
+ // line fails the build (`rule.prefer.prevent-over-correct`, rung 1).
94
+ const dialectValidated = (0, asLambdaEndpointDialect_1.asLambdaEndpointDialect)({
95
+ declared: input.struct?.payload,
96
+ });
97
+ const structValidated = { payload: dialectValidated };
98
+ // the cloud locus: the real wire, with v3 credentials and the sdk's own serde.
99
+ // the type argument is `WireDelivered<TOutput>`, never `TOutput` — it names
100
+ // the shape to PARSE OUT OF the wire payload.
101
+ //
102
+ // 🔴 the credentials fault is named HERE and deliberately NOT on
103
+ // `askLambdaEndpoint`. same aws error, opposite diagnosis:
104
+ //
105
+ // | boundary | who meets it | an absent credential is |
106
+ // |---|---|---|
107
+ // | `onSerialized({ at: 'cloud' })` | a developer, at a terminal | an expired sso session — one command away |
108
+ // | `askLambdaEndpoint` | a deployed lambda, in prod | a broken execution role — a server fault |
109
+ //
110
+ // `LambdaCredentialsAbsentError extends ConstraintError` ⇒ caller fault, NO
111
+ // ALARM. to map it on the runtime path would suppress the prod alarm that
112
+ // names a broken role (`invariant.badrequesterror-not-lambda-error`).
113
+ if (at === 'cloud')
114
+ return (0, askLambdaEndpoint_1.askLambdaEndpoint)({
115
+ which: input.which,
116
+ event: input.event,
117
+ struct: structValidated,
118
+ }, context).catch((error) => (0, throwIfCredentialsError_1.throwIfCredentialsError)({
119
+ error,
120
+ message: 'aws credentials are absent or expired, so the deployed endpoint cannot be invoked',
121
+ access: context.env.access,
122
+ metadata: {
123
+ which: input.which,
124
+ access: context.env.access,
125
+ at,
126
+ },
127
+ }));
128
+ // the local locus: look the handler up, run it, then hydrate exactly as the wire does
129
+ const endpoint = (0, asLambdaEndpoint_1.asLambdaEndpoint)({
130
+ service: input.which.service,
131
+ access: context.env.access,
132
+ function: input.which.function,
133
+ });
134
+ const handler = await (0, getOneHandlerFromServerlessYml_1.getOneHandlerFromServerlessYml)({
135
+ service: input.which.service,
136
+ function: input.which.function,
137
+ from: input.from,
138
+ });
139
+ // 🔴 the handler guards run HERE, ahead of the delegation — the placement IS
140
+ // the repair (see `serde/asWireFunctionErrorPayload.ts`). clamped at two
141
+ // grains, since the integration clamp imports an INTERNAL path and a barrel
142
+ // that re-caught on the way out would leave it green.
143
+ (0, assertHandlerIsRunnable_1.assertHandlerIsRunnable)({ handler });
144
+ // the exid AND its fallback report, in one call — the same call the cloud
145
+ // locus makes, so the two loci cannot diverge on this diagnostic
146
+ const exid = (0, getOneTrailExid_1.getOneTrailExid)({ log: context.log });
147
+ // reuse the referenced boundary to run it — the serialized-local cell is BUILT
148
+ // on the referenced cell, as the incumbent composes it
149
+ // (invokeLambdaForTestingLocally.ts:81).
150
+ // ⚠️ the `.catch` casts a THROW into the payload aws would have put on the
151
+ // wire, so it reaches the shared hydration below as the cloud locus does.
152
+ const output = await (0, runLambdaEndpoint_onReferenced_1.onReferenced)({
153
+ event: input.event,
154
+ handler,
155
+ struct: structValidated,
156
+ // the runtime identity is DERIVED from the endpoint, never a caller's knob —
157
+ // see `asLocalRunIdentity` for why a `context` passthrough is declined here
158
+ context: (0, asLocalRunIdentity_1.asLocalRunIdentity)({ endpoint, region: context.env.region }),
159
+ // 🟡 the trail, forwarded. omit it and the endpoint's trail middleware
160
+ // generates a fresh exid, so the caller's trace does not join up — and no
161
+ // test fails, because an absent trail is legal
162
+ // (`invariant.payload-format-compat`). it does NOT select the dialect.
163
+ trail: { exid },
164
+ }).catch(asWireFunctionErrorPayload_1.asWireFunctionErrorPayload);
165
+ // 🔴 one hydration, shared with the wire — so the two loci cannot disagree
166
+ // about what an envelope means. `asWirePayload` carries the one place they
167
+ // DO diverge (a void handler's value) and states why.
168
+ return (0, getParsedResponse_1.getParsedResponse)({
169
+ payload: (0, asWirePayload_1.asWirePayload)(output),
170
+ functionError: undefined,
171
+ endpoint,
172
+ exid,
173
+ });
174
+ };
175
+ exports.onSerialized = onSerialized;
176
+ //# sourceMappingURL=runLambdaEndpoint.onSerialized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runLambdaEndpoint.onSerialized.js","sourceRoot":"","sources":["../../../src/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,41 @@
1
+ import type { LambdaEndpointDialect } from '../../../domain.objects/LambdaEndpointDialect';
2
+ /**
3
+ * .what = casts an event into the payload frame a given dialect sends
4
+ * .why = the endpoint reads the FRAME to decide the dialect — `getIsWrappedPayload`
5
+ * checks for exactly `{ event, trail }` — so the frame IS the declaration.
6
+ *
7
+ * | dialect | the frame emitted | getIsWrappedPayload |
8
+ * |---------|-------------------|---------------------|
9
+ * | contemp | `{ event, trail }` | true → contemp envelope |
10
+ * | ancient | the event, untouched | false → ancient envelope |
11
+ *
12
+ * 🔴 .the one knob
13
+ *
14
+ * F9 names an open bound in the vision: the frame is driven by `trail:` and the
15
+ * dialect is declared by `struct.payload` — **two knobs, one fact**, so they can
16
+ * be set to disagree, and that design admits a contemp envelope under an ancient
17
+ * return type.
18
+ *
19
+ * this closes it by DERIVATION: `struct.payload` is the only declaration, and the
20
+ * frame follows from it. `trail` supplies the exid and never the dialect. so the
21
+ * disagreement is unrepresentable rather than policed
22
+ * (rule.prefer.prevent-over-correct, rung 1).
23
+ *
24
+ * 🔴 .ancient drops the trail, exactly as the wire does
25
+ *
26
+ * `askLambdaEndpoint.ts:74-77` sends `input.event` and nothing else on the ancient
27
+ * dialect — the trail does not travel. this matches it verbatim.
28
+ *
29
+ * ⚠️ ancient never merges `{ ...event, trail }` for a caller that carries an exid
30
+ * — a shape `invariant.payload-format-compat` does describe, and that **no
31
+ * caller in this sdk ever sends**. that merge is backcompat nobody asked for,
32
+ * it makes the referenced boundary disagree with the wire, and it costs two
33
+ * defensive branches.
34
+ */
35
+ export declare const asFramedPayload: (input: {
36
+ event: unknown;
37
+ trail: {
38
+ exid?: string;
39
+ } | null;
40
+ dialect: LambdaEndpointDialect;
41
+ }) => unknown;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asFramedPayload = void 0;
4
+ /**
5
+ * .what = casts an event into the payload frame a given dialect sends
6
+ * .why = the endpoint reads the FRAME to decide the dialect — `getIsWrappedPayload`
7
+ * checks for exactly `{ event, trail }` — so the frame IS the declaration.
8
+ *
9
+ * | dialect | the frame emitted | getIsWrappedPayload |
10
+ * |---------|-------------------|---------------------|
11
+ * | contemp | `{ event, trail }` | true → contemp envelope |
12
+ * | ancient | the event, untouched | false → ancient envelope |
13
+ *
14
+ * 🔴 .the one knob
15
+ *
16
+ * F9 names an open bound in the vision: the frame is driven by `trail:` and the
17
+ * dialect is declared by `struct.payload` — **two knobs, one fact**, so they can
18
+ * be set to disagree, and that design admits a contemp envelope under an ancient
19
+ * return type.
20
+ *
21
+ * this closes it by DERIVATION: `struct.payload` is the only declaration, and the
22
+ * frame follows from it. `trail` supplies the exid and never the dialect. so the
23
+ * disagreement is unrepresentable rather than policed
24
+ * (rule.prefer.prevent-over-correct, rung 1).
25
+ *
26
+ * 🔴 .ancient drops the trail, exactly as the wire does
27
+ *
28
+ * `askLambdaEndpoint.ts:74-77` sends `input.event` and nothing else on the ancient
29
+ * dialect — the trail does not travel. this matches it verbatim.
30
+ *
31
+ * ⚠️ ancient never merges `{ ...event, trail }` for a caller that carries an exid
32
+ * — a shape `invariant.payload-format-compat` does describe, and that **no
33
+ * caller in this sdk ever sends**. that merge is backcompat nobody asked for,
34
+ * it makes the referenced boundary disagree with the wire, and it costs two
35
+ * defensive branches.
36
+ */
37
+ const asFramedPayload = (input) => {
38
+ // contemp: the wrapper IS the declaration. an absent exid is legal —
39
+ // genTrailMiddleware generates one, exactly as it does for askLambdaEndpoint.
40
+ //
41
+ // .note = the wrapper carries the exid and NO other trail field, which is what
42
+ // getLambdaPayload does for the wire (`serde/getLambdaPayload.ts:9-12`). the
43
+ // two are not merged because that one demands an exid where this one may not
44
+ // have it — but they must agree on the shape they emit, and they do. forward
45
+ // the whole trail here and a `stack` survives at this boundary, then gets
46
+ // dropped by the wire.
47
+ //
48
+ // 🔴 the agreement is CLAMPED, not held by this comment alone:
49
+ // `lambdaEndpointWire/frame/contempFrameEmittersAgree.test.ts` asserts both
50
+ // emitters produce the identical frame for an exid-bearing input, so a future
51
+ // divergence (a new field on one and not the other) goes red.
52
+ if (input.dialect === 'contemp')
53
+ return {
54
+ event: input.event,
55
+ trail: input.trail?.exid ? { exid: input.trail.exid } : {},
56
+ };
57
+ // ancient: the event crosses untouched. no wrapper, so getIsWrappedPayload stays
58
+ // false and the endpoint answers in the dialect the caller declared.
59
+ return input.event;
60
+ };
61
+ exports.asFramedPayload = asFramedPayload;
62
+ //# sourceMappingURL=asFramedPayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asFramedPayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/serde/asFramedPayload.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACI,MAAM,eAAe,GAAG,CAAC,KAI/B,EAAW,EAAE;IACZ,qEAAqE;IACrE,8EAA8E;IAC9E,EAAE;IACF,+EAA+E;IAC/E,+EAA+E;IAC/E,+EAA+E;IAC/E,+EAA+E;IAC/E,4EAA4E;IAC5E,yBAAyB;IACzB,EAAE;IACF,+DAA+D;IAC/D,8EAA8E;IAC9E,gFAAgF;IAChF,gEAAgE;IAChE,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAC7B,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;SAC3D,CAAC;IAEJ,iFAAiF;IACjF,qEAAqE;IACrE,OAAO,KAAK,CAAC,KAAK,CAAC;AACrB,CAAC,CAAC;AA5BW,QAAA,eAAe,mBA4B1B"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * .what = casts a thrown handler fault into the envelope aws puts on the wire
3
+ * .why = 🔴 **a THROW does not cross a wire; a payload does.** on the cloud locus
4
+ * aws answers `{ errorMessage, errorType, stackTrace }` and
5
+ * `getParsedResponse` hydrates it. the local locus runs the handler in
6
+ * THIS process, so without this cast its throw escapes as the handler's
7
+ * own class — and one malfunction arrives as two classes on the two loci,
8
+ * which is `at` altering the contract it exists to hold constant.
9
+ *
10
+ * ## 🔴 what this DROPS — the placement rule every guard owes
11
+ *
12
+ * ⚠️ **the CANONICAL account; three peers cite it and none restates it** — both
13
+ * `guard/assert*.ts` and both `runLambdaEndpoint.on*.ts` call sites. it lives
14
+ * here because the rule and its cause die together.
15
+ *
16
+ * the cast carries three fields and no `metadata`, so no `hint`. ⇒ **every guard
17
+ * in `runLambdaEndpoint` runs AHEAD of the delegation, never inside it** — a
18
+ * guard that fires inside `.catch(asWireFunctionErrorPayload)` answers a
19
+ * local-locus caller with its fix demoted out of a structured field:
20
+ *
21
+ * | | inside the delegation | ahead of it |
22
+ * |---|---|---|
23
+ * | error class | unchanged | unchanged |
24
+ * | the hint TEXT | present, buried in `stackTrace` | present |
25
+ * | `metadata.hint` | ❌ absent | ✅ present |
26
+ *
27
+ * 🟡 the obvious alternative — preserve `metadata` when the error carries a hint
28
+ * — is what `[t4]` of `runLambdaEndpoint.onSerialized.integration.test.ts`
29
+ * forbids: aws sends no `metadata`, so a local locus that kept it would hand
30
+ * a richer error than cloud can produce. that is the divergence the fix was
31
+ * meant to remove, reintroduced.
32
+ *
33
+ * .note = a wrap-and-rethrow, never a `rule.forbid.failhide` — the fault is
34
+ * re-raised through the one shared hydration.
35
+ */
36
+ export declare const asWireFunctionErrorPayload: (error: unknown) => {
37
+ errorMessage: string;
38
+ errorType: string;
39
+ stackTrace: string[];
40
+ };
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asWireFunctionErrorPayload = void 0;
4
+ const isErrorLike_1 = require("../error/isErrorLike");
5
+ /**
6
+ * .what = casts a thrown handler fault into the envelope aws puts on the wire
7
+ * .why = 🔴 **a THROW does not cross a wire; a payload does.** on the cloud locus
8
+ * aws answers `{ errorMessage, errorType, stackTrace }` and
9
+ * `getParsedResponse` hydrates it. the local locus runs the handler in
10
+ * THIS process, so without this cast its throw escapes as the handler's
11
+ * own class — and one malfunction arrives as two classes on the two loci,
12
+ * which is `at` altering the contract it exists to hold constant.
13
+ *
14
+ * ## 🔴 what this DROPS — the placement rule every guard owes
15
+ *
16
+ * ⚠️ **the CANONICAL account; three peers cite it and none restates it** — both
17
+ * `guard/assert*.ts` and both `runLambdaEndpoint.on*.ts` call sites. it lives
18
+ * here because the rule and its cause die together.
19
+ *
20
+ * the cast carries three fields and no `metadata`, so no `hint`. ⇒ **every guard
21
+ * in `runLambdaEndpoint` runs AHEAD of the delegation, never inside it** — a
22
+ * guard that fires inside `.catch(asWireFunctionErrorPayload)` answers a
23
+ * local-locus caller with its fix demoted out of a structured field:
24
+ *
25
+ * | | inside the delegation | ahead of it |
26
+ * |---|---|---|
27
+ * | error class | unchanged | unchanged |
28
+ * | the hint TEXT | present, buried in `stackTrace` | present |
29
+ * | `metadata.hint` | ❌ absent | ✅ present |
30
+ *
31
+ * 🟡 the obvious alternative — preserve `metadata` when the error carries a hint
32
+ * — is what `[t4]` of `runLambdaEndpoint.onSerialized.integration.test.ts`
33
+ * forbids: aws sends no `metadata`, so a local locus that kept it would hand
34
+ * a richer error than cloud can produce. that is the divergence the fix was
35
+ * meant to remove, reintroduced.
36
+ *
37
+ * .note = a wrap-and-rethrow, never a `rule.forbid.failhide` — the fault is
38
+ * re-raised through the one shared hydration.
39
+ */
40
+ const asWireFunctionErrorPayload = (error) => {
41
+ /**
42
+ * .what = reads the error by duck-type, never by `instanceof Error`
43
+ * .why = 🔴 `instanceof` fails CROSS-REALM, and this runs where two realms
44
+ * meet: the local locus loads the handler through
45
+ * `getOneHandlerFromServerlessYml`, and jest executes each module in
46
+ * its own vm context.
47
+ *
48
+ * ⚠️ the miss is SILENT — it degrades the payload rather than throws:
49
+ * `errorMessage` gains an `Error: ` prefix, `errorType` collapses to
50
+ * `'Error'`, `stackTrace` is dropped. `getParsedResponse` hydrates from
51
+ * `errorType`, so a cross-realm `ConstraintError` comes back generic — a
52
+ * caller fault that no longer reads as one (`rule.forbid.failhide`).
53
+ */
54
+ if (!(0, isErrorLike_1.isErrorLike)(error))
55
+ return {
56
+ errorMessage: String(error),
57
+ errorType: 'Error',
58
+ stackTrace: [],
59
+ };
60
+ return {
61
+ errorMessage: error.message,
62
+ errorType: error.constructor?.name ?? 'Error',
63
+ // `stack` is optional on a real Error
64
+ stackTrace: typeof error.stack === 'string' ? error.stack.split('\n') : [],
65
+ };
66
+ };
67
+ exports.asWireFunctionErrorPayload = asWireFunctionErrorPayload;
68
+ //# sourceMappingURL=asWireFunctionErrorPayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asWireFunctionErrorPayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACI,MAAM,0BAA0B,GAAG,CACxC,KAAc,EACqD,EAAE;IACrE;;;;;;;;;;;;OAYG;IACH,IAAI,CAAC,IAAA,yBAAW,EAAC,KAAK,CAAC;QACrB,OAAO;YACL,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC;YAC3B,SAAS,EAAE,OAAO;YAClB,UAAU,EAAE,EAAE;SACf,CAAC;IAEJ,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,OAAO;QAC3B,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE,IAAI,IAAI,OAAO;QAC7C,sCAAsC;QACtC,UAAU,EAAE,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;KAC3E,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,0BAA0B,8BA6BrC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * .what = casts a handler's in-process answer into the byte payload aws puts on
3
+ * the wire
4
+ * .why = the local locus must hand `getParsedResponse` what the CLOUD locus
5
+ * hands it, or the two loci hydrate different things and `at` changes the
6
+ * contract it exists to hold constant.
7
+ *
8
+ * ⚠️ **`?? null` is a BOUNDARY DIVERGENCE, never a defensive default.** a void
9
+ * handler answers `undefined` on the referenced boundary
10
+ * (`asWireStripped.ts:18` returns it rather than throws) and **`null`** here —
11
+ * because aws delivers `null` for a lambda that returns no value, so `null` is
12
+ * what a real caller receives.
13
+ *
14
+ * ⇒ the two boundaries genuinely disagree about a void handler's value, and
15
+ * each is right for its own side. it is the same asymmetry the error stance
16
+ * has, one level down: the referenced boundary is HOST-faithful, the
17
+ * serialized boundary is WIRE-faithful.
18
+ *
19
+ * 🟡 an sqs or sns consumer handler is exactly the void case, so this is a real
20
+ * experience rather than an edge — see `case=11`'s actor, and
21
+ * `define.lambda-endpoint-run-boundary` for the boundary table it belongs to.
22
+ *
23
+ * .note = named rather than inline, so the `onSerialized` orchestrator reads as
24
+ * narrative rather than as a stringify-with-a-fallback plus a utf-8 encode
25
+ * (rule.forbid.inline-decode-friction). the divergence above is the whole
26
+ * reason it earns a name: it is the one line where the two loci differ.
27
+ *
28
+ * .note = the `?? null` is clamped in `asWirePayload.test.ts` on three axes, and
29
+ * each exists because a plausible edit breaks exactly one: `[case2]` the void
30
+ * divergence against its referenced peer, `[case3]` that `0` / `''` / `false`
31
+ * are NOT void, and `[case4]` that `WireDelivered`'s declared `null` and this
32
+ * runtime `null` remain one fact rather than two that drifted.
33
+ */
34
+ export declare const asWirePayload: (output: unknown) => Uint8Array;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asWirePayload = void 0;
4
+ /**
5
+ * .what = casts a handler's in-process answer into the byte payload aws puts on
6
+ * the wire
7
+ * .why = the local locus must hand `getParsedResponse` what the CLOUD locus
8
+ * hands it, or the two loci hydrate different things and `at` changes the
9
+ * contract it exists to hold constant.
10
+ *
11
+ * ⚠️ **`?? null` is a BOUNDARY DIVERGENCE, never a defensive default.** a void
12
+ * handler answers `undefined` on the referenced boundary
13
+ * (`asWireStripped.ts:18` returns it rather than throws) and **`null`** here —
14
+ * because aws delivers `null` for a lambda that returns no value, so `null` is
15
+ * what a real caller receives.
16
+ *
17
+ * ⇒ the two boundaries genuinely disagree about a void handler's value, and
18
+ * each is right for its own side. it is the same asymmetry the error stance
19
+ * has, one level down: the referenced boundary is HOST-faithful, the
20
+ * serialized boundary is WIRE-faithful.
21
+ *
22
+ * 🟡 an sqs or sns consumer handler is exactly the void case, so this is a real
23
+ * experience rather than an edge — see `case=11`'s actor, and
24
+ * `define.lambda-endpoint-run-boundary` for the boundary table it belongs to.
25
+ *
26
+ * .note = named rather than inline, so the `onSerialized` orchestrator reads as
27
+ * narrative rather than as a stringify-with-a-fallback plus a utf-8 encode
28
+ * (rule.forbid.inline-decode-friction). the divergence above is the whole
29
+ * reason it earns a name: it is the one line where the two loci differ.
30
+ *
31
+ * .note = the `?? null` is clamped in `asWirePayload.test.ts` on three axes, and
32
+ * each exists because a plausible edit breaks exactly one: `[case2]` the void
33
+ * divergence against its referenced peer, `[case3]` that `0` / `''` / `false`
34
+ * are NOT void, and `[case4]` that `WireDelivered`'s declared `null` and this
35
+ * runtime `null` remain one fact rather than two that drifted.
36
+ */
37
+ const asWirePayload = (output) => new TextEncoder().encode(JSON.stringify(output ?? null));
38
+ exports.asWirePayload = asWirePayload;
39
+ //# sourceMappingURL=asWirePayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asWirePayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/serde/asWirePayload.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACI,MAAM,aAAa,GAAG,CAAC,MAAe,EAAc,EAAE,CAC3D,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC;AAD9C,QAAA,aAAa,iBACiC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * .what = casts a live object into the shape a json wire would deliver
3
+ * .why = the referenced boundary crosses no wire, so a Date, a class instance,
4
+ * or an `undefined` would survive into the handler — data the serialized
5
+ * boundary could never deliver.
6
+ *
7
+ * this is a FIDELITY GUARD, never the boundary itself. it keeps a test on
8
+ * the referenced boundary from a pass that the serialized boundary would fail.
9
+ *
10
+ * .note = applied in BOTH directions. aws serializes the response too, so an
11
+ * input-only strip would let a test assert on an output shape the wire
12
+ * could never deliver — the same hole, pointed the other way.
13
+ *
14
+ * .of = which side is stripped, and it is REQUIRED because it decides who owns
15
+ * a refusal:
16
+ *
17
+ * | `of` | the value is | a refusal is | the class |
18
+ * |------|--------------|--------------|-----------|
19
+ * | `'event'` | what the CALLER passed | the caller's fault | `ConstraintError` |
20
+ * | `'output'` | what the HANDLER returned | the server's fault | `MalfunctionError` |
21
+ */
22
+ export declare const asWireStripped: <T>(input: {
23
+ value: T;
24
+ of: 'event' | 'output';
25
+ }) => T;