sdk-aws-lambda 0.3.0 → 0.4.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 (87) hide show
  1. package/dist/access/sdks/lambda/genLambdaSdk.d.ts +8 -1
  2. package/dist/access/sdks/lambda/genLambdaSdk.js +57 -4
  3. package/dist/access/sdks/lambda/genLambdaSdk.js.map +1 -1
  4. package/dist/domain.objects/ApiGatewayRequestPayload.d.ts +12 -0
  5. package/dist/domain.objects/ApiGatewayRequestPayload.js +3 -0
  6. package/dist/domain.objects/ApiGatewayRequestPayload.js.map +1 -0
  7. package/dist/domain.objects/ApiGatewayResponse.d.ts +30 -0
  8. package/dist/domain.objects/ApiGatewayResponse.js +3 -0
  9. package/dist/domain.objects/ApiGatewayResponse.js.map +1 -0
  10. package/dist/domain.objects/ApiGatewayResponsePayload.d.ts +30 -0
  11. package/dist/domain.objects/ApiGatewayResponsePayload.js +3 -0
  12. package/dist/domain.objects/ApiGatewayResponsePayload.js.map +1 -0
  13. package/dist/domain.objects/HttpStatusCode.d.ts +1 -0
  14. package/dist/domain.objects/HttpStatusCode.js +1 -0
  15. package/dist/domain.objects/HttpStatusCode.js.map +1 -1
  16. package/dist/domain.operations/genLambdaEndpoint/TranslateLog.d.ts +29 -0
  17. package/dist/domain.operations/genLambdaEndpoint/TranslateLog.js +3 -0
  18. package/dist/domain.operations/genLambdaEndpoint/TranslateLog.js.map +1 -0
  19. package/dist/domain.operations/genLambdaEndpoint/asContextLogTrail.d.ts +29 -0
  20. package/dist/domain.operations/genLambdaEndpoint/asContextLogTrail.js +30 -0
  21. package/dist/domain.operations/genLambdaEndpoint/asContextLogTrail.js.map +1 -0
  22. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.d.ts +36 -0
  23. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.js +3 -0
  24. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.js.map +1 -0
  25. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.d.ts +19 -0
  26. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.js +24 -0
  27. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.js.map +1 -0
  28. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayloadJson.d.ts +26 -0
  29. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayloadJson.js +31 -0
  30. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayloadJson.js.map +1 -0
  31. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.d.ts +33 -0
  32. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js +39 -0
  33. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.js.map +1 -0
  34. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.d.ts +27 -0
  35. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.js +118 -0
  36. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asUnifiedApiGatewayEvent.js.map +1 -0
  37. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +76 -36
  38. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +153 -45
  39. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
  40. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllWirePayloadKeysFound.d.ts +8 -0
  41. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllWirePayloadKeysFound.js +34 -0
  42. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getAllWirePayloadKeysFound.js.map +1 -0
  43. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/isApiGatewayResponse.d.ts +19 -0
  44. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/isApiGatewayResponse.js +36 -0
  45. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/isApiGatewayResponse.js.map +1 -0
  46. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.d.ts +7 -24
  47. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js +19 -103
  48. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js.map +1 -1
  49. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genContentTypeCoherenceMiddleware.d.ts +20 -0
  50. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genContentTypeCoherenceMiddleware.js +48 -0
  51. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genContentTypeCoherenceMiddleware.js.map +1 -0
  52. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.d.ts +16 -0
  53. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js +32 -0
  54. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js.map +1 -1
  55. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts +6 -22
  56. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js +24 -18
  57. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +1 -1
  58. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.d.ts +11 -2
  59. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js +12 -2
  60. package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js.map +1 -1
  61. package/dist/domain.operations/genLambdaEndpoint/middleware/asContextTrailed.d.ts +37 -0
  62. package/dist/domain.operations/genLambdaEndpoint/middleware/asContextTrailed.js +24 -0
  63. package/dist/domain.operations/genLambdaEndpoint/middleware/asContextTrailed.js.map +1 -0
  64. package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.d.ts +18 -10
  65. package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.js +20 -23
  66. package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.js.map +1 -1
  67. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.d.ts +29 -6
  68. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js +23 -28
  69. package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js.map +1 -1
  70. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.d.ts +16 -1
  71. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js +9 -13
  72. package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js.map +1 -1
  73. package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.d.ts +27 -6
  74. package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js +29 -4
  75. package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js.map +1 -1
  76. package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js +12 -4
  77. package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js.map +1 -1
  78. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.d.ts +27 -2
  79. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js +34 -13
  80. package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js.map +1 -1
  81. package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js +1 -0
  82. package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js.map +1 -1
  83. package/dist/index.d.ts +40 -2
  84. package/dist/index.js +28 -1
  85. package/dist/index.js.map +1 -1
  86. package/package.json +12 -11
  87. package/readme.md +50 -2
@@ -1,6 +1,6 @@
1
1
  import { LambdaClient } from '@aws-sdk/client-lambda';
2
2
  /**
3
- * .what = returns the injected LambdaClient or creates a new one
3
+ * .what = findserts the LambdaClient for this config; returns the injected one, if any
4
4
  * .why = named transformer for clear narrative in orchestrator
5
5
  */
