@moreapp/common-nodejs 0.7.3 → 0.7.5
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 +35 -9
- package/dist/schema.d.ts +24 -12
- package/dist/schema.js +2 -1
- package/dist/tracer.d.ts +4 -4
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -1,21 +1,47 @@
|
|
|
1
|
-
# MoreApp Common
|
|
1
|
+
# MoreApp Common Node.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This project contains common code that can be used for our Node.js projects.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Getting started
|
|
6
6
|
|
|
7
7
|
Run `yarn prepare` once to install Git hooks, doing lints and prettier formatting
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Project usage
|
|
10
|
+
|
|
11
|
+
Most code can be used as is, except for tracing, see below.
|
|
10
12
|
|
|
11
13
|
### Tracing
|
|
12
14
|
|
|
13
|
-
Tracing code should always be loaded first, before any other libraries. This is because the
|
|
14
|
-
instrumentations monkey patch libraries to add tracing.
|
|
15
|
-
|
|
15
|
+
Tracing code should always be loaded (`import`/`require`) first, before any other libraries. This is because the
|
|
16
|
+
OpenTelemetry instrumentations monkey patch libraries to add tracing. Patching has to happen first, because already
|
|
17
|
+
loaded libraries will be cached by the module system.
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
The recommended way to do this, is to create a file `instrumentation.ts` with the following content (the extra
|
|
20
|
+
instrumentation is there as an example):
|
|
18
21
|
|
|
19
22
|
```
|
|
20
|
-
|
|
23
|
+
import { tracer } from "@moreapp/common-nodejs";
|
|
24
|
+
import { MongoDBInstrumentation } from "@opentelemetry/instrumentation-mongodb";
|
|
25
|
+
|
|
26
|
+
tracer("<SERVICE_NAME>", {
|
|
27
|
+
extraInstrumentations: [new MongoDBInstrumentation()],
|
|
28
|
+
});
|
|
21
29
|
```
|
|
30
|
+
|
|
31
|
+
And then use the `--require` [Node.js CLI option](https://nodejs.org/api/cli.html#-r---require-module) to load this file.
|
|
32
|
+
|
|
33
|
+
## Creating a new release
|
|
34
|
+
|
|
35
|
+
Follow the steps below to create a new release:
|
|
36
|
+
|
|
37
|
+
1. Ensure that the `master` branch has the commits you want to release
|
|
38
|
+
2. Start a new build in Bitbucket Pipelines for the `master` branch with the `create-release` pipeline
|
|
39
|
+
3. Select which type of version bump you want to do
|
|
40
|
+
4. The build will automatically create a new version and publish it to NPM
|
|
41
|
+
|
|
42
|
+
### Creating a local release
|
|
43
|
+
|
|
44
|
+
If you want to test new code in other projects, then you can link this repository using `Yarn`.
|
|
45
|
+
|
|
46
|
+
1. Run `yarn link` in this repository
|
|
47
|
+
2. Run `yarn link @moreapp/common-nodejs` in the project you want to use this repository in
|
package/dist/schema.d.ts
CHANGED
|
@@ -75,7 +75,8 @@ export declare const SubmissionSchema: z.ZodObject<{
|
|
|
75
75
|
}>;
|
|
76
76
|
meta: z.ZodObject<{
|
|
77
77
|
registrationDate: z.ZodString;
|
|
78
|
-
instructionId: z.ZodNullable<z.ZodString
|
|
78
|
+
instructionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
79
|
+
taskId: z.ZodNullable<z.ZodString>;
|
|
79
80
|
serialNumber: z.ZodNumber;
|
|
80
81
|
guid: z.ZodString;
|
|
81
82
|
location: z.ZodNullable<z.ZodObject<{
|
|
@@ -90,22 +91,24 @@ export declare const SubmissionSchema: z.ZodObject<{
|
|
|
90
91
|
}>>;
|
|
91
92
|
}, "strip", z.ZodTypeAny, {
|
|
92
93
|
registrationDate: string;
|
|
93
|
-
|
|
94
|
+
taskId: string | null;
|
|
94
95
|
serialNumber: number;
|
|
95
96
|
guid: string;
|
|
96
97
|
location: {
|
|
97
98
|
longitude: string;
|
|
98
99
|
latitude: string;
|
|
99
100
|
} | null;
|
|
101
|
+
instructionId?: string | null | undefined;
|
|
100
102
|
}, {
|
|
101
103
|
registrationDate: string;
|
|
102
|
-
|
|
104
|
+
taskId: string | null;
|
|
103
105
|
serialNumber: number;
|
|
104
106
|
guid: string;
|
|
105
107
|
location: {
|
|
106
108
|
longitude: string;
|
|
107
109
|
latitude: string;
|
|
108
110
|
} | null;
|
|
111
|
+
instructionId?: string | null | undefined;
|
|
109
112
|
}>;
|
|
110
113
|
data: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
111
114
|
mailStatuses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -129,13 +132,14 @@ export declare const SubmissionSchema: z.ZodObject<{
|
|
|
129
132
|
};
|
|
130
133
|
meta: {
|
|
131
134
|
registrationDate: string;
|
|
132
|
-
|
|
135
|
+
taskId: string | null;
|
|
133
136
|
serialNumber: number;
|
|
134
137
|
guid: string;
|
|
135
138
|
location: {
|
|
136
139
|
longitude: string;
|
|
137
140
|
latitude: string;
|
|
138
141
|
} | null;
|
|
142
|
+
instructionId?: string | null | undefined;
|
|
139
143
|
};
|
|
140
144
|
mailStatuses?: {
|
|
141
145
|
emailAddresses: string[];
|
|
@@ -152,13 +156,14 @@ export declare const SubmissionSchema: z.ZodObject<{
|
|
|
152
156
|
};
|
|
153
157
|
meta: {
|
|
154
158
|
registrationDate: string;
|
|
155
|
-
|
|
159
|
+
taskId: string | null;
|
|
156
160
|
serialNumber: number;
|
|
157
161
|
guid: string;
|
|
158
162
|
location: {
|
|
159
163
|
longitude: string;
|
|
160
164
|
latitude: string;
|
|
161
165
|
} | null;
|
|
166
|
+
instructionId?: string | null | undefined;
|
|
162
167
|
};
|
|
163
168
|
mailStatuses?: {
|
|
164
169
|
emailAddresses: string[];
|
|
@@ -222,7 +227,8 @@ export declare const BaseIntegrationRequestSchema: z.ZodObject<{
|
|
|
222
227
|
}>;
|
|
223
228
|
meta: z.ZodObject<{
|
|
224
229
|
registrationDate: z.ZodString;
|
|
225
|
-
instructionId: z.ZodNullable<z.ZodString
|
|
230
|
+
instructionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
231
|
+
taskId: z.ZodNullable<z.ZodString>;
|
|
226
232
|
serialNumber: z.ZodNumber;
|
|
227
233
|
guid: z.ZodString;
|
|
228
234
|
location: z.ZodNullable<z.ZodObject<{
|
|
@@ -237,22 +243,24 @@ export declare const BaseIntegrationRequestSchema: z.ZodObject<{
|
|
|
237
243
|
}>>;
|
|
238
244
|
}, "strip", z.ZodTypeAny, {
|
|
239
245
|
registrationDate: string;
|
|
240
|
-
|
|
246
|
+
taskId: string | null;
|
|
241
247
|
serialNumber: number;
|
|
242
248
|
guid: string;
|
|
243
249
|
location: {
|
|
244
250
|
longitude: string;
|
|
245
251
|
latitude: string;
|
|
246
252
|
} | null;
|
|
253
|
+
instructionId?: string | null | undefined;
|
|
247
254
|
}, {
|
|
248
255
|
registrationDate: string;
|
|
249
|
-
|
|
256
|
+
taskId: string | null;
|
|
250
257
|
serialNumber: number;
|
|
251
258
|
guid: string;
|
|
252
259
|
location: {
|
|
253
260
|
longitude: string;
|
|
254
261
|
latitude: string;
|
|
255
262
|
} | null;
|
|
263
|
+
instructionId?: string | null | undefined;
|
|
256
264
|
}>;
|
|
257
265
|
data: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
258
266
|
mailStatuses: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -276,13 +284,14 @@ export declare const BaseIntegrationRequestSchema: z.ZodObject<{
|
|
|
276
284
|
};
|
|
277
285
|
meta: {
|
|
278
286
|
registrationDate: string;
|
|
279
|
-
|
|
287
|
+
taskId: string | null;
|
|
280
288
|
serialNumber: number;
|
|
281
289
|
guid: string;
|
|
282
290
|
location: {
|
|
283
291
|
longitude: string;
|
|
284
292
|
latitude: string;
|
|
285
293
|
} | null;
|
|
294
|
+
instructionId?: string | null | undefined;
|
|
286
295
|
};
|
|
287
296
|
mailStatuses?: {
|
|
288
297
|
emailAddresses: string[];
|
|
@@ -299,13 +308,14 @@ export declare const BaseIntegrationRequestSchema: z.ZodObject<{
|
|
|
299
308
|
};
|
|
300
309
|
meta: {
|
|
301
310
|
registrationDate: string;
|
|
302
|
-
|
|
311
|
+
taskId: string | null;
|
|
303
312
|
serialNumber: number;
|
|
304
313
|
guid: string;
|
|
305
314
|
location: {
|
|
306
315
|
longitude: string;
|
|
307
316
|
latitude: string;
|
|
308
317
|
} | null;
|
|
318
|
+
instructionId?: string | null | undefined;
|
|
309
319
|
};
|
|
310
320
|
mailStatuses?: {
|
|
311
321
|
emailAddresses: string[];
|
|
@@ -341,13 +351,14 @@ export declare const BaseIntegrationRequestSchema: z.ZodObject<{
|
|
|
341
351
|
};
|
|
342
352
|
meta: {
|
|
343
353
|
registrationDate: string;
|
|
344
|
-
|
|
354
|
+
taskId: string | null;
|
|
345
355
|
serialNumber: number;
|
|
346
356
|
guid: string;
|
|
347
357
|
location: {
|
|
348
358
|
longitude: string;
|
|
349
359
|
latitude: string;
|
|
350
360
|
} | null;
|
|
361
|
+
instructionId?: string | null | undefined;
|
|
351
362
|
};
|
|
352
363
|
mailStatuses?: {
|
|
353
364
|
emailAddresses: string[];
|
|
@@ -379,13 +390,14 @@ export declare const BaseIntegrationRequestSchema: z.ZodObject<{
|
|
|
379
390
|
};
|
|
380
391
|
meta: {
|
|
381
392
|
registrationDate: string;
|
|
382
|
-
|
|
393
|
+
taskId: string | null;
|
|
383
394
|
serialNumber: number;
|
|
384
395
|
guid: string;
|
|
385
396
|
location: {
|
|
386
397
|
longitude: string;
|
|
387
398
|
latitude: string;
|
|
388
399
|
} | null;
|
|
400
|
+
instructionId?: string | null | undefined;
|
|
389
401
|
};
|
|
390
402
|
mailStatuses?: {
|
|
391
403
|
emailAddresses: string[];
|
package/dist/schema.js
CHANGED
|
@@ -21,7 +21,8 @@ exports.SubmissionSchema = zod_1.z.object({
|
|
|
21
21
|
}),
|
|
22
22
|
meta: zod_1.z.object({
|
|
23
23
|
registrationDate: zod_1.z.string(),
|
|
24
|
-
instructionId: zod_1.z.string().nullable(),
|
|
24
|
+
instructionId: zod_1.z.string().nullable().optional().describe("DEPRECATED - Use 'taskId' instead"),
|
|
25
|
+
taskId: zod_1.z.string().nullable(),
|
|
25
26
|
serialNumber: zod_1.z.number(),
|
|
26
27
|
guid: zod_1.z.string(),
|
|
27
28
|
location: zod_1.z
|
package/dist/tracer.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as types from "@opentelemetry/instrumentation/build/src/types";
|
|
2
2
|
export declare const tracer: (serviceName: string, { http, extraInstrumentations, debug, }: {
|
|
3
|
-
http
|
|
3
|
+
http?: {
|
|
4
4
|
portsToInstrument: number[];
|
|
5
|
-
};
|
|
6
|
-
extraInstrumentations
|
|
7
|
-
debug
|
|
5
|
+
} | undefined;
|
|
6
|
+
extraInstrumentations?: types.Instrumentation[] | undefined;
|
|
7
|
+
debug?: boolean | undefined;
|
|
8
8
|
}) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moreapp/common-nodejs",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,23 +22,23 @@
|
|
|
22
22
|
"@google-cloud/opentelemetry-cloud-trace-exporter": "2.0.0",
|
|
23
23
|
"@opentelemetry/api": "1.4.1",
|
|
24
24
|
"@opentelemetry/instrumentation": "0.38.0",
|
|
25
|
-
"@opentelemetry/instrumentation-dns": "0.31.
|
|
26
|
-
"@opentelemetry/instrumentation-express": "0.32.
|
|
25
|
+
"@opentelemetry/instrumentation-dns": "0.31.5",
|
|
26
|
+
"@opentelemetry/instrumentation-express": "0.32.4",
|
|
27
27
|
"@opentelemetry/instrumentation-http": "0.38.0",
|
|
28
|
-
"@opentelemetry/instrumentation-winston": "0.31.
|
|
28
|
+
"@opentelemetry/instrumentation-winston": "0.31.4",
|
|
29
29
|
"@opentelemetry/sdk-node": "0.38.0",
|
|
30
30
|
"@opentelemetry/sdk-trace-node": "1.12.0",
|
|
31
31
|
"axios": "1.4.0",
|
|
32
32
|
"content-disposition-parser": "1.0.2",
|
|
33
|
-
"date-and-time": "3.0.
|
|
33
|
+
"date-and-time": "3.0.2",
|
|
34
34
|
"winston": "3.8.2",
|
|
35
35
|
"zod": "3.21.4"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/jest": "29.5.
|
|
39
|
-
"@types/node": "18.16.
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "5.59.
|
|
41
|
-
"@typescript-eslint/parser": "5.59.
|
|
38
|
+
"@types/jest": "29.5.3",
|
|
39
|
+
"@types/node": "18.16.20",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "5.59.11",
|
|
41
|
+
"@typescript-eslint/parser": "5.59.11",
|
|
42
42
|
"eslint": "8.40.0",
|
|
43
43
|
"eslint-config-airbnb-typescript": "17.0.0",
|
|
44
44
|
"eslint-config-prettier": "8.8.0",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"jest": "29.5.0",
|
|
49
49
|
"jest-mock-extended": "3.0.4",
|
|
50
50
|
"jest-sonar-reporter": "2.0.0",
|
|
51
|
-
"lint-staged": "13.2.
|
|
52
|
-
"nock": "13.3.
|
|
51
|
+
"lint-staged": "13.2.3",
|
|
52
|
+
"nock": "13.3.2",
|
|
53
53
|
"prettier": "2.8.8",
|
|
54
|
-
"ts-jest": "29.1.
|
|
54
|
+
"ts-jest": "29.1.1",
|
|
55
55
|
"ts-node": "10.9.1",
|
|
56
56
|
"typescript": "5.0.4"
|
|
57
57
|
},
|