sdk-aws-lambda 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.d.ts +24 -0
  2. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js +24 -0
  3. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js.map +1 -1
  4. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +19 -0
  5. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
  6. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js +7 -7
  7. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js.map +1 -1
  8. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts +28 -3
  9. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js +3 -2
  10. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +1 -1
  11. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js +6 -6
  12. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js.map +1 -1
  13. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.d.ts +1 -1
  14. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js +19 -1
  15. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js.map +1 -1
  16. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.d.ts +0 -4
  17. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js +224 -3
  18. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js.map +1 -1
  19. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.d.ts +12 -4
  20. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js +12 -4
  21. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js.map +1 -1
  22. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.d.ts +22 -0
  23. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js +29 -0
  24. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js.map +1 -0
  25. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.d.ts +35 -0
  26. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js +58 -1
  27. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js.map +1 -1
  28. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.d.ts +1 -0
  29. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js +65 -9
  30. package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js.map +1 -1
  31. package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.d.ts +20 -0
  32. package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.js +31 -2
  33. package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.js.map +1 -1
  34. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js +24 -19
  35. package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js.map +1 -1
  36. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.d.ts +10 -3
  37. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js +10 -3
  38. package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js.map +1 -1
  39. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js +9 -23
  40. package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js.map +1 -1
  41. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js +11 -18
  42. package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js.map +1 -1
  43. package/dist/domain.operations/genServiceSdk/getAllJsonSchemaNodes.d.ts +59 -0
  44. package/dist/domain.operations/genServiceSdk/getAllJsonSchemaNodes.js +87 -0
  45. package/dist/domain.operations/genServiceSdk/getAllJsonSchemaNodes.js.map +1 -0
  46. package/dist/index.d.ts +25 -0
  47. package/dist/index.js +26 -1
  48. package/dist/index.js.map +1 -1
  49. package/package.json +3 -3
  50. package/readme.md +89 -8
