-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.ts
More file actions
39 lines (34 loc) · 823 Bytes
/
script.ts
File metadata and controls
39 lines (34 loc) · 823 Bytes
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
export type ActionStep = {
type: string;
locator?: string;
url?: string;
value?: string;
args?: string;
};
export type CaptchaStep = {
type: "captcha";
steps: ActionStep[];
};
export type Step = ActionStep | CaptchaStep;
export type SecretSpec = {
placeholder: string;
kind: "username" | "password" | "secret";
};
export type RecordedScript = {
meta?: {
source?: string;
version?: number;
recordedAt?: string;
};
steps: Step[];
secrets: SecretSpec[];
};
export function parseScript(raw: string): RecordedScript {
const parsed = JSON.parse(raw) as RecordedScript;
if (!parsed || !Array.isArray(parsed.steps) || !Array.isArray(parsed.secrets)) {
throw new Error(
"Invalid script format: expected JSON with 'steps' and 'secrets' arrays.",
);
}
return parsed;
}