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
@@ -1,13 +1,234 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getJsonSchemaFromZod = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
4
5
  const zod_1 = require("zod");
5
6
  /**
6
- * .what = convert zod schema to JSON schema
7
- * .why = encapsulates zod api for future error handler if needed
7
+ * .what = publish a zod schema as the json-schema document a caller is typed against
8
+ * .why = this is the one door to `z.toJSONSchema` in src, so the wire face is a property of
9
+ * this function rather than a flag each caller must remember
10
+ *
11
+ * ✅ .the one-door claim is CLAMPED, never merely stated here —
12
+ * `genIntrospectionMiddleware.getJsonSchemaFromZod.integration.test.ts` reads the `src/` tree
13
+ * and grades both halves: exactly one prod call site (`[t1]`), and this face on it (`[t2]`).
14
+ * both rows were driven RED before the clamp was trusted — a throwaway second call site, and
15
+ * this flag flipped to `'output'`. so a second door added without the flag goes red in ci
16
+ * rather than reopens a service-wide crash silently
17
+ *
18
+ * .note = `{ io: 'input' }` is UNCONDITIONAL, at both borders. `io` names the SIDE of a
19
+ * contract (wire vs instance), never the BORDER of an endpoint (request vs response) —
20
+ * and the wire side is what crosses in both directions. on the response path
21
+ * `JSON.stringify` is the real encoder, and it emits the wire shape regardless of what
22
+ * output validation returns, so a published instance-face would describe a document no
23
+ * caller ever sends or receives
24
+ *
25
+ * ✅ .the DEPLOYED face is clamped too, byte-exact —
26
+ * `deployed.codegen.refs.acceptance.test.ts` `[case2]` calls `getOneLambdaContract` against
27
+ * the live `svc-trophy-prep-getTrophy` and pins every marker shape this function emits:
28
+ * `x-domain-object` on the trophy, plus `by: primary | unique | ref` beneath it. driven RED
29
+ * before it was trusted — this line swapped to `{ unrepresentable: 'any' }` (the `#33` shape)
30
+ * turned all three of its rows red while `returns the endpoint schema` stayed GREEN, which is
31
+ * the hazard exactly: the crash goes away and the pragmas are destroyed with no tell
32
+ * (rule.forbid.failhide). reverted to green
33
+ *
34
+ * .note = an ABSENT position publishes `{ not: {} }` rather than throws. `z.undefined()` and
35
+ * `z.void()` are the two shapes a handler that returns no value declares, and zod
36
+ * refuses to render either — so before this, such an endpoint could not introspect
37
+ * at all and its author reached for `z.unknown()`, which publishes `{}` and tells a
38
+ * caller every value is valid. `{ not: {} }` is the honest statement, and it reads
39
+ * correctly at both positions: at a root, the response carries no document; at a
40
+ * key, the key must be absent — which is exactly what `z.undefined()` accepts, so
41
+ * the key is dropped from `required` too. see `setAbsentPositionsRendered`
42
+ *
43
+ * .note = zod's default is `io: 'output'`, which asks what a parse hands BACK — a live class
44
+ * for any schema that coerces. that is not json, so the default throws
45
+ * `Transforms cannot be represented in JSON Schema` and takes down
46
+ * `getAllLambdaContracts` for the whole service. `X.contract()` always coerces, so
47
+ * every dobj position reaches that path
48
+ *
49
+ * ⚠️ .defect = LIVE, NOT FIXED — at the OUTPUT border this face DIVERGES from the document
50
+ * that crosses, for two shapes out of six measured
51
+ * .proof it is live = `[case5]` of the peer spec drives each shape through the real
52
+ * `getValidatedOutput` and serializes it as the runtime does, then grades
53
+ * the pair. the `.pipe()` and type-shift `.transform()` rows grade
54
+ * `CONTRADICTS`, and that grade is COMPUTED from the measured pair. both
55
+ * rows are GREEN, so the divergence is present
56
+ * .the class, measured = a coerced dobj AGREES exactly (the headline shape) · a plain schema
57
+ * agrees · `.default()` and `.catch()` UNDER-declare, so the face is
58
+ * weaker than the truth and never wrong · a `.pipe()` and a type-shift
59
+ * `.transform()` CONTRADICT, so the face names a type the document does
60
+ * not carry
61
+ * .why unrepaired = the only face that describes those two rows is `io: 'output'`, and it
62
+ * THROWS for every `X.contract()` position — the crash above. a per-schema
63
+ * choice between the faces is two code paths for one guarantee
64
+ * (rule.forbid.parallel-codepaths) plus a silent fallback
65
+ * (rule.forbid.failhide). so one face serves both borders, and the trade is
66
+ * DECLARED here rather than met in a generated caller
67
+ * .the trade, stated plainly = the discarded default was RIGHT for a `.pipe()` at the output
68
+ * border and could not serve a dobj at all. this one serves every
69
+ * dobj and is wrong for a `.pipe()`. the dobj is the shape this
70
+ * sdk exists to publish
71
+ * .both halves are MEASURED = `[case6]` of the peer spec drives the discarded face at a dobj
72
+ * and clamps the throw; `[case7]` drives it at the `.pipe()` and
73
+ * clamps that it does NOT throw and publishes `number`. so the
74
+ * sentence above cites a run rather than a recollection
75
+ * .the fix-forward path = `.dream/v2026_09_18.fix.published-face-contradicts-the-wire-for-a-pipe.md`
76
+ * carries the shape of the repair — the two faces reconcile only once
77
+ * zod can render a transform's output side, or once this sdk owns its
78
+ * own renderer. a per-schema choice is NOT that repair, and the dream
79
+ * records why, so the next traveler meets the measurement before the
80
+ * idea (rule.always.catch-dreams-for-followups)
8
81
  */
