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.
Files changed (101) hide show
  1. package/dist/domain.objects/LambdaEndpointRefusal.d.ts +25 -0
  2. package/dist/domain.objects/LambdaEndpointRefusal.js +19 -0
  3. package/dist/domain.objects/LambdaEndpointRefusal.js.map +1 -0
  4. package/dist/domain.objects/LambdaEndpointRefusedError.d.ts +25 -0
  5. package/dist/domain.objects/LambdaEndpointRefusedError.js +28 -0
  6. package/dist/domain.objects/LambdaEndpointRefusedError.js.map +1 -0
  7. package/dist/domain.objects/LambdaEventSchemaSource.d.ts +26 -0
  8. package/dist/domain.objects/LambdaEventSchemaSource.js +11 -0
  9. package/dist/domain.objects/LambdaEventSchemaSource.js.map +1 -0
  10. package/dist/domain.operations/asLambdaEventSchema/KinesisStreamEventDecoded.d.ts +13 -0
  11. package/dist/domain.operations/asLambdaEventSchema/KinesisStreamEventDecoded.js +3 -0
  12. package/dist/domain.operations/asLambdaEventSchema/KinesisStreamEventDecoded.js.map +1 -0
  13. package/dist/domain.operations/asLambdaEventSchema/SnsEventDecoded.d.ts +19 -0
  14. package/dist/domain.operations/asLambdaEventSchema/SnsEventDecoded.js +3 -0
  15. package/dist/domain.operations/asLambdaEventSchema/SnsEventDecoded.js.map +1 -0
  16. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventPayloadSchema.d.ts +37 -0
  17. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventPayloadSchema.js +57 -0
  18. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventPayloadSchema.js.map +1 -0
  19. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.d.ts +39 -0
  20. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromKinesis.d.ts +61 -0
  21. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromKinesis.js +89 -0
  22. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromKinesis.js.map +1 -0
  23. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromSns.d.ts +58 -0
  24. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromSns.js +81 -0
  25. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.fromSns.js.map +1 -0
  26. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.js +45 -0
  27. package/dist/domain.operations/asLambdaEventSchema/asLambdaEventSchema.js.map +1 -0
  28. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.d.ts +3 -0
  29. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.d.ts +11 -2
  30. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.js +7 -2
  31. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaApiGateway.js.map +1 -1
  32. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.d.ts +10 -0
  33. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.js +17 -5
  34. package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.viaInvoke.js.map +1 -1
  35. package/dist/domain.operations/askLambdaEndpoint/cache/asAskLambdaCacheKeyOfRefusal.d.ts +17 -0
  36. package/dist/domain.operations/askLambdaEndpoint/cache/asAskLambdaCacheKeyOfRefusal.js +22 -0
  37. package/dist/domain.operations/askLambdaEndpoint/cache/asAskLambdaCacheKeyOfRefusal.js.map +1 -0
  38. package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.d.ts +2 -0
  39. package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js +1 -0
  40. package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js.map +1 -1
  41. package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.d.ts +9 -5
  42. package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.js +27 -9
  43. package/dist/domain.operations/askLambdaEndpoint/serde/asErrorFromHttpResponse.js.map +1 -1
  44. package/dist/domain.operations/askLambdaEndpoint/serde/asLambdaEndpointRefusal.d.ts +15 -0
  45. package/dist/domain.operations/askLambdaEndpoint/serde/asLambdaEndpointRefusal.js +43 -0
  46. package/dist/domain.operations/askLambdaEndpoint/serde/asLambdaEndpointRefusal.js.map +1 -0
  47. package/dist/domain.operations/askLambdaEndpoint/serde/getIsHttpThrottle.d.ts +11 -0
  48. package/dist/domain.operations/askLambdaEndpoint/serde/getIsHttpThrottle.js +15 -0
  49. package/dist/domain.operations/askLambdaEndpoint/serde/getIsHttpThrottle.js.map +1 -0
  50. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.d.ts +1 -1
  51. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js +9 -2
  52. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js.map +1 -1
  53. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genLambdaEventRefusedLogMiddleware.d.ts +25 -0
  54. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genLambdaEventRefusedLogMiddleware.js +66 -0
  55. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/genLambdaEventRefusedLogMiddleware.js.map +1 -0
  56. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/getAllLambdaEventIds.d.ts +12 -0
  57. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/getAllLambdaEventIds.js +42 -0
  58. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/getAllLambdaEventIds.js.map +1 -0
  59. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/logLambdaEventRefused.d.ts +27 -0
  60. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/logLambdaEventRefused.js +103 -0
  61. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/middleware/logLambdaEventRefused.js.map +1 -0
  62. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js +1 -1
  63. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js.map +1 -1
  64. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js +1 -1
  65. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/setSqsRecordsValidated.js.map +1 -1
  66. package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forSqs → middleware}/asCallerFault.d.ts +4 -3
  67. package/dist/domain.operations/genLambdaEndpoint/{genLambdaEndpoint.forSqs → middleware}/asCallerFault.js +5 -4
  68. package/dist/domain.operations/genLambdaEndpoint/middleware/asCallerFault.js.map +1 -0
  69. package/dist/domain.operations/genLambdaEndpoint/middleware/asLogMethodOfFailure.d.ts +17 -0
  70. package/dist/domain.operations/genLambdaEndpoint/middleware/asLogMethodOfFailure.js +26 -0
  71. package/dist/domain.operations/genLambdaEndpoint/middleware/asLogMethodOfFailure.js.map +1 -0
  72. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js +2 -2
  73. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js.map +1 -1
  74. package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.d.ts +15 -0
  75. package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js +34 -13
  76. package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js.map +1 -1
  77. package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.js +1 -1
  78. package/dist/domain.operations/genServiceSdk/gen.file/asMechanismsFileSource.js.map +1 -1
  79. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.d.ts +2 -0
  80. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js +8 -4
  81. package/dist/domain.operations/genServiceSdk/gen.mechanism/asMechanismFnSource.js.map +1 -1
  82. package/dist/domain.operations/lambdaEndpointWire/error/asErrorFromPeerRefusal.d.ts +22 -0
  83. package/dist/domain.operations/lambdaEndpointWire/error/asErrorFromPeerRefusal.js +34 -0
  84. package/dist/domain.operations/lambdaEndpointWire/error/asErrorFromPeerRefusal.js.map +1 -0
  85. package/dist/domain.operations/lambdaEndpointWire/frame/getOneLambdaEventSchemaSource.d.ts +15 -0
  86. package/dist/domain.operations/lambdaEndpointWire/frame/getOneLambdaEventSchemaSource.js +50 -0
  87. package/dist/domain.operations/lambdaEndpointWire/frame/getOneLambdaEventSchemaSource.js.map +1 -0
  88. package/dist/domain.operations/lambdaEndpointWire/frame/setLambdaEventSchemaSource.d.ts +27 -0
  89. package/dist/domain.operations/lambdaEndpointWire/frame/setLambdaEventSchemaSource.js +31 -0
  90. package/dist/domain.operations/lambdaEndpointWire/frame/setLambdaEventSchemaSource.js.map +1 -0
  91. package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.d.ts +15 -4
  92. package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js +32 -17
  93. package/dist/domain.operations/lambdaEndpointWire/getParsedResponse.js.map +1 -1
  94. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js +12 -0
  95. package/dist/domain.operations/runLambdaEndpoint/runLambdaEndpoint.onSerialized.js.map +1 -1
  96. package/dist/index.d.ts +15 -0
  97. package/dist/index.js +10 -1
  98. package/dist/index.js.map +1 -1
  99. package/package.json +10 -8
  100. package/readme.md +115 -2
  101. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/asCallerFault.js.map +0 -1
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
  * triggers mint a fresh `exid` per invoke (`domain.terms/trail.md`)
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.runLambdaEndpoint = exports.isLambdaEndpointErrorEnvelopeContemp = exports.isLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointErrorEnvelopeContemp = exports.asLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointOutput = exports.asLambdaContext = exports.asTrailExidHeaders = exports.getOneLambdaContract = exports.getAllLambdaFunctionsByPrefix = exports.getAllLambdaContracts = exports.genServiceSdk = exports.getValidatedOutput = exports.getValidatedInput = exports.genZodOutputValidationMiddleware = exports.genTrailMiddleware = exports.genIoLoggerMiddleware = exports.genIntrospectionMiddleware = exports.genInternalServiceErrorMiddleware = exports.genConstraintErrorMiddleware = exports.asContextTrailed = exports.genZodEventValidationMiddleware = exports.genZodInputValidationMiddleware = exports.genContentTypeCoherenceMiddleware = exports.genApiGatewayRequestEventNormalizationMiddleware = exports.isApiGatewayResponse = exports.asApiGatewayResponseSchema = exports.genLambdaEndpoint = exports.asLambdaEvent = exports.asLambdaEndpoint = exports.getAskLambdaCacheKey = exports.asCacheWithoutSet = exports.askLambdaEndpoint = exports.LambdaServiceNotFoundError = exports.LambdaIntrospectionNotSupportedError = exports.LambdaIntrospectionBlockedError = exports.LambdaFunctionNotFoundError = exports.LambdaEndpointError = exports.LambdaEndpoint = exports.LambdaDomainObjectRefUnbindableError = exports.LambdaDomainObjectNotCapturableError = exports.LambdaCredentialsAbsentError = exports.HttpStatusCode = exports.GeneratedFile = exports.delLambdaSdks = exports.BadRequestError = void 0;
13
+ exports.runLambdaEndpoint = exports.isLambdaEndpointErrorEnvelopeContemp = exports.isLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointErrorEnvelopeContemp = exports.asLambdaEndpointErrorEnvelopeAncient = exports.asLambdaEndpointOutput = exports.asLambdaContext = exports.asTrailExidHeaders = exports.getOneLambdaContract = exports.getAllLambdaFunctionsByPrefix = exports.getAllLambdaContracts = exports.genServiceSdk = exports.getValidatedOutput = exports.getValidatedInput = exports.genZodOutputValidationMiddleware = exports.genTrailMiddleware = exports.genIoLoggerMiddleware = exports.genIntrospectionMiddleware = exports.genInternalServiceErrorMiddleware = exports.genConstraintErrorMiddleware = exports.asContextTrailed = exports.genZodEventValidationMiddleware = exports.genZodInputValidationMiddleware = exports.genContentTypeCoherenceMiddleware = exports.genApiGatewayRequestEventNormalizationMiddleware = exports.isApiGatewayResponse = exports.asApiGatewayResponseSchema = exports.genLambdaEndpoint = exports.asLambdaEventSchema = exports.asLambdaEvent = exports.asLambdaEndpoint = exports.getAskLambdaCacheKey = exports.asCacheWithoutSet = exports.askLambdaEndpoint = exports.LambdaServiceNotFoundError = exports.LambdaIntrospectionNotSupportedError = exports.LambdaIntrospectionBlockedError = exports.LambdaFunctionNotFoundError = exports.LambdaEndpointRefusedError = exports.LambdaEndpointError = exports.LambdaEndpoint = exports.LambdaDomainObjectRefUnbindableError = exports.LambdaDomainObjectNotCapturableError = exports.LambdaCredentialsAbsentError = exports.HttpStatusCode = exports.GeneratedFile = exports.delLambdaSdks = exports.BadRequestError = void 0;
14
14
  // re-export from helpful-errors for convenience
