@moreapp/common-nodejs 0.9.1 → 0.10.0

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.
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { AxiosRequestConfig } from "axios";
4
2
  interface Options {
5
3
  serviceName: string;
@@ -42,7 +42,7 @@ test("unable to connect", async () => {
42
42
  prefix: "https://non-existing.moreapp.com",
43
43
  seal: "my-seal",
44
44
  });
45
- await expect(client.getBinary("/download")).rejects.toThrowError("getaddrinfo ENOTFOUND non-existing.moreapp.com");
45
+ await expect(client.getBinary("/download")).rejects.toThrow("getaddrinfo ENOTFOUND non-existing.moreapp.com");
46
46
  });
47
47
  const client = new MoreAppClient_1.default({
48
48
  serviceName: "Common Test",
package/dist/dateUtil.js CHANGED
@@ -3,30 +3,29 @@ 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
- exports.formatDateTime = exports.formatDate = exports.isDateTime = exports.isDate = void 0;
6
+ exports.isDate = isDate;
7
+ exports.isDateTime = isDateTime;
8
+ exports.formatDate = formatDate;
9
+ exports.formatDateTime = formatDateTime;
7
10
  const date_and_time_1 = __importDefault(require("date-and-time"));
8
11
  const DATE_REGEX = /^\d{4}-\d{1,2}-\d{1,2}$/;
9
12
  const DATE_TIME_REGEX = /^\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{2}$/;
10
13
  function isDate(string) {
11
14
  return DATE_REGEX.test(string) && !isNaN(Date.parse(string));
12
15
  }
13
- exports.isDate = isDate;
14
16
  function isDateTime(string) {
15
17
  return DATE_TIME_REGEX.test(string) && !isNaN(Date.parse(string));
16
18
  }
17
- exports.isDateTime = isDateTime;
18
19
  function formatDate(dateString, format) {
19
20
  const date = date_and_time_1.default.parse(dateString, "YYYY-MM-DD");
20
21
  return date_and_time_1.default.format(date, formatDateFormat(format));
21
22
  }
22
- exports.formatDate = formatDate;
23
23
  function formatDateTime(dateTime, format) {
24
24
  const date = typeof dateTime === "string"
25
25
  ? date_and_time_1.default.parse(dateTime, "YYYY-MM-DD HH:mm", { timeZone: "UTC" })
26
26
  : new Date(dateTime);
27
27
  return date_and_time_1.default.format(date, formatDateFormat(format) + " HH:mm", { timeZone: "UTC" });
28
28
  }
29
- exports.formatDateTime = formatDateTime;
30
29
  function formatDateFormat(format) {
31
30
  switch (format) {
32
31
  case "DDMMYYYY":
package/dist/index.d.ts CHANGED
@@ -5,6 +5,6 @@ export * from "./tracer";
5
5
  export * from "./logger";
6
6
  export * from "./dateUtil";
7
7
  export * from "./utils";
8
- export * from "./k8s";
8
+ export * from "./observability";
9
9
  export { BinaryFile } from "./MoreAppClient";
10
10
  export { MoreAppClient };
package/dist/index.js CHANGED
@@ -26,4 +26,4 @@ __exportStar(require("./tracer"), exports);
26
26
  __exportStar(require("./logger"), exports);
27
27
  __exportStar(require("./dateUtil"), exports);
28
28
  __exportStar(require("./utils"), exports);
29
- __exportStar(require("./k8s"), exports);
29
+ __exportStar(require("./observability"), exports);
@@ -1,15 +1,15 @@
1
1
  import ExpressRequestTracker from "./ExpressRequestTracker";
2
- type HealthServerOptions = {
2
+ type ObservabilityServerOptions = {
3
3
  port: number;
4
4
  };
5
- export default class HealthServer {
5
+ export default class ObservabilityServer {
6
6
  private readonly requestTracker;
7
7
  private readonly options;
8
8
  private readonly server;
9
9
  private status;
10
10
  private isReady;
11
11
  private constructor();
12
- static create(requestTracker: ExpressRequestTracker, options: HealthServerOptions): Promise<HealthServer>;
12
+ static create(requestTracker: ExpressRequestTracker, options: ObservabilityServerOptions): Promise<ObservabilityServer>;
13
13
  start(): Promise<void>;
14
14
  stop(): Promise<void>;
15
15
  setReady(value: boolean): void;
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const node_http_1 = __importDefault(require("node:http"));
7
+ const prom_client_1 = __importDefault(require("prom-client"));
7
8
  const logger_1 = require("../logger");
8
- class HealthServer {
9
+ class ObservabilityServer {
9
10
  requestTracker;
10
11
  options;
11
12
  server;
@@ -14,7 +15,8 @@ class HealthServer {
14
15
  constructor(requestTracker, options) {
15
16
  this.requestTracker = requestTracker;
16
17
  this.options = options;
17
- this.server = node_http_1.default.createServer((req, res) => {
18
+ prom_client_1.default.collectDefaultMetrics();
19
+ this.server = node_http_1.default.createServer(async (req, res) => {
18
20
  if (req.url === "/live") {
19
21
  res.writeHead(200, { "Content-Type": "application/json" });
20
22
  return res.end(JSON.stringify({ status: "ok" }));
@@ -26,6 +28,10 @@ class HealthServer {
26
28
  activeRequests: this.requestTracker.nrOfActiveRequests(),
27
29
  }));
28
30
  }
31
+ else if (req.url === "/metrics") {
32
+ res.setHeader("Content-Type", prom_client_1.default.register.contentType);
33
+ return res.end(await prom_client_1.default.register.metrics());
34
+ }
29
35
  else {
30
36
  res.statusCode = 404;
31
37
  return res.end();
@@ -33,28 +39,32 @@ class HealthServer {
33
39
  });
34
40
  }
35
41
  static async create(requestTracker, options) {
36
- const hs = new HealthServer(requestTracker, options);
42
+ const hs = new ObservabilityServer(requestTracker, options);
37
43
  await hs.start();
38
44
  return hs;
39
45
  }
40
46
  start() {
41
47
  if (this.status !== "stopped") {
42
- logger_1.logger.info("Cannot start Health server, due to invalid status", { status: this.status });
48
+ logger_1.logger.info("Cannot start Observability server, due to invalid status", {
49
+ status: this.status,
50
+ });
43
51
  return Promise.resolve();
44
52
  }
45
53
  this.status = "starting";
46
54
  return new Promise((resolve) => {
47
55
  this.server.listen(this.options.port, () => {
48
56
  this.status = "started";
49
- logger_1.logger.info("Started Health server");
57
+ logger_1.logger.info("Started Observability server");
50
58
  resolve();
51
59
  });
52
60
  });
53
61
  }
54
62
  stop() {
55
63
  if (this.status !== "started") {
56
- logger_1.logger.warn("Cannot stop Health server, due to invalid status", { status: this.status });
57
- return Promise.reject(new Error("Health server not started"));
64
+ logger_1.logger.warn("Cannot stop Observability server, due to invalid status", {
65
+ status: this.status,
66
+ });
67
+ return Promise.reject(new Error("Observability server not started"));
58
68
  }
59
69
  this.status = "stopping";
60
70
  this.isReady = false;
@@ -64,4 +74,4 @@ class HealthServer {
64
74
  this.isReady = value;
65
75
  }
66
76
  }
67
- exports.default = HealthServer;
77
+ exports.default = ObservabilityServer;
@@ -7,8 +7,8 @@ const testUtils_1 = require("../testUtils");
7
7
  (0, testUtils_1.silenceLogger)();
8
8
  const node_http_1 = __importDefault(require("node:http"));
9
9
  const node_events_1 = require("node:events");
10
- const HealthServer_1 = __importDefault(require("./HealthServer"));
11
- describe("HealthServer", () => {
10
+ const ObservabilityServer_1 = __importDefault(require("./ObservabilityServer"));
11
+ describe("ObservabilityServer", () => {
12
12
  const createFakeServer = () => {
13
13
  const emitter = new node_events_1.EventEmitter();
14
14
  const server = {
@@ -57,7 +57,7 @@ describe("HealthServer", () => {
57
57
  return fakeServer;
58
58
  });
59
59
  const requestTracker = { nrOfActiveRequests: jest.fn(() => 0) };
60
- const hs = await HealthServer_1.default.create(requestTracker, { port: 0 });
60
+ const hs = await ObservabilityServer_1.default.create(requestTracker, { port: 0 });
61
61
  expect(fakeServer.listen).toHaveBeenCalled();
62
62
  // /live
63
63
  const resLive = createRes();
@@ -1,12 +1,11 @@
1
- /// <reference types="node" />
2
1
  import ExpressRequestTracker from "./ExpressRequestTracker";
3
- import HealthServer from "./HealthServer";
2
+ import ObservabilityServer from "./ObservabilityServer";
4
3
  import { Server } from "node:http";
5
4
  export default class TerminationHandler {
6
5
  private readonly server;
7
6
  private readonly hs;
8
7
  private readonly requestTracker;
9
8
  private readonly sockets;
10
- constructor(server: Server, hs: HealthServer, requestTracker: ExpressRequestTracker);
9
+ constructor(server: Server, hs: ObservabilityServer, requestTracker: ExpressRequestTracker);
11
10
  shutdown(): void;
12
11
  }
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -0,0 +1,4 @@
1
+ import ExpressRequestTracker from "./ExpressRequestTracker";
2
+ import ObservabilityServer from "./ObservabilityServer";
3
+ import TerminationHandler from "./TerminationHandler";
4
+ export { ExpressRequestTracker, ObservabilityServer, TerminationHandler };
@@ -3,10 +3,10 @@ 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
- exports.TerminationHandler = exports.HealthServer = exports.ExpressRequestTracker = void 0;
6
+ exports.TerminationHandler = exports.ObservabilityServer = exports.ExpressRequestTracker = void 0;
7
7
  const ExpressRequestTracker_1 = __importDefault(require("./ExpressRequestTracker"));
8
8
  exports.ExpressRequestTracker = ExpressRequestTracker_1.default;
9
- const HealthServer_1 = __importDefault(require("./HealthServer"));
10
- exports.HealthServer = HealthServer_1.default;
9
+ const ObservabilityServer_1 = __importDefault(require("./ObservabilityServer"));
10
+ exports.ObservabilityServer = ObservabilityServer_1.default;
11
11
  const TerminationHandler_1 = __importDefault(require("./TerminationHandler"));
12
12
  exports.TerminationHandler = TerminationHandler_1.default;
package/dist/schema.d.ts CHANGED
@@ -1,61 +1,19 @@
1
1
  import { z } from "zod";
2
- export declare const EmailAddressSchema: z.ZodEffects<z.ZodString, string, string>;
2
+ export declare const EmailAddressSchema: z.ZodString;
3
3
  export declare const FormVersionFieldSchema: z.ZodObject<{
4
4
  uid: z.ZodString;
5
5
  properties: z.ZodObject<{
6
6
  data_name: z.ZodOptional<z.ZodString>;
7
- }, "strip", z.ZodTypeAny, {
8
- data_name?: string | undefined;
9
- }, {
10
- data_name?: string | undefined;
11
- }>;
12
- }, "strip", z.ZodTypeAny, {
13
- uid: string;
14
- properties: {
15
- data_name?: string | undefined;
16
- };
17
- }, {
18
- uid: string;
19
- properties: {
20
- data_name?: string | undefined;
21
- };
22
- }>;
7
+ }, z.core.$strip>;
8
+ }, z.core.$strip>;
23
9
  export declare const FormVersionSchema: z.ZodObject<{
24
10
  fields: z.ZodArray<z.ZodObject<{
25
11
  uid: z.ZodString;
26
12
  properties: z.ZodObject<{
27
13
  data_name: z.ZodOptional<z.ZodString>;
28
- }, "strip", z.ZodTypeAny, {
29
- data_name?: string | undefined;
30
- }, {
31
- data_name?: string | undefined;
32
- }>;
33
- }, "strip", z.ZodTypeAny, {
34
- uid: string;
35
- properties: {
36
- data_name?: string | undefined;
37
- };
38
- }, {
39
- uid: string;
40
- properties: {
41
- data_name?: string | undefined;
42
- };
43
- }>, "many">;
44
- }, "strip", z.ZodTypeAny, {
45
- fields: {
46
- uid: string;
47
- properties: {
48
- data_name?: string | undefined;
49
- };
50
- }[];
51
- }, {
52
- fields: {
53
- uid: string;
54
- properties: {
55
- data_name?: string | undefined;
56
- };
57
- }[];
58
- }>;
14
+ }, z.core.$strip>;
15
+ }, z.core.$strip>>;
16
+ }, z.core.$strip>;
59
17
  export declare const SubmissionSchema: z.ZodObject<{
60
18
  id: z.ZodString;
61
19
  info: z.ZodObject<{
@@ -63,17 +21,7 @@ export declare const SubmissionSchema: z.ZodObject<{
63
21
  formName: z.ZodString;
64
22
  date: z.ZodNumber;
65
23
  userId: z.ZodString;
66
- }, "strip", z.ZodTypeAny, {
67
- date: number;
68
- customerId: number;
69
- formName: string;
70
- userId: string;
71
- }, {
72
- date: number;
73
- customerId: number;
74
- formName: string;
75
- userId: string;
76
- }>;
24
+ }, z.core.$strip>;
77
25
  meta: z.ZodObject<{
78
26
  registrationDate: z.ZodString;
79
27
  instructionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -83,131 +31,23 @@ export declare const SubmissionSchema: z.ZodObject<{
83
31
  location: z.ZodNullable<z.ZodObject<{
84
32
  longitude: z.ZodString;
85
33
  latitude: z.ZodString;
86
- }, "strip", z.ZodTypeAny, {
87
- longitude: string;
88
- latitude: string;
89
- }, {
90
- longitude: string;
91
- latitude: string;
92
- }>>;
93
- }, "strip", z.ZodTypeAny, {
94
- registrationDate: string;
95
- taskId: string | null;
96
- serialNumber: number;
97
- guid: string;
98
- location: {
99
- longitude: string;
100
- latitude: string;
101
- } | null;
102
- instructionId?: string | null | undefined;
103
- }, {
104
- registrationDate: string;
105
- taskId: string | null;
106
- serialNumber: number;
107
- guid: string;
108
- location: {
109
- longitude: string;
110
- latitude: string;
111
- } | null;
112
- instructionId?: string | null | undefined;
113
- }>;
34
+ }, z.core.$strip>>;
35
+ }, z.core.$strip>;
114
36
  data: z.ZodRecord<z.ZodString, z.ZodAny>;
115
37
  mailStatuses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
116
38
  pdfFileId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
117
- emailAddresses: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
118
- }, "strip", z.ZodTypeAny, {
119
- emailAddresses: string[];
120
- pdfFileId?: string | null | undefined;
121
- }, {
122
- emailAddresses: string[];
123
- pdfFileId?: string | null | undefined;
124
- }>, "many">>>;
125
- }, "strip", z.ZodTypeAny, {
126
- data: Record<string, any>;
127
- id: string;
128
- info: {
129
- date: number;
130
- customerId: number;
131
- formName: string;
132
- userId: string;
133
- };
134
- meta: {
135
- registrationDate: string;
136
- taskId: string | null;
137
- serialNumber: number;
138
- guid: string;
139
- location: {
140
- longitude: string;
141
- latitude: string;
142
- } | null;
143
- instructionId?: string | null | undefined;
144
- };
145
- mailStatuses?: {
146
- emailAddresses: string[];
147
- pdfFileId?: string | null | undefined;
148
- }[] | null | undefined;
149
- }, {
150
- data: Record<string, any>;
151
- id: string;
152
- info: {
153
- date: number;
154
- customerId: number;
155
- formName: string;
156
- userId: string;
157
- };
158
- meta: {
159
- registrationDate: string;
160
- taskId: string | null;
161
- serialNumber: number;
162
- guid: string;
163
- location: {
164
- longitude: string;
165
- latitude: string;
166
- } | null;
167
- instructionId?: string | null | undefined;
168
- };
169
- mailStatuses?: {
170
- emailAddresses: string[];
171
- pdfFileId?: string | null | undefined;
172
- }[] | null | undefined;
173
- }>;
39
+ emailAddresses: z.ZodArray<z.ZodString>;
40
+ }, z.core.$strip>>>>;
41
+ }, z.core.$strip>;
174
42
  export declare const BaseIntegrationRequestSchema: z.ZodObject<{
175
43
  view: z.ZodObject<{
176
44
  fields: z.ZodArray<z.ZodObject<{
177
45
  uid: z.ZodString;
178
46
  properties: z.ZodObject<{
179
47
  data_name: z.ZodOptional<z.ZodString>;
180
- }, "strip", z.ZodTypeAny, {
181
- data_name?: string | undefined;
182
- }, {
183
- data_name?: string | undefined;
184
- }>;
185
- }, "strip", z.ZodTypeAny, {
186
- uid: string;
187
- properties: {
188
- data_name?: string | undefined;
189
- };
190
- }, {
191
- uid: string;
192
- properties: {
193
- data_name?: string | undefined;
194
- };
195
- }>, "many">;
196
- }, "strip", z.ZodTypeAny, {
197
- fields: {
198
- uid: string;
199
- properties: {
200
- data_name?: string | undefined;
201
- };
202
- }[];
203
- }, {
204
- fields: {
205
- uid: string;
206
- properties: {
207
- data_name?: string | undefined;
208
- };
209
- }[];
210
- }>;
48
+ }, z.core.$strip>;
49
+ }, z.core.$strip>>;
50
+ }, z.core.$strip>;
211
51
  registration: z.ZodObject<{
212
52
  id: z.ZodString;
213
53
  info: z.ZodObject<{
@@ -215,17 +55,7 @@ export declare const BaseIntegrationRequestSchema: z.ZodObject<{
215
55
  formName: z.ZodString;
216
56
  date: z.ZodNumber;
217
57
  userId: z.ZodString;
218
- }, "strip", z.ZodTypeAny, {
219
- date: number;
220
- customerId: number;
221
- formName: string;
222
- userId: string;
223
- }, {
224
- date: number;
225
- customerId: number;
226
- formName: string;
227
- userId: string;
228
- }>;
58
+ }, z.core.$strip>;
229
59
  meta: z.ZodObject<{
230
60
  registrationDate: z.ZodString;
231
61
  instructionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -235,179 +65,17 @@ export declare const BaseIntegrationRequestSchema: z.ZodObject<{
235
65
  location: z.ZodNullable<z.ZodObject<{
236
66
  longitude: z.ZodString;
237
67
  latitude: z.ZodString;
238
- }, "strip", z.ZodTypeAny, {
239
- longitude: string;
240
- latitude: string;
241
- }, {
242
- longitude: string;
243
- latitude: string;
244
- }>>;
245
- }, "strip", z.ZodTypeAny, {
246
- registrationDate: string;
247
- taskId: string | null;
248
- serialNumber: number;
249
- guid: string;
250
- location: {
251
- longitude: string;
252
- latitude: string;
253
- } | null;
254
- instructionId?: string | null | undefined;
255
- }, {
256
- registrationDate: string;
257
- taskId: string | null;
258
- serialNumber: number;
259
- guid: string;
260
- location: {
261
- longitude: string;
262
- latitude: string;
263
- } | null;
264
- instructionId?: string | null | undefined;
265
- }>;
68
+ }, z.core.$strip>>;
69
+ }, z.core.$strip>;
266
70
  data: z.ZodRecord<z.ZodString, z.ZodAny>;
267
71
  mailStatuses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
268
72
  pdfFileId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
269
- emailAddresses: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
270
- }, "strip", z.ZodTypeAny, {
271
- emailAddresses: string[];
272
- pdfFileId?: string | null | undefined;
273
- }, {
274
- emailAddresses: string[];
275
- pdfFileId?: string | null | undefined;
276
- }>, "many">>>;
277
- }, "strip", z.ZodTypeAny, {
278
- data: Record<string, any>;
279
- id: string;
280
- info: {
281
- date: number;
282
- customerId: number;
283
- formName: string;
284
- userId: string;
285
- };
286
- meta: {
287
- registrationDate: string;
288
- taskId: string | null;
289
- serialNumber: number;
290
- guid: string;
291
- location: {
292
- longitude: string;
293
- latitude: string;
294
- } | null;
295
- instructionId?: string | null | undefined;
296
- };
297
- mailStatuses?: {
298
- emailAddresses: string[];
299
- pdfFileId?: string | null | undefined;
300
- }[] | null | undefined;
301
- }, {
302
- data: Record<string, any>;
303
- id: string;
304
- info: {
305
- date: number;
306
- customerId: number;
307
- formName: string;
308
- userId: string;
309
- };
310
- meta: {
311
- registrationDate: string;
312
- taskId: string | null;
313
- serialNumber: number;
314
- guid: string;
315
- location: {
316
- longitude: string;
317
- latitude: string;
318
- } | null;
319
- instructionId?: string | null | undefined;
320
- };
321
- mailStatuses?: {
322
- emailAddresses: string[];
323
- pdfFileId?: string | null | undefined;
324
- }[] | null | undefined;
325
- }>;
73
+ emailAddresses: z.ZodArray<z.ZodString>;
74
+ }, z.core.$strip>>>>;
75
+ }, z.core.$strip>;
326
76
  seal: z.ZodString;
327
77
  origin: z.ZodString;
328
78
  settings: z.ZodObject<{
329
79
  dateFormat: z.ZodString;
330
- }, "strip", z.ZodTypeAny, {
331
- dateFormat: string;
332
- }, {
333
- dateFormat: string;
334
- }>;
335
- }, "strip", z.ZodTypeAny, {
336
- view: {
337
- fields: {
338
- uid: string;
339
- properties: {
340
- data_name?: string | undefined;
341
- };
342
- }[];
343
- };
344
- registration: {
345
- data: Record<string, any>;
346
- id: string;
347
- info: {
348
- date: number;
349
- customerId: number;
350
- formName: string;
351
- userId: string;
352
- };
353
- meta: {
354
- registrationDate: string;
355
- taskId: string | null;
356
- serialNumber: number;
357
- guid: string;
358
- location: {
359
- longitude: string;
360
- latitude: string;
361
- } | null;
362
- instructionId?: string | null | undefined;
363
- };
364
- mailStatuses?: {
365
- emailAddresses: string[];
366
- pdfFileId?: string | null | undefined;
367
- }[] | null | undefined;
368
- };
369
- seal: string;
370
- origin: string;
371
- settings: {
372
- dateFormat: string;
373
- };
374
- }, {
375
- view: {
376
- fields: {
377
- uid: string;
378
- properties: {
379
- data_name?: string | undefined;
380
- };
381
- }[];
382
- };
383
- registration: {
384
- data: Record<string, any>;
385
- id: string;
386
- info: {
387
- date: number;
388
- customerId: number;
389
- formName: string;
390
- userId: string;
391
- };
392
- meta: {
393
- registrationDate: string;
394
- taskId: string | null;
395
- serialNumber: number;
396
- guid: string;
397
- location: {
398
- longitude: string;
399
- latitude: string;
400
- } | null;
401
- instructionId?: string | null | undefined;
402
- };
403
- mailStatuses?: {
404
- emailAddresses: string[];
405
- pdfFileId?: string | null | undefined;
406
- }[] | null | undefined;
407
- };
408
- seal: string;
409
- origin: string;
410
- settings: {
411
- dateFormat: string;
412
- };
413
- }>;
80
+ }, z.core.$strip>;
81
+ }, z.core.$strip>;
package/dist/schema.js CHANGED
@@ -37,7 +37,7 @@ exports.SubmissionSchema = zod_1.z.object({
37
37
  })
