@tramvai/module-environment 2.70.1 → 2.72.3
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/browser.js +2 -28
- package/lib/server/EnvironmentManagerServer.es.js +76 -0
- package/lib/server/EnvironmentManagerServer.js +84 -0
- package/lib/server.es.js +2 -101
- package/lib/server.js +4 -104
- package/lib/shared/EnvironmentManager.browser.js +26 -0
- package/lib/shared/EnvironmentManager.es.js +26 -0
- package/lib/shared/EnvironmentManager.js +30 -0
- package/lib/shared/EnvironmentStore.browser.js +5 -0
- package/lib/shared/EnvironmentStore.es.js +5 -0
- package/lib/shared/EnvironmentStore.js +9 -0
- package/package.json +9 -10
package/lib/browser.js
CHANGED
|
@@ -2,34 +2,8 @@ import { __decorate } from 'tslib';
|
|
|
2
2
|
import { Module, Scope } from '@tramvai/core';
|
|
3
3
|
import { ENV_MANAGER_TOKEN, STORE_TOKEN, COMBINE_REDUCERS } from '@tramvai/tokens-common';
|
|
4
4
|
export { ENV_MANAGER_TOKEN, ENV_USED_TOKEN } from '@tramvai/tokens-common';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
class EnvironmentManager {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.parameters = {};
|
|
10
|
-
}
|
|
11
|
-
get(name) {
|
|
12
|
-
return this.parameters[name];
|
|
13
|
-
}
|
|
14
|
-
getInt(name, def) {
|
|
15
|
-
const value = Number(name in this.parameters ? this.parameters[name] : def);
|
|
16
|
-
return Number.isFinite(value) ? value : def;
|
|
17
|
-
}
|
|
18
|
-
getAll() {
|
|
19
|
-
return this.parameters;
|
|
20
|
-
}
|
|
21
|
-
update(result) {
|
|
22
|
-
this.parameters = Object.assign(this.parameters, result);
|
|
23
|
-
}
|
|
24
|
-
clientUsed() {
|
|
25
|
-
return this.getAll();
|
|
26
|
-
}
|
|
27
|
-
updateClientUsed(result) {
|
|
28
|
-
this.update(result);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const EnvironmentStore = createReducer('environment', {});
|
|
5
|
+
import { EnvironmentManager } from './shared/EnvironmentManager.browser.js';
|
|
6
|
+
import { EnvironmentStore } from './shared/EnvironmentStore.browser.js';
|
|
33
7
|
|
|
34
8
|
let EnvironmentModule = class EnvironmentModule {
|
|
35
9
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import noop from '@tinkoff/utils/function/noop';
|
|
2
|
+
import { EnvironmentManager } from '../shared/EnvironmentManager.es.js';
|
|
3
|
+
|
|
4
|
+
const readFileWithEnv = (path) => {
|
|
5
|
+
try {
|
|
6
|
+
const requireFunc =
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
|
|
9
|
+
return requireFunc(path);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
class EnvironmentManagerServer extends EnvironmentManager {
|
|
16
|
+
constructor(tokens) {
|
|
17
|
+
super();
|
|
18
|
+
this.tokens = tokens;
|
|
19
|
+
this.clientUsedList = {};
|
|
20
|
+
this.processing();
|
|
21
|
+
}
|
|
22
|
+
clientUsed() {
|
|
23
|
+
return this.clientUsedList;
|
|
24
|
+
}
|
|
25
|
+
updateClientUsed(result) {
|
|
26
|
+
this.clientUsedList = Object.assign(this.clientUsedList, result);
|
|
27
|
+
}
|
|
28
|
+
// eslint-disable-next-line class-methods-use-this
|
|
29
|
+
getEnvInFiles() {
|
|
30
|
+
if (process.env.NODE_ENV === 'production' &&
|
|
31
|
+
process.env.DANGEROUS_UNSAFE_ENV_FILES !== 'true') {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
const path = require('path');
|
|
35
|
+
return {
|
|
36
|
+
...readFileWithEnv(path.resolve(process.cwd(), 'server', `env.js`)),
|
|
37
|
+
...readFileWithEnv(path.resolve(process.cwd(), `env.development.js`)),
|
|
38
|
+
...readFileWithEnv(path.resolve(process.cwd(), `env.js`)),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
getEnvInApp() {
|
|
42
|
+
const appValue = {};
|
|
43
|
+
this.tokens.forEach((token) => {
|
|
44
|
+
if (token.value !== undefined) {
|
|
45
|
+
appValue[token.key] = token.value;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return appValue;
|
|
49
|
+
}
|
|
50
|
+
collectionEnv() {
|
|
51
|
+
return { ...this.getEnvInApp(), ...this.getEnvInFiles(), ...process.env };
|
|
52
|
+
}
|
|
53
|
+
processing() {
|
|
54
|
+
const result = {};
|
|
55
|
+
const envParameters = this.collectionEnv();
|
|
56
|
+
this.tokens.forEach(({ key, validator = noop, optional, dehydrate }) => {
|
|
57
|
+
const value = envParameters[key];
|
|
58
|
+
if (typeof value === 'undefined' && !optional) {
|
|
59
|
+
throw new Error(`Env parameter ${key} not found. You need add a this env parameter. If you have questions read the docs`);
|
|
60
|
+
}
|
|
61
|
+
// Not calling validation on empty values.
|
|
62
|
+
const validation = typeof value !== 'undefined' && validator(value);
|
|
63
|
+
if (typeof validation === 'string') {
|
|
64
|
+
throw new Error(`Env parameter ${key} with value ${value} not valid, message: ${validation}`);
|
|
65
|
+
}
|
|
66
|
+
result[key] = value;
|
|
67
|
+
if (dehydrate !== false) {
|
|
68
|
+
this.clientUsedList[key] = value;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
process.env = envParameters; // Записываем в process.env итоговый результат. TODO убрать позже
|
|
72
|
+
this.update(result);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { EnvironmentManagerServer };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var noop = require('@tinkoff/utils/function/noop');
|
|
6
|
+
var EnvironmentManager = require('../shared/EnvironmentManager.js');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var noop__default = /*#__PURE__*/_interopDefaultLegacy(noop);
|
|
11
|
+
|
|
12
|
+
const readFileWithEnv = (path) => {
|
|
13
|
+
try {
|
|
14
|
+
const requireFunc =
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
|
|
17
|
+
return requireFunc(path);
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
class EnvironmentManagerServer extends EnvironmentManager.EnvironmentManager {
|
|
24
|
+
constructor(tokens) {
|
|
25
|
+
super();
|
|
26
|
+
this.tokens = tokens;
|
|
27
|
+
this.clientUsedList = {};
|
|
28
|
+
this.processing();
|
|
29
|
+
}
|
|
30
|
+
clientUsed() {
|
|
31
|
+
return this.clientUsedList;
|
|
32
|
+
}
|
|
33
|
+
updateClientUsed(result) {
|
|
34
|
+
this.clientUsedList = Object.assign(this.clientUsedList, result);
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line class-methods-use-this
|
|
37
|
+
getEnvInFiles() {
|
|
38
|
+
if (process.env.NODE_ENV === 'production' &&
|
|
39
|
+
process.env.DANGEROUS_UNSAFE_ENV_FILES !== 'true') {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
const path = require('path');
|
|
43
|
+
return {
|
|
44
|
+
...readFileWithEnv(path.resolve(process.cwd(), 'server', `env.js`)),
|
|
45
|
+
...readFileWithEnv(path.resolve(process.cwd(), `env.development.js`)),
|
|
46
|
+
...readFileWithEnv(path.resolve(process.cwd(), `env.js`)),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
getEnvInApp() {
|
|
50
|
+
const appValue = {};
|
|
51
|
+
this.tokens.forEach((token) => {
|
|
52
|
+
if (token.value !== undefined) {
|
|
53
|
+
appValue[token.key] = token.value;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return appValue;
|
|
57
|
+
}
|
|
58
|
+
collectionEnv() {
|
|
59
|
+
return { ...this.getEnvInApp(), ...this.getEnvInFiles(), ...process.env };
|
|
60
|
+
}
|
|
61
|
+
processing() {
|
|
62
|
+
const result = {};
|
|
63
|
+
const envParameters = this.collectionEnv();
|
|
64
|
+
this.tokens.forEach(({ key, validator = noop__default["default"], optional, dehydrate }) => {
|
|
65
|
+
const value = envParameters[key];
|
|
66
|
+
if (typeof value === 'undefined' && !optional) {
|
|
67
|
+
throw new Error(`Env parameter ${key} not found. You need add a this env parameter. If you have questions read the docs`);
|
|
68
|
+
}
|
|
69
|
+
// Not calling validation on empty values.
|
|
70
|
+
const validation = typeof value !== 'undefined' && validator(value);
|
|
71
|
+
if (typeof validation === 'string') {
|
|
72
|
+
throw new Error(`Env parameter ${key} with value ${value} not valid, message: ${validation}`);
|
|
73
|
+
}
|
|
74
|
+
result[key] = value;
|
|
75
|
+
if (dehydrate !== false) {
|
|
76
|
+
this.clientUsedList[key] = value;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
process.env = envParameters; // Записываем в process.env итоговый результат. TODO убрать позже
|
|
80
|
+
this.update(result);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
exports.EnvironmentManagerServer = EnvironmentManagerServer;
|
package/lib/server.es.js
CHANGED
|
@@ -5,107 +5,8 @@ import { ENV_MANAGER_TOKEN, ENV_USED_TOKEN, COMBINE_REDUCERS, CONTEXT_TOKEN } fr
|
|
|
5
5
|
export { ENV_MANAGER_TOKEN, ENV_USED_TOKEN } from '@tramvai/tokens-common';
|
|
6
6
|
import { SERVER_MODULE_PAPI_PUBLIC_ROUTE } from '@tramvai/tokens-server';
|
|
7
7
|
import { createPapiMethod } from '@tramvai/papi';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
const EnvironmentStore = createReducer('environment', {});
|
|
12
|
-
|
|
13
|
-
class EnvironmentManager {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.parameters = {};
|
|
16
|
-
}
|
|
17
|
-
get(name) {
|
|
18
|
-
return this.parameters[name];
|
|
19
|
-
}
|
|
20
|
-
getInt(name, def) {
|
|
21
|
-
const value = Number(name in this.parameters ? this.parameters[name] : def);
|
|
22
|
-
return Number.isFinite(value) ? value : def;
|
|
23
|
-
}
|
|
24
|
-
getAll() {
|
|
25
|
-
return this.parameters;
|
|
26
|
-
}
|
|
27
|
-
update(result) {
|
|
28
|
-
this.parameters = Object.assign(this.parameters, result);
|
|
29
|
-
}
|
|
30
|
-
clientUsed() {
|
|
31
|
-
return this.getAll();
|
|
32
|
-
}
|
|
33
|
-
updateClientUsed(result) {
|
|
34
|
-
this.update(result);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const readFileWithEnv = (path) => {
|
|
39
|
-
try {
|
|
40
|
-
const requireFunc =
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
|
|
43
|
-
return requireFunc(path);
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
class EnvironmentManagerServer extends EnvironmentManager {
|
|
50
|
-
constructor(tokens) {
|
|
51
|
-
super();
|
|
52
|
-
this.tokens = tokens;
|
|
53
|
-
this.clientUsedList = {};
|
|
54
|
-
this.processing();
|
|
55
|
-
}
|
|
56
|
-
clientUsed() {
|
|
57
|
-
return this.clientUsedList;
|
|
58
|
-
}
|
|
59
|
-
updateClientUsed(result) {
|
|
60
|
-
this.clientUsedList = Object.assign(this.clientUsedList, result);
|
|
61
|
-
}
|
|
62
|
-
// eslint-disable-next-line class-methods-use-this
|
|
63
|
-
getEnvInFiles() {
|
|
64
|
-
if (process.env.NODE_ENV === 'production' &&
|
|
65
|
-
process.env.DANGEROUS_UNSAFE_ENV_FILES !== 'true') {
|
|
66
|
-
return {};
|
|
67
|
-
}
|
|
68
|
-
const path = require('path');
|
|
69
|
-
return {
|
|
70
|
-
...readFileWithEnv(path.resolve(process.cwd(), 'server', `env.js`)),
|
|
71
|
-
...readFileWithEnv(path.resolve(process.cwd(), `env.development.js`)),
|
|
72
|
-
...readFileWithEnv(path.resolve(process.cwd(), `env.js`)),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
getEnvInApp() {
|
|
76
|
-
const appValue = {};
|
|
77
|
-
this.tokens.forEach((token) => {
|
|
78
|
-
if (token.value !== undefined) {
|
|
79
|
-
appValue[token.key] = token.value;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return appValue;
|
|
83
|
-
}
|
|
84
|
-
collectionEnv() {
|
|
85
|
-
return { ...this.getEnvInApp(), ...this.getEnvInFiles(), ...process.env };
|
|
86
|
-
}
|
|
87
|
-
processing() {
|
|
88
|
-
const result = {};
|
|
89
|
-
const envParameters = this.collectionEnv();
|
|
90
|
-
this.tokens.forEach(({ key, validator = noop, optional, dehydrate }) => {
|
|
91
|
-
const value = envParameters[key];
|
|
92
|
-
if (typeof value === 'undefined' && !optional) {
|
|
93
|
-
throw new Error(`Env parameter ${key} not found. You need add a this env parameter. If you have questions read the docs`);
|
|
94
|
-
}
|
|
95
|
-
// Not calling validation on empty values.
|
|
96
|
-
const validation = typeof value !== 'undefined' && validator(value);
|
|
97
|
-
if (typeof validation === 'string') {
|
|
98
|
-
throw new Error(`Env parameter ${key} with value ${value} not valid, message: ${validation}`);
|
|
99
|
-
}
|
|
100
|
-
result[key] = value;
|
|
101
|
-
if (dehydrate !== false) {
|
|
102
|
-
this.clientUsedList[key] = value;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
process.env = envParameters; // Записываем в process.env итоговый результат. TODO убрать позже
|
|
106
|
-
this.update(result);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
8
|
+
import { EnvironmentStore } from './shared/EnvironmentStore.es.js';
|
|
9
|
+
import { EnvironmentManagerServer } from './server/EnvironmentManagerServer.es.js';
|
|
109
10
|
|
|
110
11
|
let EnvironmentModule = class EnvironmentModule {
|
|
111
12
|
};
|
package/lib/server.js
CHANGED
|
@@ -8,112 +8,12 @@ var flatten = require('@tinkoff/utils/array/flatten');
|
|
|
8
8
|
var tokensCommon = require('@tramvai/tokens-common');
|
|
9
9
|
var tokensServer = require('@tramvai/tokens-server');
|
|
10
10
|
var papi = require('@tramvai/papi');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var EnvironmentStore = require('./shared/EnvironmentStore.js');
|
|
12
|
+
var EnvironmentManagerServer = require('./server/EnvironmentManagerServer.js');
|
|
13
13
|
|
|
14
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
15
|
|
|
16
16
|
var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
|
|
17
|
-
var noop__default = /*#__PURE__*/_interopDefaultLegacy(noop);
|
|
18
|
-
|
|
19
|
-
const EnvironmentStore = state.createReducer('environment', {});
|
|
20
|
-
|
|
21
|
-
class EnvironmentManager {
|
|
22
|
-
constructor() {
|
|
23
|
-
this.parameters = {};
|
|
24
|
-
}
|
|
25
|
-
get(name) {
|
|
26
|
-
return this.parameters[name];
|
|
27
|
-
}
|
|
28
|
-
getInt(name, def) {
|
|
29
|
-
const value = Number(name in this.parameters ? this.parameters[name] : def);
|
|
30
|
-
return Number.isFinite(value) ? value : def;
|
|
31
|
-
}
|
|
32
|
-
getAll() {
|
|
33
|
-
return this.parameters;
|
|
34
|
-
}
|
|
35
|
-
update(result) {
|
|
36
|
-
this.parameters = Object.assign(this.parameters, result);
|
|
37
|
-
}
|
|
38
|
-
clientUsed() {
|
|
39
|
-
return this.getAll();
|
|
40
|
-
}
|
|
41
|
-
updateClientUsed(result) {
|
|
42
|
-
this.update(result);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const readFileWithEnv = (path) => {
|
|
47
|
-
try {
|
|
48
|
-
const requireFunc =
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
|
|
51
|
-
return requireFunc(path);
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
return {};
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
class EnvironmentManagerServer extends EnvironmentManager {
|
|
58
|
-
constructor(tokens) {
|
|
59
|
-
super();
|
|
60
|
-
this.tokens = tokens;
|
|
61
|
-
this.clientUsedList = {};
|
|
62
|
-
this.processing();
|
|
63
|
-
}
|
|
64
|
-
clientUsed() {
|
|
65
|
-
return this.clientUsedList;
|
|
66
|
-
}
|
|
67
|
-
updateClientUsed(result) {
|
|
68
|
-
this.clientUsedList = Object.assign(this.clientUsedList, result);
|
|
69
|
-
}
|
|
70
|
-
// eslint-disable-next-line class-methods-use-this
|
|
71
|
-
getEnvInFiles() {
|
|
72
|
-
if (process.env.NODE_ENV === 'production' &&
|
|
73
|
-
process.env.DANGEROUS_UNSAFE_ENV_FILES !== 'true') {
|
|
74
|
-
return {};
|
|
75
|
-
}
|
|
76
|
-
const path = require('path');
|
|
77
|
-
return {
|
|
78
|
-
...readFileWithEnv(path.resolve(process.cwd(), 'server', `env.js`)),
|
|
79
|
-
...readFileWithEnv(path.resolve(process.cwd(), `env.development.js`)),
|
|
80
|
-
...readFileWithEnv(path.resolve(process.cwd(), `env.js`)),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
getEnvInApp() {
|
|
84
|
-
const appValue = {};
|
|
85
|
-
this.tokens.forEach((token) => {
|
|
86
|
-
if (token.value !== undefined) {
|
|
87
|
-
appValue[token.key] = token.value;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return appValue;
|
|
91
|
-
}
|
|
92
|
-
collectionEnv() {
|
|
93
|
-
return { ...this.getEnvInApp(), ...this.getEnvInFiles(), ...process.env };
|
|
94
|
-
}
|
|
95
|
-
processing() {
|
|
96
|
-
const result = {};
|
|
97
|
-
const envParameters = this.collectionEnv();
|
|
98
|
-
this.tokens.forEach(({ key, validator = noop__default["default"], optional, dehydrate }) => {
|
|
99
|
-
const value = envParameters[key];
|
|
100
|
-
if (typeof value === 'undefined' && !optional) {
|
|
101
|
-
throw new Error(`Env parameter ${key} not found. You need add a this env parameter. If you have questions read the docs`);
|
|
102
|
-
}
|
|
103
|
-
// Not calling validation on empty values.
|
|
104
|
-
const validation = typeof value !== 'undefined' && validator(value);
|
|
105
|
-
if (typeof validation === 'string') {
|
|
106
|
-
throw new Error(`Env parameter ${key} with value ${value} not valid, message: ${validation}`);
|
|
107
|
-
}
|
|
108
|
-
result[key] = value;
|
|
109
|
-
if (dehydrate !== false) {
|
|
110
|
-
this.clientUsedList[key] = value;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
process.env = envParameters; // Записываем в process.env итоговый результат. TODO убрать позже
|
|
114
|
-
this.update(result);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
17
|
|
|
118
18
|
exports.EnvironmentModule = class EnvironmentModule {
|
|
119
19
|
};
|
|
@@ -123,7 +23,7 @@ exports.EnvironmentModule = tslib.__decorate([
|
|
|
123
23
|
core.provide({
|
|
124
24
|
provide: tokensCommon.ENV_MANAGER_TOKEN,
|
|
125
25
|
useFactory: ({ tokens }) => {
|
|
126
|
-
return new EnvironmentManagerServer(flatten__default["default"](tokens !== null && tokens !== void 0 ? tokens : []));
|
|
26
|
+
return new EnvironmentManagerServer.EnvironmentManagerServer(flatten__default["default"](tokens !== null && tokens !== void 0 ? tokens : []));
|
|
127
27
|
},
|
|
128
28
|
deps: {
|
|
129
29
|
tokens: {
|
|
@@ -135,7 +35,7 @@ exports.EnvironmentModule = tslib.__decorate([
|
|
|
135
35
|
}),
|
|
136
36
|
core.provide({
|
|
137
37
|
provide: tokensCommon.COMBINE_REDUCERS,
|
|
138
|
-
useValue: EnvironmentStore,
|
|
38
|
+
useValue: EnvironmentStore.EnvironmentStore,
|
|
139
39
|
multi: true,
|
|
140
40
|
}),
|
|
141
41
|
core.provide({
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class EnvironmentManager {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.parameters = {};
|
|
4
|
+
}
|
|
5
|
+
get(name) {
|
|
6
|
+
return this.parameters[name];
|
|
7
|
+
}
|
|
8
|
+
getInt(name, def) {
|
|
9
|
+
const value = Number(name in this.parameters ? this.parameters[name] : def);
|
|
10
|
+
return Number.isFinite(value) ? value : def;
|
|
11
|
+
}
|
|
12
|
+
getAll() {
|
|
13
|
+
return this.parameters;
|
|
14
|
+
}
|
|
15
|
+
update(result) {
|
|
16
|
+
this.parameters = Object.assign(this.parameters, result);
|
|
17
|
+
}
|
|
18
|
+
clientUsed() {
|
|
19
|
+
return this.getAll();
|
|
20
|
+
}
|
|
21
|
+
updateClientUsed(result) {
|
|
22
|
+
this.update(result);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { EnvironmentManager };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class EnvironmentManager {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.parameters = {};
|
|
4
|
+
}
|
|
5
|
+
get(name) {
|
|
6
|
+
return this.parameters[name];
|
|
7
|
+
}
|
|
8
|
+
getInt(name, def) {
|
|
9
|
+
const value = Number(name in this.parameters ? this.parameters[name] : def);
|
|
10
|
+
return Number.isFinite(value) ? value : def;
|
|
11
|
+
}
|
|
12
|
+
getAll() {
|
|
13
|
+
return this.parameters;
|
|
14
|
+
}
|
|
15
|
+
update(result) {
|
|
16
|
+
this.parameters = Object.assign(this.parameters, result);
|
|
17
|
+
}
|
|
18
|
+
clientUsed() {
|
|
19
|
+
return this.getAll();
|
|
20
|
+
}
|
|
21
|
+
updateClientUsed(result) {
|
|
22
|
+
this.update(result);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { EnvironmentManager };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
class EnvironmentManager {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.parameters = {};
|
|
8
|
+
}
|
|
9
|
+
get(name) {
|
|
10
|
+
return this.parameters[name];
|
|
11
|
+
}
|
|
12
|
+
getInt(name, def) {
|
|
13
|
+
const value = Number(name in this.parameters ? this.parameters[name] : def);
|
|
14
|
+
return Number.isFinite(value) ? value : def;
|
|
15
|
+
}
|
|
16
|
+
getAll() {
|
|
17
|
+
return this.parameters;
|
|
18
|
+
}
|
|
19
|
+
update(result) {
|
|
20
|
+
this.parameters = Object.assign(this.parameters, result);
|
|
21
|
+
}
|
|
22
|
+
clientUsed() {
|
|
23
|
+
return this.getAll();
|
|
24
|
+
}
|
|
25
|
+
updateClientUsed(result) {
|
|
26
|
+
this.update(result);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.EnvironmentManager = EnvironmentManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-environment",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.72.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -14,18 +14,17 @@
|
|
|
14
14
|
"url": "git@github.com:Tinkoff/tramvai.git"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "tramvai-build --
|
|
18
|
-
"watch": "tsc -w"
|
|
19
|
-
"build-for-publish": "true"
|
|
17
|
+
"build": "tramvai-build --forPublish --preserveModules",
|
|
18
|
+
"watch": "tsc -w"
|
|
20
19
|
},
|
|
21
20
|
"peerDependencies": {
|
|
22
21
|
"@tinkoff/utils": "^2.1.2",
|
|
23
|
-
"@tramvai/core": "2.
|
|
24
|
-
"@tramvai/papi": "2.
|
|
25
|
-
"@tramvai/state": "2.
|
|
26
|
-
"@tramvai/tokens-common": "2.
|
|
27
|
-
"@tramvai/tokens-server": "2.
|
|
28
|
-
"@tinkoff/dippy": "0.8.
|
|
22
|
+
"@tramvai/core": "2.72.3",
|
|
23
|
+
"@tramvai/papi": "2.72.3",
|
|
24
|
+
"@tramvai/state": "2.72.3",
|
|
25
|
+
"@tramvai/tokens-common": "2.72.3",
|
|
26
|
+
"@tramvai/tokens-server": "2.72.3",
|
|
27
|
+
"@tinkoff/dippy": "0.8.13",
|
|
29
28
|
"react": ">=16.14.0",
|
|
30
29
|
"react-dom": ">=16.14.0",
|
|
31
30
|
"tslib": "^2.4.0"
|