82
+ /**
83
+ * .what = the fix half of the message an engineer meets when the schema is not this zod's
84
+ * .why = `rule.require.errors-name-the-fix`. measured on `zod@4.4.3`: a schema object whose
85
+ * `_zod` marker is absent or hollow reaches zod's dispatch and raises a bare
86
+ * `TypeError: Cannot read properties of undefined (reading 'def')` — loud, and it names
87
+ * neither zod, nor the schema, nor the two-copy cause. so the engineer's path is a stack
88
+ * trace into a vendor file, with no clue what to change
89
+ *
90
+ * .note = the likeliest single cause is a SPLIT INSTALL: `package.json` declares `zod` a plain
91
+ * dependency with no peer range, and this function does a value import of `z` then
92
+ * renders a schema the CONSUMER's zod built. two copies in one `node_modules` and the
93
+ * markers no longer match. that is tracked as `F03`, and this hint is what makes the
94
+ * failure diagnosable while the manifest question stays open
95
+ */
96
+ const FOREIGN_SCHEMA_HINT = "the value handed to `getJsonSchemaFromZod` does not carry this zod install's marker — most often two copies of `zod` in one `node_modules`, so a schema built by one is rendered by the other. run `npm ls zod` (or `pnpm why zod`) and dedupe to a single version";
97
+ /**
98
+ * .what = the zod node types that denote NO value at all
99
+ * .why = `z.undefined()` and `z.void()` both accept a handler that returns no value, and
100
+ * zod refuses to render either one — so an endpoint that returns no value could not
101
+ * introspect, and its author was pushed to `z.unknown()`, which publishes `{}` and
102
+ * tells a caller that ANY value is valid. that is the rubber-stamp this sdk exists
103
+ * to retire, surviving one corner in
104
+ *
105
+ * .the rendering = `{ not: {} }` — "no json value is valid here". true at BOTH positions:
106
+ * at a root it says the response carries no document; at a key it says the key must
107
+ * be absent, which is exactly what `z.undefined()` accepts
108
+ */
109
+ const TYPES_ABSENT = ['undefined', 'void'];
110
+ /**
111
+ * .what = the zod node types whose EMPTY `{}` rendering is the truth rather than a silence
112
+ * .why = `unrepresentable: 'any'` below renders every un-renderable node as `{}`, which is
113
+ * indistinguishable from the `{}` these two produce honestly. so the set is named,
114
+ * and every OTHER empty node is re-raised by `setAbsentPositionsRendered`
115
+ */
116
+ const TYPES_OPEN = ['unknown', 'any'];
117
+ /**
118
+ * .what = whether a zod node type denotes an absent value
119
+ */
120
+ const getIsAbsentType = (type) => !!type && TYPES_ABSENT.includes(type);
121
+ /**
122
+ * .what = read a zod node's type off a `toJSONSchema` override context
123
+ * .why = the override hands the live schema object, and its type is the only signal that
124
+ * says WHICH position was rendered. one reader, so the shape of that reach is
125
+ * stated once rather than at each branch (rule.require.named-transformers)
126
+ */
127
+ const getNodeType = (zodSchema) => zodSchema?._zod?.def?.type;
128
+ /**
129
+ * .what = whether a zod node hands its render off to another node it wraps
130
+ * .why = a wrapper's `{}` is INHERITED, never its own — so it must not be re-raised. measured:
131
+ * `asApiGatewayResponseSchema` writes `body: input.body.optional()`, so a perfectly
132
+ * legal `z.any()` body reaches the override as an `optional` node that renders `{}`,
133
+ * and a naive emptiness test refused it. that is a FALSE REFUSAL of the one shape the
134
+ * re-raise exists to permit
135
+ * .measured = `[case17][t2]` of `genLambdaEndpoint.forApiGateway.test.ts` went 200 -> 500 on
136
+ * the first draft of this branch, and is the clamp that holds it
137
+ *
138
+ * .note = the test is the PRESENCE OF AN INNER, never a list of wrapper names. a name list is
139
+ * a guess that goes stale the moment zod adds a wrapper; this reads the property the
140
+ * render actually depends on. the three shapes zod uses, measured on `4.4.3` against
141
+ * `json-schema-processors.cjs`: `def.innerType` (optional, nullable, default, prefault,
142
+ * nonoptional, readonly, catch, success), `def.in` / `def.out` (pipe, line 529), and
143
+ * `_zod.innerType` (lazy, line 558)
144
+ *
145
+ * ⚠️ .why it matters beyond the one false refusal = it makes the re-raise ORDER-INDEPENDENT.
146
+ * zod runs the override over `[...ctx.seen.entries()].reverse()`, which is deepest-first
147
+ * (`to-json-schema.cjs:302`) — but `flattenRef` recurses into a parent at line 279, so a
148
+ * wrapper CAN be overridden before its inner. with this test the verdict is the same either
149
+ * way, since the wrapper never carries a verdict of its own. the leaf always gets its own
150
+ * call, because every node `process` touches lands in `ctx.seen`
151
+ */
152
+ const getIsNodeWithInner = (zodSchema) => {
153
+ const node = zodSchema;
154
+ return !!(node?._zod?.def?.innerType ??
155
+ node?._zod?.def?.in ??
156
+ node?._zod?.innerType);
157
+ };
158
+ /**
159
+ * .what = rewrite one rendered node so an ABSENT position publishes honestly, and so no
160
+ * OTHER un-renderable position is silenced by the blanket flag that makes this
161
+ * rewrite reachable
162
+ * .why = `unrepresentable: 'any'` is what stops zod's throw, and on its own it is a
163
+ * failhide at scale — measured on `zod@4.4.3`, it renders `date`, `bigint`,
164
+ * `symbol`, `map`, and `custom` each as `{}`, the same rubber-stamp. so the flag
165
+ * disarms the refusal globally and this re-arms it precisely (rule.forbid.failhide)
166
+ *
167
+ * ⚠️ .why it is NOT the `#33` hazard = that hazard is `unrepresentable: 'any'` used INSTEAD
168
+ * of `{ io: 'input' }`, which renders every coerced dobj as `{}` and destroys the
169
+ * `x-domain-object` pragma with no tell. here the flag rides BESIDE `io: 'input'`,
170
+ * which already resolves every transform — measured byte-identical for a dobj schema
171
+ * with and without the flag
172
+ */
173
+ const setAbsentPositionsRendered = (ctx) => {
174
+ const type = getNodeType(ctx.zodSchema);
175
+ // an absent position publishes `{ not: {} }` — no json value is valid here
176
+ //
177
+ // ⚠️ .why the parent's `required` is left ALONE = a first draft stripped an absent key
178
+ // out of `required`, on the reasoning that the position accepts the key being
179
+ // omitted. MEASURED FALSE: `z.object({ b: z.undefined() }).safeParse({})` returns
180
+ // `success: false` on `zod@4.4.3` — zod demands the key be PRESENT and hold
181
+ // `undefined`. so the strip would have published a face that accepts a document the
182
+ // parse then rejects. left in place, `required: ['b']` beside `b: { not: {} }` is
183
+ // unsatisfiable by any json document, which is the truth exactly
184
+ // (`[case11][t2]` clamps both halves)
185
+ if (getIsAbsentType(type)) {
186
+ for (const key of Object.keys(ctx.jsonSchema))
187
+ delete ctx.jsonSchema[key];
188
+ ctx.jsonSchema.not = {};
189
+ return;
190
+ }
191
+ // any OTHER position the blanket flag emptied is re-raised, and by NAME — zod's own
192
+ // message names the kind and never the field, so an engineer met a stack trace into a
193
+ // vendor file with no clue which position to change (rule.require.errors-name-the-fix)
194
+ //
195
+ // .why a node WITH AN INNER is skipped = its `{}` came from the node it wraps, and that
196
+ // node gets its own call. to re-raise here would name `optional` where the real
197
+ // culprit is `date`, and would refuse a legal `z.any().optional()` outright
198
+ if (Object.keys(ctx.jsonSchema).length === 0 &&
199
+ !TYPES_OPEN.includes(type ?? '') &&
200
+ !getIsNodeWithInner(ctx.zodSchema))
201
+ throw new helpful_errors_1.MalfunctionError(`introspection cannot render this schema: a '${type}' position has no json representation`, {
202
+ type,
203
+ hint: `replace the \`${type}\` position with a json-representable one (for a value that is genuinely open, \`z.unknown()\`; for one that is absent, \`z.undefined()\`)`,
204
+ });
205
+ };
9
206
  const getJsonSchemaFromZod = (schema) => {
10
- return zod_1.z.toJSONSchema(schema);
207
+ /**
208
+ * .what = refuse a schema this zod install cannot recognize, by NAME rather than by TypeError
209
+ * .why = the throw already happened one frame deeper, inside the vendor, with a message that
210
+ * names a property and not a cause (`[case8][t0]`, `[t1]`). this changes no path that
211
+ * succeeds today — it fires on exactly the set that already crashed, and hands that set
212
+ * an error an engineer can act on (rule.require.failloud)
213
+ *
214
+ * .note = it does NOT compare versions. two copies at the SAME version still carry distinct
215
+ * markers, and a version check would pass while the render fails — so the test is the
216
+ * marker itself, which is the property the render actually needs
217
+ */
218
+ const marker = schema?._zod;
219
+ if (!marker?.def?.type)
220
+ throw new helpful_errors_1.MalfunctionError('introspection cannot render this schema: it carries no recognizable zod marker', { hint: FOREIGN_SCHEMA_HINT });
221
+ return zod_1.z.toJSONSchema(schema, {
222
+ io: 'input',
223
+ // .why the blanket + the override = zod refuses an un-renderable position by THROW,
224
+ // which took `z.undefined()` / `z.void()` off the table for every endpoint that
225
+ // introspects. the flag disarms that throw for every kind at once, and
226
+ // `setAbsentPositionsRendered` re-arms it for every kind but the two that have an
227
+ // honest rendering. neither half is safe alone: the flag alone is a failhide,
228
+ // the override alone never runs (zod throws before it returns)
229
+ unrepresentable: 'any',
230
+ override: setAbsentPositionsRendered,
231
+ });
11
232
  };
