@geekmidas/constructs 0.0.22 → 0.1.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/README.md +90 -0
- package/dist/{AWSLambdaFunction-qWpalqfr.d.mts → AWSLambdaFunction-DCh1tOhB.d.mts} +3 -3
- package/dist/{AWSLambdaSubscriberAdaptor-CWbBNRz3.d.mts → AWSLambdaSubscriberAdaptor-DtNZPMoV.d.mts} +2 -2
- package/dist/{AmazonApiGatewayEndpointAdaptor-BQ0IJdaI.d.mts → AmazonApiGatewayEndpointAdaptor-BaTM2TNu.d.mts} +3 -3
- package/dist/{AmazonApiGatewayEndpointAdaptor-DXssXsJi.cjs → AmazonApiGatewayEndpointAdaptor-CPqlw2Rx.cjs} +3 -3
- package/dist/{AmazonApiGatewayEndpointAdaptor-DXssXsJi.cjs.map → AmazonApiGatewayEndpointAdaptor-CPqlw2Rx.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayEndpointAdaptor-CacGag6F.mjs → AmazonApiGatewayEndpointAdaptor-Cm4iD199.mjs} +3 -3
- package/dist/{AmazonApiGatewayEndpointAdaptor-CacGag6F.mjs.map → AmazonApiGatewayEndpointAdaptor-Cm4iD199.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayEndpointAdaptor-Da9BR5On.d.cts → AmazonApiGatewayEndpointAdaptor-TP_hLNAa.d.cts} +2 -2
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-C4_AZ1ek.d.mts → AmazonApiGatewayV1EndpointAdaptor-B2ZpUFiC.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-CSm3NsWz.d.cts → AmazonApiGatewayV1EndpointAdaptor-CConfCqz.d.cts} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-BpnG55R7.mjs → AmazonApiGatewayV1EndpointAdaptor-D38HuQa9.mjs} +2 -2
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-BpnG55R7.mjs.map → AmazonApiGatewayV1EndpointAdaptor-D38HuQa9.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-Df4kszio.cjs → AmazonApiGatewayV1EndpointAdaptor-tjpvLBRb.cjs} +2 -2
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-Df4kszio.cjs.map → AmazonApiGatewayV1EndpointAdaptor-tjpvLBRb.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DdM8Tr1X.d.mts → AmazonApiGatewayV2EndpointAdaptor-BwMQInBi.d.mts} +4 -4
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-ZORzMEET.mjs → AmazonApiGatewayV2EndpointAdaptor-ByYtiJtN.mjs} +2 -2
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-ZORzMEET.mjs.map → AmazonApiGatewayV2EndpointAdaptor-ByYtiJtN.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-5SIvqPby.cjs → AmazonApiGatewayV2EndpointAdaptor-DcJ_w3ro.cjs} +2 -2
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-5SIvqPby.cjs.map → AmazonApiGatewayV2EndpointAdaptor-DcJ_w3ro.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-6hsBFVLf.d.cts → AmazonApiGatewayV2EndpointAdaptor-DurJvFwa.d.cts} +3 -3
- package/dist/Authorizer-C0ge_tc8.cjs +92 -0
- package/dist/Authorizer-C0ge_tc8.cjs.map +1 -0
- package/dist/Authorizer-CpSUMTIs.d.cts +125 -0
- package/dist/Authorizer-D1w7MpK6.d.mts +125 -0
- package/dist/Authorizer-r9U3y_ms.mjs +68 -0
- package/dist/Authorizer-r9U3y_ms.mjs.map +1 -0
- package/dist/{BaseFunctionBuilder-Ct6zY6Jq.d.mts → BaseFunctionBuilder-Oc2xmxmg.d.mts} +2 -2
- package/dist/{Construct-DDR0295I.d.mts → Construct-DCPATqec.d.mts} +1 -1
- package/dist/Construct.d.mts +1 -1
- package/dist/{Cron-DnMRWPFR.d.mts → Cron-DPEcDCDW.d.mts} +2 -2
- package/dist/{CronBuilder-RLDitFmP.d.mts → CronBuilder-CxKTiepV.d.mts} +4 -4
- package/dist/{Endpoint-D2Imgihs.d.cts → Endpoint-BJPJTGjV.d.cts} +2 -2
- package/dist/{Endpoint-PtQ-wLIS.d.mts → Endpoint-DoY1Owv2.d.mts} +4 -4
- package/dist/{EndpointBuilder-W5fdXxYQ.mjs → EndpointBuilder-69uVrKZL.mjs} +15 -2
- package/dist/EndpointBuilder-69uVrKZL.mjs.map +1 -0
- package/dist/{EndpointBuilder-BPHpUekp.d.mts → EndpointBuilder-BJRkivxQ.d.mts} +6 -5
- package/dist/{EndpointBuilder-CYkeYpsL.cjs → EndpointBuilder-Bhyft7WY.cjs} +15 -2
- package/dist/EndpointBuilder-Bhyft7WY.cjs.map +1 -0
- package/dist/{EndpointBuilder-TApJQhtG.d.cts → EndpointBuilder-CQ-jOXsD.d.cts} +4 -3
- package/dist/{EndpointFactory-B27nfeiE.mjs → EndpointFactory-ARUlRlyM.mjs} +68 -14
- package/dist/EndpointFactory-ARUlRlyM.mjs.map +1 -0
- package/dist/{EndpointFactory-CNlfBDuD.d.mts → EndpointFactory-BKEPcQgE.d.mts} +45 -20
- package/dist/{EndpointFactory-D5lFZXqY.cjs → EndpointFactory-BcVbkrxf.cjs} +68 -14
- package/dist/EndpointFactory-BcVbkrxf.cjs.map +1 -0
- package/dist/{EndpointFactory-B5fOINuc.d.cts → EndpointFactory-DgwmAR_8.d.cts} +45 -20
- package/dist/{Function-CD3rXWfa.d.mts → Function-Dthlh2Fb.d.mts} +2 -2
- package/dist/{FunctionBuilder-j2VkwuGf.d.mts → FunctionBuilder-CZFBLfdV.d.mts} +4 -4
- package/dist/{FunctionExecutionWrapper-B0WP-Vec.d.mts → FunctionExecutionWrapper-CfuajSB5.d.mts} +2 -2
- package/dist/{HonoEndpointAdaptor-Bg_vTyA5.mjs → HonoEndpointAdaptor-BmB4Sc7L.mjs} +3 -3
- package/dist/{HonoEndpointAdaptor-Bg_vTyA5.mjs.map → HonoEndpointAdaptor-BmB4Sc7L.mjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-B_gJPWGD.cjs → HonoEndpointAdaptor-CnqR6PSB.cjs} +3 -3
- package/dist/{HonoEndpointAdaptor-B_gJPWGD.cjs.map → HonoEndpointAdaptor-CnqR6PSB.cjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-CLOpobdq.d.cts → HonoEndpointAdaptor-DBjipl6Q.d.mts} +6 -6
- package/dist/{HonoEndpointAdaptor-C9gYYBWu.d.mts → HonoEndpointAdaptor-sSG85VER.d.cts} +8 -8
- package/dist/{Subscriber-itwm7ugy.d.mts → Subscriber-BfxLwZpX.d.mts} +2 -2
- package/dist/{Subscriber-D-FPWts6.cjs → Subscriber-DvOtIyWq.cjs} +1 -1
- package/dist/{Subscriber-D-FPWts6.cjs.map → Subscriber-DvOtIyWq.cjs.map} +1 -1
- package/dist/{Subscriber-CGb8LjZa.mjs → Subscriber-JzcFFi4p.mjs} +1 -1
- package/dist/{Subscriber-CGb8LjZa.mjs.map → Subscriber-JzcFFi4p.mjs.map} +1 -1
- package/dist/{SubscriberBuilder-BfE2cL1q.cjs → SubscriberBuilder-DUuV207i.cjs} +2 -2
- package/dist/{SubscriberBuilder-BfE2cL1q.cjs.map → SubscriberBuilder-DUuV207i.cjs.map} +1 -1
- package/dist/{SubscriberBuilder-9j3JCu8-.d.mts → SubscriberBuilder-lTiTUS1o.d.mts} +2 -2
- package/dist/{SubscriberBuilder-BcAspHv9.mjs → SubscriberBuilder-tm4oVOt3.mjs} +2 -2
- package/dist/{SubscriberBuilder-BcAspHv9.mjs.map → SubscriberBuilder-tm4oVOt3.mjs.map} +1 -1
- package/dist/{TestEndpointAdaptor-Bew9lWsx.cjs → TestEndpointAdaptor-BtLcw4JW.cjs} +3 -3
- package/dist/{TestEndpointAdaptor-Bew9lWsx.cjs.map → TestEndpointAdaptor-BtLcw4JW.cjs.map} +1 -1
- package/dist/{TestEndpointAdaptor-C-c8v7VI.d.mts → TestEndpointAdaptor-CGQVysE0.d.mts} +3 -3
- package/dist/{TestEndpointAdaptor-BYCwwiYk.d.cts → TestEndpointAdaptor-CJO-og9U.d.cts} +2 -2
- package/dist/{TestEndpointAdaptor-JONQJeXc.mjs → TestEndpointAdaptor-o7JbNcL-.mjs} +3 -3
- package/dist/{TestEndpointAdaptor-JONQJeXc.mjs.map → TestEndpointAdaptor-o7JbNcL-.mjs.map} +1 -1
- package/dist/adaptors/aws.cjs +4 -4
- package/dist/adaptors/aws.d.cts +5 -5
- package/dist/adaptors/aws.d.mts +15 -15
- package/dist/adaptors/aws.mjs +4 -4
- package/dist/adaptors/hono.cjs +2 -2
- package/dist/adaptors/hono.d.cts +3 -3
- package/dist/adaptors/hono.d.mts +9 -9
- package/dist/adaptors/hono.mjs +2 -2
- package/dist/adaptors/testing.cjs +2 -2
- package/dist/adaptors/testing.d.cts +3 -3
- 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.cts +4 -4
- package/dist/crons/index.d.mts +7 -7
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +2 -2
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +3 -3
- 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 +4 -4
- 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 +4 -4
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +10 -10
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +3 -3
- package/dist/endpoints/Authorizer.cjs +5 -14
- package/dist/endpoints/Authorizer.d.cts +2 -2
- package/dist/endpoints/Authorizer.d.mts +2 -2
- package/dist/endpoints/Authorizer.mjs +2 -13
- package/dist/endpoints/Endpoint.d.cts +2 -2
- package/dist/endpoints/Endpoint.d.mts +8 -8
- package/dist/endpoints/EndpointBuilder.cjs +2 -1
- package/dist/endpoints/EndpointBuilder.d.cts +3 -3
- package/dist/endpoints/EndpointBuilder.d.mts +9 -9
- package/dist/endpoints/EndpointBuilder.mjs +2 -1
- package/dist/endpoints/EndpointFactory.cjs +3 -2
- package/dist/endpoints/EndpointFactory.d.cts +4 -4
- package/dist/endpoints/EndpointFactory.d.mts +10 -10
- package/dist/endpoints/EndpointFactory.mjs +3 -2
- package/dist/endpoints/HonoEndpointAdaptor.cjs +2 -2
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +3 -3
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/HonoEndpointAdaptor.mjs +2 -2
- package/dist/endpoints/TestEndpointAdaptor.cjs +2 -2
- package/dist/endpoints/TestEndpointAdaptor.d.cts +3 -3
- package/dist/endpoints/TestEndpointAdaptor.d.mts +9 -9
- package/dist/endpoints/TestEndpointAdaptor.mjs +2 -2
- package/dist/endpoints/audit.d.cts +2 -2
- package/dist/endpoints/audit.d.mts +8 -8
- package/dist/endpoints/helpers.d.cts +2 -2
- package/dist/endpoints/helpers.d.mts +8 -8
- package/dist/endpoints/index.cjs +3 -2
- package/dist/endpoints/index.cjs.map +1 -1
- package/dist/endpoints/index.d.cts +6 -6
- package/dist/endpoints/index.d.mts +12 -12
- package/dist/endpoints/index.mjs +3 -2
- package/dist/endpoints/index.mjs.map +1 -1
- package/dist/endpoints/processAudits.cjs +1 -1
- package/dist/endpoints/processAudits.d.cts +24 -5
- package/dist/endpoints/processAudits.d.mts +30 -11
- package/dist/endpoints/processAudits.mjs +1 -1
- 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/index-9gJrM7Rw.d.mts +10 -0
- package/dist/index.d.mts +2 -2
- package/dist/{processAudits-BFokHhCO.cjs → processAudits-CzHkPokQ.cjs} +13 -7
- package/dist/processAudits-CzHkPokQ.cjs.map +1 -0
- package/dist/{processAudits-DfcB-X-4.mjs → processAudits-Dj8UGqcW.mjs} +13 -7
- package/dist/processAudits-Dj8UGqcW.mjs.map +1 -0
- package/dist/publisher.d.mts +1 -1
- 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.cts +2 -2
- package/dist/subscribers/index.d.mts +5 -5
- package/dist/subscribers/index.mjs +2 -2
- package/dist/{types-DKf0juBf.d.mts → types-Cy1IhmUB.d.mts} +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +5 -5
- package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +2 -0
- package/src/endpoints/Authorizer.ts +119 -1
- package/src/endpoints/EndpointBuilder.ts +23 -6
- package/src/endpoints/EndpointFactory.ts +156 -27
- package/src/endpoints/HonoEndpointAdaptor.ts +2 -0
- package/src/endpoints/TestEndpointAdaptor.ts +2 -0
- package/src/endpoints/processAudits.ts +39 -16
- package/dist/Authorizer-BTmly8ps.d.cts +0 -29
- package/dist/Authorizer-pmPvIVgv.d.mts +0 -29
- package/dist/EndpointBuilder-CYkeYpsL.cjs.map +0 -1
- package/dist/EndpointBuilder-W5fdXxYQ.mjs.map +0 -1
- package/dist/EndpointFactory-B27nfeiE.mjs.map +0 -1
- package/dist/EndpointFactory-D5lFZXqY.cjs.map +0 -1
- package/dist/endpoints/Authorizer.cjs.map +0 -1
- package/dist/endpoints/Authorizer.mjs.map +0 -1
- package/dist/index-licEVXjh.d.mts +0 -10
- package/dist/processAudits-BFokHhCO.cjs.map +0 -1
- package/dist/processAudits-DfcB-X-4.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpMethod } from "./types-Bp9ysFXd.cjs";
|
|
2
|
-
import { Endpoint, EndpointSchemas } from "./Endpoint-
|
|
3
|
-
import { AmazonApiGatewayEndpoint, AmazonApiGatewayV2EndpointHandler, GetInputResponse, LoggerContext } from "./AmazonApiGatewayEndpointAdaptor-
|
|
2
|
+
import { Endpoint, EndpointSchemas } from "./Endpoint-BJPJTGjV.cjs";
|
|
3
|
+
import { AmazonApiGatewayEndpoint, AmazonApiGatewayV2EndpointHandler, GetInputResponse, LoggerContext } from "./AmazonApiGatewayEndpointAdaptor-TP_hLNAa.cjs";
|
|
4
4
|
import { EventPublisher } from "@geekmidas/events";
|
|
5
5
|
import { Logger } from "@geekmidas/logger";
|
|
6
6
|
import { Service } from "@geekmidas/services";
|
|
@@ -18,4 +18,4 @@ declare class AmazonApiGatewayV2Endpoint<TRoute extends string, TMethod extends
|
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
20
|
export { AmazonApiGatewayV2Endpoint };
|
|
21
|
-
//# sourceMappingURL=AmazonApiGatewayV2EndpointAdaptor-
|
|
21
|
+
//# sourceMappingURL=AmazonApiGatewayV2EndpointAdaptor-DurJvFwa.d.cts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/endpoints/Authorizer.ts
|
|
3
|
+
/**
|
|
4
|
+
* Built-in security schemes available by default.
|
|
5
|
+
* Users can use these without defining them via .securitySchemes().
|
|
6
|
+
*/
|
|
7
|
+
const BUILT_IN_SECURITY_SCHEMES = {
|
|
8
|
+
jwt: {
|
|
9
|
+
type: "http",
|
|
10
|
+
scheme: "bearer",
|
|
11
|
+
bearerFormat: "JWT",
|
|
12
|
+
description: "JWT Bearer token authentication"
|
|
13
|
+
},
|
|
14
|
+
bearer: {
|
|
15
|
+
type: "http",
|
|
16
|
+
scheme: "bearer",
|
|
17
|
+
description: "Bearer token authentication"
|
|
18
|
+
},
|
|
19
|
+
apiKey: {
|
|
20
|
+
type: "apiKey",
|
|
21
|
+
in: "header",
|
|
22
|
+
name: "X-API-Key",
|
|
23
|
+
description: "API key authentication via header"
|
|
24
|
+
},
|
|
25
|
+
oauth2: {
|
|
26
|
+
type: "oauth2",
|
|
27
|
+
flows: {},
|
|
28
|
+
description: "OAuth 2.0 authentication"
|
|
29
|
+
},
|
|
30
|
+
oidc: {
|
|
31
|
+
type: "openIdConnect",
|
|
32
|
+
openIdConnectUrl: "",
|
|
33
|
+
description: "OpenID Connect authentication"
|
|
34
|
+
},
|
|
35
|
+
iam: {
|
|
36
|
+
type: "apiKey",
|
|
37
|
+
in: "header",
|
|
38
|
+
name: "Authorization",
|
|
39
|
+
description: "AWS IAM Signature Version 4 authentication",
|
|
40
|
+
"x-amazon-apigateway-authtype": "awsSigv4"
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Helper to create an authorizer configuration
|
|
45
|
+
*/
|
|
46
|
+
function createAuthorizer(name, options) {
|
|
47
|
+
return {
|
|
48
|
+
name,
|
|
49
|
+
...options
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if a name is a built-in security scheme
|
|
54
|
+
*/
|
|
55
|
+
function isBuiltInSecurityScheme(name) {
|
|
56
|
+
return name in BUILT_IN_SECURITY_SCHEMES;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get a security scheme by name (built-in or custom)
|
|
60
|
+
*/
|
|
61
|
+
function getSecurityScheme(name, customSchemes) {
|
|
62
|
+
if (customSchemes && name in customSchemes) return customSchemes[name];
|
|
63
|
+
if (isBuiltInSecurityScheme(name)) return BUILT_IN_SECURITY_SCHEMES[name];
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
Object.defineProperty(exports, 'BUILT_IN_SECURITY_SCHEMES', {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () {
|
|
71
|
+
return BUILT_IN_SECURITY_SCHEMES;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, 'createAuthorizer', {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () {
|
|
77
|
+
return createAuthorizer;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, 'getSecurityScheme', {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () {
|
|
83
|
+
return getSecurityScheme;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(exports, 'isBuiltInSecurityScheme', {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () {
|
|
89
|
+
return isBuiltInSecurityScheme;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=Authorizer-C0ge_tc8.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authorizer-C0ge_tc8.cjs","names":["name: string","options?: Omit<Authorizer, 'name'>","customSchemes?: Record<string, SecurityScheme>"],"sources":["../src/endpoints/Authorizer.ts"],"sourcesContent":["/**\n * OpenAPI 3.1 compliant security scheme definition.\n * @see https://spec.openapis.org/oas/v3.1.0#security-scheme-object\n */\nexport interface SecurityScheme {\n /** The type of the security scheme */\n type: 'apiKey' | 'http' | 'mutualTLS' | 'oauth2' | 'openIdConnect';\n /** A description for security scheme */\n description?: string;\n /** Required for apiKey. The name of the header, query or cookie parameter */\n name?: string;\n /** Required for apiKey. The location of the API key */\n in?: 'query' | 'header' | 'cookie';\n /** Required for http. The name of the HTTP Authorization scheme (e.g., 'bearer') */\n scheme?: string;\n /** Optional for http bearer. A hint to the format of the bearer token */\n bearerFormat?: string;\n /** Required for oauth2. An object containing configuration for the flow types */\n flows?: OAuthFlows;\n /** Required for openIdConnect. The URL to discover OAuth2 configuration */\n openIdConnectUrl?: string;\n /** Vendor extensions (e.g., x-amazon-apigateway-authtype) */\n [key: `x-${string}`]: unknown;\n}\n\n/**\n * OAuth2 flow configuration\n */\nexport interface OAuthFlows {\n implicit?: OAuthFlow;\n password?: OAuthFlow;\n clientCredentials?: OAuthFlow;\n authorizationCode?: OAuthFlow;\n}\n\nexport interface OAuthFlow {\n authorizationUrl?: string;\n tokenUrl?: string;\n refreshUrl?: string;\n scopes: Record<string, string>;\n}\n\n/**\n * Built-in security schemes available by default.\n * Users can use these without defining them via .securitySchemes().\n */\nexport const BUILT_IN_SECURITY_SCHEMES = {\n jwt: {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n description: 'JWT Bearer token authentication',\n },\n bearer: {\n type: 'http',\n scheme: 'bearer',\n description: 'Bearer token authentication',\n },\n apiKey: {\n type: 'apiKey',\n in: 'header',\n name: 'X-API-Key',\n description: 'API key authentication via header',\n },\n oauth2: {\n type: 'oauth2',\n flows: {},\n description: 'OAuth 2.0 authentication',\n },\n oidc: {\n type: 'openIdConnect',\n openIdConnectUrl: '',\n description: 'OpenID Connect authentication',\n },\n iam: {\n type: 'apiKey',\n in: 'header',\n name: 'Authorization',\n description: 'AWS IAM Signature Version 4 authentication',\n 'x-amazon-apigateway-authtype': 'awsSigv4',\n },\n} as const satisfies Record<string, SecurityScheme>;\n\n/** Names of built-in security schemes */\nexport type BuiltInSecuritySchemeId = keyof typeof BUILT_IN_SECURITY_SCHEMES;\n\n/**\n * Represents an authorizer configuration for endpoints\n */\nexport interface Authorizer {\n /**\n * Unique identifier for the authorizer\n */\n name: string;\n /**\n * The OpenAPI security scheme definition for this authorizer\n */\n securityScheme?: SecurityScheme;\n /**\n * Type of authorizer (e.g., 'iam', 'jwt', 'custom')\n * @deprecated Use securityScheme.type instead\n */\n type?: string;\n /**\n * Description of what this authorizer does\n * @deprecated Use securityScheme.description instead\n */\n description?: string;\n /**\n * Additional metadata specific to the authorizer type\n * @deprecated Use securityScheme with x-* extensions instead\n */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Helper to create an authorizer configuration\n */\nexport function createAuthorizer(\n name: string,\n options?: Omit<Authorizer, 'name'>,\n): Authorizer {\n return {\n name,\n ...options,\n };\n}\n\n/**\n * Check if a name is a built-in security scheme\n */\nexport function isBuiltInSecurityScheme(\n name: string,\n): name is BuiltInSecuritySchemeId {\n return name in BUILT_IN_SECURITY_SCHEMES;\n}\n\n/**\n * Get a security scheme by name (built-in or custom)\n */\nexport function getSecurityScheme(\n name: string,\n customSchemes?: Record<string, SecurityScheme>,\n): SecurityScheme | undefined {\n if (customSchemes && name in customSchemes) {\n return customSchemes[name];\n }\n if (isBuiltInSecurityScheme(name)) {\n return BUILT_IN_SECURITY_SCHEMES[name];\n }\n return undefined;\n}\n"],"mappings":";;;;;;AA8CA,MAAa,4BAA4B;CACvC,KAAK;EACH,MAAM;EACN,QAAQ;EACR,cAAc;EACd,aAAa;CACd;CACD,QAAQ;EACN,MAAM;EACN,QAAQ;EACR,aAAa;CACd;CACD,QAAQ;EACN,MAAM;EACN,IAAI;EACJ,MAAM;EACN,aAAa;CACd;CACD,QAAQ;EACN,MAAM;EACN,OAAO,CAAE;EACT,aAAa;CACd;CACD,MAAM;EACJ,MAAM;EACN,kBAAkB;EAClB,aAAa;CACd;CACD,KAAK;EACH,MAAM;EACN,IAAI;EACJ,MAAM;EACN,aAAa;EACb,gCAAgC;CACjC;AACF;;;;AAqCD,SAAgB,iBACdA,MACAC,SACY;AACZ,QAAO;EACL;EACA,GAAG;CACJ;AACF;;;;AAKD,SAAgB,wBACdD,MACiC;AACjC,QAAO,QAAQ;AAChB;;;;AAKD,SAAgB,kBACdA,MACAE,eAC4B;AAC5B,KAAI,iBAAiB,QAAQ,cAC3B,QAAO,cAAc;AAEvB,KAAI,wBAAwB,KAAK,CAC/B,QAAO,0BAA0B;AAEnC;AACD"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
//#region src/endpoints/Authorizer.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* OpenAPI 3.1 compliant security scheme definition.
|
|
4
|
+
* @see https://spec.openapis.org/oas/v3.1.0#security-scheme-object
|
|
5
|
+
*/
|
|
6
|
+
interface SecurityScheme {
|
|
7
|
+
/** The type of the security scheme */
|
|
8
|
+
type: 'apiKey' | 'http' | 'mutualTLS' | 'oauth2' | 'openIdConnect';
|
|
9
|
+
/** A description for security scheme */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Required for apiKey. The name of the header, query or cookie parameter */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Required for apiKey. The location of the API key */
|
|
14
|
+
in?: 'query' | 'header' | 'cookie';
|
|
15
|
+
/** Required for http. The name of the HTTP Authorization scheme (e.g., 'bearer') */
|
|
16
|
+
scheme?: string;
|
|
17
|
+
/** Optional for http bearer. A hint to the format of the bearer token */
|
|
18
|
+
bearerFormat?: string;
|
|
19
|
+
/** Required for oauth2. An object containing configuration for the flow types */
|
|
20
|
+
flows?: OAuthFlows;
|
|
21
|
+
/** Required for openIdConnect. The URL to discover OAuth2 configuration */
|
|
22
|
+
openIdConnectUrl?: string;
|
|
23
|
+
/** Vendor extensions (e.g., x-amazon-apigateway-authtype) */
|
|
24
|
+
[key: `x-${string}`]: unknown;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* OAuth2 flow configuration
|
|
28
|
+
*/
|
|
29
|
+
interface OAuthFlows {
|
|
30
|
+
implicit?: OAuthFlow;
|
|
31
|
+
password?: OAuthFlow;
|
|
32
|
+
clientCredentials?: OAuthFlow;
|
|
33
|
+
authorizationCode?: OAuthFlow;
|
|
34
|
+
}
|
|
35
|
+
interface OAuthFlow {
|
|
36
|
+
authorizationUrl?: string;
|
|
37
|
+
tokenUrl?: string;
|
|
38
|
+
refreshUrl?: string;
|
|
39
|
+
scopes: Record<string, string>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Built-in security schemes available by default.
|
|
43
|
+
* Users can use these without defining them via .securitySchemes().
|
|
44
|
+
*/
|
|
45
|
+
declare const BUILT_IN_SECURITY_SCHEMES: {
|
|
46
|
+
readonly jwt: {
|
|
47
|
+
readonly type: "http";
|
|
48
|
+
readonly scheme: "bearer";
|
|
49
|
+
readonly bearerFormat: "JWT";
|
|
50
|
+
readonly description: "JWT Bearer token authentication";
|
|
51
|
+
};
|
|
52
|
+
readonly bearer: {
|
|
53
|
+
readonly type: "http";
|
|
54
|
+
readonly scheme: "bearer";
|
|
55
|
+
readonly description: "Bearer token authentication";
|
|
56
|
+
};
|
|
57
|
+
readonly apiKey: {
|
|
58
|
+
readonly type: "apiKey";
|
|
59
|
+
readonly in: "header";
|
|
60
|
+
readonly name: "X-API-Key";
|
|
61
|
+
readonly description: "API key authentication via header";
|
|
62
|
+
};
|
|
63
|
+
readonly oauth2: {
|
|
64
|
+
readonly type: "oauth2";
|
|
65
|
+
readonly flows: {};
|
|
66
|
+
readonly description: "OAuth 2.0 authentication";
|
|
67
|
+
};
|
|
68
|
+
readonly oidc: {
|
|
69
|
+
readonly type: "openIdConnect";
|
|
70
|
+
readonly openIdConnectUrl: "";
|
|
71
|
+
readonly description: "OpenID Connect authentication";
|
|
72
|
+
};
|
|
73
|
+
readonly iam: {
|
|
74
|
+
readonly type: "apiKey";
|
|
75
|
+
readonly in: "header";
|
|
76
|
+
readonly name: "Authorization";
|
|
77
|
+
readonly description: "AWS IAM Signature Version 4 authentication";
|
|
78
|
+
readonly 'x-amazon-apigateway-authtype': "awsSigv4";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
/** Names of built-in security schemes */
|
|
82
|
+
type BuiltInSecuritySchemeId = keyof typeof BUILT_IN_SECURITY_SCHEMES;
|
|
83
|
+
/**
|
|
84
|
+
* Represents an authorizer configuration for endpoints
|
|
85
|
+
*/
|
|
86
|
+
interface Authorizer {
|
|
87
|
+
/**
|
|
88
|
+
* Unique identifier for the authorizer
|
|
89
|
+
*/
|
|
90
|
+
name: string;
|
|
91
|
+
/**
|
|
92
|
+
* The OpenAPI security scheme definition for this authorizer
|
|
93
|
+
*/
|
|
94
|
+
securityScheme?: SecurityScheme;
|
|
95
|
+
/**
|
|
96
|
+
* Type of authorizer (e.g., 'iam', 'jwt', 'custom')
|
|
97
|
+
* @deprecated Use securityScheme.type instead
|
|
98
|
+
*/
|
|
99
|
+
type?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Description of what this authorizer does
|
|
102
|
+
* @deprecated Use securityScheme.description instead
|
|
103
|
+
*/
|
|
104
|
+
description?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Additional metadata specific to the authorizer type
|
|
107
|
+
* @deprecated Use securityScheme with x-* extensions instead
|
|
108
|
+
*/
|
|
109
|
+
metadata?: Record<string, unknown>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Helper to create an authorizer configuration
|
|
113
|
+
*/
|
|
114
|
+
declare function createAuthorizer(name: string, options?: Omit<Authorizer, 'name'>): Authorizer;
|
|
115
|
+
/**
|
|
116
|
+
* Check if a name is a built-in security scheme
|
|
117
|
+
*/
|
|
118
|
+
declare function isBuiltInSecurityScheme(name: string): name is BuiltInSecuritySchemeId;
|
|
119
|
+
/**
|
|
120
|
+
* Get a security scheme by name (built-in or custom)
|
|
121
|
+
*/
|
|
122
|
+
declare function getSecurityScheme(name: string, customSchemes?: Record<string, SecurityScheme>): SecurityScheme | undefined;
|
|
123
|
+
//#endregion
|
|
124
|
+
export { Authorizer, BUILT_IN_SECURITY_SCHEMES, BuiltInSecuritySchemeId, OAuthFlow, OAuthFlows, SecurityScheme, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme };
|
|
125
|
+
//# sourceMappingURL=Authorizer-CpSUMTIs.d.cts.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
//#region src/endpoints/Authorizer.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* OpenAPI 3.1 compliant security scheme definition.
|
|
4
|
+
* @see https://spec.openapis.org/oas/v3.1.0#security-scheme-object
|
|
5
|
+
*/
|
|
6
|
+
interface SecurityScheme {
|
|
7
|
+
/** The type of the security scheme */
|
|
8
|
+
type: 'apiKey' | 'http' | 'mutualTLS' | 'oauth2' | 'openIdConnect';
|
|
9
|
+
/** A description for security scheme */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Required for apiKey. The name of the header, query or cookie parameter */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Required for apiKey. The location of the API key */
|
|
14
|
+
in?: 'query' | 'header' | 'cookie';
|
|
15
|
+
/** Required for http. The name of the HTTP Authorization scheme (e.g., 'bearer') */
|
|
16
|
+
scheme?: string;
|
|
17
|
+
/** Optional for http bearer. A hint to the format of the bearer token */
|
|
18
|
+
bearerFormat?: string;
|
|
19
|
+
/** Required for oauth2. An object containing configuration for the flow types */
|
|
20
|
+
flows?: OAuthFlows;
|
|
21
|
+
/** Required for openIdConnect. The URL to discover OAuth2 configuration */
|
|
22
|
+
openIdConnectUrl?: string;
|
|
23
|
+
/** Vendor extensions (e.g., x-amazon-apigateway-authtype) */
|
|
24
|
+
[key: `x-${string}`]: unknown;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* OAuth2 flow configuration
|
|
28
|
+
*/
|
|
29
|
+
interface OAuthFlows {
|
|
30
|
+
implicit?: OAuthFlow;
|
|
31
|
+
password?: OAuthFlow;
|
|
32
|
+
clientCredentials?: OAuthFlow;
|
|
33
|
+
authorizationCode?: OAuthFlow;
|
|
34
|
+
}
|
|
35
|
+
interface OAuthFlow {
|
|
36
|
+
authorizationUrl?: string;
|
|
37
|
+
tokenUrl?: string;
|
|
38
|
+
refreshUrl?: string;
|
|
39
|
+
scopes: Record<string, string>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Built-in security schemes available by default.
|
|
43
|
+
* Users can use these without defining them via .securitySchemes().
|
|
44
|
+
*/
|
|
45
|
+
declare const BUILT_IN_SECURITY_SCHEMES: {
|
|
46
|
+
readonly jwt: {
|
|
47
|
+
readonly type: "http";
|
|
48
|
+
readonly scheme: "bearer";
|
|
49
|
+
readonly bearerFormat: "JWT";
|
|
50
|
+
readonly description: "JWT Bearer token authentication";
|
|
51
|
+
};
|
|
52
|
+
readonly bearer: {
|
|
53
|
+
readonly type: "http";
|
|
54
|
+
readonly scheme: "bearer";
|
|
55
|
+
readonly description: "Bearer token authentication";
|
|
56
|
+
};
|
|
57
|
+
readonly apiKey: {
|
|
58
|
+
readonly type: "apiKey";
|
|
59
|
+
readonly in: "header";
|
|
60
|
+
readonly name: "X-API-Key";
|
|
61
|
+
readonly description: "API key authentication via header";
|
|
62
|
+
};
|
|
63
|
+
readonly oauth2: {
|
|
64
|
+
readonly type: "oauth2";
|
|
65
|
+
readonly flows: {};
|
|
66
|
+
readonly description: "OAuth 2.0 authentication";
|
|
67
|
+
};
|
|
68
|
+
readonly oidc: {
|
|
69
|
+
readonly type: "openIdConnect";
|
|
70
|
+
readonly openIdConnectUrl: "";
|
|
71
|
+
readonly description: "OpenID Connect authentication";
|
|
72
|
+
};
|
|
73
|
+
readonly iam: {
|
|
74
|
+
readonly type: "apiKey";
|
|
75
|
+
readonly in: "header";
|
|
76
|
+
readonly name: "Authorization";
|
|
77
|
+
readonly description: "AWS IAM Signature Version 4 authentication";
|
|
78
|
+
readonly 'x-amazon-apigateway-authtype': "awsSigv4";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
/** Names of built-in security schemes */
|
|
82
|
+
type BuiltInSecuritySchemeId = keyof typeof BUILT_IN_SECURITY_SCHEMES;
|
|
83
|
+
/**
|
|
84
|
+
* Represents an authorizer configuration for endpoints
|
|
85
|
+
*/
|
|
86
|
+
interface Authorizer {
|
|
87
|
+
/**
|
|
88
|
+
* Unique identifier for the authorizer
|
|
89
|
+
*/
|
|
90
|
+
name: string;
|
|
91
|
+
/**
|
|
92
|
+
* The OpenAPI security scheme definition for this authorizer
|
|
93
|
+
*/
|
|
94
|
+
securityScheme?: SecurityScheme;
|
|
95
|
+
/**
|
|
96
|
+
* Type of authorizer (e.g., 'iam', 'jwt', 'custom')
|
|
97
|
+
* @deprecated Use securityScheme.type instead
|
|
98
|
+
*/
|
|
99
|
+
type?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Description of what this authorizer does
|
|
102
|
+
* @deprecated Use securityScheme.description instead
|
|
103
|
+
*/
|
|
104
|
+
description?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Additional metadata specific to the authorizer type
|
|
107
|
+
* @deprecated Use securityScheme with x-* extensions instead
|
|
108
|
+
*/
|
|
109
|
+
metadata?: Record<string, unknown>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Helper to create an authorizer configuration
|
|
113
|
+
*/
|
|
114
|
+
declare function createAuthorizer(name: string, options?: Omit<Authorizer, 'name'>): Authorizer;
|
|
115
|
+
/**
|
|
116
|
+
* Check if a name is a built-in security scheme
|
|
117
|
+
*/
|
|
118
|
+
declare function isBuiltInSecurityScheme(name: string): name is BuiltInSecuritySchemeId;
|
|
119
|
+
/**
|
|
120
|
+
* Get a security scheme by name (built-in or custom)
|
|
121
|
+
*/
|
|
122
|
+
declare function getSecurityScheme(name: string, customSchemes?: Record<string, SecurityScheme>): SecurityScheme | undefined;
|
|
123
|
+
//#endregion
|
|
124
|
+
export { Authorizer, BUILT_IN_SECURITY_SCHEMES, BuiltInSecuritySchemeId, OAuthFlow, OAuthFlows, SecurityScheme, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme };
|
|
125
|
+
//# sourceMappingURL=Authorizer-D1w7MpK6.d.mts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/endpoints/Authorizer.ts
|
|
2
|
+
/**
|
|
3
|
+
* Built-in security schemes available by default.
|
|
4
|
+
* Users can use these without defining them via .securitySchemes().
|
|
5
|
+
*/
|
|
6
|
+
const BUILT_IN_SECURITY_SCHEMES = {
|
|
7
|
+
jwt: {
|
|
8
|
+
type: "http",
|
|
9
|
+
scheme: "bearer",
|
|
10
|
+
bearerFormat: "JWT",
|
|
11
|
+
description: "JWT Bearer token authentication"
|
|
12
|
+
},
|
|
13
|
+
bearer: {
|
|
14
|
+
type: "http",
|
|
15
|
+
scheme: "bearer",
|
|
16
|
+
description: "Bearer token authentication"
|
|
17
|
+
},
|
|
18
|
+
apiKey: {
|
|
19
|
+
type: "apiKey",
|
|
20
|
+
in: "header",
|
|
21
|
+
name: "X-API-Key",
|
|
22
|
+
description: "API key authentication via header"
|
|
23
|
+
},
|
|
24
|
+
oauth2: {
|
|
25
|
+
type: "oauth2",
|
|
26
|
+
flows: {},
|
|
27
|
+
description: "OAuth 2.0 authentication"
|
|
28
|
+
},
|
|
29
|
+
oidc: {
|
|
30
|
+
type: "openIdConnect",
|
|
31
|
+
openIdConnectUrl: "",
|
|
32
|
+
description: "OpenID Connect authentication"
|
|
33
|
+
},
|
|
34
|
+
iam: {
|
|
35
|
+
type: "apiKey",
|
|
36
|
+
in: "header",
|
|
37
|
+
name: "Authorization",
|
|
38
|
+
description: "AWS IAM Signature Version 4 authentication",
|
|
39
|
+
"x-amazon-apigateway-authtype": "awsSigv4"
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Helper to create an authorizer configuration
|
|
44
|
+
*/
|
|
45
|
+
function createAuthorizer(name, options) {
|
|
46
|
+
return {
|
|
47
|
+
name,
|
|
48
|
+
...options
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if a name is a built-in security scheme
|
|
53
|
+
*/
|
|
54
|
+
function isBuiltInSecurityScheme(name) {
|
|
55
|
+
return name in BUILT_IN_SECURITY_SCHEMES;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get a security scheme by name (built-in or custom)
|
|
59
|
+
*/
|
|
60
|
+
function getSecurityScheme(name, customSchemes) {
|
|
61
|
+
if (customSchemes && name in customSchemes) return customSchemes[name];
|
|
62
|
+
if (isBuiltInSecurityScheme(name)) return BUILT_IN_SECURITY_SCHEMES[name];
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { BUILT_IN_SECURITY_SCHEMES, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme };
|
|
68
|
+
//# sourceMappingURL=Authorizer-r9U3y_ms.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authorizer-r9U3y_ms.mjs","names":["name: string","options?: Omit<Authorizer, 'name'>","customSchemes?: Record<string, SecurityScheme>"],"sources":["../src/endpoints/Authorizer.ts"],"sourcesContent":["/**\n * OpenAPI 3.1 compliant security scheme definition.\n * @see https://spec.openapis.org/oas/v3.1.0#security-scheme-object\n */\nexport interface SecurityScheme {\n /** The type of the security scheme */\n type: 'apiKey' | 'http' | 'mutualTLS' | 'oauth2' | 'openIdConnect';\n /** A description for security scheme */\n description?: string;\n /** Required for apiKey. The name of the header, query or cookie parameter */\n name?: string;\n /** Required for apiKey. The location of the API key */\n in?: 'query' | 'header' | 'cookie';\n /** Required for http. The name of the HTTP Authorization scheme (e.g., 'bearer') */\n scheme?: string;\n /** Optional for http bearer. A hint to the format of the bearer token */\n bearerFormat?: string;\n /** Required for oauth2. An object containing configuration for the flow types */\n flows?: OAuthFlows;\n /** Required for openIdConnect. The URL to discover OAuth2 configuration */\n openIdConnectUrl?: string;\n /** Vendor extensions (e.g., x-amazon-apigateway-authtype) */\n [key: `x-${string}`]: unknown;\n}\n\n/**\n * OAuth2 flow configuration\n */\nexport interface OAuthFlows {\n implicit?: OAuthFlow;\n password?: OAuthFlow;\n clientCredentials?: OAuthFlow;\n authorizationCode?: OAuthFlow;\n}\n\nexport interface OAuthFlow {\n authorizationUrl?: string;\n tokenUrl?: string;\n refreshUrl?: string;\n scopes: Record<string, string>;\n}\n\n/**\n * Built-in security schemes available by default.\n * Users can use these without defining them via .securitySchemes().\n */\nexport const BUILT_IN_SECURITY_SCHEMES = {\n jwt: {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n description: 'JWT Bearer token authentication',\n },\n bearer: {\n type: 'http',\n scheme: 'bearer',\n description: 'Bearer token authentication',\n },\n apiKey: {\n type: 'apiKey',\n in: 'header',\n name: 'X-API-Key',\n description: 'API key authentication via header',\n },\n oauth2: {\n type: 'oauth2',\n flows: {},\n description: 'OAuth 2.0 authentication',\n },\n oidc: {\n type: 'openIdConnect',\n openIdConnectUrl: '',\n description: 'OpenID Connect authentication',\n },\n iam: {\n type: 'apiKey',\n in: 'header',\n name: 'Authorization',\n description: 'AWS IAM Signature Version 4 authentication',\n 'x-amazon-apigateway-authtype': 'awsSigv4',\n },\n} as const satisfies Record<string, SecurityScheme>;\n\n/** Names of built-in security schemes */\nexport type BuiltInSecuritySchemeId = keyof typeof BUILT_IN_SECURITY_SCHEMES;\n\n/**\n * Represents an authorizer configuration for endpoints\n */\nexport interface Authorizer {\n /**\n * Unique identifier for the authorizer\n */\n name: string;\n /**\n * The OpenAPI security scheme definition for this authorizer\n */\n securityScheme?: SecurityScheme;\n /**\n * Type of authorizer (e.g., 'iam', 'jwt', 'custom')\n * @deprecated Use securityScheme.type instead\n */\n type?: string;\n /**\n * Description of what this authorizer does\n * @deprecated Use securityScheme.description instead\n */\n description?: string;\n /**\n * Additional metadata specific to the authorizer type\n * @deprecated Use securityScheme with x-* extensions instead\n */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Helper to create an authorizer configuration\n */\nexport function createAuthorizer(\n name: string,\n options?: Omit<Authorizer, 'name'>,\n): Authorizer {\n return {\n name,\n ...options,\n };\n}\n\n/**\n * Check if a name is a built-in security scheme\n */\nexport function isBuiltInSecurityScheme(\n name: string,\n): name is BuiltInSecuritySchemeId {\n return name in BUILT_IN_SECURITY_SCHEMES;\n}\n\n/**\n * Get a security scheme by name (built-in or custom)\n */\nexport function getSecurityScheme(\n name: string,\n customSchemes?: Record<string, SecurityScheme>,\n): SecurityScheme | undefined {\n if (customSchemes && name in customSchemes) {\n return customSchemes[name];\n }\n if (isBuiltInSecurityScheme(name)) {\n return BUILT_IN_SECURITY_SCHEMES[name];\n }\n return undefined;\n}\n"],"mappings":";;;;;AA8CA,MAAa,4BAA4B;CACvC,KAAK;EACH,MAAM;EACN,QAAQ;EACR,cAAc;EACd,aAAa;CACd;CACD,QAAQ;EACN,MAAM;EACN,QAAQ;EACR,aAAa;CACd;CACD,QAAQ;EACN,MAAM;EACN,IAAI;EACJ,MAAM;EACN,aAAa;CACd;CACD,QAAQ;EACN,MAAM;EACN,OAAO,CAAE;EACT,aAAa;CACd;CACD,MAAM;EACJ,MAAM;EACN,kBAAkB;EAClB,aAAa;CACd;CACD,KAAK;EACH,MAAM;EACN,IAAI;EACJ,MAAM;EACN,aAAa;EACb,gCAAgC;CACjC;AACF;;;;AAqCD,SAAgB,iBACdA,MACAC,SACY;AACZ,QAAO;EACL;EACA,GAAG;CACJ;AACF;;;;AAKD,SAAgB,wBACdD,MACiC;AACjC,QAAO,QAAQ;AAChB;;;;AAKD,SAAgB,kBACdA,MACAE,eAC4B;AAC5B,KAAI,iBAAiB,QAAQ,cAC3B,QAAO,cAAc;AAEvB,KAAI,wBAAwB,KAAK,CAC/B,QAAO,0BAA0B;AAEnC;AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConstructType } from "./Construct-
|
|
1
|
+
import { ConstructType } from "./Construct-DCPATqec.mjs";
|
|
2
2
|
import { Service } from "@geekmidas/services";
|
|
3
3
|
import { AuditStorage } from "@geekmidas/audit";
|
|
4
4
|
import { EventPublisher, MappedEvent } from "@geekmidas/events";
|
|
@@ -37,4 +37,4 @@ declare abstract class BaseFunctionBuilder<TInput extends ComposableStandardSche
|
|
|
37
37
|
}
|
|
38
38
|
//#endregion
|
|
39
39
|
export { BaseFunctionBuilder };
|
|
40
|
-
//# sourceMappingURL=BaseFunctionBuilder-
|
|
40
|
+
//# sourceMappingURL=BaseFunctionBuilder-Oc2xmxmg.d.mts.map
|
package/dist/Construct.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Construct, ConstructType } from "./Construct-
|
|
1
|
+
import { Construct, ConstructType } from "./Construct-DCPATqec.mjs";
|
|
2
2
|
export { Construct, ConstructType };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Function, FunctionHandler } from "./Function-
|
|
1
|
+
import { Function, FunctionHandler } from "./Function-Dthlh2Fb.mjs";
|
|
2
2
|
import { Service } from "@geekmidas/services";
|
|
3
3
|
import { AuditableAction } from "@geekmidas/audit";
|
|
4
4
|
import { EventPublisher } from "@geekmidas/events";
|
|
@@ -23,4 +23,4 @@ type CronExpression = `cron(${CronMinute} ${CronHour} ${CronDay} ${CronMonth} ${
|
|
|
23
23
|
type ScheduleExpression = RateExpression | CronExpression;
|
|
24
24
|
//#endregion
|
|
25
25
|
export { Cron, CronExpression, RateExpression, ScheduleExpression };
|
|
26
|
-
//# sourceMappingURL=Cron-
|
|
26
|
+
//# sourceMappingURL=Cron-DPEcDCDW.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionHandler } from "./Function-
|
|
2
|
-
import { FunctionBuilder } from "./FunctionBuilder-
|
|
3
|
-
import { Cron, ScheduleExpression } from "./Cron-
|
|
1
|
+
import { FunctionHandler } from "./Function-Dthlh2Fb.mjs";
|
|
2
|
+
import { FunctionBuilder } from "./FunctionBuilder-CZFBLfdV.mjs";
|
|
3
|
+
import { Cron, ScheduleExpression } from "./Cron-DPEcDCDW.mjs";
|
|
4
4
|
import { Service } from "@geekmidas/services";
|
|
5
5
|
import { EventPublisher } from "@geekmidas/events";
|
|
6
6
|
import { Logger } from "@geekmidas/logger";
|
|
@@ -27,4 +27,4 @@ declare class CronBuilder<TInput extends ComposableStandardSchema, TServices ext
|
|
|
27
27
|
}
|
|
28
28
|
//#endregion
|
|
29
29
|
export { CronBuilder };
|
|
30
|
-
//# sourceMappingURL=CronBuilder-
|
|
30
|
+
//# sourceMappingURL=CronBuilder-CxKTiepV.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-Bp9ysFXd.cjs";
|
|
2
2
|
import { Function, FunctionHandler } from "./Function-DHD1V9QW.cjs";
|
|
3
|
-
import { Authorizer } from "./Authorizer-
|
|
3
|
+
import { Authorizer } from "./Authorizer-CpSUMTIs.cjs";
|
|
4
4
|
import { AuditActor, AuditStorage, AuditableAction, Auditor, ExtractAuditPayload, ExtractAuditType } from "@geekmidas/audit";
|
|
5
5
|
import { EventPublisher, ExtractPublisherMessage, MappedEvent } from "@geekmidas/events";
|
|
6
6
|
import { Logger } from "@geekmidas/logger";
|
|
@@ -664,4 +664,4 @@ type EndpointOutput<T> = T extends Endpoint<any, any, any, infer OutSchema, any,
|
|
|
664
664
|
type EndpointEvent<T> = T extends Endpoint<any, any, any, any, any, any, any, infer TEventPublisher> ? ExtractPublisherMessage<TEventPublisher> : never;
|
|
665
665
|
//#endregion
|
|
666
666
|
export { ActorExtractor, AuthorizeContext, AuthorizeFn, ConvertRouteParams, CookieFn, CookieOptions, Endpoint, EndpointAuditorConfig, EndpointContext, EndpointEvent, EndpointHandler, EndpointHeaders, EndpointInput, EndpointOpenApiSchema, EndpointOptions, EndpointOutput, EndpointSchemas, HeaderFn, MappedAudit, MultiHeaderFn, ResponseBuilder, ResponseMetadata, ResponseWithMetadata, SessionContext, SessionFn, SingleHeaderFn, SuccessStatus };
|
|
667
|
-
//# sourceMappingURL=Endpoint-
|
|
667
|
+
//# sourceMappingURL=Endpoint-BJPJTGjV.d.cts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-
|
|
2
|
-
import { Function, FunctionHandler } from "./Function-
|
|
3
|
-
import { Authorizer } from "./Authorizer-
|
|
1
|
+
import { HttpMethod, LowerHttpMethod, RemoveUndefined } from "./types-Cy1IhmUB.mjs";
|
|
2
|
+
import { Function, FunctionHandler } from "./Function-Dthlh2Fb.mjs";
|
|
3
|
+
import { Authorizer } from "./Authorizer-D1w7MpK6.mjs";
|
|
4
4
|
import { ComponentCollector, OpenApiSchemaOptions } from "@geekmidas/schema/openapi";
|
|
5
5
|
import { Service, ServiceRecord } from "@geekmidas/services";
|
|
6
6
|
import { AuditActor, AuditStorage, AuditableAction, Auditor, ExtractAuditPayload, ExtractAuditType } from "@geekmidas/audit";
|
|
@@ -664,4 +664,4 @@ type EndpointOutput<T> = T extends Endpoint<any, any, any, infer OutSchema, any,
|
|
|
664
664
|
type EndpointEvent<T> = T extends Endpoint<any, any, any, any, any, any, any, infer TEventPublisher> ? ExtractPublisherMessage<TEventPublisher> : never;
|
|
665
665
|
//#endregion
|
|
666
666
|
export { ActorExtractor, AuthorizeContext, AuthorizeFn, ConvertRouteParams, CookieFn, CookieOptions, Endpoint, EndpointAuditorConfig, EndpointContext, EndpointEvent, EndpointHandler, EndpointHeaders, EndpointInput, EndpointOpenApiSchema, EndpointOptions, EndpointOutput, EndpointSchemas, HeaderFn, MappedAudit, MultiHeaderFn, ResponseBuilder, ResponseMetadata, ResponseWithMetadata, SessionContext, SessionFn, SingleHeaderFn, SuccessStatus };
|
|
667
|
-
//# sourceMappingURL=Endpoint-
|
|
667
|
+
//# sourceMappingURL=Endpoint-DoY1Owv2.d.mts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConstructType } from "./Construct-LWeB1rSQ.mjs";
|
|
2
2
|
import { BaseFunctionBuilder } from "./BaseFunctionBuilder-B5gkW0Kt.mjs";
|
|
3
3
|
import { Endpoint } from "./Endpoint-DbPsw13b.mjs";
|
|
4
|
+
import { getSecurityScheme } from "./Authorizer-r9U3y_ms.mjs";
|
|
4
5
|
import uniqBy from "lodash.uniqby";
|
|
5
6
|
|
|
6
7
|
//#region src/endpoints/EndpointBuilder.ts
|
|
@@ -17,6 +18,7 @@ var EndpointBuilder = class extends BaseFunctionBuilder {
|
|
|
17
18
|
_authorizerName;
|
|
18
19
|
_actorExtractor;
|
|
19
20
|
_audits = [];
|
|
21
|
+
_customSecuritySchemes = {};
|
|
20
22
|
constructor(route, method) {
|
|
21
23
|
super(ConstructType.Endpoint);
|
|
22
24
|
this.route = route;
|
|
@@ -160,7 +162,18 @@ var EndpointBuilder = class extends BaseFunctionBuilder {
|
|
|
160
162
|
throw new Error("EndpointBuilder does not support generic input. Use body(), query(), or params() instead.");
|
|
161
163
|
}
|
|
162
164
|
handle(fn) {
|
|
163
|
-
|
|
165
|
+
let authorizer;
|
|
166
|
+
if (this._authorizerName) {
|
|
167
|
+
const existingAuthorizer = this._availableAuthorizers.find((a) => a.name === this._authorizerName);
|
|
168
|
+
if (existingAuthorizer) authorizer = existingAuthorizer;
|
|
169
|
+
else {
|
|
170
|
+
const securityScheme = getSecurityScheme(this._authorizerName, this._customSecuritySchemes);
|
|
171
|
+
authorizer = {
|
|
172
|
+
name: this._authorizerName,
|
|
173
|
+
securityScheme
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
164
177
|
return new Endpoint({
|
|
165
178
|
fn,
|
|
166
179
|
method: this.method,
|
|
@@ -190,4 +203,4 @@ var EndpointBuilder = class extends BaseFunctionBuilder {
|
|
|
190
203
|
|
|
191
204
|
//#endregion
|
|
192
205
|
export { EndpointBuilder };
|
|
193
|
-
//# sourceMappingURL=EndpointBuilder-
|
|
206
|
+
//# sourceMappingURL=EndpointBuilder-69uVrKZL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointBuilder-69uVrKZL.mjs","names":["route: TRoute","method: TMethod","publisher: Service<TEventPublisherServiceName, TEventPublisher>","storage: Service<TAuditStorageServiceName, TAuditStorage>","service: Service<TDatabaseServiceName, TDatabase>","description: string","status: SuccessStatus","event: TEvent","tags: string[]","memorySize: number","publisher: Service<TName, T>","schema: T","config: RateLimitConfig","name: TAuthorizers[number] | 'none'","services: T","logger: T","storage: Service<TName, T>","extractor: ActorExtractor<TServices, TSession, TLogger>","audits: MappedAudit<TAuditAction, OutSchema>[]","service: Service<TName, T>","_schema: any","fn: EndpointHandler<\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TDatabase,\n TAuditStorage,\n TAuditAction\n >","authorizer: Authorizer | undefined"],"sources":["../src/endpoints/EndpointBuilder.ts"],"sourcesContent":["import type {\n AuditStorage,\n AuditableAction,\n ExtractStorageAuditAction,\n} from '@geekmidas/audit';\nimport type { EventPublisher, MappedEvent } from '@geekmidas/events';\nimport type { Logger } from '@geekmidas/logger';\nimport type { RateLimitConfig } from '@geekmidas/rate-limit';\nimport type { Service } from '@geekmidas/services';\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\nimport uniqBy from 'lodash.uniqby';\nimport { ConstructType } from '../Construct';\nimport { BaseFunctionBuilder } from '../functions';\nimport type { HttpMethod } from '../types';\nimport type { Authorizer, SecurityScheme } from './Authorizer';\nimport { getSecurityScheme } from './Authorizer';\nimport { Endpoint, type EndpointSchemas } from './Endpoint';\nimport type {\n AuthorizeFn,\n EndpointHandler,\n SessionFn,\n SuccessStatus,\n} from './Endpoint';\nimport type { ActorExtractor, MappedAudit } from './audit';\n\nexport class EndpointBuilder<\n TRoute extends string,\n TMethod extends HttpMethod,\n TInput extends EndpointSchemas = {},\n TServices extends Service[] = [],\n TLogger extends Logger = Logger,\n OutSchema extends StandardSchemaV1 | undefined = undefined,\n TSession = unknown,\n TEventPublisher extends EventPublisher<any> | undefined = undefined,\n TEventPublisherServiceName extends string = string,\n TAuthorizers extends readonly string[] = readonly string[],\n TAuditStorage extends AuditStorage | undefined = undefined,\n TAuditStorageServiceName extends string = string,\n TAuditAction extends AuditableAction<string, unknown> = AuditableAction<\n string,\n unknown\n >,\n TDatabase = undefined,\n TDatabaseServiceName extends string = string,\n> extends BaseFunctionBuilder<\n TInput,\n OutSchema,\n TServices,\n TLogger,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuditStorage,\n TAuditStorageServiceName,\n TDatabase,\n TDatabaseServiceName\n> {\n protected schemas: TInput = {} as TInput;\n protected _description?: string;\n protected _status?: SuccessStatus;\n protected _tags?: string[];\n protected _memorySize?: number;\n _getSession: SessionFn<TServices, TLogger, TSession, TDatabase> = () =>\n ({}) as TSession;\n _authorize: AuthorizeFn<TServices, TLogger, TSession> = () => true;\n _rateLimit?: RateLimitConfig;\n _availableAuthorizers: Authorizer[] = [];\n _authorizerName?: TAuthorizers[number];\n _actorExtractor?: ActorExtractor<TServices, TSession, TLogger>;\n _audits: MappedAudit<TAuditAction, OutSchema>[] = [];\n _customSecuritySchemes: Record<string, SecurityScheme> = {};\n\n constructor(\n readonly route: TRoute,\n readonly method: TMethod,\n ) {\n super(ConstructType.Endpoint);\n }\n\n // Internal setter for EndpointFactory to set default publisher\n _setPublisher(\n publisher: Service<TEventPublisherServiceName, TEventPublisher>,\n ) {\n this._publisher = publisher;\n }\n\n // Internal setter for EndpointFactory to set default auditor storage\n _setAuditorStorage(\n storage: Service<TAuditStorageServiceName, TAuditStorage>,\n ) {\n this._auditorStorage = storage;\n }\n\n // Internal setter for EndpointFactory to set default database service\n _setDatabaseService(service: Service<TDatabaseServiceName, TDatabase>) {\n this._databaseService = service;\n }\n\n description(description: string): this {\n this._description = description;\n return this;\n }\n\n status(status: SuccessStatus): this {\n this._status = status;\n return this;\n }\n\n event<TEvent extends MappedEvent<TEventPublisher, OutSchema>>(\n event: TEvent,\n ): this {\n this._events.push(event);\n return this;\n }\n\n tags(tags: string[]): this {\n this._tags = tags;\n return this;\n }\n\n memorySize(memorySize: number): this {\n this._memorySize = memorySize;\n return this;\n }\n\n publisher<T extends EventPublisher<any>, TName extends string>(\n publisher: Service<TName, T>,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n T,\n TName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n this._publisher = publisher as unknown as Service<\n TEventPublisherServiceName,\n TEventPublisher\n >;\n\n return this as unknown as EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n T,\n TName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n >;\n }\n\n body<T extends StandardSchemaV1>(\n schema: T,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n Omit<TInput, 'body'> & { body: T },\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n this.schemas.body = schema as unknown as T;\n // @ts-ignore\n return this;\n }\n\n search<T extends StandardSchemaV1>(\n schema: T,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n Omit<TInput, 'query'> & { query: T },\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n this.schemas.query = schema as unknown as T;\n // @ts-ignore\n return this;\n }\n\n query<T extends StandardSchemaV1>(\n schema: T,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n Omit<TInput, 'query'> & { query: T },\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n return this.search(schema);\n }\n\n params<T extends StandardSchemaV1>(\n schema: T,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n Omit<TInput, 'params'> & { params: T },\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n this.schemas.params = schema as unknown as T;\n // @ts-ignore\n return this;\n }\n\n rateLimit(config: RateLimitConfig): this {\n this._rateLimit = config;\n return this;\n }\n\n authorizer(\n name: TAuthorizers[number] | 'none',\n ): EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n // Special case: 'none' explicitly marks endpoint as having no authorizer\n if (name === 'none') {\n this._authorizerName = undefined;\n return this;\n }\n\n // Validate that the authorizer exists in available authorizers\n const authorizerExists = this._availableAuthorizers.some(\n (a) => a.name === name,\n );\n if (!authorizerExists && this._availableAuthorizers.length > 0) {\n const available = this._availableAuthorizers\n .map((a) => a.name)\n .join(', ');\n throw new Error(\n `Authorizer \"${name as string}\" not found in available authorizers: ${available}`,\n );\n }\n this._authorizerName = name;\n return this;\n }\n\n services<T extends Service[]>(\n services: T,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n [...TServices, ...T],\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n this._services = uniqBy(\n [...this._services, ...services],\n (s) => s.serviceName,\n ) as TServices;\n\n return this as unknown as EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n [...TServices, ...T],\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n >;\n }\n\n logger<T extends Logger>(\n logger: T,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n T,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n this._logger = logger as unknown as TLogger;\n\n return this as unknown as EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n T,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n >;\n }\n\n output<T extends StandardSchemaV1>(\n schema: T,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n T,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n this.outputSchema = schema as unknown as OutSchema;\n\n return this as unknown as EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n T,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n >;\n }\n\n /**\n * Set the auditor storage service for this endpoint.\n * This enables audit functionality and makes `auditor` available in the handler context.\n * The audit action type is automatically inferred from the storage's generic parameter.\n */\n auditor<T extends AuditStorage<any>, TName extends string>(\n storage: Service<TName, T>,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n T,\n TName,\n ExtractStorageAuditAction<T>,\n TDatabase,\n TDatabaseServiceName\n > {\n this._auditorStorage = storage as unknown as Service<\n TAuditStorageServiceName,\n TAuditStorage\n >;\n\n return this as unknown as EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n T,\n TName,\n ExtractStorageAuditAction<T>,\n TDatabase,\n TDatabaseServiceName\n >;\n }\n\n /**\n * Set the actor extractor function for audit records.\n * The actor is extracted from the request context and attached to all audits.\n */\n actor(\n extractor: ActorExtractor<TServices, TSession, TLogger>,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n this._actorExtractor = extractor;\n return this;\n }\n\n /**\n * Add declarative audit definitions that are processed after the handler executes.\n * Similar to `.event()` for events, but for audits.\n *\n * @example\n * ```typescript\n * .audit<AppAuditAction>([\n * {\n * type: 'user.created',\n * payload: (response) => ({ userId: response.id, email: response.email }),\n * when: (response) => response.active,\n * entityId: (response) => response.id,\n * table: 'users',\n * },\n * ])\n * ```\n */\n audit(audits: MappedAudit<TAuditAction, OutSchema>[]): this {\n this._audits = audits;\n return this;\n }\n\n /**\n * Set the database service for this endpoint.\n * The database will be available in the handler context as `db`.\n * When audit storage is configured and uses the same database,\n * `db` will automatically be the transaction for ACID compliance.\n *\n * @example\n * ```typescript\n * .database(databaseService)\n * .handle(async ({ db }) => {\n * // db is the raw database or transaction (when auditor uses same db)\n * return await db.selectFrom('users').selectAll().execute();\n * })\n * ```\n */\n database<T, TName extends string>(\n service: Service<TName, T>,\n ): EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n T,\n TName\n > {\n this._databaseService = service as unknown as Service<\n TDatabaseServiceName,\n TDatabase\n >;\n\n return this as unknown as EndpointBuilder<\n TRoute,\n TMethod,\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuthorizers,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n T,\n TName\n >;\n }\n\n // EndpointBuilder doesn't have a generic input method - it uses body, query, params instead\n input(_schema: any): any {\n throw new Error(\n 'EndpointBuilder does not support generic input. Use body(), query(), or params() instead.',\n );\n }\n\n handle(\n fn: EndpointHandler<\n TInput,\n TServices,\n TLogger,\n OutSchema,\n TSession,\n TDatabase,\n TAuditStorage,\n TAuditAction\n >,\n ): Endpoint<\n TRoute,\n TMethod,\n TInput,\n OutSchema,\n TServices,\n TLogger,\n TSession,\n TEventPublisher,\n TEventPublisherServiceName,\n TAuditStorage,\n TAuditStorageServiceName,\n TAuditAction,\n TDatabase,\n TDatabaseServiceName\n > {\n // Find authorizer metadata if name is set\n // If the authorizer name is set but not in availableAuthorizers, create a simple authorizer object\n let authorizer: Authorizer | undefined;\n if (this._authorizerName) {\n const existingAuthorizer = this._availableAuthorizers.find(\n (a) => a.name === this._authorizerName,\n );\n\n if (existingAuthorizer) {\n authorizer = existingAuthorizer;\n } else {\n // Create authorizer with security scheme if available (built-in or custom)\n const securityScheme = getSecurityScheme(\n this._authorizerName as string,\n this._customSecuritySchemes,\n );\n authorizer = {\n name: this._authorizerName as string,\n securityScheme,\n };\n }\n }\n\n return new Endpoint({\n fn,\n method: this.method,\n route: this.route,\n description: this._description,\n tags: this._tags,\n input: this.schemas,\n output: this.outputSchema,\n services: this._services,\n logger: this._logger,\n timeout: this._timeout,\n memorySize: this._memorySize,\n authorize: this._authorize,\n status: this._status,\n getSession: this._getSession,\n rateLimit: this._rateLimit,\n publisherService: this._publisher,\n events: this._events,\n authorizer,\n auditorStorageService: this._auditorStorage,\n actorExtractor: this._actorExtractor,\n audits: this._audits,\n databaseService: this._databaseService,\n });\n }\n}\n"],"mappings":";;;;;;;AAyBA,IAAa,kBAAb,cAmBU,oBAWR;CACA,AAAU,UAAkB,CAAE;CAC9B,AAAU;CACV,AAAU;CACV,AAAU;CACV,AAAU;CACV,cAAkE,OAC/D,CAAE;CACL,aAAwD,MAAM;CAC9D;CACA,wBAAsC,CAAE;CACxC;CACA;CACA,UAAkD,CAAE;CACpD,yBAAyD,CAAE;CAE3D,YACWA,OACAC,QACT;AACA,QAAM,cAAc,SAAS;EAHpB;EACA;CAGV;CAGD,cACEC,WACA;AACA,OAAK,aAAa;CACnB;CAGD,mBACEC,SACA;AACA,OAAK,kBAAkB;CACxB;CAGD,oBAAoBC,SAAmD;AACrE,OAAK,mBAAmB;CACzB;CAED,YAAYC,aAA2B;AACrC,OAAK,eAAe;AACpB,SAAO;CACR;CAED,OAAOC,QAA6B;AAClC,OAAK,UAAU;AACf,SAAO;CACR;CAED,MACEC,OACM;AACN,OAAK,QAAQ,KAAK,MAAM;AACxB,SAAO;CACR;CAED,KAAKC,MAAsB;AACzB,OAAK,QAAQ;AACb,SAAO;CACR;CAED,WAAWC,YAA0B;AACnC,OAAK,cAAc;AACnB,SAAO;CACR;CAED,UACEC,WAiBA;AACA,OAAK,aAAa;AAKlB,SAAO;CAiBR;CAED,KACEC,QAiBA;AACA,OAAK,QAAQ,OAAO;AAEpB,SAAO;CACR;CAED,OACEA,QAiBA;AACA,OAAK,QAAQ,QAAQ;AAErB,SAAO;CACR;CAED,MACEA,QAiBA;AACA,SAAO,KAAK,OAAO,OAAO;CAC3B;CAED,OACEA,QAiBA;AACA,OAAK,QAAQ,SAAS;AAEtB,SAAO;CACR;CAED,UAAUC,QAA+B;AACvC,OAAK,aAAa;AAClB,SAAO;CACR;CAED,WACEC,MAiBA;AAEA,MAAI,SAAS,QAAQ;AACnB,QAAK;AACL,UAAO;EACR;EAGD,MAAM,mBAAmB,KAAK,sBAAsB,KAClD,CAAC,MAAM,EAAE,SAAS,KACnB;AACD,OAAK,oBAAoB,KAAK,sBAAsB,SAAS,GAAG;GAC9D,MAAM,YAAY,KAAK,sBACpB,IAAI,CAAC,MAAM,EAAE,KAAK,CAClB,KAAK,KAAK;AACb,SAAM,IAAI,OACP,cAAc,KAAe,wCAAwC,UAAU;EAEnF;AACD,OAAK,kBAAkB;AACvB,SAAO;CACR;CAED,SACEC,UAiBA;AACA,OAAK,YAAY,OACf,CAAC,GAAG,KAAK,WAAW,GAAG,QAAS,GAChC,CAAC,MAAM,EAAE,YACV;AAED,SAAO;CAiBR;CAED,OACEC,QAiBA;AACA,OAAK,UAAU;AAEf,SAAO;CAiBR;CAED,OACEJ,QAiBA;AACA,OAAK,eAAe;AAEpB,SAAO;CAiBR;;;;;;CAOD,QACEK,SAiBA;AACA,OAAK,kBAAkB;AAKvB,SAAO;CAiBR;;;;;CAMD,MACEC,WAiBA;AACA,OAAK,kBAAkB;AACvB,SAAO;CACR;;;;;;;;;;;;;;;;;;CAmBD,MAAMC,QAAsD;AAC1D,OAAK,UAAU;AACf,SAAO;CACR;;;;;;;;;;;;;;;;CAiBD,SACEC,SAiBA;AACA,OAAK,mBAAmB;AAKxB,SAAO;CAiBR;CAGD,MAAMC,SAAmB;AACvB,QAAM,IAAI,MACR;CAEH;CAED,OACEC,IAyBA;EAGA,IAAIC;AACJ,MAAI,KAAK,iBAAiB;GACxB,MAAM,qBAAqB,KAAK,sBAAsB,KACpD,CAAC,MAAM,EAAE,SAAS,KAAK,gBACxB;AAED,OAAI,mBACF,cAAa;QACR;IAEL,MAAM,iBAAiB,kBACrB,KAAK,iBACL,KAAK,uBACN;AACD,iBAAa;KACX,MAAM,KAAK;KACX;IACD;GACF;EACF;AAED,SAAO,IAAI,SAAS;GAClB;GACA,QAAQ,KAAK;GACb,OAAO,KAAK;GACZ,aAAa,KAAK;GAClB,MAAM,KAAK;GACX,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,UAAU,KAAK;GACf,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,YAAY,KAAK;GACjB,WAAW,KAAK;GAChB,QAAQ,KAAK;GACb,YAAY,KAAK;GACjB,WAAW,KAAK;GAChB,kBAAkB,KAAK;GACvB,QAAQ,KAAK;GACb;GACA,uBAAuB,KAAK;GAC5B,gBAAgB,KAAK;GACrB,QAAQ,KAAK;GACb,iBAAiB,KAAK;EACvB;CACF;AACF"}
|