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.
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.d.ts +24 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js +24 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +19 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js +7 -7
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts +28 -3
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js +3 -2
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js +6 -6
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js +19 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.d.ts +0 -4
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js +224 -3
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.d.ts +12 -4
- package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js +12 -4
- package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.d.ts +22 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js +29 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.d.ts +35 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js +58 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.d.ts +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js +65 -9
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.d.ts +20 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.js +31 -2
- package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.js.map +1 -1
- package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js +24 -19
- package/dist/domain.operations/genServiceSdk/gen.mechanism/getTypescriptFromJsonSchema.js.map +1 -1
- package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.d.ts +10 -3
- package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js +10 -3
- package/dist/domain.operations/genServiceSdk/gen.resource/asDomainObjectPragma.js.map +1 -1
- package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js +9 -23
- package/dist/domain.operations/genServiceSdk/gen.resource/assertAllDomainObjectRefsBind.js.map +1 -1
- package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js +11 -18
- package/dist/domain.operations/genServiceSdk/gen.resource/getAllDomainObjectsFromContracts.js.map +1 -1
- package/dist/domain.operations/genServiceSdk/getAllJsonSchemaNodes.d.ts +59 -0
- package/dist/domain.operations/genServiceSdk/getAllJsonSchemaNodes.js +87 -0
- package/dist/domain.operations/genServiceSdk/getAllJsonSchemaNodes.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/readme.md +89 -8
|
@@ -13,6 +13,30 @@ import type { ApiGatewayResponse } from '../../../domain.objects/ApiGatewayRespo
|
|
|
13
13
|
* any non-empty subset. the at-least-one rule is held by the TYPE at compile
|
|
14
14
|
* time; this schema guards the field types
|
|
15
15
|
*
|
|
16
|
+
* .note for a BODY-LESS response = `z.undefined()`, `z.void()` and `z.never()` are now
|
|
17
|
+
* EQUIVALENT, and each publishes honestly. all three accept `{ status: 204 }`, all
|
|
18
|
+
* three refuse an accidental `{ body: 'oops' }`, and all three serialize to
|
|
19
|
+
* `{ "not": {} }` — "no body is ever carried". there is no introspection penalty
|
|
20
|
+
* for any of them
|
|
21
|
+
*
|
|
22
|
+
* ⇒ **`z.undefined()` is the named idiom** — the readme states it, this spec's
|
|
23
|
+
* cases declare it, and it names what the value IS: the `body` key is absent, and
|
|
24
|
+
* `undefined` is the js word for absent. `z.never()` is a type-theory bottom type,
|
|
25
|
+
* which claims more than the domain means
|
|
26
|
+
*
|
|
27
|
+
* what to AVOID is `z.any()` / `z.unknown()`, which publish `{}` — a rubber-stamp
|
|
28
|
+
* that tells a caller ANY body may arrive, the one your handler never sends as well
|
|
29
|
+
*
|
|
30
|
+
* ⚠️ .this was NOT always so = `z.undefined()` and `z.void()` used to throw
|
|
31
|
+
* `Undefined cannot be represented in JSON Schema`, and the throw took down
|
|
32
|
+
* `getAllLambdaContracts` for the WHOLE service once `{ introspect: 'schema' }`
|
|
33
|
+
* arrived in `prep`. it was position-INDEPENDENT, so the `.optional()` this function
|
|
34
|
+
* adds was no shelter. `getJsonSchemaFromZod` now renders both shapes via an
|
|
35
|
+
* `override`, so the hazard is closed at the one door rather than dodged per schema
|
|
36
|
+
* .measured = `[case17]` of the peer spec drives all three candidates through a REAL
|
|
37
|
+
* introspection request and grades each. `[t1]` goes red if the render
|
|
38
|
+
* regresses to a throw
|
|
39
|
+
*
|
|
16
40
|
* .as = zod cannot express "at least one key present", so it infers `{ status?, headers?,
|
|
17
41
|
* body? }` — a superset of `PickAny` by exactly one member, `{}` — and no structural
|
|
18
42
|
* assignment relates the two
|
|
@@ -15,6 +15,30 @@ const zod_1 = require("zod");
|
|
|
15
15
|
* any non-empty subset. the at-least-one rule is held by the TYPE at compile
|
|
16
16
|
* time; this schema guards the field types
|
|
17
17
|
*
|
|
18
|
+
* .note for a BODY-LESS response = `z.undefined()`, `z.void()` and `z.never()` are now
|
|
19
|
+
* EQUIVALENT, and each publishes honestly. all three accept `{ status: 204 }`, all
|
|
20
|
+
* three refuse an accidental `{ body: 'oops' }`, and all three serialize to
|
|
21
|
+
* `{ "not": {} }` — "no body is ever carried". there is no introspection penalty
|
|
22
|
+
* for any of them
|
|
23
|
+
*
|
|
24
|
+
* ⇒ **`z.undefined()` is the named idiom** — the readme states it, this spec's
|
|
25
|
+
* cases declare it, and it names what the value IS: the `body` key is absent, and
|
|
26
|
+
* `undefined` is the js word for absent. `z.never()` is a type-theory bottom type,
|
|
27
|
+
* which claims more than the domain means
|
|
28
|
+
*
|
|
29
|
+
* what to AVOID is `z.any()` / `z.unknown()`, which publish `{}` — a rubber-stamp
|
|
30
|
+
* that tells a caller ANY body may arrive, the one your handler never sends as well
|
|
31
|
+
*
|
|
32
|
+
* ⚠️ .this was NOT always so = `z.undefined()` and `z.void()` used to throw
|
|
33
|
+
* `Undefined cannot be represented in JSON Schema`, and the throw took down
|
|
34
|
+
* `getAllLambdaContracts` for the WHOLE service once `{ introspect: 'schema' }`
|
|
35
|
+
* arrived in `prep`. it was position-INDEPENDENT, so the `.optional()` this function
|
|
36
|
+
* adds was no shelter. `getJsonSchemaFromZod` now renders both shapes via an
|
|
37
|
+
* `override`, so the hazard is closed at the one door rather than dodged per schema
|
|
38
|
+
* .measured = `[case17]` of the peer spec drives all three candidates through a REAL
|
|
39
|
+
* introspection request and grades each. `[t1]` goes red if the render
|
|
40
|
+
* regresses to a throw
|
|
41
|
+
*
|
|
18
42
|
* .as = zod cannot express "at least one key present", so it infers `{ status?, headers?,
|
|
19
43
|
* body? }` — a superset of `PickAny` by exactly one member, `{}` — and no structural
|
|
20
44
|
* assignment relates the two
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asApiGatewayResponseSchema.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.ts"],"names":[],"mappings":";;;AAAA,6BAAwC;AAIxC
|
|
1
|
+
{"version":3,"file":"asApiGatewayResponseSchema.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.ts"],"names":[],"mappings":";;;AAAA,6BAAwC;AAIxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACI,MAAM,0BAA0B,GAAG,CAAQ,KAEjD,EAAwC,EAAE,CACzC,OAAC,CAAC,MAAM,CAAC;IACP,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpD,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE;CAC5B,CAAoD,CAAC;AAP3C,QAAA,0BAA0B,8BAOiB"}
|
|
@@ -64,6 +64,25 @@ export type ForApiGatewayInput<TInput, TBody> = {
|
|
|
64
64
|
* .what = describes `inputAfter` — what `invoke` receives
|
|
65
65
|
* .why = guards the point of consequence on the way in: a caller who sent the wrong
|
|
66
66
|
* shape is refused before the handler runs
|
|
67
|
+
*
|
|
68
|
+
* ⚠️ .why ONE type param here, where the twin carries TWO = this asymmetry is CORRECT, and
|
|
69
|
+
* it reads like a missed parity fix. the twin declares
|
|
70
|
+
* `input: ZodSchema<TInput, TInputBefore>` (`forAskEndpoint.ts:80`) to track the
|
|
71
|
+
* codec's two faces — the wire face a caller sends, and the instance face `invoke`
|
|
72
|
+
* receives after a coerce.
|
|
73
|
+
*
|
|
74
|
+
* .why the twin NEEDS it = its returned handler is typed
|
|
75
|
+
* `LambdaHandlerInput<TInputBefore>` (`forAskEndpoint.ts:108`), so the WIRE face
|
|
76
|
+
* carries weight in its own public signature — a caller of the generated handler is
|
|
77
|
+
* typed against what they put on the wire
|
|
78
|
+
* .why this family does NOT = the handler this returns is pinned to
|
|
79
|
+
* `ApiGatewayRequestPayload` (`:196`), an envelope fixed by aws that does not vary
|
|
80
|
+
* with the schema. so the wire face has no slot to land in, and a `TInputBefore`
|
|
81
|
+
* declared here would be unused — it changes `TInput` inference not at all, since
|
|
82
|
+
* zod's `ZodType<Output, Input>` infers `TInput` from the Output position either way
|
|
83
|
+
*
|
|
84
|
+
* ⇒ so do NOT "fix" this to match the twin. the two families differ because their PUBLIC
|
|
85
|
+
* HANDLER TYPES differ, never because one of them was overlooked
|
|
67
86
|
*/
|
|
68
87
|
input: ZodSchema<TInput>;
|
|
69
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genLambdaEndpoint.forApiGateway.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAChC,iEAAwC;AACxC,+FAAqE;AACrE,yFAA+D;AAE/D,mDAAkD;AAQlD,4DAAyD;AACzD,6FAA0F;AAC1F,uGAAoG;AACpG,yFAAsF;AACtF,+EAA4E;AAC5E,yEAAsE;AACtE,yEAAsE;AAEtE,+EAA4E;AAC5E,uFAAoF;AACpF,yEAAiE;AACjE,6EAA0E;AAC1E,iEAA8D;AAC9D,sHAAmH;AACnH,sGAAmG;AACnG,gGAA6F;
|
|
1
|
+
{"version":3,"file":"genLambdaEndpoint.forApiGateway.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAChC,iEAAwC;AACxC,+FAAqE;AACrE,yFAA+D;AAE/D,mDAAkD;AAQlD,4DAAyD;AACzD,6FAA0F;AAC1F,uGAAoG;AACpG,yFAAsF;AACtF,+EAA4E;AAC5E,yEAAsE;AACtE,yEAAsE;AAEtE,+EAA4E;AAC5E,uFAAoF;AACpF,yEAAiE;AACjE,6EAA0E;AAC1E,iEAA8D;AAC9D,sHAAmH;AACnH,sGAAmG;AACnG,gGAA6F;AAmJ7F,8EAA8E;AAC9E,MAAM,qBAAqB,GAAG,CAAC,IAAgB,EAAE,EAAE;IACjD,OAAO;QACL;;;;;;;WAOG;QACH,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QACvE,WAAW,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1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.genZodBodyValidationMiddleware = void 0;
|
|
4
|
-
const
|
|
4
|
+
const getValidatedInput_1 = require("../../middleware/getValidatedInput");
|
|
5
5
|
/**
|
|
6
6
|
* .what = validates event.body against zod schema for API Gateway
|
|
7
7
|
* .why = API Gateway events have body as separate property, validate just the body
|
|
@@ -25,10 +25,10 @@ const getValidationError_1 = require("../../middleware/getValidationError");
|
|
|
25
25
|
const genZodBodyValidationMiddleware = (input) => {
|
|
26
26
|
const before = async (request) => {
|
|
27
27
|
const event = request.event;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
28
|
+
const inputAfter = (0, getValidatedInput_1.getValidatedInput)({
|
|
29
|
+
schema: input.schema,
|
|
30
|
+
value: event.body,
|
|
31
|
+
});
|
|
32
32
|
// replace body with parsed (transformed) result
|
|
33
33
|
/**
|
|
34
34
|
* .note = DELIBERATE MUTATION — `request` is middy's only channel to hand a value onward,
|
|
@@ -40,13 +40,13 @@ const genZodBodyValidationMiddleware = (input) => {
|
|
|
40
40
|
* (`^\s*(event|response|payload)\.\w+\s*=`), which finds exactly this one
|
|
41
41
|
*
|
|
42
42
|
* .as = `UnifiedApiGatewayEvent.body` is the PRE-validation shape (a string, or a parsed
|
|
43
|
-
* json value), while `
|
|
43
|
+
* json value), while `inputAfter` is `TInput` — the POST-validation domain shape.
|
|
44
44
|
* the two are unrelated by declaration, which is exactly right: this assignment IS
|
|
45
45
|
* the step that changes which of them lives in the slot
|
|
46
46
|
* .removal = drops once the input-side translator lands and the chain carries `inputAfter`
|
|
47
47
|
* in its own slot rather than back in the event's `body` — the 🚧 F31 fulcrum
|
|
48
48
|
*/
|
|
49
|
-
event.body =
|
|
49
|
+
event.body = inputAfter;
|
|
50
50
|
};
|
|
51
51
|
return { before };
|
|
52
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genZodBodyValidationMiddleware.js","sourceRoot":"","sources":["../../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"genZodBodyValidationMiddleware.js","sourceRoot":"","sources":["../../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.ts"],"names":[],"mappings":";;;AAGA,0EAAuE;AAGvE;;;;;;;;;;;;;;;;;;;GAmBG;AACI,MAAM,8BAA8B,GAAG,CAAS,KAEtD,EAEC,EAAE;IACF,MAAM,MAAM,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC7D,MAAM,KAAK,GAAG,OAAO,CAAC,KAA+B,CAAC;QACtD,MAAM,UAAU,GAAG,IAAA,qCAAiB,EAAC;YACnC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,IAAI;SAClB,CAAC,CAAC;QAEH,gDAAgD;QAChD;;;;;;;;;;;;;;;WAeG;QACH,KAAK,CAAC,IAAI,GAAG,UAA0C,CAAC;IAC1D,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;AAjCW,QAAA,8BAA8B,kCAiCzC"}
|
|
@@ -40,10 +40,35 @@ export type EndpointOperation<TInput, TOutput> = (input: {
|
|
|
40
40
|
/**
|
|
41
41
|
* .what = sdk contract type for genLambdaEndpoint input
|
|
42
42
|
* .why = exported for consumer type inference
|
|
43
|
+
*
|
|
44
|
+
* ⚠️ .why `TInputBefore` exists = a zod schema is a CODEC, so it holds two faces, and they
|
|
45
|
+
* differ the moment a `.transform()` or an `X.contract()` sits in it. `ZodSchema<T>`
|
|
46
|
+
* is `ZodType<Output, Input>` with `Input` left at `unknown` — so one parameter named
|
|
47
|
+
* only the face the HANDLER sees, and the face the CALLER sends had no name at all
|
|
48
|
+
*
|
|
49
|
+
* - `TInput` = `inputAfter` — what `invoke` receives. an `X.contract()` position
|
|
50
|
+
* yields `WithImmute<Surfer>` here
|
|
51
|
+
* - `TInputBefore` = the WIRE face — what a caller puts on the wire. the same position
|
|
52
|
+
* yields the plain `Surfer` shape here
|
|
53
|
+
*
|
|
54
|
+
* ⇒ this is the TYPE-side twin of the `{ io: 'input' }` publish repair: both say the wire
|
|
55
|
+
* face is what crosses the border, and both were wrong in the same direction before.
|
|
56
|
+
* measured — a `[case11]` payload of plain objects failed to compile against a schema
|
|
57
|
+
* with three `X.contract()` positions, because the handler's own parameter demanded the
|
|
58
|
+
* instance face it is the codec's job to PRODUCE
|
|
59
|
+
*
|
|
60
|
+
* .note = it defaults to `TInput`, so every schema with no codec in it binds both to one type
|
|
61
|
+
* and no extant consumer sees a change (rule.require.retest-the-model-on-every-family
|
|
62
|
+
* — the pair collapses per-consumer here, which that rule names as the legitimate case)
|
|
63
|
+
*
|
|
64
|
+
* .note = the names trace to this repo's extant position vocabulary — `inputBefore` /
|
|
65
|
+
* `inputAfter`, as `genZodBodyValidationMiddleware`'s F31 `.removal` uses them. the
|
|
66
|
+
* rename of `TInput` to `TInputAfter` belongs with F31, which collapses both families'
|
|
67
|
+
* validators at their common ancestor (rule.prefer.names-by-position-over-claim)
|
|
43
68
|
*/
|
|
44
|
-
export type GenLambdaEndpointInput<TInput, TOutput> = {
|
|
69
|
+
export type GenLambdaEndpointInput<TInput, TOutput, TInputBefore = TInput> = {
|
|
45
70
|
schema: {
|
|
46
|
-
input: ZodSchema<TInput>;
|
|
71
|
+
input: ZodSchema<TInput, TInputBefore>;
|
|
47
72
|
output: ZodSchema<TOutput>;
|
|
48
73
|
};
|
|
49
74
|
invoke: EndpointOperation<TInput, TOutput>;
|
|
@@ -61,4 +86,4 @@ export type GenLambdaEndpointContext = ContextAwsLambdaServer;
|
|
|
61
86
|
* constraint error (a caller fault becomes a response object, never a throw), internal
|
|
62
87
|
* service error (logs loudly), io logger, trail, input + output validation
|
|
63
88
|
*/
|
|
64
|
-
export declare const genLambdaEndpoint: <TInput, TOutput>(input: GenLambdaEndpointInput<TInput, TOutput>, context?: ContextAwsLambdaServer) => middy.MiddyfiedHandler<LambdaHandlerInput<
|
|
89
|
+
export declare const genLambdaEndpoint: <TInput, TOutput, TInputBefore = TInput>(input: GenLambdaEndpointInput<TInput, TOutput, TInputBefore>, context?: ContextAwsLambdaServer) => middy.MiddyfiedHandler<LambdaHandlerInput<TInputBefore>, TOutput, Error, Context>;
|
|
@@ -58,8 +58,9 @@ input, context) => {
|
|
|
58
58
|
(0, genZodEventValidationMiddleware_1.genZodEventValidationMiddleware)({ schema: input.schema.input }),
|
|
59
59
|
];
|
|
60
60
|
/**
|
|
61
|
-
* .as = assertion needed because middleware transforms LambdaHandlerInput<
|
|
62
|
-
* before logic runs
|
|
61
|
+
* .as = assertion needed because middleware transforms LambdaHandlerInput<TInputBefore> into
|
|
62
|
+
* TInput before logic runs — it unwraps the envelope AND runs the codec — but
|
|
63
|
+
* typescript cannot track either transformation through middy
|
|
63
64
|
* .removal = if middy gains typed middleware inference, remove cast
|
|
64
65
|
*/
|
|
65
66
|
return (0, core_1.default)(logic).use(middlewares);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genLambdaEndpoint.forAskEndpoint.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAOhC,4DAAyD;AACzD,6FAA0F;AAC1F,uGAAoG;AACpG,yFAAsF;AACtF,+EAA4E;AAC5E,yEAAsE;AACtE,yEAAsE;AAEtE,kGAA+F;
|
|
1
|
+
{"version":3,"file":"genLambdaEndpoint.forAskEndpoint.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAOh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AAE,EAAE,CAAC,OAAO,CAAC,KAAK;YACxC,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM;SAClC,CAAC;QACF,IAAA,iEAA+B,EAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;KAChE,CAAC;IAEF;;;;;OAKG;IACH,OAAO,IAAA,cAAK,EACV,KAGqB,CACtB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACrB,CAAC,CAAC;AAlEW,QAAA,iBAAiB,qBAkE5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.genZodEventValidationMiddleware = void 0;
|
|
4
|
-
const
|
|
4
|
+
const getValidatedInput_1 = require("../../middleware/getValidatedInput");
|
|
5
5
|
/**
|
|
6
6
|
* .what = validates the entire event against a zod schema
|
|
7
7
|
* .why = the ask-endpoint family reaches this step with the caller's value AT `request.event`,
|
|
@@ -17,13 +17,13 @@ const getValidationError_1 = require("../../middleware/getValidationError");
|
|
|
17
17
|
*/
|
|
18
18
|
const genZodEventValidationMiddleware = (input) => {
|
|
19
19
|
const before = async (request) => {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
20
|
+
const inputAfter = (0, getValidatedInput_1.getValidatedInput)({
|
|
21
|
+
schema: input.schema,
|
|
22
|
+
value: request.event,
|
|
23
|
+
});
|
|
24
24
|
// replace event with parsed (transformed) result
|
|
25
25
|
// .note = DELIBERATE MUTATION — `request` is middy's only channel to hand a value onward
|
|
26
|
-
request.event =
|
|
26
|
+
request.event = inputAfter;
|
|
27
27
|
};
|
|
28
28
|
return { before };
|
|
29
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genZodEventValidationMiddleware.js","sourceRoot":"","sources":["../../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"genZodEventValidationMiddleware.js","sourceRoot":"","sources":["../../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.ts"],"names":[],"mappings":";;;AAGA,0EAAuE;AAEvE;;;;;;;;;;;;GAYG;AACI,MAAM,+BAA+B,GAAG,CAAS,KAEvD,EAEC,EAAE;IACF,MAAM,MAAM,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC7D,MAAM,UAAU,GAAG,IAAA,qCAAiB,EAAC;YACnC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;QAEH,iDAAiD;QACjD,yFAAyF;QACzF,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC;IAC7B,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;AAjBW,QAAA,+BAA+B,mCAiB1C"}
|
package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const genInternalServiceErrorMiddleware: (opts: {
|
|
|
20
20
|
* a response and a hung request is worse than a 500
|
|
21
21
|
* false -> DISARMED; rethrow, so the invocation FAILS, cloudwatch records the error, and
|
|
22
22
|
* the caller may retry — which is the right contract for a server fault when no
|
|
23
|
-
* http
|
|
23
|
+
* http caller waits on it
|
|
24
24
|
*
|
|
25
25
|
* .note = the off-state is `false`, never absent. an absent field would disable a guarantee by
|
|
26
26
|
* omission, so a caller who forgot it would be indistinguishable from one who chose it
|
package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js
CHANGED
|
@@ -25,9 +25,27 @@ const genInternalServiceErrorMiddleware = (opts) => {
|
|
|
25
25
|
return;
|
|
26
26
|
// read the sdk-managed context once — trail may not have run yet
|
|
27
27
|
const { log } = (0, asContextTrailed_1.asContextTrailed)({ context: request.context });
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* .what = log the fault, and name WHICH endpoint raised it
|
|
30
|
+
* .why = the wire body a caller meets is deliberately generic — no internal detail, no
|
|
31
|
+
* secret — so cloudwatch is the only surface that can carry a diagnosis. it carried
|
|
32
|
+
* the message and the stack and never the endpoint, which is the half that matters
|
|
33
|
+
* most where the fault is service-wide: one bad schema position 500s
|
|
34
|
+
* `getAllLambdaContracts` for every endpoint beside it, and the log said WHAT broke
|
|
35
|
+
* without WHERE
|
|
36
|
+
*
|
|
37
|
+
* .note = `functionName` is aws's own field on the lambda `Context`, never one this sdk
|
|
38
|
+
* writes — so it is read straight off `request.context` rather than through
|
|
39
|
+
* `asContextTrailed`, which exists for the sdk-added fields only
|
|
40
|
+
*
|
|
41
|
+
* ⚠️ .why the WIRE body is still bare = whether a 500 may name an internal schema position
|
|
42
|
+
* at all is a disclosure call, and it belongs to the wisher — tracked as `F02`.
|
|
43
|
+
* a log line crosses no trust boundary, so THIS half needed no such call
|
|
44
|
+
*/
|
|
29
45
|
const logError = log?.error ?? console.error;
|
|
30
46
|
logError('handler.error', {
|
|
47
|
+
endpoint: request.context
|
|
48
|
+
?.functionName ?? null,
|
|
31
49
|
errorMessage: error.message,
|
|
32
50
|
stackTrace: error.stack,
|
|
33
51
|
});
|
package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genInternalServiceErrorMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.ts"],"names":[],"mappings":";;;AAEA,yDAAsD;AACtD,iEAA8D;AAE9D;;;;;;;;;GASG;AACI,MAAM,iCAAiC,GAAG,CAAC,IAqBjD,EAEC,EAAE;IACF,MAAM,OAAO,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK;YAAE,OAAO;QAEnB,4DAA4D;QAC5D,yEAAyE;QACzE,MAAM,YAAY,GAAG,IAAA,2CAAoB,EAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACrD,IAAI,YAAY;YAAE,OAAO;QAEzB,iEAAiE;QACjE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,mCAAgB,EAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAE/D
|
|
1
|
+
{"version":3,"file":"genInternalServiceErrorMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.ts"],"names":[],"mappings":";;;AAEA,yDAAsD;AACtD,iEAA8D;AAE9D;;;;;;;;;GASG;AACI,MAAM,iCAAiC,GAAG,CAAC,IAqBjD,EAEC,EAAE;IACF,MAAM,OAAO,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK;YAAE,OAAO;QAEnB,4DAA4D;QAC5D,yEAAyE;QACzE,MAAM,YAAY,GAAG,IAAA,2CAAoB,EAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACrD,IAAI,YAAY;YAAE,OAAO;QAEzB,iEAAiE;QACjE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,mCAAgB,EAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAE/D;;;;;;;;;;;;;;;;WAgBG;QACH,MAAM,QAAQ,GAAG,GAAG,EAAE,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC;QAC7C,QAAQ,CAAC,eAAe,EAAE;YACxB,QAAQ,EACL,OAAO,CAAC,OAAiD;gBACxD,EAAE,YAAY,IAAI,IAAI;YAC1B,YAAY,EAAE,KAAK,CAAC,OAAO;YAC3B,UAAU,EAAE,KAAK,CAAC,KAAK;SACxB,CAAC,CAAC;QAEH,sFAAsF;QACtF,IAAI,IAAI,CAAC,aAAa,KAAK,KAAK;YAAE,MAAM,KAAK,CAAC;QAE9C,2DAA2D;QAC3D,MAAM,IAAI,GAAG,GAAG,EAAE,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC;QAEtC;;;;;;WAMG;QACH,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC,CAAC;AA9EW,QAAA,iCAAiC,qCA8E5C"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { JSONSchema } from 'zod/v4/core/json-schema';
|
|
3
|
-
/**
|
|
4
|
-
* .what = convert zod schema to JSON schema
|
|
5
|
-
* .why = encapsulates zod api for future error handler if needed
|
|
6
|
-
*/
|
|
7
3
|
export declare const getJsonSchemaFromZod: <T extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>(schema: T) => JSONSchema;
|
|
@@ -1,13 +1,234 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getJsonSchemaFromZod = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
4
5
|
const zod_1 = require("zod");
|
|
5
6
|
/**
|
|
6
|
-
* .what =
|
|
7
|
-
* .why =
|
|
7
|
+
* .what = publish a zod schema as the json-schema document a caller is typed against
|
|
8
|
+
* .why = this is the one door to `z.toJSONSchema` in src, so the wire face is a property of
|
|
9
|
+
* this function rather than a flag each caller must remember
|
|
10
|
+
*
|
|
11
|
+
* ✅ .the one-door claim is CLAMPED, never merely stated here —
|
|
12
|
+
* `genIntrospectionMiddleware.getJsonSchemaFromZod.integration.test.ts` reads the `src/` tree
|
|
13
|
+
* and grades both halves: exactly one prod call site (`[t1]`), and this face on it (`[t2]`).
|
|
14
|
+
* both rows were driven RED before the clamp was trusted — a throwaway second call site, and
|
|
15
|
+
* this flag flipped to `'output'`. so a second door added without the flag goes red in ci
|
|
16
|
+
* rather than reopens a service-wide crash silently
|
|
17
|
+
*
|
|
18
|
+
* .note = `{ io: 'input' }` is UNCONDITIONAL, at both borders. `io` names the SIDE of a
|
|
19
|
+
* contract (wire vs instance), never the BORDER of an endpoint (request vs response) —
|
|
20
|
+
* and the wire side is what crosses in both directions. on the response path
|
|
21
|
+
* `JSON.stringify` is the real encoder, and it emits the wire shape regardless of what
|
|
22
|
+
* output validation returns, so a published instance-face would describe a document no
|
|
23
|
+
* caller ever sends or receives
|
|
24
|
+
*
|
|
25
|
+
* ✅ .the DEPLOYED face is clamped too, byte-exact —
|
|
26
|
+
* `deployed.codegen.refs.acceptance.test.ts` `[case2]` calls `getOneLambdaContract` against
|
|
27
|
+
* the live `svc-trophy-prep-getTrophy` and pins every marker shape this function emits:
|
|
28
|
+
* `x-domain-object` on the trophy, plus `by: primary | unique | ref` beneath it. driven RED
|
|
29
|
+
* before it was trusted — this line swapped to `{ unrepresentable: 'any' }` (the `#33` shape)
|
|
30
|
+
* turned all three of its rows red while `returns the endpoint schema` stayed GREEN, which is
|
|
31
|
+
* the hazard exactly: the crash goes away and the pragmas are destroyed with no tell
|
|
32
|
+
* (rule.forbid.failhide). reverted to green
|
|
33
|
+
*
|
|
34
|
+
* .note = an ABSENT position publishes `{ not: {} }` rather than throws. `z.undefined()` and
|
|
35
|
+
* `z.void()` are the two shapes a handler that returns no value declares, and zod
|
|
36
|
+
* refuses to render either — so before this, such an endpoint could not introspect
|
|
37
|
+
* at all and its author reached for `z.unknown()`, which publishes `{}` and tells a
|
|
38
|
+
* caller every value is valid. `{ not: {} }` is the honest statement, and it reads
|
|
39
|
+
* correctly at both positions: at a root, the response carries no document; at a
|
|
40
|
+
* key, the key must be absent — which is exactly what `z.undefined()` accepts, so
|
|
41
|
+
* the key is dropped from `required` too. see `setAbsentPositionsRendered`
|
|
42
|
+
*
|
|
43
|
+
* .note = zod's default is `io: 'output'`, which asks what a parse hands BACK — a live class
|
|
44
|
+
* for any schema that coerces. that is not json, so the default throws
|
|
45
|
+
* `Transforms cannot be represented in JSON Schema` and takes down
|
|
46
|
+
* `getAllLambdaContracts` for the whole service. `X.contract()` always coerces, so
|
|
47
|
+
* every dobj position reaches that path
|
|
48
|
+
*
|
|
49
|
+
* ⚠️ .defect = LIVE, NOT FIXED — at the OUTPUT border this face DIVERGES from the document
|
|
50
|
+
* that crosses, for two shapes out of six measured
|
|
51
|
+
* .proof it is live = `[case5]` of the peer spec drives each shape through the real
|
|
52
|
+
* `getValidatedOutput` and serializes it as the runtime does, then grades
|
|
53
|
+
* the pair. the `.pipe()` and type-shift `.transform()` rows grade
|
|
54
|
+
* `CONTRADICTS`, and that grade is COMPUTED from the measured pair. both
|
|
55
|
+
* rows are GREEN, so the divergence is present
|
|
56
|
+
* .the class, measured = a coerced dobj AGREES exactly (the headline shape) · a plain schema
|
|
57
|
+
* agrees · `.default()` and `.catch()` UNDER-declare, so the face is
|
|
58
|
+
* weaker than the truth and never wrong · a `.pipe()` and a type-shift
|
|
59
|
+
* `.transform()` CONTRADICT, so the face names a type the document does
|
|
60
|
+
* not carry
|
|
61
|
+
* .why unrepaired = the only face that describes those two rows is `io: 'output'`, and it
|
|
62
|
+
* THROWS for every `X.contract()` position — the crash above. a per-schema
|
|
63
|
+
* choice between the faces is two code paths for one guarantee
|
|
64
|
+
* (rule.forbid.parallel-codepaths) plus a silent fallback
|
|
65
|
+
* (rule.forbid.failhide). so one face serves both borders, and the trade is
|
|
66
|
+
* DECLARED here rather than met in a generated caller
|
|
67
|
+
* .the trade, stated plainly = the discarded default was RIGHT for a `.pipe()` at the output
|
|
68
|
+
* border and could not serve a dobj at all. this one serves every
|
|
69
|
+
* dobj and is wrong for a `.pipe()`. the dobj is the shape this
|
|
70
|
+
* sdk exists to publish
|
|
71
|
+
* .both halves are MEASURED = `[case6]` of the peer spec drives the discarded face at a dobj
|
|
72
|
+
* and clamps the throw; `[case7]` drives it at the `.pipe()` and
|
|
73
|
+
* clamps that it does NOT throw and publishes `number`. so the
|
|
74
|
+
* sentence above cites a run rather than a recollection
|
|
75
|
+
* .the fix-forward path = `.dream/v2026_09_18.fix.published-face-contradicts-the-wire-for-a-pipe.md`
|
|
76
|
+
* carries the shape of the repair — the two faces reconcile only once
|
|
77
|
+
* zod can render a transform's output side, or once this sdk owns its
|
|
78
|
+
* own renderer. a per-schema choice is NOT that repair, and the dream
|
|
79
|
+
* records why, so the next traveler meets the measurement before the
|
|
80
|
+
* idea (rule.always.catch-dreams-for-followups)
|
|
8
81
|
*/
|
|
82
|
+
/**
|
|
83
|
+
* .what = the fix half of the message an engineer meets when the schema is not this zod's
|
|
84
|
+
* .why = `rule.require.errors-name-the-fix`. measured on `zod@4.4.3`: a schema object whose
|
|
85
|
+
* `_zod` marker is absent or hollow reaches zod's dispatch and raises a bare
|
|
86
|
+
* `TypeError: Cannot read properties of undefined (reading 'def')` — loud, and it names
|
|
87
|
+
* neither zod, nor the schema, nor the two-copy cause. so the engineer's path is a stack
|
|
88
|
+
* trace into a vendor file, with no clue what to change
|
|
89
|
+
*
|
|
90
|
+
* .note = the likeliest single cause is a SPLIT INSTALL: `package.json` declares `zod` a plain
|
|
91
|
+
* dependency with no peer range, and this function does a value import of `z` then
|
|
92
|
+
* renders a schema the CONSUMER's zod built. two copies in one `node_modules` and the
|
|
93
|
+
* markers no longer match. that is tracked as `F03`, and this hint is what makes the
|
|
94
|
+
* failure diagnosable while the manifest question stays open
|
|
95
|
+
*/
|
|
96
|
+
const FOREIGN_SCHEMA_HINT = "the value handed to `getJsonSchemaFromZod` does not carry this zod install's marker — most often two copies of `zod` in one `node_modules`, so a schema built by one is rendered by the other. run `npm ls zod` (or `pnpm why zod`) and dedupe to a single version";
|
|
97
|
+
/**
|
|
98
|
+
* .what = the zod node types that denote NO value at all
|
|
99
|
+
* .why = `z.undefined()` and `z.void()` both accept a handler that returns no value, and
|
|
100
|
+
* zod refuses to render either one — so an endpoint that returns no value could not
|
|
101
|
+
* introspect, and its author was pushed to `z.unknown()`, which publishes `{}` and
|
|
102
|
+
* tells a caller that ANY value is valid. that is the rubber-stamp this sdk exists
|
|
103
|
+
* to retire, surviving one corner in
|
|
104
|
+
*
|
|
105
|
+
* .the rendering = `{ not: {} }` — "no json value is valid here". true at BOTH positions:
|
|
106
|
+
* at a root it says the response carries no document; at a key it says the key must
|
|
107
|
+
* be absent, which is exactly what `z.undefined()` accepts
|
|
108
|
+
*/
|
|
109
|
+
const TYPES_ABSENT = ['undefined', 'void'];
|
|
110
|
+
/**
|
|
111
|
+
* .what = the zod node types whose EMPTY `{}` rendering is the truth rather than a silence
|
|
112
|
+
* .why = `unrepresentable: 'any'` below renders every un-renderable node as `{}`, which is
|
|
113
|
+
* indistinguishable from the `{}` these two produce honestly. so the set is named,
|
|
114
|
+
* and every OTHER empty node is re-raised by `setAbsentPositionsRendered`
|
|
115
|
+
*/
|
|
116
|
+
const TYPES_OPEN = ['unknown', 'any'];
|
|
117
|
+
/**
|
|
118
|
+
* .what = whether a zod node type denotes an absent value
|
|
119
|
+
*/
|
|
120
|
+
const getIsAbsentType = (type) => !!type && TYPES_ABSENT.includes(type);
|
|
121
|
+
/**
|
|
122
|
+
* .what = read a zod node's type off a `toJSONSchema` override context
|
|
123
|
+
* .why = the override hands the live schema object, and its type is the only signal that
|
|
124
|
+
* says WHICH position was rendered. one reader, so the shape of that reach is
|
|
125
|
+
* stated once rather than at each branch (rule.require.named-transformers)
|
|
126
|
+
*/
|
|
127
|
+
const getNodeType = (zodSchema) => zodSchema?._zod?.def?.type;
|
|
128
|
+
/**
|
|
129
|
+
* .what = whether a zod node hands its render off to another node it wraps
|
|
130
|
+
* .why = a wrapper's `{}` is INHERITED, never its own — so it must not be re-raised. measured:
|
|
131
|
+
* `asApiGatewayResponseSchema` writes `body: input.body.optional()`, so a perfectly
|
|
132
|
+
* legal `z.any()` body reaches the override as an `optional` node that renders `{}`,
|
|
133
|
+
* and a naive emptiness test refused it. that is a FALSE REFUSAL of the one shape the
|
|
134
|
+
* re-raise exists to permit
|
|
135
|
+
* .measured = `[case17][t2]` of `genLambdaEndpoint.forApiGateway.test.ts` went 200 -> 500 on
|
|
136
|
+
* the first draft of this branch, and is the clamp that holds it
|
|
137
|
+
*
|
|
138
|
+
* .note = the test is the PRESENCE OF AN INNER, never a list of wrapper names. a name list is
|
|
139
|
+
* a guess that goes stale the moment zod adds a wrapper; this reads the property the
|
|
140
|
+
* render actually depends on. the three shapes zod uses, measured on `4.4.3` against
|
|
141
|
+
* `json-schema-processors.cjs`: `def.innerType` (optional, nullable, default, prefault,
|
|
142
|
+
* nonoptional, readonly, catch, success), `def.in` / `def.out` (pipe, line 529), and
|
|
143
|
+
* `_zod.innerType` (lazy, line 558)
|
|
144
|
+
*
|
|
145
|
+
* ⚠️ .why it matters beyond the one false refusal = it makes the re-raise ORDER-INDEPENDENT.
|
|
146
|
+
* zod runs the override over `[...ctx.seen.entries()].reverse()`, which is deepest-first
|
|
147
|
+
* (`to-json-schema.cjs:302`) — but `flattenRef` recurses into a parent at line 279, so a
|
|
148
|
+
* wrapper CAN be overridden before its inner. with this test the verdict is the same either
|
|
149
|
+
* way, since the wrapper never carries a verdict of its own. the leaf always gets its own
|
|
150
|
+
* call, because every node `process` touches lands in `ctx.seen`
|
|
151
|
+
*/
|
|
152
|
+
const getIsNodeWithInner = (zodSchema) => {
|
|
153
|
+
const node = zodSchema;
|
|
154
|
+
return !!(node?._zod?.def?.innerType ??
|
|
155
|
+
node?._zod?.def?.in ??
|
|
156
|
+
node?._zod?.innerType);
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* .what = rewrite one rendered node so an ABSENT position publishes honestly, and so no
|
|
160
|
+
* OTHER un-renderable position is silenced by the blanket flag that makes this
|
|
161
|
+
* rewrite reachable
|
|
162
|
+
* .why = `unrepresentable: 'any'` is what stops zod's throw, and on its own it is a
|
|
163
|
+
* failhide at scale — measured on `zod@4.4.3`, it renders `date`, `bigint`,
|
|
164
|
+
* `symbol`, `map`, and `custom` each as `{}`, the same rubber-stamp. so the flag
|
|
165
|
+
* disarms the refusal globally and this re-arms it precisely (rule.forbid.failhide)
|
|
166
|
+
*
|
|
167
|
+
* ⚠️ .why it is NOT the `#33` hazard = that hazard is `unrepresentable: 'any'` used INSTEAD
|
|
168
|
+
* of `{ io: 'input' }`, which renders every coerced dobj as `{}` and destroys the
|
|
169
|
+
* `x-domain-object` pragma with no tell. here the flag rides BESIDE `io: 'input'`,
|
|
170
|
+
* which already resolves every transform — measured byte-identical for a dobj schema
|
|
171
|
+
* with and without the flag
|
|
172
|
+
*/
|
|
173
|
+
const setAbsentPositionsRendered = (ctx) => {
|
|
174
|
+
const type = getNodeType(ctx.zodSchema);
|
|
175
|
+
// an absent position publishes `{ not: {} }` — no json value is valid here
|
|
176
|
+
//
|
|
177
|
+
// ⚠️ .why the parent's `required` is left ALONE = a first draft stripped an absent key
|
|
178
|
+
// out of `required`, on the reasoning that the position accepts the key being
|
|
179
|
+
// omitted. MEASURED FALSE: `z.object({ b: z.undefined() }).safeParse({})` returns
|
|
180
|
+
// `success: false` on `zod@4.4.3` — zod demands the key be PRESENT and hold
|
|
181
|
+
// `undefined`. so the strip would have published a face that accepts a document the
|
|
182
|
+
// parse then rejects. left in place, `required: ['b']` beside `b: { not: {} }` is
|
|
183
|
+
// unsatisfiable by any json document, which is the truth exactly
|
|
184
|
+
// (`[case11][t2]` clamps both halves)
|
|
185
|
+
if (getIsAbsentType(type)) {
|
|
186
|
+
for (const key of Object.keys(ctx.jsonSchema))
|
|
187
|
+
delete ctx.jsonSchema[key];
|
|
188
|
+
ctx.jsonSchema.not = {};
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
// any OTHER position the blanket flag emptied is re-raised, and by NAME — zod's own
|
|
192
|
+
// message names the kind and never the field, so an engineer met a stack trace into a
|
|
193
|
+
// vendor file with no clue which position to change (rule.require.errors-name-the-fix)
|
|
194
|
+
//
|
|
195
|
+
// .why a node WITH AN INNER is skipped = its `{}` came from the node it wraps, and that
|
|
196
|
+
// node gets its own call. to re-raise here would name `optional` where the real
|
|
197
|
+
// culprit is `date`, and would refuse a legal `z.any().optional()` outright
|
|
198
|
+
if (Object.keys(ctx.jsonSchema).length === 0 &&
|
|
199
|
+
!TYPES_OPEN.includes(type ?? '') &&
|
|
200
|
+
!getIsNodeWithInner(ctx.zodSchema))
|
|
201
|
+
throw new helpful_errors_1.MalfunctionError(`introspection cannot render this schema: a '${type}' position has no json representation`, {
|
|
202
|
+
type,
|
|
203
|
+
hint: `replace the \`${type}\` position with a json-representable one (for a value that is genuinely open, \`z.unknown()\`; for one that is absent, \`z.undefined()\`)`,
|
|
204
|
+
});
|
|
205
|
+
};
|
|
9
206
|
const getJsonSchemaFromZod = (schema) => {
|
|
10
|
-
|
|
207
|
+
/**
|
|
208
|
+
* .what = refuse a schema this zod install cannot recognize, by NAME rather than by TypeError
|
|
209
|
+
* .why = the throw already happened one frame deeper, inside the vendor, with a message that
|
|
210
|
+
* names a property and not a cause (`[case8][t0]`, `[t1]`). this changes no path that
|
|
211
|
+
* succeeds today — it fires on exactly the set that already crashed, and hands that set
|
|
212
|
+
* an error an engineer can act on (rule.require.failloud)
|
|
213
|
+
*
|
|
214
|
+
* .note = it does NOT compare versions. two copies at the SAME version still carry distinct
|
|
215
|
+
* markers, and a version check would pass while the render fails — so the test is the
|
|
216
|
+
* marker itself, which is the property the render actually needs
|
|
217
|
+
*/
|
|
218
|
+
const marker = schema?._zod;
|
|
219
|
+
if (!marker?.def?.type)
|
|
220
|
+
throw new helpful_errors_1.MalfunctionError('introspection cannot render this schema: it carries no recognizable zod marker', { hint: FOREIGN_SCHEMA_HINT });
|
|
221
|
+
return zod_1.z.toJSONSchema(schema, {
|
|
222
|
+
io: 'input',
|
|
223
|
+
// .why the blanket + the override = zod refuses an un-renderable position by THROW,
|
|
224
|
+
// which took `z.undefined()` / `z.void()` off the table for every endpoint that
|
|
225
|
+
// introspects. the flag disarms that throw for every kind at once, and
|
|
226
|
+
// `setAbsentPositionsRendered` re-arms it for every kind but the two that have an
|
|
227
|
+
// honest rendering. neither half is safe alone: the flag alone is a failhide,
|
|
228
|
+
// the override alone never runs (zod throws before it returns)
|
|
229
|
+
unrepresentable: 'any',
|
|
230
|
+
override: setAbsentPositionsRendered,
|
|
231
|
+
});
|
|
11
232
|
};
|
|
12
233
|
exports.getJsonSchemaFromZod = getJsonSchemaFromZod;
|
|
13
234
|
//# sourceMappingURL=genIntrospectionMiddleware.getJsonSchemaFromZod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genIntrospectionMiddleware.getJsonSchemaFromZod.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAGxB
|
|
1
|
+
{"version":3,"file":"genIntrospectionMiddleware.getJsonSchemaFromZod.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAClD,6BAAwB;AAGxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH;;;;;;;;;;;;;GAaG;AACH,MAAM,mBAAmB,GACvB,oQAAoQ,CAAC;AAEvQ;;;;;;;;;;;GAWG;AACH,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAEtC;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,IAAwB,EAAW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,KAAK,CAAC;QACxC,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;QAChC,CAAC,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC;QAElC,MAAM,IAAI,iCAAgB,CACxB,+CAA+C,IAAI,uCAAuC,EAC1F;YACE,IAAI;YACJ,IAAI,EAAE,iBAAiB,IAAI,4IAA4I;SACxK,CACF,CAAC;AACN,CAAC,CAAC;AAEK,MAAM,oBAAoB,GAAG,CAClC,MAAS,EACG,EAAE;IACd;;;;;;;;;;OAUG;IACH,MAAM,MAAM,GAAI,MAAkD,EAAE,IAAI,CAAC;IACzE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI;QACpB,MAAM,IAAI,iCAAgB,CACxB,gFAAgF,EAChF,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAC9B,CAAC;IAEJ,OAAO,OAAC,CAAC,YAAY,CAAC,MAAM,EAAE;QAC5B,EAAE,EAAE,OAAO;QACX,oFAAoF;QACpF,qFAAqF;QACrF,4EAA4E;QAC5E,uFAAuF;QACvF,mFAAmF;QACnF,oEAAoE;QACpE,eAAe,EAAE,KAAK;QACtB,QAAQ,EAAE,0BAA0B;KACrC,CAAe,CAAC;AACnB,CAAC,CAAC;AAhCW,QAAA,oBAAoB,wBAgC/B"}
|
package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.d.ts
CHANGED
|
@@ -18,16 +18,24 @@ import type { ZodSchema } from 'zod';
|
|
|
18
18
|
* signature cannot warn them — `request.response` is `unknown` to middy, so both bind.
|
|
19
19
|
*
|
|
20
20
|
* .note = UNRESOLVED, NOT A DEFECT — this export carries two contracts with no discriminant.
|
|
21
|
-
* tracked as **F33** in
|
|
22
|
-
*
|
|
21
|
+
* tracked as **F33** in
|
|
22
|
+
* `.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md`'s fulcrum
|
|
23
|
+
* table — the bound that SHIPPED this export, and already merged — where the three
|
|
24
|
+
* options (deprecate, add a `point` discriminant, accept) are spelled out.
|
|
23
25
|
*
|
|
24
26
|
* no shipped chain registers it — both families validate inline instead, because each
|
|
25
27
|
* knows which of the two shapes it holds at that moment and this middleware cannot. so
|
|
26
28
|
* the open question is one of surface area, never of a live defect.
|
|
27
29
|
*
|
|
28
|
-
* .note = the validation itself is delegated to `getValidatedOutput`, as both input-side
|
|
29
|
-
* delegate to `
|
|
30
|
+
* .note = the validation itself is delegated to `getValidatedOutput`, exactly as both input-side
|
|
31
|
+
* peers delegate to `getValidatedInput` — one guarantee, one implementation, per border
|
|
30
32
|
* (rule.forbid.parallel-codepaths)
|
|
33
|
+
*
|
|
34
|
+
* the two root primitives are peers rather than one, because they make DIFFERENT
|
|
35
|
+
* guarantees: a bad input is the caller's fault and raises a `ConstraintError`, while a
|
|
36
|
+
* bad output is the server's fault and raises a `MalfunctionError`
|
|
37
|
+
* (rule.require.failloud). to merge them would need an error-class argument, which is a
|
|
38
|
+
* fork on handed config — the shape that rule forbids
|
|
31
39
|
*/
|
|
32
40
|
export declare const genZodOutputValidationMiddleware: <TOutput>(input: {
|
|
33
41
|
schema: ZodSchema<TOutput>;
|