38
38
  .nullable(),
39
39
  }),
40
- data: zod_1.z.record(zod_1.z.any()),
40
+ data: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
41
41
  mailStatuses: zod_1.z
42
42
  .array(zod_1.z.object({
43
43
  pdfFileId: zod_1.z.string().nullish(),
@@ -1,2 +1 @@
1
- /// <reference types="jest" />
2
1
  export declare const silenceLogger: () => typeof jest;
package/dist/tracer.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as types from "@opentelemetry/instrumentation/build/src/types";
2
2
  export declare const tracer: (serviceName: string, { http, extraInstrumentations, debug, }: {
3
3
  http?: {
4
4
  portsToInstrument: number[];
5
- } | undefined;
6
- extraInstrumentations?: types.Instrumentation[] | undefined;
7
- debug?: boolean | undefined;
5
+ };
6
+ extraInstrumentations?: types.Instrumentation[];
7
+ debug?: boolean;
8
8
  }) => void;
package/dist/tracer.js CHANGED
@@ -31,25 +31,28 @@ const tracer = (serviceName, { http = {
31
31
  ],
32
32
  });
33
33
  const provider = new sdk_trace_node_1.NodeTracerProvider({
34
- resource: new resources_1.Resource({
34
+ resource: (0, resources_1.resourceFromAttributes)({
35
35
  [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: serviceName,
36
36
  [semantic_conventions_1.SemanticResourceAttributes.SERVICE_INSTANCE_ID]: (0, utils_1.environmentVariable)("HOSTNAME", "local"),
37
37
  }),
38
+ spanProcessors: [
39
+ ...((0, utils_1.environmentVariable)("STACKDRIVER_TRACING_ENABLED", false)
40
+ ? [
41
+ new sdk_trace_base_1.BatchSpanProcessor(new opentelemetry_cloud_trace_exporter_1.TraceExporter({
42
+ resourceFilter: /^service\./,
43
+ })),
44
+ ]
45
+ : []),
46
+ ...(debug ? [new sdk_trace_base_1.BatchSpanProcessor(new sdk_trace_node_1.ConsoleSpanExporter())] : []),
47
+ ],
38
48
  });
39
49
  provider.register({
40
50
  propagator: new propagator_b3_1.B3Propagator({
41
51
  injectEncoding: propagator_b3_1.B3InjectEncoding.MULTI_HEADER,
42
52
  }),
43
53
  });
44
- if ((0, utils_1.environmentVariable)("STACKDRIVER_TRACING_ENABLED", false)) {
45
- const exporter = new opentelemetry_cloud_trace_exporter_1.TraceExporter({
46
- resourceFilter: /^service\./,
47
- });
48
- provider.addSpanProcessor(new sdk_trace_base_1.BatchSpanProcessor(exporter));
49
- }
50
54
  if (debug) {
51
55
  api_1.diag.setLogger(new api_1.DiagConsoleLogger(), api_1.DiagLogLevel.DEBUG);
52
- provider.addSpanProcessor(new sdk_trace_base_1.BatchSpanProcessor(new sdk_trace_node_1.ConsoleSpanExporter()));
53
56
  }
54
57
  };
55
58
  exports.tracer = tracer;
package/dist/utils.js CHANGED
@@ -15,15 +15,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getDataForDataName = exports.parseDynamicRecipients = exports.isValidEmail = exports.currentTraceId = exports.environmentVariable = void 0;
36
+ exports.environmentVariable = environmentVariable;
37
+ exports.currentTraceId = currentTraceId;
38
+ exports.isValidEmail = isValidEmail;
39
+ exports.parseDynamicRecipients = parseDynamicRecipients;
40
+ exports.getDataForDataName = getDataForDataName;
27
41
  const api_1 = require("@opentelemetry/api");
28
42
  const lodash_1 = __importStar(require("lodash"));
29
43
  function environmentVariable(key, fallback) {
@@ -46,11 +60,9 @@ function environmentVariable(key, fallback) {
46
60
  }
47
61
  throw new Error(`Wrong type for environment variable '${key}'`);
48
62
  }
49
- exports.environmentVariable = environmentVariable;
50
63
  function currentTraceId() {
51
64
  return api_1.trace.getSpanContext(api_1.context.active())?.traceId;
52
65
  }
53
- exports.currentTraceId = currentTraceId;
54
66
  const emailAddressMaxLength = 254; // https://stackoverflow.com/a/574698
55
67
  const emailAddressLocalPattern = /^.+$/;
56
68
  const emailAddressDomainPattern = /^(?:[A-z0-9À-ž](?:[A-z0-9À-ž-]{0,61}[A-z0-9À-ž])?\.)+[A-z0-9À-ž][A-z0-9À-ž-]{0,61}[A-z0-9]$/;
@@ -73,7 +85,6 @@ function isValidEmail(email) {
73
85
  emailAddressLocalPattern.test(localAddr) &&
74
86
  emailAddressDomainPattern.test(domain));
75
87
  }
76
- exports.isValidEmail = isValidEmail;
77
88
  function parseDynamicRecipients(dynamicRecipients, fields, data) {
78
89
  const recipients = [];
79
90
  dynamicRecipients.forEach((fieldUid) => {
@@ -106,7 +117,6 @@ function parseDynamicRecipients(dynamicRecipients, fields, data) {
106
117
  });
107
118
  return recipients;
108
119
  }
109
- exports.parseDynamicRecipients = parseDynamicRecipients;
110
120
  function getDataNameForFieldUid(fields, fieldUid) {
111
121
  return fields.find((field) => field.uid === fieldUid)?.properties.data_name;
112
122
  }
@@ -125,7 +135,6 @@ function getDataForDataName(data, dataName) {
125
135
  }
126
136
  return data[dataName];
127
137
  }
128
- exports.getDataForDataName = getDataForDataName;
129
138
  function isObject(data) {
130
139
  return (0, lodash_1.isPlainObject)(data);
131
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moreapp/common-nodejs",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "license": "UNLICENSED",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,49 +19,50 @@
19
19
  "dist/**/*"
20
20
  ],
21
21
  "dependencies": {
22
- "@google-cloud/logging": "11.2.0",
23
- "@google-cloud/opentelemetry-cloud-trace-exporter": "2.1.0",
24
- "@opentelemetry/api": "1.8.0",
25
- "@opentelemetry/core": "1.22.0",
26
- "@opentelemetry/instrumentation": "0.49.1",
27
- "@opentelemetry/instrumentation-dns": "0.34.0",
28
- "@opentelemetry/instrumentation-express": "0.36.1",
29
- "@opentelemetry/instrumentation-http": "0.49.1",
30
- "@opentelemetry/instrumentation-winston": "0.35.0",
31
- "@opentelemetry/resources": "1.22.0",
32
- "@opentelemetry/sdk-node": "0.49.1",
33
- "@opentelemetry/sdk-trace-base": "1.22.0",
34
- "@opentelemetry/sdk-trace-node": "1.22.0",
35
- "@opentelemetry/semantic-conventions": "1.22.0",
22
+ "@google-cloud/logging": "11.2.1",
23
+ "@google-cloud/opentelemetry-cloud-trace-exporter": "3.0.0",
24
+ "@opentelemetry/api": "1.9.0",
25
+ "@opentelemetry/core": "2.2.0",
26
+ "@opentelemetry/instrumentation": "0.208.0",
27
+ "@opentelemetry/instrumentation-dns": "0.52.0",
28
+ "@opentelemetry/instrumentation-express": "0.57.0",
29
+ "@opentelemetry/instrumentation-http": "0.208.0",
30
+ "@opentelemetry/instrumentation-winston": "0.53.0",
31
+ "@opentelemetry/resources": "2.2.0",
32
+ "@opentelemetry/sdk-node": "0.208.0",
33
+ "@opentelemetry/sdk-trace-base": "2.2.0",
34
+ "@opentelemetry/sdk-trace-node": "2.2.0",
35
+ "@opentelemetry/semantic-conventions": "1.38.0",
36
36
  "axios": "1.13.2",
37
37
  "content-disposition-parser": "1.0.2",
38
- "date-and-time": "4.1.0",
38
+ "date-and-time": "4.1.2",
39
39
  "express": "5.2.1",
40
40
  "lodash": "4.17.21",
41
- "winston": "3.13.0",
42
- "zod": "3.25.76"
41
+ "prom-client": "15.1.3",
42
+ "winston": "3.18.3",
43
+ "zod": "4.1.13"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@types/express": "5.0.6",
46
- "@types/jest": "29.5.11",
47
- "@types/lodash": "4.17.0",
48
- "@types/node": "24.10.1",
49
- "@typescript-eslint/eslint-plugin": "6.21.0",
50
- "@typescript-eslint/parser": "6.21.0",
51
- "eslint": "8.57.0",
47
+ "@types/jest": "30.0.0",
48
+ "@types/lodash": "4.17.21",
49
+ "@types/node": "24.10.4",
50
+ "@typescript-eslint/eslint-plugin": "8.49.0",
51
+ "@typescript-eslint/parser": "8.49.0",
52
+ "eslint": "8.57.1",
52
53
  "eslint-config-airbnb-typescript": "18.0.0",
53
- "eslint-config-prettier": "9.1.0",
54
- "eslint-plugin-import": "2.29.1",
55
- "eslint-plugin-prettier": "5.1.3",
56
- "husky": "9.0.7",
57
- "jest": "29.7.0",
54
+ "eslint-config-prettier": "10.1.8",
55
+ "eslint-plugin-import": "2.32.0",
56
+ "eslint-plugin-prettier": "5.5.4",
57
+ "husky": "9.1.7",
58
+ "jest": "30.2.0",
58
59
  "jest-mock-extended": "4.0.0",
59
- "lint-staged": "16.2.6",
60
+ "lint-staged": "16.2.7",
60
61
  "nock": "14.0.10",
61
- "prettier": "3.2.4",
62
- "ts-jest": "29.1.2",
62
+ "prettier": "3.7.4",
63
+ "ts-jest": "29.4.6",
63
64
  "ts-node": "10.9.2",
64
- "typescript": "5.4.3"
65
+ "typescript": "5.9.3"
65
66
  },
66
67
  "prettier": {
67
68
  "printWidth": 100,
@@ -1,4 +0,0 @@
1
- import ExpressRequestTracker from "./ExpressRequestTracker";
2
- import HealthServer from "./HealthServer";
3
- import TerminationHandler from "./TerminationHandler";
4
- export { ExpressRequestTracker, HealthServer, TerminationHandler };