12
233
  exports.getJsonSchemaFromZod = getJsonSchemaFromZod;
13
234
  //# sourceMappingURL=genIntrospectionMiddleware.getJsonSchemaFromZod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"genIntrospectionMiddleware.getJsonSchemaFromZod.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAGxB;;;GAGG;AACI,MAAM,oBAAoB,GAAG,CAClC,MAAS,EACG,EAAE;IACd,OAAO,OAAC,CAAC,YAAY,CAAC,MAAM,CAAe,CAAC;AAC9C,CAAC,CAAC;AAJW,QAAA,oBAAoB,wBAI/B"}
1
+ {"version":3,"file":"genIntrospectionMiddleware.getJsonSchemaFromZod.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAClD,6BAAwB;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH;;;;;;;;;;;;;GAaG;AACH,MAAM,mBAAmB,GACvB,oQAAoQ,CAAC;AAEvQ;;;;;;;;;;;GAWG;AACH,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAEtC;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,IAAwB,EAAW,EAAE,CAC5D,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,WAAW,GAAG,CAAC,SAAkB,EAAsB,EAAE,CAC5D,SAAoD,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,kBAAkB,GAAG,CAAC,SAAkB,EAAW,EAAE;IACzD,MAAM,IAAI,GAAG,SAEZ,CAAC;IACF,OAAO,CAAC,CAAC,CACP,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS;QAC1B,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACnB,IAAI,EAAE,IAAI,EAAE,SAAS,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,0BAA0B,GAAG,CAAC,GAGnC,EAAQ,EAAE;IACT,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAExC,2EAA2E;IAC3E,EAAE;IACF,uFAAuF;IACvF,iFAAiF;IACjF,qFAAqF;IACrF,+EAA+E;IAC/E,uFAAuF;IACvF,qFAAqF;IACrF,oEAAoE;IACpE,yCAAyC;IACzC,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC1E,GAAG,CAAC,UAAU,CAAC,GAAG,GAAG,EAAE,CAAC;QACxB,OAAO;IACT,CAAC;IAED,oFAAoF;IACpF,sFAAsF;IACtF,uFAAuF;IACvF,EAAE;IACF,wFAAwF;IACxF,qFAAqF;IACrF,iFAAiF;IACjF,IACE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC;QACxC,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;QAChC,CAAC,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC;QAElC,MAAM,IAAI,iCAAgB,CACxB,+CAA+C,IAAI,uCAAuC,EAC1F;YACE,IAAI;YACJ,IAAI,EAAE,iBAAiB,IAAI,4IAA4I;SACxK,CACF,CAAC;AACN,CAAC,CAAC;AAEK,MAAM,oBAAoB,GAAG,CAClC,MAAS,EACG,EAAE;IACd;;;;;;;;;;OAUG;IACH,MAAM,MAAM,GAAI,MAAkD,EAAE,IAAI,CAAC;IACzE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI;QACpB,MAAM,IAAI,iCAAgB,CACxB,gFAAgF,EAChF,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAC9B,CAAC;IAEJ,OAAO,OAAC,CAAC,YAAY,CAAC,MAAM,EAAE;QAC5B,EAAE,EAAE,OAAO;QACX,oFAAoF;QACpF,qFAAqF;QACrF,4EAA4E;QAC5E,uFAAuF;QACvF,mFAAmF;QACnF,oEAAoE;QACpE,eAAe,EAAE,KAAK;QACtB,QAAQ,EAAE,0BAA0B;KACrC,CAAe,CAAC;AACnB,CAAC,CAAC;AAhCW,QAAA,oBAAoB,wBAgC/B"}
@@ -18,16 +18,24 @@ import type { ZodSchema } from 'zod';
18
18
  * signature cannot warn them — `request.response` is `unknown` to middy, so both bind.
