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,239 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getOneHandlerFromServerlessYml = void 0;
27
+ const helpful_errors_1 = require("helpful-errors");
28
+ const node_fs_1 = require("node:fs");
29
+ const node_path_1 = require("node:path");
30
+ const isErrorLike_1 = require("../error/isErrorLike");
31
+ /**
32
+ * .what = finds the project root — the nearest ancestor with a package.json
33
+ * .why = serverless.yml sits beside package.json, and a test runs from an
34
+ * arbitrary cwd
35
+ *
36
+ * .note = DELIBERATE MUTATION ZONE (rule.require.immutable-vars, scoped
37
+ * exception). `at` is a cursor per hop up the ancestor chain — an ascent has no
38
+ * map/reduce form, and the pure alternative costs a frame per directory. the
39
+ * cursor is local; only a string escapes.
40
+ */
41
+ const getOneProjectRoot = (input) => {
42
+ let at = (0, node_path_1.resolve)(input.from);
43
+ for (;;) {
44
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(at, 'package.json')))
45
+ return at;
46
+ const up = (0, node_path_1.dirname)(at);
47
+ if (up === at)
48
+ return helpful_errors_1.ConstraintError.throw('could not find a project root — no package.json in any ancestor', {
49
+ from: input.from,
50
+ // 🔴 the FIRST throw an `at: 'local'` caller is likely to meet, so it
51
+ // owes a next step (`rule.require.errors-name-the-fix`).
52
+ hint: "run from inside the project, or pass `from:` pointing at the directory that holds your package.json — e.g. `{ at: 'local', from: process.cwd() }`",
53
+ });
54
+ at = up;
55
+ }
56
+ };
57
+ /**
58
+ * .what = casts a serverless.yml `handler:` string into its two parts
59
+ * .why = the value reads `path/to/file.exportName`, and the split is a regex with
60
+ * two positional groups — inline, that is decode-friction.
61
+ *
62
+ * .note = answers `null` rather than throws, because the caller's throw carries
63
+ * `pathOfConfig` and the yml key to edit, and none of that is knowable here.
64
+ */
65
+ const asHandlerPathAndExport = (input) => {
66
+ const matched = input.handler?.match(/^([\w\-./]+)\.(\w+)$/);
67
+ if (!matched)
68
+ return null;
69
+ return { pathOfFile: matched[1], nameOfExport: matched[2] };
70
+ };
71
+ /**
72
+ * .what = the parsed serverless.yml, memoized against the FILE'S OWN CONTENT
73
+ * .why = `yaml.parse` is ~78% of this operation's cost. measured on a 6.5 KB yml
74
+ * (40 functions), 1000 runs: parse 8.778 ms/call · root ascent 0.019 · a
75
+ * `readFileSync`, which is what a hit costs instead, 0.010.
76
+ *
77
+ * 🔴 the key is the file's CONTENT, never `(service, function, from)` — that key
78
+ * caches a PATH's content under a LOOKUP's identity, so a consumer who rewrites
79
+ * its serverless.yml mid-process is served a stale parse and goes green on a
80
+ * file that no longer exists (rule.forbid.failhide).
81
+ *
82
+ * an mtime+size key narrows that race and leaves one: a rewrite inside one tick
83
+ * that keeps an identical byte length — a rename to another name of the same
84
+ * length. content removes the class, and costs 0.006 ms over a stat to do it.
85
+ *
86
+ * ✅ only the PARSE is cached. the four throws below re-run every call, because a
87
+ * result-level memo would keep the old error after a repaired serverless.yml.
88
+ *
89
+ * .note = DELIBERATE MUTATION ZONE (rule.require.immutable-vars, scoped
90
+ * exception). module-private, never read by a caller, and it changes only how
91
+ * long the operation takes.
92
+ */
93
+ const parsedConfigByPath = new Map();
94
+ /**
95
+ * .what = looks up the handler function a serverless.yml declares for an endpoint
96
+ * .why = `at: 'local'` addresses the endpoint by SLUG, so the util must find the
97
+ * function the slug names. same mechanism the incumbent uses.
98
+ *
99
+ * 🔴 every failure names the fix — case=10's whole subject. when the lookup fails
100
+ * the incumbent's error blames the HANDLER and the author debugs the wrong
101
+ * file, so each throw below states what was sought, where it looked, and what
102
+ * to do (rule.require.errors-name-the-fix).
103
+ */
104
+ const getOneHandlerFromServerlessYml = async (input) => {
105
+ const root = getOneProjectRoot({ from: input.from ?? process.cwd() });
106
+ const pathOfConfig = (0, node_path_1.join)(root, 'serverless.yml');
107
+ if (!(0, node_fs_1.existsSync)(pathOfConfig))
108
+ return helpful_errors_1.ConstraintError.throw('no serverless.yml found, so a local endpoint cannot be looked up', {
109
+ sought: pathOfConfig,
110
+ projectRoot: root,
111
+ hint: "add a serverless.yml, or run with at: 'cloud' to invoke the deployed function",
112
+ });
113
+ // the file's own content, which is what the memo above keys on
114
+ const raw = (0, node_fs_1.readFileSync)(pathOfConfig, 'utf8');
115
+ const memoed = parsedConfigByPath.get(pathOfConfig);
116
+ const config = memoed && memoed.raw === raw
117
+ ? memoed.config
118
+ : await (async () => {
119
+ /**
120
+ * .what = `yaml` is reached LAZILY, never at module load
121
+ * .why = this file is its only reader and runs on one path
122
+ * (`at: 'local'`, a test-time locus). a static import would put a
123
+ * 670 KB parser in the module graph of every consumer that merely
124
+ * imports the root barrel.
125
+ *
126
+ * 🟡 LOAD time only. `yaml` stays in `dependencies`, so install size is
127
+ * unchanged and a consumer who BUNDLES still gets it. the install
128
+ * half wants an `exports`-map subpath split (F4).
129
+ */
130
+ const { parse: parseYaml } = await Promise.resolve().then(() => __importStar(require('yaml')));
131
+ /**
132
+ * .as = `parseYaml` answers `any`; a yml file has no compile-time shape.
133
+ * every field is declared OPTIONAL, so the cast asserts no key a real
134
+ * file might lack — each is re-checked at runtime.
135
+ * .removal = never. 🟡 a zod parse WOULD remove it, and would collapse
136
+ * the four throws below into one schema error that names none of their
137
+ * fixes — which is case=10's whole subject.
138
+ */
139
+ const fresh = parseYaml(raw);
140
+ parsedConfigByPath.set(pathOfConfig, { raw, config: fresh });
141
+ return fresh;
142
+ })();
143
+ // the slug names a service; a mismatch means the test addresses another repo
144
+ if (config.service !== input.service)
145
+ return helpful_errors_1.ConstraintError.throw('the serverless.yml declares a different service than the endpoint names', {
146
+ declared: config.service,
147
+ addressed: input.service,
148
+ pathOfConfig,
149
+ hint: 'check input.which.service — a local run can only reach endpoints of THIS repo',
150
+ });
151
+ const definition = config.functions?.[input.function];
152
+ if (!definition)
153
+ return helpful_errors_1.ConstraintError.throw('the serverless.yml declares no such function', {
154
+ addressed: input.function,
155
+ declared: Object.keys(config.functions ?? {}),
156
+ pathOfConfig,
157
+ hint: `add serverless.yml#functions.${input.function}, or check it against the declared list`,
158
+ });
159
+ const parts = asHandlerPathAndExport({ handler: definition.handler });
160
+ if (!parts)
161
+ return helpful_errors_1.ConstraintError.throw('the serverless.yml handler is malformed — it must read `path/to/file.exportName`', {
162
+ found: definition.handler,
163
+ addressed: input.function,
164
+ pathOfConfig,
165
+ });
166
+ const pathOfHandler = (0, node_path_1.join)(root, parts.pathOfFile);
167
+ const nameOfExport = parts.nameOfExport;
168
+ const module = await (async () => {
169
+ try {
170
+ /**
171
+ * .as = a dynamic import of a runtime path has no compile-time shape. the
172
+ * value is re-narrowed below by `typeof handler !== 'function'`.
173
+ * .removal = never
174
+ */
175
+ return (await Promise.resolve(`${pathOfHandler}`).then(s => __importStar(require(s))));
176
+ }
177
+ catch (error) {
178
+ /**
179
+ * .what = reads the message by duck-type, never by `instanceof Error`
180
+ * .why = 🔴 `instanceof` fails CROSS-REALM, and a test util runs in exactly
181
+ * the place with two realms — jest executes each module in its own vm
182
+ * context, so an `Error` its resolver constructs is not the test realm's.
183
+ * an `instanceof` guard here rethrows the raw module error before the
184
+ * message check can run. caught by case=10 `[t0]`.
185
+ */
186
+ const message = (0, isErrorLike_1.isErrorLike)(error) ? error.message : '';
187
+ // 🔴 case=10: the incumbent lets this surface as a bare module error, and
188
+ // the author debugs the handler that never loaded. name the real fault.
189
+ if (message.includes('Cannot find module'))
190
+ return helpful_errors_1.ConstraintError.throw('the serverless.yml points at a handler file that does not exist', {
191
+ declared: definition.handler,
192
+ sought: pathOfHandler,
193
+ addressed: input.function,
194
+ pathOfConfig,
195
+ hint: `the handler MOVED or the path is stale — update serverless.yml#functions.${input.function}.handler`,
196
+ });
197
+ // 🔴 any other import failure is the HANDLER'S OWN — a syntax error, a throw
198
+ // at module scope, a bad transitive import — so the original must survive:
199
+ // its message and stack carry the file and line, which IS the fix.
200
+ //
201
+ // ⚠️ a bare rethrow is not good enough either: it answers `SyntaxError:
202
+ // Unexpected token` with no word about WHICH file this util tried to
203
+ // load. `cause` carries both (rule.prefer.helpful-error-wrap).
204
+ //
205
+ // ✅ bite-probed: restore the bare `throw error` and `[case6]` goes red on
206
+ // both halves.
207
+ throw new helpful_errors_1.MalfunctionError('the handler file was found but could not be imported', {
208
+ pathOfHandler,
209
+ declared: definition.handler,
210
+ addressed: input.function,
211
+ pathOfConfig,
212
+ hint: 'the fault is inside the handler module itself — read `cause` below for its own error, which names the file and line. this util found the file exactly where serverless.yml said it would be.',
213
+ // 🔴 `isErrorLike`, never `instanceof Error` — the same cross-realm
214
+ // reason as above. a non-Error throw keeps its context in `thrown`,
215
+ // so nothing is lost whatever the module threw.
216
+ ...((0, isErrorLike_1.isErrorLike)(error) ? { cause: error } : { thrown: error }),
217
+ });
218
+ }
219
+ })();
220
+ const handler = module[nameOfExport];
221
+ if (typeof handler !== 'function')
222
+ return helpful_errors_1.ConstraintError.throw('the handler file exports no such function', {
223
+ sought: nameOfExport,
224
+ found: Object.keys(module),
225
+ pathOfHandler,
226
+ addressed: input.function,
227
+ hint: `export \`${nameOfExport}\` from that file, or update serverless.yml#functions.${input.function}.handler`,
228
+ });
229
+ /**
230
+ * .as = the `typeof` guard narrows to `Function`, which carries no parameter or
231
+ * return type. no runtime check can supply a signature.
232
+ * .why-not-assure = `.assure` throws a generic rejection error; this throw
233
+ * carries `sought`, `found`, `pathOfHandler`, and the exact yml key to edit.
234
+ * .removal = never
235
+ */
236
+ return handler;
237
+ };
238
+ exports.getOneHandlerFromServerlessYml = getOneHandlerFromServerlessYml;
239
+ //# sourceMappingURL=getOneHandlerFromServerlessYml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOneHandlerFromServerlessYml.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAmE;AAEnE,qCAAmD;AACnD,yCAAqE;AACrE,sDAAmD;AAEnD;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAAuB,EAAU,EAAE;IAC5D,IAAI,EAAE,GAAG,IAAA,mBAAc,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpC,SAAS,CAAC;QACR,IAAI,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,EAAE,EAAE,cAAc,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC;QACpD,MAAM,EAAE,GAAG,IAAA,mBAAO,EAAC,EAAE,CAAC,CAAC;QACvB,IAAI,EAAE,KAAK,EAAE;YACX,OAAO,gCAAe,CAAC,KAAK,CAC1B,iEAAiE,EACjE;gBACE,IAAI,EAAE,KAAK,CAAC,IAAI;gBAEhB,sEAAsE;gBACtE,4DAA4D;gBAC5D,IAAI,EAAE,mJAAmJ;aAC1J,CACF,CAAC;QACJ,EAAE,GAAG,EAAE,CAAC;IACV,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,sBAAsB,GAAG,CAAC,KAE/B,EAAuD,EAAE;IACxD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC7D,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,CAAC;AAChE,CAAC,CAAC;AAWF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM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D,KAAK,CAAC,QAAQ,UAAU;SAChH,CAAC,CAAC;IAEL;;;;;;OAMG;IACH,OAAO,OAAiE,CAAC;AAC3E,CAAC,CAAC;AA7KW,QAAA,8BAA8B,kCA6KzC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * .what = runs a lambda endpoint, on either side of the RUN BOUNDARY
3
+ * .why = to run an endpoint, shapes must cross a boundary into it. they cross one
4
+ * of two ways, and the way they cross is a domain axis
5
+ * (define.lambda-endpoint-run-boundary)
6
+ *
7
+ * | boundary | shapes cross as | you hold |
8
+ * |----------|-----------------|----------|
9
+ * | **serialized** | json over a wire (real or simulated) | the endpoint's **slug** |
10
+ * | **referenced** | live object references, same process | the handler **function** |
11
+ *
12
+ * ```ts
13
+ * runLambdaEndpoint.onSerialized({ which, event, at: 'cloud' | 'local' }, context)
14
+ * runLambdaEndpoint.onReferenced({ handler, event }) // no `at` — none is possible
15
+ * ```
16
+ *
17
+ * ## 🔴 the boundary determines the ERROR STANCE
18
+ *
19
+ * this is the axis's whole value: it is *causal*, so it predicts behavior that a
20
+ * locus axis (cloud vs local) does not.
21
+ *
22
+ * | boundary | a constraint error arrives as | why |
23
+ * |----------|-------------------------------|-----|
24
+ * | **serialized** | a **thrown** error | you addressed the endpoint by slug, so you are a CALLER |
25
+ * | **referenced** | a **returned** envelope | you hold the handler, so you are the HOST |
26
+ *
27
+ * locus does not cleave this. `at: 'local'` and `at: 'cloud'` sit on the **same**
28
+ * side — both throw.
29
+ *
30
+ * ## the matrix — 4 cells, 3 reachable, 1 barred by nature
31
+ *
32
+ * | | **local** | **cloud** |
33
+ * |---|---|---|
34
+ * | **serialized** | ✅ look the slug up, simulate the wire | ✅ the real wire |
35
+ * | **referenced** | ✅ hold the handler, call it | 🚫 **barred** |
36
+ *
37
+ * ⚠️ **`referenced × cloud` is impossible: a function reference cannot cross a
38
+ * process.** to reach a cloud lambda you must name it, and to name it is to
39
+ * serialize.
40
+ *
41
+ * 🔴 **and the bar is UNREPRESENTABLE, by arity** — not documented and policed:
42
+ * `onSerialized` takes `at`, because a slug points either way;
43
+ * `onReferenced` takes **no** `at`, because a reference has one locus only.
44
+ * ⇒ `rule.prefer.prevent-over-correct`, rung 1: make it impossible.
45
+ *
46
+ * ## what it replaces
47
+ *
48
+ * | incumbent | successor |
49
+ * |---|---|
50
+ * | `invokeLambdaForTesting({ …, locally: false })` | `runLambdaEndpoint.onSerialized({ …, at: 'cloud' })` |
51
+ * | `invokeLambdaForTesting({ …, locally: true })` | `runLambdaEndpoint.onSerialized({ …, at: 'local' })` |
52
+ * | `invokeHandlerForTesting({ event, handler })` | `runLambdaEndpoint.onReferenced({ handler, event })` |
53
+ *
54
+ * ⚠️ the incumbent's `locally = false` is a **negative-default boolean** whose
55
+ * name states a locus and hides a stance. the named variants state both
56
+ * (`rule.forbid.ambiguous-labels`).
57
+ */
58
+ export declare const runLambdaEndpoint: {
59
+ onReferenced: <TEvent, TOutput, TDialect extends import("../..").LambdaEndpointDialect = "contemp">(input: {
60
+ event: TEvent;
61
+ handler: import("./runLambdaEndpoint.onReferenced").LambdaEndpointHandlerReferenced<any, TOutput>;
62
+ struct?: {
63
+ payload: TDialect;
64
+ } | undefined;
65
+ trail?: {
66
+ exid?: string | undefined;
67
+ } | null | undefined;
68
+ context?: Partial<import("aws-lambda").Context> | undefined;
69
+ }) => Promise<import("./dialect/LambdaEndpointRunOutput").LambdaEndpointRunOutput<TOutput, TDialect>>;
70
+ onSerialized: <TEvent_1, TOutput_1>(input: {
71
+ which: {
72
+ service: string;
73
+ function: string;
74
+ };
75
+ event: TEvent_1;
76
+ at?: import("./runLambdaEndpoint.onSerialized").LambdaEndpointLocus | undefined;
77
+ struct?: {
78
+ payload: import("../..").LambdaEndpointDialect;
79
+ } | undefined;
80
+ from?: string | undefined;
81
+ }, context: import("../..").ContextAwsLambdaCaller) => Promise<import("./dialect/LambdaEndpointRunOutput").WireDelivered<TOutput_1>>;
82
+ };
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runLambdaEndpoint = void 0;
4
+ const runLambdaEndpoint_onReferenced_1 = require("./runLambdaEndpoint.onReferenced");
5
+ const runLambdaEndpoint_onSerialized_1 = require("./runLambdaEndpoint.onSerialized");
6
+ /**
7
+ * .what = runs a lambda endpoint, on either side of the RUN BOUNDARY
8
+ * .why = to run an endpoint, shapes must cross a boundary into it. they cross one
9
+ * of two ways, and the way they cross is a domain axis
10
+ * (define.lambda-endpoint-run-boundary)
11
+ *
12
+ * | boundary | shapes cross as | you hold |
13
+ * |----------|-----------------|----------|
14
+ * | **serialized** | json over a wire (real or simulated) | the endpoint's **slug** |
15
+ * | **referenced** | live object references, same process | the handler **function** |
16
+ *
17
+ * ```ts
18
+ * runLambdaEndpoint.onSerialized({ which, event, at: 'cloud' | 'local' }, context)
19
+ * runLambdaEndpoint.onReferenced({ handler, event }) // no `at` — none is possible
20
+ * ```
21
+ *
22
+ * ## 🔴 the boundary determines the ERROR STANCE
23
+ *
24
+ * this is the axis's whole value: it is *causal*, so it predicts behavior that a
25
+ * locus axis (cloud vs local) does not.
26
+ *
27
+ * | boundary | a constraint error arrives as | why |
28
+ * |----------|-------------------------------|-----|
29
+ * | **serialized** | a **thrown** error | you addressed the endpoint by slug, so you are a CALLER |
30
+ * | **referenced** | a **returned** envelope | you hold the handler, so you are the HOST |
31
+ *
32
+ * locus does not cleave this. `at: 'local'` and `at: 'cloud'` sit on the **same**
33
+ * side — both throw.
34
+ *
35
+ * ## the matrix — 4 cells, 3 reachable, 1 barred by nature
36
+ *
37
+ * | | **local** | **cloud** |
38
+ * |---|---|---|
39
+ * | **serialized** | ✅ look the slug up, simulate the wire | ✅ the real wire |
40
+ * | **referenced** | ✅ hold the handler, call it | 🚫 **barred** |
41
+ *
42
+ * ⚠️ **`referenced × cloud` is impossible: a function reference cannot cross a
43
+ * process.** to reach a cloud lambda you must name it, and to name it is to
44
+ * serialize.
45
+ *
46
+ * 🔴 **and the bar is UNREPRESENTABLE, by arity** — not documented and policed:
47
+ * `onSerialized` takes `at`, because a slug points either way;
48
+ * `onReferenced` takes **no** `at`, because a reference has one locus only.
49
+ * ⇒ `rule.prefer.prevent-over-correct`, rung 1: make it impossible.
50
+ *
51
+ * ## what it replaces
52
+ *
53
+ * | incumbent | successor |
54
+ * |---|---|
55
+ * | `invokeLambdaForTesting({ …, locally: false })` | `runLambdaEndpoint.onSerialized({ …, at: 'cloud' })` |
56
+ * | `invokeLambdaForTesting({ …, locally: true })` | `runLambdaEndpoint.onSerialized({ …, at: 'local' })` |
57
+ * | `invokeHandlerForTesting({ event, handler })` | `runLambdaEndpoint.onReferenced({ handler, event })` |
58
+ *
59
+ * ⚠️ the incumbent's `locally = false` is a **negative-default boolean** whose
60
+ * name states a locus and hides a stance. the named variants state both
61
+ * (`rule.forbid.ambiguous-labels`).
62
+ */
63
+ exports.runLambdaEndpoint = {
64
+ onReferenced: runLambdaEndpoint_onReferenced_1.onReferenced,
65
+ onSerialized: runLambdaEndpoint_onSerialized_1.onSerialized,
66
+ };
67
+ //# sourceMappingURL=runLambdaEndpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runLambdaEndpoint.js","sourceRoot":"","sources":["../../../src/domain.operations/runLambdaEndpoint/runLambdaEndpoint.ts"],"names":[],"mappings":";;;AAAA,qFAAgE;AAChE,qFAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACU,QAAA,iBAAiB,GAAG;IAC/B,YAAY,EAAZ,6CAAY;IACZ,YAAY,EAAZ,6CAAY;CACb,CAAC"}
@@ -0,0 +1,120 @@
1
+ import type { Context } from 'aws-lambda';
2
+ import type { LambdaEndpointDialect } from '../../domain.objects/LambdaEndpointDialect';
3
+ import type { LambdaEndpointRunOutput } from './dialect/LambdaEndpointRunOutput';
4
+ /**
5
+ * .what = a handler reachable by reference — the function itself, in this process
6
+ * .why = deliberately loose: a plain lambda handler, NOT a `genLambdaEndpoint`
7
+ * return type. 19 of 20 repos and 314 of 318 legacy call sites still define
8
+ * handlers with `createStandardHandler`; bind this to `genLambdaEndpoint` and
9
+ * none of them can adopt the util until they finish a migration not yet started.
10
+ */
11
+ export type LambdaEndpointHandlerReferenced<TEvent, TOutput> = (event: TEvent, context: Context) => Promise<TOutput> | TOutput;
12
+ /**
13
+ * .what = runs a lambda endpoint you hold a REFERENCE to — the handler function
14
+ * itself, in this process
15
+ * .why = shapes cross this boundary as live object references, so you are the
16
+ * endpoint's HOST rather than its caller — and a host sees what the
17
+ * function returned (define.lambda-endpoint-run-boundary)
18
+ *
19
+ * ## the error stance — a pass-through, both directions
20
+ *
21
+ * the handler RETURNS a constraint envelope ⇒ this returns it, stripped. the
22
+ * handler THROWS a malfunction ⇒ this lets it throw, untouched.
23
+ *
24
+ * ⚠️ it does NOT convert an envelope into a throw — that is the WIRE's job
25
+ * (`getParsedResponse`), and it is what makes `onSerialized` throw where this
26
+ * returns. nor does it swallow a throw: that needs a `catch` over a server
27
+ * fault (rule.forbid.failhide).
28
+ *
29
+ * ## the fidelity guard
30
+ *
31
+ * the event is json-stripped inbound and the output json-stripped outbound. this
32
+ * boundary crosses no wire, so without the strip a `Date` survives either way and
33
+ * a test passes on a shape the wire could never deliver.
34
+ *
35
+ * ## 🔴 the dialect frames the INPUT too, not only the answer
36
+ *
37
+ * | dialect | the handler RECEIVES | it must ANSWER |
38
+ * |---------|---------------------|----------------|
39
+ * | `contemp` (default) | `{ event, trail }` — the wrapper IS the declaration | the nested envelope |
40
+ * | `ancient` | the event, untouched | the flat `{ errorMessage, errorType }` |
41
+ *
42
+ * a `genLambdaEndpoint` handler never notices — `genTrailMiddleware` unwraps the
43
+ * frame first. a PLAIN handler does, and the failure is QUIET: contemp-framed, it
44
+ * reads `event.uuid` off the wrapper, finds `undefined`, and takes its own reject
45
+ * branch — a rejection envelope on the success case, with no type error anywhere.
46
+ *
47
+ * ⇒ so a legacy `createStandardHandler` handler needs `struct: { payload: 'ancient' }`.
48
+ * the frame is DERIVED from `struct.payload`, never from `trail`, so the two
49
+ * cannot disagree.
50
+ *
51
+ * ## two gates stand between a call and an error field, in order
52
+ *
53
+ * the return is a UNION — `TOutput | Envelope` — because a caller fault is a
54
+ * legitimate answer. so the union rejects every error field on either dialect;
55
+ * narrow FIRST, and only then does the dialect decide which fields you may read.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * // success — the handler's validated output, wire-stripped
60
+ * const out = await runLambdaEndpoint.onReferenced({ event: { uuid }, handler });
61
+ * expect(asLambdaEndpointOutput(out).found).toEqual(true);
62
+ *
63
+ * // a caller fault — an envelope, RETURNED. the lambda succeeded.
64
+ * const res = await runLambdaEndpoint.onReferenced({ event: { uuid: 'bad' }, handler });
65
+ * expect(asLambdaEndpointErrorEnvelopeContemp(res).error.class).toEqual('ConstraintError');
66
+ *
67
+ * // the ancient dialect, opt-in — declared on the call, and again on the narrow
68
+ * const old = await runLambdaEndpoint.onReferenced({
69
+ * event: { uuid: 'bad' }, handler, struct: { payload: 'ancient' },
70
+ * });
71
+ * expect(asLambdaEndpointErrorEnvelopeAncient(old).errorType).toEqual('BadRequestError');
72
+ *
73
+ * // a malfunction — THROWN, untouched, on either dialect
74
+ * await expect(
75
+ * runLambdaEndpoint.onReferenced({ event, handler: brokenHandler }),
76
+ * ).rejects.toThrow(MalfunctionError);
77
+ * ```
78
+ */
79
+ export declare const onReferenced: <TEvent, TOutput, TDialect extends LambdaEndpointDialect = "contemp">(input: {
80
+ /**
81
+ * the event to send, as the endpoint's own input shape
82
+ */
83
+ event: TEvent;
84
+ /**
85
+ * the handler to run — held by reference, so no slug and no `at`
86
+ *
87
+ * 🔴 the `any` on the EVENT slot is deliberate — every alternative was probed:
88
+ *
89
+ * | event param | consumer errors | why |
90
+ * |---|---|---|
91
+ * | `unknown` | **24** | contravariant under `strictFunctionTypes`, so it demands a handler that accepts EVERY shape — it refuses every typed handler |
92
+ * | `never` | 0 | variance-correct, and then `handler(payload, …)` cannot compile |
93
+ * | `TEvent`, both slots | 0 | works, and 🔴 rejects a schema-rejection fixture (`TS2741`) and a wire-hostile `Date` (`TS2322`) |
94
+ * | `any` | 0 | what ships |
95
+ *
96
+ * 🔴 the `TEvent` row is the one to hold: a handler's event type is the
97
+ * POST-validation shape, so a test that proves *"the schema refuses this"*
98
+ * must send an event that does not fit it. to bind `TEvent` bars `[case2]`
99
+ * and `[case4]`, the two experiences the util was built for.
100
+ *
101
+ * ⇒ the looseness is caught at RUNTIME — `assertHandlerIsRunnable` below.
102
+ */
103
+ handler: LambdaEndpointHandlerReferenced<any, TOutput>;
104
+ /**
105
+ * which error dialect the endpoint answers in. contemp by default.
106
+ */
107
+ struct?: {
108
+ payload: TDialect;
109
+ };
110
+ /**
111
+ * the trail to carry. supplies the exid only — it never selects the dialect.
112
+ */
113
+ trail?: {
114
+ exid?: string;
115
+ } | null;
116
+ /**
117
+ * overrides for the aws lambda context the handler receives
118
+ */
119
+ context?: Partial<Context>;
120
+ }) => Promise<LambdaEndpointRunOutput<TOutput, TDialect>>;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onReferenced = void 0;
4
+ const asLambdaContext_1 = require("./context/asLambdaContext");
5
+ const asLambdaEndpointDialect_1 = require("./dialect/asLambdaEndpointDialect");
6
+ const assertEventIsGiven_1 = require("./guard/assertEventIsGiven");
7
+ const assertHandlerIsRunnable_1 = require("./guard/assertHandlerIsRunnable");
8
+ const asFramedPayload_1 = require("./serde/asFramedPayload");
9
+ const asWireStripped_1 = require("./serde/asWireStripped");
10
+ /**
11
+ * .what = runs a lambda endpoint you hold a REFERENCE to — the handler function
12
+ * itself, in this process
13
+ * .why = shapes cross this boundary as live object references, so you are the
14
+ * endpoint's HOST rather than its caller — and a host sees what the
15
+ * function returned (define.lambda-endpoint-run-boundary)
16
+ *
17
+ * ## the error stance — a pass-through, both directions
18
+ *
19
+ * the handler RETURNS a constraint envelope ⇒ this returns it, stripped. the
20
+ * handler THROWS a malfunction ⇒ this lets it throw, untouched.
21
+ *
22
+ * ⚠️ it does NOT convert an envelope into a throw — that is the WIRE's job
23
+ * (`getParsedResponse`), and it is what makes `onSerialized` throw where this
24
+ * returns. nor does it swallow a throw: that needs a `catch` over a server
25
+ * fault (rule.forbid.failhide).
26
+ *
27
+ * ## the fidelity guard
28
+ *
29
+ * the event is json-stripped inbound and the output json-stripped outbound. this
30
+ * boundary crosses no wire, so without the strip a `Date` survives either way and
31
+ * a test passes on a shape the wire could never deliver.
32
+ *
33
+ * ## 🔴 the dialect frames the INPUT too, not only the answer
34
+ *
35
+ * | dialect | the handler RECEIVES | it must ANSWER |
36
+ * |---------|---------------------|----------------|
37
+ * | `contemp` (default) | `{ event, trail }` — the wrapper IS the declaration | the nested envelope |
38
+ * | `ancient` | the event, untouched | the flat `{ errorMessage, errorType }` |
39
+ *
40
+ * a `genLambdaEndpoint` handler never notices — `genTrailMiddleware` unwraps the
41
+ * frame first. a PLAIN handler does, and the failure is QUIET: contemp-framed, it
42
+ * reads `event.uuid` off the wrapper, finds `undefined`, and takes its own reject
43
+ * branch — a rejection envelope on the success case, with no type error anywhere.
44
+ *
45
+ * ⇒ so a legacy `createStandardHandler` handler needs `struct: { payload: 'ancient' }`.
46
+ * the frame is DERIVED from `struct.payload`, never from `trail`, so the two
47
+ * cannot disagree.
48
+ *
49
+ * ## two gates stand between a call and an error field, in order
50
+ *
51
+ * the return is a UNION — `TOutput | Envelope` — because a caller fault is a
52
+ * legitimate answer. so the union rejects every error field on either dialect;
53
+ * narrow FIRST, and only then does the dialect decide which fields you may read.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * // success — the handler's validated output, wire-stripped
58
+ * const out = await runLambdaEndpoint.onReferenced({ event: { uuid }, handler });
59
+ * expect(asLambdaEndpointOutput(out).found).toEqual(true);
60
+ *
61
+ * // a caller fault — an envelope, RETURNED. the lambda succeeded.
62
+ * const res = await runLambdaEndpoint.onReferenced({ event: { uuid: 'bad' }, handler });
63
+ * expect(asLambdaEndpointErrorEnvelopeContemp(res).error.class).toEqual('ConstraintError');
64
+ *
65
+ * // the ancient dialect, opt-in — declared on the call, and again on the narrow
66
+ * const old = await runLambdaEndpoint.onReferenced({
67
+ * event: { uuid: 'bad' }, handler, struct: { payload: 'ancient' },
68
+ * });
69
+ * expect(asLambdaEndpointErrorEnvelopeAncient(old).errorType).toEqual('BadRequestError');
70
+ *
71
+ * // a malfunction — THROWN, untouched, on either dialect
72
+ * await expect(
73
+ * runLambdaEndpoint.onReferenced({ event, handler: brokenHandler }),
74
+ * ).rejects.toThrow(MalfunctionError);
75
+ * ```
76
+ */
77
+ const onReferenced = async (input) => {
78
+ // 🔴 an ABSENT event is REFUSED, never defaulted to `{}`. the corpus settles
79
+ // the direction: `event: {}` is the measured convention for an endpoint
80
+ // that takes no input (`event: undefined` → 0 matches across `ahbode/*`).
81
+ //
82
+ // ⚠️ the row the guard is owed for is a plain handler that READS rather
83
+ // than derefs — `(e) => e.slug` raises no error at all, so it answers a
84
+ // success-shaped value for work that ran on no input
85
+ // (`rule.forbid.failhide`).
86
+ (0, assertEventIsGiven_1.assertEventIsGiven)({ event: input.event, metadata: null });
87
+ // the dialect declares the frame; an unknown value is REFUSED, never fallen
88
+ // through — see `asLambdaEndpointDialect` for why
89
+ const dialect = (0, asLambdaEndpointDialect_1.asLambdaEndpointDialect)({
90
+ declared: input.struct?.payload,
91
+ });
92
+ // strip inbound, so no live object reaches the handler that the wire could not deliver
93
+ // `of: 'event'` — a refusal here is the CALLER's payload, so it raises a ConstraintError
94
+ const eventStripped = (0, asWireStripped_1.asWireStripped)({ value: input.event, of: 'event' });
95
+ // frame the payload, so the endpoint reads the dialect the caller declared
96
+ const payload = (0, asFramedPayload_1.asFramedPayload)({
97
+ event: eventStripped,
98
+ trail: input.trail ?? null,
99
+ dialect,
100
+ });
101
+ const context = (0, asLambdaContext_1.asLambdaContext)(input.context);
102
+ // shared with the serialized boundary, which needs it ahead of its delegation
103
+ (0, assertHandlerIsRunnable_1.assertHandlerIsRunnable)({ handler: input.handler });
104
+ // run it. a throw crosses untouched — this util adds no catch, and the absence
105
+ // is clamped for both actors (`[case3][t0]/[t1]`, `[case7][t2]`).
106
+ const output = await input.handler(payload, context);
107
+ // strip outbound, so no live object reaches the author that the wire would flatten
108
+ // `of: 'output'` — a refusal here is the HANDLER's return ⇒ MalfunctionError
109
+ //
110
+ // .as = a checker limit, never a shapefit dodge. `LambdaEndpointRunOutput` is a
111
+ // CONDITIONAL on an unresolved `TDialect`, which typescript cannot reduce
112
+ // inside a generic body; it resolves at every call site.
113
+ return (0, asWireStripped_1.asWireStripped)({
114
+ value: output,
115
+ of: 'output',
116
+ });
117
+ };
118
+ exports.onReferenced = onReferenced;
119
+ //# sourceMappingURL=runLambdaEndpoint.onReferenced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runLambdaEndpoint.onReferenced.js","sourceRoot":"","sources":["../../../src/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.ts"],"names":[],"mappings":";;;AAGA,+DAA4D;AAC5D,+EAA4E;AAE5E,mEAAgE;AAChE,6EAA0E;AAC1E,6DAA0D;AAC1D,2DAAwD;AAcxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACI,MAAM,YAAY,GAAG,KAAK,EAI/B,KAyCD,EAAuD,EAAE;IACxD,6EAA6E;IAC7E,2EAA2E;IAC3E,6EAA6E;IAC7E,EAAE;IACF,2EAA2E;IAC3E,8EAA8E;IAC9E,2DAA2D;IAC3D,kCAAkC;IAClC,IAAA,uCAAkB,EAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAE3D,4EAA4E;IAC5E,kDAAkD;IAClD,MAAM,OAAO,GAA0B,IAAA,iDAAuB,EAAC;QAC7D,QAAQ,EAAE,KAAK,CA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