@modern-js/types 2.28.0 → 2.29.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/CHANGELOG.md +7 -0
- package/package.json +3 -3
- package/server/context.d.ts +7 -1
- package/server/hook.d.ts +2 -0
- package/server/utils.d.ts +34 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.29.0",
|
|
19
19
|
"types": "./index.d.ts",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"http-proxy-middleware": "^2.0.4",
|
|
46
46
|
"jest": "^29",
|
|
47
47
|
"type-fest": "2.15.0",
|
|
48
|
-
"@scripts/
|
|
49
|
-
"@scripts/
|
|
48
|
+
"@scripts/jest-config": "2.29.0",
|
|
49
|
+
"@scripts/build": "2.29.0"
|
|
50
50
|
},
|
|
51
51
|
"sideEffects": false,
|
|
52
52
|
"publishConfig": {
|
package/server/context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
|
|
2
2
|
import qs from 'querystring';
|
|
3
3
|
import type { SSRMode } from 'common';
|
|
4
|
-
import { Metrics, Logger } from './utils';
|
|
4
|
+
import { Metrics, Logger, Reporter, ServerTiming } from './utils';
|
|
5
5
|
|
|
6
6
|
export interface ModernServerContext {
|
|
7
7
|
req: IncomingMessage;
|
|
@@ -14,6 +14,10 @@ export interface ModernServerContext {
|
|
|
14
14
|
|
|
15
15
|
metrics: Metrics;
|
|
16
16
|
|
|
17
|
+
reporter: Reporter;
|
|
18
|
+
|
|
19
|
+
serverTiming: ServerTiming;
|
|
20
|
+
|
|
17
21
|
setParams: (params: Record<string, string>) => void;
|
|
18
22
|
|
|
19
23
|
getReqHeader: (key: string) => void;
|
|
@@ -86,6 +90,8 @@ export type BaseSSRServerContext = {
|
|
|
86
90
|
tags: Record<string, unknown> = {},
|
|
87
91
|
) => void;
|
|
88
92
|
};
|
|
93
|
+
reporter: Reporter;
|
|
94
|
+
serverTiming: ServerTiming;
|
|
89
95
|
cacheConfig?: any;
|
|
90
96
|
|
|
91
97
|
enableUnsafeCtx?: boolean;
|
package/server/hook.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
|
|
2
|
+
import { Reporter } from './utils';
|
|
2
3
|
|
|
3
4
|
export type CookieAPI = {
|
|
4
5
|
/**
|
|
@@ -35,6 +36,7 @@ export type HookContext = {
|
|
|
35
36
|
response: ModernResponse;
|
|
36
37
|
request: ModernRequest;
|
|
37
38
|
logger: Logger;
|
|
39
|
+
reporter?: Reporter;
|
|
38
40
|
metrics?: Metrics;
|
|
39
41
|
};
|
|
40
42
|
|
package/server/utils.d.ts
CHANGED
|
@@ -19,6 +19,40 @@ export type Logger = {
|
|
|
19
19
|
log: LoggerFunction;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
export interface ServerTiming {
|
|
23
|
+
addServeTiming: (name: string, dur: number, decs?: string) => this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type Reporter = {
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
userId?: string;
|
|
29
|
+
client?: any;
|
|
30
|
+
|
|
31
|
+
init: (payload: { match: any }) => void | Promise<void>;
|
|
32
|
+
|
|
33
|
+
reportError: (
|
|
34
|
+
content: string,
|
|
35
|
+
e: Error,
|
|
36
|
+
extra?: Record<string, string | number>,
|
|
37
|
+
) => void;
|
|
38
|
+
|
|
39
|
+
reportTiming: (
|
|
40
|
+
name: string,
|
|
41
|
+
value: number,
|
|
42
|
+
extra?: Record<string, string>,
|
|
43
|
+
) => void;
|
|
44
|
+
|
|
45
|
+
reportInfo: (
|
|
46
|
+
content: string,
|
|
47
|
+
extra?: Record<string, string | number>,
|
|
48
|
+
) => void;
|
|
49
|
+
|
|
50
|
+
reportWarn: (
|
|
51
|
+
content: string,
|
|
52
|
+
extra?: Record<string, string | number>,
|
|
53
|
+
) => void;
|
|
54
|
+
};
|
|
55
|
+
|
|
22
56
|
export type NextFunction = () => void;
|
|
23
57
|
|
|
24
58
|
export type ProxyDetail = ProxyOptions & {
|