@composurecdk/cloudwatch 0.3.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 ADDED
@@ -0,0 +1,68 @@
1
+ # @composurecdk/cloudwatch
2
+
3
+ CloudWatch alarm primitives for [ComposureCDK](../../README.md).
4
+
5
+ This package provides the shared types and utilities that ComposureCDK resource packages use to create CloudWatch alarms. It separates generic alarm machinery from resource-specific alarm definitions, so the same primitives can be reused across `@composurecdk/lambda` and future resource packages.
6
+
7
+ Most users interact with alarms through a resource package (e.g., `@composurecdk/lambda`'s `recommendedAlarms` and `addAlarm`). Use this package directly when building custom alarm definitions or creating a new ComposureCDK resource package.
8
+
9
+ ## AlarmConfig
10
+
11
+ Partial override type for tuning alarm thresholds without replacing the entire alarm configuration. Resource packages use this as the user-facing knob for recommended alarms.
12
+
13
+ ```ts
14
+ import type { AlarmConfig } from "@composurecdk/cloudwatch";
15
+
16
+ const overrides: AlarmConfig = {
17
+ threshold: 5,
18
+ evaluationPeriods: 3,
19
+ datapointsToAlarm: 2,
20
+ };
21
+ ```
22
+
23
+ ## AlarmDefinitionBuilder
24
+
25
+ Fluent builder for constructing deferred alarm definitions. The metric factory is stored at configuration time and resolved later against a concrete construct during `build()`.
26
+
27
+ ```ts
28
+ import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
29
+ import type { Function as LambdaFunction } from "aws-cdk-lib/aws-lambda";
30
+
31
+ const builder = new AlarmDefinitionBuilder<LambdaFunction>("highInvocations")
32
+ .metric((fn) => fn.metricInvocations({ period: Duration.minutes(1) }))
33
+ .threshold(1000)
34
+ .greaterThanOrEqual()
35
+ .evaluationPeriods(3)
36
+ .datapointsToAlarm(2)
37
+ .description("Invocation count is unusually high");
38
+
39
+ // Later, during build:
40
+ const definition = builder.resolve(lambdaFunction);
41
+ ```
42
+
43
+ The `description` method also accepts a factory for contextual descriptions:
44
+
45
+ ```ts
46
+ builder.description((def) => `Alert when invocations >= ${def.threshold} per minute`);
47
+ ```
48
+
49
+ ## createAlarms
50
+
51
+ Factory function that creates CDK [Alarm](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.Alarm.html) constructs from fully-resolved `AlarmDefinition`s. Returns a `Record<string, Alarm>` keyed by each definition's key.
52
+
53
+ ```ts
54
+ import { createAlarms } from "@composurecdk/cloudwatch";
55
+
56
+ const alarms = createAlarms(scope, "MyFunction", definitions);
57
+ // alarms.errors, alarms.throttles, etc.
58
+ ```
59
+
60
+ Construct IDs follow the pattern `${id}${Capitalize(key)}Alarm` (e.g., `MyFunctionErrorsAlarm`).
61
+
62
+ ## AlarmDefinition
63
+
64
+ The fully-resolved alarm descriptor consumed by `createAlarms`. All fields are required — this is the canonical form after defaults and overrides have been merged.
65
+
66
+ ```ts
67
+ import type { AlarmDefinition } from "@composurecdk/cloudwatch";
68
+ ```
@@ -0,0 +1,17 @@
1
+ import type { TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
2
+ /**
3
+ * Configuration for a single recommended CloudWatch alarm.
4
+ * Every field has a documented default; users override individual
5
+ * fields to tune thresholds without replacing the entire alarm.
6
+ */
7
+ export interface AlarmConfig {
8
+ /** Alarm threshold. Default varies per alarm type. */
9
+ threshold?: number;
10
+ /** Number of evaluation periods before triggering. @default 1 */
11
+ evaluationPeriods?: number;
12
+ /** Datapoints within evaluation periods required to trigger. @default 1 */
13
+ datapointsToAlarm?: number;
14
+ /** How to treat missing data points. @default TreatMissingData.NOT_BREACHING */
15
+ treatMissingData?: TreatMissingData;
16
+ }
17
+ //# 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,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iEAAiE;IACjE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,2EAA2E;IAC3E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=alarm-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alarm-config.js","sourceRoot":"","sources":["../src/alarm-config.ts"],"names":[],"mappings":""}
@@ -0,0 +1,40 @@
1
+ import { type Metric, TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
2
+ import type { AlarmDefinition } from "./alarm-definition.js";
3
+ /**
4
+ * Fluent builder for constructing deferred {@link AlarmDefinition}s.
5
+ *
6
+ * Stores a metric factory `(construct: T) => Metric` at configuration time.
7
+ * Call {@link resolve} during build to invoke the factory and produce a
8
+ * complete {@link AlarmDefinition}.
9
+ *
10
+ * @typeParam TConstruct - The construct type the metric factory receives.
11
+ */
12
+ export declare class AlarmDefinitionBuilder<TConstruct> {
13
+ private readonly _key;
14
+ private _metricFactory?;
15
+ private _threshold;
16
+ private _comparisonOperator;
17
+ private _evaluationPeriods;
18
+ private _datapointsToAlarm;
19
+ private _treatMissingData;
20
+ private _description;
21
+ constructor(key: string);
22
+ metric(factory: (construct: TConstruct) => Metric): this;
23
+ threshold(value: number): this;
24
+ greaterThan(): this;
25
+ greaterThanOrEqual(): this;
26
+ lessThan(): this;
27
+ lessThanOrEqual(): this;
28
+ evaluationPeriods(n: number): this;
29
+ datapointsToAlarm(n: number): this;
30
+ treatMissingData(treatment: TreatMissingData): this;
31
+ description(text: string | ((definition: AlarmDefinition) => string)): this;
32
+ /**
33
+ * Resolves the deferred metric factory against a construct and
34
+ * returns a complete {@link AlarmDefinition}.
35
+ *
36
+ * @throws If {@link metric} was not called before resolve.
37
+ */
38
+ resolve(construct: TConstruct): AlarmDefinition;
39
+ }
40
+ //# sourceMappingURL=alarm-definition-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alarm-definition-builder.d.ts","sourceRoot":"","sources":["../src/alarm-definition-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,MAAM,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;;;;;GAQG;AACH,qBAAa,sBAAsB,CAAC,UAAU;IAC5C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAC,CAAoC;IAC3D,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,mBAAmB,CAA6C;IACxE,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,YAAY,CAA0D;gBAElE,GAAG,EAAE,MAAM;IAIvB,MAAM,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,MAAM,GAAG,IAAI;IAKxD,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK9B,WAAW,IAAI,IAAI;IAKnB,kBAAkB,IAAI,IAAI;IAK1B,QAAQ,IAAI,IAAI;IAKhB,eAAe,IAAI,IAAI;IAKvB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAKlC,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAKlC,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAKnD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,UAAU,EAAE,eAAe,KAAK,MAAM,CAAC,GAAG,IAAI;IAK3E;;;;;OAKG;IACH,OAAO,CAAC,SAAS,EAAE,UAAU,GAAG,eAAe;CAuBhD"}
@@ -0,0 +1,88 @@
1
+ import { ComparisonOperator, TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
2
+ /**
3
+ * Fluent builder for constructing deferred {@link AlarmDefinition}s.
4
+ *
5
+ * Stores a metric factory `(construct: T) => Metric` at configuration time.
6
+ * Call {@link resolve} during build to invoke the factory and produce a
7
+ * complete {@link AlarmDefinition}.
8
+ *
9
+ * @typeParam TConstruct - The construct type the metric factory receives.
10
+ */
11
+ export class AlarmDefinitionBuilder {
12
+ _key;
13
+ _metricFactory;
14
+ _threshold = 0;
15
+ _comparisonOperator = ComparisonOperator.GREATER_THAN_THRESHOLD;
16
+ _evaluationPeriods = 1;
17
+ _datapointsToAlarm = 1;
18
+ _treatMissingData = TreatMissingData.NOT_BREACHING;
19
+ _description = "";
20
+ constructor(key) {
21
+ this._key = key;
22
+ }
23
+ metric(factory) {
24
+ this._metricFactory = factory;
25
+ return this;
26
+ }
27
+ threshold(value) {
28
+ this._threshold = value;
29
+ return this;
30
+ }
31
+ greaterThan() {
32
+ this._comparisonOperator = ComparisonOperator.GREATER_THAN_THRESHOLD;
33
+ return this;
34
+ }
35
+ greaterThanOrEqual() {
36
+ this._comparisonOperator = ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD;
37
+ return this;
38
+ }
39
+ lessThan() {
40
+ this._comparisonOperator = ComparisonOperator.LESS_THAN_THRESHOLD;
41
+ return this;
42
+ }
43
+ lessThanOrEqual() {
44
+ this._comparisonOperator = ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD;
45
+ return this;
46
+ }
47
+ evaluationPeriods(n) {
48
+ this._evaluationPeriods = n;
49
+ return this;
50
+ }
51
+ datapointsToAlarm(n) {
52
+ this._datapointsToAlarm = n;
53
+ return this;
54
+ }
55
+ treatMissingData(treatment) {
56
+ this._treatMissingData = treatment;
57
+ return this;
58
+ }
59
+ description(text) {
60
+ this._description = text;
61
+ return this;
62
+ }
63
+ /**
64
+ * Resolves the deferred metric factory against a construct and
65
+ * returns a complete {@link AlarmDefinition}.
66
+ *
67
+ * @throws If {@link metric} was not called before resolve.
68
+ */
69
+ resolve(construct) {
70
+ if (!this._metricFactory) {
71
+ throw new Error(`AlarmDefinitionBuilder "${this._key}": metric() must be called before resolve()`);
72
+ }
73
+ const definition = {
74
+ key: this._key,
75
+ metric: this._metricFactory(construct),
76
+ threshold: this._threshold,
77
+ comparisonOperator: this._comparisonOperator,
78
+ evaluationPeriods: this._evaluationPeriods,
79
+ datapointsToAlarm: this._datapointsToAlarm,
80
+ treatMissingData: this._treatMissingData,
81
+ description: "",
82
+ };
83
+ definition.description =
84
+ typeof this._description === "function" ? this._description(definition) : this._description;
85
+ return definition;
86
+ }
87
+ }
88
+ //# sourceMappingURL=alarm-definition-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alarm-definition-builder.js","sourceRoot":"","sources":["../src/alarm-definition-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAe,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG/F;;;;;;;;GAQG;AACH,MAAM,OAAO,sBAAsB;IAChB,IAAI,CAAS;IACtB,cAAc,CAAqC;IACnD,UAAU,GAAG,CAAC,CAAC;IACf,mBAAmB,GAAG,kBAAkB,CAAC,sBAAsB,CAAC;IAChE,kBAAkB,GAAG,CAAC,CAAC;IACvB,kBAAkB,GAAG,CAAC,CAAC;IACvB,iBAAiB,GAAG,gBAAgB,CAAC,aAAa,CAAC;IACnD,YAAY,GAAuD,EAAE,CAAC;IAE9E,YAAY,GAAW;QACrB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,OAA0C;QAC/C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS,CAAC,KAAa;QACrB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW;QACT,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC,sBAAsB,CAAC;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC,kCAAkC,CAAC;QACjF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,eAAe;QACb,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC,+BAA+B,CAAC;QAC9E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iBAAiB,CAAC,CAAS;QACzB,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iBAAiB,CAAC,CAAS;QACzB,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB,CAAC,SAA2B;QAC1C,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CAAC,IAAwD;QAClE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,SAAqB;QAC3B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,2BAA2B,IAAI,CAAC,IAAI,6CAA6C,CAClF,CAAC;QACJ,CAAC;QAED,MAAM,UAAU,GAAoB;YAClC,GAAG,EAAE,IAAI,CAAC,IAAI;YACd,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YACtC,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,kBAAkB,EAAE,IAAI,CAAC,mBAAmB;YAC5C,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;YAC1C,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;YAC1C,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;YACxC,WAAW,EAAE,EAAE;SAChB,CAAC;QAEF,UAAU,CAAC,WAAW;YACpB,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC;QAE9F,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import type { ComparisonOperator, Metric, TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
2
+ /**
3
+ * A fully-resolved alarm descriptor. All fields are required —
4
+ * this is the canonical form consumed by {@link createAlarms}.
5
+ */
6
+ export interface AlarmDefinition {
7
+ key: string;
8
+ metric: Metric;
9
+ threshold: number;
10
+ comparisonOperator: ComparisonOperator;
11
+ evaluationPeriods: number;
12
+ datapointsToAlarm: number;
13
+ treatMissingData: TreatMissingData;
14
+ description: string;
15
+ }
16
+ //# sourceMappingURL=alarm-definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alarm-definition.d.ts","sourceRoot":"","sources":["../src/alarm-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/F;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=alarm-definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alarm-definition.js","sourceRoot":"","sources":["../src/alarm-definition.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { Alarm } from "aws-cdk-lib/aws-cloudwatch";
2
+ import type { IConstruct } from "constructs";
3
+ import type { AlarmDefinition } from "./alarm-definition.js";
4
+ /**
5
+ * Creates CDK {@link Alarm} constructs from fully-resolved {@link AlarmDefinition}s.
6
+ *
7
+ * Validates that all definition keys are unique before creating alarms.
8
+ *
9
+ * @param scope - CDK construct scope.
10
+ * @param id - Base identifier; each alarm ID is `${id}${Capitalize(key)}Alarm`.
11
+ * @param definitions - Fully-resolved alarm definitions.
12
+ * @returns A record mapping each definition's key to its created Alarm.
13
+ * @throws If duplicate keys are found in the definitions.
14
+ */
15
+ export declare function createAlarms(scope: IConstruct, id: string, definitions: AlarmDefinition[]): Record<string, Alarm>;
16
+ //# sourceMappingURL=create-alarms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-alarms.d.ts","sourceRoot":"","sources":["../src/create-alarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAM7D;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,eAAe,EAAE,GAC7B,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAqBvB"}
@@ -0,0 +1,33 @@
1
+ function capitalize(s) {
2
+ return s[0].toUpperCase() + s.slice(1);
3
+ }
4
+ /**
5
+ * Creates CDK {@link Alarm} constructs from fully-resolved {@link AlarmDefinition}s.
6
+ *
7
+ * Validates that all definition keys are unique before creating alarms.
8
+ *
9
+ * @param scope - CDK construct scope.
10
+ * @param id - Base identifier; each alarm ID is `${id}${Capitalize(key)}Alarm`.
11
+ * @param definitions - Fully-resolved alarm definitions.
12
+ * @returns A record mapping each definition's key to its created Alarm.
13
+ * @throws If duplicate keys are found in the definitions.
14
+ */
15
+ export function createAlarms(scope, id, definitions) {
16
+ const alarms = {};
17
+ for (const def of definitions) {
18
+ if (def.key in alarms) {
19
+ throw new Error(`Duplicate alarm key "${def.key}". Custom alarms cannot use the same key as a recommended alarm. ` +
20
+ `Disable the recommended alarm first, or use a different key.`);
21
+ }
22
+ alarms[def.key] = def.metric.createAlarm(scope, `${id}${capitalize(def.key)}Alarm`, {
23
+ threshold: def.threshold,
24
+ evaluationPeriods: def.evaluationPeriods,
25
+ datapointsToAlarm: def.datapointsToAlarm,
26
+ treatMissingData: def.treatMissingData,
27
+ comparisonOperator: def.comparisonOperator,
28
+ alarmDescription: def.description,
29
+ });
30
+ }
31
+ return alarms;
32
+ }
33
+ //# sourceMappingURL=create-alarms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-alarms.js","sourceRoot":"","sources":["../src/create-alarms.ts"],"names":[],"mappings":"AAIA,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAiB,EACjB,EAAU,EACV,WAA8B;IAE9B,MAAM,MAAM,GAA0B,EAAE,CAAC;IAEzC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,IAAI,GAAG,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,wBAAwB,GAAG,CAAC,GAAG,mEAAmE;gBAChG,8DAA8D,CACjE,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE;YAClF,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;YACtC,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;YAC1C,gBAAgB,EAAE,GAAG,CAAC,WAAW;SAClC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type { AlarmConfig } from "./alarm-config.js";
2
+ export type { AlarmDefinition } from "./alarm-definition.js";
3
+ export { AlarmDefinitionBuilder } from "./alarm-definition-builder.js";
4
+ export { createAlarms } from "./create-alarms.js";
5
+ export { resolveAlarmConfig, type ResolvedAlarmConfig } from "./resolve-alarm-config.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { AlarmDefinitionBuilder } from "./alarm-definition-builder.js";
2
+ export { createAlarms } from "./create-alarms.js";
3
+ export { resolveAlarmConfig } from "./resolve-alarm-config.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAA4B,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
2
+ import type { AlarmConfig } from "./alarm-config.js";
3
+ /**
4
+ * A fully-resolved alarm configuration where every field is required.
5
+ * Produced by {@link resolveAlarmConfig} after merging user overrides
6
+ * onto defaults.
7
+ */
8
+ export interface ResolvedAlarmConfig {
9
+ threshold: number;
10
+ evaluationPeriods: number;
11
+ datapointsToAlarm: number;
12
+ treatMissingData: TreatMissingData;
13
+ }
14
+ /**
15
+ * Resolves an absolute-threshold alarm config by layering user overrides
16
+ * onto the defaults.
17
+ */
18
+ export declare function resolveAlarmConfig(userConfig: AlarmConfig | undefined, defaults: Required<AlarmConfig>): ResolvedAlarmConfig;
19
+ //# sourceMappingURL=resolve-alarm-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-alarm-config.d.ts","sourceRoot":"","sources":["../src/resolve-alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,WAAW,GAAG,SAAS,EACnC,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,GAC9B,mBAAmB,CAOrB"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Resolves an absolute-threshold alarm config by layering user overrides
3
+ * onto the defaults.
4
+ */
5
+ export function resolveAlarmConfig(userConfig, defaults) {
6
+ return {
7
+ threshold: userConfig?.threshold ?? defaults.threshold,
8
+ evaluationPeriods: userConfig?.evaluationPeriods ?? defaults.evaluationPeriods,
9
+ datapointsToAlarm: userConfig?.datapointsToAlarm ?? defaults.datapointsToAlarm,
10
+ treatMissingData: userConfig?.treatMissingData ?? defaults.treatMissingData,
11
+ };
12
+ }
13
+ //# sourceMappingURL=resolve-alarm-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-alarm-config.js","sourceRoot":"","sources":["../src/resolve-alarm-config.ts"],"names":[],"mappings":"AAeA;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAmC,EACnC,QAA+B;IAE/B,OAAO;QACL,SAAS,EAAE,UAAU,EAAE,SAAS,IAAI,QAAQ,CAAC,SAAS;QACtD,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,IAAI,QAAQ,CAAC,iBAAiB;QAC9E,iBAAiB,EAAE,UAAU,EAAE,iBAAiB,IAAI,QAAQ,CAAC,iBAAiB;QAC9E,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,IAAI,QAAQ,CAAC,gBAAgB;KAC5E,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@composurecdk/cloudwatch",
3
+ "version": "0.3.0",
4
+ "description": "Composable CloudWatch alarm primitives for composureCDK resource packages",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/laazyj/composureCDK",
8
+ "directory": "packages/cloudwatch"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "clean": "rm -rf dist",
25
+ "build": "tsc -p tsconfig.build.json",
26
+ "typecheck": "tsc --noEmit",
27
+ "test": "vitest run --passWithNoTests",
28
+ "test:watch": "vitest"
29
+ },
30
+ "keywords": [],
31
+ "author": "Jason Duffett (https://github.com/laazyj)",
32
+ "license": "MIT",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "type": "module",
37
+ "peerDependencies": {
38
+ "aws-cdk-lib": "^2.0.0",
39
+ "constructs": "^10.0.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^25.5.0",
43
+ "aws-cdk-lib": "^2.245.0",
44
+ "constructs": "^10.6.0",
45
+ "typescript": "^6.0.2",
46
+ "vitest": "^4.1.2"
47
+ }
48
+ }