@tramvai/module-common 5.9.2 → 5.14.9
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/lib/CommonModule.browser.js +1 -1
- package/lib/CommonModule.es.js +1 -1
- package/lib/CommonModule.js +1 -1
- package/lib/actions/ActionModule.browser.js +2 -0
- package/lib/actions/ActionModule.es.js +2 -0
- package/lib/actions/ActionModule.js +2 -0
- package/lib/actions/actionChecker.browser.js +1 -2
- package/lib/actions/actionChecker.es.js +1 -2
- package/lib/actions/actionChecker.js +1 -2
- package/lib/actions/actionExecution.browser.js +6 -7
- package/lib/actions/actionExecution.es.js +6 -7
- package/lib/actions/actionExecution.js +6 -7
- package/lib/actions/actionPageRunner.browser.browser.js +7 -2
- package/lib/actions/actionPageRunner.browser.d.ts +2 -0
- package/lib/actions/actionPageRunner.d.ts +2 -0
- package/lib/actions/actionPageRunner.es.js +9 -6
- package/lib/actions/actionPageRunner.js +9 -6
- package/lib/cache/cacheFactory.es.js +1 -1
- package/lib/cache/cacheFactory.js +1 -1
- package/lib/cache/cacheMetrics.es.js +4 -4
- package/lib/cache/cacheMetrics.js +4 -4
- package/lib/cache/cacheWithMetricsProxy.es.js +6 -9
- package/lib/cache/cacheWithMetricsProxy.js +6 -9
- package/lib/command/commandLineRunner.browser.js +3 -5
- package/lib/command/commandLineRunner.es.js +3 -5
- package/lib/command/commandLineRunner.js +3 -5
- package/lib/componentRegistry/componentRegistry.browser.js +1 -1
- package/lib/componentRegistry/componentRegistry.es.js +1 -1
- package/lib/componentRegistry/componentRegistry.js +1 -1
- package/lib/executionContext/executionContextManager.browser.js +1 -1
- package/lib/executionContext/executionContextManager.es.js +1 -1
- package/lib/executionContext/executionContextManager.js +1 -1
- package/lib/providers/clientProviders.browser.js +1 -2
- package/lib/providers/serverProviders.es.js +4 -6
- package/lib/providers/serverProviders.js +4 -6
- package/lib/requestManager/RequestManagerModule.browser.browser.js +1 -1
- package/lib/requestManager/requestManager.browser.js +2 -4
- package/lib/requestManager/requestManager.es.js +2 -4
- package/lib/requestManager/requestManager.js +2 -4
- package/package.json +20 -20
|
@@ -58,7 +58,7 @@ CommonModule = __decorate([
|
|
|
58
58
|
provide: BUNDLE_MANAGER_TOKEN,
|
|
59
59
|
scope: Scope.SINGLETON,
|
|
60
60
|
useFactory: ({ additionalBundleList, ...bundleManagerDeps }) => {
|
|
61
|
-
additionalBundleList
|
|
61
|
+
additionalBundleList?.forEach((bundles) => {
|
|
62
62
|
each((bundle, name) => {
|
|
63
63
|
const bundleAlreadyExists = name in bundleManagerDeps.bundleList;
|
|
64
64
|
if (!bundleAlreadyExists) {
|
package/lib/CommonModule.es.js
CHANGED
|
@@ -58,7 +58,7 @@ CommonModule = __decorate([
|
|
|
58
58
|
provide: BUNDLE_MANAGER_TOKEN,
|
|
59
59
|
scope: Scope.SINGLETON,
|
|
60
60
|
useFactory: ({ additionalBundleList, ...bundleManagerDeps }) => {
|
|
61
|
-
additionalBundleList
|
|
61
|
+
additionalBundleList?.forEach((bundles) => {
|
|
62
62
|
each((bundle, name) => {
|
|
63
63
|
const bundleAlreadyExists = name in bundleManagerDeps.bundleList;
|
|
64
64
|
if (!bundleAlreadyExists) {
|
package/lib/CommonModule.js
CHANGED
|
@@ -66,7 +66,7 @@ exports.CommonModule = tslib.__decorate([
|
|
|
66
66
|
provide: tokensCommon.BUNDLE_MANAGER_TOKEN,
|
|
67
67
|
scope: core.Scope.SINGLETON,
|
|
68
68
|
useFactory: ({ additionalBundleList, ...bundleManagerDeps }) => {
|
|
69
|
-
additionalBundleList
|
|
69
|
+
additionalBundleList?.forEach((bundles) => {
|
|
70
70
|
each__default["default"]((bundle, name) => {
|
|
71
71
|
const bundleAlreadyExists = name in bundleManagerDeps.bundleList;
|
|
72
72
|
if (!bundleAlreadyExists) {
|
|
@@ -3,6 +3,7 @@ import { Module, provide, Scope, ACTIONS_LIST_TOKEN, DI_TOKEN, optional } from '
|
|
|
3
3
|
import { COMBINE_REDUCERS, ACTION_REGISTRY_TOKEN, ACTION_EXECUTION_TOKEN, ACTION_CONDITIONALS, CONTEXT_TOKEN, STORE_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN, DEFERRED_ACTIONS_MAP_TOKEN, ACTION_PAGE_RUNNER_TOKEN, COMMAND_LINE_EXECUTION_CONTEXT_TOKEN, LIMIT_ACTION_GLOBAL_TIME_RUN, LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
4
4
|
import { SERVER_RESPONSE_TASK_MANAGER, SERVER_RESPONSE_STREAM } from '@tramvai/tokens-server-private';
|
|
5
5
|
import { ROUTER_TOKEN } from '@tramvai/tokens-router';
|
|
6
|
+
import { IS_CHILD_APP_DI_TOKEN } from '@tramvai/tokens-child-app';
|
|
6
7
|
import { actionTramvaiReducer } from './actionTramvaiReducer.browser.js';
|
|
7
8
|
import { ActionExecution } from './actionExecution.browser.js';
|
|
8
9
|
import { ActionRegistry } from './actionRegistry.browser.js';
|
|
@@ -70,6 +71,7 @@ ActionModule = __decorate([
|
|
|
70
71
|
responseTaskManager: optional(SERVER_RESPONSE_TASK_MANAGER),
|
|
71
72
|
serverResponseStream: optional(SERVER_RESPONSE_STREAM),
|
|
72
73
|
router: ROUTER_TOKEN,
|
|
74
|
+
isChildAppRunner: optional(IS_CHILD_APP_DI_TOKEN),
|
|
73
75
|
},
|
|
74
76
|
}),
|
|
75
77
|
provide({
|
|
@@ -3,6 +3,7 @@ import { Module, provide, Scope, ACTIONS_LIST_TOKEN, DI_TOKEN, optional } from '
|
|
|
3
3
|
import { COMBINE_REDUCERS, ACTION_REGISTRY_TOKEN, ACTION_EXECUTION_TOKEN, ACTION_CONDITIONALS, CONTEXT_TOKEN, STORE_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN, DEFERRED_ACTIONS_MAP_TOKEN, ACTION_PAGE_RUNNER_TOKEN, COMMAND_LINE_EXECUTION_CONTEXT_TOKEN, LIMIT_ACTION_GLOBAL_TIME_RUN, LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
4
4
|
import { SERVER_RESPONSE_TASK_MANAGER, SERVER_RESPONSE_STREAM } from '@tramvai/tokens-server-private';
|
|
5
5
|
import { ROUTER_TOKEN } from '@tramvai/tokens-router';
|
|
6
|
+
import { IS_CHILD_APP_DI_TOKEN } from '@tramvai/tokens-child-app';
|
|
6
7
|
import { actionTramvaiReducer } from './actionTramvaiReducer.es.js';
|
|
7
8
|
import { ActionExecution } from './actionExecution.es.js';
|
|
8
9
|
import { ActionRegistry } from './actionRegistry.es.js';
|
|
@@ -70,6 +71,7 @@ ActionModule = __decorate([
|
|
|
70
71
|
responseTaskManager: optional(SERVER_RESPONSE_TASK_MANAGER),
|
|
71
72
|
serverResponseStream: optional(SERVER_RESPONSE_STREAM),
|
|
72
73
|
router: ROUTER_TOKEN,
|
|
74
|
+
isChildAppRunner: optional(IS_CHILD_APP_DI_TOKEN),
|
|
73
75
|
},
|
|
74
76
|
}),
|
|
75
77
|
provide({
|
|
@@ -7,6 +7,7 @@ var core = require('@tramvai/core');
|
|
|
7
7
|
var tokensCommon = require('@tramvai/tokens-common');
|
|
8
8
|
var tokensServerPrivate = require('@tramvai/tokens-server-private');
|
|
9
9
|
var tokensRouter = require('@tramvai/tokens-router');
|
|
10
|
+
var tokensChildApp = require('@tramvai/tokens-child-app');
|
|
10
11
|
var actionTramvaiReducer = require('./actionTramvaiReducer.js');
|
|
11
12
|
var actionExecution = require('./actionExecution.js');
|
|
12
13
|
var actionRegistry = require('./actionRegistry.js');
|
|
@@ -68,6 +69,7 @@ exports.ActionModule = tslib.__decorate([
|
|
|
68
69
|
responseTaskManager: core.optional(tokensServerPrivate.SERVER_RESPONSE_TASK_MANAGER),
|
|
69
70
|
serverResponseStream: core.optional(tokensServerPrivate.SERVER_RESPONSE_STREAM),
|
|
70
71
|
router: tokensRouter.ROUTER_TOKEN,
|
|
72
|
+
isChildAppRunner: core.optional(tokensChildApp.IS_CHILD_APP_DI_TOKEN),
|
|
71
73
|
},
|
|
72
74
|
}),
|
|
73
75
|
core.provide({
|
|
@@ -4,7 +4,6 @@ const DEFAULT_CONDITIONS = {};
|
|
|
4
4
|
class ActionChecker {
|
|
5
5
|
// eslint-disable-next-line max-params
|
|
6
6
|
constructor(globalConditionals, payload, parameters, executionState, type) {
|
|
7
|
-
var _a;
|
|
8
7
|
this.globalConditionals = globalConditionals;
|
|
9
8
|
this.payload = payload;
|
|
10
9
|
this.parameters = parameters;
|
|
@@ -18,7 +17,7 @@ class ActionChecker {
|
|
|
18
17
|
// если экшен был уже выполнен, то считаем, что его не нужно больше выполнять
|
|
19
18
|
this.status = executionState.status !== 'success';
|
|
20
19
|
}
|
|
21
|
-
this.conditions =
|
|
20
|
+
this.conditions = parameters.conditions ?? DEFAULT_CONDITIONS;
|
|
22
21
|
}
|
|
23
22
|
check() {
|
|
24
23
|
this.globalConditionals.forEach((filter) => {
|
|
@@ -4,7 +4,6 @@ const DEFAULT_CONDITIONS = {};
|
|
|
4
4
|
class ActionChecker {
|
|
5
5
|
// eslint-disable-next-line max-params
|
|
6
6
|
constructor(globalConditionals, payload, parameters, executionState, type) {
|
|
7
|
-
var _a;
|
|
8
7
|
this.globalConditionals = globalConditionals;
|
|
9
8
|
this.payload = payload;
|
|
10
9
|
this.parameters = parameters;
|
|
@@ -18,7 +17,7 @@ class ActionChecker {
|
|
|
18
17
|
// если экшен был уже выполнен, то считаем, что его не нужно больше выполнять
|
|
19
18
|
this.status = executionState.status !== 'success';
|
|
20
19
|
}
|
|
21
|
-
this.conditions =
|
|
20
|
+
this.conditions = parameters.conditions ?? DEFAULT_CONDITIONS;
|
|
22
21
|
}
|
|
23
22
|
check() {
|
|
24
23
|
this.globalConditionals.forEach((filter) => {
|
|
@@ -8,7 +8,6 @@ const DEFAULT_CONDITIONS = {};
|
|
|
8
8
|
class ActionChecker {
|
|
9
9
|
// eslint-disable-next-line max-params
|
|
10
10
|
constructor(globalConditionals, payload, parameters, executionState, type) {
|
|
11
|
-
var _a;
|
|
12
11
|
this.globalConditionals = globalConditionals;
|
|
13
12
|
this.payload = payload;
|
|
14
13
|
this.parameters = parameters;
|
|
@@ -22,7 +21,7 @@ class ActionChecker {
|
|
|
22
21
|
// если экшен был уже выполнен, то считаем, что его не нужно больше выполнять
|
|
23
22
|
this.status = executionState.status !== 'success';
|
|
24
23
|
}
|
|
25
|
-
this.conditions =
|
|
24
|
+
this.conditions = parameters.conditions ?? DEFAULT_CONDITIONS;
|
|
26
25
|
}
|
|
27
26
|
check() {
|
|
28
27
|
this.globalConditionals.forEach((filter) => {
|
|
@@ -13,7 +13,7 @@ const EMPTY_DEPS = {};
|
|
|
13
13
|
const getParameters = (action) => action[ACTION_PARAMETERS];
|
|
14
14
|
class ActionExecution {
|
|
15
15
|
constructor({ store, context, deferredActionsMap, di, executionContextManager, actionConditionals, transformAction, }) {
|
|
16
|
-
this.actionConditionals = flatten(actionConditionals
|
|
16
|
+
this.actionConditionals = flatten(actionConditionals ?? []);
|
|
17
17
|
this.context = context;
|
|
18
18
|
this.store = store;
|
|
19
19
|
this.deferredActionsMap = deferredActionsMap;
|
|
@@ -29,10 +29,9 @@ class ActionExecution {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
async runInContext(executionContext, action, ...params) {
|
|
32
|
-
var _a;
|
|
33
32
|
const payload = params[0];
|
|
34
33
|
// TODO: replace type with pure context usage
|
|
35
|
-
const type =
|
|
34
|
+
const type = executionContext?.values.pageActions === true ? actionType.global : actionType.local;
|
|
36
35
|
const parameters = this.getActionParameters(action);
|
|
37
36
|
if (!parameters) {
|
|
38
37
|
throw new Error('Cannot resolve internal data for action. Make sure you are using the result of `declareAction` call as an action');
|
|
@@ -42,7 +41,7 @@ class ActionExecution {
|
|
|
42
41
|
switch (parameters.conditionsFailResult) {
|
|
43
42
|
case 'reject':
|
|
44
43
|
return Promise.reject(new ConditionFailError({
|
|
45
|
-
conditionName:
|
|
44
|
+
conditionName: executionState.forbiddenBy ?? 'unknown',
|
|
46
45
|
targetName: parameters.name,
|
|
47
46
|
}));
|
|
48
47
|
default:
|
|
@@ -60,7 +59,7 @@ class ActionExecution {
|
|
|
60
59
|
executionState.status = 'pending';
|
|
61
60
|
return this.executionContextManager.withContext(executionContext, {
|
|
62
61
|
name: parameters.name,
|
|
63
|
-
values:
|
|
62
|
+
values: executionContext?.values.pageActions === true ? { pageActions: false } : undefined,
|
|
64
63
|
}, (executionActionContext, abortController) => {
|
|
65
64
|
const context = this.createActionContext(executionContext, executionActionContext, abortController, parameters);
|
|
66
65
|
return Promise.resolve()
|
|
@@ -129,10 +128,10 @@ class ActionExecution {
|
|
|
129
128
|
createActionContext(parentExecutionContext, actionExecutionContext, abortController, parameters) {
|
|
130
129
|
return {
|
|
131
130
|
abortController,
|
|
132
|
-
abortSignal: actionExecutionContext
|
|
131
|
+
abortSignal: actionExecutionContext?.abortSignal,
|
|
133
132
|
executeAction: this.runInContext.bind(this, actionExecutionContext),
|
|
134
133
|
deps: parameters.deps ? this.di.getOfDeps(parameters.deps) : EMPTY_DEPS,
|
|
135
|
-
actionType:
|
|
134
|
+
actionType: parentExecutionContext?.values.pageActions ? 'page' : 'standalone',
|
|
136
135
|
dispatch: this.store.dispatch,
|
|
137
136
|
getState: this.store.getState,
|
|
138
137
|
};
|
|
@@ -13,7 +13,7 @@ const EMPTY_DEPS = {};
|
|
|
13
13
|
const getParameters = (action) => action[ACTION_PARAMETERS];
|
|
14
14
|
class ActionExecution {
|
|
15
15
|
constructor({ store, context, deferredActionsMap, di, executionContextManager, actionConditionals, transformAction, }) {
|
|
16
|
-
this.actionConditionals = flatten(actionConditionals
|
|
16
|
+
this.actionConditionals = flatten(actionConditionals ?? []);
|
|
17
17
|
this.context = context;
|
|
18
18
|
this.store = store;
|
|
19
19
|
this.deferredActionsMap = deferredActionsMap;
|
|
@@ -29,10 +29,9 @@ class ActionExecution {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
async runInContext(executionContext, action, ...params) {
|
|
32
|
-
var _a;
|
|
33
32
|
const payload = params[0];
|
|
34
33
|
// TODO: replace type with pure context usage
|
|
35
|
-
const type =
|
|
34
|
+
const type = executionContext?.values.pageActions === true ? actionType.global : actionType.local;
|
|
36
35
|
const parameters = this.getActionParameters(action);
|
|
37
36
|
if (!parameters) {
|
|
38
37
|
throw new Error('Cannot resolve internal data for action. Make sure you are using the result of `declareAction` call as an action');
|
|
@@ -42,7 +41,7 @@ class ActionExecution {
|
|
|
42
41
|
switch (parameters.conditionsFailResult) {
|
|
43
42
|
case 'reject':
|
|
44
43
|
return Promise.reject(new ConditionFailError({
|
|
45
|
-
conditionName:
|
|
44
|
+
conditionName: executionState.forbiddenBy ?? 'unknown',
|
|
46
45
|
targetName: parameters.name,
|
|
47
46
|
}));
|
|
48
47
|
default:
|
|
@@ -60,7 +59,7 @@ class ActionExecution {
|
|
|
60
59
|
executionState.status = 'pending';
|
|
61
60
|
return this.executionContextManager.withContext(executionContext, {
|
|
62
61
|
name: parameters.name,
|
|
63
|
-
values:
|
|
62
|
+
values: executionContext?.values.pageActions === true ? { pageActions: false } : undefined,
|
|
64
63
|
}, (executionActionContext, abortController) => {
|
|
65
64
|
const context = this.createActionContext(executionContext, executionActionContext, abortController, parameters);
|
|
66
65
|
return Promise.resolve()
|
|
@@ -129,10 +128,10 @@ class ActionExecution {
|
|
|
129
128
|
createActionContext(parentExecutionContext, actionExecutionContext, abortController, parameters) {
|
|
130
129
|
return {
|
|
131
130
|
abortController,
|
|
132
|
-
abortSignal: actionExecutionContext
|
|
131
|
+
abortSignal: actionExecutionContext?.abortSignal,
|
|
133
132
|
executeAction: this.runInContext.bind(this, actionExecutionContext),
|
|
134
133
|
deps: parameters.deps ? this.di.getOfDeps(parameters.deps) : EMPTY_DEPS,
|
|
135
|
-
actionType:
|
|
134
|
+
actionType: parentExecutionContext?.values.pageActions ? 'page' : 'standalone',
|
|
136
135
|
dispatch: this.store.dispatch,
|
|
137
136
|
getState: this.store.getState,
|
|
138
137
|
};
|
|
@@ -24,7 +24,7 @@ const EMPTY_DEPS = {};
|
|
|
24
24
|
const getParameters = (action) => action[core.ACTION_PARAMETERS];
|
|
25
25
|
class ActionExecution {
|
|
26
26
|
constructor({ store, context, deferredActionsMap, di, executionContextManager, actionConditionals, transformAction, }) {
|
|
27
|
-
this.actionConditionals = flatten__default["default"](actionConditionals
|
|
27
|
+
this.actionConditionals = flatten__default["default"](actionConditionals ?? []);
|
|
28
28
|
this.context = context;
|
|
29
29
|
this.store = store;
|
|
30
30
|
this.deferredActionsMap = deferredActionsMap;
|
|
@@ -40,10 +40,9 @@ class ActionExecution {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
async runInContext(executionContext, action, ...params) {
|
|
43
|
-
var _a;
|
|
44
43
|
const payload = params[0];
|
|
45
44
|
// TODO: replace type with pure context usage
|
|
46
|
-
const type =
|
|
45
|
+
const type = executionContext?.values.pageActions === true ? constants.actionType.global : constants.actionType.local;
|
|
47
46
|
const parameters = this.getActionParameters(action);
|
|
48
47
|
if (!parameters) {
|
|
49
48
|
throw new Error('Cannot resolve internal data for action. Make sure you are using the result of `declareAction` call as an action');
|
|
@@ -53,7 +52,7 @@ class ActionExecution {
|
|
|
53
52
|
switch (parameters.conditionsFailResult) {
|
|
54
53
|
case 'reject':
|
|
55
54
|
return Promise.reject(new errors.ConditionFailError({
|
|
56
|
-
conditionName:
|
|
55
|
+
conditionName: executionState.forbiddenBy ?? 'unknown',
|
|
57
56
|
targetName: parameters.name,
|
|
58
57
|
}));
|
|
59
58
|
default:
|
|
@@ -71,7 +70,7 @@ class ActionExecution {
|
|
|
71
70
|
executionState.status = 'pending';
|
|
72
71
|
return this.executionContextManager.withContext(executionContext, {
|
|
73
72
|
name: parameters.name,
|
|
74
|
-
values:
|
|
73
|
+
values: executionContext?.values.pageActions === true ? { pageActions: false } : undefined,
|
|
75
74
|
}, (executionActionContext, abortController) => {
|
|
76
75
|
const context = this.createActionContext(executionContext, executionActionContext, abortController, parameters);
|
|
77
76
|
return Promise.resolve()
|
|
@@ -140,10 +139,10 @@ class ActionExecution {
|
|
|
140
139
|
createActionContext(parentExecutionContext, actionExecutionContext, abortController, parameters) {
|
|
141
140
|
return {
|
|
142
141
|
abortController,
|
|
143
|
-
abortSignal: actionExecutionContext
|
|
142
|
+
abortSignal: actionExecutionContext?.abortSignal,
|
|
144
143
|
executeAction: this.runInContext.bind(this, actionExecutionContext),
|
|
145
144
|
deps: parameters.deps ? this.di.getOfDeps(parameters.deps) : EMPTY_DEPS,
|
|
146
|
-
actionType:
|
|
145
|
+
actionType: parentExecutionContext?.values.pageActions ? 'page' : 'standalone',
|
|
147
146
|
dispatch: this.store.dispatch,
|
|
148
147
|
getState: this.store.getState,
|
|
149
148
|
};
|
|
@@ -6,6 +6,7 @@ class ActionPageRunner {
|
|
|
6
6
|
constructor(deps) {
|
|
7
7
|
this.deps = deps;
|
|
8
8
|
this.log = deps.logger('action:action-page-runner');
|
|
9
|
+
this.isChildAppRunner = deps.isChildAppRunner ?? false;
|
|
9
10
|
}
|
|
10
11
|
runActions(actions, stopRunAtError = () => false) {
|
|
11
12
|
return this.deps.executionContextManager.withContext(this.deps.commandLineExecutionContext(), { name: 'pageActions', values: { pageActions: true } }, async (executionContext, abortController) => {
|
|
@@ -21,16 +22,20 @@ class ActionPageRunner {
|
|
|
21
22
|
return promise;
|
|
22
23
|
})
|
|
23
24
|
.catch((error) => {
|
|
24
|
-
var _a;
|
|
25
25
|
if (!isSilentError(error)) {
|
|
26
26
|
const parameters = isTramvaiAction(action) ? action : action[ACTION_PARAMETERS];
|
|
27
27
|
this.log.error({
|
|
28
28
|
error,
|
|
29
29
|
event: `action-execution-error`,
|
|
30
|
-
message: `An error occurred during "${
|
|
30
|
+
message: `An error occurred during "${parameters?.name ?? 'unknown'}" action execution`,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
if (stopRunAtError(error)) {
|
|
34
|
+
if (process.env.NODE_ENV === 'development') {
|
|
35
|
+
if (this.isChildAppRunner) {
|
|
36
|
+
console.error(`Throwing error ${error.errorName} is not supported in Child Apps, host application command line will not be aborted!`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
34
39
|
throw error;
|
|
35
40
|
}
|
|
36
41
|
});
|
|
@@ -6,12 +6,14 @@ import type { ActionExecution } from './actionExecution';
|
|
|
6
6
|
export declare class ActionPageRunner {
|
|
7
7
|
private deps;
|
|
8
8
|
log: ReturnType<ExtractDependencyType<typeof LOGGER_TOKEN>>;
|
|
9
|
+
private isChildAppRunner;
|
|
9
10
|
constructor(deps: {
|
|
10
11
|
actionExecution: ActionExecution;
|
|
11
12
|
executionContextManager: ExtractDependencyType<typeof EXECUTION_CONTEXT_MANAGER_TOKEN>;
|
|
12
13
|
commandLineExecutionContext: ExtractDependencyType<typeof COMMAND_LINE_EXECUTION_CONTEXT_TOKEN>;
|
|
13
14
|
logger: ExtractDependencyType<typeof LOGGER_TOKEN>;
|
|
14
15
|
router: ExtractDependencyType<typeof ROUTER_TOKEN>;
|
|
16
|
+
isChildAppRunner: boolean | null;
|
|
15
17
|
});
|
|
16
18
|
runActions(actions: Array<Action | TramvaiAction<any[], any, any>>, stopRunAtError?: (error: Error) => boolean): Promise<void>;
|
|
17
19
|
}
|
|
@@ -12,6 +12,7 @@ export declare class ActionPageRunner implements ActionPageRunnerInterface {
|
|
|
12
12
|
private deferredMap;
|
|
13
13
|
private responseTaskManager;
|
|
14
14
|
private serverResponseStream;
|
|
15
|
+
private isChildAppRunner;
|
|
15
16
|
constructor(deps: {
|
|
16
17
|
store: ExtractDependencyType<typeof STORE_TOKEN>;
|
|
17
18
|
actionExecution: ExtractDependencyType<typeof ACTION_EXECUTION_TOKEN>;
|
|
@@ -22,6 +23,7 @@ export declare class ActionPageRunner implements ActionPageRunnerInterface {
|
|
|
22
23
|
deferredMap: ExtractDependencyType<typeof DEFERRED_ACTIONS_MAP_TOKEN>;
|
|
23
24
|
responseTaskManager: ExtractDependencyType<typeof SERVER_RESPONSE_TASK_MANAGER> | null;
|
|
24
25
|
serverResponseStream: ExtractDependencyType<typeof SERVER_RESPONSE_STREAM> | null;
|
|
26
|
+
isChildAppRunner: boolean | null;
|
|
25
27
|
});
|
|
26
28
|
runActions(actions: Array<Action | TramvaiAction<any[], any, any>>, stopRunAtError?: (error: Error) => boolean): Promise<void>;
|
|
27
29
|
private syncStateActions;
|
|
@@ -11,6 +11,7 @@ class ActionPageRunner {
|
|
|
11
11
|
this.deferredMap = deps.deferredMap;
|
|
12
12
|
this.responseTaskManager = deps.responseTaskManager;
|
|
13
13
|
this.serverResponseStream = deps.serverResponseStream;
|
|
14
|
+
this.isChildAppRunner = deps.isChildAppRunner ?? false;
|
|
14
15
|
}
|
|
15
16
|
// TODO stopRunAtError нужен только для редиректов на стороне сервера в экшенах. И нужно пересмотреть реализацию редиректов
|
|
16
17
|
runActions(actions, stopRunAtError = () => false) {
|
|
@@ -50,10 +51,9 @@ You can find more detailed information from "action-execution-error" logs, and f
|
|
|
50
51
|
const isDeferredAction = ACTION_PARAMETERS in action && action[ACTION_PARAMETERS].deferred;
|
|
51
52
|
return Promise.resolve()
|
|
52
53
|
.then(() => {
|
|
53
|
-
var _a;
|
|
54
54
|
const promise = this.deps.actionExecution.runInContext(executionContext, action, DEFAULT_PAYLOAD);
|
|
55
55
|
if (isDeferredAction) {
|
|
56
|
-
|
|
56
|
+
this.responseTaskManager?.push(async () => {
|
|
57
57
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
58
58
|
const deferred = this.deferredMap.get(action.name);
|
|
59
59
|
// scripts will already be present on the page HTML
|
|
@@ -81,10 +81,9 @@ You can find more detailed information from "action-execution-error" logs, and f
|
|
|
81
81
|
return promise;
|
|
82
82
|
})
|
|
83
83
|
.then((payload) => {
|
|
84
|
-
var _a;
|
|
85
84
|
if (executionContext.abortSignal.aborted) {
|
|
86
85
|
const parameters = isTramvaiAction(action) ? action : action[ACTION_PARAMETERS];
|
|
87
|
-
const actionName =
|
|
86
|
+
const actionName = parameters?.name ?? 'unknown';
|
|
88
87
|
const contextName = `${executionContext.name}.${actionName}`;
|
|
89
88
|
this.log.warn({
|
|
90
89
|
error: new ExecutionAbortError({
|
|
@@ -101,14 +100,18 @@ Also, the necessary network accesses may not be present.`,
|
|
|
101
100
|
return payload;
|
|
102
101
|
})
|
|
103
102
|
.catch((error) => {
|
|
104
|
-
var _a;
|
|
105
103
|
const isCriticalError = stopRunAtError(error);
|
|
104
|
+
if (process.env.NODE_ENV === 'development') {
|
|
105
|
+
if (isCriticalError && this.isChildAppRunner) {
|
|
106
|
+
console.error(`Throwing error ${error.errorName} is not supported in Child Apps, host application command line will not be aborted!`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
106
109
|
if (!isSilentError(error)) {
|
|
107
110
|
const parameters = isTramvaiAction(action) ? action : action[ACTION_PARAMETERS];
|
|
108
111
|
this.log.warn({
|
|
109
112
|
error,
|
|
110
113
|
event: `action-execution-error`,
|
|
111
|
-
message: `${
|
|
114
|
+
message: `${parameters?.name ?? 'unknown'} execution error, ${isCriticalError
|
|
112
115
|
? `${error.name} error are expected and will stop actions execution and prevent page rendering`
|
|
113
116
|
: `this action will be automatically executed on client - https://tramvai.dev/docs/features/data-fetching/action#synchronizing-between-server-and-client
|
|
114
117
|
If the request in this action takes too long, you can move it to the client using "onlyBrowser" condition or use Deferred Actions.
|
|
@@ -15,6 +15,7 @@ class ActionPageRunner {
|
|
|
15
15
|
this.deferredMap = deps.deferredMap;
|
|
16
16
|
this.responseTaskManager = deps.responseTaskManager;
|
|
17
17
|
this.serverResponseStream = deps.serverResponseStream;
|
|
18
|
+
this.isChildAppRunner = deps.isChildAppRunner ?? false;
|
|
18
19
|
}
|
|
19
20
|
// TODO stopRunAtError нужен только для редиректов на стороне сервера в экшенах. И нужно пересмотреть реализацию редиректов
|
|
20
21
|
runActions(actions, stopRunAtError = () => false) {
|
|
@@ -54,10 +55,9 @@ You can find more detailed information from "action-execution-error" logs, and f
|
|
|
54
55
|
const isDeferredAction = core.ACTION_PARAMETERS in action && action[core.ACTION_PARAMETERS].deferred;
|
|
55
56
|
return Promise.resolve()
|
|
56
57
|
.then(() => {
|
|
57
|
-
var _a;
|
|
58
58
|
const promise = this.deps.actionExecution.runInContext(executionContext, action, DEFAULT_PAYLOAD);
|
|
59
59
|
if (isDeferredAction) {
|
|
60
|
-
|
|
60
|
+
this.responseTaskManager?.push(async () => {
|
|
61
61
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
62
62
|
const deferred = this.deferredMap.get(action.name);
|
|
63
63
|
// scripts will already be present on the page HTML
|
|
@@ -85,10 +85,9 @@ You can find more detailed information from "action-execution-error" logs, and f
|
|
|
85
85
|
return promise;
|
|
86
86
|
})
|
|
87
87
|
.then((payload) => {
|
|
88
|
-
var _a;
|
|
89
88
|
if (executionContext.abortSignal.aborted) {
|
|
90
89
|
const parameters = core.isTramvaiAction(action) ? action : action[core.ACTION_PARAMETERS];
|
|
91
|
-
const actionName =
|
|
90
|
+
const actionName = parameters?.name ?? 'unknown';
|
|
92
91
|
const contextName = `${executionContext.name}.${actionName}`;
|
|
93
92
|
this.log.warn({
|
|
94
93
|
error: new errors.ExecutionAbortError({
|
|
@@ -105,14 +104,18 @@ Also, the necessary network accesses may not be present.`,
|
|
|
105
104
|
return payload;
|
|
106
105
|
})
|
|
107
106
|
.catch((error) => {
|
|
108
|
-
var _a;
|
|
109
107
|
const isCriticalError = stopRunAtError(error);
|
|
108
|
+
if (process.env.NODE_ENV === 'development') {
|
|
109
|
+
if (isCriticalError && this.isChildAppRunner) {
|
|
110
|
+
console.error(`Throwing error ${error.errorName} is not supported in Child Apps, host application command line will not be aborted!`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
110
113
|
if (!errors.isSilentError(error)) {
|
|
111
114
|
const parameters = core.isTramvaiAction(action) ? action : action[core.ACTION_PARAMETERS];
|
|
112
115
|
this.log.warn({
|
|
113
116
|
error,
|
|
114
117
|
event: `action-execution-error`,
|
|
115
|
-
message: `${
|
|
118
|
+
message: `${parameters?.name ?? 'unknown'} execution error, ${isCriticalError
|
|
116
119
|
? `${error.name} error are expected and will stop actions execution and prevent page rendering`
|
|
117
120
|
: `this action will be automatically executed on client - https://tramvai.dev/docs/features/data-fetching/action#synchronizing-between-server-and-client
|
|
118
121
|
If the request in this action takes too long, you can move it to the client using "onlyBrowser" condition or use Deferred Actions.
|
|
@@ -46,7 +46,7 @@ function cacheFactory(cacheType = MEMORY_LRU, options) {
|
|
|
46
46
|
function getCacheFactory({ cacheNames, metrics, }) {
|
|
47
47
|
return function (cacheType, options) {
|
|
48
48
|
const cache = cacheFactory(cacheType, options);
|
|
49
|
-
if (!
|
|
49
|
+
if (!options?.name || cacheNames === null) {
|
|
50
50
|
return cache;
|
|
51
51
|
}
|
|
52
52
|
if (cacheNames.has(options.name)) {
|
|
@@ -55,7 +55,7 @@ function cacheFactory(cacheType$1 = tokensCommon.MEMORY_LRU, options) {
|
|
|
55
55
|
function getCacheFactory({ cacheNames, metrics, }) {
|
|
56
56
|
return function (cacheType, options) {
|
|
57
57
|
const cache = cacheFactory(cacheType, options);
|
|
58
|
-
if (!
|
|
58
|
+
if (!options?.name || cacheNames === null) {
|
|
59
59
|
return cache;
|
|
60
60
|
}
|
|
61
61
|
if (cacheNames.has(options.name)) {
|
|
@@ -29,16 +29,16 @@ const cacheMetricsServerFactory = ({ metrics, }) => {
|
|
|
29
29
|
: undefined;
|
|
30
30
|
return {
|
|
31
31
|
onHit(name, method) {
|
|
32
|
-
cacheMetrics
|
|
32
|
+
cacheMetrics?.hitCounter.inc({ name, method });
|
|
33
33
|
},
|
|
34
34
|
onMiss(name, method) {
|
|
35
|
-
cacheMetrics
|
|
35
|
+
cacheMetrics?.missCounter.inc({ name, method });
|
|
36
36
|
},
|
|
37
37
|
onMax(name, size) {
|
|
38
|
-
cacheMetrics
|
|
38
|
+
cacheMetrics?.cacheMaxGauge.set({ name }, size);
|
|
39
39
|
},
|
|
40
40
|
onSize(name, size) {
|
|
41
|
-
cacheMetrics
|
|
41
|
+
cacheMetrics?.cacheSizeGauge.set({ name }, size);
|
|
42
42
|
},
|
|
43
43
|
};
|
|
44
44
|
};
|
|
@@ -33,16 +33,16 @@ const cacheMetricsServerFactory = ({ metrics, }) => {
|
|
|
33
33
|
: undefined;
|
|
34
34
|
return {
|
|
35
35
|
onHit(name, method) {
|
|
36
|
-
cacheMetrics
|
|
36
|
+
cacheMetrics?.hitCounter.inc({ name, method });
|
|
37
37
|
},
|
|
38
38
|
onMiss(name, method) {
|
|
39
|
-
cacheMetrics
|
|
39
|
+
cacheMetrics?.missCounter.inc({ name, method });
|
|
40
40
|
},
|
|
41
41
|
onMax(name, size) {
|
|
42
|
-
cacheMetrics
|
|
42
|
+
cacheMetrics?.cacheMaxGauge.set({ name }, size);
|
|
43
43
|
},
|
|
44
44
|
onSize(name, size) {
|
|
45
|
-
cacheMetrics
|
|
45
|
+
cacheMetrics?.cacheSizeGauge.set({ name }, size);
|
|
46
46
|
},
|
|
47
47
|
};
|
|
48
48
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
class CacheWithMetricsProxy {
|
|
2
2
|
constructor(cache, options, metrics) {
|
|
3
|
-
var _a;
|
|
4
3
|
this.cache = cache;
|
|
5
4
|
this.options = options;
|
|
6
5
|
this.metrics = metrics;
|
|
@@ -8,27 +7,25 @@ class CacheWithMetricsProxy {
|
|
|
8
7
|
this.options.name &&
|
|
9
8
|
'max' in this.options &&
|
|
10
9
|
typeof this.options.max === 'number') {
|
|
11
|
-
|
|
10
|
+
this.metrics?.onMax(this.options.name, this.options.max);
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
handleAccess(_key, value, method) {
|
|
15
|
-
|
|
16
|
-
if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
14
|
+
if (!this.options?.name) {
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
19
17
|
if (value) {
|
|
20
|
-
|
|
18
|
+
this.metrics?.onHit(this.options.name, method);
|
|
21
19
|
}
|
|
22
20
|
else {
|
|
23
|
-
|
|
21
|
+
this.metrics?.onMiss(this.options.name, method);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
syncSize() {
|
|
27
|
-
|
|
28
|
-
if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
25
|
+
if (!this.options?.name) {
|
|
29
26
|
return;
|
|
30
27
|
}
|
|
31
|
-
|
|
28
|
+
this.metrics?.onSize(this.options.name, this.cache.size);
|
|
32
29
|
}
|
|
33
30
|
get(key) {
|
|
34
31
|
const value = this.cache.get(key);
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
class CacheWithMetricsProxy {
|
|
6
6
|
constructor(cache, options, metrics) {
|
|
7
|
-
var _a;
|
|
8
7
|
this.cache = cache;
|
|
9
8
|
this.options = options;
|
|
10
9
|
this.metrics = metrics;
|
|
@@ -12,27 +11,25 @@ class CacheWithMetricsProxy {
|
|
|
12
11
|
this.options.name &&
|
|
13
12
|
'max' in this.options &&
|
|
14
13
|
typeof this.options.max === 'number') {
|
|
15
|
-
|
|
14
|
+
this.metrics?.onMax(this.options.name, this.options.max);
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
handleAccess(_key, value, method) {
|
|
19
|
-
|
|
20
|
-
if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
18
|
+
if (!this.options?.name) {
|
|
21
19
|
return;
|
|
22
20
|
}
|
|
23
21
|
if (value) {
|
|
24
|
-
|
|
22
|
+
this.metrics?.onHit(this.options.name, method);
|
|
25
23
|
}
|
|
26
24
|
else {
|
|
27
|
-
|
|
25
|
+
this.metrics?.onMiss(this.options.name, method);
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
syncSize() {
|
|
31
|
-
|
|
32
|
-
if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
29
|
+
if (!this.options?.name) {
|
|
33
30
|
return;
|
|
34
31
|
}
|
|
35
|
-
|
|
32
|
+
this.metrics?.onSize(this.options.name, this.cache.size);
|
|
36
33
|
}
|
|
37
34
|
get(key) {
|
|
38
35
|
const value = this.cache.get(key);
|
|
@@ -14,7 +14,7 @@ class CommandLineRunner {
|
|
|
14
14
|
this.executionEndHandlers = executionEndHandlers;
|
|
15
15
|
}
|
|
16
16
|
run(type, status, providers, customDi, key) {
|
|
17
|
-
const di = customDi
|
|
17
|
+
const di = customDi ?? this.resolveDi(type, status, this.rootDi, providers);
|
|
18
18
|
const rootExecutionContext = di.get({ token: ROOT_EXECUTION_CONTEXT_TOKEN, optional: true });
|
|
19
19
|
this.log.debug({
|
|
20
20
|
event: 'command-run',
|
|
@@ -67,8 +67,7 @@ class CommandLineRunner {
|
|
|
67
67
|
return di;
|
|
68
68
|
}
|
|
69
69
|
resolveExecutionContextFromDi(di) {
|
|
70
|
-
|
|
71
|
-
return (_a = this.executionContextByDi.get(di)) !== null && _a !== void 0 ? _a : null;
|
|
70
|
+
return this.executionContextByDi.get(di) ?? null;
|
|
72
71
|
}
|
|
73
72
|
createLineChain(di, line) {
|
|
74
73
|
let lineInstance;
|
|
@@ -122,7 +121,6 @@ class CommandLineRunner {
|
|
|
122
121
|
return Promise.resolve()
|
|
123
122
|
.then(() => instance())
|
|
124
123
|
.catch((err) => {
|
|
125
|
-
var _a;
|
|
126
124
|
this.log[isSilentError(err) ? 'debug' : 'error']({
|
|
127
125
|
event: 'line-error',
|
|
128
126
|
error: err,
|
|
@@ -130,7 +128,7 @@ class CommandLineRunner {
|
|
|
130
128
|
command: name,
|
|
131
129
|
});
|
|
132
130
|
// in case if any error happens during line execution results from other line handlers will not be used anyway
|
|
133
|
-
|
|
131
|
+
this.abortControllerByDi.get(di)?.abort();
|
|
134
132
|
this.throwError(err, di);
|
|
135
133
|
});
|
|
136
134
|
}
|
|
@@ -14,7 +14,7 @@ class CommandLineRunner {
|
|
|
14
14
|
this.executionEndHandlers = executionEndHandlers;
|
|
15
15
|
}
|
|
16
16
|
run(type, status, providers, customDi, key) {
|
|
17
|
-
const di = customDi
|
|
17
|
+
const di = customDi ?? this.resolveDi(type, status, this.rootDi, providers);
|
|
18
18
|
const rootExecutionContext = di.get({ token: ROOT_EXECUTION_CONTEXT_TOKEN, optional: true });
|
|
19
19
|
this.log.debug({
|
|
20
20
|
event: 'command-run',
|
|
@@ -67,8 +67,7 @@ class CommandLineRunner {
|
|
|
67
67
|
return di;
|
|
68
68
|
}
|
|
69
69
|
resolveExecutionContextFromDi(di) {
|
|
70
|
-
|
|
71
|
-
return (_a = this.executionContextByDi.get(di)) !== null && _a !== void 0 ? _a : null;
|
|
70
|
+
return this.executionContextByDi.get(di) ?? null;
|
|
72
71
|
}
|
|
73
72
|
createLineChain(di, line) {
|
|
74
73
|
let lineInstance;
|
|
@@ -122,7 +121,6 @@ class CommandLineRunner {
|
|
|
122
121
|
return Promise.resolve()
|
|
123
122
|
.then(() => instance())
|
|
124
123
|
.catch((err) => {
|
|
125
|
-
var _a;
|
|
126
124
|
this.log[isSilentError(err) ? 'debug' : 'error']({
|
|
127
125
|
event: 'line-error',
|
|
128
126
|
error: err,
|
|
@@ -130,7 +128,7 @@ class CommandLineRunner {
|
|
|
130
128
|
command: name,
|
|
131
129
|
});
|
|
132
130
|
// in case if any error happens during line execution results from other line handlers will not be used anyway
|
|
133
|
-
|
|
131
|
+
this.abortControllerByDi.get(di)?.abort();
|
|
134
132
|
this.throwError(err, di);
|
|
135
133
|
});
|
|
136
134
|
}
|
|
@@ -18,7 +18,7 @@ class CommandLineRunner {
|
|
|
18
18
|
this.executionEndHandlers = executionEndHandlers;
|
|
19
19
|
}
|
|
20
20
|
run(type, status, providers, customDi, key) {
|
|
21
|
-
const di = customDi
|
|
21
|
+
const di = customDi ?? this.resolveDi(type, status, this.rootDi, providers);
|
|
22
22
|
const rootExecutionContext = di.get({ token: tokensCommon.ROOT_EXECUTION_CONTEXT_TOKEN, optional: true });
|
|
23
23
|
this.log.debug({
|
|
24
24
|
event: 'command-run',
|
|
@@ -71,8 +71,7 @@ class CommandLineRunner {
|
|
|
71
71
|
return di;
|
|
72
72
|
}
|
|
73
73
|
resolveExecutionContextFromDi(di) {
|
|
74
|
-
|
|
75
|
-
return (_a = this.executionContextByDi.get(di)) !== null && _a !== void 0 ? _a : null;
|
|
74
|
+
return this.executionContextByDi.get(di) ?? null;
|
|
76
75
|
}
|
|
77
76
|
createLineChain(di, line) {
|
|
78
77
|
let lineInstance;
|
|
@@ -126,7 +125,6 @@ class CommandLineRunner {
|
|
|
126
125
|
return Promise.resolve()
|
|
127
126
|
.then(() => instance())
|
|
128
127
|
.catch((err) => {
|
|
129
|
-
var _a;
|
|
130
128
|
this.log[errors.isSilentError(err) ? 'debug' : 'error']({
|
|
131
129
|
event: 'line-error',
|
|
132
130
|
error: err,
|
|
@@ -134,7 +132,7 @@ class CommandLineRunner {
|
|
|
134
132
|
command: name,
|
|
135
133
|
});
|
|
136
134
|
// in case if any error happens during line execution results from other line handlers will not be used anyway
|
|
137
|
-
|
|
135
|
+
this.abortControllerByDi.get(di)?.abort();
|
|
138
136
|
this.throwError(err, di);
|
|
139
137
|
});
|
|
140
138
|
}
|
|
@@ -5,7 +5,7 @@ const DEFAULT_GROUP = '__default';
|
|
|
5
5
|
class ComponentRegistry {
|
|
6
6
|
constructor({ componentList } = {}) {
|
|
7
7
|
this.components = {
|
|
8
|
-
[DEFAULT_GROUP]: Object.assign({}, ...flatten(componentList
|
|
8
|
+
[DEFAULT_GROUP]: Object.assign({}, ...flatten(componentList ?? [])),
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
add(name, component, group = DEFAULT_GROUP) {
|
|
@@ -5,7 +5,7 @@ const DEFAULT_GROUP = '__default';
|
|
|
5
5
|
class ComponentRegistry {
|
|
6
6
|
constructor({ componentList } = {}) {
|
|
7
7
|
this.components = {
|
|
8
|
-
[DEFAULT_GROUP]: Object.assign({}, ...flatten(componentList
|
|
8
|
+
[DEFAULT_GROUP]: Object.assign({}, ...flatten(componentList ?? [])),
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
add(name, component, group = DEFAULT_GROUP) {
|
|
@@ -14,7 +14,7 @@ const DEFAULT_GROUP = '__default';
|
|
|
14
14
|
class ComponentRegistry {
|
|
15
15
|
constructor({ componentList } = {}) {
|
|
16
16
|
this.components = {
|
|
17
|
-
[DEFAULT_GROUP]: Object.assign({}, ...flatten__default["default"](componentList
|
|
17
|
+
[DEFAULT_GROUP]: Object.assign({}, ...flatten__default["default"](componentList ?? [])),
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
add(name, component, group = DEFAULT_GROUP) {
|
|
@@ -10,7 +10,7 @@ class ExecutionContextManager {
|
|
|
10
10
|
const options = normalizeOptions(nameOrOptions);
|
|
11
11
|
const { name, values: selfValues = EMPTY_VALUES } = options;
|
|
12
12
|
const contextName = parentContext ? `${parentContext.name}.${name}` : name;
|
|
13
|
-
if (parentContext
|
|
13
|
+
if (parentContext?.abortSignal.aborted) {
|
|
14
14
|
throw new ExecutionAbortError({
|
|
15
15
|
message: `Execution aborted in context "${contextName}"`,
|
|
16
16
|
reason: parentContext.abortSignal.reason,
|
|
@@ -10,7 +10,7 @@ class ExecutionContextManager {
|
|
|
10
10
|
const options = normalizeOptions(nameOrOptions);
|
|
11
11
|
const { name, values: selfValues = EMPTY_VALUES } = options;
|
|
12
12
|
const contextName = parentContext ? `${parentContext.name}.${name}` : name;
|
|
13
|
-
if (parentContext
|
|
13
|
+
if (parentContext?.abortSignal.aborted) {
|
|
14
14
|
throw new ExecutionAbortError({
|
|
15
15
|
message: `Execution aborted in context "${contextName}"`,
|
|
16
16
|
reason: parentContext.abortSignal.reason,
|
|
@@ -14,7 +14,7 @@ class ExecutionContextManager {
|
|
|
14
14
|
const options = normalizeOptions(nameOrOptions);
|
|
15
15
|
const { name, values: selfValues = EMPTY_VALUES } = options;
|
|
16
16
|
const contextName = parentContext ? `${parentContext.name}.${name}` : name;
|
|
17
|
-
if (parentContext
|
|
17
|
+
if (parentContext?.abortSignal.aborted) {
|
|
18
18
|
throw new errors.ExecutionAbortError({
|
|
19
19
|
message: `Execution aborted in context "${contextName}"`,
|
|
20
20
|
reason: parentContext.abortSignal.reason,
|
|
@@ -6,10 +6,9 @@ const providers = [
|
|
|
6
6
|
provide: INITIAL_APP_STATE_TOKEN,
|
|
7
7
|
scope: Scope.REQUEST,
|
|
8
8
|
useFactory: () => {
|
|
9
|
-
var _a;
|
|
10
9
|
let initialState;
|
|
11
10
|
try {
|
|
12
|
-
initialState =
|
|
11
|
+
initialState = document.getElementById('__TRAMVAI_STATE__')?.textContent;
|
|
13
12
|
if (!initialState) {
|
|
14
13
|
throw Error('__TRAMVAI_STATE__ element is empty or missing');
|
|
15
14
|
}
|
|
@@ -96,8 +96,7 @@ function detectDiScopesCollisions({ di, logger, }) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
function walkOverDepsRecords(rootRecord, callback) {
|
|
99
|
-
|
|
100
|
-
const resolvedDepsList = Object.values((_a = rootRecord.resolvedDeps) !== null && _a !== void 0 ? _a : {});
|
|
99
|
+
const resolvedDepsList = Object.values(rootRecord.resolvedDeps ?? {});
|
|
101
100
|
resolvedDepsList.forEach((token) => {
|
|
102
101
|
const tokenObj = token.token || token;
|
|
103
102
|
const tokenName = typeof tokenObj === 'string' ? Symbol.for(tokenObj) : tokenObj.name;
|
|
@@ -118,17 +117,16 @@ function detectDiScopesCollisions({ di, logger, }) {
|
|
|
118
117
|
}
|
|
119
118
|
});
|
|
120
119
|
collisions.forEach((records, key) => {
|
|
121
|
-
var _a, _b, _c, _d, _e;
|
|
122
120
|
const recordsArr = Array.from(records.values());
|
|
123
|
-
const { record, paths } =
|
|
121
|
+
const { record, paths } = recordsArr[0] ?? {};
|
|
124
122
|
let message = `\nIncorrect usage of "${key}" - token has Request scope, but requested in Singleton scoped provider.
|
|
125
123
|
Requested dependency path: \n ${paths.map((path) => path.name).join(' -> ')}\n`;
|
|
126
124
|
if (record.stack) {
|
|
127
|
-
message += `Request token stack trace: \n ${
|
|
125
|
+
message += `Request token stack trace: \n ${record.stack.split('\n')[1]?.trim() ?? 'unknown'}`;
|
|
128
126
|
}
|
|
129
127
|
const root = paths[0];
|
|
130
128
|
if (root.record.stack) {
|
|
131
|
-
message += `\nSingleton token stack trace: \n ${
|
|
129
|
+
message += `\nSingleton token stack trace: \n ${root.record.stack.split('\n')[1]?.trim() ?? 'unknown'}`;
|
|
132
130
|
}
|
|
133
131
|
log.error(message);
|
|
134
132
|
});
|
|
@@ -100,8 +100,7 @@ function detectDiScopesCollisions({ di, logger, }) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
function walkOverDepsRecords(rootRecord, callback) {
|
|
103
|
-
|
|
104
|
-
const resolvedDepsList = Object.values((_a = rootRecord.resolvedDeps) !== null && _a !== void 0 ? _a : {});
|
|
103
|
+
const resolvedDepsList = Object.values(rootRecord.resolvedDeps ?? {});
|
|
105
104
|
resolvedDepsList.forEach((token) => {
|
|
106
105
|
const tokenObj = token.token || token;
|
|
107
106
|
const tokenName = typeof tokenObj === 'string' ? Symbol.for(tokenObj) : tokenObj.name;
|
|
@@ -122,17 +121,16 @@ function detectDiScopesCollisions({ di, logger, }) {
|
|
|
122
121
|
}
|
|
123
122
|
});
|
|
124
123
|
collisions.forEach((records, key) => {
|
|
125
|
-
var _a, _b, _c, _d, _e;
|
|
126
124
|
const recordsArr = Array.from(records.values());
|
|
127
|
-
const { record, paths } =
|
|
125
|
+
const { record, paths } = recordsArr[0] ?? {};
|
|
128
126
|
let message = `\nIncorrect usage of "${key}" - token has Request scope, but requested in Singleton scoped provider.
|
|
129
127
|
Requested dependency path: \n ${paths.map((path) => path.name).join(' -> ')}\n`;
|
|
130
128
|
if (record.stack) {
|
|
131
|
-
message += `Request token stack trace: \n ${
|
|
129
|
+
message += `Request token stack trace: \n ${record.stack.split('\n')[1]?.trim() ?? 'unknown'}`;
|
|
132
130
|
}
|
|
133
131
|
const root = paths[0];
|
|
134
132
|
if (root.record.stack) {
|
|
135
|
-
message += `\nSingleton token stack trace: \n ${
|
|
133
|
+
message += `\nSingleton token stack trace: \n ${root.record.stack.split('\n')[1]?.trim() ?? 'unknown'}`;
|
|
136
134
|
}
|
|
137
135
|
log.error(message);
|
|
138
136
|
});
|
|
@@ -18,7 +18,7 @@ RequestManagerModule = __decorate([
|
|
|
18
18
|
return {
|
|
19
19
|
...fromServer,
|
|
20
20
|
headers: {
|
|
21
|
-
...fromServer
|
|
21
|
+
...fromServer?.headers,
|
|
22
22
|
'user-agent': navigator.userAgent,
|
|
23
23
|
cookie: document.cookie,
|
|
24
24
|
},
|
|
@@ -31,8 +31,7 @@ class RequestManager {
|
|
|
31
31
|
return this.request.method;
|
|
32
32
|
}
|
|
33
33
|
getHeader(key) {
|
|
34
|
-
|
|
35
|
-
return (_a = this.request.headers) === null || _a === void 0 ? void 0 : _a[key];
|
|
34
|
+
return this.request.headers?.[key];
|
|
36
35
|
}
|
|
37
36
|
getHeaders() {
|
|
38
37
|
return this.request.headers;
|
|
@@ -44,8 +43,7 @@ class RequestManager {
|
|
|
44
43
|
return this.request.cookies;
|
|
45
44
|
}
|
|
46
45
|
getClientIp() {
|
|
47
|
-
|
|
48
|
-
return this.getHeader('x-real-ip') || ((_b = (_a = this.request) === null || _a === void 0 ? void 0 : _a.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress) || '';
|
|
46
|
+
return this.getHeader('x-real-ip') || this.request?.socket?.remoteAddress || '';
|
|
49
47
|
}
|
|
50
48
|
getHost() {
|
|
51
49
|
if (typeof window === 'undefined') {
|
|
@@ -31,8 +31,7 @@ class RequestManager {
|
|
|
31
31
|
return this.request.method;
|
|
32
32
|
}
|
|
33
33
|
getHeader(key) {
|
|
34
|
-
|
|
35
|
-
return (_a = this.request.headers) === null || _a === void 0 ? void 0 : _a[key];
|
|
34
|
+
return this.request.headers?.[key];
|
|
36
35
|
}
|
|
37
36
|
getHeaders() {
|
|
38
37
|
return this.request.headers;
|
|
@@ -44,8 +43,7 @@ class RequestManager {
|
|
|
44
43
|
return this.request.cookies;
|
|
45
44
|
}
|
|
46
45
|
getClientIp() {
|
|
47
|
-
|
|
48
|
-
return this.getHeader('x-real-ip') || ((_b = (_a = this.request) === null || _a === void 0 ? void 0 : _a.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress) || '';
|
|
46
|
+
return this.getHeader('x-real-ip') || this.request?.socket?.remoteAddress || '';
|
|
49
47
|
}
|
|
50
48
|
getHost() {
|
|
51
49
|
if (typeof window === 'undefined') {
|
|
@@ -35,8 +35,7 @@ class RequestManager {
|
|
|
35
35
|
return this.request.method;
|
|
36
36
|
}
|
|
37
37
|
getHeader(key) {
|
|
38
|
-
|
|
39
|
-
return (_a = this.request.headers) === null || _a === void 0 ? void 0 : _a[key];
|
|
38
|
+
return this.request.headers?.[key];
|
|
40
39
|
}
|
|
41
40
|
getHeaders() {
|
|
42
41
|
return this.request.headers;
|
|
@@ -48,8 +47,7 @@ class RequestManager {
|
|
|
48
47
|
return this.request.cookies;
|
|
49
48
|
}
|
|
50
49
|
getClientIp() {
|
|
51
|
-
|
|
52
|
-
return this.getHeader('x-real-ip') || ((_b = (_a = this.request) === null || _a === void 0 ? void 0 : _a.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress) || '';
|
|
50
|
+
return this.getHeader('x-real-ip') || this.request?.socket?.remoteAddress || '';
|
|
53
51
|
}
|
|
54
52
|
getHost() {
|
|
55
53
|
if (typeof window === 'undefined') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-common",
|
|
3
|
-
"version": "5.9
|
|
3
|
+
"version": "5.14.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -36,31 +36,31 @@
|
|
|
36
36
|
"@tinkoff/lru-cache-nano": "^7.9.0",
|
|
37
37
|
"@tinkoff/pubsub": "0.8.2",
|
|
38
38
|
"@tinkoff/url": "0.11.2",
|
|
39
|
-
"@tramvai/experiments": "5.9
|
|
40
|
-
"@tramvai/module-cookie": "5.9
|
|
41
|
-
"@tramvai/module-environment": "5.9
|
|
42
|
-
"@tramvai/module-log": "5.9
|
|
43
|
-
"@tramvai/safe-strings": "0.8.
|
|
44
|
-
"@tramvai/tokens-child-app": "5.9
|
|
45
|
-
"@tramvai/tokens-common": "5.9
|
|
46
|
-
"@tramvai/tokens-core-private": "5.9
|
|
47
|
-
"@tramvai/tokens-metrics": "5.9
|
|
48
|
-
"@tramvai/tokens-render": "5.9
|
|
49
|
-
"@tramvai/tokens-router": "5.9
|
|
50
|
-
"@tramvai/tokens-server-private": "5.9
|
|
51
|
-
"@tramvai/types-actions-state-context": "5.9
|
|
39
|
+
"@tramvai/experiments": "5.14.9",
|
|
40
|
+
"@tramvai/module-cookie": "5.14.9",
|
|
41
|
+
"@tramvai/module-environment": "5.14.9",
|
|
42
|
+
"@tramvai/module-log": "5.14.9",
|
|
43
|
+
"@tramvai/safe-strings": "0.8.4",
|
|
44
|
+
"@tramvai/tokens-child-app": "5.14.9",
|
|
45
|
+
"@tramvai/tokens-common": "5.14.9",
|
|
46
|
+
"@tramvai/tokens-core-private": "5.14.9",
|
|
47
|
+
"@tramvai/tokens-metrics": "5.14.9",
|
|
48
|
+
"@tramvai/tokens-render": "5.14.9",
|
|
49
|
+
"@tramvai/tokens-router": "5.14.9",
|
|
50
|
+
"@tramvai/tokens-server-private": "5.14.9",
|
|
51
|
+
"@tramvai/types-actions-state-context": "5.14.9",
|
|
52
52
|
"hoist-non-react-statics": "^3.3.1",
|
|
53
53
|
"node-abort-controller": "^3.0.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@tinkoff/dippy": "0.11.3",
|
|
57
57
|
"@tinkoff/utils": "^2.1.2",
|
|
58
|
-
"@tramvai/cli": "5.9
|
|
59
|
-
"@tramvai/core": "5.9
|
|
60
|
-
"@tramvai/papi": "5.9
|
|
61
|
-
"@tramvai/react": "5.9
|
|
62
|
-
"@tramvai/state": "5.9
|
|
63
|
-
"@tramvai/tokens-server": "5.9
|
|
58
|
+
"@tramvai/cli": "5.14.9",
|
|
59
|
+
"@tramvai/core": "5.14.9",
|
|
60
|
+
"@tramvai/papi": "5.14.9",
|
|
61
|
+
"@tramvai/react": "5.14.9",
|
|
62
|
+
"@tramvai/state": "5.14.9",
|
|
63
|
+
"@tramvai/tokens-server": "5.14.9",
|
|
64
64
|
"react": ">=16.14.0",
|
|
65
65
|
"tslib": "^2.4.0"
|
|
66
66
|
},
|