@tramvai/module-common 1.55.4 → 1.58.0
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/README.md +48 -46
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
# Common
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Base module consisted of the architectural blocks for typical tramvai app. This module is required at most cases and is used a lot by the other modules.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
First install `@tramvai/module-common`
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```bash
|
|
9
|
+
```bash npm2yarn
|
|
12
10
|
npm i @tramvai/module-common
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Нужно передать в список модулей приложения CommonModule
|
|
13
|
+
Add CommonModule to the modules list
|
|
18
14
|
|
|
19
15
|
```tsx
|
|
20
16
|
import { createApp } from '@tramvai/core';
|
|
@@ -25,54 +21,68 @@ createApp({
|
|
|
25
21
|
});
|
|
26
22
|
```
|
|
27
23
|
|
|
28
|
-
##
|
|
24
|
+
## Explanation
|
|
25
|
+
|
|
26
|
+
### Submodules
|
|
27
|
+
|
|
28
|
+
#### CommandModule
|
|
29
|
+
|
|
30
|
+
Module that adds implementation for the [commandLineRunner](concepts/command-line-runner.md) and defines default command lines
|
|
31
|
+
|
|
32
|
+
This module logs with id `command:command-line-runner`
|
|
33
|
+
|
|
34
|
+
#### StateModule
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
Adds state-manager
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
#### ActionModule
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
Implements [action system](concepts/action.md)
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
This module logs with id `action:action-page-runner`
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
#### CookieModule
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
Add providers that works with cookie. See [docs](references/modules/cookie.md)
|
|
41
47
|
|
|
42
|
-
|
|
48
|
+
#### EnvironmentModule
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
Implements work with environment variables both on server and client. See [docs](references/modules/env.md)
|
|
45
51
|
|
|
46
|
-
|
|
52
|
+
#### PubSub
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
Provides PubSub interface to implement communication between components. See [docs](references/libs/pubsub.md)
|
|
49
55
|
|
|
50
|
-
|
|
56
|
+
This modules logs with id `pubsub`
|
|
51
57
|
|
|
52
|
-
|
|
58
|
+
#### LogModule
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
Module for logging. Uses [`@tramvai/module-log`](references/modules/log.md)
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
#### CacheModule
|
|
57
63
|
|
|
58
|
-
|
|
64
|
+
Module that implements caches.
|
|
59
65
|
|
|
60
|
-
|
|
66
|
+
It provides next functionality:
|
|
61
67
|
|
|
62
|
-
|
|
68
|
+
- create new cache instance (currently it will be instance of lru-cache)
|
|
69
|
+
- clear all of the previously create caches
|
|
70
|
+
- subscribe on cache clearance event to execute own cache clearance actions
|
|
71
|
+
- adds papi-route `/clear-cache` that will trigger caches clear event
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
This modules logs wit id `cache:papi-clear-cache`
|
|
65
74
|
|
|
66
|
-
|
|
75
|
+
#### RequestManagerModule
|
|
67
76
|
|
|
68
|
-
|
|
69
|
-
- Очистить все ранее созданные кеши
|
|
70
|
-
- Подписка на событие очистки кеша для реализации собственного тригера очистки своих кешей
|
|
71
|
-
- Добавляет papi-метод '/clear-cache' который генерирует событе очистки кешей
|
|
77
|
+
Wrapper for the client request
|
|
72
78
|
|
|
73
|
-
|
|
79
|
+
#### ResponseManagerModule
|
|
74
80
|
|
|
75
|
-
|
|
81
|
+
Wrapper for the client response
|
|
82
|
+
|
|
83
|
+
## How to
|
|
84
|
+
|
|
85
|
+
### Create cache
|
|
76
86
|
|
|
77
87
|
```tsx
|
|
78
88
|
import { provide } from '@tramvai/core';
|
|
@@ -82,7 +92,7 @@ export const providers = [
|
|
|
82
92
|
provide: MY_MODULE_PROVIDER_FACTORY,
|
|
83
93
|
scope: Scope.SINGLETON,
|
|
84
94
|
useFactory: ({ createCache }) => {
|
|
85
|
-
const cache = createCache('memory', ...args); //
|
|
95
|
+
const cache = createCache('memory', ...args); // type of the cache and any additional options that will be passed to the cache constructor
|
|
86
96
|
|
|
87
97
|
return someFactory({ cache });
|
|
88
98
|
},
|
|
@@ -109,7 +119,7 @@ export const providers = [
|
|
|
109
119
|
provide: commandLineListTokens.clear,
|
|
110
120
|
useFactory: ({ clearCache }) => {
|
|
111
121
|
return function clear() {
|
|
112
|
-
clearCache(); //
|
|
122
|
+
clearCache(); // clear caches explicitly
|
|
113
123
|
};
|
|
114
124
|
},
|
|
115
125
|
deps: {
|
|
@@ -119,15 +129,7 @@ export const providers = [
|
|
|
119
129
|
];
|
|
120
130
|
```
|
|
121
131
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
Модуль для работы с параметрами запроса
|
|
125
|
-
|
|
126
|
-
### ResponseManagerModule
|
|
127
|
-
|
|
128
|
-
Модуль для работы с параметрами ответа
|
|
129
|
-
|
|
130
|
-
## Экспортируемые токены
|
|
132
|
+
## Exported tokens
|
|
131
133
|
|
|
132
134
|
- [tokens-common](references/tokens/common-tokens.md)
|
|
133
135
|
- [cookie](references/modules/cookie.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -30,24 +30,24 @@
|
|
|
30
30
|
"@tinkoff/errors": "0.2.18",
|
|
31
31
|
"@tinkoff/pubsub": "0.4.23",
|
|
32
32
|
"@tinkoff/url": "0.7.37",
|
|
33
|
-
"@tramvai/module-cookie": "1.
|
|
34
|
-
"@tramvai/module-environment": "1.
|
|
35
|
-
"@tramvai/module-log": "1.
|
|
36
|
-
"@tramvai/tokens-child-app": "1.
|
|
37
|
-
"@tramvai/tokens-common": "1.
|
|
38
|
-
"@tramvai/tokens-render": "1.
|
|
39
|
-
"@tramvai/experiments": "1.
|
|
33
|
+
"@tramvai/module-cookie": "1.58.0",
|
|
34
|
+
"@tramvai/module-environment": "1.58.0",
|
|
35
|
+
"@tramvai/module-log": "1.58.0",
|
|
36
|
+
"@tramvai/tokens-child-app": "1.58.0",
|
|
37
|
+
"@tramvai/tokens-common": "1.58.0",
|
|
38
|
+
"@tramvai/tokens-render": "1.58.0",
|
|
39
|
+
"@tramvai/experiments": "1.58.0",
|
|
40
40
|
"@tinkoff/hook-runner": "0.3.21",
|
|
41
41
|
"lru-cache": "^6.0.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@tinkoff/utils": "^2.1.2",
|
|
45
|
-
"@tramvai/cli": "1.
|
|
46
|
-
"@tramvai/core": "1.
|
|
47
|
-
"@tramvai/papi": "1.
|
|
48
|
-
"@tramvai/state": "1.
|
|
49
|
-
"@tramvai/tokens-metrics": "1.
|
|
50
|
-
"@tramvai/tokens-server": "1.
|
|
45
|
+
"@tramvai/cli": "1.58.0",
|
|
46
|
+
"@tramvai/core": "1.58.0",
|
|
47
|
+
"@tramvai/papi": "1.58.0",
|
|
48
|
+
"@tramvai/state": "1.58.0",
|
|
49
|
+
"@tramvai/tokens-metrics": "1.58.0",
|
|
50
|
+
"@tramvai/tokens-server": "1.58.0",
|
|
51
51
|
"@tinkoff/dippy": "0.7.38",
|
|
52
52
|
"react": ">=16.8.0",
|
|
53
53
|
"tslib": "^2.0.3"
|