@tramvai/module-common 2.31.0 → 2.33.1
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/index.browser.js +13 -10
- package/lib/index.es.js +8 -8
- package/lib/index.js +7 -7
- package/lib/requestManager/requestManager.d.ts +7 -7
- package/package.json +17 -16
package/lib/index.browser.js
CHANGED
|
@@ -6,12 +6,13 @@ import { CookieModule } from '@tramvai/module-cookie';
|
|
|
6
6
|
export { COOKIE_MANAGER_TOKEN } from '@tramvai/module-cookie';
|
|
7
7
|
import { LogModule } from '@tramvai/module-log';
|
|
8
8
|
import { Hooks } from '@tinkoff/hook-runner';
|
|
9
|
-
import { REQUEST_MANAGER_TOKEN,
|
|
9
|
+
import { REQUEST_MANAGER_TOKEN, COMBINE_REDUCERS, STORE_TOKEN, RESPONSE_MANAGER_TOKEN, ACTION_EXECUTION_TOKEN, ROOT_EXECUTION_CONTEXT_TOKEN, LOGGER_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN, COMMAND_LINE_EXECUTION_CONTEXT_TOKEN, PUBSUB_FACTORY_TOKEN, PUBSUB_TOKEN, ROOT_PUBSUB_TOKEN, INITIAL_APP_STATE_TOKEN, ACTION_REGISTRY_TOKEN, ACTION_CONDITIONALS, CONTEXT_TOKEN, ACTION_PAGE_RUNNER_TOKEN, DISPATCHER_TOKEN, DISPATCHER_CONTEXT_TOKEN, STORE_MIDDLEWARE, CREATE_CACHE_TOKEN, CLEAR_CACHE_TOKEN, REGISTER_CLEAR_CACHE_TOKEN, HOOK_TOKEN, COMPONENT_REGISTRY_TOKEN, BUNDLE_MANAGER_TOKEN, ADDITIONAL_BUNDLE_TOKEN } from '@tramvai/tokens-common';
|
|
10
10
|
export * from '@tramvai/tokens-common';
|
|
11
11
|
import { resolveLazyComponent, __lazyErrorHandler } from '@tramvai/react';
|
|
12
12
|
import { fileSystemPagesEnabled, getAllFileSystemPages, isFileSystemPageComponent } from '@tramvai/experiments';
|
|
13
13
|
import pathOr from '@tinkoff/utils/object/pathOr';
|
|
14
14
|
import flatten from '@tinkoff/utils/array/flatten';
|
|
15
|
+
import { FASTIFY_REQUEST, FASTIFY_RESPONSE } from '@tramvai/tokens-server-private';
|
|
15
16
|
import { createEvent, createReducer, convertAction, createDispatcher, devTools, Provider } from '@tramvai/state';
|
|
16
17
|
import { format, parse } from '@tinkoff/url';
|
|
17
18
|
import isEmpty from '@tinkoff/utils/is/empty';
|
|
@@ -145,7 +146,7 @@ class RequestManager {
|
|
|
145
146
|
this.url = format({
|
|
146
147
|
protocol: this.getHeader('x-forwarded-proto') || this.request.protocol,
|
|
147
148
|
host: this.getHost(),
|
|
148
|
-
path: this.request.
|
|
149
|
+
path: this.request.url,
|
|
149
150
|
});
|
|
150
151
|
}
|
|
151
152
|
else {
|
|
@@ -168,7 +169,8 @@ class RequestManager {
|
|
|
168
169
|
return this.request.method;
|
|
169
170
|
}
|
|
170
171
|
getHeader(key) {
|
|
171
|
-
|
|
172
|
+
var _a;
|
|
173
|
+
return (_a = this.request.headers) === null || _a === void 0 ? void 0 : _a[key];
|
|
172
174
|
}
|
|
173
175
|
getHeaders() {
|
|
174
176
|
return this.request.headers;
|
|
@@ -180,7 +182,8 @@ class RequestManager {
|
|
|
180
182
|
return this.request.cookies;
|
|
181
183
|
}
|
|
182
184
|
getClientIp() {
|
|
183
|
-
|
|
185
|
+
var _a, _b;
|
|
186
|
+
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) || '';
|
|
184
187
|
}
|
|
185
188
|
getHost() {
|
|
186
189
|
if (typeof window === 'undefined') {
|
|
@@ -196,7 +199,7 @@ const sharedProviders$1 = [
|
|
|
196
199
|
scope: Scope.REQUEST,
|
|
197
200
|
useClass: RequestManager,
|
|
198
201
|
deps: {
|
|
199
|
-
request:
|
|
202
|
+
request: FASTIFY_REQUEST,
|
|
200
203
|
},
|
|
201
204
|
},
|
|
202
205
|
{
|
|
@@ -213,7 +216,7 @@ RequestManagerModule = __decorate([
|
|
|
213
216
|
providers: [
|
|
214
217
|
...sharedProviders$1,
|
|
215
218
|
provide({
|
|
216
|
-
provide:
|
|
219
|
+
provide: FASTIFY_REQUEST,
|
|
217
220
|
useFactory: ({ store }) => {
|
|
218
221
|
const fromServer = store.getState(RequestManagerStore);
|
|
219
222
|
return {
|
|
@@ -223,6 +226,9 @@ RequestManagerModule = __decorate([
|
|
|
223
226
|
'user-agent': navigator.userAgent,
|
|
224
227
|
cookie: document.cookie,
|
|
225
228
|
},
|
|
229
|
+
// the type is not actually the same and is only partially compatible with actual request object
|
|
230
|
+
// but provide it as a backup for some of the isomorphic code
|
|
231
|
+
// anyway it is better not to use request/response on client
|
|
226
232
|
};
|
|
227
233
|
},
|
|
228
234
|
deps: {
|
|
@@ -286,9 +292,6 @@ const sharedProviders = [
|
|
|
286
292
|
provide: RESPONSE_MANAGER_TOKEN,
|
|
287
293
|
scope: Scope.REQUEST,
|
|
288
294
|
useClass: ResponseManager,
|
|
289
|
-
deps: {
|
|
290
|
-
response: RESPONSE,
|
|
291
|
-
},
|
|
292
295
|
},
|
|
293
296
|
];
|
|
294
297
|
|
|
@@ -299,7 +302,7 @@ ResponseManagerModule = __decorate([
|
|
|
299
302
|
providers: [
|
|
300
303
|
...sharedProviders,
|
|
301
304
|
{
|
|
302
|
-
provide:
|
|
305
|
+
provide: FASTIFY_RESPONSE,
|
|
303
306
|
useValue: {},
|
|
304
307
|
},
|
|
305
308
|
],
|
package/lib/index.es.js
CHANGED
|
@@ -6,13 +6,14 @@ import { CookieModule } from '@tramvai/module-cookie';
|
|
|
6
6
|
export { COOKIE_MANAGER_TOKEN } from '@tramvai/module-cookie';
|
|
7
7
|
import { LogModule } from '@tramvai/module-log';
|
|
8
8
|
import { Hooks } from '@tinkoff/hook-runner';
|
|
9
|
-
import { REQUEST_MANAGER_TOKEN,
|
|
9
|
+
import { REQUEST_MANAGER_TOKEN, COMBINE_REDUCERS, CONTEXT_TOKEN, RESPONSE_MANAGER_TOKEN, ACTION_EXECUTION_TOKEN, ROOT_EXECUTION_CONTEXT_TOKEN, LOGGER_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN, COMMAND_LINE_EXECUTION_CONTEXT_TOKEN, PUBSUB_FACTORY_TOKEN, PUBSUB_TOKEN, ROOT_PUBSUB_TOKEN, ACTION_REGISTRY_TOKEN, ACTION_CONDITIONALS, STORE_TOKEN, ACTION_PAGE_RUNNER_TOKEN, DISPATCHER_TOKEN, DISPATCHER_CONTEXT_TOKEN, STORE_MIDDLEWARE, INITIAL_APP_STATE_TOKEN, CLEAR_CACHE_TOKEN, CREATE_CACHE_TOKEN, REGISTER_CLEAR_CACHE_TOKEN, HOOK_TOKEN, COMPONENT_REGISTRY_TOKEN, BUNDLE_MANAGER_TOKEN, ADDITIONAL_BUNDLE_TOKEN } from '@tramvai/tokens-common';
|
|
10
10
|
export * from '@tramvai/tokens-common';
|
|
11
11
|
import { resolveLazyComponent, __lazyErrorHandler } from '@tramvai/react';
|
|
12
12
|
import { fileSystemPagesEnabled, getAllFileSystemPages, isFileSystemPageComponent } from '@tramvai/experiments';
|
|
13
13
|
import pathOr from '@tinkoff/utils/object/pathOr';
|
|
14
14
|
import flatten from '@tinkoff/utils/array/flatten';
|
|
15
15
|
import { createEvent, createReducer, convertAction, createDispatcher, devTools, Provider } from '@tramvai/state';
|
|
16
|
+
import { FASTIFY_REQUEST } from '@tramvai/tokens-server-private';
|
|
16
17
|
import { format, parse } from '@tinkoff/url';
|
|
17
18
|
import isEmpty from '@tinkoff/utils/is/empty';
|
|
18
19
|
import values from '@tinkoff/utils/object/values';
|
|
@@ -147,7 +148,7 @@ class RequestManager {
|
|
|
147
148
|
this.url = format({
|
|
148
149
|
protocol: this.getHeader('x-forwarded-proto') || this.request.protocol,
|
|
149
150
|
host: this.getHost(),
|
|
150
|
-
path: this.request.
|
|
151
|
+
path: this.request.url,
|
|
151
152
|
});
|
|
152
153
|
}
|
|
153
154
|
else {
|
|
@@ -170,7 +171,8 @@ class RequestManager {
|
|
|
170
171
|
return this.request.method;
|
|
171
172
|
}
|
|
172
173
|
getHeader(key) {
|
|
173
|
-
|
|
174
|
+
var _a;
|
|
175
|
+
return (_a = this.request.headers) === null || _a === void 0 ? void 0 : _a[key];
|
|
174
176
|
}
|
|
175
177
|
getHeaders() {
|
|
176
178
|
return this.request.headers;
|
|
@@ -182,7 +184,8 @@ class RequestManager {
|
|
|
182
184
|
return this.request.cookies;
|
|
183
185
|
}
|
|
184
186
|
getClientIp() {
|
|
185
|
-
|
|
187
|
+
var _a, _b;
|
|
188
|
+
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) || '';
|
|
186
189
|
}
|
|
187
190
|
getHost() {
|
|
188
191
|
if (typeof window === 'undefined') {
|
|
@@ -198,7 +201,7 @@ const sharedProviders$1 = [
|
|
|
198
201
|
scope: Scope.REQUEST,
|
|
199
202
|
useClass: RequestManager,
|
|
200
203
|
deps: {
|
|
201
|
-
request:
|
|
204
|
+
request: FASTIFY_REQUEST,
|
|
202
205
|
},
|
|
203
206
|
},
|
|
204
207
|
{
|
|
@@ -289,9 +292,6 @@ const sharedProviders = [
|
|
|
289
292
|
provide: RESPONSE_MANAGER_TOKEN,
|
|
290
293
|
scope: Scope.REQUEST,
|
|
291
294
|
useClass: ResponseManager,
|
|
292
|
-
deps: {
|
|
293
|
-
response: RESPONSE,
|
|
294
|
-
},
|
|
295
295
|
},
|
|
296
296
|
];
|
|
297
297
|
|
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var experiments = require('@tramvai/experiments');
|
|
|
15
15
|
var pathOr = require('@tinkoff/utils/object/pathOr');
|
|
16
16
|
var flatten = require('@tinkoff/utils/array/flatten');
|
|
17
17
|
var state = require('@tramvai/state');
|
|
18
|
+
var tokensServerPrivate = require('@tramvai/tokens-server-private');
|
|
18
19
|
var url = require('@tinkoff/url');
|
|
19
20
|
var isEmpty = require('@tinkoff/utils/is/empty');
|
|
20
21
|
var values = require('@tinkoff/utils/object/values');
|
|
@@ -164,7 +165,7 @@ class RequestManager {
|
|
|
164
165
|
this.url = url.format({
|
|
165
166
|
protocol: this.getHeader('x-forwarded-proto') || this.request.protocol,
|
|
166
167
|
host: this.getHost(),
|
|
167
|
-
path: this.request.
|
|
168
|
+
path: this.request.url,
|
|
168
169
|
});
|
|
169
170
|
}
|
|
170
171
|
else {
|
|
@@ -187,7 +188,8 @@ class RequestManager {
|
|
|
187
188
|
return this.request.method;
|
|
188
189
|
}
|
|
189
190
|
getHeader(key) {
|
|
190
|
-
|
|
191
|
+
var _a;
|
|
192
|
+
return (_a = this.request.headers) === null || _a === void 0 ? void 0 : _a[key];
|
|
191
193
|
}
|
|
192
194
|
getHeaders() {
|
|
193
195
|
return this.request.headers;
|
|
@@ -199,7 +201,8 @@ class RequestManager {
|
|
|
199
201
|
return this.request.cookies;
|
|
200
202
|
}
|
|
201
203
|
getClientIp() {
|
|
202
|
-
|
|
204
|
+
var _a, _b;
|
|
205
|
+
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) || '';
|
|
203
206
|
}
|
|
204
207
|
getHost() {
|
|
205
208
|
if (typeof window === 'undefined') {
|
|
@@ -215,7 +218,7 @@ const sharedProviders$1 = [
|
|
|
215
218
|
scope: core.Scope.REQUEST,
|
|
216
219
|
useClass: RequestManager,
|
|
217
220
|
deps: {
|
|
218
|
-
request:
|
|
221
|
+
request: tokensServerPrivate.FASTIFY_REQUEST,
|
|
219
222
|
},
|
|
220
223
|
},
|
|
221
224
|
{
|
|
@@ -306,9 +309,6 @@ const sharedProviders = [
|
|
|
306
309
|
provide: tokensCommon.RESPONSE_MANAGER_TOKEN,
|
|
307
310
|
scope: core.Scope.REQUEST,
|
|
308
311
|
useClass: ResponseManager,
|
|
309
|
-
deps: {
|
|
310
|
-
response: tokensCommon.RESPONSE,
|
|
311
|
-
},
|
|
312
312
|
},
|
|
313
313
|
];
|
|
314
314
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { Url } from '@tinkoff/url';
|
|
3
|
-
import type {
|
|
2
|
+
import type { REQUEST_MANAGER_TOKEN } from '@tramvai/tokens-common';
|
|
3
|
+
import type { FASTIFY_REQUEST } from '@tramvai/tokens-server-private';
|
|
4
4
|
declare type Interface = typeof REQUEST_MANAGER_TOKEN;
|
|
5
5
|
export declare class RequestManager implements Interface {
|
|
6
6
|
private request;
|
|
7
7
|
private url;
|
|
8
8
|
private parsedUrl;
|
|
9
9
|
constructor({ request }: {
|
|
10
|
-
request: typeof
|
|
10
|
+
request: typeof FASTIFY_REQUEST;
|
|
11
11
|
});
|
|
12
|
-
getBody():
|
|
12
|
+
getBody(): unknown;
|
|
13
13
|
getUrl(): string;
|
|
14
14
|
getParsedUrl(): Url;
|
|
15
15
|
getMethod(): string;
|
|
16
16
|
getHeader(key: string): string | string[];
|
|
17
|
-
getHeaders():
|
|
18
|
-
getCookie(key: string):
|
|
19
|
-
getCookies():
|
|
17
|
+
getHeaders(): Record<string, string | string[]>;
|
|
18
|
+
getCookie(key: string): string;
|
|
19
|
+
getCookies(): Record<string, string>;
|
|
20
20
|
getClientIp(): string;
|
|
21
21
|
getHost(): string;
|
|
22
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.33.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -33,26 +33,27 @@
|
|
|
33
33
|
"@tinkoff/lru-cache-nano": "^7.8.1",
|
|
34
34
|
"@tinkoff/pubsub": "0.5.4",
|
|
35
35
|
"@tinkoff/url": "0.8.3",
|
|
36
|
-
"@tramvai/experiments": "2.
|
|
37
|
-
"@tramvai/module-cookie": "2.
|
|
38
|
-
"@tramvai/module-environment": "2.
|
|
39
|
-
"@tramvai/module-log": "2.
|
|
40
|
-
"@tramvai/tokens-child-app": "2.
|
|
41
|
-
"@tramvai/tokens-common": "2.
|
|
42
|
-
"@tramvai/tokens-render": "2.
|
|
36
|
+
"@tramvai/experiments": "2.33.1",
|
|
37
|
+
"@tramvai/module-cookie": "2.33.1",
|
|
38
|
+
"@tramvai/module-environment": "2.33.1",
|
|
39
|
+
"@tramvai/module-log": "2.33.1",
|
|
40
|
+
"@tramvai/tokens-child-app": "2.33.1",
|
|
41
|
+
"@tramvai/tokens-common": "2.33.1",
|
|
42
|
+
"@tramvai/tokens-render": "2.33.1",
|
|
43
|
+
"@tramvai/tokens-server-private": "2.33.1",
|
|
43
44
|
"hoist-non-react-statics": "^3.3.1",
|
|
44
45
|
"node-abort-controller": "^3.0.1"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@tinkoff/dippy": "0.8.
|
|
48
|
+
"@tinkoff/dippy": "0.8.7",
|
|
48
49
|
"@tinkoff/utils": "^2.1.2",
|
|
49
|
-
"@tramvai/cli": "2.
|
|
50
|
-
"@tramvai/core": "2.
|
|
51
|
-
"@tramvai/papi": "2.
|
|
52
|
-
"@tramvai/react": "2.
|
|
53
|
-
"@tramvai/state": "2.
|
|
54
|
-
"@tramvai/tokens-metrics": "2.
|
|
55
|
-
"@tramvai/tokens-server": "2.
|
|
50
|
+
"@tramvai/cli": "2.33.1",
|
|
51
|
+
"@tramvai/core": "2.33.1",
|
|
52
|
+
"@tramvai/papi": "2.33.1",
|
|
53
|
+
"@tramvai/react": "2.33.1",
|
|
54
|
+
"@tramvai/state": "2.33.1",
|
|
55
|
+
"@tramvai/tokens-metrics": "2.33.1",
|
|
56
|
+
"@tramvai/tokens-server": "2.33.1",
|
|
56
57
|
"react": ">=16.14.0",
|
|
57
58
|
"tslib": "^2.4.0"
|
|
58
59
|
},
|