sdk-aws-lambda 0.1.1 → 0.3.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 (177) hide show
  1. package/dist/{domain.operations/askLambdaEndpoint/invoke/genLambdaClient.d.ts → access/sdks/lambda/genLambdaSdk.d.ts} +2 -2
  2. package/dist/{domain.operations/askLambdaEndpoint/invoke/genLambdaClient.js → access/sdks/lambda/genLambdaSdk.js} +7 -7
  3. package/dist/access/sdks/lambda/genLambdaSdk.js.map +1 -0
  4. package/dist/{domain.operations/askLambdaEndpoint/invoke → access/sdks/lambda}/sdkLambdaInvoke.d.ts +6 -2
  5. package/dist/{domain.operations/askLambdaEndpoint/invoke → access/sdks/lambda}/sdkLambdaInvoke.js +6 -3
  6. package/dist/access/sdks/lambda/sdkLambdaInvoke.js.map +1 -0
  7. package/dist/contract/cli/asGenArgs.d.ts +21 -0
  8. package/dist/contract/cli/asGenArgs.js +69 -0
  9. package/dist/contract/cli/asGenArgs.js.map +1 -0
  10. package/dist/contract/cli/gen.d.ts +23 -0
  11. package/dist/contract/cli/gen.js +72 -0
  12. package/dist/contract/cli/gen.js.map +1 -0
  13. package/dist/domain.objects/ContextAwsLambdaCaller.d.ts +25 -0
  14. package/dist/domain.objects/ContextAwsLambdaCaller.js +3 -0
  15. package/dist/domain.objects/ContextAwsLambdaCaller.js.map +1 -0
  16. package/dist/domain.objects/ContextAwsLambdaServer.d.ts +30 -0
  17. package/dist/domain.objects/ContextAwsLambdaServer.js +3 -0
  18. package/dist/domain.objects/ContextAwsLambdaServer.js.map +1 -0
  19. package/dist/domain.objects/DomainObjectCaptured.d.ts +51 -0
  20. package/dist/domain.objects/DomainObjectCaptured.js +8 -0
  21. package/dist/domain.objects/DomainObjectCaptured.js.map +1 -0
  22. package/dist/domain.objects/GeneratedFile.d.ts +18 -0
  23. package/dist/domain.objects/GeneratedFile.js +8 -0
  24. package/dist/domain.objects/GeneratedFile.js.map +1 -0
  25. package/dist/domain.objects/HttpStatusCode.d.ts +2 -2
  26. package/dist/domain.objects/HttpStatusCode.js +3 -3
  27. package/dist/domain.objects/LambdaCredentialsAbsentError.d.ts +11 -0
  28. package/dist/domain.objects/LambdaCredentialsAbsentError.js +16 -0
  29. package/dist/domain.objects/LambdaCredentialsAbsentError.js.map +1 -0
  30. package/dist/domain.objects/LambdaDomainObjectNotCapturableError.d.ts +12 -0
  31. package/dist/domain.objects/LambdaDomainObjectNotCapturableError.js +17 -0
  32. package/dist/domain.objects/LambdaDomainObjectNotCapturableError.js.map +1 -0
  33. package/dist/domain.objects/LambdaDomainObjectRefUnbindableError.d.ts +14 -0
  34. package/dist/domain.objects/LambdaDomainObjectRefUnbindableError.js +19 -0
  35. package/dist/domain.objects/LambdaDomainObjectRefUnbindableError.js.map +1 -0
  36. package/dist/domain.objects/LambdaEndpoint.d.ts +35 -0
  37. package/dist/domain.objects/LambdaEndpoint.js +10 -0
  38. package/dist/domain.objects/LambdaEndpoint.js.map +1 -0
  39. package/dist/domain.objects/LambdaEndpointError.d.ts +5 -8
  40. package/dist/domain.objects/LambdaEndpointError.js.map +1 -1
  41. package/dist/domain.objects/LambdaEndpointSchema.d.ts +9 -0
  42. package/dist/domain.objects/LambdaEndpointSchema.js +3 -0
  43. package/dist/domain.objects/LambdaEndpointSchema.js.map +1 -0
  44. package/dist/domain.objects/LambdaFunctionNotFoundError.d.ts +10 -0
  45. package/dist/domain.objects/LambdaFunctionNotFoundError.js +15 -0
  46. package/dist/domain.objects/LambdaFunctionNotFoundError.js.map +1 -0
  47. package/dist/domain.objects/LambdaIntrospectionBlockedError.d.ts +10 -0
  48. package/dist/domain.objects/LambdaIntrospectionBlockedError.js +15 -0
  49. package/dist/domain.objects/LambdaIntrospectionBlockedError.js.map +1 -0
  50. package/dist/domain.objects/LambdaIntrospectionNotSupportedError.d.ts +18 -0
  51. package/dist/domain.objects/LambdaIntrospectionNotSupportedError.js +15 -0
  52. package/dist/domain.objects/LambdaIntrospectionNotSupportedError.js.map +1 -0
  53. package/dist/domain.objects/LambdaServiceNotFoundError.d.ts +10 -0
  54. package/dist/domain.objects/LambdaServiceNotFoundError.js +15 -0
  55. package/dist/domain.objects/LambdaServiceNotFoundError.js.map +1 -0
  56. package/dist/domain.operations/asLambdaEndpoint/asLambdaEndpoint.d.ts +20 -0
  57. package/dist/domain.operations/asLambdaEndpoint/asLambdaEndpoint.js +47 -0
  58. package/dist/domain.operations/asLambdaEndpoint/asLambdaEndpoint.js.map +1 -0
  59. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.d.ts +2 -12
  60. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js +13 -22
  61. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js.map +1 -1
  62. package/dist/domain.operations/askLambdaEndpoint/cache/asCachedExecutor.d.ts +2 -2
  63. package/dist/domain.operations/askLambdaEndpoint/cache/asCachedExecutor.js.map +1 -1
  64. package/dist/domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey.d.ts +3 -4
  65. package/dist/domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey.js +17 -5
  66. package/dist/domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey.js.map +1 -1
  67. package/dist/domain.operations/askLambdaEndpoint/error/getStatusCodeHint.d.ts +1 -1
  68. package/dist/domain.operations/askLambdaEndpoint/error/getStatusCodeHint.js +3 -3
  69. package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.d.ts +13 -8
  70. package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js +20 -19
  71. package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js.map +1 -1
  72. package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.d.ts +13 -0
  73. package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js +26 -0
  74. package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js.map +1 -0
  75. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.d.ts +2 -2
  76. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js +15 -14
  77. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js.map +1 -1
  78. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +15 -8
  79. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +16 -9
  80. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
  81. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getCorsOrigin.d.ts +3 -3
  82. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getCorsOrigin.js +5 -5
  83. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayEvent.d.ts +1 -1
  84. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayEvent.js +1 -1
  85. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js +88 -63
  86. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js.map +1 -1
  87. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts +7 -9
  88. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js +14 -11
  89. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +1 -1
  90. package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.js +1 -1
  91. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.d.ts +22 -0
  92. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.d.ts +7 -0
  93. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js +13 -0
  94. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js.map +1 -0
  95. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.d.ts +5 -0
  96. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.js +16 -0
  97. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.js.map +1 -0
  98. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js +53 -0
  99. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js.map +1 -0
  100. package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js +1 -1
  101. package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.d.ts +1 -1
  102. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.d.ts +1 -1
  103. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js +12 -4
  104. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js.map +1 -1
  105. package/dist/domain.operations/genServiceSdk/asServiceSymbols/asServiceSymbols.d.ts +16 -0
  106. package/dist/domain.operations/genServiceSdk/asServiceSymbols/asServiceSymbols.js +36 -0
  107. package/dist/domain.operations/genServiceSdk/asServiceSymbols/asServiceSymbols.js.map +1 -0
  108. package/dist/domain.operations/genServiceSdk/gen.file/asBarrelFileSource.d.ts +10 -0
  109. package/dist/domain.operations/genServiceSdk/gen.file/asBarrelFileSource.js +18 -0
  110. package/dist/domain.operations/genServiceSdk/gen.file/asBarrelFileSource.js.map +1 -0
  111. package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.d.ts +14 -0
  112. package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.js +44 -0
  113. package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.js.map +1 -0
  114. package/dist/domain.operations/genServiceSdk/gen.file/asResourcesFileSource.d.ts +11 -0
  115. package/dist/domain.operations/genServiceSdk/gen.file/asResourcesFileSource.js +42 -0
  116. package/dist/domain.operations/genServiceSdk/gen.file/asResourcesFileSource.js.map +1 -0
  117. package/dist/domain.operations/genServiceSdk/gen.file/banner.d.ts +9 -0
  118. package/dist/domain.operations/genServiceSdk/gen.file/banner.js +16 -0
  119. package/dist/domain.operations/genServiceSdk/gen.file/banner.js.map +1 -0
  120. package/dist/domain.operations/genServiceSdk/gen.file/formatTypescript.d.ts +20 -0
  121. package/dist/domain.operations/genServiceSdk/gen.file/formatTypescript.js +44 -0
  122. package/dist/domain.operations/genServiceSdk/gen.file/formatTypescript.js.map +1 -0
  123. package/dist/domain.operations/genServiceSdk/gen.file/setGeneratedFilesBatch.d.ts +13 -0
  124. package/dist/domain.operations/genServiceSdk/gen.file/setGeneratedFilesBatch.js +49 -0
  125. package/dist/domain.operations/genServiceSdk/gen.file/setGeneratedFilesBatch.js.map +1 -0
  126. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.d.ts +16 -0
  127. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js +39 -0
  128. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js.map +1 -0
  129. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.d.ts +35 -0
  130. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js +189 -0
  131. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js.map +1 -0
  132. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.d.ts +15 -0
  133. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js +37 -0
  134. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js.map +1 -0
  135. package/dist/domain.operations/genServiceSdk/gen.resource/asResourceClassSource.d.ts +26 -0
  136. package/dist/domain.operations/genServiceSdk/gen.resource/asResourceClassSource.js +106 -0
  137. package/dist/domain.operations/genServiceSdk/gen.resource/asResourceClassSource.js.map +1 -0
  138. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.d.ts +15 -0
  139. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js +51 -0
  140. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js.map +1 -0
  141. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.d.ts +14 -0
  142. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js +68 -0
  143. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js.map +1 -0
  144. package/dist/domain.operations/genServiceSdk/genServiceSdk.d.ts +20 -0
  145. package/dist/domain.operations/genServiceSdk/genServiceSdk.js +88 -0
  146. package/dist/domain.operations/genServiceSdk/genServiceSdk.js.map +1 -0
  147. package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.d.ts +33 -0
  148. package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js +134 -0
  149. package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js.map +1 -0
  150. package/dist/domain.operations/getAllLambdaContracts/lambdaContract/asContractRecord.d.ts +6 -0
  151. package/dist/domain.operations/getAllLambdaContracts/lambdaContract/asContractRecord.js +12 -0
  152. package/dist/domain.operations/getAllLambdaContracts/lambdaContract/asContractRecord.js.map +1 -0
  153. package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/getAllLambdaFunctionsByPrefix.d.ts +15 -0
  154. package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/getAllLambdaFunctionsByPrefix.js +44 -0
  155. package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/getAllLambdaFunctionsByPrefix.js.map +1 -0
  156. package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/sdkLambdaGetAllFunctions.d.ts +16 -0
  157. package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/sdkLambdaGetAllFunctions.js +26 -0
  158. package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/sdkLambdaGetAllFunctions.js.map +1 -0
  159. package/dist/domain.operations/getOneLambdaContract/asLambdaEndpointSchema.d.ts +16 -0
  160. package/dist/domain.operations/getOneLambdaContract/asLambdaEndpointSchema.js +76 -0
  161. package/dist/domain.operations/getOneLambdaContract/asLambdaEndpointSchema.js.map +1 -0
  162. package/dist/domain.operations/getOneLambdaContract/getOneLambdaContract.d.ts +32 -0
  163. package/dist/domain.operations/getOneLambdaContract/getOneLambdaContract.js +112 -0
  164. package/dist/domain.operations/getOneLambdaContract/getOneLambdaContract.js.map +1 -0
  165. package/dist/index.d.ts +19 -1
  166. package/dist/index.js +35 -2
  167. package/dist/index.js.map +1 -1
  168. package/package.json +19 -14
  169. package/readme.md +64 -4
  170. package/dist/domain.operations/askLambdaEndpoint/context/getAccessFromContext.d.ts +0 -11
  171. package/dist/domain.operations/askLambdaEndpoint/context/getAccessFromContext.js +0 -21
  172. package/dist/domain.operations/askLambdaEndpoint/context/getAccessFromContext.js.map +0 -1
  173. package/dist/domain.operations/askLambdaEndpoint/invoke/genLambdaClient.js.map +0 -1
  174. package/dist/domain.operations/askLambdaEndpoint/invoke/sdkLambdaInvoke.js.map +0 -1
  175. package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.d.ts +0 -9
  176. package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.js +0 -12
  177. package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"executeLambdaInvocation.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.ts"],"names":[],"mappings":";;;AAEA,qFAAkF;AAClF,kEAA+D;AAC/D,kEAA+D;AAC/D,uDAAoD;AAwBpD;;;GAGG;AACI,MAAM,uBAAuB,GAAG,KAAK,EAC1C,KAAqB,EACD,EAAE;IACtB,iBAAiB;IACjB,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,0BAA0B,EAAE;QAC3C,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;IAEH,iCAAiC;IACjC,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAe,EAAC;QACnC,MAAM,EAAE,KAAK,CAAC,YAAY;QAC1B,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAC1B,MAAM,IAAI,yCAAmB,CAC3B,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACpF;YACE,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SAClD,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,gFAAgF;IAChF,6EAA6E;IAC7E,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC;IAC1C,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,0DAA0D;QAC1D,MAAM,UAAU,GAAG,IAAA,qCAAiB,EAAC,UAAU,CAAC,CAAC;QACjD,MAAM,IAAI,yCAAmB,CAAC,6BAA6B,UAAU,EAAE,EAAE;YACvE,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED,iBAAiB;IACjB,MAAM,QAAQ,GAAG,IAAA,qCAAiB,EAAY;QAC5C,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;IAEH,aAAa;IACb,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,0BAA0B,EAAE;QAC3C,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAxDW,QAAA,uBAAuB,2BAwDlC"}
