sdk-aws-lambda 0.4.2 → 0.5.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 (161) 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.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts +9 -7
  42. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +1 -1
  43. package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.d.ts +6 -19
  44. package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js +6 -1
  45. package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js.map +1 -1
  46. package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.d.ts +1 -1
  47. package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.js +1 -1
  48. package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.js.map +1 -1
  49. package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js +16 -35
  50. package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js.map +1 -1
  51. package/dist/domain.operations/lambdaEndpointWire/context/getExidFromContext.js.map +1 -0
  52. package/dist/domain.operations/lambdaEndpointWire/context/getLogForExidExtraction.js.map +1 -0
  53. package/dist/domain.operations/lambdaEndpointWire/context/getOneTrailExid.d.ts +36 -0
  54. package/dist/domain.operations/lambdaEndpointWire/context/getOneTrailExid.js +53 -0
  55. package/dist/domain.operations/lambdaEndpointWire/context/getOneTrailExid.js.map +1 -0
  56. package/dist/domain.operations/lambdaEndpointWire/error/getIsContempErrorTagged.d.ts +1 -0
  57. package/dist/domain.operations/lambdaEndpointWire/error/getIsContempErrorTagged.js +32 -0
  58. package/dist/domain.operations/lambdaEndpointWire/error/getIsContempErrorTagged.js.map +1 -0
  59. package/dist/domain.operations/lambdaEndpointWire/error/getIsLambdaErrorResponse.d.ts +63 -0
  60. package/dist/domain.operations/lambdaEndpointWire/error/getIsLambdaErrorResponse.js +39 -0
  61. package/dist/domain.operations/lambdaEndpointWire/error/getIsLambdaErrorResponse.js.map +1 -0
  62. package/dist/domain.operations/lambdaEndpointWire/error/getLambdaErrorMetadata.js.map +1 -0
  63. package/dist/domain.operations/lambdaEndpointWire/error/getStackTraceString.js.map +1 -0
  64. package/dist/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.d.ts +54 -0
  65. package/dist/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.js +107 -0
  66. package/dist/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.js.map +1 -0
  67. package/dist/domain.operations/{genLambdaEndpoint/middleware → lambdaEndpointWire/frame}/getIsWrappedPayload.d.ts +6 -0
  68. package/dist/domain.operations/lambdaEndpointWire/frame/getIsWrappedPayload.js.map +1 -0
  69. package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.d.ts +45 -0
  70. package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js +173 -0
  71. package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js.map +1 -0
  72. package/dist/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.d.ts +21 -0
  73. package/dist/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.js +33 -0
  74. package/dist/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.js.map +1 -0
  75. package/dist/domain.operations/lambdaEndpointWire/serde/getDecodedPayload.js.map +1 -0
  76. package/dist/domain.operations/lambdaEndpointWire/serde/getParsedJson.js.map +1 -0
  77. package/dist/domain.operations/runLambdaEndpoint/context/asLambdaContext.d.ts +24 -0
  78. package/dist/domain.operations/runLambdaEndpoint/context/asLambdaContext.js +70 -0
  79. package/dist/domain.operations/runLambdaEndpoint/context/asLambdaContext.js.map +1 -0
  80. package/dist/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.d.ts +67 -0
  81. package/dist/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.js +3 -0
  82. package/dist/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.js.map +1 -0
  83. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.d.ts +26 -0
  84. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.js +43 -0
  85. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.js.map +1 -0
  86. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.d.ts +47 -0
  87. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.js +89 -0
  88. package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.js.map +1 -0
  89. package/dist/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.d.ts +73 -0
  90. package/dist/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.js +108 -0
  91. package/dist/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.js.map +1 -0
  92. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.d.ts +50 -0
  93. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js +55 -0
  94. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js.map +1 -0
  95. package/dist/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.d.ts +56 -0
  96. package/dist/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.js +57 -0
  97. package/dist/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.js.map +1 -0
  98. package/dist/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.d.ts +16 -0
  99. package/dist/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.js +71 -0
  100. package/dist/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.js.map +1 -0
  101. package/dist/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.d.ts +48 -0
  102. package/dist/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.js +57 -0
  103. package/dist/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.js.map +1 -0
  104. package/dist/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.d.ts +18 -0
  105. package/dist/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.js +239 -0
  106. package/dist/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.js.map +1 -0
  107. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.d.ts +82 -0
  108. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.js +67 -0
  109. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.js.map +1 -0
  110. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.d.ts +120 -0
  111. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js +119 -0
  112. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js.map +1 -0
  113. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.d.ts +98 -0
  114. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js +176 -0
  115. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js.map +1 -0
  116. package/dist/domain.operations/runLambdaEndpoint/serde/asFramedPayload.d.ts +41 -0
  117. package/dist/domain.operations/runLambdaEndpoint/serde/asFramedPayload.js +62 -0
  118. package/dist/domain.operations/runLambdaEndpoint/serde/asFramedPayload.js.map +1 -0
  119. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.d.ts +40 -0
  120. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js +68 -0
  121. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js.map +1 -0
  122. package/dist/domain.operations/runLambdaEndpoint/serde/asWirePayload.d.ts +34 -0
  123. package/dist/domain.operations/runLambdaEndpoint/serde/asWirePayload.js +39 -0
  124. package/dist/domain.operations/runLambdaEndpoint/serde/asWirePayload.js.map +1 -0
  125. package/dist/domain.operations/runLambdaEndpoint/serde/asWireStripped.d.ts +25 -0
  126. package/dist/domain.operations/runLambdaEndpoint/serde/asWireStripped.js +85 -0
  127. package/dist/domain.operations/runLambdaEndpoint/serde/asWireStripped.js.map +1 -0
  128. package/dist/index.d.ts +9 -0
  129. package/dist/index.js +25 -1
  130. package/dist/index.js.map +1 -1
  131. package/package.json +2 -1
  132. package/readme.md +108 -49
  133. package/dist/domain.operations/askLambdaEndpoint/context/getExidFromContext.js.map +0 -1
  134. package/dist/domain.operations/askLambdaEndpoint/context/getLogForExidExtraction.js.map +0 -1
  135. package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.d.ts +0 -42
  136. package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.js +0 -21
  137. package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.js.map +0 -1
  138. package/dist/domain.operations/askLambdaEndpoint/error/getLambdaErrorMetadata.js.map +0 -1
  139. package/dist/domain.operations/askLambdaEndpoint/error/getStackTraceString.js.map +0 -1
  140. package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.d.ts +0 -13
  141. package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js +0 -26
  142. package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js.map +0 -1
  143. package/dist/domain.operations/askLambdaEndpoint/serde/getDecodedPayload.js.map +0 -1
  144. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedJson.js.map +0 -1
  145. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.d.ts +0 -15
  146. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js +0 -100
  147. package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js.map +0 -1
  148. package/dist/domain.operations/genLambdaEndpoint/middleware/getIsWrappedPayload.js.map +0 -1
  149. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getExidFromContext.d.ts +0 -0
  150. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getExidFromContext.js +0 -0
  151. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getLogForExidExtraction.d.ts +0 -0
  152. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getLogForExidExtraction.js +0 -0
  153. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getLambdaErrorMetadata.d.ts +0 -0
  154. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getLambdaErrorMetadata.js +0 -0
  155. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getStackTraceString.d.ts +0 -0
  156. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getStackTraceString.js +0 -0
  157. /package/dist/domain.operations/{genLambdaEndpoint/middleware → lambdaEndpointWire/frame}/getIsWrappedPayload.js +0 -0
  158. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getDecodedPayload.d.ts +0 -0
  159. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getDecodedPayload.js +0 -0
  160. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getParsedJson.d.ts +0 -0
  161. /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getParsedJson.js +0 -0
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertEventIsGiven = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = refuses an absent event, with an error that names the fix
7
+ * .why = both boundaries need this guard, and each needs it AHEAD of any
8
+ * delegation — so the two call sites stay, and only the TEXT is lifted.
9
+ *
10
+ * ⇒ the placement rule and its cause: `serde/asWireFunctionErrorPayload.ts`,
11
+ * section *"what this DROPS"*. it is the canonical account; this file
12
+ * states only what it MEASURED.
13
+ *
14
+ * ## ✅ this guard's own probe — and the two loci fail DIFFERENTLY
15
+ *
16
+ * measured by a probe that disabled the serialized guard and left the referenced
17
+ * twin in place, so the twin was the only guard that could have answered:
18
+ *
19
+ * | locus | with only the twin's guard |
20
+ * |---|---|
21
+ * | `'cloud'` | never reaches the twin — `JSON.stringify` DROPS an `undefined` key, and the fault surfaces **90s away, in aws** (case=9) |
22
+ * | `'local'` | the message crossed, and `metadata.hint` came back **`""`** |
23
+ *
24
+ * ⇒ so the delegated guard would answer one locus late and the other locus
25
+ * stripped of the one field that names the fix.
26
+ *
27
+ * ## 🔴 why the EXTRACTION, given the two call sites are deliberate
28
+ *
29
+ * ⚠️ **the duplication that stays and the duplication that goes are different
30
+ * duplications, and a review that conflates them reaches the wrong verdict.**
31
+ *
32
+ * | what is duplicated | verdict |
33
+ * |---|---|
34
+ * | the guard's **placement** — one per boundary, ahead of delegation | ✅ **deliberate**, and measured above. it stays |
35
+ * | the guard's **message and hint text**, byte-for-byte in two files | 🔴 a drift hazard. it goes |
36
+ *
37
+ * ⇒ so this operation changes no control flow at all: each boundary refuses
38
+ * its own absent event, at the same line, before any `.catch` exists. what
39
+ * is shared is the one fact the two had in common — the words.
40
+ *
41
+ * ⇒ **so the third guard this family grows is correct on both boundaries by
42
+ * construction**: it states its text once here, and each boundary keeps its own
43
+ * placement. `guard/assertHandlerIsRunnable.ts` is the peer that follows the
44
+ * same shape.
45
+ */
46
+ const assertEventIsGiven = (input) => {
47
+ // .note = no `return` prefix, unlike the call sites this was extracted from.
48
+ // `ConstraintError.throw` answers `never` and this operation answers `void`,
49
+ // so `return ConstraintError.throw(…)` trips `lint/correctness/noVoidTypeReturn`.
50
+ if (input.event === undefined)
51
+ helpful_errors_1.ConstraintError.throw('no event was given, so there is no payload to send the endpoint', {
52
+ ...(input.metadata ?? {}),
53
+ hint: 'pass `event: {}` if the endpoint genuinely takes no input — that is what the wire delivers for an empty invoke. an `undefined` here is usually a typo in the variable you meant to pass.',
54
+ });
55
+ };
56
+ exports.assertEventIsGiven = assertEventIsGiven;
57
+ //# sourceMappingURL=assertEventIsGiven.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertEventIsGiven.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAclC,EAAQ,EAAE;IACT,6EAA6E;IAC7E,+EAA+E;IAC/E,oFAAoF;IACpF,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAC3B,gCAAe,CAAC,KAAK,CACnB,iEAAiE,EACjE;YACE,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;YACzB,IAAI,EAAE,0LAA0L;SACjM,CACF,CAAC;AACN,CAAC,CAAC;AA1BW,QAAA,kBAAkB,sBA0B7B"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * .what = refuses a handler this util cannot run, with an error that names the fix
3
+ * .why = both boundaries need these guards AHEAD of any delegation, so they live
4
+ * in one shared operation with two call sites.
5
+ *
6
+ * 🔴 placement is the whole repair, and it is measured. with this removed from
7
+ * `onSerialized` the same guard fires INSIDE the delegation and
8
+ * `asWireFunctionErrorPayload` washes its metadata — same `ConstraintError`,
9
+ * and `metadata.hint` is gone.
10
+ *
11
+ * ⚠️ a duplicate ahead of the delegation would repair the probed caller and leave
12
+ * every other hint-bearer washed. see `serde/asWireFunctionErrorPayload.ts`.
13
+ */
14
+ export declare const assertHandlerIsRunnable: (input: {
15
+ handler: unknown;
16
+ }) => void;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertHandlerIsRunnable = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = refuses a handler this util cannot run, with an error that names the fix
7
+ * .why = both boundaries need these guards AHEAD of any delegation, so they live
8
+ * in one shared operation with two call sites.
9
+ *
10
+ * 🔴 placement is the whole repair, and it is measured. with this removed from
11
+ * `onSerialized` the same guard fires INSIDE the delegation and
12
+ * `asWireFunctionErrorPayload` washes its metadata — same `ConstraintError`,
13
+ * and `metadata.hint` is gone.
14
+ *
15
+ * ⚠️ a duplicate ahead of the delegation would repair the probed caller and leave
16
+ * every other hint-bearer washed. see `serde/asWireFunctionErrorPayload.ts`.
17
+ */
18
+ const assertHandlerIsRunnable = (input) => {
19
+ // 🔴 the likeliest migrant slip is the IMPORT: a wrong export name binds
20
+ // `handler` to `undefined`, and `input.handler(…)` throws a bare
21
+ // `TypeError: input.handler is not a function` — which names neither this
22
+ // util nor the fix (rule.require.errors-name-the-fix).
23
+ //
24
+ // .note = typescript types `handler` as a function at the referenced boundary,
25
+ // so this reads redundant there. a test file is routinely `any`-typed at the
26
+ // import, and this is the external boundary.
27
+ //
28
+ // .note = no `return` prefix — `ConstraintError.throw` answers `never` and this
29
+ // answers `void`, which trips `lint/correctness/noVoidTypeReturn`.
30
+ if (typeof input.handler !== 'function')
31
+ helpful_errors_1.ConstraintError.throw('the handler given is not a function, so there is no endpoint to run', {
32
+ received: input.handler === undefined ? 'undefined' : typeof input.handler,
33
+ hint: 'check the import — a wrong export name binds `handler` to undefined. `runLambdaEndpoint.onReferenced` takes the handler itself, never its module.',
34
+ });
35
+ // 🔴 a CALLBACK-style handler is refused by ARITY, because its failure is
36
+ // otherwise SILENT. it answers `undefined` rather than a promise, so the
37
+ // author gets `undefined` back on a green path and the handler's later
38
+ // `callback(err, result)` throws OUT OF BAND with no test to fail —
39
+ // rule.forbid.failhide at the boundary.
40
+ //
41
+ // measured by a probe that disabled this guard:
42
+ //
43
+ // | the handler | without this guard |
44
+ // |---|---|
45
+ // | calls `callback(…)` synchronously | `TypeError: callback is not a function` |
46
+ // | calls it later, or not at all | 🔴 no error at all — `undefined`, green |
47
+ //
48
+ // the second is the shape a REAL callback handler takes, so the common case
49
+ // is the silent one.
50
+ //
51
+ // .note = the false positive is a promise handler that declares an unused third
52
+ // parameter. measured across `ahbode/*`: 1 match, in a research doc, never a
53
+ // handler — every handler in the population is middy-wrapped. the hint names
54
+ // the escape rather than assume it cannot happen.
55
+ //
56
+ // 🔴 .the MIRROR false negative is real: `Function.prototype.length` counts
57
+ // parameters before the first rest, so `(...args) => handler(...args)`
58
+ // reports 0 whatever it wraps — the shape `rule.require.hook-wrapper-pattern`
59
+ // composes with. a thenable check cannot fix it either: a SYNC handler answers
60
+ // a non-thenable exactly as a callback handler does. clamped as a known limit
61
+ // (`assertHandlerIsRunnable.knownLimit.test.ts`).
62
+ //
63
+ // ⇒ this guard is a NET, never a proof.
64
+ if (input.handler.length >= 3)
65
+ helpful_errors_1.ConstraintError.throw('the handler given is callback-style, and this util runs handlers that answer with a promise', {
66
+ declaredParameters: input.handler.length,
67
+ hint: 'answer with a promise instead of a callback — `async (event, context) => …`. if your handler already answers with a promise and merely declares an unused third parameter, drop it from the signature.',
68
+ });
69
+ };
70
+ exports.assertHandlerIsRunnable = assertHandlerIsRunnable;
71
+ //# sourceMappingURL=assertHandlerIsRunnable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertHandlerIsRunnable.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;;;;;;;;;GAYG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAA2B,EAAQ,EAAE;IAC3E,yEAAyE;IACzE,oEAAoE;IACpE,6EAA6E;IAC7E,0DAA0D;IAC1D,EAAE;IACF,gFAAgF;IAChF,gFAAgF;IAChF,gDAAgD;IAChD,EAAE;IACF,iFAAiF;IACjF,sEAAsE;IACtE,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU;QACrC,gCAAe,CAAC,KAAK,CACnB,qEAAqE,EACrE;YACE,QAAQ,EACN,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,OAAO;YAClE,IAAI,EAAE,mJAAmJ;SAC1J,CACF,CAAC;IAEJ,0EAA0E;IAC1E,4EAA4E;IAC5E,0EAA0E;IAC1E,uEAAuE;IACvE,2CAA2C;IAC3C,EAAE;IACF,mDAAmD;IACnD,EAAE;IACF,0CAA0C;IAC1C,eAAe;IACf,qFAAqF;IACrF,iFAAiF;IACjF,EAAE;IACF,+EAA+E;IAC/E,wBAAwB;IACxB,EAAE;IACF,gFAAgF;IAChF,+EAA+E;IAC/E,+EAA+E;IAC/E,oDAAoD;IACpD,EAAE;IACF,4EAA4E;IAC5E,0EAA0E;IAC1E,iFAAiF;IACjF,kFAAkF;IAClF,iFAAiF;IACjF,qDAAqD;IACrD,EAAE;IACF,2CAA2C;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC;QAC3B,gCAAe,CAAC,KAAK,CACnB,6FAA6F,EAC7F;YACE,kBAAkB,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM;YACxC,IAAI,EAAE,wMAAwM;SAC/M,CACF,CAAC;AACN,CAAC,CAAC;AA3DW,QAAA,uBAAuB,2BA2DlC"}
@@ -0,0 +1,48 @@
1
+ import type { Context } from 'aws-lambda';
2
+ import type { LambdaEndpoint } from '../../../domain.objects/LambdaEndpoint';
3
+ /**
4
+ * .what = casts an endpoint into the runtime identity aws would have supplied
5
+ * .why = the local locus must answer the same `context.functionName` the cloud
6
+ * locus does, or a handler that branches on it takes the wrong branch in
7
+ * every ci pipeline
8
+ *
9
+ * 🔴 **the identity is DERIVED from the endpoint, never defaulted.**
10
+ *
11
+ * `context.functionName` is, per `define.lambda-endpoint-ubiqlang`, the
12
+ * endpoint's **slug** — so aws delivers `svc-x-test-getY` at `at: 'cloud'`.
13
+ * supply no identity at the local locus and `asLambdaContext()` falls back to
14
+ * its own placeholder, so one call answers two identities:
15
+ *
16
+ * | locus | `context.functionName` the handler would see |
17
+ * |---|---|
18
+ * | `'cloud'` | `svc-x-test-getY` — the slug |
19
+ * | `'local'` | `run-lambda-endpoint` — a default |
20
+ *
21
+ * ⇒ and F6 names `functionName` *"the one field a handler can legitimately
22
+ * branch on"*, on measured evidence. so a handler that branches would take the
23
+ * WRONG branch on the locus that runs in every ci pipeline, and the right one
24
+ * only against real aws — the most expensive place to learn it.
25
+ *
26
+ * 🔴 **and it is a DERIVATION, never a knob.** a `context?: Partial<Context>`
27
+ * passthrough on `onSerialized` is declined, and the reason is the boundary's
28
+ * own contract:
29
+ *
30
+ * - `at: 'cloud'` CANNOT honor a context override — aws builds it
31
+ * - ⇒ so the parameter would be a knob one locus silently ignores
32
+ * (`rule.forbid.unexpected-defaults`), on the one operation whose stated
33
+ * guarantee is that *"the locus changes where, never what"*
34
+ *
35
+ * and the override is not needed, because the identity is not the caller's to
36
+ * supply: they already named it in `which` (`rule.require.solve-at-cause`). an
37
+ * author who genuinely wants to forge a context holds the referenced boundary,
38
+ * where the override lives and where no wire can contradict it.
39
+ *
40
+ * .note = the account id is a placeholder, deliberately, and it is the ONE
41
+ * placeholder — `domain.objects/AwsIdentitySynthetic` owns it. a local copy of
42
+ * the region default or of the account here makes this file another
43
+ * independent speaker of one convention.
44
+ */
45
+ export declare const asLocalRunIdentity: (input: {
46
+ endpoint: LambdaEndpoint;
47
+ region: string | undefined;
48
+ }) => Partial<Context>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asLocalRunIdentity = void 0;
4
+ const AwsIdentitySynthetic_1 = require("../../../domain.objects/AwsIdentitySynthetic");
5
+ /**
6
+ * .what = casts an endpoint into the runtime identity aws would have supplied
7
+ * .why = the local locus must answer the same `context.functionName` the cloud
8
+ * locus does, or a handler that branches on it takes the wrong branch in
9
+ * every ci pipeline
10
+ *
11
+ * 🔴 **the identity is DERIVED from the endpoint, never defaulted.**
12
+ *
13
+ * `context.functionName` is, per `define.lambda-endpoint-ubiqlang`, the
14
+ * endpoint's **slug** — so aws delivers `svc-x-test-getY` at `at: 'cloud'`.
15
+ * supply no identity at the local locus and `asLambdaContext()` falls back to
16
+ * its own placeholder, so one call answers two identities:
17
+ *
18
+ * | locus | `context.functionName` the handler would see |
19
+ * |---|---|
20
+ * | `'cloud'` | `svc-x-test-getY` — the slug |
21
+ * | `'local'` | `run-lambda-endpoint` — a default |
22
+ *
23
+ * ⇒ and F6 names `functionName` *"the one field a handler can legitimately
24
+ * branch on"*, on measured evidence. so a handler that branches would take the
25
+ * WRONG branch on the locus that runs in every ci pipeline, and the right one
26
+ * only against real aws — the most expensive place to learn it.
27
+ *
28
+ * 🔴 **and it is a DERIVATION, never a knob.** a `context?: Partial<Context>`
29
+ * passthrough on `onSerialized` is declined, and the reason is the boundary's
30
+ * own contract:
31
+ *
32
+ * - `at: 'cloud'` CANNOT honor a context override — aws builds it
33
+ * - ⇒ so the parameter would be a knob one locus silently ignores
34
+ * (`rule.forbid.unexpected-defaults`), on the one operation whose stated
35
+ * guarantee is that *"the locus changes where, never what"*
36
+ *
37
+ * and the override is not needed, because the identity is not the caller's to
38
+ * supply: they already named it in `which` (`rule.require.solve-at-cause`). an
39
+ * author who genuinely wants to forge a context holds the referenced boundary,
40
+ * where the override lives and where no wire can contradict it.
41
+ *
42
+ * .note = the account id is a placeholder, deliberately, and it is the ONE
43
+ * placeholder — `domain.objects/AwsIdentitySynthetic` owns it. a local copy of
44
+ * the region default or of the account here makes this file another
45
+ * independent speaker of one convention.
46
+ */
47
+ const asLocalRunIdentity = (input) => {
48
+ const region = input.region ?? AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC;
49
+ return {
50
+ functionName: input.endpoint.slug,
51
+ invokedFunctionArn: `arn:aws:lambda:${region}:${AwsIdentitySynthetic_1.AWS_ACCOUNT_SYNTHETIC}:function:${input.endpoint.slug}`,
52
+ logGroupName: `/aws/lambda/${input.endpoint.slug}`,
53
+ logStreamName: input.endpoint.slug,
54
+ };
55
+ };
56
+ exports.asLocalRunIdentity = asLocalRunIdentity;
57
+ //# sourceMappingURL=asLocalRunIdentity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLocalRunIdentity.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.ts"],"names":[],"mappings":";;;AAEA,uFAGsD;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAGlC,EAAoB,EAAE;IACrB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,2CAAoB,CAAC;IAEpD,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;QACjC,kBAAkB,EAAE,kBAAkB,MAAM,IAAI,4CAAqB,aAAa,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE;QACvG,YAAY,EAAE,eAAe,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE;QAClD,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;KACnC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,kBAAkB,sBAY7B"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * .what = looks up the handler function a serverless.yml declares for an endpoint
3
+ * .why = `at: 'local'` addresses the endpoint by SLUG, so the util must find the
4
+ * function the slug names. same mechanism the incumbent uses.
5
+ *
6
+ * 🔴 every failure names the fix — case=10's whole subject. when the lookup fails
7
+ * the incumbent's error blames the HANDLER and the author debugs the wrong
8
+ * file, so each throw below states what was sought, where it looked, and what
9
+ * to do (rule.require.errors-name-the-fix).
10
+ */
11
+ export declare const getOneHandlerFromServerlessYml: (input: {
12
+ service: string;
13
+ function: string;
14
+ /**
15
+ * where to start the search for the project root. cwd by default.
16
+ */
17
+ from?: string;
18
+ }) => Promise<(event: unknown, context: unknown) => Promise<unknown>>;
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getOneHandlerFromServerlessYml = void 0;
27
+ const helpful_errors_1 = require("helpful-errors");
28
+ const node_fs_1 = require("node:fs");
29
+ const node_path_1 = require("node:path");
30
+ const isErrorLike_1 = require("../error/isErrorLike");
31
+ /**
32
+ * .what = finds the project root — the nearest ancestor with a package.json
33
+ * .why = serverless.yml sits beside package.json, and a test runs from an
34
+ * arbitrary cwd
35
+ *
36
+ * .note = DELIBERATE MUTATION ZONE (rule.require.immutable-vars, scoped
37
+ * exception). `at` is a cursor per hop up the ancestor chain — an ascent has no
38
+ * map/reduce form, and the pure alternative costs a frame per directory. the
39
+ * cursor is local; only a string escapes.
40
+ */
41
+ const getOneProjectRoot = (input) => {
42
+ let at = (0, node_path_1.resolve)(input.from);
43
+ for (;;) {
44
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(at, 'package.json')))
45
+ return at;
46
+ const up = (0, node_path_1.dirname)(at);
47
+ if (up === at)
48
+ return helpful_errors_1.ConstraintError.throw('could not find a project root — no package.json in any ancestor', {
49
+ from: input.from,
50
+ // 🔴 the FIRST throw an `at: 'local'` caller is likely to meet, so it
51
+ // owes a next step (`rule.require.errors-name-the-fix`).
52
+ hint: "run from inside the project, or pass `from:` pointing at the directory that holds your package.json — e.g. `{ at: 'local', from: process.cwd() }`",
53
+ });
54
+ at = up;
55
+ }
56
+ };
57
+ /**
58
+ * .what = casts a serverless.yml `handler:` string into its two parts
59
+ * .why = the value reads `path/to/file.exportName`, and the split is a regex with
60
+ * two positional groups — inline, that is decode-friction.
61
+ *
62
+ * .note = answers `null` rather than throws, because the caller's throw carries
63
+ * `pathOfConfig` and the yml key to edit, and none of that is knowable here.
64
+ */
65
+ const asHandlerPathAndExport = (input) => {
66
+ const matched = input.handler?.match(/^([\w\-./]+)\.(\w+)$/);
67
+ if (!matched)
68
+ return null;
69
+ return { pathOfFile: matched[1], nameOfExport: matched[2] };
70
+ };
71
+ /**
72
+ * .what = the parsed serverless.yml, memoized against the FILE'S OWN CONTENT
73
+ * .why = `yaml.parse` is ~78% of this operation's cost. measured on a 6.5 KB yml
74
+ * (40 functions), 1000 runs: parse 8.778 ms/call · root ascent 0.019 · a
75
+ * `readFileSync`, which is what a hit costs instead, 0.010.
76
+ *
77
+ * 🔴 the key is the file's CONTENT, never `(service, function, from)` — that key
78
+ * caches a PATH's content under a LOOKUP's identity, so a consumer who rewrites
79
+ * its serverless.yml mid-process is served a stale parse and goes green on a
80
+ * file that no longer exists (rule.forbid.failhide).
81
+ *
82
+ * an mtime+size key narrows that race and leaves one: a rewrite inside one tick
83
+ * that keeps an identical byte length — a rename to another name of the same
84
+ * length. content removes the class, and costs 0.006 ms over a stat to do it.
85
+ *
86
+ * ✅ only the PARSE is cached. the four throws below re-run every call, because a
87
+ * result-level memo would keep the old error after a repaired serverless.yml.
88
+ *
89
+ * .note = DELIBERATE MUTATION ZONE (rule.require.immutable-vars, scoped
90
+ * exception). module-private, never read by a caller, and it changes only how
91
+ * long the operation takes.
92
+ */
93
+ const parsedConfigByPath = new Map();
94
+ /**
95
+ * .what = looks up the handler function a serverless.yml declares for an endpoint
96
+ * .why = `at: 'local'` addresses the endpoint by SLUG, so the util must find the
97
+ * function the slug names. same mechanism the incumbent uses.
98
+ *
99
+ * 🔴 every failure names the fix — case=10's whole subject. when the lookup fails
100
+ * the incumbent's error blames the HANDLER and the author debugs the wrong
101
+ * file, so each throw below states what was sought, where it looked, and what
102
+ * to do (rule.require.errors-name-the-fix).
103
+ */
104
+ const getOneHandlerFromServerlessYml = async (input) => {
105
+ const root = getOneProjectRoot({ from: input.from ?? process.cwd() });
106
+ const pathOfConfig = (0, node_path_1.join)(root, 'serverless.yml');
107
+ if (!(0, node_fs_1.existsSync)(pathOfConfig))
108
+ return helpful_errors_1.ConstraintError.throw('no serverless.yml found, so a local endpoint cannot be looked up', {
109
+ sought: pathOfConfig,
110
+ projectRoot: root,
111
+ hint: "add a serverless.yml, or run with at: 'cloud' to invoke the deployed function",
112
+ });
113
+ // the file's own content, which is what the memo above keys on
114
+ const raw = (0, node_fs_1.readFileSync)(pathOfConfig, 'utf8');
115
+ const memoed = parsedConfigByPath.get(pathOfConfig);
116
+ const config = memoed && memoed.raw === raw
117
+ ? memoed.config
118
+ : await (async () => {
119
+ /**
120
+ * .what = `yaml` is reached LAZILY, never at module load
121
+ * .why = this file is its only reader and runs on one path
122
+ * (`at: 'local'`, a test-time locus). a static import would put a
123
+ * 670 KB parser in the module graph of every consumer that merely
124
+ * imports the root barrel.
125
+ *
126
+ * 🟡 LOAD time only. `yaml` stays in `dependencies`, so install size is
127
+ * unchanged and a consumer who BUNDLES still gets it. the install
128
+ * half wants an `exports`-map subpath split (F4).
129
+ */
130
+ const { parse: parseYaml } = await Promise.resolve().then(() => __importStar(require('yaml')));
131
+ /**
132
+ * .as = `parseYaml` answers `any`; a yml file has no compile-time shape.
133
+ * every field is declared OPTIONAL, so the cast asserts no key a real
134
+ * file might lack — each is re-checked at runtime.
135
+ * .removal = never. 🟡 a zod parse WOULD remove it, and would collapse
136
+ * the four throws below into one schema error that names none of their
137
+ * fixes — which is case=10's whole subject.
138
+ */
139
+ const fresh = parseYaml(raw);
140
+ parsedConfigByPath.set(pathOfConfig, { raw, config: fresh });
141
+ return fresh;
142
+ })();
143
+ // the slug names a service; a mismatch means the test addresses another repo
144
+ if (config.service !== input.service)
145
+ return helpful_errors_1.ConstraintError.throw('the serverless.yml declares a different service than the endpoint names', {
146
+ declared: config.service,
147
+ addressed: input.service,
148
+ pathOfConfig,
149
+ hint: 'check input.which.service — a local run can only reach endpoints of THIS repo',
150
+ });
151
+ const definition = config.functions?.[input.function];
152
+ if (!definition)
153
+ return helpful_errors_1.ConstraintError.throw('the serverless.yml declares no such function', {
154
+ addressed: input.function,
155
+ declared: Object.keys(config.functions ?? {}),
156
+ pathOfConfig,
157
+ hint: `add serverless.yml#functions.${input.function}, or check it against the declared list`,
158
+ });
159
+ const parts = asHandlerPathAndExport({ handler: definition.handler });
160
+ if (!parts)
161
+ return helpful_errors_1.ConstraintError.throw('the serverless.yml handler is malformed — it must read `path/to/file.exportName`', {
162
+ found: definition.handler,
163
+ addressed: input.function,
164
+ pathOfConfig,
165
+ });
166
+ const pathOfHandler = (0, node_path_1.join)(root, parts.pathOfFile);
167
+ const nameOfExport = parts.nameOfExport;
168
+ const module = await (async () => {
169
+ try {
170
+ /**
171
+ * .as = a dynamic import of a runtime path has no compile-time shape. the
172
+ * value is re-narrowed below by `typeof handler !== 'function'`.
173
+ * .removal = never
174
+ */
175
+ return (await Promise.resolve(`${pathOfHandler}`).then(s => __importStar(require(s))));
176
+ }
177
+ catch (error) {
178
+ /**
179
+ * .what = reads the message by duck-type, never by `instanceof Error`
180
+ * .why = 🔴 `instanceof` fails CROSS-REALM, and a test util runs in exactly
181
+ * the place with two realms — jest executes each module in its own vm
182
+ * context, so an `Error` its resolver constructs is not the test realm's.
183
+ * an `instanceof` guard here rethrows the raw module error before the
184
+ * message check can run. caught by case=10 `[t0]`.
185
+ */
186
+ const message = (0, isErrorLike_1.isErrorLike)(error) ? error.message : '';
187
+ // 🔴 case=10: the incumbent lets this surface as a bare module error, and
188
+ // the author debugs the handler that never loaded. name the real fault.
189
+ if (message.includes('Cannot find module'))
190
+ return helpful_errors_1.ConstraintError.throw('the serverless.yml points at a handler file that does not exist', {
191
+ declared: definition.handler,
192
+ sought: pathOfHandler,
193
+ addressed: input.function,
194
+ pathOfConfig,
195
+ hint: `the handler MOVED or the path is stale — update serverless.yml#functions.${input.function}.handler`,
196
+ });
197
+ // 🔴 any other import failure is the HANDLER'S OWN — a syntax error, a throw
198
+ // at module scope, a bad transitive import — so the original must survive:
199
+ // its message and stack carry the file and line, which IS the fix.
200
+ //
201
+ // ⚠️ a bare rethrow is not good enough either: it answers `SyntaxError:
202
+ // Unexpected token` with no word about WHICH file this util tried to
203
+ // load. `cause` carries both (rule.prefer.helpful-error-wrap).
204
+ //
205
+ // ✅ bite-probed: restore the bare `throw error` and `[case6]` goes red on
206
+ // both halves.
207
+ throw new helpful_errors_1.MalfunctionError('the handler file was found but could not be imported', {
208
+ pathOfHandler,
209
+ declared: definition.handler,
210
+ addressed: input.function,
211
+ pathOfConfig,
212
+ hint: 'the fault is inside the handler module itself — read `cause` below for its own error, which names the file and line. this util found the file exactly where serverless.yml said it would be.',
213
+ // 🔴 `isErrorLike`, never `instanceof Error` — the same cross-realm
214
+ // reason as above. a non-Error throw keeps its context in `thrown`,
215
+ // so nothing is lost whatever the module threw.
216
+ ...((0, isErrorLike_1.isErrorLike)(error) ? { cause: error } : { thrown: error }),
217
+ });
218
+ }
219
+ })();
220
+ const handler = module[nameOfExport];
221
+ if (typeof handler !== 'function')
222
+ return helpful_errors_1.ConstraintError.throw('the handler file exports no such function', {
223
+ sought: nameOfExport,
224
+ found: Object.keys(module),
225
+ pathOfHandler,
226
+ addressed: input.function,
227
+ hint: `export \`${nameOfExport}\` from that file, or update serverless.yml#functions.${input.function}.handler`,
228
+ });
229
+ /**
230
+ * .as = the `typeof` guard narrows to `Function`, which carries no parameter or
231
+ * return type. no runtime check can supply a signature.
232
+ * .why-not-assure = `.assure` throws a generic rejection error; this throw
233
+ * carries `sought`, `found`, `pathOfHandler`, and the exact yml key to edit.
234
+ * .removal = never
235
+ */
236
+ return handler;
237
+ };
238
+ exports.getOneHandlerFromServerlessYml = getOneHandlerFromServerlessYml;
239
+ //# sourceMappingURL=getOneHandlerFromServerlessYml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOneHandlerFromServerlessYml.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAmE;AAEnE,qCAAmD;AACnD,yCAAqE;AACrE,sDAAmD;AAEnD;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG,CAAC,KAAuB,EAAU,EAAE;IAC5D,IAAI,EAAE,GAAG,IAAA,mBAAc,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpC,SAAS,CAAC;QACR,IAAI,IAAA,oBAAU,EAAC,IAAA,gBAAI,EAAC,EAAE,EAAE,cAAc,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC;QACpD,MAAM,EAAE,GAAG,IAAA,mBAAO,EAAC,EAAE,CAAC,CAAC;QACvB,IAAI,EAAE,KAAK,EAAE;YACX,OAAO,gCAAe,CAAC,KAAK,CAC1B,iEAAiE,EACjE;gBACE,IAAI,EAAE,KAAK,CAAC,IAAI;gBAEhB,sEAAsE;gBACtE,4DAA4D;gBAC5D,IAAI,EAAE,mJAAmJ;aAC1J,CACF,CAAC;QACJ,EAAE,GAAG,EAAE,CAAC;IACV,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,sBAAsB,GAAG,CAAC,KAE/B,EAAuD,EAAE;IACxD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC7D,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,CAAC;AAChE,CAAC,CAAC;AAWF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAG/B,CAAC;AAEJ;;;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;;;;;;OAMG;IACH,OAAO,OAAiE,CAAC;AAC3E,CAAC,CAAC;AA7KW,QAAA,8BAA8B,kCA6KzC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * .what = runs a lambda endpoint, on either side of the RUN BOUNDARY
3
+ * .why = to run an endpoint, shapes must cross a boundary into it. they cross one
4
+ * of two ways, and the way they cross is a domain axis
5
+ * (define.lambda-endpoint-run-boundary)
6
+ *
7
+ * | boundary | shapes cross as | you hold |
8
+ * |----------|-----------------|----------|
9
+ * | **serialized** | json over a wire (real or simulated) | the endpoint's **slug** |
10
+ * | **referenced** | live object references, same process | the handler **function** |
11
+ *
12
+ * ```ts
13
+ * runLambdaEndpoint.onSerialized({ which, event, at: 'cloud' | 'local' }, context)
14
+ * runLambdaEndpoint.onReferenced({ handler, event }) // no `at` — none is possible
15
+ * ```
16
+ *
17
+ * ## 🔴 the boundary determines the ERROR STANCE
18
+ *
19
+ * this is the axis's whole value: it is *causal*, so it predicts behavior that a
20
+ * locus axis (cloud vs local) does not.
21
+ *
22
+ * | boundary | a constraint error arrives as | why |
23
+ * |----------|-------------------------------|-----|
24
+ * | **serialized** | a **thrown** error | you addressed the endpoint by slug, so you are a CALLER |
25
+ * | **referenced** | a **returned** envelope | you hold the handler, so you are the HOST |
26
+ *
27
+ * locus does not cleave this. `at: 'local'` and `at: 'cloud'` sit on the **same**
28
+ * side — both throw.
29
+ *
30
+ * ## the matrix — 4 cells, 3 reachable, 1 barred by nature
31
+ *
32
+ * | | **local** | **cloud** |
33
+ * |---|---|---|
34
+ * | **serialized** | ✅ look the slug up, simulate the wire | ✅ the real wire |
35
+ * | **referenced** | ✅ hold the handler, call it | 🚫 **barred** |
36
+ *
37
+ * ⚠️ **`referenced × cloud` is impossible: a function reference cannot cross a
38
+ * process.** to reach a cloud lambda you must name it, and to name it is to
39
+ * serialize.
40
+ *
41
+ * 🔴 **and the bar is UNREPRESENTABLE, by arity** — not documented and policed:
42
+ * `onSerialized` takes `at`, because a slug points either way;
43
+ * `onReferenced` takes **no** `at`, because a reference has one locus only.
44
+ * ⇒ `rule.prefer.prevent-over-correct`, rung 1: make it impossible.
45
+ *
46
+ * ## what it replaces
47
+ *
48
+ * | incumbent | successor |
49
+ * |---|---|
50
+ * | `invokeLambdaForTesting({ …, locally: false })` | `runLambdaEndpoint.onSerialized({ …, at: 'cloud' })` |
51
+ * | `invokeLambdaForTesting({ …, locally: true })` | `runLambdaEndpoint.onSerialized({ …, at: 'local' })` |
52
+ * | `invokeHandlerForTesting({ event, handler })` | `runLambdaEndpoint.onReferenced({ handler, event })` |
53
+ *
54
+ * ⚠️ the incumbent's `locally = false` is a **negative-default boolean** whose
55
+ * name states a locus and hides a stance. the named variants state both
56
+ * (`rule.forbid.ambiguous-labels`).
57
+ */
58
+ export declare const runLambdaEndpoint: {
59
+ onReferenced: <TEvent, TOutput, TDialect extends import("../..").LambdaEndpointDialect = "contemp">(input: {
60
+ event: TEvent;
61
+ handler: import("./runLambdaEndpoint.onReferenced").LambdaEndpointHandlerReferenced<any, TOutput>;
62
+ struct?: {
63
+ payload: TDialect;
64
+ } | undefined;
65
+ trail?: {
66
+ exid?: string | undefined;
67
+ } | null | undefined;
68
+ context?: Partial<import("aws-lambda").Context> | undefined;
69
+ }) => Promise<import("./dialect/LambdaEndpointRunOutput").LambdaEndpointRunOutput<TOutput, TDialect>>;
70
+ onSerialized: <TEvent_1, TOutput_1>(input: {
71
+ which: {
72
+ service: string;
73
+ function: string;
74
+ };
75
+ event: TEvent_1;
76
+ at?: import("./runLambdaEndpoint.onSerialized").LambdaEndpointLocus | undefined;
77
+ struct?: {
78
+ payload: import("../..").LambdaEndpointDialect;
79
+ } | undefined;
80
+ from?: string | undefined;
81
+ }, context: import("../..").ContextAwsLambdaCaller) => Promise<import("./dialect/LambdaEndpointRunOutput").WireDelivered<TOutput_1>>;
82
+ };