Skip to content

Commit cc8ac0e

Browse files
author
Mark Kuhn
authored
Add validation for namespace, metric and timestamp (#135)
* add validation for namespace, metric and timestamp * update typescript, eslint, prettier, npm-pack-zip * replace faker with non deprecated faker * update repo to comply with new eslint rules * update readme with validation errors
1 parent 3a5af62 commit cc8ac0e

30 files changed

+5220
-7351
lines changed

.eslintrc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"plugin:@typescript-eslint/eslint-recommended",
99
"plugin:@typescript-eslint/recommended",
1010
"plugin:@typescript-eslint/recommended-requiring-type-checking",
11-
"prettier",
12-
"prettier/@typescript-eslint"
11+
"prettier"
1312
],
1413
"rules": {
1514
"@typescript-eslint/interface-name-prefix": "off"
@@ -24,7 +23,15 @@
2423
"@typescript-eslint/no-explicit-any": "off",
2524
"@typescript-eslint/no-non-null-assertion": "off",
2625
"@typescript-eslint/no-use-before-define": "off",
27-
"@typescript-eslint/unbound-method": "off"
26+
"@typescript-eslint/unbound-method": "off",
27+
"@typescript-eslint/no-unsafe-member-access": "off",
28+
"@typescript-eslint/no-unsafe-argument": "off",
29+
"@typescript-eslint/no-unsafe-assignment": "off",
30+
"@typescript-eslint/no-unsafe-call": "off",
31+
"@typescript-eslint/no-unsafe-return": "off",
32+
"@typescript-eslint/no-floating-promises": "off",
33+
"@typescript-eslint/no-var-requires": "off",
34+
"@typescript-eslint/ban-ts-comment": "off"
2835
}
2936
}
3037
]

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Requirements:
113113
- Name Length 1-255 characters
114114
- Name must be ASCII characters only
115115
- Values must be in the range of 8.515920e-109 to 1.174271e+108. In addition, special values (for example, NaN, +Infinity, -Infinity) are not supported.
116-
- Units must meet CW Metrics unit requirements, if not it will default to None.
116+
- Metrics must meet CloudWatch Metrics requirements, otherwise a `InvalidMetricError` will be thrown. See [MetricDatum](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html) for valid values.
117117

118118
Examples:
119119

@@ -149,6 +149,7 @@ using `setProperty` instead.
149149
Requirements:
150150
- Length 1-255 characters
151151
- ASCII characters only
152+
- Dimensions must meet CloudWatch Dimensions requirements, otherwise a `InvalidDimensionError` or `DimensionSetExceededError` will be thrown. See [Dimensions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Dimension.html) for valid values.
152153

153154
Examples:
154155
```js
@@ -167,6 +168,7 @@ using `setProperty` instead.
167168
Requirements:
168169
- Length 1-255 characters
169170
- ASCII characters only
171+
- Dimensions must meet CloudWatch Dimensions requirements, otherwise a `InvalidDimensionError` or `DimensionSetExceededError` will be thrown. See [Dimensions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_Dimension.html) for valid values.
170172

171173
Examples:
172174

@@ -184,6 +186,7 @@ Requirements:
184186

185187
- Name Length 1-255 characters
186188
- Name must be ASCII characters only
189+
- Namespaces must meet CloudWatch Namespace requirements, otherwise a `InvalidNamespaceError` will be thrown. See [Namespace](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace) for valid values.
187190

188191
Examples:
189192

@@ -198,7 +201,7 @@ Sets the CloudWatch [timestamp](https://docs.aws.amazon.com/AmazonCloudWatch/lat
198201
If set for a given `MetricsLogger`, timestamp will be preserved across calls to flush().
199202

200203
Requirements:
201-
* Date or Unix epoch millis, up to two weeks in the past and up to two hours in the future, as enforced by [CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#about_timestamp).
204+
* Date or Unix epoch millis, up to two weeks in the past and up to two hours in the future, as enforced by [CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#about_timestamp). If the timestamp is outside of this range, a `InvalidTimestampError` will be thrown.
202205

203206
Examples:
204207

0 commit comments

Comments
 (0)