sm-utility 2.4.26 → 2.4.28-beta-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/date/index.js +1 -2
- package/excel/excel-creator/excelCreator.d.ts +0 -1
- package/excel/interfaces.d.ts +0 -1
- package/general/decorators/logMethod.decorator.js +1 -2
- package/general/gracefulShutdownManager.d.ts +0 -1
- package/general/index.js +7 -7
- package/infrastructure/redis/cacheClient.d.ts +2 -46
- package/infrastructure/redis/cacheClient.js +2 -2
- package/logger/config/index.js +0 -1
- package/logger/formatters/blacklist.js +7 -5
- package/logger/formatters/error.js +26 -28
- package/logger/index.d.ts +0 -2
- package/logger/transports/index.js +2 -3
- package/logger/utils/request.js +2 -3
- package/logger/utils/route.js +3 -4
- package/package.json +17 -17
- package/request/axios-custom-client.js +1 -2
- package/request/interceptors/error.interceptor.js +1 -2
- package/request/interceptors/request.interceptor.js +1 -2
- package/request/interceptors/response.interceptor.d.ts +1 -1
- package/request/interceptors/response.interceptor.js +1 -2
- package/request/loggers/error.logger.js +1 -2
- package/request/loggers/request.logger.js +1 -2
- package/request/loggers/response.logger.js +1 -2
- package/request/utils.js +2 -3
- package/stubs/index.js +3 -4
- package/thread/index.js +1 -2
- package/tracing/sqsOtelContextHandler.d.ts +5 -0
- package/tracing/sqsOtelContextHandler.js +45 -0
package/date/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDifferenceInMinutesBetweenDates =
|
|
3
|
+
exports.getDifferenceInMinutesBetweenDates = getDifferenceInMinutesBetweenDates;
|
|
4
4
|
function getDifferenceInMinutesBetweenDates(initialDate, lastDate) {
|
|
5
5
|
const diffInMilliseconds = Math.abs(initialDate.getTime() - lastDate.getTime());
|
|
6
6
|
const result = Math.floor(diffInMilliseconds / 1000 / 60);
|
|
7
7
|
return result;
|
|
8
8
|
}
|
|
9
|
-
exports.getDifferenceInMinutesBetweenDates = getDifferenceInMinutesBetweenDates;
|
package/excel/interfaces.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogMethod =
|
|
3
|
+
exports.LogMethod = LogMethod;
|
|
4
4
|
const logger_1 = require("../../logger");
|
|
5
5
|
const axios_1 = require("axios");
|
|
6
6
|
const axiosErrors_1 = require("../../errors/axiosErrors");
|
|
@@ -59,7 +59,6 @@ function LogMethod(options) {
|
|
|
59
59
|
return descriptor;
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
exports.LogMethod = LogMethod;
|
|
63
62
|
function handleError(error, className, propertyKey, metadata, params) {
|
|
64
63
|
if ((0, axios_1.isAxiosError)(error)) {
|
|
65
64
|
const fullErr = axiosErrors_1.AxiosErrHandler.extract(error);
|
package/general/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GracefulShutdownManager = exports.LogMethod = exports.Command = exports.MetadataModel =
|
|
3
|
+
exports.GracefulShutdownManager = exports.LogMethod = exports.Command = exports.MetadataModel = void 0;
|
|
4
|
+
exports.pipe = pipe;
|
|
5
|
+
exports.randomSixDigitNumber = randomSixDigitNumber;
|
|
6
|
+
exports.timeout = timeout;
|
|
7
|
+
exports.mergeDeep = mergeDeep;
|
|
8
|
+
exports.shortUniqueId = shortUniqueId;
|
|
9
|
+
exports.copy = copy;
|
|
4
10
|
const nanoid_1 = require("nanoid");
|
|
5
11
|
function pipe(...fns) {
|
|
6
12
|
return (x) => fns.reduce((v, f) => f(v), x);
|
|
7
13
|
}
|
|
8
|
-
exports.pipe = pipe;
|
|
9
14
|
function randomSixDigitNumber() {
|
|
10
15
|
return Math.floor(100000 + Math.random() * 900000);
|
|
11
16
|
}
|
|
12
|
-
exports.randomSixDigitNumber = randomSixDigitNumber;
|
|
13
17
|
function timeout(ms) {
|
|
14
18
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
19
|
}
|
|
16
|
-
exports.timeout = timeout;
|
|
17
20
|
function isObject(obj) {
|
|
18
21
|
return !!obj && obj.constructor === Object;
|
|
19
22
|
}
|
|
@@ -36,13 +39,11 @@ function mergeDeep(target, source) {
|
|
|
36
39
|
});
|
|
37
40
|
return target;
|
|
38
41
|
}
|
|
39
|
-
exports.mergeDeep = mergeDeep;
|
|
40
42
|
function shortUniqueId() {
|
|
41
43
|
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
42
44
|
const nanoid = (0, nanoid_1.customAlphabet)(alphabet, 8);
|
|
43
45
|
return nanoid();
|
|
44
46
|
}
|
|
45
|
-
exports.shortUniqueId = shortUniqueId;
|
|
46
47
|
/**
|
|
47
48
|
* Creates a deep copy of any JavaScript value, handling nested objects and various built-in types.
|
|
48
49
|
*
|
|
@@ -101,7 +102,6 @@ function copy(obj) {
|
|
|
101
102
|
});
|
|
102
103
|
return clone;
|
|
103
104
|
}
|
|
104
|
-
exports.copy = copy;
|
|
105
105
|
var metadata_model_1 = require("./metadata.model");
|
|
106
106
|
Object.defineProperty(exports, "MetadataModel", { enumerable: true, get: function () { return metadata_model_1.MetadataModel; } });
|
|
107
107
|
var command_abstract_1 = require("./command.abstract");
|
|
@@ -20,10 +20,10 @@ export declare class CacheClient {
|
|
|
20
20
|
list: typeof import("@redis/graph/dist/commands/LIST");
|
|
21
21
|
PROFILE: typeof import("@redis/graph/dist/commands/PROFILE");
|
|
22
22
|
profile: typeof import("@redis/graph/dist/commands/PROFILE");
|
|
23
|
+
QUERY_RO: typeof import("@redis/graph/dist/commands/QUERY_RO");
|
|
24
|
+
queryRo: typeof import("@redis/graph/dist/commands/QUERY_RO");
|
|
23
25
|
QUERY: typeof import("@redis/graph/dist/commands/QUERY");
|
|
24
26
|
query: typeof import("@redis/graph/dist/commands/QUERY");
|
|
25
|
-
RO_QUERY: typeof import("@redis/graph/dist/commands/RO_QUERY");
|
|
26
|
-
roQuery: typeof import("@redis/graph/dist/commands/RO_QUERY");
|
|
27
27
|
SLOWLOG: typeof import("@redis/graph/dist/commands/SLOWLOG");
|
|
28
28
|
slowLog: typeof import("@redis/graph/dist/commands/SLOWLOG");
|
|
29
29
|
};
|
|
@@ -48,12 +48,8 @@ export declare class CacheClient {
|
|
|
48
48
|
forget: typeof import("@redis/json/dist/commands/FORGET");
|
|
49
49
|
GET: typeof import("@redis/json/dist/commands/GET");
|
|
50
50
|
get: typeof import("@redis/json/dist/commands/GET");
|
|
51
|
-
MERGE: typeof import("@redis/json/dist/commands/MERGE");
|
|
52
|
-
merge: typeof import("@redis/json/dist/commands/MERGE");
|
|
53
51
|
MGET: typeof import("@redis/json/dist/commands/MGET");
|
|
54
52
|
mGet: typeof import("@redis/json/dist/commands/MGET");
|
|
55
|
-
MSET: typeof import("@redis/json/dist/commands/MSET");
|
|
56
|
-
mSet: typeof import("@redis/json/dist/commands/MSET");
|
|
57
53
|
NUMINCRBY: typeof import("@redis/json/dist/commands/NUMINCRBY");
|
|
58
54
|
numIncrBy: typeof import("@redis/json/dist/commands/NUMINCRBY");
|
|
59
55
|
NUMMULTBY: typeof import("@redis/json/dist/commands/NUMMULTBY");
|
|
@@ -78,8 +74,6 @@ export declare class CacheClient {
|
|
|
78
74
|
_list: typeof import("@redis/search/dist/commands/_LIST");
|
|
79
75
|
ALTER: typeof import("@redis/search/dist/commands/ALTER");
|
|
80
76
|
alter: typeof import("@redis/search/dist/commands/ALTER");
|
|
81
|
-
AGGREGATE_WITHCURSOR: typeof import("@redis/search/dist/commands/AGGREGATE_WITHCURSOR");
|
|
82
|
-
aggregateWithCursor: typeof import("@redis/search/dist/commands/AGGREGATE_WITHCURSOR");
|
|
83
77
|
AGGREGATE: typeof import("@redis/search/dist/commands/AGGREGATE");
|
|
84
78
|
aggregate: typeof import("@redis/search/dist/commands/AGGREGATE");
|
|
85
79
|
ALIASADD: typeof import("@redis/search/dist/commands/ALIASADD");
|
|
@@ -94,10 +88,6 @@ export declare class CacheClient {
|
|
|
94
88
|
configSet: typeof import("@redis/search/dist/commands/CONFIG_SET");
|
|
95
89
|
CREATE: typeof import("@redis/search/dist/commands/CREATE");
|
|
96
90
|
create: typeof import("@redis/search/dist/commands/CREATE");
|
|
97
|
-
CURSOR_DEL: typeof import("@redis/search/dist/commands/CURSOR_DEL");
|
|
98
|
-
cursorDel: typeof import("@redis/search/dist/commands/CURSOR_DEL");
|
|
99
|
-
CURSOR_READ: typeof import("@redis/search/dist/commands/CURSOR_READ");
|
|
100
|
-
cursorRead: typeof import("@redis/search/dist/commands/CURSOR_READ");
|
|
101
91
|
DICTADD: typeof import("@redis/search/dist/commands/DICTADD");
|
|
102
92
|
dictAdd: typeof import("@redis/search/dist/commands/DICTADD");
|
|
103
93
|
DICTDEL: typeof import("@redis/search/dist/commands/DICTDEL");
|
|
@@ -118,8 +108,6 @@ export declare class CacheClient {
|
|
|
118
108
|
profileAggregate: typeof import("@redis/search/dist/commands/PROFILE_AGGREGATE");
|
|
119
109
|
SEARCH: typeof import("@redis/search/dist/commands/SEARCH");
|
|
120
110
|
search: typeof import("@redis/search/dist/commands/SEARCH");
|
|
121
|
-
SEARCH_NOCONTENT: typeof import("@redis/search/dist/commands/SEARCH_NOCONTENT");
|
|
122
|
-
searchNoContent: typeof import("@redis/search/dist/commands/SEARCH_NOCONTENT");
|
|
123
111
|
SPELLCHECK: typeof import("@redis/search/dist/commands/SPELLCHECK");
|
|
124
112
|
spellCheck: typeof import("@redis/search/dist/commands/SPELLCHECK");
|
|
125
113
|
SUGADD: typeof import("@redis/search/dist/commands/SUGADD");
|
|
@@ -190,8 +178,6 @@ export declare class CacheClient {
|
|
|
190
178
|
bf: {
|
|
191
179
|
ADD: typeof import("@redis/bloom/dist/commands/bloom/ADD");
|
|
192
180
|
add: typeof import("@redis/bloom/dist/commands/bloom/ADD");
|
|
193
|
-
CARD: typeof import("@redis/bloom/dist/commands/bloom/CARD");
|
|
194
|
-
card: typeof import("@redis/bloom/dist/commands/bloom/CARD");
|
|
195
181
|
EXISTS: typeof import("@redis/bloom/dist/commands/bloom/EXISTS");
|
|
196
182
|
exists: typeof import("@redis/bloom/dist/commands/bloom/EXISTS");
|
|
197
183
|
INFO: typeof import("@redis/bloom/dist/commands/bloom/INFO");
|
|
@@ -247,36 +233,6 @@ export declare class CacheClient {
|
|
|
247
233
|
SCANDUMP: typeof import("@redis/bloom/dist/commands/cuckoo/SCANDUMP");
|
|
248
234
|
scanDump: typeof import("@redis/bloom/dist/commands/cuckoo/SCANDUMP");
|
|
249
235
|
};
|
|
250
|
-
tDigest: {
|
|
251
|
-
ADD: typeof import("@redis/bloom/dist/commands/t-digest/ADD");
|
|
252
|
-
add: typeof import("@redis/bloom/dist/commands/t-digest/ADD");
|
|
253
|
-
BYRANK: typeof import("@redis/bloom/dist/commands/t-digest/BYRANK");
|
|
254
|
-
byRank: typeof import("@redis/bloom/dist/commands/t-digest/BYRANK");
|
|
255
|
-
BYREVRANK: typeof import("@redis/bloom/dist/commands/t-digest/BYREVRANK");
|
|
256
|
-
byRevRank: typeof import("@redis/bloom/dist/commands/t-digest/BYREVRANK");
|
|
257
|
-
CDF: typeof import("@redis/bloom/dist/commands/t-digest/CDF");
|
|
258
|
-
cdf: typeof import("@redis/bloom/dist/commands/t-digest/CDF");
|
|
259
|
-
CREATE: typeof import("@redis/bloom/dist/commands/t-digest/CREATE");
|
|
260
|
-
create: typeof import("@redis/bloom/dist/commands/t-digest/CREATE");
|
|
261
|
-
INFO: typeof import("@redis/bloom/dist/commands/t-digest/INFO");
|
|
262
|
-
info: typeof import("@redis/bloom/dist/commands/t-digest/INFO");
|
|
263
|
-
MAX: typeof import("@redis/bloom/dist/commands/t-digest/MAX");
|
|
264
|
-
max: typeof import("@redis/bloom/dist/commands/t-digest/MAX");
|
|
265
|
-
MERGE: typeof import("@redis/bloom/dist/commands/t-digest/MERGE");
|
|
266
|
-
merge: typeof import("@redis/bloom/dist/commands/t-digest/MERGE");
|
|
267
|
-
MIN: typeof import("@redis/bloom/dist/commands/t-digest/MIN");
|
|
268
|
-
min: typeof import("@redis/bloom/dist/commands/t-digest/MIN");
|
|
269
|
-
QUANTILE: typeof import("@redis/bloom/dist/commands/t-digest/QUANTILE");
|
|
270
|
-
quantile: typeof import("@redis/bloom/dist/commands/t-digest/QUANTILE");
|
|
271
|
-
RANK: typeof import("@redis/bloom/dist/commands/t-digest/RANK");
|
|
272
|
-
rank: typeof import("@redis/bloom/dist/commands/t-digest/RANK");
|
|
273
|
-
RESET: typeof import("@redis/bloom/dist/commands/t-digest/RESET");
|
|
274
|
-
reset: typeof import("@redis/bloom/dist/commands/t-digest/RESET");
|
|
275
|
-
REVRANK: typeof import("@redis/bloom/dist/commands/t-digest/REVRANK");
|
|
276
|
-
revRank: typeof import("@redis/bloom/dist/commands/t-digest/REVRANK");
|
|
277
|
-
TRIMMED_MEAN: typeof import("@redis/bloom/dist/commands/t-digest/TRIMMED_MEAN");
|
|
278
|
-
trimmedMean: typeof import("@redis/bloom/dist/commands/t-digest/TRIMMED_MEAN");
|
|
279
|
-
};
|
|
280
236
|
topK: {
|
|
281
237
|
ADD: typeof import("@redis/bloom/dist/commands/top-k/ADD");
|
|
282
238
|
add: typeof import("@redis/bloom/dist/commands/top-k/ADD");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CacheClient = void 0;
|
|
4
|
+
exports.getCacheClient = getCacheClient;
|
|
4
5
|
const redis_1 = require("redis");
|
|
5
6
|
const factory = (options) => {
|
|
6
7
|
return (0, redis_1.createClient)(options);
|
|
@@ -29,4 +30,3 @@ function getCacheClient() {
|
|
|
29
30
|
const cacheClient = CacheClient.getInstance();
|
|
30
31
|
return cacheClient.redisClient;
|
|
31
32
|
}
|
|
32
|
-
exports.getCacheClient = getCacheClient;
|
package/logger/config/index.js
CHANGED
|
@@ -3,23 +3,26 @@ 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.formatBlacklistedBody =
|
|
6
|
+
exports.formatBlacklistedBody = formatBlacklistedBody;
|
|
7
7
|
const winston_1 = __importDefault(require("winston"));
|
|
8
8
|
const request_1 = require("../utils/request");
|
|
9
9
|
const route_1 = require("../utils/route");
|
|
10
10
|
const config_1 = require("../config");
|
|
11
11
|
function filterBlacklistedBodysByRoute(info) {
|
|
12
12
|
var _a, _b;
|
|
13
|
+
const meta = info.meta;
|
|
14
|
+
const request = meta === null || meta === void 0 ? void 0 : meta.req;
|
|
15
|
+
if (!request)
|
|
16
|
+
return info;
|
|
13
17
|
const blacklistedResponseRoutes = config_1.configs.responseBlacklistBodyRoutes || [];
|
|
14
18
|
const blacklistedRequestRoutes = config_1.configs.requestBlacklistBodyRoutes || [];
|
|
15
|
-
const request = info.meta.req;
|
|
16
19
|
const shouldResponseBeFiltered = (0, route_1.shouldRouteBeFiltered)(request, blacklistedResponseRoutes);
|
|
17
20
|
const shouldRequestBeFiltered = (0, route_1.shouldRouteBeFiltered)(request, blacklistedRequestRoutes);
|
|
18
21
|
if (shouldResponseBeFiltered) {
|
|
19
|
-
(_a =
|
|
22
|
+
(_a = meta === null || meta === void 0 ? void 0 : meta.res) === null || _a === void 0 ? true : delete _a.body;
|
|
20
23
|
}
|
|
21
24
|
if (shouldRequestBeFiltered) {
|
|
22
|
-
(_b =
|
|
25
|
+
(_b = meta === null || meta === void 0 ? void 0 : meta.req) === null || _b === void 0 ? true : delete _b.body;
|
|
23
26
|
}
|
|
24
27
|
return info;
|
|
25
28
|
}
|
|
@@ -33,4 +36,3 @@ function formatBlacklistedBody() {
|
|
|
33
36
|
return info;
|
|
34
37
|
})();
|
|
35
38
|
}
|
|
36
|
-
exports.formatBlacklistedBody = formatBlacklistedBody;
|
|
@@ -5,41 +5,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.errorFormatter = void 0;
|
|
7
7
|
const winston_1 = __importDefault(require("winston"));
|
|
8
|
+
function isObjectRecord(value) {
|
|
9
|
+
return typeof value === "object" && value !== null;
|
|
10
|
+
}
|
|
11
|
+
function isAxiosLikeError(value) {
|
|
12
|
+
return isObjectRecord(value) && value.isAxiosError === true;
|
|
13
|
+
}
|
|
14
|
+
function normalizeAxiosError(error) {
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
16
|
+
return {
|
|
17
|
+
message: error.message,
|
|
18
|
+
code: error.code,
|
|
19
|
+
status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
20
|
+
statusText: (_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText,
|
|
21
|
+
url: (_c = error.config) === null || _c === void 0 ? void 0 : _c.url,
|
|
22
|
+
method: (_d = error.config) === null || _d === void 0 ? void 0 : _d.method,
|
|
23
|
+
baseURL: (_e = error.config) === null || _e === void 0 ? void 0 : _e.baseURL,
|
|
24
|
+
timeout: (_f = error.config) === null || _f === void 0 ? void 0 : _f.timeout,
|
|
25
|
+
responseData: (_g = error.response) === null || _g === void 0 ? void 0 : _g.data,
|
|
26
|
+
requestId: (_j = (_h = error.config) === null || _h === void 0 ? void 0 : _h.headers) === null || _j === void 0 ? void 0 : _j["x-request-id"],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
8
29
|
exports.errorFormatter = winston_1.default.format((info) => {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
10
30
|
if (info.rejection) {
|
|
11
31
|
const error = info.error;
|
|
12
|
-
if (error
|
|
32
|
+
if (isAxiosLikeError(error)) {
|
|
13
33
|
delete info.rejection;
|
|
14
|
-
info.error =
|
|
15
|
-
message: error.message,
|
|
16
|
-
code: error.code,
|
|
17
|
-
status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
18
|
-
statusText: (_b = error.response) === null || _b === void 0 ? void 0 : _b.statusText,
|
|
19
|
-
url: (_c = error.config) === null || _c === void 0 ? void 0 : _c.url,
|
|
20
|
-
method: (_d = error.config) === null || _d === void 0 ? void 0 : _d.method,
|
|
21
|
-
baseURL: (_e = error.config) === null || _e === void 0 ? void 0 : _e.baseURL,
|
|
22
|
-
timeout: (_f = error.config) === null || _f === void 0 ? void 0 : _f.timeout,
|
|
23
|
-
responseData: (_g = error.response) === null || _g === void 0 ? void 0 : _g.data,
|
|
24
|
-
requestId: (_j = (_h = error.config) === null || _h === void 0 ? void 0 : _h.headers) === null || _j === void 0 ? void 0 : _j["x-request-id"],
|
|
25
|
-
};
|
|
34
|
+
info.error = normalizeAxiosError(error);
|
|
26
35
|
}
|
|
27
36
|
return info;
|
|
28
37
|
}
|
|
29
|
-
const error = info.err || info.exception || info.error;
|
|
30
|
-
if (error
|
|
31
|
-
info.err =
|
|
32
|
-
message: error.message,
|
|
33
|
-
code: error.code,
|
|
34
|
-
status: (_k = error.response) === null || _k === void 0 ? void 0 : _k.status,
|
|
35
|
-
statusText: (_l = error.response) === null || _l === void 0 ? void 0 : _l.statusText,
|
|
36
|
-
url: (_m = error.config) === null || _m === void 0 ? void 0 : _m.url,
|
|
37
|
-
method: (_o = error.config) === null || _o === void 0 ? void 0 : _o.method,
|
|
38
|
-
baseURL: (_p = error.config) === null || _p === void 0 ? void 0 : _p.baseURL,
|
|
39
|
-
timeout: (_q = error.config) === null || _q === void 0 ? void 0 : _q.timeout,
|
|
40
|
-
responseData: (_r = error.response) === null || _r === void 0 ? void 0 : _r.data,
|
|
41
|
-
requestId: (_t = (_s = error.config) === null || _s === void 0 ? void 0 : _s.headers) === null || _t === void 0 ? void 0 : _t["x-request-id"],
|
|
42
|
-
};
|
|
38
|
+
const error = (info.err || info.exception || info.error);
|
|
39
|
+
if (isAxiosLikeError(error)) {
|
|
40
|
+
info.err = normalizeAxiosError(error);
|
|
43
41
|
}
|
|
44
42
|
return info;
|
|
45
43
|
})();
|
package/logger/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="express" />
|
|
2
|
-
/// <reference types="qs" />
|
|
3
1
|
import winston from "winston";
|
|
4
2
|
export declare const loggerMiddleware: import("express").Handler;
|
|
5
3
|
export declare const logError: import("express").ErrorRequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
@@ -3,7 +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
|
-
exports.
|
|
6
|
+
exports.getMiddlewareTransports = getMiddlewareTransports;
|
|
7
|
+
exports.getLoggerTransports = getLoggerTransports;
|
|
7
8
|
const winston_1 = __importDefault(require("winston"));
|
|
8
9
|
const config_1 = require("../config");
|
|
9
10
|
function getMiddlewareTransports() {
|
|
@@ -24,7 +25,6 @@ function getMiddlewareTransports() {
|
|
|
24
25
|
}
|
|
25
26
|
return transports;
|
|
26
27
|
}
|
|
27
|
-
exports.getMiddlewareTransports = getMiddlewareTransports;
|
|
28
28
|
function getLoggerTransports() {
|
|
29
29
|
const transports = [];
|
|
30
30
|
if (config_1.configs.console) {
|
|
@@ -43,4 +43,3 @@ function getLoggerTransports() {
|
|
|
43
43
|
}
|
|
44
44
|
return transports;
|
|
45
45
|
}
|
|
46
|
-
exports.getLoggerTransports = getLoggerTransports;
|
package/logger/utils/request.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.filterRequestHeaders = filterRequestHeaders;
|
|
4
|
+
exports.isRequestInfo = isRequestInfo;
|
|
4
5
|
function filterRequestHeaders(confidentialHeaders = []) {
|
|
5
6
|
return (req, propName) => {
|
|
6
7
|
if (propName !== "headers")
|
|
@@ -14,9 +15,7 @@ function filterRequestHeaders(confidentialHeaders = []) {
|
|
|
14
15
|
return filteredHeaders;
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
exports.filterRequestHeaders = filterRequestHeaders;
|
|
18
18
|
function isRequestInfo(info) {
|
|
19
19
|
const metadata = info.meta;
|
|
20
20
|
return (metadata === null || metadata === void 0 ? void 0 : metadata.req) && (metadata === null || metadata === void 0 ? void 0 : metadata.res) ? true : false;
|
|
21
21
|
}
|
|
22
|
-
exports.isRequestInfo = isRequestInfo;
|
package/logger/utils/route.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateRouteRegex = generateRouteRegex;
|
|
4
|
+
exports.shouldFilterRoute = shouldFilterRoute;
|
|
5
|
+
exports.shouldRouteBeFiltered = shouldRouteBeFiltered;
|
|
4
6
|
function generateRouteRegex(route) {
|
|
5
7
|
const splitedRoute = route.split("/").filter((i) => i !== "");
|
|
6
8
|
const regexString = splitedRoute
|
|
@@ -10,7 +12,6 @@ function generateRouteRegex(route) {
|
|
|
10
12
|
.join("/");
|
|
11
13
|
return new RegExp("^/" + regexString + "$", "g");
|
|
12
14
|
}
|
|
13
|
-
exports.generateRouteRegex = generateRouteRegex;
|
|
14
15
|
function shouldFilterRoute(url, routesToBeFiltered) {
|
|
15
16
|
return routesToBeFiltered.some((route) => {
|
|
16
17
|
const regExp = generateRouteRegex(route);
|
|
@@ -18,7 +19,6 @@ function shouldFilterRoute(url, routesToBeFiltered) {
|
|
|
18
19
|
return !!(matches === null || matches === void 0 ? void 0 : matches.length);
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
|
-
exports.shouldFilterRoute = shouldFilterRoute;
|
|
22
22
|
function shouldRouteBeFiltered(request, blacklistedRoutes) {
|
|
23
23
|
return blacklistedRoutes.some(({ route, method }) => {
|
|
24
24
|
const regExp = generateRouteRegex(route);
|
|
@@ -26,4 +26,3 @@ function shouldRouteBeFiltered(request, blacklistedRoutes) {
|
|
|
26
26
|
return ((matches === null || matches === void 0 ? void 0 : matches.length) && request.method.toLowerCase() === method.toLowerCase());
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
exports.shouldRouteBeFiltered = shouldRouteBeFiltered;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sm-utility",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.28-beta-1",
|
|
4
4
|
"description": "reusable utility codes for sm projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"prebuild": "npm run clean",
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"postbuild": "npm run copy-files",
|
|
13
|
-
"copy-files": "
|
|
13
|
+
"copy-files": "cp package.json README.md ./dist",
|
|
14
14
|
"publish-package": "npm run build && cd ./dist && npm publish"
|
|
15
15
|
},
|
|
16
16
|
"author": "Caio Poyares",
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"*/**"
|
|
20
20
|
],
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@types/express": "
|
|
23
|
-
"@types/node": "
|
|
22
|
+
"@types/express": "4.17.11",
|
|
23
|
+
"@types/node": "14.14.40",
|
|
24
24
|
"@types/request-ip": "0.0.41",
|
|
25
|
-
"@types/uuid": "
|
|
26
|
-
"
|
|
27
|
-
"typescript": "^4.2.4"
|
|
25
|
+
"@types/uuid": "8.3.1",
|
|
26
|
+
"typescript": "5.6.3"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
30
|
-
"@aws-sdk/client-secrets-manager": "3.
|
|
31
|
-
"@
|
|
29
|
+
"@aws-sdk/client-secrets-manager": "3.993.0",
|
|
30
|
+
"@aws-sdk/client-sqs": "3.993.0",
|
|
31
|
+
"@elastic/ecs-winston-format": "1.5.3",
|
|
32
32
|
"@opentelemetry/auto-instrumentations-node": "0.55.3",
|
|
33
33
|
"@opentelemetry/exporter-trace-otlp-http": "0.57.1",
|
|
34
34
|
"@opentelemetry/id-generator-aws-xray": "1.2.2",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"@opentelemetry/resources": "1.30.1",
|
|
38
38
|
"@opentelemetry/sdk-node": "0.57.1",
|
|
39
39
|
"@opentelemetry/sdk-trace-base": "1.30.1",
|
|
40
|
-
"axios": "1.
|
|
41
|
-
"express-winston": "
|
|
42
|
-
"nanoid": "
|
|
43
|
-
"node-xlsx": "
|
|
44
|
-
"redis": "
|
|
40
|
+
"axios": "1.13.5",
|
|
41
|
+
"express-winston": "4.1.0",
|
|
42
|
+
"nanoid": "3.3.11",
|
|
43
|
+
"node-xlsx": "0.24.0",
|
|
44
|
+
"redis": "4.1.0",
|
|
45
45
|
"request-ip": "3.3.0",
|
|
46
|
-
"ts-node": "
|
|
47
|
-
"uuid": "
|
|
48
|
-
"winston": "
|
|
46
|
+
"ts-node": "10.9.1",
|
|
47
|
+
"uuid": "8.3.2",
|
|
48
|
+
"winston": "3.3.3"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -3,7 +3,7 @@ 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.createApi =
|
|
6
|
+
exports.createApi = createApi;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const request_interceptor_1 = require("./interceptors/request.interceptor");
|
|
9
9
|
const response_interceptor_1 = require("./interceptors/response.interceptor");
|
|
@@ -14,4 +14,3 @@ function createApi(axiosConfig) {
|
|
|
14
14
|
axiosApi.interceptors.response.use((0, response_interceptor_1.createResponseInterceptor)(), (0, error_interceptor_1.createErrorInterceptor)());
|
|
15
15
|
return axiosApi;
|
|
16
16
|
}
|
|
17
|
-
exports.createApi = createApi;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createErrorInterceptor =
|
|
3
|
+
exports.createErrorInterceptor = createErrorInterceptor;
|
|
4
4
|
const loggers_1 = require("../loggers");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
function createErrorInterceptor() {
|
|
@@ -12,4 +12,3 @@ function createErrorInterceptor() {
|
|
|
12
12
|
throw error;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
exports.createErrorInterceptor = createErrorInterceptor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRequestInterceptor =
|
|
3
|
+
exports.createRequestInterceptor = createRequestInterceptor;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const loggers_1 = require("../loggers");
|
|
@@ -17,4 +17,3 @@ function createRequestInterceptor() {
|
|
|
17
17
|
return request;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
exports.createRequestInterceptor = createRequestInterceptor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AxiosResponse } from "axios";
|
|
2
|
-
export declare function createResponseInterceptor(): (response: AxiosResponse) => AxiosResponse<any, any>;
|
|
2
|
+
export declare function createResponseInterceptor(): (response: AxiosResponse) => AxiosResponse<any, any, {}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createResponseInterceptor =
|
|
3
|
+
exports.createResponseInterceptor = createResponseInterceptor;
|
|
4
4
|
const loggers_1 = require("../loggers");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
function createResponseInterceptor() {
|
|
@@ -16,4 +16,3 @@ function createResponseInterceptor() {
|
|
|
16
16
|
return response;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
exports.createResponseInterceptor = createResponseInterceptor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logError =
|
|
3
|
+
exports.logError = logError;
|
|
4
4
|
const logger_1 = require("../../logger");
|
|
5
5
|
const tracing_1 = require("../../tracing");
|
|
6
6
|
function logError(id, method, url, data, status, message) {
|
|
@@ -22,4 +22,3 @@ function logError(id, method, url, data, status, message) {
|
|
|
22
22
|
}
|
|
23
23
|
logger_1.logger.error("sm-utility/api-error", { err });
|
|
24
24
|
}
|
|
25
|
-
exports.logError = logError;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logRequest =
|
|
3
|
+
exports.logRequest = logRequest;
|
|
4
4
|
const logger_1 = require("../../logger");
|
|
5
5
|
const tracing_1 = require("../../tracing");
|
|
6
6
|
function logRequest(id, method, url, body, params) {
|
|
@@ -21,4 +21,3 @@ function logRequest(id, method, url, body, params) {
|
|
|
21
21
|
}
|
|
22
22
|
logger_1.logger.info("sm-utility/api-request", { request });
|
|
23
23
|
}
|
|
24
|
-
exports.logRequest = logRequest;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logResponse =
|
|
3
|
+
exports.logResponse = logResponse;
|
|
4
4
|
const logger_1 = require("../../logger");
|
|
5
5
|
const tracing_1 = require("../../tracing");
|
|
6
6
|
function logResponse(id, method, url, body, status, responseTime) {
|
|
@@ -22,4 +22,3 @@ function logResponse(id, method, url, body, status, responseTime) {
|
|
|
22
22
|
}
|
|
23
23
|
logger_1.logger.info("sm-utility/api-response", { response });
|
|
24
24
|
}
|
|
25
|
-
exports.logResponse = logResponse;
|
package/request/utils.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getFullUrlFromConfig = getFullUrlFromConfig;
|
|
4
|
+
exports.getResponseTimeFromConfig = getResponseTimeFromConfig;
|
|
4
5
|
function getFullUrlFromConfig(config) {
|
|
5
6
|
const { baseURL, url } = config || {};
|
|
6
7
|
const fullUrl = baseURL && url ? new String().concat(baseURL, url) : "";
|
|
7
8
|
return fullUrl;
|
|
8
9
|
}
|
|
9
|
-
exports.getFullUrlFromConfig = getFullUrlFromConfig;
|
|
10
10
|
function getResponseTimeFromConfig(config) {
|
|
11
11
|
var _a;
|
|
12
12
|
const requestStart = (_a = config === null || config === void 0 ? void 0 : config.meta) === null || _a === void 0 ? void 0 : _a.requestStartedAt;
|
|
@@ -16,4 +16,3 @@ function getResponseTimeFromConfig(config) {
|
|
|
16
16
|
}
|
|
17
17
|
return responseTime + " ms";
|
|
18
18
|
}
|
|
19
|
-
exports.getResponseTimeFromConfig = getResponseTimeFromConfig;
|
package/stubs/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mockResolvedClass = mockResolvedClass;
|
|
4
|
+
exports.mockClass = mockClass;
|
|
5
|
+
exports.rawInstance = rawInstance;
|
|
4
6
|
class MockedClassInstance {
|
|
5
7
|
}
|
|
6
8
|
;
|
|
@@ -27,7 +29,6 @@ function mockResolvedClass(Class, givenMethods) {
|
|
|
27
29
|
}
|
|
28
30
|
return MockedClass;
|
|
29
31
|
}
|
|
30
|
-
exports.mockResolvedClass = mockResolvedClass;
|
|
31
32
|
/**
|
|
32
33
|
* Creates a mock instance of a given class with customized method implementations.
|
|
33
34
|
* @example
|
|
@@ -50,7 +51,6 @@ function mockClass(Class, givenMethods) {
|
|
|
50
51
|
}
|
|
51
52
|
return MockedClass;
|
|
52
53
|
}
|
|
53
|
-
exports.mockClass = mockClass;
|
|
54
54
|
/**
|
|
55
55
|
* Creates a raw mock instance of a given class with no method implementations.
|
|
56
56
|
* This function is intended for use with testing frameworks like jest (spyOn) when
|
|
@@ -75,4 +75,3 @@ function rawInstance(Class) {
|
|
|
75
75
|
}
|
|
76
76
|
return MockedClass;
|
|
77
77
|
}
|
|
78
|
-
exports.rawInstance = rawInstance;
|
package/thread/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.workerfy =
|
|
3
|
+
exports.workerfy = workerfy;
|
|
4
4
|
const worker_threads_1 = require("worker_threads");
|
|
5
5
|
function workerfy(workerData) {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
@@ -20,4 +20,3 @@ function workerfy(workerData) {
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
exports.workerfy = workerfy;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SendMessageCommandInput, Message } from '@aws-sdk/client-sqs';
|
|
2
|
+
export declare class SQSOtelContextHandler {
|
|
3
|
+
static injectContext(params: SendMessageCommandInput): SendMessageCommandInput;
|
|
4
|
+
static extractContext(message: Message): import("@opentelemetry/api").Context;
|
|
5
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SQSOtelContextHandler = void 0;
|
|
4
|
+
const api_1 = require("@opentelemetry/api");
|
|
5
|
+
class SQSOtelContextHandler {
|
|
6
|
+
static injectContext(params) {
|
|
7
|
+
var _a;
|
|
8
|
+
const carrier = {};
|
|
9
|
+
// Inject current active trace context into carrier
|
|
10
|
+
api_1.propagation.inject(api_1.context.active(), carrier, {
|
|
11
|
+
set: (c, k, v) => {
|
|
12
|
+
c[k] = String(v);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
// Convert carrier to SQS MessageAttributes
|
|
16
|
+
const otelAttributes = {};
|
|
17
|
+
for (const [key, value] of Object.entries(carrier)) {
|
|
18
|
+
otelAttributes[key] = {
|
|
19
|
+
DataType: 'String',
|
|
20
|
+
StringValue: value,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
...params,
|
|
25
|
+
MessageAttributes: {
|
|
26
|
+
...((_a = params.MessageAttributes) !== null && _a !== void 0 ? _a : {}),
|
|
27
|
+
...otelAttributes,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
static extractContext(message) {
|
|
32
|
+
var _a;
|
|
33
|
+
const attrs = (_a = message.MessageAttributes) !== null && _a !== void 0 ? _a : {};
|
|
34
|
+
const carrier = {};
|
|
35
|
+
for (const [key, val] of Object.entries(attrs)) {
|
|
36
|
+
if (val === null || val === void 0 ? void 0 : val.StringValue)
|
|
37
|
+
carrier[key] = val.StringValue;
|
|
38
|
+
}
|
|
39
|
+
return api_1.propagation.extract(api_1.context.active(), carrier, {
|
|
40
|
+
get: (c, k) => c[k],
|
|
41
|
+
keys: (c) => Object.keys(c),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.SQSOtelContextHandler = SQSOtelContextHandler;
|