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
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = decide whether an error is an aws sdk credentials failure, ANYWHERE in
|
|
3
|
+
* its cause chain
|
|
4
|
+
* .why = a creds failure is caller-must-fix (unlock + retry) at every boundary a
|
|
5
|
+
* DEVELOPER drives, so it is worth a named error rather than aws's own
|
|
6
|
+
*
|
|
7
|
+
* 🔴 the CHAIN WALK removes a dependency on a peer file's message format. the
|
|
8
|
+
* invoke path wraps first (`executeLambdaInvocation.ts:63`), so the top-level
|
|
9
|
+
* name is `LambdaEndpointError` and the only thing that carries *"credentials"*
|
|
10
|
+
* up to it is an interpolated `${error.message}` — a format choice a reasonable
|
|
11
|
+
* edit would quietly end.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ probed: a detector reduced to a top-level read leaves `[case12]` GREEN, so
|
|
14
|
+
* the walk is not what makes the invoke path work today. `[case2]` of this
|
|
15
|
+
* file's unit suite is what bites.
|
|
16
|
+
*
|
|
17
|
+
* ⇒ a belt-and-braces guard on a live coupling, worth its four lines because a
|
|
18
|
+
* dead detector fails QUIET — it returns `false`, the error rethrows, and the
|
|
19
|
+
* developer is back to aws's own string with no test red.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getIsCredentialsError: (error: unknown, seen?: Set<unknown>) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* .what = maps an aws credentials failure to a hinted `LambdaCredentialsAbsentError`;
|
|
24
|
+
* rethrows every other error unchanged
|
|
25
|
+
* .why = an absent credential is the one aws fault a developer fixes in ONE
|
|
26
|
+
* command, and aws's *"Could not load credentials from any providers"* says
|
|
27
|
+
* naught about which env, which owner, or what to run.
|
|
28
|
+
*
|
|
29
|
+
* 🔴 the boundary this must NOT be wired into: `askLambdaEndpoint`, a RUNTIME
|
|
30
|
+
* caller. same aws error, opposite diagnosis —
|
|
31
|
+
*
|
|
32
|
+
* | boundary | who meets it | an absent credential is |
|
|
33
|
+
* |---|---|---|
|
|
34
|
+
* | `getAllLambdaContracts`, `onSerialized({ at: 'cloud' })` | a developer, at a terminal | an expired sso session |
|
|
35
|
+
* | `askLambdaEndpoint` | a deployed lambda, in prod | a broken execution role |
|
|
36
|
+
*
|
|
37
|
+
* `LambdaCredentialsAbsentError extends ConstraintError` ⇒ caller fault, no
|
|
38
|
+
* retry, NO ALARM (invariant.badrequesterror-not-lambda-error). to map it on
|
|
39
|
+
* the runtime path would suppress the prod alarm that names a broken role.
|
|
40
|
+
*
|
|
41
|
+
* ⚠️ so the runtime path's lack of this mapper is a DESIGN, not a gap.
|
|
42
|
+
*/
|
|
43
|
+
export declare const throwIfCredentialsError: (input: {
|
|
44
|
+
error: unknown;
|
|
45
|
+
message: string;
|
|
46
|
+
/**
|
|
47
|
+
* .what = the env the caller addressed, so the hint names THEIR env
|
|
48
|
+
* .why = a hardcoded `--env prep` names the WRONG env for a `prod` caller, and
|
|
49
|
+
* a wrong hint is worse than none — it reads authoritative and sends the
|
|
50
|
+
* developer to unlock a credential that was never the one absent.
|
|
51
|
+
*/
|
|
52
|
+
access: string;
|
|
53
|
+
metadata: Record<string, unknown>;
|
|
54
|
+
}) => never;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.throwIfCredentialsError = exports.getIsCredentialsError = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const LambdaCredentialsAbsentError_1 = require("../../../domain.objects/LambdaCredentialsAbsentError");
|
|
6
|
+
/**
|
|
7
|
+
* .what = decide whether an error is an aws sdk credentials failure, ANYWHERE in
|
|
8
|
+
* its cause chain
|
|
9
|
+
* .why = a creds failure is caller-must-fix (unlock + retry) at every boundary a
|
|
10
|
+
* DEVELOPER drives, so it is worth a named error rather than aws's own
|
|
11
|
+
*
|
|
12
|
+
* 🔴 the CHAIN WALK removes a dependency on a peer file's message format. the
|
|
13
|
+
* invoke path wraps first (`executeLambdaInvocation.ts:63`), so the top-level
|
|
14
|
+
* name is `LambdaEndpointError` and the only thing that carries *"credentials"*
|
|
15
|
+
* up to it is an interpolated `${error.message}` — a format choice a reasonable
|
|
16
|
+
* edit would quietly end.
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ probed: a detector reduced to a top-level read leaves `[case12]` GREEN, so
|
|
19
|
+
* the walk is not what makes the invoke path work today. `[case2]` of this
|
|
20
|
+
* file's unit suite is what bites.
|
|
21
|
+
*
|
|
22
|
+
* ⇒ a belt-and-braces guard on a live coupling, worth its four lines because a
|
|
23
|
+
* dead detector fails QUIET — it returns `false`, the error rethrows, and the
|
|
24
|
+
* developer is back to aws's own string with no test red.
|
|
25
|
+
*/
|
|
26
|
+
const getIsCredentialsError = (error,
|
|
27
|
+
// 🔴 a SET, never a `cause === error` self-compare — that catches a one-step
|
|
28
|
+
// cycle and recurses to `RangeError` on a two-step one (`A→B→A`). a stack
|
|
29
|
+
// overflow REPLACES the real error with a crash that names neither the fault
|
|
30
|
+
// nor the fix, which is worse than the quiet failure above.
|
|
31
|
+
seen = new Set()) => {
|
|
32
|
+
// 🔴 `instanceof Error`, NOT the shared `isErrorLike` duck-type: the line below
|
|
33
|
+
// reads `error.name`, which a `.message`-only shape check does not guarantee.
|
|
34
|
+
// the cross-realm risk is bounded here — both callers raise the aws sdk error
|
|
35
|
+
// in-realm, so a realm-foreign `Error` cannot reach this gate.
|
|
36
|
+
if (!(error instanceof Error))
|
|
37
|
+
return false;
|
|
38
|
+
if (seen.has(error))
|
|
39
|
+
return false;
|
|
40
|
+
seen.add(error);
|
|
41
|
+
const name = error.name.toLowerCase();
|
|
42
|
+
const message = error.message.toLowerCase();
|
|
43
|
+
/**
|
|
44
|
+
* 🔴 the MESSAGE arm reads AWS's vocabulary, so it applies only to an error aws
|
|
45
|
+
* raised. a `HelpfulError`'s `.message` at these boundaries is most often the
|
|
46
|
+
* HANDLER's own text — `getParsedResponse` hydrates a caller fault into a
|
|
47
|
+
* bare `ConstraintError` that carries whatever the endpoint rejected with.
|
|
48
|
+
*
|
|
49
|
+
* ⇒ so an endpoint whose DOMAIN is credentials rejects with *"credential is
|
|
50
|
+
* invalid for this surfer"*, and an unguarded match would send the
|
|
51
|
+
* developer to unlock a credential that was never absent — a hint that is
|
|
52
|
+
* confident and wrong, which is worse than none.
|
|
53
|
+
*
|
|
54
|
+
* ✅ it costs no reach: a genuine aws fault wrapped by a `HelpfulError` is still
|
|
55
|
+
* found through `metadata.cause`, where both arms apply.
|
|
56
|
+
*
|
|
57
|
+
* 🟡 the NAME arm is left unguarded — a class name does not survive the wire.
|
|
58
|
+
*/
|
|
59
|
+
const isAwsRaised = !(error instanceof helpful_errors_1.HelpfulError);
|
|
60
|
+
const isMatchHere = name.includes('credential') ||
|
|
61
|
+
(isAwsRaised &&
|
|
62
|
+
(message.includes('credential') ||
|
|
63
|
+
(message.includes('security token') && message.includes('expired'))));
|
|
64
|
+
if (isMatchHere)
|
|
65
|
+
return true;
|
|
66
|
+
// walk the cause, so a wrap at any depth cannot hide the fault. `cause` is
|
|
67
|
+
// read off both the standard `Error.cause` and `helpful-errors`' metadata,
|
|
68
|
+
// which is where this repo's own wrappers put it.
|
|
69
|
+
const cause = error.cause ??
|
|
70
|
+
error.metadata?.cause;
|
|
71
|
+
if (cause === undefined)
|
|
72
|
+
return false;
|
|
73
|
+
return (0, exports.getIsCredentialsError)(cause, seen);
|
|
74
|
+
};
|
|
75
|
+
exports.getIsCredentialsError = getIsCredentialsError;
|
|
76
|
+
/**
|
|
77
|
+
* .what = maps an aws credentials failure to a hinted `LambdaCredentialsAbsentError`;
|
|
78
|
+
* rethrows every other error unchanged
|
|
79
|
+
* .why = an absent credential is the one aws fault a developer fixes in ONE
|
|
80
|
+
* command, and aws's *"Could not load credentials from any providers"* says
|
|
81
|
+
* naught about which env, which owner, or what to run.
|
|
82
|
+
*
|
|
83
|
+
* 🔴 the boundary this must NOT be wired into: `askLambdaEndpoint`, a RUNTIME
|
|
84
|
+
* caller. same aws error, opposite diagnosis —
|
|
85
|
+
*
|
|
86
|
+
* | boundary | who meets it | an absent credential is |
|
|
87
|
+
* |---|---|---|
|
|
88
|
+
* | `getAllLambdaContracts`, `onSerialized({ at: 'cloud' })` | a developer, at a terminal | an expired sso session |
|
|
89
|
+
* | `askLambdaEndpoint` | a deployed lambda, in prod | a broken execution role |
|
|
90
|
+
*
|
|
91
|
+
* `LambdaCredentialsAbsentError extends ConstraintError` ⇒ caller fault, no
|
|
92
|
+
* retry, NO ALARM (invariant.badrequesterror-not-lambda-error). to map it on
|
|
93
|
+
* the runtime path would suppress the prod alarm that names a broken role.
|
|
94
|
+
*
|
|
95
|
+
* ⚠️ so the runtime path's lack of this mapper is a DESIGN, not a gap.
|
|
96
|
+
*/
|
|
97
|
+
const throwIfCredentialsError = (input) => {
|
|
98
|
+
if (!(0, exports.getIsCredentialsError)(input.error))
|
|
99
|
+
throw input.error;
|
|
100
|
+
throw new LambdaCredentialsAbsentError_1.LambdaCredentialsAbsentError(input.message, {
|
|
101
|
+
...input.metadata,
|
|
102
|
+
hint: `unlock aws creds (e.g. \`rhx keyrack unlock --owner ehmpath --env ${input.access}\`), then re-run`,
|
|
103
|
+
cause: input.error instanceof Error ? input.error : undefined,
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
exports.throwIfCredentialsError = throwIfCredentialsError;
|
|
107
|
+
//# sourceMappingURL=throwIfCredentialsError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throwIfCredentialsError.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/error/throwIfCredentialsError.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAE9C,uGAAoG;AAEpG;;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yBAmDhC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAavC,EAAS,EAAE;IACV,IAAI,CAAC,IAAA,6BAAqB,EAAC,KAAK,CAAC,KAAK,CAAC;QAAE,MAAM,KAAK,CAAC,KAAK,CAAC;IAC3D,MAAM,IAAI,2DAA4B,CAAC,KAAK,CAAC,OAAO,EAAE;QACpD,GAAG,KAAK,CAAC,QAAQ;QACjB,IAAI,EAAE,qEAAqE,KAAK,CAAC,MAAM,kBAAkB;QACzG,KAAK,EAAE,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;KAC9D,CAAC,CAAC;AACL,CAAC,CAAC;AApBW,QAAA,uBAAuB,2BAoBlC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* .what = wrapped payload format with event and trail
|
|
3
3
|
* .why = askLambdaEndpoint sends this format for trail propagation
|
|
4
|
+
*
|
|
5
|
+
* .note = it lives at this common ancestor because THREE contexts touch the
|
|
6
|
+
* frame — `askLambdaEndpoint` emits it over the wire, `asFramedPayload` emits
|
|
7
|
+
* it in-process, and `getUnwrappedEventWithExid` reads it. a detector parked
|
|
8
|
+
* inside the reader forces both emitters to reach in
|
|
9
|
+
* (`rule.prefer.most-common-denominator`).
|
|
4
10
|
*/
|
|
5
11
|
export interface WrappedPayload<TEvent = unknown> {
|
|
6
12
|
event: TEvent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getIsWrappedPayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/frame/getIsWrappedPayload.ts"],"names":[],"mappings":";;;AAeA;;;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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { LambdaEndpoint } from '../../domain.objects/LambdaEndpoint';
|
|
2
|
+
/**
|
|
3
|
+
* .what = reads a lambda's raw wire response, and throws whatever fault it carries
|
|
4
|
+
* .why = this is the SERIALIZED boundary's hydration step — the one place a
|
|
5
|
+
* returned error envelope becomes a thrown error, which is what makes a
|
|
6
|
+
* caller's experience differ from the host's
|
|
7
|
+
* (`define.lambda-endpoint-run-boundary`)
|
|
8
|
+
*
|
|
9
|
+
* 🔴 **the branch order IS the contract, and it is precedence rather than a
|
|
10
|
+
* sequence of independent checks.** each branch wins over the ones below it:
|
|
11
|
+
*
|
|
12
|
+
* | # | when | it throws |
|
|
13
|
+
* |---|---|---|
|
|
14
|
+
* | 1 | the payload is absent or is not json | `LambdaEndpointError` |
|
|
15
|
+
* | 2 | a CONTEMP envelope — `{ error: { _serde, class, … } }` | `ConstraintError` when `class` is one; else `LambdaEndpointError` |
|
|
16
|
+
* | 3 | an ANCIENT envelope — `{ errorMessage, … }` | `ConstraintError` when `errorType` is `ConstraintError` **or** `BadRequestError`; else `LambdaEndpointError` |
|
|
17
|
+
* | 4 | aws reported a `functionError` and no shape above matched | `LambdaEndpointError`, with the payload in `details` |
|
|
18
|
+
* | 5 | none of the above | returns the payload as `TResponse` |
|
|
19
|
+
*
|
|
20
|
+
* ⚠️ **rows 2 and 3 split on the same question and answer it differently**, which
|
|
21
|
+
* is deliberate: a caller's bad request is not a lambda failure, so it
|
|
22
|
+
* hydrates to `ConstraintError` rather than to an invocation error
|
|
23
|
+
* (`invariant.badrequesterror-not-lambda-error`). the ancient arm accepts
|
|
24
|
+
* `BadRequestError` too, because that is the name the legacy family emits for
|
|
25
|
+
* the same fact (`invariant.ancient-vs-contemp-callers`).
|
|
26
|
+
*
|
|
27
|
+
* ⚠️ **row 4 reads aws's own verdict, and it only ever NARROWS** — the block at
|
|
28
|
+
* its site carries the argument.
|
|
29
|
+
*
|
|
30
|
+
* 🟡 **row 3 is LOOSER than its run-side peer by design** — it admits an envelope
|
|
31
|
+
* with no `errorType`, because a lambda that exceeds its duration answers
|
|
32
|
+
* exactly that shape. `getIsLambdaErrorResponse.ts` carries the argument.
|
|
33
|
+
*
|
|
34
|
+
* .note = three fulcrums cite this operation — **F16** (it was lifted here, so
|
|
35
|
+
* both callers share one serde), **F19/F20** (whether its two detectors should
|
|
36
|
+
* share one implementation with the run-side third), and **F17** (why the
|
|
37
|
+
* raw-wire test fixture must NOT route through it: this hydration is precisely
|
|
38
|
+
* what that instrument exists to observe from the outside).
|
|
39
|
+
*/
|
|
40
|
+
export declare const getParsedResponse: <TResponse>(input: {
|
|
41
|
+
payload: Uint8Array | undefined;
|
|
42
|
+
functionError: string | undefined;
|
|
43
|
+
endpoint: LambdaEndpoint;
|
|
44
|
+
exid: string | null;
|
|
45
|
+
}) => TResponse;
|
|
@@ -0,0 +1,173 @@
|
|
|
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("./serde/asUnprefixedErrorMessage");
|
|
10
|
+
const getDecodedPayload_1 = require("./serde/getDecodedPayload");
|
|
11
|
+
const getParsedJson_1 = require("./serde/getParsedJson");
|
|
12
|
+
/**
|
|
13
|
+
* .what = reads a lambda's raw wire response, and throws whatever fault it carries
|
|
14
|
+
* .why = this is the SERIALIZED boundary's hydration step — the one place a
|
|
15
|
+
* returned error envelope becomes a thrown error, which is what makes a
|
|
16
|
+
* caller's experience differ from the host's
|
|
17
|
+
* (`define.lambda-endpoint-run-boundary`)
|
|
18
|
+
*
|
|
19
|
+
* 🔴 **the branch order IS the contract, and it is precedence rather than a
|
|
20
|
+
* sequence of independent checks.** each branch wins over the ones below it:
|
|
21
|
+
*
|
|
22
|
+
* | # | when | it throws |
|
|
23
|
+
* |---|---|---|
|
|
24
|
+
* | 1 | the payload is absent or is not json | `LambdaEndpointError` |
|
|
25
|
+
* | 2 | a CONTEMP envelope — `{ error: { _serde, class, … } }` | `ConstraintError` when `class` is one; else `LambdaEndpointError` |
|
|
26
|
+
* | 3 | an ANCIENT envelope — `{ errorMessage, … }` | `ConstraintError` when `errorType` is `ConstraintError` **or** `BadRequestError`; else `LambdaEndpointError` |
|
|
27
|
+
* | 4 | aws reported a `functionError` and no shape above matched | `LambdaEndpointError`, with the payload in `details` |
|
|
28
|
+
* | 5 | none of the above | returns the payload as `TResponse` |
|
|
29
|
+
*
|
|
30
|
+
* ⚠️ **rows 2 and 3 split on the same question and answer it differently**, which
|
|
31
|
+
* is deliberate: a caller's bad request is not a lambda failure, so it
|
|
32
|
+
* hydrates to `ConstraintError` rather than to an invocation error
|
|
33
|
+
* (`invariant.badrequesterror-not-lambda-error`). the ancient arm accepts
|
|
34
|
+
* `BadRequestError` too, because that is the name the legacy family emits for
|
|
35
|
+
* the same fact (`invariant.ancient-vs-contemp-callers`).
|
|
36
|
+
*
|
|
37
|
+
* ⚠️ **row 4 reads aws's own verdict, and it only ever NARROWS** — the block at
|
|
38
|
+
* its site carries the argument.
|
|
39
|
+
*
|
|
40
|
+
* 🟡 **row 3 is LOOSER than its run-side peer by design** — it admits an envelope
|
|
41
|
+
* with no `errorType`, because a lambda that exceeds its duration answers
|
|
42
|
+
* exactly that shape. `getIsLambdaErrorResponse.ts` carries the argument.
|
|
43
|
+
*
|
|
44
|
+
* .note = three fulcrums cite this operation — **F16** (it was lifted here, so
|
|
45
|
+
* both callers share one serde), **F19/F20** (whether its two detectors should
|
|
46
|
+
* share one implementation with the run-side third), and **F17** (why the
|
|
47
|
+
* raw-wire test fixture must NOT route through it: this hydration is precisely
|
|
48
|
+
* what that instrument exists to observe from the outside).
|
|
49
|
+
*/
|
|
50
|
+
const getParsedResponse = (input) => {
|
|
51
|
+
// validate payload exists
|
|
52
|
+
if (!input.payload) {
|
|
53
|
+
throw new LambdaEndpointError_1.LambdaEndpointError('lambda returned empty payload', {
|
|
54
|
+
endpoint: input.endpoint,
|
|
55
|
+
exid: input.exid,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// decode payload to string
|
|
59
|
+
const payloadString = (0, getDecodedPayload_1.getDecodedPayload)({ payload: input.payload });
|
|
60
|
+
// parse json
|
|
61
|
+
const parseResult = (0, getParsedJson_1.getParsedJson)({ json: payloadString });
|
|
62
|
+
if (!parseResult.success) {
|
|
63
|
+
throw new LambdaEndpointError_1.LambdaEndpointError('lambda returned invalid json', {
|
|
64
|
+
endpoint: input.endpoint,
|
|
65
|
+
exid: input.exid,
|
|
66
|
+
cause: parseResult.error,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const parsed = parseResult.data;
|
|
70
|
+
// detect contemp error response (preferred, check first)
|
|
71
|
+
if ((0, getIsLambdaErrorResponse_1.getIsContempErrorResponse)(parsed)) {
|
|
72
|
+
const err = parsed.error;
|
|
73
|
+
// ConstraintError = caller's fault, not lambda error (lambda succeeded)
|
|
74
|
+
if (err.class === 'ConstraintError') {
|
|
75
|
+
// strip prefix to avoid double prefix (handler already prefixed the message)
|
|
76
|
+
const message = (0, asUnprefixedErrorMessage_1.asUnprefixedErrorMessage)({ message: err.message });
|
|
77
|
+
throw new helpful_errors_1.ConstraintError(message, {
|
|
78
|
+
endpoint: input.endpoint,
|
|
79
|
+
exid: input.exid,
|
|
80
|
+
causeMessage: err.cause,
|
|
81
|
+
details: err.details,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// all other error classes = lambda invocation error
|
|
85
|
+
throw new LambdaEndpointError_1.LambdaEndpointError(err.message, {
|
|
86
|
+
endpoint: input.endpoint,
|
|
87
|
+
exid: input.exid,
|
|
88
|
+
errorType: err.class,
|
|
89
|
+
causeMessage: err.cause,
|
|
90
|
+
details: err.details,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
// detect ancient error response (backwards compat)
|
|
94
|
+
if ((0, getIsLambdaErrorResponse_1.getIsAncientErrorResponse)(parsed)) {
|
|
95
|
+
const stackTrace = (0, getStackTraceString_1.getStackTraceString)({ stackTrace: parsed.stackTrace });
|
|
96
|
+
const errorMeta = (0, getLambdaErrorMetadata_1.getLambdaErrorMetadata)({ errorResponse: parsed });
|
|
97
|
+
// ConstraintError/BadRequestError = caller's fault, not lambda error (lambda succeeded)
|
|
98
|
+
// .note = check both for backwards compat with handlers that use old error types
|
|
99
|
+
if (parsed.errorType === 'ConstraintError' ||
|
|
100
|
+
parsed.errorType === 'BadRequestError') {
|
|
101
|
+
// strip prefix to avoid double prefix (handler already prefixed the message)
|
|
102
|
+
const message = (0, asUnprefixedErrorMessage_1.asUnprefixedErrorMessage)({
|
|
103
|
+
message: parsed.errorMessage,
|
|
104
|
+
});
|
|
105
|
+
throw new helpful_errors_1.ConstraintError(message, {
|
|
106
|
+
endpoint: input.endpoint,
|
|
107
|
+
exid: input.exid,
|
|
108
|
+
stackTrace,
|
|
109
|
+
...errorMeta,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// all other error types = lambda invocation error
|
|
113
|
+
throw new LambdaEndpointError_1.LambdaEndpointError(parsed.errorMessage, {
|
|
114
|
+
endpoint: input.endpoint,
|
|
115
|
+
exid: input.exid,
|
|
116
|
+
errorType: parsed.errorType,
|
|
117
|
+
stackTrace,
|
|
118
|
+
...errorMeta,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 🔴 the LAST WORD goes to aws, because every branch above only GUESSES.
|
|
123
|
+
*
|
|
124
|
+
* `functionError` is aws's own verdict — `'Unhandled'` or `'Handled'` — and it
|
|
125
|
+
* arrives from `sdkLambdaInvoke.ts:38` via `executeLambdaInvocation.ts:86`.
|
|
126
|
+
* every branch above re-derives *"is this an error"* from the payload's SHAPE,
|
|
127
|
+
* which is an inference; this one reads the ground truth.
|
|
128
|
+
*
|
|
129
|
+
* ⚠️ **without it, a fault aws reported whose payload matched neither envelope
|
|
130
|
+
* shape reaches the caller as a SUCCESS** — `rule.forbid.failhide` on a wire
|
|
131
|
+
* boundary, with the answer left unread in the input.
|
|
132
|
+
*
|
|
133
|
+
* ⇒ it only ever NARROWS, which is what makes it safe beside the shape branches:
|
|
134
|
+
*
|
|
135
|
+
* | aws said | shape matched | absent this check | with it |
|
|
136
|
+
* |---|---|---|---|
|
|
137
|
+
* | fault | yes | throws, richly classified | **the same** — the branches above win |
|
|
138
|
+
* | fault | no | 🔴 returned as success | throws |
|
|
139
|
+
* | no fault | — | returns | **returns** |
|
|
140
|
+
*
|
|
141
|
+
* it converts no throw into a return, so it cannot commit the inverse
|
|
142
|
+
* failhide that F20's branch A risks.
|
|
143
|
+
*
|
|
144
|
+
* 🟡 **and it does NOT fail open on the local locus.** `onSerialized.ts` passes
|
|
145
|
+
* `functionError: undefined` because there is no aws to ask, and `undefined`
|
|
146
|
+
* reads here as *"no verdict — trust the shapes"*. ⇒ aws is consulted where
|
|
147
|
+
* it spoke, never assumed silent where it could not.
|
|
148
|
+
*
|
|
149
|
+
* .note = `functionError` is a declared parameter, so it must be READ. a
|
|
150
|
+
* signature that accepts a verdict and never consults it advertises a check
|
|
151
|
+
* it does not perform, which is the shape a reader trusts and should not.
|
|
152
|
+
*/
|
|
153
|
+
if (input.functionError)
|
|
154
|
+
throw new LambdaEndpointError_1.LambdaEndpointError(
|
|
155
|
+
// rule.require.errors-name-the-fix — the metadata shape carries no `hint`
|
|
156
|
+
// field, so the fix rides in the message, which is what a human reads off
|
|
157
|
+
// a stack trace first. `details.payload` carries the shape itself.
|
|
158
|
+
'aws reported a function error, and the payload matched neither error envelope — read details.payload for what the handler actually emitted', {
|
|
159
|
+
endpoint: input.endpoint,
|
|
160
|
+
exid: input.exid,
|
|
161
|
+
errorType: input.functionError,
|
|
162
|
+
details: { payload: parsed },
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
* .cast = TResponse
|
|
166
|
+
* .why = caller specifies expected response type via generic; runtime validation
|
|
167
|
+
* occurs at endpoint via zod schema, not here
|
|
168
|
+
* .removal = add runtime schema validation to askLambdaEndpoint when needed
|
|
169
|
+
*/
|
|
170
|
+
return parsed;
|
|
171
|
+
};
|
|
172
|
+
exports.getParsedResponse = getParsedResponse;
|
|
173
|
+
//# sourceMappingURL=getParsedResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getParsedResponse.js","sourceRoot":"","sources":["../../../src/domain.operations/l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C;QAED,kDAAkD;QAClD,MAAM,IAAI,yCAAmB,CAAC,MAAM,CAAC,YAAY,EAAE;YACjD,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU;YACV,GAAG,SAAS;SACb,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,IAAI,KAAK,CAAC,aAAa;QACrB,MAAM,IAAI,yCAAmB;QAC3B,0EAA0E;QAC1E,0EAA0E;QAC1E,mEAAmE;QACnE,4IAA4I,EAC5I;YACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,KAAK,CAAC,aAAa;YAC9B,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;SAC7B,CACF,CAAC;IAEJ;;;;;OAKG;IACH,OAAO,MAAmB,CAAC;AAC7B,CAAC,CAAC;AA5IW,QAAA,iBAAiB,qBA4I5B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = strips a helpful-errors class prefix from an error message
|
|
3
|
+
* .why = prevents a double prefix when an error crosses the lambda boundary.
|
|
4
|
+
* the handler's error already carries one, and the caller constructs a
|
|
5
|
+
* fresh error from that message — so an unstripped prefix compounds.
|
|
6
|
+
*
|
|
7
|
+
* 🔴 the emoji is OPTIONAL — `helpful-errors` emits `{emoji} {Name}: ` only where
|
|
8
|
+
* the class declares a static emoji, and exactly TWO do (`ConstraintError`
|
|
9
|
+
* `✋`, `MalfunctionError` `💥`). every other subclass emits a bare
|
|
10
|
+
* `{Name}: `, so a pattern anchored on one emoji misses the majority —
|
|
11
|
+
* `BadRequestError` among them, which is the ancient path's own class.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ the class name must end in `Error`, and that bound is what keeps the
|
|
14
|
+
* pattern safe: a bare `^\w+:\s*` would strip the caller's own text, so
|
|
15
|
+
* `field: uuid must be a uuid` would lose `field: `.
|
|
16
|
+
*
|
|
17
|
+
* .note = the `\d*` admits bundler deduplication suffixes (`ConstraintError5`).
|
|
18
|
+
*/
|
|
19
|
+
export declare const asUnprefixedErrorMessage: (input: {
|
|
20
|
+
message: string;
|
|
21
|
+
}) => string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asUnprefixedErrorMessage = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = strips a helpful-errors class prefix from an error message
|
|
6
|
+
* .why = prevents a double prefix when an error crosses the lambda boundary.
|
|
7
|
+
* the handler's error already carries one, and the caller constructs a
|
|
8
|
+
* fresh error from that message — so an unstripped prefix compounds.
|
|
9
|
+
*
|
|
10
|
+
* 🔴 the emoji is OPTIONAL — `helpful-errors` emits `{emoji} {Name}: ` only where
|
|
11
|
+
* the class declares a static emoji, and exactly TWO do (`ConstraintError`
|
|
12
|
+
* `✋`, `MalfunctionError` `💥`). every other subclass emits a bare
|
|
13
|
+
* `{Name}: `, so a pattern anchored on one emoji misses the majority —
|
|
14
|
+
* `BadRequestError` among them, which is the ancient path's own class.
|
|
15
|
+
*
|
|
16
|
+
* ⚠️ the class name must end in `Error`, and that bound is what keeps the
|
|
17
|
+
* pattern safe: a bare `^\w+:\s*` would strip the caller's own text, so
|
|
18
|
+
* `field: uuid must be a uuid` would lose `field: `.
|
|
19
|
+
*
|
|
20
|
+
* .note = the `\d*` admits bundler deduplication suffixes (`ConstraintError5`).
|
|
21
|
+
*/
|
|
22
|
+
const asUnprefixedErrorMessage = (input) => {
|
|
23
|
+
// match "{emoji}? {ClassName}Error{digits}?: {rest}"
|
|
24
|
+
const prefixPattern = /^(?:\S+\s+)?\w*Error\d*:\s*/;
|
|
25
|
+
const match = input.message.match(prefixPattern);
|
|
26
|
+
if (!match) {
|
|
27
|
+
return input.message;
|
|
28
|
+
}
|
|
29
|
+
// strip the prefix
|
|
30
|
+
return input.message.slice(match[0].length);
|
|
31
|
+
};
|
|
32
|
+
exports.asUnprefixedErrorMessage = asUnprefixedErrorMessage;
|
|
33
|
+
//# sourceMappingURL=asUnprefixedErrorMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asUnprefixedErrorMessage.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/serde/asUnprefixedErrorMessage.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,wBAAwB,GAAG,CAAC,KAExC,EAAU,EAAE;IACX,qDAAqD;IACrD,MAAM,aAAa,GAAG,6BAA6B,CAAC;IACpD,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;AAbW,QAAA,wBAAwB,4BAanC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDecodedPayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getParsedJson.js","sourceRoot":"","sources":["../../../../src/domain.operations/lambdaEndpointWire/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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Context } from 'aws-lambda';
|
|
2
|
+
/**
|
|
3
|
+
* .what = casts a partial aws lambda context into a whole one, with defaults
|
|
4
|
+
* .why = a handler receives a `Context` from the runtime. off the runtime, one
|
|
5
|
+
* must be supplied, and every field the author does not care about is
|
|
6
|
+
* noise in their test.
|
|
7
|
+
*
|
|
8
|
+
* 🔴 .jest-free, deliberately
|
|
9
|
+
*
|
|
10
|
+
* this is the shipped twin of `__test_assets__/createTestContext`. that file's
|
|
11
|
+
* peer export `createMockLog` calls `jest.fn()`, and `jest` is a devDependency
|
|
12
|
+
* (`package.json`), so a shipped module that reached it would break a consumer's
|
|
13
|
+
* install while this repo's own suite stayed green — the defect is invisible
|
|
14
|
+
* from here.
|
|
15
|
+
*
|
|
16
|
+
* ⇒ so the pure half ships and the jest-bound half stays private. this file
|
|
17
|
+
* imports no test runner, and none of its transitive imports may either.
|
|
18
|
+
*
|
|
19
|
+
* ✅ **the root-barrel export is DELIBERATE public surface, not a leak** (F6 —
|
|
20
|
+
* *"the lambda `Context` is overridable, and partial"*). an author who wants a
|
|
21
|
+
* bare `Context` without a full `onReferenced` run reaches for this directly;
|
|
22
|
+
* the `Partial<Context>` override is the whole point of the export.
|
|
23
|
+
*/
|
|
24
|
+
export declare const asLambdaContext: (overrides?: Partial<Context>) => Context;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asLambdaContext = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const AwsIdentitySynthetic_1 = require("../../../domain.objects/AwsIdentitySynthetic");
|
|
6
|
+
/**
|
|
7
|
+
* .what = the legacy callback signals, each a LOUD refusal
|
|
8
|
+
* .why = 🔴 **a no-op stub here is a failhide.** `context.fail(error)` is how a
|
|
9
|
+
* callback-style handler reports a fault, so `fail: () => {}` swallows
|
|
10
|
+
* that fault and the run answers `undefined` as though the handler had
|
|
11
|
+
* succeeded (`rule.forbid.failhide`). `done(error)` swallows the same
|
|
12
|
+
* way, and `succeed(result)` drops the handler's whole output.
|
|
13
|
+
*
|
|
14
|
+
* .note = this util takes handlers that return a promise, and only those — the
|
|
15
|
+
* contract F8 declares, on measured evidence that every handler in the
|
|
16
|
+
* population is middy-wrapped and so returns one.
|
|
17
|
+
*
|
|
18
|
+
* 🔴 **F8 named its own weak spot, and this closes it.** an `any`-typed
|
|
19
|
+
* callback handler was to get a promise that never settles — a hang to test
|
|
20
|
+
* timeout, which teaches the author naught. now the first legacy signal it
|
|
21
|
+
* sends throws with the fix in the message.
|
|
22
|
+
*
|
|
23
|
+
* ⇒ `rule.prefer.prevent-over-correct`, rung 3 rather than rung 4: caught at
|
|
24
|
+
* the boundary, before harm, by an error that names the fix.
|
|
25
|
+
*
|
|
26
|
+
* .note = a consumer who genuinely wants the no-op keeps it — `overrides` spread
|
|
27
|
+
* last, so `asLambdaContext({ fail: () => {} })` restores the old shape.
|
|
28
|
+
*/
|
|
29
|
+
const refuseTheLegacyCallbackApi = () => helpful_errors_1.ConstraintError.throw('the handler signalled through the legacy callback api, which runLambdaEndpoint does not support', {
|
|
30
|
+
hint: 'return a promise from the handler instead. a middy-wrapped handler already does; a raw `(event, context, callback) => …` handler must be converted first.',
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* .what = casts a partial aws lambda context into a whole one, with defaults
|
|
34
|
+
* .why = a handler receives a `Context` from the runtime. off the runtime, one
|
|
35
|
+
* must be supplied, and every field the author does not care about is
|
|
36
|
+
* noise in their test.
|
|
37
|
+
*
|
|
38
|
+
* 🔴 .jest-free, deliberately
|
|
39
|
+
*
|
|
40
|
+
* this is the shipped twin of `__test_assets__/createTestContext`. that file's
|
|
41
|
+
* peer export `createMockLog` calls `jest.fn()`, and `jest` is a devDependency
|
|
42
|
+
* (`package.json`), so a shipped module that reached it would break a consumer's
|
|
43
|
+
* install while this repo's own suite stayed green — the defect is invisible
|
|
44
|
+
* from here.
|
|
45
|
+
*
|
|
46
|
+
* ⇒ so the pure half ships and the jest-bound half stays private. this file
|
|
47
|
+
* imports no test runner, and none of its transitive imports may either.
|
|
48
|
+
*
|
|
49
|
+
* ✅ **the root-barrel export is DELIBERATE public surface, not a leak** (F6 —
|
|
50
|
+
* *"the lambda `Context` is overridable, and partial"*). an author who wants a
|
|
51
|
+
* bare `Context` without a full `onReferenced` run reaches for this directly;
|
|
52
|
+
* the `Partial<Context>` override is the whole point of the export.
|
|
53
|
+
*/
|
|
54
|
+
const asLambdaContext = (overrides) => ({
|
|
55
|
+
callbackWaitsForEmptyEventLoop: true,
|
|
56
|
+
functionName: 'run-lambda-endpoint',
|
|
57
|
+
functionVersion: '1',
|
|
58
|
+
invokedFunctionArn: `arn:aws:lambda:${AwsIdentitySynthetic_1.AWS_REGION_SYNTHETIC}:${AwsIdentitySynthetic_1.AWS_ACCOUNT_SYNTHETIC}:function:run-lambda-endpoint`,
|
|
59
|
+
memoryLimitInMB: '128',
|
|
60
|
+
awsRequestId: '00000000-0000-4000-8000-000000000000',
|
|
61
|
+
logGroupName: '/aws/lambda/run-lambda-endpoint',
|
|
62
|
+
logStreamName: 'run-lambda-endpoint',
|
|
63
|
+
getRemainingTimeInMillis: () => 30000,
|
|
64
|
+
done: refuseTheLegacyCallbackApi,
|
|
65
|
+
fail: refuseTheLegacyCallbackApi,
|
|
66
|
+
succeed: refuseTheLegacyCallbackApi,
|
|
67
|
+
...overrides,
|
|
68
|
+
});
|
|
69
|
+
exports.asLambdaContext = asLambdaContext;
|
|
70
|
+
//# sourceMappingURL=asLambdaContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asLambdaContext.js","sourceRoot":"","sources":["../../../../src/domain.operations/runLambdaEndpoint/context/asLambdaContext.ts"],"names":[],"mappings":";;;AACA,mDAAiD;AAEjD,uFAGsD;AAEtD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,0BAA0B,GAAG,GAAU,EAAE,CAC7C,gCAAe,CAAC,KAAK,CACnB,iGAAiG,EACjG;IACE,IAAI,EAAE,2JAA2J;CAClK,CACF,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,MAAM,eAAe,GAAG,CAAC,SAA4B,EAAW,EAAE,CAAC,CAAC;IACzE,8BAA8B,EAAE,IAAI;IACpC,YAAY,EAAE,qBAAqB;IACnC,eAAe,EAAE,GAAG;IACpB,kBAAkB,EAAE,kBAAkB,2CAAoB,IAAI,4CAAqB,+BAA+B;IAClH,eAAe,EAAE,KAAK;IACtB,YAAY,EAAE,sCAAsC;IACpD,YAAY,EAAE,iCAAiC;IAC/C,aAAa,EAAE,qBAAqB;IACpC,wBAAwB,EAAE,GAAG,EAAE,CAAC,KAAM;IACtC,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE,0BAA0B;IAChC,OAAO,EAAE,0BAA0B;IACnC,GAAG,SAAS;CACb,CAAC,CAAC;AAdU,QAAA,eAAe,mBAczB"}
|