@burdenoff/ui-engine 2026.1127.1 → 2026.1127.3
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/README.md +68 -3
- package/dist/capture.js +3 -2
- package/dist/dom-runtime/actions.d.ts +65 -0
- package/dist/dom-runtime/iife.d.ts +1 -0
- package/dist/dom-runtime/index.d.ts +7 -0
- package/dist/dom-runtime/runtime.d.ts +79 -0
- package/dist/dom-runtime.d.ts +2 -0
- package/dist/dom-runtime.iife.js +1 -0
- package/dist/dom-runtime.js +535 -0
- package/dist/{index-05zgh18g.js → index-2kgsgn1c.js} +1 -1
- package/dist/{index-phd8yhyg.js → index-bnvmt4wf.js} +7 -5
- package/dist/{index-c6pmt2rg.js → index-cs6acyjn.js} +6 -59
- package/dist/index-mgztm37r.js +57 -0
- package/dist/index-q1b0j9yr.js +1349 -0
- package/dist/index-zwrxw3zp.js +1988 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +180 -6
- package/dist/recording.js +1 -1
- package/dist/replay.js +2 -2
- package/dist/script/adapters/browser-action-contract.d.ts +22 -0
- package/dist/script/adapters/from-browser-action.d.ts +7 -0
- package/dist/script/adapters/from-remote-browser.d.ts +7 -0
- package/dist/script/adapters/recording.d.ts +25 -0
- package/dist/script/adapters/to-browser-action.d.ts +8 -0
- package/dist/script/canonical.d.ts +6 -0
- package/dist/script/capabilities.d.ts +29 -0
- package/dist/script/describe.d.ts +83 -0
- package/dist/script/fingerprint.d.ts +9 -0
- package/dist/script/hash.d.ts +3 -0
- package/dist/script/index.d.ts +22 -0
- package/dist/script/json-schema.d.ts +4 -0
- package/dist/script/limits.d.ts +61 -0
- package/dist/script/parse.d.ts +31 -0
- package/dist/script/schema.d.ts +87 -0
- package/dist/script/types.d.ts +489 -0
- package/dist/script/walk.d.ts +29 -0
- package/dist/script.d.ts +2 -0
- package/dist/script.js +175 -0
- package/dist/target/aria.d.ts +31 -0
- package/dist/target/dom.d.ts +35 -0
- package/dist/target/index.d.ts +13 -0
- package/dist/target/markers.d.ts +18 -0
- package/dist/target/methods.d.ts +52 -0
- package/dist/target/resolve.d.ts +46 -0
- package/dist/target/snapshot.d.ts +57 -0
- package/dist/target/text.d.ts +23 -0
- package/dist/target/types.d.ts +88 -0
- package/dist/target.d.ts +2 -0
- package/dist/target.js +92 -0
- package/dist/testing/fixtures/ambiguous.d.ts +7 -0
- package/dist/testing/fixtures/iframe.d.ts +6 -0
- package/dist/testing/fixtures/index.d.ts +26 -0
- package/dist/testing/fixtures/invoices-v2.d.ts +8 -0
- package/dist/testing/fixtures/invoices-v3.d.ts +7 -0
- package/dist/testing/fixtures/invoices.d.ts +6 -0
- package/dist/testing/fixtures/login.d.ts +6 -0
- package/dist/testing/fixtures/shadow.d.ts +7 -0
- package/dist/testing/index.d.ts +6 -0
- package/dist/testing/mount.d.ts +18 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +324 -0
- package/package.json +28 -5
- package/schema/ui-script-v1.schema.json +8199 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The zod schema of UI script v1. It checks the shape and the per-field
|
|
3
|
+
* limits; `parse.ts` adds the checks a schema cannot express (unique step ids,
|
|
4
|
+
* element references, total step count, nesting, size, fingerprints and
|
|
5
|
+
* credentials).
|
|
6
|
+
*
|
|
7
|
+
* No field has a zod default and no field is transformed, so a parsed script
|
|
8
|
+
* is exactly the stored one and serialises back unchanged. The JSON Schema in
|
|
9
|
+
* `schema/ui-script-v1.schema.json` is generated from this file
|
|
10
|
+
* (`json-schema.ts`) and its hash is `UI_SCRIPT_SCHEMA_HASH` (`hash.ts`).
|
|
11
|
+
*
|
|
12
|
+
* The recursive parts (expressions, steps) carry ids in a registry that
|
|
13
|
+
* belongs to this module, never zod's global registry, so two copies of the
|
|
14
|
+
* engine in one bundle do not collide.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import { type UiExpression, type UiScript, type UiStep, type UiTarget, type UiTargetRef } from './types.js';
|
|
18
|
+
/** Ids of the named parts of the schema, used as `$defs` names in the JSON Schema. */
|
|
19
|
+
export declare const uiScriptRegistry: z.core.$ZodRegistry<{
|
|
20
|
+
id: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
}, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
23
|
+
/** Variable, input, output and field names: an identifier. */
|
|
24
|
+
export declare const NAME_PATTERN: RegExp;
|
|
25
|
+
/** Step ids (the Stewards saved-step id rule). */
|
|
26
|
+
export declare const STEP_ID_PATTERN: RegExp;
|
|
27
|
+
/** Element keys inside a script. */
|
|
28
|
+
export declare const ELEMENT_KEY_PATTERN: RegExp;
|
|
29
|
+
export declare const uiExpressionSchema: z.ZodType<UiExpression>;
|
|
30
|
+
export declare const uiTargetMethodSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
31
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
kind: z.ZodLiteral<"role">;
|
|
33
|
+
role: z.ZodString;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
nth: z.ZodOptional<z.ZodInt>;
|
|
36
|
+
app: z.ZodOptional<z.ZodString>;
|
|
37
|
+
window: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
39
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
kind: z.ZodLiteral<"css">;
|
|
41
|
+
selector: z.ZodString;
|
|
42
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
43
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
kind: z.ZodLiteral<"testId">;
|
|
45
|
+
value: z.ZodString;
|
|
46
|
+
attribute: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
48
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
kind: z.ZodLiteral<"xpath">;
|
|
50
|
+
xpath: z.ZodString;
|
|
51
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
52
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
kind: z.ZodLiteral<"fuzzy">;
|
|
54
|
+
role: z.ZodOptional<z.ZodString>;
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
threshold: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
+
kind: z.ZodLiteral<"anchor">;
|
|
60
|
+
anchor: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
61
|
+
kind: z.ZodLiteral<"text">;
|
|
62
|
+
text: z.ZodString;
|
|
63
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
64
|
+
kind: z.ZodLiteral<"role">;
|
|
65
|
+
role: z.ZodString;
|
|
66
|
+
name: z.ZodString;
|
|
67
|
+
}, z.core.$strict>], "kind">;
|
|
68
|
+
relation: z.ZodEnum<{
|
|
69
|
+
leftOf: "leftOf";
|
|
70
|
+
rightOf: "rightOf";
|
|
71
|
+
above: "above";
|
|
72
|
+
below: "below";
|
|
73
|
+
inside: "inside";
|
|
74
|
+
sameRow: "sameRow";
|
|
75
|
+
}>;
|
|
76
|
+
role: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
78
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
kind: z.ZodLiteral<"text">;
|
|
80
|
+
text: z.ZodString;
|
|
81
|
+
exact: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
nth: z.ZodOptional<z.ZodInt>;
|
|
83
|
+
}, z.core.$strict>], "kind">;
|
|
84
|
+
export declare const uiTargetSchema: z.ZodType<UiTarget>;
|
|
85
|
+
export declare const uiTargetRefSchema: z.ZodType<UiTargetRef>;
|
|
86
|
+
export declare const uiStepSchema: z.ZodType<UiStep>;
|
|
87
|
+
export declare const uiScriptSchema: z.ZodType<UiScript>;
|
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI script v1: the portable form of a UI sequence that a desk runs
|
|
3
|
+
* (spec 03 section 5, spec 05, plan P0-04).
|
|
4
|
+
*
|
|
5
|
+
* These are the TypeScript types; `schema.ts` holds the zod schema that
|
|
6
|
+
* validates them and `schema/ui-script-v1.schema.json` the JSON Schema
|
|
7
|
+
* generated from it. A script holds data only. Optional fields are left out
|
|
8
|
+
* rather than defaulted, so parsing never rewrites a script and a parsed
|
|
9
|
+
* script serialises back to exactly what was stored; each field documents
|
|
10
|
+
* the default an interpreter applies when it is absent.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The operators of the expression language. An expression is a JSON tree
|
|
14
|
+
* (no text to parse), side-effect free, evaluated over the script's inputs
|
|
15
|
+
* and variables only (spec 03 section 5.1). `if` evaluates only the branch
|
|
16
|
+
* it takes, and `and`/`or` short-circuit.
|
|
17
|
+
*/
|
|
18
|
+
export declare const UI_EXPRESSION_OPS: readonly ["eq", "ne", "lt", "le", "gt", "ge", "and", "or", "not", "add", "sub", "mul", "div", "mod", "neg", "abs", "round", "min", "max", "concat", "contains", "startsWith", "endsWith", "lower", "upper", "trim", "replace", "split", "join", "length", "toNumber", "toText", "toBoolean", "isEmpty", "coalesce", "if", "get", "now", "formatDate", "addDays"];
|
|
19
|
+
export type UiExpressionOp = (typeof UI_EXPRESSION_OPS)[number];
|
|
20
|
+
/** A path into a structured value: object keys and list indexes. */
|
|
21
|
+
export type UiValuePath = Array<string | number>;
|
|
22
|
+
/**
|
|
23
|
+
* An expression: a literal (text, number, true or false, null), a reference
|
|
24
|
+
* to an input or a variable (with an optional path into it), a list or an
|
|
25
|
+
* object of expressions, or an operator applied to arguments.
|
|
26
|
+
*/
|
|
27
|
+
export type UiExpression = string | number | boolean | null | {
|
|
28
|
+
input: string;
|
|
29
|
+
path?: UiValuePath;
|
|
30
|
+
} | {
|
|
31
|
+
var: string;
|
|
32
|
+
path?: UiValuePath;
|
|
33
|
+
} | {
|
|
34
|
+
list: UiExpression[];
|
|
35
|
+
} | {
|
|
36
|
+
object: Record<string, UiExpression>;
|
|
37
|
+
} | {
|
|
38
|
+
op: UiExpressionOp;
|
|
39
|
+
args: UiExpression[];
|
|
40
|
+
};
|
|
41
|
+
interface MethodBase {
|
|
42
|
+
/** The editor's on or off switch for this method. Absent means on. */
|
|
43
|
+
enabled?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Strict accessibility match: role and accessible name, the n-th among equal
|
|
47
|
+
* matches. A superset of the Stewards saved-step target (`app` and `window`
|
|
48
|
+
* for desktop desks), so a saved step maps onto a UI script without loss.
|
|
49
|
+
*/
|
|
50
|
+
export interface UiRoleMethod extends MethodBase {
|
|
51
|
+
kind: 'role';
|
|
52
|
+
role: string;
|
|
53
|
+
name: string;
|
|
54
|
+
/** Which of several equal matches (0 = the first). Absent means 0. */
|
|
55
|
+
nth?: number;
|
|
56
|
+
app?: string;
|
|
57
|
+
window?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Strict DOM match by a CSS selector (the extension's selector generator output). */
|
|
60
|
+
export interface UiCssMethod extends MethodBase {
|
|
61
|
+
kind: 'css';
|
|
62
|
+
selector: string;
|
|
63
|
+
}
|
|
64
|
+
/** Strict DOM match by a test id attribute. */
|
|
65
|
+
export interface UiTestIdMethod extends MethodBase {
|
|
66
|
+
kind: 'testId';
|
|
67
|
+
value: string;
|
|
68
|
+
/** The attribute that holds the id. Absent means `data-testid`. */
|
|
69
|
+
attribute?: string;
|
|
70
|
+
}
|
|
71
|
+
/** Strict DOM match by an XPath expression. */
|
|
72
|
+
export interface UiXPathMethod extends MethodBase {
|
|
73
|
+
kind: 'xpath';
|
|
74
|
+
xpath: string;
|
|
75
|
+
}
|
|
76
|
+
/** Fuzzy match: role and name with a similarity threshold on the name. */
|
|
77
|
+
export interface UiFuzzyMethod extends MethodBase {
|
|
78
|
+
kind: 'fuzzy';
|
|
79
|
+
role?: string;
|
|
80
|
+
name: string;
|
|
81
|
+
/** Lowest accepted similarity, 0.5 to 1. Absent means 0.8. */
|
|
82
|
+
threshold?: number;
|
|
83
|
+
}
|
|
84
|
+
/** What an anchor method is anchored to: a visible text or an accessible element. */
|
|
85
|
+
export type UiAnchor = {
|
|
86
|
+
kind: 'text';
|
|
87
|
+
text: string;
|
|
88
|
+
} | {
|
|
89
|
+
kind: 'role';
|
|
90
|
+
role: string;
|
|
91
|
+
name: string;
|
|
92
|
+
};
|
|
93
|
+
/** The relation between the anchor and the element. */
|
|
94
|
+
export declare const UI_ANCHOR_RELATIONS: readonly ["leftOf", "rightOf", "above", "below", "inside", "sameRow"];
|
|
95
|
+
export type UiAnchorRelation = (typeof UI_ANCHOR_RELATIONS)[number];
|
|
96
|
+
/** Anchor match: the element of a role that stands in a relation to an anchor (usually its label). */
|
|
97
|
+
export interface UiAnchorMethod extends MethodBase {
|
|
98
|
+
kind: 'anchor';
|
|
99
|
+
anchor: UiAnchor;
|
|
100
|
+
relation: UiAnchorRelation;
|
|
101
|
+
/** The element's own role, to tell it from other elements beside the anchor. */
|
|
102
|
+
role?: string;
|
|
103
|
+
}
|
|
104
|
+
/** Visible text match, the n-th occurrence. */
|
|
105
|
+
export interface UiTextMethod extends MethodBase {
|
|
106
|
+
kind: 'text';
|
|
107
|
+
text: string;
|
|
108
|
+
/** Whole-text match. Absent means a case-insensitive contains match. */
|
|
109
|
+
exact?: boolean;
|
|
110
|
+
/** Which occurrence (0 = the first). Absent means 0. */
|
|
111
|
+
nth?: number;
|
|
112
|
+
}
|
|
113
|
+
/** The target methods of v1, in the order the spec lists them. Image and model methods come later. */
|
|
114
|
+
export declare const UI_TARGET_METHOD_KINDS: readonly ["role", "css", "testId", "xpath", "fuzzy", "anchor", "text"];
|
|
115
|
+
export type UiTargetMethodKind = (typeof UI_TARGET_METHOD_KINDS)[number];
|
|
116
|
+
export type UiTargetMethod = UiRoleMethod | UiCssMethod | UiTestIdMethod | UiXPathMethod | UiFuzzyMethod | UiAnchorMethod | UiTextMethod;
|
|
117
|
+
/**
|
|
118
|
+
* A target: an ordered list of methods. The engine tries them in order and
|
|
119
|
+
* uses the first that finds exactly one visible, enabled element (spec 05
|
|
120
|
+
* section 3.1).
|
|
121
|
+
*/
|
|
122
|
+
export interface UiTarget {
|
|
123
|
+
methods: UiTargetMethod[];
|
|
124
|
+
/** Web: the chain of frames and shadow hosts (CSS selectors, outermost first) the element sits in. */
|
|
125
|
+
frame?: string[];
|
|
126
|
+
}
|
|
127
|
+
/** A reference to a library element the script pins (a key of `UiScript.elements`). */
|
|
128
|
+
export interface UiElementRef {
|
|
129
|
+
element: string;
|
|
130
|
+
}
|
|
131
|
+
/** Where a step acts: an inline target, or a pinned library element. */
|
|
132
|
+
export type UiTargetRef = UiTarget | UiElementRef;
|
|
133
|
+
/** A library element pinned by version. The worker fills `target` when it compiles the script. */
|
|
134
|
+
export interface UiScriptElement {
|
|
135
|
+
elementId: string;
|
|
136
|
+
version: number;
|
|
137
|
+
name?: string;
|
|
138
|
+
target?: UiTarget;
|
|
139
|
+
}
|
|
140
|
+
/** An expected outcome checked after a step acts (spec 05 section 3.3). */
|
|
141
|
+
export type UiVerify = {
|
|
142
|
+
kind: 'elementVisible';
|
|
143
|
+
target: UiTargetRef;
|
|
144
|
+
timeoutMs?: number;
|
|
145
|
+
} | {
|
|
146
|
+
kind: 'elementGone';
|
|
147
|
+
target: UiTargetRef;
|
|
148
|
+
timeoutMs?: number;
|
|
149
|
+
} | {
|
|
150
|
+
kind: 'urlContains';
|
|
151
|
+
value: UiExpression;
|
|
152
|
+
timeoutMs?: number;
|
|
153
|
+
} | {
|
|
154
|
+
kind: 'textPresent';
|
|
155
|
+
text: UiExpression;
|
|
156
|
+
timeoutMs?: number;
|
|
157
|
+
} | {
|
|
158
|
+
kind: 'valueEquals';
|
|
159
|
+
target: UiTargetRef;
|
|
160
|
+
value: UiExpression;
|
|
161
|
+
timeoutMs?: number;
|
|
162
|
+
};
|
|
163
|
+
/** Fields every step may carry. */
|
|
164
|
+
export interface UiStepBase {
|
|
165
|
+
/** Unique within the script, across nested blocks. */
|
|
166
|
+
id: string;
|
|
167
|
+
/** What the step does, in the author's words (the Stewards saved-step intent). */
|
|
168
|
+
intent?: string;
|
|
169
|
+
/** A note for the author, such as the recorder's "fill this in" hint. */
|
|
170
|
+
note?: string;
|
|
171
|
+
/** Keeps the step's result under this name: a variable, and a key of the node's `results`. */
|
|
172
|
+
saveAs?: string;
|
|
173
|
+
/** A disabled step is skipped. */
|
|
174
|
+
disabled?: boolean;
|
|
175
|
+
/** Test runs pause before this step; production runs never do. */
|
|
176
|
+
breakpoint?: boolean;
|
|
177
|
+
/** How long the step waits for its target, in ms. Absent means the script settings. */
|
|
178
|
+
timeoutMs?: number;
|
|
179
|
+
/** Retries of the step after a failure. Absent means none. */
|
|
180
|
+
retry?: {
|
|
181
|
+
attempts: number;
|
|
182
|
+
delayMs?: number;
|
|
183
|
+
};
|
|
184
|
+
/** What a failure does after the retries. Absent means `fail` (the node fails). */
|
|
185
|
+
onError?: 'fail' | 'continue';
|
|
186
|
+
/** An outcome to check after acting. A failed check retries the step within its retry limit. */
|
|
187
|
+
verify?: UiVerify;
|
|
188
|
+
/** Screenshot policy for this step. Absent means the script settings. */
|
|
189
|
+
screenshot?: 'never' | 'onFailure' | 'always';
|
|
190
|
+
/** Input method (spec 05 section 4). Absent means `auto`. */
|
|
191
|
+
inputMethod?: 'auto' | 'direct' | 'hardware';
|
|
192
|
+
/** The step can run again after an interruption without a second outward effect. Absent means false. */
|
|
193
|
+
safeToRepeat?: boolean;
|
|
194
|
+
/** A masked screenshot of the step (storage key), from a Stewards recording. */
|
|
195
|
+
screenshotRef?: string;
|
|
196
|
+
/** Integrity check over the step's action and target (`uiStepFingerprint`); a changed target fails to parse. */
|
|
197
|
+
fingerprint?: string;
|
|
198
|
+
}
|
|
199
|
+
/** A field an extract step reads. */
|
|
200
|
+
export interface UiExtractField {
|
|
201
|
+
name: string;
|
|
202
|
+
target: UiTargetRef;
|
|
203
|
+
/** `text`, `html`, `value` or an attribute name. Absent means text, or the value of a form control. */
|
|
204
|
+
attribute?: string;
|
|
205
|
+
/** Read every match as a list. Absent means the single match. */
|
|
206
|
+
all?: boolean;
|
|
207
|
+
}
|
|
208
|
+
export interface UiNavigateStep extends UiStepBase {
|
|
209
|
+
action: 'navigate';
|
|
210
|
+
url: UiExpression;
|
|
211
|
+
/** Absent means `load`. */
|
|
212
|
+
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
|
|
213
|
+
}
|
|
214
|
+
export interface UiGoBackStep extends UiStepBase {
|
|
215
|
+
action: 'goBack';
|
|
216
|
+
}
|
|
217
|
+
export interface UiReloadStep extends UiStepBase {
|
|
218
|
+
action: 'reload';
|
|
219
|
+
}
|
|
220
|
+
export interface UiCloseTabStep extends UiStepBase {
|
|
221
|
+
action: 'closeTab';
|
|
222
|
+
}
|
|
223
|
+
export interface UiClickStep extends UiStepBase {
|
|
224
|
+
action: 'click';
|
|
225
|
+
target: UiTargetRef;
|
|
226
|
+
/** Absent means `left`. */
|
|
227
|
+
button?: 'left' | 'right';
|
|
228
|
+
}
|
|
229
|
+
export interface UiDoubleClickStep extends UiStepBase {
|
|
230
|
+
action: 'doubleClick';
|
|
231
|
+
target: UiTargetRef;
|
|
232
|
+
/** Absent means `left`. */
|
|
233
|
+
button?: 'left' | 'right';
|
|
234
|
+
}
|
|
235
|
+
export interface UiHoverStep extends UiStepBase {
|
|
236
|
+
action: 'hover';
|
|
237
|
+
target: UiTargetRef;
|
|
238
|
+
}
|
|
239
|
+
export interface UiTypeStep extends UiStepBase {
|
|
240
|
+
action: 'type';
|
|
241
|
+
/** Absent means the focused element. */
|
|
242
|
+
target?: UiTargetRef;
|
|
243
|
+
/**
|
|
244
|
+
* Absent when the recorder masked the value. A step with neither text nor
|
|
245
|
+
* `masked` (possible in a Stewards recording) types nothing until an author
|
|
246
|
+
* gives it a value.
|
|
247
|
+
*/
|
|
248
|
+
text?: UiExpression;
|
|
249
|
+
/** The recorder masked the typed value: the step carries no text and needs a value before it can run. */
|
|
250
|
+
masked?: boolean;
|
|
251
|
+
/** Replace the field's content. Absent means true. */
|
|
252
|
+
clear?: boolean;
|
|
253
|
+
/** Press Enter after typing. Absent means false. */
|
|
254
|
+
pressEnter?: boolean;
|
|
255
|
+
/** Type character by character with this delay, in ms. Absent means set the value at once. */
|
|
256
|
+
delayMs?: number;
|
|
257
|
+
}
|
|
258
|
+
export interface UiTypeSecretStep extends UiStepBase {
|
|
259
|
+
action: 'typeSecret';
|
|
260
|
+
target: UiTargetRef;
|
|
261
|
+
/** A secret reference (vault or connection field); the value never appears in the script. */
|
|
262
|
+
secretRef: string;
|
|
263
|
+
/** The page origin the secret may be typed into. */
|
|
264
|
+
expectedOrigin?: string;
|
|
265
|
+
}
|
|
266
|
+
export interface UiClearStep extends UiStepBase {
|
|
267
|
+
action: 'clear';
|
|
268
|
+
target: UiTargetRef;
|
|
269
|
+
}
|
|
270
|
+
export interface UiSelectStep extends UiStepBase {
|
|
271
|
+
action: 'select';
|
|
272
|
+
target: UiTargetRef;
|
|
273
|
+
/** Option values or labels; more than one for a multiple select. */
|
|
274
|
+
values: UiExpression[];
|
|
275
|
+
}
|
|
276
|
+
export interface UiCheckStep extends UiStepBase {
|
|
277
|
+
action: 'check';
|
|
278
|
+
target: UiTargetRef;
|
|
279
|
+
/** Absent means true (check). */
|
|
280
|
+
checked?: boolean;
|
|
281
|
+
}
|
|
282
|
+
export interface UiPressKeyStep extends UiStepBase {
|
|
283
|
+
action: 'pressKey';
|
|
284
|
+
/** Keys pressed together, such as ["Enter"] or ["Control", "A"]. */
|
|
285
|
+
keys: string[];
|
|
286
|
+
/** Absent means the focused element. */
|
|
287
|
+
target?: UiTargetRef;
|
|
288
|
+
}
|
|
289
|
+
export interface UiScrollStep extends UiStepBase {
|
|
290
|
+
action: 'scroll';
|
|
291
|
+
/** The element to scroll into view or to scroll inside. Absent means the page. */
|
|
292
|
+
target?: UiTargetRef;
|
|
293
|
+
dx?: number;
|
|
294
|
+
dy?: number;
|
|
295
|
+
to?: 'top' | 'bottom';
|
|
296
|
+
}
|
|
297
|
+
export interface UiWaitForStep extends UiStepBase {
|
|
298
|
+
action: 'waitFor';
|
|
299
|
+
/** Exactly one of target, text, urlContains and milliseconds. */
|
|
300
|
+
target?: UiTargetRef;
|
|
301
|
+
text?: UiExpression;
|
|
302
|
+
urlContains?: UiExpression;
|
|
303
|
+
milliseconds?: number;
|
|
304
|
+
/** With a target. Absent means `visible`. */
|
|
305
|
+
state?: 'visible' | 'hidden' | 'attached' | 'detached';
|
|
306
|
+
}
|
|
307
|
+
export interface UiExtractStep extends UiStepBase {
|
|
308
|
+
action: 'extract';
|
|
309
|
+
fields: UiExtractField[];
|
|
310
|
+
}
|
|
311
|
+
export interface UiExtractListStep extends UiStepBase {
|
|
312
|
+
action: 'extractList';
|
|
313
|
+
/** Each repeated item; the field targets are searched inside it. */
|
|
314
|
+
item: UiTargetRef;
|
|
315
|
+
fields: UiExtractField[];
|
|
316
|
+
/** Absent means 100. */
|
|
317
|
+
maxItems?: number;
|
|
318
|
+
/** The control that opens the next page. */
|
|
319
|
+
next?: UiTargetRef;
|
|
320
|
+
/** Absent means 1. */
|
|
321
|
+
maxPages?: number;
|
|
322
|
+
}
|
|
323
|
+
export interface UiGetTextStep extends UiStepBase {
|
|
324
|
+
action: 'getText';
|
|
325
|
+
target: UiTargetRef;
|
|
326
|
+
}
|
|
327
|
+
export interface UiGetValueStep extends UiStepBase {
|
|
328
|
+
action: 'getValue';
|
|
329
|
+
target: UiTargetRef;
|
|
330
|
+
}
|
|
331
|
+
export interface UiGetAttributeStep extends UiStepBase {
|
|
332
|
+
action: 'getAttribute';
|
|
333
|
+
target: UiTargetRef;
|
|
334
|
+
attribute: string;
|
|
335
|
+
}
|
|
336
|
+
export interface UiElementExistsStep extends UiStepBase {
|
|
337
|
+
action: 'elementExists';
|
|
338
|
+
target: UiTargetRef;
|
|
339
|
+
}
|
|
340
|
+
export interface UiGetPageTextStep extends UiStepBase {
|
|
341
|
+
action: 'getPageText';
|
|
342
|
+
}
|
|
343
|
+
export interface UiGetPageHtmlStep extends UiStepBase {
|
|
344
|
+
action: 'getPageHtml';
|
|
345
|
+
}
|
|
346
|
+
export interface UiScreenshotStep extends UiStepBase {
|
|
347
|
+
action: 'screenshot';
|
|
348
|
+
/** Absent means the visible page. */
|
|
349
|
+
target?: UiTargetRef;
|
|
350
|
+
fullPage?: boolean;
|
|
351
|
+
}
|
|
352
|
+
/** Sign in through the node's Browser Login connection (remote browsers). Absent targets use the defaults. */
|
|
353
|
+
export interface UiLoginStep extends UiStepBase {
|
|
354
|
+
action: 'login';
|
|
355
|
+
username?: UiTargetRef;
|
|
356
|
+
password?: UiTargetRef;
|
|
357
|
+
submit?: UiTargetRef;
|
|
358
|
+
success?: UiTargetRef;
|
|
359
|
+
}
|
|
360
|
+
export interface UiFocusWindowStep extends UiStepBase {
|
|
361
|
+
action: 'focusWindow';
|
|
362
|
+
app: string;
|
|
363
|
+
title?: string;
|
|
364
|
+
}
|
|
365
|
+
export interface UiIfStep extends UiStepBase {
|
|
366
|
+
action: 'if';
|
|
367
|
+
/** Exactly one of condition and elementExists. */
|
|
368
|
+
condition?: UiExpression;
|
|
369
|
+
elementExists?: UiTargetRef;
|
|
370
|
+
then: UiStep[];
|
|
371
|
+
else?: UiStep[];
|
|
372
|
+
}
|
|
373
|
+
export interface UiForEachStep extends UiStepBase {
|
|
374
|
+
action: 'forEach';
|
|
375
|
+
/** Exactly one: a list expression, or every element a target matches. */
|
|
376
|
+
in?: UiExpression;
|
|
377
|
+
elements?: UiTargetRef;
|
|
378
|
+
/** The variable that holds the current item. */
|
|
379
|
+
as: string;
|
|
380
|
+
/** The variable that holds the current index, from 0. */
|
|
381
|
+
index?: string;
|
|
382
|
+
/** Most iterations. Absent means the engine limit. */
|
|
383
|
+
max?: number;
|
|
384
|
+
steps: UiStep[];
|
|
385
|
+
}
|
|
386
|
+
export interface UiWhileStep extends UiStepBase {
|
|
387
|
+
action: 'while';
|
|
388
|
+
/** Exactly one of condition and elementExists. */
|
|
389
|
+
condition?: UiExpression;
|
|
390
|
+
elementExists?: UiTargetRef;
|
|
391
|
+
/** Mandatory: a while block always has a limit. */
|
|
392
|
+
maxIterations: number;
|
|
393
|
+
steps: UiStep[];
|
|
394
|
+
}
|
|
395
|
+
export interface UiRetryScopeStep extends UiStepBase {
|
|
396
|
+
action: 'retryScope';
|
|
397
|
+
attempts: number;
|
|
398
|
+
delayMs?: number;
|
|
399
|
+
steps: UiStep[];
|
|
400
|
+
}
|
|
401
|
+
export interface UiSetStep extends UiStepBase {
|
|
402
|
+
action: 'set';
|
|
403
|
+
name: string;
|
|
404
|
+
value: UiExpression;
|
|
405
|
+
}
|
|
406
|
+
export interface UiLogStep extends UiStepBase {
|
|
407
|
+
action: 'log';
|
|
408
|
+
/** Absent means `info`. */
|
|
409
|
+
level?: 'debug' | 'info' | 'warn' | 'error';
|
|
410
|
+
message: UiExpression;
|
|
411
|
+
}
|
|
412
|
+
/** A call to a shared sequence, pinned by version. The worker inlines calls when it compiles the script. */
|
|
413
|
+
export interface UiCallStep extends UiStepBase {
|
|
414
|
+
action: 'call';
|
|
415
|
+
sequenceId: string;
|
|
416
|
+
version: number;
|
|
417
|
+
args?: Record<string, UiExpression>;
|
|
418
|
+
}
|
|
419
|
+
export type UiWebStep = UiNavigateStep | UiGoBackStep | UiReloadStep | UiCloseTabStep | UiClickStep | UiDoubleClickStep | UiHoverStep | UiTypeStep | UiTypeSecretStep | UiClearStep | UiSelectStep | UiCheckStep | UiPressKeyStep | UiScrollStep | UiWaitForStep | UiExtractStep | UiExtractListStep | UiGetTextStep | UiGetValueStep | UiGetAttributeStep | UiElementExistsStep | UiGetPageTextStep | UiGetPageHtmlStep | UiScreenshotStep | UiLoginStep;
|
|
420
|
+
export type UiDesktopStep = UiFocusWindowStep;
|
|
421
|
+
export type UiFlowStep = UiIfStep | UiForEachStep | UiWhileStep | UiRetryScopeStep | UiSetStep | UiLogStep | UiCallStep;
|
|
422
|
+
export type UiStep = UiWebStep | UiDesktopStep | UiFlowStep;
|
|
423
|
+
export type UiStepAction = UiStep['action'];
|
|
424
|
+
/** Web actions: run on a paired browser, a remote browser or a robot's managed browser. */
|
|
425
|
+
export declare const UI_WEB_ACTIONS: readonly ["navigate", "goBack", "reload", "closeTab", "click", "doubleClick", "hover", "type", "typeSecret", "clear", "select", "check", "pressKey", "scroll", "waitFor", "extract", "extractList", "getText", "getValue", "getAttribute", "elementExists", "getPageText", "getPageHtml", "screenshot", "login"];
|
|
426
|
+
/** Actions that only a desktop desk runs; they arrive from Stewards recordings. */
|
|
427
|
+
export declare const UI_DESKTOP_ACTIONS: readonly ["focusWindow"];
|
|
428
|
+
/** Flow actions inside a sequence. */
|
|
429
|
+
export declare const UI_FLOW_ACTIONS: readonly ["if", "forEach", "while", "retryScope", "set", "log", "call"];
|
|
430
|
+
/** Every v1 action. */
|
|
431
|
+
export declare const UI_STEP_ACTIONS: readonly ["navigate", "goBack", "reload", "closeTab", "click", "doubleClick", "hover", "type", "typeSecret", "clear", "select", "check", "pressKey", "scroll", "waitFor", "extract", "extractList", "getText", "getValue", "getAttribute", "elementExists", "getPageText", "getPageHtml", "screenshot", "login", "focusWindow", "if", "forEach", "while", "retryScope", "set", "log", "call"];
|
|
432
|
+
export declare const UI_VALUE_TYPES: readonly ["text", "number", "boolean", "list", "object", "any"];
|
|
433
|
+
export type UiValueType = (typeof UI_VALUE_TYPES)[number];
|
|
434
|
+
/** A named value the workflow supplies at dispatch. Secrets are never inputs: they are referenced by `typeSecret`. */
|
|
435
|
+
export interface UiScriptInput {
|
|
436
|
+
name: string;
|
|
437
|
+
/** Absent means `any`. */
|
|
438
|
+
type?: UiValueType;
|
|
439
|
+
/** Absent means false. */
|
|
440
|
+
required?: boolean;
|
|
441
|
+
default?: UiExpression;
|
|
442
|
+
description?: string;
|
|
443
|
+
}
|
|
444
|
+
/** A named value the script returns to the workflow, evaluated when the script ends. */
|
|
445
|
+
export interface UiScriptOutput {
|
|
446
|
+
name: string;
|
|
447
|
+
type?: UiValueType;
|
|
448
|
+
value: UiExpression;
|
|
449
|
+
description?: string;
|
|
450
|
+
}
|
|
451
|
+
/** A script-local variable with an optional initial value. */
|
|
452
|
+
export interface UiScriptVariable {
|
|
453
|
+
name: string;
|
|
454
|
+
type?: UiValueType;
|
|
455
|
+
initial?: UiExpression;
|
|
456
|
+
}
|
|
457
|
+
/** The application or page the script works on. */
|
|
458
|
+
export interface UiScriptApplication {
|
|
459
|
+
name?: string;
|
|
460
|
+
/** Pages the script expects, with `*` wildcards (such as `https://portal.example.com/*`). */
|
|
461
|
+
urlPattern?: string;
|
|
462
|
+
}
|
|
463
|
+
/** Script-wide settings. */
|
|
464
|
+
export interface UiScriptSettings {
|
|
465
|
+
/** Wait for the first step on a screen, in ms. Absent means 30000 (spec 05 section 3.3). */
|
|
466
|
+
firstWaitMs?: number;
|
|
467
|
+
/** Wait for later steps, in ms. Absent means 10000. */
|
|
468
|
+
waitMs?: number;
|
|
469
|
+
/** Screenshot policy. Absent means `onFailure`. */
|
|
470
|
+
screenshots?: 'never' | 'onFailure' | 'everyStep';
|
|
471
|
+
/** Absent means `auto`. */
|
|
472
|
+
inputMethod?: 'auto' | 'direct' | 'hardware';
|
|
473
|
+
}
|
|
474
|
+
/** A UI script, version 1. */
|
|
475
|
+
export interface UiScript {
|
|
476
|
+
scriptVersion: 1;
|
|
477
|
+
name?: string;
|
|
478
|
+
application?: UiScriptApplication;
|
|
479
|
+
settings?: UiScriptSettings;
|
|
480
|
+
inputs?: UiScriptInput[];
|
|
481
|
+
outputs?: UiScriptOutput[];
|
|
482
|
+
variables?: UiScriptVariable[];
|
|
483
|
+
/** Library elements the steps refer to, by key. */
|
|
484
|
+
elements?: Record<string, UiScriptElement>;
|
|
485
|
+
steps: UiStep[];
|
|
486
|
+
/** Steps that run when the script ends, after a failure or a cancel too. */
|
|
487
|
+
cleanup?: UiStep[];
|
|
488
|
+
}
|
|
489
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walking a UI script's steps, nested blocks included, with a stable path for
|
|
3
|
+
* each step. A path names a step by its position: `"2"` is the third
|
|
4
|
+
* top-level step, `"2.then.0"` the first step of its `then` block, and
|
|
5
|
+
* `"cleanup.0"` the first clean-up step. The interpreter's step ranges and
|
|
6
|
+
* the step events use the same paths.
|
|
7
|
+
*/
|
|
8
|
+
import type { UiExpression, UiScript, UiStep, UiTargetRef } from './types.js';
|
|
9
|
+
/** The nested blocks of a step, by block name. */
|
|
10
|
+
export declare function childBlocks(step: UiStep): Array<[string, UiStep[]]>;
|
|
11
|
+
/** One step with where it sits. */
|
|
12
|
+
export interface WalkedStep {
|
|
13
|
+
step: UiStep;
|
|
14
|
+
path: string;
|
|
15
|
+
/** Flow blocks around the step (0 for a top-level or clean-up step). */
|
|
16
|
+
depth: number;
|
|
17
|
+
}
|
|
18
|
+
/** Every step of a script in document order: the main steps, then the clean-up block. */
|
|
19
|
+
export declare function walkSteps(script: Pick<UiScript, 'steps' | 'cleanup'>): Generator<WalkedStep>;
|
|
20
|
+
/** Total steps in a script, nested blocks and the clean-up block included. */
|
|
21
|
+
export declare function countSteps(script: Pick<UiScript, 'steps' | 'cleanup'>): number;
|
|
22
|
+
/** The step at a path, or undefined. */
|
|
23
|
+
export declare function stepAtPath(script: Pick<UiScript, 'steps' | 'cleanup'>, path: string): UiStep | undefined;
|
|
24
|
+
/** Every target reference a step holds, with the field it sits in (the step's own blocks excluded). */
|
|
25
|
+
export declare function stepTargets(step: UiStep): Array<[string, UiTargetRef]>;
|
|
26
|
+
/** Every expression a step holds, with the field it sits in (the step's own blocks excluded). */
|
|
27
|
+
export declare function stepExpressions(step: UiStep): Array<[string, UiExpression]>;
|
|
28
|
+
/** Calls `visit` on an expression and every expression inside it, with its depth (the root is 1). */
|
|
29
|
+
export declare function visitExpression(expression: UiExpression, visit: (node: UiExpression, depth: number) => void, depth?: number): void;
|
package/dist/script.d.ts
ADDED