-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype.d.ts
101 lines (92 loc) · 2.43 KB
/
type.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import init from '@/spider/init.ts';
export {};
type WaitMixin<T extends Record<string, any>> = {
/** 操作结束后等待时间(毫秒) */
wait?: number;
} & T;
declare global {
namespace NodeJS {
interface ProcessEnv {
SHOW_BROWSER: 'true' | 'false';
FORCE_USE_PROXY: 'true' | 'false';
PROXY: string;
RETRY_TIMES: string;
LOG_MESSAGE_DIR: string;
DATABASE: 'sqlite' | 'mysql' | 'sqlserver';
}
}
type Visit = WaitMixin<{
/** 访问网页 */
type: 'visit';
/** 用于后续操作辨认网页是哪个 */
id: string;
input: `${'http' | 'https'}://${string}.${string}`;
}>;
type AutoLogin = WaitMixin<{
/** 登录 */
type: 'login';
id: 'qyyjt' | 'qcc';
mode: 'auto' | 'manual';
input?: {
/** 用户名 */
userName: string;
/** 密码 */
password: string;
};
}>;
type Selector = WaitMixin<{
/** 选择网页元素操作 */
type: 'select';
/** 使用前面visit操作的网页 */
id: string;
/** 选择器 */
input: string;
/**
* 处理网页元素
* 函数: 入参select结果,返回Promise<any>,用于后续操作
* text: 将结果转为文本,用于后续操作
* origin: 查询结果不做操作,直接用于后续操作
*/
handle: ((dom: Awaited<ReturnType<Page['$']>>) => Promise<any>) | 'text' | 'origin';
/** 后续操作key tag */
processTag: string;
}>;
type DBConnect = WaitMixin<{
type: 'dbConnect';
id: 'sqlite' | 'mysql';
input: {
/** 数据库地址 */
host: string;
/** 数据库端口 */
port: number;
/** 数据库名称 */
database: string;
/** 用户名 */
user: string;
/** 密码 */
password: string;
}
}>;
type DataBase = WaitMixin<{
id: 'sqlite' | 'mysql';
/** 数据库操作 */
type: 'database';
/** before 取前一步操作, string使用具体的前面定义的processTag */
input: string;
/**
* 操作语句
* 如果包含${processTag},则会将processTag替换为具体的前面操作结果注入
* 例:UPDATE Customers SET ContactName = '${userName}' WHERE CustomerID = 1;
*/
sql?: string;
}>;
type EventList = [
WaitMixin<{
/** 初始化操作 */
type: 'init';
input?: Parameters<typeof init>[0];
}>,
Visit,
...(Visit | Selector | DataBase | AutoLogin | DBConnect)[]
];
}