sdk-aws-lambda 0.4.2 → 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/contract/cli/gen.js +18 -0
- package/dist/contract/cli/gen.js.map +1 -1
- package/dist/domain.objects/AwsIdentitySynthetic.d.ts +20 -0
- package/dist/domain.objects/AwsIdentitySynthetic.js +24 -0
- package/dist/domain.objects/AwsIdentitySynthetic.js.map +1 -0
- package/dist/domain.objects/LambdaEndpointDialect.d.ts +19 -0
- package/dist/domain.objects/LambdaEndpointDialect.js +3 -0
- package/dist/domain.objects/LambdaEndpointDialect.js.map +1 -0
- package/dist/domain.objects/LambdaEndpointErrorResponseBody.d.ts +70 -0
- package/dist/domain.objects/LambdaEndpointErrorResponseBody.js +41 -0
- package/dist/domain.objects/LambdaEndpointErrorResponseBody.js.map +1 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.asExampleUuid.d.ts +7 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.asExampleUuid.js +13 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.asExampleUuid.js.map +1 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.constants.d.ts +36 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.constants.js +88 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.constants.js.map +1 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.d.ts +81 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.d.ts +75 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.js +163 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromApiGateway.js.map +1 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromKinesis.d.ts +32 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromKinesis.js +55 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromKinesis.js.map +1 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromS3.d.ts +40 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromS3.js +71 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromS3.js.map +1 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSns.d.ts +27 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSns.js +51 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSns.js.map +1 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSqs.d.ts +35 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSqs.js +50 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.fromSqs.js.map +1 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.js +59 -0
- package/dist/domain.operations/asLambdaEvent/asLambdaEvent.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.d.ts +2 -1
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js +19 -18
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js +1 -1
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js.map +1 -1
- 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 +37 -10
- 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/getErrorResponseBody.d.ts +6 -19
- package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js +6 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.js +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.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/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js +16 -35
- package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js.map +1 -1
- package/dist/domain.operations/lambdaEndpointWire/context/getExidFromContext.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/context/getLogForExidExtraction.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/context/getOneTrailExid.d.ts +36 -0
- package/dist/domain.operations/lambdaEndpointWire/context/getOneTrailExid.js +53 -0
- package/dist/domain.operations/lambdaEndpointWire/context/getOneTrailExid.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/error/getIsContempErrorTagged.d.ts +1 -0
- package/dist/domain.operations/lambdaEndpointWire/error/getIsContempErrorTagged.js +32 -0
- package/dist/domain.operations/lambdaEndpointWire/error/getIsContempErrorTagged.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/error/getIsLambdaErrorResponse.d.ts +63 -0
- package/dist/domain.operations/lambdaEndpointWire/error/getIsLambdaErrorResponse.js +39 -0
- package/dist/domain.operations/lambdaEndpointWire/error/getIsLambdaErrorResponse.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/error/getLambdaErrorMetadata.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/error/getStackTraceString.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.d.ts +54 -0
- package/dist/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.js +107 -0
- package/dist/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.js.map +1 -0
- package/dist/domain.operations/{genLambdaEndpoint/middleware → lambdaEndpointWire/frame}/getIsWrappedPayload.d.ts +6 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getIsWrappedPayload.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.d.ts +45 -0
- package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js +173 -0
- package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.d.ts +21 -0
- package/dist/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.js +33 -0
- package/dist/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/serde/getDecodedPayload.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/serde/getParsedJson.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/context/asLambdaContext.d.ts +24 -0
- package/dist/domain.operations/runLambdaEndpoint/context/asLambdaContext.js +70 -0
- package/dist/domain.operations/runLambdaEndpoint/context/asLambdaContext.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.d.ts +67 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.js +3 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.d.ts +26 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.js +43 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointDialect.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.d.ts +47 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.js +89 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.d.ts +73 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.js +108 -0
- package/dist/domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.d.ts +50 -0
- package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js +55 -0
- package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.d.ts +56 -0
- package/dist/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.js +57 -0
- package/dist/domain.operations/runLambdaEndpoint/guard/assertEventIsGiven.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.d.ts +16 -0
- package/dist/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.js +71 -0
- package/dist/domain.operations/runLambdaEndpoint/guard/assertHandlerIsRunnable.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.d.ts +48 -0
- package/dist/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.js +57 -0
- package/dist/domain.operations/runLambdaEndpoint/local/asLocalRunIdentity.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.d.ts +18 -0
- package/dist/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.js +239 -0
- package/dist/domain.operations/runLambdaEndpoint/local/getOneHandlerFromServerlessYml.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.d.ts +82 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.js +67 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.d.ts +120 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js +119 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.d.ts +98 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js +176 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asFramedPayload.d.ts +41 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asFramedPayload.js +62 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asFramedPayload.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.d.ts +40 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js +68 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWirePayload.d.ts +34 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWirePayload.js +39 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWirePayload.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWireStripped.d.ts +25 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWireStripped.js +85 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWireStripped.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/readme.md +188 -48
- package/dist/domain.operations/askLambdaEndpoint/context/getExidFromContext.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/context/getLogForExidExtraction.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.d.ts +0 -42
- package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.js +0 -21
- package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/error/getLambdaErrorMetadata.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/error/getStackTraceString.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.d.ts +0 -13
- package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js +0 -26
- package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/serde/getDecodedPayload.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedJson.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.d.ts +0 -15
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js +0 -100
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js.map +0 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsWrappedPayload.js.map +0 -1
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getExidFromContext.d.ts +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getExidFromContext.js +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getLogForExidExtraction.d.ts +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/context/getLogForExidExtraction.js +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getLambdaErrorMetadata.d.ts +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getLambdaErrorMetadata.js +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getStackTraceString.d.ts +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/error/getStackTraceString.js +0 -0
- /package/dist/domain.operations/{genLambdaEndpoint/middleware → lambdaEndpointWire/frame}/getIsWrappedPayload.js +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getDecodedPayload.d.ts +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getDecodedPayload.js +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getParsedJson.d.ts +0 -0
- /package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getParsedJson.js +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asWireStripped = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const isErrorLike_1 = require("../error/isErrorLike");
|
|
6
|
+
/**
|
|
7
|
+
* .what = casts a live object into the shape a json wire would deliver
|
|
8
|
+
* .why = the referenced boundary crosses no wire, so a Date, a class instance,
|
|
9
|
+
* or an `undefined` would survive into the handler — data the serialized
|
|
10
|
+
* boundary could never deliver.
|
|
11
|
+
*
|
|
12
|
+
* this is a FIDELITY GUARD, never the boundary itself. it keeps a test on
|
|
13
|
+
* the referenced boundary from a pass that the serialized boundary would fail.
|
|
14
|
+
*
|
|
15
|
+
* .note = applied in BOTH directions. aws serializes the response too, so an
|
|
16
|
+
* input-only strip would let a test assert on an output shape the wire
|
|
17
|
+
* could never deliver — the same hole, pointed the other way.
|
|
18
|
+
*
|
|
19
|
+
* .of = which side is stripped, and it is REQUIRED because it decides who owns
|
|
20
|
+
* a refusal:
|
|
21
|
+
*
|
|
22
|
+
* | `of` | the value is | a refusal is | the class |
|
|
23
|
+
* |------|--------------|--------------|-----------|
|
|
24
|
+
* | `'event'` | what the CALLER passed | the caller's fault | `ConstraintError` |
|
|
25
|
+
* | `'output'` | what the HANDLER returned | the server's fault | `MalfunctionError` |
|
|
26
|
+
*/
|
|
27
|
+
const asWireStripped = (input) => {
|
|
28
|
+
/**
|
|
29
|
+
* .what = undefined has no json representation, so it is returned as-is
|
|
30
|
+
* .why = `JSON.stringify(undefined)` yields `undefined`, which `JSON.parse`
|
|
31
|
+
* then refuses. so the round trip below cannot carry this case.
|
|
32
|
+
*
|
|
33
|
+
* .as = the cast is sound rather than a shapefit dodge: `value` is typed `T`,
|
|
34
|
+
* so `value === undefined` proves `undefined` inhabits `T`. typescript
|
|
35
|
+
* cannot carry that proof out of the narrow on an unresolved generic.
|
|
36
|
+
* .removal = drops out if typescript narrows a generic by an equality check
|
|
37
|
+
*/
|
|
38
|
+
if (input.value === undefined)
|
|
39
|
+
return undefined;
|
|
40
|
+
try {
|
|
41
|
+
/**
|
|
42
|
+
* .as = JSON round-trip erases the type at runtime while the shape survives
|
|
43
|
+
* .removal = if typescript gains a JsonOf<T> mapped type, narrow the return
|
|
44
|
+
*/
|
|
45
|
+
return JSON.parse(JSON.stringify(input.value));
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
// 🔴 the THROW is correct — aws serializes the payload too and would refuse
|
|
49
|
+
// the same value, so a circular reference or a bigint must not pass here.
|
|
50
|
+
// it rethrows and swallows naught (`rule.forbid.failhide`); what must not
|
|
51
|
+
// escape is a bare TypeError, which names neither the strip nor why it
|
|
52
|
+
// exists (`rule.require.errors-name-the-fix`).
|
|
53
|
+
//
|
|
54
|
+
// 🔴 the FAULT OWNER is decided by `of`, never guessed. a MESSAGE can name
|
|
55
|
+
// both sides in one sentence; a CLASS cannot — it is a single claim about
|
|
56
|
+
// who must fix the fault, so a guessed one is wrong half the time. a
|
|
57
|
+
// caller who hands a circular event would get `MalfunctionError`, which in
|
|
58
|
+
// this domain reads as *"the handler ran and broke"*
|
|
59
|
+
// (`invariant.badrequesterror-not-lambda-error`).
|
|
60
|
+
//
|
|
61
|
+
// ⇒ and `of` costs two call sites, both in `onReferenced` — one per side,
|
|
62
|
+
// each of which knows its own. with the direction known the message
|
|
63
|
+
// sharpens too, so no two-way hint is owed.
|
|
64
|
+
//
|
|
65
|
+
// duck-type rather than `instanceof Error` — jest runs each module in its own
|
|
66
|
+
// vm context, so a cross-realm error fails the prototype check and would
|
|
67
|
+
// degrade to `new Error(String(error))`, which loses the real constructor
|
|
68
|
+
// name and stack.
|
|
69
|
+
//
|
|
70
|
+
// 🟡 the predicate is shared rather than inline — three call sites read it,
|
|
71
|
+
// each with its own return contract, and a fork between any two is silent.
|
|
72
|
+
const cause = (0, isErrorLike_1.isErrorLike)(error) ? error : new Error(String(error));
|
|
73
|
+
if (input.of === 'event')
|
|
74
|
+
return helpful_errors_1.ConstraintError.throw('the event given cannot cross the wire — json refused to serialize it', {
|
|
75
|
+
cause,
|
|
76
|
+
hint: 'a circular reference or a bigint cannot reach a lambda. check the event you passed. aws would refuse the same payload, so it refuses here rather than let a test pass on a value the wire could never deliver.',
|
|
77
|
+
});
|
|
78
|
+
throw new helpful_errors_1.MalfunctionError('the handler returned a value that cannot cross the wire — json refused to serialize it', {
|
|
79
|
+
cause,
|
|
80
|
+
hint: 'a circular reference or a bigint cannot leave a lambda. check the value your handler returned. aws would refuse the same response, so it refuses here rather than let a test assert on an output the wire could never deliver.',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
exports.asWireStripped = asWireStripped;
|
|
85
|
+
//# sourceMappingURL=asWireStripped.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asWireStripped.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/serde/asWireStripped.ts"],"names":[],"mappings":";;;AAAA,mDAAmE;AAEnE,sDAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,cAAc,GAAG,CAAI,KAGjC,EAAK,EAAE;IACN;;;;;;;;;OASG;IACH,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,SAAc,CAAC;IAErD,IAAI,CAAC;QACH;;;WAGG;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAM,CAAC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,4EAA4E;QAC5E,6EAA6E;QAC7E,6EAA6E;QAC7E,0EAA0E;QAC1E,kDAAkD;QAClD,EAAE;QACF,2EAA2E;QAC3E,6EAA6E;QAC7E,wEAAwE;QACxE,8EAA8E;QAC9E,wDAAwD;QACxD,qDAAqD;QACrD,EAAE;QACF,6EAA6E;QAC7E,yEAAyE;QACzE,iDAAiD;QACjD,EAAE;QACF,8EAA8E;QAC9E,yEAAyE;QACzE,0EAA0E;QAC1E,kBAAkB;QAClB,EAAE;QACF,4EAA4E;QAC5E,8EAA8E;QAC9E,MAAM,KAAK,GAAG,IAAA,yBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAEpE,IAAI,KAAK,CAAC,EAAE,KAAK,OAAO;YACtB,OAAO,gCAAe,CAAC,KAAK,CAC1B,sEAAsE,EACtE;gBACE,KAAK;gBACL,IAAI,EAAE,gNAAgN;aACvN,CACF,CAAC;QAEJ,MAAM,IAAI,iCAAgB,CACxB,wFAAwF,EACxF;YACE,KAAK;YACL,IAAI,EAAE,gOAAgO;SACvO,CACF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAlEW,QAAA,cAAc,kBAkEzB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { LambdaCredentialsAbsentError } from './domain.objects/LambdaCredentials
|
|
|
22
22
|
export { LambdaDomainObjectNotCapturableError } from './domain.objects/LambdaDomainObjectNotCapturableError';
|
|
23
23
|
export { LambdaDomainObjectRefUnbindableError } from './domain.objects/LambdaDomainObjectRefUnbindableError';
|
|
24
24
|
export { LambdaEndpoint } from './domain.objects/LambdaEndpoint';
|
|
25
|
+
export type { LambdaEndpointDialect } from './domain.objects/LambdaEndpointDialect';
|
|
25
26
|
export { LambdaEndpointError } from './domain.objects/LambdaEndpointError';
|
|
26
27
|
export type { LambdaEndpointSchema } from './domain.objects/LambdaEndpointSchema';
|
|
27
28
|
export { LambdaFunctionNotFoundError } from './domain.objects/LambdaFunctionNotFoundError';
|
|
@@ -33,6 +34,7 @@ export { askLambdaEndpoint } from './domain.operations/askLambdaEndpoint/askLamb
|
|
|
33
34
|
export { asCacheWithoutSet } from './domain.operations/askLambdaEndpoint/cache/asCacheWithoutSet';
|
|
34
35
|
export { getAskLambdaCacheKey } from './domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey';
|
|
35
36
|
export { asLambdaEndpoint } from './domain.operations/asLambdaEndpoint/asLambdaEndpoint';
|
|
37
|
+
export { asLambdaEvent } from './domain.operations/asLambdaEvent/asLambdaEvent';
|
|
36
38
|
export { asApiGatewayResponseSchema } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema';
|
|
37
39
|
export type { CorsConfig, ForApiGatewayContext, ForApiGatewayInput, } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway';
|
|
38
40
|
export { forApiGateway } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway';
|
|
@@ -65,6 +67,31 @@ export { genZodOutputValidationMiddleware } from './domain.operations/genLambdaE
|
|
|
65
67
|
* public boundary (rule.forbid.as-cast)
|
|
66
68
|
*/
|
|
67
69
|
export type { LambdaEndpointErrorResponseBodyAncient, LambdaEndpointErrorResponseBodyContemp, } from './domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody';
|
|
70
|
+
/**
|
|
71
|
+
* .what = the two ROOT primitives a consumer needs to validate a border in a chain of their own
|
|
72
|
+
* .why = the advanced-use exports above are middlewares, and the one on the OUTPUT side —
|
|
73
|
+
* `genZodOutputValidationMiddleware` — is positionally ambiguous by its own admission
|
|
74
|
+
* (F33). so a consumer who wanted to validate output safely had exactly one public tool,
|
|
75
|
+
* and it was the foot-gun: the atom was hidden and the risky composite was public
|
|
76
|
+
*
|
|
77
|
+
* these two are unambiguous by construction — each takes the value it validates as an
|
|
78
|
+
* argument rather than reads it out of a slot whose type depends on registration order.
|
|
79
|
+
* so a consumer builds their own correctly-ordered step and the ambiguity never reaches it
|
|
80
|
+
*
|
|
81
|
+
* .note = this does NOT settle F33. that fulcrum asks whether the middleware should keep its
|
|
82
|
+
* export at all, and it belongs to the bound that shipped it
|
|
83
|
+
* (`.behavior/v2026_08_03.feat-apigateway-wire-response/`). what this changes is that the
|
|
84
|
+
* ambiguous export is no longer the ONLY option — which is the half that needed no
|
|
85
|
+
* wisher call, because it breaks no consumer (rule.always.fix-forward-under-scouts-honor)
|
|
86
|
+
*
|
|
87
|
+
* .note = each metadata type rides along for the same reason `LambdaEndpointErrorResponseBody*`
|
|
88
|
+
* does — a consumer who catches the throw must be able to NAME what `.metadata` holds,
|
|
89
|
+
* or they reach for an `as`-cast at the public boundary (rule.forbid.as-cast)
|
|
90
|
+
*/
|
|
91
|
+
export { getValidatedInput } from './domain.operations/genLambdaEndpoint/middleware/getValidatedInput';
|
|
92
|
+
export { getValidatedOutput, type OutputValidationErrorMetadata, } from './domain.operations/genLambdaEndpoint/middleware/getValidatedOutput';
|
|
93
|
+
export type { ValidationErrorMetadata } from './domain.operations/genLambdaEndpoint/middleware/getValidationError';
|
|
94
|
+
export type { ZodIssueSummary } from './domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary';
|
|
68
95
|
/**
|
|
69
96
|
* .note = `TranslateLog` is public because `logTranslate` accepts it, and it replaces the
|
|
70
97
|
* formerly-public `IoLogTranslate`. its three designed peers — `Translate<TShapes>`,
|
|
@@ -78,3 +105,10 @@ export { genServiceSdk } from './domain.operations/genServiceSdk/genServiceSdk';
|
|
|
78
105
|
export { type GetAllLambdaContractsContext, type GetAllLambdaContractsInput, getAllLambdaContracts, } from './domain.operations/getAllLambdaContracts/getAllLambdaContracts';
|
|
79
106
|
export { getAllLambdaFunctionsByPrefix } from './domain.operations/getAllLambdaContracts/lambdaFunction/getAllLambdaFunctionsByPrefix';
|
|
80
107
|
export { type GetOneLambdaContractContext, type GetOneLambdaContractInput, getOneLambdaContract, } from './domain.operations/getOneLambdaContract/getOneLambdaContract';
|
|
108
|
+
export { asLambdaContext } from './domain.operations/runLambdaEndpoint/context/asLambdaContext';
|
|
109
|
+
export { asLambdaEndpointOutput } from './domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput';
|
|
110
|
+
export { asLambdaEndpointErrorEnvelopeAncient, asLambdaEndpointErrorEnvelopeContemp, isLambdaEndpointErrorEnvelopeAncient, isLambdaEndpointErrorEnvelopeContemp, } from './domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope';
|
|
111
|
+
export type { LambdaEndpointErrorEnvelope, LambdaEndpointRunOutput, } from './domain.operations/runLambdaEndpoint/dialect/LambdaEndpointRunOutput';
|
|
112
|
+
export { runLambdaEndpoint } from './domain.operations/runLambdaEndpoint/runLambdaEndpoint';
|
|
113
|
+
export type { LambdaEndpointHandlerReferenced } from './domain.operations/runLambdaEndpoint/runLambdaEndpoint.onReferenced';
|
|
114
|
+
export type { LambdaEndpointLocus } from './domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized';
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* define endpoints, ask endpoints, auto-propagate trace-ids.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.getOneLambdaContract = exports.getAllLambdaFunctionsByPrefix = exports.getAllLambdaContracts = exports.genServiceSdk = exports.genZodOutputValidationMiddleware = exports.genTrailMiddleware = exports.genIoLoggerMiddleware = exports.genIntrospectionMiddleware = exports.genInternalServiceErrorMiddleware = exports.genConstraintErrorMiddleware = exports.asContextTrailed = exports.genZodEventValidationMiddleware = exports.genLambdaEndpoint = exports.genZodBodyValidationMiddleware = exports.genContentTypeCoherenceMiddleware = exports.genApiGatewayEventNormalizationMiddleware = exports.isApiGatewayResponse = exports.forApiGateway = exports.asApiGatewayResponseSchema = exports.asLambdaEndpoint = exports.getAskLambdaCacheKey = exports.asCacheWithoutSet = exports.askLambdaEndpoint = exports.LambdaServiceNotFoundError = exports.LambdaIntrospectionNotSupportedError = exports.LambdaIntrospectionBlockedError = exports.LambdaFunctionNotFoundError = exports.LambdaEndpointError = exports.LambdaEndpoint = exports.LambdaDomainObjectRefUnbindableError = exports.LambdaDomainObjectNotCapturableError = exports.LambdaCredentialsAbsentError = exports.HttpStatusCode = exports.GeneratedFile = exports.delLambdaSdks = exports.BadRequestError = void 0;
|
|
8
|
+
exports.runLambdaEndpoint = exports.isLambdaEndpointErrorEnvelopeContemp = exports.isLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointErrorEnvelopeContemp = exports.asLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointOutput = exports.asLambdaContext = exports.getOneLambdaContract = exports.getAllLambdaFunctionsByPrefix = exports.getAllLambdaContracts = exports.genServiceSdk = exports.getValidatedOutput = exports.getValidatedInput = exports.genZodOutputValidationMiddleware = exports.genTrailMiddleware = exports.genIoLoggerMiddleware = exports.genIntrospectionMiddleware = exports.genInternalServiceErrorMiddleware = exports.genConstraintErrorMiddleware = exports.asContextTrailed = exports.genZodEventValidationMiddleware = exports.genLambdaEndpoint = exports.genZodBodyValidationMiddleware = exports.genContentTypeCoherenceMiddleware = exports.genApiGatewayEventNormalizationMiddleware = exports.isApiGatewayResponse = exports.forApiGateway = exports.asApiGatewayResponseSchema = exports.asLambdaEvent = exports.asLambdaEndpoint = exports.getAskLambdaCacheKey = exports.asCacheWithoutSet = exports.askLambdaEndpoint = exports.LambdaServiceNotFoundError = exports.LambdaIntrospectionNotSupportedError = exports.LambdaIntrospectionBlockedError = exports.LambdaFunctionNotFoundError = exports.LambdaEndpointError = exports.LambdaEndpoint = exports.LambdaDomainObjectRefUnbindableError = exports.LambdaDomainObjectNotCapturableError = exports.LambdaCredentialsAbsentError = exports.HttpStatusCode = exports.GeneratedFile = exports.delLambdaSdks = exports.BadRequestError = void 0;
|
|
9
9
|
// re-export from helpful-errors for convenience
|
|
10
10
|
var helpful_errors_1 = require("helpful-errors");
|
|
11
11
|
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return helpful_errors_1.BadRequestError; } });
|
|
@@ -50,6 +50,9 @@ Object.defineProperty(exports, "getAskLambdaCacheKey", { enumerable: true, get:
|
|
|
50
50
|
// transformers
|
|
51
51
|
var asLambdaEndpoint_1 = require("./domain.operations/asLambdaEndpoint/asLambdaEndpoint");
|
|
52
52
|
Object.defineProperty(exports, "asLambdaEndpoint", { enumerable: true, get: function () { return asLambdaEndpoint_1.asLambdaEndpoint; } });
|
|
53
|
+
// test utils — the event source axis (construct the envelope a source delivers)
|
|
54
|
+
var asLambdaEvent_1 = require("./domain.operations/asLambdaEvent/asLambdaEvent");
|
|
55
|
+
Object.defineProperty(exports, "asLambdaEvent", { enumerable: true, get: function () { return asLambdaEvent_1.asLambdaEvent; } });
|
|
53
56
|
var asApiGatewayResponseSchema_1 = require("./domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema");
|
|
54
57
|
Object.defineProperty(exports, "asApiGatewayResponseSchema", { enumerable: true, get: function () { return asApiGatewayResponseSchema_1.asApiGatewayResponseSchema; } });
|
|
55
58
|
var genLambdaEndpoint_forApiGateway_1 = require("./domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway");
|
|
@@ -88,6 +91,31 @@ var genTrailMiddleware_1 = require("./domain.operations/genLambdaEndpoint/middle
|
|
|
88
91
|
Object.defineProperty(exports, "genTrailMiddleware", { enumerable: true, get: function () { return genTrailMiddleware_1.genTrailMiddleware; } });
|
|
89
92
|
var genZodOutputValidationMiddleware_1 = require("./domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware");
|
|
90
93
|
Object.defineProperty(exports, "genZodOutputValidationMiddleware", { enumerable: true, get: function () { return genZodOutputValidationMiddleware_1.genZodOutputValidationMiddleware; } });
|
|
94
|
+
/**
|
|
95
|
+
* .what = the two ROOT primitives a consumer needs to validate a border in a chain of their own
|
|
96
|
+
* .why = the advanced-use exports above are middlewares, and the one on the OUTPUT side —
|
|
97
|
+
* `genZodOutputValidationMiddleware` — is positionally ambiguous by its own admission
|
|
98
|
+
* (F33). so a consumer who wanted to validate output safely had exactly one public tool,
|
|
99
|
+
* and it was the foot-gun: the atom was hidden and the risky composite was public
|
|
100
|
+
*
|
|
101
|
+
* these two are unambiguous by construction — each takes the value it validates as an
|
|
102
|
+
* argument rather than reads it out of a slot whose type depends on registration order.
|
|
103
|
+
* so a consumer builds their own correctly-ordered step and the ambiguity never reaches it
|
|
104
|
+
*
|
|
105
|
+
* .note = this does NOT settle F33. that fulcrum asks whether the middleware should keep its
|
|
106
|
+
* export at all, and it belongs to the bound that shipped it
|
|
107
|
+
* (`.behavior/v2026_08_03.feat-apigateway-wire-response/`). what this changes is that the
|
|
108
|
+
* ambiguous export is no longer the ONLY option — which is the half that needed no
|
|
109
|
+
* wisher call, because it breaks no consumer (rule.always.fix-forward-under-scouts-honor)
|
|
110
|
+
*
|
|
111
|
+
* .note = each metadata type rides along for the same reason `LambdaEndpointErrorResponseBody*`
|
|
112
|
+
* does — a consumer who catches the throw must be able to NAME what `.metadata` holds,
|
|
113
|
+
* or they reach for an `as`-cast at the public boundary (rule.forbid.as-cast)
|
|
114
|
+
*/
|
|
115
|
+
var getValidatedInput_1 = require("./domain.operations/genLambdaEndpoint/middleware/getValidatedInput");
|
|
116
|
+
Object.defineProperty(exports, "getValidatedInput", { enumerable: true, get: function () { return getValidatedInput_1.getValidatedInput; } });
|
|
117
|
+
var getValidatedOutput_1 = require("./domain.operations/genLambdaEndpoint/middleware/getValidatedOutput");
|
|
118
|
+
Object.defineProperty(exports, "getValidatedOutput", { enumerable: true, get: function () { return getValidatedOutput_1.getValidatedOutput; } });
|
|
91
119
|
// sdk codegen (generate a per-service sdk from introspection)
|
|
92
120
|
var genServiceSdk_1 = require("./domain.operations/genServiceSdk/genServiceSdk");
|
|
93
121
|
Object.defineProperty(exports, "genServiceSdk", { enumerable: true, get: function () { return genServiceSdk_1.genServiceSdk; } });
|
|
@@ -98,4 +126,25 @@ var getAllLambdaFunctionsByPrefix_1 = require("./domain.operations/getAllLambdaC
|
|
|
98
126
|
Object.defineProperty(exports, "getAllLambdaFunctionsByPrefix", { enumerable: true, get: function () { return getAllLambdaFunctionsByPrefix_1.getAllLambdaFunctionsByPrefix; } });
|
|
99
127
|
var getOneLambdaContract_1 = require("./domain.operations/getOneLambdaContract/getOneLambdaContract");
|
|
100
128
|
Object.defineProperty(exports, "getOneLambdaContract", { enumerable: true, get: function () { return getOneLambdaContract_1.getOneLambdaContract; } });
|
|
129
|
+
// test utils — the run boundary axis (run an endpoint by reference, or by slug)
|
|
130
|
+
var asLambdaContext_1 = require("./domain.operations/runLambdaEndpoint/context/asLambdaContext");
|
|
131
|
+
Object.defineProperty(exports, "asLambdaContext", { enumerable: true, get: function () { return asLambdaContext_1.asLambdaContext; } });
|
|
132
|
+
// the narrows the union needs — a field read on `TOutput | Envelope` does not
|
|
133
|
+
// compile on EITHER arm, and an `as` cast is the only other way through.
|
|
134
|
+
// ⚠️ the success-side narrow was absent until self-review r6. the vision named
|
|
135
|
+
// only the error one, so the MAJORITY case — a read on the handler's own
|
|
136
|
+
// output — had no supported form at all.
|
|
137
|
+
var asLambdaEndpointOutput_1 = require("./domain.operations/runLambdaEndpoint/dialect/asLambdaEndpointOutput");
|
|
138
|
+
Object.defineProperty(exports, "asLambdaEndpointOutput", { enumerable: true, get: function () { return asLambdaEndpointOutput_1.asLambdaEndpointOutput; } });
|
|
139
|
+
// the envelope narrows, one per dialect (F22). contemp reads the codec-versioned
|
|
140
|
+
// tag (EXACT); ancient reads the flat shape (ambiguous by the wire). the caller
|
|
141
|
+
// names the dialect by WHICH function they call — so F9 (dialect-in-the-type)
|
|
142
|
+
// holds with no runtime dialect argument.
|
|
143
|
+
var isLambdaEndpointErrorEnvelope_1 = require("./domain.operations/runLambdaEndpoint/dialect/isLambdaEndpointErrorEnvelope");
|
|
144
|
+
Object.defineProperty(exports, "asLambdaEndpointErrorEnvelopeAncient", { enumerable: true, get: function () { return isLambdaEndpointErrorEnvelope_1.asLambdaEndpointErrorEnvelopeAncient; } });
|
|
145
|
+
Object.defineProperty(exports, "asLambdaEndpointErrorEnvelopeContemp", { enumerable: true, get: function () { return isLambdaEndpointErrorEnvelope_1.asLambdaEndpointErrorEnvelopeContemp; } });
|
|
146
|
+
Object.defineProperty(exports, "isLambdaEndpointErrorEnvelopeAncient", { enumerable: true, get: function () { return isLambdaEndpointErrorEnvelope_1.isLambdaEndpointErrorEnvelopeAncient; } });
|
|
147
|
+
Object.defineProperty(exports, "isLambdaEndpointErrorEnvelopeContemp", { enumerable: true, get: function () { return isLambdaEndpointErrorEnvelope_1.isLambdaEndpointErrorEnvelopeContemp; } });
|
|
148
|
+
var runLambdaEndpoint_1 = require("./domain.operations/runLambdaEndpoint/runLambdaEndpoint");
|
|
149
|
+
Object.defineProperty(exports, "runLambdaEndpoint", { enumerable: true, get: function () { return runLambdaEndpoint_1.runLambdaEndpoint; } });
|
|
101
150
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,gDAAgD;AAChD,iDAAiD;AAAxC,iHAAA,eAAe,OAAA;AAExB;;;;;GAKG;AACH,kEAAkE;AAAzD,6GAAA,aAAa,OAAA;AAWtB,gEAA+D;AAAtD,8GAAA,aAAa,OAAA;AACtB,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AACvB,8FAA6F;AAApF,4IAAA,4BAA4B,OAAA;AACrC,8GAA6G;AAApG,4JAAA,oCAAoC,OAAA;AAC7C,8GAA6G;AAApG,4JAAA,oCAAoC,OAAA;AAC7C,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,gDAAgD;AAChD,iDAAiD;AAAxC,iHAAA,eAAe,OAAA;AAExB;;;;;GAKG;AACH,kEAAkE;AAAzD,6GAAA,aAAa,OAAA;AAWtB,gEAA+D;AAAtD,8GAAA,aAAa,OAAA;AACtB,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AACvB,8FAA6F;AAApF,4IAAA,4BAA4B,OAAA;AACrC,8GAA6G;AAApG,4JAAA,oCAAoC,OAAA;AAC7C,8GAA6G;AAApG,4JAAA,oCAAoC,OAAA;AAC7C,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AAEvB,4EAA2E;AAAlE,0HAAA,mBAAmB,OAAA;AAE5B,4BAA4B;AAC5B,4FAA2F;AAAlF,0IAAA,2BAA2B,OAAA;AACpC,oGAAmG;AAA1F,kJAAA,+BAA+B,OAAA;AACxC,8GAA6G;AAApG,4JAAA,oCAAoC,OAAA;AAC7C,0FAAyF;AAAhF,wIAAA,0BAA0B,OAAA;AAKnC,oBAAoB;AACpB,6FAA4F;AAAnF,sHAAA,iBAAiB,OAAA;AAC1B,mGAAkG;AAAzF,sHAAA,iBAAiB,OAAA;AAC1B,yGAAwG;AAA/F,4HAAA,oBAAoB,OAAA;AAC7B,eAAe;AACf,0FAAyF;AAAhF,oHAAA,gBAAgB,OAAA;AACzB,gFAAgF;AAChF,iFAAgF;AAAvE,8GAAA,aAAa,OAAA;AACtB,+IAA8I;AAArI,wIAAA,0BAA0B,OAAA;AAMnC,yJAAsI;AAA7H,gIAAA,aAAa,OAAA;AACtB,mIAAkI;AAAzH,4HAAA,oBAAoB,OAAA;AAC7B,wLAAuL;AAA9K,sKAAA,yCAAyC,OAAA;AAClD,wKAAuK;AAA9J,sJAAA,iCAAiC,OAAA;AAC1C,kKAAiK;AAAxJ,gJAAA,8BAA8B,OAAA;AAUvC,4JAA4I;AAAnI,qIAAA,iBAAiB,OAAA;AAC1B,qKAAoK;AAA3J,kJAAA,+BAA+B,OAAA;AACxC;;;;;;GAMG;AACH,sGAG2E;AAFzE,oHAAA,gBAAgB,OAAA;AAGlB,8HAA6H;AAApH,4IAAA,4BAA4B,OAAA;AACrC,wIAAuI;AAA9H,sJAAA,iCAAiC,OAAA;AAC1C,0HAAyH;AAAhH,wIAAA,0BAA0B,OAAA;AACnC,gHAA+G;AAAtG,8HAAA,qBAAqB,OAAA;AAC9B,gCAAgC;AAChC,0GAAyG;AAAhG,wHAAA,kBAAkB,OAAA;AAC3B,sIAAqI;AAA5H,oJAAA,gCAAgC,OAAA;AAWzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wGAAuG;AAA9F,sHAAA,iBAAiB,OAAA;AAC1B,0GAG6E;AAF3E,wHAAA,kBAAkB,OAAA;AAcpB,8DAA8D;AAC9D,iFAAgF;AAAvE,8GAAA,aAAa,OAAA;AACtB,0CAA0C;AAC1C,yGAIyE;AADvE,8HAAA,qBAAqB,OAAA;AAEvB,wIAAuI;AAA9H,8IAAA,6BAA6B,OAAA;AACtC,sGAIuE;AADrE,4HAAA,oBAAoB,OAAA;AAEtB,gFAAgF;AAChF,iGAAgG;AAAvF,kHAAA,eAAe,OAAA;AACxB,8EAA8E;AAC9E,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,4CAA4C;AAC5C,+GAA8G;AAArG,gIAAA,sBAAsB,OAAA;AAC/B,iFAAiF;AACjF,gFAAgF;AAChF,8EAA8E;AAC9E,0CAA0C;AAC1C,6HAKqF;AAJnF,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AAMtC,6FAA4F;AAAnF,sHAAA,iBAAiB,OAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "sdk-aws-lambda",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "a simple and opinionated sdk for aws lambda. define endpoints, ask endpoints, auto-propagate trace-ids.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.6.0",
|
|
6
6
|
"repository": "ehmpathy/sdk-aws-lambda",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/sdk-aws-lambda",
|
|
8
8
|
"keywords": [
|
|
@@ -68,13 +68,14 @@
|
|
|
68
68
|
"@middy/http-json-body-parser": "4.7.0",
|
|
69
69
|
"@middy/http-response-serializer": "4.7.0",
|
|
70
70
|
"@middy/http-security-headers": "4.7.0",
|
|
71
|
-
"domain-objects": "0.
|
|
71
|
+
"domain-objects": "0.34.0",
|
|
72
72
|
"helpful-errors": "1.7.3",
|
|
73
73
|
"sdk-environment": "0.1.5",
|
|
74
74
|
"sdk-logs": "0.9.0",
|
|
75
75
|
"simple-in-memory-cache": "0.4.0",
|
|
76
76
|
"type-fns": "1.21.4",
|
|
77
77
|
"with-simple-cache": "0.15.3",
|
|
78
|
+
"yaml": "2.9.0",
|
|
78
79
|
"zod": "4.4.3"
|
|
79
80
|
},
|
|
80
81
|
"devDependencies": {
|
|
@@ -106,7 +107,7 @@
|
|
|
106
107
|
"rhachet-brains-xai": "0.3.3",
|
|
107
108
|
"rhachet-roles-bhrain": "0.37.0",
|
|
108
109
|
"rhachet-roles-bhuild": "0.21.36",
|
|
109
|
-
"rhachet-roles-ehmpathy": "1.
|
|
110
|
+
"rhachet-roles-ehmpathy": "1.39.0",
|
|
110
111
|
"rhachet-roles-rhachet": "0.1.7",
|
|
111
112
|
"test-fns": "1.15.8",
|
|
112
113
|
"tsc-alias": "1.8.10",
|
package/readme.md
CHANGED
|
@@ -33,68 +33,197 @@ import { askLambdaEndpoint } from 'sdk-aws-lambda';
|
|
|
33
33
|
|
|
34
34
|
const result = await askLambdaEndpoint<TRequest, TResponse>(
|
|
35
35
|
{
|
|
36
|
-
which: { service: 'svc-jobs',
|
|
36
|
+
which: { service: 'svc-jobs', function: 'getJobByUuid' },
|
|
37
37
|
event: { uuid },
|
|
38
38
|
},
|
|
39
|
-
{ log }, //
|
|
39
|
+
{ log, env: { access: 'prep' } }, // access completes the slug; trail auto-propagates
|
|
40
40
|
);
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
##
|
|
43
|
+
## run an endpoint, in a test
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
| you call | you hold | a caller fault arrives as |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `onReferenced` | the handler **function** | a **returned** envelope |
|
|
48
|
+
| `onSerialized` | the endpoint **slug** | a **thrown** error |
|
|
46
49
|
|
|
47
50
|
```ts
|
|
48
|
-
import {
|
|
51
|
+
import {
|
|
52
|
+
asLambdaEndpointErrorEnvelopeContemp,
|
|
53
|
+
asLambdaEndpointOutput,
|
|
54
|
+
runLambdaEndpoint,
|
|
55
|
+
} from 'sdk-aws-lambda';
|
|
56
|
+
|
|
57
|
+
// you hold the handler, so you see what it returned
|
|
58
|
+
const out = await runLambdaEndpoint.onReferenced({ event: { uuid }, handler });
|
|
59
|
+
expect(asLambdaEndpointOutput(out).found).toEqual(true);
|
|
60
|
+
|
|
61
|
+
// a caller fault RETURNS here — the lambda succeeded, it just rejected the request
|
|
62
|
+
const res = await runLambdaEndpoint.onReferenced({ event: { uuid: 'bad' }, handler });
|
|
63
|
+
expect(asLambdaEndpointErrorEnvelopeContemp(res).error.class).toEqual('ConstraintError');
|
|
64
|
+
|
|
65
|
+
// you hold the slug, so you are a caller — and the same fault THROWS
|
|
66
|
+
await expect(
|
|
67
|
+
runLambdaEndpoint.onSerialized(
|
|
68
|
+
{
|
|
69
|
+
which: { service: 'svc-jobs', function: 'getJobByUuid' },
|
|
70
|
+
event: { uuid: 'bad' },
|
|
71
|
+
at: 'cloud', // or 'local' — resolve the handler from serverless.yml
|
|
72
|
+
},
|
|
73
|
+
{ log, env: { access: 'prep' } },
|
|
74
|
+
),
|
|
75
|
+
).rejects.toThrow(ConstraintError);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
a malfunction throws on both. the util adds no `catch`.
|
|
79
|
+
|
|
80
|
+
the return is a union — `TOutput | Envelope` — so read either arm through a narrow:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
asLambdaEndpointOutput(res).scheduledAt; // the handler's own output
|
|
84
|
+
asLambdaEndpointErrorEnvelopeContemp(res).error.class; // the envelope
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
each throws loud when the endpoint answered with the other shape, so neither needs an `as` cast.
|
|
88
|
+
|
|
89
|
+
### legacy handlers
|
|
90
|
+
|
|
91
|
+
`handler` is a plain `(event, context) => Promise<T>`, so an unmigrated handler works today — it
|
|
92
|
+
just needs its dialect declared:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
await runLambdaEndpoint.onReferenced({
|
|
96
|
+
event,
|
|
97
|
+
handler: createStandardHandler({ logic }),
|
|
98
|
+
struct: { payload: 'ancient' }, // required — see below
|
|
99
|
+
});
|
|
100
|
+
```
|
|
49
101
|
|
|
50
|
-
|
|
102
|
+
`struct.payload` frames what your handler **receives**, not only what it answers:
|
|
103
|
+
|
|
104
|
+
| dialect | your handler receives | your handler answers |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| `contemp` (default) | `{ event, trail }` | the nested `{ error: { class, … } }` |
|
|
107
|
+
| `ancient` | the event, untouched | the flat `{ errorMessage, errorType }` |
|
|
108
|
+
|
|
109
|
+
a `genLambdaEndpoint` handler never notices — its middleware unwraps the frame first. a plain
|
|
110
|
+
handler does: under the contemp default it reads its own fields off a wrapper and finds them absent.
|
|
111
|
+
|
|
112
|
+
## build an event for a source
|
|
113
|
+
|
|
114
|
+
`asLambdaEvent` casts a payload into the envelope aws actually delivers, wire-faithful by default:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { asLambdaEvent } from 'sdk-aws-lambda';
|
|
118
|
+
|
|
119
|
+
const event = asLambdaEvent.fromApiGateway({ body: { slug }, httpMethod: 'POST' });
|
|
120
|
+
const event = asLambdaEvent.fromSqs({ messages: [JSON.stringify(task)] });
|
|
121
|
+
// asLambdaEvent.from$Source(...) // sns, kinesis, s3 too
|
|
122
|
+
|
|
123
|
+
// override only what your test is about — the rest stay wire-faithful
|
|
124
|
+
const event = asLambdaEvent.fromApiGateway({
|
|
125
|
+
body,
|
|
126
|
+
requestContext: { identity: { sourceIp: '10.0.0.1' } },
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## introspection
|
|
131
|
+
|
|
132
|
+
endpoints with zod schemas expose their schema at runtime:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
51
135
|
const schema = await askLambdaEndpoint(
|
|
52
136
|
{
|
|
53
|
-
which: { service: 'svc-user',
|
|
137
|
+
which: { service: 'svc-user', function: 'getUser' },
|
|
54
138
|
event: { introspect: 'schema' },
|
|
55
139
|
},
|
|
56
|
-
{ log },
|
|
140
|
+
{ log, env: { access: 'prep' } },
|
|
57
141
|
);
|
|
58
142
|
// returns: { input: {...jsonSchema}, output: {...jsonSchema} }
|
|
59
143
|
```
|
|
60
144
|
|
|
61
|
-
|
|
145
|
+
requires `env.access === 'prep'`. in prod, it throws a `ConstraintError`.
|
|
146
|
+
|
|
147
|
+
## validate the input only
|
|
62
148
|
|
|
63
|
-
|
|
149
|
+
`schema.output` is required. for an endpoint that returns no value, declare `z.void()`:
|
|
64
150
|
|
|
65
151
|
```ts
|
|
66
|
-
|
|
67
|
-
|
|
152
|
+
export const handler = genLambdaEndpoint(
|
|
153
|
+
{
|
|
154
|
+
schema: { input: inputSchema, output: z.void() },
|
|
155
|
+
invoke: async ({ event }) => { await doTheWork(event); },
|
|
156
|
+
},
|
|
157
|
+
{ env: { access: 'prep' } },
|
|
158
|
+
);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`z.void()`, `z.undefined()`, `z.null()` and `z.never()` each publish an honest contract. avoid
|
|
162
|
+
`z.any()` and `z.unknown()` — they publish `{}`, which tells a caller that **any** value is valid.
|
|
163
|
+
|
|
164
|
+
## domain objects at the border
|
|
68
165
|
|
|
69
|
-
|
|
70
|
-
|
|
166
|
+
declare a domain object in the schema and `invoke` receives the **instance**, not the plain object
|
|
167
|
+
zod yields. no `as` cast, no per-field rebuild:
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import { Surfer } from './domain.objects/Surfer';
|
|
71
171
|
|
|
72
172
|
export const handler = genLambdaEndpoint(
|
|
73
173
|
{
|
|
74
|
-
schema: { input:
|
|
75
|
-
invoke: async ({ event }) =>
|
|
76
|
-
return { name: 'alice', email: 'alice@example.com' };
|
|
77
|
-
},
|
|
174
|
+
schema: { input: z.object({ surfer: Surfer.contract() }), output: z.void() },
|
|
175
|
+
invoke: async ({ event }) => bookSurfLesson(event.surfer), // event.surfer instanceof Surfer
|
|
78
176
|
},
|
|
79
|
-
{ env: { access: 'prep' } },
|
|
177
|
+
{ env: { access: 'prep' } },
|
|
80
178
|
);
|
|
81
179
|
```
|
|
82
180
|
|
|
83
|
-
|
|
181
|
+
`X.contract()` reaches every depth — not the top level alone:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
schema: {
|
|
185
|
+
input: z.object({
|
|
186
|
+
surfer: Surfer.contract(), // depth 0
|
|
187
|
+
signup: z.object({ // a PLAIN wrapper...
|
|
188
|
+
spot: SurfSpot.contract(), // ...and the dobj one level under it
|
|
189
|
+
}).nullable(),
|
|
190
|
+
boards: z.array(Surfboard.contract()), // every element of the array
|
|
191
|
+
report: WaveReport.contract(), // its `static nested` rebuilds `report.spot`
|
|
192
|
+
}),
|
|
193
|
+
output: z.void(),
|
|
194
|
+
},
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
a value that fails the domain object's own constructor **fails loud at the border** and never reaches
|
|
198
|
+
`invoke` half-built.
|
|
199
|
+
|
|
200
|
+
what a caller of your generated cross-service client sees is the **wire** shape —
|
|
201
|
+
`{ surfer: { uuid, name } }` — never the instance. the two differ by design: the wire is what
|
|
202
|
+
crosses, the instance is what you hold once through.
|
|
203
|
+
|
|
204
|
+
two syntax notes:
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
// a dobj that names ITSELF must defer, per js class-field order
|
|
208
|
+
static schema = z.object({ replies: z.array(z.lazy(() => Comment.contract())) });
|
|
209
|
+
|
|
210
|
+
// .ref() goes on the raw contract, before any chain
|
|
211
|
+
z.object({ rider: Surfer.contract().ref('primary') }).optional()
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## contract discovery
|
|
84
215
|
|
|
85
216
|
```ts
|
|
86
217
|
import { getAllLambdaContracts, getOneLambdaContract } from 'sdk-aws-lambda';
|
|
87
218
|
|
|
88
|
-
// get schema for one endpoint
|
|
89
219
|
const contract = await getOneLambdaContract(
|
|
90
|
-
{ which: { service: 'svc-user',
|
|
91
|
-
{ env: { region: 'us-east-1' } },
|
|
220
|
+
{ which: { service: 'svc-user', function: 'getUser' } },
|
|
221
|
+
{ env: { access: 'prep', region: 'us-east-1' } },
|
|
92
222
|
);
|
|
93
223
|
|
|
94
|
-
// get schemas for all endpoints in a service (keyed by bare function name)
|
|
95
224
|
const contracts = await getAllLambdaContracts(
|
|
96
|
-
{ which: { service: 'svc-user'
|
|
97
|
-
{ env: { region: 'us-east-1' } },
|
|
225
|
+
{ which: { service: 'svc-user' } },
|
|
226
|
+
{ env: { access: 'prep', region: 'us-east-1' } },
|
|
98
227
|
);
|
|
99
228
|
// returns: { getUser: {...schema}, getSettings: {...schema} }
|
|
100
229
|
```
|
|
@@ -109,10 +238,10 @@ import { forApiGateway, asApiGatewayResponseSchema } from 'sdk-aws-lambda';
|
|
|
109
238
|
|
|
110
239
|
export const handler = forApiGateway({
|
|
111
240
|
schema: {
|
|
112
|
-
input: z.any(),
|
|
113
|
-
output: asApiGatewayResponseSchema({ body: z.undefined() }),
|
|
241
|
+
input: z.any(), // a twilio form blob
|
|
242
|
+
output: asApiGatewayResponseSchema({ body: z.undefined() }), // carries no body
|
|
114
243
|
},
|
|
115
|
-
invoke: async ({ event }) => ({ status: 204 }),
|
|
244
|
+
invoke: async ({ event }) => ({ status: 204 }), // 204, no body
|
|
116
245
|
});
|
|
117
246
|
```
|
|
118
247
|
|
|
@@ -127,36 +256,47 @@ export const handler = forApiGateway({
|
|
|
127
256
|
set a `Content-Type` yourself and the serializer stands aside, so xml/text reach the wire
|
|
128
257
|
byte-identical. omit it with a body and you get `application/json`.
|
|
129
258
|
|
|
130
|
-
###
|
|
259
|
+
### the body-less response
|
|
131
260
|
|
|
132
261
|
`schema.output` describes what `invoke` **returns** (the envelope), so
|
|
133
|
-
`asApiGatewayResponseSchema({ body })` wraps a body schema into it.
|
|
134
|
-
|
|
135
|
-
|
|
262
|
+
`asApiGatewayResponseSchema({ body })` wraps a body schema into it.
|
|
263
|
+
|
|
264
|
+
for a response that carries **no body at all** — a 204, a redirect — declare the body
|
|
265
|
+
`z.undefined()`:
|
|
266
|
+
|
|
267
|
+
<!-- prettier-ignore -->
|
|
268
|
+
| you declare | the published `body` slot | reads as |
|
|
269
|
+
|---|---|---|
|
|
270
|
+
| `z.undefined()` · `z.void()` · `z.never()` | `{ "not": {} }` | **"no body is ever carried"** |
|
|
271
|
+
| `z.any()` · `z.unknown()` | `{}` | ⛔ the rubber-stamp — every value reads as valid |
|
|
272
|
+
| `z.null()` | `{ "type": "null" }` | ⛔ claims the wire carries the four bytes `null` |
|
|
273
|
+
|
|
274
|
+
all of them behave identically at **runtime**: each accepts `{ status: 204 }` and each still refuses
|
|
275
|
+
an accidental `{ body: 'oops' }`. only the published contract differs, which is why the wrong choice
|
|
276
|
+
ships green.
|
|
136
277
|
|
|
137
278
|
# features
|
|
138
279
|
|
|
139
|
-
- **genLambdaEndpoint** — define
|
|
280
|
+
- **genLambdaEndpoint** — define endpoints with validation, log capture, error classification
|
|
140
281
|
- `genLambdaEndpoint()` — direct invoke (default)
|
|
141
282
|
- `forApiGateway()` — http via api gateway, with full wire-response control (above)
|
|
283
|
+
- **domain objects at the border** — `X.contract()` in a schema hands `invoke` real instances, at
|
|
284
|
+
every depth, with no `as` cast (above)
|
|
142
285
|
- **askLambdaEndpoint** — ask another lambda with typed request/response, automatic trail propagation
|
|
143
|
-
- **
|
|
286
|
+
- **runLambdaEndpoint** — run an endpoint from a test
|
|
287
|
+
- `onReferenced()` — you hold the handler; a caller fault is **returned**
|
|
288
|
+
- `onSerialized()` — you hold the slug; a caller fault **throws**. `at: 'cloud' | 'local'`
|
|
289
|
+
- **asLambdaEvent** — cast a payload into the envelope aws delivers, wire-faithful by default
|
|
290
|
+
- `fromApiGateway()`, `fromSqs()`, `fromSns()`, `fromKinesis()`, `fromS3()`
|
|
291
|
+
- **trace-id propagation** — pass `log`, and `trail.exid` threads through the call chain
|
|
144
292
|
- **introspection** — expose json-schema via `{ introspect: 'schema' }` (prep only)
|
|
145
293
|
- **contract discovery** — `getOneLambdaContract`, `getAllLambdaContracts` for sdk generation
|
|
146
294
|
|
|
147
295
|
# docs
|
|
148
296
|
|
|
149
|
-
|
|
150
|
-
above — you need read no further to use the package.
|
|
151
|
-
|
|
152
|
-
the links below are **internal design records**, kept for a maintainer who wants the reasons:
|
|
297
|
+
design records, on github only — they ship in no tarball.
|
|
153
298
|
|
|
154
|
-
-
|
|
155
|
-
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
<!-- prettier-ignore -->
|
|
159
|
-
| record | holds |
|
|
160
|
-
|---|---|
|
|
161
|
-
| [the wire-response design](./.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md) | why the contract widened rather than grew a peer, its four named pipeline points, and each deferred defect with its clamp |
|
|
162
|
-
| [the endpoint vocabulary](./.behavior/v2026_05_08.rename/1.vision.yield.md) | how `LambdaEndpoint` and its slug were named |
|
|
299
|
+
- [run boundary](./.agent/repo=.this/role=any/briefs/define.lambda-endpoint-run-boundary.md) — serialized vs referenced, and why the error stance inverts
|
|
300
|
+
- [event source](./.agent/repo=.this/role=any/briefs/define.lambda-event-source.md) — which envelope each aws source wraps a payload in
|
|
301
|
+
- [wire response](./.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md) — how the api-gateway response contract was shaped
|
|
302
|
+
- [endpoint vocabulary](./.behavior/v2026_05_08.rename/1.vision.yield.md) — how `LambdaEndpoint` and its slug were named
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getExidFromContext.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/context/getExidFromContext.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC;;;;;GAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAElC,EAAuD,EAAE;IACxD,8BAA8B;IAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC;IACpC,IAAI,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAE/C,kDAAkD;IAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAA,mBAAU,GAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAC/D,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLogForExidExtraction.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/context/getLogForExidExtraction.ts"],"names":[],"mappings":";;;AAUA;;;;;;;GAOG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAEvC,EAAoD,EAAE;IACrD,IAAI,CAAC,KAAK,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC7C,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;AAC3D,CAAC,CAAC;AANW,QAAA,uBAAuB,2BAMlC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* contemp error response shape from genLambdaEndpoint
|
|
3
|
-
* .note = has explicit _serde discriminator for clean detection
|
|
4
|
-
*/
|
|
5
|
-
export interface LambdaErrorResponseContemp {
|
|
6
|
-
error: {
|
|
7
|
-
_serde: 'LambdaEndpointError::contemp';
|
|
8
|
-
class: string;
|
|
9
|
-
message: string;
|
|
10
|
-
cause?: string;
|
|
11
|
-
details?: unknown;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* ancient error response shape from AWS Lambda or old genLambdaEndpoint
|
|
16
|
-
* .note = stackTrace can be string[] (aws native) or string (genLambdaEndpoint)
|
|
17
|
-
*/
|
|
18
|
-
export interface LambdaErrorResponseAncient {
|
|
19
|
-
errorMessage: string;
|
|
20
|
-
errorType?: string;
|
|
21
|
-
stackTrace?: string[] | string;
|
|
22
|
-
/**
|
|
23
|
-
* validation issues or other error details from genLambdaEndpoint
|
|
24
|
-
* .note = genConstraintErrorMiddleware sends error.metadata as details
|
|
25
|
-
*/
|
|
26
|
-
details?: unknown;
|
|
27
|
-
/**
|
|
28
|
-
* cause error message from genLambdaEndpoint
|
|
29
|
-
* .note = genConstraintErrorMiddleware sends error.cause.message as causeMessage
|
|
30
|
-
*/
|
|
31
|
-
causeMessage?: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* .what = checks if parsed response is a contemp lambda error response
|
|
35
|
-
* .why = contemp errors have { error: { _serde: 'LambdaEndpointError::contemp' } }
|
|
36
|
-
*/
|
|
37
|
-
export declare const getIsContempErrorResponse: (parsed: unknown) => parsed is LambdaErrorResponseContemp;
|
|
38
|
-
/**
|
|
39
|
-
* .what = checks if parsed response is an ancient lambda error response
|
|
40
|
-
* .why = ancient errors have flat errorMessage property
|
|
41
|
-
*/
|
|
42
|
-
export declare const getIsAncientErrorResponse: (parsed: unknown) => parsed is LambdaErrorResponseAncient;
|