1
+ {"version":3,"file":"executeLambdaInvocation.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.ts"],"names":[],"mappings":";;;AAEA,iFAA8E;AAE9E,qFAAkF;AAClF,kEAA+D;AAC/D,kEAA+D;AA6B/D;;;GAGG;AACI,MAAM,uBAAuB,GAAG,KAAK,EAC1C,KAAsB,EACtB,OAA0B,EACN,EAAE;IACtB,iBAAiB;IACjB,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,0BAA0B,EAAE;QAC7C,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;QACzB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;IAEH,iCAAiC;IACjC,8EAA8E;IAC9E,iFAAiF;IACjF,gEAAgE;IAChE,uDAAuD;IACvD,MAAM,MAAM,GAAG,MAAM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AQ,CAAC,IAAI;QACzB,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AA1DW,QAAA,uBAAuB,2BA0DlC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * .what = strips helpful-errors emoji prefix from error message
3
+ * .why = prevents double prefix when errors cross lambda boundary
4
+ *
5
+ * helpful-errors prefixes messages with pattern: "✋ {ClassName}: {message}"
6
+ * when we create a new ConstraintError with this message, it adds another prefix
7
+ * e.g., "✋ ConstraintError: ✋ ConstraintError: validation failed"
8
+ *
9
+ * this transformer extracts the original message to avoid duplicate prefixes
10
+ */
11
+ export declare const asUnprefixedErrorMessage: (input: {
12
+ message: string;
13
+ }) => string;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asUnprefixedErrorMessage = void 0;
4
+ /**
5
+ * .what = strips helpful-errors emoji prefix from error message
6
+ * .why = prevents double prefix when errors cross lambda boundary
7
+ *
8
+ * helpful-errors prefixes messages with pattern: "✋ {ClassName}: {message}"
9
+ * when we create a new ConstraintError with this message, it adds another prefix
10
+ * e.g., "✋ ConstraintError: ✋ ConstraintError: validation failed"
11
+ *
12
+ * this transformer extracts the original message to avoid duplicate prefixes
13
+ */
14
+ const asUnprefixedErrorMessage = (input) => {
15
+ // match pattern: "✋ {ClassName}: {rest}"
16
+ // .note = class names may have suffixes from bundler deduplication (e.g., ConstraintError5)
17
+ const prefixPattern = /^✋\s+\w+:\s*/;
18
+ const match = input.message.match(prefixPattern);
19
+ if (!match) {
20
+ return input.message;
21
+ }
22
+ // strip the prefix
23
+ return input.message.slice(match[0].length);
24
+ };
25
+ exports.asUnprefixedErrorMessage = asUnprefixedErrorMessage;
26
+ //# sourceMappingURL=asUnprefixedErrorMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asUnprefixedErrorMessage.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACI,MAAM,wBAAwB,GAAG,CAAC,KAExC,EAAU,EAAE;IACX,yCAAyC;IACzC,4FAA4F;IAC5F,MAAM,aAAa,GAAG,cAAc,CAAC;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAEjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,mBAAmB;IACnB,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,CAAC;AAdW,QAAA,wBAAwB,4BAcnC"}
@@ -1,3 +1,4 @@
1
+ import type { LambdaEndpoint } from '../../../domain.objects/LambdaEndpoint';
1
2
  /**
2
3
  * .what = parses lambda response payload and throws on error
3
4
  * .why = orchestrator composes decode, parse, and error detection
@@ -9,7 +10,6 @@
9
10
  export declare const getParsedResponse: <TResponse>(input: {
10
11
  payload: Uint8Array | undefined;
11
12
  functionError: string | undefined;
12
- service: string;
13
- function: string;
13
+ endpoint: LambdaEndpoint;
14
14
  exid: string | null;
15
15
  }) => TResponse;
@@ -6,6 +6,7 @@ const LambdaEndpointError_1 = require("../../../domain.objects/LambdaEndpointErr
6
6
  const getIsLambdaErrorResponse_1 = require("../error/getIsLambdaErrorResponse");
7
7
  const getLambdaErrorMetadata_1 = require("../error/getLambdaErrorMetadata");
8
8
  const getStackTraceString_1 = require("../error/getStackTraceString");
9
+ const asUnprefixedErrorMessage_1 = require("./asUnprefixedErrorMessage");
9
10
  const getDecodedPayload_1 = require("./getDecodedPayload");
10
11
  const getParsedJson_1 = require("./getParsedJson");
11
12
  /**
@@ -20,8 +21,7 @@ const getParsedResponse = (input) => {
20
21
  // validate payload exists
21
22
  if (!input.payload) {
22
23
  throw new LambdaEndpointError_1.LambdaEndpointError('lambda returned empty payload', {
23
- service: input.service,
24
- function: input.function,
24
+ endpoint: input.endpoint,
25
25
  exid: input.exid,
26
26
  });
27
27
  }
@@ -31,8 +31,7 @@ const getParsedResponse = (input) => {
31
31
  const parseResult = (0, getParsedJson_1.getParsedJson)({ json: payloadString });
32
32
  if (!parseResult.success) {
33
33
  throw new LambdaEndpointError_1.LambdaEndpointError('lambda returned invalid json', {
34
- service: input.service,
35
- function: input.function,
34
+ endpoint: input.endpoint,
36
35
  exid: input.exid,
37
36
  cause: parseResult.error,
38
37
  });
@@ -43,9 +42,10 @@ const getParsedResponse = (input) => {
43
42
  const err = parsed.error;
44
43
  // ConstraintError = caller's fault, not lambda error (lambda succeeded)
45
44
  if (err.class === 'ConstraintError') {
46
- throw new helpful_errors_1.ConstraintError(err.message, {
47
- service: input.service,
48
- function: input.function,
45
+ // strip prefix to avoid double prefix (handler already prefixed the message)
46
+ const message = (0, asUnprefixedErrorMessage_1.asUnprefixedErrorMessage)({ message: err.message });
47
+ throw new helpful_errors_1.ConstraintError(message, {
48
+ endpoint: input.endpoint,
49
49
  exid: input.exid,
50
50
  causeMessage: err.cause,
51
51
  details: err.details,
@@ -53,8 +53,7 @@ const getParsedResponse = (input) => {
53
53
  }
54
54
  // all other error classes = lambda invocation error
55
55
  throw new LambdaEndpointError_1.LambdaEndpointError(err.message, {
56
- service: input.service,
57
- function: input.function,
56
+ endpoint: input.endpoint,
58
57
  exid: input.exid,
59
58
  errorType: err.class,
60
59
  causeMessage: err.cause,
@@ -69,9 +68,12 @@ const getParsedResponse = (input) => {
69
68
  // .note = check both for backwards compat with handlers that use old error types
70
69
  if (parsed.errorType === 'ConstraintError' ||
71
70
  parsed.errorType === 'BadRequestError') {
72
- throw new helpful_errors_1.ConstraintError(parsed.errorMessage, {
73
- service: input.service,
74
- function: input.function,
71
+ // strip prefix to avoid double prefix (handler already prefixed the message)
72
+ const message = (0, asUnprefixedErrorMessage_1.asUnprefixedErrorMessage)({
73
+ message: parsed.errorMessage,
74
+ });
75
+ throw new helpful_errors_1.ConstraintError(message, {
76
+ endpoint: input.endpoint,
75
77
  exid: input.exid,
76
78
  stackTrace,
77
79
  ...errorMeta,
@@ -79,8 +81,7 @@ const getParsedResponse = (input) => {
79
81
  }
80
82
  // all other error types = lambda invocation error
81
83
  throw new LambdaEndpointError_1.LambdaEndpointError(parsed.errorMessage, {
82
- service: input.service,
83
- function: input.function,
84
+ endpoint: input.endpoint,
84
85
  exid: input.exid,
85
86
  errorType: parsed.errorType,
86
87
  stackTrace,
@@ -1 +1 @@
1
- {"version":3,"file":"getParsedResponse.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/getParsedResponse.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD,qFAAkF;AAClF,gFAG2C;AAC3C,4EAAyE;AACzE,sEAAmE;AACnE,2DAAwD;AACxD,mDAAgD;AAEhD;;;;;;;GAOG;AACI,MAAM,iBAAiB,GAAG,CAAY,KAM5C,EAAa,EAAE;IACd,0BAA0B;IAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,IAAI,yCAAmB,CAAC,+BAA+B,EAAE;YAC7D,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;IAED,2BAA2B;IAC3B,MAAM,aAAa,GAAG,IAAA,qCAAiB,EAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAEpE,aAAa;IACb,MAAM,WAAW,GAAG,IAAA,6BAAa,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;IAC3D,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACzB,MAAM,IAAI,yCAAmB,CAAC,8BAA8B,EAAE;YAC5D,OAAO,EAAE,KAAK,CAAC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;QAEpE,wFAAwF;QACxF,iFAAiF;QACjF,IACE,MAAM,CAAC,SAAS,KAAK,iBAAiB;YACtC,MAAM,CAAC,SAAS,KAAK,iBAAiB,EACtC,CAAC;YACD,MAAM,IAAI,gCAAe,CAAC,MAAM,CAAC,YAAY,EAAE;gBAC7C,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,UAAU;gBACV,GAAG,SAAS;aACb,CAAC,CAAC;QACL,CAAC;QAED,kDAAkD;QAClD,MAAM,IAAI,yCAAmB,CAAC,MAAM,CAAC,YAAY,EAAE;YACjD,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU;YACV,GAAG,SAAS;SACb,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,OAAO,MAAmB,CAAC;AAC7B,CAAC,CAAC;AA/FW,QAAA,iBAAiB,qBA+F5B"}
1
+ {"version":3,"file":"getParsedResponse.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/getParsedResponse.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAGjD,qFAAkF;AAClF,gFAG2C;AAC3C,4EAAyE;AACzE,sEAAmE;AACnE,yEAAsE;AACtE,2DAAwD;AACxD,mDAAgD;AAEhD;;;;;;;GAOG;AACI,MAAM,iBAAiB,GAAG,CAAY,KAK5C,EAAa,EAAE;IACd,0BAA0B;IAC1B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,IAAI,yCAAmB,CAAC,+BAA+B,EAAE;YAC7D,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;IA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,KAAK;YACvB,OAAO,EAAE,GAAG,CAAC,OAAO;SACrB,CAAC,CAAC;IACL,CAAC;IAED,mDAAmD;IACnD,IAAI,IAAA,oDAAyB,EAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,UAAU,GAAG,IAAA,yCAAmB,EAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QAC1E,MAAM,SAAS,GAAG,IAAA,+CAAsB,EAAC,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;QAEpE,wFAAwF;QACxF,iFAAiF;QACjF,IACE,MAAM,CAAC,SAAS,KAAK,iBAAiB;YACtC,MAAM,CAAC,SAAS,KAAK,iBAAiB,EACtC,CAAC;YACD,6EAA6E;YAC7E,MAAM,OAAO,GAAG,IAAA,mDAAwB,EAAC;gBACvC,OAAO,EAAE,MAAM,CAAC,YAAY;aAC7B,CAAC,CAAC;YACH,MAAM,IAAI,gCAAe,CAAC,OAAO,EAAE;gBACjC,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,UAAU;gBACV,GAAG,SAAS;aACb,CAAC,CAAC;QACL,CAAC;QAED,kDAAkD;QAClD,MAAM,IAAI,yCAAmB,CAAC,MAAM,CAAC,YAAY,EAAE;YACjD,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU;YACV,GAAG,SAAS;SACb,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,OAAO,MAAmB,CAAC;AAC7B,CAAC,CAAC;AA9FW,QAAA,iBAAiB,qBA8F5B"}
@@ -2,11 +2,12 @@ import middy from '@middy/core';
2
2
  import type { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from 'aws-lambda';
3
3
  import type { ContextLogTrail } from 'sdk-logs';
4
4
  import type { ZodSchema } from 'zod';
5
+ import type { ContextAwsLambdaServer } from '../../../domain.objects/ContextAwsLambdaServer';
5
6
  import type { IoLogTranslate } from '../middleware/genIoLoggerMiddleware';
6
7
  import { type UnifiedApiGatewayEvent } from './middleware/genApiGatewayEventNormalizationMiddleware';
7
8
  export interface CorsConfig {
8
9
  /**
9
- * .what = origins to accept for CORS
10
+ * .what = origins to accept for cors
10
11
  * .why = sets Access-Control-Allow-Origin header
11
12
  *
12
13
  * special:
@@ -23,7 +24,7 @@ export interface CorsConfig {
23
24
  */