@@ -1 +1 @@
1
- {"version":3,"file":"assertAllDomainObjectRefsBind.js","sourceRoot":"","sources":["../../../../src/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.ts"],"names":[],"mappings":";;;AAEA,uHAAoH;AAGpH;;;;;;;;;GASG;AACI,MAAM,6BAA6B,GAAG,CAAC,KAG7C,EAAQ,EAAE;IACT,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAE1C,wEAAwE;IACxE,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACpD,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,C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C,CAAC"}
1
+ {"version":3,"file":"assertAllDomainObjectRefsBind.js","sourceRoot":"","sources":["../../../../src/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.ts"],"names":[],"mappings":";;;AAEA,uHAAoH;AAEpH,oEAAiE;AAEjE;;;;;;;;;GASG;AACI,MAAM,6BAA6B,GAAG,CAAC,KAG7C,EAAQ,EAAE;IACT,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAE1C,wEAAwE;IACxE,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;QACjD,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;YAC9C,KAAK,MAAM,IAAI,IAAI,IAAA,6CAAqB,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;gBACnD,MAAM,GAAG,GAAI,IAA0D,CACrE,qBAAqB,CACtB,CAAC;gBACF,IAAI,GAAG,EAAE,EAAE;oBAAE,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3C,CAAC;IAEL,2EAA2E;IAC3E,MAAM,OAAO,GAAG,CAAC,GAAG,eAAe,CAAC;SACjC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SAChD,IAAI,EAAE,CAAC;IACV,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;QACpB,MAAM,IAAI,2EAAoC,CAC5C,2CAA2C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,kDAAkD,EAC/G;YACE,OAAO;YACP,IAAI,EAAE,6JAA6J;SACpK,CACF,CAAC;AACN,CAAC,CAAC;AA5BW,QAAA,6BAA6B,iCA4BxC"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAllDomainObjectsFromContracts = void 0;
4
4
  const LambdaDomainObjectNotCapturableError_1 = require("../../../domain.objects/LambdaDomainObjectNotCapturableError");
5
+ const getAllJsonSchemaNodes_1 = require("../getAllJsonSchemaNodes");
5
6
  const asDomainObjectPragma_1 = require("./asDomainObjectPragma");
6
7
  /**
7
8
  * .what = collect every domain-object captured across a service's contracts,
@@ -16,23 +17,23 @@ const getAllDomainObjectsFromContracts = (input) => {
16
17
  // collect every dobj contract from every endpoint's input + output schemas
17
18
  const captured = new Map();
18
19
  // walk each endpoint's input and output schema trees
19
- for (const schema of Object.values(input.contracts)) {
20
- collectFromNode({ node: schema.input, captured });
21
- collectFromNode({ node: schema.output, captured });
22
- }
20
+ for (const schema of Object.values(input.contracts))
21
+ for (const root of [schema.input, schema.output])
22
+ for (const node of (0, getAllJsonSchemaNodes_1.getAllJsonSchemaNodes)({ root }))
23
+ captureDomainObjectAt({ node, captured });
23
24
  // return the de-duplicated contracts in stable (name-sorted) order
24
25
  return [...captured.values()].sort((a, b) => a.name.localeCompare(b.name));
25
26
  };
26
27
  exports.getAllDomainObjectsFromContracts = getAllDomainObjectsFromContracts;
27
28
  /**
28
- * .what = recursively walk a json-schema node, collect every `x-domain-object`
29
- * .why = a dobj can appear at any depth (properties, items, $defs, anyOf, etc.)
29
+ * .what = capture ONE node, if it carries an `x-domain-object` pragma
30
+ * .why = the descent that reaches every node is `getAllJsonSchemaNodes`; what is left here
31
+ * is this file's own semantics — the pragma read, the uc.9 guard, and the de-dup.
32
+ * a dobj can appear at any depth (properties, items, $defs, anyOf, etc.), and the
33
+ * walker reaches each without this function aware of the shape it sat in
30
34
  */
31
- const collectFromNode = (input) => {
35
+ const captureDomainObjectAt = (input) => {
32
36
  const { node, captured } = input;
33
- // skip non-object nodes (leaves like strings/booleans/numbers)
34
- if (typeof node !== 'object' || node === null)
35
- return;
36
37
  // capture this node if it carries a domain-object pragma
37
38
  const contract = (0, asDomainObjectPragma_1.asDomainObjectPragma)({ node: node });
38
39
  if (contract) {
@@ -46,14 +47,6 @@ const collectFromNode = (input) => {
46
47
  if (!captured.has(contract.name))
47
48
  captured.set(contract.name, contract);
48
49
  }
49
- // recurse into every child value (arrays + nested objects)
50
- for (const value of Object.values(node)) {
51
- if (Array.isArray(value))
52
- for (const item of value)
53
- collectFromNode({ node: item, captured });
54
- else
55
- collectFromNode({ node: value, captured });
56
- }
57
50
  };
58
51
  /**
59
52
  * .what = decide whether a schema node has an object shape we can reconstruct
@@ -1 +1 @@
1
- {"version":3,"file":"getAllDomainObjectsFromContracts.js","sourceRoot":"","sources":["../../../../src/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.ts"],"names":[],"mappings":";;;AAGA,uHAAoH;AAEpH,iEAA8D;AAE9D;;;;;;;;GAQG;AACI,MAAM,gCAAgC,GAAG,CAAC,KAEhD,EAA0B,EAAE;IAC3B,2EAA2E;IAC3E,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEzD,qDAAqD;IACrD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACpD,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAClD,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,mEAAmE;IACnE,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7E,CAAC,CAAC;AAdW,QAAA,gCAAgC,oCAc3C;AAEF;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC,KAGxB,EAAQ,EAAE;IACT,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAA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AAC,CACnC,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"getAllDomainObjectsFromContracts.js","sourceRoot":"","sources":["../../../../src/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.ts"],"names":[],"mappings":";;;AAGA,uHAAoH;AAEpH,oEAAiE;AACjE,iEAA8D;AAE9D;;;;;;;;GAQG;AACI,MAAM,gCAAgC,GAAG,CAAC,KAEhD,EAA0B,EAAE;IAC3B,2EAA2E;IAC3E,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEzD,qDAAqD;IACrD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;QACjD,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;YAC9C,KAAK,MAAM,IAAI,IAAI,IAAA,6CAAqB,EAAC,EAAE,IAAI,EAAE,CAAC;gBAChD,qBAAqB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEhD,mEAAmE;IACnE,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7E,CAAC,CAAC;AAdW,QAAA,gCAAgC,oCAc3C;AAEF;;;;;;GAMG;AACH,MAAM,qBAAqB,GAAG,CAAC,KAG9B,EAAQ,EAAE;IACT,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEjC,yDAAyD;IACzD,MAAM,QAAQ,GAAG,IAAA,2CAAoB,EAAC,EAAE,IAAI,EAAE,IAAkB,EAAE,CAAC,CAAC;IACpE,IAAI,QAAQ,EAAE,CAAC;QACb,4EAA4E;QAC5E,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;YAC7B,MAAM,IAAI,2EAAoC,CAC5C,kBAAkB,QAAQ,CAAC,IAAI,+EAA+E,EAC9G;gBACE,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,IAAI,EAAE,qGAAqG;aAC5G,CACF,CAAC;QAEJ,sEAAsE;QACtE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAW,EAAE;IACrD,MAAM,UAAU,GAAI,IAAiC,CAAC,UAAU,CAAC;IACjE,OAAO,CACL,OAAO,UAAU,KAAK,QAAQ;QAC9B,UAAU,KAAK,IAAI;QACnB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CACnC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * .what = every object node in a json-schema tree, in pre-order
3
+ * .why = three call sites each hand-rolled this identical recursive descent, which clears
4
+ * `rule.prefer.wet-over-dry`'s rule-of-three by a wide margin. each one wanted the
5
+ * SAME traversal and a DIFFERENT thing per node, so the walk was all they shared
6
+ *
7
+ * .the three it replaces:
8
+ * - `collectRefNames` — `gen.resource/assertAllDomainObjectRefsBind.ts`
9
+ * - `collectFromNode` — `gen.resource/getAllDomainObjectsFromContracts.ts`
10
+ * - `collectRefGenerics` — `gen.mechanism/getTypescriptFromJsonSchema.ts`
11
+ *
12
+ * .why it returns a LIST rather than takes a `visit` callback = a list turns each caller's
13
+ * body into a flat `for` loop it can read in one pass. a callback keeps the inversion
14
+ * of control the hand-rolled recursion already had, so it would have collapsed the
15
+ * duplication and left the decode cost (`rule.forbid.inline-decode-friction`), and
16
+ * its name would have had to start with a verb the repo does not sanction
17
+ * (`rule.require.get-set-gen-verbs`)
18
+ *
19
+ * .why it lives HERE = `gen.resource/` and `gen.mechanism/` are the two consumers, so
20
+ * `genServiceSdk/` is their common ancestor (`rule.prefer.most-common-denominator`).
21
+ * it is not lifted higher: no third subtree asks for it
22
+ *
23
+ * ⚠️ .why PRE-ORDER is part of the contract = one caller
24
+ * (`getAllDomainObjectsFromContracts`) keeps the FIRST capture of a repeated name and
25
+ * throws on the first uncapturable one, so the order a node is met in is observable. a
26
+ * post-order or breadth-first walk would change which duplicate wins and which node the
27
+ * throw names
28
+ *
29
+ * .note = it descends EVERY value of every object, so `properties`, `items`, `$defs`,
30
+ * `anyOf`, and any keyword a future zod emits are all reached with no edit here.
31
+ * that is the property the three hand-rolled copies each had, and each had to keep
32
+ *
33
+ * ⚠️ .why a VISITED set = a graph that cycles by IDENTITY has no base case here, so the
34
+ * descent recurses until the stack blows — a `RangeError` with no diagnostic, at all
35
+ * three consumers at once. the three hand-rolled copies each carried the same hole;
36
+ * one shared walk is what lets ONE guard close it (that correctness fix is the payoff
37
+ * the extraction was argued on, so it belongs here rather than deferred)
38
+ *
39
+ * - today's real inputs are acyclic: `z.toJSONSchema` emits a self-reference as the
40
+ * STRING `'#'`, which is a leaf, so no shipped fixture reaches the guard
41
+ * - ⇒ so this guards against a shape zod does not emit TODAY, and against the
42
+ * hand-built fixture that a caller of this now-shared primitive may hand it
43
+ *
44
+ * ⚠️ .the consequence is WIDER than a cycle, and it is deliberate = the set dedupes by
45
+ * REFERENCE, so a DAG — one object reachable by two distinct paths — is now recorded
46
+ * ONCE rather than twice. measured against all three consumers before it landed:
47
+ *
48
+ * - `assertAllDomainObjectRefsBind` -> `referencedNames.add(ref.of)` — a Set
49
+ * - `getAllDomainObjectsFromContracts` -> a Map keyed by name, first wins — set-like
50
+ * - `getTypescriptFromJsonSchema` -> `used.add(REF_GENERIC_BY[…])` — a Set
51
+ *
52
+ * ⇒ every one accumulates set-semantically by NAME, so a second visit to the SAME
53
+ * object adds no entry any of them can observe. a caller that COUNTED nodes would
54
+ * observe it, and no such caller exists — `[case6]` states the property so a future
55
+ * one meets it as a contract rather than as a surprise
56
+ */
57
+ export declare const getAllJsonSchemaNodes: (input: {
58
+ root: unknown;
59
+ }) => object[];
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAllJsonSchemaNodes = void 0;
4
+ /**
5
+ * .what = every object node in a json-schema tree, in pre-order
6
+ * .why = three call sites each hand-rolled this identical recursive descent, which clears
7
+ * `rule.prefer.wet-over-dry`'s rule-of-three by a wide margin. each one wanted the
8
+ * SAME traversal and a DIFFERENT thing per node, so the walk was all they shared
9
+ *
10
+ * .the three it replaces:
11
+ * - `collectRefNames` — `gen.resource/assertAllDomainObjectRefsBind.ts`
12
+ * - `collectFromNode` — `gen.resource/getAllDomainObjectsFromContracts.ts`
13
+ * - `collectRefGenerics` — `gen.mechanism/getTypescriptFromJsonSchema.ts`
14
+ *
15
+ * .why it returns a LIST rather than takes a `visit` callback = a list turns each caller's
16
+ * body into a flat `for` loop it can read in one pass. a callback keeps the inversion
17
+ * of control the hand-rolled recursion already had, so it would have collapsed the
18
+ * duplication and left the decode cost (`rule.forbid.inline-decode-friction`), and
19
+ * its name would have had to start with a verb the repo does not sanction
20
+ * (`rule.require.get-set-gen-verbs`)
21
+ *
22
+ * .why it lives HERE = `gen.resource/` and `gen.mechanism/` are the two consumers, so
23
+ * `genServiceSdk/` is their common ancestor (`rule.prefer.most-common-denominator`).
24
+ * it is not lifted higher: no third subtree asks for it
25
+ *
26
+ * ⚠️ .why PRE-ORDER is part of the contract = one caller
27
+ * (`getAllDomainObjectsFromContracts`) keeps the FIRST capture of a repeated name and
28
+ * throws on the first uncapturable one, so the order a node is met in is observable. a
29
+ * post-order or breadth-first walk would change which duplicate wins and which node the
30
+ * throw names
31
+ *
32
+ * .note = it descends EVERY value of every object, so `properties`, `items`, `$defs`,
33
+ * `anyOf`, and any keyword a future zod emits are all reached with no edit here.
34
+ * that is the property the three hand-rolled copies each had, and each had to keep
35
+ *
36
+ * ⚠️ .why a VISITED set = a graph that cycles by IDENTITY has no base case here, so the
37
+ * descent recurses until the stack blows — a `RangeError` with no diagnostic, at all
38
+ * three consumers at once. the three hand-rolled copies each carried the same hole;
39
+ * one shared walk is what lets ONE guard close it (that correctness fix is the payoff
40
+ * the extraction was argued on, so it belongs here rather than deferred)
41
+ *
42
+ * - today's real inputs are acyclic: `z.toJSONSchema` emits a self-reference as the
43
+ * STRING `'#'`, which is a leaf, so no shipped fixture reaches the guard
44
+ * - ⇒ so this guards against a shape zod does not emit TODAY, and against the
45
+ * hand-built fixture that a caller of this now-shared primitive may hand it
46
+ *
47
+ * ⚠️ .the consequence is WIDER than a cycle, and it is deliberate = the set dedupes by
48
+ * REFERENCE, so a DAG — one object reachable by two distinct paths — is now recorded
49
+ * ONCE rather than twice. measured against all three consumers before it landed:
50
+ *
51
+ * - `assertAllDomainObjectRefsBind` -> `referencedNames.add(ref.of)` — a Set
52
+ * - `getAllDomainObjectsFromContracts` -> a Map keyed by name, first wins — set-like
53
+ * - `getTypescriptFromJsonSchema` -> `used.add(REF_GENERIC_BY[…])` — a Set
54
+ *
55
+ * ⇒ every one accumulates set-semantically by NAME, so a second visit to the SAME
56
+ * object adds no entry any of them can observe. a caller that COUNTED nodes would
57
+ * observe it, and no such caller exists — `[case6]` states the property so a future
58
+ * one meets it as a contract rather than as a surprise
59
+ */
60
+ const getAllJsonSchemaNodes = (input) => {
61
+ const nodes = [];
62
+ // track nodes already recorded, so a cycle terminates and a DAG is not double-counted
63
+ const visited = new WeakSet();
64
+ const descend = (node) => {
65
+ // skip leaves — a string, a number, a boolean, a null carries no node
66
+ if (typeof node !== 'object' || node === null)
67
+ return;
68
+ // stop at a node already met, so a cycle by identity terminates rather than overflows
69
+ if (visited.has(node))
70
+ return;
71
+ visited.add(node);
72
+ // record this node BEFORE its children, so the list reads in pre-order
73
+ nodes.push(node);
74
+ // descend into every child value, arrays and nested objects alike
75
+ for (const value of Object.values(node)) {
76
+ if (Array.isArray(value))
77
+ for (const item of value)
78
+ descend(item);
79
+ else
80
+ descend(value);
81
+ }
82
+ };
83
+ descend(input.root);
84
+ return nodes;
85
+ };
86
+ exports.getAllJsonSchemaNodes = getAllJsonSchemaNodes;
87
+ //# sourceMappingURL=getAllJsonSchemaNodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllJsonSchemaNodes.js","sourceRoot":"","sources":["../../../src/domain.operations/genServiceSdk/getAllJsonSchemaNodes.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACI,MAAM,qBAAqB,GAAG,CAAC,KAAwB,EAAY,EAAE;IAC1E,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,sFAAsF;IACtF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAU,CAAC;IAEtC,MAAM,OAAO,GAAG,CAAC,IAAa,EAAQ,EAAE;QACtC,sEAAsE;QACtE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO;QAEtD,sFAAsF;QACtF,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO;QAC9B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAElB,uEAAuE;QACvE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjB,kEAAkE;QAClE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,IAA+B,CAAC,EAAE,CAAC;YACnE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,KAAK,MAAM,IAAI,IAAI,KAAK;oBAAE,OAAO,CAAC,IAAI,CAAC,CAAC;;gBAC7D,OAAO,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AA1BW,QAAA,qBAAqB,yBA0BhC"}
package/dist/index.d.ts CHANGED
@@ -67,6 +67,31 @@ export { genZodOutputValidationMiddleware } from './domain.operations/genLambdaE
67
67
  * public boundary (rule.forbid.as-cast)
68
68
  */
69
69
  export type { LambdaEndpointErrorResponseBodyAncient, LambdaEndpointErrorResponseBodyContemp, } from './domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody';
70
+ /**
71
+ * .what = the two ROOT primitives a consumer needs to validate a border in a chain of their own
72
+ * .why = the advanced-use exports above are middlewares, and the one on the OUTPUT side —
73
+ * `genZodOutputValidationMiddleware` — is positionally ambiguous by its own admission
74
+ * (F33). so a consumer who wanted to validate output safely had exactly one public tool,
75
+ * and it was the foot-gun: the atom was hidden and the risky composite was public
76
+ *
77
+ * these two are unambiguous by construction — each takes the value it validates as an
78
+ * argument rather than reads it out of a slot whose type depends on registration order.
79
+ * so a consumer builds their own correctly-ordered step and the ambiguity never reaches it
80
+ *
81
+ * .note = this does NOT settle F33. that fulcrum asks whether the middleware should keep its
82
+ * export at all, and it belongs to the bound that shipped it
83
+ * (`.behavior/v2026_08_03.feat-apigateway-wire-response/`). what this changes is that the
84
+ * ambiguous export is no longer the ONLY option — which is the half that needed no
85
+ * wisher call, because it breaks no consumer (rule.always.fix-forward-under-scouts-honor)
86
+ *
87
+ * .note = each metadata type rides along for the same reason `LambdaEndpointErrorResponseBody*`
88
+ * does — a consumer who catches the throw must be able to NAME what `.metadata` holds,
89
+ * or they reach for an `as`-cast at the public boundary (rule.forbid.as-cast)
90
+ */
91
+ export { getValidatedInput } from './domain.operations/genLambdaEndpoint/middleware/getValidatedInput';
92
+ export { getValidatedOutput, type OutputValidationErrorMetadata, } from './domain.operations/genLambdaEndpoint/middleware/getValidatedOutput';
93
+ export type { ValidationErrorMetadata } from './domain.operations/genLambdaEndpoint/middleware/getValidationError';
94
+ export type { ZodIssueSummary } from './domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary';
70
95
  /**
71
96
  * .note = `TranslateLog` is public because `logTranslate` accepts it, and it replaces the
72
97
  * formerly-public `IoLogTranslate`. its three designed peers — `Translate<TShapes>`,
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * define endpoints, ask endpoints, auto-propagate trace-ids.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.runLambdaEndpoint = exports.isLambdaEndpointErrorEnvelopeContemp = exports.isLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointErrorEnvelopeContemp = exports.asLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointOutput = exports.asLambdaContext = exports.getOneLambdaContract = exports.getAllLambdaFunctionsByPrefix = exports.getAllLambdaContracts = exports.genServiceSdk = exports.genZodOutputValidationMiddleware = exports.genTrailMiddleware = exports.genIoLoggerMiddleware = exports.genIntrospectionMiddleware = exports.genInternalServiceErrorMiddleware = exports.genConstraintErrorMiddleware = exports.asContextTrailed = exports.genZodEventValidationMiddleware = exports.genLambdaEndpoint = exports.genZodBodyValidationMiddleware = exports.genContentTypeCoherenceMiddleware = exports.genApiGatewayEventNormalizationMiddleware = exports.isApiGatewayResponse = exports.forApiGateway = exports.asApiGatewayResponseSchema = exports.asLambdaEvent = exports.asLambdaEndpoint = exports.getAskLambdaCacheKey = exports.asCacheWithoutSet = exports.askLambdaEndpoint = exports.LambdaServiceNotFoundError = exports.LambdaIntrospectionNotSupportedError = exports.LambdaIntrospectionBlockedError = exports.LambdaFunctionNotFoundError = exports.LambdaEndpointError = exports.LambdaEndpoint = exports.LambdaDomainObjectRefUnbindableError = exports.LambdaDomainObjectNotCapturableError = exports.LambdaCredentialsAbsentError = exports.HttpStatusCode = exports.GeneratedFile = exports.delLambdaSdks = exports.BadRequestError = void 0;
8
+ exports.runLambdaEndpoint = exports.isLambdaEndpointErrorEnvelopeContemp = exports.isLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointErrorEnvelopeContemp = exports.asLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointOutput = exports.asLambdaContext = exports.getOneLambdaContract = exports.getAllLambdaFunctionsByPrefix = exports.getAllLambdaContracts = exports.genServiceSdk = exports.getValidatedOutput = exports.getValidatedInput = exports.genZodOutputValidationMiddleware = exports.genTrailMiddleware = exports.genIoLoggerMiddleware = exports.genIntrospectionMiddleware = exports.genInternalServiceErrorMiddleware = exports.genConstraintErrorMiddleware = exports.asContextTrailed = exports.genZodEventValidationMiddleware = exports.genLambdaEndpoint = exports.genZodBodyValidationMiddleware = exports.genContentTypeCoherenceMiddleware = exports.genApiGatewayEventNormalizationMiddleware = exports.isApiGatewayResponse = exports.forApiGateway = exports.asApiGatewayResponseSchema = exports.asLambdaEvent = exports.asLambdaEndpoint = exports.getAskLambdaCacheKey = exports.asCacheWithoutSet = exports.askLambdaEndpoint = exports.LambdaServiceNotFoundError = exports.LambdaIntrospectionNotSupportedError = exports.LambdaIntrospectionBlockedError = exports.LambdaFunctionNotFoundError = exports.LambdaEndpointError = exports.LambdaEndpoint = exports.LambdaDomainObjectRefUnbindableError = exports.LambdaDomainObjectNotCapturableError = exports.LambdaCredentialsAbsentError = exports.HttpStatusCode = exports.GeneratedFile = exports.delLambdaSdks = exports.BadRequestError = void 0;
9
9
  // re-export from helpful-errors for convenience
10
10
  var helpful_errors_1 = require("helpful-errors");
11
11
  Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return helpful_errors_1.BadRequestError; } });
@@ -91,6 +91,31 @@ var genTrailMiddleware_1 = require("./domain.operations/genLambdaEndpoint/middle
91
91
  Object.defineProperty(exports, "genTrailMiddleware", { enumerable: true, get: function () { return genTrailMiddleware_1.genTrailMiddleware; } });
92
92
  var genZodOutputValidationMiddleware_1 = require("./domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware");
93
93
  Object.defineProperty(exports, "genZodOutputValidationMiddleware", { enumerable: true, get: function () { return genZodOutputValidationMiddleware_1.genZodOutputValidationMiddleware; } });
94
+ /**
95
+ * .what = the two ROOT primitives a consumer needs to validate a border in a chain of their own
96
+ * .why = the advanced-use exports above are middlewares, and the one on the OUTPUT side —
97
+ * `genZodOutputValidationMiddleware` — is positionally ambiguous by its own admission
98
+ * (F33). so a consumer who wanted to validate output safely had exactly one public tool,
99
+ * and it was the foot-gun: the atom was hidden and the risky composite was public
100
+ *
101
+ * these two are unambiguous by construction — each takes the value it validates as an
102
+ * argument rather than reads it out of a slot whose type depends on registration order.
103
+ * so a consumer builds their own correctly-ordered step and the ambiguity never reaches it
104
+ *
105
+ * .note = this does NOT settle F33. that fulcrum asks whether the middleware should keep its
106
+ * export at all, and it belongs to the bound that shipped it
107
+ * (`.behavior/v2026_08_03.feat-apigateway-wire-response/`). what this changes is that the
108
+ * ambiguous export is no longer the ONLY option — which is the half that needed no
109
+ * wisher call, because it breaks no consumer (rule.always.fix-forward-under-scouts-honor)
110
+ *
111
+ * .note = each metadata type rides along for the same reason `LambdaEndpointErrorResponseBody*`
112
+ * does — a consumer who catches the throw must be able to NAME what `.metadata` holds,
113
+ * or they reach for an `as`-cast at the public boundary (rule.forbid.as-cast)
114
+ */
115
+ var getValidatedInput_1 = require("./domain.operations/genLambdaEndpoint/middleware/getValidatedInput");
116
+ Object.defineProperty(exports, "getValidatedInput", { enumerable: true, get: function () { return getValidatedInput_1.getValidatedInput; } });
117
+ var getValidatedOutput_1 = require("./domain.operations/genLambdaEndpoint/middleware/getValidatedOutput");
118
+ Object.defineProperty(exports, "getValidatedOutput", { enumerable: true, get: function () { return getValidatedOutput_1.getValidatedOutput; } });
94
119
  // sdk codegen (generate a per-service sdk from introspection)
95
120
  var genServiceSdk_1 = require("./domain.operations/genServiceSdk/genServiceSdk");
96
121
  Object.defineProperty(exports, "genServiceSdk", { enumerable: true, get: function () { return genServiceSdk_1.genServiceSdk; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],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AqB,OAAA;AAC9B,gCAAgC;AAChC,0GAAyG;AAAhG,wHAAA,kBAAkB,OAAA;AAC3B,sIAAqI;AAA5H,oJAAA,gCAAgC,OAAA;AAWzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wGAAuG;AAA9F,sHAAA,iBAAiB,OAAA;AAC1B,0GAG6E;AAF3E,wHAAA,kBAAkB,OAAA;AAcpB,8DAA8D;AAC9D,iFAAgF;AAAvE,8GAAA,aAAa,OAAA;AACtB,0CAA0C;AAC1C,yGAIyE;AADvE,8HAAA,qBAAqB,OAAA;AAEvB,wIAAuI;AAA9H,8IAAA,6BAA6B,OAAA;AACtC,sGAIuE;AADrE,4HAAA,oBAAoB,OAAA;AAEtB,gFAAgF;AAChF,iGAAgG;AAAvF,kHAAA,eAAe,OAAA;AACxB,8EAA8E;AAC9E,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,4CAA4C;AAC5C,+GAA8G;AAArG,gIAAA,sBAAsB,OAAA;AAC/B,iFAAiF;AACjF,gFAAgF;AAChF,8EAA8E;AAC9E,0CAA0C;AAC1C,6HAKqF;AAJnF,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AAMtC,6FAA4F;AAAnF,sHAAA,iBAAiB,OAAA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "sdk-aws-lambda",
3
3
  "author": "ehmpathy",
4
4
  "description": "a simple and opinionated sdk for aws lambda. define endpoints, ask endpoints, auto-propagate trace-ids.",
5
- "version": "0.5.0",
5
+ "version": "0.6.0",
6
6
  "repository": "ehmpathy/sdk-aws-lambda",
7
7
  "homepage": "https://github.com/ehmpathy/sdk-aws-lambda",
8
8
  "keywords": [
@@ -68,7 +68,7 @@
68
68
  "@middy/http-json-body-parser": "4.7.0",
69
69
  "@middy/http-response-serializer": "4.7.0",
70
70
  "@middy/http-security-headers": "4.7.0",
71
- "domain-objects": "0.33.0",
71
+ "domain-objects": "0.34.0",
72
72
  "helpful-errors": "1.7.3",
73
73
  "sdk-environment": "0.1.5",
74
74
  "sdk-logs": "0.9.0",
@@ -107,7 +107,7 @@
107
107
  "rhachet-brains-xai": "0.3.3",
108
108
  "rhachet-roles-bhrain": "0.37.0",
109
109
  "rhachet-roles-bhuild": "0.21.36",
110
- "rhachet-roles-ehmpathy": "1.38.12",
110
+ "rhachet-roles-ehmpathy": "1.39.0",
111
111
  "rhachet-roles-rhachet": "0.1.7",
112
112
  "test-fns": "1.15.8",
113
113
  "tsc-alias": "1.8.10",
package/readme.md CHANGED
@@ -144,6 +144,73 @@ const schema = await askLambdaEndpoint(
144
144
 
145
145
  requires `env.access === 'prep'`. in prod, it throws a `ConstraintError`.
146
146
 
147
+ ## validate the input only
148
+
149
+ `schema.output` is required. for an endpoint that returns no value, declare `z.void()`:
150
+
151
+ ```ts
152
+ export const handler = genLambdaEndpoint(
153
+ {
154
+ schema: { input: inputSchema, output: z.void() },
155
+ invoke: async ({ event }) => { await doTheWork(event); },
156
+ },
157
+ { env: { access: 'prep' } },
158
+ );
159
+ ```
160
+
161
+ `z.void()`, `z.undefined()`, `z.null()` and `z.never()` each publish an honest contract. avoid
162
+ `z.any()` and `z.unknown()` — they publish `{}`, which tells a caller that **any** value is valid.
163
+
164
+ ## domain objects at the border
165
+
166
+ declare a domain object in the schema and `invoke` receives the **instance**, not the plain object
167
+ zod yields. no `as` cast, no per-field rebuild:
168
+
169
+ ```ts
170
+ import { Surfer } from './domain.objects/Surfer';
171
+
172
+ export const handler = genLambdaEndpoint(
173
+ {
174
+ schema: { input: z.object({ surfer: Surfer.contract() }), output: z.void() },
175
+ invoke: async ({ event }) => bookSurfLesson(event.surfer), // event.surfer instanceof Surfer
176
+ },
177
+ { env: { access: 'prep' } },
178
+ );
179
+ ```
180
+
181
+ `X.contract()` reaches every depth — not the top level alone:
182
+
183
+ ```ts
184
+ schema: {
185
+ input: z.object({
186
+ surfer: Surfer.contract(), // depth 0
187
+ signup: z.object({ // a PLAIN wrapper...
188
+ spot: SurfSpot.contract(), // ...and the dobj one level under it
189
+ }).nullable(),
190
+ boards: z.array(Surfboard.contract()), // every element of the array
191
+ report: WaveReport.contract(), // its `static nested` rebuilds `report.spot`
192
+ }),
193
+ output: z.void(),
194
+ },
195
+ ```
196
+
197
+ a value that fails the domain object's own constructor **fails loud at the border** and never reaches
198
+ `invoke` half-built.
199
+
200
+ what a caller of your generated cross-service client sees is the **wire** shape —
201
+ `{ surfer: { uuid, name } }` — never the instance. the two differ by design: the wire is what
202
+ crosses, the instance is what you hold once through.
203
+
204
+ two syntax notes:
205
+
206
+ ```ts
207
+ // a dobj that names ITSELF must defer, per js class-field order
208
+ static schema = z.object({ replies: z.array(z.lazy(() => Comment.contract())) });
209
+
210
+ // .ref() goes on the raw contract, before any chain
211
+ z.object({ rider: Surfer.contract().ref('primary') }).optional()
212
+ ```
213
+
147
214
  ## contract discovery
148
215
 
149
216
  ```ts
@@ -171,10 +238,10 @@ import { forApiGateway, asApiGatewayResponseSchema } from 'sdk-aws-lambda';
171
238
 
172
239
  export const handler = forApiGateway({
173
240
  schema: {
174
- input: z.any(), // a twilio form blob
175
- output: asApiGatewayResponseSchema({ body: z.undefined() }),
241
+ input: z.any(), // a twilio form blob
242
+ output: asApiGatewayResponseSchema({ body: z.undefined() }), // carries no body
176
243
  },
177
- invoke: async ({ event }) => ({ status: 204 }), // 204, no body
244
+ invoke: async ({ event }) => ({ status: 204 }), // 204, no body
178
245
  });
179
246
  ```
180
247
 
@@ -189,18 +256,32 @@ export const handler = forApiGateway({
189
256
  set a `Content-Type` yourself and the serializer stands aside, so xml/text reach the wire
190
257
  byte-identical. omit it with a body and you get `application/json`.
191
258
 
192
- ### schema is required; `z.any()` is the opt-out
259
+ ### the body-less response
193
260
 
194
261
  `schema.output` describes what `invoke` **returns** (the envelope), so
195
- `asApiGatewayResponseSchema({ body })` wraps a body schema into it. a required field with a visible
196
- opt-out keeps validation and introspection on one code path, and puts the choice where a reviewer can
197
- see it.
262
+ `asApiGatewayResponseSchema({ body })` wraps a body schema into it.
263
+
264
+ for a response that carries **no body at all** — a 204, a redirect — declare the body
265
+ `z.undefined()`:
266
+
267
+ <!-- prettier-ignore -->
268
+ | you declare | the published `body` slot | reads as |
269
+ |---|---|---|
270
+ | `z.undefined()` · `z.void()` · `z.never()` | `{ "not": {} }` | **"no body is ever carried"** |
271
+ | `z.any()` · `z.unknown()` | `{}` | ⛔ the rubber-stamp — every value reads as valid |
272
+ | `z.null()` | `{ "type": "null" }` | ⛔ claims the wire carries the four bytes `null` |
273
+
274
+ all of them behave identically at **runtime**: each accepts `{ status: 204 }` and each still refuses
275
+ an accidental `{ body: 'oops' }`. only the published contract differs, which is why the wrong choice
276
+ ships green.
198
277
 
199
278
  # features
200
279
 
201
280
  - **genLambdaEndpoint** — define endpoints with validation, log capture, error classification
202
281
  - `genLambdaEndpoint()` — direct invoke (default)
203
282
  - `forApiGateway()` — http via api gateway, with full wire-response control (above)
283
+ - **domain objects at the border** — `X.contract()` in a schema hands `invoke` real instances, at
284
+ every depth, with no `as` cast (above)
204
285
  - **askLambdaEndpoint** — ask another lambda with typed request/response, automatic trail propagation
205
286
  - **runLambdaEndpoint** — run an endpoint from a test
206
287
  - `onReferenced()` — you hold the handler; a caller fault is **returned**
@@ -209,7 +290,7 @@ see it.
209
290
  - `fromApiGateway()`, `fromSqs()`, `fromSns()`, `fromKinesis()`, `fromS3()`
210
291
  - **trace-id propagation** — pass `log`, and `trail.exid` threads through the call chain
211
292
  - **introspection** — expose json-schema via `{ introspect: 'schema' }` (prep only)
212
- - **contract discovery** — `getOneLambdaContract`, `getAllLambdaContracts`
293
+ - **contract discovery** — `getOneLambdaContract`, `getAllLambdaContracts` for sdk generation
213
294
 
214
295
  # docs
215
296