@moreapp/common-nodejs 0.10.2 → 0.10.6
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/dist/MoreAppClient.d.ts +2 -2
- package/dist/MoreAppClient.js +5 -0
- package/dist/MoreAppClient.test.js +1 -1
- package/dist/dateUtil.test.js +4 -4
- package/dist/logger.test.js +3 -3
- package/dist/observability/ExpressRequestTracker.test.js +1 -1
- package/dist/observability/ObservabilityServer.js +8 -6
- package/dist/observability/ObservabilityServer.test.js +3 -1
- package/dist/observability/TerminationHandler.d.ts +1 -1
- package/dist/observability/TerminationHandler.js +2 -2
- package/dist/observability/TerminationHandler.test.js +12 -19
- package/dist/testUtils.js +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +2 -2
- package/dist/utils.test.js +10 -10
- package/package.json +27 -28
package/dist/MoreAppClient.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export default class MoreAppClient {
|
|
|
15
15
|
constructor(options: Options);
|
|
16
16
|
getBinary(path: string): Promise<BinaryFile>;
|
|
17
17
|
get<T>(path: string): Promise<T>;
|
|
18
|
-
post<T>(path: string, payload: Record<string,
|
|
19
|
-
delete(path: string): Promise<
|
|
18
|
+
post<T>(path: string, payload: Record<string, unknown>): Promise<T>;
|
|
19
|
+
delete(path: string): Promise<unknown>;
|
|
20
20
|
}
|
|
21
21
|
export {};
|
package/dist/MoreAppClient.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const axios_1 = __importDefault(require("axios"));
|
|
7
7
|
const content_disposition_parser_1 = __importDefault(require("content-disposition-parser"));
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
8
9
|
class MoreAppClient {
|
|
9
10
|
client;
|
|
10
11
|
constructor(options) {
|
|
@@ -49,7 +50,11 @@ class MoreAppClient {
|
|
|
49
50
|
}
|
|
50
51
|
exports.default = MoreAppClient;
|
|
51
52
|
function getFilename(res) {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
52
54
|
const contentDispositionHeader = res.headers["content-disposition"];
|
|
55
|
+
if (!(0, lodash_1.isString)(contentDispositionHeader)) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
53
58
|
const filename = (0, content_disposition_parser_1.default)(contentDispositionHeader)?.filename;
|
|
54
59
|
return filename ? decodeURI(filename) : undefined;
|
|
55
60
|
}
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const MoreAppClient_1 = __importDefault(require("./MoreAppClient"));
|
|
7
6
|
const nock_1 = __importDefault(require("nock"));
|
|
8
7
|
const axios_1 = require("axios");
|
|
8
|
+
const MoreAppClient_1 = __importDefault(require("./MoreAppClient"));
|
|
9
9
|
test("download binary file", async () => {
|
|
10
10
|
const file = Buffer.from("Some data");
|
|
11
11
|
const apiMock = (0, nock_1.default)("https://api.moreapp.com")
|
package/dist/dateUtil.test.js
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const dateUtil_1 = require("./dateUtil");
|
|
4
4
|
describe("isDate", () => {
|
|
5
|
-
test("should handle valid dates",
|
|
5
|
+
test("should handle valid dates", () => {
|
|
6
6
|
expect((0, dateUtil_1.isDate)("2020-01-01")).toBe(true);
|
|
7
7
|
expect((0, dateUtil_1.isDate)("2020-1-1")).toBe(true);
|
|
8
8
|
expect((0, dateUtil_1.isDate)("0000-1-1")).toBe(true);
|
|
9
9
|
});
|
|
10
|
-
test("should handle invalid dates",
|
|
10
|
+
test("should handle invalid dates", () => {
|
|
11
11
|
expect((0, dateUtil_1.isDate)("not-a-date")).toBe(false);
|
|
12
12
|
expect((0, dateUtil_1.isDate)("3039-20-01")).toBe(false);
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
describe("isDateTime", () => {
|
|
16
|
-
test("should handle valid date times",
|
|
16
|
+
test("should handle valid date times", () => {
|
|
17
17
|
expect((0, dateUtil_1.isDateTime)("2020-01-01 12:00")).toBe(true);
|
|
18
18
|
expect((0, dateUtil_1.isDateTime)("2020-01-01 0:00")).toBe(true);
|
|
19
19
|
});
|
|
20
|
-
test("should handle invalid date times",
|
|
20
|
+
test("should handle invalid date times", () => {
|
|
21
21
|
expect((0, dateUtil_1.isDateTime)("2020-01-01 0:99")).toBe(false);
|
|
22
22
|
expect((0, dateUtil_1.isDateTime)("2020-01-01 25:12")).toBe(false);
|
|
23
23
|
});
|
package/dist/logger.test.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const logger_1 = require("./logger");
|
|
4
4
|
describe("errorFormat", () => {
|
|
5
|
-
test("should format standard errors",
|
|
5
|
+
test("should format standard errors", () => {
|
|
6
6
|
const error = new Error("Failed to persist");
|
|
7
7
|
const formatted = logger_1.formatters
|
|
8
8
|
.errorFormat()
|
|
@@ -16,7 +16,7 @@ describe("errorFormat", () => {
|
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
-
test("should format error with (deeply nested) cause",
|
|
19
|
+
test("should format error with (deeply nested) cause", () => {
|
|
20
20
|
const error = new Error("Failed to persist", {
|
|
21
21
|
cause: new Error("Caused by me!", { cause: "Well actually..." }),
|
|
22
22
|
});
|
|
@@ -41,7 +41,7 @@ describe("errorFormat", () => {
|
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
describe("tracingFormat", () => {
|
|
44
|
-
test("should transform tracing data to Stackdriver format",
|
|
44
|
+
test("should transform tracing data to Stackdriver format", () => {
|
|
45
45
|
const formatted = logger_1.formatters.stackdriverTracingFormat().transform({
|
|
46
46
|
level: "error",
|
|
47
47
|
message: "Something went wrong",
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ExpressRequestTracker_1 = __importDefault(require("./ExpressRequestTracker"));
|
|
7
6
|
const node_events_1 = require("node:events");
|
|
7
|
+
const ExpressRequestTracker_1 = __importDefault(require("./ExpressRequestTracker"));
|
|
8
8
|
// Create a minimal Response mock that can emit the 'finish' event
|
|
9
9
|
const createMockResponse = () => {
|
|
10
10
|
const emitter = new node_events_1.EventEmitter();
|
|
@@ -16,25 +16,27 @@ class ObservabilityServer {
|
|
|
16
16
|
this.requestTracker = requestTracker;
|
|
17
17
|
this.options = options;
|
|
18
18
|
prom_client_1.default.collectDefaultMetrics();
|
|
19
|
-
this.server = node_http_1.default.createServer(
|
|
19
|
+
this.server = node_http_1.default.createServer((req, res) => {
|
|
20
20
|
if (req.url === "/live") {
|
|
21
21
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
22
|
-
|
|
22
|
+
res.end(JSON.stringify({ status: "ok" }));
|
|
23
23
|
}
|
|
24
24
|
else if (req.url === "/ready") {
|
|
25
25
|
res.writeHead(this.isReady ? 200 : 503, { "Content-Type": "application/json" });
|
|
26
|
-
|
|
26
|
+
res.end(JSON.stringify({
|
|
27
27
|
status: this.isReady ? "ok" : "not ready",
|
|
28
28
|
activeRequests: this.requestTracker.nrOfActiveRequests(),
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
31
|
else if (req.url === "/metrics") {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
void prom_client_1.default.register.metrics().then((metrics) => {
|
|
33
|
+
res.setHeader("Content-Type", prom_client_1.default.register.contentType);
|
|
34
|
+
res.end(metrics);
|
|
35
|
+
});
|
|
34
36
|
}
|
|
35
37
|
else {
|
|
36
38
|
res.statusCode = 404;
|
|
37
|
-
|
|
39
|
+
res.end();
|
|
38
40
|
}
|
|
39
41
|
});
|
|
40
42
|
}
|
|
@@ -56,7 +56,9 @@ describe("ObservabilityServer", () => {
|
|
|
56
56
|
capturedHandler = handler;
|
|
57
57
|
return fakeServer;
|
|
58
58
|
});
|
|
59
|
-
const requestTracker = {
|
|
59
|
+
const requestTracker = {
|
|
60
|
+
nrOfActiveRequests: jest.fn(() => 0),
|
|
61
|
+
};
|
|
60
62
|
const hs = await ObservabilityServer_1.default.create(requestTracker, { port: 0 });
|
|
61
63
|
expect(fakeServer.listen).toHaveBeenCalled();
|
|
62
64
|
// /live
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Server } from "node:http";
|
|
1
2
|
import ExpressRequestTracker from "./ExpressRequestTracker";
|
|
2
3
|
import ObservabilityServer from "./ObservabilityServer";
|
|
3
|
-
import { Server } from "node:http";
|
|
4
4
|
export default class TerminationHandler {
|
|
5
5
|
private readonly server;
|
|
6
6
|
private readonly hs;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const logger_1 = require("../logger");
|
|
4
3
|
const node_timers_1 = require("node:timers");
|
|
4
|
+
const logger_1 = require("../logger");
|
|
5
5
|
const TERMINATION_SIGNALS = ["SIGTERM", "SIGHUP", "SIGINT"];
|
|
6
6
|
const SHUTDOWN_TIMEOUT = 30_000;
|
|
7
7
|
class TerminationHandler {
|
|
@@ -34,7 +34,7 @@ class TerminationHandler {
|
|
|
34
34
|
(0, node_timers_1.clearInterval)(interval);
|
|
35
35
|
// Destroy any remaining sockets
|
|
36
36
|
this.sockets.forEach((socket) => socket.destroy());
|
|
37
|
-
this.hs.stop().finally(() => {
|
|
37
|
+
void this.hs.stop().finally(() => {
|
|
38
38
|
logger_1.logger.info("Server stopped");
|
|
39
39
|
process.exit(0);
|
|
40
40
|
});
|
|
@@ -39,14 +39,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
const testUtils_1 = require("../testUtils");
|
|
40
40
|
(0, testUtils_1.silenceLogger)();
|
|
41
41
|
const node_events_1 = require("node:events");
|
|
42
|
+
const timers = __importStar(require("node:timers"));
|
|
43
|
+
const TerminationHandler_1 = __importDefault(require("./TerminationHandler"));
|
|
42
44
|
// Mock node:timers so we can control callbacks (TerminationHandler imports from node:timers)
|
|
43
45
|
jest.mock("node:timers", () => ({
|
|
44
46
|
setInterval: jest.fn(),
|
|
45
47
|
clearInterval: jest.fn(),
|
|
46
48
|
setTimeout: jest.fn(),
|
|
47
49
|
}));
|
|
48
|
-
const timers = __importStar(require("node:timers"));
|
|
49
|
-
const TerminationHandler_1 = __importDefault(require("./TerminationHandler"));
|
|
50
50
|
describe("TerminationHandler", () => {
|
|
51
51
|
let intervalCb;
|
|
52
52
|
let timeoutCb;
|
|
@@ -58,10 +58,7 @@ describe("TerminationHandler", () => {
|
|
|
58
58
|
return 1;
|
|
59
59
|
});
|
|
60
60
|
timers.clearInterval.mockImplementation(() => { });
|
|
61
|
-
jest
|
|
62
|
-
.spyOn(globalThis, "setTimeout")
|
|
63
|
-
// @ts-ignore simplify types for test
|
|
64
|
-
.mockImplementation((cb) => {
|
|
61
|
+
jest.spyOn(globalThis, "setTimeout").mockImplementation((cb) => {
|
|
65
62
|
timeoutCb = cb;
|
|
66
63
|
return 2;
|
|
67
64
|
});
|
|
@@ -91,7 +88,7 @@ describe("TerminationHandler", () => {
|
|
|
91
88
|
socket.destroy = jest.fn();
|
|
92
89
|
return socket;
|
|
93
90
|
};
|
|
94
|
-
test("shutdown waits for active requests to reach 0 then stops and exits 0",
|
|
91
|
+
test("shutdown waits for active requests to reach 0 then stops and exits 0", () => {
|
|
95
92
|
const server = createFakeServer();
|
|
96
93
|
const hs = {
|
|
97
94
|
setReady: jest.fn(),
|
|
@@ -103,10 +100,7 @@ describe("TerminationHandler", () => {
|
|
|
103
100
|
})),
|
|
104
101
|
};
|
|
105
102
|
const requestTracker = { nrOfActiveRequests: jest.fn(() => 0) };
|
|
106
|
-
const exitSpy = jest
|
|
107
|
-
.spyOn(process, "exit")
|
|
108
|
-
// never return to process
|
|
109
|
-
.mockImplementation(((..._args) => undefined));
|
|
103
|
+
const exitSpy = jest.spyOn(process, "exit").mockImplementation(() => undefined);
|
|
110
104
|
const th = new TerminationHandler_1.default(server, hs, requestTracker);
|
|
111
105
|
th.shutdown();
|
|
112
106
|
expect(hs.setReady).toHaveBeenCalledWith(false);
|
|
@@ -117,7 +111,7 @@ describe("TerminationHandler", () => {
|
|
|
117
111
|
expect(hs.stop).toHaveBeenCalled();
|
|
118
112
|
expect(exitSpy).toHaveBeenCalledWith(0);
|
|
119
113
|
});
|
|
120
|
-
test("shutdown polls until requests finish then exits 0",
|
|
114
|
+
test("shutdown polls until requests finish then exits 0", () => {
|
|
121
115
|
const server = createFakeServer();
|
|
122
116
|
const hs = {
|
|
123
117
|
setReady: jest.fn(),
|
|
@@ -131,9 +125,7 @@ describe("TerminationHandler", () => {
|
|
|
131
125
|
const requestTracker = { nrOfActiveRequests: jest.fn() };
|
|
132
126
|
// Return >0 first, then 0
|
|
133
127
|
requestTracker.nrOfActiveRequests.mockReturnValueOnce(2).mockReturnValueOnce(0);
|
|
134
|
-
const exitSpy = jest
|
|
135
|
-
.spyOn(process, "exit")
|
|
136
|
-
.mockImplementation(((..._args) => undefined));
|
|
128
|
+
const exitSpy = jest.spyOn(process, "exit").mockImplementation(() => undefined);
|
|
137
129
|
const th = new TerminationHandler_1.default(server, hs, requestTracker);
|
|
138
130
|
th.shutdown();
|
|
139
131
|
// First tick: still waiting
|
|
@@ -146,11 +138,12 @@ describe("TerminationHandler", () => {
|
|
|
146
138
|
});
|
|
147
139
|
test("forceful stop after 30s destroys sockets and exits 1", () => {
|
|
148
140
|
const server = createFakeServer();
|
|
149
|
-
const hs = {
|
|
141
|
+
const hs = {
|
|
142
|
+
setReady: jest.fn(),
|
|
143
|
+
stop: jest.fn(() => Promise.resolve()),
|
|
144
|
+
};
|
|
150
145
|
const requestTracker = { nrOfActiveRequests: jest.fn(() => 5) }; // never reaches 0
|
|
151
|
-
const exitSpy = jest
|
|
152
|
-
.spyOn(process, "exit")
|
|
153
|
-
.mockImplementation(((..._args) => undefined));
|
|
146
|
+
const exitSpy = jest.spyOn(process, "exit").mockImplementation(() => undefined);
|
|
154
147
|
const th = new TerminationHandler_1.default(server, hs, requestTracker);
|
|
155
148
|
// Register a socket via the server's connection event
|
|
156
149
|
const socket = createSocket();
|
package/dist/testUtils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.silenceLogger = void 0;
|
|
4
|
-
// Utility to silence logger output in tests
|
|
4
|
+
// Utility to silence logger output in tests must be at the top of the test file
|
|
5
5
|
const silenceLogger = () => jest.mock("./logger", () => ({
|
|
6
6
|
logger: {
|
|
7
7
|
info: jest.fn(),
|
package/dist/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type IntegrationTestResponse = {
|
|
|
7
7
|
} | {
|
|
8
8
|
status: "INVALID";
|
|
9
9
|
globalError: string;
|
|
10
|
-
fieldErrors?: Record<string,
|
|
10
|
+
fieldErrors?: Record<string, unknown>;
|
|
11
11
|
};
|
|
12
12
|
export type IntegrationHandleResponse = {
|
|
13
13
|
status: "SUCCESS";
|
|
@@ -16,7 +16,7 @@ export type IntegrationHandleResponse = {
|
|
|
16
16
|
name: string;
|
|
17
17
|
data: string;
|
|
18
18
|
}[];
|
|
19
|
-
data?: Record<string,
|
|
19
|
+
data?: Record<string, unknown>;
|
|
20
20
|
} | {
|
|
21
21
|
status: "ERROR";
|
|
22
22
|
message: string;
|
package/dist/utils.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export declare function environmentVariable(key: string, fallback: boolean): boo
|
|
|
6
6
|
export declare function currentTraceId(): string | undefined;
|
|
7
7
|
export declare function isValidEmail(email: string): boolean;
|
|
8
8
|
export declare function parseDynamicRecipients(dynamicRecipients: string[], fields: FormVersionField[], data: Record<string, unknown>): string[];
|
|
9
|
-
export declare function getDataForDataName(data: Record<string, unknown>, dataName: string | undefined): unknown
|
|
9
|
+
export declare function getDataForDataName(data: Record<string, unknown>, dataName: string | undefined): unknown;
|
package/dist/utils.js
CHANGED
|
@@ -69,7 +69,7 @@ const emailAddressDomainPattern = /^(?:[A-z0-9À-ž](?:[A-z0-9À-ž-]{0,61}[A-z0
|
|
|
69
69
|
// There are many regex patterns to validate email addresses, but they all have flaws and cannot 100% correctly verify
|
|
70
70
|
// every possible email address. For us, it's more important to avoid the majority of typo's instead of catching every
|
|
71
71
|
// invalid email address. We let our email provider handle and false positives (either by their validation or the fact
|
|
72
|
-
// that the email could not be delivered.
|
|
72
|
+
// that the email could not be delivered).
|
|
73
73
|
// ! This code is duplicated in other projects, make sure that changes are made there too (including tests).
|
|
74
74
|
function isValidEmail(email) {
|
|
75
75
|
if (email.length > emailAddressMaxLength) {
|
|
@@ -127,7 +127,7 @@ function getDataForDataName(data, dataName) {
|
|
|
127
127
|
// resolve nested field (like: SEARCH_FIELD.name)
|
|
128
128
|
if (dataName.includes(".")) {
|
|
129
129
|
const parts = dataName.split(".");
|
|
130
|
-
|
|
130
|
+
const nestedData = data[parts[0]];
|
|
131
131
|
if (isObject(nestedData)) {
|
|
132
132
|
const nestedKey = parts.slice(1).join(".");
|
|
133
133
|
return getDataForDataName(nestedData, nestedKey);
|
package/dist/utils.test.js
CHANGED
|
@@ -2,35 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("./utils");
|
|
4
4
|
describe("environmentVariable", () => {
|
|
5
|
-
test("Should throw when environment variable does not exist",
|
|
5
|
+
test("Should throw when environment variable does not exist", () => {
|
|
6
6
|
expect(() => (0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_NON_EXISTING")).toThrow("Missing environment variable 'COMMONS_NODEJS_TEST_NON_EXISTING'");
|
|
7
7
|
});
|
|
8
|
-
test("Should return fallback value when environment variable does not exist (string)",
|
|
8
|
+
test("Should return fallback value when environment variable does not exist (string)", () => {
|
|
9
9
|
expect((0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_NON_EXISTING", "my-fallback")).toBe("my-fallback");
|
|
10
10
|
});
|
|
11
|
-
test("Should return fallback value when environment variable does not exist (number)",
|
|
11
|
+
test("Should return fallback value when environment variable does not exist (number)", () => {
|
|
12
12
|
expect((0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_NON_EXISTING", 1)).toBe(1);
|
|
13
13
|
});
|
|
14
|
-
test("Should return fallback value when environment variable does not exist (boolean)",
|
|
14
|
+
test("Should return fallback value when environment variable does not exist (boolean)", () => {
|
|
15
15
|
expect((0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_NON_EXISTING", false)).toBe(false);
|
|
16
16
|
});
|
|
17
|
-
test("Should return actual value when environment variable exists (string)",
|
|
17
|
+
test("Should return actual value when environment variable exists (string)", () => {
|
|
18
18
|
process.env["COMMONS_NODEJS_TEST_EXISTING"] = "actual-value";
|
|
19
19
|
expect((0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_EXISTING", "my-fallback")).toBe("actual-value");
|
|
20
20
|
});
|
|
21
|
-
test("Should return actual value when environment variable exists (number)",
|
|
21
|
+
test("Should return actual value when environment variable exists (number)", () => {
|
|
22
22
|
process.env["COMMONS_NODEJS_TEST_EXISTING"] = "2";
|
|
23
23
|
expect((0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_EXISTING", 1)).toBe(2);
|
|
24
24
|
});
|
|
25
|
-
test("Should return actual value when environment variable exists (boolean)",
|
|
25
|
+
test("Should return actual value when environment variable exists (boolean)", () => {
|
|
26
26
|
process.env["COMMONS_NODEJS_TEST_EXISTING"] = "true";
|
|
27
27
|
expect((0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_EXISTING", false)).toBe(true);
|
|
28
28
|
});
|
|
29
|
-
test("should throw when environment variable contains an invalid type (number)",
|
|
29
|
+
test("should throw when environment variable contains an invalid type (number)", () => {
|
|
30
30
|
process.env["COMMONS_NODEJS_TEST_EXISTING"] = "not-a-number";
|
|
31
31
|
expect(() => (0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_EXISTING", 1)).toThrow("Wrong type for environment variable 'COMMONS_NODEJS_TEST_EXISTING'");
|
|
32
32
|
});
|
|
33
|
-
test("should throw when environment variable contains an invalid type (boolean)",
|
|
33
|
+
test("should throw when environment variable contains an invalid type (boolean)", () => {
|
|
34
34
|
process.env["COMMONS_NODEJS_TEST_EXISTING"] = "not-a-boolean";
|
|
35
35
|
expect(() => (0, utils_1.environmentVariable)("COMMONS_NODEJS_TEST_EXISTING", false)).toThrow("Wrong type for environment variable 'COMMONS_NODEJS_TEST_EXISTING'");
|
|
36
36
|
});
|
|
@@ -96,7 +96,7 @@ describe("parseDynamicRecipients", () => {
|
|
|
96
96
|
});
|
|
97
97
|
describe("getDataForDataName", () => {
|
|
98
98
|
test("should return (nested) values in objects based on dataName", () => {
|
|
99
|
-
|
|
99
|
+
const data = {
|
|
100
100
|
name: "John",
|
|
101
101
|
age: 10,
|
|
102
102
|
address: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moreapp/common-nodejs",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.6",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"prettier": "prettier './**/*.{ts,json,yaml,md,}'",
|
|
22
22
|
"format:check": "yarn prettier --check",
|
|
23
23
|
"format:fix": "yarn prettier --write",
|
|
24
|
-
"lint:check": "eslint
|
|
24
|
+
"lint:check": "eslint src",
|
|
25
25
|
"lint:fix": "yarn lint:check --fix",
|
|
26
26
|
"prepare": "husky"
|
|
27
27
|
},
|
|
@@ -32,47 +32,46 @@
|
|
|
32
32
|
"@google-cloud/logging": "11.2.1",
|
|
33
33
|
"@google-cloud/opentelemetry-cloud-trace-exporter": "3.0.0",
|
|
34
34
|
"@opentelemetry/api": "1.9.0",
|
|
35
|
-
"@opentelemetry/core": "2.
|
|
36
|
-
"@opentelemetry/instrumentation": "0.
|
|
37
|
-
"@opentelemetry/instrumentation-dns": "0.
|
|
38
|
-
"@opentelemetry/instrumentation-express": "0.
|
|
39
|
-
"@opentelemetry/instrumentation-http": "0.
|
|
40
|
-
"@opentelemetry/instrumentation-winston": "0.
|
|
41
|
-
"@opentelemetry/resources": "2.
|
|
42
|
-
"@opentelemetry/sdk-node": "0.
|
|
43
|
-
"@opentelemetry/sdk-trace-base": "2.
|
|
44
|
-
"@opentelemetry/sdk-trace-node": "2.
|
|
45
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
46
|
-
"axios": "1.13.
|
|
35
|
+
"@opentelemetry/core": "2.5.0",
|
|
36
|
+
"@opentelemetry/instrumentation": "0.211.0",
|
|
37
|
+
"@opentelemetry/instrumentation-dns": "0.54.0",
|
|
38
|
+
"@opentelemetry/instrumentation-express": "0.59.0",
|
|
39
|
+
"@opentelemetry/instrumentation-http": "0.211.0",
|
|
40
|
+
"@opentelemetry/instrumentation-winston": "0.55.0",
|
|
41
|
+
"@opentelemetry/resources": "2.5.0",
|
|
42
|
+
"@opentelemetry/sdk-node": "0.211.0",
|
|
43
|
+
"@opentelemetry/sdk-trace-base": "2.5.0",
|
|
44
|
+
"@opentelemetry/sdk-trace-node": "2.5.0",
|
|
45
|
+
"@opentelemetry/semantic-conventions": "1.39.0",
|
|
46
|
+
"axios": "1.13.4",
|
|
47
47
|
"content-disposition-parser": "1.0.2",
|
|
48
|
-
"date-and-time": "4.
|
|
48
|
+
"date-and-time": "4.2.0",
|
|
49
49
|
"express": "5.2.1",
|
|
50
|
-
"lodash": "4.17.
|
|
50
|
+
"lodash": "4.17.23",
|
|
51
51
|
"prom-client": "15.1.3",
|
|
52
|
-
"winston": "3.
|
|
53
|
-
"zod": "4.
|
|
52
|
+
"winston": "3.19.0",
|
|
53
|
+
"zod": "4.3.6"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/express": "5.0.6",
|
|
57
57
|
"@types/jest": "30.0.0",
|
|
58
|
-
"@types/lodash": "4.17.
|
|
59
|
-
"@types/node": "24.10.
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
61
|
-
"@typescript-eslint/parser": "8.
|
|
62
|
-
"eslint": "
|
|
63
|
-
"eslint-config-airbnb-typescript": "18.0.0",
|
|
58
|
+
"@types/lodash": "4.17.23",
|
|
59
|
+
"@types/node": "24.10.9",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "8.54.0",
|
|
61
|
+
"@typescript-eslint/parser": "8.54.0",
|
|
62
|
+
"eslint": "9.39.2",
|
|
64
63
|
"eslint-config-prettier": "10.1.8",
|
|
65
|
-
"eslint-plugin-
|
|
66
|
-
"eslint-plugin-prettier": "5.5.4",
|
|
64
|
+
"eslint-plugin-prettier": "5.5.5",
|
|
67
65
|
"husky": "9.1.7",
|
|
68
66
|
"jest": "30.2.0",
|
|
69
67
|
"jest-mock-extended": "4.0.0",
|
|
70
68
|
"lint-staged": "16.2.7",
|
|
71
69
|
"nock": "14.0.10",
|
|
72
|
-
"prettier": "3.
|
|
70
|
+
"prettier": "3.8.1",
|
|
73
71
|
"ts-jest": "29.4.6",
|
|
74
72
|
"ts-node": "10.9.2",
|
|
75
|
-
"typescript": "5.9.3"
|
|
73
|
+
"typescript": "5.9.3",
|
|
74
|
+
"typescript-eslint": "8.54.0"
|
|
76
75
|
},
|
|
77
76
|
"prettier": {
|
|
78
77
|
"printWidth": 100,
|