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.
Files changed (53) hide show
  1. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +1 -1
  2. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.d.ts +14 -0
  3. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.js +20 -0
  4. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.js.map +1 -0
  5. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.d.ts +9 -0
  6. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.js +13 -0
  7. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsBatchResponse.js.map +1 -0
  8. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.d.ts +10 -0
  9. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.js +11 -0
  10. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asSqsRecordIds.js.map +1 -0
  11. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.d.ts +9 -3
  12. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js +35 -37
  13. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js.map +1 -1
  14. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.d.ts +12 -6
  15. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js +54 -34
  16. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js.map +1 -1
  17. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.d.ts +11 -7
  18. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js +11 -7
  19. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genSqsEndpointMiddlewares.js.map +1 -1
  20. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.d.ts +19 -0
  21. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.js +22 -0
  22. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsRetried.js.map +1 -0
  23. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.d.ts +11 -0
  24. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.js +13 -0
  25. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsIdsUnclaimable.js.map +1 -0
  26. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.d.ts +11 -0
  27. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.js +18 -0
  28. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/getAllSqsSuccessRefsMalformed.js.map +1 -0
  29. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.d.ts +8 -0
  30. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.js +14 -0
  31. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/isSqsSuccessRef.js.map +1 -0
  32. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.d.ts +15 -0
  33. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.js +22 -0
  34. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordInvalid.js.map +1 -0
  35. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.d.ts +27 -0
  36. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.js +33 -0
  37. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/logSqsRecordRefused.js.map +1 -0
  38. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.d.ts +6 -5
  39. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js +6 -5
  40. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordValidated.js.map +1 -1
  41. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.d.ts +31 -0
  42. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js +46 -0
  43. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js.map +1 -0
  44. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.d.ts +6 -1
  45. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js +6 -1
  46. package/dist/domain.operations/runLambdaEndpoint/error/isErrorLike.js.map +1 -1
  47. package/dist/domain.operations/runLambdaEndpoint/serde/asErrorTypeOfErrorLike.d.ts +41 -0
  48. package/dist/domain.operations/runLambdaEndpoint/serde/asErrorTypeOfErrorLike.js +116 -0
  49. package/dist/domain.operations/runLambdaEndpoint/serde/asErrorTypeOfErrorLike.js.map +1 -0
  50. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js +52 -17
  51. package/dist/domain.operations/runLambdaEndpoint/serde/asWireFunctionErrorPayload.js.map +1 -1
  52. package/package.json +6 -6
  53. 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 client — is ancient and gets the flat one. where trail never
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
@@ -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"}
@@ -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;
@@ -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
@@ -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
@@ -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`, and is retried
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 not reported as a success is retried, and an
78
- * answer the sdk cannot read throws, which retries the whole batch
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 setSqsRecordValidated_1 = require("./setSqsRecordValidated");
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 not reported as a success is retried, and an
22
- * answer the sdk cannot read throws, which retries the whole batch
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 refusal is logged and left out, so it is retried alone
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 = new Set(recordsValidated.map((record) => record.id));
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 = answer.successes
77
- .map((success, index) => ({ index, success }))
78
- .filter(({ success }) => typeof success?.id !== 'string');
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(({ index }) => index),
82
- got: refsMalformed.map(({ success }) => success === null ? 'null' : typeof success),
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 = answer.successes
87
- .map((success) => success.id)
88
- .filter((id) => !idsClaimable.has(id));
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
- // every record not claimed as a success is retried; deduped, since sqs reads each id once
96
- const idsSucceeded = new Set(answer.successes.map((success) => success.id));
97
- const idsFailed = [
98
- ...new Set(decoded.records
99
- .map((record) => record.id)
100
- .filter((id) => !idsSucceeded.has(id))),
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;AAOrC,mEAAgE;AA6EhE;;;;;;;;;GASG;AACI,MAAM,QAAQ,GAAG,CACtB,MAA+C,EAC/C,OAAgC,EACoC,EAAE;IACtE,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,EACK,EAAE;QAC7B,gDAAgD;QAChD,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,EAAE,CAAC,CAAC;QAEpE,iFAAiF;QACjF,MAAM,gBAAgB,GAGf,EAAE,CAAC;QACV,KAAK,MAAM,MAAM,IA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AAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5E,MAAM,SAAS,GAAG;YAChB,GAAG,IAAI,GAAG,CACR,OAAO,CAAC,OAAO;iBACZ,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;iBAC1B,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CACzC;SACF,CAAC;QAEF,OAAO;YACL,iBAAiB,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;SACnE,CAAC;IACJ,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;AA/HW,QAAA,QAAQ,YA+HnB"}
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,6DAA0D;AAC1D,2DAAwD;AACxD,6DAA2D;AAC3D,qDAAkD;AAClD,2EAGqC;AACrC,+DAA4D;AAC5D,uEAAoE;AACpE,mFAAgF;AAOhF,qEAAkE;AAkFlE;;;;;;;;;;GAUG;AACI,MAAM,QAAQ,GAAG,CACtB,MAA+C,EAC/C,OAAgC,EACoC,EAAE;IACtE,wF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,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, and the refusal
23
- * fails the invoke, so sqs redrives it and eventually dead-letters it rather than
24
- * delete it
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 the queue
91
- * drains to its dead-letter, while the sender's `SendMessage` reports success.
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 = validates the one record, and writes the parsed values back into it
60
- * .note = its return is that same object, narrowed. the read happens off `eventFrozen` below
61
- * instead, which narrows the whole envelope and the record with it
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
- (0, setSqsRecordValidated_1.setSqsRecordValidated)({
64
- record: decoded.records[0],
65
- schema: config.schema.input,
66
- });
67
- /**
68
- * .what = seals the envelope before the handler's turn
69
- * .why = the envelope it hands over is the same shape `perBatch` hands over, and a guarantee
70
- * that holds on one variant and not its peer is a trap for an author who moves between
71
- * them (`rule.forbid.parallel-codepaths`)
72
- * .where = after the validator, which writes the parsed values back into the record
73
- *
74
- * .as = the validated values were written into the record, so the envelope now carries them
75
- * too — a fact typescript cannot track from a mutation
76
- * .removal = drops when the decode is parameterized on the schema's own output types
77
- */
78
- const eventFrozen = (0, setEventFrozen_1.setEventFrozen)({
79
- event: decoded,
80
- });
81
- const recordFrozen = eventFrozen.records[0];
82
- /**
83
- * .what = hands over the pair, the envelope, and the lineage. the two lifted fields are
84
- * projections of the record's slots
85
- * .note = read off `eventFrozen` rather than `decoded` — the same reference, since the freeze
86
- * is in place, and the narrowed type is what carries the readonly guarantee to the
87
- * handler. a read off `decoded` hands over the pre-freeze type and drops it
88
- */
89
- await config.invoke({
90
- payload: recordFrozen.payload,
91
- headers: recordFrozen.headers,
92
- event: eventFrozen,
93
- }, { log });
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;AAMrC,mEAAgE;AAyGhE;;;;;;;;;;;;;;;;;;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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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;AAzFW,QAAA,SAAS,aAyFpB"}
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,EAAE,CAAC,CAAC;QAEpE;;;;WAIG;QACH,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAC9B,iCAAgB,CAAC,KAAK,CACpB,6DAA6D,EAC7D;gBACE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM;gBAC7B,GAAG,EAAE,yFAAy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AAC,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
- * turns a caller fault into a successful invocation, which is correct where an http caller
21
- * waits on a response. in sqs a successful invocation means delete the message, so to
22
- * swallow a validation failure into a success would silently discard a message no handler
23
- * ever processed (`rule.forbid.failhide`). a poison pill must fail instead: `perRecord`
24
- * lets the throw escape so sqs redrives and then dead-letters it, and `perBatch` reports
25
- * that one id as a batch item failure so sqs redrives only it
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 the fault loudly, then rethrows
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
- * turns a caller fault into a successful invocation, which is correct where an http caller
24
- * waits on a response. in sqs a successful invocation means delete the message, so to
25
- * swallow a validation failure into a success would silently discard a message no handler
26
- * ever processed (`rule.forbid.failhide`). a poison pill must fail instead: `perRecord`
27
- * lets the throw escape so sqs redrives and then dead-letters it, and `perBatch` reports
28
- * that one id as a batch item failure so sqs redrives only it
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 the fault loudly, then rethrows
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;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"}
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"}
@@ -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[];
@@ -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
@@ -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[];
@@ -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