@sima-land/isomorph 9.0.3 → 9.0.7
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/cache/local-storage.d.ts +30 -10
- package/cache/local-storage.js +28 -19
- package/cache/local-storage.js.map +1 -1
- package/cache/redis.d.ts +1 -1
- package/config/helpers.d.ts +1 -1
- package/container/get-dependencies.d.ts +1 -1
- package/create-proxy/create-proxy-middleware/index.d.ts +1 -1
- package/graceful-shutdown/index.d.ts +10 -10
- package/helpers/add-error-handling/index.d.ts +1 -1
- package/helpers/analytics/index.js.map +1 -1
- package/helpers/api/middlewares/error-handlers-middlewares.js +12 -23
- package/helpers/api/middlewares/error-handlers-middlewares.js.map +1 -1
- package/helpers/api/middlewares/helpers.d.ts +1 -1
- package/helpers/api/middlewares/trace-request-middleware.d.ts +21 -9
- package/helpers/api/middlewares/trace-request-middleware.js +50 -33
- package/helpers/api/middlewares/trace-request-middleware.js.map +1 -1
- package/helpers/api/server-adapter/helpers.d.ts +1 -1
- package/helpers/get-params/index.d.ts +1 -1
- package/helpers/react/error-handlers/index.d.ts +1 -1
- package/helpers/redux/remote-data.d.ts +4 -4
- package/helpers/redux/selector/statuses.d.ts +1 -1
- package/helpers/saga/create-store.d.ts +2 -2
- package/helpers/saga/do-safe-request.d.ts +2 -2
- package/helpers/tracer/create-child-tracing-middleware.d.ts +1 -1
- package/helpers/tracer/index.d.ts +4 -4
- package/logger/create-sentry-instance/index.d.ts +2 -2
- package/logger/initialize-sentry-creator/index.d.ts +2 -2
- package/logger/sentry-logger/index.d.ts +2 -2
- package/module-federation/__example__/webpack-config.example.d.ts +14 -14
- package/module-federation/__example__/webpack-config.example.js +1 -0
- package/module-federation/__example__/webpack-config.example.js.map +1 -1
- package/module-federation/enhanced-module-federation-plugin.js +1 -0
- package/module-federation/enhanced-module-federation-plugin.js.map +1 -1
- package/module-federation/utils/index.js +1 -0
- package/module-federation/utils/index.js.map +1 -1
- package/package.json +23 -23
- package/set-header-middleware/create.d.ts +1 -1
- package/src/cache/{local-storage.js → local-storage.ts} +33 -21
- package/src/helpers/analytics/index.ts +1 -1
- package/src/helpers/api/middlewares/error-handlers-middlewares.js +19 -25
- package/src/helpers/api/middlewares/trace-request-middleware.ts +86 -0
- package/src/helpers/api/middlewares/trace-request-middleware.js +0 -43
package/cache/local-storage.d.ts
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
1
|
+
/**
|
|
2
|
+
* Определяет доступен ли кэш.
|
|
3
|
+
* @return Флаг доступности кэш.
|
|
4
|
+
*/
|
|
5
|
+
export declare const isAvailable: () => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Возвращает объект.
|
|
8
|
+
* @param key Ключ.
|
|
9
|
+
* @return Запрашиваемое значение.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getItem: (key: string) => unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Добавляет значение.
|
|
14
|
+
* @param key Ключ.
|
|
15
|
+
* @param value Значение.
|
|
16
|
+
* @param duration Время жизни значения в секундах.
|
|
17
|
+
*/
|
|
18
|
+
export declare const setItem: (key: string, value: any, duration?: number) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Определяет, превышена ли квота.
|
|
21
|
+
* @param error Информация об ошибке.
|
|
22
|
+
* @return Признак превышения квоты.
|
|
23
|
+
*/
|
|
24
|
+
export declare const isQuotaExceeded: (error: any) => boolean;
|
|
6
25
|
/**
|
|
7
26
|
* Набор методов для работы с кэшем.
|
|
8
|
-
* @type {{set: Function, get: Function, status: boolean}}
|
|
9
27
|
*/
|
|
10
|
-
declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
status: boolean;
|
|
28
|
+
declare const LocalStorageCache: {
|
|
29
|
+
readonly get: (key: string) => unknown;
|
|
30
|
+
readonly set: (key: string, value: any, duration?: number) => void;
|
|
31
|
+
readonly status: boolean;
|
|
32
|
+
readonly quotaExceeded: (error: any) => boolean;
|
|
14
33
|
};
|
|
34
|
+
export default LocalStorageCache;
|
package/cache/local-storage.js
CHANGED
|
@@ -3,17 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isQuotaExceeded = exports.setItem = exports.getItem = exports.isAvailable = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Определяет доступен ли кэш.
|
|
6
|
-
* @return
|
|
6
|
+
* @return Флаг доступности кэш.
|
|
7
7
|
*/
|
|
8
|
-
const isAvailable = () =>
|
|
8
|
+
const isAvailable = () => {
|
|
9
|
+
try {
|
|
10
|
+
const testKey = `local_storage_test_key::${Date.now()}`;
|
|
11
|
+
window.localStorage.setItem(testKey, testKey);
|
|
12
|
+
window.localStorage.removeItem(testKey);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
catch (_a) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
9
19
|
exports.isAvailable = isAvailable;
|
|
10
20
|
/**
|
|
11
|
-
* Возвращает
|
|
12
|
-
* @param
|
|
13
|
-
* @return
|
|
21
|
+
* Возвращает объект.
|
|
22
|
+
* @param key Ключ.
|
|
23
|
+
* @return Запрашиваемое значение.
|
|
14
24
|
*/
|
|
15
|
-
const getItem = key => {
|
|
16
|
-
const { value, expire } = JSON.parse(localStorage.getItem(key)
|
|
25
|
+
const getItem = (key) => {
|
|
26
|
+
const { value, expire } = JSON.parse(localStorage.getItem(key) || '{}');
|
|
17
27
|
const now = Date.now();
|
|
18
28
|
const isExpired = expire
|
|
19
29
|
? now > expire
|
|
@@ -23,10 +33,10 @@ const getItem = key => {
|
|
|
23
33
|
};
|
|
24
34
|
exports.getItem = getItem;
|
|
25
35
|
/**
|
|
26
|
-
* Добавляет
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
36
|
+
* Добавляет значение.
|
|
37
|
+
* @param key Ключ.
|
|
38
|
+
* @param value Значение.
|
|
39
|
+
* @param duration Время жизни значения в секундах.
|
|
30
40
|
*/
|
|
31
41
|
const setItem = (key, value, duration = 3600) => {
|
|
32
42
|
const now = Date.now();
|
|
@@ -39,11 +49,11 @@ const setItem = (key, value, duration = 3600) => {
|
|
|
39
49
|
};
|
|
40
50
|
exports.setItem = setItem;
|
|
41
51
|
/**
|
|
42
|
-
* Определяет,
|
|
43
|
-
* @param
|
|
44
|
-
* @return
|
|
52
|
+
* Определяет, превышена ли квота.
|
|
53
|
+
* @param error Информация об ошибке.
|
|
54
|
+
* @return Признак превышения квоты.
|
|
45
55
|
*/
|
|
46
|
-
const isQuotaExceeded = error => {
|
|
56
|
+
const isQuotaExceeded = (error) => {
|
|
47
57
|
let quotaExceeded = false;
|
|
48
58
|
if (error) {
|
|
49
59
|
if (error.code) {
|
|
@@ -60,7 +70,7 @@ const isQuotaExceeded = error => {
|
|
|
60
70
|
}
|
|
61
71
|
}
|
|
62
72
|
else if (error.number === -2147024882) {
|
|
63
|
-
//
|
|
73
|
+
// IE 8
|
|
64
74
|
quotaExceeded = true;
|
|
65
75
|
}
|
|
66
76
|
}
|
|
@@ -69,13 +79,12 @@ const isQuotaExceeded = error => {
|
|
|
69
79
|
exports.isQuotaExceeded = isQuotaExceeded;
|
|
70
80
|
/**
|
|
71
81
|
* Набор методов для работы с кэшем.
|
|
72
|
-
* @type {{set: Function, get: Function, status: boolean}}
|
|
73
82
|
*/
|
|
74
|
-
const
|
|
83
|
+
const LocalStorageCache = {
|
|
75
84
|
get: exports.getItem,
|
|
76
85
|
set: exports.setItem,
|
|
77
86
|
status: exports.isAvailable(),
|
|
78
87
|
quotaExceeded: exports.isQuotaExceeded,
|
|
79
88
|
};
|
|
80
|
-
exports.default =
|
|
89
|
+
exports.default = LocalStorageCache;
|
|
81
90
|
//# sourceMappingURL=local-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage.js","sourceRoot":"","sources":["../../src/cache/local-storage.
|
|
1
|
+
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AC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC;QACvC,KAAK;QACL,MAAM;KACP,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AATW,QAAA,OAAO,WASlB;AAEF;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAAC,KAAU,EAAW,EAAE;IACrD,IAAI,aAAa,GAAG,KAAK,CAAC;IAE1B,IAAI,KAAK,EAAE;QACT,IAAI,KAAK,CAAC,IAAI,EAAE;YACd,QAAQ,KAAK,CAAC,IAAI,EAAE;gBAClB,KAAK,EAAE;oBACL,aAAa,GAAG,IAAI,CAAC;oBACrB,MAAM;gBACR,KAAK,IAAI;oBACP,UAAU;oBACV,IAAI,KAAK,CAAC,IAAI,KAAK,4BAA4B,EAAE;wBAC/C,aAAa,GAAG,IAAI,CAAC;qBACtB;oBACD,MAAM;aACT;SACF;aAAM,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,UAAU,EAAE;YACvC,OAAO;YACP,aAAa,GAAG,IAAI,CAAC;SACtB;KACF;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAvBW,QAAA,eAAe,mBAuB1B;AAEF;;GAEG;AACH,MAAM,iBAAiB,GAAG;IACxB,GAAG,EAAE,eAAO;IACZ,GAAG,EAAE,eAAO;IACZ,MAAM,EAAE,mBAAW,EAAE;IACrB,aAAa,EAAE,uBAAe;CACtB,CAAC;AAEX,kBAAe,iBAAiB,CAAC"}
|
package/cache/redis.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function createRedisCache(config: Object, reconnectAfterError?: Function, getRepeatStrategy?: Function, getOnJoinCallback?: Function, getAfterReconnectingCallback?: Function): Object;
|
|
1
|
+
export function createRedisCache(config: Object, reconnectAfterError?: Function | undefined, getRepeatStrategy?: Function | undefined, getOnJoinCallback?: Function | undefined, getAfterReconnectingCallback?: Function | undefined): Object;
|
|
2
2
|
export function mapServiceOptionsToArgs({ config, reconnectAfterError, getRepeatStrategy, getOnJoinCallback, getAfterReconnectingCallback, }: {
|
|
3
3
|
config: Object;
|
|
4
4
|
reconnectAfterError: Function;
|
package/config/helpers.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export default getDependencies;
|
|
|
10
10
|
* @param {string} serviceName Названия сервиса.
|
|
11
11
|
* @return {Object} Объект зависимостей.
|
|
12
12
|
*/
|
|
13
|
-
declare function getDependencies(container: Object, dependencies: Object, serviceName: string): Object;
|
|
13
|
+
declare function getDependencies(container: Object, dependencies: Object | undefined, serviceName: string): Object;
|
|
@@ -13,4 +13,4 @@ export function getRequestPathResolver(path: string): Function;
|
|
|
13
13
|
* @param {string} url Url.
|
|
14
14
|
* @return {string} Path или пустую строку.
|
|
15
15
|
*/
|
|
16
|
-
export const getUrlPath: (urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean) => string;
|
|
16
|
+
export const getUrlPath: (urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean | undefined) => string | null;
|
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export const defaultExitTimeout: number;
|
|
6
6
|
export function decorateGracefulShutdown(server: import('http').Server, options?: {
|
|
7
|
-
onSuccess?: Function;
|
|
8
|
-
onError?: Function;
|
|
9
|
-
timeout?: number;
|
|
10
|
-
}): void;
|
|
7
|
+
onSuccess?: Function | undefined;
|
|
8
|
+
onError?: Function | undefined;
|
|
9
|
+
timeout?: number | undefined;
|
|
10
|
+
} | undefined): void;
|
|
11
11
|
export function createShutdownHandler(server: import('http').Server, { onError, onSuccess, timeout, }?: {
|
|
12
|
-
onSuccess?: Function;
|
|
13
|
-
onError?: Function;
|
|
14
|
-
timeout?: number;
|
|
15
|
-
}): Function;
|
|
16
|
-
export function createCloseHandler(exitCode?: number, onClose?: Function): Function;
|
|
12
|
+
onSuccess?: Function | undefined;
|
|
13
|
+
onError?: Function | undefined;
|
|
14
|
+
timeout?: number | undefined;
|
|
15
|
+
} | undefined): Function;
|
|
16
|
+
export function createCloseHandler(exitCode?: number | undefined, onClose?: Function | undefined): Function;
|
|
17
17
|
export function onExitHandlerCreator({ logger, config, message }: {
|
|
18
18
|
logger: Object;
|
|
19
|
-
config?: Object;
|
|
19
|
+
config?: Object | undefined;
|
|
20
20
|
message: string;
|
|
21
21
|
}): Function;
|
|
22
22
|
export function gracefulShutdownCreator({ onExitError: onError, onExitSuccess: onSuccess, processExitTimeout: timeout, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function addErrorHandling(handler: Function, errorHandler?: Function): Function;
|
|
1
|
+
export function addErrorHandling(handler: Function, errorHandler?: Function | undefined): Function;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/analytics/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+B;AAC/B,gDAA0C;AAC1C,mCAA6C;AAI7C;;;GAGG;AACI,MAAM,OAAO,GAAG,CAAC,SAAmB,EAAE,EAAE;;IAC7C,qFAAqF;IACrF,mBAAU,CAAC,MAAC,MAAc,CAAC,GAAG,0CAAE,IAAI,CAAC,IAAK,MAAc,CAAC,GAAG,CAAC,IAAI,mBAAM,SAAS,EAAG,CAAC;AACtF,CAAC,CAAC;AAHW,QAAA,OAAO,WAGlB;AAEF;;;GAGG;AACH,QAAgB,CAAC,CAAC,aAAa,CAAE,IAAc;IAC7C,MAAM,cAAI,CAAC,eAAO,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC;AAFD,sCAEC;AAED;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,IAAc,EAAE,EAAE;IAC7C,MAAM,OAAO,GAAG,cAAM,EAAY,CAAC;IACnC,MAAM,KAAK,GAAG,cAAM,EAAc,CAAC;IAEnC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QACpB,OAAO,CAAC,OAAO,qBAAQ,IAAI,CAAE,CAAC;KAC/B;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;QAClB,KAAK,CAAC,OAAO,GAAG,G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Default = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.createHandleExceptionMiddleware = exports.createAttachBreadcrumbsMiddleware = exports._deptToArg = exports._getLevelFromConfig = exports._sendHttpBreadcrumb = void 0;
|
|
16
16
|
const container_1 = require("../../../container");
|
|
17
|
-
const isFunction_1 = __importDefault(require("lodash/isFunction"));
|
|
18
|
-
const pathOr_1 = __importDefault(require("lodash/fp/pathOr"));
|
|
19
17
|
const pick_1 = __importDefault(require("lodash/pick"));
|
|
20
|
-
const getStatusCode = pathOr_1.default('UNKNOWN', 'status');
|
|
21
|
-
const getConfig = pathOr_1.default({}, 'config');
|
|
22
18
|
/**
|
|
23
19
|
* Отправляет крошки http запроса.
|
|
24
20
|
* @param {Function} sendBreadcrumb Функция отправки крошек.
|
|
25
|
-
* @param {Object} response Объект в формате ответа Axios, содержащий данные
|
|
21
|
+
* @param {Object} response Объект в формате ответа Axios, содержащий данные об ответе.
|
|
26
22
|
* @param {boolean} asRequest Обработать как событие запроса.
|
|
27
23
|
* @private
|
|
28
24
|
*/
|
|
29
25
|
const _sendHttpBreadcrumb = (sendBreadcrumb, response, asRequest = false) => {
|
|
30
|
-
const statusCode = asRequest ? 'FETCHING' :
|
|
31
|
-
const { url, baseURL, method, params } =
|
|
32
|
-
const fullURL = baseURL ? baseURL.replace(/\/$/, '')
|
|
26
|
+
const statusCode = asRequest ? 'FETCHING' : (response === null || response === void 0 ? void 0 : response.status) || 'UNKNOWN';
|
|
27
|
+
const { url, baseURL, method, params } = (response === null || response === void 0 ? void 0 : response.config) || {};
|
|
28
|
+
const fullURL = baseURL ? `${baseURL.replace(/\/$/, '')}${url}` : url;
|
|
33
29
|
const breadcrumb = {
|
|
34
30
|
category: asRequest ? 'http.request' : 'http.response',
|
|
35
31
|
type: 'http',
|
|
@@ -41,7 +37,7 @@ const _sendHttpBreadcrumb = (sendBreadcrumb, response, asRequest = false) => {
|
|
|
41
37
|
},
|
|
42
38
|
level: asRequest || (statusCode >= 200 && statusCode < 300) ? 'info' : 'error',
|
|
43
39
|
};
|
|
44
|
-
|
|
40
|
+
sendBreadcrumb && sendBreadcrumb(breadcrumb);
|
|
45
41
|
};
|
|
46
42
|
exports._sendHttpBreadcrumb = _sendHttpBreadcrumb;
|
|
47
43
|
/**
|
|
@@ -58,10 +54,10 @@ const _createAttachBreadcrumbsMiddleware = ({ captureBreadcrumb }) =>
|
|
|
58
54
|
* @param {Function} next Функция для передачи контекста выполнения следующему middleware.
|
|
59
55
|
* @return {Promise} Промис.
|
|
60
56
|
*/
|
|
61
|
-
(
|
|
57
|
+
(config, next, defaults) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
58
|
try {
|
|
63
|
-
exports._sendHttpBreadcrumb(captureBreadcrumb, { config:
|
|
64
|
-
const apiResponse = yield next(
|
|
59
|
+
exports._sendHttpBreadcrumb(captureBreadcrumb, { config: Object.assign(Object.assign({}, defaults), config) }, true);
|
|
60
|
+
const apiResponse = yield next(config);
|
|
65
61
|
exports._sendHttpBreadcrumb(captureBreadcrumb, apiResponse);
|
|
66
62
|
}
|
|
67
63
|
catch (error) {
|
|
@@ -76,21 +72,14 @@ const _createAttachBreadcrumbsMiddleware = ({ captureBreadcrumb }) =>
|
|
|
76
72
|
* @return {function(Object, Function)} Middleware для захвата исключения.
|
|
77
73
|
* @private
|
|
78
74
|
*/
|
|
79
|
-
const _createHandleExceptionMiddleware = ({ captureExtendedException }) =>
|
|
80
|
-
/**
|
|
81
|
-
* Middleware для отправки исключения в сервис логирования.
|
|
82
|
-
* @param {Object} requestConfig Конфигурация запроса API.
|
|
83
|
-
* @param {Function} next Функция для передачи контекста выполнения следующему middleware.
|
|
84
|
-
* @return {Promise} Промис.
|
|
85
|
-
*/
|
|
86
|
-
(requestConfig, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const _createHandleExceptionMiddleware = ({ captureExtendedException }) => (config, next, defaults) => __awaiter(void 0, void 0, void 0, function* () {
|
|
87
76
|
try {
|
|
88
|
-
yield next(
|
|
77
|
+
yield next(config);
|
|
89
78
|
}
|
|
90
79
|
catch (error) {
|
|
91
80
|
const { status } = error.response || {};
|
|
92
|
-
const { logLevelConfig } =
|
|
93
|
-
|
|
81
|
+
const { logLevelConfig } = config;
|
|
82
|
+
captureExtendedException && captureExtendedException(error, pick_1.default(Object.assign(Object.assign({}, defaults), config), ['url', 'baseURL', 'method', 'headers', 'params', 'data']), {
|
|
94
83
|
dataName: 'Request details',
|
|
95
84
|
dataAsContext: true,
|
|
96
85
|
level: exports._getLevelFromConfig(status, logLevelConfig),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handlers-middlewares.js","sourceRoot":"","sources":["../../../../src/helpers/api/middlewares/error-handlers-middlewares.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmD;AACnD,
|
|
1
|
+
{"version":3,"file":"error-handlers-middlewares.js","sourceRoot":"","sources":["../../../../src/helpers/api/middlewares/error-handlers-middlewares.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAmD;AACnD,uDAA+B;AAE/B;;;;;;GAMG;AACI,MAAM,mBAAmB,GAAG,CAAC,cAAc,EAAE,QAAQ,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE;IACjF,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,KAAI,SAAS,CAAC;IAC1E,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,KAAI,EAAE,CAAC;IAEhE,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC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5
5
|
* @return {Object.<string, string>} Коллекция сервисных заголовков.
|
|
6
6
|
*/
|
|
7
|
-
export const getServiceHeaders: (
|
|
7
|
+
export const getServiceHeaders: (...args: any[]) => any;
|
|
8
8
|
export function getServiceUserAgent({ serviceName, version }?: {
|
|
9
9
|
serviceName: string;
|
|
10
10
|
version: string;
|
|
@@ -1,12 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Middleware } from 'middleware-axios';
|
|
2
|
+
import { Tracer, SpanContext } from 'opentracing';
|
|
2
3
|
/**
|
|
3
4
|
* Создаёт middleware для трассировки запросов в API.
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @return
|
|
5
|
+
* @param options Параметры для создания middleware.
|
|
6
|
+
* @param options.tracer Объект трейсера.
|
|
7
|
+
* @param options.context Объект родительского контекста.
|
|
8
|
+
* @return Middleware для трассировки запросов в API.
|
|
9
|
+
*/
|
|
10
|
+
declare const createTraceRequestMiddleware: ({ tracer, context }: {
|
|
11
|
+
tracer: Tracer;
|
|
12
|
+
context: SpanContext;
|
|
13
|
+
}) => Middleware<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Преобразует строку вида:
|
|
16
|
+
* "/api/v2/something/123456/some-bff/123456"
|
|
17
|
+
* в строку вида:
|
|
18
|
+
* "/api/v2/something/{id}/some-bff/123456"
|
|
19
|
+
* и возвращает кортеж с этой строкой и вырезанным числом в случае если оно найдено.
|
|
20
|
+
* @param url Url.
|
|
21
|
+
* @return Кортеж со строкой и результатом поиска числа.
|
|
8
22
|
*/
|
|
9
|
-
declare
|
|
10
|
-
|
|
11
|
-
tracer: Object;
|
|
12
|
-
}): (arg0: Object, arg1: Function) => Promise<any>;
|
|
23
|
+
export declare const hideFirstId: (url: string) => [string, number | undefined];
|
|
24
|
+
export default createTraceRequestMiddleware;
|
|
@@ -8,45 +8,62 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.hideFirstId = void 0;
|
|
15
13
|
const opentracing_1 = require("opentracing");
|
|
16
|
-
const propOr_1 = __importDefault(require("lodash/fp/propOr"));
|
|
17
|
-
const getParams = propOr_1.default({}, 'params');
|
|
18
14
|
/**
|
|
19
15
|
* Создаёт middleware для трассировки запросов в API.
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @return
|
|
16
|
+
* @param options Параметры для создания middleware.
|
|
17
|
+
* @param options.tracer Объект трейсера.
|
|
18
|
+
* @param options.context Объект родительского контекста.
|
|
19
|
+
* @return Middleware для трассировки запросов в API.
|
|
24
20
|
*/
|
|
25
|
-
const createTraceRequestMiddleware = ({
|
|
21
|
+
const createTraceRequestMiddleware = ({ tracer, context }) => function (config, next, defaults) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const { method, url, foundId } = getRequestInfo(config, defaults);
|
|
24
|
+
const span = tracer.startSpan(`HTTP ${method} ${url}`, {
|
|
25
|
+
childOf: context,
|
|
26
|
+
});
|
|
27
|
+
if (!config.headers) {
|
|
28
|
+
config.headers = {};
|
|
29
|
+
}
|
|
30
|
+
span.addTags(Object.assign({ [opentracing_1.Tags.HTTP_URL]: url, [opentracing_1.Tags.HTTP_METHOD]: method, 'request.params': Object.assign({}, config.params), 'request.headers': Object.assign({}, config.headers) }, (foundId && { 'request.id': foundId })));
|
|
31
|
+
tracer.inject(span, opentracing_1.FORMAT_HTTP_HEADERS, config.headers);
|
|
32
|
+
const response = yield next(config);
|
|
33
|
+
span.setTag(opentracing_1.Tags.HTTP_STATUS_CODE, response.status);
|
|
34
|
+
span.finish();
|
|
35
|
+
});
|
|
36
|
+
};
|
|
26
37
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @param
|
|
30
|
-
* @
|
|
38
|
+
* Формирует базовые данные запроса.
|
|
39
|
+
* Заменяет первое найденное число в url на "{id}", возвращая его в результате.
|
|
40
|
+
* @param config Axios-конфиг запроса.
|
|
41
|
+
* @param defaults Базовый конфиг экземпляра Axios.
|
|
42
|
+
* @return Базовые данные запроса.
|
|
31
43
|
*/
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
44
|
+
const getRequestInfo = (config, defaults) => {
|
|
45
|
+
const method = (config.method || 'GET').toUpperCase();
|
|
46
|
+
const baseURL = config.baseURL || defaults.baseURL || '';
|
|
47
|
+
// ВАЖНО: абстрагируем id только в url игнорируя baseURL
|
|
48
|
+
const [url, foundId] = exports.hideFirstId(config.url || defaults.url || '');
|
|
49
|
+
const readyUrl = `${baseURL}${url}`;
|
|
50
|
+
return { method, url: readyUrl, foundId };
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Преобразует строку вида:
|
|
54
|
+
* "/api/v2/something/123456/some-bff/123456"
|
|
55
|
+
* в строку вида:
|
|
56
|
+
* "/api/v2/something/{id}/some-bff/123456"
|
|
57
|
+
* и возвращает кортеж с этой строкой и вырезанным числом в случае если оно найдено.
|
|
58
|
+
* @param url Url.
|
|
59
|
+
* @return Кортеж со строкой и результатом поиска числа.
|
|
60
|
+
*/
|
|
61
|
+
const hideFirstId = (url) => {
|
|
62
|
+
const found = /\d{2,}/.exec(url);
|
|
63
|
+
return found
|
|
64
|
+
? [url.replace(found[0], '{id}'), Number(found[0])]
|
|
65
|
+
: [url, undefined];
|
|
66
|
+
};
|
|
67
|
+
exports.hideFirstId = hideFirstId;
|
|
51
68
|
exports.default = createTraceRequestMiddleware;
|
|
52
69
|
//# sourceMappingURL=trace-request-middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-request-middleware.js","sourceRoot":"","sources":["../../../../src/helpers/api/middlewares/trace-request-middleware.
|
|
1
|
+
{"version":3,"file":"trace-request-middleware.js","sourceRoot":"","sources":["../../../../src/helpers/api/middlewares/trace-request-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,6CAA6E;AAE7E;;;;;;GAMG;AACH,MAAM,4BAA4B,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAGtD,EAAmB,EAAE,CAAC,UAAgB,MAAM,EAAE,IAAI,EAAE,QAAQ;;QACzD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAElE,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,MAAM,IAAI,GAAG,EAAE,EAAE;YACrD,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACnB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;SACrB;QAED,IAAI,CAAC,OAAO,iBACV,CAAC,kBAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,EACpB,CAAC,kBAAI,CAAC,WAAW,CAAC,EAAE,MAAM,EAC1B,gBAAgB,oBAAO,MAAM,CAAC,MAAM,GACpC,iBAAiB,oBAAO,MAAM,CAAC,OAAO,KAGnC,CAAC,OAAO,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,EACzC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,iCAAmB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAEzD,MAAM,QAAQ,GAA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|
|
18
18
|
transport: Object;
|
|
19
19
|
maxRedirects: number;
|
|
20
20
|
}): Object;
|
|
21
|
-
export function buildRequestPath(url: URL, params?: Object |
|
|
21
|
+
export function buildRequestPath(url: URL, params?: string | Object | URLSearchParams | undefined, paramsSerializer?: Function | undefined): string;
|
|
22
22
|
export function createOptions({ url, baseURL, method, headers, httpAgent, httpsAgent, params, paramsSerializer, maxRedirects, maxContentLength, }: Object): Object;
|
|
23
23
|
export function uncompressResponse(response: import('stream').Readable): import('stream').Readable;
|
|
24
24
|
export function enhanceError(error: Error, config: Object, code: string, request: import('http').ClientRequest, response: import('http').IncomingMessage): Error;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function getParams(request: Object, config: Object, getValue: Function, modify: Function, defaultValue: Object): Object;
|
|
1
|
+
export function getParams(request: Object, config: Object, getValue: Function | undefined, modify: Function, defaultValue: Object): Object;
|
|
2
2
|
export function parseHttpHeaders(request: Object): Object;
|
|
3
3
|
declare var _default: Function;
|
|
4
4
|
export default _default;
|
|
@@ -33,8 +33,8 @@ export function createReducer(initialState: any, createHandlers: (arg0: {
|
|
|
33
33
|
*/
|
|
34
34
|
failure: Function;
|
|
35
35
|
}) => Object, { createStatusAdder, }?: {
|
|
36
|
-
createStatusAdder?: Object;
|
|
37
|
-
}): Function;
|
|
36
|
+
createStatusAdder?: Object | undefined;
|
|
37
|
+
} | undefined): Function;
|
|
38
38
|
export function createStateMaker(baseInitialState?: any, { createStatusAdder, }?: {
|
|
39
|
-
createStatusAdder?: Function;
|
|
40
|
-
}): Function;
|
|
39
|
+
createStatusAdder?: Function | undefined;
|
|
40
|
+
} | undefined): Function;
|
|
@@ -10,7 +10,7 @@ export namespace StatusSelectors {
|
|
|
10
10
|
* @param {Function} [selectSection=identity] Вернет раздел состояния, у которого есть статус.
|
|
11
11
|
* @return {{ isInitial: Function, isFetching: Function, isSuccessful: Function, isFailed: Function }} Селекторы.
|
|
12
12
|
*/
|
|
13
|
-
declare function create(selectSection?: Function): {
|
|
13
|
+
declare function create(selectSection?: Function | undefined): {
|
|
14
14
|
isInitial: Function;
|
|
15
15
|
isFetching: Function;
|
|
16
16
|
isSuccessful: Function;
|
|
@@ -6,8 +6,8 @@ export function createStore(reducer: Function, initialSaga: Function, { isReady,
|
|
|
6
6
|
middleware: any[];
|
|
7
7
|
onReady: Function;
|
|
8
8
|
timeout: number;
|
|
9
|
-
onTimeout?: Function;
|
|
10
|
-
onSagasErrorHandler?: Function;
|
|
9
|
+
onTimeout?: Function | undefined;
|
|
10
|
+
onSagasErrorHandler?: Function | undefined;
|
|
11
11
|
}): Object;
|
|
12
12
|
export function mapServiceOptionsToArgs({ reducer, initialSaga, ...options }: {
|
|
13
13
|
reducer: Function;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* @return {ServerResponse} Ответ сервера.
|
|
14
14
|
*/
|
|
15
15
|
export default function doSafeRequest(performRequest: Function, options?: {
|
|
16
|
-
args?: any[];
|
|
17
|
-
}): ServerResponse;
|
|
16
|
+
args?: any[] | undefined;
|
|
17
|
+
} | undefined): ServerResponse;
|
|
18
18
|
/**
|
|
19
19
|
* Ответ сервера.
|
|
20
20
|
*/
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export function traceIncomingRequest(tracer: Object, key: string, httpRequest: Object, payload?: Object): Object;
|
|
1
|
+
export function traceIncomingRequest(tracer: Object, key: string, httpRequest: Object, payload?: Object | undefined): Object;
|
|
2
2
|
export function getTracer({ tracerConfig: { version, serviceName, }, additionalConfig, }: {
|
|
3
3
|
tracerConfig: {
|
|
4
4
|
serviceName: string;
|
|
5
5
|
version: number;
|
|
6
6
|
};
|
|
7
|
-
additionalConfig?: Object;
|
|
7
|
+
additionalConfig?: Object | undefined;
|
|
8
8
|
}): import('opentracing').Tracer;
|
|
9
9
|
export function _createTracingMiddleware(createSpan: Function, onSpanFinish: Function, { spanKey }?: {
|
|
10
|
-
spanKey?: string;
|
|
11
|
-
}): Function;
|
|
10
|
+
spanKey?: string | undefined;
|
|
11
|
+
} | undefined): Function;
|
|
12
12
|
export function getSpanContext({ response }: Object): Object | null;
|
|
13
13
|
export function _deptToArg({ createSpan, onSpanFinish, options }: Object): any[];
|
|
14
14
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function createSentryInstance({ BrowserClient, NodeClient, Hub }: {
|
|
2
|
-
BrowserClient?: Function;
|
|
3
|
-
NodeClient?: Function;
|
|
2
|
+
BrowserClient?: Function | undefined;
|
|
3
|
+
NodeClient?: Function | undefined;
|
|
4
4
|
Hub: Function;
|
|
5
5
|
}): SentryInstance;
|
|
6
6
|
export function deptToArg({ sentry }: Object): any[];
|
|
@@ -12,6 +12,6 @@ export default initializeSentryCreator;
|
|
|
12
12
|
declare function initializeSentryCreator({ sentryLoggerService, getSentryDsn, getSentryOptions, configureMainScope, }: {
|
|
13
13
|
sentryLoggerService: Object;
|
|
14
14
|
getSentryDsn: Function;
|
|
15
|
-
getSentryOptions?: Function;
|
|
16
|
-
configureMainScope?: Function;
|
|
15
|
+
getSentryOptions?: Function | undefined;
|
|
16
|
+
configureMainScope?: Function | undefined;
|
|
17
17
|
}): Function;
|
|
@@ -11,7 +11,7 @@ declare const _exports: {
|
|
|
11
11
|
entry: {};
|
|
12
12
|
mode: string;
|
|
13
13
|
plugins: ExtendedMFPlugin[];
|
|
14
|
-
};
|
|
14
|
+
} | undefined;
|
|
15
15
|
push(...items: {
|
|
16
16
|
entry: {};
|
|
17
17
|
mode: string;
|
|
@@ -39,7 +39,7 @@ declare const _exports: {
|
|
|
39
39
|
mode: string;
|
|
40
40
|
plugins: ExtendedMFPlugin[];
|
|
41
41
|
}[];
|
|
42
|
-
join(separator?: string): string;
|
|
42
|
+
join(separator?: string | undefined): string;
|
|
43
43
|
reverse(): {
|
|
44
44
|
entry: {};
|
|
45
45
|
mode: string;
|
|
@@ -49,13 +49,13 @@ declare const _exports: {
|
|
|
49
49
|
entry: {};
|
|
50
50
|
mode: string;
|
|
51
51
|
plugins: ExtendedMFPlugin[];
|
|
52
|
-
};
|
|
53
|
-
slice(start?: number, end?: number): {
|
|
52
|
+
} | undefined;
|
|
53
|
+
slice(start?: number | undefined, end?: number | undefined): {
|
|
54
54
|
entry: {};
|
|
55
55
|
mode: string;
|
|
56
56
|
plugins: ExtendedMFPlugin[];
|
|
57
57
|
}[];
|
|
58
|
-
sort(compareFn?: (a: {
|
|
58
|
+
sort(compareFn?: ((a: {
|
|
59
59
|
entry: {};
|
|
60
60
|
mode: string;
|
|
61
61
|
plugins: ExtendedMFPlugin[];
|
|
@@ -63,12 +63,12 @@ declare const _exports: {
|
|
|
63
63
|
entry: {};
|
|
64
64
|
mode: string;
|
|
65
65
|
plugins: ExtendedMFPlugin[];
|
|
66
|
-
}) => number): {
|
|
66
|
+
}) => number) | undefined): {
|
|
67
67
|
entry: {};
|
|
68
68
|
mode: string;
|
|
69
69
|
plugins: ExtendedMFPlugin[];
|
|
70
70
|
}[];
|
|
71
|
-
splice(start: number, deleteCount?: number): {
|
|
71
|
+
splice(start: number, deleteCount?: number | undefined): {
|
|
72
72
|
entry: {};
|
|
73
73
|
mode: string;
|
|
74
74
|
plugins: ExtendedMFPlugin[];
|
|
@@ -91,12 +91,12 @@ declare const _exports: {
|
|
|
91
91
|
entry: {};
|
|
92
92
|
mode: string;
|
|
93
93
|
plugins: ExtendedMFPlugin[];
|
|
94
|
-
}, fromIndex?: number): number;
|
|
94
|
+
}, fromIndex?: number | undefined): number;
|
|
95
95
|
lastIndexOf(searchElement: {
|
|
96
96
|
entry: {};
|
|
97
97
|
mode: string;
|
|
98
98
|
plugins: ExtendedMFPlugin[];
|
|
99
|
-
}, fromIndex?: number): number;
|
|
99
|
+
}, fromIndex?: number | undefined): number;
|
|
100
100
|
every<S extends {
|
|
101
101
|
entry: {};
|
|
102
102
|
mode: string;
|
|
@@ -294,7 +294,7 @@ declare const _exports: {
|
|
|
294
294
|
entry: {};
|
|
295
295
|
mode: string;
|
|
296
296
|
plugins: ExtendedMFPlugin[];
|
|
297
|
-
}[]) => value is S_2, thisArg?: any): S_2;
|
|
297
|
+
}[]) => value is S_2, thisArg?: any): S_2 | undefined;
|
|
298
298
|
find(predicate: (value: {
|
|
299
299
|
entry: {};
|
|
300
300
|
mode: string;
|
|
@@ -307,7 +307,7 @@ declare const _exports: {
|
|
|
307
307
|
entry: {};
|
|
308
308
|
mode: string;
|
|
309
309
|
plugins: ExtendedMFPlugin[];
|
|
310
|
-
};
|
|
310
|
+
} | undefined;
|
|
311
311
|
findIndex(predicate: (value: {
|
|
312
312
|
entry: {};
|
|
313
313
|
mode: string;
|
|
@@ -321,12 +321,12 @@ declare const _exports: {
|
|
|
321
321
|
entry: {};
|
|
322
322
|
mode: string;
|
|
323
323
|
plugins: ExtendedMFPlugin[];
|
|
324
|
-
}, start?: number, end?: number): {
|
|
324
|
+
}, start?: number | undefined, end?: number | undefined): {
|
|
325
325
|
entry: {};
|
|
326
326
|
mode: string;
|
|
327
327
|
plugins: ExtendedMFPlugin[];
|
|
328
328
|
}[];
|
|
329
|
-
copyWithin(target: number, start: number, end?: number): {
|
|
329
|
+
copyWithin(target: number, start: number, end?: number | undefined): {
|
|
330
330
|
entry: {};
|
|
331
331
|
mode: string;
|
|
332
332
|
plugins: ExtendedMFPlugin[];
|
|
@@ -360,7 +360,7 @@ declare const _exports: {
|
|
|
360
360
|
entry: {};
|
|
361
361
|
mode: string;
|
|
362
362
|
plugins: ExtendedMFPlugin[];
|
|
363
|
-
}, fromIndex?: number): boolean;
|
|
363
|
+
}, fromIndex?: number | undefined): boolean;
|
|
364
364
|
};
|
|
365
365
|
export = _exports;
|
|
366
366
|
import ExtendedMFPlugin = require("../enhanced-module-federation-plugin");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack-config.example.js","sourceRoot":"","sources":["../../../src/module-federation/__example__/webpack-config.example.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,gBAAgB,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AAEzE;;GAEG;AACH,MAAM,mBAAmB,GAAG;IAC1B,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa;IAC1E,OAAO,EAAE;QACP,IAAI,gBAAgB,CAClB;YACE,IAAI,EAAE,qBAAqB;YAC3B,QAAQ,EACJ,uBAAuB,OAAO,CAAC,GAAG,CAAC,kBAAkB,gBAAgB,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK;YAC7G,OAAO,EAAE;gBACP,SAAS,EAAE,yBAAyB;gBACpC,UAAU,EAAE,wBAAwB;aACrC;SACF,CACF;KACF;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,gBAAgB;IACvB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa;IAC1E,OAAO,EAAE;QACP,IAAI,gBAAgB,CAClB;YACE,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE;gBACP,aAAa,EAAE,qBAAqB;aACrC;SACF,CACF;KACF;IACD,OAAO,EAAE;QACP;;WAEG;QACH,QAAQ,EAAE;YACR,qBAAqB,EAAE,mCAAmC;YAC1D,sBAAsB,EAAE,mCAAmC;SAC5D;KACF;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG;IACf,mBAAmB;IACnB,iBAAiB;CAClB,CAAC"}
|
|
1
|
+
{"version":3,"file":"webpack-config.example.js","sourceRoot":"","sources":["../../../src/module-federation/__example__/webpack-config.example.js"],"names":[],"mappings":";AAAA;;GAEG;AACH,MAAM,gBAAgB,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AAEzE;;GAEG;AACH,MAAM,mBAAmB,GAAG;IAC1B,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa;IAC1E,OAAO,EAAE;QACP,IAAI,gBAAgB,CAClB;YACE,IAAI,EAAE,qBAAqB;YAC3B,QAAQ,EACJ,uBAAuB,OAAO,CAAC,GAAG,CAAC,kBAAkB,gBAAgB,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK;YAC7G,OAAO,EAAE;gBACP,SAAS,EAAE,yBAAyB;gBACpC,UAAU,EAAE,wBAAwB;aACrC;SACF,CACF;KACF;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,gBAAgB;IACvB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa;IAC1E,OAAO,EAAE;QACP,IAAI,gBAAgB,CAClB;YACE,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE;gBACP,aAAa,EAAE,qBAAqB;aACrC;SACF,CACF;KACF;IACD,OAAO,EAAE;QACP;;WAEG;QACH,QAAQ,EAAE;YACR,qBAAqB,EAAE,mCAAmC;YAC1D,sBAAsB,EAAE,mCAAmC;SAC5D;KACF;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG;IACf,mBAAmB;IACnB,iBAAiB;CAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enhanced-module-federation-plugin.js","sourceRoot":"","sources":["../../src/module-federation/enhanced-module-federation-plugin.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enhanced-module-federation-plugin.js","sourceRoot":"","sources":["../../src/module-federation/enhanced-module-federation-plugin.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC;AAChE,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CA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C,GAAG,CAAC,gCAAgC,EAAE,GAAG,EAAE;YACpE,IAAI,gBAAgB,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE;gBAC9D,IAAI,sBAAsB,iCACrB,OAAO,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,GACzC,eAAe,EAClB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;aACpB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,8BAA8B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/module-federation/utils/index.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,CAC3B,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,EAAE,CACA;gBACY,sBAAsB;;;;wBAId,mBAAmB,OAAO,WAAW;;;;0DAIH,WAAW;;kCAEnC,sBAAsB,OAAO,WAAW;;;;yCAIjC,sBAAsB;;GAE5D,CAAC;AAEJ,MAAM,CAAC,OAAO,GAAG,EAAE,oBAAoB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/module-federation/utils/index.js"],"names":[],"mappings":";AAAA;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,CAC3B,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,EAAE,CACA;gBACY,sBAAsB;;;;wBAId,mBAAmB,OAAO,WAAW;;;;0DAIH,WAAW;;kCAEnC,sBAAsB,OAAO,WAAW;;;;yCAIjC,sBAAsB;;GAE5D,CAAC;AAEJ,MAAM,CAAC,OAAO,GAAG,EAAE,oBAAoB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sima-land/isomorph",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.7",
|
|
4
4
|
"description": "Set of utils that are not directly related to UI",
|
|
5
5
|
"repository": "ssh://git@github.com:sima-land/isomorph.git",
|
|
6
6
|
"author": "www.sima-land.ru team",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"private": false,
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
10
|
+
"node": ">=14.17.0"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"prepare": "",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"express-http-proxy": "^1.5.1",
|
|
27
27
|
"ioredis": "^4.10.0",
|
|
28
28
|
"jaeger-client": "^3.15.0",
|
|
29
|
-
"middleware-axios": "^2.
|
|
29
|
+
"middleware-axios": "^2.1.1",
|
|
30
30
|
"opentracing": "^0.14.3",
|
|
31
31
|
"pino": "^5.13.1",
|
|
32
32
|
"pino-pretty": "^3.2.0",
|
|
@@ -34,15 +34,16 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.14.2",
|
|
37
|
-
"@babel/plugin-proposal-optional-chaining": "^7.14.2",
|
|
38
37
|
"@babel/preset-env": "^7.14.2",
|
|
39
38
|
"@babel/preset-react": "^7.13.13",
|
|
39
|
+
"@babel/preset-typescript": "^7.16.5",
|
|
40
40
|
"@sentry/browser": "^5.15.5",
|
|
41
41
|
"@sentry/node": "5.10.2",
|
|
42
42
|
"@sima-land/linters": "^1.0.12",
|
|
43
43
|
"@types/enzyme": "^3.10.8",
|
|
44
44
|
"@types/express": "^4.17.13",
|
|
45
|
-
"@types/
|
|
45
|
+
"@types/jaeger-client": "^3.18.2",
|
|
46
|
+
"@types/jest": "^27.0.3",
|
|
46
47
|
"@types/lodash": "^4.14.171",
|
|
47
48
|
"@types/node": "^16.4.5",
|
|
48
49
|
"@types/react": "^16.14.0",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"@types/webpack": "^5.28.0",
|
|
52
53
|
"@typescript-eslint/eslint-plugin": "^4.23.0",
|
|
53
54
|
"@typescript-eslint/parser": "^4.23.0",
|
|
54
|
-
"babel-jest": "^27.
|
|
55
|
+
"babel-jest": "^27.4.5",
|
|
55
56
|
"copyfiles": "^2.4.1",
|
|
56
57
|
"dotenv": "^8.2.0",
|
|
57
58
|
"enzyme": "3.8.x",
|
|
@@ -59,29 +60,28 @@
|
|
|
59
60
|
"enzyme-to-json": "3.3.x",
|
|
60
61
|
"husky": "^7.0.1",
|
|
61
62
|
"identity-obj-proxy": "3.0.x",
|
|
62
|
-
"jest": "^27.
|
|
63
|
+
"jest": "^27.4.5",
|
|
63
64
|
"lint-staged": "^11.1.1",
|
|
64
65
|
"lodash": "^4.17.21",
|
|
65
|
-
"react": "16.12.0",
|
|
66
|
-
"react-dom": "16.12.0",
|
|
67
|
-
"react-redux": "7.1.3",
|
|
68
|
-
"redux": "4.0.5",
|
|
69
|
-
"redux-saga": "1.1.3",
|
|
70
|
-
"reduxsauce": "1.1.2",
|
|
71
|
-
"reselect": "4.0.0",
|
|
66
|
+
"react": "^16.12.0",
|
|
67
|
+
"react-dom": "^16.12.0",
|
|
68
|
+
"react-redux": "^7.1.3",
|
|
69
|
+
"redux": "^4.0.5",
|
|
70
|
+
"redux-saga": "^1.1.3",
|
|
71
|
+
"reduxsauce": "^1.1.2",
|
|
72
|
+
"reselect": "^4.0.0",
|
|
72
73
|
"rimraf": "^3.0.2",
|
|
73
74
|
"sentry-testkit": "^3.2.1",
|
|
74
|
-
"ts-jest": "^27.0.4",
|
|
75
75
|
"typescript": "^4.2.4"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"lodash": "4.17.
|
|
79
|
-
"react": "16.12.0",
|
|
80
|
-
"react-dom": "16.12.0",
|
|
81
|
-
"react-redux": "7.1.3",
|
|
82
|
-
"redux": "4.0.5",
|
|
83
|
-
"redux-saga": "1.1.3",
|
|
84
|
-
"reduxsauce": "1.1.2",
|
|
85
|
-
"reselect": "4.0.0"
|
|
78
|
+
"lodash": "^4.17.21",
|
|
79
|
+
"react": "^16.12.0",
|
|
80
|
+
"react-dom": "^16.12.0",
|
|
81
|
+
"react-redux": "^7.1.3",
|
|
82
|
+
"redux": "^4.0.5",
|
|
83
|
+
"redux-saga": "^1.1.3",
|
|
84
|
+
"reduxsauce": "^1.1.2",
|
|
85
|
+
"reselect": "^4.0.0"
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -6,5 +6,5 @@ export default createSetHeaderMiddleware;
|
|
|
6
6
|
* @return {Function} Промежуточный слой приложения для установки заголовков со ссылками на клиентские ресурсы.
|
|
7
7
|
*/
|
|
8
8
|
declare function createSetHeaderMiddleware({ headers, }: {
|
|
9
|
-
headers?: Object;
|
|
9
|
+
headers?: Object | undefined;
|
|
10
10
|
}): Function;
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Определяет доступен ли кэш.
|
|
3
|
-
* @return
|
|
3
|
+
* @return Флаг доступности кэш.
|
|
4
4
|
*/
|
|
5
|
-
export const isAvailable = () =>
|
|
5
|
+
export const isAvailable = (): boolean => {
|
|
6
|
+
try {
|
|
7
|
+
const testKey = `local_storage_test_key::${Date.now()}`;
|
|
8
|
+
|
|
9
|
+
window.localStorage.setItem(testKey, testKey);
|
|
10
|
+
window.localStorage.removeItem(testKey);
|
|
11
|
+
|
|
12
|
+
return true;
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
6
17
|
|
|
7
18
|
/**
|
|
8
|
-
* Возвращает
|
|
9
|
-
* @param
|
|
10
|
-
* @return
|
|
19
|
+
* Возвращает объект.
|
|
20
|
+
* @param key Ключ.
|
|
21
|
+
* @return Запрашиваемое значение.
|
|
11
22
|
*/
|
|
12
|
-
export const getItem = key => {
|
|
13
|
-
const { value, expire } = JSON.parse(localStorage.getItem(key)
|
|
23
|
+
export const getItem = (key: string): unknown => {
|
|
24
|
+
const { value, expire } = JSON.parse(localStorage.getItem(key) || '{}');
|
|
14
25
|
const now = Date.now();
|
|
15
26
|
const isExpired = expire
|
|
16
27
|
? now > expire
|
|
@@ -22,12 +33,12 @@ export const getItem = key => {
|
|
|
22
33
|
};
|
|
23
34
|
|
|
24
35
|
/**
|
|
25
|
-
* Добавляет
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
36
|
+
* Добавляет значение.
|
|
37
|
+
* @param key Ключ.
|
|
38
|
+
* @param value Значение.
|
|
39
|
+
* @param duration Время жизни значения в секундах.
|
|
29
40
|
*/
|
|
30
|
-
export const setItem = (key, value, duration = 3600) => {
|
|
41
|
+
export const setItem = (key: string, value: any, duration = 3600) => {
|
|
31
42
|
const now = Date.now();
|
|
32
43
|
const durationMs = duration * 1000;
|
|
33
44
|
const expire = now + durationMs;
|
|
@@ -39,12 +50,13 @@ export const setItem = (key, value, duration = 3600) => {
|
|
|
39
50
|
};
|
|
40
51
|
|
|
41
52
|
/**
|
|
42
|
-
* Определяет,
|
|
43
|
-
* @param
|
|
44
|
-
* @return
|
|
53
|
+
* Определяет, превышена ли квота.
|
|
54
|
+
* @param error Информация об ошибке.
|
|
55
|
+
* @return Признак превышения квоты.
|
|
45
56
|
*/
|
|
46
|
-
export const isQuotaExceeded = error => {
|
|
57
|
+
export const isQuotaExceeded = (error: any): boolean => {
|
|
47
58
|
let quotaExceeded = false;
|
|
59
|
+
|
|
48
60
|
if (error) {
|
|
49
61
|
if (error.code) {
|
|
50
62
|
switch (error.code) {
|
|
@@ -59,22 +71,22 @@ export const isQuotaExceeded = error => {
|
|
|
59
71
|
break;
|
|
60
72
|
}
|
|
61
73
|
} else if (error.number === -2147024882) {
|
|
62
|
-
//
|
|
74
|
+
// IE 8
|
|
63
75
|
quotaExceeded = true;
|
|
64
76
|
}
|
|
65
77
|
}
|
|
78
|
+
|
|
66
79
|
return quotaExceeded;
|
|
67
80
|
};
|
|
68
81
|
|
|
69
82
|
/**
|
|
70
83
|
* Набор методов для работы с кэшем.
|
|
71
|
-
* @type {{set: Function, get: Function, status: boolean}}
|
|
72
84
|
*/
|
|
73
|
-
const
|
|
85
|
+
const LocalStorageCache = {
|
|
74
86
|
get: getItem,
|
|
75
87
|
set: setItem,
|
|
76
88
|
status: isAvailable(),
|
|
77
89
|
quotaExceeded: isQuotaExceeded,
|
|
78
|
-
};
|
|
90
|
+
} as const;
|
|
79
91
|
|
|
80
|
-
export default
|
|
92
|
+
export default LocalStorageCache;
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { createService } from '../../../container';
|
|
2
|
-
import isFunction from 'lodash/isFunction';
|
|
3
|
-
import pathOr from 'lodash/fp/pathOr';
|
|
4
2
|
import pick from 'lodash/pick';
|
|
5
3
|
|
|
6
|
-
const getStatusCode = pathOr('UNKNOWN', 'status');
|
|
7
|
-
const getConfig = pathOr({}, 'config');
|
|
8
|
-
|
|
9
4
|
/**
|
|
10
5
|
* Отправляет крошки http запроса.
|
|
11
6
|
* @param {Function} sendBreadcrumb Функция отправки крошек.
|
|
12
|
-
* @param {Object} response Объект в формате ответа Axios, содержащий данные
|
|
7
|
+
* @param {Object} response Объект в формате ответа Axios, содержащий данные об ответе.
|
|
13
8
|
* @param {boolean} asRequest Обработать как событие запроса.
|
|
14
9
|
* @private
|
|
15
10
|
*/
|
|
16
11
|
export const _sendHttpBreadcrumb = (sendBreadcrumb, response, asRequest = false) => {
|
|
17
|
-
const statusCode = asRequest ? 'FETCHING' :
|
|
18
|
-
const { url, baseURL, method, params } =
|
|
19
|
-
|
|
12
|
+
const statusCode = asRequest ? 'FETCHING' : response?.status || 'UNKNOWN';
|
|
13
|
+
const { url, baseURL, method, params } = response?.config || {};
|
|
14
|
+
|
|
15
|
+
const fullURL = baseURL ? `${baseURL.replace(/\/$/, '')}${url}` : url;
|
|
16
|
+
|
|
20
17
|
const breadcrumb = {
|
|
21
18
|
category: asRequest ? 'http.request' : 'http.response',
|
|
22
19
|
type: 'http',
|
|
@@ -29,7 +26,7 @@ export const _sendHttpBreadcrumb = (sendBreadcrumb, response, asRequest = false)
|
|
|
29
26
|
level: asRequest || (statusCode >= 200 && statusCode < 300) ? 'info' : 'error',
|
|
30
27
|
};
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
sendBreadcrumb && sendBreadcrumb(breadcrumb);
|
|
33
30
|
};
|
|
34
31
|
|
|
35
32
|
/**
|
|
@@ -47,10 +44,12 @@ const _createAttachBreadcrumbsMiddleware = ({ captureBreadcrumb }) =>
|
|
|
47
44
|
* @param {Function} next Функция для передачи контекста выполнения следующему middleware.
|
|
48
45
|
* @return {Promise} Промис.
|
|
49
46
|
*/
|
|
50
|
-
async (
|
|
47
|
+
async (config, next, defaults) => {
|
|
51
48
|
try {
|
|
52
|
-
_sendHttpBreadcrumb(captureBreadcrumb, { config:
|
|
53
|
-
|
|
49
|
+
_sendHttpBreadcrumb(captureBreadcrumb, { config: { ...defaults, ...config } }, true);
|
|
50
|
+
|
|
51
|
+
const apiResponse = await next(config);
|
|
52
|
+
|
|
54
53
|
_sendHttpBreadcrumb(captureBreadcrumb, apiResponse);
|
|
55
54
|
} catch (error) {
|
|
56
55
|
error.isAxiosError && error.response && _sendHttpBreadcrumb(captureBreadcrumb, error.response);
|
|
@@ -67,23 +66,17 @@ const _createAttachBreadcrumbsMiddleware = ({ captureBreadcrumb }) =>
|
|
|
67
66
|
* @private
|
|
68
67
|
*/
|
|
69
68
|
const _createHandleExceptionMiddleware = ({ captureExtendedException }) =>
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Middleware для отправки исключения в сервис логирования.
|
|
73
|
-
* @param {Object} requestConfig Конфигурация запроса API.
|
|
74
|
-
* @param {Function} next Функция для передачи контекста выполнения следующему middleware.
|
|
75
|
-
* @return {Promise} Промис.
|
|
76
|
-
*/
|
|
77
|
-
async (requestConfig, next) => {
|
|
69
|
+
async (config, next, defaults) => {
|
|
78
70
|
try {
|
|
79
|
-
await next(
|
|
71
|
+
await next(config);
|
|
80
72
|
} catch (error) {
|
|
81
73
|
const { status } = error.response || {};
|
|
82
|
-
const { logLevelConfig } =
|
|
83
|
-
|
|
74
|
+
const { logLevelConfig } = config;
|
|
75
|
+
|
|
76
|
+
captureExtendedException && captureExtendedException(
|
|
84
77
|
error,
|
|
85
78
|
pick(
|
|
86
|
-
|
|
79
|
+
{ ...defaults, ...config },
|
|
87
80
|
['url', 'baseURL', 'method', 'headers', 'params', 'data']
|
|
88
81
|
),
|
|
89
82
|
{
|
|
@@ -104,6 +97,7 @@ const _createHandleExceptionMiddleware = ({ captureExtendedException }) =>
|
|
|
104
97
|
*/
|
|
105
98
|
export const _getLevelFromConfig = (statusCode, logLevelConfig = {}) => {
|
|
106
99
|
let level = logLevelConfig.default || 'warning';
|
|
100
|
+
|
|
107
101
|
if (statusCode && logLevelConfig[statusCode]) {
|
|
108
102
|
level = logLevelConfig[statusCode];
|
|
109
103
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { Middleware } from 'middleware-axios';
|
|
3
|
+
import { Tracer, Tags, FORMAT_HTTP_HEADERS, SpanContext } from 'opentracing';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Создаёт middleware для трассировки запросов в API.
|
|
7
|
+
* @param options Параметры для создания middleware.
|
|
8
|
+
* @param options.tracer Объект трейсера.
|
|
9
|
+
* @param options.context Объект родительского контекста.
|
|
10
|
+
* @return Middleware для трассировки запросов в API.
|
|
11
|
+
*/
|
|
12
|
+
const createTraceRequestMiddleware = ({ tracer, context }: {
|
|
13
|
+
tracer: Tracer;
|
|
14
|
+
context: SpanContext;
|
|
15
|
+
}): Middleware<any> => async function (config, next, defaults) {
|
|
16
|
+
const { method, url, foundId } = getRequestInfo(config, defaults);
|
|
17
|
+
|
|
18
|
+
const span = tracer.startSpan(`HTTP ${method} ${url}`, {
|
|
19
|
+
childOf: context,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
if (!config.headers) {
|
|
23
|
+
config.headers = {};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
span.addTags({
|
|
27
|
+
[Tags.HTTP_URL]: url,
|
|
28
|
+
[Tags.HTTP_METHOD]: method,
|
|
29
|
+
'request.params': { ...config.params },
|
|
30
|
+
'request.headers': { ...config.headers },
|
|
31
|
+
|
|
32
|
+
// если нашли id - добавляем в теги
|
|
33
|
+
...(foundId && { 'request.id': foundId }),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
tracer.inject(span, FORMAT_HTTP_HEADERS, config.headers);
|
|
37
|
+
|
|
38
|
+
const response = await next(config);
|
|
39
|
+
|
|
40
|
+
span.setTag(Tags.HTTP_STATUS_CODE, response.status);
|
|
41
|
+
span.finish();
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Формирует базовые данные запроса.
|
|
46
|
+
* Заменяет первое найденное число в url на "{id}", возвращая его в результате.
|
|
47
|
+
* @param config Axios-конфиг запроса.
|
|
48
|
+
* @param defaults Базовый конфиг экземпляра Axios.
|
|
49
|
+
* @return Базовые данные запроса.
|
|
50
|
+
*/
|
|
51
|
+
const getRequestInfo = (
|
|
52
|
+
config: AxiosRequestConfig,
|
|
53
|
+
defaults: AxiosRequestConfig
|
|
54
|
+
): {
|
|
55
|
+
method: string;
|
|
56
|
+
url: string;
|
|
57
|
+
foundId?: number;
|
|
58
|
+
} => {
|
|
59
|
+
const method = (config.method || 'GET').toUpperCase();
|
|
60
|
+
const baseURL = config.baseURL || defaults.baseURL || '';
|
|
61
|
+
|
|
62
|
+
// ВАЖНО: абстрагируем id только в url игнорируя baseURL
|
|
63
|
+
const [url, foundId] = hideFirstId(config.url || defaults.url || '');
|
|
64
|
+
const readyUrl = `${baseURL}${url}`;
|
|
65
|
+
|
|
66
|
+
return { method, url: readyUrl, foundId };
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Преобразует строку вида:
|
|
71
|
+
* "/api/v2/something/123456/some-bff/123456"
|
|
72
|
+
* в строку вида:
|
|
73
|
+
* "/api/v2/something/{id}/some-bff/123456"
|
|
74
|
+
* и возвращает кортеж с этой строкой и вырезанным числом в случае если оно найдено.
|
|
75
|
+
* @param url Url.
|
|
76
|
+
* @return Кортеж со строкой и результатом поиска числа.
|
|
77
|
+
*/
|
|
78
|
+
export const hideFirstId = (url: string): [string, number | undefined] => {
|
|
79
|
+
const found = /\d{2,}/.exec(url);
|
|
80
|
+
|
|
81
|
+
return found
|
|
82
|
+
? [url.replace(found[0], '{id}'), Number(found[0])]
|
|
83
|
+
: [url, undefined];
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default createTraceRequestMiddleware;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Tags, FORMAT_HTTP_HEADERS } from 'opentracing';
|
|
2
|
-
import propOr from 'lodash/fp/propOr';
|
|
3
|
-
|
|
4
|
-
const getParams = propOr({}, 'params');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Создаёт middleware для трассировки запросов в API.
|
|
8
|
-
* @param {Object} options Параметры для создания middleware.
|
|
9
|
-
* @param {Object} options.context Объект родительского контекста.
|
|
10
|
-
* @param {Object} options.tracer Объект трейсера.
|
|
11
|
-
* @return {function(Object, Function): Promise} Middleware для трассироваки запросов в API.
|
|
12
|
-
*/
|
|
13
|
-
const createTraceRequestMiddleware = ({ context, tracer }) =>
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Middleware для трассировки запросов в API.
|
|
17
|
-
* @param {Object} requestConfig Параметры для создания middleware.
|
|
18
|
-
* @param {Function} next Функция для получения данных.
|
|
19
|
-
* @return {Promise} Promise.
|
|
20
|
-
*/
|
|
21
|
-
async (requestConfig, next) => {
|
|
22
|
-
const fullUrl = `${requestConfig.baseURL}${requestConfig.url}`;
|
|
23
|
-
const span = tracer.startSpan(`HTTP ${requestConfig.method.toUpperCase()} ${fullUrl}`, {
|
|
24
|
-
childOf: context,
|
|
25
|
-
});
|
|
26
|
-
if (!requestConfig.headers) {
|
|
27
|
-
requestConfig.headers = {};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
span.addTags({
|
|
31
|
-
[Tags.HTTP_URL]: fullUrl,
|
|
32
|
-
[Tags.HTTP_METHOD]: requestConfig.method.toUpperCase(),
|
|
33
|
-
'request.params': getParams(requestConfig),
|
|
34
|
-
'request.headers': { ...requestConfig.headers },
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
tracer.inject(span, FORMAT_HTTP_HEADERS, requestConfig.headers);
|
|
38
|
-
const response = await next(requestConfig);
|
|
39
|
-
span.setTag(Tags.HTTP_STATUS_CODE, response.status);
|
|
40
|
-
span.finish();
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default createTraceRequestMiddleware;
|