sdk-aws-lambda 0.7.2 → 0.7.3
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.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.d.ts +14 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.js +20 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.d.ts +9 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.js +13 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.d.ts +10 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.js +11 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.d.ts +9 -3
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js +35 -37
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.d.ts +12 -6
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js +54 -34
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.d.ts +11 -7
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js +11 -7
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.d.ts +19 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.js +22 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.d.ts +11 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.js +13 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.d.ts +11 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.js +18 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.d.ts +8 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.js +14 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.d.ts +15 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.js +22 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.d.ts +27 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.js +33 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.d.ts +6 -5
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js +6 -5
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.d.ts +31 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js +46 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.d.ts +6 -1
- package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js +6 -1
- package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js.map +1 -1
- package/dist/domain.operations/runLambdaEndpoint/serde/asErrorTypeOfErrorLike.d.ts +41 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asErrorTypeOfErrorLike.js +116 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asErrorTypeOfErrorLike.js.map +1 -0
- package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js +52 -17
- package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js.map +1 -1
- package/package.json +6 -6
- package/readme.md +23 -4
|
@@ -185,7 +185,7 @@ const forApiGateway = (config, context) => {
|
|
|
185
185
|
*
|
|
186
186
|
* .note = the dialect follows the caller's opt-in, as in every family. a caller that sends
|
|
187
187
|
* `x-trail-exid` is contemp and gets the nested body; one that sends none — a
|
|
188
|
-
* browser, a legacy
|
|
188
|
+
* browser, a legacy caller — is ancient and gets the flat one. where trail never
|
|
189
189
|
* ran, `asContextTrailed` defaults the flag to `false`
|
|
190
190
|
*/
|
|
191
191
|
(0, genConstraintErrorMiddleware_1.genConstraintErrorMiddleware)({
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = the thrown value as a caller fault, or null when it is not one
|
|
3
|
+
* .why = both sqs variants decide delete-vs-redrive on this one answer, so it is stated once: a
|
|
4
|
+
* variant that disagreed would delete a message its peer redrives
|
|
5
|
+
* (`invariant.constraint-errors-never-redrive-sqs`)
|
|
6
|
+
*
|
|
7
|
+
* .note = a caller fault is an `Error` that `getIsConstraintError` accepts — a `ConstraintError`,
|
|
8
|
+
* a `BadRequestError`, or a subclass. any other value, a bare `{ name }` bag included, is
|
|
9
|
+
* null, so the miss fails toward a retry
|
|
10
|
+
* .note = returns the value narrowed to `Error`, so a caller can log it without a second guard
|
|
11
|
+
*/
|
|
12
|
+
export declare const asCallerFault: (input: {
|
|
13
|
+
error: unknown;
|
|
14
|
+
}) => Error | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asCallerFault = void 0;
|
|
4
|
+
const getIsConstraintError_1 = require("../middleware/getIsConstraintError");
|
|
5
|
+
/**
|
|
6
|
+
* .what = the thrown value as a caller fault, or null when it is not one
|
|
7
|
+
* .why = both sqs variants decide delete-vs-redrive on this one answer, so it is stated once: a
|
|
8
|
+
* variant that disagreed would delete a message its peer redrives
|
|
9
|
+
* (`invariant.constraint-errors-never-redrive-sqs`)
|
|
10
|
+
*
|
|
11
|
+
* .note = a caller fault is an `Error` that `getIsConstraintError` accepts — a `ConstraintError`,
|
|
12
|
+
* a `BadRequestError`, or a subclass. any other value, a bare `{ name }` bag included, is
|
|
13
|
+
* null, so the miss fails toward a retry
|
|
14
|
+
* .note = returns the value narrowed to `Error`, so a caller can log it without a second guard
|
|
15
|
+
*/
|
|
16
|
+
const asCallerFault = (input) => input.error instanceof Error && (0, getIsConstraintError_1.getIsConstraintError)({ error: input.error })
|
|
17
|
+
? input.error
|
|
18
|
+
: null;
|
|
19
|
+
exports.asCallerFault = asCallerFault;
|
|
20
|
+
//# sourceMappingURL=asCallerFault.js.map
|
package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asCallerFault.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.ts"],"names":[],"mappings":";;;AAAA,6EAA0E;AAE1E;;;;;;;;;;GAUG;AACI,MAAM,aAAa,GAAG,CAAC,KAAyB,EAAgB,EAAE,CACvE,KAAK,CAAC,KAAK,YAAY,KAAK,IAAI,IAAA,2CAAoB,EAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1E,CAAC,CAAC,KAAK,CAAC,KAAK;IACb,CAAC,CAAC,IAAI,CAAC;AAHE,QAAA,aAAa,iBAGf"}
|
package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SQSBatchResponse } from 'aws-lambda';
|
|
2
|
+
/**
|
|
3
|
+
* .what = the answer sqs reads for a batch, rendered from the ids it must retry
|
|
4
|
+
* .why = `itemIdentifier` is aws's wire name; the sdk says `id` up to this, the one place it
|
|
5
|
+
* renders the vendor shape. which ids to retry is `getAllSqsIdsRetried`'s fact
|
|
6
|
+
*/
|
|
7
|
+
export declare const asSqsBatchResponse: (input: {
|
|
8
|
+
idsRetried: ReadonlyArray<string>;
|
|
9
|
+
}) => SQSBatchResponse;
|
package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asSqsBatchResponse = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = the answer sqs reads for a batch, rendered from the ids it must retry
|
|
6
|
+
* .why = `itemIdentifier` is aws's wire name; the sdk says `id` up to this, the one place it
|
|
7
|
+
* renders the vendor shape. which ids to retry is `getAllSqsIdsRetried`'s fact
|
|
8
|
+
*/
|
|
9
|
+
const asSqsBatchResponse = (input) => ({
|
|
10
|
+
batchItemFailures: input.idsRetried.map((id) => ({ itemIdentifier: id })),
|
|
11
|
+
});
|
|
12
|
+
exports.asSqsBatchResponse = asSqsBatchResponse;
|
|
13
|
+
//# sourceMappingURL=asSqsBatchResponse.js.map
|
package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asSqsBatchResponse.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAElC,EAAoB,EAAE,CAAC,CAAC;IACvB,iBAAiB,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;CAC1E,CAAC,CAAC;AAJU,QAAA,kBAAkB,sBAI5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = the set of ids a list of sqs records carries
|
|
3
|
+
* .why = `perBatch` reads "which ids may a handler claim" off the validated records, and a set is
|
|
4
|
+
* the shape every later membership check wants
|
|
5
|
+
*/
|
|
6
|
+
export declare const asSqsRecordIds: (input: {
|
|
7
|
+
records: ReadonlyArray<{
|
|
8
|
+
id: string;
|
|
9
|
+
}>;
|
|
10
|
+
}) => Set<string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asSqsRecordIds = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = the set of ids a list of sqs records carries
|
|
6
|
+
* .why = `perBatch` reads "which ids may a handler claim" off the validated records, and a set is
|
|
7
|
+
* the shape every later membership check wants
|
|
8
|
+
*/
|
|
9
|
+
const asSqsRecordIds = (input) => new Set(input.records.map((record) => record.id));
|
|
10
|
+
exports.asSqsRecordIds = asSqsRecordIds;
|
|
11
|
+
//# sourceMappingURL=asSqsRecordIds.js.map
|
package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asSqsRecordIds.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAC,KAE9B,EAAe,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAFxD,QAAA,cAAc,kBAE0C"}
|
|
@@ -22,7 +22,8 @@ export type ForSqsPerBatchInput<THeaders extends SqsHeadersDeclared, TPayload> =
|
|
|
22
22
|
schema: {
|
|
23
23
|
/**
|
|
24
24
|
* .what = the pair one message carries — `{ headers?, payload }`, applied per record
|
|
25
|
-
* .note = a record this refuses never reaches `invoke
|
|
25
|
+
* .note = a record this refuses never reaches `invoke`. the refusal is a caller fault, so it
|
|
26
|
+
* is logged as `sqs.record.refused` and acknowledged — sqs deletes it, with no retry
|
|
26
27
|
*/
|
|
27
28
|
input: ZodSchema<{
|
|
28
29
|
headers?: THeaders;
|
|
@@ -33,6 +34,8 @@ export type ForSqsPerBatchInput<THeaders extends SqsHeadersDeclared, TPayload> =
|
|
|
33
34
|
/**
|
|
34
35
|
* .what = the messages that passed validation — a filter over `event.records`, never a
|
|
35
36
|
* copy (`domain.terms/records.md`)
|
|
37
|
+
* .note = empty when the schema refuses every message — the handler still runs. a throw
|
|
38
|
+
* here redrives the refused records with the batch, so do not throw on `[]`
|
|
36
39
|
*/
|
|
37
40
|
records: FrozenDeep<SqsRecordDecoded<{
|
|
38
41
|
headers: SqsHeadersMerged<THeaders>;
|
|
@@ -56,6 +59,8 @@ export type ForSqsPerBatchInput<THeaders extends SqsHeadersDeclared, TPayload> =
|
|
|
56
59
|
* .what = the records this handler processed, so sqs may delete them
|
|
57
60
|
* .why = fail safe. a record not named here is retried, so a forgotten record redrives rather
|
|
58
61
|
* than vanishes (`rule.forbid.failhide`)
|
|
62
|
+
* .note = a record named here that the handler chose to drop leaves no sdk log line; log it
|
|
63
|
+
* yourself where an operator needs the trace
|
|
59
64
|
*/
|
|
60
65
|
successes: readonly FrozenDeep<SqsRecordSuccessRef>[];
|
|
61
66
|
}>;
|
|
@@ -74,8 +79,9 @@ export type ForSqsPerBatchInput<THeaders extends SqsHeadersDeclared, TPayload> =
|
|
|
74
79
|
* .why = a handler that acts on many messages at once cannot be expressed one record at a time,
|
|
75
80
|
* and a partial-batch response lets one poison message fail alone
|
|
76
81
|
*
|
|
77
|
-
* .note = fail safe by construction: every record
|
|
78
|
-
* answer the sdk cannot read throws, which retries the
|
|
82
|
+
* .note = fail safe by construction: every record neither reported as a success nor refused by
|
|
83
|
+
* the schema is retried, and an answer the sdk cannot read throws, which retries the
|
|
84
|
+
* whole batch
|
|
79
85
|
* .note = deploy precondition: the event source must declare
|
|
80
86
|
* `functionResponseTypes: ['ReportBatchItemFailures']`, or sqs deletes every message
|
|
81
87
|
*/
|
|
@@ -9,17 +9,23 @@ const helpful_errors_1 = require("helpful-errors");
|
|
|
9
9
|
const setHandlerTrailCarrier_1 = require("../../lambdaEndpointWire/frame/setHandlerTrailCarrier");
|
|
10
10
|
const asContextLogTrail_1 = require("../asContextLogTrail");
|
|
11
11
|
const setEventFrozen_1 = require("../setEventFrozen");
|
|
12
|
+
const asSqsBatchResponse_1 = require("./asSqsBatchResponse");
|
|
12
13
|
const asSqsEventDecoded_1 = require("./asSqsEventDecoded");
|
|
13
14
|
const asSqsRecordDecoded_1 = require("./asSqsRecordDecoded");
|
|
15
|
+
const asSqsRecordIds_1 = require("./asSqsRecordIds");
|
|
14
16
|
const genSqsEndpointMiddlewares_1 = require("./genSqsEndpointMiddlewares");
|
|
15
|
-
const
|
|
17
|
+
const getAllSqsIdsRetried_1 = require("./getAllSqsIdsRetried");
|
|
18
|
+
const getAllSqsIdsUnclaimable_1 = require("./getAllSqsIdsUnclaimable");
|
|
19
|
+
const getAllSqsSuccessRefsMalformed_1 = require("./getAllSqsSuccessRefsMalformed");
|
|
20
|
+
const setSqsRecordsValidated_1 = require("./setSqsRecordsValidated");
|
|
16
21
|
/**
|
|
17
22
|
* .what = generates an sqs lambda handler that serves a whole batch per invoke
|
|
18
23
|
* .why = a handler that acts on many messages at once cannot be expressed one record at a time,
|
|
19
24
|
* and a partial-batch response lets one poison message fail alone
|
|
20
25
|
*
|
|
21
|
-
* .note = fail safe by construction: every record
|
|
22
|
-
* answer the sdk cannot read throws, which retries the
|
|
26
|
+
* .note = fail safe by construction: every record neither reported as a success nor refused by
|
|
27
|
+
* the schema is retried, and an answer the sdk cannot read throws, which retries the
|
|
28
|
+
* whole batch
|
|
23
29
|
* .note = deploy precondition: the event source must declare
|
|
24
30
|
* `functionResponseTypes: ['ReportBatchItemFailures']`, or sqs deletes every message
|
|
25
31
|
*/
|
|
@@ -35,23 +41,10 @@ const perBatch = (config, context) => {
|
|
|
35
41
|
// read the trail log `genTrailMiddleware` wrote
|
|
36
42
|
const { log } = (0, asContextLogTrail_1.asContextLogTrail)({ context: lambdaContext });
|
|
37
43
|
const decoded = (0, asSqsEventDecoded_1.asSqsEventDecoded)({ wire: event }, { deserialize });
|
|
38
|
-
// validate each record; a
|
|
39
|
-
const recordsValidated =
|
|
40
|
-
for (const record of decoded.records) {
|
|
41
|
-
try {
|
|
42
|
-
recordsValidated.push((0, setSqsRecordValidated_1.setSqsRecordValidated)({ record, schema: config.schema.input }));
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
if (!(error instanceof Error))
|
|
46
|
-
throw error;
|
|
47
|
-
log.warn('sqs.record.invalid', {
|
|
48
|
-
id: record.id,
|
|
49
|
-
errorMessage: error.message,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
44
|
+
// validate each record; a caller fault is acknowledged, a server fault retried alone
|
|
45
|
+
const { recordsValidated, idsRefused } = (0, setSqsRecordsValidated_1.setSqsRecordsValidated)({ records: decoded.records, schema: config.schema.input }, { log });
|
|
53
46
|
// the only ids a handler may claim; read before its turn, so no write it makes can widen them
|
|
54
|
-
const idsClaimable =
|
|
47
|
+
const idsClaimable = (0, asSqsRecordIds_1.asSqsRecordIds)({ records: recordsValidated });
|
|
55
48
|
/**
|
|
56
49
|
* .what = seals the envelope before the handler's turn (`rule.require.frozen-invoke-inputs`)
|
|
57
50
|
* .where = after validation, since the validator writes parsed values back into each record
|
|
@@ -64,6 +57,13 @@ const perBatch = (config, context) => {
|
|
|
64
57
|
event: decoded,
|
|
65
58
|
},
|
|
66
59
|
});
|
|
60
|
+
/**
|
|
61
|
+
* .what = hands the batch to the handler; a throw escapes unchanged, whatever its class
|
|
62
|
+
* .why = a throw names no record, so it carries no verdict on any one of them — the handler
|
|
63
|
+
* may have served some before it threw. to acknowledge the batch would delete records
|
|
64
|
+
* of unknown outcome, so the throw is forwarded and the whole batch redrives. a
|
|
65
|
+
* handler that refuses one record acknowledges it by name, in `successes`
|
|
66
|
+
*/
|
|
67
67
|
const answer = await config.invoke({ records: frozen.records, event: frozen.event }, { log });
|
|
68
68
|
// refuse an answer with no `successes` array; the throw retries the whole batch
|
|
69
69
|
if (!Array.isArray(answer?.successes))
|
|
@@ -73,35 +73,33 @@ const perBatch = (config, context) => {
|
|
|
73
73
|
fix: 'return `{ successes: recordsThatSucceeded }` — the records themselves. none succeeded? `{ successes: [] }`',
|
|
74
74
|
});
|
|
75
75
|
// refuse an entry with no string `id`; the throw retries the whole batch
|
|
76
|
-
const refsMalformed =
|
|
77
|
-
.
|
|
78
|
-
|
|
76
|
+
const refsMalformed = (0, getAllSqsSuccessRefsMalformed_1.getAllSqsSuccessRefsMalformed)({
|
|
77
|
+
successes: answer.successes,
|
|
78
|
+
});
|
|
79
79
|
if (refsMalformed.length)
|
|
80
80
|
helpful_errors_1.MalfunctionError.throw('forSqs.perBatch handler answered with a success that carries no `id`', {
|
|
81
|
-
indexes: refsMalformed.map((
|
|
82
|
-
got: refsMalformed.map((
|
|
81
|
+
indexes: refsMalformed.map((ref) => ref.index),
|
|
82
|
+
got: refsMalformed.map((ref) => ref.got),
|
|
83
83
|
fix: 'return the records themselves — `return { successes: recordsThatSucceeded }` — rather than bare id strings',
|
|
84
84
|
});
|
|
85
85
|
// refuse a claim on a record the handler was not handed; the throw retries the whole batch
|
|
86
|
-
const idsUnclaimable =
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
const idsUnclaimable = (0, getAllSqsIdsUnclaimable_1.getAllSqsIdsUnclaimable)({
|
|
87
|
+
successes: answer.successes,
|
|
88
|
+
idsClaimable,
|
|
89
|
+
});
|
|
89
90
|
if (idsUnclaimable.length)
|
|
90
91
|
helpful_errors_1.MalfunctionError.throw('forSqs.perBatch handler claimed a success for a record it was not handed', {
|
|
91
92
|
idsUnclaimable,
|
|
92
93
|
idsClaimable: [...idsClaimable],
|
|
93
94
|
fix: 'return the records themselves — `return { successes: recordsThatSucceeded }` — drawn from `records`, never from `event.records` or a hand-written id',
|
|
94
95
|
});
|
|
95
|
-
//
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
batchItemFailures: idsFailed.map((id) => ({ itemIdentifier: id })),
|
|
104
|
-
};
|
|
96
|
+
// answer sqs: a record neither claimed nor refused is retried
|
|
97
|
+
const idsRetried = (0, getAllSqsIdsRetried_1.getAllSqsIdsRetried)({
|
|
98
|
+
records: decoded.records,
|
|
99
|
+
successes: answer.successes,
|
|
100
|
+
idsRefused,
|
|
101
|
+
});
|
|
102
|
+
return (0, asSqsBatchResponse_1.asSqsBatchResponse)({ idsRetried });
|
|
105
103
|
};
|
|
106
104
|
return (0, setHandlerTrailCarrier_1.setHandlerTrailCarrier)({
|
|
107
105
|
handler: (0, core_1.default)(logic).use((0, genSqsEndpointMiddlewares_1.genSqsEndpointMiddlewares)({ logTranslate: config.logTranslate })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genLambdaEndpoint.forSqs.perBatch.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAEhC,mDAAkD;AAMlD,kGAA+F;AAC/F,4DAAyD;AACzD,sDAAmD;AAEnD,2DAAwD;AACxD,6DAA2D;AAC3D,2EAGqC;
|
|
1
|
+
{"version":3,"file":"genLambdaEndpoint.forSqs.perBatch.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;A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D;QAC9D,MAAM,UAAU,GAAG,IAAA,yCAAmB,EAAC;YACrC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU;SACX,CAAC,CAAC;QACH,OAAO,IAAA,uCAAkB,EAAC,EAAE,UAAU,EAAE,CAAC,CAAC;IAC5C,CAAC,CAAC;IAEF,OAAO,IAAA,+CAAsB,EAAC;QAC5B,OAAO,EAAE,IAAA,cAAK,EAAC,KAAK,CAAC,CAAC,GAAG,CACvB,IAAA,qDAAyB,EAAC,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CACjE;QACD,OAAO,EAAE,uCAAW;KACrB,CAAC,CAAC;AACL,CAAC,CAAC;AAlHW,QAAA,QAAQ,YAkHnB"}
|
|
@@ -19,9 +19,9 @@ export type ForSqsPerRecordInput<THeaders extends SqsHeadersDeclared, TPayload>
|
|
|
19
19
|
schema: {
|
|
20
20
|
/**
|
|
21
21
|
* .what = describes the pair `invoke` receives for one message — `{ headers?, payload }`
|
|
22
|
-
* .why = a message with the wrong shape is refused before the handler runs
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* .why = a message with the wrong shape is refused before the handler runs. the refusal is
|
|
23
|
+
* a caller fault, so it is logged as `sqs.record.refused` and the invoke succeeds —
|
|
24
|
+
* sqs deletes the message once, with no retry and no dead-letter entry
|
|
25
25
|
*
|
|
26
26
|
* .note = `payload` is required and `headers` is optional. an absent `headers` key constrains
|
|
27
27
|
* naught, so header enforcement is opt-in (`rule.require.explicit-optout`)
|
|
@@ -33,6 +33,12 @@ export type ForSqsPerRecordInput<THeaders extends SqsHeadersDeclared, TPayload>
|
|
|
33
33
|
payload: TPayload;
|
|
34
34
|
}>;
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* .what = serves one message; a return acknowledges it, a throw redrives it
|
|
38
|
+
* .note = the class is the verdict: a `ConstraintError` (or `BadRequestError`) that escapes is a
|
|
39
|
+
* caller fault, so the message is logged `sqs.record.refused` and deleted — a downstream
|
|
40
|
+
* one too, such as a 429. to retry a transient fault, throw a `MalfunctionError`
|
|
41
|
+
*/
|
|
36
42
|
invoke: (input: {
|
|
37
43
|
/**
|
|
38
44
|
* .what = the message body, parsed and validated against `schema.input.payload`
|
|
@@ -87,9 +93,9 @@ export type ForSqsPerRecordInput<THeaders extends SqsHeadersDeclared, TPayload>
|
|
|
87
93
|
* exact bytes reads the string (`rule.require.explicit-optout`)
|
|
88
94
|
* .note = `false` hands `payload` to your schema as a string, so it must be set with the
|
|
89
95
|
* schema's payload half. a mis-pair is a total outage rather than one bad message:
|
|
90
|
-
* the config is per handler, so every message meets the same mismatch and
|
|
91
|
-
*
|
|
92
|
-
* clamped by `[case15]`
|
|
96
|
+
* the config is per handler, so every message meets the same mismatch and each is
|
|
97
|
+
* refused and deleted, while the sender's `SendMessage` reports success. the
|
|
98
|
+
* `sqs.record.refused` warn on every message is the one sign. clamped by `[case15]`
|
|
93
99
|
*
|
|
94
100
|
* deserialize.payload | the schema's payload half
|
|
95
101
|
* --------------------|--------------------------
|
|
@@ -9,9 +9,11 @@ const helpful_errors_1 = require("helpful-errors");
|
|
|
9
9
|
const setHandlerTrailCarrier_1 = require("../../lambdaEndpointWire/frame/setHandlerTrailCarrier");
|
|
10
10
|
const asContextLogTrail_1 = require("../asContextLogTrail");
|
|
11
11
|
const setEventFrozen_1 = require("../setEventFrozen");
|
|
12
|
+
const asCallerFault_1 = require("./asCallerFault");
|
|
12
13
|
const asSqsEventDecoded_1 = require("./asSqsEventDecoded");
|
|
13
14
|
const asSqsRecordDecoded_1 = require("./asSqsRecordDecoded");
|
|
14
15
|
const genSqsEndpointMiddlewares_1 = require("./genSqsEndpointMiddlewares");
|
|
16
|
+
const logSqsRecordRefused_1 = require("./logSqsRecordRefused");
|
|
15
17
|
const setSqsRecordValidated_1 = require("./setSqsRecordValidated");
|
|
16
18
|
/**
|
|
17
19
|
* .what = generates an sqs lambda handler that serves one message per invoke
|
|
@@ -55,42 +57,60 @@ const perRecord = (config, context) => {
|
|
|
55
57
|
fix: 'set the event source `batchSize` to 1, or reach for `genLambdaEndpoint.forSqs.perBatch`',
|
|
56
58
|
ids: decoded.records.map((record) => record.id),
|
|
57
59
|
});
|
|
60
|
+
const record = decoded.records[0];
|
|
58
61
|
/**
|
|
59
|
-
* .what =
|
|
60
|
-
* .
|
|
61
|
-
*
|
|
62
|
+
* .what = serves the one record: validate, freeze, invoke
|
|
63
|
+
* .why = a caller fault on this message is acknowledged — logged, and the invoke succeeds, so
|
|
64
|
+
* sqs deletes it once. the same bytes fail the same way on every receive, so a redrive
|
|
65
|
+
* could only page someone for the producer's fault
|
|
66
|
+
* (`invariant.constraint-errors-never-redrive-sqs`). any other fault escapes, so sqs
|
|
67
|
+
* redrives it (`rule.forbid.failhide`)
|
|
68
|
+
* .note = the batch-size refusal above stays outside this catch: it is the deployer's fault,
|
|
69
|
+
* and a `MalfunctionError` besides
|
|
62
70
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
71
|
+
try {
|
|
72
|
+
/**
|
|
73
|
+
* .what = validates the one record, and writes the parsed values back into it
|
|
74
|
+
* .note = its return is that same object, narrowed. the read happens off `eventFrozen`
|
|
75
|
+
* below instead, which narrows the whole envelope and the record with it
|
|
76
|
+
*/
|
|
77
|
+
(0, setSqsRecordValidated_1.setSqsRecordValidated)({ record, schema: config.schema.input });
|
|
78
|
+
/**
|
|
79
|
+
* .what = seals the envelope before the handler's turn
|
|
80
|
+
* .why = the envelope it hands over is the same shape `perBatch` hands over, and a
|
|
81
|
+
* guarantee that holds on one variant and not its peer is a trap for an author who
|
|
82
|
+
* moves between them (`rule.forbid.parallel-codepaths`)
|
|
83
|
+
* .where = after the validator, which writes the parsed values back into the record
|
|
84
|
+
*
|
|
85
|
+
* .as = the validated values were written into the record, so the envelope now carries
|
|
86
|
+
* them too — a fact typescript cannot track from a mutation
|
|
87
|
+
* .removal = drops when the decode is parameterized on the schema's own output types
|
|
88
|
+
*/
|
|
89
|
+
const eventFrozen = (0, setEventFrozen_1.setEventFrozen)({
|
|
90
|
+
event: decoded,
|
|
91
|
+
});
|
|
92
|
+
const recordFrozen = eventFrozen.records[0];
|
|
93
|
+
/**
|
|
94
|
+
* .what = hands over the pair, the envelope, and the lineage. the two lifted fields are
|
|
95
|
+
* projections of the record's slots
|
|
96
|
+
* .note = read off `eventFrozen` rather than `decoded` — the same reference, since the
|
|
97
|
+
* freeze is in place, and the narrowed type is what carries the readonly guarantee
|
|
98
|
+
* to the handler. a read off `decoded` hands over the pre-freeze type and drops it
|
|
99
|
+
*/
|
|
100
|
+
await config.invoke({
|
|
101
|
+
payload: recordFrozen.payload,
|
|
102
|
+
headers: recordFrozen.headers,
|
|
103
|
+
event: eventFrozen,
|
|
104
|
+
}, { log });
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
// rethrow every fault that is not the caller's, so sqs redrives it; the escaped throw is its trace
|
|
108
|
+
const callerFault = (0, asCallerFault_1.asCallerFault)({ error });
|
|
109
|
+
if (!callerFault)
|
|
110
|
+
throw error;
|
|
111
|
+
// acknowledge the caller fault, by the leaves `setSqsRecordsValidated` shares; the return deletes it
|
|
112
|
+
(0, logSqsRecordRefused_1.logSqsRecordRefused)({ message: record._.raw, error: callerFault }, { log });
|
|
113
|
+
}
|
|
94
114
|
};
|
|
95
115
|
return (0, setHandlerTrailCarrier_1.setHandlerTrailCarrier)({
|
|
96
116
|
handler: (0, core_1.default)(logic).use((0, genSqsEndpointMiddlewares_1.genSqsEndpointMiddlewares)({ logTranslate: config.logTranslate })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genLambdaEndpoint.forSqs.perRecord.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAEhC,mDAAkD;AAMlD,kGAA+F;AAC/F,4DAAyD;AACzD,sDAAmD;AAEnD,2DAAwD;AACxD,6DAA2D;AAC3D,2EAGqC;
|
|
1
|
+
{"version":3,"file":"genLambdaEndpoint.forSqs.perRecord.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAEhC,mDAAkD;AAMlD,kGAA+F;AAC/F,4DAAyD;AACzD,sDAAmD;AAEnD,mDAAgD;AAChD,2DAAwD;AACxD,6DAA2D;AAC3D,2EAGqC;AACrC,+DAA4D;AAM5D,mEAAgE;AA+GhE;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,SAAS,GAAG,CACvB,MAAgD,EAChD,OAAgC,EACwB,EAAE;IAC1D,wFAAwF;IACxF,KAAK,OAAO,CAAC;IAEb,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,wCAAmB,CAAC;IAE9D;;;OAGG;IACH,MAAM,KAAK,GAAG,KAAK,EACjB,KAAe,EACf,aAAsB,EACP,EAAE;QACjB,qFAAqF;QACrF,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,qCAAiB,EAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;QAE9D,MAAM,OAAO,GAAG,IAAA,qCAAiB,EAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,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,EAC7C,EAAE,GAAG,EAAE,CACR,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,IAAA,+CAAsB,EAAC;QAC5B,OAAO,EAAE,IAAA,cAAK,EAAC,KAAK,CAAC,CAAC,GAAG,CACvB,IAAA,qDAAyB,EAAC,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CACjE;QACD,OAAO,EAAE,uCAAW;KACrB,CAAC,CAAC;AACL,CAAC,CAAC;AA9GW,QAAA,SAAS,aA8GpB"}
|
|
@@ -17,12 +17,14 @@ export declare const CARRIER_SQS: TrailCarrier;
|
|
|
17
17
|
* (`rule.forbid.parallel-codepaths`)
|
|
18
18
|
*
|
|
19
19
|
* .why no constraint-error middleware, where both peer families register one = that middleware
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
20
|
+
* answers a caller fault with a response body, and an sqs invoke has no one to answer.
|
|
21
|
+
* each variant acknowledges a caller fault itself, per message, where the record id is in
|
|
22
|
+
* hand: `perRecord` logs `sqs.record.refused` and returns, so sqs deletes the message;
|
|
23
|
+
* `perBatch` logs it and leaves that id out of `batchItemFailures`. a refusal is never
|
|
24
|
+
* retried and never dead-lettered, since the same bytes fail the same way on every
|
|
25
|
+
* receive (`invariant.constraint-errors-never-redrive-sqs`). the log line is the discard's
|
|
26
|
+
* trace, so it is not a failhide. a fault that names no message — a `perBatch` handler
|
|
27
|
+
* throw, of any class — escapes here and redrives the batch
|
|
26
28
|
*
|
|
27
29
|
* .why no introspection middleware = introspection exists so `genServiceSdk` can generate a typed
|
|
28
30
|
* caller, and an sqs handler has no caller sdk — a producer sends to a queue, and never
|
|
@@ -34,7 +36,9 @@ export declare const CARRIER_SQS: TrailCarrier;
|
|
|
34
36
|
*
|
|
35
37
|
* index | hook | run order
|
|
36
38
|
* ------|----------------------|------------------------------------------
|
|
37
|
-
* 0 | onError | LAST — logs
|
|
39
|
+
* 0 | onError | LAST — logs a server fault loudly, then rethrows;
|
|
40
|
+
* | | a caller fault passes unlogged
|
|
41
|
+
* | | (`.dream/2026_10_22.sqs-forwarded-caller-fault-logs-loud.dream.md`)
|
|
38
42
|
* 1 | before | FIRST — produces `context.log`
|
|
39
43
|
* 2 | before/after/onError | reads `context.log`
|
|
40
44
|
*
|
|
@@ -20,12 +20,14 @@ exports.CARRIER_SQS = 'wrapper';
|
|
|
20
20
|
* (`rule.forbid.parallel-codepaths`)
|
|
21
21
|
*
|
|
22
22
|
* .why no constraint-error middleware, where both peer families register one = that middleware
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* answers a caller fault with a response body, and an sqs invoke has no one to answer.
|
|
24
|
+
* each variant acknowledges a caller fault itself, per message, where the record id is in
|
|
25
|
+
* hand: `perRecord` logs `sqs.record.refused` and returns, so sqs deletes the message;
|
|
26
|
+
* `perBatch` logs it and leaves that id out of `batchItemFailures`. a refusal is never
|
|
27
|
+
* retried and never dead-lettered, since the same bytes fail the same way on every
|
|
28
|
+
* receive (`invariant.constraint-errors-never-redrive-sqs`). the log line is the discard's
|
|
29
|
+
* trace, so it is not a failhide. a fault that names no message — a `perBatch` handler
|
|
30
|
+
* throw, of any class — escapes here and redrives the batch
|
|
29
31
|
*
|
|
30
32
|
* .why no introspection middleware = introspection exists so `genServiceSdk` can generate a typed
|
|
31
33
|
* caller, and an sqs handler has no caller sdk — a producer sends to a queue, and never
|
|
@@ -37,7 +39,9 @@ exports.CARRIER_SQS = 'wrapper';
|
|
|
37
39
|
*
|
|
38
40
|
* index | hook | run order
|
|
39
41
|
* ------|----------------------|------------------------------------------
|
|
40
|
-
* 0 | onError | LAST — logs
|
|
42
|
+
* 0 | onError | LAST — logs a server fault loudly, then rethrows;
|
|
43
|
+
* | | a caller fault passes unlogged
|
|
44
|
+
* | | (`.dream/2026_10_22.sqs-forwarded-caller-fault-logs-loud.dream.md`)
|
|
41
45
|
* 1 | before | FIRST — produces `context.log`
|
|
42
46
|
* 2 | before/after/onError | reads `context.log`
|
|
43
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genSqsEndpointMiddlewares.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.ts"],"names":[],"mappings":";;;AAGA,uGAAoG;AACpG,+EAA4E;AAC5E,yEAAsE;AAGtE;;;;;;GAMG;AACU,QAAA,WAAW,GAAiB,SAAS,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"genSqsEndpointMiddlewares.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.ts"],"names":[],"mappings":";;;AAGA,uGAAoG;AACpG,+EAA4E;AAC5E,yEAAsE;AAGtE;;;;;;GAMG;AACU,QAAA,WAAW,GAAiB,SAAS,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACI,MAAM,yBAAyB,GAAG,CAAC,KAEzC,EAIG,EAAE,CAAC;IACL;;;;;;;;;;;OAWG;IACH,IAAA,qEAAiC,EAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAC3D,IAAA,uCAAkB,EAAC,EAAE,OAAO,EAAE,mBAAW,EAAE,CAAC;IAC5C,IAAA,6CAAqB,EAAC,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC;CAC5D,CAAC;AAtBW,QAAA,yBAAyB,6BAsBpC"}
|
package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = the ids sqs must retry: every delivered record neither claimed as a success nor refused
|
|
3
|
+
* .why = fail safe by construction — a record the handler did not vouch for is retried, never
|
|
4
|
+
* deleted. a record the schema refused is a caller fault, so it is acknowledged and left
|
|
5
|
+
* out (`invariant.constraint-errors-never-redrive-sqs`)
|
|
6
|
+
*
|
|
7
|
+
* .note = retry is the default for every record this does not exclude, so a server fault met at
|
|
8
|
+
* validation needs no list of its own — it is simply never excluded
|
|
9
|
+
* .note = deduped, since sqs reads each id once
|
|
10
|
+
*/
|
|
11
|
+
export declare const getAllSqsIdsRetried: (input: {
|
|
12
|
+
records: ReadonlyArray<{
|
|
13
|
+
id: string;
|
|
14
|
+
}>;
|
|
15
|
+
successes: ReadonlyArray<{
|
|
16
|
+
id: string;
|
|
17
|
+
}>;
|
|
18
|
+
idsRefused: ReadonlySet<string>;
|
|
19
|
+
}) => string[];
|
package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllSqsIdsRetried = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = the ids sqs must retry: every delivered record neither claimed as a success nor refused
|
|
6
|
+
* .why = fail safe by construction — a record the handler did not vouch for is retried, never
|
|
7
|
+
* deleted. a record the schema refused is a caller fault, so it is acknowledged and left
|
|
8
|
+
* out (`invariant.constraint-errors-never-redrive-sqs`)
|
|
9
|
+
*
|
|
10
|
+
* .note = retry is the default for every record this does not exclude, so a server fault met at
|
|
11
|
+
* validation needs no list of its own — it is simply never excluded
|
|
12
|
+
* .note = deduped, since sqs reads each id once
|
|
13
|
+
*/
|
|
14
|
+
const getAllSqsIdsRetried = (input) => {
|
|
15
|
+
const idsSucceeded = new Set(input.successes.map((success) => success.id));
|
|
16
|
+
const isRetried = (id) => !idsSucceeded.has(id) && !input.idsRefused.has(id);
|
|
17
|
+
return [
|
|
18
|
+
...new Set(input.records.map((record) => record.id).filter(isRetried)),
|
|
19
|
+
];
|
|
20
|
+
};
|
|
21
|
+
exports.getAllSqsIdsRetried = getAllSqsIdsRetried;
|
|
22
|
+
//# sourceMappingURL=getAllSqsIdsRetried.js.map
|
package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllSqsIdsRetried.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAInC,EAAY,EAAE;IACb,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,CAAC,EAAU,EAAW,EAAE,CACxC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrD,OAAO;QACL,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;KACvE,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,mBAAmB,uBAW9B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = the ids a perBatch answer claims that the handler was never handed
|
|
3
|
+
* .why = a claim on a record outside the validated set — a forged id, or one drawn from
|
|
4
|
+
* `event.records` — would delete a message no handler served, so each must be refused
|
|
5
|
+
*/
|
|
6
|
+
export declare const getAllSqsIdsUnclaimable: (input: {
|
|
7
|
+
successes: ReadonlyArray<{
|
|
8
|
+
id: string;
|
|
9
|
+
}>;
|
|
10
|
+
idsClaimable: ReadonlySet<string>;
|
|
11
|
+
}) => string[];
|
package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllSqsIdsUnclaimable = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = the ids a perBatch answer claims that the handler was never handed
|
|
6
|
+
* .why = a claim on a record outside the validated set — a forged id, or one drawn from
|
|
7
|
+
* `event.records` — would delete a message no handler served, so each must be refused
|
|
8
|
+
*/
|
|
9
|
+
const getAllSqsIdsUnclaimable = (input) => input.successes
|
|
10
|
+
.map((success) => success.id)
|
|
11
|
+
.filter((id) => !input.idsClaimable.has(id));
|
|
12
|
+
exports.getAllSqsIdsUnclaimable = getAllSqsIdsUnclaimable;
|
|
13
|
+
//# sourceMappingURL=getAllSqsIdsUnclaimable.js.map
|