19
19
  *
20
20
  * .note = UNRESOLVED, NOT A DEFECT — this export carries two contracts with no discriminant.
21
- * tracked as **F33** in `1.vision.yield.md`'s fulcrum table, where the three options
22
- * (deprecate, add a `point` discriminant, accept) are spelled out.
21
+ * tracked as **F33** in
22
+ * `.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md`'s fulcrum
23
+ * table — the bound that SHIPPED this export, and already merged — where the three
24
+ * options (deprecate, add a `point` discriminant, accept) are spelled out.
23
25
  *
24
26
  * no shipped chain registers it — both families validate inline instead, because each
25
27
  * knows which of the two shapes it holds at that moment and this middleware cannot. so
26
28
  * the open question is one of surface area, never of a live defect.
27
29
  *
28
- * .note = the validation itself is delegated to `getValidatedOutput`, as both input-side peers
29
- * delegate to `getValidationError` — one guarantee, one implementation
30
+ * .note = the validation itself is delegated to `getValidatedOutput`, exactly as both input-side
31
+ * peers delegate to `getValidatedInput` — one guarantee, one implementation, per border
30
32
  * (rule.forbid.parallel-codepaths)
33
+ *
34
+ * the two root primitives are peers rather than one, because they make DIFFERENT
35
+ * guarantees: a bad input is the caller's fault and raises a `ConstraintError`, while a
36
+ * bad output is the server's fault and raises a `MalfunctionError`
37
+ * (rule.require.failloud). to merge them would need an error-class argument, which is a
38
+ * fork on handed config — the shape that rule forbids
31
39
  */
