@geekmidas/constructs 0.1.0 → 0.2.0
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/{AWSLambdaFunction-DCh1tOhB.d.mts → AWSLambdaFunction-D9RZhm0N.d.mts} +3 -3
- package/dist/{AWSLambdaSubscriberAdaptor-DtNZPMoV.d.mts → AWSLambdaSubscriberAdaptor-C0aZBU64.d.mts} +2 -2
- package/dist/{AmazonApiGatewayEndpointAdaptor-CPqlw2Rx.cjs → AmazonApiGatewayEndpointAdaptor-Bk6ssx3K.cjs} +38 -25
- package/dist/AmazonApiGatewayEndpointAdaptor-Bk6ssx3K.cjs.map +1 -0
- package/dist/{AmazonApiGatewayEndpointAdaptor-TP_hLNAa.d.cts → AmazonApiGatewayEndpointAdaptor-CbJqLU6I.d.cts} +2 -2
- package/dist/{AmazonApiGatewayEndpointAdaptor-BaTM2TNu.d.mts → AmazonApiGatewayEndpointAdaptor-DC3N7zY_.d.mts} +3 -3
- package/dist/{AmazonApiGatewayEndpointAdaptor-Cm4iD199.mjs → AmazonApiGatewayEndpointAdaptor-pEWzF2uY.mjs} +38 -25
- package/dist/AmazonApiGatewayEndpointAdaptor-pEWzF2uY.mjs.map +1 -0
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-B2ZpUFiC.d.mts → AmazonApiGatewayV1EndpointAdaptor-BVxgQ-7J.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-CConfCqz.d.cts → AmazonApiGatewayV1EndpointAdaptor-CVwJ5k16.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-D38HuQa9.mjs → AmazonApiGatewayV1EndpointAdaptor-MJpRbIaQ.mjs} +2 -2
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-D38HuQa9.mjs.map → AmazonApiGatewayV1EndpointAdaptor-MJpRbIaQ.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-tjpvLBRb.cjs → AmazonApiGatewayV1EndpointAdaptor-uBp_4zLf.cjs} +2 -2
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-tjpvLBRb.cjs.map → AmazonApiGatewayV1EndpointAdaptor-uBp_4zLf.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DurJvFwa.d.cts → AmazonApiGatewayV2EndpointAdaptor-1oBZdQH3.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-BwMQInBi.d.mts → AmazonApiGatewayV2EndpointAdaptor-C3H8Hpv7.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-ByYtiJtN.mjs → AmazonApiGatewayV2EndpointAdaptor-ChO8BlDz.mjs} +2 -2
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-ByYtiJtN.mjs.map → AmazonApiGatewayV2EndpointAdaptor-ChO8BlDz.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DcJ_w3ro.cjs → AmazonApiGatewayV2EndpointAdaptor-I1W23Nvn.cjs} +2 -2
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DcJ_w3ro.cjs.map → AmazonApiGatewayV2EndpointAdaptor-I1W23Nvn.cjs.map} +1 -1
- package/dist/{Authorizer-D1w7MpK6.d.mts → Authorizer-Cpx59w_q.d.mts} +1 -1
- package/dist/{BaseFunctionBuilder-Oc2xmxmg.d.mts → BaseFunctionBuilder-CoV7J45W.d.mts} +2 -2
- package/dist/{Construct-DCPATqec.d.mts → Construct-jBKqb-Zi.d.mts} +1 -1
- package/dist/Construct.d.mts +1 -1
- package/dist/{Cron-DPEcDCDW.d.mts → Cron-JZkp_fHy.d.mts} +2 -2
- package/dist/{CronBuilder-CxKTiepV.d.mts → CronBuilder-BmFDO0Dm.d.mts} +4 -4
- package/dist/{Endpoint-DbPsw13b.mjs → Endpoint-B70_KKhu.mjs} +8 -2
- package/dist/Endpoint-B70_KKhu.mjs.map +1 -0
- package/dist/{Endpoint-CA-byrDr.cjs → Endpoint-BJo9Hhwm.cjs} +8 -2
- package/dist/Endpoint-BJo9Hhwm.cjs.map +1 -0
- package/dist/{Endpoint-DoY1Owv2.d.mts → Endpoint-C5djXyae.d.mts} +69 -6
- package/dist/{Endpoint-BJPJTGjV.d.cts → Endpoint-CC2RGjkl.d.cts} +66 -3
- package/dist/{EndpointBuilder-BJRkivxQ.d.mts → EndpointBuilder-CD8LkBda.d.mts} +42 -5
- package/dist/{EndpointBuilder-Bhyft7WY.cjs → EndpointBuilder-DeswNQdG.cjs} +55 -3
- package/dist/EndpointBuilder-DeswNQdG.cjs.map +1 -0
- package/dist/{EndpointBuilder-69uVrKZL.mjs → EndpointBuilder-FyyoFTJ5.mjs} +55 -3
- package/dist/{EndpointBuilder-Bhyft7WY.cjs.map → EndpointBuilder-FyyoFTJ5.mjs.map} +1 -1
- package/dist/{EndpointBuilder-CQ-jOXsD.d.cts → EndpointBuilder-vXk6eIJk.d.cts} +39 -2
- package/dist/{EndpointFactory-DgwmAR_8.d.cts → EndpointFactory-3g-7Rznt.d.cts} +30 -8
- package/dist/{EndpointFactory-BKEPcQgE.d.mts → EndpointFactory-DaFR9LQG.d.mts} +31 -9
- package/dist/{EndpointFactory-BcVbkrxf.cjs → EndpointFactory-DcT_g9M_.cjs} +63 -14
- package/dist/EndpointFactory-DcT_g9M_.cjs.map +1 -0
- package/dist/{EndpointFactory-ARUlRlyM.mjs → EndpointFactory-KJAjBWmO.mjs} +63 -14
- package/dist/EndpointFactory-KJAjBWmO.mjs.map +1 -0
- package/dist/{Function-Dthlh2Fb.d.mts → Function-Vh1t-Qjj.d.mts} +2 -2
- package/dist/{FunctionBuilder-CZFBLfdV.d.mts → FunctionBuilder-3jsoFffg.d.mts} +4 -4
- package/dist/{FunctionExecutionWrapper-CfuajSB5.d.mts → FunctionExecutionWrapper-CI3CaoCo.d.mts} +2 -2
- package/dist/{HonoEndpointAdaptor-sSG85VER.d.cts → HonoEndpointAdaptor-BJh4J-J9.d.cts} +2 -2
- package/dist/{HonoEndpointAdaptor-BmB4Sc7L.mjs → HonoEndpointAdaptor-CcvXzoYV.mjs} +41 -28
- package/dist/HonoEndpointAdaptor-CcvXzoYV.mjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-CnqR6PSB.cjs → HonoEndpointAdaptor-DodwLM0-.cjs} +41 -28
- package/dist/HonoEndpointAdaptor-DodwLM0-.cjs.map +1 -0
- package/dist/{HonoEndpointAdaptor-DBjipl6Q.d.mts → HonoEndpointAdaptor-kb1ByjUL.d.mts} +5 -5
- package/dist/{Subscriber-DvOtIyWq.cjs → Subscriber-DOt3svUC.cjs} +1 -1
- package/dist/{Subscriber-DvOtIyWq.cjs.map → Subscriber-DOt3svUC.cjs.map} +1 -1
- package/dist/{Subscriber-BfxLwZpX.d.mts → Subscriber-aNr1qkxR.d.mts} +2 -2
- package/dist/{Subscriber-JzcFFi4p.mjs → Subscriber-kCHbH2fZ.mjs} +1 -1
- package/dist/{Subscriber-JzcFFi4p.mjs.map → Subscriber-kCHbH2fZ.mjs.map} +1 -1
- package/dist/{SubscriberBuilder-lTiTUS1o.d.mts → SubscriberBuilder-CWS4tdbp.d.mts} +2 -2
- package/dist/{SubscriberBuilder-DUuV207i.cjs → SubscriberBuilder-Cj2u9k5Q.cjs} +2 -2
- package/dist/{SubscriberBuilder-DUuV207i.cjs.map → SubscriberBuilder-Cj2u9k5Q.cjs.map} +1 -1
- package/dist/{SubscriberBuilder-tm4oVOt3.mjs → SubscriberBuilder-DmxMU89X.mjs} +2 -2
- package/dist/{SubscriberBuilder-tm4oVOt3.mjs.map → SubscriberBuilder-DmxMU89X.mjs.map} +1 -1
- package/dist/{TestEndpointAdaptor-o7JbNcL-.mjs → TestEndpointAdaptor-1pPixE6y.mjs} +2 -2
- package/dist/{TestEndpointAdaptor-o7JbNcL-.mjs.map → TestEndpointAdaptor-1pPixE6y.mjs.map} +1 -1
- package/dist/{TestEndpointAdaptor-CGQVysE0.d.mts → TestEndpointAdaptor-5-unBV8O.d.mts} +3 -3
- package/dist/{TestEndpointAdaptor-CJO-og9U.d.cts → TestEndpointAdaptor-Bm0UjDtV.d.cts} +2 -2
- package/dist/{TestEndpointAdaptor-BtLcw4JW.cjs → TestEndpointAdaptor-wA-fmq4v.cjs} +2 -2
- package/dist/{TestEndpointAdaptor-BtLcw4JW.cjs.map → TestEndpointAdaptor-wA-fmq4v.cjs.map} +1 -1
- package/dist/adaptors/aws.cjs +4 -4
- package/dist/adaptors/aws.d.cts +4 -4
- package/dist/adaptors/aws.d.mts +15 -15
- package/dist/adaptors/aws.mjs +4 -4
- package/dist/adaptors/hono.cjs +3 -3
- package/dist/adaptors/hono.d.cts +2 -2
- package/dist/adaptors/hono.d.mts +9 -9
- package/dist/adaptors/hono.mjs +3 -3
- package/dist/adaptors/testing.cjs +2 -2
- package/dist/adaptors/testing.d.cts +2 -2
- package/dist/adaptors/testing.d.mts +9 -9
- package/dist/adaptors/testing.mjs +2 -2
- package/dist/crons/Cron.d.mts +6 -6
- package/dist/crons/CronBuilder.d.mts +7 -7
- package/dist/crons/index.d.mts +7 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +2 -2
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +2 -2
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +2 -2
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +3 -3
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +3 -3
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +10 -10
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +3 -3
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +3 -3
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +3 -3
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +10 -10
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +3 -3
- package/dist/endpoints/Authorizer.d.mts +1 -1
- package/dist/endpoints/Endpoint.cjs +1 -1
- package/dist/endpoints/Endpoint.d.cts +1 -1
- package/dist/endpoints/Endpoint.d.mts +8 -8
- package/dist/endpoints/Endpoint.mjs +1 -1
- package/dist/endpoints/EndpointBuilder.cjs +3 -2
- package/dist/endpoints/EndpointBuilder.d.cts +2 -2
- package/dist/endpoints/EndpointBuilder.d.mts +9 -9
- package/dist/endpoints/EndpointBuilder.mjs +3 -2
- package/dist/endpoints/EndpointFactory.cjs +4 -3
- package/dist/endpoints/EndpointFactory.d.cts +3 -3
- package/dist/endpoints/EndpointFactory.d.mts +10 -10
- package/dist/endpoints/EndpointFactory.mjs +4 -3
- package/dist/endpoints/HonoEndpointAdaptor.cjs +3 -3
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +2 -2
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/HonoEndpointAdaptor.mjs +3 -3
- package/dist/endpoints/TestEndpointAdaptor.cjs +2 -2
- package/dist/endpoints/TestEndpointAdaptor.d.cts +2 -2
- package/dist/endpoints/TestEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/TestEndpointAdaptor.mjs +2 -2
- package/dist/endpoints/audit.d.cts +1 -1
- package/dist/endpoints/audit.d.mts +8 -8
- package/dist/endpoints/helpers.cjs +2 -2
- package/dist/endpoints/helpers.d.cts +1 -1
- package/dist/endpoints/helpers.d.mts +8 -8
- package/dist/endpoints/helpers.mjs +2 -2
- package/dist/endpoints/index.cjs +5 -3
- package/dist/endpoints/index.cjs.map +1 -1
- package/dist/endpoints/index.d.cts +5 -5
- package/dist/endpoints/index.d.mts +13 -13
- package/dist/endpoints/index.mjs +5 -4
- package/dist/endpoints/index.mjs.map +1 -1
- package/dist/endpoints/processAudits.d.cts +1 -1
- package/dist/endpoints/processAudits.d.mts +8 -8
- package/dist/endpoints/rls.cjs +3 -0
- package/dist/endpoints/rls.d.cts +9 -0
- package/dist/endpoints/rls.d.mts +9 -0
- package/dist/endpoints/rls.mjs +3 -0
- package/dist/functions/AWSLambdaFunction.d.mts +4 -4
- package/dist/functions/BaseFunctionBuilder.d.mts +2 -2
- package/dist/functions/Function.d.mts +2 -2
- package/dist/functions/FunctionBuilder.d.mts +4 -4
- package/dist/functions/FunctionExecutionWrapper.d.mts +3 -3
- package/dist/functions/TestFunctionAdaptor.d.mts +2 -2
- package/dist/functions/index.d.mts +5 -5
- package/dist/{helpers-CrrdyA04.mjs → helpers-C3B2lVrM.mjs} +2 -2
- package/dist/{helpers-CrrdyA04.mjs.map → helpers-C3B2lVrM.mjs.map} +1 -1
- package/dist/{helpers-DiPZVJQC.cjs → helpers-DxxSpLfw.cjs} +2 -2
- package/dist/{helpers-DiPZVJQC.cjs.map → helpers-DxxSpLfw.cjs.map} +1 -1
- package/dist/{index-9gJrM7Rw.d.mts → index-CFyaRrck.d.mts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/publisher.d.mts +1 -1
- package/dist/rls-Bf3FRwto.mjs +9 -0
- package/dist/rls-Bf3FRwto.mjs.map +1 -0
- package/dist/rls-CmJ7bRsz.cjs +15 -0
- package/dist/rls-CmJ7bRsz.cjs.map +1 -0
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.d.mts +3 -3
- package/dist/subscribers/Subscriber.cjs +1 -1
- package/dist/subscribers/Subscriber.d.mts +2 -2
- package/dist/subscribers/Subscriber.mjs +1 -1
- package/dist/subscribers/SubscriberBuilder.cjs +2 -2
- package/dist/subscribers/SubscriberBuilder.d.mts +3 -3
- package/dist/subscribers/SubscriberBuilder.mjs +2 -2
- package/dist/subscribers/index.cjs +2 -2
- package/dist/subscribers/index.d.mts +3 -3
- package/dist/subscribers/index.mjs +2 -2
- package/dist/{types-Cy1IhmUB.d.mts → types-CScirkHt.d.mts} +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +6 -5
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +57 -26
- package/src/endpoints/Endpoint.ts +19 -0
- package/src/endpoints/EndpointBuilder.ts +57 -0
- package/src/endpoints/EndpointFactory.ts +119 -12
- package/src/endpoints/HonoEndpointAdaptor.ts +66 -37
- package/src/endpoints/index.ts +7 -0
- package/src/endpoints/rls.ts +67 -0
- package/dist/AmazonApiGatewayEndpointAdaptor-CPqlw2Rx.cjs.map +0 -1
- package/dist/AmazonApiGatewayEndpointAdaptor-Cm4iD199.mjs.map +0 -1
- package/dist/Endpoint-CA-byrDr.cjs.map +0 -1
- package/dist/Endpoint-DbPsw13b.mjs.map +0 -1
- package/dist/EndpointBuilder-69uVrKZL.mjs.map +0 -1
- package/dist/EndpointFactory-ARUlRlyM.mjs.map +0 -1
- package/dist/EndpointFactory-BcVbkrxf.cjs.map +0 -1
- package/dist/HonoEndpointAdaptor-BmB4Sc7L.mjs.map +0 -1
- package/dist/HonoEndpointAdaptor-CnqR6PSB.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../Function-
|
|
3
|
-
import "../FunctionExecutionWrapper-
|
|
4
|
-
import { AWSLambdaFunction, AWSLambdaHandler } from "../AWSLambdaFunction-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import "../Function-Vh1t-Qjj.mjs";
|
|
3
|
+
import "../FunctionExecutionWrapper-CI3CaoCo.mjs";
|
|
4
|
+
import { AWSLambdaFunction, AWSLambdaHandler } from "../AWSLambdaFunction-D9RZhm0N.mjs";
|
|
5
5
|
export { AWSLambdaFunction, AWSLambdaHandler };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { BaseFunctionBuilder } from "../BaseFunctionBuilder-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import { BaseFunctionBuilder } from "../BaseFunctionBuilder-CoV7J45W.mjs";
|
|
3
3
|
export { BaseFunctionBuilder };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Function, FunctionContext, FunctionFactory, FunctionHandler } from "../Function-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import { Function, FunctionContext, FunctionFactory, FunctionHandler } from "../Function-Vh1t-Qjj.mjs";
|
|
3
3
|
export { Function, FunctionContext, FunctionFactory, FunctionHandler };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../Function-
|
|
3
|
-
import "../BaseFunctionBuilder-
|
|
4
|
-
import { FunctionBuilder } from "../FunctionBuilder-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import "../Function-Vh1t-Qjj.mjs";
|
|
3
|
+
import "../BaseFunctionBuilder-CoV7J45W.mjs";
|
|
4
|
+
import { FunctionBuilder } from "../FunctionBuilder-3jsoFffg.mjs";
|
|
5
5
|
export { FunctionBuilder };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../Function-
|
|
3
|
-
import { FunctionExecutionWrapper } from "../FunctionExecutionWrapper-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import "../Function-Vh1t-Qjj.mjs";
|
|
3
|
+
import { FunctionExecutionWrapper } from "../FunctionExecutionWrapper-CI3CaoCo.mjs";
|
|
4
4
|
export { FunctionExecutionWrapper };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Function } from "../Function-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import { Function } from "../Function-Vh1t-Qjj.mjs";
|
|
3
3
|
import { Service, ServiceDiscovery, ServiceRecord } from "@geekmidas/services";
|
|
4
4
|
import { AuditStorage, AuditableAction, Auditor } from "@geekmidas/audit";
|
|
5
5
|
import { EventPublisher } from "@geekmidas/events";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Function, FunctionContext, FunctionHandler } from "../Function-
|
|
3
|
-
import { BaseFunctionBuilder } from "../BaseFunctionBuilder-
|
|
4
|
-
import { FunctionBuilder } from "../FunctionBuilder-
|
|
5
|
-
import { f } from "../index-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import { Function, FunctionContext, FunctionHandler } from "../Function-Vh1t-Qjj.mjs";
|
|
3
|
+
import { BaseFunctionBuilder } from "../BaseFunctionBuilder-CoV7J45W.mjs";
|
|
4
|
+
import { FunctionBuilder } from "../FunctionBuilder-3jsoFffg.mjs";
|
|
5
|
+
import { f } from "../index-CFyaRrck.mjs";
|
|
6
6
|
export { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Endpoint } from "./Endpoint-
|
|
1
|
+
import { Endpoint } from "./Endpoint-B70_KKhu.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fg from "fast-glob";
|
|
4
4
|
|
|
@@ -80,4 +80,4 @@ async function getEndpointsFromRoutes(routes, cwd) {
|
|
|
80
80
|
|
|
81
81
|
//#endregion
|
|
82
82
|
export { getEndpointsFromRoutes, getProjectRoot };
|
|
83
|
-
//# sourceMappingURL=helpers-
|
|
83
|
+
//# sourceMappingURL=helpers-C3B2lVrM.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-
|
|
1
|
+
{"version":3,"file":"helpers-C3B2lVrM.mjs","names":["cwd: string","routes: string[]","endpoints: Endpoint<string, HttpMethod, any, any, TServices>[]"],"sources":["../src/endpoints/helpers.ts"],"sourcesContent":["import path from 'node:path';\nimport fg from 'fast-glob';\nimport { Endpoint } from './Endpoint';\n\nimport type { Service } from '@geekmidas/services';\nimport type { HttpMethod } from '../types';\n\n// Re-export utility functions\n\n/**\n * Recursively finds the project root directory by looking for lock files.\n * Traverses up the directory tree until it finds a package manager lock file.\n *\n * @param cwd - The current working directory to start searching from\n * @returns Promise resolving to the absolute path of the project root\n *\n * @example\n * ```typescript\n * const projectRoot = await getProjectRoot(process.cwd());\n * console.log(`Project root: ${projectRoot}`);\n * // Output: Project root: /Users/user/my-project\n * ```\n */\nexport async function getProjectRoot(cwd: string): Promise<string> {\n if (cwd === '/') {\n return cwd;\n }\n\n const stream = fg.stream(\n ['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json', 'deno.lock'],\n { dot: true, cwd },\n );\n\n let isRoot = false;\n\n for await (const _ of stream) {\n isRoot = true;\n break;\n }\n\n if (isRoot) {\n return cwd;\n }\n\n return getProjectRoot(path.resolve(cwd, '..'));\n}\n\n/**\n * Discovers and imports all Endpoint instances from the specified route patterns.\n * Uses fast-glob to find files matching the patterns and extracts exported Endpoints.\n *\n * @template TServices - Array of service types used by the endpoints\n * @param routes - Array of glob patterns to match route files (e.g., ['src/routes/*.ts'])\n * @param cwd - The current working directory to resolve paths from\n * @returns Promise resolving to an array of Endpoint instances found in the matched files\n *\n * @example\n * ```typescript\n * // Find all endpoints in the routes directory\n * const endpoints = await getEndpointsFromRoutes(\n * ['src/routes/**\\/*.ts'],\n * process.cwd()\n * );\n *\n * // Register endpoints with your server\n * for (const endpoint of endpoints) {\n * server.register(endpoint);\n * }\n * ```\n *\n * @remarks\n * - Only exports that are valid Endpoint instances are included\n * - Files are imported dynamically, so they must be valid ES modules\n * - The function filters out non-Endpoint exports automatically\n */\nexport async function getEndpointsFromRoutes<TServices extends Service[]>(\n routes: string[],\n cwd: string,\n): Promise<Endpoint<string, HttpMethod, any, any, TServices>[]> {\n const stream = fg.stream(routes, { cwd });\n\n const endpoints: Endpoint<string, HttpMethod, any, any, TServices>[] = [];\n\n for await (const f of stream) {\n // Resolve the absolute path for the route file\n const routePath = path.resolve(cwd, f.toString());\n // Dynamically import the route module\n const route = await import(routePath);\n\n // Filter exported values to find only Endpoint instances\n const handlers = Object.values(route).filter((value) => {\n return Endpoint.isEndpoint(value);\n }) as unknown as Endpoint<string, HttpMethod, any, any, TServices>[];\n\n endpoints.push(...handlers);\n }\n\n return endpoints;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,eAAeA,KAA8B;AACjE,KAAI,QAAQ,IACV,QAAO;CAGT,MAAM,SAAS,GAAG,OAChB;EAAC;EAAa;EAAkB;EAAqB;CAAY,GACjE;EAAE,KAAK;EAAM;CAAK,EACnB;CAED,IAAI,SAAS;AAEb,YAAW,MAAM,KAAK,QAAQ;AAC5B,WAAS;AACT;CACD;AAED,KAAI,OACF,QAAO;AAGT,QAAO,eAAe,KAAK,QAAQ,KAAK,KAAK,CAAC;AAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BD,eAAsB,uBACpBC,QACAD,KAC8D;CAC9D,MAAM,SAAS,GAAG,OAAO,QAAQ,EAAE,IAAK,EAAC;CAEzC,MAAME,YAAiE,CAAE;AAEzE,YAAW,MAAM,KAAK,QAAQ;EAE5B,MAAM,YAAY,KAAK,QAAQ,KAAK,EAAE,UAAU,CAAC;EAEjD,MAAM,QAAQ,MAAM,OAAO;EAG3B,MAAM,WAAW,OAAO,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU;AACtD,UAAO,SAAS,WAAW,MAAM;EAClC,EAAC;AAEF,YAAU,KAAK,GAAG,SAAS;CAC5B;AAED,QAAO;AACR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_Endpoint = require('./Endpoint-
|
|
2
|
+
const require_Endpoint = require('./Endpoint-BJo9Hhwm.cjs');
|
|
3
3
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
4
|
const fast_glob = require_chunk.__toESM(require("fast-glob"));
|
|
5
5
|
|
|
@@ -92,4 +92,4 @@ Object.defineProperty(exports, 'getProjectRoot', {
|
|
|
92
92
|
return getProjectRoot;
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
|
-
//# sourceMappingURL=helpers-
|
|
95
|
+
//# sourceMappingURL=helpers-DxxSpLfw.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-
|
|
1
|
+
{"version":3,"file":"helpers-DxxSpLfw.cjs","names":["cwd: string","routes: string[]","endpoints: Endpoint<string, HttpMethod, any, any, TServices>[]"],"sources":["../src/endpoints/helpers.ts"],"sourcesContent":["import path from 'node:path';\nimport fg from 'fast-glob';\nimport { Endpoint } from './Endpoint';\n\nimport type { Service } from '@geekmidas/services';\nimport type { HttpMethod } from '../types';\n\n// Re-export utility functions\n\n/**\n * Recursively finds the project root directory by looking for lock files.\n * Traverses up the directory tree until it finds a package manager lock file.\n *\n * @param cwd - The current working directory to start searching from\n * @returns Promise resolving to the absolute path of the project root\n *\n * @example\n * ```typescript\n * const projectRoot = await getProjectRoot(process.cwd());\n * console.log(`Project root: ${projectRoot}`);\n * // Output: Project root: /Users/user/my-project\n * ```\n */\nexport async function getProjectRoot(cwd: string): Promise<string> {\n if (cwd === '/') {\n return cwd;\n }\n\n const stream = fg.stream(\n ['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json', 'deno.lock'],\n { dot: true, cwd },\n );\n\n let isRoot = false;\n\n for await (const _ of stream) {\n isRoot = true;\n break;\n }\n\n if (isRoot) {\n return cwd;\n }\n\n return getProjectRoot(path.resolve(cwd, '..'));\n}\n\n/**\n * Discovers and imports all Endpoint instances from the specified route patterns.\n * Uses fast-glob to find files matching the patterns and extracts exported Endpoints.\n *\n * @template TServices - Array of service types used by the endpoints\n * @param routes - Array of glob patterns to match route files (e.g., ['src/routes/*.ts'])\n * @param cwd - The current working directory to resolve paths from\n * @returns Promise resolving to an array of Endpoint instances found in the matched files\n *\n * @example\n * ```typescript\n * // Find all endpoints in the routes directory\n * const endpoints = await getEndpointsFromRoutes(\n * ['src/routes/**\\/*.ts'],\n * process.cwd()\n * );\n *\n * // Register endpoints with your server\n * for (const endpoint of endpoints) {\n * server.register(endpoint);\n * }\n * ```\n *\n * @remarks\n * - Only exports that are valid Endpoint instances are included\n * - Files are imported dynamically, so they must be valid ES modules\n * - The function filters out non-Endpoint exports automatically\n */\nexport async function getEndpointsFromRoutes<TServices extends Service[]>(\n routes: string[],\n cwd: string,\n): Promise<Endpoint<string, HttpMethod, any, any, TServices>[]> {\n const stream = fg.stream(routes, { cwd });\n\n const endpoints: Endpoint<string, HttpMethod, any, any, TServices>[] = [];\n\n for await (const f of stream) {\n // Resolve the absolute path for the route file\n const routePath = path.resolve(cwd, f.toString());\n // Dynamically import the route module\n const route = await import(routePath);\n\n // Filter exported values to find only Endpoint instances\n const handlers = Object.values(route).filter((value) => {\n return Endpoint.isEndpoint(value);\n }) as unknown as Endpoint<string, HttpMethod, any, any, TServices>[];\n\n endpoints.push(...handlers);\n }\n\n return endpoints;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,eAAeA,KAA8B;AACjE,KAAI,QAAQ,IACV,QAAO;CAGT,MAAM,SAAS,kBAAG,OAChB;EAAC;EAAa;EAAkB;EAAqB;CAAY,GACjE;EAAE,KAAK;EAAM;CAAK,EACnB;CAED,IAAI,SAAS;AAEb,YAAW,MAAM,KAAK,QAAQ;AAC5B,WAAS;AACT;CACD;AAED,KAAI,OACF,QAAO;AAGT,QAAO,eAAe,kBAAK,QAAQ,KAAK,KAAK,CAAC;AAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BD,eAAsB,uBACpBC,QACAD,KAC8D;CAC9D,MAAM,SAAS,kBAAG,OAAO,QAAQ,EAAE,IAAK,EAAC;CAEzC,MAAME,YAAiE,CAAE;AAEzE,YAAW,MAAM,KAAK,QAAQ;EAE5B,MAAM,YAAY,kBAAK,QAAQ,KAAK,EAAE,UAAU,CAAC;EAEjD,MAAM,QAAQ,MAAM,OAAO;EAG3B,MAAM,WAAW,OAAO,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU;AACtD,UAAO,0BAAS,WAAW,MAAM;EAClC,EAAC;AAEF,YAAU,KAAK,GAAG,SAAS;CAC5B;AAED,QAAO;AACR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FunctionBuilder } from "./FunctionBuilder-
|
|
1
|
+
import { FunctionBuilder } from "./FunctionBuilder-3jsoFffg.mjs";
|
|
2
2
|
import * as _geekmidas_audit9 from "@geekmidas/audit";
|
|
3
3
|
import * as _geekmidas_logger8 from "@geekmidas/logger";
|
|
4
4
|
import * as _geekmidas_schema7 from "@geekmidas/schema";
|
|
@@ -7,4 +7,4 @@ import * as _geekmidas_schema7 from "@geekmidas/schema";
|
|
|
7
7
|
declare const f: FunctionBuilder<_geekmidas_schema7.ComposableStandardSchema, undefined, [], _geekmidas_logger8.Logger, undefined, string, undefined, string, undefined, string, _geekmidas_audit9.AuditableAction<string, unknown>>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { f };
|
|
10
|
-
//# sourceMappingURL=index-
|
|
10
|
+
//# sourceMappingURL=index-CFyaRrck.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Construct, ConstructType } from "./Construct-
|
|
2
|
-
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-
|
|
1
|
+
import { Construct, ConstructType } from "./Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-CScirkHt.mjs";
|
|
3
3
|
import { Service, ServiceRecord } from "@geekmidas/services";
|
|
4
4
|
export { Construct, ConstructType, HttpMethod, LowerHttpMethod, RemoveUndefined, Service, ServiceRecord };
|
package/dist/publisher.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Construct } from "./Construct-
|
|
1
|
+
import { Construct } from "./Construct-jBKqb-Zi.mjs";
|
|
2
2
|
import { Service, ServiceDiscovery } from "@geekmidas/services";
|
|
3
3
|
import { AuditStorage } from "@geekmidas/audit";
|
|
4
4
|
import { EventPublisher, MappedEvent } from "@geekmidas/events";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rls-Bf3FRwto.mjs","names":[],"sources":["../src/endpoints/rls.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { CookieFn, HeaderFn } from './Endpoint';\n\n/**\n * RLS context - key-value pairs to set as PostgreSQL session variables.\n * Keys become `prefix.key` (e.g., `app.user_id`).\n */\nexport interface RlsContext {\n [key: string]: string | number | boolean | null | undefined;\n}\n\n/**\n * Function type for extracting RLS context from request context.\n *\n * @template TServices - Available service dependencies\n * @template TSession - Session data type\n * @template TLogger - Logger type\n *\n * @example\n * ```ts\n * const extractor: RlsContextExtractor<[], UserSession> = ({ session }) => ({\n * user_id: session.userId,\n * tenant_id: session.tenantId,\n * roles: session.roles.join(','),\n * });\n * ```\n */\nexport type RlsContextExtractor<\n TServices extends Service[] = [],\n TSession = unknown,\n TLogger extends Logger = Logger,\n> = (ctx: {\n services: ServiceRecord<TServices>;\n session: TSession;\n header: HeaderFn;\n cookie: CookieFn;\n logger: TLogger;\n}) => RlsContext | Promise<RlsContext>;\n\n/**\n * Configuration for RLS on an endpoint or factory.\n *\n * @template TServices - Available service dependencies\n * @template TSession - Session data type\n * @template TLogger - Logger type\n */\nexport interface RlsConfig<\n TServices extends Service[] = [],\n TSession = unknown,\n TLogger extends Logger = Logger,\n> {\n /** Function to extract RLS context from request */\n extractor: RlsContextExtractor<TServices, TSession, TLogger>;\n /** Prefix for PostgreSQL session variables (default: 'app') */\n prefix?: string;\n}\n\n/**\n * Symbol used to bypass RLS for an endpoint.\n */\nexport const RLS_BYPASS = Symbol.for('geekmidas.rls.bypass');\n\n/**\n * Type for RLS bypass marker.\n */\nexport type RlsBypass = typeof RLS_BYPASS;\n"],"mappings":";;;;AA6DA,MAAa,aAAa,OAAO,IAAI,uBAAuB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/endpoints/rls.ts
|
|
3
|
+
/**
|
|
4
|
+
* Symbol used to bypass RLS for an endpoint.
|
|
5
|
+
*/
|
|
6
|
+
const RLS_BYPASS = Symbol.for("geekmidas.rls.bypass");
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
Object.defineProperty(exports, 'RLS_BYPASS', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return RLS_BYPASS;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=rls-CmJ7bRsz.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rls-CmJ7bRsz.cjs","names":[],"sources":["../src/endpoints/rls.ts"],"sourcesContent":["import type { Logger } from '@geekmidas/logger';\nimport type { Service, ServiceRecord } from '@geekmidas/services';\nimport type { CookieFn, HeaderFn } from './Endpoint';\n\n/**\n * RLS context - key-value pairs to set as PostgreSQL session variables.\n * Keys become `prefix.key` (e.g., `app.user_id`).\n */\nexport interface RlsContext {\n [key: string]: string | number | boolean | null | undefined;\n}\n\n/**\n * Function type for extracting RLS context from request context.\n *\n * @template TServices - Available service dependencies\n * @template TSession - Session data type\n * @template TLogger - Logger type\n *\n * @example\n * ```ts\n * const extractor: RlsContextExtractor<[], UserSession> = ({ session }) => ({\n * user_id: session.userId,\n * tenant_id: session.tenantId,\n * roles: session.roles.join(','),\n * });\n * ```\n */\nexport type RlsContextExtractor<\n TServices extends Service[] = [],\n TSession = unknown,\n TLogger extends Logger = Logger,\n> = (ctx: {\n services: ServiceRecord<TServices>;\n session: TSession;\n header: HeaderFn;\n cookie: CookieFn;\n logger: TLogger;\n}) => RlsContext | Promise<RlsContext>;\n\n/**\n * Configuration for RLS on an endpoint or factory.\n *\n * @template TServices - Available service dependencies\n * @template TSession - Session data type\n * @template TLogger - Logger type\n */\nexport interface RlsConfig<\n TServices extends Service[] = [],\n TSession = unknown,\n TLogger extends Logger = Logger,\n> {\n /** Function to extract RLS context from request */\n extractor: RlsContextExtractor<TServices, TSession, TLogger>;\n /** Prefix for PostgreSQL session variables (default: 'app') */\n prefix?: string;\n}\n\n/**\n * Symbol used to bypass RLS for an endpoint.\n */\nexport const RLS_BYPASS = Symbol.for('geekmidas.rls.bypass');\n\n/**\n * Type for RLS bypass marker.\n */\nexport type RlsBypass = typeof RLS_BYPASS;\n"],"mappings":";;;;;AA6DA,MAAa,aAAa,OAAO,IAAI,uBAAuB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../Subscriber-
|
|
3
|
-
import { AWSLambdaHandler, AWSLambdaSubscriber } from "../AWSLambdaSubscriberAdaptor-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import "../Subscriber-aNr1qkxR.mjs";
|
|
3
|
+
import { AWSLambdaHandler, AWSLambdaSubscriber } from "../AWSLambdaSubscriberAdaptor-C0aZBU64.mjs";
|
|
4
4
|
export { AWSLambdaHandler, AWSLambdaSubscriber };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Subscriber, SubscriberContext, SubscriberHandler } from "../Subscriber-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import { Subscriber, SubscriberContext, SubscriberHandler } from "../Subscriber-aNr1qkxR.mjs";
|
|
3
3
|
export { Subscriber, SubscriberContext, SubscriberHandler };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require('../Construct-BYSPikVm.cjs');
|
|
2
|
-
require('../Subscriber-
|
|
3
|
-
const require_SubscriberBuilder = require('../SubscriberBuilder-
|
|
2
|
+
require('../Subscriber-DOt3svUC.cjs');
|
|
3
|
+
const require_SubscriberBuilder = require('../SubscriberBuilder-Cj2u9k5Q.cjs');
|
|
4
4
|
|
|
5
5
|
exports.SubscriberBuilder = require_SubscriberBuilder.SubscriberBuilder;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import "../Subscriber-
|
|
3
|
-
import { SubscriberBuilder } from "../SubscriberBuilder-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import "../Subscriber-aNr1qkxR.mjs";
|
|
3
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-CWS4tdbp.mjs";
|
|
4
4
|
export { SubscriberBuilder };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../Construct-LWeB1rSQ.mjs";
|
|
2
|
-
import "../Subscriber-
|
|
3
|
-
import { SubscriberBuilder } from "../SubscriberBuilder-
|
|
2
|
+
import "../Subscriber-kCHbH2fZ.mjs";
|
|
3
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-DmxMU89X.mjs";
|
|
4
4
|
|
|
5
5
|
export { SubscriberBuilder };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('../Construct-BYSPikVm.cjs');
|
|
2
|
-
const require_Subscriber = require('../Subscriber-
|
|
3
|
-
const require_SubscriberBuilder = require('../SubscriberBuilder-
|
|
2
|
+
const require_Subscriber = require('../Subscriber-DOt3svUC.cjs');
|
|
3
|
+
const require_SubscriberBuilder = require('../SubscriberBuilder-Cj2u9k5Q.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/subscribers/index.ts
|
|
6
6
|
const s = new require_SubscriberBuilder.SubscriberBuilder();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../Construct-
|
|
2
|
-
import { Subscriber } from "../Subscriber-
|
|
3
|
-
import { SubscriberBuilder } from "../SubscriberBuilder-
|
|
1
|
+
import "../Construct-jBKqb-Zi.mjs";
|
|
2
|
+
import { Subscriber } from "../Subscriber-aNr1qkxR.mjs";
|
|
3
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-CWS4tdbp.mjs";
|
|
4
4
|
import * as _geekmidas_logger10 from "@geekmidas/logger";
|
|
5
5
|
|
|
6
6
|
//#region src/subscribers/index.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../Construct-LWeB1rSQ.mjs";
|
|
2
|
-
import { Subscriber } from "../Subscriber-
|
|
3
|
-
import { SubscriberBuilder } from "../SubscriberBuilder-
|
|
2
|
+
import { Subscriber } from "../Subscriber-kCHbH2fZ.mjs";
|
|
3
|
+
import { SubscriberBuilder } from "../SubscriberBuilder-DmxMU89X.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/subscribers/index.ts
|
|
6
6
|
const s = new SubscriberBuilder();
|
|
@@ -4,4 +4,4 @@ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
|
|
4
4
|
type LowerHttpMethod<T extends HttpMethod> = Lowercase<T>;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { HttpMethod, LowerHttpMethod, RemoveUndefined };
|
|
7
|
-
//# sourceMappingURL=types-
|
|
7
|
+
//# sourceMappingURL=types-CScirkHt.d.mts.map
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-
|
|
1
|
+
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-CScirkHt.mjs";
|
|
2
2
|
export { HttpMethod, LowerHttpMethod, RemoveUndefined };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/constructs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -67,13 +67,14 @@
|
|
|
67
67
|
"lodash.uniqby": "~4.7.0",
|
|
68
68
|
"openapi-types": "~12.1.3",
|
|
69
69
|
"@geekmidas/audit": "0.0.8",
|
|
70
|
-
"@geekmidas/errors": "0.0.1",
|
|
71
70
|
"@geekmidas/cache": "0.0.7",
|
|
72
|
-
"@geekmidas/
|
|
71
|
+
"@geekmidas/db": "0.1.0",
|
|
72
|
+
"@geekmidas/errors": "0.0.1",
|
|
73
73
|
"@geekmidas/logger": "0.0.1",
|
|
74
|
-
"@geekmidas/
|
|
74
|
+
"@geekmidas/rate-limit": "0.1.0",
|
|
75
|
+
"@geekmidas/events": "0.0.2",
|
|
75
76
|
"@geekmidas/schema": "0.0.2",
|
|
76
|
-
"@geekmidas/
|
|
77
|
+
"@geekmidas/services": "0.0.1"
|
|
77
78
|
},
|
|
78
79
|
"devDependencies": {
|
|
79
80
|
"@types/lodash.compact": "~3.0.9",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AuditStorage, AuditableAction } from '@geekmidas/audit';
|
|
2
|
+
import { withRlsContext } from '@geekmidas/db/rls';
|
|
2
3
|
import type { Logger } from '@geekmidas/logger';
|
|
3
4
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
5
|
import type { HttpMethod } from '../types';
|
|
@@ -297,6 +298,21 @@ export abstract class AmazonApiGatewayEndpoint<
|
|
|
297
298
|
// Get pre-resolved database from middleware
|
|
298
299
|
const rawDb = (event as any).db;
|
|
299
300
|
|
|
301
|
+
// Extract RLS context if configured and not bypassed
|
|
302
|
+
const rlsActive =
|
|
303
|
+
this.endpoint.rlsConfig &&
|
|
304
|
+
!this.endpoint.rlsBypass &&
|
|
305
|
+
rawDb !== undefined;
|
|
306
|
+
const rlsContext = rlsActive
|
|
307
|
+
? await this.endpoint.rlsConfig!.extractor({
|
|
308
|
+
services: event.services as ServiceRecord<TServices>,
|
|
309
|
+
session: event.session,
|
|
310
|
+
header: event.header,
|
|
311
|
+
cookie: event.cookie,
|
|
312
|
+
logger,
|
|
313
|
+
})
|
|
314
|
+
: undefined;
|
|
315
|
+
|
|
300
316
|
// Execute handler with automatic audit transaction support
|
|
301
317
|
const result = await executeWithAuditTransaction(
|
|
302
318
|
auditContext,
|
|
@@ -306,39 +322,54 @@ export abstract class AmazonApiGatewayEndpoint<
|
|
|
306
322
|
auditContext?.storage?.databaseServiceName &&
|
|
307
323
|
auditContext.storage.databaseServiceName ===
|
|
308
324
|
this.endpoint.databaseService?.serviceName;
|
|
309
|
-
const
|
|
325
|
+
const baseDb = sameDatabase
|
|
310
326
|
? (auditor?.getTransaction?.() ?? rawDb)
|
|
311
327
|
: rawDb;
|
|
312
328
|
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
329
|
+
// Helper to execute handler with given db
|
|
330
|
+
const executeHandler = async (db: any) => {
|
|
331
|
+
const responseBuilder = new ResponseBuilder();
|
|
332
|
+
const response = await this.endpoint.handler(
|
|
333
|
+
{
|
|
334
|
+
header: event.header,
|
|
335
|
+
cookie: event.cookie,
|
|
336
|
+
logger: event.logger,
|
|
337
|
+
services: event.services,
|
|
338
|
+
session: event.session,
|
|
339
|
+
auditor,
|
|
340
|
+
db,
|
|
341
|
+
...input,
|
|
342
|
+
} as any,
|
|
343
|
+
responseBuilder,
|
|
344
|
+
);
|
|
327
345
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
346
|
+
// Check if response has metadata
|
|
347
|
+
let data = response;
|
|
348
|
+
let metadata = responseBuilder.getMetadata();
|
|
331
349
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
350
|
+
if (Endpoint.hasMetadata(response)) {
|
|
351
|
+
data = response.data;
|
|
352
|
+
metadata = response.metadata;
|
|
353
|
+
}
|
|
336
354
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
355
|
+
const output = this.endpoint.outputSchema
|
|
356
|
+
? await this.endpoint.parseOutput(data)
|
|
357
|
+
: undefined;
|
|
358
|
+
|
|
359
|
+
return { output, metadata, responseBuilder };
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// If RLS is active, wrap handler with RLS context
|
|
363
|
+
if (rlsActive && rlsContext && baseDb) {
|
|
364
|
+
return withRlsContext(
|
|
365
|
+
baseDb,
|
|
366
|
+
rlsContext,
|
|
367
|
+
async (trx: any) => executeHandler(trx),
|
|
368
|
+
{ prefix: this.endpoint.rlsConfig!.prefix },
|
|
369
|
+
);
|
|
370
|
+
}
|
|
340
371
|
|
|
341
|
-
return
|
|
372
|
+
return executeHandler(baseDb);
|
|
342
373
|
},
|
|
343
374
|
// Process declarative audits after handler (inside transaction)
|
|
344
375
|
async (result, auditor) => {
|
|
@@ -29,6 +29,7 @@ import { Function, type FunctionHandler } from '../functions';
|
|
|
29
29
|
import type { HttpMethod, LowerHttpMethod, RemoveUndefined } from '../types';
|
|
30
30
|
import type { Authorizer } from './Authorizer';
|
|
31
31
|
import type { ActorExtractor, MappedAudit } from './audit';
|
|
32
|
+
import type { RlsConfig } from './rls';
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Represents an HTTP endpoint that can handle requests with type-safe input/output validation,
|
|
@@ -123,6 +124,10 @@ export class Endpoint<
|
|
|
123
124
|
public audits: MappedAudit<TAuditAction, OutSchema>[] = [];
|
|
124
125
|
/** Database service for this endpoint */
|
|
125
126
|
public declare databaseService?: Service<TDatabaseServiceName, TDatabase>;
|
|
127
|
+
/** RLS configuration for this endpoint */
|
|
128
|
+
public rlsConfig?: RlsConfig<TServices, TSession, TLogger>;
|
|
129
|
+
/** Whether to bypass RLS for this endpoint */
|
|
130
|
+
public rlsBypass?: boolean;
|
|
126
131
|
/** The endpoint handler function */
|
|
127
132
|
private endpointFn!: EndpointHandler<
|
|
128
133
|
TInput,
|
|
@@ -593,6 +598,8 @@ export class Endpoint<
|
|
|
593
598
|
actorExtractor,
|
|
594
599
|
audits,
|
|
595
600
|
databaseService,
|
|
601
|
+
rlsConfig,
|
|
602
|
+
rlsBypass,
|
|
596
603
|
}: EndpointOptions<
|
|
597
604
|
TRoute,
|
|
598
605
|
TMethod,
|
|
@@ -658,6 +665,14 @@ export class Endpoint<
|
|
|
658
665
|
if (databaseService) {
|
|
659
666
|
this.databaseService = databaseService;
|
|
660
667
|
}
|
|
668
|
+
|
|
669
|
+
if (rlsConfig) {
|
|
670
|
+
this.rlsConfig = rlsConfig;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
if (rlsBypass) {
|
|
674
|
+
this.rlsBypass = rlsBypass;
|
|
675
|
+
}
|
|
661
676
|
}
|
|
662
677
|
}
|
|
663
678
|
|
|
@@ -775,6 +790,10 @@ export interface EndpointOptions<
|
|
|
775
790
|
audits?: MappedAudit<TAuditAction, OutSchema>[];
|
|
776
791
|
/** Database service for this endpoint */
|
|
777
792
|
databaseService?: Service<TDatabaseServiceName, TDatabase>;
|
|
793
|
+
/** RLS configuration for this endpoint */
|
|
794
|
+
rlsConfig?: RlsConfig<TServices, TSession, TLogger>;
|
|
795
|
+
/** Whether to bypass RLS for this endpoint */
|
|
796
|
+
rlsBypass?: boolean;
|
|
778
797
|
}
|
|
779
798
|
|
|
780
799
|
/**
|
|
@@ -22,6 +22,8 @@ import type {
|
|
|
22
22
|
SuccessStatus,
|
|
23
23
|
} from './Endpoint';
|
|
24
24
|
import type { ActorExtractor, MappedAudit } from './audit';
|
|
25
|
+
import type { RlsBypass, RlsConfig } from './rls';
|
|
26
|
+
import { RLS_BYPASS } from './rls';
|
|
25
27
|
|
|
26
28
|
export class EndpointBuilder<
|
|
27
29
|
TRoute extends string,
|
|
@@ -68,6 +70,8 @@ export class EndpointBuilder<
|
|
|
68
70
|
_actorExtractor?: ActorExtractor<TServices, TSession, TLogger>;
|
|
69
71
|
_audits: MappedAudit<TAuditAction, OutSchema>[] = [];
|
|
70
72
|
_customSecuritySchemes: Record<string, SecurityScheme> = {};
|
|
73
|
+
_rlsConfig?: RlsConfig<TServices, TSession, TLogger>;
|
|
74
|
+
_rlsBypass?: boolean;
|
|
71
75
|
|
|
72
76
|
constructor(
|
|
73
77
|
readonly route: TRoute,
|
|
@@ -583,6 +587,57 @@ export class EndpointBuilder<
|
|
|
583
587
|
>;
|
|
584
588
|
}
|
|
585
589
|
|
|
590
|
+
/**
|
|
591
|
+
* Configure RLS (Row-Level Security) context for this endpoint.
|
|
592
|
+
* Pass `false` or `RLS_BYPASS` to explicitly bypass RLS for this endpoint.
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* ```typescript
|
|
596
|
+
* // Custom RLS config for this endpoint
|
|
597
|
+
* .rls({
|
|
598
|
+
* extractor: ({ session }) => ({
|
|
599
|
+
* user_id: session.userId,
|
|
600
|
+
* tenant_id: session.tenantId,
|
|
601
|
+
* }),
|
|
602
|
+
* prefix: 'app',
|
|
603
|
+
* })
|
|
604
|
+
*
|
|
605
|
+
* // Bypass RLS (for admin endpoints)
|
|
606
|
+
* .rls(false)
|
|
607
|
+
* ```
|
|
608
|
+
*/
|
|
609
|
+
rls(
|
|
610
|
+
config: RlsConfig<TServices, TSession, TLogger> | false | RlsBypass,
|
|
611
|
+
): this {
|
|
612
|
+
if (config === false || config === RLS_BYPASS) {
|
|
613
|
+
this._rlsBypass = true;
|
|
614
|
+
this._rlsConfig = undefined;
|
|
615
|
+
} else {
|
|
616
|
+
this._rlsConfig = config;
|
|
617
|
+
this._rlsBypass = false;
|
|
618
|
+
}
|
|
619
|
+
return this;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Explicitly bypass RLS for this endpoint.
|
|
624
|
+
* Useful for admin operations that need unrestricted database access.
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```typescript
|
|
628
|
+
* .rlsBypass()
|
|
629
|
+
* .handle(async ({ db }) => {
|
|
630
|
+
* // Full access, no RLS filtering
|
|
631
|
+
* return db.selectFrom('orders').selectAll().execute();
|
|
632
|
+
* })
|
|
633
|
+
* ```
|
|
634
|
+
*/
|
|
635
|
+
rlsBypass(): this {
|
|
636
|
+
this._rlsBypass = true;
|
|
637
|
+
this._rlsConfig = undefined;
|
|
638
|
+
return this;
|
|
639
|
+
}
|
|
640
|
+
|
|
586
641
|
// EndpointBuilder doesn't have a generic input method - it uses body, query, params instead
|
|
587
642
|
input(_schema: any): any {
|
|
588
643
|
throw new Error(
|
|
@@ -663,6 +718,8 @@ export class EndpointBuilder<
|
|
|
663
718
|
actorExtractor: this._actorExtractor,
|
|
664
719
|
audits: this._audits,
|
|
665
720
|
databaseService: this._databaseService,
|
|
721
|
+
rlsConfig: this._rlsConfig,
|
|
722
|
+
rlsBypass: this._rlsBypass,
|
|
666
723
|
});
|
|
667
724
|
}
|
|
668
725
|
}
|