@iflyrpa/share 0.0.15-beta.0 → 0.0.15-beta.2
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 +1 -0
- package/dist/index.js +3410 -8
- package/dist/index.mjs +3399 -5
- package/dist/types.d.ts +145 -47
- package/dist/utils.d.ts +1 -0
- package/package.json +4 -2
package/dist/types.d.ts
CHANGED
|
@@ -1,50 +1,85 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Steel } from "steel-sdk";
|
|
3
|
+
import type { Browser, BrowserContext, Page } from "playwright-core";
|
|
4
|
+
export type Session = Steel.Session;
|
|
2
5
|
export type { Locator, Response, ElectronApplication } from "playwright-core";
|
|
3
|
-
export
|
|
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
|
-
secure?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Whether the cookie should be marked as HTTP only. Defaults to false.
|
|
33
|
-
*/
|
|
34
|
-
httpOnly?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* The expiration date of the cookie as the number of seconds since the UNIX epoch.
|
|
37
|
-
* If omitted then the cookie becomes a session cookie and will not be retained
|
|
38
|
-
* between sessions.
|
|
39
|
-
*/
|
|
40
|
-
expirationDate?: number;
|
|
41
|
-
/**
|
|
42
|
-
* The Same Site policy to apply to this cookie. Can be `unspecified`,
|
|
43
|
-
* `no_restriction`, `lax` or `strict`. Default is `lax`.
|
|
44
|
-
*/
|
|
45
|
-
sameSite?: "unspecified" | "no_restriction" | "lax" | "strict";
|
|
46
|
-
}
|
|
6
|
+
export declare const CookieBaseSchema: z.ZodObject<{
|
|
7
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
8
|
+
path: z.ZodOptional<z.ZodString>;
|
|
9
|
+
expires: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
session: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const CookieSchema: z.ZodObject<{
|
|
15
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
16
|
+
path: z.ZodOptional<z.ZodString>;
|
|
17
|
+
expires: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
session: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
url: z.ZodString;
|
|
22
|
+
name: z.ZodOptional<z.ZodString>;
|
|
23
|
+
value: z.ZodOptional<z.ZodString>;
|
|
24
|
+
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
unspecified: "unspecified";
|
|
26
|
+
no_restriction: "no_restriction";
|
|
27
|
+
lax: "lax";
|
|
28
|
+
strict: "strict";
|
|
29
|
+
}>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type CookiesSetDetails = z.infer<typeof CookieSchema>;
|
|
47
32
|
export type CookieMap = CookiesSetDetails[];
|
|
33
|
+
export declare const CDPSameSite: z.ZodEnum<{
|
|
34
|
+
Strict: "Strict";
|
|
35
|
+
Lax: "Lax";
|
|
36
|
+
None: "None";
|
|
37
|
+
}>;
|
|
38
|
+
export declare const CDPCookiePriority: z.ZodEnum<{
|
|
39
|
+
Low: "Low";
|
|
40
|
+
Medium: "Medium";
|
|
41
|
+
High: "High";
|
|
42
|
+
}>;
|
|
43
|
+
export declare const CDPSourceScheme: z.ZodEnum<{
|
|
44
|
+
Unset: "Unset";
|
|
45
|
+
NonSecure: "NonSecure";
|
|
46
|
+
Secure: "Secure";
|
|
47
|
+
}>;
|
|
48
|
+
export declare const CDPCookieSchema: z.ZodObject<{
|
|
49
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
50
|
+
path: z.ZodOptional<z.ZodString>;
|
|
51
|
+
expires: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
httpOnly: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
secure: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
session: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
value: z.ZodString;
|
|
57
|
+
url: z.ZodOptional<z.ZodString>;
|
|
58
|
+
sameSite: z.ZodOptional<z.ZodEnum<{
|
|
59
|
+
Strict: "Strict";
|
|
60
|
+
Lax: "Lax";
|
|
61
|
+
None: "None";
|
|
62
|
+
}>>;
|
|
63
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
partitionKey: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
topLevelSite: z.ZodString;
|
|
66
|
+
hasCrossSiteAncestor: z.ZodBoolean;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
priority: z.ZodOptional<z.ZodEnum<{
|
|
69
|
+
Low: "Low";
|
|
70
|
+
Medium: "Medium";
|
|
71
|
+
High: "High";
|
|
72
|
+
}>>;
|
|
73
|
+
sameParty: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
sourceScheme: z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
Unset: "Unset";
|
|
76
|
+
NonSecure: "NonSecure";
|
|
77
|
+
Secure: "Secure";
|
|
78
|
+
}>>;
|
|
79
|
+
sourcePort: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
export type CDPCookieDetails = z.infer<typeof CDPCookieSchema>;
|
|
82
|
+
export type CDPCookieMap = CDPCookieDetails[];
|
|
48
83
|
export interface PageParams {
|
|
49
84
|
cookies?: CookieMap;
|
|
50
85
|
url: string;
|
|
@@ -56,6 +91,57 @@ export interface LoggerImplement {
|
|
|
56
91
|
warn(msg: string, extras?: Record<string, unknown>): void;
|
|
57
92
|
error(prefix: string, error?: Error | unknown, extras?: Record<string, unknown>): void;
|
|
58
93
|
}
|
|
94
|
+
export interface UserInfo extends Record<string, unknown> {
|
|
95
|
+
name: string;
|
|
96
|
+
uniqueId: string;
|
|
97
|
+
avatar: string;
|
|
98
|
+
}
|
|
99
|
+
export interface IReportService {
|
|
100
|
+
reportLoginStatus?(status: number, message: string, data: {
|
|
101
|
+
id?: string;
|
|
102
|
+
cookie?: string;
|
|
103
|
+
stage?: 'cookie' | 'connectAddress' | 'scanQrcode';
|
|
104
|
+
connectAddress?: string;
|
|
105
|
+
userInfo?: UserInfo;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
}): Promise<ResponseData>;
|
|
108
|
+
repportTaskStatus?(status: number, message: string, data: {
|
|
109
|
+
id?: string;
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
} | string, stage?: string): Promise<ResponseData>;
|
|
112
|
+
settingSessionID?(sessionID: string): void;
|
|
113
|
+
}
|
|
114
|
+
export declare enum TaskState {
|
|
115
|
+
INIT = "INIT",
|
|
116
|
+
ACTION = "ACTION",
|
|
117
|
+
WAIT_SCAN = "WAIT_SCAN",
|
|
118
|
+
SCANNED = "SCANNED",
|
|
119
|
+
CONFIRMED = "CONFIRMED",
|
|
120
|
+
SUCCESS = "SUCCESS",
|
|
121
|
+
FAILED = "FAILED",
|
|
122
|
+
TIMEOUT = "TIMEOUT"
|
|
123
|
+
}
|
|
124
|
+
export interface TaskStageStore {
|
|
125
|
+
update(id: string, patch: Partial<{
|
|
126
|
+
sessionId?: string;
|
|
127
|
+
state: TaskState;
|
|
128
|
+
connectAddress: string;
|
|
129
|
+
error: string;
|
|
130
|
+
result: {
|
|
131
|
+
cookie?: string;
|
|
132
|
+
token?: string;
|
|
133
|
+
userInfo?: Record<string, unknown>;
|
|
134
|
+
[key: string]: unknown;
|
|
135
|
+
};
|
|
136
|
+
}>): Promise<void>;
|
|
137
|
+
}
|
|
138
|
+
export interface PodImagesData {
|
|
139
|
+
path: string;
|
|
140
|
+
size: number;
|
|
141
|
+
}
|
|
142
|
+
export interface SteelConnector {
|
|
143
|
+
getProxyUrl(sessionId: string, path: string): string;
|
|
144
|
+
}
|
|
59
145
|
export interface AutomateTask {
|
|
60
146
|
debug?: boolean;
|
|
61
147
|
cachePath: string;
|
|
@@ -63,14 +149,26 @@ export interface AutomateTask {
|
|
|
63
149
|
logger: LoggerImplement;
|
|
64
150
|
isInitializedGB: boolean;
|
|
65
151
|
isBeta?: boolean;
|
|
66
|
-
_timerRecord: Record<string,
|
|
152
|
+
_timerRecord: Record<string, number>;
|
|
153
|
+
_steelBrowser?: Browser | null;
|
|
154
|
+
_steelBrowserContext?: BrowserContext;
|
|
155
|
+
_session?: Session | null;
|
|
156
|
+
_client?: Steel | null;
|
|
157
|
+
reportService?: IReportService;
|
|
158
|
+
taskStageStore?: TaskStageStore;
|
|
159
|
+
taskId?: string;
|
|
160
|
+
sessionId?: string;
|
|
161
|
+
steelBrowser?: Browser | null;
|
|
162
|
+
steelBrowserContext?: BrowserContext;
|
|
163
|
+
steelConnector?: SteelConnector;
|
|
164
|
+
steelEnv?: Record<string, unknown>;
|
|
67
165
|
getTmpPath(): string;
|
|
68
166
|
createPage(pageParams: PageParams): Promise<Page>;
|
|
69
167
|
setArticleId(articleId: string): void;
|
|
70
168
|
setSaveType(saveType: string): void;
|
|
71
169
|
setGbInitType(initType: boolean): void;
|
|
72
170
|
isFeatOn(key: string): boolean;
|
|
73
|
-
setTimeConsuming(Record: Record<string,
|
|
171
|
+
setTimeConsuming(Record: Record<string, unknown>): void;
|
|
74
172
|
}
|
|
75
173
|
export type ResponseData<T = any> = {
|
|
76
174
|
code: number;
|
package/dist/utils.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export declare function downloadImage(url: string, savePath: string): Promise<st
|
|
|
12
12
|
export declare function getFilenameFromUrl(imageUrl: string): string;
|
|
13
13
|
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
14
14
|
export declare const success: <T>(data: T, message?: string) => ResponseData<T>;
|
|
15
|
+
export declare const response: <T>(code: number, message: string, data: T) => ResponseData<T>;
|
|
15
16
|
export declare const randomString: (length: number) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iflyrpa/share",
|
|
3
|
-
"version": "0.0.15-beta.
|
|
3
|
+
"version": "0.0.15-beta.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
],
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@rslib/core": "^0.4.1",
|
|
14
|
-
"playwright-core": "1.46.1"
|
|
14
|
+
"playwright-core": "1.46.1",
|
|
15
|
+
"steel-sdk": "0.11.0",
|
|
16
|
+
"zod": "^4.1.12"
|
|
15
17
|
},
|
|
16
18
|
"scripts": {
|
|
17
19
|
"build": "rslib build",
|