@allwright.dev/core 0.1.5 → 0.1.7

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 CHANGED
@@ -28,11 +28,25 @@ import { firefox, hooks } from "@allwright.dev/core";
28
28
 
29
29
  const browser = await firefox.launch();
30
30
  const page = browser.page();
31
- const hook = await browser.registerHook(hooks.newPage);
31
+ const hook = await page.registerHook(hooks.newPage);
32
32
  await page.click("a[target=_blank]");
33
33
  const newPage = await hook.wait();
34
34
  ```
35
35
 
36
+ ```ts
37
+ const hook = await page.registerHook(hooks.fileChooser);
38
+ await page.click("button.open-upload");
39
+ const chooser = await hook.wait();
40
+ await chooser.setFiles("fixtures/document.pdf");
41
+ ```
42
+
43
+ ```ts
44
+ const hook = await page.registerHook(hooks.download);
45
+ await page.click("a.download-report");
46
+ const download = await hook.wait();
47
+ await download.saveAs(`artifacts/${download.suggestedFilename}`);
48
+ ```
49
+
36
50
  Runnable examples live in [examples/web-basic.ts](./examples/web-basic.ts) and [examples/android-basic.ts](./examples/android-basic.ts).
37
51
 
38
52
  Shared config files are stack-agnostic and can live in `allwright.config.yaml` or `allwright.config.json`.
package/dist/bootstrap.js CHANGED
@@ -12,7 +12,7 @@ const ALLWRIGHT_HOME_ENV_VAR = "ALLWRIGHT_HOME";
12
12
  const ALLWRIGHT_REPOSITORY_ENV_VAR = "ALLWRIGHT_REPOSITORY";
13
13
  const ALLWRIGHT_VERSION_ENV_VAR = "ALLWRIGHT_VERSION";
14
14
  const DEFAULT_RELEASE_REPOSITORY = "allwright-dev/allwright";
15
- const DEFAULT_RELEASE_VERSION = "0.1.5";
15
+ const DEFAULT_RELEASE_VERSION = "0.1.7";
16
16
  const STARTUP_TIMEOUT_MS = 20_000;
17
17
  const PING_TIMEOUT_MS = 1_000;
18
18
  const PROTO_ROOT = fileURLToPath(new URL("../proto/", import.meta.url));
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Browser, BrowserInfo, BrowserKind, BrowserLaunchState, BrowserType, CommandOptions, Hook, HookType, LaunchOptions, Page } from "./types.js";
1
+ import type { Browser, BrowserInfo, BrowserKind, BrowserLaunchState, BrowserType, CommandOptions, LaunchOptions, Page } from "./types.js";
2
2
  export declare class BrowserTypeImpl implements BrowserType {
3
3
  #private;
4
4
  constructor(browserKind?: BrowserKind);
@@ -16,7 +16,6 @@ export declare class BrowserImpl implements Browser {
16
16
  initialPage(): Page;
17
17
  pages(): Page[];
18
18
  newPage(options?: CommandOptions): Promise<Page>;
19
- registerHook<T>(type: HookType<T>): Promise<Hook<T>>;
20
19
  close(): Promise<void>;
21
20
  ping(message?: string): Promise<string>;
22
21
  browserInfo(): BrowserInfo;
package/dist/browser.js CHANGED
@@ -66,48 +66,6 @@ export class BrowserImpl {
66
66
  }
67
67
  }
68
68
  }
69
- async registerHook(type) {
70
- this.#ensureOpen();
71
- if (type.name !== "newPage") {
72
- throw formatActionError("register hook", `unsupported hook type: ${type.name}`);
73
- }
74
- this.#stream.write({ registerHook: { newPage: {} } });
75
- while (true) {
76
- const event = await this.#queue.next();
77
- if (event.hookRegistered?.hookId) {
78
- const hookId = event.hookRegistered.hookId;
79
- return {
80
- id: hookId,
81
- type,
82
- wait: (options = {}) => this.#waitForHook(hookId, type, options),
83
- };
84
- }
85
- if (event.error?.message) {
86
- throw formatActionError(`register ${type.name} hook`, event.error.message);
87
- }
88
- }
89
- }
90
- async #waitForHook(hookId, type, options) {
91
- this.#ensureOpen();
92
- this.#stream.write({
93
- waitForHook: {
94
- hookId,
95
- retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
96
- },
97
- });
98
- while (true) {
99
- const event = await this.#queue.next();
100
- if (event.hookCompleted?.hookId === hookId) {
101
- if (type.name === "newPage" && event.hookCompleted.newPage?.contextSessionId) {
102
- return this.#createPage(event.hookCompleted.newPage.contextSessionId);
103
- }
104
- throw formatActionError(`wait for ${type.name} hook`, "hook returned an invalid result");
105
- }
106
- if (event.error?.message) {
107
- throw formatActionError(`wait for ${type.name} hook`, event.error.message);
108
- }
109
- }
110
- }
111
69
  async close() {
112
70
  if (this.#closed) {
113
71
  return;
@@ -171,6 +129,7 @@ export class BrowserImpl {
171
129
  runtime: this.#runtime,
172
130
  browserSessionId: this.sessionId,
173
131
  sessionId,
132
+ createPage: (newSessionId) => this.#createPage(newSessionId),
174
133
  });
175
134
  this.#pages.set(sessionId, page);
176
135
  return page;
package/dist/index.d.ts CHANGED
@@ -3,13 +3,15 @@ import { findConfigFile, loadConfigFile, resolveConfig } from "./config.js";
3
3
  import { mobile } from "./mobile.js";
4
4
  import { PageImpl } from "./page.js";
5
5
  import { setServerAddr, shutdown } from "./runtime.js";
6
- import type { Browser, BrowserKind, BrowserType, LaunchOptions, Page, HookType, ResolveConfigOptions, ResolvedAllwrightConfig } from "./types.js";
6
+ import type { Browser, BrowserKind, BrowserType, LaunchOptions, Page, FileChooser, Download, HookType, ResolveConfigOptions, ResolvedAllwrightConfig } from "./types.js";
7
7
  export { findConfigFile, loadConfigFile, resolveConfig, setServerAddr, shutdown };
8
- export type { AccessibilitySnapshotOptions, AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, Hook, HookType, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, LaunchOptions, MobileAndroidConnectOptions, MobileAndroidDevice, MobileAndroidLaunchOptions, MobileAndroidLocator, MobileAndroidApp, Locator, LocatorInfo, MobileSurfaceNamespace, NavigateResult, Page, PageInfo, PressOptions, PressResult, ResolveConfigOptions, ResolvedAllwrightConfig, RetryConfig, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
8
+ export type { AccessibilitySnapshotOptions, AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, Hook, HookType, FileChooser, Download, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, LaunchOptions, MobileAndroidConnectOptions, MobileAndroidDevice, MobileAndroidLaunchOptions, MobileAndroidLocator, MobileAndroidApp, Locator, LocatorInfo, MobileSurfaceNamespace, NavigateResult, Page, PageInfo, PressOptions, PressResult, ResolveConfigOptions, ResolvedAllwrightConfig, RetryConfig, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
9
9
  export declare const chromium: BrowserType;
10
10
  export declare const firefox: BrowserType;
11
11
  export declare const hooks: {
12
12
  newPage: HookType<Page>;
13
+ fileChooser: HookType<FileChooser>;
14
+ download: HookType<Download>;
13
15
  };
14
16
  export { mobile };
15
17
  export type Tab = Page;
package/dist/index.js CHANGED
@@ -9,6 +9,8 @@ export const chromium = new BrowserTypeImpl("chromium");
9
9
  export const firefox = new BrowserTypeImpl("firefox");
10
10
  export const hooks = {
11
11
  newPage: Object.freeze({ name: "newPage" }),
12
+ fileChooser: Object.freeze({ name: "fileChooser" }),
13
+ download: Object.freeze({ name: "download" }),
12
14
  };
13
15
  export { mobile };
14
16
  export async function ping() {
package/dist/page.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import { WebLocatorBuilders, type LocatorFilterOptions } from "./web-locators.js";
2
- import type { AccessibilitySnapshotOptions, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, Locator, NavigateResult, Page, PageInfo, PressOptions, PressResult, RuntimeClient, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult } from "./types.js";
2
+ import type { AccessibilitySnapshotOptions, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, FileChooser, Download, HighlightOptions, HighlightResult, Hook, HookType, Locator, NavigateResult, Page, PageInfo, PressOptions, PressResult, RuntimeClient, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult } from "./types.js";
3
3
  export declare class PageImpl extends WebLocatorBuilders implements Page {
4
4
  #private;
5
5
  constructor(input: PageInfo & {
6
6
  runtime: RuntimeClient;
7
+ createPage?: (sessionId: string) => Page;
7
8
  });
8
9
  readonly sessionId: string;
9
10
  readonly browserSessionId: string;
11
+ registerHook<T>(type: HookType<T>): Promise<Hook<T>>;
12
+ setFileChooserFiles(fileChooserId: string, files: string[], options?: CommandOptions): Promise<void>;
13
+ saveDownload(downloadId: string, path: string, options?: CommandOptions): Promise<void>;
10
14
  locator(selector: string, options?: LocatorFilterOptions): Locator;
11
15
  goto(url: string, options?: CommandOptions): Promise<NavigateResult>;
12
16
  click(selector: string, options?: CommandOptions): Promise<ClickResult>;
@@ -27,3 +31,19 @@ export declare class PageImpl extends WebLocatorBuilders implements Page {
27
31
  navigate(url: string, options?: CommandOptions): Promise<NavigateResult>;
28
32
  dispose(): void;
29
33
  }
34
+ export declare class FileChooserImpl implements FileChooser {
35
+ readonly page: PageImpl;
36
+ readonly id: string;
37
+ readonly multiple: boolean;
38
+ constructor(page: PageImpl, id: string, multiple: boolean);
39
+ isMultiple(): boolean;
40
+ setFiles(files: string | string[], options?: CommandOptions): Promise<void>;
41
+ }
42
+ export declare class DownloadImpl implements Download {
43
+ readonly page: PageImpl;
44
+ readonly id: string;
45
+ readonly url: string;
46
+ readonly suggestedFilename: string;
47
+ constructor(page: PageImpl, id: string, url: string, suggestedFilename: string);
48
+ saveAs(path: string, options?: CommandOptions): Promise<void>;
49
+ }
package/dist/page.js CHANGED
@@ -7,14 +7,125 @@ import { createPageHandle } from "./runtime.js";
7
7
  export class PageImpl extends WebLocatorBuilders {
8
8
  #runtime;
9
9
  #handlePromise = null;
10
+ #createPage;
10
11
  constructor(input) {
11
12
  super();
12
13
  this.#runtime = input.runtime;
13
14
  this.sessionId = input.sessionId;
14
15
  this.browserSessionId = input.browserSessionId;
16
+ this.#createPage = input.createPage ?? ((sessionId) => new PageImpl({
17
+ runtime: this.#runtime,
18
+ browserSessionId: this.browserSessionId,
19
+ sessionId,
20
+ createPage: this.#createPage,
21
+ }));
15
22
  }
16
23
  sessionId;
17
24
  browserSessionId;
25
+ async registerHook(type) {
26
+ if (type.name !== "newPage" && type.name !== "fileChooser" && type.name !== "download") {
27
+ throw formatActionError("register hook", `unsupported hook type: ${type.name}`);
28
+ }
29
+ const handle = await this.#getHandle();
30
+ this.#ensureOpen(handle);
31
+ handle.stream.write({
32
+ surfaceSessionId: this.browserSessionId,
33
+ contextSessionId: this.sessionId,
34
+ registerHook: type.name === "newPage"
35
+ ? { newPage: {} }
36
+ : type.name === "fileChooser"
37
+ ? { fileChooser: {} }
38
+ : { download: {} },
39
+ });
40
+ while (true) {
41
+ const event = await handle.queue.next();
42
+ if (event.hookRegistered?.hookId) {
43
+ const hookId = event.hookRegistered.hookId;
44
+ return {
45
+ id: hookId,
46
+ type,
47
+ wait: (options = {}) => this.#waitForHook(hookId, type, options),
48
+ };
49
+ }
50
+ if (event.error?.message) {
51
+ throw formatActionError(`register ${type.name} hook`, event.error.message);
52
+ }
53
+ }
54
+ }
55
+ async #waitForHook(hookId, type, options) {
56
+ const handle = await this.#getHandle();
57
+ this.#ensureOpen(handle);
58
+ handle.stream.write({
59
+ surfaceSessionId: this.browserSessionId,
60
+ contextSessionId: this.sessionId,
61
+ waitForHook: {
62
+ hookId,
63
+ retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
64
+ },
65
+ });
66
+ while (true) {
67
+ const event = await handle.queue.next();
68
+ if (event.hookCompleted?.hookId === hookId) {
69
+ if (type.name === "newPage" && event.hookCompleted.newPage?.contextSessionId) {
70
+ return this.#createPage(event.hookCompleted.newPage.contextSessionId);
71
+ }
72
+ if (type.name === "fileChooser" && event.hookCompleted.fileChooser?.fileChooserId) {
73
+ return new FileChooserImpl(this, event.hookCompleted.fileChooser.fileChooserId, event.hookCompleted.fileChooser.isMultiple ?? false);
74
+ }
75
+ if (type.name === "download" && event.hookCompleted.download?.downloadId) {
76
+ return new DownloadImpl(this, event.hookCompleted.download.downloadId, event.hookCompleted.download.url ?? "", event.hookCompleted.download.suggestedFilename ?? "");
77
+ }
78
+ throw formatActionError(`wait for ${type.name} hook`, "hook returned an invalid result");
79
+ }
80
+ if (event.error?.message) {
81
+ throw formatActionError(`wait for ${type.name} hook`, event.error.message);
82
+ }
83
+ }
84
+ }
85
+ async setFileChooserFiles(fileChooserId, files, options = {}) {
86
+ const handle = await this.#getHandle();
87
+ this.#ensureOpen(handle);
88
+ handle.stream.write({
89
+ surfaceSessionId: this.browserSessionId,
90
+ contextSessionId: this.sessionId,
91
+ setFileChooserFiles: {
92
+ fileChooserId,
93
+ files,
94
+ retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
95
+ },
96
+ });
97
+ while (true) {
98
+ const event = await handle.queue.next();
99
+ if (event.fileChooserFilesSet?.fileChooserId === fileChooserId) {
100
+ return;
101
+ }
102
+ if (event.error?.message) {
103
+ throw formatActionError("set file chooser files", event.error.message);
104
+ }
105
+ }
106
+ }
107
+ async saveDownload(downloadId, path, options = {}) {
108
+ const handle = await this.#getHandle();
109
+ this.#ensureOpen(handle);
110
+ handle.stream.write({
111
+ surfaceSessionId: this.browserSessionId,
112
+ contextSessionId: this.sessionId,
113
+ saveDownload: {
114
+ downloadId,
115
+ path,
116
+ retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
117
+ },
118
+ });
119
+ while (true) {
120
+ const event = await handle.queue.next();
121
+ if (event.downloadSaved?.downloadId === downloadId) {
122
+ return;
123
+ }
124
+ if (event.error?.message) {
125
+ throw formatActionError("save download", event.error.message);
126
+ }
127
+ }
128
+ }
18
129
  locator(selector, options) {
19
130
  const result = new LocatorImpl({ page: this, selector: normalizeSelectorForTransport(selector) });
20
131
  return options ? result.filter(options) : result;
@@ -509,3 +620,38 @@ export class PageImpl extends WebLocatorBuilders {
509
620
  });
510
621
  }
511
622
  }
623
+ export class FileChooserImpl {
624
+ page;
625
+ id;
626
+ multiple;
627
+ constructor(page, id, multiple) {
628
+ this.page = page;
629
+ this.id = id;
630
+ this.multiple = multiple;
631
+ }
632
+ isMultiple() {
633
+ return this.multiple;
634
+ }
635
+ async setFiles(files, options = {}) {
636
+ const paths = typeof files === "string" ? [files] : files;
637
+ if (!this.multiple && paths.length > 1) {
638
+ throw formatActionError("set file chooser files", "file chooser does not accept multiple files");
639
+ }
640
+ await this.page.setFileChooserFiles(this.id, paths, options);
641
+ }
642
+ }
643
+ export class DownloadImpl {
644
+ page;
645
+ id;
646
+ url;
647
+ suggestedFilename;
648
+ constructor(page, id, url, suggestedFilename) {
649
+ this.page = page;
650
+ this.id = id;
651
+ this.url = url;
652
+ this.suggestedFilename = suggestedFilename;
653
+ }
654
+ async saveAs(path, options = {}) {
655
+ await this.page.saveDownload(this.id, path, options);
656
+ }
657
+ }
package/dist/types.d.ts CHANGED
@@ -108,6 +108,19 @@ export interface Hook<T> {
108
108
  readonly type: HookType<T>;
109
109
  wait(options?: CommandOptions): Promise<T>;
110
110
  }
111
+ export interface FileChooser {
112
+ readonly id: string;
113
+ readonly page: Page;
114
+ isMultiple(): boolean;
115
+ setFiles(files: string | string[], options?: CommandOptions): Promise<void>;
116
+ }
117
+ export interface Download {
118
+ readonly id: string;
119
+ readonly page: Page;
120
+ readonly url: string;
121
+ readonly suggestedFilename: string;
122
+ saveAs(path: string, options?: CommandOptions): Promise<void>;
123
+ }
111
124
  export interface Browser extends BrowserInfo {
112
125
  page(): Page;
113
126
  initialPage(): Page;
@@ -115,12 +128,12 @@ export interface Browser extends BrowserInfo {
115
128
  pages(): Page[];
116
129
  newPage(options?: CommandOptions): Promise<Page>;
117
130
  newTab(options?: CommandOptions): Promise<Page>;
118
- registerHook<T>(type: HookType<T>): Promise<Hook<T>>;
119
131
  close(): Promise<void>;
120
132
  ping(message?: string): Promise<string>;
121
133
  browserInfo(): BrowserInfo;
122
134
  }
123
135
  export interface Page extends PageInfo, WebLocators {
136
+ registerHook<T>(type: HookType<T>): Promise<Hook<T>>;
124
137
  accessibilitySnapshot(options?: AccessibilitySnapshotOptions): Promise<string>;
125
138
  locator(selector: string, options?: LocatorFilterOptions): Locator;
126
139
  goto(url: string, options?: CommandOptions): Promise<NavigateResult>;
@@ -349,18 +362,6 @@ export interface SurfaceSessionEvent {
349
362
  contextSessionId?: string;
350
363
  note?: string;
351
364
  };
352
- hookRegistered?: {
353
- hookId?: string;
354
- hookType?: number;
355
- };
356
- hookCompleted?: {
357
- hookId?: string;
358
- hookType?: number;
359
- newPage?: {
360
- contextSessionId?: string;
361
- note?: string;
362
- };
363
- };
364
365
  pong?: {
365
366
  message?: string;
366
367
  };
@@ -390,6 +391,37 @@ export interface ContextSessionEvent {
390
391
  error?: {
391
392
  message?: string;
392
393
  };
394
+ hookRegistered?: {
395
+ hookId?: string;
396
+ };
397
+ hookCompleted?: {
398
+ hookId?: string;
399
+ newPage?: {
400
+ contextSessionId?: string;
401
+ note?: string;
402
+ };
403
+ fileChooser?: {
404
+ fileChooserId?: string;
405
+ isMultiple?: boolean;
406
+ note?: string;
407
+ };
408
+ download?: {
409
+ downloadId?: string;
410
+ url?: string;
411
+ suggestedFilename?: string;
412
+ note?: string;
413
+ };
414
+ };
415
+ fileChooserFilesSet?: {
416
+ fileChooserId?: string;
417
+ files?: string[];
418
+ note?: string;
419
+ };
420
+ downloadSaved?: {
421
+ downloadId?: string;
422
+ path?: string;
423
+ note?: string;
424
+ };
393
425
  navigated?: {
394
426
  url?: string;
395
427
  note?: string;
@@ -479,11 +511,39 @@ export interface OpenContextRequest {
479
511
  };
480
512
  }
481
513
  export interface RegisterHookRequest {
514
+ surfaceSessionId: string;
515
+ contextSessionId: string;
482
516
  registerHook: {
483
517
  newPage?: Record<string, never>;
518
+ fileChooser?: Record<string, never>;
519
+ download?: Record<string, never>;
520
+ };
521
+ }
522
+ export interface SaveDownloadRequest {
523
+ surfaceSessionId: string;
524
+ contextSessionId: string;
525
+ saveDownload: {
526
+ downloadId: string;
527
+ path: string;
528
+ retryOptions?: {
529
+ timeoutMs?: number;
530
+ };
531
+ };
532
+ }
533
+ export interface SetFileChooserFilesRequest {
534
+ surfaceSessionId: string;
535
+ contextSessionId: string;
536
+ setFileChooserFiles: {
537
+ fileChooserId: string;
538
+ files: string[];
539
+ retryOptions?: {
540
+ timeoutMs?: number;
541
+ };
484
542
  };
485
543
  }
486
544
  export interface WaitForHookRequest {
545
+ surfaceSessionId: string;
546
+ contextSessionId: string;
487
547
  waitForHook: {
488
548
  hookId: string;
489
549
  retryOptions?: {
@@ -669,8 +729,8 @@ export interface CloseContextRequest {
669
729
  contextSessionId: string;
670
730
  close: Record<string, never>;
671
731
  }
672
- export type SurfaceSessionRequest = LaunchBrowserRequest | LaunchChromeRequest | OpenContextRequest | RegisterHookRequest | WaitForHookRequest | ConnectMobileRequest | LaunchAppRequest | SurfacePingRequest | CloseSurfaceRequest;
673
- export type ContextSessionRequest = ContextPingRequest | NavigateRequest | ClickRequest | CountRequest | HighlightRequest | FocusRequest | FillRequest | HoverRequest | PressRequest | TextContentRequest | InnerTextRequest | WaitForSelectorRequest | AccessibilitySnapshotRequest | ScreenshotRequest | CloseContextRequest;
732
+ export type SurfaceSessionRequest = LaunchBrowserRequest | LaunchChromeRequest | OpenContextRequest | ConnectMobileRequest | LaunchAppRequest | SurfacePingRequest | CloseSurfaceRequest;
733
+ export type ContextSessionRequest = ContextPingRequest | RegisterHookRequest | WaitForHookRequest | SetFileChooserFilesRequest | SaveDownloadRequest | NavigateRequest | ClickRequest | CountRequest | HighlightRequest | FocusRequest | FillRequest | HoverRequest | PressRequest | TextContentRequest | InnerTextRequest | WaitForSelectorRequest | AccessibilitySnapshotRequest | ScreenshotRequest | CloseContextRequest;
674
734
  export type SurfaceSessionStream = grpc.ClientDuplexStream<SurfaceSessionRequest, SurfaceSessionEvent>;
675
735
  export type ContextSessionStream = grpc.ClientDuplexStream<ContextSessionRequest, ContextSessionEvent>;
676
736
  export interface EngineServiceClientShape {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allwright.dev/core",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "High-level TypeScript client for the allwright automation engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -6,6 +6,7 @@ option java_package = "dev.allwright.engine.v1";
6
6
  option java_multiple_files = true;
7
7
 
8
8
  import "core/v1/common.proto";
9
+ import "surfaces/web/v1/web.proto";
9
10
 
10
11
  message ContextSessionCommand {
11
12
  string surface_session_id = 1;
@@ -27,6 +28,10 @@ message ContextSessionCommand {
27
28
  WaitForSelectorCommand wait_for_selector = 15;
28
29
  ScreenshotCommand screenshot = 16;
29
30
  AccessibilitySnapshotCommand accessibility_snapshot = 17;
31
+ RegisterHookCommand register_hook = 18;
32
+ WaitForHookCommand wait_for_hook = 19;
33
+ SetFileChooserFilesCommand set_file_chooser_files = 20;
34
+ SaveDownloadCommand save_download = 21;
30
35
  }
31
36
  }
32
37
 
@@ -58,6 +63,10 @@ message ContextSessionEvent {
58
63
  SelectorWaitSatisfiedEvent selector_wait_satisfied = 17;
59
64
  ScreenshotCapturedEvent screenshot_captured = 18;
60
65
  AccessibilitySnapshotCapturedEvent accessibility_snapshot_captured = 19;
66
+ HookRegisteredEvent hook_registered = 20;
67
+ HookCompletedEvent hook_completed = 21;
68
+ FileChooserFilesSetEvent file_chooser_files_set = 22;
69
+ DownloadSavedEvent download_saved = 23;
61
70
  }
62
71
  }
63
72
 
@@ -77,6 +86,33 @@ message ContextSessionErrorEvent {
77
86
  string message = 1;
78
87
  }
79
88
 
89
+ message RegisterHookCommand {
90
+ oneof hook {
91
+ RegisterNewPageHook new_page = 1;
92
+ RegisterFileChooserHook file_chooser = 2;
93
+ RegisterDownloadHook download = 3;
94
+ }
95
+ }
96
+
97
+ message WaitForHookCommand {
98
+ string hook_id = 1;
99
+ optional CommandRetryOptions retry_options = 2;
100
+ }
101
+
102
+ message HookRegisteredEvent {
103
+ string hook_id = 1;
104
+ }
105
+
106
+ message HookCompletedEvent {
107
+ string hook_id = 1;
108
+
109
+ oneof result {
110
+ NewPageHookResult new_page = 2;
111
+ FileChooserHookResult file_chooser = 3;
112
+ DownloadHookResult download = 4;
113
+ }
114
+ }
115
+
80
116
  message NavigatePageCommand {
81
117
  string url = 1;
82
118
  optional CommandRetryOptions retry_options = 2;
@@ -18,8 +18,6 @@ message SurfaceSessionCommand {
18
18
  LaunchBrowserCommand launch_browser = 5;
19
19
  ConnectMobileCommand connect_mobile = 6;
20
20
  LaunchAppCommand launch_app = 7;
21
- RegisterHookCommand register_hook = 8;
22
- WaitForHookCommand wait_for_hook = 9;
23
21
  }
24
22
  }
25
23
 
@@ -33,17 +31,6 @@ message SessionPingCommand {
33
31
 
34
32
  message CloseSurfaceSessionCommand {}
35
33
 
36
- message RegisterHookCommand {
37
- oneof hook {
38
- RegisterNewPageHook new_page = 1;
39
- }
40
- }
41
-
42
- message WaitForHookCommand {
43
- string hook_id = 1;
44
- optional CommandRetryOptions retry_options = 2;
45
- }
46
-
47
34
  message SurfaceSessionEvent {
48
35
  string session_id = 1;
49
36
 
@@ -56,8 +43,6 @@ message SurfaceSessionEvent {
56
43
  BrowserLaunchedEvent browser_launched = 7;
57
44
  MobileConnectedEvent mobile_connected = 8;
58
45
  AppLaunchedEvent app_launched = 9;
59
- HookRegisteredEvent hook_registered = 10;
60
- HookCompletedEvent hook_completed = 11;
61
46
  }
62
47
  }
63
48
 
@@ -77,15 +62,3 @@ message SurfaceSessionClosedEvent {
77
62
  message SurfaceSessionErrorEvent {
78
63
  string message = 1;
79
64
  }
80
-
81
- message HookRegisteredEvent {
82
- string hook_id = 1;
83
- }
84
-
85
- message HookCompletedEvent {
86
- string hook_id = 1;
87
-
88
- oneof result {
89
- NewPageHookResult new_page = 2;
90
- }
91
- }
@@ -46,3 +46,44 @@ message NewPageHookResult {
46
46
  string context_session_id = 1;
47
47
  string note = 2;
48
48
  }
49
+
50
+ message RegisterFileChooserHook {}
51
+
52
+ message FileChooserHookResult {
53
+ string file_chooser_id = 1;
54
+ bool is_multiple = 2;
55
+ string note = 3;
56
+ }
57
+
58
+ message SetFileChooserFilesCommand {
59
+ string file_chooser_id = 1;
60
+ repeated string files = 2;
61
+ optional CommandRetryOptions retry_options = 3;
62
+ }
63
+
64
+ message FileChooserFilesSetEvent {
65
+ string file_chooser_id = 1;
66
+ repeated string files = 2;
67
+ string note = 3;
68
+ }
69
+
70
+ message RegisterDownloadHook {}
71
+
72
+ message DownloadHookResult {
73
+ string download_id = 1;
74
+ string url = 2;
75
+ string suggested_filename = 3;
76
+ string note = 4;
77
+ }
78
+
79
+ message SaveDownloadCommand {
80
+ string download_id = 1;
81
+ string path = 2;
82
+ optional CommandRetryOptions retry_options = 3;
83
+ }
84
+
85
+ message DownloadSavedEvent {
86
+ string download_id = 1;
87
+ string path = 2;
88
+ string note = 3;
89
+ }