@digitraffic/common 2025.3.11-1 → 2025.4.9-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.
@@ -4,6 +4,10 @@ const LOG_LINE = {
4
4
  method: "dt-logger.test",
5
5
  message: "FOO",
6
6
  };
7
+ const EXPECTED_LOG_LINE = {
8
+ method: "dt-logger.test",
9
+ message: "dt-logger.test FOO",
10
+ };
7
11
  describe("dt-logger", () => {
8
12
  function assertLog(config, message, expected) {
9
13
  assertWrite(config, (logger) => {
@@ -57,7 +61,7 @@ describe("dt-logger", () => {
57
61
  ...LOG_LINE,
58
62
  customDate: date,
59
63
  }, {
60
- ...LOG_LINE,
64
+ ...EXPECTED_LOG_LINE,
61
65
  date: date.toISOString(),
62
66
  });
63
67
  });
@@ -66,14 +70,21 @@ describe("dt-logger", () => {
66
70
  ...LOG_LINE,
67
71
  customFooCount: 123,
68
72
  }, {
69
- ...LOG_LINE,
73
+ ...EXPECTED_LOG_LINE,
70
74
  fooCount: 123,
71
75
  });
72
76
  });
73
77
  test("default values", () => {
74
78
  assertLog({}, LOG_LINE, {
75
- method: LOG_LINE.method,
76
- message: LOG_LINE.message,
79
+ method: EXPECTED_LOG_LINE.method,
80
+ message: EXPECTED_LOG_LINE.message,
81
+ level: "INFO",
82
+ });
83
+ });
84
+ test("method not duplicated", () => {
85
+ assertLog({}, EXPECTED_LOG_LINE, {
86
+ method: EXPECTED_LOG_LINE.method,
87
+ message: EXPECTED_LOG_LINE.message,
77
88
  level: "INFO",
78
89
  });
79
90
  });
@@ -81,16 +92,16 @@ describe("dt-logger", () => {
81
92
  const LAMBDA_NAME = "test_lambda_name";
82
93
  assertLog({ lambdaName: LAMBDA_NAME }, LOG_LINE, {
83
94
  lambdaName: LAMBDA_NAME,
84
- method: LOG_LINE.method,
85
- message: LOG_LINE.message,
95
+ method: EXPECTED_LOG_LINE.method,
96
+ message: EXPECTED_LOG_LINE.message,
86
97
  level: "INFO",
87
98
  });
88
99
  });
89
100
  test("set runtime", () => {
90
101
  const RUNTIME = "test_runtime";
91
102
  assertLog({ runTime: RUNTIME }, LOG_LINE, {
92
- message: LOG_LINE.message,
93
- method: LOG_LINE.method,
103
+ message: EXPECTED_LOG_LINE.message,
104
+ method: EXPECTED_LOG_LINE.method,
94
105
  level: "INFO",
95
106
  runtime: RUNTIME,
96
107
  });
@@ -121,7 +132,7 @@ describe("dt-logger", () => {
121
132
  ...LOG_LINE,
122
133
  error,
123
134
  }, {
124
- ...LOG_LINE,
135
+ ...EXPECTED_LOG_LINE,
125
136
  error: "FAIL!",
126
137
  level: "ERROR",
127
138
  });
@@ -135,7 +146,7 @@ describe("dt-logger", () => {
135
146
  ...LOG_LINE,
136
147
  error,
137
148
  }, {
138
- ...LOG_LINE,
149
+ ...EXPECTED_LOG_LINE,
139
150
  error: '{"errorMessage":"FAIL!","errorCode":123}',
140
151
  level: "ERROR",
141
152
  });
@@ -146,7 +157,7 @@ describe("dt-logger", () => {
146
157
  ...LOG_LINE,
147
158
  error,
148
159
  }, {
149
- ...LOG_LINE,
160
+ ...EXPECTED_LOG_LINE,
150
161
  error: "Error: FAIL!",
151
162
  level: "ERROR",
152
163
  });
@@ -167,7 +178,7 @@ describe("dt-logger", () => {
167
178
  ...LOG_LINE,
168
179
  error,
169
180
  }, {
170
- ...LOG_LINE,
181
+ ...EXPECTED_LOG_LINE,
171
182
  error: "TypeError: Cannot read properties of undefined (reading 'length')",
172
183
  level: "ERROR",
173
184
  stack: "TypeError: Cannot read properties of undefined (reading 'length')",
@@ -40,7 +40,7 @@ describe("dt-logger", () => {
40
40
  assertLogError(STRING_ERROR, {
41
41
  type: "Error",
42
42
  method: TEST_METHODNAME,
43
- message: STRING_ERROR,
43
+ message: `${TEST_METHODNAME} ${STRING_ERROR}`,
44
44
  level: "ERROR",
45
45
  });
46
46
  });
@@ -49,7 +49,7 @@ describe("dt-logger", () => {
49
49
  assertLogError(ERROR, {
50
50
  type: "Error",
51
51
  method: TEST_METHODNAME,
52
- message: ERROR.message,
52
+ message: `${TEST_METHODNAME} ${ERROR.message}`,
53
53
  level: "ERROR",
54
54
  });
55
55
  });
@@ -58,7 +58,7 @@ describe("dt-logger", () => {
58
58
  assertLogError(ERROR, {
59
59
  type: "Error",
60
60
  method: TEST_METHODNAME,
61
- message: ERROR.message,
61
+ message: `${TEST_METHODNAME} ${ERROR.message}`,
62
62
  level: "ERROR",
63
63
  stack: true,
64
64
  }, true);
@@ -69,7 +69,7 @@ describe("dt-logger", () => {
69
69
  assertAxiosError(ERROR, {
70
70
  type: "Error",
71
71
  method: TEST_METHODNAME,
72
- message: ERROR.message,
72
+ message: `${TEST_METHODNAME} ${ERROR.message}`,
73
73
  level: "ERROR",
74
74
  code: ERROR.code,
75
75
  });
@@ -85,6 +85,11 @@ export class DtLogger {
85
85
  * @see {@link LoggableType}
86
86
  */
87
87
  log(message) {
88
+ // Append always method to message
89
+ if (!message.message || !message.message.length ||
90
+ !message.message.includes(message.method)) {
91
+ message.message = `${message.method} ${message.message ?? ""}`;
92
+ }
88
93
  const error = message.error
89
94
  ? (message.error instanceof Error)
90
95
  ? `${message.error.name}: ${message.error.message}`
@@ -70,7 +70,7 @@ export const openapiPathItem = z
70
70
  .partial();
71
71
  export const openapiSchema = z
72
72
  .object({
73
- openapi: z.string().regex(new RegExp("^3\\.0\\.\\d(-.+)?$")),
73
+ openapi: z.string().regex(new RegExp("^3\\.\\d\\.\\d(-.+)?$")),
74
74
  info: z
75
75
  .object({
76
76
  title: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2025.3.11-1",
3
+ "version": "2025.4.9-1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "repository": {
@@ -104,14 +104,14 @@
104
104
  "./dist/aws/runtime/digitraffic-integration-response": "./dist/aws/runtime/digitraffic-integration-response.js"
105
105
  },
106
106
  "peerDependencies": {
107
- "@aws-sdk/client-api-gateway": "^3.758.0",
108
- "@aws-sdk/client-s3": "^3.758.0",
109
- "@aws-sdk/client-secrets-manager": "^3.758.0",
110
- "@aws-sdk/client-sns": "^3.758.0",
111
- "@aws-sdk/lib-storage": "^3.758.0",
107
+ "@aws-sdk/client-api-gateway": "^3.777.0",
108
+ "@aws-sdk/client-s3": "^3.777.0",
109
+ "@aws-sdk/client-secrets-manager": "^3.777.0",
110
+ "@aws-sdk/client-sns": "^3.777.0",
111
+ "@aws-sdk/lib-storage": "^3.777.0",
112
112
  "@date-fns/tz": "1.2.0",
113
- "@smithy/fetch-http-handler": "5.0.1",
114
- "aws-cdk-lib": "^2.181.1",
113
+ "@smithy/fetch-http-handler": "5.0.2",
114
+ "aws-cdk-lib": "^2.188.0",
115
115
  "change-case": "^5.4.4",
116
116
  "constructs": "~10.4.2",
117
117
  "date-fns": "~4.1.0",
@@ -120,62 +120,62 @@
120
120
  "ky": "^1.7.5",
121
121
  "lodash-es": "^4.17.21",
122
122
  "node-ttl": "^0.2.0",
123
- "pg-native": "^3.2.2",
124
- "pg-promise": "^11.10.2",
125
- "pg-query-stream": "4.7.1",
123
+ "pg-native": "^3.3.0",
124
+ "pg-promise": "^11.13.0",
125
+ "pg-query-stream": "4.8.1",
126
126
  "zod": "^3.24.2"
127
127
  },
128
128
  "devDependencies": {
129
+ "@aws-sdk/client-api-gateway": "^3.777.0",
130
+ "@aws-sdk/client-s3": "^3.777.0",
131
+ "@aws-sdk/client-secrets-manager": "^3.777.0",
132
+ "@aws-sdk/client-sns": "^3.777.0",
133
+ "@aws-sdk/lib-storage": "^3.777.0",
134
+ "@date-fns/tz": "1.2.0",
129
135
  "@digitraffic/eslint-config": "^3.1.1",
130
136
  "@jest/globals": "^29.7.0",
131
137
  "@rushstack/eslint-config": "^3.7.1",
132
- "@rushstack/heft": "^0.69.1",
133
- "@rushstack/heft-jest-plugin": "^0.14.11",
134
- "@rushstack/heft-lint-plugin": "^0.5.20",
135
- "@rushstack/heft-typescript-plugin": "^0.6.13",
136
- "@smithy/types": "^4.1.0",
137
- "@types/aws-lambda": "8.10.147",
138
+ "@rushstack/heft": "^0.71.1",
139
+ "@rushstack/heft-jest-plugin": "^0.15.3",
140
+ "@rushstack/heft-lint-plugin": "^0.5.29",
141
+ "@rushstack/heft-typescript-plugin": "^0.8.1",
142
+ "@smithy/fetch-http-handler": "5.0.2",
143
+ "@smithy/types": "^4.2.0",
144
+ "@types/aws-lambda": "8.10.148",
138
145
  "@types/etag": "^1.8.3",
139
146
  "@types/geojson": "7946.0.16",
140
147
  "@types/geojson-validation": "^1.0.3",
141
148
  "@types/jest": "29.5.14",
142
149
  "@types/lodash-es": "4.17.12",
143
150
  "@types/madge": "5.0.3",
144
- "@types/node": "22.13.5",
151
+ "@types/node": "22.13.14",
145
152
  "@typescript-eslint/eslint-plugin": "~7.14.1",
146
- "@typescript-eslint/parser": "^7.0.0",
153
+ "@typescript-eslint/parser": "^7.18.0",
154
+ "aws-cdk-lib": "^2.188.0",
147
155
  "aws-sdk": "^2.1692.0",
156
+ "change-case": "^5.4.4",
157
+ "constructs": "~10.4.2",
158
+ "date-fns": "~4.1.0",
148
159
  "eslint": "^8.57.1",
149
160
  "eslint-config-prettier": "^9.1.0",
150
161
  "eslint-plugin-deprecation": "~3.0.0",
162
+ "etag": "^1.8.1",
163
+ "geojson-validation": "^1.0.2",
151
164
  "jest": "^29.7.0",
152
165
  "jest-junit": "^16.0.0",
153
- "lefthook": "^1.11.2",
166
+ "ky": "^1.7.5",
167
+ "lefthook": "^1.11.5",
154
168
  "lodash": "^4.17.21",
169
+ "lodash-es": "^4.17.21",
155
170
  "madge": "^8.0.0",
171
+ "node-ttl": "^0.2.0",
172
+ "pg-native": "^3.3.0",
173
+ "pg-promise": "^11.13.0",
174
+ "pg-query-stream": "4.8.1",
156
175
  "rimraf": "^6.0.1",
157
- "ts-jest": "^29.2.6",
176
+ "ts-jest": "^29.3.0",
158
177
  "typescript": "~5.6.3",
159
178
  "velocityjs": "^2.0.6",
160
- "@aws-sdk/client-api-gateway": "^3.758.0",
161
- "@aws-sdk/client-s3": "^3.758.0",
162
- "@aws-sdk/client-secrets-manager": "^3.758.0",
163
- "@aws-sdk/client-sns": "^3.758.0",
164
- "@aws-sdk/lib-storage": "^3.758.0",
165
- "@date-fns/tz": "1.2.0",
166
- "@smithy/fetch-http-handler": "5.0.1",
167
- "aws-cdk-lib": "^2.181.1",
168
- "change-case": "^5.4.4",
169
- "constructs": "~10.4.2",
170
- "date-fns": "~4.1.0",
171
- "etag": "^1.8.1",
172
- "geojson-validation": "^1.0.2",
173
- "ky": "^1.7.5",
174
- "lodash-es": "^4.17.21",
175
- "node-ttl": "^0.2.0",
176
- "pg-native": "^3.2.2",
177
- "pg-promise": "^11.10.2",
178
- "pg-query-stream": "4.7.1",
179
179
  "zod": "^3.24.2"
180
180
  },
181
181
  "scripts": {