@composurecdk/cloudwatch 0.8.3 → 0.8.5

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.
@@ -7,13 +7,15 @@ declare const alarmNameBrand: unique symbol;
7
7
  export type AlarmName = string & {
8
8
  readonly [alarmNameBrand]: true;
9
9
  };
10
+ /** Validates a CloudWatch alarm name against {@link ALARM_NAME}. @throws on invalid input. */
11
+ export declare function validateAlarmName(value: string): void;
10
12
  /**
11
- * Validates and brands a string as an {@link AlarmName}. The string is used
12
- * verbatim no sanitisation — so what the caller writes is exactly what
13
- * appears in CloudWatch.
13
+ * Validates and brands a string as an {@link AlarmName}. Surrounding whitespace
14
+ * is trimmed, then the value is used verbatim — so what the caller writes is
15
+ * exactly what appears in CloudWatch.
14
16
  *
15
17
  * @throws If the input is empty, exceeds 255 chars, or contains characters
16
- * outside CloudWatch's allowed set: `[A-Za-z0-9-_./#:()+ =@]`.
18
+ * outside CloudWatch's allowed set.
17
19
  */
18
20
  export declare function alarmName(input: string): AlarmName;
19
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"alarm-name.d.ts","sourceRoot":"","sources":["../../src/alarm-name.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAKrE;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAclD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,SAAM,GAAG,SAAS,CAG/E;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ3C"}
1
+ {"version":3,"file":"alarm-name.d.ts","sourceRoot":"","sources":["../../src/alarm-name.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAiBrE,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAErD;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAIlD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,SAAM,GAAG,SAAS,CAG/E;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ3C"}
@@ -1,29 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAlarmName = validateAlarmName;
3
4
  exports.alarmName = alarmName;
4
5
  exports.joinAlarmName = joinAlarmName;
5
6
  exports.kebab = kebab;
6
- const VALID_CHARS = /^[A-Za-z0-9\-_./#:()+ =@]+$/;
7
- const MAX_LEN = 255;
7
+ const cloudformation_1 = require("@composurecdk/cloudformation");
8
8
  /**
9
- * Validates and brands a string as an {@link AlarmName}. The string is used
10
- * verbatim no sanitisation so what the caller writes is exactly what
11
- * appears in CloudWatch.
9
+ * The CloudWatch AlarmName constraint. Its character set is exactly the shared
10
+ * `charSets.ALNUM` + `charSets.AWS_NAME_PUNCT` spine with no property-specific
11
+ * tail a clean reuse of the catalogue fragments. See ADR-0010.
12
+ */
13
+ const ALARM_NAME = (0, cloudformation_1.stringConstraint)({
14
+ name: "CloudWatch AlarmName",
15
+ charClass: `${cloudformation_1.charSets.ALNUM}${cloudformation_1.charSets.AWS_NAME_PUNCT}`,
16
+ minLength: 1,
17
+ maxLength: 255,
18
+ allowed: "A-Z a-z 0-9 space and - _ . / # : ( ) + = @",
19
+ source: "https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html",
20
+ });
21
+ /** Validates a CloudWatch alarm name against {@link ALARM_NAME}. @throws on invalid input. */
22
+ function validateAlarmName(value) {
23
+ (0, cloudformation_1.validateString)(value, ALARM_NAME);
24
+ }
25
+ /**
26
+ * Validates and brands a string as an {@link AlarmName}. Surrounding whitespace
27
+ * is trimmed, then the value is used verbatim — so what the caller writes is
28
+ * exactly what appears in CloudWatch.
12
29
  *
13
30
  * @throws If the input is empty, exceeds 255 chars, or contains characters
14
- * outside CloudWatch's allowed set: `[A-Za-z0-9-_./#:()+ =@]`.
31
+ * outside CloudWatch's allowed set.
15
32
  */
16
33
  function alarmName(input) {
17
34
  const trimmed = input.trim();
18
- if (trimmed.length === 0) {
19
- throw new Error("alarm name cannot be empty");
20
- }
21
- if (trimmed.length > MAX_LEN) {
22
- throw new Error(`alarm name exceeds ${String(MAX_LEN)} chars: "${trimmed}"`);
23
- }
24
- if (!VALID_CHARS.test(trimmed)) {
25
- throw new Error(`alarm name contains invalid characters (allowed: A-Z a-z 0-9 - _ . / # : ( ) + = @ space): "${trimmed}"`);
26
- }
35
+ validateAlarmName(trimmed);
27
36
  return trimmed;
28
37
  }
29
38
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"alarm-name.js","sourceRoot":"","sources":["../../src/alarm-name.ts"],"names":[],"mappings":";;AAoBA,8BAcC;AAQD,sCAGC;AAMD,sBAQC;AAlDD,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAClD,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB;;;;;;;GAOG;AACH,SAAgB,SAAS,CAAC,KAAa;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI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The input value's type (e.g. `Duration`, `number`).
6
+ */
7
+ export interface AlarmThresholdBasisOptions<T> {
8
+ /** Construct to annotate when the alarm is skipped. */
9
+ scope: IConstruct;
10
+ /**
11
+ * The value the alarm threshold is derived from. May be `undefined` (the
12
+ * input was simply not configured) or an unresolved token (e.g. threaded
13
+ * through a `CfnParameter`).
14
+ */
15
+ value: T | undefined;
16
+ /**
17
+ * Converts a known-resolved `value` into the numeric basis for the threshold
18
+ * (e.g. `(d) => d.toMilliseconds()`, or the identity for a raw number). Only
19
+ * invoked once `value` is confirmed present and resolved, so it is safe to
20
+ * call conversions that throw on tokens.
21
+ */
22
+ resolve: (value: T) => number;
23
+ /**
24
+ * Predicate deciding whether `value` is an unresolved token. Defaults to
25
+ * {@link Token.isUnresolved}. Override for wrapper types that carry their own
26
+ * check rather than being a token directly — notably a CDK `Duration`, whose
27
+ * token state is exposed via `value.isUnresolved()`.
28
+ */
29
+ isUnresolved?: (value: T) => boolean;
30
+ /**
31
+ * Stable warning identifier, also the handle callers pass to
32
+ * `Annotations.of(scope).acknowledgeWarning(...)` to suppress it. By
33
+ * convention `@composurecdk/<package>:<slug>`.
34
+ */
35
+ warningId: string;
36
+ /**
37
+ * Human-readable name of the alarm being skipped, interpolated into the
38
+ * warning (e.g. `"Lambda duration"`). Phrase it to read after
39
+ * "Skipping the recommended ".
40
+ */
41
+ alarmLabel: string;
42
+ /**
43
+ * How a caller can intentionally suppress the warning, interpolated into the
44
+ * warning's closing sentence (e.g. `"recommendedAlarms({ duration: false })"`).
45
+ */
46
+ suppressHint: string;
47
+ }
48
+ /**
49
+ * Resolves the numeric basis for a derived-threshold alarm, short-circuiting
50
+ * when the basis cannot be known at synth time.
51
+ *
52
+ * Recommended alarms whose threshold is a function of a configured input (a
53
+ * percentage of a timeout, of a reserved-concurrency limit, etc.) can only be
54
+ * rendered when that input is concrete. When the input is an unresolved token —
55
+ * e.g. a value threaded through a `CfnParameter` — there is no number to derive
56
+ * from at synth time, and unit-converting it would either throw or silently
57
+ * produce a meaningless threshold. In that case this annotates `scope` with a
58
+ * standardized, acknowledgeable warning and returns `undefined`, signalling the
59
+ * caller to omit the alarm.
60
+ *
61
+ * Returns `undefined` (without warning) when `value` is `undefined`, since an
62
+ * unconfigured input is not a skipped guardrail. The escape hatch that disables
63
+ * the alarm entirely (e.g. `recommendedAlarms({ duration: false })`) belongs at
64
+ * the call site, ahead of this call.
65
+ *
66
+ * @returns The resolved numeric basis, or `undefined` when the alarm should be
67
+ * omitted.
68
+ * @see https://github.com/laazyj/composureCDK/issues/196
69
+ */
70
+ export declare function resolveAlarmThresholdBasis<T>(opts: AlarmThresholdBasisOptions<T>): number | undefined;
71
+ //# sourceMappingURL=alarm-threshold-basis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alarm-threshold-basis.d.ts","sourceRoot":"","sources":["../../src/alarm-threshold-basis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,0BAA0B,CAAC,CAAC;IAC3C,uDAAuD;IACvD,KAAK,EAAE,UAAU,CAAC;IAElB;;;;OAIG;IACH,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IAErB;;;;;OAKG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IAE9B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IAErC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAClC,MAAM,GAAG,SAAS,CAgBpB"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveAlarmThresholdBasis = resolveAlarmThresholdBasis;
4
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
5
+ /**
6
+ * Resolves the numeric basis for a derived-threshold alarm, short-circuiting
7
+ * when the basis cannot be known at synth time.
8
+ *
9
+ * Recommended alarms whose threshold is a function of a configured input (a
10
+ * percentage of a timeout, of a reserved-concurrency limit, etc.) can only be
11
+ * rendered when that input is concrete. When the input is an unresolved token —
12
+ * e.g. a value threaded through a `CfnParameter` — there is no number to derive
13
+ * from at synth time, and unit-converting it would either throw or silently
14
+ * produce a meaningless threshold. In that case this annotates `scope` with a
15
+ * standardized, acknowledgeable warning and returns `undefined`, signalling the
16
+ * caller to omit the alarm.
17
+ *
18
+ * Returns `undefined` (without warning) when `value` is `undefined`, since an
19
+ * unconfigured input is not a skipped guardrail. The escape hatch that disables
20
+ * the alarm entirely (e.g. `recommendedAlarms({ duration: false })`) belongs at
21
+ * the call site, ahead of this call.
22
+ *
23
+ * @returns The resolved numeric basis, or `undefined` when the alarm should be
24
+ * omitted.
25
+ * @see https://github.com/laazyj/composureCDK/issues/196
26
+ */
27
+ function resolveAlarmThresholdBasis(opts) {
28
+ if (opts.value === undefined)
29
+ return undefined;
30
+ const isUnresolved = opts.isUnresolved ?? aws_cdk_lib_1.Token.isUnresolved;
31
+ if (isUnresolved(opts.value)) {
32
+ aws_cdk_lib_1.Annotations.of(opts.scope).addWarningV2(opts.warningId, `Skipping the recommended ${opts.alarmLabel} alarm: its threshold is derived from a ` +
33
+ `value that is an unresolved token and cannot be resolved to a concrete threshold at ` +
34
+ `synth time. Set a literal value, add the alarm explicitly via addAlarm() with a fixed ` +
35
+ `threshold, or suppress this warning with ${opts.suppressHint}.`);
36
+ return undefined;
37
+ }
38
+ return opts.resolve(opts.value);
39
+ }
40
+ //# sourceMappingURL=alarm-threshold-basis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alarm-threshold-basis.js","sourceRoot":"","sources":["../../src/alarm-threshold-basis.ts"],"names":[],"mappings":";;AA8EA,gEAkBC;AAhGD,6CAAiD;AAwDjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,0BAA0B,CACxC,IAAmC;IAEnC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE/C,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,mBAAK,CAAC,YAAY,CAAC;IAC7D,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,yBAAW,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CACrC,IAAI,CAAC,SAAS,EACd,4BAA4B,IAAI,CAAC,UAAU,0CAA0C;YACnF,sFAAsF;YACtF,wFAAwF;YACxF,4CAA4C,IAAI,CAAC,YAAY,GAAG,CACnE,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC"}
@@ -1,11 +1,26 @@
1
+ import { validateAlarmName } from "./alarm-name.js";
1
2
  export type { AlarmConfig, AlarmConfigDefaults } from "./alarm-config.js";
2
3
  export type { AlarmDefinition, AlarmMetric } from "./alarm-definition.js";
3
4
  export { AlarmDefinitionBuilder } from "./alarm-definition-builder.js";
4
5
  export { type AlarmName, alarmName } from "./alarm-name.js";
6
+ export { type AlarmThresholdBasisOptions, resolveAlarmThresholdBasis, } from "./alarm-threshold-basis.js";
5
7
  export { defaultAlarmName } from "./default-alarm-name.js";
6
8
  export { createAlarms } from "./create-alarms.js";
7
9
  export { resolveAlarmConfig, type ResolvedAlarmConfig } from "./resolve-alarm-config.js";
8
10
  export { alarmActionsPolicy } from "./policies/alarm-actions-policy.js";
9
11
  export type { AlarmActionsPolicyConfig, AlarmMatchContext, AlarmMatcher, } from "./policies/alarm-actions-policy.js";
10
12
  export { alarmNamePolicy, type AlarmNamePolicyConfig, type AlarmNameRule, type AlarmNameTransformContext, } from "./policies/alarm-name-policy.js";
13
+ /**
14
+ * This package's AWS-property constraints, grouped by application strategy.
15
+ * The `constraints.validate.*` / `constraints.sanitize.*` shape is identical in
16
+ * every builder package; the underlying constraint definition stays
17
+ * module-private. The branded {@link alarmName} constructor layers on top of the
18
+ * same validation. See ADR-0010.
19
+ */
20
+ export declare const constraints: {
21
+ validate: {
22
+ alarmName: typeof validateAlarmName;
23
+ };
24
+ sanitize: {};
25
+ };
11
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,YAAY,EACV,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,yBAAyB,GAC/B,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EACL,KAAK,0BAA0B,EAC/B,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,YAAY,EACV,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,GACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,yBAAyB,GAC/B,MAAM,iCAAiC,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;;;;CAGO,CAAC"}
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.alarmNamePolicy = exports.alarmActionsPolicy = exports.resolveAlarmConfig = exports.createAlarms = exports.defaultAlarmName = exports.alarmName = exports.AlarmDefinitionBuilder = void 0;
3
+ exports.constraints = exports.alarmNamePolicy = exports.alarmActionsPolicy = exports.resolveAlarmConfig = exports.createAlarms = exports.defaultAlarmName = exports.resolveAlarmThresholdBasis = exports.alarmName = exports.AlarmDefinitionBuilder = void 0;
4
+ const alarm_name_js_1 = require("./alarm-name.js");
4
5
  var alarm_definition_builder_js_1 = require("./alarm-definition-builder.js");
5
6
  Object.defineProperty(exports, "AlarmDefinitionBuilder", { enumerable: true, get: function () { return alarm_definition_builder_js_1.AlarmDefinitionBuilder; } });
6
- var alarm_name_js_1 = require("./alarm-name.js");
7
- Object.defineProperty(exports, "alarmName", { enumerable: true, get: function () { return alarm_name_js_1.alarmName; } });
7
+ var alarm_name_js_2 = require("./alarm-name.js");
8
+ Object.defineProperty(exports, "alarmName", { enumerable: true, get: function () { return alarm_name_js_2.alarmName; } });
9
+ var alarm_threshold_basis_js_1 = require("./alarm-threshold-basis.js");
10
+ Object.defineProperty(exports, "resolveAlarmThresholdBasis", { enumerable: true, get: function () { return alarm_threshold_basis_js_1.resolveAlarmThresholdBasis; } });
8
11
  var default_alarm_name_js_1 = require("./default-alarm-name.js");
9
12
  Object.defineProperty(exports, "defaultAlarmName", { enumerable: true, get: function () { return default_alarm_name_js_1.defaultAlarmName; } });
10
13
  var create_alarms_js_1 = require("./create-alarms.js");
@@ -15,4 +18,15 @@ var alarm_actions_policy_js_1 = require("./policies/alarm-actions-policy.js");
15
18
  Object.defineProperty(exports, "alarmActionsPolicy", { enumerable: true, get: function () { return alarm_actions_policy_js_1.alarmActionsPolicy; } });
16
19
  var alarm_name_policy_js_1 = require("./policies/alarm-name-policy.js");
17
20
  Object.defineProperty(exports, "alarmNamePolicy", { enumerable: true, get: function () { return alarm_name_policy_js_1.alarmNamePolicy; } });
21
+ /**
22
+ * This package's AWS-property constraints, grouped by application strategy.
23
+ * The `constraints.validate.*` / `constraints.sanitize.*` shape is identical in
24
+ * every builder package; the underlying constraint definition stays
25
+ * module-private. The branded {@link alarmName} constructor layers on top of the
26
+ * same validation. See ADR-0010.
27
+ */
28
+ exports.constraints = {
29
+ validate: { alarmName: alarm_name_js_1.validateAlarmName },
30
+ sanitize: {},
31
+ };
18
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAEA,6EAAuE;AAA9D,qIAAA,sBAAsB,OAAA;AAC/B,iDAA4D;AAAnC,0GAAA,SAAS,OAAA;AAClC,iEAA2D;AAAlD,yHAAA,gBAAgB,OAAA;AACzB,uDAAkD;AAAzC,gHAAA,YAAY,OAAA;AACrB,qEAAyF;AAAhF,6HAAA,kBAAkB,OAAA;AAC3B,8EAAwE;AAA/D,6HAAA,kBAAkB,OAAA;AAM3B,wEAKyC;AAJvC,uHAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,mDAAoD;AAIpD,6EAAuE;AAA9D,qIAAA,sBAAsB,OAAA;AAC/B,iDAA4D;AAAnC,0GAAA,SAAS,OAAA;AAClC,uEAGoC;AADlC,sIAAA,0BAA0B,OAAA;AAE5B,iEAA2D;AAAlD,yHAAA,gBAAgB,OAAA;AACzB,uDAAkD;AAAzC,gHAAA,YAAY,OAAA;AACrB,qEAAyF;AAAhF,6HAAA,kBAAkB,OAAA;AAC3B,8EAAwE;AAA/D,6HAAA,kBAAkB,OAAA;AAM3B,wEAKyC;AAJvC,uHAAA,eAAe,OAAA;AAMjB;;;;;;GAMG;AACU,QAAA,WAAW,GAAG;IACzB,QAAQ,EAAE,EAAE,SAAS,EAAE,iCAAiB,EAAE;IAC1C,QAAQ,EAAE,EAAE;CACiB,CAAC"}
@@ -7,13 +7,15 @@ declare const alarmNameBrand: unique symbol;
7
7
  export type AlarmName = string & {
8
8
  readonly [alarmNameBrand]: true;
9
9
  };
10
+ /** Validates a CloudWatch alarm name against {@link ALARM_NAME}. @throws on invalid input. */
11
+ export declare function validateAlarmName(value: string): void;
10
12
  /**
11
- * Validates and brands a string as an {@link AlarmName}. The string is used
12
- * verbatim no sanitisation — so what the caller writes is exactly what
13
- * appears in CloudWatch.
13
+ * Validates and brands a string as an {@link AlarmName}. Surrounding whitespace
14
+ * is trimmed, then the value is used verbatim — so what the caller writes is
15
+ * exactly what appears in CloudWatch.
14
16
  *
15
17
  * @throws If the input is empty, exceeds 255 chars, or contains characters
16
- * outside CloudWatch's allowed set: `[A-Za-z0-9-_./#:()+ =@]`.
18
+ * outside CloudWatch's allowed set.
17
19
  */
18
20
  export declare function alarmName(input: string): AlarmName;
19
21
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"alarm-name.d.ts","sourceRoot":"","sources":["../../src/alarm-name.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAKrE;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAclD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,SAAM,GAAG,SAAS,CAG/E;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ3C"}
1
+ {"version":3,"file":"alarm-name.d.ts","sourceRoot":"","sources":["../../src/alarm-name.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,cAAc,EAAE,OAAO,MAAM,CAAC;AAE5C;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAiBrE,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAErD;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAIlD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,SAAM,GAAG,SAAS,CAG/E;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ3C"}
@@ -1,24 +1,32 @@
1
- const VALID_CHARS = /^[A-Za-z0-9\-_./#:()+ =@]+$/;
2
- const MAX_LEN = 255;
1
+ import { charSets, stringConstraint, validateString } from "@composurecdk/cloudformation";
3
2
  /**
4
- * Validates and brands a string as an {@link AlarmName}. The string is used
5
- * verbatim no sanitisation so what the caller writes is exactly what
6
- * appears in CloudWatch.
3
+ * The CloudWatch AlarmName constraint. Its character set is exactly the shared
4
+ * `charSets.ALNUM` + `charSets.AWS_NAME_PUNCT` spine with no property-specific
5
+ * tail a clean reuse of the catalogue fragments. See ADR-0010.
6
+ */
7
+ const ALARM_NAME = stringConstraint({
8
+ name: "CloudWatch AlarmName",
9
+ charClass: `${charSets.ALNUM}${charSets.AWS_NAME_PUNCT}`,
10
+ minLength: 1,
11
+ maxLength: 255,
12
+ allowed: "A-Z a-z 0-9 space and - _ . / # : ( ) + = @",
13
+ source: "https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html",
14
+ });
15
+ /** Validates a CloudWatch alarm name against {@link ALARM_NAME}. @throws on invalid input. */
16
+ export function validateAlarmName(value) {
17
+ validateString(value, ALARM_NAME);
18
+ }
19
+ /**
20
+ * Validates and brands a string as an {@link AlarmName}. Surrounding whitespace
21
+ * is trimmed, then the value is used verbatim — so what the caller writes is
22
+ * exactly what appears in CloudWatch.
7
23
  *
8
24
  * @throws If the input is empty, exceeds 255 chars, or contains characters
9
- * outside CloudWatch's allowed set: `[A-Za-z0-9-_./#:()+ =@]`.
25
+ * outside CloudWatch's allowed set.
10
26
  */
11
27
  export function alarmName(input) {
12
28
  const trimmed = input.trim();
13
- if (trimmed.length === 0) {
14
- throw new Error("alarm name cannot be empty");
15
- }
16
- if (trimmed.length > MAX_LEN) {
17
- throw new Error(`alarm name exceeds ${String(MAX_LEN)} chars: "${trimmed}"`);
18
- }
19
- if (!VALID_CHARS.test(trimmed)) {
20
- throw new Error(`alarm name contains invalid characters (allowed: A-Z a-z 0-9 - _ . / # : ( ) + = @ space): "${trimmed}"`);
21
- }
29
+ validateAlarmName(trimmed);
22
30
  return trimmed;
23
31
  }
24
32
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"alarm-name.js","sourceRoot":"","sources":["../../src/alarm-name.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAClD,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,sBAAsB,MAAM,CAAC,OAAO,CAAC,YAAY,OAAO,GAAG,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,+FAA+F,OAAO,GAAG,CAC1G,CAAC;IACJ,CAAC;IACD,OAAO,OAAoB,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,QAA2B,EAAE,GAAG,GAAG,GAAG;IAClE,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC9D,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAA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AC;IAC9D,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,OAAO,KAAK;SACT,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,OAAO,CAAC,uBAAuB,EAAE,OAAO,CAAC;SACzC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,WAAW,EAAE,CAAC;AACnB,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { IConstruct } from "constructs";
2
+ /**
3
+ * Inputs to {@link resolveAlarmThresholdBasis}.
4
+ *
5
+ * @typeParam T - The input value's type (e.g. `Duration`, `number`).
6
+ */
7
+ export interface AlarmThresholdBasisOptions<T> {
8
+ /** Construct to annotate when the alarm is skipped. */
9
+ scope: IConstruct;
10
+ /**
11
+ * The value the alarm threshold is derived from. May be `undefined` (the
12
+ * input was simply not configured) or an unresolved token (e.g. threaded
13
+ * through a `CfnParameter`).
14
+ */
15
+ value: T | undefined;
16
+ /**
17
+ * Converts a known-resolved `value` into the numeric basis for the threshold
18
+ * (e.g. `(d) => d.toMilliseconds()`, or the identity for a raw number). Only
19
+ * invoked once `value` is confirmed present and resolved, so it is safe to
20
+ * call conversions that throw on tokens.
21
+ */
22
+ resolve: (value: T) => number;
23
+ /**
24
+ * Predicate deciding whether `value` is an unresolved token. Defaults to
25
+ * {@link Token.isUnresolved}. Override for wrapper types that carry their own
26
+ * check rather than being a token directly — notably a CDK `Duration`, whose
27
+ * token state is exposed via `value.isUnresolved()`.
28
+ */
29
+ isUnresolved?: (value: T) => boolean;
30
+ /**
31
+ * Stable warning identifier, also the handle callers pass to
32
+ * `Annotations.of(scope).acknowledgeWarning(...)` to suppress it. By
33
+ * convention `@composurecdk/<package>:<slug>`.
34
+ */
35
+ warningId: string;
36
+ /**
37
+ * Human-readable name of the alarm being skipped, interpolated into the
38
+ * warning (e.g. `"Lambda duration"`). Phrase it to read after
39
+ * "Skipping the recommended ".
40
+ */
41
+ alarmLabel: string;
42
+ /**
43
+ * How a caller can intentionally suppress the warning, interpolated into the
44
+ * warning's closing sentence (e.g. `"recommendedAlarms({ duration: false })"`).
45
+ */
46
+ suppressHint: string;
47
+ }
48
+ /**
49
+ * Resolves the numeric basis for a derived-threshold alarm, short-circuiting
50
+ * when the basis cannot be known at synth time.
51
+ *
52
+ * Recommended alarms whose threshold is a function of a configured input (a
53
+ * percentage of a timeout, of a reserved-concurrency limit, etc.) can only be
54
+ * rendered when that input is concrete. When the input is an unresolved token —
55
+ * e.g. a value threaded through a `CfnParameter` — there is no number to derive
56
+ * from at synth time, and unit-converting it would either throw or silently
57
+ * produce a meaningless threshold. In that case this annotates `scope` with a
58
+ * standardized, acknowledgeable warning and returns `undefined`, signalling the
59
+ * caller to omit the alarm.
60
+ *
61
+ * Returns `undefined` (without warning) when `value` is `undefined`, since an
62
+ * unconfigured input is not a skipped guardrail. The escape hatch that disables
63
+ * the alarm entirely (e.g. `recommendedAlarms({ duration: false })`) belongs at
64
+ * the call site, ahead of this call.
65
+ *
66
+ * @returns The resolved numeric basis, or `undefined` when the alarm should be
67
+ * omitted.
68
+ * @see https://github.com/laazyj/composureCDK/issues/196
69
+ */
70
+ export declare function resolveAlarmThresholdBasis<T>(opts: AlarmThresholdBasisOptions<T>): number | undefined;
71
+ //# sourceMappingURL=alarm-threshold-basis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alarm-threshold-basis.d.ts","sourceRoot":"","sources":["../../src/alarm-threshold-basis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,0BAA0B,CAAC,CAAC;IAC3C,uDAAuD;IACvD,KAAK,EAAE,UAAU,CAAC;IAElB;;;;OAIG;IACH,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IAErB;;;;;OAKG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IAE9B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;IAErC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAClC,MAAM,GAAG,SAAS,CAgBpB"}
@@ -0,0 +1,37 @@
1
+ import { Annotations, Token } from "aws-cdk-lib";
2
+ /**
3
+ * Resolves the numeric basis for a derived-threshold alarm, short-circuiting
4
+ * when the basis cannot be known at synth time.
5
+ *
6
+ * Recommended alarms whose threshold is a function of a configured input (a
7
+ * percentage of a timeout, of a reserved-concurrency limit, etc.) can only be
8
+ * rendered when that input is concrete. When the input is an unresolved token —
9
+ * e.g. a value threaded through a `CfnParameter` — there is no number to derive
10
+ * from at synth time, and unit-converting it would either throw or silently
11
+ * produce a meaningless threshold. In that case this annotates `scope` with a
12
+ * standardized, acknowledgeable warning and returns `undefined`, signalling the
13
+ * caller to omit the alarm.
14
+ *
15
+ * Returns `undefined` (without warning) when `value` is `undefined`, since an
16
+ * unconfigured input is not a skipped guardrail. The escape hatch that disables
17
+ * the alarm entirely (e.g. `recommendedAlarms({ duration: false })`) belongs at
18
+ * the call site, ahead of this call.
19
+ *
20
+ * @returns The resolved numeric basis, or `undefined` when the alarm should be
21
+ * omitted.
22
+ * @see https://github.com/laazyj/composureCDK/issues/196
23
+ */
24
+ export function resolveAlarmThresholdBasis(opts) {
25
+ if (opts.value === undefined)
26
+ return undefined;
27
+ const isUnresolved = opts.isUnresolved ?? Token.isUnresolved;
28
+ if (isUnresolved(opts.value)) {
29
+ Annotations.of(opts.scope).addWarningV2(opts.warningId, `Skipping the recommended ${opts.alarmLabel} alarm: its threshold is derived from a ` +
30
+ `value that is an unresolved token and cannot be resolved to a concrete threshold at ` +
31
+ `synth time. Set a literal value, add the alarm explicitly via addAlarm() with a fixed ` +
32
+ `threshold, or suppress this warning with ${opts.suppressHint}.`);
33
+ return undefined;
34
+ }
35
+ return opts.resolve(opts.value);
36
+ }
37
+ //# sourceMappingURL=alarm-threshold-basis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alarm-threshold-basis.js","sourceRoot":"","sources":["../../src/alarm-threshold-basis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAwDjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAAmC;IAEnC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAE/C,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,YAAY,CAAC;IAC7D,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CACrC,IAAI,CAAC,SAAS,EACd,4BAA4B,IAAI,CAAC,UAAU,0CAA0C;YACnF,sFAAsF;YACtF,wFAAwF;YACxF,4CAA4C,IAAI,CAAC,YAAY,GAAG,CACnE,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC"}
@@ -1,11 +1,26 @@
1
+ import { validateAlarmName } from "./alarm-name.js";
1
2
  export type { AlarmConfig, AlarmConfigDefaults } from "./alarm-config.js";
2
3
  export type { AlarmDefinition, AlarmMetric } from "./alarm-definition.js";
3
4
  export { AlarmDefinitionBuilder } from "./alarm-definition-builder.js";
4
5
  export { type AlarmName, alarmName } from "./alarm-name.js";
6
+ export { type AlarmThresholdBasisOptions, resolveAlarmThresholdBasis, } from "./alarm-threshold-basis.js";
5
7
  export { defaultAlarmName } from "./default-alarm-name.js";
6
8
  export { createAlarms } from "./create-alarms.js";
7
9
  export { resolveAlarmConfig, type ResolvedAlarmConfig } from "./resolve-alarm-config.js";
8
10
  export { alarmActionsPolicy } from "./policies/alarm-actions-policy.js";
9
11
  export type { AlarmActionsPolicyConfig, AlarmMatchContext, AlarmMatcher, } from "./policies/alarm-actions-policy.js";
10
12
  export { alarmNamePolicy, type AlarmNamePolicyConfig, type AlarmNameRule, type AlarmNameTransformContext, } from "./policies/alarm-name-policy.js";
13
+ /**
14
+ * This package's AWS-property constraints, grouped by application strategy.
15
+ * The `constraints.validate.*` / `constraints.sanitize.*` shape is identical in
16
+ * every builder package; the underlying constraint definition stays
17
+ * module-private. The branded {@link alarmName} constructor layers on top of the
18
+ * same validation. See ADR-0010.
19
+ */
20
+ export declare const constraints: {
21
+ validate: {
22
+ alarmName: typeof validateAlarmName;
23
+ };
24
+ sanitize: {};
25
+ };
11
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAA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;;;;;CAGO,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,8 +1,21 @@
1
+ import { validateAlarmName } from "./alarm-name.js";
1
2
  export { AlarmDefinitionBuilder } from "./alarm-definition-builder.js";
2
3
  export { alarmName } from "./alarm-name.js";
4
+ export { resolveAlarmThresholdBasis, } from "./alarm-threshold-basis.js";
3
5
  export { defaultAlarmName } from "./default-alarm-name.js";
4
6
  export { createAlarms } from "./create-alarms.js";
5
7
  export { resolveAlarmConfig } from "./resolve-alarm-config.js";
6
8
  export { alarmActionsPolicy } from "./policies/alarm-actions-policy.js";
7
9
  export { alarmNamePolicy, } from "./policies/alarm-name-policy.js";
10
+ /**
11
+ * This package's AWS-property constraints, grouped by application strategy.
12
+ * The `constraints.validate.*` / `constraints.sanitize.*` shape is identical in
13
+ * every builder package; the underlying constraint definition stays
14
+ * module-private. The branded {@link alarmName} constructor layers on top of the
15
+ * same validation. See ADR-0010.
16
+ */
17
+ export const constraints = {
18
+ validate: { alarmName: validateAlarmName },
19
+ sanitize: {},
20
+ };
8
21
  //# sourceMappingURL=index.js.map
@@ -1 +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,EAAkB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAA4B,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAMxE,OAAO,EACL,eAAe,GAIhB,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAkB,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAEL,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAA4B,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAMxE,OAAO,EACL,eAAe,GAIhB,MAAM,iCAAiC,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,EAAE,SAAS,EAAE,iBAAiB,EAAE;IAC1C,QAAQ,EAAE,EAAE;CACiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composurecdk/cloudwatch",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "Composable CloudWatch alarm primitives for composureCDK resource packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,19 @@
20
20
  "test": "vitest run --passWithNoTests",
21
21
  "test:watch": "vitest"
22
22
  },
23
- "keywords": [],
23
+ "keywords": [
24
+ "aws",
25
+ "cdk",
26
+ "aws-cdk",
27
+ "infrastructure-as-code",
28
+ "iac",
29
+ "composurecdk",
30
+ "cloudwatch",
31
+ "alarm",
32
+ "monitoring",
33
+ "metrics",
34
+ "observability"
35
+ ],
24
36
  "author": "Jason Duffett (https://github.com/laazyj)",
25
37
  "license": "MIT",
26
38
  "publishConfig": {
@@ -37,15 +49,16 @@
37
49
  }
38
50
  },
39
51
  "peerDependencies": {
40
- "aws-cdk-lib": "^2.1.0",
52
+ "@composurecdk/cloudformation": "^0.8.0",
53
+ "aws-cdk-lib": "^2.93.0",
41
54
  "constructs": "^10.0.0"
42
55
  },
43
56
  "devDependencies": {
44
- "@types/node": "^25.9.1",
45
- "aws-cdk-lib": "^2.257.0",
57
+ "@types/node": "^25.9.3",
58
+ "aws-cdk-lib": "^2.258.1",
46
59
  "constructs": "^10.6.0",
47
60
  "typescript": "^6.0.3",
48
- "vitest": "^4.1.7"
61
+ "vitest": "^4.1.8"
49
62
  },
50
63
  "exports": {
51
64
  "./package.json": "./package.json",