32
40
  export declare const genZodOutputValidationMiddleware: <TOutput>(input: {
33
41
  schema: ZodSchema<TOutput>;
@@ -20,16 +20,24 @@ const getValidatedOutput_1 = require("./getValidatedOutput");
20
20
  * signature cannot warn them — `request.response` is `unknown` to middy, so both bind.
21
21
  *
22
22
  * .note = UNRESOLVED, NOT A DEFECT — this export carries two contracts with no discriminant.
23
- * tracked as **F33** in `1.vision.yield.md`'s fulcrum table, where the three options
24
- * (deprecate, add a `point` discriminant, accept) are spelled out.
23
+ * tracked as **F33** in
24
+ * `.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md`'s fulcrum
25
+ * table — the bound that SHIPPED this export, and already merged — where the three
26
+ * options (deprecate, add a `point` discriminant, accept) are spelled out.
25
27
  *
26
28
  * no shipped chain registers it — both families validate inline instead, because each
27
29
  * knows which of the two shapes it holds at that moment and this middleware cannot. so
28
30
  * the open question is one of surface area, never of a live defect.
29
31
  *
30
- * .note = the validation itself is delegated to `getValidatedOutput`, as both input-side peers
31
- * delegate to `getValidationError` — one guarantee, one implementation
32
+ * .note = the validation itself is delegated to `getValidatedOutput`, exactly as both input-side
33
+ * peers delegate to `getValidatedInput` — one guarantee, one implementation, per border
32
34
  * (rule.forbid.parallel-codepaths)
35
+ *
36
+ * the two root primitives are peers rather than one, because they make DIFFERENT
37
+ * guarantees: a bad input is the caller's fault and raises a `ConstraintError`, while a
38
+ * bad output is the server's fault and raises a `MalfunctionError`
39
+ * (rule.require.failloud). to merge them would need an error-class argument, which is a
40
+ * fork on handed config — the shape that rule forbids
33
41
  */
34
42
  const genZodOutputValidationMiddleware = (input) => {
35
43
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"genZodOutputValidationMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.ts"],"names":[],"mappings":";;;AAGA,6DAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACI,MAAM,gCAAgC,GAAG,CAAU,KAEzD,EAAyC,EAAE;IAC1C,OAAO;QACL,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACvB,uEAAuE;YACvE,yFAAyF;YACzF,OAAO,CAAC,QAAQ,GAAG,IAAA,uCAAkB,EAAC;gBACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,gCAAgC,oCAa3C"}
1
+ {"version":3,"file":"genZodOutputValidationMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.ts"],"names":[],"mappings":";;;AAGA,6DAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACI,MAAM,gCAAgC,GAAG,CAAU,KAEzD,EAAyC,EAAE;IAC1C,OAAO;QACL,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACvB,uEAAuE;YACvE,yFAAyF;YACzF,OAAO,CAAC,QAAQ,GAAG,IAAA,uCAAkB,EAAC;gBACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,gCAAgC,oCAa3C"}
@@ -1,24 +1,11 @@
1
+ import { type LambdaEndpointErrorResponseBodyAncient, type LambdaEndpointErrorResponseBodyContemp } from '../../../domain.objects/LambdaEndpointErrorResponseBody';
1
2
  /**
2
- * ancient error response body (flat format, backwards compat)
3
+ * .what = re-exports the envelope shapes this module WRITES
4
+ * .why = they are DECLARED in `domain.objects/`, because a peer operation types
5
+ * its public return against them. this module is their producer, never their
6
+ * owner — the re-export keeps its own consumers on one import.
3
7
  */
