sdk-aws-lambda 0.4.1 → 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,67 @@
1
+ import type { LambdaEndpointDialect } from '../../../domain.objects/LambdaEndpointDialect';
2
+ import type { LambdaEndpointErrorResponseBodyAncient, LambdaEndpointErrorResponseBodyContemp } from '../../../domain.objects/LambdaEndpointErrorResponseBody';
3
+ /**
4
+ * .what = the constraint envelope a given dialect returns
5
+ * .why = puts the envelope SHAPE in the return type, so a cross-dialect field
6
+ * access does not compile — rung 1 of rule.prefer.prevent-over-correct, where a
7
+ * runtime reader would be rung 4.
8
+ *
9
+ * 🔴 the BARE `TDialect extends` form is deliberate: it DISTRIBUTES, so
10
+ * `…Envelope<LambdaEndpointDialect>` resolves to `Ancient | Contemp` and
11
+ * `asLambdaEndpointOutput`'s `Exclude` subtracts BOTH arms. wrap either side in
12
+ * a tuple — the usual non-distributive idiom — and it subtracts contemp only,
13
+ * so an ancient run's success narrow still holds the envelope.
14
+ *
15
+ * ⚠️ no runtime test can see that; the predicate reads the VALUE, so the break
16
+ * is purely ergonomic and surfaces first at a consumer's type gate. clamped
17
+ * in `LambdaEndpointRunOutput.test.ts`.
18
+ */
19
+ export type LambdaEndpointErrorEnvelope<TDialect extends LambdaEndpointDialect> = TDialect extends 'ancient' ? LambdaEndpointErrorResponseBodyAncient : LambdaEndpointErrorResponseBodyContemp;
20
+ /**
21
+ * .what = the type a value HAS after it crosses the json wire
22
+ * .why = the util json-strips what a handler returns, so `{ scheduledAt: Date }`
23
+ * yields a `string`. without this type the run output carries the HANDLER's
24
+ * declaration and `out.scheduledAt.toISOString()` compiles, then throws — an
25
+ * unsound public type is the compile-time twin of rule.forbid.failhide.
26
+ *
27
+ * ⚠️ .the BOUND = it models `Date` → iso string, and recurses arrays + objects.
28
+ * it does NOT model the two key-DROP cases (a required key valued `undefined`,
29
+ * a function value), because both need a key-remap that turns the type into an
30
+ * intersection — which then renders in every consumer's error messages.
31
+ */
32
+ export type WireStripped<T> = T extends Date ? string : T extends (infer TItem)[] ? WireStripped<TItem>[] : T extends object ? {
33
+ [K in keyof T]: WireStripped<T[K]>;
34
+ } : T;
35
+ /**
36
+ * .what = the type a value HAS after aws DELIVERS it — the wire strip, plus the
37
+ * one divergence a wire has that an in-process strip does not
38
+ * .why = 🔴 the two boundaries disagree about a VOID handler, and both are right.
39
+ * `onReferenced` is HOST-faithful and answers `undefined` (what the function
40
+ * returned); `onSerialized` is WIRE-faithful and answers `null` (what aws
41
+ * delivers). so one type cannot serve both, and this is the serialized half.
42
+ *
43
+ * 🔴 not an edge case — it is the sqs and sns consumer shape, so a migrant who
44
+ * tests one handler on both boundaries meets it on their first pair of tests.
45
+ *
46
+ * .note = the TUPLE form is deliberate. a bare `T extends void` distributes, so
47
+ * `void | { found }` would map arm-by-arm to `null | { found }` where the wire
48
+ * delivers one or the other. `[T] extends [void]` asks of the whole type.
49
+ */
50
+ export type WireDelivered<T> = [T] extends [void] ? null : WireStripped<T>;
51
+ /**
52
+ * .what = what a run of an endpoint answers: the output, or the constraint envelope
53
+ * .why = a constraint error is RETURNED on the referenced boundary — the lambda
54
+ * succeeded, it just told the caller their request was invalid
55
+ * (invariant.badrequesterror-not-lambda-error). so the union is the honest
56
+ * return type, and a test that expects only `TOutput` gets a compile error.
57
+ *
58
+ * .note = why these live in the operation rather than `domain.objects/` — and the
59
+ * answer differs per type, so a blanket lift would be wrong:
60
+ *
61
+ * | type | why here |
62
+ * |---|---|
63
+ * | `WireStripped` / `WireDelivered` | type-level MAPPERS over one boundary's lossiness. not nouns the domain holds |
64
+ * | `LambdaEndpointRunOutput` | an operation's RETURN CONTRACT (rule.forbid.io-as-domain-objects) |
65
+ * | `LambdaEndpointErrorEnvelope` | 🟡 the one real candidate. its only consumers are the lines below it, so a lift buys naught |
66
+ */
67
+ export type LambdaEndpointRunOutput<TOutput, TDialect extends LambdaEndpointDialect> = WireStripped<TOutput> | LambdaEndpointErrorEnvelope<TDialect>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LambdaEndpointRunOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LambdaEndpointRunOutput.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import type { LambdaEndpointDialect } from '../../../domain.objects/LambdaEndpointDialect';
2
+ /**
3
+ * .what = casts a declared `struct.payload` into a dialect, and refuses any value
4
+ * that is not one
5
+ * .why = the branch that reads the dialect is `if (dialect === 'contemp') … else
6
+ * ancient`, so a typo, a stale config value, or an `as any` call site falls
7
+ * through to ancient — the event goes FLAT, the endpoint answers
8
+ * `{ errorMessage, errorType }`, and the run SUCCEEDS in the wrong dialect while
9
+ * the author's contemp assertions fail for a reason that names neither.
10
+ *
11
+ * ⚠️ the type does not cover a js consumer, an `as any` call site, or a
12
+ * data-driven dialect. a published sdk boundary is validated at runtime or it
13
+ * is not validated (rule.forbid.unexpected-defaults) — the same argument the
14
+ * `at` guard makes on its peer field.
15
+ *
16
+ * .note = a THROW here, and a silent fall to ancient on `askLambdaEndpoint` — the
17
+ * production caller keeps the fall so a live deploy that passes a bad value
18
+ * today does not break (rule.require.contemp-must-self-identify: an
19
+ * unrecognized value is ancient, never contemp). tracked at
20
+ * `.dream/v2026_09_11.repair.one-dialect-two-validation-philosophies.md`.
21
+ *
22
+ * .note = it lives in `dialect/` because BOTH boundaries need it.
23
+ */
24
+ export declare const asLambdaEndpointDialect: (input: {
25
+ declared?: unknown;
26
+ }) => LambdaEndpointDialect;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asLambdaEndpointDialect = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ /**
6
+ * .what = casts a declared `struct.payload` into a dialect, and refuses any value
7
+ * that is not one
8
+ * .why = the branch that reads the dialect is `if (dialect === 'contemp') … else
9
+ * ancient`, so a typo, a stale config value, or an `as any` call site falls
10
+ * through to ancient — the event goes FLAT, the endpoint answers
11
+ * `{ errorMessage, errorType }`, and the run SUCCEEDS in the wrong dialect while
12
+ * the author's contemp assertions fail for a reason that names neither.
13
+ *
14
+ * ⚠️ the type does not cover a js consumer, an `as any` call site, or a
15
+ * data-driven dialect. a published sdk boundary is validated at runtime or it
16
+ * is not validated (rule.forbid.unexpected-defaults) — the same argument the
17
+ * `at` guard makes on its peer field.
18
+ *
19
+ * .note = a THROW here, and a silent fall to ancient on `askLambdaEndpoint` — the
20
+ * production caller keeps the fall so a live deploy that passes a bad value
21
+ * today does not break (rule.require.contemp-must-self-identify: an
22
+ * unrecognized value is ancient, never contemp). tracked at
23
+ * `.dream/v2026_09_11.repair.one-dialect-two-validation-philosophies.md`.
24
+ *
25
+ * .note = it lives in `dialect/` because BOTH boundaries need it.
26
+ */
27
+ const asLambdaEndpointDialect = (input) => {
28
+ // absent is legal, and contemp is the default
29
+ // (rule.require.contemp-contracts-default)
30
+ if (input.declared === undefined || input.declared === null)
31
+ return 'contemp';
32
+ if (input.declared === 'contemp')
33
+ return 'contemp';
34
+ if (input.declared === 'ancient')
35
+ return 'ancient';
36
+ return helpful_errors_1.ConstraintError.throw('the payload dialect given is not one this util can send', {
37
+ declared: input.declared,
38
+ options: ['contemp', 'ancient'],
39
+ hint: "pass `struct: { payload: 'contemp' }` for the `{ event, trail }` wrapper and a `{ error: { class, message } }` envelope, or `struct: { payload: 'ancient' }` for a flat event and an `{ errorMessage, errorType }` envelope. omit `struct` for the 'contemp' default.",
40
+ });
41
+ };
42
+ exports.asLambdaEndpointDialect = asLambdaEndpointDialect;
43
+ //# sourceMappingURL=asLambdaEndpointDialect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaEndpointDialect.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAIjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAEvC,EAAyB,EAAE;IAC1B,8CAA8C;IAC9C,2CAA2C;IAC3C,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAE9E,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACnD,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAEnD,OAAO,gCAAe,CAAC,KAAK,CAC1B,yDAAyD,EACzD;QACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;QAC/B,IAAI,EAAE,uQAAuQ;KAC9Q,CACF,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,uBAAuB,2BAkBlC"}
@@ -0,0 +1,47 @@
1
+ import type { LambdaEndpointDialect } from '../../../domain.objects/LambdaEndpointDialect';
2
+ import type { LambdaEndpointErrorEnvelope } from './LambdaEndpointRunOutput';
3
+ /**
4
+ * .what = asserts a run output IS the handler's output, and narrows it
5
+ * .why = the union refuses a field read on EITHER arm, so the SUCCESS path needs
6
+ * a narrow exactly as the error path does.
7
+ *
8
+ * 🔴 **the SUCCESS arm is not privileged, and it is the majority case.** a reader
9
+ * who knows the error arm needs `asLambdaEndpointErrorEnvelopeContemp` will
10
+ * assume a bare `res.field` works on the other side. it does not — typescript
11
+ * refuses a field that is not on every arm:
12
+ *
13
+ * TS2339: Property 'scheduledAt' does not exist on type
14
+ * 'LambdaEndpointRunOutput<{ scheduledAt: string; }, "contemp">'.
15
+ * Property 'scheduledAt' does not exist on type
16
+ * 'LambdaEndpointErrorResponseBodyContemp'.
17
+ *
18
+ * ⚠️ **and this repo's own suite cannot catch its absence, by construction.** every
19
+ * test here asserts with a WHOLE-OBJECT `toEqual({ … })`, which takes `unknown`
20
+ * and so exercises no field read at all. ⇒ a green suite is no evidence that
21
+ * this narrow exists or works; only a sample run through the type gate is.
22
+ *
23
+ * .note = the dialect needs no declaration here, unlike its error-side twin.
24
+ * `Exclude` distributes over the union and subtracts the envelope arm, so
25
+ * `TRun` survives inference. the asymmetry is a property of `Exclude`, never a
26
+ * design preference — the NAME pair stays symmetric.
27
+ *
28
+ * ✅ **the narrowed type states the outbound strip — fulcrum F13, closed.**
29
+ * `TOutput` is the type the HANDLER declares, and the util JSON-strips what
30
+ * it returns, so the two disagree. `LambdaEndpointRunOutput` carries
31
+ * `WireStripped<TOutput>` rather than `TOutput`, and the narrow inherits it:
32
+ * a handler typed `{ scheduledAt: Date }` narrows to `{ scheduledAt: string }`.
33
+ *
34
+ * const out = asLambdaEndpointOutput(res);
35
+ * out.scheduledAt.toISOString(); // 💥 no longer compiles — TS2339
36
+ *
37
+ * clamped in `advertisedExamples.test.ts` `[case8][t2]` and in
38
+ * `LambdaEndpointRunOutput.test.ts`, which asserts the `Date` → `string`
39
+ * map directly rather than through a run.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const res = await runLambdaEndpoint.onReferenced({ event, handler });
44
+ * expect(asLambdaEndpointOutput(res).scheduledAt).toEqual('2026-09-03T14:00:00.000Z');
45
+ * ```
46
+ */
47
+ export declare const asLambdaEndpointOutput: <TRun>(output: TRun) => Exclude<TRun, LambdaEndpointErrorEnvelope<LambdaEndpointDialect>>;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asLambdaEndpointOutput = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const isLambdaEndpointErrorEnvelope_1 = require("./isLambdaEndpointErrorEnvelope");
6
+ /**
7
+ * .what = the predicate half of the narrow below
8
+ * .why = `asLambdaEndpointOutput` needs a type guard to return from. a consumer
9
+ * needs the assert form only — a bare boolean read on this union serves
10
+ * naught that `!isLambdaEndpointErrorEnvelopeAnyDialect(x)` does not already.
11
+ *
12
+ * 🔴 **it subtracts BOTH dialects' envelopes**, because the success arm is what
13
+ * remains once every constraint envelope is removed — and a run's dialect is
14
+ * not known here (the value carries no dialect; the caller declared one on the
15
+ * call). so it reads the any-dialect guard, which is contemp-tag OR
16
+ * ancient-shape. F22 split the two public narrows by dialect; this private one
17
+ * stays over both, because that is the honest complement of "the output".
18
+ *
19
+ * 🔴 **it is private, so every fact a CONSUMER must hold belongs on the export
20
+ * below.** typescript emits a `.d.ts` entry only for what is exported, and a
21
+ * comment travels with the declaration it annotates — probed against the
22
+ * emitted `.d.ts`, a note parked here reaches no consumer at all.
23
+ */
24
+ const isLambdaEndpointOutput = (output) => !(0, isLambdaEndpointErrorEnvelope_1.isLambdaEndpointErrorEnvelopeAnyDialect)(output);
25
+ /**
26
+ * .what = asserts a run output IS the handler's output, and narrows it
27
+ * .why = the union refuses a field read on EITHER arm, so the SUCCESS path needs
28
+ * a narrow exactly as the error path does.
29
+ *
30
+ * 🔴 **the SUCCESS arm is not privileged, and it is the majority case.** a reader
31
+ * who knows the error arm needs `asLambdaEndpointErrorEnvelopeContemp` will
32
+ * assume a bare `res.field` works on the other side. it does not — typescript
33
+ * refuses a field that is not on every arm:
34
+ *
35
+ * TS2339: Property 'scheduledAt' does not exist on type
36
+ * 'LambdaEndpointRunOutput<{ scheduledAt: string; }, "contemp">'.
37
+ * Property 'scheduledAt' does not exist on type
38
+ * 'LambdaEndpointErrorResponseBodyContemp'.
39
+ *
40
+ * ⚠️ **and this repo's own suite cannot catch its absence, by construction.** every
41
+ * test here asserts with a WHOLE-OBJECT `toEqual({ … })`, which takes `unknown`
42
+ * and so exercises no field read at all. ⇒ a green suite is no evidence that
43
+ * this narrow exists or works; only a sample run through the type gate is.
44
+ *
45
+ * .note = the dialect needs no declaration here, unlike its error-side twin.
46
+ * `Exclude` distributes over the union and subtracts the envelope arm, so
47
+ * `TRun` survives inference. the asymmetry is a property of `Exclude`, never a
48
+ * design preference — the NAME pair stays symmetric.
49
+ *
50
+ * ✅ **the narrowed type states the outbound strip — fulcrum F13, closed.**
51
+ * `TOutput` is the type the HANDLER declares, and the util JSON-strips what
52
+ * it returns, so the two disagree. `LambdaEndpointRunOutput` carries
53
+ * `WireStripped<TOutput>` rather than `TOutput`, and the narrow inherits it:
54
+ * a handler typed `{ scheduledAt: Date }` narrows to `{ scheduledAt: string }`.
55
+ *
56
+ * const out = asLambdaEndpointOutput(res);
57
+ * out.scheduledAt.toISOString(); // 💥 no longer compiles — TS2339
58
+ *
59
+ * clamped in `advertisedExamples.test.ts` `[case8][t2]` and in
60
+ * `LambdaEndpointRunOutput.test.ts`, which asserts the `Date` → `string`
61
+ * map directly rather than through a run.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const res = await runLambdaEndpoint.onReferenced({ event, handler });
66
+ * expect(asLambdaEndpointOutput(res).scheduledAt).toEqual('2026-09-03T14:00:00.000Z');
67
+ * ```
68
+ */
69
+ const asLambdaEndpointOutput = (output) => {
70
+ if (isLambdaEndpointOutput(output))
71
+ return output;
72
+ // 🟡 the hint names the LIKELY cause AND the one case where it is wrong.
73
+ //
74
+ // 🔴 this narrow cannot know the run's declared dialect, so it reads the
75
+ // ANY-dialect guard — `contemp-tag OR ancient-shape`. the ancient arm (a
76
+ // flat `{ errorMessage, errorType }` pair) therefore runs on every call,
77
+ // and a handler whose legitimate SUCCESS output carries those two string
78
+ // keys reads as an envelope on EITHER dialect.
79
+ //
80
+ // ⇒ a confident wrong *"the handler rejected this event"* sends an author to
81
+ // search for a rejection that never happened, so the hint states the
82
+ // ambiguity (`rule.require.errors-name-the-fix`).
83
+ throw new helpful_errors_1.ConstraintError('the endpoint answered with a constraint envelope, never an output', {
84
+ output,
85
+ hint: 'the handler rejected this event. assert on the envelope via asLambdaEndpointErrorEnvelopeContemp (or …Ancient if you declared the ancient dialect), or send an event the schema accepts. — on EITHER dialect, one other cause is possible: this success narrow subtracts both envelope shapes, so the flat { errorMessage: string, errorType: string } pair reads as an envelope even under contemp. if that is your success output shape, read it directly rather than through this narrow.',
86
+ });
87
+ };
88
+ exports.asLambdaEndpointOutput = asLambdaEndpointOutput;
89
+ //# sourceMappingURL=asLambdaEndpointOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asLambdaEndpointOutput.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAGjD,mFAA0F;AAG1F;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,sBAAsB,GAAG,CAC7B,MAAY,EAIZ,EAAE,CAAC,CAAC,IAAA,uEAAuC,EAAC,MAAM,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACI,MAAM,sBAAsB,GAAG,CACpC,MAAY,EACuD,EAAE;IACrE,IAAI,sBAAsB,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAElD,yEAAyE;IACzE,EAAE;IACF,0EAA0E;IAC1E,6EAA6E;IAC7E,6EAA6E;IAC7E,6EAA6E;IAC7E,mDAAmD;IACnD,EAAE;IACF,8EAA8E;IAC9E,wEAAwE;IACxE,qDAAqD;IACrD,MAAM,IAAI,gCAAe,CACvB,mEAAmE,EACnE;QACE,MAAM;QACN,IAAI,EAAE,8dAA8d;KACre,CACF,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,sBAAsB,0BAuBjC"}
@@ -0,0 +1,73 @@
1
+ import type { LambdaEndpointErrorResponseBodyAncient, LambdaEndpointErrorResponseBodyContemp } from '../../../domain.objects/LambdaEndpointErrorResponseBody';
2
+ import type { LambdaEndpointErrorEnvelope } from './LambdaEndpointRunOutput';
3
+ /**
4
+ * .what = narrows a run output to the CONTEMP constraint envelope it may carry
5
+ * .why = the contemp envelope stamps its own codec tag (`…::contemp@$v`) and we
6
+ * author every one, so this narrow is EXACT: carries the tag ⇒ is one; lacks it
7
+ * ⇒ is not. no shape heuristic, no fallback.
8
+ *
9
+ * .note = dialect-fixed on purpose. the caller names the dialect by WHICH function
10
+ * they call, so the tag check and the shape check never run on one value —
11
+ * which is what stops a contemp caller from reading `.error.message` as
12
+ * `undefined` off an ancient value.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const res = await runLambdaEndpoint.onReferenced({ event, handler });
17
+ * if (isLambdaEndpointErrorEnvelopeContemp(res)) res.error.class; // ✅ exact, by the tag
18
+ * ```
19
+ */
20
+ export declare const isLambdaEndpointErrorEnvelopeContemp: (output: unknown) => output is LambdaEndpointErrorResponseBodyContemp;
21
+ /**
22
+ * .what = narrows a run output to the ANCIENT constraint envelope it may carry
23
+ * .why = the ancient wire carries no tag, so this reads the flat
24
+ * `{ errorMessage: string, errorType: string }` pair.
25
+ *
26
+ * ⚠️ a HEURISTIC, inherently — a success output that happens to carry those two
27
+ * string keys is indistinguishable from a rejection, and the ancient dialect
28
+ * has no discriminator to stamp.
29
+ *
30
+ * .note = demands BOTH fields, stricter than the wire's `getIsAncientErrorResponse`
31
+ * (`'errorMessage' in parsed`). this asks *"did MY handler reject?"*; the wire
32
+ * asks *"did the upstream fault, by any route?"* — and aws sends a bare
33
+ * `errorMessage` with no type on a duration-exceeded fault.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const old = await runLambdaEndpoint.onReferenced({ event, handler, struct: { payload: 'ancient' } });
38
+ * if (isLambdaEndpointErrorEnvelopeAncient(old)) old.errorType; // ⚠️ by shape, ambiguous
39
+ * ```
40
+ */
41
+ export declare const isLambdaEndpointErrorEnvelopeAncient: (output: unknown) => output is LambdaEndpointErrorResponseBodyAncient;
42
+ /**
43
+ * .what = is this run output EITHER dialect's constraint envelope?
44
+ * .why = `asLambdaEndpointOutput` subtracts the whole envelope union to leave the
45
+ * handler's output, so it needs both dialects at once. private — a consumer
46
+ * picks a dialect-fixed peer above.
47
+ */
48
+ export declare const isLambdaEndpointErrorEnvelopeAnyDialect: (output: unknown) => output is LambdaEndpointErrorEnvelope<"contemp" | "ancient">;
49
+ /**
50
+ * .what = asserts a run output IS the CONTEMP constraint envelope, and narrows it
51
+ * .why = a test that reads `.error.message` must fail LOUD when the endpoint
52
+ * answered with a success payload — a silent `undefined` teaches naught
53
+ * (rule.require.failfast). `ConstraintError`, because the fault is the caller's.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const envelope = asLambdaEndpointErrorEnvelopeContemp(res);
58
+ * expect(envelope.error.message).toContain('the uuid names no known surfer');
59
+ * ```
60
+ */
61
+ export declare const asLambdaEndpointErrorEnvelopeContemp: (output: unknown) => LambdaEndpointErrorResponseBodyContemp;
62
+ /**
63
+ * .what = asserts a run output IS the ANCIENT constraint envelope, and narrows it
64
+ * .why = for a caller that declared `struct.payload: 'ancient'`. reads the flat
65
+ * shape, so its confidence is the wire's — see the guard above.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const envelope = asLambdaEndpointErrorEnvelopeAncient(old);
70
+ * expect(envelope.errorType).toEqual('BadRequestError');
71
+ * ```
72
+ */
73
+ export declare const asLambdaEndpointErrorEnvelopeAncient: (output: unknown) => LambdaEndpointErrorResponseBodyAncient;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointErrorEnvelopeContemp = exports.isLambdaEndpointErrorEnvelopeAnyDialect = exports.isLambdaEndpointErrorEnvelopeAncient = exports.isLambdaEndpointErrorEnvelopeContemp = void 0;
4
+ const helpful_errors_1 = require("helpful-errors");
5
+ const getIsContempErrorTagged_1 = require("../../lambdaEndpointWire/error/getIsContempErrorTagged");
6
+ /**
7
+ * .what = narrows a run output to the CONTEMP constraint envelope it may carry
8
+ * .why = the contemp envelope stamps its own codec tag (`…::contemp@$v`) and we
9
+ * author every one, so this narrow is EXACT: carries the tag ⇒ is one; lacks it
10
+ * ⇒ is not. no shape heuristic, no fallback.
11
+ *
12
+ * .note = dialect-fixed on purpose. the caller names the dialect by WHICH function
13
+ * they call, so the tag check and the shape check never run on one value —
14
+ * which is what stops a contemp caller from reading `.error.message` as
15
+ * `undefined` off an ancient value.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const res = await runLambdaEndpoint.onReferenced({ event, handler });
20
+ * if (isLambdaEndpointErrorEnvelopeContemp(res)) res.error.class; // ✅ exact, by the tag
21
+ * ```
22
+ */
23
+ const isLambdaEndpointErrorEnvelopeContemp = (output) => (0, getIsContempErrorTagged_1.getIsContempErrorTagged)(output);
24
+ exports.isLambdaEndpointErrorEnvelopeContemp = isLambdaEndpointErrorEnvelopeContemp;
25
+ /**
26
+ * .what = narrows a run output to the ANCIENT constraint envelope it may carry
27
+ * .why = the ancient wire carries no tag, so this reads the flat
28
+ * `{ errorMessage: string, errorType: string }` pair.
29
+ *
30
+ * ⚠️ a HEURISTIC, inherently — a success output that happens to carry those two
31
+ * string keys is indistinguishable from a rejection, and the ancient dialect
32
+ * has no discriminator to stamp.
33
+ *
34
+ * .note = demands BOTH fields, stricter than the wire's `getIsAncientErrorResponse`
35
+ * (`'errorMessage' in parsed`). this asks *"did MY handler reject?"*; the wire
36
+ * asks *"did the upstream fault, by any route?"* — and aws sends a bare
37
+ * `errorMessage` with no type on a duration-exceeded fault.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const old = await runLambdaEndpoint.onReferenced({ event, handler, struct: { payload: 'ancient' } });
42
+ * if (isLambdaEndpointErrorEnvelopeAncient(old)) old.errorType; // ⚠️ by shape, ambiguous
43
+ * ```
44
+ */
45
+ const isLambdaEndpointErrorEnvelopeAncient = (output) => {
46
+ if (typeof output !== 'object' || output === null)
47
+ return false;
48
+ /**
49
+ * .as = the inspection cast every type guard is made of. fields are optional +
50
+ * `unknown`, so it asserts no shape — the check below decides.
51
+ * .removal = never; a `x is T` predicate is rule.forbid.as-cast's own carve-out.
52
+ */
53
+ const ancient = output;
54
+ return (typeof ancient.errorMessage === 'string' &&
55
+ typeof ancient.errorType === 'string');
56
+ };
57
+ exports.isLambdaEndpointErrorEnvelopeAncient = isLambdaEndpointErrorEnvelopeAncient;
58
+ /**
59
+ * .what = is this run output EITHER dialect's constraint envelope?
60
+ * .why = `asLambdaEndpointOutput` subtracts the whole envelope union to leave the
61
+ * handler's output, so it needs both dialects at once. private — a consumer
62
+ * picks a dialect-fixed peer above.
63
+ */
64
+ const isLambdaEndpointErrorEnvelopeAnyDialect = (output) => (0, exports.isLambdaEndpointErrorEnvelopeContemp)(output) ||
65
+ (0, exports.isLambdaEndpointErrorEnvelopeAncient)(output);
66
+ exports.isLambdaEndpointErrorEnvelopeAnyDialect = isLambdaEndpointErrorEnvelopeAnyDialect;
67
+ /**
68
+ * .what = asserts a run output IS the CONTEMP constraint envelope, and narrows it
69
+ * .why = a test that reads `.error.message` must fail LOUD when the endpoint
70
+ * answered with a success payload — a silent `undefined` teaches naught
71
+ * (rule.require.failfast). `ConstraintError`, because the fault is the caller's.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const envelope = asLambdaEndpointErrorEnvelopeContemp(res);
76
+ * expect(envelope.error.message).toContain('the uuid names no known surfer');
77
+ * ```
78
+ */
79
+ const asLambdaEndpointErrorEnvelopeContemp = (output) => {
80
+ if ((0, exports.isLambdaEndpointErrorEnvelopeContemp)(output))
81
+ return output;
82
+ throw new helpful_errors_1.ConstraintError('the endpoint answered with an output, never a contemp constraint envelope', {
83
+ output,
84
+ hint: 'the handler did not reject this event with a contemp envelope. assert on the output shape, send an event the schema refuses, or — if you declared the ancient dialect — use asLambdaEndpointErrorEnvelopeAncient.',
85
+ });
86
+ };
87
+ exports.asLambdaEndpointErrorEnvelopeContemp = asLambdaEndpointErrorEnvelopeContemp;
88
+ /**
89
+ * .what = asserts a run output IS the ANCIENT constraint envelope, and narrows it
90
+ * .why = for a caller that declared `struct.payload: 'ancient'`. reads the flat
91
+ * shape, so its confidence is the wire's — see the guard above.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const envelope = asLambdaEndpointErrorEnvelopeAncient(old);
96
+ * expect(envelope.errorType).toEqual('BadRequestError');
97
+ * ```
98
+ */
99
+ const asLambdaEndpointErrorEnvelopeAncient = (output) => {
100
+ if ((0, exports.isLambdaEndpointErrorEnvelopeAncient)(output))
101
+ return output;
102
+ throw new helpful_errors_1.ConstraintError('the endpoint answered with an output, never an ancient constraint envelope', {
103
+ output,
104
+ hint: 'the handler did not return a flat { errorMessage, errorType } envelope. assert on the output shape, or — if you expected the contemp dialect — use asLambdaEndpointErrorEnvelopeContemp.',
105
+ });
106
+ };
107
+ exports.asLambdaEndpointErrorEnvelopeAncient = asLambdaEndpointErrorEnvelopeAncient;
108
+ //# sourceMappingURL=isLambdaEndpointErrorEnvelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isLambdaEndpointErrorEnvelope.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAMjD,oGAAiG;AAGjG;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,oCAAoC,GAAG,CAClD,MAAe,EACmC,EAAE,CACpD,IAAA,iDAAuB,EAAC,MAAM,CAAC,CAAC;AAHrB,QAAA,oCAAoC,wCAGf;AAElC;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,oCAAoC,GAAG,CAClD,MAAe,EACmC,EAAE;IACpD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAEhE;;;;OAIG;IACH,MAAM,OAAO,GAAG,MAAyD,CAAC;IAC1E,OAAO,CACL,OAAO,OAAO,CAAC,YAAY,KAAK,QAAQ;QACxC,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,CACtC,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,oCAAoC,wCAe/C;AAEF;;;;;GAKG;AACI,MAAM,uCAAuC,GAAG,CACrD,MAAe,EAC+C,EAAE,CAChE,IAAA,4CAAoC,EAAC,MAAM,CAAC;IAC5C,IAAA,4CAAoC,EAAC,MAAM,CAAC,CAAC;AAJlC,QAAA,uCAAuC,2CAIL;AAE/C;;;;;;;;;;;GAWG;AACI,MAAM,oCAAoC,GAAG,CAClD,MAAe,EACyB,EAAE;IAC1C,IAAI,IAAA,4CAAoC,EAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAEhE,MAAM,IAAI,gCAAe,CACvB,2EAA2E,EAC3E;QACE,MAAM;QACN,IAAI,EAAE,mNAAmN;KAC1N,CACF,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,oCAAoC,wCAY/C;AAEF;;;;;;;;;;GAUG;AACI,MAAM,oCAAoC,GAAG,CAClD,MAAe,EACyB,EAAE;IAC1C,IAAI,IAAA,4CAAoC,EAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAEhE,MAAM,IAAI,gCAAe,CACvB,4EAA4E,EAC5E;QACE,MAAM;QACN,IAAI,EAAE,0LAA0L;KACjM,CACF,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,oCAAoC,wCAY/C"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * .what = narrows an `unknown` catch value to an `Error`, by SHAPE rather than
3
+ * by prototype
4
+ * .why = 🔴 `instanceof Error` is unreliable across this util's own boundaries,
5
+ * and the failure is silent.
6
+ *
7
+ * jest runs each module in its own vm context, so an `Error` thrown in
8
+ * one realm fails the prototype check in another. the check does not
9
+ * error — it returns `false`, and every site then degrades to a
10
+ * stringified fallback that drops the constructor name and the stack.
11
+ *
12
+ * 🔴 **this exists because the same duck-type has THREE call sites, and a fork
13
+ * between any two of them is silent.**
14
+ *
15
+ * | site | what it wanted |
16
+ * |---|---|
17
+ * | `runLambdaEndpoint.onSerialized.ts` (`asWireFunctionErrorPayload`) | `message` · `stack` · `constructor.name` |
18
+ * | `serde/asWireStripped.ts` | the whole `Error`, to hang as a `cause` |
19
+ * | `local/getOneHandlerFromServerlessYml.ts` | `message`, to branch on a text match |
20
+ *
21
+ * ⇒ `rule.prefer.wet-over-dry`'s own threshold: 1 usage inline, 2 copy-paste,
22
+ * **3+ consider the abstraction**. it reached three.
23
+ *
24
+ * .note = the risk this prices is a FOURTH site, not duplication:
25
+ *
26
+ * > *"cross-realm boundaries are endemic to this local-locus/jest
27
+ * > architecture, so a 4th is likely … [and] has no canonical pattern to reach
28
+ * > for and will probably write a 4th slightly-different variant."*
29
+ *
30
+ * ✅ **and a fork between copies is measured, not hypothetical.** the three
31
+ * sites above each want a different return: the value cast to `Error`, a
32
+ * fresh `Error`, a bare string with `''` as its fallback. same predicate,
33
+ * three contracts.
34
+ *
35
+ * .note = it is a PREDICATE rather than three getters, and that is what lets one
36
+ * operation serve all three sites: a narrow to `Error` gives each caller the
37
+ * field it wants, typed, with no second import
38
+ * (`rule.require.assure-via-type-checks`, `rule.require.get-set-gen-verbs`'s
39
+ * `is*` prefix).
40
+ *
41
+ * .note = it lives at `runLambdaEndpoint/` rather than higher because all three
42
+ * consumers do (`rule.prefer.most-common-denominator`: lift to the common
43
+ * ancestor of the callers that exist, never past it).
44
+ *
45
+ * ⚠️ **the shape it tests is `.message`, and that is deliberate.** `.stack` is
46
+ * optional on a real `Error` and absent on a plain thrown object; `.name` is
47
+ * present on a bare `{ name }` bag. `.message` as a string is the one field
48
+ * every `Error` carries and few impostors do.
49
+ */
50
+ export declare const isErrorLike: (value: unknown) => value is Error;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isErrorLike = void 0;
4
+ /**
5
+ * .what = narrows an `unknown` catch value to an `Error`, by SHAPE rather than
6
+ * by prototype
7
+ * .why = 🔴 `instanceof Error` is unreliable across this util's own boundaries,
8
+ * and the failure is silent.
9
+ *
10
+ * jest runs each module in its own vm context, so an `Error` thrown in
11
+ * one realm fails the prototype check in another. the check does not
12
+ * error — it returns `false`, and every site then degrades to a
13
+ * stringified fallback that drops the constructor name and the stack.
14
+ *
15
+ * 🔴 **this exists because the same duck-type has THREE call sites, and a fork
16
+ * between any two of them is silent.**
17
+ *
18
+ * | site | what it wanted |
19
+ * |---|---|
20
+ * | `runLambdaEndpoint.onSerialized.ts` (`asWireFunctionErrorPayload`) | `message` · `stack` · `constructor.name` |
21
+ * | `serde/asWireStripped.ts` | the whole `Error`, to hang as a `cause` |
22
+ * | `local/getOneHandlerFromServerlessYml.ts` | `message`, to branch on a text match |
23
+ *
24
+ * ⇒ `rule.prefer.wet-over-dry`'s own threshold: 1 usage inline, 2 copy-paste,
25
+ * **3+ consider the abstraction**. it reached three.
26
+ *
27
+ * .note = the risk this prices is a FOURTH site, not duplication:
28
+ *
29
+ * > *"cross-realm boundaries are endemic to this local-locus/jest
30
+ * > architecture, so a 4th is likely … [and] has no canonical pattern to reach
31
+ * > for and will probably write a 4th slightly-different variant."*
32
+ *
33
+ * ✅ **and a fork between copies is measured, not hypothetical.** the three
34
+ * sites above each want a different return: the value cast to `Error`, a
35
+ * fresh `Error`, a bare string with `''` as its fallback. same predicate,
36
+ * three contracts.
37
+ *
38
+ * .note = it is a PREDICATE rather than three getters, and that is what lets one
39
+ * operation serve all three sites: a narrow to `Error` gives each caller the
40
+ * field it wants, typed, with no second import
41
+ * (`rule.require.assure-via-type-checks`, `rule.require.get-set-gen-verbs`'s
42
+ * `is*` prefix).
43
+ *
44
+ * .note = it lives at `runLambdaEndpoint/` rather than higher because all three
45
+ * consumers do (`rule.prefer.most-common-denominator`: lift to the common
46
+ * ancestor of the callers that exist, never past it).
47
+ *
48
+ * ⚠️ **the shape it tests is `.message`, and that is deliberate.** `.stack` is
49
+ * optional on a real `Error` and absent on a plain thrown object; `.name` is
50
+ * present on a bare `{ name }` bag. `.message` as a string is the one field
51
+ * every `Error` carries and few impostors do.
52
+ */
53
+ const isErrorLike = (value) => typeof value?.message === 'string';
54
+ exports.isErrorLike = isErrorLike;
55
+ //# sourceMappingURL=isErrorLike.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isErrorLike.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/error/isErrorLike.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACI,MAAM,WAAW,GAAG,CAAC,KAAc,EAAkB,EAAE,CAC5D,OAAQ,KAA+B,EAAE,OAAO,KAAK,QAAQ,CAAC;AADnD,QAAA,WAAW,eACwC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * .what = refuses an absent event, with an error that names the fix
3
+ * .why = both boundaries need this guard, and each needs it AHEAD of any
4
+ * delegation — so the two call sites stay, and only the TEXT is lifted.
5
+ *
6
+ * ⇒ the placement rule and its cause: `serde/asWireFunctionErrorPayload.ts`,
7
+ * section *"what this DROPS"*. it is the canonical account; this file
8
+ * states only what it MEASURED.
9
+ *
10
+ * ## ✅ this guard's own probe — and the two loci fail DIFFERENTLY
11
+ *
12
+ * measured by a probe that disabled the serialized guard and left the referenced
13
+ * twin in place, so the twin was the only guard that could have answered:
14
+ *
15
+ * | locus | with only the twin's guard |
16
+ * |---|---|
17
+ * | `'cloud'` | never reaches the twin — `JSON.stringify` DROPS an `undefined` key, and the fault surfaces **90s away, in aws** (case=9) |
18
+ * | `'local'` | the message crossed, and `metadata.hint` came back **`""`** |
19
+ *
20
+ * ⇒ so the delegated guard would answer one locus late and the other locus
21
+ * stripped of the one field that names the fix.
22
+ *
23
+ * ## 🔴 why the EXTRACTION, given the two call sites are deliberate
24
+ *
25
+ * ⚠️ **the duplication that stays and the duplication that goes are different
26
+ * duplications, and a review that conflates them reaches the wrong verdict.**
27
+ *
28
+ * | what is duplicated | verdict |
29
+ * |---|---|
30
+ * | the guard's **placement** — one per boundary, ahead of delegation | ✅ **deliberate**, and measured above. it stays |
31
+ * | the guard's **message and hint text**, byte-for-byte in two files | 🔴 a drift hazard. it goes |
32
+ *
33
+ * ⇒ so this operation changes no control flow at all: each boundary refuses
34
+ * its own absent event, at the same line, before any `.catch` exists. what
35
+ * is shared is the one fact the two had in common — the words.
36
+ *
37
+ * ⇒ **so the third guard this family grows is correct on both boundaries by
38
+ * construction**: it states its text once here, and each boundary keeps its own
39
+ * placement. `guard/assertHandlerIsRunnable.ts` is the peer that follows the
40
+ * same shape.
41
+ */
42
+ export declare const assertEventIsGiven: (input: {
43
+ event: unknown;
44
+ /**
45
+ * .what = the boundary's own context fields, merged into the error's metadata
46
+ * .why = the serialized boundary can name `which` and `at`; the referenced one
47
+ * has neither, and passes `null` rather than an absent key.
48
+ *
49
+ * .note = `| null` rather than optional, deliberately. `rule.forbid.undefined-inputs`
50
+ * grades an optional attribute on an INTERNAL contract a blocker, and scopes
51
+ * its exception to the boundary a human meets. F15 took that exception for the
52
+ * five optionals on this drive's PUBLIC surface; this operation is internal,
53
+ * reached only by the two callers below, so the rule's letter governs it.
54
+ */
55
+ metadata: Record<string, unknown> | null;
56
+ }) => void;