perspective_viewer/config/options.rs
1// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7// ┃ Copyright (c) 2017, the Perspective Authors. ┃
8// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9// ┃ This file is part of the Perspective library, distributed under the terms ┃
10// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
13//! Argument dictionaries for the public `PerspectiveViewerElement` methods.
14//! Each derives `ts_rs::TS` so its TypeScript type is generated (and
15//! re-exported from the crate's `typescript_custom_section`) alongside the
16//! config types, rather than hand-maintained.
17
18use serde::Deserialize;
19use ts_rs::TS;
20
21use crate::config::ExportMethod;
22
23/// Selects the target panel of a panel-scoped `<perspective-viewer>` method;
24/// the active panel when `panel` is omitted.
25#[derive(Deserialize, Default, TS)]
26pub struct PanelOptions {
27 #[ts(optional)]
28 pub panel: Option<String>,
29}
30
31/// Options for the `restore()` method.
32#[derive(Deserialize, Default, TS)]
33pub struct RestoreOptions {
34 /// The target panel; the active panel when omitted.
35 #[ts(optional)]
36 pub panel: Option<String>,
37
38 /// When `true`, a failed restore only REJECTS the returned `Promise` —
39 /// the error is not committed to the viewer's visible error state, and
40 /// the session remains usable for subsequent calls. For programmatic
41 /// callers (e.g. the LLM agent's `set_view_config` tool) for whom a
42 /// failed config patch is feedback rather than a user-facing fault.
43 /// The config may be partially applied on failure; restore a
44 /// known-good config to recover exactly.
45 #[ts(optional)]
46 pub suppress_errors: Option<bool>,
47}
48
49/// The `eject` argument: the loaded client to remove by name; the active
50/// panel's client when omitted.
51#[derive(Deserialize, Default, TS)]
52pub struct ClientOptions {
53 #[ts(optional)]
54 pub client: Option<String>,
55}
56
57/// The `download` / `export` / `copy` argument: the `ExportMethod` and target
58/// panel.
59#[derive(Deserialize, Default, TS)]
60pub struct ExportOptions {
61 #[ts(as = "Option<ExportMethod>")]
62 #[ts(optional)]
63 pub method: Option<String>,
64
65 #[ts(optional)]
66 pub panel: Option<String>,
67}
68
69/// The `getTable` argument: whether to `wait` for a `Table`, and the target
70/// panel.
71#[derive(Deserialize, Default, TS)]
72pub struct GetTableOptions {
73 #[ts(optional)]
74 pub wait: Option<bool>,
75
76 #[ts(optional)]
77 pub panel: Option<String>,
78}
79
80/// The `getClient` argument: whether to `wait` for a `Client`, and the target
81/// panel.
82#[derive(Deserialize, Default, TS)]
83pub struct GetClientOptions {
84 #[ts(optional)]
85 pub wait: Option<bool>,
86
87 #[ts(optional)]
88 pub panel: Option<String>,
89}