4
- export interface LambdaEndpointErrorResponseBodyAncient {
5
- errorMessage: string;
6
- errorType: string;
7
- causeMessage?: string;
8
- details?: unknown;
9
- }
10
- /**
11
- * contemp error response body (nested under error with explicit serde tag)
12
- */
13
- export interface LambdaEndpointErrorResponseBodyContemp {
14
- error: {
15
- _serde: 'LambdaEndpointError::contemp';
16
- class: string;
17
- message: string;
18
- cause?: string;
19
- details?: unknown;
20
- };
21
- }
8
+ export type { LambdaEndpointErrorResponseBodyAncient, LambdaEndpointErrorResponseBodyContemp, };
22
9
  /**
23
10
  * .what = constructs ancient error response body (flat format)
24
11
  * .why = backwards compat for ancient callers that expect errorType/errorMessage
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getErrorResponseBodyContemp = exports.getErrorResponseBodyAncient = void 0;
4
+ const LambdaEndpointErrorResponseBody_1 = require("../../../domain.objects/LambdaEndpointErrorResponseBody");
4
5
  /**
5
6
  * .what = extracts cause message from error if error has error cause
6
7
  * .why = named transformer for clear narrative
@@ -46,7 +47,11 @@ const getErrorResponseBodyContemp = (input) => {
46
47
  const details = getErrorMetadata({ error: input.error });
47
48
  return {
48
49
  error: {
49
- _serde: 'LambdaEndpointError::contemp',
50
+ // the tag is the whole discriminator, so it has ONE writer — a producer
51
+ // that spells it by hand can fork from the detectors, and that fork fails
52
+ // silent: the envelope stops to be recognized and a caller fault reads as
53
+ // a success payload.
54
+ _serde: LambdaEndpointErrorResponseBody_1.LAMBDA_ENDPOINT_ERROR_SERDE_CONTEMP,
50
55
  class: input.errorClass,
51
56
  message: input.error.message,
52
57
  ...(cause !== undefined ? { cause } : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"getErrorResponseBody.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.ts"],"names":[],"mappings":";;;AAuBA;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC,KAAuB,EAAsB,EAAE;IACtE,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;IACnC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,KAAuB,EAAuB,EAAE;IACxE,8EAA8E;IAC9E,IAAI,UAAU,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC9B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;;GAGG;AACI,MAAM,2BAA2B,GAAG,CAAC,KAG3C,EAA0C,EAAE;IAC3C,MAAM,YAAY,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAE1D,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;QACjC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,2BAA2B,+BAatC;AAEF;;;GAGG;AACI,MAAM,2BAA2B,GAAG,CAAC,KAG3C,EAA0C,EAAE;IAC3C,MAAM,KAAK,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAEzD,OAAO;QACL,KAAK,EAAE;YACL,MAAM,EAAE,8BAA8B;YACtC,KAAK,EAAE,KAAK,CAAC,UAAU;YACvB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;YAC5B,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzC,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9C;KACF,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,2BAA2B,+BAgBtC"}
1
+ {"version":3,"file":"getErrorResponseBody.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.ts"],"names":[],"mappings":";;;AAAA,6GAIiE;AAajE;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC,KAAuB,EAAsB,EAAE;IACtE,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;IACnC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,KAAuB,EAAuB,EAAE;IACxE,8EAA8E;IAC9E,IAAI,UAAU,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC9B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;;GAGG;AACI,MAAM,2BAA2B,GAAG,CAAC,KAG3C,EAA0C,EAAE;IAC3C,MAAM,YAAY,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAE1D,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;QACjC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,2BAA2B,+BAatC;AAEF;;;GAGG;AACI,MAAM,2BAA2B,GAAG,CAAC,KAG3C,EAA0C,EAAE;IAC3C,MAAM,KAAK,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAEzD,OAAO;QACL,KAAK,EAAE;YACL,wEAAwE;YACxE,0EAA0E;YAC1E,0EAA0E;YAC1E,qBAAqB;YACrB,MAAM,EAAE,qEAAmC;YAC3C,KAAK,EAAE,KAAK,CAAC,UAAU;YACvB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;YAC5B,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzC,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9C;KACF,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,2BAA2B,+BAoBtC"}
@@ -1,4 +1,4 @@
1
- import { type WrappedPayload } from './getIsWrappedPayload';
1
+ import { type WrappedPayload } from '../../lambdaEndpointWire/frame/getIsWrappedPayload';
2
2
  /**
3
3
  * .what = extracts exid and unwrapped event from payload, detects caller version
4
4
  * .why = handlers accept wrapped (with trail) or raw (without trail) payloads
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUnwrappedEventWithExid = void 0;
4
- const getIsWrappedPayload_1 = require("./getIsWrappedPayload");
4
+ const getIsWrappedPayload_1 = require("../../lambdaEndpointWire/frame/getIsWrappedPayload");
5
5
  /**
6
6
  * .what = extracts exid and unwrapped event from payload, detects caller version
7
7
  * .why = handlers accept wrapped (with trail) or raw (without trail) payloads
@@ -1 +1 @@
1
- {"version":3,"file":"getUnwrappedEventWithExid.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.ts"],"names":[],"mappings":";;;AAAA,+DAG+B;AAE/B;;;;GAIG;AACI,MAAM,yBAAyB,GAAG,CAAS,KAEjD,EAIC,EAAE;IACF,IAAI,IAAA,yCAAmB,EAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,OAAO;YACL,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI;YAClD,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;YACnC,eAAe,EAAE,IAAI;SACtB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE,KAAK,CAAC,OAAO;QAC7B,eAAe,EAAE,KAAK;KACvB,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,yBAAyB,6BAmBpC"}
1
+ {"version":3,"file":"getUnwrappedEventWithExid.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.ts"],"names":[],"mappings":";;;AAAA,4FAG4D;AAE5D;;;;GAIG;AACI,MAAM,yBAAyB,GAAG,CAAS,KAEjD,EAIC,EAAE;IACF,IAAI,IAAA,yCAAmB,EAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,OAAO;YACL,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI;YAClD,cAAc,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK;YACnC,eAAe,EAAE,IAAI;SACtB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE,KAAK,CAAC,OAAO;QAC7B,eAAe,EAAE,KAAK;KACvB,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,yBAAyB,6BAmBpC"}
@@ -0,0 +1,22 @@
1
+ import type { ZodSchema } from 'zod';
2
+ /**
3
+ * .what = validate a caller's value against an endpoint's input schema, and hand back the
4
+ * parsed result
5
+ * .why = this is the ONE root primitive for the input border. both endpoint families reach it,
6
+ * so a guarantee added here — a coerce, a redaction, an error shape — lands once rather
7
+ * than in each family's own validator
8
+ *
9
+ * .note = the two families differ only in WHICH SLOT carries the caller's value, never in what
10
+ * validation means. `forAskEndpoint` hands the whole `request.event`; `forApiGateway`
11
+ * hands `event.body`, because its `request.event` must stay http-shaped for
12
+ * `@middy/http-cors`. that slot choice stays with each family; the validation itself
13
+ * lives here
14
+ *
15
+ * .note = the result is the POST-parse shape, so a schema that coerces (any `X.contract()`
16
+ * position) yields live domain instances rather than the plain objects that crossed the
17
+ * wire. the caller assigns it into its own slot
18
+ */
19
+ export declare const getValidatedInput: <TInput>(input: {
20
+ schema: ZodSchema<TInput>;
21
+ value: unknown;
22
+ }) => TInput;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getValidatedInput = void 0;
4
+ const getValidationError_1 = require("./getValidationError");
5
+ /**
6
+ * .what = validate a caller's value against an endpoint's input schema, and hand back the
7
+ * parsed result
8
+ * .why = this is the ONE root primitive for the input border. both endpoint families reach it,
9
+ * so a guarantee added here — a coerce, a redaction, an error shape — lands once rather
10
+ * than in each family's own validator
11
+ *
12
+ * .note = the two families differ only in WHICH SLOT carries the caller's value, never in what
13
+ * validation means. `forAskEndpoint` hands the whole `request.event`; `forApiGateway`
14
+ * hands `event.body`, because its `request.event` must stay http-shaped for
15
+ * `@middy/http-cors`. that slot choice stays with each family; the validation itself
16
+ * lives here
17
+ *
18
+ * .note = the result is the POST-parse shape, so a schema that coerces (any `X.contract()`
19
+ * position) yields live domain instances rather than the plain objects that crossed the
20
+ * wire. the caller assigns it into its own slot
21
+ */
22
+ const getValidatedInput = (input) => {
23
+ const result = input.schema.safeParse(input.value);
24
+ if (!result.success)
25
+ throw (0, getValidationError_1.getValidationError)({ error: result.error });
26
+ return result.data;
27
+ };
28
+ exports.getValidatedInput = getValidatedInput;
29
+ //# sourceMappingURL=getValidatedInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getValidatedInput.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.ts"],"names":[],"mappings":";;;AAEA,6DAA0D;AAE1D;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,iBAAiB,GAAG,CAAS,KAGzC,EAAU,EAAE;IACX,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAA,uCAAkB,EAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACvE,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC;AAPW,QAAA,iBAAiB,qBAO5B"}
@@ -1,7 +1,42 @@
1
1
  import type { ZodType } from 'zod';
