@tramvai/tokens-common 3.41.0 → 3.41.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/env.d.ts CHANGED
@@ -1,18 +1,38 @@
1
1
  export interface EnvironmentManager {
2
2
  get(name: string): string | undefined;
3
3
  getInt(name: string, def: number): number;
4
- getAll(): Record<string, string>;
4
+ getAll(): Record<string, string | undefined>;
5
5
  update(result: Record<string, string>): void;
6
- clientUsed(): Record<string, string>;
6
+ /**
7
+ * @deprecated use CLIENT_ENV_MANAGER_TOKEN
8
+ */
9
+ clientUsed(): Record<string, string | undefined>;
10
+ /**
11
+ * @deprecated use CLIENT_ENV_MANAGER_TOKEN
12
+ */
7
13
  updateClientUsed(result: Record<string, string>): void;
8
14
  }
15
+ export interface ClientEnvironmentRepository {
16
+ get(name: string): string | undefined;
17
+ set(name: string, value: string): void;
18
+ getAll(): Record<string, string | undefined>;
19
+ update(result: Record<string, string>): void;
20
+ }
9
21
  /**
10
22
  * @description
11
- * Instance that used for managing env data on the server and on the client
23
+ * Instance that used for managing environment variables
12
24
  */
13
25
  export declare const ENV_MANAGER_TOKEN: EnvironmentManager & {
14
26
  __type?: "base token" | undefined;
15
27
  };
28
+ /**
29
+ * @description
30
+ * Instance that used for store and manage environment variables map, which are passed to the client.
31
+ * Use only server-side for client env values modification depending on the specific request conditions.
32
+ */
33
+ export declare const CLIENT_ENV_REPOSITORY_TOKEN: ClientEnvironmentRepository & {
34
+ __type?: "base token" | undefined;
35
+ };
16
36
  /**
17
37
  * @description
18
38
  * List of envs that are used by the module or the app.
@@ -45,4 +65,11 @@ export interface EnvParameter {
45
65
  export declare const ENV_USED_TOKEN: EnvParameter[] & {
46
66
  __type?: "multi token" | undefined;
47
67
  };
68
+ export type EnvTemplate = {
69
+ key: string;
70
+ fn: (...args: any[]) => string;
71
+ };
72
+ export declare const ENV_TEMPLATE_TOKEN: EnvTemplate & {
73
+ __type?: "multi token" | undefined;
74
+ };
48
75
  //# sourceMappingURL=env.d.ts.map
package/lib/env.es.js CHANGED
@@ -1,10 +1,24 @@
1
- import { createToken } from '@tinkoff/dippy';
1
+ import { createToken, Scope } from '@tinkoff/dippy';
2
2
 
3
3
  /**
4
4
  * @description
5
- * Instance that used for managing env data on the server and on the client
5
+ * Instance that used for managing environment variables
6
6
  */
7
- const ENV_MANAGER_TOKEN = createToken('environmentManager');
7
+ const ENV_MANAGER_TOKEN = createToken('environmentManager', {
8
+ scope: Scope.SINGLETON,
9
+ });
10
+ /**
11
+ * @description
12
+ * Instance that used for store and manage environment variables map, which are passed to the client.
13
+ * Use only server-side for client env values modification depending on the specific request conditions.
14
+ */
15
+ const CLIENT_ENV_REPOSITORY_TOKEN = createToken('clientEnvironmentManager', {
16
+ scope: Scope.REQUEST,
17
+ });
8
18
  const ENV_USED_TOKEN = createToken('envUsed', { multi: true });
19
+ const ENV_TEMPLATE_TOKEN = createToken('env template token', {
20
+ multi: true,
21
+ scope: Scope.SINGLETON,
22
+ });
9
23
 
10
- export { ENV_MANAGER_TOKEN, ENV_USED_TOKEN };
24
+ export { CLIENT_ENV_REPOSITORY_TOKEN, ENV_MANAGER_TOKEN, ENV_TEMPLATE_TOKEN, ENV_USED_TOKEN };
package/lib/env.js CHANGED
@@ -6,10 +6,26 @@ var dippy = require('@tinkoff/dippy');
6
6
 
7
7
  /**
8
8
  * @description
9
- * Instance that used for managing env data on the server and on the client
9
+ * Instance that used for managing environment variables
10
10
  */
