sdk-aws-lambda 0.7.3 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domain.objects/LambdaEndpointRefusal.d.ts +25 -0
- package/dist/domain.objects/LambdaEndpointRefusal.js +19 -0
- package/dist/domain.objects/LambdaEndpointRefusal.js.map +1 -0
- package/dist/domain.objects/LambdaEndpointRefusedError.d.ts +25 -0
- package/dist/domain.objects/LambdaEndpointRefusedError.js +28 -0
- package/dist/domain.objects/LambdaEndpointRefusedError.js.map +1 -0
- package/dist/domain.objects/LambdaEventSchemaSource.d.ts +26 -0
- package/dist/domain.objects/LambdaEventSchemaSource.js +11 -0
- package/dist/domain.objects/LambdaEventSchemaSource.js.map +1 -0
- package/dist/domain.operations/asLambdaEventSchema/KinesisStreamEventDecoded.d.ts +13 -0
- package/dist/domain.operations/asLambdaEventSchema/KinesisStreamEventDecoded.js +3 -0
- package/dist/domain.operations/asLambdaEventSchema/KinesisStreamEventDecoded.js.map +1 -0
- package/dist/domain.operations/asLambdaEventSchema/SnsEventDecoded.d.ts +19 -0
- package/dist/domain.operations/asLambdaEventSchema/SnsEventDecoded.js +3 -0
- package/dist/domain.operations/asLambdaEventSchema/SnsEventDecoded.js.map +1 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventPayloadSchema.d.ts +37 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventPayloadSchema.js +57 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventPayloadSchema.js.map +1 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.d.ts +39 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromKinesis.d.ts +61 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromKinesis.js +89 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromKinesis.js.map +1 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromSns.d.ts +58 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromSns.js +81 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromSns.js.map +1 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.js +45 -0
- package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.d.ts +3 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.d.ts +11 -2
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.js +7 -2
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.d.ts +10 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.js +17 -5
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/cache/asAskLambdaCacheKeyOfRefusal.d.ts +17 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/asAskLambdaCacheKeyOfRefusal.js +22 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/asAskLambdaCacheKeyOfRefusal.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.d.ts +2 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js +1 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.d.ts +9 -5
- package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.js +27 -9
- package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/serde/asLambdaEndpointRefusal.d.ts +15 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asLambdaEndpointRefusal.js +43 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asLambdaEndpointRefusal.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getIsHttpThrottle.d.ts +11 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getIsHttpThrottle.js +15 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getIsHttpThrottle.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js +9 -2
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genLambdaEventRefusedLogMiddleware.d.ts +25 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genLambdaEventRefusedLogMiddleware.js +66 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genLambdaEventRefusedLogMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/getAllLambdaEventIds.d.ts +12 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/getAllLambdaEventIds.js +42 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/getAllLambdaEventIds.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/logLambdaEventRefused.d.ts +27 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/logLambdaEventRefused.js +103 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/logLambdaEventRefused.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forSqs → middleware}/asCallerFault.d.ts +4 -3
- package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forSqs → middleware}/asCallerFault.js +5 -4
- package/dist/domain.operations/genLambdaEndpoint/middleware/asCallerFault.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/asLogMethodOfFailure.d.ts +17 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/asLogMethodOfFailure.js +26 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/asLogMethodOfFailure.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js +2 -2
- package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.d.ts +15 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js +34 -13
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js.map +1 -1
- package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.js +1 -1
- package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.js.map +1 -1
- package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.d.ts +2 -0
- package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js +8 -4
- package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js.map +1 -1
- package/dist/domain.operations/lambdaEndpointWire/error/asErrorFromPeerRefusal.d.ts +22 -0
- package/dist/domain.operations/lambdaEndpointWire/error/asErrorFromPeerRefusal.js +34 -0
- package/dist/domain.operations/lambdaEndpointWire/error/asErrorFromPeerRefusal.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneLambdaEventSchemaSource.d.ts +15 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneLambdaEventSchemaSource.js +50 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/getOneLambdaEventSchemaSource.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/setLambdaEventSchemaSource.d.ts +27 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/setLambdaEventSchemaSource.js +31 -0
- package/dist/domain.operations/lambdaEndpointWire/frame/setLambdaEventSchemaSource.js.map +1 -0
- package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.d.ts +15 -4
- package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js +32 -17
- package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js.map +1 -1
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js +12 -0
- package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js.map +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +10 -8
- package/readme.md +115 -2
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.js.map +0 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromSns = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const setLambdaEventSchemaSource_1 = require("../lambdaEndpointWire/frame/setLambdaEventSchemaSource");
|
|
6
|
+
const asLambdaEventPayloadSchema_1 = require("./asLambdaEventPayloadSchema");
|
|
7
|
+
/**
|
|
8
|
+
* .what = the schema of the sns envelope, with the message slot supplied
|
|
9
|
+
* .why = one envelope serves both call forms; only the message slot differs (the wire string
|
|
10
|
+
* alone, or the decoded payload)
|
|
11
|
+
* .note = loose objects: a key aws adds later is kept, never stripped or refused (F4)
|
|
12
|
+
* .note = the cert url and unsubscribe url keys are optional: aws's own docs sample spells the
|
|
13
|
+
* first with `URL`, and `@types/aws-lambda` records the dispute (F10). `Subject` is
|
|
14
|
+
* nullish: sns sends `null` for a message published with no subject
|
|
15
|
+
* .note = `Records` holds at least one record: sns never invokes with none, and a handler that
|
|
16
|
+
* reads `Records[0]` would meet an empty one as a TypeError, a server fault sns retries
|
|
17
|
+
*/
|
|
18
|
+
const genSchemaOfSnsEvent = (input) => zod_1.z.looseObject({
|
|
19
|
+
Records: zod_1.z
|
|
20
|
+
.array(zod_1.z.looseObject({
|
|
21
|
+
EventVersion: zod_1.z.string(),
|
|
22
|
+
EventSubscriptionArn: zod_1.z.string(),
|
|
23
|
+
EventSource: zod_1.z.literal('aws:sns'),
|
|
24
|
+
Sns: zod_1.z.looseObject({
|
|
25
|
+
SignatureVersion: zod_1.z.string(),
|
|
26
|
+
Timestamp: zod_1.z.string(),
|
|
27
|
+
Signature: zod_1.z.string(),
|
|
28
|
+
SigningCertUrl: zod_1.z.string().optional(),
|
|
29
|
+
MessageId: zod_1.z.string(),
|
|
30
|
+
Message: input.message,
|
|
31
|
+
MessageAttributes: zod_1.z.record(zod_1.z.string(), zod_1.z.looseObject({ Type: zod_1.z.string(), Value: zod_1.z.string() })),
|
|
32
|
+
Type: zod_1.z.string(),
|
|
33
|
+
UnsubscribeUrl: zod_1.z.string().optional(),
|
|
34
|
+
TopicArn: zod_1.z.string(),
|
|
35
|
+
Subject: zod_1.z.string().nullish(),
|
|
36
|
+
}),
|
|
37
|
+
}))
|
|
38
|
+
.min(1),
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* .what = the zod schema of the event sns delivers to a lambda, optionally with the schema of
|
|
42
|
+
* the message inside it
|
|
43
|
+
* .why = an sns handler wired via `genLambdaEndpoint.forAsk` gets a validated envelope and a
|
|
44
|
+
* typed message, where it used to get `z.custom<SNSEvent>` and a hand `JSON.parse`
|
|
45
|
+
*
|
|
46
|
+
* .note = the wire face (zod input) is `SNSEvent`, so `forAsk` returns a handler typed on it
|
|
47
|
+
* .note = two call forms, two contracts, by design: `fromSns()` makes no claim about the
|
|
48
|
+
* message, so it stays the wire string; `fromSns({ payload })` claims a shape, so the
|
|
49
|
+
* message is decoded and validated. an absent `input` is the envelope-only contract, not
|
|
50
|
+
* a skipped default — each form carries its own return type and its own tests
|
|
51
|
+
* .note = a refusal is answered as a caller fault, so the invoke succeeds and lambda does not
|
|
52
|
+
* retry. `forAsk` logs a warn line with the message id, since the log is the only trace
|
|
53
|
+
*
|
|
54
|
+
* .as = zod infers `looseObject` types with an index signature on input and output, which no
|
|
55
|
+
* aws-lambda interface carries, so neither face is assignable to `SNSEvent` structurally.
|
|
56
|
+
* the cast asserts the runtime shape the schema enforces, which `@types/aws-lambda` names
|
|
57
|
+
* .removal = drops when zod can infer a loose object without an index signature
|
|
58
|
+
* .note = the cast does not cut the tie to the aws type: the envelope-only schema `satisfies`
|
|
59
|
+
* `ZodType<SnsEventKeysContested, unknown>`, so a required key `@types/aws-lambda` adds,
|
|
60
|
+
* or one the schema drops, fails to compile. the three contested keys (named on
|
|
61
|
+
* `SnsEventKeysContested`) are the one stated gap between the declared type and the runtime
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* schema: { input: asLambdaEventSchema.fromSns({ payload: schemaOfNotice }), output: z.void() },
|
|
66
|
+
* invoke: async ({ payload }) => handle(payload.Records[0]!.Sns.Message), // typed, validated
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
exports.fromSns = ((input) => {
|
|
70
|
+
const schema = input
|
|
71
|
+
? genSchemaOfSnsEvent({
|
|
72
|
+
message: (0, asLambdaEventPayloadSchema_1.asLambdaEventPayloadSchema)({
|
|
73
|
+
payload: input.payload,
|
|
74
|
+
deserialize: input.deserialize ?? asLambdaEventPayloadSchema_1.DESERIALIZE_DEFAULT,
|
|
75
|
+
decode: ({ wire }) => wire,
|
|
76
|
+
}),
|
|
77
|
+
})
|
|
78
|
+
: (genSchemaOfSnsEvent({ message: zod_1.z.string() }));
|
|
79
|
+
return (0, setLambdaEventSchemaSource_1.setLambdaEventSchemaSource)({ schema, source: { name: 'sns' } });
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=asLambdaEventSchema.fromSns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asLambdaEventSchema.fromSns.js","sourceRoot":"","sources":["../../../src/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromSns.ts"],"names":[],"mappings":";;;AACA,6BAAsC;AAEtC,uGAAoG;AACpG,6EAGsC;AAoDtC;;;;;;;;;;GAUG;AACH,MAAM,mBAAmB,GAAG,CAAW,KAEtC,EAAE,EAAE,CACH,OAAC,CAAC,WAAW,CAAC;IACZ,OAAO,EAAE,OAAC;SACP,KAAK,CACJ,OAAC,CAAC,WAAW,CAAC;QACZ,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;QACxB,oBAAoB,EAAE,OAAC,CAAC,MAAM,EAAE;QAChC,WAAW,EAAE,OAAC,CAAC,OAAO,CAAC,SAAS,CAAC;QACjC,GAAG,EAAE,OAAC,CAAC,WAAW,CAAC;YACjB,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE;YAC5B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;YACrB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;YACrB,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YACrC,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;YACrB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,iBAAiB,EAAE,OAA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esis_1 = require("./asLambdaEventSchema.fromKinesis");
|
|
5
|
+
const asLambdaEventSchema_fromSns_1 = require("./asLambdaEventSchema.fromSns");
|
|
6
|
+
/**
|
|
7
|
+
* .what = the zod schema of the event an event source delivers, optionally with the schema of
|
|
8
|
+
* the payload inside it
|
|
9
|
+
* .why = the validate direction of the event-source axis. `asLambdaEvent.from$Source` builds an
|
|
10
|
+
* envelope; `asLambdaEventSchema.from$Source` validates one (`define.lambda-event-source`).
|
|
11
|
+
* it covers the sources whose payload no endpoint family already validates, so its list
|
|
12
|
+
* is a subset of `asLambdaEvent`'s, each absence on a stated axis below
|
|
13
|
+
*
|
|
14
|
+
* | source | the payload slot | decode before `payload` |
|
|
15
|
+
* |--------|------------------|-------------------------|
|
|
16
|
+
* | **sns** | `Records[].Sns.Message` | json parse (or none, under `deserialize: { payload: false }`) |
|
|
17
|
+
* | **kinesis** | `Records[].kinesis.data` | base64 → utf8, then json parse (or none) |
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ **there is no `fromSqs`, deliberately.** `genLambdaEndpoint.forSqs.{perRecord,perBatch}`
|
|
20
|
+
* already validates each record's body against `schema.input.payload`, and answers per
|
|
21
|
+
* message: a refused message is acknowledged alone, never with its batch. use it for sqs
|
|
22
|
+
*
|
|
23
|
+
* ⚠️ **there is no `fromApiGateway`, on the same axis.** `genLambdaEndpoint.forApiGateway`
|
|
24
|
+
* validates the request through its own `schema.input` pair (`headers`, `payload`)
|
|
25
|
+
*
|
|
26
|
+
* ⚠️ **there is no `fromS3`, for want of a payload.** an s3 notice carries a reference (bucket,
|
|
27
|
+
* key), never content, so it has no payload slot to decode, and no evidenced consumer yet
|
|
28
|
+
*
|
|
29
|
+
* ⚠️ **one zod in the tree.** the envelope is built with this sdk's zod and pipes into your
|
|
30
|
+
* `payload` schema. a schema from another zod copy or major is a compile-time type error, as
|
|
31
|
+
* at `forAsk`'s `schema.input`; the cure is `pnpm.overrides.zod` to one version
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* genLambdaEndpoint.forAsk({
|
|
36
|
+
* schema: { input: asLambdaEventSchema.fromSns({ payload: schemaOfNotice }), output: z.void() },
|
|
37
|
+
* invoke: async ({ payload }) => handle(payload.Records[0]!.Sns.Message),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
exports.asLambdaEventSchema = {
|
|
42
|
+
fromKinesis: asLambdaEventSchema_fromKinesis_1.fromKinesis,
|
|
43
|
+
fromSns: asLambdaEventSchema_fromSns_1.fromSns,
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=asLambdaEventSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asLambdaEventSchema.js","sourceRoot":"","sources":["../../../src/domain.operations/asLambdaEventSchema/asLambdaEventSchema.ts"],"names":[],"mappings":";;;AAAA,uFAAgE;AAChE,+EAAwD;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACU,QAAA,mBAAmB,GAAG;IACjC,WAAW,EAAX,6CAAW;IACX,OAAO,EAAP,qCAAO;CACR,CAAC"}
|
|
@@ -23,6 +23,7 @@ export declare const askLambdaEndpoint: (<TRequest, TResponse>(input: {
|
|
|
23
23
|
struct?: {
|
|
24
24
|
payload?: import("../..").LambdaEndpointDialect | undefined;
|
|
25
25
|
} | undefined;
|
|
26
|
+
refusal?: import("../..").LambdaEndpointRefusal | undefined;
|
|
26
27
|
}, context: import("../..").ContextAwsLambdaCaller & {
|
|
27
28
|
cache?: {
|
|
28
29
|
response?: import("with-simple-cache").SimpleCache<TResponse> | undefined;
|
|
@@ -38,6 +39,7 @@ export declare const askLambdaEndpoint: (<TRequest, TResponse>(input: {
|
|
|
38
39
|
struct?: {
|
|
39
40
|
payload?: import("../..").LambdaEndpointDialect | undefined;
|
|
40
41
|
} | undefined;
|
|
42
|
+
refusal?: import("../..").LambdaEndpointRefusal | undefined;
|
|
41
43
|
}, context: import("../..").ContextAwsLambdaCaller & {
|
|
42
44
|
cache?: {
|
|
43
45
|
response?: import("with-simple-cache").SimpleCache<TResponse> | undefined;
|
|
@@ -49,6 +51,7 @@ export declare const askLambdaEndpoint: (<TRequest, TResponse>(input: {
|
|
|
49
51
|
method?: string | undefined;
|
|
50
52
|
headers?: Record<string, string> | undefined;
|
|
51
53
|
body?: unknown;
|
|
54
|
+
refusal?: import("../..").LambdaEndpointRefusal | undefined;
|
|
52
55
|
}, context: import("sdk-logs").ContextLogTrail) => Promise<{
|
|
53
56
|
status: number;
|
|
54
57
|
headers: Record<string, string>;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { ContextLogTrail } from 'sdk-logs';
|
|
2
|
+
import type { LambdaEndpointRefusal } from '../../domain.objects/LambdaEndpointRefusal';
|
|
2
3
|
/**
|
|
3
4
|
* .what = asks an api gateway endpoint over http, opted into the contemp dialect with the caller's trail
|
|
4
5
|
* .why = an aws-delivered event cannot hold a `{ event, trail }` wrapper, so the opt-in and the
|
|
5
6
|
* trail ride the request's own `x-trail-exid` header. this sends it, and casts a fault back
|
|
6
|
-
* into the throw `askLambdaEndpoint` gives, so one catch block serves both roads
|
|
7
|
+
* into the throw `askLambdaEndpoint` gives, so one catch block for a refusal serves both roads
|
|
7
8
|
* (`invariant.ancient-vs-contemp-callers.md`, `domain.terms/x-trail-exid.md`)
|
|
8
9
|
*
|
|
9
10
|
* | answer | the caller gets |
|
|
10
11
|
* |--------|-----------------|
|
|
11
12
|
* | < 400 | `{ status, headers, text, body }` — `body` is the json, or null where the answer has none |
|
|
12
|
-
* | 4xx | a thrown `ConstraintError`, with the endpoint's message |
|
|
13
|
+
* | 4xx, save 429 | a thrown `LambdaEndpointRefusedError` (or `ConstraintError`, with `refusal: { as: 'ConstraintError' }`), with the endpoint's message |
|
|
14
|
+
* | 429 | a thrown `MalfunctionError` under either opt: a throttle, not a refusal; `retry-after` rides `metadata.headers` |
|
|
13
15
|
* | 5xx | a thrown `MalfunctionError`, with the `correlationId` that finds the log line |
|
|
14
16
|
*
|
|
15
17
|
* .note = takes the standard http request — `{ url, method, headers, body }` — as fetch does, and
|
|
@@ -27,6 +29,13 @@ export declare const viaApiGateway: <TResponse = unknown>(input: {
|
|
|
27
29
|
method?: string;
|
|
28
30
|
headers?: Record<string, string>;
|
|
29
31
|
body?: unknown;
|
|
32
|
+
/**
|
|
33
|
+
* .what = the class a 4xx answer is thrown as (a 429 excepted: it is a throttle, a `MalfunctionError`)
|
|
34
|
+
* .why = this caller composed the request, so by default a refusal is this caller's own
|
|
35
|
+
* malfunction, as on the invoke road
|
|
36
|
+
* .default = { as: 'LambdaEndpointRefusedError' }
|
|
37
|
+
*/
|
|
38
|
+
refusal?: LambdaEndpointRefusal;
|
|
30
39
|
}, context: ContextLogTrail) => Promise<{
|
|
31
40
|
status: number;
|
|
32
41
|
headers: Record<string, string>;
|
|
@@ -8,18 +8,20 @@ const asHeadersRecord_1 = require("./serde/asHeadersRecord");
|
|
|
8
8
|
const asHttpMethod_1 = require("./serde/asHttpMethod");
|
|
9
9
|
const asHttpRequestBody_1 = require("./serde/asHttpRequestBody");
|
|
10
10
|
const asHttpRequestHeaders_1 = require("./serde/asHttpRequestHeaders");
|
|
11
|
+
const asLambdaEndpointRefusal_1 = require("./serde/asLambdaEndpointRefusal");
|
|
11
12
|
const getOneBodyFromHttpText_1 = require("./serde/getOneBodyFromHttpText");
|
|
12
13
|
/**
|
|
13
14
|
* .what = asks an api gateway endpoint over http, opted into the contemp dialect with the caller's trail
|
|
14
15
|
* .why = an aws-delivered event cannot hold a `{ event, trail }` wrapper, so the opt-in and the
|
|
15
16
|
* trail ride the request's own `x-trail-exid` header. this sends it, and casts a fault back
|
|
16
|
-
* into the throw `askLambdaEndpoint` gives, so one catch block serves both roads
|
|
17
|
+
* into the throw `askLambdaEndpoint` gives, so one catch block for a refusal serves both roads
|
|
17
18
|
* (`invariant.ancient-vs-contemp-callers.md`, `domain.terms/x-trail-exid.md`)
|
|
18
19
|
*
|
|
19
20
|
* | answer | the caller gets |
|
|
20
21
|
* |--------|-----------------|
|
|
21
22
|
* | < 400 | `{ status, headers, text, body }` — `body` is the json, or null where the answer has none |
|
|
22
|
-
* | 4xx | a thrown `ConstraintError`, with the endpoint's message |
|
|
23
|
+
* | 4xx, save 429 | a thrown `LambdaEndpointRefusedError` (or `ConstraintError`, with `refusal: { as: 'ConstraintError' }`), with the endpoint's message |
|
|
24
|
+
* | 429 | a thrown `MalfunctionError` under either opt: a throttle, not a refusal; `retry-after` rides `metadata.headers` |
|
|
23
25
|
* | 5xx | a thrown `MalfunctionError`, with the `correlationId` that finds the log line |
|
|
24
26
|
*
|
|
25
27
|
* .note = takes the standard http request — `{ url, method, headers, body }` — as fetch does, and
|
|
@@ -33,6 +35,8 @@ const getOneBodyFromHttpText_1 = require("./serde/getOneBodyFromHttpText");
|
|
|
33
35
|
* dependency, and sets no timeout: fetch waits as long as the endpoint does
|
|
34
36
|
*/
|
|
35
37
|
const viaApiGateway = async (input, context) => {
|
|
38
|
+
// refuse an unknown refusal opt before any request is sent
|
|
39
|
+
const refusal = (0, asLambdaEndpointRefusal_1.asLambdaEndpointRefusal)({ declared: input.refusal });
|
|
36
40
|
// the caller's exid, or a generated one — the same call `askLambdaEndpoint` makes
|
|
37
41
|
const exid = (0, getOneTrailExid_1.getOneTrailExid)({ log: context.log });
|
|
38
42
|
// send the request, opted in by the trail header
|
|
@@ -60,6 +64,7 @@ const viaApiGateway = async (input, context) => {
|
|
|
60
64
|
headers,
|
|
61
65
|
url: input.url,
|
|
62
66
|
exid,
|
|
67
|
+
refusal,
|
|
63
68
|
});
|
|
64
69
|
if (error)
|
|
65
70
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"askLambdaEndpoint.viaApiGateway.js","sourceRoot":"","sources":["../../../src/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"askLambdaEndpoint.viaApiGateway.js","sourceRoot":"","sources":["../../../src/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.ts"],"names":[],"mappings":";;;AAGA,mFAAgF;AAChF,oEAAiE;AACjE,6EAA0E;AAC1E,6DAA0D;AAC1D,uDAAoD;AACpD,iEAA8D;AAC9D,uEAAoE;AACpE,6EAA0E;AAC1E,2EAAwE;AAExE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,aAAa,GAAG,KAAK,EAChC,KAYC,EACD,OAAwB,EAMvB,EAAE;IACH,2DAA2D;IAC3D,MAAM,OAAO,GAAG,IAAA,iDAAuB,EAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAErE,kFAAkF;IAClF,MAAM,IAAI,GAAG,IAAA,iCAAe,EAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAEnD,iDAAiD;IACjD,MAAM,OAAO,GAAG,IAAA,qCAAiB,EAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,MAAM,IAAA,uCAAkB,EAAC;QACxC,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,IAAA,2BAAY,EAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QAChE,OAAO,EAAE,IAAA,2CAAoB,EAAC;YAC5B,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB,CAAC;QACF,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI;KACL,CAAC,CAAC;IAEH,uEAAuE;IACvE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,IAAI,GAAG,IAAA,+CAAsB,EAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAE9C,6DAA6D;IAC7D,MAAM,OAAO,GAAG,IAAA,iCAAe,EAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAA,iDAAuB,EAAC;QACpC,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;IACH,IAAI,KAAK;QAAE,MAAM,KAAK,CAAC;IAEvB;;;;;OAKG;IACH,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,OAAO;QACP,IAAI;QACJ,IAAI,EAAE,IAAwB;KAC/B,CAAC;AACJ,CAAC,CAAC;AAtEW,QAAA,aAAa,iBAsExB"}
|
|
@@ -2,6 +2,7 @@ import type { SimpleInMemoryCache } from 'simple-in-memory-cache';
|
|
|
2
2
|
import type { SimpleCache } from 'with-simple-cache';
|
|
3
3
|
import type { ContextAwsLambdaCaller } from '../../domain.objects/ContextAwsLambdaCaller';
|
|
4
4
|
import type { LambdaEndpointDialect } from '../../domain.objects/LambdaEndpointDialect';
|
|
5
|
+
import type { LambdaEndpointRefusal } from '../../domain.objects/LambdaEndpointRefusal';
|
|
5
6
|
/**
|
|
6
7
|
* .what = invokes a lambda endpoint with trail propagation, over the aws lambda invoke api
|
|
7
8
|
* .why = enables service-to-service calls with observability
|
|
@@ -29,6 +30,15 @@ export declare const viaInvoke: <TRequest, TResponse>(input: {
|
|
|
29
30
|
*/
|
|
30
31
|
payload?: LambdaEndpointDialect;
|
|
31
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* .what = the class a peer's refusal (its ConstraintError / BadRequestError) is thrown as
|
|
35
|
+
* .why = this caller composed the request, so by default a refusal is this caller's own
|
|
36
|
+
* malfunction — an api-gateway caller answers 500, never a 400 its caller cannot fix
|
|
37
|
+
* .default = { as: 'LambdaEndpointRefusedError' }
|
|
38
|
+
* .note = name `{ as: 'ConstraintError' }` only where the request forwards your own caller's
|
|
39
|
+
* input verbatim, so the fault truly is theirs to fix
|
|
40
|
+
*/
|
|
41
|
+
refusal?: LambdaEndpointRefusal;
|
|
32
42
|
}, context: ContextAwsLambdaCaller & {
|
|
33
43
|
cache?: {
|
|
34
44
|
response?: SimpleCache<TResponse>;
|
|
@@ -4,8 +4,10 @@ exports.viaInvoke = void 0;
|
|
|
4
4
|
const genLambdaSdk_1 = require("../../access/sdks/lambda/genLambdaSdk");
|
|
5
5
|
const asLambdaEndpoint_1 = require("../asLambdaEndpoint/asLambdaEndpoint");
|
|
6
6
|
const getOneTrailExid_1 = require("../lambdaEndpointWire/context/getOneTrailExid");
|
|
7
|
+
const asAskLambdaCacheKeyOfRefusal_1 = require("./cache/asAskLambdaCacheKeyOfRefusal");
|
|
7
8
|
const asCachedExecutor_1 = require("./cache/asCachedExecutor");
|
|
8
9
|
const getAskLambdaCacheKey_1 = require("./cache/getAskLambdaCacheKey");
|
|
10
|
+
const asLambdaEndpointRefusal_1 = require("./serde/asLambdaEndpointRefusal");
|
|
9
11
|
const getLambdaPayload_1 = require("./serde/getLambdaPayload");
|
|
10
12
|
/**
|
|
11
13
|
* .what = invokes a lambda endpoint with trail propagation, over the aws lambda invoke api
|
|
@@ -17,6 +19,8 @@ const getLambdaPayload_1 = require("./serde/getLambdaPayload");
|
|
|
17
19
|
* .note = use struct: 'ancient' for handlers that don't understand wrapped payloads
|
|
18
20
|
*/
|
|
19
21
|
const viaInvoke = async (input, context) => {
|
|
22
|
+
// refuse an unknown refusal opt before any invoke is sent
|
|
23
|
+
const refusal = (0, asLambdaEndpointRefusal_1.asLambdaEndpointRefusal)({ declared: input.refusal });
|
|
20
24
|
// extract or generate the trail exid, and report the fallback if one was made.
|
|
21
25
|
// shared with `runLambdaEndpoint.onSerialized` so the two loci cannot diverge
|
|
22
26
|
// on the diagnostic — see `getOneTrailExid` for why that parity is structural
|
|
@@ -48,15 +52,23 @@ const viaInvoke = async (input, context) => {
|
|
|
48
52
|
env: { region: context.env.region },
|
|
49
53
|
});
|
|
50
54
|
// prepare invocation input + context
|
|
51
|
-
const invocationInput = {
|
|
55
|
+
const invocationInput = {
|
|
56
|
+
endpoint,
|
|
57
|
+
payload,
|
|
58
|
+
exid,
|
|
59
|
+
refusal,
|
|
60
|
+
};
|
|
52
61
|
const invocationContext = {
|
|
53
62
|
sdkLambda,
|
|
54
63
|
log: context.log,
|
|
55
64
|
};
|
|
56
|
-
// build cache key generator
|
|
57
|
-
const getCacheKey = () => (0,
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
// build cache key generator; a pass-through ask never shares a key with a default ask
|
|
66
|
+
const getCacheKey = () => (0, asAskLambdaCacheKeyOfRefusal_1.asAskLambdaCacheKeyOfRefusal)({
|
|
67
|
+
key: (0, getAskLambdaCacheKey_1.getAskLambdaCacheKey)({
|
|
68
|
+
endpoint,
|
|
69
|
+
event: input.event,
|
|
70
|
+
}),
|
|
71
|
+
refusal,
|
|
60
72
|
});
|
|
61
73
|
// get executor with cache wrapper
|
|
62
74
|
const execute = (0, asCachedExecutor_1.asCachedExecutor)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"askLambdaEndpoint.viaInvoke.js","sourceRoot":"","sources":["../../../src/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.ts"],"names":[],"mappings":";;;AAGA,wEAAqE;
|
|
1
|
+
{"version":3,"file":"askLambdaEndpoint.viaInvoke.js","sourceRoot":"","sources":["../../../src/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.ts"],"names":[],"mappings":";;;AAGA,wEAAqE;AAIrE,2EAAwE;AACxE,mFAAgF;AAChF,uFAAoF;AACpF,+DAA4D;AAC5D,uEAAoE;AAKpE,6EAA0E;AAC1E,+DAA4D;AAE5D;;;;;;;;GAQG;AACI,MAAM,SAAS,GAAG,KA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Q;QACR,OAAO;QACP,IAAI;QACJ,OAAO;KACR,CAAC;IACF,MAAM,iBAAiB,GAAsB;QAC3C,SAAS;QACT,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC;IAEF,sFAAsF;IACtF,MAAM,WAAW,GAAG,GAAW,EAAE,CAC/B,IAAA,2DAA4B,EAAC;QAC3B,GAAG,EAAE,IAAA,2CAAoB,EAAC;YACxB,QAAQ;YACR,KAAK,EAAE,KAAK,CAAC,KAAgC;SAC9C,CAAC;QACF,OAAO;KACR,CAAC,CAAC;IAEL,kCAAkC;IAClC,MAAM,OAAO,GAAG,IAAA,mCAAgB,EAAY;QAC1C,GAAG,OAAO,CAAC,KAAK;QAChB,WAAW;KACZ,CAAC,CAAC;IAEH,qBAAqB;IACrB,OAAO,OAAO,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AACrD,CAAC,CAAC;AAxGW,QAAA,SAAS,aAwGpB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LambdaEndpointRefusal } from '../../../domain.objects/LambdaEndpointRefusal';
|
|
2
|
+
/**
|
|
3
|
+
* .what = the cache key of one ask, under the refusal opt it was asked with
|
|
4
|
+
* .why = the dedupe cache shares one in-flight promise per key, and a rejection's class depends on
|
|
5
|
+
* the opt. so a pass-through ask must never share a key with a default ask, or a caller
|
|
6
|
+
* could catch the class the other caller asked for (sdk-aws-lambda#77)
|
|
7
|
+
*
|
|
8
|
+
* .note = the default opt keeps the key it had before the opt existed, so the public
|
|
9
|
+
* `getAskLambdaCacheKey` and every extant cached entry stay as they were
|
|
10
|
+
* .note = the cost: a pass-through ask no longer shares a cached success with a default ask of
|
|
11
|
+
* the same event. a class-neutral throw cast at the `viaInvoke` boundary would keep those
|
|
12
|
+
* hits, but needs a marker that tells a peer refusal from a local `ConstraintError`
|
|
13
|
+
*/
|
|
14
|
+
export declare const asAskLambdaCacheKeyOfRefusal: (input: {
|
|
15
|
+
key: string;
|
|
16
|
+
refusal: LambdaEndpointRefusal;
|
|
17
|
+
}) => string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asAskLambdaCacheKeyOfRefusal = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = the cache key of one ask, under the refusal opt it was asked with
|
|
6
|
+
* .why = the dedupe cache shares one in-flight promise per key, and a rejection's class depends on
|
|
7
|
+
* the opt. so a pass-through ask must never share a key with a default ask, or a caller
|
|
8
|
+
* could catch the class the other caller asked for (sdk-aws-lambda#77)
|
|
9
|
+
*
|
|
10
|
+
* .note = the default opt keeps the key it had before the opt existed, so the public
|
|
11
|
+
* `getAskLambdaCacheKey` and every extant cached entry stay as they were
|
|
12
|
+
* .note = the cost: a pass-through ask no longer shares a cached success with a default ask of
|
|
13
|
+
* the same event. a class-neutral throw cast at the `viaInvoke` boundary would keep those
|
|
14
|
+
* hits, but needs a marker that tells a peer refusal from a local `ConstraintError`
|
|
15
|
+
*/
|
|
16
|
+
const asAskLambdaCacheKeyOfRefusal = (input) => {
|
|
17
|
+
if (input.refusal.as === 'LambdaEndpointRefusedError')
|
|
18
|
+
return input.key;
|
|
19
|
+
return `${input.key}::refusal=${input.refusal.as}`;
|
|
20
|
+
};
|
|
21
|
+
exports.asAskLambdaCacheKeyOfRefusal = asAskLambdaCacheKeyOfRefusal;
|
|
22
|
+
//# sourceMappingURL=asAskLambdaCacheKeyOfRefusal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asAskLambdaCacheKeyOfRefusal.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/cache/asAskLambdaCacheKeyOfRefusal.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACI,MAAM,4BAA4B,GAAG,CAAC,KAG5C,EAAU,EAAE;IACX,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,4BAA4B;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IACxE,OAAO,GAAG,KAAK,CAAC,GAAG,aAAa,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;AACrD,CAAC,CAAC;AANW,QAAA,4BAA4B,gCAMvC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LambdaClient } from '@aws-sdk/client-lambda';
|
|
2
2
|
import type { LambdaEndpoint } from '../../../domain.objects/LambdaEndpoint';
|
|
3
|
+
import type { LambdaEndpointRefusal } from '../../../domain.objects/LambdaEndpointRefusal';
|
|
3
4
|
/**
|
|
4
5
|
* .what = minimal log interface for lambda invocation
|
|
5
6
|
* .why = accepts console, sdk-logs LogMethods, or any object with debug method
|
|
@@ -15,6 +16,7 @@ export type InvocationInput = {
|
|
|
15
16
|
endpoint: LambdaEndpoint;
|
|
16
17
|
payload: unknown;
|
|
17
18
|
exid: string;
|
|
19
|
+
refusal: LambdaEndpointRefusal;
|
|
18
20
|
};
|
|
19
21
|
/**
|
|
20
22
|
* .what = invocation context for lambda execution
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeLambdaInvocation.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.ts"],"names":[],"mappings":";;;AAEA,iFAA8E;AAE9E,qFAAkF;
|
|
1
|
+
{"version":3,"file":"executeLambdaInvocation.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.ts"],"names":[],"mappings":";;;AAEA,iFAA8E;AAE9E,qFAAkF;AAElF,kFAA+E;AAC/E,kEAA+D;AA8B/D;;;GAGG;AACI,MAAM,uBAAuB,GAAG,KAAK,EAC1C,KAAsB,EACtB,OAA0B,EACN,EAAE;IACtB,iBAAiB;IACjB,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,0BAA0B,EAAE;QAC7C,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;QACzB,IAAI,EAAE,KAAK,C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CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC;IAEH,aAAa;IACb,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,0BAA0B,EAAE;QAC7C,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;QACzB,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AA3DW,QAAA,uBAAuB,2BA2DlC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { ConstraintError, MalfunctionError } from 'helpful-errors';
|
|
1
|
+
import { type ConstraintError, MalfunctionError } from 'helpful-errors';
|
|
2
|
+
import type { LambdaEndpointRefusal } from '../../../domain.objects/LambdaEndpointRefusal';
|
|
3
|
+
import type { LambdaEndpointRefusedError } from '../../../domain.objects/LambdaEndpointRefusedError';
|
|
2
4
|
/**
|
|
3
5
|
* .what = casts an http response into the error a caller should throw, or null for a success
|
|
4
6
|
* .why = an api gateway endpoint answers a fault as a RETURNED http response, never a lambda error
|
|
@@ -8,7 +10,8 @@ import { ConstraintError, MalfunctionError } from 'helpful-errors';
|
|
|
8
10
|
* | status | the error | because |
|
|
9
11
|
* |--------|-----------|---------|
|
|
10
12
|
* | < 400 | none | a success. a redirect is followed by fetch by default, so a 3xx seldom arrives here |
|
|
11
|
-
* | 4xx | `ConstraintError` |
|
|
13
|
+
* | 4xx, save 429 | the `refusal` class: `LambdaEndpointRefusedError` by default, `ConstraintError` on opt-in | this caller composed the request, so the refusal is its own malfunction — unless it forwards its own caller's input |
|
|
14
|
+
* | 429 | `MalfunctionError`, under either opt | a throttle, not a refusal: the same request succeeds after `retry-after` |
|
|
12
15
|
* | 5xx | `MalfunctionError` | the endpoint must fix itself; its `correlationId` finds the log line |
|
|
13
16
|
*
|
|
14
17
|
* .note = the message comes from the body's contemp envelope when it has one, else from the
|
|
@@ -18,8 +21,8 @@ import { ConstraintError, MalfunctionError } from 'helpful-errors';
|
|
|
18
21
|
* .note = the raw answer text rides the error metadata, cut to a bound, so a message no arm reads
|
|
19
22
|
* (an old endpoint's flat body, a proxy's html page) is never lost to the caller. it is null
|
|
20
23
|
* where the message came from the contemp envelope, which is the text already. the
|
|
21
|
-
* response headers ride it too, so a
|
|
22
|
-
*
|
|
24
|
+
* response headers ride it too, so a throttle's `retry-after` can be read from the thrown
|
|
25
|
+
* error
|
|
23
26
|
*/
|
|
24
27
|
export declare const asErrorFromHttpResponse: (input: {
|
|
25
28
|
status: number;
|
|
@@ -28,4 +31,5 @@ export declare const asErrorFromHttpResponse: (input: {
|
|
|
28
31
|
headers: Record<string, string>;
|
|
29
32
|
url: string;
|
|
30
33
|
exid: string;
|
|
31
|
-
|
|
34
|
+
refusal: LambdaEndpointRefusal;
|
|
35
|
+
}) => ConstraintError | LambdaEndpointRefusedError | MalfunctionError | null;
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.asErrorFromHttpResponse = void 0;
|
|
4
4
|
const helpful_errors_1 = require("helpful-errors");
|
|
5
5
|
const HttpStatusCode_1 = require("../../../domain.objects/HttpStatusCode");
|
|
6
|
+
const asErrorFromPeerRefusal_1 = require("../../lambdaEndpointWire/error/asErrorFromPeerRefusal");
|
|
6
7
|
const getIsLambdaErrorResponse_1 = require("../../lambdaEndpointWire/error/getIsLambdaErrorResponse");
|
|
7
8
|
const asUnprefixedErrorMessage_1 = require("../../lambdaEndpointWire/serde/asUnprefixedErrorMessage");
|
|
9
|
+
const getIsHttpThrottle_1 = require("./getIsHttpThrottle");
|
|
8
10
|
const getOneCorrelationIdFromBody_1 = require("./getOneCorrelationIdFromBody");
|
|
9
11
|
const ERROR_TEXT_LENGTH_MAX = 1000;
|
|
10
12
|
/**
|
|
@@ -16,7 +18,8 @@ const ERROR_TEXT_LENGTH_MAX = 1000;
|
|
|
16
18
|
* | status | the error | because |
|
|
17
19
|
* |--------|-----------|---------|
|
|
18
20
|
* | < 400 | none | a success. a redirect is followed by fetch by default, so a 3xx seldom arrives here |
|
|
19
|
-
* | 4xx | `ConstraintError` |
|
|
21
|
+
* | 4xx, save 429 | the `refusal` class: `LambdaEndpointRefusedError` by default, `ConstraintError` on opt-in | this caller composed the request, so the refusal is its own malfunction — unless it forwards its own caller's input |
|
|
22
|
+
* | 429 | `MalfunctionError`, under either opt | a throttle, not a refusal: the same request succeeds after `retry-after` |
|
|
20
23
|
* | 5xx | `MalfunctionError` | the endpoint must fix itself; its `correlationId` finds the log line |
|
|
21
24
|
*
|
|
22
25
|
* .note = the message comes from the body's contemp envelope when it has one, else from the
|
|
@@ -26,14 +29,18 @@ const ERROR_TEXT_LENGTH_MAX = 1000;
|
|
|
26
29
|
* .note = the raw answer text rides the error metadata, cut to a bound, so a message no arm reads
|
|
27
30
|
* (an old endpoint's flat body, a proxy's html page) is never lost to the caller. it is null
|
|
28
31
|
* where the message came from the contemp envelope, which is the text already. the
|
|
29
|
-
* response headers ride it too, so a
|
|
30
|
-
*
|
|
32
|
+
* response headers ride it too, so a throttle's `retry-after` can be read from the thrown
|
|
33
|
+
* error
|
|
31
34
|
*/
|
|
32
35
|
const asErrorFromHttpResponse = (input) => {
|
|
33
36
|
if (input.status < HttpStatusCode_1.HttpStatusCode.BAD_REQUEST_400)
|
|
34
37
|
return null;
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
// the envelope, resolved once: every field below reads it, or the status where there is none
|
|
39
|
+
const envelope = (0, getIsLambdaErrorResponse_1.getIsContempErrorResponse)(input.body)
|
|
40
|
+
? input.body.error
|
|
41
|
+
: null;
|
|
42
|
+
const message = envelope
|
|
43
|
+
? (0, asUnprefixedErrorMessage_1.asUnprefixedErrorMessage)({ message: envelope.message })
|
|
37
44
|
: `the endpoint answered http ${input.status}`;
|
|
38
45
|
const metadata = {
|
|
39
46
|
url: input.url,
|
|
@@ -42,13 +49,24 @@ const asErrorFromHttpResponse = (input) => {
|
|
|
42
49
|
correlationId: (0, getOneCorrelationIdFromBody_1.getOneCorrelationIdFromBody)({ body: input.body }),
|
|
43
50
|
// the raw text rides only where the message did not come from it: an envelope's message is
|
|
44
51
|
// the text already, and a second copy would bury the fix a person reads first
|
|
45
|
-
text: (0,
|
|
46
|
-
? null
|
|
47
|
-
: input.text.slice(0, ERROR_TEXT_LENGTH_MAX),
|
|
52
|
+
text: envelope ? null : input.text.slice(0, ERROR_TEXT_LENGTH_MAX),
|
|
48
53
|
headers: input.headers,
|
|
49
54
|
};
|
|
55
|
+
// a 429: a throttle, not a refusal — the same request succeeds after `retry-after`, so it is a
|
|
56
|
+
// server fault under either opt, its headers kept for the retry (`domain.terms/refusal.md`)
|
|
57
|
+
if ((0, getIsHttpThrottle_1.getIsHttpThrottle)({ status: input.status }))
|
|
58
|
+
return new helpful_errors_1.MalfunctionError(message, metadata);
|
|
59
|
+
// any other 4xx: the endpoint refused the request this caller composed; the opt names the class
|
|
60
|
+
// .note = the peer's verdict is its envelope's class where it sent one, else the status alone
|
|
50
61
|
if (input.status < HttpStatusCode_1.HttpStatusCode.INTERNAL_SERVER_ERROR_500)
|
|
51
|
-
return
|
|
62
|
+
return (0, asErrorFromPeerRefusal_1.asErrorFromPeerRefusal)({
|
|
63
|
+
refusal: input.refusal,
|
|
64
|
+
peer: input.url,
|
|
65
|
+
message,
|
|
66
|
+
errorType: envelope ? envelope.class : `http ${input.status}`,
|
|
67
|
+
metadata,
|
|
68
|
+
});
|
|
69
|
+
// a 5xx: the endpoint must fix itself
|
|
52
70
|
return new helpful_errors_1.MalfunctionError(message, metadata);
|
|
53
71
|
};
|
|
54
72
|
exports.asErrorFromHttpResponse = asErrorFromHttpResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asErrorFromHttpResponse.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"asErrorFromHttpResponse.js","s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E,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;QAC7C,OAAO,IAAI,iCAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEjD,gGAAgG;IAChG,8FAA8F;IAC9F,IAAI,KAAK,CAAC,MAAM,GAAG,+BAAc,CAAC,yBAAyB;QACzD,OAAO,IAAA,+CAAsB,EAAC;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,GAAG;YACf,OAAO;YACP,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,MAAM,EAAE;YAC7D,QAAQ;SACT,CAAC,CAAC;IAEL,sCAAsC;IACtC,OAAO,IAAI,iCAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC,CAAC;AAhDW,QAAA,uBAAuB,2BAgDlC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type LambdaEndpointRefusal } from '../../../domain.objects/LambdaEndpointRefusal';
|
|
2
|
+
/**
|
|
3
|
+
* .what = casts a declared `refusal` opt into one this sdk can honor, and refuses any other
|
|
4
|
+
* .why = the cast branches on one literal, so a typo or a config-driven value
|
|
5
|
+
* (`{ as: 'constraintError' }`) would fall to the default class, and the thrown message
|
|
6
|
+
* would then tell the caller to set the very opt they believe they set. a published sdk
|
|
7
|
+
* boundary is validated at runtime or it is not validated (rule.forbid.unexpected-defaults),
|
|
8
|
+
* as `asLambdaEndpointDialect` does for its peer field
|
|
9
|
+
*
|
|
10
|
+
* .note = refused at the ask, before any request is sent, so a bad opt fails on the first call —
|
|
11
|
+
* never only on the first peer refusal, which may come weeks later
|
|
12
|
+
*/
|
|
13
|
+
export declare const asLambdaEndpointRefusal: (input: {
|
|
14
|
+
declared?: unknown;
|
|
15
|
+
}) => LambdaEndpointRefusal;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asLambdaEndpointRefusal = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const LambdaEndpointRefusal_1 = require("../../../domain.objects/LambdaEndpointRefusal");
|
|
6
|
+
/**
|
|
7
|
+
* .what = casts a declared `refusal` opt into one this sdk can honor, and refuses any other
|
|
8
|
+
* .why = the cast branches on one literal, so a typo or a config-driven value
|
|
9
|
+
* (`{ as: 'constraintError' }`) would fall to the default class, and the thrown message
|
|
10
|
+
* would then tell the caller to set the very opt they believe they set. a published sdk
|
|
11
|
+
* boundary is validated at runtime or it is not validated (rule.forbid.unexpected-defaults),
|
|
12
|
+
* as `asLambdaEndpointDialect` does for its peer field
|
|
13
|
+
*
|
|
14
|
+
* .note = refused at the ask, before any request is sent, so a bad opt fails on the first call —
|
|
15
|
+
* never only on the first peer refusal, which may come weeks later
|
|
16
|
+
*/
|
|
17
|
+
const asLambdaEndpointRefusal = (input) => {
|
|
18
|
+
// absent is legal: the asker composed the request
|
|
19
|
+
if (input.declared === undefined || input.declared === null)
|
|
20
|
+
return LambdaEndpointRefusal_1.REFUSAL_DEFAULT;
|
|
21
|
+
// a known class is honored as given
|
|
22
|
+
const as = typeof input.declared === 'object' && 'as' in input.declared
|
|
23
|
+
? input.declared.as
|
|
24
|
+
: undefined;
|
|
25
|
+
if (as === 'ConstraintError')
|
|
26
|
+
return LambdaEndpointRefusal_1.REFUSAL_PASSTHROUGH;
|
|
27
|
+
if (as === 'LambdaEndpointRefusedError')
|
|
28
|
+
return LambdaEndpointRefusal_1.REFUSAL_DEFAULT;
|
|
29
|
+
// any other value is refused, with both options named. the asker's own code composed the opt,
|
|
30
|
+
// so it is the asker's defect, never its caller's: a ConstraintError here would answer that
|
|
31
|
+
// caller a 400 it cannot fix (sdk-aws-lambda#77), as `asLambdaEndpoint` refuses a bad slug.
|
|
32
|
+
// MalfunctionError, not its parent UnexpectedCodePathError: only the child prints a `💥` header
|
|
33
|
+
return helpful_errors_1.MalfunctionError.throw('the refusal opt given is not one this sdk can honor', {
|
|
34
|
+
declared: input.declared,
|
|
35
|
+
options: [
|
|
36
|
+
{ as: 'LambdaEndpointRefusedError' },
|
|
37
|
+
{ as: 'ConstraintError' },
|
|
38
|
+
],
|
|
39
|
+
hint: "omit `refusal` when this caller composed the request (a peer refusal is then a LambdaEndpointRefusedError, a server fault). pass `refusal: { as: 'ConstraintError' }` only where the request forwards your own caller's input verbatim.",
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.asLambdaEndpointRefusal = asLambdaEndpointRefusal;
|
|
43
|
+
//# sourceMappingURL=asLambdaEndpointRefusal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asLambdaEndpointRefusal.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/asLambdaEndpointRefusal.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAElD,yFAIuD;AAEvD;;;;;;;;;;GAUG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAEvC,EAAyB,EAAE;IAC1B,kDAAkD;IAClD,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI;QACzD,OAAO,uCAAe,CAAC;IAEzB,oCAAoC;IACpC,MAAM,EAAE,GACN,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,IAAI,KAAK,CAAC,QAAQ;QAC1D,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;QACnB,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,EAAE,KAAK,iBAAiB;QAAE,OAAO,2CAAmB,CAAC;IACzD,IAAI,EAAE,KAAK,4BAA4B;QAAE,OAAO,uCAAe,CAAC;IAEhE,8FAA8F;IAC9F,4FAA4F;IAC5F,4FAA4F;IAC5F,gGAAgG;IAChG,OAAO,iCAAgB,CAAC,KAAK,CAC3B,qDAAqD,EACrD;QACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,OAAO,EAAE;YACP,EAAE,EAAE,EAAE,4BAA4B,EAAE;YACpC,EAAE,EAAE,EAAE,iBAAiB,EAAE;SAC1B;QACD,IAAI,EAAE,yOAAyO;KAChP,CACF,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,uBAAuB,2BA8BlC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = whether an http status asks the caller to wait, never to fix the request
|
|
3
|
+
* .why = a throttle is a 4xx that is not a refusal: the same request succeeds after `retry-after`,
|
|
4
|
+
* so it is a server fault under either refusal opt (`domain.terms/refusal.md`, F8)
|
|
5
|
+
*
|
|
6
|
+
* .note = names one status, 429, the one rfc 9110 defines as "retry later". widen it here, and only
|
|
7
|
+
* here, if a peer is seen to answer another transient 4xx (a 408, say)
|
|
8
|
+
*/
|
|
9
|
+
export declare const getIsHttpThrottle: (input: {
|
|
10
|
+
status: number;
|
|
11
|
+
}) => boolean;
|