@middy/cloudwatch-metrics 7.3.0 → 7.3.1

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.
Files changed (3) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +17 -3
  3. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export { MetricsLogger } from "aws-embedded-metrics";
7
7
 
8
8
  export interface Options {
9
9
  namespace?: string;
10
- dimensions?: Array<Record<string, string>>;
10
+ dimensions?: Record<string, string> | Array<Record<string, string>>;
11
11
  onFlushError?: (error: Error) => void;
12
12
  }
13
13
 
package/index.js CHANGED
@@ -8,10 +8,24 @@ const defaults = {
8
8
  onFlushError: undefined,
9
9
  };
10
10
 
11
+ // `dimensions` accepts either a single dimension set (object of
12
+ // string->string) or an array of dimension sets, matching the documented
13
+ // API and aws-embedded-metrics' `setDimensions(dimensionSets)` signature.
14
+ const dimensionSetSchema = {
15
+ type: "object",
16
+ additionalProperties: { type: "string", minLength: 1, maxLength: 1024 },
17
+ };
18
+
11
19
  const optionSchema = {
12
- namespace: "string?",
13
- dimensions: "array?",
14
- onFlushError: "function?",
20
+ type: "object",
21
+ properties: {
22
+ namespace: { type: "string", minLength: 1, maxLength: 256 },
23
+ dimensions: {
24
+ oneOf: [dimensionSetSchema, { type: "array", items: dimensionSetSchema }],
25
+ },
26
+ onFlushError: { instanceof: "Function" },
27
+ },
28
+ additionalProperties: false,
15
29
  };
16
30
 
17
31
  export const cloudwatchMetricsValidateOptions = (options) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/cloudwatch-metrics",
3
- "version": "7.3.0",
3
+ "version": "7.3.1",
4
4
  "description": "Embedded CloudWatch metrics middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -68,7 +68,7 @@
68
68
  "aws-embedded-metrics": "4.2.1"
69
69
  },
70
70
  "devDependencies": {
71
- "@middy/core": "7.3.0",
71
+ "@middy/core": "7.3.1",
72
72
  "@types/aws-lambda": "^8.0.0",
73
73
  "@types/node": "^22.0.0"
74
74
  }