24
25
  credentials: boolean;
25
26
  /**
26
- * .what = headers allowed in CORS requests
27
+ * .what = headers allowed in cors requests
27
28
  * .why = sets Access-Control-Allow-Headers header
28
29
  *
29
30
  * defaults to 'content-type,authorization'
@@ -47,8 +48,8 @@ export type ForApiGatewayInput<TInput, TOutput> = {
47
48
  cors?: CorsConfig;
48
49
  deserialize?: {
49
50
  /**
50
- * .what = whether to deserialize JSON body
51
- * .why = converts JSON string body to object when content-type is application/json
51
+ * .what = whether to deserialize json body
52
+ * .why = converts json string body to object when content-type is application/json
52
53
  *
53
54
  * defaults to true; set to false for raw string input
54
55
  */
@@ -56,14 +57,20 @@ export type ForApiGatewayInput<TInput, TOutput> = {
56
57
  };
57
58
  };
58
59
  /**
59
- * .what = generates API Gateway lambda handler with HTTP features
60
- * .why = adds CORS, security headers, error handler, body serialization, and validation
60
+ * .what = sdk contract type for forApiGateway context
61
+ * .why = exported for consumer type inference; the shared handler-side context
62
+ * ({ env?: EnvConfig; log? }) reused by genLambdaEndpoint + forApiGateway
63
+ */
64
+ export type ForApiGatewayContext = ContextAwsLambdaServer;
65
+ /**
66
+ * .what = generates API Gateway lambda handler with http features
67
+ * .why = adds cors, security headers, error handler, body serialization, and validation
61
68
  *
62
69
  * follows simple-lambda-handlers createApiGatewayHandler pattern:
63
70
  * - uses middy middleware chain
64
71
  * - uses @middy/http-cors for dynamic origin match
65
72
  * - uses @middy/http-security-headers for OWASP security headers
66
- * - uses @middy/http-json-body-parser for JSON body parse
73
+ * - uses @middy/http-json-body-parser for json body parse
67
74
  * - uses @middy/http-response-serializer for response serialization
68
75
  */
