sdk-aws-lambda 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domain.operations/genLambdaEndpoint/InvokeInputSuperset.d.ts +9 -6
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perBatch.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint.forSqs.perRecord.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsConstraintError.js +4 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsConstraintError.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsFrozenMutatorRefusal.d.ts +17 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsFrozenMutatorRefusal.js +32 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsFrozenMutatorRefusal.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.d.ts +19 -57
- package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.js +30 -78
- package/dist/domain.operations/genLambdaEndpoint/setEventFrozen.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FrozenDeep } from '
|
|
1
|
+
import type { FrozenDeep } from 'type-fns';
|
|
2
2
|
/**
|
|
3
3
|
* .what = the shapes one family binds into the superset — its own types, per slot
|
|
4
4
|
* .why = the superset must be checkable against a variant that carries real types, never against
|
|
@@ -37,11 +37,14 @@ export interface InvokeShapes {
|
|
|
37
37
|
*
|
|
38
38
|
* .note = every slot is `FrozenDeep`, because every value handed to an `invoke` is deep-frozen
|
|
39
39
|
* in every family (`rule.require.frozen-invoke-inputs`)
|
|
40
|
-
* .note = the freeze is NOT clampable from here, measured
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
40
|
+
* .note = the freeze is NOT clampable from here, measured. per arm of `FrozenDeep`:
|
|
41
|
+
* - an object property: typescript ignores `readonly` in assignability, in both
|
|
42
|
+
* directions — `{ to: string }` is assignable to `{ readonly to: string }` and back
|
|
43
|
+
* - an array, `Set`, or `Map`: the mutable form is assignable to its readonly peer
|
|
44
|
+
* (`string[]` → `readonly string[]`); only the reverse fails
|
|
45
|
+
* either way, a mutable slot satisfies a frozen one. so a variant that drops `FrozenDeep`
|
|
46
|
+
* from a slot still satisfies this superset, and a bite check written for it goes TS2578
|
|
47
|
+
* rather than red. each arm is run in `InvokeInputSuperset.test.ts [case2][t2]`. the freeze is held by each variant's
|
|
45
48
|
* own `@ts-expect-error` depth arm instead; this superset clamps a slot's NAME and its
|
|
46
49
|
* VALUE TYPE, and naught else
|
|
47
50
|
*/
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import middy from '@middy/core';
|
|
2
2
|
import type { Context } from 'aws-lambda';
|
|
3
3
|
import type { ContextLogTrail } from 'sdk-logs';
|
|
4
|
+
import type { FrozenDeep } from 'type-fns';
|
|
4
5
|
import type { ZodSchema } from 'zod';
|
|
5
6
|
import type { ApiGatewayRequestEventOnwire } from '../../../domain.objects/ApiGatewayRequestEventOnwire';
|
|
6
7
|
import type { ApiGatewayResponse } from '../../../domain.objects/ApiGatewayResponse';
|
|
7
8
|
import type { ApiGatewayResponseOnwire } from '../../../domain.objects/ApiGatewayResponseOnwire';
|
|
8
9
|
import type { ContextAwsLambdaServer } from '../../../domain.objects/ContextAwsLambdaServer';
|
|
9
|
-
import { type FrozenDeep } from '../setEventFrozen';
|
|
10
10
|
import type { TranslateLog } from '../TranslateLog';
|
|
11
11
|
import type { ApiGatewayHeadersDeclared, ApiGatewayHeadersMerged, ApiGatewayRequestEventUnified } from './ApiGatewayRequestEventUnified';
|
|
12
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genLambdaEndpoint.forApiGateway.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAChC,iEAAwC;AACxC,+FAAqE;AACrE,yFAA+D;AAE/D,mDAAkD;
|
|
1
|
+
{"version":3,"file":"genLambdaEndpoint.forApiGateway.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAChC,iEAAwC;AACxC,+FAAqE;AACrE,yFAA+D;AAE/D,mDAAkD;AASlD,4DAAyD;AACzD,6FAA0F;AAC1F,uGAAoG;AACpG,yFAAsF;AACtF,+EAA4E;AAC5E,yEAAsE;AACtE,yEAAsE;AACtE,sDAAmD;AAOnD,uFAAwE;AACxE,6EAA0E;AAC1E,qFAAkF;AAClF,mFAAgF;AAChF,iEAA8D;AAC9D,oIAAiI;AACjI,sGAAmG;AACnG,kGAA+F;AA0L/F,8EAA8E;AAC9E,MAAM,qBAAqB,GAAG,CAAC,IAAgB,EAAE,EAAE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C,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;SACnE,CAAC;QACF,IAAA,iEAA+B,EAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;KACjE,CAAC;IAEF;;;;;;;;OAQG;IACH,OAAO,IAAA,cAAK,EACV,KAGsC,CACvC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACrB,CAAC,CAAC;AA5NW,QAAA,aAAa,iBA4NxB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import middy from '@middy/core';
|
|
2
2
|
import type { Context } from 'aws-lambda';
|
|
3
3
|
import type { ContextLogTrail } from 'sdk-logs';
|
|
4
|
+
import type { FrozenDeep } from 'type-fns';
|
|
4
5
|
import type { ZodSchema } from 'zod';
|
|
5
6
|
import type { ContextAwsLambdaServer } from '../../../domain.objects/ContextAwsLambdaServer';
|
|
6
7
|
import type { WrappedPayload } from '../../lambdaEndpointWire/frame/getIsWrappedPayload';
|
|
7
|
-
import { type FrozenDeep } from '../setEventFrozen';
|
|
8
8
|
import type { TranslateLog } from '../TranslateLog';
|
|
9
9
|
/**
|
|
10
10
|
* .what = wrapped payload format: event nested under `event` key with trail
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genLambdaEndpoint.forAsk.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;
|
|
1
|
+
{"version":3,"file":"genLambdaEndpoint.forAsk.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAsk/genLambdaEndpoint.forAsk.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAgC;AAQhC,4DAAyD;AACzD,6FAA0F;AAC1F,uGAAoG;AACpG,yFAAsF;AACtF,+EAA4E;AAC5E,yEAAsE;AACtE,yEAAsE;AACt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,CAAC,MAAM;YACpB,GAAG,EAAE,OAAO,EAAE,GAAG;YACjB,0FAA0F;YAC1F,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK;YACxC,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM;SAClC,CAAC;QACF,IAAA,iEAA+B,EAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;KAChE,CAAC;IAEF;;;;;OAKG;IACH,OAAO,IAAA,cAAK,EACV,KAGqB,CACtB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACrB,CAAC,CAAC;AA/EW,QAAA,MAAM,UA+EjB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import middy from '@middy/core';
|
|
2
2
|
import type { Context, SQSBatchResponse, SQSEvent } from 'aws-lambda';
|
|
3
3
|
import type { ContextLogTrail } from 'sdk-logs';
|
|
4
|
+
import type { FrozenDeep } from 'type-fns';
|
|
4
5
|
import type { ZodSchema } from 'zod';
|
|
5
6
|
import type { ContextAwsLambdaServer } from '../../../domain.objects/ContextAwsLambdaServer';
|
|
6
|
-
import { type FrozenDeep } from '../setEventFrozen';
|
|
7
7
|
import type { TranslateLog } from '../TranslateLog';
|
|
8
8
|
import type { SqsEventDecoded, SqsHeadersDeclared, SqsHeadersMerged, SqsRecordDecoded } from './SqsEventDecoded';
|
|
9
9
|
/**
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"genLambdaEndpoint.forSqs.perBatch.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forSqs/genLambdaEndpoint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;IAEF,OAAO,IAAA,cAAK,EAAC,KAAK,CAAC,CAAC,GAAG,CACrB,IAAA,qDAAyB,EAAC,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CACjE,CAAC;AACJ,CAAC,CAAC;AA5HW,QAAA,QAAQ,YA4HnB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import middy from '@middy/core';
|
|
2
2
|
import type { Context, SQSEvent } from 'aws-lambda';
|
|
3
3
|
import type { ContextLogTrail } from 'sdk-logs';
|
|
4
|
+
import type { FrozenDeep } from 'type-fns';
|
|
4
5
|
import type { ZodSchema } from 'zod';
|
|
5
6
|
import type { ContextAwsLambdaServer } from '../../../domain.objects/ContextAwsLambdaServer';
|
|
6
|
-
import { type FrozenDeep } from '../setEventFrozen';
|
|
7
7
|
import type { TranslateLog } from '../TranslateLog';
|
|
8
8
|
import type { SqsEventDecoded, SqsHeadersDeclared, SqsHeadersMerged } from './SqsEventDecoded';
|
|
9
9
|
/**
|
|
@@ -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;
|
|
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,4DAAyD;AACzD,sDAAmD;AAEnD,2DAAwD;AACxD,6DAA2D;AAC3D,2EAAwE;AAMxE,mEAAgE;AAyGhE;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,SAAS,GAAG,CACvB,MAAgD,EAChD,OAAgC,EACwB,EAAE;IAC1D,wFAAwF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CACR,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,IAAA,cAAK,EAAC,KAAK,CAAC,CAAC,GAAG,CACrB,IAAA,qDAAyB,EAAC,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,CACjE,CAAC;AACJ,CAAC,CAAC;AAtFW,QAAA,SAAS,aAsFpB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getIsConstraintError = void 0;
|
|
4
4
|
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const getIsFrozenMutatorRefusal_1 = require("./getIsFrozenMutatorRefusal");
|
|
5
6
|
/**
|
|
6
7
|
* .what = decides if error is a constraint error via thorough check
|
|
7
8
|
* .why = robust detection for cross-boundary error response
|
|
@@ -15,6 +16,9 @@ const getIsConstraintError = (input) => {
|
|
|
15
16
|
// not an error at all
|
|
16
17
|
if (!(error instanceof Error))
|
|
17
18
|
return false;
|
|
19
|
+
// the invoke freeze's refusal is a handler defect, never a caller fault, though it wears the class
|
|
20
|
+
if ((0, getIsFrozenMutatorRefusal_1.getIsFrozenMutatorRefusal)({ error }))
|
|
21
|
+
return false;
|
|
18
22
|
// direct instanceof check (ConstraintError and BadRequestError for backwards compat)
|
|
19
23
|
if (error instanceof helpful_errors_1.ConstraintError)
|
|
20
24
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIsConstraintError.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getIsConstraintError.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAElE;;;;;;;GAOG;AACI,MAAM,oBAAoB,GAAG,CAAC,KAAyB,EAAW,EAAE;IACzE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAE1B,sBAAsB;IACtB,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE5C,qFAAqF;IACrF,IAAI,KAAK,YAAY,gCAAe;QAAE,OAAO,IAAI,CAAC;IAClD,IAAI,KAAK,YAAY,gCAAe;QAAE,OAAO,IAAI,CAAC;IAElD,kDAAkD;IAClD,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IAClD,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IAElD,wEAAwE;IACxE,IACE,wCAAwC,CAAC;QACvC,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;KACpC,CAAC;QAEF,OAAO,IAAI,CAAC;IAEd,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"getIsConstraintError.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getIsConstraintError.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAElE,2EAAwE;AAExE;;;;;;;GAOG;AACI,MAAM,oBAAoB,GAAG,CAAC,KAAyB,EAAW,EAAE;IACzE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAE1B,sBAAsB;IACtB,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE5C,mGAAmG;IACnG,IAAI,IAAA,qDAAyB,EAAC,EAAE,KAAK,EAAE,CAAC;QAAE,OAAO,KAAK,CAAC;IAEvD,qFAAqF;IACrF,IAAI,KAAK,YAAY,gCAAe;QAAE,OAAO,IAAI,CAAC;IAClD,IAAI,KAAK,YAAY,gCAAe;QAAE,OAAO,IAAI,CAAC;IAElD,kDAAkD;IAClD,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IAClD,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IAElD,wEAAwE;IACxE,IACE,wCAAwC,CAAC;QACvC,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;KACpC,CAAC;QAEF,OAAO,IAAI,CAAC;IAEd,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AA1BW,QAAA,oBAAoB,wBA0B/B;AAEF;;;;;GAKG;AACH,MAAM,wCAAwC,GAAG,CAAC,KAEjD,EAAW,EAAE;IACZ,MAAM,KAAK,GAAG,KAAK,CAAC,KAAmD,CAAC;IACxE,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IAC/D,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IAC/D,OAAO,wCAAwC,CAAC;QAC9C,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;KACpC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = decides if an error is the invoke freeze's refusal of a mutator call
|
|
3
|
+
* .why = the freeze (`asFrozenDeep`, via `setEventFrozen`) replaces each mutator of a frozen `Date`,
|
|
4
|
+
* `Map`, `Set`, `WeakMap`, `WeakSet`, `DataView`, `RegExp`, or `ArrayBuffer` with a thrower,
|
|
5
|
+
* and that thrower raises a `ConstraintError`. at type-fns' boundary that is correct — its
|
|
6
|
+
* caller misused the value. at this sdk's boundary its caller is the HANDLER, so the refusal
|
|
7
|
+
* is a server fault: the lambda's caller sent a valid request and must never be told
|
|
8
|
+
* otherwise (`invariant.badrequesterror-not-lambda-error`)
|
|
9
|
+
*
|
|
10
|
+
* .note = matched by shape, never by class: type-fns throws a plain `ConstraintError` with no
|
|
11
|
+
* subclass of its own, and it may load a separate `helpful-errors` instance. the shape is
|
|
12
|
+
* the metadata it stamps (`{ kind, mutator }`) plus a message that names that mutator, so a
|
|
13
|
+
* handler's own `ConstraintError` with a coincident key does not match
|
|
14
|
+
*/
|
|
15
|
+
export declare const getIsFrozenMutatorRefusal: (input: {
|
|
16
|
+
error: unknown;
|
|
17
|
+
}) => boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIsFrozenMutatorRefusal = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = decides if an error is the invoke freeze's refusal of a mutator call
|
|
6
|
+
* .why = the freeze (`asFrozenDeep`, via `setEventFrozen`) replaces each mutator of a frozen `Date`,
|
|
7
|
+
* `Map`, `Set`, `WeakMap`, `WeakSet`, `DataView`, `RegExp`, or `ArrayBuffer` with a thrower,
|
|
8
|
+
* and that thrower raises a `ConstraintError`. at type-fns' boundary that is correct — its
|
|
9
|
+
* caller misused the value. at this sdk's boundary its caller is the HANDLER, so the refusal
|
|
10
|
+
* is a server fault: the lambda's caller sent a valid request and must never be told
|
|
11
|
+
* otherwise (`invariant.badrequesterror-not-lambda-error`)
|
|
12
|
+
*
|
|
13
|
+
* .note = matched by shape, never by class: type-fns throws a plain `ConstraintError` with no
|
|
14
|
+
* subclass of its own, and it may load a separate `helpful-errors` instance. the shape is
|
|
15
|
+
* the metadata it stamps (`{ kind, mutator }`) plus a message that names that mutator, so a
|
|
16
|
+
* handler's own `ConstraintError` with a coincident key does not match
|
|
17
|
+
*/
|
|
18
|
+
const getIsFrozenMutatorRefusal = (input) => {
|
|
19
|
+
// not an error at all
|
|
20
|
+
if (!(input.error instanceof Error))
|
|
21
|
+
return false;
|
|
22
|
+
// the refusal stamps `{ kind, mutator }`, both strings
|
|
23
|
+
const metadata = input.error.metadata;
|
|
24
|
+
if (typeof metadata?.kind !== 'string')
|
|
25
|
+
return false;
|
|
26
|
+
if (typeof metadata?.mutator !== 'string')
|
|
27
|
+
return false;
|
|
28
|
+
// and its message names that kind and that mutator
|
|
29
|
+
return input.error.message.includes(`a frozen ${metadata.kind} refuses .${metadata.mutator}()`);
|
|
30
|
+
};
|
|
31
|
+
exports.getIsFrozenMutatorRefusal = getIsFrozenMutatorRefusal;
|
|
32
|
+
//# sourceMappingURL=getIsFrozenMutatorRefusal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getIsFrozenMutatorRefusal.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getIsFrozenMutatorRefusal.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACI,MAAM,yBAAyB,GAAG,CAAC,KAEzC,EAAW,EAAE;IACZ,sBAAsB;IACtB,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAElD,uDAAuD;IACvD,MAAM,QAAQ,GAAI,KAAK,CAAC,KAAgC,CAAC,QAE5C,CAAC;IACd,IAAI,OAAO,QAAQ,EAAE,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,OAAO,QAAQ,EAAE,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAExD,mDAAmD;IACnD,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CACjC,YAAY,QAAQ,CAAC,IAAI,aAAa,QAAQ,CAAC,OAAO,IAAI,CAC3D,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,yBAAyB,6BAiBpC"}
|
|
@@ -1,24 +1,6 @@
|
|
|
1
|
+
import { type FrozenDeep } from 'type-fns';
|
|
1
2
|
/**
|
|
2
|
-
* .what = the
|
|
3
|
-
* .why = typescript's own `Readonly<T>` is shallow, so it refuses `event.x = 1` and allows
|
|
4
|
-
* `event.headers.x = 1`. the runtime freeze below is deep, so the two would disagree: a
|
|
5
|
-
* write one level in type-checks cleanly and then throws a `TypeError` in production,
|
|
6
|
-
* which turns a well-typed handler into a 500
|
|
7
|
-
* .why here = it is named for the mechanism it types (`setFrozenDeep`), so the contract and its
|
|
8
|
-
* enforcement sit in one file and cannot drift apart
|
|
9
|
-
*
|
|
10
|
-
* .note = a function passes through unmapped. `Object.freeze` does freeze a function, but to map
|
|
11
|
-
* over one would discard its call signature — and no field of this envelope is a
|
|
12
|
-
* function, so the arm is free and it guards the general case
|
|
13
|
-
* .note = `readonly` is a compile-time refusal only; it erases at runtime. the freeze is what
|
|
14
|
-
* enforces it, and this type is what announces it — neither replaces the other
|
|
15
|
-
* (`rule.prefer.prevent-over-correct`: refuse it at rung 1, report it at rung 4)
|
|
16
|
-
*/
|
|
17
|
-
export type FrozenDeep<T> = T extends (...args: never[]) => unknown ? T : T extends ReadonlyArray<infer TItem> ? ReadonlyArray<FrozenDeep<TItem>> : T extends object ? {
|
|
18
|
-
readonly [TKey in keyof T]: FrozenDeep<T[TKey]>;
|
|
19
|
-
} : T;
|
|
20
|
-
/**
|
|
21
|
-
* .what = seals the envelope before `invoke` receives it
|
|
3
|
+
* .what = seals the envelope before `invoke` receives it, in place, typed `FrozenDeep`
|
|
22
4
|
* .why = the envelope outlives the handler's turn, so a write through it corrupts a value
|
|
23
5
|
* somebody else reads after `invoke` returns — with no type error and no throw. the freeze
|
|
24
6
|
* makes that unrepresentable
|
|
@@ -31,47 +13,27 @@ export type FrozenDeep<T> = T extends (...args: never[]) => unknown ? T : T exte
|
|
|
31
13
|
* property of today, so a rule keyed to one expires silently the first commit that adds a
|
|
32
14
|
* post-invoke read (`rule.require.frozen-invoke-inputs`)
|
|
33
15
|
*
|
|
34
|
-
* .why the
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* .where = the family root rather than inside `forApiGateway`, because two variants of one family
|
|
40
|
-
* reach for it. lifted on the second use (`rule.prefer.most-common-denominator`)
|
|
16
|
+
* .why type-fns' `asFrozenDeep` = the type and the runtime come from one package, so they cannot
|
|
17
|
+
* drift: what `FrozenDeep` refuses at compile time, `asFrozenDeep` refuses at run time. that
|
|
18
|
+
* includes the state a bare `Object.freeze` cannot reach — a `Date`, `Map`, `Set`, `WeakMap`,
|
|
19
|
+
* or `WeakSet` has its mutators replaced by throwers, and the walk reaches symbol keys and
|
|
20
|
+
* non-enumerable own props
|
|
41
21
|
*
|
|
22
|
+
* .note = in place, deliberately. `asFrozenDeep` returns the same reference, so
|
|
23
|
+
* `headers === event.headers` holds and the bag cannot drift from the envelope it projects
|
|
24
|
+
* (`domain.terms/event.md`). a defensive copy would remove the hazard and break the projection
|
|
42
25
|
* .note = the projections freeze with it, by design: `headers`, `payload`, and `records` are the
|
|
43
|
-
* envelope's own slots, so a handler mutates none
|
|
26
|
+
* envelope's own slots, so a handler mutates none
|
|
44
27
|
* .note = `forSqs.perBatch`'s harm is the sharpest, and `[case17]` walks it end to end: a handler
|
|
45
28
|
* that forges `event.records[n].id` would rewrite the set the unknown-id guard checks
|
|
46
|
-
* against, so
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* sqs -> `wire.Records[n]` is reachable as `event._.raw.Records[n]` and as
|
|
55
|
-
* `event.records[n]._.raw` (`asSqsEventDecoded.ts:37`,
|
|
56
|
-
* `asSqsRecordDecoded.ts:94`)
|
|
57
|
-
*
|
|
58
|
-
* it is not a cycle guard. no cycle is reachable from this event — `requestContext` is an
|
|
59
|
-
* explicit four-field copy of primitives and `headers` is a new object — though the set
|
|
60
|
-
* would terminate one a later author introduced
|
|
61
|
-
*
|
|
62
|
-
* .note = a frozen write throws in strict mode and no-ops in sloppy mode. every module this sdk
|
|
63
|
-
* ships is an es module, which is strict by construction, so the throw is the behavior a
|
|
64
|
-
* consumer meets (ecma-262 §11.2.2)
|
|
65
|
-
* .note = the throw's message is terse — node raises a bare `TypeError: Cannot assign to read
|
|
66
|
-
* only property …`, which names no cause and no remedy. `Object.freeze` accepts no
|
|
67
|
-
* message, and the only mechanism that could supply one is a `Proxy` — a different
|
|
68
|
-
* object, so `headers === event.headers` would stop to hold. the remedy is prevention
|
|
69
|
-
* instead: `FrozenDeep` refuses the write at compile time, so a type-checked consumer
|
|
70
|
-
* never reaches the message (`rule.prefer.prevent-over-correct`)
|
|
71
|
-
*
|
|
72
|
-
* .why it returns = the same reference, narrowed to `FrozenDeep`. it still freezes in place — the
|
|
73
|
-
* return is the type half of one act, so a caller receives the guarantee from the step
|
|
74
|
-
* that establishes it rather than asserts it by hand at the hand-off
|
|
29
|
+
* against, so sqs is answered with an `itemIdentifier` it cannot match
|
|
30
|
+
*
|
|
31
|
+
* .why a refusal is a `MalfunctionError` = `asFrozenDeep` refuses, all or none and before any
|
|
32
|
+
* freeze, a value it cannot seal: a typed array that holds bytes, a global or sticky
|
|
33
|
+
* `RegExp`. `JSON.parse` yields neither, so one reaches the envelope only when the handler's
|
|
34
|
+
* own schema builds it. that is a server fault, never the caller's, so it must not ride the
|
|
35
|
+
* caller-fault path a bare `ConstraintError` would take (`getIsConstraintError`). the
|
|
36
|
+
* type-fns refusal rides as `cause`, so its `path` and `hint` still name the fix
|
|
75
37
|
*/
|
|
76
38
|
export declare const setEventFrozen: <TEvent>(input: {
|
|
77
39
|
event: TEvent;
|
|
@@ -1,35 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setEventFrozen = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const type_fns_1 = require("type-fns");
|
|
4
6
|
/**
|
|
5
|
-
* .what =
|
|
6
|
-
* .why = `Object.freeze` alone is shallow, so it would leave `event.headers` writable — and
|
|
7
|
-
* `headers` is exactly the object `@middy/http-cors` reads in its `after` hook
|
|
8
|
-
* (`@middy/http-cors/index.js:83`), after the handler has returned
|
|
9
|
-
*
|
|
10
|
-
* .why not `withImmute` = `domain-objects` ships a recursive helper whose name reads as this
|
|
11
|
-
* mechanism and is not it. measured in its dist (`withImmute.js:9-22,27-31`,
|
|
12
|
-
* domain-objects@0.33.0): it adds a `.clone()` — an affordance rather than an enforcement,
|
|
13
|
-
* so a write still succeeds — and it applies only where `isOfDomainObject(value)` holds,
|
|
14
|
-
* so on this plain-interface envelope it is a total no-op
|
|
15
|
-
*
|
|
16
|
-
* .note = in place, deliberately. a defensive copy would remove the same hazard and destroy the
|
|
17
|
-
* projection: `headers === event.headers` would stop to hold, and the bag could drift
|
|
18
|
-
* from the envelope it claims to project (`domain.terms/event.md`)
|
|
19
|
-
*/
|
|
20
|
-
const setFrozenDeep = (value, seen) => {
|
|
21
|
-
if (value === null || typeof value !== 'object')
|
|
22
|
-
return;
|
|
23
|
-
if (seen.has(value))
|
|
24
|
-
return;
|
|
25
|
-
seen.add(value);
|
|
26
|
-
Object.freeze(value);
|
|
27
|
-
// recurse over the OWN values only; a prototype belongs to whoever declared it
|
|
28
|
-
for (const nested of Object.values(value))
|
|
29
|
-
setFrozenDeep(nested, seen);
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* .what = seals the envelope before `invoke` receives it
|
|
7
|
+
* .what = seals the envelope before `invoke` receives it, in place, typed `FrozenDeep`
|
|
33
8
|
* .why = the envelope outlives the handler's turn, so a write through it corrupts a value
|
|
34
9
|
* somebody else reads after `invoke` returns — with no type error and no throw. the freeze
|
|
35
10
|
* makes that unrepresentable
|
|
@@ -42,62 +17,39 @@ const setFrozenDeep = (value, seen) => {
|
|
|
42
17
|
* property of today, so a rule keyed to one expires silently the first commit that adds a
|
|
43
18
|
* post-invoke read (`rule.require.frozen-invoke-inputs`)
|
|
44
19
|
*
|
|
45
|
-
* .why the
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* .where = the family root rather than inside `forApiGateway`, because two variants of one family
|
|
51
|
-
* reach for it. lifted on the second use (`rule.prefer.most-common-denominator`)
|
|
20
|
+
* .why type-fns' `asFrozenDeep` = the type and the runtime come from one package, so they cannot
|
|
21
|
+
* drift: what `FrozenDeep` refuses at compile time, `asFrozenDeep` refuses at run time. that
|
|
22
|
+
* includes the state a bare `Object.freeze` cannot reach — a `Date`, `Map`, `Set`, `WeakMap`,
|
|
23
|
+
* or `WeakSet` has its mutators replaced by throwers, and the walk reaches symbol keys and
|
|
24
|
+
* non-enumerable own props
|
|
52
25
|
*
|
|
26
|
+
* .note = in place, deliberately. `asFrozenDeep` returns the same reference, so
|
|
27
|
+
* `headers === event.headers` holds and the bag cannot drift from the envelope it projects
|
|
28
|
+
* (`domain.terms/event.md`). a defensive copy would remove the hazard and break the projection
|
|
53
29
|
* .note = the projections freeze with it, by design: `headers`, `payload`, and `records` are the
|
|
54
|
-
* envelope's own slots, so a handler mutates none
|
|
30
|
+
* envelope's own slots, so a handler mutates none
|
|
55
31
|
* .note = `forSqs.perBatch`'s harm is the sharpest, and `[case17]` walks it end to end: a handler
|
|
56
32
|
* that forges `event.records[n].id` would rewrite the set the unknown-id guard checks
|
|
57
|
-
* against, so
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* sqs -> `wire.Records[n]` is reachable as `event._.raw.Records[n]` and as
|
|
66
|
-
* `event.records[n]._.raw` (`asSqsEventDecoded.ts:37`,
|
|
67
|
-
* `asSqsRecordDecoded.ts:94`)
|
|
68
|
-
*
|
|
69
|
-
* it is not a cycle guard. no cycle is reachable from this event — `requestContext` is an
|
|
70
|
-
* explicit four-field copy of primitives and `headers` is a new object — though the set
|
|
71
|
-
* would terminate one a later author introduced
|
|
72
|
-
*
|
|
73
|
-
* .note = a frozen write throws in strict mode and no-ops in sloppy mode. every module this sdk
|
|
74
|
-
* ships is an es module, which is strict by construction, so the throw is the behavior a
|
|
75
|
-
* consumer meets (ecma-262 §11.2.2)
|
|
76
|
-
* .note = the throw's message is terse — node raises a bare `TypeError: Cannot assign to read
|
|
77
|
-
* only property …`, which names no cause and no remedy. `Object.freeze` accepts no
|
|
78
|
-
* message, and the only mechanism that could supply one is a `Proxy` — a different
|
|
79
|
-
* object, so `headers === event.headers` would stop to hold. the remedy is prevention
|
|
80
|
-
* instead: `FrozenDeep` refuses the write at compile time, so a type-checked consumer
|
|
81
|
-
* never reaches the message (`rule.prefer.prevent-over-correct`)
|
|
82
|
-
*
|
|
83
|
-
* .why it returns = the same reference, narrowed to `FrozenDeep`. it still freezes in place — the
|
|
84
|
-
* return is the type half of one act, so a caller receives the guarantee from the step
|
|
85
|
-
* that establishes it rather than asserts it by hand at the hand-off
|
|
33
|
+
* against, so sqs is answered with an `itemIdentifier` it cannot match
|
|
34
|
+
*
|
|
35
|
+
* .why a refusal is a `MalfunctionError` = `asFrozenDeep` refuses, all or none and before any
|
|
36
|
+
* freeze, a value it cannot seal: a typed array that holds bytes, a global or sticky
|
|
37
|
+
* `RegExp`. `JSON.parse` yields neither, so one reaches the envelope only when the handler's
|
|
38
|
+
* own schema builds it. that is a server fault, never the caller's, so it must not ride the
|
|
39
|
+
* caller-fault path a bare `ConstraintError` would take (`getIsConstraintError`). the
|
|
40
|
+
* type-fns refusal rides as `cause`, so its `path` and `hint` still name the fix
|
|
86
41
|
*/
|
|
87
42
|
const setEventFrozen = (input) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* .removal = drops if typescript ever proves a homomorphic mapped type against its own input
|
|
99
|
-
*/
|
|
100
|
-
return input.event;
|
|
43
|
+
try {
|
|
44
|
+
return (0, type_fns_1.asFrozenDeep)(input.event);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
// a non-error throw is no refusal of the walk; let it surface as-is
|
|
48
|
+
if (!(error instanceof Error))
|
|
49
|
+
throw error;
|
|
50
|
+
// a refusal: the handler's schema built a value the freeze cannot seal
|
|
51
|
+
throw new helpful_errors_1.MalfunctionError('the event holds a value the invoke freeze cannot seal — the handler schema built it', { cause: error });
|
|
52
|
+
}
|
|
101
53
|
};
|
|
102
54
|
exports.setEventFrozen = setEventFrozen;
|
|
103
55
|
//# sourceMappingURL=setEventFrozen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setEventFrozen.js","sourceRoot":"","sources":["../../../src/domain.operations/genLambdaEndpoint/setEventFrozen.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"setEventFrozen.js","sourceRoot":"","sources":["../../../src/domain.operations/genLambdaEndpoint/setEventFrozen.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAClD,uCAAyD;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACI,MAAM,cAAc,GAAG,CAAS,KAEtC,EAAsB,EAAE;IACvB,IAAI,CAAC;QACH,OAAO,IAAA,uBAAY,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,oEAAoE;QACpE,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAE3C,uEAAuE;QACvE,MAAM,IAAI,iCAAgB,CACxB,qFAAqF,EACrF,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAfW,QAAA,cAAc,kBAezB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
* triggers mint a fresh `exid` per invoke (`domain.terms/trail.md`)
|
|
9
9
|
*/
|
|
10
10
|
export { BadRequestError } from 'helpful-errors';
|
|
11
|
+
/**
|
|
12
|
+
* .what = the type of every value a `genLambdaEndpoint.for*` variant hands its `invoke`
|
|
13
|
+
* .why = a consumer who declares a handler apart from the call site must be able to name it
|
|
14
|
+
* .note = `FrozenDeep` is type-fns' own, re-exported so no consumer import changes
|
|
15
|
+
*/
|
|
16
|
+
export type { FrozenDeep } from 'type-fns';
|
|
11
17
|
/**
|
|
12
18
|
* .what = releases every LambdaClient this sdk memoized on the caller's behalf
|
|
13
19
|
* .why = `askLambdaEndpoint` findserts a client per region and holds it for the process, so
|
|
@@ -107,11 +113,6 @@ export { getValidatedInput } from './domain.operations/genLambdaEndpoint/middlew
|
|
|
107
113
|
export { getValidatedOutput, type OutputValidationErrorMetadata, } from './domain.operations/genLambdaEndpoint/middleware/getValidatedOutput';
|
|
108
114
|
export type { ValidationErrorMetadata } from './domain.operations/genLambdaEndpoint/middleware/getValidationError';
|
|
109
115
|
export type { ZodIssueSummary } from './domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary';
|
|
110
|
-
/**
|
|
111
|
-
* .what = types reachable from the public `ForApiGatewayInput` signature
|
|
112
|
-
* .why = a consumer who declares a handler apart from the call site must be able to name them
|
|
113
|
-
*/
|
|
114
|
-
export type { FrozenDeep } from './domain.operations/genLambdaEndpoint/setEventFrozen';
|
|
115
116
|
/**
|
|
116
117
|
* .what = the `logTranslate` config type
|
|
117
118
|
* .note = `TranslateLog` is public because `logTranslate` accepts it, and it replaces the
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,gDAAgD;AAChD,iDAAiD;AAAxC,iHAAA,eAAe,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;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,4JAAA,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,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,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.
|
|
5
|
+
"version": "0.7.1",
|
|
6
6
|
"repository": "ehmpathy/sdk-aws-lambda",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/sdk-aws-lambda",
|
|
8
8
|
"keywords": [
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"sdk-environment": "0.1.5",
|
|
74
74
|
"sdk-logs": "0.9.0",
|
|
75
75
|
"simple-in-memory-cache": "0.4.0",
|
|
76
|
-
"type-fns": "1.21.
|
|
76
|
+
"type-fns": "1.21.5",
|
|
77
77
|
"with-simple-cache": "0.15.3",
|
|
78
78
|
"yaml": "2.9.0",
|
|
79
79
|
"zod": "4.4.3"
|
|
@@ -100,14 +100,16 @@
|
|
|
100
100
|
"esbuild": "0.28.1",
|
|
101
101
|
"esbuild-register": "3.6.0",
|
|
102
102
|
"husky": "8.0.3",
|
|
103
|
+
"iso-time": "1.11.7",
|
|
103
104
|
"jest": "30.2.0",
|
|
104
|
-
"rhachet": "1.48.
|
|
105
|
+
"rhachet": "1.48.1",
|
|
105
106
|
"rhachet-brains-anthropic": "0.4.3",
|
|
106
107
|
"rhachet-brains-fireworksai": "0.2.3",
|
|
108
|
+
"rhachet-brains-openrouter": "0.1.1",
|
|
107
109
|
"rhachet-brains-xai": "0.3.3",
|
|
108
|
-
"rhachet-roles-bhrain": "0.
|
|
110
|
+
"rhachet-roles-bhrain": "0.38.0",
|
|
109
111
|
"rhachet-roles-bhuild": "0.21.36",
|
|
110
|
-
"rhachet-roles-ehmpathy": "1.39.
|
|
112
|
+
"rhachet-roles-ehmpathy": "1.39.2",
|
|
111
113
|
"rhachet-roles-rhachet": "0.1.7",
|
|
112
114
|
"test-fns": "1.15.8",
|
|
113
115
|
"tsc-alias": "1.8.10",
|