Skip to main content

auditaur_core/
drive_bridge.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4pub const DRIVE_BRIDGE_CAPABILITY: &str = "drive_bridge";
5pub const DRIVE_BRIDGE_PROTOCOL_VERSION: u8 = 1;
6pub const DRIVE_BRIDGE_DIR: &str = "drive-bridge";
7pub const DRIVE_BRIDGE_REQUESTS_DIR: &str = "requests";
8pub const DRIVE_BRIDGE_IN_FLIGHT_DIR: &str = "in-flight";
9pub const DRIVE_BRIDGE_RESPONSES_DIR: &str = "responses";
10pub const DRIVE_BRIDGE_STATUS_FILE: &str = "status.json";
11pub const DRIVE_BRIDGE_STALE_FILE_NANOS: i64 = 60_000_000_000;
12pub const DRIVE_BRIDGE_REQUEST_EVENT: &str = "auditaur://drive-bridge/request";
13/// Discovery capability of a plugin that keeps a drilled app's window in the background.
14pub const WINDOW_BACKGROUND_CAPABILITY: &str = "window_background";
15/// App environment variable `auditaur drill test` sets to `background` or `foreground`.
16pub const WINDOW_MODE_ENV: &str = "AUDITAUR_DRILL_WINDOW";
17/// Drive request the plugin answers natively (never reaching the JS bridge); its `value` is
18/// `status`, `front`, or `back`.
19pub const WINDOW_ACTION: &str = "auditaur.window";
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
22#[serde(rename_all = "camelCase")]
23pub struct DriveBridgeStatus {
24    pub schema_version: u8,
25    pub protocol_version: u8,
26    pub active: bool,
27    pub window_label: Option<String>,
28    pub registered_at_unix_nanos: i64,
29    pub last_heartbeat_unix_nanos: i64,
30    #[serde(default)]
31    pub targets: Vec<DriveBridgeTarget>,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(rename_all = "camelCase")]
36pub struct DriveBridgeTarget {
37    pub target_id: String,
38    pub title: String,
39    pub window_label: Option<String>,
40    pub active: bool,
41    pub last_heartbeat_unix_nanos: i64,
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(rename_all = "camelCase")]
46pub struct DriveBridgeRequest {
47    pub schema_version: u8,
48    pub protocol_version: u8,
49    pub request_id: String,
50    pub action: String,
51    pub selector: Option<String>,
52    pub value: Option<String>,
53    #[serde(default)]
54    pub values: Vec<String>,
55    pub visible_only: bool,
56    #[serde(default)]
57    pub window_label: Option<String>,
58    pub test_id: Option<String>,
59    pub step_id: Option<String>,
60    pub created_at_unix_nanos: i64,
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(rename_all = "camelCase")]
65pub struct DriveBridgeResponse {
66    pub schema_version: u8,
67    pub protocol_version: u8,
68    pub request_id: String,
69    pub action: String,
70    pub selector: Option<String>,
71    pub visible_only: bool,
72    pub ok: bool,
73    pub payload: Value,
74    pub error: Option<String>,
75    pub completed_at_unix_nanos: i64,
76}