@digitraffic/common 2025.3.10-1 → 2025.4.2-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.
package/README.md
CHANGED
@@ -15,6 +15,11 @@ describe("dt-logger", () => {
|
|
15
15
|
logger.debug(message);
|
16
16
|
}, expected);
|
17
17
|
}
|
18
|
+
function assertError(config, message, expected) {
|
19
|
+
assertWrite(config, (logger) => {
|
20
|
+
logger.error(message);
|
21
|
+
}, expected);
|
22
|
+
}
|
18
23
|
function assertWrite(config, writeFunction, expected) {
|
19
24
|
const logged = [];
|
20
25
|
const writeStream = new Writable({
|
@@ -33,10 +38,16 @@ describe("dt-logger", () => {
|
|
33
38
|
if (typeof expected === "object" && "stack" in expected && expected.stack) {
|
34
39
|
// eslint-disable-next-line dot-notation
|
35
40
|
const stack = loggedLine["stack"];
|
41
|
+
expect(stack).toBeDefined();
|
42
|
+
// @ts-ignore // stack should be multiline string
|
43
|
+
const stackLines = stack.split("\n");
|
44
|
+
expect(stackLines.length).toBeGreaterThanOrEqual(2);
|
45
|
+
expect(stackLines[0]).toEqual(expected.stack);
|
46
|
+
// @ts-ignore
|
47
|
+
expect(stackLines[1].trim().startsWith("at ")).toBe(true);
|
36
48
|
// eslint-disable-next-line dot-notation
|
37
49
|
delete loggedLine["stack"];
|
38
50
|
delete expected.stack;
|
39
|
-
expect(stack).toBeDefined();
|
40
51
|
}
|
41
52
|
expect(loggedLine).toMatchObject(expected);
|
42
53
|
}
|
@@ -104,5 +115,63 @@ describe("dt-logger", () => {
|
|
104
115
|
level: "DEBUG",
|
105
116
|
});
|
106
117
|
});
|
118
|
+
test("error - Error string", () => {
|
119
|
+
const error = "FAIL!";
|
120
|
+
assertError({}, {
|
121
|
+
...LOG_LINE,
|
122
|
+
error,
|
123
|
+
}, {
|
124
|
+
...LOG_LINE,
|
125
|
+
error: "FAIL!",
|
126
|
+
level: "ERROR",
|
127
|
+
});
|
128
|
+
});
|
129
|
+
test("error - Error object", () => {
|
130
|
+
const error = {
|
131
|
+
errorMessage: "FAIL!",
|
132
|
+
errorCode: 123,
|
133
|
+
};
|
134
|
+
assertError({}, {
|
135
|
+
...LOG_LINE,
|
136
|
+
error,
|
137
|
+
}, {
|
138
|
+
...LOG_LINE,
|
139
|
+
error: '{"errorMessage":"FAIL!","errorCode":123}',
|
140
|
+
level: "ERROR",
|
141
|
+
});
|
142
|
+
});
|
143
|
+
test("error - Error", () => {
|
144
|
+
const error = new Error("FAIL!");
|
145
|
+
assertError({}, {
|
146
|
+
...LOG_LINE,
|
147
|
+
error,
|
148
|
+
}, {
|
149
|
+
...LOG_LINE,
|
150
|
+
error: "Error: FAIL!",
|
151
|
+
level: "ERROR",
|
152
|
+
});
|
153
|
+
});
|
154
|
+
test("error - Error with stack", () => {
|
155
|
+
let error;
|
156
|
+
try {
|
157
|
+
// @ts-ignore
|
158
|
+
console.log(`Result: ${undefined.length}`);
|
159
|
+
}
|
160
|
+
catch (e) {
|
161
|
+
// @ts-ignore
|
162
|
+
console.debug(`Failed message: ${e.message}`);
|
163
|
+
console.debug(`Failed stack: ${e.stack}`);
|
164
|
+
error = e;
|
165
|
+
}
|
166
|
+
assertError({}, {
|
167
|
+
...LOG_LINE,
|
168
|
+
error,
|
169
|
+
}, {
|
170
|
+
...LOG_LINE,
|
171
|
+
error: "TypeError: Cannot read properties of undefined (reading 'length')",
|
172
|
+
level: "ERROR",
|
173
|
+
stack: "TypeError: Cannot read properties of undefined (reading 'length')",
|
174
|
+
});
|
175
|
+
});
|
107
176
|
});
|
108
177
|
//# sourceMappingURL=dt-logger.test.js.map
|
@@ -86,13 +86,21 @@ export class DtLogger {
|
|
86
86
|
*/
|
87
87
|
log(message) {
|
88
88
|
const error = message.error
|
89
|
-
?
|
90
|
-
? message.error
|
91
|
-
:
|
89
|
+
? (message.error instanceof Error)
|
90
|
+
? `${message.error.name}: ${message.error.message}`
|
91
|
+
: typeof message.error === "string"
|
92
|
+
? message.error
|
93
|
+
: JSON.stringify(message.error)
|
92
94
|
: undefined;
|
95
|
+
const stack = message.stack
|
96
|
+
? message.stack
|
97
|
+
: message.error
|
98
|
+
? (message.error instanceof Error) ? message.error.stack : undefined
|
99
|
+
: undefined;
|
93
100
|
const logMessage = {
|
94
101
|
...removePrefix("custom", message),
|
95
102
|
error,
|
103
|
+
stack,
|
96
104
|
lambdaName: this.lambdaName,
|
97
105
|
runtime: this.runtime,
|
98
106
|
};
|
@@ -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
|
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
|
+
"version": "2025.4.2-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.
|
108
|
-
"@aws-sdk/client-s3": "^3.
|
109
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
110
|
-
"@aws-sdk/client-sns": "^3.
|
111
|
-
"@aws-sdk/lib-storage": "^3.
|
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.
|
114
|
-
"aws-cdk-lib": "^2.
|
113
|
+
"@smithy/fetch-http-handler": "5.0.2",
|
114
|
+
"aws-cdk-lib": "^2.186.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.
|
124
|
-
"pg-promise": "^11.
|
125
|
-
"pg-query-stream": "4.
|
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.
|
133
|
-
"@rushstack/heft-jest-plugin": "^0.
|
134
|
-
"@rushstack/heft-lint-plugin": "^0.5.
|
135
|
-
"@rushstack/heft-typescript-plugin": "^0.
|
136
|
-
"@smithy/
|
137
|
-
"@types
|
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.
|
151
|
+
"@types/node": "22.13.14",
|
145
152
|
"@typescript-eslint/eslint-plugin": "~7.14.1",
|
146
|
-
"@typescript-eslint/parser": "^7.
|
153
|
+
"@typescript-eslint/parser": "^7.18.0",
|
154
|
+
"aws-cdk-lib": "^2.186.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
|
-
"
|
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.
|
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": {
|