15
15
  var helpful_errors_1 = require("helpful-errors");
16
16
  Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return helpful_errors_1.BadRequestError; } });
@@ -36,6 +36,8 @@ var LambdaEndpoint_1 = require("./domain.objects/LambdaEndpoint");
36
36
  Object.defineProperty(exports, "LambdaEndpoint", { enumerable: true, get: function () { return LambdaEndpoint_1.LambdaEndpoint; } });
37
37
  var LambdaEndpointError_1 = require("./domain.objects/LambdaEndpointError");
38
38
  Object.defineProperty(exports, "LambdaEndpointError", { enumerable: true, get: function () { return LambdaEndpointError_1.LambdaEndpointError; } });
39
+ var LambdaEndpointRefusedError_1 = require("./domain.objects/LambdaEndpointRefusedError");
40
+ Object.defineProperty(exports, "LambdaEndpointRefusedError", { enumerable: true, get: function () { return LambdaEndpointRefusedError_1.LambdaEndpointRefusedError; } });
39
41
  // contract discovery errors
40
42
  var LambdaFunctionNotFoundError_1 = require("./domain.objects/LambdaFunctionNotFoundError");
41
43
  Object.defineProperty(exports, "LambdaFunctionNotFoundError", { enumerable: true, get: function () { return LambdaFunctionNotFoundError_1.LambdaFunctionNotFoundError; } });
