@tinywork/glass 0.0.4 → 0.0.6
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/dist/index.d.ts +55 -0
- package/package.json +2 -4
- package/src/index.ts +0 -37
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import https from 'node:https';
|
|
6
|
+
import axios from 'axios';
|
|
7
|
+
export type DocSchema = {
|
|
8
|
+
apiId: string;
|
|
9
|
+
groupId: string;
|
|
10
|
+
name: string;
|
|
11
|
+
desc?: string;
|
|
12
|
+
pathname?: string;
|
|
13
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
14
|
+
code?: string;
|
|
15
|
+
modifier?: string;
|
|
16
|
+
modifyTime?: string;
|
|
17
|
+
status: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type GroupSchema = {
|
|
20
|
+
id: string;
|
|
21
|
+
parentId: string | null;
|
|
22
|
+
name: string;
|
|
23
|
+
desc?: string;
|
|
24
|
+
origin?: string;
|
|
25
|
+
prefix?: string;
|
|
26
|
+
status: boolean;
|
|
27
|
+
};
|
|
28
|
+
export interface IGlassContext {
|
|
29
|
+
getItem?: <T>(key: string) => Promise<T>;
|
|
30
|
+
setItem?: <T>(key: string, value: T) => Promise<void>;
|
|
31
|
+
onItemChange?: <T>(key: string, cb: (params: {
|
|
32
|
+
key: string;
|
|
33
|
+
value: T;
|
|
34
|
+
}) => void) => void;
|
|
35
|
+
}
|
|
36
|
+
export interface IGlassExtension {
|
|
37
|
+
install?(context: IGlassContext): Promise<void>;
|
|
38
|
+
activate?(context: IGlassContext): Promise<void>;
|
|
39
|
+
/** 要修改url时,直接在params.url = new URL方式修改 */
|
|
40
|
+
onRequest?(context: IGlassContext, params: {
|
|
41
|
+
url: URL;
|
|
42
|
+
req: http.IncomingMessage;
|
|
43
|
+
res: http.ServerResponse;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
onResponse?(context: IGlassContext, params: {
|
|
46
|
+
url: URL;
|
|
47
|
+
req: http.IncomingMessage;
|
|
48
|
+
res: http.ServerResponse;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
deactivate?(context: IGlassContext): Promise<void>;
|
|
51
|
+
uninstall?(context: IGlassContext): Promise<void>;
|
|
52
|
+
onDocChange?(context: IGlassContext, doc: DocSchema | null, originDoc: DocSchema | null): Promise<boolean>;
|
|
53
|
+
onGroupChange?(context: IGlassContext, group: GroupSchema | null, originGroup: GroupSchema | null): Promise<boolean>;
|
|
54
|
+
}
|
|
55
|
+
export { fs, path, http, https, axios };
|
package/package.json
CHANGED
package/src/index.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import http from 'node:http';
|
|
4
|
-
import https from 'node:https';
|
|
5
|
-
import axios from 'axios';
|
|
6
|
-
|
|
7
|
-
export type DevtoolsContext = {
|
|
8
|
-
getItem?: <T>(key: string) => Promise<T>;
|
|
9
|
-
setItem?: <T>(key: string, value: T) => Promise<void>;
|
|
10
|
-
onItemChange?: <T>(key: string, cb: (params: { key: string; value: T }) => void) => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export interface IDevtoolsExtension {
|
|
14
|
-
install?(context: DevtoolsContext): void | Promise<void>;
|
|
15
|
-
activate?(context: DevtoolsContext): void | Promise<void>;
|
|
16
|
-
/** 要修改url时,直接在params.url = new URL方式修改 */
|
|
17
|
-
onRequest?(
|
|
18
|
-
context: DevtoolsContext,
|
|
19
|
-
params: {
|
|
20
|
-
url: URL;
|
|
21
|
-
req: http.IncomingMessage;
|
|
22
|
-
res: http.ServerResponse;
|
|
23
|
-
}
|
|
24
|
-
): void | Promise<void>;
|
|
25
|
-
onResponse?(
|
|
26
|
-
context: DevtoolsContext,
|
|
27
|
-
params: {
|
|
28
|
-
url: URL;
|
|
29
|
-
req: http.IncomingMessage;
|
|
30
|
-
res: http.ServerResponse;
|
|
31
|
-
}
|
|
32
|
-
): void | Promise<void>;
|
|
33
|
-
deactivate?(context: DevtoolsContext): void | Promise<void>;
|
|
34
|
-
uninstall?(context: DevtoolsContext): void | Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { fs, path, http, https, axios };
|