6
6
  export declare const genLambdaSdk: (input: {
@@ -9,3 +9,10 @@ export declare const genLambdaSdk: (input: {
9
9
  region?: string;
10
10
  };
11
11
  }) => LambdaClient;
12
+ /**
13
+ * .what = releases every memoized LambdaClient and destroys its sockets
14
+ * .why = the `del` mirror of `gen`. a memoized client holds a keep-alive agent, and a live
15
+ * agent can hold the event loop open in a cli or a one-off command, which drains its
16
+ * loop rather than a call to `process.exit`. this is that escape hatch
17
+ */
18
+ export declare const delLambdaSdks: () => void;
@@ -1,17 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.genLambdaSdk = void 0;
3
+ exports.delLambdaSdks = exports.genLambdaSdk = void 0;
4
4
  const client_lambda_1 = require("@aws-sdk/client-lambda");
5
+ const domain_objects_1 = require("domain-objects");
6
+ const helpful_errors_1 = require("helpful-errors");
5
7
  /**
6
- * .what = returns the injected LambdaClient or creates a new one
8
+ * .what = the LambdaClient already made per distinct client config
9
+ * .why = `gen` promises findsert, so the same input must converge on the same client.
10
+ * a client per call is an `https.Agent` per call, and an agent's keep-alive pool
11
+ * is per-agent — so a fresh agent always starts empty, never reuses a socket, and
12
+ * starves the runtime's dns budget (`getaddrinfo EBUSY` -> `Runtime.ExitError`)
13
+ */
14
+ const sdkByConfig = new Map();
15
+ /**
16
+ * .what = the memo key for a LambdaClient config
17
+ * .why = the key must cover EVERY knob that changes client identity, so it derives from
18
+ * the config object itself rather than from a hand-listed field. a hand-listed key
19
+ * silently hands back a wrong-config client the day a second knob lands
20
+ * .note = throws when a knob does not survive serialization (e.g. a function-valued
21
+ * `credentials` provider), since such a knob would collide in silence
22
+ */
23
+ const asLambdaSdkMemoKey = (config) => {
24
+ const key = (0, domain_objects_1.serialize)(config);
25
+ // failfast when a knob drops out of the key; a dropped knob is a silent collision
26
+ const knobsGiven = Object.keys(config);
27
+ const knobsKeyed = Object.keys(JSON.parse(key));
28
+ if (knobsKeyed.length !== knobsGiven.length)
29
+ helpful_errors_1.MalfunctionError.throw('lambda sdk config holds a knob the memo key drops', {
30
+ knobsGiven,
31
+ knobsKeyed,
32
+ });
33
+ return key;
34
+ };
35
+ /**
36
+ * .what = findserts the LambdaClient for this config; returns the injected one, if any
7
37
  * .why = named transformer for clear narrative in orchestrator
8
38
  */
9
39
  const genLambdaSdk = (input) => {
10
40
  // return injected LambdaClient if provided
11
41
  if (input.sdk)
12
42
  return input.sdk;
13
- // create LambdaClient, let sdk infer region unless explicitly provided
14
- return new client_lambda_1.LambdaClient(input.env?.region ? { region: input.env.region } : {});
43
+ // build the config, let sdk infer region unless explicitly provided
44
+ const config = input.env?.region
45
+ ? { region: input.env.region }
46
+ : {};
47
+ // find the client already made for this config, if any
48
+ const key = asLambdaSdkMemoKey(config);
49
+ const sdkFound = sdkByConfig.get(key);
50
+ if (sdkFound)
51
+ return sdkFound;
52
+ // otherwise, insert one
53
+ const sdkMade = new client_lambda_1.LambdaClient(config);
54
+ sdkByConfig.set(key, sdkMade);
55
+ return sdkMade;
15
56
  };
16
57
  exports.genLambdaSdk = genLambdaSdk;
58
+ /**
59
+ * .what = releases every memoized LambdaClient and destroys its sockets
60
+ * .why = the `del` mirror of `gen`. a memoized client holds a keep-alive agent, and a live
61
+ * agent can hold the event loop open in a cli or a one-off command, which drains its
62
+ * loop rather than a call to `process.exit`. this is that escape hatch
63
+ */
64
+ const delLambdaSdks = () => {
65
+ for (const sdk of sdkByConfig.values())
66
+ sdk.destroy();
67
+ sdkByConfig.clear();
68
+ };
69
+ exports.delLambdaSdks = delLambdaSdks;
17
70
  //# sourceMappingURL=genLambdaSdk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"genLambdaSdk.js","sourceRoot":"","sources":["../../../../src/access/sdks/lambda/genLambdaSdk.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AAEtD;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,KAG5B,EAAgB,EAAE;IACjB,2CAA2C;IAC3C,IAAI,KAAK,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IAEhC,uEAAuE;IACvE,OAAO,IAAI,4BAAY,CACrB,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CACtD,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,YAAY,gBAWvB"}
1
+ {"version":3,"file":"genLambdaSdk.js","sourceRoot":"","sources":["../../../../src/access/sdks/lambda/genLambdaSdk.ts"],"names":[],"mappings":";;;AAAA,0DAA+E;AAC/E,mDAA2C;AAC3C,mDAAkD;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,GAA8B,IAAI,GAAG,EAAE,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,CAAC,MAA0B,EAAU,EAAE;IAChE,MAAM,GAAG,GAAG,IAAA,0BAAS,EAAC,MAAM,CAAC,CAAC;IAE9B,kFAAkF;IAClF,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAA4B,CAAC,CAAC;IAC3E,IAAI,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM;QACzC,iCAAgB,CAAC,KAAK,CACpB,mDAAmD,EACnD;YACE,UAAU;YACV,UAAU;SACX,CACF,CAAC;IAEJ,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,KAG5B,EAAgB,EAAE;IACjB,2CAA2C;IAC3C,IAAI,KAAK,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IAEhC,oEAAoE;IACpE,MAAM,MAAM,GAAuB,KAAK,CAAC,GAAG,EAAE,MAAM;QAClD,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE;QAC9B,CAAC,CAAC,EAAE,CAAC;IAEP,uDAAuD;IACvD,MAAM,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAE9B,wBAAwB;IACxB,MAAM,OAAO,GAAG,IAAI,4BAAY,CAAC,MAAM,CAAC,CAAC;IACzC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AArBW,QAAA,YAAY,gBAqBvB;AAEF;;;;;GAKG;AACI,MAAM,aAAa,GAAG,GAAS,EAAE;IACtC,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE;QAAE,GAAG,CAAC,OAAO,EAAE,CAAC;IACtD,WAAW,CAAC,KAAK,EAAE,CAAC;AACtB,CAAC,CAAC;AAHW,QAAA,aAAa,iBAGxB"}
@@ -0,0 +1,12 @@
1
+ import type { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from 'aws-lambda';
2
+ /**
3
+ * .what = the wire payload an api-gateway trigger delivers, either version
4
+ * .why = api gateway ships two incompatible request shapes (rest/v1, http/v2), and a
5
+ * handler must be able to name the shape as it LANDS, before any translate runs
6
+ *
7
+ * .note = this is the `inputBefore` point: the untouched bytes-as-parsed, before the
8
+ * input translator. its peer at the other end of the pipeline is
9
+ * `ApiGatewayResponsePayload` — request/response, each qualified by `Payload`
10
+ * to mark it as the wire form
11
+ */
12
+ export type ApiGatewayRequestPayload = APIGatewayProxyEvent | APIGatewayProxyEventV2;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ApiGatewayRequestPayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiGatewayRequestPayload.js","sourceRoot":"","sources":["../../src/domain.objects/ApiGatewayRequestPayload.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import type { PickAny } from 'type-fns';
2
+ /**
3
+ * .what = the http response a handler puts on the wire — the `outputBefore` point, which
4
+ * `schema.output` describes
5
+ *
6
+ * .note = `PickAny` demands at least one key, so `{}` is a compile error. an empty response
7
+ * would reach middy's `normalizeHttpResponse` and pick up `statusCode ??= 500` — a
8
+ * silent server-fault on the wire for code that returned success
9
+ */
10
+ export type ApiGatewayResponse<TBody> = PickAny<{
11
+ /** .note = omit for 200 */
12
+ status: number;
13
+ /**
14
+ * .note = set `Content-Type` to take the body verbatim; the serializer skips a response that
15
+ * already declares one. omit it and the body is json-encoded for you
16
+ *
17
+ * ⚠️ .note = ONE VALUE PER HEADER, so a header that must repeat (`Set-Cookie`) cannot be
18
+ * expressed — a `Record` key is unique, and js drops the earlier value with no
19
+ * warn. aws carries repeats in `multiValueHeaders` (v1) / `cookies` (v2); this
20
+ * contract declares neither, and `getAllWirePayloadKeysFound` REFUSES both loudly
21
+ * so the attempt fails fast. deferred, not denied — each is one additive key (F7)
22
+ */
23
+ headers: Record<string, string>;
24
+ /**
25
+ * ⚠️ .note = OMIT the key for no body. an explicit `body: ''` is a different value — a real
26
+ * two-byte json `""` under `application/json`, which is coherent but is not
27
+ * body-less. `[case10]` of `local.wireResponse.acceptance.test.ts` pins both
28
+ */
29
+ body: TBody;
30
+ }>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ApiGatewayResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiGatewayResponse.js","sourceRoot":"","sources":["../../src/domain.objects/ApiGatewayResponse.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import type { APIGatewayProxyResult } from 'aws-lambda';
2
+ /**
3
+ * .what = the wire payload api gateway receives back
4
+ * .why = names the `outputAfter` point — what lands on the wire, after the output
5
+ * translator has run. by here the body is a `string`, whatever domain type it
6
+ * held before, so its contents are opaque
7
+ *
8
+ * .why = the sdk adds no field to aws's shape; it adds a NAME, so a consumer can say
9
+ * "the bytes on the wire" and a translator can target it. the extant code had no
10
+ * term for this value, which is exactly why its encode sat hardcoded
11
+ *
12
+ * .note = `body` is OPTIONAL here, where aws declares it required. a body-less response
13
+ * (a 204, a 308) must reach the wire with the key ABSENT, never as `''` — the
14
+ * response serializer runs after the encode and would turn an empty string into
15
+ * `'""'`. api gateway reads an absent body as no body, so absence is the correct
16
+ * wire form and this type says so rather than leave a cast to hide it
17
+ *
18
+ * .note = `TBody` is PARAMETERIZED because the body is encoded one step later than the
19
+ * output translator runs, so this shape occurs twice in the chain:
20
+ *
21
+ * ApiGatewayResponsePayload<TBody> <- `outputAfter`, what the translator yields
22
+ * ↓ the response serializer — an sdk-internal step, not a model point
23
+ * ApiGatewayResponsePayload <- what aws receives; the body is bytes
24
+ *
25
+ * it defaults to `string` so the bare name reads as the wire shape. the serializer
26
+ * sits OUTSIDE the four points, mirror to the trail read which sits before them
27
+ */
28
+ export type ApiGatewayResponsePayload<TBody = string> = Omit<APIGatewayProxyResult, 'body'> & {
29
+ body?: TBody;
30
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ApiGatewayResponsePayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiGatewayResponsePayload.js","sourceRoot":"","sources":["../../src/domain.objects/ApiGatewayResponsePayload.ts"],"names":[],"mappings":""}
@@ -12,6 +12,7 @@ export declare enum HttpStatusCode {
12
12
  MOVED_PERMANENTLY_301 = 301,
13
13
  FOUND_302 = 302,
14
14
  NOT_MODIFIED_304 = 304,
15
+ PERMANENT_REDIRECT_308 = 308,
15
16
  BAD_REQUEST_400 = 400,
16
17
  UNAUTHORIZED_401 = 401,
17
18
  FORBIDDEN_403 = 403,
@@ -18,6 +18,7 @@ var HttpStatusCode;
18
18
  HttpStatusCode[HttpStatusCode["MOVED_PERMANENTLY_301"] = 301] = "MOVED_PERMANENTLY_301";
19
19
  HttpStatusCode[HttpStatusCode["FOUND_302"] = 302] = "FOUND_302";
20
20
  HttpStatusCode[HttpStatusCode["NOT_MODIFIED_304"] = 304] = "NOT_MODIFIED_304";
21
+ HttpStatusCode[HttpStatusCode["PERMANENT_REDIRECT_308"] = 308] = "PERMANENT_REDIRECT_308";
21
22
  // caller error
22
23
  HttpStatusCode[HttpStatusCode["BAD_REQUEST_400"] = 400] = "BAD_REQUEST_400";
23
24
  HttpStatusCode[HttpStatusCode["UNAUTHORIZED_401"] = 401] = "UNAUTHORIZED_401";
@@ -1 +1 @@
1
- {"version":3,"file":"HttpStatusCode.js","sourceRoot":"","sources":["../../src/domain.objects/HttpStatusCode.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,IAAY,cA4BX;AA5BD,WAAY,cAAc;IACxB,UAAU;IACV,mEAAiB,CAAA;IACjB,mEAAiB,CAAA;IACjB,qEAAkB,CAAA;IAClB,yEAAoB,CAAA;IAEpB,WAAW;IACX,uFAA2B,CAAA;IAC3B,+DAAe,CAAA;IACf,6EAAsB,CAAA;IAEtB,eAAe;IACf,2EAAqB,CAAA;IACrB,6EAAsB,CAAA;IACtB,uEAAmB,CAAA;IACnB,uEAAmB,CAAA;IACnB,yFAA4B,CAAA;IAC5B,qEAAkB,CAAA;IAClB,6FAA8B,CAAA;IAC9B,uFAA2B,CAAA;IAE3B,eAAe;IACf,+FAA+B,CAAA;IAC/B,mFAAyB,CAAA;IACzB,2EAAqB,CAAA;IACrB,2FAA6B,CAAA;IAC7B,mFAAyB,CAAA;AAC3B,CAAC,EA5BW,cAAc,8BAAd,cAAc,QA4BzB"}
1
+ {"version":3,"file":"HttpStatusCode.js","sourceRoot":"","sources":["../../src/domain.objects/HttpStatusCode.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,IAAY,cA6BX;AA7BD,WAAY,cAAc;IACxB,UAAU;IACV,mEAAiB,CAAA;IACjB,mEAAiB,CAAA;IACjB,qEAAkB,CAAA;IAClB,yEAAoB,CAAA;IAEpB,WAAW;IACX,uFAA2B,CAAA;IAC3B,+DAAe,CAAA;IACf,6EAAsB,CAAA;IACtB,yFAA4B,CAAA;IAE5B,eAAe;IACf,2EAAqB,CAAA;IACrB,6EAAsB,CAAA;IACtB,uEAAmB,CAAA;IACnB,uEAAmB,CAAA;IACnB,yFAA4B,CAAA;IAC5B,qEAAkB,CAAA;IAClB,6FAA8B,CAAA;IAC9B,uFAA2B,CAAA;IAE3B,eAAe;IACf,+FAA+B,CAAA;IAC/B,mFAAyB,CAAA;IACzB,2EAAqB,CAAA;IACrB,2FAA6B,CAAA;IAC7B,mFAAyB,CAAA;AAC3B,CAAC,EA7BW,cAAc,8BAAd,cAAc,QA6BzB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * .what = projections applied to io before it reaches cloudwatch
3
+ * .why = a log projection is cosmetic — it changes what an operator reads, never what the
4
+ * caller receives
5
+ *
6
+ * .note = these are untyped on purpose. a log projection runs over whatever the chain holds
7
+ * at that moment, which for an error path is neither of the declared output shapes
8
+ *
9
+ * .note = this type once sat in a `Translate.ts` beside a `Translate<TShapes>` interface, a
10
+ * `LambdaEndpointShapes` bag, and a `Translator<TFrom, TInto>` alias — a config
11
+ * namespace for the four translator boundaries an endpoint has. those three shipped
12
+ * with ZERO production consumers, because the input-side translator they existed to
13
+ * type never landed: its home in the middy chain is unresolved (`request.event` is
14
+ * read by `@middy/http-cors` in its `after` hook, so the natural seam starves cors).
15
+ * so they were dead declarations, below the rule of three
16
+ * (rule.prefer.wet-over-dry), and they are deleted rather than shipped.
17
+ *
18
+ * the DESIGN is not lost — the four points (`inputBefore` / `inputAfter` /
19
+ * `outputBefore` / `outputAfter`), the tri-state (absent = default, `false` =
20
+ * disarmed, function = yours), and the structural-bind rationale are recorded in
21
+ * `1.vision.yield.md`. a term costs one line to restore from there; a dead
22
+ * declaration costs every reader who meets it. `TranslateLog` stays because it is
23
+ * the one member with real consumers — `logTranslate` on both endpoint families and
24
+ * on `genIoLoggerMiddleware`, plus a public export.
25
+ */
26
+ export interface TranslateLog {
27
+ input?: (payload: unknown) => unknown;
28
+ output?: (response: unknown) => unknown;
29
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TranslateLog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TranslateLog.js","sourceRoot":"","sources":["../../../src/domain.operations/genLambdaEndpoint/TranslateLog.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import type { Context } from 'aws-lambda';
2
+ import type { ContextLogTrail } from 'sdk-logs';
3
+ /**
4
+ * .what = reads the trail log that `genTrailMiddleware` wrote onto the lambda context
5
+ * .why = BOTH family handlers need it, and each had restated the same cast with its own
6
+ * ~10-line doc block — one of which called itself "the twin of" the other. one
7
+ * declaration, so the two cannot drift (rule.forbid.parallel-codepaths)
8
+ *
9
+ * .as = aws types a handler's second argument as `Context`, which declares no `log`. this
10
+ * sdk's own `genTrailMiddleware` puts it there, so the cast asserts what the sdk's own
11
+ * middleware wrote — never an outside claim
12
+ *
13
+ * .as = `unknown` is the intermediate because `Context` and `ContextLogTrail` overlap on no
14
+ * member, so tsc refuses the direct assertion
15
+ *
16
+ * .why NOT `asContextTrailed` = that reader returns OPTIONAL fields, because a middleware's
17
+ * array position decides whether trail has run yet. a handler has no such doubt: trail is
18
+ * a `before` hook, so it has always run by the time the handler does. so this reader
19
+ * states `log` as PRESENT, and a caller owes no `?.` — the two readers differ in the one
20
+ * guarantee that matters, which is why they are a pair rather than one function
21
+ *
22
+ * .removal = removable when aws-lambda's `Handler` takes a caller-declared context type, or
23
+ * when the families hand their `logic` the middy request rather than the raw arguments —
24
+ * the latter is the cheaper path, and it is why `asContextTrailed` exists for the
25
+ * middleware sites
26
+ */
27
+ export declare const asContextLogTrail: (input: {
28
+ context: Context;
29
+ }) => ContextLogTrail;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asContextLogTrail = void 0;
4
+ /**
5
+ * .what = reads the trail log that `genTrailMiddleware` wrote onto the lambda context
6
+ * .why = BOTH family handlers need it, and each had restated the same cast with its own
7
+ * ~10-line doc block — one of which called itself "the twin of" the other. one
8
+ * declaration, so the two cannot drift (rule.forbid.parallel-codepaths)
9
+ *
10
+ * .as = aws types a handler's second argument as `Context`, which declares no `log`. this
11
+ * sdk's own `genTrailMiddleware` puts it there, so the cast asserts what the sdk's own
12
+ * middleware wrote — never an outside claim
13
+ *
14
+ * .as = `unknown` is the intermediate because `Context` and `ContextLogTrail` overlap on no
15
+ * member, so tsc refuses the direct assertion
16
+ *
17
+ * .why NOT `asContextTrailed` = that reader returns OPTIONAL fields, because a middleware's
18
+ * array position decides whether trail has run yet. a handler has no such doubt: trail is
19
+ * a `before` hook, so it has always run by the time the handler does. so this reader
20
+ * states `log` as PRESENT, and a caller owes no `?.` — the two readers differ in the one
21
+ * guarantee that matters, which is why they are a pair rather than one function
22
+ *
23
+ * .removal = removable when aws-lambda's `Handler` takes a caller-declared context type, or
24
+ * when the families hand their `logic` the middy request rather than the raw arguments —
25
+ * the latter is the cheaper path, and it is why `asContextTrailed` exists for the
26
+ * middleware sites
27
+ */
28
+ const asContextLogTrail = (input) => input.context;
29
+ exports.asContextLogTrail = asContextLogTrail;
30
+ //# sourceMappingURL=asContextLogTrail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asContextLogTrail.js","sourceRoot":"","sources":["../../../src/domain.operations/genLambdaEndpoint/asContextLogTrail.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,iBAAiB,GAAG,CAAC,KAEjC,EAAmB,EAAE,CAAC,KAAK,CAAC,OAAqC,CAAC;AAFtD,QAAA,iBAAiB,qBAEqC"}
@@ -0,0 +1,36 @@
1
+ import type { ApiGatewayRequestPayload } from '../../../domain.objects/ApiGatewayRequestPayload';
2
+ /**
3
+ * .what = an api-gateway request with v1/v2 differences reconciled
4
+ * .why = v1 puts the method at `httpMethod` and v2 at `requestContext.http.method`. a
5
+ * handler that reads either directly is version-locked, so the sdk reconciles them
6
+ * once and hands over one shape
7
+ *
8
+ * .note = `Unified` carries weight, never decoration: this is NOT the wire shape. the wire
9
+ * shape is `ApiGatewayRequestPayload`, the raw v1|v2 union. this is a step the
10
+ * default input translator takes on the way to `inputAfter`
11
+ */
12
+ export interface UnifiedApiGatewayEvent {
13
+ httpMethod: string;
14
+ path: string;
15
+ headers: Record<string, string | undefined>;
16
+ queryStringParameters: Record<string, string | undefined> | null;
17
+ pathParameters: Record<string, string | undefined> | null;
18
+ body: unknown;
19
+ rawBody: string | null;
20
+ isBase64Encoded: boolean;
21
+ requestContext: {
22
+ requestId: string;
23
+ stage: string;
24
+ domainName?: string;
25
+ accountId?: string;
26
+ };
27
+ /**
28
+ * .what = the ejection route — the wire payload, before this shape reconciled it
29
+ * .why = `_` marks it as an escape hatch rather than a paved path. every field above is
30
+ * version-agnostic; reach in here and you are version-locked again, so a reader who
31
+ * sees `_` knows they have left the supported surface
32
+ */
33
+ _: {
34
+ raw: ApiGatewayRequestPayload;
35
+ };
36
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=UnifiedApiGatewayEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnifiedApiGatewayEvent.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/UnifiedApiGatewayEvent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import type { ApiGatewayResponse } from '../../../domain.objects/ApiGatewayResponse';
2
+ import type { ApiGatewayResponsePayload } from '../../../domain.objects/ApiGatewayResponsePayload';
3
+ /**
4
+ * .what = the default output translator: what `invoke` returns becomes the wire payload
5
+ *
6
+ * .note = `status` defaults HERE, ahead of every middleware — middy's `normalizeHttpResponse`
7
+ * applies `statusCode ??= 500`, so a later default would put a server-fault on the wire
8
+ * for a handler that meant 200
9
+ *
10
+ * .note = `body` is OMITTED, never `''` — the serializer would encode `''` into `'""'`. it is
11
+ * left as the DOMAIN value for the serializer to encode one step later, which is what
12
+ * lets a handler's own `Content-Type` carry bytes through untouched
13
+ *
14
+ * ⚠️ the omission holds at the WIRE, not mid-chain: the serializer re-adds `body` as an
15
+ * own key with value `undefined`. benign, and visible in the unit snapshots
16
+ */
17
+ export declare const asApiGatewayResponsePayload: <TBody>(input: {
18
+ response: ApiGatewayResponse<TBody>;
19
+ }) => ApiGatewayResponsePayload<TBody>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asApiGatewayResponsePayload = void 0;
4
+ /**
5
+ * .what = the default output translator: what `invoke` returns becomes the wire payload
6
+ *
7
+ * .note = `status` defaults HERE, ahead of every middleware — middy's `normalizeHttpResponse`
8
+ * applies `statusCode ??= 500`, so a later default would put a server-fault on the wire
9
+ * for a handler that meant 200
10
+ *
11
+ * .note = `body` is OMITTED, never `''` — the serializer would encode `''` into `'""'`. it is
12
+ * left as the DOMAIN value for the serializer to encode one step later, which is what
13
+ * lets a handler's own `Content-Type` carry bytes through untouched
14
+ *
15
+ * ⚠️ the omission holds at the WIRE, not mid-chain: the serializer re-adds `body` as an
16
+ * own key with value `undefined`. benign, and visible in the unit snapshots
17
+ */
18
+ const asApiGatewayResponsePayload = (input) => ({
19
+ statusCode: input.response.status ?? 200,
20
+ ...(input.response.headers ? { headers: input.response.headers } : {}),
21
+ ...('body' in input.response ? { body: input.response.body } : {}),
22
+ });
23
+ exports.asApiGatewayResponsePayload = asApiGatewayResponsePayload;
24
+ //# sourceMappingURL=asApiGatewayResponsePayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asApiGatewayResponsePayload.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayload.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;GAaG;AACI,MAAM,2BAA2B,GAAG,CAAQ,KAElD,EAAoC,EAAE,CAAC,CAAC;IACvC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG;IACxC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,GAAG,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CACnE,CAAC,CAAC;AANU,QAAA,2BAA2B,+BAMrC"}
@@ -0,0 +1,26 @@
1
+ import type { ApiGatewayResponsePayload } from '../../../domain.objects/ApiGatewayResponsePayload';
2
+ /**
3
+ * .what = the wire payload for a body this family must encode ITSELF, as json
4
+ * .why = three middleware entries short-circuit the chain — the 400 builder, the 500 builder,
5
+ * and the introspection reply — and a short-circuit BYPASSES the response serializer,
6
+ * so each owes the wire an already-encoded body plus its own `Content-Type`. all three
7
+ * route through here; a fourth short-circuit owes the same
8
+ *
9
+ * .note = this is the SIBLING of `asApiGatewayResponsePayload`, never a replacement. the two
10
+ * differ on exactly one axis — WHO encodes the body:
11
+ * - `asApiGatewayResponsePayload` leaves the body a DOMAIN value, for the serializer
12
+ * to encode one step later. that is the handler's path
13
+ * - THIS one encodes here, because no serializer step follows a short-circuit
14
+ *
15
+ * .note = the `Content-Type` is stamped unconditionally, which is also what makes the encode
16
+ * safe to do here: `genContentTypeCoherenceMiddleware` demands a body and a
17
+ * content-type agree, and `httpResponseSerializer` skips a response that already
18
+ * declares one — so a second encode cannot double-wrap this body
19
+ *
20
+ * ⚠️ .note = the test doubles that restate this shape stay independent ON PURPOSE. a test that
21
+ * imported this transformer could no longer prove this transformer's shape
22
+ */
23
+ export declare const asApiGatewayResponsePayloadJson: (input: {
24
+ status: number;
25
+ body: unknown;
26
+ }) => ApiGatewayResponsePayload;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asApiGatewayResponsePayloadJson = void 0;
4
+ /**
5
+ * .what = the wire payload for a body this family must encode ITSELF, as json
6
+ * .why = three middleware entries short-circuit the chain — the 400 builder, the 500 builder,
7
+ * and the introspection reply — and a short-circuit BYPASSES the response serializer,
8
+ * so each owes the wire an already-encoded body plus its own `Content-Type`. all three
9
+ * route through here; a fourth short-circuit owes the same
10
+ *
11
+ * .note = this is the SIBLING of `asApiGatewayResponsePayload`, never a replacement. the two
12
+ * differ on exactly one axis — WHO encodes the body:
13
+ * - `asApiGatewayResponsePayload` leaves the body a DOMAIN value, for the serializer
14
+ * to encode one step later. that is the handler's path
15
+ * - THIS one encodes here, because no serializer step follows a short-circuit
16
+ *
17
+ * .note = the `Content-Type` is stamped unconditionally, which is also what makes the encode
18
+ * safe to do here: `genContentTypeCoherenceMiddleware` demands a body and a
19
+ * content-type agree, and `httpResponseSerializer` skips a response that already
20
+ * declares one — so a second encode cannot double-wrap this body
21
+ *
22
+ * ⚠️ .note = the test doubles that restate this shape stay independent ON PURPOSE. a test that
23
+ * imported this transformer could no longer prove this transformer's shape
24
+ */
25
+ const asApiGatewayResponsePayloadJson = (input) => ({
26
+ statusCode: input.status,
27
+ body: JSON.stringify(input.body),
28
+ headers: { 'Content-Type': 'application/json' },
29
+ });
30
+ exports.asApiGatewayResponsePayloadJson = asApiGatewayResponsePayloadJson;
31
+ //# sourceMappingURL=asApiGatewayResponsePayloadJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asApiGatewayResponsePayloadJson.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponsePayloadJson.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,+BAA+B,GAAG,CAAC,KAG/C,EAA6B,EAAE,CAAC,CAAC;IAChC,UAAU,EAAE,KAAK,CAAC,MAAM;IACxB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;IAChC,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;CAChD,CAAC,CAAC;AAPU,QAAA,+BAA+B,mCAOzC"}
@@ -0,0 +1,33 @@
1
+ import { type ZodSchema } from 'zod';
2
+ import type { ApiGatewayResponse } from '../../../domain.objects/ApiGatewayResponse';
3
+ /**
4
+ * .what = lifts a body schema into the response-envelope schema
5
+ * .why = `schema.output` describes the whole response (`outputBefore`), never the body
6
+ * inside it — so a reader can line the schema up against the pipeline. this keeps
7
+ * the common case a one-liner instead of a hand-written envelope per call site
8
+ *
9
+ * .note = `body` is NAMED rather than positional because the envelope holds three fields, so
10
+ * the argument must say which one it supplies
11
+ *
12
+ * .note = every field is optional in the schema, since `PickAny` lets a handler supply
13
+ * any non-empty subset. the at-least-one rule is held by the TYPE at compile
14
+ * time; this schema guards the field types
15
+ *
16
+ * .as = zod cannot express "at least one key present", so it infers `{ status?, headers?,
17
+ * body? }` — a superset of `PickAny` by exactly one member, `{}` — and no structural
18
+ * assignment relates the two
19
+ * ⚠️ .note for a DIRECT consumer = this schema is publicly exported, and on its own it ACCEPTS
20
+ * `{}`. inside `forApiGateway` that is unreachable — `isApiGatewayResponse.assure`
21
+ * refuses an empty response before this schema is ever reached — but a consumer who
22
+ * validates against this schema DIRECTLY inherits no such guard. so pair it with the
23
+ * `ApiGatewayResponse` type (which refuses `{}` at compile time) rather than treat a
24
+ * parse as the whole check
25
+ *
26
+ * .removal = drops when zod can express an at-least-one-key refinement that still narrows the
27
+ * inferred type (a `.refine` narrows values, never the type). until then the
28
+ * compile-time guarantee lives in `ApiGatewayResponse` and the runtime guarantee
29
+ * lives here, and this cast is the seam between them
30
+ */
31
+ export declare const asApiGatewayResponseSchema: <TBody>(input: {
32
+ body: ZodSchema<TBody>;
33
+ }) => ZodSchema<ApiGatewayResponse<TBody>>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asApiGatewayResponseSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * .what = lifts a body schema into the response-envelope schema
7
+ * .why = `schema.output` describes the whole response (`outputBefore`), never the body
8
+ * inside it — so a reader can line the schema up against the pipeline. this keeps
9
+ * the common case a one-liner instead of a hand-written envelope per call site
10
+ *
11
+ * .note = `body` is NAMED rather than positional because the envelope holds three fields, so
12
+ * the argument must say which one it supplies
13
+ *
14
+ * .note = every field is optional in the schema, since `PickAny` lets a handler supply
15
+ * any non-empty subset. the at-least-one rule is held by the TYPE at compile
16
+ * time; this schema guards the field types
17
+ *
18
+ * .as = zod cannot express "at least one key present", so it infers `{ status?, headers?,
19
+ * body? }` — a superset of `PickAny` by exactly one member, `{}` — and no structural
20
+ * assignment relates the two
21
+ * ⚠️ .note for a DIRECT consumer = this schema is publicly exported, and on its own it ACCEPTS
22
+ * `{}`. inside `forApiGateway` that is unreachable — `isApiGatewayResponse.assure`
23
+ * refuses an empty response before this schema is ever reached — but a consumer who
24
+ * validates against this schema DIRECTLY inherits no such guard. so pair it with the
25
+ * `ApiGatewayResponse` type (which refuses `{}` at compile time) rather than treat a
26
+ * parse as the whole check
27
+ *
28
+ * .removal = drops when zod can express an at-least-one-key refinement that still narrows the
29
+ * inferred type (a `.refine` narrows values, never the type). until then the
30
+ * compile-time guarantee lives in `ApiGatewayResponse` and the runtime guarantee
31
+ * lives here, and this cast is the seam between them
32
+ */
33
+ const asApiGatewayResponseSchema = (input) => zod_1.z.object({
34
+ status: zod_1.z.number().optional(),
35
+ headers: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
36
+ body: input.body.optional(),
37
+ });
38
+ exports.asApiGatewayResponseSchema = asApiGatewayResponseSchema;
39
+ //# sourceMappingURL=asApiGatewayResponseSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asApiGatewayResponseSchema.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/asApiGatewayResponseSchema.ts"],"names":[],"mappings":";;;AAAA,6BAAwC;AAIxC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,MAAM,0BAA0B,GAAG,CAAQ,KAEjD,EAAwC,EAAE,CACzC,OAAC,CAAC,MAAM,CAAC;IACP,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpD,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE;CAC5B,CAAoD,CAAC;AAP3C,QAAA,0BAA0B,8BAOiB"}
@@ -0,0 +1,27 @@
1
+ import type { ApiGatewayRequestPayload } from '../../../domain.objects/ApiGatewayRequestPayload';
2
+ import type { UnifiedApiGatewayEvent } from './UnifiedApiGatewayEvent';
3
+ /**
4
+ * .what = what `deserialize` means when a caller declares none — ONE declaration, read by both
5
+ * this transformer and `forApiGateway`'s config (rule.forbid.parallel-codepaths)
6
+ * .why body = json is the common case, and a caller who wants the raw string opts out by value:
7
+ * `deserialize: { body: false }`
8
+ */
9
+ export declare const DESERIALIZE_DEFAULT: {
10
+ body: boolean;
11
+ };
12
+ /**
13
+ * .what = reconciles either api-gateway payload version into one shape
14
+ * .why = the chain must read one shape whichever version the trigger delivered, so this runs
15
+ * first and every step after it reads `UnifiedApiGatewayEvent`
16
+ *
17
+ * .note = a named transformer rather than middleware-local logic, so ONE implementation serves
18
+ * both entry points — `genApiGatewayEventNormalizationMiddleware` delegates here
19
+ * (rule.forbid.parallel-codepaths)
20
+ */
21
+ export declare const asUnifiedApiGatewayEvent: (input: {
22
+ payload: ApiGatewayRequestPayload;
23
+ }, options?: {
24
+ deserialize: {
25
+ body: boolean;
26
+ };
27
+ }) => UnifiedApiGatewayEvent;