@@ -58,6 +60,13 @@ Object.defineProperty(exports, "asLambdaEndpoint", { enumerable: true, get: func
58
60
  // test utils — the event source axis (construct the envelope a source delivers)
59
61
  var asLambdaEvent_1 = require("./domain.operations/asLambdaEvent/asLambdaEvent");
60
62
  Object.defineProperty(exports, "asLambdaEvent", { enumerable: true, get: function () { return asLambdaEvent_1.asLambdaEvent; } });
63
+ /**
64
+ * .what = the validate direction of the event source axis — `{ fromSns, fromKinesis }`
65
+ * .why = an sns or kinesis handler wired via `genLambdaEndpoint.forAsk` gets a validated
66
+ * envelope and a typed payload. sqs is served by `genLambdaEndpoint.forSqs`
67
+ */
68
+ var asLambdaEventSchema_1 = require("./domain.operations/asLambdaEventSchema/asLambdaEventSchema");
69
+ Object.defineProperty(exports, "asLambdaEventSchema", { enumerable: true, get: function () { return asLambdaEventSchema_1.asLambdaEventSchema; } });
61
70
  /**
62
71
  * .what = the `genLambdaEndpoint` family —
63
72
  * `{ forAsk, forApiGateway, forSqs: { perRecord, perBatch } }`
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,gDAAgD;AAChD,iDAAiD;AAAxC,iHAAA,eAAe,OAAA;AAQxB;;;;;GAKG;AACH,kEAAkE;AAAzD,6GAAA,aAAa,OAAA;AAWtB,gEAA+D;AAAtD,8GAAA,aAAa,OAAA;AACtB,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AACvB,8FAA6F;AAApF,4IAAA,4BAA4B,OAAA;AACrC,8GAA6G;AAApG,4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,wHAAA,kBAAkB,OAAA;AAC3B,sIAAqI;AAA5H,oJAAA,gCAAgC,OAAA;AASzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wGAAuG;AAA9F,sHAAA,iBAAiB,OAAA;AAC1B,0GAG6E;AAF3E,wHAAA,kBAAkB,OAAA;AAcpB,8DAA8D;AAC9D,iFAAgF;AAAvE,8GAAA,aAAa,OAAA;AACtB,0CAA0C;AAC1C,yGAIyE;AADvE,8HAAA,qBAAqB,OAAA;AAEvB,wIAAuI;AAA9H,8IAAA,6BAA6B,OAAA;AACtC,sGAIuE;AADrE,4HAAA,oBAAoB,OAAA;AAEtB;;;;GAIG;AACH,sGAAqG;AAA5F,wHAAA,kBAAkB,OAAA;AAC3B,gFAAgF;AAChF,iGAAgG;AAAvF,kHAAA,eAAe,OAAA;AACxB,8EAA8E;AAC9E,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,4CAA4C;AAC5C,+GAA8G;AAArG,gIAAA,sBAAsB,OAAA;AAC/B,iFAAiF;AACjF,gFAAgF;AAChF,8EAA8E;AAC9E,0CAA0C;AAC1C,6HAKqF;AAJnF,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AACpC,qJAAA,oCAAoC,OAAA;AAMtC,6FAA4F;AAAnF,sHAAA,iBAAiB,OAAA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "sdk-aws-lambda",
3
3
  "author": "ehmpathy",
4
4
  "description": "a simple and opinionated sdk for aws lambda. define endpoints, ask endpoints, auto-propagate trace-ids.",
5
- "version": "0.7.3",
5
+ "version": "0.8.1",
6
6
  "repository": "ehmpathy/sdk-aws-lambda",
7
7
  "homepage": "https://github.com/ehmpathy/sdk-aws-lambda",
8
8
  "keywords": [
@@ -55,7 +55,7 @@
55
55
  "preversion": "npm run prepush",
56
56
  "postversion": "git push origin HEAD --tags --no-verify",
57
57
  "prepare:husky": "husky install && chmod ug+x .husky/*",
58
- "prepare:rhachet": "rhachet init --hooks --roles mechanic architect ergonomist driver reviewer dreamer behaver dispatcher",
58
+ "prepare:rhachet": "rhachet init --keys --hooks --roles mechanic behaver driver reviewer librarian ergonomist architect dispatcher learner achiever telepath operator observer deployer playwright enroller",
59
59
  "prepare": "if [ -e .git ] && [ -z $CI ]; then npm run prepare:husky && npm run prepare:rhachet; fi",
60
60
  "upgrade:rhachet": "rhachet upgrade"
61
61
  },
@@ -91,8 +91,8 @@
91
91
  "@types/node": "22.15.21",
92
92
  "archiver": "8.0.0",
93
93
  "cz-conventional-changelog": "3.3.0",
94
- "declapract": "^0.13.18",
95
- "declapract-typescript-ehmpathy": "^0.49.4",
94
+ "declapract": "^0.13.27",
95
+ "declapract-typescript-ehmpathy": "^0.50.0",
96
96
  "declastruct": "1.7.3",
97
97
  "declastruct-aws": "^1.5.2",
98
98
  "declastruct-github": "1.3.0",
@@ -102,14 +102,16 @@
102
102
  "husky": "8.0.3",
103
103
  "iso-time": "1.11.7",
104
104
  "jest": "30.2.0",
105
- "rhachet": "1.50.1",
105
+ "rhachet": "1.51.0",
106
106
  "rhachet-brains-anthropic": "0.4.3",
107
107
  "rhachet-brains-fireworksai": "0.2.3",
108
108
  "rhachet-brains-openrouter": "0.1.4",
109
109
  "rhachet-brains-xai": "0.3.3",
110
- "rhachet-roles-bhrain": "0.42.3",
111
- "rhachet-roles-bhuild": "0.23.3",
112
- "rhachet-roles-ehmpathy": "1.40.0",
110
+ "rhachet-roles-bhrain": "0.43.1",
111
+ "rhachet-roles-bhrowser": "0.1.0",
112
+ "rhachet-roles-bhuild": "0.24.0",
113
+ "rhachet-roles-ehmpathy": "1.42.0",
114
+ "rhachet-roles-ghlitch": "0.4.0",
113
115
  "rhachet-roles-rhachet": "0.1.7",
114
116
  "test-fns": "1.15.8",
115
117
  "tsc-alias": "1.8.10",
package/readme.md CHANGED
@@ -159,6 +159,8 @@ retried, and an answer the sdk cannot read retries the whole batch. its event so
159
159
  a caller fault is never retried. a message the schema refuses, or a `ConstraintError` (or
160
160
  `BadRequestError`) a `perRecord` handler throws, logs `sqs.record.refused` at warn and is deleted,
161
161
  with no dead-letter entry. to retry a fault, throw a `MalfunctionError`; every other throw redrives.
162
+ a peer's refusal of a request the handler composed is the handler's own fault, so it redrives too
163
+ (see [when the endpoint refuses the request](#when-the-endpoint-refuses-the-request)).
162
164
 
163
165
  - `sqs.record.refused` carries the full message as delivered (`message`: body, attributes, queue
164
166
  arn), so an operator can requeue it from the log. alarm on its volume: a schema bug of ours
@@ -172,6 +174,77 @@ with no dead-letter entry. to retry a fault, throw a `MalfunctionError`; every o
172
174
 
173
175
  ⇒ zoom in: [records](./.agent/repo=.this/role=any/briefs/domain.terms/records.md)
174
176
 
177
+ ### an sns or kinesis endpoint
178
+
179
+ `asLambdaEventSchema` gives `forAsk` the schema of the event aws delivers, and optionally the schema
180
+ of the message inside it. one argument validates the envelope and the message, decoded in place:
181
+
182
+ ```ts
183
+ import { asLambdaEventSchema, genLambdaEndpoint } from 'sdk-aws-lambda';
184
+
185
+ export const handler = genLambdaEndpoint.forAsk({
186
+ schema: {
187
+ input: asLambdaEventSchema.fromSns({ payload: schemaOfSesNotice }), // Message: json → validated
188
+ output: z.void(),
189
+ },
190
+ invoke: async ({ payload }, context) =>
191
+ handleSesNotice({ notice: payload.Records[0]!.Sns.Message }, context), // typed, no JSON.parse
192
+ });
193
+ ```
194
+
195
+ | call | the handler reads | the handler accepts |
196
+ |---|---|---|
197
+ | `fromSns()` | `SNSEvent`, as sent | `SNSEvent` |
198
+ | `fromSns({ payload })` | `SnsEventDecoded<X>`: `Records[].Sns.Message` decoded | `SNSEvent` |
199
+ | `fromKinesis()` | `KinesisStreamEvent`, `data` still base64 | `KinesisStreamEvent` |
200
+ | `fromKinesis({ payload })` | `KinesisStreamEventDecoded<X>`: `Records[].kinesis.data` base64-decoded | `KinesisStreamEvent` |
201
+
202
+ - the message is parsed as json by default. a text message (a log line, a csv row) sets
203
+ `deserialize: { payload: false }`, and `payload` meets the utf8 string. a text stream left on the
204
+ json default refuses every event; the refusal's issue names the opt-out
205
+ - a caller fault is acknowledged, never retried: a refusal by the schema, or a `ConstraintError` (or
206
+ `BadRequestError`) your `invoke` throws, makes the invoke succeed, so sns does not retry it and
207
+ kinesis advances the shard, outside a tumble window. no dead-letter queue or on-failure destination receives it. a
208
+ `lambda.event.refused` warn line names the source, the cause, the issue paths, and the ids (sns
209
+ `MessageId`, kinesis `eventID`), since the log is its only trace
210
+ - to retry, throw a `MalfunctionError` (or any other error): the invoke fails. for sns, lambda's
211
+ async invoke retries it (twice by default), then hands it to the function's on-failure
212
+ destination or dead-letter queue; for kinesis, the batch retries and the shard halts until it
213
+ succeeds or the records expire. that holds for a plain `Error` a payload `.transform()` throws
214
+ too, so a transform that cannot build its value should throw a `ConstraintError` to drop it
215
+ - alarm on the warn line's volume, e.g. a cloudwatch metric filter on the term
216
+ `"lambda.event.refused"`, which matches under the text and the json log format alike: a schema
217
+ bug of ours acknowledges every event, with no lambda error to alarm on
218
+ - on a wide kinesis batch, the line shows the first 100 ids and 20 issues, with `idsCount`,
219
+ `issuesCount`, and `idLast` beside them, so it fits one cloudwatch event and still bounds the
220
+ range to replay
221
+ - `.refine()`, `.describe()` and `.meta()` on the built schema keep its source, so its refusals still
222
+ warn. a schema that wraps it (`.optional()`, `.nullable()`, `.default()`, `.transform()`,
223
+ `.pipe()`, a union) is a new schema, so its refusals log at debug only, as any other `forAsk`
224
+ caller's do. to check a whole batch, `.refine()` the built schema rather than wrap it
225
+ - kinesis `Records` may be empty (aws's own sample handlers guard it, and a tumble window's final
226
+ invoke may carry none), so check its length before `Records[0]`. sns always delivers one
227
+ - kinesis response configs: under tumble windows, an answer with no `state` fails the invoke, so a
228
+ refusal suspends the shard rather than advance it; under `ReportBatchItemFailures`, return
229
+ `{ batchItemFailures }` from an envelope-only (`fromKinesis()`) handler to retry only the bad
230
+ records, which also answers the whole-batch caution below
231
+ - ⚠️ **kinesis: one refused record refuses the whole batch**, good records included. for a stream of
232
+ mixed quality, use `fromKinesis()` (envelope only) and judge each record in the handler. binary
233
+ data (a KPL aggregate, cloudwatch-logs gzip) does not fit `payload` either: under
234
+ `deserialize: { payload: false }` the bytes arrive as a mangled string a bare `z.string()`
235
+ accepts, so use the envelope-only form for a binary stream, and constrain a text schema's form
236
+ (e.g. a regex)
237
+ - **sqs has no `asLambdaEventSchema.fromSqs`**: use `genLambdaEndpoint.forSqs`, which validates each
238
+ record's body and refuses a bad message alone, never with its batch. api gateway has no
239
+ `fromApiGateway` on the same axis (`genLambdaEndpoint.forApiGateway` validates its own
240
+ `schema.input`), and s3 has no `fromS3`, since an s3 notice carries a reference, never a payload
241
+ - one zod in your tree: a `payload` schema from another zod copy or major is a type error. pin one
242
+ version via `pnpm.overrides.zod`
243
+ - in a test, pass `struct: { payload: 'ancient' }` to `runLambdaEndpoint.onReferenced` with an
244
+ `asLambdaEvent.fromSns` / `fromKinesis` event: aws sends the bare event, so a refusal there answers
245
+ the flat `{ errorMessage, errorType }` body prod meets. the contemp default frames a
246
+ `{ event, trail }` wrapper aws never sends, and answers the nested `{ error: { class, … } }` body
247
+
175
248
  ## ask an endpoint
176
249
 
177
250
  ```ts
@@ -185,6 +258,43 @@ const result = await askLambdaEndpoint<TRequest, TResponse>(
185
258
 
186
259
  the caller's `trail.exid` rides along, so logs correlate across the call.
187
260
 
261
+ ### when the endpoint refuses the request
262
+
263
+ a peer that answers `ConstraintError` or `BadRequestError` (or an http 4xx) refuses the request **you
264
+ composed**. that is your malfunction, not your caller's fault, so the ask throws
265
+ `LambdaEndpointRefusedError`, a `MalfunctionError`. an api gateway endpoint then answers its caller a
266
+ 500 with a `correlationId`, never a 400 the caller cannot fix, and logs the failure at error. the
267
+ message names the peer, its reason, and the fix.
268
+
269
+ where the request forwards your own caller's input verbatim, the refusal is your caller's to fix. opt
270
+ in per call, and the ask throws a `ConstraintError` instead:
271
+
272
+ ```ts
273
+ await askLambdaEndpoint(
274
+ { which, event, refusal: { as: 'ConstraintError' } },
275
+ { log, env: { access: 'prep' } },
276
+ );
277
+ ```
278
+
279
+ ⚠️ upgrade from 0.7: a `catch (e) { if (e instanceof ConstraintError) … }` around an ask no longer
280
+ sees a peer refusal, with no compile error. catch `LambdaEndpointRefusedError`, or opt in where the
281
+ call forwards. in a `forSqs.perRecord` handler, a peer refusal now redrives the message, then
282
+ dead-letters it, unless the call opts in. a failed async invoke is retried by aws, and a retry
283
+ wrapper that retries a `MalfunctionError` retries a refusal too.
284
+
285
+ every failure an endpoint's chain observes logs `handler.output` at warn (a caller fault) or error
286
+ (all else), with its message and stack, where 0.7 logged it at debug. a warn-keyed alarm sees more
287
+ volume. one exception: a caller fault a `forSqs.perRecord` handler throws is acknowledged inside
288
+ the leaf, so the chain sees a success and writes `handler.output` at debug. its trace is the
289
+ `sqs.record.refused` warn line above.
290
+
291
+ a function generated by `genServiceSdk` takes the same opt as a third argument:
292
+ `svcJobs.getJob(event, context, { refusal: { as: 'ConstraintError' } })`. regenerate the sdk to get
293
+ the slot.
294
+
295
+ an http 429 is a throttle, not a refusal: it throws a `MalfunctionError` under either opt, with
296
+ `retry-after` in `metadata.headers`.
297
+
188
298
  ### ask an api gateway endpoint, over http
189
299
 
190
300
  ```ts
@@ -198,8 +308,9 @@ const { status, body } = await askLambdaEndpoint.viaApiGateway<TResponse>(
198
308
 
199
309
  takes the standard http request: `{ url, method, headers, body }`. an object `body` is sent as json.
200
310
 
201
- it resolves `{ status, headers, text, body }`. a 4xx throws a `ConstraintError`; a 5xx throws a
202
- `MalfunctionError` that carries the `correlationId`. your trail rides the request, so the endpoint's
311
+ it resolves `{ status, headers, text, body }`. a 4xx throws a `LambdaEndpointRefusedError` (or a
312
+ `ConstraintError`, with `refusal: { as: 'ConstraintError' }`); a 429 or a 5xx throws a
313
+ `MalfunctionError`, and a 5xx carries the `correlationId`. your trail rides the request, so the endpoint's
203
314
  logs join yours.
204
315
 
205
316
  any other http caller spreads the `x-trail-exid` header in to send the trail. the header also opts the
@@ -418,6 +529,8 @@ z.object({ rider: Surfer.contract().ref('primary') }).optional()
418
529
  - `onSerialized()` — you hold the slug; a caller fault **throws**. `at: 'cloud' | 'local'`
419
530
  - **asLambdaEvent** — cast a payload into the envelope aws delivers, wire-faithful by default
420
531
  - `fromApiGateway()`, `fromSqs()`, `fromSns()`, `fromKinesis()`, `fromS3()`
532
+ - **asLambdaEventSchema** — the zod schema of the event aws delivers, with an optional message schema
533
+ - `fromSns()`, `fromKinesis()`; sqs is served by `genLambdaEndpoint.forSqs`
421
534
  - **trace-id propagation** — pass `log`, and `trail.exid` threads through the lambda-to-lambda call
422
535
  chain. http and sqs triggers mint a fresh `exid` per invoke
423
536
  - **introspection** — expose json-schema via `{ introspect: 'schema' }` (prep only), collected by
@@ -1 +0,0 @@
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"}