@geekmidas/constructs 2.0.0 → 3.0.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/CHANGELOG.md +15 -0
- package/dist/AWSLambdaFunction-BF1gJJjG.d.mts.map +1 -1
- package/dist/{AWSLambdaFunction-wtE9Lx_-.cjs → AWSLambdaFunction-BVpc9xFN.cjs} +14 -2
- package/dist/AWSLambdaFunction-BVpc9xFN.cjs.map +1 -0
- package/dist/{AWSLambdaFunction-BDL7Thi_.mjs → AWSLambdaFunction-OPazEPhQ.mjs} +14 -2
- package/dist/AWSLambdaFunction-OPazEPhQ.mjs.map +1 -0
- package/dist/AWSLambdaFunction-tzqv5XU6.d.cts.map +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-BtBKExsh.cjs → AWSLambdaSubscriberAdaptor-BL7Yl1XE.cjs} +13 -2
- package/dist/AWSLambdaSubscriberAdaptor-BL7Yl1XE.cjs.map +1 -0
- package/dist/{AWSLambdaSubscriberAdaptor-DsRmmGm1.mjs → AWSLambdaSubscriberAdaptor-YxZ_z3XG.mjs} +14 -3
- package/dist/AWSLambdaSubscriberAdaptor-YxZ_z3XG.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-BuyXynoH.d.cts → HonoEndpointAdaptor-BCql3gLP.d.cts} +3 -3
- package/dist/{HonoEndpointAdaptor-BnG87BVG.d.mts.map → HonoEndpointAdaptor-BCql3gLP.d.cts.map} +1 -1
- package/dist/{HonoEndpointAdaptor-BnG87BVG.d.mts → HonoEndpointAdaptor-C3AdQ0xS.d.mts} +3 -3
- package/dist/{HonoEndpointAdaptor-BuyXynoH.d.cts.map → HonoEndpointAdaptor-C3AdQ0xS.d.mts.map} +1 -1
- package/dist/TestFunctionAdaptor-BHk2bDOV.d.cts.map +1 -1
- package/dist/{TestFunctionAdaptor-CK-dbKpO.mjs → TestFunctionAdaptor-C5CLuR-9.mjs} +25 -17
- package/dist/TestFunctionAdaptor-C5CLuR-9.mjs.map +1 -0
- package/dist/{TestFunctionAdaptor-CSMX7myB.cjs → TestFunctionAdaptor-CH6-gO_B.cjs} +24 -16
- package/dist/TestFunctionAdaptor-CH6-gO_B.cjs.map +1 -0
- package/dist/TestFunctionAdaptor-DzT8GRdR.d.mts.map +1 -1
- package/dist/TestSubscriberAdaptor-CPEiqSfE.d.mts.map +1 -1
- package/dist/{TestSubscriberAdaptor-CrqLkyUE.mjs → TestSubscriberAdaptor-CwP3qNJ4.mjs} +22 -14
- package/dist/TestSubscriberAdaptor-CwP3qNJ4.mjs.map +1 -0
- package/dist/TestSubscriberAdaptor-DQk5xzb0.d.cts.map +1 -1
- package/dist/{TestSubscriberAdaptor-1m-2bM_j.cjs → TestSubscriberAdaptor-Dgxr_0vL.cjs} +21 -13
- package/dist/TestSubscriberAdaptor-Dgxr_0vL.cjs.map +1 -0
- package/dist/adaptors/aws.cjs +2 -2
- package/dist/adaptors/aws.d.cts +1 -1
- package/dist/adaptors/aws.d.mts +1 -1
- package/dist/adaptors/aws.mjs +2 -2
- package/dist/adaptors/hono.d.cts +2 -2
- package/dist/adaptors/hono.d.mts +2 -2
- package/dist/adaptors/testing.cjs +2 -2
- package/dist/adaptors/testing.d.cts +1 -1
- package/dist/adaptors/testing.d.mts +1 -1
- package/dist/adaptors/testing.mjs +2 -2
- package/dist/crons/Cron.d.cts +1 -1
- package/dist/crons/Cron.d.mts +1 -1
- package/dist/crons/CronBuilder.d.cts +1 -1
- package/dist/crons/CronBuilder.d.mts +1 -1
- package/dist/crons/index.d.cts +5 -5
- package/dist/crons/index.d.mts +5 -5
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +1 -1
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +1 -1
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +1 -1
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +1 -1
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +1 -1
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +1 -1
- package/dist/endpoints/Endpoint.d.cts +1 -1
- package/dist/endpoints/Endpoint.d.mts +1 -1
- package/dist/endpoints/EndpointBuilder.d.cts +1 -1
- package/dist/endpoints/EndpointBuilder.d.mts +1 -1
- package/dist/endpoints/EndpointFactory.d.cts +1 -1
- package/dist/endpoints/EndpointFactory.d.mts +1 -1
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +2 -2
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +2 -2
- package/dist/endpoints/TestEndpointAdaptor.d.cts +1 -1
- package/dist/endpoints/TestEndpointAdaptor.d.mts +1 -1
- package/dist/endpoints/audit.d.cts +1 -1
- package/dist/endpoints/audit.d.mts +1 -1
- package/dist/endpoints/helpers.d.cts +1 -1
- package/dist/endpoints/helpers.d.mts +1 -1
- package/dist/endpoints/index.d.cts +3 -3
- package/dist/endpoints/index.d.mts +3 -3
- package/dist/endpoints/lazyAccessors.d.cts +1 -1
- package/dist/endpoints/lazyAccessors.d.mts +1 -1
- package/dist/endpoints/processAudits.d.cts +1 -1
- package/dist/endpoints/processAudits.d.mts +1 -1
- package/dist/endpoints/rls.d.cts +1 -1
- package/dist/endpoints/rls.d.mts +1 -1
- package/dist/functions/AWSLambdaFunction.cjs +1 -1
- package/dist/functions/AWSLambdaFunction.mjs +1 -1
- package/dist/functions/TestFunctionAdaptor.cjs +1 -1
- package/dist/functions/TestFunctionAdaptor.mjs +1 -1
- package/dist/functions/index.d.cts +1 -1
- package/dist/functions/index.d.mts +1 -1
- package/dist/index-BfeupgMl.d.cts +12 -0
- package/dist/{index-BnoOaBQV.d.cts.map → index-BfeupgMl.d.cts.map} +1 -1
- package/dist/index-_5DYCNAt.d.mts +12 -0
- package/dist/{index-CtMNRkV7.d.mts.map → index-_5DYCNAt.d.mts.map} +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +1 -1
- package/dist/subscribers/TestSubscriberAdaptor.cjs +1 -1
- package/dist/subscribers/TestSubscriberAdaptor.mjs +1 -1
- package/dist/subscribers/index.d.cts +2 -2
- package/dist/subscribers/index.d.cts.map +1 -1
- package/package.json +12 -12
- package/src/functions/AWSLambdaFunction.ts +16 -2
- package/src/functions/TestFunctionAdaptor.ts +38 -31
- package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +55 -0
- package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +82 -0
- package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +17 -2
- package/src/subscribers/TestSubscriberAdaptor.ts +35 -29
- package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +64 -0
- package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +94 -0
- package/dist/AWSLambdaFunction-BDL7Thi_.mjs.map +0 -1
- package/dist/AWSLambdaFunction-wtE9Lx_-.cjs.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-BtBKExsh.cjs.map +0 -1
- package/dist/AWSLambdaSubscriberAdaptor-DsRmmGm1.mjs.map +0 -1
- package/dist/TestFunctionAdaptor-CK-dbKpO.mjs.map +0 -1
- package/dist/TestFunctionAdaptor-CSMX7myB.cjs.map +0 -1
- package/dist/TestSubscriberAdaptor-1m-2bM_j.cjs.map +0 -1
- package/dist/TestSubscriberAdaptor-CrqLkyUE.mjs.map +0 -1
- package/dist/index-BnoOaBQV.d.cts +0 -12
- package/dist/index-CtMNRkV7.d.mts +0 -12
|
@@ -3,7 +3,7 @@ import "../types-aFmq5cKh.mjs";
|
|
|
3
3
|
import "../BaseFunctionBuilder-CsvFjzA8.mjs";
|
|
4
4
|
import "../Function-CZw1DRQ6.mjs";
|
|
5
5
|
import "../FunctionBuilder-m5BNA2Ap.mjs";
|
|
6
|
-
import "../index-
|
|
6
|
+
import "../index-_5DYCNAt.mjs";
|
|
7
7
|
import "../Authorizer-DBsrDTuf.mjs";
|
|
8
8
|
import "../Endpoint-BiPM0glm.mjs";
|
|
9
9
|
import { createApiGatewayCookies, createApiGatewayHeaders, createCookieHeaderAccessor, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, createObjectHeaders } from "../lazyAccessors-DXkJpnyX.mjs";
|
|
@@ -3,7 +3,7 @@ import "../types-B5H3piDg.cjs";
|
|
|
3
3
|
import "../BaseFunctionBuilder-C-4hYTfj.cjs";
|
|
4
4
|
import "../Function-CwlB89lS.cjs";
|
|
5
5
|
import "../FunctionBuilder-D_7f5MfS.cjs";
|
|
6
|
-
import "../index-
|
|
6
|
+
import "../index-BfeupgMl.cjs";
|
|
7
7
|
import "../Authorizer-DWtwC8we.cjs";
|
|
8
8
|
import { CookieFn, Endpoint, HeaderFn } from "../Endpoint-C9N6CmvB.cjs";
|
|
9
9
|
import { AuditStorage, AuditableAction, Auditor } from "@geekmidas/audit";
|
|
@@ -3,7 +3,7 @@ import "../types-aFmq5cKh.mjs";
|
|
|
3
3
|
import "../BaseFunctionBuilder-CsvFjzA8.mjs";
|
|
4
4
|
import "../Function-CZw1DRQ6.mjs";
|
|
5
5
|
import "../FunctionBuilder-m5BNA2Ap.mjs";
|
|
6
|
-
import "../index-
|
|
6
|
+
import "../index-_5DYCNAt.mjs";
|
|
7
7
|
import "../Authorizer-DBsrDTuf.mjs";
|
|
8
8
|
import { CookieFn, Endpoint, HeaderFn } from "../Endpoint-BiPM0glm.mjs";
|
|
9
9
|
import { Service, ServiceDiscovery } from "@geekmidas/services";
|
package/dist/endpoints/rls.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import "../types-B5H3piDg.cjs";
|
|
|
3
3
|
import "../BaseFunctionBuilder-C-4hYTfj.cjs";
|
|
4
4
|
import "../Function-CwlB89lS.cjs";
|
|
5
5
|
import "../FunctionBuilder-D_7f5MfS.cjs";
|
|
6
|
-
import "../index-
|
|
6
|
+
import "../index-BfeupgMl.cjs";
|
|
7
7
|
import "../Authorizer-DWtwC8we.cjs";
|
|
8
8
|
import { RLS_BYPASS, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor } from "../Endpoint-C9N6CmvB.cjs";
|
|
9
9
|
export { RLS_BYPASS, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor };
|
package/dist/endpoints/rls.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import "../types-aFmq5cKh.mjs";
|
|
|
3
3
|
import "../BaseFunctionBuilder-CsvFjzA8.mjs";
|
|
4
4
|
import "../Function-CZw1DRQ6.mjs";
|
|
5
5
|
import "../FunctionBuilder-m5BNA2Ap.mjs";
|
|
6
|
-
import "../index-
|
|
6
|
+
import "../index-_5DYCNAt.mjs";
|
|
7
7
|
import "../Authorizer-DBsrDTuf.mjs";
|
|
8
8
|
import { RLS_BYPASS, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor } from "../Endpoint-BiPM0glm.mjs";
|
|
9
9
|
export { RLS_BYPASS, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor };
|
|
@@ -4,6 +4,6 @@ require('../BaseFunctionBuilder-DXf6HK-N.cjs');
|
|
|
4
4
|
require('../Function-DgQ_no6B.cjs');
|
|
5
5
|
require('../FunctionBuilder-C_xG9As7.cjs');
|
|
6
6
|
require('../FunctionExecutionWrapper-7B-CufYj.cjs');
|
|
7
|
-
const require_AWSLambdaFunction = require('../AWSLambdaFunction-
|
|
7
|
+
const require_AWSLambdaFunction = require('../AWSLambdaFunction-BVpc9xFN.cjs');
|
|
8
8
|
|
|
9
9
|
exports.AWSLambdaFunction = require_AWSLambdaFunction.AWSLambdaFunction;
|
|
@@ -4,6 +4,6 @@ import "../BaseFunctionBuilder-C3rQMoWb.mjs";
|
|
|
4
4
|
import "../Function-xfQbftdE.mjs";
|
|
5
5
|
import "../FunctionBuilder-CBeqX18X.mjs";
|
|
6
6
|
import "../FunctionExecutionWrapper-Ba0Z-iwe.mjs";
|
|
7
|
-
import { AWSLambdaFunction } from "../AWSLambdaFunction-
|
|
7
|
+
import { AWSLambdaFunction } from "../AWSLambdaFunction-OPazEPhQ.mjs";
|
|
8
8
|
|
|
9
9
|
export { AWSLambdaFunction };
|
|
@@ -3,6 +3,6 @@ require('../publisher-lFQleddL.cjs');
|
|
|
3
3
|
require('../BaseFunctionBuilder-DXf6HK-N.cjs');
|
|
4
4
|
require('../Function-DgQ_no6B.cjs');
|
|
5
5
|
require('../FunctionBuilder-C_xG9As7.cjs');
|
|
6
|
-
const require_TestFunctionAdaptor = require('../TestFunctionAdaptor-
|
|
6
|
+
const require_TestFunctionAdaptor = require('../TestFunctionAdaptor-CH6-gO_B.cjs');
|
|
7
7
|
|
|
8
8
|
exports.TestFunctionAdaptor = require_TestFunctionAdaptor.TestFunctionAdaptor;
|
|
@@ -3,6 +3,6 @@ import "../publisher-Bw4770Hi.mjs";
|
|
|
3
3
|
import "../BaseFunctionBuilder-C3rQMoWb.mjs";
|
|
4
4
|
import "../Function-xfQbftdE.mjs";
|
|
5
5
|
import "../FunctionBuilder-CBeqX18X.mjs";
|
|
6
|
-
import { TestFunctionAdaptor } from "../TestFunctionAdaptor-
|
|
6
|
+
import { TestFunctionAdaptor } from "../TestFunctionAdaptor-C5CLuR-9.mjs";
|
|
7
7
|
|
|
8
8
|
export { TestFunctionAdaptor };
|
|
@@ -2,5 +2,5 @@ import "../Construct-CX7HyFfT.cjs";
|
|
|
2
2
|
import { BaseFunctionBuilder } from "../BaseFunctionBuilder-C-4hYTfj.cjs";
|
|
3
3
|
import { Function, FunctionContext, FunctionHandler } from "../Function-CwlB89lS.cjs";
|
|
4
4
|
import { FunctionBuilder } from "../FunctionBuilder-D_7f5MfS.cjs";
|
|
5
|
-
import { f } from "../index-
|
|
5
|
+
import { f } from "../index-BfeupgMl.cjs";
|
|
6
6
|
export { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f };
|
|
@@ -2,5 +2,5 @@ import "../Construct-C2SyofdS.mjs";
|
|
|
2
2
|
import { BaseFunctionBuilder } from "../BaseFunctionBuilder-CsvFjzA8.mjs";
|
|
3
3
|
import { Function, FunctionContext, FunctionHandler } from "../Function-CZw1DRQ6.mjs";
|
|
4
4
|
import { FunctionBuilder } from "../FunctionBuilder-m5BNA2Ap.mjs";
|
|
5
|
-
import { f } from "../index-
|
|
5
|
+
import { f } from "../index-_5DYCNAt.mjs";
|
|
6
6
|
export { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FunctionBuilder } from "./FunctionBuilder-D_7f5MfS.cjs";
|
|
2
|
+
import * as _geekmidas_audit5 from "@geekmidas/audit";
|
|
3
|
+
import * as _geekmidas_logger4 from "@geekmidas/logger";
|
|
4
|
+
import * as _geekmidas_schema3 from "@geekmidas/schema";
|
|
5
|
+
|
|
6
|
+
//#region src/functions/index.d.ts
|
|
7
|
+
declare const f: FunctionBuilder<_geekmidas_schema3.ComposableStandardSchema, undefined, [], _geekmidas_logger4.Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit5.AuditableAction<string, unknown>>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { f };
|
|
12
|
+
//# sourceMappingURL=index-BfeupgMl.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-BfeupgMl.d.cts","names":[],"sources":["../src/functions/index.ts"],"sourcesContent":[],"mappings":";;;;;;cAWa,GAAC,gBAAwB,kBAAA,CAAxB,wBAAA,iBAAA,kBAAA,CAAA,MAAA,2DAAA,iBAAA,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FunctionBuilder } from "./FunctionBuilder-m5BNA2Ap.mjs";
|
|
2
|
+
import * as _geekmidas_audit2 from "@geekmidas/audit";
|
|
3
|
+
import * as _geekmidas_logger1 from "@geekmidas/logger";
|
|
4
|
+
import * as _geekmidas_schema0 from "@geekmidas/schema";
|
|
5
|
+
|
|
6
|
+
//#region src/functions/index.d.ts
|
|
7
|
+
declare const f: FunctionBuilder<_geekmidas_schema0.ComposableStandardSchema, undefined, [], _geekmidas_logger1.Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit2.AuditableAction<string, unknown>>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { f };
|
|
12
|
+
//# sourceMappingURL=index-_5DYCNAt.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-_5DYCNAt.d.mts","names":[],"sources":["../src/functions/index.ts"],"sourcesContent":[],"mappings":";;;;;;cAWa,GAAC,gBAAwB,kBAAA,CAAxB,wBAAA,iBAAA,kBAAA,CAAA,MAAA,2DAAA,iBAAA,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const require_AWSLambdaSubscriberAdaptor = require('../AWSLambdaSubscriberAdaptor-
|
|
1
|
+
const require_AWSLambdaSubscriberAdaptor = require('../AWSLambdaSubscriberAdaptor-BL7Yl1XE.cjs');
|
|
2
2
|
|
|
3
3
|
exports.AWSLambdaSubscriber = require_AWSLambdaSubscriberAdaptor.AWSLambdaSubscriber;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
require('../publisher-lFQleddL.cjs');
|
|
2
|
-
const require_TestSubscriberAdaptor = require('../TestSubscriberAdaptor-
|
|
2
|
+
const require_TestSubscriberAdaptor = require('../TestSubscriberAdaptor-Dgxr_0vL.cjs');
|
|
3
3
|
|
|
4
4
|
exports.TestSubscriberAdaptor = require_TestSubscriberAdaptor.TestSubscriberAdaptor;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../Construct-CX7HyFfT.cjs";
|
|
2
2
|
import { Subscriber } from "../Subscriber-1rDE7HuM.cjs";
|
|
3
3
|
import { SubscriberBuilder } from "../SubscriberBuilder-B9uva8fZ.cjs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _geekmidas_logger10 from "@geekmidas/logger";
|
|
5
5
|
|
|
6
6
|
//#region src/subscribers/index.d.ts
|
|
7
|
-
declare const s: SubscriberBuilder<[],
|
|
7
|
+
declare const s: SubscriberBuilder<[], _geekmidas_logger10.Logger, undefined, undefined, string, []>;
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/subscribers/index.ts"],"sourcesContent":[],"mappings":";;;;;;cAKa,GAAC,sBAA0B,
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/subscribers/index.ts"],"sourcesContent":[],"mappings":";;;;;;cAKa,GAAC,sBAA0B,mBAAA,CAA1B,MAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/constructs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -78,32 +78,32 @@
|
|
|
78
78
|
"kysely": "~0.28.8",
|
|
79
79
|
"pg": "~8.16.3",
|
|
80
80
|
"zod": "~4.1.13",
|
|
81
|
-
"@geekmidas/audit": "^
|
|
82
|
-
"@geekmidas/cache": "^1.
|
|
81
|
+
"@geekmidas/audit": "^2.0.0",
|
|
82
|
+
"@geekmidas/cache": "^1.1.0",
|
|
83
83
|
"@geekmidas/db": "^1.0.0",
|
|
84
|
-
"@geekmidas/envkit": "^1.0.3",
|
|
85
84
|
"@geekmidas/errors": "^1.0.0",
|
|
85
|
+
"@geekmidas/envkit": "^1.0.3",
|
|
86
86
|
"@geekmidas/events": "^1.1.0",
|
|
87
|
-
"@geekmidas/logger": "^1.0.0",
|
|
88
|
-
"@geekmidas/rate-limit": "^1.0.0",
|
|
89
87
|
"@geekmidas/schema": "^1.0.0",
|
|
90
88
|
"@geekmidas/services": "^1.0.1",
|
|
91
|
-
"@geekmidas/
|
|
89
|
+
"@geekmidas/logger": "^1.0.0",
|
|
90
|
+
"@geekmidas/testkit": "^1.0.2",
|
|
91
|
+
"@geekmidas/rate-limit": "^2.0.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"@middy/core": ">=6.3.1",
|
|
95
95
|
"@types/aws-lambda": ">=8.10.92",
|
|
96
96
|
"hono": ">=4.8.2",
|
|
97
|
-
"@geekmidas/
|
|
98
|
-
"@geekmidas/envkit": "^1.0.3",
|
|
97
|
+
"@geekmidas/audit": "^2.0.0",
|
|
99
98
|
"@geekmidas/db": "^1.0.0",
|
|
99
|
+
"@geekmidas/envkit": "^1.0.3",
|
|
100
100
|
"@geekmidas/errors": "^1.0.0",
|
|
101
|
+
"@geekmidas/cache": "^1.1.0",
|
|
101
102
|
"@geekmidas/events": "^1.1.0",
|
|
102
103
|
"@geekmidas/logger": "^1.0.0",
|
|
103
|
-
"@geekmidas/rate-limit": "^
|
|
104
|
+
"@geekmidas/rate-limit": "^2.0.0",
|
|
104
105
|
"@geekmidas/schema": "^1.0.0",
|
|
105
|
-
"@geekmidas/services": "^1.0.1"
|
|
106
|
-
"@geekmidas/audit": "^1.0.0"
|
|
106
|
+
"@geekmidas/services": "^1.0.1"
|
|
107
107
|
},
|
|
108
108
|
"peerDependenciesMeta": {
|
|
109
109
|
"@geekmidas/audit": {
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
InferStandardSchema,
|
|
10
10
|
} from '@geekmidas/schema';
|
|
11
11
|
import type { Service, ServiceRecord } from '@geekmidas/services';
|
|
12
|
+
import { runWithRequestContext } from '@geekmidas/services';
|
|
12
13
|
import middy, { type MiddlewareObj } from '@middy/core';
|
|
13
14
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
14
15
|
import type { Context, Handler } from 'aws-lambda';
|
|
@@ -321,7 +322,7 @@ export class AWSLambdaFunction<
|
|
|
321
322
|
const handler = this._handler.bind(this);
|
|
322
323
|
|
|
323
324
|
// Apply middleware in order
|
|
324
|
-
|
|
325
|
+
const chain = middy(handler)
|
|
325
326
|
.use(this.loggerMiddleware())
|
|
326
327
|
.use(this.baseInput())
|
|
327
328
|
.use(this.error())
|
|
@@ -329,6 +330,19 @@ export class AWSLambdaFunction<
|
|
|
329
330
|
.use(this.database())
|
|
330
331
|
.use(this.auditor())
|
|
331
332
|
.use(this.input())
|
|
332
|
-
.use(this.events())
|
|
333
|
+
.use(this.events());
|
|
334
|
+
|
|
335
|
+
// Wrap entire Middy chain in request context for service access
|
|
336
|
+
const wrappedHandler = async (event: unknown, context: Context) => {
|
|
337
|
+
const startTime = Date.now();
|
|
338
|
+
const requestId = context.awsRequestId;
|
|
339
|
+
const logger = this.fn.logger.child({ requestId }) as TLogger;
|
|
340
|
+
|
|
341
|
+
return runWithRequestContext({ logger, requestId, startTime }, () =>
|
|
342
|
+
chain(event as Parameters<typeof chain>[0], context),
|
|
343
|
+
);
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
return wrappedHandler as unknown as AWSLambdaHandler;
|
|
333
347
|
}
|
|
334
348
|
}
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
InferStandardSchema,
|
|
10
10
|
} from '@geekmidas/schema';
|
|
11
11
|
import {
|
|
12
|
+
runWithRequestContext,
|
|
12
13
|
type Service,
|
|
13
14
|
ServiceDiscovery,
|
|
14
15
|
type ServiceRecord,
|
|
@@ -153,41 +154,47 @@ export class TestFunctionAdaptor<
|
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
//
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
);
|
|
176
|
-
|
|
157
|
+
// Wrap execution in request context for service access via context.getLogger()
|
|
158
|
+
const requestId = `test-${Date.now()}`;
|
|
159
|
+
const startTime = Date.now();
|
|
160
|
+
|
|
161
|
+
return runWithRequestContext({ logger, requestId, startTime }, async () => {
|
|
162
|
+
// Execute the function
|
|
163
|
+
const response = await this.fn.fn({
|
|
164
|
+
input: parsedInput,
|
|
165
|
+
services,
|
|
166
|
+
logger,
|
|
167
|
+
db,
|
|
168
|
+
auditor,
|
|
169
|
+
} as any);
|
|
170
|
+
|
|
171
|
+
// Parse output if schema is provided
|
|
172
|
+
const output = await this.fn.parseOutput(response);
|
|
173
|
+
|
|
174
|
+
// Flush audits if any were recorded
|
|
175
|
+
if (auditor) {
|
|
176
|
+
const records = auditor.getRecords();
|
|
177
|
+
if (records.length > 0) {
|
|
178
|
+
logger.debug(
|
|
179
|
+
{ auditCount: records.length },
|
|
180
|
+
'Flushing function audits',
|
|
181
|
+
);
|
|
182
|
+
await auditor.flush();
|
|
183
|
+
}
|
|
177
184
|
}
|
|
178
|
-
}
|
|
179
185
|
|
|
180
|
-
|
|
186
|
+
// Register publisher service if provided in context
|
|
181
187
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
await publishEvents(
|
|
189
|
+
logger,
|
|
190
|
+
this.serviceDiscovery,
|
|
191
|
+
this.fn.events,
|
|
192
|
+
output,
|
|
193
|
+
this.fn.publisherService,
|
|
194
|
+
);
|
|
189
195
|
|
|
190
|
-
|
|
196
|
+
return output;
|
|
197
|
+
}) as Promise<InferStandardSchema<TOutSchema>>;
|
|
191
198
|
}
|
|
192
199
|
}
|
|
193
200
|
|
|
@@ -2,6 +2,7 @@ import { EnvironmentParser } from '@geekmidas/envkit';
|
|
|
2
2
|
import type { EventPublisher, PublishableMessage } from '@geekmidas/events';
|
|
3
3
|
import { ConsoleLogger } from '@geekmidas/logger/console';
|
|
4
4
|
import type { Service } from '@geekmidas/services';
|
|
5
|
+
import { serviceContext } from '@geekmidas/services';
|
|
5
6
|
import type { Context } from 'aws-lambda';
|
|
6
7
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
7
8
|
import { z } from 'zod/v4';
|
|
@@ -455,4 +456,58 @@ describe('AWSLambdaFunction', () => {
|
|
|
455
456
|
expect(result).toEqual({ hasDb: false });
|
|
456
457
|
});
|
|
457
458
|
});
|
|
459
|
+
|
|
460
|
+
describe('request context', () => {
|
|
461
|
+
it('should make serviceContext.getLogger() available inside handler', async () => {
|
|
462
|
+
let contextLogger: any;
|
|
463
|
+
let contextRequestId: string | undefined;
|
|
464
|
+
|
|
465
|
+
const fn = new Function(
|
|
466
|
+
async () => {
|
|
467
|
+
contextLogger = serviceContext.getLogger();
|
|
468
|
+
contextRequestId = serviceContext.getRequestId();
|
|
469
|
+
return { success: true };
|
|
470
|
+
},
|
|
471
|
+
undefined,
|
|
472
|
+
undefined,
|
|
473
|
+
undefined,
|
|
474
|
+
undefined,
|
|
475
|
+
[],
|
|
476
|
+
logger,
|
|
477
|
+
);
|
|
478
|
+
|
|
479
|
+
const adaptor = new AWSLambdaFunction(envParser, fn);
|
|
480
|
+
const handler = adaptor.handler;
|
|
481
|
+
|
|
482
|
+
const context = createMockContext();
|
|
483
|
+
await handler({}, context, vi.fn());
|
|
484
|
+
|
|
485
|
+
expect(contextLogger).toBeDefined();
|
|
486
|
+
expect(contextRequestId).toBe('test-request-id');
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it('should make serviceContext.hasContext() return true inside handler', async () => {
|
|
490
|
+
let hasContext = false;
|
|
491
|
+
|
|
492
|
+
const fn = new Function(
|
|
493
|
+
async () => {
|
|
494
|
+
hasContext = serviceContext.hasContext();
|
|
495
|
+
return { success: true };
|
|
496
|
+
},
|
|
497
|
+
undefined,
|
|
498
|
+
undefined,
|
|
499
|
+
undefined,
|
|
500
|
+
undefined,
|
|
501
|
+
[],
|
|
502
|
+
logger,
|
|
503
|
+
);
|
|
504
|
+
|
|
505
|
+
const adaptor = new AWSLambdaFunction(envParser, fn);
|
|
506
|
+
const handler = adaptor.handler;
|
|
507
|
+
|
|
508
|
+
await handler({}, createMockContext(), vi.fn());
|
|
509
|
+
|
|
510
|
+
expect(hasContext).toBe(true);
|
|
511
|
+
});
|
|
512
|
+
});
|
|
458
513
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EventPublisher, PublishableMessage } from '@geekmidas/events';
|
|
2
2
|
import { ConsoleLogger } from '@geekmidas/logger/console';
|
|
3
3
|
import type { Service } from '@geekmidas/services';
|
|
4
|
+
import { serviceContext } from '@geekmidas/services';
|
|
4
5
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
6
|
import { z } from 'zod/v4';
|
|
6
7
|
|
|
@@ -395,4 +396,85 @@ describe.skip('TestFunctionAdaptor', () => {
|
|
|
395
396
|
).rejects.toThrow('Function failed');
|
|
396
397
|
});
|
|
397
398
|
});
|
|
399
|
+
|
|
400
|
+
describe('request context', () => {
|
|
401
|
+
it('should make serviceContext.getLogger() available inside handler', async () => {
|
|
402
|
+
let contextLogger: any;
|
|
403
|
+
|
|
404
|
+
const fn = new Function(
|
|
405
|
+
async () => {
|
|
406
|
+
contextLogger = serviceContext.getLogger();
|
|
407
|
+
return { success: true };
|
|
408
|
+
},
|
|
409
|
+
undefined,
|
|
410
|
+
undefined,
|
|
411
|
+
undefined,
|
|
412
|
+
undefined,
|
|
413
|
+
[],
|
|
414
|
+
logger,
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
const adaptor = new TestFunctionAdaptor(fn);
|
|
418
|
+
|
|
419
|
+
await adaptor.invoke({
|
|
420
|
+
input: {},
|
|
421
|
+
services: {},
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
expect(contextLogger).toBeDefined();
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it('should make serviceContext.hasContext() return true inside handler', async () => {
|
|
428
|
+
let hasContext = false;
|
|
429
|
+
|
|
430
|
+
const fn = new Function(
|
|
431
|
+
async () => {
|
|
432
|
+
hasContext = serviceContext.hasContext();
|
|
433
|
+
return { success: true };
|
|
434
|
+
},
|
|
435
|
+
undefined,
|
|
436
|
+
undefined,
|
|
437
|
+
undefined,
|
|
438
|
+
undefined,
|
|
439
|
+
[],
|
|
440
|
+
logger,
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
const adaptor = new TestFunctionAdaptor(fn);
|
|
444
|
+
|
|
445
|
+
await adaptor.invoke({
|
|
446
|
+
input: {},
|
|
447
|
+
services: {},
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
expect(hasContext).toBe(true);
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
it('should provide a request ID starting with test-', async () => {
|
|
454
|
+
let requestId: string | undefined;
|
|
455
|
+
|
|
456
|
+
const fn = new Function(
|
|
457
|
+
async () => {
|
|
458
|
+
requestId = serviceContext.getRequestId();
|
|
459
|
+
return { success: true };
|
|
460
|
+
},
|
|
461
|
+
undefined,
|
|
462
|
+
undefined,
|
|
463
|
+
undefined,
|
|
464
|
+
undefined,
|
|
465
|
+
[],
|
|
466
|
+
logger,
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
const adaptor = new TestFunctionAdaptor(fn);
|
|
470
|
+
|
|
471
|
+
await adaptor.invoke({
|
|
472
|
+
input: {},
|
|
473
|
+
services: {},
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
expect(requestId).toBeDefined();
|
|
477
|
+
expect(requestId).toMatch(/^test-/);
|
|
478
|
+
});
|
|
479
|
+
});
|
|
398
480
|
});
|
|
@@ -4,7 +4,7 @@ import type { EventPublisher } from '@geekmidas/events';
|
|
|
4
4
|
import type { Logger } from '@geekmidas/logger';
|
|
5
5
|
import type { InferStandardSchema } from '@geekmidas/schema';
|
|
6
6
|
import type { Service, ServiceRecord } from '@geekmidas/services';
|
|
7
|
-
import { ServiceDiscovery } from '@geekmidas/services';
|
|
7
|
+
import { runWithRequestContext, ServiceDiscovery } from '@geekmidas/services';
|
|
8
8
|
import middy, { type MiddlewareObj } from '@middy/core';
|
|
9
9
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
10
10
|
import type {
|
|
@@ -318,10 +318,25 @@ export class AWSLambdaSubscriber<
|
|
|
318
318
|
const handler = this._handler.bind(this);
|
|
319
319
|
|
|
320
320
|
// Apply middleware in order
|
|
321
|
-
|
|
321
|
+
const chain = middy(handler)
|
|
322
322
|
.use(this.loggerMiddleware())
|
|
323
323
|
.use(this.parseEvents())
|
|
324
324
|
.use(this.error())
|
|
325
325
|
.use(this.services());
|
|
326
|
+
|
|
327
|
+
// Wrap entire Middy chain in request context for service access
|
|
328
|
+
const wrappedHandler = async (event: unknown, context: Context) => {
|
|
329
|
+
const startTime = Date.now();
|
|
330
|
+
const requestId = context.awsRequestId;
|
|
331
|
+
const logger = this.subscriber.logger.child({
|
|
332
|
+
requestId,
|
|
333
|
+
}) as TLogger;
|
|
334
|
+
|
|
335
|
+
return runWithRequestContext({ logger, requestId, startTime }, () =>
|
|
336
|
+
chain(event as Parameters<typeof chain>[0], context),
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
return wrappedHandler as unknown as AWSLambdaHandler;
|
|
326
341
|
}
|
|
327
342
|
}
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
import type { Logger } from '@geekmidas/logger';
|
|
7
7
|
import type { InferStandardSchema } from '@geekmidas/schema';
|
|
8
8
|
import type { Service, ServiceRecord } from '@geekmidas/services';
|
|
9
|
-
import { ServiceDiscovery } from '@geekmidas/services';
|
|
9
|
+
import { runWithRequestContext, ServiceDiscovery } from '@geekmidas/services';
|
|
10
10
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
11
11
|
import { publishEvents } from '../publisher';
|
|
12
12
|
import type { Subscriber } from './Subscriber';
|
|
@@ -72,36 +72,42 @@ export class TestSubscriberAdaptor<
|
|
|
72
72
|
return { batchItemFailures: [] } as any;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
//
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
// Wrap execution in request context for service access via context.getLogger()
|
|
76
|
+
const requestId = `test-${Date.now()}`;
|
|
77
|
+
const startTime = Date.now();
|
|
78
|
+
|
|
79
|
+
return runWithRequestContext({ logger, requestId, startTime }, async () => {
|
|
80
|
+
// Execute the subscriber handler
|
|
81
|
+
const result = await this.subscriber.handler({
|
|
82
|
+
events: filteredEvents,
|
|
83
|
+
services,
|
|
84
|
+
logger,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Validate output if schema is provided
|
|
88
|
+
let output: any = result;
|
|
89
|
+
if (this.subscriber.outputSchema && result) {
|
|
90
|
+
const validationResult =
|
|
91
|
+
await this.subscriber.outputSchema['~standard'].validate(result);
|
|
92
|
+
|
|
93
|
+
if (validationResult.issues) {
|
|
94
|
+
throw new Error('Subscriber output validation failed');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
output = validationResult.value;
|
|
90
98
|
}
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
return output;
|
|
100
|
+
// Publish events if configured
|
|
101
|
+
await publishEvents(
|
|
102
|
+
logger,
|
|
103
|
+
this.serviceDiscovery,
|
|
104
|
+
this.subscriber.events,
|
|
105
|
+
output,
|
|
106
|
+
this.subscriber.publisherService,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
return output;
|
|
110
|
+
}) as Promise<InferStandardSchema<OutSchema>>;
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
private filterEvents(
|