@composurecdk/apigateway 0.6.0 → 0.8.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/commonjs/alarm-config.d.ts.map +1 -0
- package/dist/commonjs/alarm-config.js +3 -0
- package/dist/{alarm-config.js.map → commonjs/alarm-config.js.map} +1 -1
- package/dist/commonjs/alarm-defaults.d.ts.map +1 -0
- package/dist/commonjs/alarm-defaults.js +46 -0
- package/dist/commonjs/alarm-defaults.js.map +1 -0
- package/dist/commonjs/builder-common.d.ts.map +1 -0
- package/dist/commonjs/builder-common.js +3 -0
- package/dist/{builder-common.js.map → commonjs/builder-common.js.map} +1 -1
- package/dist/commonjs/defaults.d.ts.map +1 -0
- package/dist/commonjs/defaults.js +56 -0
- package/dist/commonjs/defaults.js.map +1 -0
- package/dist/commonjs/deploy-options.d.ts.map +1 -0
- package/dist/commonjs/deploy-options.js +33 -0
- package/dist/commonjs/deploy-options.js.map +1 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +13 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/{resource-builder.d.ts → commonjs/resource-builder.d.ts} +12 -0
- package/dist/commonjs/resource-builder.d.ts.map +1 -0
- package/dist/commonjs/resource-builder.js +90 -0
- package/dist/commonjs/resource-builder.js.map +1 -0
- package/dist/commonjs/rest-api-alarms.d.ts.map +1 -0
- package/dist/commonjs/rest-api-alarms.js +102 -0
- package/dist/commonjs/rest-api-alarms.js.map +1 -0
- package/dist/{rest-api-builder.d.ts → commonjs/rest-api-builder.d.ts} +13 -2
- package/dist/commonjs/rest-api-builder.d.ts.map +1 -0
- package/dist/commonjs/rest-api-builder.js +105 -0
- package/dist/commonjs/rest-api-builder.js.map +1 -0
- package/dist/{spec-rest-api-builder.d.ts → commonjs/spec-rest-api-builder.d.ts} +5 -2
- package/dist/commonjs/spec-rest-api-builder.d.ts.map +1 -0
- package/dist/commonjs/spec-rest-api-builder.js +74 -0
- package/dist/commonjs/spec-rest-api-builder.js.map +1 -0
- package/dist/esm/alarm-config.d.ts +47 -0
- package/dist/esm/alarm-config.d.ts.map +1 -0
- package/dist/esm/alarm-config.js.map +1 -0
- package/dist/esm/alarm-defaults.d.ts +15 -0
- package/dist/esm/alarm-defaults.d.ts.map +1 -0
- package/dist/esm/alarm-defaults.js.map +1 -0
- package/dist/esm/builder-common.d.ts +68 -0
- package/dist/esm/builder-common.d.ts.map +1 -0
- package/dist/esm/builder-common.js.map +1 -0
- package/dist/esm/defaults.d.ts +22 -0
- package/dist/esm/defaults.d.ts.map +1 -0
- package/dist/esm/defaults.js.map +1 -0
- package/dist/esm/deploy-options.d.ts +17 -0
- package/dist/esm/deploy-options.d.ts.map +1 -0
- package/dist/esm/deploy-options.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/resource-builder.d.ts +70 -0
- package/dist/esm/resource-builder.d.ts.map +1 -0
- package/dist/{resource-builder.js → esm/resource-builder.js} +17 -0
- package/dist/esm/resource-builder.js.map +1 -0
- package/dist/esm/rest-api-alarms.d.ts +26 -0
- package/dist/esm/rest-api-alarms.d.ts.map +1 -0
- package/dist/esm/rest-api-alarms.js.map +1 -0
- package/dist/esm/rest-api-builder.d.ts +116 -0
- package/dist/esm/rest-api-builder.d.ts.map +1 -0
- package/dist/{rest-api-builder.js → esm/rest-api-builder.js} +16 -2
- package/dist/esm/rest-api-builder.js.map +1 -0
- package/dist/esm/spec-rest-api-builder.d.ts +90 -0
- package/dist/esm/spec-rest-api-builder.d.ts.map +1 -0
- package/dist/{spec-rest-api-builder.js → esm/spec-rest-api-builder.js} +7 -2
- package/dist/esm/spec-rest-api-builder.js.map +1 -0
- package/package.json +36 -17
- package/dist/alarm-config.d.ts.map +0 -1
- package/dist/alarm-defaults.d.ts.map +0 -1
- package/dist/alarm-defaults.js.map +0 -1
- package/dist/builder-common.d.ts.map +0 -1
- package/dist/defaults.d.ts.map +0 -1
- package/dist/defaults.js.map +0 -1
- package/dist/deploy-options.d.ts.map +0 -1
- package/dist/deploy-options.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/resource-builder.d.ts.map +0 -1
- package/dist/resource-builder.js.map +0 -1
- package/dist/rest-api-alarms.d.ts.map +0 -1
- package/dist/rest-api-alarms.js.map +0 -1
- package/dist/rest-api-builder.d.ts.map +0 -1
- package/dist/rest-api-builder.js.map +0 -1
- package/dist/spec-rest-api-builder.d.ts.map +0 -1
- package/dist/spec-rest-api-builder.js.map +0 -1
- /package/dist/{alarm-config.d.ts → commonjs/alarm-config.d.ts} +0 -0
- /package/dist/{alarm-defaults.d.ts → commonjs/alarm-defaults.d.ts} +0 -0
- /package/dist/{builder-common.d.ts → commonjs/builder-common.d.ts} +0 -0
- /package/dist/{defaults.d.ts → commonjs/defaults.d.ts} +0 -0
- /package/dist/{deploy-options.d.ts → commonjs/deploy-options.d.ts} +0 -0
- /package/dist/{index.d.ts → commonjs/index.d.ts} +0 -0
- /package/dist/{rest-api-alarms.d.ts → commonjs/rest-api-alarms.d.ts} +0 -0
- /package/dist/{alarm-config.js → esm/alarm-config.js} +0 -0
- /package/dist/{alarm-defaults.js → esm/alarm-defaults.js} +0 -0
- /package/dist/{builder-common.js → esm/builder-common.js} +0 -0
- /package/dist/{defaults.js → esm/defaults.js} +0 -0
- /package/dist/{deploy-options.js → esm/deploy-options.js} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{rest-api-alarms.js → esm/rest-api-alarms.js} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSpecRestApiBuilder = createSpecRestApiBuilder;
|
|
4
|
+
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
|
5
|
+
const core_1 = require("@composurecdk/core");
|
|
6
|
+
const cloudformation_1 = require("@composurecdk/cloudformation");
|
|
7
|
+
const cloudwatch_1 = require("@composurecdk/cloudwatch");
|
|
8
|
+
const defaults_js_1 = require("./defaults.js");
|
|
9
|
+
const deploy_options_js_1 = require("./deploy-options.js");
|
|
10
|
+
const rest_api_alarms_js_1 = require("./rest-api-alarms.js");
|
|
11
|
+
class SpecRestApiBuilder {
|
|
12
|
+
props = {};
|
|
13
|
+
#customAlarms = [];
|
|
14
|
+
addAlarm(key, configure) {
|
|
15
|
+
this.#customAlarms.push(configure(new cloudwatch_1.AlarmDefinitionBuilder(key)));
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
/** @internal — see ADR-0005. */
|
|
19
|
+
[core_1.COPY_STATE](target) {
|
|
20
|
+
target.#customAlarms.push(...this.#customAlarms);
|
|
21
|
+
}
|
|
22
|
+
build(scope, id) {
|
|
23
|
+
const { accessLogging, recommendedAlarms: alarmConfig, ...specRestApiProps } = this.props;
|
|
24
|
+
const { accessLogGroup, deployOptions } = (0, deploy_options_js_1.resolveDeployOptions)(scope, id, accessLogging, defaults_js_1.SPEC_REST_API_DEFAULTS.deployOptions ?? {}, specRestApiProps.deployOptions ?? {});
|
|
25
|
+
const api = new aws_apigateway_1.SpecRestApi(scope, id, {
|
|
26
|
+
...specRestApiProps,
|
|
27
|
+
deployOptions,
|
|
28
|
+
});
|
|
29
|
+
const alarms = (0, rest_api_alarms_js_1.createRestApiAlarms)(scope, id, api, alarmConfig, this.#customAlarms);
|
|
30
|
+
return { api, accessLogGroup, alarms };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new {@link ISpecRestApiBuilder} for configuring an API Gateway
|
|
35
|
+
* REST API from an OpenAPI specification.
|
|
36
|
+
*
|
|
37
|
+
* This is the entry point for defining a spec-driven REST API component. The
|
|
38
|
+
* returned builder exposes every {@link SpecRestApiProps} property as a fluent
|
|
39
|
+
* setter/getter. It implements {@link Lifecycle} for use with {@link compose}.
|
|
40
|
+
*
|
|
41
|
+
* The API structure — resources, methods, and integrations — is defined
|
|
42
|
+
* entirely by the OpenAPI specification passed to {@link apiDefinition}.
|
|
43
|
+
* Use CDK's {@link ApiDefinition} static methods to load the spec from an
|
|
44
|
+
* inline object, a local file, or an S3 bucket.
|
|
45
|
+
*
|
|
46
|
+
* @returns A fluent builder for a spec-driven API Gateway REST API.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* // From a local OpenAPI file
|
|
51
|
+
* const api = createSpecRestApiBuilder()
|
|
52
|
+
* .restApiName("PetStore")
|
|
53
|
+
* .apiDefinition(ApiDefinition.fromAsset("openapi/petstore.yaml"));
|
|
54
|
+
*
|
|
55
|
+
* // From an inline definition
|
|
56
|
+
* const api = createSpecRestApiBuilder()
|
|
57
|
+
* .restApiName("PetStore")
|
|
58
|
+
* .apiDefinition(ApiDefinition.fromInline({
|
|
59
|
+
* openapi: "3.0.2",
|
|
60
|
+
* info: { title: "PetStore", version: "1.0" },
|
|
61
|
+
* paths: { "/pets": { get: { ... } } },
|
|
62
|
+
* }));
|
|
63
|
+
*
|
|
64
|
+
* // Compose into a system
|
|
65
|
+
* const system = compose(
|
|
66
|
+
* { api },
|
|
67
|
+
* { api: [] },
|
|
68
|
+
* );
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
function createSpecRestApiBuilder() {
|
|
72
|
+
return (0, cloudformation_1.taggedBuilder)(SpecRestApiBuilder);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=spec-rest-api-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-rest-api-builder.js","sourceRoot":"","sources":["../../src/spec-rest-api-builder.ts"],"names":[],"mappings":";;AA2HA,4DAEC;AA7HD,+DAAkG;AAElG,6CAAgE;AAChE,iEAAkF;AAClF,yDAAkE;AAElE,+CAAuD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|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AlarmConfig } from "@composurecdk/cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* Controls which recommended alarms are created for an API Gateway REST API.
|
|
4
|
+
* All applicable alarms are enabled by default with AWS-recommended thresholds.
|
|
5
|
+
* Set individual alarms to `false` to disable them, or provide an
|
|
6
|
+
* {@link AlarmConfig} to tune thresholds.
|
|
7
|
+
*
|
|
8
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ApiGateway
|
|
9
|
+
*/
|
|
10
|
+
export interface RestApiAlarmConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Master switch: set to `false` to disable all recommended alarms.
|
|
13
|
+
* Individual alarms can also be disabled via their own entry.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Alarm when the API returns an elevated rate of client-side errors
|
|
19
|
+
* (4XX HTTP status codes).
|
|
20
|
+
*
|
|
21
|
+
* Metric: `AWS/ApiGateway 4XXError`, statistic Average, period 1 minute.
|
|
22
|
+
* Default threshold: > 0.05 (5% of requests).
|
|
23
|
+
*
|
|
24
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ApiGateway
|
|
25
|
+
*/
|
|
26
|
+
clientError?: AlarmConfig | false;
|
|
27
|
+
/**
|
|
28
|
+
* Alarm when the API returns an elevated rate of server-side errors
|
|
29
|
+
* (5XX HTTP status codes).
|
|
30
|
+
*
|
|
31
|
+
* Metric: `AWS/ApiGateway 5XXError`, statistic Average, period 1 minute.
|
|
32
|
+
* Default threshold: > 0.05 (5% of requests).
|
|
33
|
+
*
|
|
34
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ApiGateway
|
|
35
|
+
*/
|
|
36
|
+
serverError?: AlarmConfig | false;
|
|
37
|
+
/**
|
|
38
|
+
* Alarm when API latency is elevated.
|
|
39
|
+
*
|
|
40
|
+
* Metric: `AWS/ApiGateway Latency`, statistic p90, period 1 minute.
|
|
41
|
+
* Default threshold: >= 2500ms.
|
|
42
|
+
*
|
|
43
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ApiGateway
|
|
44
|
+
*/
|
|
45
|
+
latency?: AlarmConfig | false;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=alarm-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-config.d.ts","sourceRoot":"","sources":["../../src/alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAElC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAElC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-config.js","sourceRoot":"","sources":["../../src/alarm-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AlarmConfigDefaults } from "@composurecdk/cloudwatch";
|
|
2
|
+
interface RestApiAlarmDefaults {
|
|
3
|
+
enabled: true;
|
|
4
|
+
clientError: AlarmConfigDefaults;
|
|
5
|
+
serverError: AlarmConfigDefaults;
|
|
6
|
+
latency: AlarmConfigDefaults;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* AWS-recommended default alarm configuration for API Gateway REST APIs.
|
|
10
|
+
*
|
|
11
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ApiGateway
|
|
12
|
+
*/
|
|
13
|
+
export declare const REST_API_ALARM_DEFAULTS: RestApiAlarmDefaults;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=alarm-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-defaults.d.ts","sourceRoot":"","sources":["../../src/alarm-defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,UAAU,oBAAoB;IAC5B,OAAO,EAAE,IAAI,CAAC;IACd,WAAW,EAAE,mBAAmB,CAAC;IACjC,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,oBAsCrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alarm-defaults.js","sourceRoot":"","sources":["../../src/alarm-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAU9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAyB;IAC3D,OAAO,EAAE,IAAI;IAEb;;;;OAIG;IACH,WAAW,EAAE;QACX,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;IAED;;;;OAIG;IACH,WAAW,EAAE;QACX,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;IAED;;;;OAIG;IACH,OAAO,EAAE;QACP,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;CACF,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
import type { RestApiBase } from "aws-cdk-lib/aws-apigateway";
|
|
3
|
+
import type { LogGroup } from "aws-cdk-lib/aws-logs";
|
|
4
|
+
import type { RestApiAlarmConfig } from "./alarm-config.js";
|
|
5
|
+
/**
|
|
6
|
+
* Builder-specific properties shared by both {@link RestApiBuilderProps}
|
|
7
|
+
* and {@link SpecRestApiBuilderProps}.
|
|
8
|
+
*/
|
|
9
|
+
export interface RestApiBuilderPropsBase {
|
|
10
|
+
/**
|
|
11
|
+
* Whether to automatically create a CloudWatch log group for access logging.
|
|
12
|
+
*
|
|
13
|
+
* When `true`, the builder creates a log group using
|
|
14
|
+
* {@link createLogGroupBuilder} (with its secure defaults) and configures it
|
|
15
|
+
* as the stage's access log destination with JSON-formatted output. The
|
|
16
|
+
* created log group is returned in the build result as `accessLogGroup`.
|
|
17
|
+
*
|
|
18
|
+
* When `false`, no access log group is created. You can still provide your
|
|
19
|
+
* own destination via `deployOptions.accessLogDestination`.
|
|
20
|
+
*
|
|
21
|
+
* This setting is ignored when `deployOptions.accessLogDestination` is
|
|
22
|
+
* provided — the user-supplied destination takes precedence.
|
|
23
|
+
*/
|
|
24
|
+
accessLogging?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for AWS-recommended CloudWatch alarms.
|
|
27
|
+
*
|
|
28
|
+
* By default, the builder creates recommended alarms for client error rate,
|
|
29
|
+
* server error rate, and latency. Individual alarms can be customized or
|
|
30
|
+
* disabled. Set to `false` to disable all alarms.
|
|
31
|
+
*
|
|
32
|
+
* No alarm actions are configured by default since notification
|
|
33
|
+
* methods are user-specific. Access alarms from the build result
|
|
34
|
+
* or use an `afterBuild` hook to apply actions.
|
|
35
|
+
*
|
|
36
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ApiGateway
|
|
37
|
+
*/
|
|
38
|
+
recommendedAlarms?: RestApiAlarmConfig | false;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Build result properties shared by both {@link RestApiBuilderResult}
|
|
42
|
+
* and {@link SpecRestApiBuilderResult}.
|
|
43
|
+
*
|
|
44
|
+
* @typeParam T - The concrete REST API type (`RestApi` or `SpecRestApi`).
|
|
45
|
+
*/
|
|
46
|
+
export interface RestApiBuilderResultBase<T extends RestApiBase> {
|
|
47
|
+
/** The REST API construct created by the builder. */
|
|
48
|
+
api: T;
|
|
49
|
+
/**
|
|
50
|
+
* The CloudWatch log group created for access logging, or `undefined` if
|
|
51
|
+
* access logging was disabled or the user provided their own destination.
|
|
52
|
+
*/
|
|
53
|
+
accessLogGroup?: LogGroup;
|
|
54
|
+
/**
|
|
55
|
+
* CloudWatch alarms created for the API, keyed by alarm name.
|
|
56
|
+
*
|
|
57
|
+
* Includes both AWS-recommended alarms and any custom alarms added
|
|
58
|
+
* via `addAlarm()`. Access individual alarms by key
|
|
59
|
+
* (e.g., `result.alarms.serverError`).
|
|
60
|
+
*
|
|
61
|
+
* No alarm actions are configured — apply them via the result or an
|
|
62
|
+
* `afterBuild` hook.
|
|
63
|
+
*
|
|
64
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ApiGateway
|
|
65
|
+
*/
|
|
66
|
+
alarms: Record<string, Alarm>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=builder-common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder-common.d.ts","sourceRoot":"","sources":["../../src/builder-common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;;;;;OAaG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,EAAE,kBAAkB,GAAG,KAAK,CAAC;CAChD;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,WAAW;IAC7D,qDAAqD;IACrD,GAAG,EAAE,CAAC,CAAC;IAEP;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder-common.js","sourceRoot":"","sources":["../../src/builder-common.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type StageOptions } from "aws-cdk-lib/aws-apigateway";
|
|
2
|
+
import type { RestApiBuilderProps } from "./rest-api-builder.js";
|
|
3
|
+
import type { SpecRestApiBuilderProps } from "./spec-rest-api-builder.js";
|
|
4
|
+
/**
|
|
5
|
+
* Secure, AWS-recommended deploy-stage defaults shared by all API Gateway
|
|
6
|
+
* builders. Each property can be individually overridden via the builder's
|
|
7
|
+
* fluent API.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEPLOY_OPTIONS_DEFAULTS: StageOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Secure, AWS-recommended defaults applied to every REST API built with
|
|
12
|
+
* {@link createRestApiBuilder}. Each property can be individually overridden
|
|
13
|
+
* via the builder's fluent API.
|
|
14
|
+
*/
|
|
15
|
+
export declare const REST_API_DEFAULTS: Partial<RestApiBuilderProps>;
|
|
16
|
+
/**
|
|
17
|
+
* Secure, AWS-recommended defaults applied to every spec-driven REST API
|
|
18
|
+
* built with {@link createSpecRestApiBuilder}. Each property can be
|
|
19
|
+
* individually overridden via the builder's fluent API.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SPEC_REST_API_DEFAULTS: Partial<SpecRestApiBuilderProps>;
|
|
22
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,YAmBrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,mBAAmB,CAU1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,OAAO,CAAC,uBAAuB,CAQnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,4BAA4B,CAAC;AAInF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAiB;IACnD;;;OAGG;IACH,cAAc,EAAE,IAAI;IAEpB;;;OAGG;IACH,YAAY,EAAE,kBAAkB,CAAC,IAAI;IAErC;;;;OAIG;IACH,gBAAgB,EAAE,KAAK;CACxB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAiC;IAC7D;;;;;OAKG;IACH,aAAa,EAAE,IAAI;IAEnB,aAAa,EAAE,uBAAuB;CACvC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqC;IACtE;;;OAGG;IACH,aAAa,EAAE,IAAI;IAEnB,aAAa,EAAE,uBAAuB;CACvC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type StageOptions } from "aws-cdk-lib/aws-apigateway";
|
|
2
|
+
import { type LogGroup } from "aws-cdk-lib/aws-logs";
|
|
3
|
+
import { type IConstruct } from "constructs";
|
|
4
|
+
interface AccessLoggingResult {
|
|
5
|
+
accessLogGroup?: LogGroup;
|
|
6
|
+
deployOptions: StageOptions;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolves access logging configuration and merges deploy options with
|
|
10
|
+
* the provided defaults. Shared by {@link RestApiBuilder} and
|
|
11
|
+
* {@link SpecRestApiBuilder}.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveDeployOptions(scope: IConstruct, id: string, accessLogging: boolean | undefined, defaults: StageOptions, userDeployOptions: StageOptions): AccessLoggingResult;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=deploy-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-options.d.ts","sourceRoot":"","sources":["../../src/deploy-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,UAAU,mBAAmB;IAC3B,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,aAAa,EAAE,YAAY,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,aAAa,EAAE,OAAO,GAAG,SAAS,EAClC,QAAQ,EAAE,YAAY,EACtB,iBAAiB,EAAE,YAAY,GAC9B,mBAAmB,CAsBrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-options.js","sourceRoot":"","sources":["../../src/deploy-options.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,sBAAsB,GAEvB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAO3D;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAiB,EACjB,EAAU,EACV,aAAkC,EAClC,QAAsB,EACtB,iBAA+B;IAE/B,MAAM,aAAa,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC;IAEzF,IAAI,cAAoC,CAAC;IACzC,IAAI,cAAc,GAAG,EAAE,CAAC;IAExB,IAAI,aAAa,EAAE,CAAC;QAClB,cAAc,GAAG,qBAAqB,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,QAAQ,CAAC;QAClF,cAAc,GAAG;YACf,oBAAoB,EAAE,IAAI,sBAAsB,CAAC,cAAc,CAAC;YAChE,eAAe,EAAE,eAAe,CAAC,sBAAsB,EAAE;SAC1D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,cAAc;QACd,aAAa,EAAE;YACb,GAAG,QAAQ;YACX,GAAG,cAAc;YACjB,GAAG,iBAAiB;SACrB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createRestApiBuilder, type RestApiBuilderProps, type RestApiBuilderResult, type IRestApiBuilder, } from "./rest-api-builder.js";
|
|
2
|
+
export { type RestApiBuilderPropsBase } from "./builder-common.js";
|
|
3
|
+
export { createSpecRestApiBuilder, type SpecRestApiBuilderProps, type SpecRestApiBuilderResult, type ISpecRestApiBuilder, } from "./spec-rest-api-builder.js";
|
|
4
|
+
export { REST_API_DEFAULTS, SPEC_REST_API_DEFAULTS } from "./defaults.js";
|
|
5
|
+
export { type RestApiAlarmConfig } from "./alarm-config.js";
|
|
6
|
+
export { REST_API_ALARM_DEFAULTS } from "./alarm-defaults.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,wBAAwB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAIrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,wBAAwB,GAIzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type Integration, type IResource, type MethodOptions } from "aws-cdk-lib/aws-apigateway";
|
|
2
|
+
import { type Resolvable } from "@composurecdk/core";
|
|
3
|
+
interface MethodDefinition {
|
|
4
|
+
httpMethod: string;
|
|
5
|
+
integration?: Resolvable<Integration>;
|
|
6
|
+
options?: MethodOptions;
|
|
7
|
+
}
|
|
8
|
+
interface ResourceDefinition {
|
|
9
|
+
methods: MethodDefinition[];
|
|
10
|
+
children: Map<string, ResourceDefinition>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A declarative builder for defining API Gateway resources and methods.
|
|
14
|
+
*
|
|
15
|
+
* `ResourceBuilder` captures a tree of resource paths and HTTP methods as
|
|
16
|
+
* data. The tree is applied to actual CDK constructs during
|
|
17
|
+
* {@link RestApiBuilder.build}. Users do not construct `ResourceBuilder`
|
|
18
|
+
* directly — instances are provided via the {@link IRestApiBuilder.addResource}
|
|
19
|
+
* callback.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* createRestApiBuilder()
|
|
24
|
+
* .addResource("users", users => users
|
|
25
|
+
* .addMethod("GET", listIntegration)
|
|
26
|
+
* .addResource("{id}", user => user
|
|
27
|
+
* .addMethod("GET", getIntegration)
|
|
28
|
+
* .addMethod("DELETE", deleteIntegration)
|
|
29
|
+
* )
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class ResourceBuilder {
|
|
34
|
+
/** @internal */
|
|
35
|
+
readonly definition: ResourceDefinition;
|
|
36
|
+
/**
|
|
37
|
+
* Adds an HTTP method to this resource.
|
|
38
|
+
*
|
|
39
|
+
* @param httpMethod - The HTTP verb (GET, POST, PUT, DELETE, etc.).
|
|
40
|
+
* @param integration - The backend integration for this method. Accepts a concrete
|
|
41
|
+
* {@link Integration} or a {@link Ref} that resolves to one at build time.
|
|
42
|
+
* @param options - Additional method configuration such as authorization or method responses.
|
|
43
|
+
* @returns This builder for chaining.
|
|
44
|
+
*/
|
|
45
|
+
addMethod(httpMethod: string, integration?: Resolvable<Integration>, options?: MethodOptions): this;
|
|
46
|
+
/**
|
|
47
|
+
* Adds a child resource under this resource.
|
|
48
|
+
*
|
|
49
|
+
* @param pathPart - The path segment for the child resource (e.g. "users" or "\{id\}").
|
|
50
|
+
* @param configure - Optional callback to configure the child resource's methods and nested resources.
|
|
51
|
+
* @returns This builder for chaining.
|
|
52
|
+
*/
|
|
53
|
+
addResource(pathPart: string, configure?: (resource: ResourceBuilder) => void): this;
|
|
54
|
+
/**
|
|
55
|
+
* Copies this builder's resource tree onto `target`. Used by
|
|
56
|
+
* `RestApiBuilder.[COPY_STATE]` per ADR-0005's containers-fresh,
|
|
57
|
+
* elements-shared rule: the `methods` array and `children` Map are
|
|
58
|
+
* reconstructed on `target`, but `MethodDefinition` and child
|
|
59
|
+
* `ResourceDefinition` entries are shared by reference. Sharing the
|
|
60
|
+
* child entries is safe because the public API (`addResource`)
|
|
61
|
+
* replaces a child wholesale rather than mutating it in place.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
copyInto(target: ResourceBuilder): void;
|
|
66
|
+
/** @internal */
|
|
67
|
+
applyTo(resource: IResource, context?: Record<string, object>): void;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=resource-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-builder.d.ts","sourceRoot":"","sources":["../../src/resource-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE9D,UAAU,gBAAgB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED,UAAU,kBAAkB;IAC1B,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,eAAe;IAC1B,gBAAgB;IAChB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAwC;IAE/E;;;;;;;;OAQG;IACH,SAAS,CACP,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,EACrC,OAAO,CAAC,EAAE,aAAa,GACtB,IAAI;IAKP;;;;;;OAMG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,GAAG,IAAI;IASpF;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAOvC,gBAAgB;IAChB,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,IAAI;CAczE"}
|
|
@@ -51,6 +51,23 @@ export class ResourceBuilder {
|
|
|
51
51
|
this.definition.children.set(pathPart, child.definition);
|
|
52
52
|
return this;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Copies this builder's resource tree onto `target`. Used by
|
|
56
|
+
* `RestApiBuilder.[COPY_STATE]` per ADR-0005's containers-fresh,
|
|
57
|
+
* elements-shared rule: the `methods` array and `children` Map are
|
|
58
|
+
* reconstructed on `target`, but `MethodDefinition` and child
|
|
59
|
+
* `ResourceDefinition` entries are shared by reference. Sharing the
|
|
60
|
+
* child entries is safe because the public API (`addResource`)
|
|
61
|
+
* replaces a child wholesale rather than mutating it in place.
|
|
62
|
+
*
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
copyInto(target) {
|
|
66
|
+
target.definition.methods.push(...this.definition.methods);
|
|
67
|
+
for (const [pathPart, childDef] of this.definition.children) {
|
|
68
|
+
target.definition.children.set(pathPart, childDef);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
54
71
|
/** @internal */
|
|
55
72
|
applyTo(resource, context = {}) {
|
|
56
73
|
for (const method of this.definition.methods) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-builder.js","sourceRoot":"","sources":["../../src/resource-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAmB,MAAM,oBAAoB,CAAC;AAa9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,eAAe;IAC1B,gBAAgB;IACP,UAAU,GAAuB,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;IAE/E;;;;;;;;OAQG;IACH,SAAS,CACP,UAAkB,EAClB,WAAqC,EACrC,OAAuB;QAEvB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,QAAgB,EAAE,SAA+C;QAC3E,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,SAAS,EAAE,CAAC;YACd,SAAS,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAuB;QAC9B,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC3D,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,IAAI,C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ruct } from "constructs";
|
|
4
|
+
import type { AlarmDefinition } from "@composurecdk/cloudwatch";
|
|
5
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
6
|
+
import type { RestApiAlarmConfig } from "./alarm-config.js";
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the recommended alarm configuration into fully-resolved
|
|
9
|
+
* {@link AlarmDefinition}s for an API Gateway REST API.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveRestApiAlarmDefinitions(api: RestApiBase, config: RestApiAlarmConfig | undefined): AlarmDefinition[];
|
|
12
|
+
/**
|
|
13
|
+
* Creates AWS-recommended CloudWatch alarms for an API Gateway REST API,
|
|
14
|
+
* merging recommended definitions with any custom alarm builders.
|
|
15
|
+
*
|
|
16
|
+
* @param scope - CDK construct scope for creating alarm constructs.
|
|
17
|
+
* @param id - Base identifier for alarm construct ids.
|
|
18
|
+
* @param api - The REST API to create alarms for.
|
|
19
|
+
* @param config - User-provided alarm configuration, or `false` to disable all.
|
|
20
|
+
* @param customAlarms - Custom alarm builders added via `addAlarm()`.
|
|
21
|
+
* @returns A record mapping alarm keys to their created Alarm constructs.
|
|
22
|
+
*
|
|
23
|
+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html#ApiGateway
|
|
24
|
+
*/
|
|
25
|
+
export declare function createRestApiAlarms(scope: IConstruct, id: string, api: RestApiBase, config: RestApiAlarmConfig | false | undefined, customAlarms?: AlarmDefinitionBuilder<RestApiBase>[]): Record<string, Alarm>;
|
|
26
|
+
//# sourceMappingURL=rest-api-alarms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest-api-alarms.d.ts","sourceRoot":"","sources":["../../src/rest-api-alarms.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAqC,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA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EAChB,MAA8C,EAC9C,eAAsD,EAAE;IAExD,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,EAAE,CAAC;IAEhC,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC;IACnE,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,WAAW,GAAG,8BAA8B,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvD,OAAO,YAAY,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type Integration, type MethodOptions, RestApi, type RestApiBase, type RestApiProps } from "aws-cdk-lib/aws-apigateway";
|
|
2
|
+
import { type IConstruct } from "constructs";
|
|
3
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
4
|
+
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
5
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
6
|
+
import type { RestApiBuilderPropsBase, RestApiBuilderResultBase } from "./builder-common.js";
|
|
7
|
+
import { ResourceBuilder } from "./resource-builder.js";
|
|
8
|
+
/**
|
|
9
|
+
* Configuration properties for the REST API builder.
|
|
10
|
+
*
|
|
11
|
+
* Extends the CDK {@link RestApiProps} with additional builder-specific options.
|
|
12
|
+
*/
|
|
13
|
+
export interface RestApiBuilderProps extends RestApiProps, RestApiBuilderPropsBase {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The build output of a {@link IRestApiBuilder}. Contains the CDK constructs
|
|
17
|
+
* created during {@link Lifecycle.build}, keyed by role.
|
|
18
|
+
*/
|
|
19
|
+
export type RestApiBuilderResult = RestApiBuilderResultBase<RestApi>;
|
|
20
|
+
/**
|
|
21
|
+
* A fluent builder for configuring and creating an API Gateway REST API.
|
|
22
|
+
*
|
|
23
|
+
* Configuration properties from CDK {@link RestApiProps} are exposed as
|
|
24
|
+
* overloaded getter/setter methods via the builder proxy. The resource tree
|
|
25
|
+
* (paths and HTTP methods) is defined using {@link addResource} and
|
|
26
|
+
* {@link addMethod}, which accept the same arguments as their CDK equivalents.
|
|
27
|
+
*
|
|
28
|
+
* The builder implements {@link Lifecycle}, so it can be used directly as a
|
|
29
|
+
* component in a {@link compose | composed system}. When built, it creates
|
|
30
|
+
* a REST API with the configured properties and resource tree, and returns
|
|
31
|
+
* a {@link RestApiBuilderResult}.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const api = createRestApiBuilder()
|
|
36
|
+
* .restApiName("My Service")
|
|
37
|
+
* .description("Public API")
|
|
38
|
+
* .addResource("users", users => users
|
|
39
|
+
* .addMethod("GET", listUsersIntegration)
|
|
40
|
+
* .addResource("{id}", user => user
|
|
41
|
+
* .addMethod("GET", getUserIntegration)
|
|
42
|
+
* )
|
|
43
|
+
* );
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export type IRestApiBuilder = ITaggedBuilder<RestApiBuilderProps, RestApiBuilder>;
|
|
47
|
+
declare class RestApiBuilder implements Lifecycle<RestApiBuilderResult> {
|
|
48
|
+
#private;
|
|
49
|
+
props: Partial<RestApiBuilderProps>;
|
|
50
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<RestApiBase>) => AlarmDefinitionBuilder<RestApiBase>): this;
|
|
51
|
+
/**
|
|
52
|
+
* Adds an HTTP method to the API root resource (`/`).
|
|
53
|
+
*
|
|
54
|
+
* @param httpMethod - The HTTP verb (GET, POST, PUT, DELETE, etc.).
|
|
55
|
+
* @param integration - The backend integration for this method. Accepts a concrete
|
|
56
|
+
* {@link Integration} or a {@link Ref} that resolves to one at build time.
|
|
57
|
+
* @param options - Additional method configuration such as authorization or method responses.
|
|
58
|
+
* @returns This builder for chaining.
|
|
59
|
+
*/
|
|
60
|
+
addMethod(httpMethod: string, integration?: Resolvable<Integration>, options?: MethodOptions): this;
|
|
61
|
+
/**
|
|
62
|
+
* Adds a child resource under the API root resource (`/`).
|
|
63
|
+
*
|
|
64
|
+
* @param pathPart - The path segment for the resource (e.g. "users" or "\{id\}").
|
|
65
|
+
* @param configure - Optional callback to configure the resource's methods and nested resources.
|
|
66
|
+
* @returns This builder for chaining.
|
|
67
|
+
*/
|
|
68
|
+
addResource(pathPart: string, configure?: (resource: ResourceBuilder) => void): this;
|
|
69
|
+
/**
|
|
70
|
+
* Copies non-`props` state onto a freshly cloned builder. The resource
|
|
71
|
+
* tree is deep-cloned via `ResourceBuilder.copyInto` so mutations on
|
|
72
|
+
* either side after `.copy()` do not leak; the alarm-builder array is
|
|
73
|
+
* spread into a fresh container with elements shared by reference per
|
|
74
|
+
* ADR-0005's shallow-clone stance.
|
|
75
|
+
*
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
[COPY_STATE](target: RestApiBuilder): void;
|
|
79
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): RestApiBuilderResult;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new {@link IRestApiBuilder} for configuring an API Gateway REST API.
|
|
83
|
+
*
|
|
84
|
+
* This is the entry point for defining a REST API component. The returned
|
|
85
|
+
* builder exposes every {@link RestApiProps} property as a fluent setter/getter,
|
|
86
|
+
* plus {@link IRestApiBuilder.addResource | addResource} and
|
|
87
|
+
* {@link IRestApiBuilder.addMethod | addMethod} for defining the resource tree.
|
|
88
|
+
* It implements {@link Lifecycle} for use with {@link compose}.
|
|
89
|
+
*
|
|
90
|
+
* @returns A fluent builder for an API Gateway REST API.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const api = createRestApiBuilder()
|
|
95
|
+
* .restApiName("My Service")
|
|
96
|
+
* .description("Public API")
|
|
97
|
+
* .addResource("users", users => users
|
|
98
|
+
* .addMethod("GET", listUsersIntegration)
|
|
99
|
+
* .addResource("{id}", user => user
|
|
100
|
+
* .addMethod("GET", getUserIntegration)
|
|
101
|
+
* )
|
|
102
|
+
* );
|
|
103
|
+
*
|
|
104
|
+
* // Use standalone:
|
|
105
|
+
* const result = api.build(stack, "MyApi");
|
|
106
|
+
*
|
|
107
|
+
* // Or compose into a system:
|
|
108
|
+
* const system = compose(
|
|
109
|
+
* { api, handler: createFunctionBuilder() },
|
|
110
|
+
* { api: ["handler"], handler: [] },
|
|
111
|
+
* );
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare function createRestApiBuilder(): IRestApiBuilder;
|
|
115
|
+
export {};
|
|
116
|
+
//# sourceMappingURL=rest-api-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest-api-builder.d.ts","sourceRoot":"","sources":["../../src/rest-api-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAG7F,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD;;;;GAIG;AACH,MAAM,WAAW,mBAAoB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formation";
|
|
3
4
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
4
5
|
import { REST_API_DEFAULTS } from "./defaults.js";
|
|
5
6
|
import { resolveDeployOptions } from "./deploy-options.js";
|
|
@@ -37,6 +38,19 @@ class RestApiBuilder {
|
|
|
37
38
|
this.#root.addResource(pathPart, configure);
|
|
38
39
|
return this;
|
|
39
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Copies non-`props` state onto a freshly cloned builder. The resource
|
|
43
|
+
* tree is deep-cloned via `ResourceBuilder.copyInto` so mutations on
|
|
44
|
+
* either side after `.copy()` do not leak; the alarm-builder array is
|
|
45
|
+
* spread into a fresh container with elements shared by reference per
|
|
46
|
+
* ADR-0005's shallow-clone stance.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
[COPY_STATE](target) {
|
|
51
|
+
this.#root.copyInto(target.#root);
|
|
52
|
+
target.#customAlarms.push(...this.#customAlarms);
|
|
53
|
+
}
|
|
40
54
|
build(scope, id, context) {
|
|
41
55
|
const { accessLogging, recommendedAlarms: alarmConfig, ...restApiProps } = this.props;
|
|
42
56
|
const { accessLogGroup, deployOptions } = resolveDeployOptions(scope, id, accessLogging, REST_API_DEFAULTS.deployOptions ?? {}, restApiProps.deployOptions ?? {});
|
|
@@ -83,6 +97,6 @@ class RestApiBuilder {
|
|
|
83
97
|
* ```
|
|
84
98
|
*/
|
|
85
99
|
export function createRestApiBuilder() {
|
|
86
|
-
return
|
|
100
|
+
return taggedBuilder(RestApiBuilder);
|
|
87
101
|
}
|
|
88
102
|
//# sourceMappingURL=rest-api-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest-api-builder.js","sourceRoot":"","sources":["../../src/rest-api-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,OAAO,GAGR,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAmC,MAAM,oBAAoB,CAAC;A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