sdk-aws-lambda 0.6.0 → 0.7.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.objects/ApiGatewayRequestEventOnwire.d.ts +18 -0
- package/dist/domain.objects/ApiGatewayRequestEventOnwire.js +3 -0
- package/dist/domain.objects/ApiGatewayRequestEventOnwire.js.map +1 -0
- package/dist/domain.objects/ApiGatewayResponse.d.ts +17 -10
- package/dist/domain.objects/{ApiGatewayResponsePayload.d.ts → ApiGatewayResponseOnwire.d.ts} +8 -4
- package/dist/domain.objects/{ApiGatewayRequestPayload.js → ApiGatewayResponseOnwire.js} +1 -1
- package/dist/domain.objects/ApiGatewayResponseOnwire.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/InvokeInputSuperset.d.ts +125 -0
- package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.js → InvokeInputSuperset.js} +1 -1
- package/dist/domain.operations/genLambdaEndpoint/InvokeInputSuperset.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/TranslateLog.d.ts +0 -17
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.d.ts +27 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/ApiGatewayRequestEventUnified.d.ts +100 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/ApiGatewayRequestEventUnified.js +3 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/ApiGatewayRequestEventUnified.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayRequestEventUnified.d.ts +34 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayRequestEventUnified.js +141 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayRequestEventUnified.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseOnwire.d.ts +22 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseOnwire.js +27 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseOnwire.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{asApiGatewayResponsePayloadJson.d.ts → asApiGatewayResponseOnwireJson.d.ts} +11 -11
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{asApiGatewayResponsePayloadJson.js → asApiGatewayResponseOnwireJson.js} +12 -12
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseOnwireJson.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.d.ts +15 -13
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js +13 -11
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asHeaderKeysLowercased.d.ts +35 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asHeaderKeysLowercased.js +44 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asHeaderKeysLowercased.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +93 -56
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +88 -62
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getAllWirePayloadKeysFound.d.ts → getAllResponseOnwireKeysFound.d.ts} +2 -2
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllResponseOnwireKeysFound.js +43 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllResponseOnwireKeysFound.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getIsV1ApiGatewayEvent.d.ts → getIsV1ApiGatewayRequestEvent.d.ts} +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getIsV1ApiGatewayEvent.js → getIsV1ApiGatewayRequestEvent.js} +4 -4
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV1ApiGatewayRequestEvent.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getIsV2ApiGatewayEvent.d.ts → getIsV2ApiGatewayRequestEvent.d.ts} +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/{getIsV2ApiGatewayEvent.js → getIsV2ApiGatewayRequestEvent.js} +4 -4
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayRequestEvent.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/isApiGatewayResponse.d.ts +8 -5
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/isApiGatewayResponse.js +11 -8
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/isApiGatewayResponse.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/{genApiGatewayEventNormalizationMiddleware.d.ts → genApiGatewayRequestEventNormalizationMiddleware.d.ts} +3 -3
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/{genApiGatewayEventNormalizationMiddleware.js → genApiGatewayRequestEventNormalizationMiddleware.js} +8 -8
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayRequestEventNormalizationMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genContentTypeCoherenceMiddleware.d.ts +4 -4
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genContentTypeCoherenceMiddleware.js +5 -5
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodInputValidationMiddleware.d.ts +36 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodInputValidationMiddleware.js +113 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodInputValidationMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts → genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.d.ts} +50 -14
- package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js → genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js} +31 -16
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genAskEventOnwireCaptureMiddleware.d.ts +18 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genAskEventOnwireCaptureMiddleware.js +29 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genAskEventOnwireCaptureMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genZodEventValidationMiddleware.d.ts +23 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genZodEventValidationMiddleware.js +38 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genZodEventValidationMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/SqsEventDecoded.d.ts +123 -0
- package/dist/{domain.objects/ApiGatewayResponsePayload.js → domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/SqsEventDecoded.js} +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/SqsEventDecoded.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsEventDecoded.d.ts +23 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsEventDecoded.js +33 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsEventDecoded.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsHeadersOnwire.d.ts +30 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsHeadersOnwire.js +38 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsHeadersOnwire.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordDecoded.d.ts +30 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordDecoded.js +86 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordDecoded.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.d.ts +26 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.js +32 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.d.ts +82 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js +108 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.d.ts +121 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js +97 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.d.ts +52 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js +68 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getIsSqsEvent.d.ts +21 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getIsSqsEvent.js +36 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getIsSqsEvent.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.d.ts +46 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js +79 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.js +31 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.d.ts +8 -4
- package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.d.ts +10 -4
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionInput.d.ts +12 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionInput.js +23 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionInput.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js +17 -6
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.d.ts +16 -18
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js +16 -18
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.d.ts +5 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js +5 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.d.ts +14 -14
- package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js +15 -15
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.d.ts +5 -8
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js +5 -8
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.d.ts +9 -27
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js +9 -27
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.d.ts +14 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js +48 -16
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.d.ts +78 -0
- package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.js +103 -0
- package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.js.map +1 -0
- package/dist/domain.operations/genServiceSdk/gen.file/banner.d.ts +2 -3
- package/dist/domain.operations/genServiceSdk/gen.file/banner.js +2 -3
- package/dist/domain.operations/genServiceSdk/gen.file/banner.js.map +1 -1
- package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.d.ts +7 -2
- package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js +7 -2
- package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js.map +1 -1
- package/dist/index.d.ts +38 -18
- package/dist/index.js +20 -14
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/readme.md +164 -93
- package/dist/domain.objects/ApiGatewayRequestPayload.d.ts +0 -12
- package/dist/domain.objects/ApiGatewayRequestPayload.js.map +0 -1
- package/dist/domain.objects/ApiGatewayResponsePayload.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.d.ts +0 -36
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.d.ts +0 -19
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.js +0 -24
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayloadJson.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.d.ts +0 -27
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.js +0 -118
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllWirePayloadKeysFound.js +0 -34
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllWirePayloadKeysFound.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV1ApiGatewayEvent.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayEvent.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.d.ts +0 -27
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js +0 -54
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.d.ts +0 -20
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js +0 -31
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.d.ts +0 -5
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.js +0 -16
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.js.map +0 -1
|
@@ -4,29 +4,27 @@ import type { TranslateLog } from '../TranslateLog';
|
|
|
4
4
|
* .what = middleware that logs handler input and output
|
|
5
5
|
* .why = enables debug observability with optional redaction via translate.log
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* never runs. both shipped chains log the `errorMessage` / `stackTrace` branch
|
|
9
|
-
* instead.
|
|
7
|
+
* .defect = LIVE, NOT FIXED — on an error, the `request.response` branch of `onError` below
|
|
8
|
+
* never runs. both shipped chains log the `errorMessage` / `stackTrace` branch instead
|
|
10
9
|
*
|
|
11
10
|
* .the cause = middy `unshift`s `after` and `onError` hooks
|
|
12
|
-
* (`@middy/core/index.js:79-100`), so registration order
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* all. today it sits HIGHER in both.
|
|
11
|
+
* (`@middy/core/index.js:79-100`), so registration order reverses at run time: a higher
|
|
12
|
+
* array index runs earlier on the error path. `onError` here reads `request.response`,
|
|
13
|
+
* which exists only once an error-builder has set it — so this middleware must sit at a
|
|
14
|
+
* lower index than `genConstraintErrorMiddleware` / `genInternalServiceErrorMiddleware`
|
|
15
|
+
* for its response branch to observe a value at all. it sits higher in both
|
|
18
16
|
*
|
|
19
17
|
* .the repair, unapplied = move it below the error builders. left with the peer
|
|
20
|
-
* header-order defect
|
|
21
|
-
*
|
|
18
|
+
* header-order defect because that reorder also moves the success-path `after` order for
|
|
19
|
+
* every handler — a blast radius this wish's bound does not cover. the peer and the
|
|
20
|
+
* shared reorder both wait on
|
|
21
|
+
* `.dream/v2026_09_22.fix.no-cors-or-owasp-headers-on-error-responses.md`
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* ⚠️ the same mechanism binds a CUSTOM chain: place this below your own error
|
|
29
|
-
* builders, or its error-path response branch is dead there too.
|
|
23
|
+
* .note = do not delete the response branch as dead code. it names a real intent — on an error,
|
|
24
|
+
* log what the caller actually received — and it goes live the moment the reorder lands
|
|
25
|
+
* (rule.require.retest-the-model-on-every-family: prune a slot, never a name)
|
|
26
|
+
* .note = the same mechanism binds a custom chain: place this below your own error builders, or
|
|
27
|
+
* its error-path response branch is dead there too
|
|
30
28
|
*/
|
|
31
29
|
export declare const genIoLoggerMiddleware: (input?: {
|
|
32
30
|
logTranslate?: TranslateLog;
|
|
@@ -6,29 +6,27 @@ const asContextTrailed_1 = require("./asContextTrailed");
|
|
|
6
6
|
* .what = middleware that logs handler input and output
|
|
7
7
|
* .why = enables debug observability with optional redaction via translate.log
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* never runs. both shipped chains log the `errorMessage` / `stackTrace` branch
|
|
11
|
-
* instead.
|
|
9
|
+
* .defect = LIVE, NOT FIXED — on an error, the `request.response` branch of `onError` below
|
|
10
|
+
* never runs. both shipped chains log the `errorMessage` / `stackTrace` branch instead
|
|
12
11
|
*
|
|
13
12
|
* .the cause = middy `unshift`s `after` and `onError` hooks
|
|
14
|
-
* (`@middy/core/index.js:79-100`), so registration order
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* all. today it sits HIGHER in both.
|
|
13
|
+
* (`@middy/core/index.js:79-100`), so registration order reverses at run time: a higher
|
|
14
|
+
* array index runs earlier on the error path. `onError` here reads `request.response`,
|
|
15
|
+
* which exists only once an error-builder has set it — so this middleware must sit at a
|
|
16
|
+
* lower index than `genConstraintErrorMiddleware` / `genInternalServiceErrorMiddleware`
|
|
17
|
+
* for its response branch to observe a value at all. it sits higher in both
|
|
20
18
|
*
|
|
21
19
|
* .the repair, unapplied = move it below the error builders. left with the peer
|
|
22
|
-
* header-order defect
|
|
23
|
-
*
|
|
20
|
+
* header-order defect because that reorder also moves the success-path `after` order for
|
|
21
|
+
* every handler — a blast radius this wish's bound does not cover. the peer and the
|
|
22
|
+
* shared reorder both wait on
|
|
23
|
+
* `.dream/v2026_09_22.fix.no-cors-or-owasp-headers-on-error-responses.md`
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* ⚠️ the same mechanism binds a CUSTOM chain: place this below your own error
|
|
31
|
-
* builders, or its error-path response branch is dead there too.
|
|
25
|
+
* .note = do not delete the response branch as dead code. it names a real intent — on an error,
|
|
26
|
+
* log what the caller actually received — and it goes live the moment the reorder lands
|
|
27
|
+
* (rule.require.retest-the-model-on-every-family: prune a slot, never a name)
|
|
28
|
+
* .note = the same mechanism binds a custom chain: place this below your own error builders, or
|
|
29
|
+
* its error-path response branch is dead there too
|
|
32
30
|
*/
|
|
33
31
|
const genIoLoggerMiddleware = (input) => {
|
|
34
32
|
const translateInput = input?.logTranslate?.input ?? ((event) => event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genIoLoggerMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.ts"],"names":[],"mappings":";;;AAGA,yDAAsD;AAEtD
|
|
1
|
+
{"version":3,"file":"genIoLoggerMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.ts"],"names":[],"mappings":";;;AAGA,yDAAsD;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,MAAM,qBAAqB,GAAG,CAAC,KAErC,EAIC,EAAE;IACF,MAAM,cAAc,GAAG,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IACxE,MAAM,eAAe,GACnB,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;IAE1D,MAAM,MAAM,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC7D,MAAM,GAAG,GAAG,IAAA,mCAAgB,EAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC;QAC/D,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,KAAK,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC5D,MAAM,GAAG,GAAG,IAAA,mCAAgB,EAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC;QAC/D,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,KAAK,CAAC,gBAAgB,EAAE;gBAC1B,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC;aAC5C,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,OAAO,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC9D,MAAM,GAAG,GAAG,IAAA,mCAAgB,EAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC;QAC/D,IAAI,GAAG,EAAE,CAAC;YACR,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrB,GAAG,CAAC,KAAK,CAAC,gBAAgB,EAAE;oBAC1B,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC;iBAC5C,CAAC,CAAC;YACL,CAAC;iBAAM,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBACzB,GAAG,CAAC,KAAK,CAAC,gBAAgB,EAAE;oBAC1B,YAAY,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO;oBACnC,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK;iBAChC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACpC,CAAC,CAAC;AA5CW,QAAA,qBAAqB,yBA4ChC"}
|
|
@@ -6,6 +6,11 @@ import type middy from '@middy/core';
|
|
|
6
6
|
* payload formats:
|
|
7
7
|
* - wrapped: { event: X, trail: { exid } } → extracts trail, unwraps to X
|
|
8
8
|
* - raw: X → generates trail, uses X as event
|
|
9
|
+
*
|
|
10
|
+
* .note = the wrapped arm is the only inbound source of an `exid`, and only `askLambdaEndpoint`
|
|
11
|
+
* sends that shape. so an api-gateway or an sqs envelope cannot match it, and both
|
|
12
|
+
* families mint a fresh id every invoke — a trace does not cross an http or a queue
|
|
13
|
+
* boundary (`domain.terms/trail.md`)
|
|
9
14
|
*/
|
|
10
15
|
export declare const genTrailMiddleware: () => {
|
|
11
16
|
before: middy.MiddlewareFn<any, any>;
|
|
@@ -11,6 +11,11 @@ const getUnwrappedEventWithExid_1 = require("./getUnwrappedEventWithExid");
|
|
|
11
11
|
* payload formats:
|
|
12
12
|
* - wrapped: { event: X, trail: { exid } } → extracts trail, unwraps to X
|
|
13
13
|
* - raw: X → generates trail, uses X as event
|
|
14
|
+
*
|
|
15
|
+
* .note = the wrapped arm is the only inbound source of an `exid`, and only `askLambdaEndpoint`
|
|
16
|
+
* sends that shape. so an api-gateway or an sqs envelope cannot match it, and both
|
|
17
|
+
* families mint a fresh id every invoke — a trace does not cross an http or a queue
|
|
18
|
+
* boundary (`domain.terms/trail.md`)
|
|
14
19
|
*/
|
|
15
20
|
const genTrailMiddleware = () => {
|
|
16
21
|
const before = async (request) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genTrailMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.ts"],"names":[],"mappings":";;;AACA,mCAAoC;AACpC,uCAIkB;AAElB,2EAAwE;AAExE
|
|
1
|
+
{"version":3,"file":"genTrailMiddleware.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.ts"],"names":[],"mappings":";;;AACA,mCAAoC;AACpC,uCAIkB;AAElB,2EAAwE;AAExE;;;;;;;;;;;;GAYG;AACI,MAAM,kBAAkB,GAAG,GAEhC,EAAE;IACF,MAAM,MAAM,GAAiC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC7D,kDAAkD;QAClD,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,GACxD,IAAA,qDAAyB,EAAC;YACxB,OAAO,EAAE,OAAO,CAAC,KAAK;SACvB,CAAC,CAAC;QAEL,gCAAgC;QAChC,MAAM,IAAI,GAAG,eAAe,IAAI,QAAQ,IAAA,mBAAU,GAAE,EAAE,CAAC;QAEvD,eAAe;QACf,MAAM,KAAK,GAAa;YACtB,IAAI;YACJ,KAAK,EAAE,EAAE;SACV,CAAC;QAEF,kCAAkC;QAClC,MAAM,eAAe,GAAG,IAAA,6BAAkB,EAAC;YACzC,KAAK;YACL,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;QAEH,mCAAmC;QACnC,yFAAyF;QACzF,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC;QAE/B,kDAAkD;QAClD;;;;;;;;;;;WAWG;QACH,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAG3C,CAAC;QACF,OAAO,CAAC,OAAO,GAAG;YAChB,GAAG,aAAa;YAChB,GAAG,EAAE,eAAe,CAAC,GAAG;YACxB,eAAe;SAE+B,CAAC;IACnD,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;AAvDW,QAAA,kBAAkB,sBAuD7B"}
|
package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.d.ts
CHANGED
|
@@ -4,28 +4,28 @@ import type { ZodSchema } from 'zod';
|
|
|
4
4
|
* .what = middleware that validates handler output against a zod schema
|
|
5
5
|
* .why = ensures type-safe output before the response is returned
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* .note = which shape this validates depends on where you register it. it reads
|
|
8
|
+
* `request.response`, and on the api-gateway path that slot holds a different type at
|
|
9
|
+
* different points in the chain:
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* before the output translator -> `ApiGatewayResponse<TBody>` (the handler's shape)
|
|
13
|
-
* after the output translator -> `ApiGatewayResponsePayload` (the wire form, body
|
|
14
|
-
* already a string)
|
|
11
|
+
* before the output translator -> `ApiGatewayResponse<TBody>` (the handler's shape)
|
|
12
|
+
* after the output translator -> `ApiGatewayResponseOnwire` (the wire form, body
|
|
13
|
+
* already a string)
|
|
15
14
|
*
|
|
16
15
|
* a schema written for one refuses the other, so a caller who composes this into a
|
|
17
16
|
* custom chain validates whichever shape their registration order produces. the
|
|
18
|
-
* signature cannot warn them — `request.response` is `unknown` to middy, so both bind
|
|
17
|
+
* signature cannot warn them — `request.response` is `unknown` to middy, so both bind
|
|
19
18
|
*
|
|
20
|
-
* .note =
|
|
21
|
-
* tracked as
|
|
22
|
-
* `.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md
|
|
23
|
-
*
|
|
24
|
-
*
|
|
19
|
+
* .note = unresolved, not a defect — this export carries two contracts with no discriminant.
|
|
20
|
+
* tracked as F33 in the fulcrum table of
|
|
21
|
+
* `.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md`, where the
|
|
22
|
+
* three options (deprecate, add a `point` discriminant, accept) are spelled out. the
|
|
23
|
+
* route is named in full on purpose: a later route adds its own `1.vision.yield.md`,
|
|
24
|
+
* and a bare filename then resolves to a table with no F33 in it.
|
|
25
25
|
*
|
|
26
26
|
* no shipped chain registers it — both families validate inline instead, because each
|
|
27
27
|
* knows which of the two shapes it holds at that moment and this middleware cannot. so
|
|
28
|
-
* the open question is one of surface area, never of a live defect
|
|
28
|
+
* the open question is one of surface area, never of a live defect
|
|
29
29
|
*
|
|
30
30
|
* .note = the validation itself is delegated to `getValidatedOutput`, exactly as both input-side
|
|
31
31
|
* peers delegate to `getValidatedInput` — one guarantee, one implementation, per border
|
package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js
CHANGED
|
@@ -6,28 +6,28 @@ const getValidatedOutput_1 = require("./getValidatedOutput");
|
|
|
6
6
|
* .what = middleware that validates handler output against a zod schema
|
|
7
7
|
* .why = ensures type-safe output before the response is returned
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* .note = which shape this validates depends on where you register it. it reads
|
|
10
|
+
* `request.response`, and on the api-gateway path that slot holds a different type at
|
|
11
|
+
* different points in the chain:
|
|
10
12
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* before the output translator -> `ApiGatewayResponse<TBody>` (the handler's shape)
|
|
15
|
-
* after the output translator -> `ApiGatewayResponsePayload` (the wire form, body
|
|
16
|
-
* already a string)
|
|
13
|
+
* before the output translator -> `ApiGatewayResponse<TBody>` (the handler's shape)
|
|
14
|
+
* after the output translator -> `ApiGatewayResponseOnwire` (the wire form, body
|
|
15
|
+
* already a string)
|
|
17
16
|
*
|
|
18
17
|
* a schema written for one refuses the other, so a caller who composes this into a
|
|
19
18
|
* custom chain validates whichever shape their registration order produces. the
|
|
20
|
-
* signature cannot warn them — `request.response` is `unknown` to middy, so both bind
|
|
19
|
+
* signature cannot warn them — `request.response` is `unknown` to middy, so both bind
|
|
21
20
|
*
|
|
22
|
-
* .note =
|
|
23
|
-
* tracked as
|
|
24
|
-
* `.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md
|
|
25
|
-
*
|
|
26
|
-
*
|
|
21
|
+
* .note = unresolved, not a defect — this export carries two contracts with no discriminant.
|
|
22
|
+
* tracked as F33 in the fulcrum table of
|
|
23
|
+
* `.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md`, where the
|
|
24
|
+
* three options (deprecate, add a `point` discriminant, accept) are spelled out. the
|
|
25
|
+
* route is named in full on purpose: a later route adds its own `1.vision.yield.md`,
|
|
26
|
+
* and a bare filename then resolves to a table with no F33 in it.
|
|
27
27
|
*
|
|
28
28
|
* no shipped chain registers it — both families validate inline instead, because each
|
|
29
29
|
* knows which of the two shapes it holds at that moment and this middleware cannot. so
|
|
30
|
-
* the open question is one of surface area, never of a live defect
|
|
30
|
+
* the open question is one of surface area, never of a live defect
|
|
31
31
|
*
|
|
32
32
|
* .note = the validation itself is delegated to `getValidatedOutput`, exactly as both input-side
|
|
33
33
|
* peers delegate to `getValidatedInput` — one guarantee, one implementation, per border
|
|
@@ -43,7 +43,7 @@ const genZodOutputValidationMiddleware = (input) => {
|
|
|
43
43
|
return {
|
|
44
44
|
after: async (request) => {
|
|
45
45
|
// replace response with validated data (defaults + transforms applied)
|
|
46
|
-
// .note =
|
|
46
|
+
// .note = deliberate mutation — `request` is middy's only channel to hand a value onward
|
|
47
47
|
request.response = (0, getValidatedOutput_1.getValidatedOutput)({
|
|
48
48
|
response: request.response,
|
|
49
49
|
schema: input.schema,
|
|
@@ -2,15 +2,12 @@ import type { ZodSchema } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* .what = validate a caller's value against an endpoint's input schema, and hand back the
|
|
4
4
|
* parsed result
|
|
5
|
-
* .why = this is the ONE root primitive for the input border.
|
|
6
|
-
*
|
|
7
|
-
* than in each family's own validator
|
|
5
|
+
* .why = this is the ONE root primitive for the input border. every family reaches it, so a
|
|
6
|
+
* guarantee added here — a coerce, a redaction, an error shape — lands once
|
|
8
7
|
*
|
|
9
|
-
* .note = the
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `@middy/http-cors`. that slot choice stays with each family; the validation itself
|
|
13
|
-
* lives here
|
|
8
|
+
* .note = the families differ only in WHICH VALUE they hand in, never in what validation means:
|
|
9
|
+
* `forAsk` hands the unwrapped body; `forApiGateway` and `forSqs` hand the
|
|
10
|
+
* `{ headers, payload }` pair. each family writes the result back into its own slots
|
|
14
11
|
*
|
|
15
12
|
* .note = the result is the POST-parse shape, so a schema that coerces (any `X.contract()`
|
|
16
13
|
* position) yields live domain instances rather than the plain objects that crossed the
|
|
@@ -5,15 +5,12 @@ const getValidationError_1 = require("./getValidationError");
|
|
|
5
5
|
/**
|
|
6
6
|
* .what = validate a caller's value against an endpoint's input schema, and hand back the
|
|
7
7
|
* parsed result
|
|
8
|
-
* .why = this is the ONE root primitive for the input border.
|
|
9
|
-
*
|
|
10
|
-
* than in each family's own validator
|
|
8
|
+
* .why = this is the ONE root primitive for the input border. every family reaches it, so a
|
|
9
|
+
* guarantee added here — a coerce, a redaction, an error shape — lands once
|
|
11
10
|
*
|
|
12
|
-
* .note = the
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* `@middy/http-cors`. that slot choice stays with each family; the validation itself
|
|
16
|
-
* lives here
|
|
11
|
+
* .note = the families differ only in WHICH VALUE they hand in, never in what validation means:
|
|
12
|
+
* `forAsk` hands the unwrapped body; `forApiGateway` and `forSqs` hand the
|
|
13
|
+
* `{ headers, payload }` pair. each family writes the result back into its own slots
|
|
17
14
|
*
|
|
18
15
|
* .note = the result is the POST-parse shape, so a schema that coerces (any `X.contract()`
|
|
19
16
|
* position) yields live domain instances rather than the plain objects that crossed the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValidatedInput.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.ts"],"names":[],"mappings":";;;AAEA,6DAA0D;AAE1D
|
|
1
|
+
{"version":3,"file":"getValidatedInput.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidatedInput.ts"],"names":[],"mappings":";;;AAEA,6DAA0D;AAE1D;;;;;;;;;;;;;GAaG;AACI,MAAM,iBAAiB,GAAG,CAAS,KAGzC,EAAU,EAAE;IACX,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAA,uCAAkB,EAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACvE,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC;AAPW,QAAA,iBAAiB,qBAO5B"}
|
|
@@ -8,35 +8,17 @@ export interface OutputValidationErrorMetadata {
|
|
|
8
8
|
* .what = validates output against schema and returns typed result
|
|
9
9
|
* .why = named transformer for decode-friction-free validation in orchestrators
|
|
10
10
|
*
|
|
11
|
-
* .note = this is the ONE output-side validator, and
|
|
12
|
-
* `
|
|
13
|
-
* borders at once,
|
|
11
|
+
* .note = this is the ONE output-side validator, and the two families that answer a caller —
|
|
12
|
+
* `forAsk` and `forApiGateway` — call it DIRECTLY in their `logic`. so a repair here lands
|
|
13
|
+
* at both borders at once, as `getValidatedInput` does on the input side
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
* consumer who composes their own chain
|
|
17
|
-
* validates inline because each knows which of two shapes it holds at that moment and the
|
|
18
|
-
* middleware cannot (its own `.note` states the same, as does the readme)
|
|
15
|
+
* .why NOT through `genZodOutputValidationMiddleware` = that export wraps this function for a
|
|
16
|
+
* consumer who composes their own chain; no shipped chain registers it
|
|
19
17
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* readme's own consumer example: `response: request.response`. the name states
|
|
25
|
-
* the slot, so the call site reads as an identity
|
|
26
|
-
* - at the INPUT border it has TWO homes — `forAskEndpoint` hands `request.event`
|
|
27
|
-
* whole, `forApiGateway` hands `event.body`, because its `request.event` must
|
|
28
|
-
* stay http-shaped for `@middy/http-cors`. no slot name is true of both, so
|
|
29
|
-
* `value` is the honest neutral there rather than a claim about position
|
|
30
|
-
* (rule.prefer.names-by-position-over-claim)
|
|
31
|
-
*
|
|
32
|
-
* ⇒ ⛔ the plan that used to sit here is VOID: it deferred the rename to *"F35's
|
|
33
|
-
* resolution, which forces a shared `parseOrThrow` primitive"*. F35 was ruled
|
|
34
|
-
* 2026-09-21 as NO REPAIR OWED, so no such extraction will arrive and no future
|
|
35
|
-
* edit will carry this rename for free
|
|
36
|
-
*
|
|
37
|
-
* ⇒ the divergence therefore stands on its own merits, which are the two bullets
|
|
38
|
-
* above and are sufficient: one border has a true slot name, the other has two
|
|
39
|
-
* homes and no name true of both. ⇒ this is a settled asymmetry, never a debt
|
|
18
|
+
* .why the parameter is `response` where its input twin takes `value` = at THIS border the value
|
|
19
|
+
* has one home — `request.response` — so the name states the slot. at the input border
|
|
20
|
+
* each family hands a different value, so `value` is the neutral name there
|
|
21
|
+
* (rule.prefer.names-by-position-over-claim)
|
|
40
22
|
*/
|
|
41
23
|
export declare const getValidatedOutput: <TOutput>(input: {
|
|
42
24
|
response: unknown;
|
|
@@ -34,35 +34,17 @@ const OUTPUT_VALIDATION_HINT = 'the handler returned a value its own declared ou
|
|
|
34
34
|
* .what = validates output against schema and returns typed result
|
|
35
35
|
* .why = named transformer for decode-friction-free validation in orchestrators
|
|
36
36
|
*
|
|
37
|
-
* .note = this is the ONE output-side validator, and
|
|
38
|
-
* `
|
|
39
|
-
* borders at once,
|
|
37
|
+
* .note = this is the ONE output-side validator, and the two families that answer a caller —
|
|
38
|
+
* `forAsk` and `forApiGateway` — call it DIRECTLY in their `logic`. so a repair here lands
|
|
39
|
+
* at both borders at once, as `getValidatedInput` does on the input side
|
|
40
40
|
*
|
|
41
|
-
*
|
|
42
|
-
* consumer who composes their own chain
|
|
43
|
-
* validates inline because each knows which of two shapes it holds at that moment and the
|
|
44
|
-
* middleware cannot (its own `.note` states the same, as does the readme)
|
|
41
|
+
* .why NOT through `genZodOutputValidationMiddleware` = that export wraps this function for a
|
|
42
|
+
* consumer who composes their own chain; no shipped chain registers it
|
|
45
43
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* readme's own consumer example: `response: request.response`. the name states
|
|
51
|
-
* the slot, so the call site reads as an identity
|
|
52
|
-
* - at the INPUT border it has TWO homes — `forAskEndpoint` hands `request.event`
|
|
53
|
-
* whole, `forApiGateway` hands `event.body`, because its `request.event` must
|
|
54
|
-
* stay http-shaped for `@middy/http-cors`. no slot name is true of both, so
|
|
55
|
-
* `value` is the honest neutral there rather than a claim about position
|
|
56
|
-
* (rule.prefer.names-by-position-over-claim)
|
|
57
|
-
*
|
|
58
|
-
* ⇒ ⛔ the plan that used to sit here is VOID: it deferred the rename to *"F35's
|
|
59
|
-
* resolution, which forces a shared `parseOrThrow` primitive"*. F35 was ruled
|
|
60
|
-
* 2026-09-21 as NO REPAIR OWED, so no such extraction will arrive and no future
|
|
61
|
-
* edit will carry this rename for free
|
|
62
|
-
*
|
|
63
|
-
* ⇒ the divergence therefore stands on its own merits, which are the two bullets
|
|
64
|
-
* above and are sufficient: one border has a true slot name, the other has two
|
|
65
|
-
* homes and no name true of both. ⇒ this is a settled asymmetry, never a debt
|
|
44
|
+
* .why the parameter is `response` where its input twin takes `value` = at THIS border the value
|
|
45
|
+
* has one home — `request.response` — so the name states the slot. at the input border
|
|
46
|
+
* each family hands a different value, so `value` is the neutral name there
|
|
47
|
+
* (rule.prefer.names-by-position-over-claim)
|
|
66
48
|
*/
|
|
67
49
|
const getValidatedOutput = (input) => {
|
|
68
50
|
const result = input.schema.safeParse(input.response);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValidatedOutput.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAGlD,+DAI+B;AAO/B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,sBAAsB,GAC1B,yTAAyT,CAAC;AAE5T
|
|
1
|
+
{"version":3,"file":"getValidatedOutput.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAGlD,+DAI+B;AAO/B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,sBAAsB,GAC1B,yTAAyT,CAAC;AAE5T;;;;;;;;;;;;;;;GAeG;AACI,MAAM,kBAAkB,GAAG,CAAU,KAG3C,EAAW,EAAE;IACZ,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,IAAA,yCAAmB,EAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACpE,MAAM,IAAI,iCAAgB,CACxB,6BAA6B,IAAA,wCAAkB,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAC7D,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,EAAE,CACzC,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC;AAbW,QAAA,kBAAkB,sBAa7B"}
|
|
@@ -8,6 +8,20 @@ export interface ValidationErrorMetadata {
|
|
|
8
8
|
/**
|
|
9
9
|
* .what = transforms zod validation error into ConstraintError
|
|
10
10
|
* .why = callers need friendly error messages for invalid input
|
|
11
|
+
*
|
|
12
|
+
* .why the hint ships on the wire, though it addresses the author and not the caller = a strict
|
|
13
|
+
* header bag refuses 100% of traffic, so this message can only ever be read in a broken
|
|
14
|
+
* deployment — the author's own first request is the first to meet it. there is no
|
|
15
|
+
* author-only channel here in any case: `getErrorResponseBody` already forwards this
|
|
16
|
+
* error's metadata as `details`
|
|
17
|
+
*
|
|
18
|
+
* .why not refused at gen time, which would be one rung higher = a `toJSONSchema` probe of
|
|
19
|
+
* `schema.input` could read `additionalProperties: false` and throw at construction. it
|
|
20
|
+
* is refused on two counts: the failure here is already loud and total — never silent —
|
|
21
|
+
* and the ladder in `rule.prefer.prevent-over-correct` exists to close silent failures;
|
|
22
|
+
* and the probe throws on schemas it cannot represent, so the guard would need a
|
|
23
|
+
* swallowed error to stay safe, which trades a documented footgun for an undocumented
|
|
24
|
+
* failure mode (`rule.forbid.failhide`)
|
|
11
25
|
*/
|
|
12
26
|
export declare const getValidationError: (input: {
|
|
13
27
|
error: ZodError;
|
|
@@ -14,8 +14,8 @@ const getZodIssuesSummary_1 = require("./getZodIssuesSummary");
|
|
|
14
14
|
* - *"introspect the schema with `{ introspect: 'schema' }`"* — `genIntrospectionMiddleware`
|
|
15
15
|
* gates on `env.access === 'prep'` (`genIntrospectionMiddleware.ts:63`), so the hint would
|
|
16
16
|
* be a dead end in prod
|
|
17
|
-
* - *"check the `deserialize` option"* —
|
|
18
|
-
*
|
|
17
|
+
* - *"check the `deserialize` option"* — meaningless at the ask-endpoint border, which shares
|
|
18
|
+
* this builder
|
|
19
19
|
* ⇒ so the hint names the ACT, which is true at both borders and in every env. a hint that is
|
|
20
20
|
* false in one env is worse than none, since a caller spends the trip before they learn it
|
|
21
21
|
*/
|
|
@@ -23,19 +23,10 @@ const getZodIssuesSummary_1 = require("./getZodIssuesSummary");
|
|
|
23
23
|
* ⚠️ .why DOUBLE quotes, where this repo's formatter prefers single = the possessive. biome
|
|
24
24
|
* picks the delimiter that needs fewer escapes, so a string that carries `'` takes `"`
|
|
25
25
|
*
|
|
26
|
-
* .
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* prove they moved right — the CLEAN half of `rule.always.fix-forward-under-scouts-honor`
|
|
31
|
-
*
|
|
32
|
-
* ⇒ the deferral rested on an absence nobody had measured. a grep of the SUBJECT found
|
|
33
|
-
* 22 byte-identical hits across 8 files, and SEVEN of them are UNIT snapshots — among
|
|
34
|
-
* them `genLambdaEndpoint.forApiGateway.test.ts.snap`, which carries the fully-escaped
|
|
35
|
-
* JSON-in-string form the acceptance hits have. so a unit run proves the identical
|
|
36
|
-
* transformation on the identical shape (rule.require.positive-control-before-absence-claims)
|
|
37
|
-
* ⇒ the repair is one `sedreplace` over all 8 files, then a unit run with NO `--resnap`.
|
|
38
|
-
* green means the hand-applied edit equals what the code emits, byte for byte
|
|
26
|
+
* .note = this string is emitted verbatim into unit AND acceptance snapshots, in the same
|
|
27
|
+
* escaped JSON-in-string form. to reword it: `sedreplace` the old text across every
|
|
28
|
+
* snapshot, then run unit with NO `--resnap` — green proves the hand edit matches the
|
|
29
|
+
* emit byte for byte, which covers the acceptance snaps that share the form
|
|
39
30
|
*/
|
|
40
31
|
const VALIDATION_HINT_GENERIC = "send a value that satisfies the endpoint's declared input schema — correct each path named in `issues`";
|
|
41
32
|
/**
|
|
@@ -64,9 +55,46 @@ const VALIDATION_HINT_SELF_NAMED = 'each entry in `issues` names its own fix —
|
|
|
64
55
|
* the generic hint is appended exactly as it is today, so no new failure mode opens
|
|
65
56
|
*/
|
|
66
57
|
const FIX_NAMED_MARKER = 'fix:';
|
|
58
|
+
/**
|
|
59
|
+
* .what = detects the one validation failure whose cause is the author's schema rather than
|
|
60
|
+
* the caller's request — a `.strict()` (or `z.strictObject`) header bag
|
|
61
|
+
* .why = the sdk parses the whole wire header bag against `schema.input`, and api gateway
|
|
62
|
+
* injects keys no author declares (`host`, `x-forwarded-for`, `x-amzn-trace-id`, and
|
|
63
|
+
* cloudfront's own set). so a strict header schema refuses every real request — a total
|
|
64
|
+
* outage from an idiomatic zod instinct
|
|
65
|
+
* .note = scoped to the `headers` path deliberately. `.strict()` on `payload` is correct and
|
|
66
|
+
* safe: the body is wholly the handler's, so an undeclared key there really is a
|
|
67
|
+
* caller fault. the axis is who else writes into the bag
|
|
68
|
+
* (`rule.require.read-the-slot-a-dependency-reads`)
|
|
69
|
+
*/
|
|
70
|
+
const getIsStrictHeaderRefusal = (input) => input.issues.some((issue) => issue.code === 'unrecognized_keys' && issue.path === 'headers');
|
|
71
|
+
/**
|
|
72
|
+
* .what = the fix, named at the one moment an author is certain to read it
|
|
73
|
+
* .why = zod's own message names the SYMPTOM precisely (`Unrecognized keys: "host", …`) and
|
|
74
|
+
* the CURE not at all, so an author reads it as a question about api gateway rather
|
|
75
|
+
* than about their own schema (`rule.require.errors-name-the-fix`)
|
|
76
|
+
*/
|
|
77
|
+
const HINT_STRICT_HEADERS = ' — a `headers` schema must NOT be `.strict()`: this sdk parses the WHOLE wire bag, and api' +
|
|
78
|
+
' gateway injects keys you did not declare, so a strict bag refuses every real request. drop' +
|
|
79
|
+
' `.strict()` — zod strips undeclared keys by default, and the sdk merges your validated keys' +
|
|
80
|
+
' back over the wire bag, so no key is lost. (`.strict()` on `payload` stays safe.)';
|
|
67
81
|
/**
|
|
68
82
|
* .what = transforms zod validation error into ConstraintError
|
|
69
83
|
* .why = callers need friendly error messages for invalid input
|
|
84
|
+
*
|
|
85
|
+
* .why the hint ships on the wire, though it addresses the author and not the caller = a strict
|
|
86
|
+
* header bag refuses 100% of traffic, so this message can only ever be read in a broken
|
|
87
|
+
* deployment — the author's own first request is the first to meet it. there is no
|
|
88
|
+
* author-only channel here in any case: `getErrorResponseBody` already forwards this
|
|
89
|
+
* error's metadata as `details`
|
|
90
|
+
*
|
|
91
|
+
* .why not refused at gen time, which would be one rung higher = a `toJSONSchema` probe of
|
|
92
|
+
* `schema.input` could read `additionalProperties: false` and throw at construction. it
|
|
93
|
+
* is refused on two counts: the failure here is already loud and total — never silent —
|
|
94
|
+
* and the ladder in `rule.prefer.prevent-over-correct` exists to close silent failures;
|
|
95
|
+
* and the probe throws on schemas it cannot represent, so the guard would need a
|
|
96
|
+
* swallowed error to stay safe, which trades a documented footgun for an undocumented
|
|
97
|
+
* failure mode (`rule.forbid.failhide`)
|
|
70
98
|
*/
|
|
71
99
|
const getValidationError = (input) => {
|
|
72
100
|
const issues = (0, getZodIssuesSummary_1.getZodIssuesSummary)({ issues: input.error.issues });
|
|
@@ -75,7 +103,11 @@ const getValidationError = (input) => {
|
|
|
75
103
|
const hint = issues.every((issue) => issue.message.includes(FIX_NAMED_MARKER))
|
|
76
104
|
? VALIDATION_HINT_SELF_NAMED
|
|
77
105
|
: VALIDATION_HINT_GENERIC;
|
|
78
|
-
|
|
106
|
+
// a strict header bag is the one refusal whose cure is the author's, so it rides the title
|
|
107
|
+
const hintStrictHeaders = getIsStrictHeaderRefusal({ issues })
|
|
108
|
+
? HINT_STRICT_HEADERS
|
|
109
|
+
: '';
|
|
110
|
+
return new helpful_errors_1.ConstraintError(`validation failed: ${issuesMessage}${hintStrictHeaders}`, { issues, hint });
|
|
79
111
|
};
|
|
80
112
|
exports.getValidationError = getValidationError;
|
|
81
113
|
//# sourceMappingURL=getValidationError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValidationError.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidationError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAGjD,+DAI+B;AAO/B;;;;;;;;;;;;;;;GAeG;AACH
|
|
1
|
+
{"version":3,"file":"getValidationError.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidationError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAGjD,+DAI+B;AAO/B;;;;;;;;;;;;;;;GAeG;AACH;;;;;;;;GAQG;AACH,MAAM,uBAAuB,GAC3B,wGAAwG,CAAC;AAE3G;;;;;;;;GAQG;AACH,MAAM,0BAA0B,GAC9B,sMAAsM,CAAC;AAEzM;;;;;;;;;;;;;;GAcG;AACH,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,wBAAwB,GAAG,CAAC,KAEjC,EAAW,EAAE,CACZ,KAAK,CAAC,MAAM,CAAC,IAAI,CACf,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,mBAAmB,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAC1E,CAAC;AAEJ;;;;;GAKG;AACH,MAAM,mBAAmB,GACvB,4FAA4F;IAC5F,6FAA6F;IAC7F,8FAA8F;IAC9F,oFAAoF,CAAC;AAEvF;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAElC,EAA4C,EAAE;IAC7C,MAAM,MAAM,GAAG,IAAA,yCAAmB,EAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACnE,MAAM,aAAa,GAAG,IAAA,wCAAkB,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAErD,sFAAsF;IACtF,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAC5E,CAAC,CAAC,0BAA0B;QAC5B,CAAC,CAAC,uBAAuB,CAAC;IAE5B,2FAA2F;IAC3F,MAAM,iBAAiB,GAAG,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5D,CAAC,CAAC,mBAAmB;QACrB,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,IAAI,gCAAe,CACxB,sBAAsB,aAAa,GAAG,iBAAiB,EAAE,EACzD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,kBAAkB,sBAoB7B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = the type of what `setEventFrozen` produces — readonly all the way down
|
|
3
|
+
* .why = typescript's own `Readonly<T>` is shallow, so it refuses `event.x = 1` and allows
|
|
4
|
+
* `event.headers.x = 1`. the runtime freeze below is deep, so the two would disagree: a
|
|
5
|
+
* write one level in type-checks cleanly and then throws a `TypeError` in production,
|
|
6
|
+
* which turns a well-typed handler into a 500
|
|
7
|
+
* .why here = it is named for the mechanism it types (`setFrozenDeep`), so the contract and its
|
|
8
|
+
* enforcement sit in one file and cannot drift apart
|
|
9
|
+
*
|
|
10
|
+
* .note = a function passes through unmapped. `Object.freeze` does freeze a function, but to map
|
|
11
|
+
* over one would discard its call signature — and no field of this envelope is a
|
|
12
|
+
* function, so the arm is free and it guards the general case
|
|
13
|
+
* .note = `readonly` is a compile-time refusal only; it erases at runtime. the freeze is what
|
|
14
|
+
* enforces it, and this type is what announces it — neither replaces the other
|
|
15
|
+
* (`rule.prefer.prevent-over-correct`: refuse it at rung 1, report it at rung 4)
|
|
16
|
+
*/
|
|
17
|
+
export type FrozenDeep<T> = T extends (...args: never[]) => unknown ? T : T extends ReadonlyArray<infer TItem> ? ReadonlyArray<FrozenDeep<TItem>> : T extends object ? {
|
|
18
|
+
readonly [TKey in keyof T]: FrozenDeep<T[TKey]>;
|
|
19
|
+
} : T;
|
|
20
|
+
/**
|
|
21
|
+
* .what = seals the envelope before `invoke` receives it
|
|
22
|
+
* .why = the envelope outlives the handler's turn, so a write through it corrupts a value
|
|
23
|
+
* somebody else reads after `invoke` returns — with no type error and no throw. the freeze
|
|
24
|
+
* makes that unrepresentable
|
|
25
|
+
*
|
|
26
|
+
* .why every family freezes, with no exception = the membership rule is the hand-off, never the
|
|
27
|
+
* reader set. who reads the envelope after `invoke` differs per family — a vendor for
|
|
28
|
+
* `forApiGateway` (`@middy/http-cors` and `…response-serializer`, in their `after` hooks),
|
|
29
|
+
* the sdk itself for `forSqs.perBatch` (`idsInBatch` is built from `decoded.records` after
|
|
30
|
+
* `invoke`), and neither for `forSqs.perRecord` or `forAsk`. an empty column is a
|
|
31
|
+
* property of today, so a rule keyed to one expires silently the first commit that adds a
|
|
32
|
+
* post-invoke read (`rule.require.frozen-invoke-inputs`)
|
|
33
|
+
*
|
|
34
|
+
* .why the cost is paid on purpose = `FrozenDeep<TInput>` makes `event` unassignable to every
|
|
35
|
+
* mutable parameter a handler forwards it to, so a handler must declare its sinks
|
|
36
|
+
* readonly. a guarantee that holds on three variants of four is a trap for whoever moves
|
|
37
|
+
* between them
|
|
38
|
+
*
|
|
39
|
+
* .where = the family root rather than inside `forApiGateway`, because two variants of one family
|
|
40
|
+
* reach for it. lifted on the second use (`rule.prefer.most-common-denominator`)
|
|
41
|
+
*
|
|
42
|
+
* .note = the projections freeze with it, by design: `headers`, `payload`, and `records` are the
|
|
43
|
+
* envelope's own slots, so a handler mutates none (`domain.terms/event.md`)
|
|
44
|
+
* .note = `forSqs.perBatch`'s harm is the sharpest, and `[case17]` walks it end to end: a handler
|
|
45
|
+
* that forges `event.records[n].id` would rewrite the set the unknown-id guard checks
|
|
46
|
+
* against, so the guard passes and sqs is answered with an `itemIdentifier` it cannot
|
|
47
|
+
* match — the message the author meant to save is deleted, on a successful invocation
|
|
48
|
+
*
|
|
49
|
+
* .why a `WeakSet` = an envelope and its `_.raw` share sub-objects, so each is reachable by two
|
|
50
|
+
* paths and would otherwise be walked twice. measured in both families:
|
|
51
|
+
*
|
|
52
|
+
* apiGateway -> `queryStringParameters` and `pathParameters` pass by reference
|
|
53
|
+
* (`asApiGatewayRequestEventUnified.ts:68-69`)
|
|
54
|
+
* sqs -> `wire.Records[n]` is reachable as `event._.raw.Records[n]` and as
|
|
55
|
+
* `event.records[n]._.raw` (`asSqsEventDecoded.ts:37`,
|
|
56
|
+
* `asSqsRecordDecoded.ts:94`)
|
|
57
|
+
*
|
|
58
|
+
* it is not a cycle guard. no cycle is reachable from this event — `requestContext` is an
|
|
59
|
+
* explicit four-field copy of primitives and `headers` is a new object — though the set
|
|
60
|
+
* would terminate one a later author introduced
|
|
61
|
+
*
|
|
62
|
+
* .note = a frozen write throws in strict mode and no-ops in sloppy mode. every module this sdk
|
|
63
|
+
* ships is an es module, which is strict by construction, so the throw is the behavior a
|
|
64
|
+
* consumer meets (ecma-262 §11.2.2)
|
|
65
|
+
* .note = the throw's message is terse — node raises a bare `TypeError: Cannot assign to read
|
|
66
|
+
* only property …`, which names no cause and no remedy. `Object.freeze` accepts no
|
|
67
|
+
* message, and the only mechanism that could supply one is a `Proxy` — a different
|
|
68
|
+
* object, so `headers === event.headers` would stop to hold. the remedy is prevention
|
|
69
|
+
* instead: `FrozenDeep` refuses the write at compile time, so a type-checked consumer
|
|
70
|
+
* never reaches the message (`rule.prefer.prevent-over-correct`)
|
|
71
|
+
*
|
|
72
|
+
* .why it returns = the same reference, narrowed to `FrozenDeep`. it still freezes in place — the
|
|
73
|
+
* return is the type half of one act, so a caller receives the guarantee from the step
|
|
74
|
+
* that establishes it rather than asserts it by hand at the hand-off
|
|
75
|
+
*/
|
|
76
|
+
export declare const setEventFrozen: <TEvent>(input: {
|
|
77
|
+
event: TEvent;
|
|
78
|
+
}) => FrozenDeep<TEvent>;
|