2
+ import { type ZodIssueSummary } from './getZodIssuesSummary';
3
+ export interface OutputValidationErrorMetadata {
4
+ issues: ZodIssueSummary[];
5
+ hint: string;
6
+ }
2
7
  /**
3
8
  * .what = validates output against schema and returns typed result
4
9
  * .why = named transformer for decode-friction-free validation in orchestrators
10
+ *
11
+ * .note = this is the ONE output-side validator, and BOTH families call it DIRECTLY —
12
+ * `forAskEndpoint.ts:125` and `forApiGateway.ts:274`. so a repair here lands at both
13
+ * borders at once, exactly as `getValidatedInput` does on the input side
14
+ *
15
+ * ⚠️ .why NOT through `genZodOutputValidationMiddleware` = that export wraps this function for a
16
+ * consumer who composes their own chain, and no shipped chain registers it. each family
17
+ * validates inline because each knows which of two shapes it holds at that moment and the
18
+ * middleware cannot (its own `.note` states the same, as does the readme)
19
+ *
20
+ * 🟡 .why the parameter is `response` where its input-border twin takes `value` = the asymmetry
21
+ * is motivated, not an oversight, and it was raised as a nitpick at i018:
22
+ *
23
+ * - at THIS border the value has exactly one home, in both families and in the
24
+ * readme's own consumer example: `response: request.response`. the name states
25
+ * the slot, so the call site reads as an identity
26
+ * - at the INPUT border it has TWO homes — `forAskEndpoint` hands `request.event`
27
+ * whole, `forApiGateway` hands `event.body`, because its `request.event` must
28
+ * stay http-shaped for `@middy/http-cors`. no slot name is true of both, so
29
+ * `value` is the honest neutral there rather than a claim about position
30
+ * (rule.prefer.names-by-position-over-claim)
31
+ *
32
+ * ⇒ ⛔ the plan that used to sit here is VOID: it deferred the rename to *"F35's
33
+ * resolution, which forces a shared `parseOrThrow` primitive"*. F35 was ruled
34
+ * 2026-09-21 as NO REPAIR OWED, so no such extraction will arrive and no future
35
+ * edit will carry this rename for free
36
+ *
37
+ * ⇒ the divergence therefore stands on its own merits, which are the two bullets
38
+ * above and are sufficient: one border has a true slot name, the other has two
39
+ * homes and no name true of both. ⇒ this is a settled asymmetry, never a debt
5
40
  */