69
76
  export declare const forApiGateway: <TInput, TOutput>(config: {
@@ -80,4 +87,4 @@ export declare const forApiGateway: <TInput, TOutput>(config: {
80
87
  deserialize?: {
81
88
  body: boolean;
82
89
  };
83
- }) => middy.MiddyfiedHandler<APIGatewayProxyEvent, APIGatewayProxyResult, Error, Context>;
90
+ }, context?: ContextAwsLambdaServer) => middy.MiddyfiedHandler<APIGatewayProxyEvent, APIGatewayProxyResult, Error, Context>;
@@ -10,6 +10,7 @@ const http_response_serializer_1 = __importDefault(require("@middy/http-response
10
10
  const http_security_headers_1 = __importDefault(require("@middy/http-security-headers"));
11
11
  const genConstraintErrorMiddleware_1 = require("../middleware/genConstraintErrorMiddleware");
12
12
  const genInternalServiceErrorMiddleware_1 = require("../middleware/genInternalServiceErrorMiddleware");
13
+ const genIntrospectionMiddleware_1 = require("../middleware/genIntrospectionMiddleware");
13
14
  const genIoLoggerMiddleware_1 = require("../middleware/genIoLoggerMiddleware");
14
15
  const genTrailMiddleware_1 = require("../middleware/genTrailMiddleware");
15
16
  const getValidatedOutput_1 = require("../middleware/getValidatedOutput");
@@ -36,22 +37,22 @@ const serializers = [
36
37
  },
37
38
  ];
38
39
  /**
39
- * .what = generates API Gateway lambda handler with HTTP features
40
- * .why = adds CORS, security headers, error handler, body serialization, and validation
40
+ * .what = generates API Gateway lambda handler with http features
41
+ * .why = adds cors, security headers, error handler, body serialization, and validation
41
42
  *
42
43
  * follows simple-lambda-handlers createApiGatewayHandler pattern:
43
44
  * - uses middy middleware chain
44
45
  * - uses @middy/http-cors for dynamic origin match
45
46
  * - uses @middy/http-security-headers for OWASP security headers
46
- * - uses @middy/http-json-body-parser for JSON body parse
47
+ * - uses @middy/http-json-body-parser for json body parse
47
48
  * - uses @middy/http-response-serializer for response serialization
48
49
  */
49
- const forApiGateway = (config) => {
50
+ const forApiGateway = (config, context) => {
50
51
  const deserialize = config.deserialize ?? { body: true };
51
52
  // build logic wrapper that validates output and invokes user handler
52
- const logic = async (event, context) => {
53
- // get log from context (injected by trail middleware)
54
- const log = context.log;
53
+ const logic = async (event, lambdaContext) => {
54
+ // get log from lambda context (injected by trail middleware)
55
+ const log = lambdaContext.log;
55
56
  // invoke user handler with validated body and raw event
56
57
  const response = await config.invoke({ event: event.body, rawEvent: event }, { log });
57
58
  // validate output and return typed result
@@ -67,12 +68,13 @@ const forApiGateway = (config) => {
67
68
  // middleware order matters:
68
69
  // 1. error handlers (onError) - must be first to catch errors from all other middleware
69
70
  // 2. io logger - logs input/output for debug
70
- // 3. response serializer (onAfter) - serializes response body to JSON
71
+ // 3. response serializer (onAfter) - serializes response body to json
71
72
  // 4. cors (onAfter) - adds cors headers to response
72
73
  // 5. security headers (onAfter) - adds security headers to response
73
74
  // 6. event normalization (onBefore) - normalizes v1/v2 API Gateway events
74
75
  // 7. trail (onBefore) - injects trail context
75
- // 8. body validation (onBefore) - validates event.body against schema
76
+ // 8. introspection (onBefore) - intercepts introspect requests, returns schema
77
+ // 9. body validation (onBefore) - validates event.body against schema
76
78
  const middlewares = [
77
79
  (0, genConstraintErrorMiddleware_1.genConstraintErrorMiddleware)({ apiGateway: true }),
78
80
  (0, genInternalServiceErrorMiddleware_1.genInternalServiceErrorMiddleware)({ apiGateway: true }),
@@ -87,6 +89,11 @@ const forApiGateway = (config) => {
87
89
  }),
88
90
  (0, genApiGatewayEventNormalizationMiddleware_1.genApiGatewayEventNormalizationMiddleware)({ parseBody: deserialize.body }),
89
91
  (0, genTrailMiddleware_1.genTrailMiddleware)(),
92
+ (0, genIntrospectionMiddleware_1.genIntrospectionMiddleware)({
93
+ schema: config.schema,
94
+ env: context?.env,
95
+ apiGateway: true,
96
+ }),
90
97
  (0, genZodBodyValidationMiddleware_1.genZodBodyValidationMiddleware)({ schema: config.schema.input }),
91
98
  ];
92
99
  // note: type assertion needed because middleware transforms:
@@ -1 +1 @@
1
- {"version":3,"file":"genLambdaEndpoint.forApiGateway.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAChC,iEAAwC;AACxC,+FAAqE;AACrE,yFAA+D;AAS/D,6FAA0F;AAC1F,uGAAoG;AAEpG,+EAA4E;AAC5E,yEAAsE;AACtE,yEAAsE;AACtE,sHAGgE;AAChE,gGAA6F;AAyD7F;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,IAAgB,EAAE,EAAE;IACjD,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;QAC9C,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QAC/D,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,4BAA4B;QACrD,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,SAAS;KACxB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB;QACE,KAAK,EAAE,qBAAqB;QAC5B,UAAU,EAAE,CAAC,EAAE,IAAI,EAAqB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAClE;CACF,CAAC;AAEF;;;;;;;;;;GAUG;AACI,MAAM,aAAa,GAAG,CAAkB,MAY9C,EAKC,EAAE;IACF,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAEzD,qEAAqE;IACrE,MAAM,KAAK,GAAG,KAAK,EACjB,KAA6B,EAC7B,OAAgB,EAIf,EAAE;QACH,sDAAsD;QACtD,MAAM,GAAG,GAAI,OAAsC,CAAC,GAAG,CAAC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AAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;KAChE,CAAC;IAEF,6DAA6D;IAC7D,yEAAyE;IACzE,wEAAwE;IACxE,4EAA4E;IAC5E,OAAO,IAAA,cAAK,EACV,KAGmC,CACpC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACrB,CAAC,CAAC;AArFW,QAAA,aAAa,iBAqFxB"}
1
+ {"version":3,"file":"genLambdaEndpoint.forApiGateway.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAChC,iEAAwC;AACxC,+FAAqE;AACrE,yFAA+D;AAU/D,6FAA0F;AAC1F,uGAAoG;AACpG,yFAAsF;AAEtF,+EAA4E;AAC5E,yEAAsE;AACtE,yEAAsE;AACtE,sHAGgE;AAChE,gGAA6F;AAgE7F;;;GAGG;AACH,MAAM,qBAAqB,GAAG,CAAC,IAAgB,EAAE,EAAE;IACjD,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;QAC9C,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QAC/D,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,4BAA4B;QACrD,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,SAAS;KACxB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB;QACE,KAAK,EAAE,qBAAqB;QAC5B,UAAU,EAAE,CAAC,EAAE,IAAI,EAAqB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAClE;CACF,CAAC;AAEF;;;;;;;;;;GAUG;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AqB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,IAAA,+BAAmB,EAAC;YAClB,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;SACjC,CAAC;QACF,IAAA,qFAAyC,EAAC,EAAE,SAAS,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAC1E,IAAA,uCAAkB,GAAE;QACpB,IAAA,uDAA0B,EAAC;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,GAAG,EAAE,OAAO,EAAE,GAAG;YACjB,UAAU,EAAE,IAAI;SACjB,CAAC;QACF,IAAA,+DAA8B,EAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;KAChE,CAAC;IAEF,6DAA6D;IAC7D,yEAAyE;IACzE,wEAAwE;IACxE,4EAA4E;IAC5E,OAAO,IAAA,cAAK,EACV,KAGmC,CACpC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACrB,CAAC,CAAC;AA9FW,QAAA,aAAa,iBA8FxB"}
@@ -1,11 +1,11 @@
1
1
  /**
2
- * .what = transforms CORS origins config to header value with dynamic origin match
3
- * .why = HTTP spec only allows ONE origin in Access-Control-Allow-Origin header
2
+ * .what = transforms cors origins config to header value with dynamic origin match
3
+ * .why = http spec only allows ONE origin in Access-Control-Allow-Origin header
4
4
  *
5
5
  * .how = matches request origin against allowed list:
6
6
  * - '*' returns '*' (unless credentials, then echoes request origin)
7
7
  * - string[] checks if request origin in list, echoes that origin if matched
8
- * - no match returns null (no CORS header should be set)
8
+ * - no match returns null (no cors header should be set)
9
9
  */
10
10
  export declare const getCorsOrigin: (input: {
11
11
  origins: string | string[];
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCorsOrigin = void 0;
4
4
  /**
5
- * .what = transforms CORS origins config to header value with dynamic origin match
6
- * .why = HTTP spec only allows ONE origin in Access-Control-Allow-Origin header
5
+ * .what = transforms cors origins config to header value with dynamic origin match
6
+ * .why = http spec only allows ONE origin in Access-Control-Allow-Origin header
7
7
  *
8
8
  * .how = matches request origin against allowed list:
9
9
  * - '*' returns '*' (unless credentials, then echoes request origin)
10
10
  * - string[] checks if request origin in list, echoes that origin if matched
11
- * - no match returns null (no CORS header should be set)
11
+ * - no match returns null (no cors header should be set)
12
12
  */
13
13
  const getCorsOrigin = (input) => {
14
14
  const { origins, requestOrigin, credentials } = input;
@@ -26,14 +26,14 @@ const getCorsOrigin = (input) => {
26
26
  return origins;
27
27
  }
28
28
  // no request origin or no match - return configured origin anyway
29
- // (may cause CORS failure but that's the expected behavior)
29
+ // (may cause cors failure but that's the expected behavior)
30
30
  return origins;
31
31
  }
32
32
  // array of origins: match against request origin
33
33
  if (requestOrigin && origins.includes(requestOrigin)) {
34
34
  return requestOrigin;
35
35
  }
36
- // no match - don't set CORS header (return null, not empty string)
36
+ // no match - don't set cors header (return null, not empty string)
37
37
  // note: if no requestOrigin provided, fall back to first origin for backwards compat
38
38
  if (!requestOrigin && origins.length > 0) {
39
39
  return origins[0];
@@ -1,6 +1,6 @@
1
1
  import type { APIGatewayProxyEventV2 } from 'aws-lambda';
2
2
  /**
3
- * .what = type guard for API Gateway v2 (HTTP API) events
3
+ * .what = type guard for api gateway v2 (http api) events
4
4
  * .why = enables detection of event format for middleware
5
5
  */
6
6
  export declare const getIsV2ApiGatewayEvent: (event: unknown) => event is APIGatewayProxyEventV2;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getIsV2ApiGatewayEvent = void 0;
4
4
  /**
5
- * .what = type guard for API Gateway v2 (HTTP API) events
5
+ * .what = type guard for api gateway v2 (http api) events
6
6
  * .why = enables detection of event format for middleware
7
7
  */
8
8
  const getIsV2ApiGatewayEvent = (event) => {
@@ -4,6 +4,83 @@ exports.genApiGatewayEventNormalizationMiddleware = void 0;
4
4
  const helpful_errors_1 = require("helpful-errors");
5
5
  const getIsV1ApiGatewayEvent_1 = require("../getIsV1ApiGatewayEvent");
6
6
  const getIsV2ApiGatewayEvent_1 = require("../getIsV2ApiGatewayEvent");
7
+ /**
8
+ * .what = parses JSON body string to object
9
+ * .why = API Gateway sends body as string, handlers need object
10
+ */
11
+ const getParsedApiGatewayBody = (input) => {
12
+ if (!input.body)
13
+ return null;
14
+ // decode base64 if needed
15
+ const decoded = input.isBase64Encoded
16
+ ? Buffer.from(input.body, 'base64').toString('utf-8')
17
+ : input.body;
18
+ // parse json or return raw string
19
+ try {
20
+ return JSON.parse(decoded);
21
+ }
22
+ catch {
23
+ return decoded;
24
+ }
25
+ };
26
+ /**
27
+ * .what = convert v2 HTTP API event to unified format
28
+ * .why = isolates transformation logic from orchestrator
29
+ */
30
+ const asUnifiedEventFromV2 = (input) => {
31
+ const body = input.parseBody
32
+ ? getParsedApiGatewayBody({
33
+ body: input.event.body,
34
+ isBase64Encoded: input.event.isBase64Encoded,
35
+ })
36
+ : input.event.body;
37
+ return {
38
+ httpMethod: input.event.requestContext.http.method,
39
+ path: input.event.requestContext.http.path,
40
+ headers: input.event.headers,
41
+ queryStringParameters: input.event.queryStringParameters ?? null,
42
+ pathParameters: input.event.pathParameters ?? null,
43
+ body,
44
+ rawBody: input.event.body ?? null,
45
+ isBase64Encoded: input.event.isBase64Encoded,
46
+ requestContext: {
47
+ requestId: input.event.requestContext.requestId,
48
+ stage: input.event.requestContext.stage,
49
+ domainName: input.event.requestContext.domainName,
50
+ accountId: input.event.requestContext.accountId,
51
+ },
52
+ rawEvent: input.event,
53
+ };
54
+ };
55
+ /**
56
+ * .what = convert v1 REST API event to unified format
57
+ * .why = isolates transformation logic from orchestrator
58
+ */
59
+ const asUnifiedEventFromV1 = (input) => {
60
+ const body = input.parseBody
61
+ ? getParsedApiGatewayBody({
62
+ body: input.event.body,
63
+ isBase64Encoded: input.event.isBase64Encoded,
64
+ })
65
+ : input.event.body;
66
+ return {
67
+ httpMethod: input.event.httpMethod,
68
+ path: input.event.path,
69
+ headers: input.event.headers,
70
+ queryStringParameters: input.event.queryStringParameters ?? null,
71
+ pathParameters: input.event.pathParameters ?? null,
72
+ body,
73
+ rawBody: input.event.body ?? null,
74
+ isBase64Encoded: input.event.isBase64Encoded,
75
+ requestContext: {
76
+ requestId: input.event.requestContext.requestId,
77
+ stage: input.event.requestContext.stage,
78
+ domainName: input.event.requestContext.domainName,
79
+ accountId: input.event.requestContext.accountId,
80
+ },
81
+ rawEvent: input.event,
82
+ };
83
+ };
7
84
  /**
8
85
  * .what = converts v1/v2 API Gateway events to unified format
9
86
  * .why = handlers work with consistent event shape regardless of API type
@@ -11,57 +88,23 @@ const getIsV2ApiGatewayEvent_1 = require("../getIsV2ApiGatewayEvent");
11
88
  const genApiGatewayEventNormalizationMiddleware = (input) => {
12
89
  const before = async (request) => {
13
90
  const rawEvent = request.event;
14
- // detect event version
91
+ // convert v2 HTTP API event to unified format
15
92
  if ((0, getIsV2ApiGatewayEvent_1.getIsV2ApiGatewayEvent)(rawEvent)) {
16
- // v2 (HTTP API) event
17
- const v2Event = rawEvent;
18
- const body = input.parseBody
19
- ? parseBody(v2Event.body, v2Event.isBase64Encoded)
20
- : v2Event.body;
21
- request.event = {
22
- httpMethod: v2Event.requestContext.http.method,
23
- path: v2Event.requestContext.http.path,
24
- headers: v2Event.headers,
25
- queryStringParameters: v2Event.queryStringParameters ?? null,
26
- pathParameters: v2Event.pathParameters ?? null,
27
- body,
28
- rawBody: v2Event.body ?? null,
29
- isBase64Encoded: v2Event.isBase64Encoded,
30
- requestContext: {
31
- requestId: v2Event.requestContext.requestId,
32
- stage: v2Event.requestContext.stage,
33
- domainName: v2Event.requestContext.domainName,
34
- accountId: v2Event.requestContext.accountId,
35
- },
36
- rawEvent,
37
- };
93
+ request.event = asUnifiedEventFromV2({
94
+ event: rawEvent,
95
+ parseBody: input.parseBody,
96
+ });
38
97
  return;
39
98
  }
99
+ // convert v1 REST API event to unified format
40
100
  if ((0, getIsV1ApiGatewayEvent_1.getIsV1ApiGatewayEvent)(rawEvent)) {
41
- // v1 (REST API) event
42
- const v1Event = rawEvent;
43
- const body = input.parseBody
44
- ? parseBody(v1Event.body, v1Event.isBase64Encoded)
45
- : v1Event.body;
46
- request.event = {
47
- httpMethod: v1Event.httpMethod,
48
- path: v1Event.path,
49
- headers: v1Event.headers,
50
- queryStringParameters: v1Event.queryStringParameters ?? null,
51
- pathParameters: v1Event.pathParameters ?? null,
52
- body,
53
- rawBody: v1Event.body ?? null,
54
- isBase64Encoded: v1Event.isBase64Encoded,
55
- requestContext: {
56
- requestId: v1Event.requestContext.requestId,
57
- stage: v1Event.requestContext.stage,
58
- domainName: v1Event.requestContext.domainName,
59
- accountId: v1Event.requestContext.accountId,
60
- },
61
- rawEvent,
62
- };
101
+ request.event = asUnifiedEventFromV1({
102
+ event: rawEvent,
103
+ parseBody: input.parseBody,
104
+ });
63
105
  return;
64
106
  }
107
+ // fail if neither v1 nor v2
65
108
  throw new helpful_errors_1.MalfunctionError('event is neither v1 nor v2 API Gateway event', {
66
109
  rawEvent,
67
110
  });
@@ -69,22 +112,4 @@ const genApiGatewayEventNormalizationMiddleware = (input) => {
69
112
  return { before };
70
113
  };
71
114
  exports.genApiGatewayEventNormalizationMiddleware = genApiGatewayEventNormalizationMiddleware;
72
- /**
73
- * .what = parses JSON body string to object
74
- * .why = API Gateway sends body as string, handlers need object
75
- */
76
- const parseBody = (body, isBase64Encoded) => {
77
- if (!body)
78
- return null;
79
- const decoded = isBase64Encoded
80
- ? Buffer.from(body, 'base64').toString('utf-8')
81
- : body;
82
- try {
83
- return JSON.parse(decoded);
84
- }
85
- catch {
86
- // return raw string if not valid JSON
87
- return decoded;
88
- }
89
- };
90
115
  //# sourceMappingURL=genApiGatewayEventNormalizationMiddleware.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"genApiGatewayEventNormalizationMiddleware.js","sourceRoot":"","sources":["../../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApi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eAAe;QAC7B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/C,CAAC,CAAC,IAAI,CAAC;IAET,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,sCAAsC;QACtC,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC,CAAC"}
1
+ {"version":3,"file":"genApiGatewayEventNormalizationMiddleware.js","sourceRoot":"","sources":["../../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.ts"],"names":[],"mappings":";;;AAEA,mDAAkD;AAElD,sEAAmE;AACnE,sEAAmE;AAwBnE;;;GAGG;AACH,MAAM,uBAAuB,GAAG,CAAC,KAGhC,EAAW,EAAE;IACZ,IAAI,CAAC,KAAK,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAE7B,0BAA0B;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,eAAe;QACnC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;QACrD,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;IAEf,kCAAkC;IAClC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,oBAAoB,GAAG,CAAC,KAG7B,EAA0B,EAAE;IAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS;QAC1B,CAAC,CAAC,uBAAuB,CAAC;YACtB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI;YACtB,eAAe,EAAE,KAAK,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AS,EAAE,KAAK,CAAC,SAAS;aAC3B,CAAoC,CAAC;YACtC,OAAO;QACT,CAAC;QAED,4BAA4B;QAC5B,MAAM,IAAI,iCAAgB,CAAC,8CAA8C,EAAE;YACzE,QAAQ;SACT,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;AAjCW,QAAA,yCAAyC,6CAiCpD"}
@@ -1,7 +1,8 @@
1
1
  import middy from '@middy/core';
2
2
  import type { Context } from 'aws-lambda';
3
- import type { ContextLogTrail, LogMethods } from 'sdk-logs';
3
+ import type { ContextLogTrail } from 'sdk-logs';
4
4
  import type { ZodSchema } from 'zod';
5
+ import type { ContextAwsLambdaServer } from '../../../domain.objects/ContextAwsLambdaServer';
5
6
  import type { IoLogTranslate } from '../middleware/genIoLoggerMiddleware';
6
7
  /**
7
8
  * .what = wrapped payload format: event nested under `event` key with trail
@@ -48,11 +49,10 @@ export type GenLambdaEndpointInput<TInput, TOutput> = {
48
49
  };
49
50
  /**
50
51
  * .what = sdk contract type for genLambdaEndpoint context
51
- * .why = exported for consumer type inference
52
+ * .why = exported for consumer type inference; the shared handler-side context
53
+ * ({ env?: EnvConfig; log? }) reused by genLambdaEndpoint + forApiGateway
52
54
  */
53
- export type GenLambdaEndpointContext = {
54
- log?: LogMethods;
55
- };
55
+ export type GenLambdaEndpointContext = ContextAwsLambdaServer;
56
56
  /**
57
57
  * .what = generates a lambda handler with validation and trail context
58
58
  * .why = standardizes handler creation with schema validation and observability
@@ -68,13 +68,11 @@ export type GenLambdaEndpointContext = {
68
68
  * - trail middleware injects log with trail context
69
69
  * - output validation via zod schema
70
70
  */
71
- export declare const genLambdaEndpoint: <TInput, TOutput>(config: {
71
+ export declare const genLambdaEndpoint: <TInput, TOutput>(input: {
72
72
  schema: {
73
73
  input: ZodSchema<TInput>;
74
74
  output: ZodSchema<TOutput>;
75
75
  };
76
76
  invoke: EndpointOperation<TInput, TOutput>;
77
77
  logTranslate?: IoLogTranslate;
78
- }, _genContext?: {
79
- log?: LogMethods;
80
- }) => middy.MiddyfiedHandler<LambdaHandlerInput<TInput>, TOutput, Error, Context>;
78
+ }, context?: ContextAwsLambdaServer) => middy.MiddyfiedHandler<LambdaHandlerInput<TInput>, TOutput, Error, Context>;