sdk-aws-lambda 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts +9 -7
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.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/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 +9 -0
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/readme.md +108 -49
- 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
package/readme.md
CHANGED
|
@@ -33,68 +33,130 @@ 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
|
+
```
|
|
49
77
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
// returns: { input: {...jsonSchema}, output: {...jsonSchema} }
|
|
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
|
|
59
85
|
```
|
|
60
86
|
|
|
61
|
-
|
|
87
|
+
each throws loud when the endpoint answered with the other shape, so neither needs an `as` cast.
|
|
88
|
+
|
|
89
|
+
### legacy handlers
|
|
62
90
|
|
|
63
|
-
|
|
91
|
+
`handler` is a plain `(event, context) => Promise<T>`, so an unmigrated handler works today — it
|
|
92
|
+
just needs its dialect declared:
|
|
64
93
|
|
|
65
94
|
```ts
|
|
66
|
-
|
|
67
|
-
|
|
95
|
+
await runLambdaEndpoint.onReferenced({
|
|
96
|
+
event,
|
|
97
|
+
handler: createStandardHandler({ logic }),
|
|
98
|
+
struct: { payload: 'ancient' }, // required — see below
|
|
99
|
+
});
|
|
100
|
+
```
|
|
68
101
|
|
|
69
|
-
|
|
70
|
-
const outputSchema = z.object({ name: z.string(), email: z.string() });
|
|
102
|
+
`struct.payload` frames what your handler **receives**, not only what it answers:
|
|
71
103
|
|
|
72
|
-
|
|
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
|
|
135
|
+
const schema = await askLambdaEndpoint(
|
|
73
136
|
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return { name: 'alice', email: 'alice@example.com' };
|
|
77
|
-
},
|
|
137
|
+
which: { service: 'svc-user', function: 'getUser' },
|
|
138
|
+
event: { introspect: 'schema' },
|
|
78
139
|
},
|
|
79
|
-
{ env: { access: 'prep' } },
|
|
140
|
+
{ log, env: { access: 'prep' } },
|
|
80
141
|
);
|
|
142
|
+
// returns: { input: {...jsonSchema}, output: {...jsonSchema} }
|
|
81
143
|
```
|
|
82
144
|
|
|
83
|
-
|
|
145
|
+
requires `env.access === 'prep'`. in prod, it throws a `ConstraintError`.
|
|
146
|
+
|
|
147
|
+
## contract discovery
|
|
84
148
|
|
|
85
149
|
```ts
|
|
86
150
|
import { getAllLambdaContracts, getOneLambdaContract } from 'sdk-aws-lambda';
|
|
87
151
|
|
|
88
|
-
// get schema for one endpoint
|
|
89
152
|
const contract = await getOneLambdaContract(
|
|
90
|
-
{ which: { service: 'svc-user',
|
|
91
|
-
{ env: { region: 'us-east-1' } },
|
|
153
|
+
{ which: { service: 'svc-user', function: 'getUser' } },
|
|
154
|
+
{ env: { access: 'prep', region: 'us-east-1' } },
|
|
92
155
|
);
|
|
93
156
|
|
|
94
|
-
// get schemas for all endpoints in a service (keyed by bare function name)
|
|
95
157
|
const contracts = await getAllLambdaContracts(
|
|
96
|
-
{ which: { service: 'svc-user'
|
|
97
|
-
{ env: { region: 'us-east-1' } },
|
|
158
|
+
{ which: { service: 'svc-user' } },
|
|
159
|
+
{ env: { access: 'prep', region: 'us-east-1' } },
|
|
98
160
|
);
|
|
99
161
|
// returns: { getUser: {...schema}, getSettings: {...schema} }
|
|
100
162
|
```
|
|
@@ -136,27 +198,24 @@ see it.
|
|
|
136
198
|
|
|
137
199
|
# features
|
|
138
200
|
|
|
139
|
-
- **genLambdaEndpoint** — define
|
|
201
|
+
- **genLambdaEndpoint** — define endpoints with validation, log capture, error classification
|
|
140
202
|
- `genLambdaEndpoint()` — direct invoke (default)
|
|
141
203
|
- `forApiGateway()` — http via api gateway, with full wire-response control (above)
|
|
142
204
|
- **askLambdaEndpoint** — ask another lambda with typed request/response, automatic trail propagation
|
|
143
|
-
- **
|
|
205
|
+
- **runLambdaEndpoint** — run an endpoint from a test
|
|
206
|
+
- `onReferenced()` — you hold the handler; a caller fault is **returned**
|
|
207
|
+
- `onSerialized()` — you hold the slug; a caller fault **throws**. `at: 'cloud' | 'local'`
|
|
208
|
+
- **asLambdaEvent** — cast a payload into the envelope aws delivers, wire-faithful by default
|
|
209
|
+
- `fromApiGateway()`, `fromSqs()`, `fromSns()`, `fromKinesis()`, `fromS3()`
|
|
210
|
+
- **trace-id propagation** — pass `log`, and `trail.exid` threads through the call chain
|
|
144
211
|
- **introspection** — expose json-schema via `{ introspect: 'schema' }` (prep only)
|
|
145
|
-
- **contract discovery** — `getOneLambdaContract`, `getAllLambdaContracts`
|
|
212
|
+
- **contract discovery** — `getOneLambdaContract`, `getAllLambdaContracts`
|
|
146
213
|
|
|
147
214
|
# docs
|
|
148
215
|
|
|
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:
|
|
216
|
+
design records, on github only — they ship in no tarball.
|
|
153
217
|
|
|
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 |
|
|
218
|
+
- [run boundary](./.agent/repo=.this/role=any/briefs/define.lambda-endpoint-run-boundary.md) — serialized vs referenced, and why the error stance inverts
|
|
219
|
+
- [event source](./.agent/repo=.this/role=any/briefs/define.lambda-event-source.md) — which envelope each aws source wraps a payload in
|
|
220
|
+
- [wire response](./.behavior/v2026_08_03.feat-apigateway-wire-response/1.vision.yield.md) — how the api-gateway response contract was shaped
|
|
221
|
+
- [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;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getIsAncientErrorResponse = exports.getIsContempErrorResponse = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* .what = checks if parsed response is a contemp lambda error response
|
|
6
|
-
* .why = contemp errors have { error: { _serde: 'LambdaEndpointError::contemp' } }
|
|
7
|
-
*/
|
|
8
|
-
const getIsContempErrorResponse = (parsed) => typeof parsed === 'object' &&
|
|
9
|
-
parsed !== null &&
|
|
10
|
-
'error' in parsed &&
|
|
11
|
-
typeof parsed.error === 'object' &&
|
|
12
|
-
parsed.error !== null &&
|
|
13
|
-
parsed.error._serde === 'LambdaEndpointError::contemp';
|
|
14
|
-
exports.getIsContempErrorResponse = getIsContempErrorResponse;
|
|
15
|
-
/**
|
|
16
|
-
* .what = checks if parsed response is an ancient lambda error response
|
|
17
|
-
* .why = ancient errors have flat errorMessage property
|
|
18
|
-
*/
|
|
19
|
-
const getIsAncientErrorResponse = (parsed) => typeof parsed === 'object' && parsed !== null && 'errorMessage' in parsed;
|
|
20
|
-
exports.getIsAncientErrorResponse = getIsAncientErrorResponse;
|
|
21
|
-
//# sourceMappingURL=getIsLambdaErrorResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getIsLambdaErrorResponse.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.ts"],"names":[],"mappings":";;;AAkCA;;;GAGG;AACI,MAAM,yBAAyB,GAAG,CACvC,MAAe,EACuB,EAAE,CACxC,OAAO,MAAM,KAAK,QAAQ;IAC1B,MAAM,KAAK,IAAI;IACf,OAAO,IAAI,MAAM;IACjB,OAAQ,MAAkC,CAAC,KAAK,KAAK,QAAQ;IAC5D,MAAkC,CAAC,KAAK,KAAK,IAAI;IAE/C,MAAkD,CAAC,KAIrD,CAAC,MAAM,KAAK,8BAA8B,CAAC;AAbjC,QAAA,yBAAyB,6BAaQ;AAE9C;;;GAGG;AACI,MAAM,yBAAyB,GAAG,CACvC,MAAe,EACuB,EAAE,CACxC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,cAAc,IAAI,MAAM,CAAC;AAH/D,QAAA,yBAAyB,6BAGsC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLambdaErrorMetadata.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/error/getLambdaErrorMetadata.ts"],"names":[],"mappings":";;;AAWA;;;GAGG;AACI,MAAM,sBAAsB,GAAG,CAAC,KAEtC,EAAuB,EAAE;IACxB,OAAO;QACL,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,KAAK,SAAS,IAAI;YAC/C,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO;SACrC,CAAC;QACF,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,YAAY,KAAK,SAAS,IAAI;YACpD,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,YAAY;SAC/C,CAAC;KACH,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,sBAAsB,0BAWjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getStackTraceString.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/error/getStackTraceString.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAEnC,EAAsB,EAAE;IACvB,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACrD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxE,OAAO,KAAK,CAAC,UAAU,CAAC;AAC1B,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .what = strips helpful-errors emoji prefix from error message
|
|
3
|
-
* .why = prevents double prefix when errors cross lambda boundary
|
|
4
|
-
*
|
|
5
|
-
* helpful-errors prefixes messages with pattern: "✋ {ClassName}: {message}"
|
|
6
|
-
* when we create a new ConstraintError with this message, it adds another prefix
|
|
7
|
-
* e.g., "✋ ConstraintError: ✋ ConstraintError: validation failed"
|
|
8
|
-
*
|
|
9
|
-
* this transformer extracts the original message to avoid duplicate prefixes
|
|
10
|
-
*/
|
|
11
|
-
export declare const asUnprefixedErrorMessage: (input: {
|
|
12
|
-
message: string;
|
|
13
|
-
}) => string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.asUnprefixedErrorMessage = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* .what = strips helpful-errors emoji prefix from error message
|
|
6
|
-
* .why = prevents double prefix when errors cross lambda boundary
|
|
7
|
-
*
|
|
8
|
-
* helpful-errors prefixes messages with pattern: "✋ {ClassName}: {message}"
|
|
9
|
-
* when we create a new ConstraintError with this message, it adds another prefix
|
|
10
|
-
* e.g., "✋ ConstraintError: ✋ ConstraintError: validation failed"
|
|
11
|
-
*
|
|
12
|
-
* this transformer extracts the original message to avoid duplicate prefixes
|
|
13
|
-
*/
|
|
14
|
-
const asUnprefixedErrorMessage = (input) => {
|
|
15
|
-
// match pattern: "✋ {ClassName}: {rest}"
|
|
16
|
-
// .note = class names may have suffixes from bundler deduplication (e.g., ConstraintError5)
|
|
17
|
-
const prefixPattern = /^✋\s+\w+:\s*/;
|
|
18
|
-
const match = input.message.match(prefixPattern);
|
|
19
|
-
if (!match) {
|
|
20
|
-
return input.message;
|
|
21
|
-
}
|
|
22
|
-
// strip the prefix
|
|
23
|
-
return input.message.slice(match[0].length);
|
|
24
|
-
};
|
|
25
|
-
exports.asUnprefixedErrorMessage = asUnprefixedErrorMessage;
|
|
26
|
-
//# sourceMappingURL=asUnprefixedErrorMessage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asUnprefixedErrorMessage.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACI,MAAM,wBAAwB,GAAG,CAAC,KAExC,EAAU,EAAE;IACX,yCAAyC;IACzC,4FAA4F;IAC5F,MAAM,aAAa,GAAG,cAAc,CAAC;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAEjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,mBAAmB;IACnB,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC,CAAC;AAdW,QAAA,wBAAwB,4BAcnC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDecodedPayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/getDecodedPayload.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAA8B,EAAU,EAAE;IAC1E,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getParsedJson.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/getParsedJson.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACI,MAAM,aAAa,GAAG,CAAC,KAAuB,EAAoB,EAAE;IACzE,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACnC,CAAC;QACD,yCAAyC;QACzC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,aAAa,iBAWxB"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { LambdaEndpoint } from '../../../domain.objects/LambdaEndpoint';
|
|
2
|
-
/**
|
|
3
|
-
* .what = parses lambda response payload and throws on error
|
|
4
|
-
* .why = orchestrator composes decode, parse, and error detection
|
|
5
|
-
*
|
|
6
|
-
* supports both contemp and ancient error response shapes:
|
|
7
|
-
* - contemp: { error: { _serde, class, message, cause?, details? } }
|
|
8
|
-
* - ancient: { errorMessage, errorType?, causeMessage?, details? }
|
|
9
|
-
*/
|
|
10
|
-
export declare const getParsedResponse: <TResponse>(input: {
|
|
11
|
-
payload: Uint8Array | undefined;
|
|
12
|
-
functionError: string | undefined;
|
|
13
|
-
endpoint: LambdaEndpoint;
|
|
14
|
-
exid: string | null;
|
|
15
|
-
}) => TResponse;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getParsedResponse = void 0;
|
|
4
|
-
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
-
const LambdaEndpointError_1 = require("../../../domain.objects/LambdaEndpointError");
|
|
6
|
-
const getIsLambdaErrorResponse_1 = require("../error/getIsLambdaErrorResponse");
|
|
7
|
-
const getLambdaErrorMetadata_1 = require("../error/getLambdaErrorMetadata");
|
|
8
|
-
const getStackTraceString_1 = require("../error/getStackTraceString");
|
|
9
|
-
const asUnprefixedErrorMessage_1 = require("./asUnprefixedErrorMessage");
|
|
10
|
-
const getDecodedPayload_1 = require("./getDecodedPayload");
|
|
11
|
-
const getParsedJson_1 = require("./getParsedJson");
|
|
12
|
-
/**
|
|
13
|
-
* .what = parses lambda response payload and throws on error
|
|
14
|
-
* .why = orchestrator composes decode, parse, and error detection
|
|
15
|
-
*
|
|
16
|
-
* supports both contemp and ancient error response shapes:
|
|
17
|
-
* - contemp: { error: { _serde, class, message, cause?, details? } }
|
|
18
|
-
* - ancient: { errorMessage, errorType?, causeMessage?, details? }
|
|
19
|
-
*/
|
|
20
|
-
const getParsedResponse = (input) => {
|
|
21
|
-
// validate payload exists
|
|
22
|
-
if (!input.payload) {
|
|
23
|
-
throw new LambdaEndpointError_1.LambdaEndpointError('lambda returned empty payload', {
|
|
24
|
-
endpoint: input.endpoint,
|
|
25
|
-
exid: input.exid,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
// decode payload to string
|
|
29
|
-
const payloadString = (0, getDecodedPayload_1.getDecodedPayload)({ payload: input.payload });
|
|
30
|
-
// parse json
|
|
31
|
-
const parseResult = (0, getParsedJson_1.getParsedJson)({ json: payloadString });
|
|
32
|
-
if (!parseResult.success) {
|
|
33
|
-
throw new LambdaEndpointError_1.LambdaEndpointError('lambda returned invalid json', {
|
|
34
|
-
endpoint: input.endpoint,
|
|
35
|
-
exid: input.exid,
|
|
36
|
-
cause: parseResult.error,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
const parsed = parseResult.data;
|
|
40
|
-
// detect contemp error response (preferred, check first)
|
|
41
|
-
if ((0, getIsLambdaErrorResponse_1.getIsContempErrorResponse)(parsed)) {
|
|
42
|
-
const err = parsed.error;
|
|
43
|
-
// ConstraintError = caller's fault, not lambda error (lambda succeeded)
|
|
44
|
-
if (err.class === 'ConstraintError') {
|
|
45
|
-
// strip prefix to avoid double prefix (handler already prefixed the message)
|
|
46
|
-
const message = (0, asUnprefixedErrorMessage_1.asUnprefixedErrorMessage)({ message: err.message });
|
|
47
|
-
throw new helpful_errors_1.ConstraintError(message, {
|
|
48
|
-
endpoint: input.endpoint,
|
|
49
|
-
exid: input.exid,
|
|
50
|
-
causeMessage: err.cause,
|
|
51
|
-
details: err.details,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
// all other error classes = lambda invocation error
|
|
55
|
-
throw new LambdaEndpointError_1.LambdaEndpointError(err.message, {
|
|
56
|
-
endpoint: input.endpoint,
|
|
57
|
-
exid: input.exid,
|
|
58
|
-
errorType: err.class,
|
|
59
|
-
causeMessage: err.cause,
|
|
60
|
-
details: err.details,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
// detect ancient error response (backwards compat)
|
|
64
|
-
if ((0, getIsLambdaErrorResponse_1.getIsAncientErrorResponse)(parsed)) {
|
|
65
|
-
const stackTrace = (0, getStackTraceString_1.getStackTraceString)({ stackTrace: parsed.stackTrace });
|
|
66
|
-
const errorMeta = (0, getLambdaErrorMetadata_1.getLambdaErrorMetadata)({ errorResponse: parsed });
|
|
67
|
-
// ConstraintError/BadRequestError = caller's fault, not lambda error (lambda succeeded)
|
|
68
|
-
// .note = check both for backwards compat with handlers that use old error types
|
|
69
|
-
if (parsed.errorType === 'ConstraintError' ||
|
|
70
|
-
parsed.errorType === 'BadRequestError') {
|
|
71
|
-
// strip prefix to avoid double prefix (handler already prefixed the message)
|
|
72
|
-
const message = (0, asUnprefixedErrorMessage_1.asUnprefixedErrorMessage)({
|
|
73
|
-
message: parsed.errorMessage,
|
|
74
|
-
});
|
|
75
|
-
throw new helpful_errors_1.ConstraintError(message, {
|
|
76
|
-
endpoint: input.endpoint,
|
|
77
|
-
exid: input.exid,
|
|
78
|
-
stackTrace,
|
|
79
|
-
...errorMeta,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
// all other error types = lambda invocation error
|
|
83
|
-
throw new LambdaEndpointError_1.LambdaEndpointError(parsed.errorMessage, {
|
|
84
|
-
endpoint: input.endpoint,
|
|
85
|
-
exid: input.exid,
|
|
86
|
-
errorType: parsed.errorType,
|
|
87
|
-
stackTrace,
|
|
88
|
-
...errorMeta,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* .cast = TResponse
|
|
93
|
-
* .why = caller specifies expected response type via generic; runtime validation
|
|
94
|
-
* occurs at endpoint via zod schema, not here
|
|
95
|
-
* .removal = add runtime schema validation to askLambdaEndpoint when needed
|
|
96
|
-
*/
|
|
97
|
-
return parsed;
|
|
98
|
-
};
|
|
99
|
-
exports.getParsedResponse = getParsedResponse;
|
|
100
|
-
//# sourceMappingURL=getParsedResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getParsedResponse.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/getParsedResponse.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getIsWrappedPayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getIsWrappedPayload.ts"],"names":[],"mappings":";;;AASA;;;GAGG;AACH,MAAM,YAAY,GAAG,CAAC,KAAc,EAA8B,EAAE;IAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrE,OAAO,KAAK,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;AACtD,CAAC,CAAC;AAEF;;;GAGG;AACI,MAAM,mBAAmB,GAAG,CACjC,OAAgB,EACmB,EAAE;IACrC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QACzE,OAAO,KAAK,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,GAAG,OAA6C,CAAC;IACxD,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC,CAAC;AAbW,QAAA,mBAAmB,uBAa9B"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getDecodedPayload.js
RENAMED
|
File without changes
|
/package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getParsedJson.d.ts
RENAMED
|
File without changes
|
/package/dist/domain.operations/{askLambdaEndpoint → lambdaEndpointWire}/serde/getParsedJson.js
RENAMED
|
File without changes
|