6
41
  export declare const getValidatedOutput: <TOutput>(input: {
7
42
  response: unknown;
@@ -3,15 +3,72 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getValidatedOutput = void 0;
4
4
  const helpful_errors_1 = require("helpful-errors");
5
5
  const getZodIssuesSummary_1 = require("./getZodIssuesSummary");
6
+ /**
7
+ * .what = the FIX half of the message a HANDLER AUTHOR meets when their own return is refused
8
+ * .why = `rule.require.errors-name-the-fix` asks for what, why, and the concrete next move. the
9
+ * zod summary supplies the first two; the third has to name an act the reader can perform
10
+ *
11
+ * ⚠️ .why it names a DIFFERENT fix than the input border = the audience inverts. an input
12
+ * failure is the CALLER's to fix, so its hint tells them what to send. an output failure
13
+ * is the HANDLER's to fix, and the caller has no move available at all — which is why
14
+ * this throws `MalfunctionError` where the input border throws `ConstraintError`
15
+ * (invariant.badrequesterror-not-lambda-error)
16
+ *
17
+ * 🔴 .why the constructor is named as a FACT rather than as the FIX = a prior draft of this hint
18
+ * read *"hand back the INSTANCE (`new X({ … })`) rather than a plain object"*, on the
19
+ * premise that `X.contract()` refuses a prop bag here. **that premise is measured FALSE.**
20
+ *
21
+ * - `X.contract()` COERCES, so a bag whose fields are correct PARSES and is handed back
22
+ * as an instance. the shape a handler returns is a TYPE-level contract, never a
23
+ * runtime gate, and the compiler enforces it unevenly — it demands the instance only
24
+ * where a union in the schema blocks inference of `TOutput` from the `invoke` return
25
+ * - ⇒ so bag-vs-instance is ORTHOGONAL to pass-vs-fail, and the DATA is what decides.
26
+ * a bag with a field absent throws HERE; `new X({ … })` built from that same data
27
+ * throws EARLIER, at construction, on the identical path
28
+ * - ⇒ a hint that names the constructor therefore names a move that does not fix the
29
+ * failure it is attached to, which is the defect `rule.require.errors-name-the-fix`
30
+ * exists to prevent
31
+ */
32
+ const OUTPUT_VALIDATION_HINT = 'the handler returned a value its own declared output schema refuses — correct each path named in `issues`. ⚠️ a plain object is NOT the cause: `X.contract()` coerces, so a bag whose fields are correct parses here. `new X({ … })` is the TYPE-level contract, and it checks these same paths at construction instead';
6
33
  /**
7
34
  * .what = validates output against schema and returns typed result
8
35
  * .why = named transformer for decode-friction-free validation in orchestrators
36
+ *
37
+ * .note = this is the ONE output-side validator, and BOTH families call it DIRECTLY —
38
+ * `forAskEndpoint.ts:125` and `forApiGateway.ts:274`. so a repair here lands at both
39
+ * borders at once, exactly as `getValidatedInput` does on the input side
40
+ *
41
+ * ⚠️ .why NOT through `genZodOutputValidationMiddleware` = that export wraps this function for a
42
+ * consumer who composes their own chain, and no shipped chain registers it. each family
43
+ * validates inline because each knows which of two shapes it holds at that moment and the
44
+ * middleware cannot (its own `.note` states the same, as does the readme)
45
+ *
46
+ * 🟡 .why the parameter is `response` where its input-border twin takes `value` = the asymmetry
47
+ * is motivated, not an oversight, and it was raised as a nitpick at i018:
48
+ *
49
+ * - at THIS border the value has exactly one home, in both families and in the
50
+ * readme's own consumer example: `response: request.response`. the name states
51
+ * the slot, so the call site reads as an identity
52
+ * - at the INPUT border it has TWO homes — `forAskEndpoint` hands `request.event`
53
+ * whole, `forApiGateway` hands `event.body`, because its `request.event` must
54
+ * stay http-shaped for `@middy/http-cors`. no slot name is true of both, so
55
+ * `value` is the honest neutral there rather than a claim about position
56
+ * (rule.prefer.names-by-position-over-claim)
57
+ *
58
+ * ⇒ ⛔ the plan that used to sit here is VOID: it deferred the rename to *"F35's
59
+ * resolution, which forces a shared `parseOrThrow` primitive"*. F35 was ruled
60
+ * 2026-09-21 as NO REPAIR OWED, so no such extraction will arrive and no future
61
+ * edit will carry this rename for free
62
+ *
63
+ * ⇒ the divergence therefore stands on its own merits, which are the two bullets
64
+ * above and are sufficient: one border has a true slot name, the other has two
65
+ * homes and no name true of both. ⇒ this is a settled asymmetry, never a debt
9
66
  */
10
67
  const getValidatedOutput = (input) => {
11
68
  const result = input.schema.safeParse(input.response);
12
69
  if (!result.success) {
13
70
  const issues = (0, getZodIssuesSummary_1.getZodIssuesSummary)({ issues: result.error.issues });
14
- throw new helpful_errors_1.MalfunctionError('output validation failed', { issues });
71
+ throw new helpful_errors_1.MalfunctionError(`output validation failed: ${(0, getZodIssuesSummary_1.asZodIssuesMessage)({ issues })}`, { issues, hint: OUTPUT_VALIDATION_HINT });
15
72
  }
16
73
  return result.data;
17
74
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getValidatedOutput.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAGlD,+DAA4D;AAE5D;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAU,KAG3C,EAAW,EAAE;IACZ,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,IAAA,yCAAmB,EAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACpE,MAAM,IAAI,iCAAgB,CAAC,0BAA0B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC;AAVW,QAAA,kBAAkB,sBAU7B"}
1
+ {"version":3,"file":"getValidatedOutput.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAGlD,+DAI+B;AAO/B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,sBAAsB,GAC1B,yTAAyT,CAAC;AAE5T;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACI,MAAM,kBAAkB,GAAG,CAAU,KAG3C,EAAW,EAAE;IACZ,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,IAAA,yCAAmB,EAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACpE,MAAM,IAAI,iCAAgB,CACxB,6BAA6B,IAAA,wCAAkB,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAC7D,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,EAAE,CACzC,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC;AAbW,QAAA,kBAAkB,sBAa7B"}
@@ -3,6 +3,7 @@ import type { ZodError } from 'zod';
3
3
  import { type ZodIssueSummary } from './getZodIssuesSummary';
4
4
  export interface ValidationErrorMetadata {
5
5
  issues: ZodIssueSummary[];
6
+ hint: string;
6
7
  }
7
8
  /**
8
9
  * .what = transforms zod validation error into ConstraintError