11
- const ENV_MANAGER_TOKEN = dippy.createToken('environmentManager');
11
+ const ENV_MANAGER_TOKEN = dippy.createToken('environmentManager', {
12
+ scope: dippy.Scope.SINGLETON,
13
+ });
14
+ /**
15
+ * @description
16
+ * Instance that used for store and manage environment variables map, which are passed to the client.
17
+ * Use only server-side for client env values modification depending on the specific request conditions.
18
+ */
19
+ const CLIENT_ENV_REPOSITORY_TOKEN = dippy.createToken('clientEnvironmentManager', {
20
+ scope: dippy.Scope.REQUEST,
21
+ });
12
22
  const ENV_USED_TOKEN = dippy.createToken('envUsed', { multi: true });
23
+ const ENV_TEMPLATE_TOKEN = dippy.createToken('env template token', {
24
+ multi: true,
25
+ scope: dippy.Scope.SINGLETON,
26
+ });
13
27
 
28
+ exports.CLIENT_ENV_REPOSITORY_TOKEN = CLIENT_ENV_REPOSITORY_TOKEN;
14
29
  exports.ENV_MANAGER_TOKEN = ENV_MANAGER_TOKEN;
30
+ exports.ENV_TEMPLATE_TOKEN = ENV_TEMPLATE_TOKEN;
15
31
  exports.ENV_USED_TOKEN = ENV_USED_TOKEN;
package/lib/index.es.js CHANGED
@@ -9,6 +9,6 @@ export { COMBINE_REDUCERS, DISPATCHER_CONTEXT_TOKEN, DISPATCHER_TOKEN, INITIAL_A
9
9
  export { LOGGER_INIT_HOOK, LOGGER_REMOTE_REPORTER, LOGGER_SHARED_CONTEXT, LOGGER_TOKEN } from './logger.es.js';
10
10
  export { REQUEST_MANAGER_TOKEN } from './requestManager.es.js';
11
11
  export { RESPONSE_MANAGER_TOKEN } from './responseManager.es.js';
12
- export { ENV_MANAGER_TOKEN, ENV_USED_TOKEN } from './env.es.js';
12
+ export { CLIENT_ENV_REPOSITORY_TOKEN, ENV_MANAGER_TOKEN, ENV_TEMPLATE_TOKEN, ENV_USED_TOKEN } from './env.es.js';
13
13
  export { COMMAND_LINE_EXECUTION_CONTEXT_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN, ROOT_EXECUTION_CONTEXT_TOKEN } from './execution.es.js';
14
14
  export { ASYNC_LOCAL_STORAGE_TOKEN } from './async-local-storage.es.js';
package/lib/index.js CHANGED
@@ -47,7 +47,9 @@ exports.LOGGER_SHARED_CONTEXT = logger.LOGGER_SHARED_CONTEXT;
47
47
  exports.LOGGER_TOKEN = logger.LOGGER_TOKEN;
48
48
  exports.REQUEST_MANAGER_TOKEN = requestManager.REQUEST_MANAGER_TOKEN;
49
49
  exports.RESPONSE_MANAGER_TOKEN = responseManager.RESPONSE_MANAGER_TOKEN;
50
+ exports.CLIENT_ENV_REPOSITORY_TOKEN = env.CLIENT_ENV_REPOSITORY_TOKEN;
50
51
  exports.ENV_MANAGER_TOKEN = env.ENV_MANAGER_TOKEN;
52
+ exports.ENV_TEMPLATE_TOKEN = env.ENV_TEMPLATE_TOKEN;
51
53
  exports.ENV_USED_TOKEN = env.ENV_USED_TOKEN;
52
54
  exports.COMMAND_LINE_EXECUTION_CONTEXT_TOKEN = execution.COMMAND_LINE_EXECUTION_CONTEXT_TOKEN;
53
55
  exports.EXECUTION_CONTEXT_MANAGER_TOKEN = execution.EXECUTION_CONTEXT_MANAGER_TOKEN;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/tokens-common",
3
- "version": "3.41.0",
3
+ "version": "3.41.3",
4
4
  "description": "Tramvai tokens for @tramvai/module-common",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.es.js",
@@ -20,13 +20,13 @@
20
20
  "dependencies": {
21
21
  "@tinkoff/lru-cache-nano": "^7.9.0",
22
22
  "@tinkoff/url": "0.9.2",
23
- "@tramvai/react": "3.41.0",
24
- "@tramvai/tokens-core": "3.41.0"
23
+ "@tramvai/react": "3.41.3",
24
+ "@tramvai/tokens-core": "3.41.3"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@tinkoff/dippy": "0.9.4",
28
28
  "@tinkoff/logger": "0.10.172",
29
- "@tramvai/types-actions-state-context": "3.41.0",
29
+ "@tramvai/types-actions-state-context": "3.41.3",
30
30
  "react": ">=16.8",
31
31
  "tslib": "^2.4.0"
32
32
  },