@hasna/browser 0.2.0 → 0.2.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.
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Login scripts — multi-step workflows that combine browser actions + connector calls.
3
+ * Supports variable interpolation, regex extraction, conditions, and state saving.
4
+ *
5
+ * Usage: save a script once, replay with `browser login-script <name>`
6
+ */
7
+ import type { Page } from "playwright";
8
+ export type StepType = "browser" | "connector" | "extract" | "wait" | "condition" | "save_state";
9
+ export interface ScriptStep {
10
+ type: StepType;
11
+ description?: string;
12
+ action?: "navigate" | "type" | "click" | "click_text" | "wait_for_navigation" | "wait_for_text" | "snapshot";
13
+ url?: string;
14
+ selector?: string;
15
+ text?: string;
16
+ value?: string;
17
+ timeout?: number;
18
+ connector?: string;
19
+ args?: string[];
20
+ format?: string;
21
+ pattern?: string;
22
+ json_path?: string;
23
+ save_as?: string;
24
+ seconds?: number;
25
+ check?: string;
26
+ equals?: string;
27
+ contains?: string;
28
+ skip_to?: number;
29
+ name?: string;
30
+ }
31
+ export interface LoginScript {
32
+ name: string;
33
+ domain: string;
34
+ description?: string;
35
+ variables: Record<string, string>;
36
+ steps: ScriptStep[];
37
+ created_at: string;
38
+ updated_at: string;
39
+ }
40
+ export interface ScriptRunResult {
41
+ success: boolean;
42
+ steps_executed: number;
43
+ steps_failed: number;
44
+ variables: Record<string, string>;
45
+ errors: string[];
46
+ duration_ms: number;
47
+ }
48
+ export interface ScriptJob {
49
+ id: string;
50
+ script_name: string;
51
+ status: "running" | "completed" | "failed";
52
+ current_step: number;
53
+ total_steps: number;
54
+ current_step_description: string;
55
+ steps_log: Array<{
56
+ step: number;
57
+ type: string;
58
+ description: string;
59
+ status: "ok" | "failed" | "running";
60
+ duration_ms?: number;
61
+ error?: string;
62
+ }>;
63
+ result?: ScriptRunResult;
64
+ started_at: string;
65
+ }
66
+ export declare function getJob(jobId: string): ScriptJob | null;
67
+ export declare function listJobs(): ScriptJob[];
68
+ export declare function saveScript(script: LoginScript): string;
69
+ export declare function loadScript(name: string): LoginScript | null;
70
+ export declare function listScripts(): Array<{
71
+ name: string;
72
+ domain: string;
73
+ description?: string;
74
+ steps: number;
75
+ }>;
76
+ export declare function deleteScript(name: string): boolean;
77
+ export declare function runScript(script: LoginScript, page: Page, overrides?: Record<string, string>, jobId?: string): Promise<ScriptRunResult>;
78
+ /**
79
+ * Run a script asynchronously — returns immediately with a job ID.
80
+ * Poll with getJob(jobId) for progress.
81
+ */
82
+ export declare function runScriptAsync(script: LoginScript, page: Page, overrides?: Record<string, string>): string;
83
+ export declare function createUsestableScript(email: string): LoginScript;
84
+ //# sourceMappingURL=login-scripts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-scripts.d.ts","sourceRoot":"","sources":["../../src/lib/login-scripts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;AAEjG,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,qBAAqB,GAAG,eAAe,GAAG,UAAU,CAAC;IAC7G,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,OAAO,CAAC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