Admin d39c66eb82
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled
feat: add OCR refinement workbench
2026-09-25 21:21:24 +00:00

234 lines
5.9 KiB
Rust

use serde::{Deserialize, Serialize};
use serde_json::Value;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum CaptureMode {
RawProxy,
SpoolFolder,
Both,
}
impl Default for CaptureMode {
fn default() -> Self {
Self::RawProxy
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AppConfig {
pub mode: CaptureMode,
pub listen_addr: String,
pub forward_addr: String,
#[serde(default)]
pub forward_printer: String,
pub spool_dir: String,
pub api_base_url: String,
pub issuer: String,
pub client_id: String,
pub station_id: String,
pub installation_id: String,
pub device_id: Option<String>,
}
impl Default for AppConfig {
fn default() -> Self {
Self {
mode: CaptureMode::RawProxy,
listen_addr: "127.0.0.1:9100".into(),
forward_addr: String::new(),
forward_printer: String::new(),
spool_dir: String::new(),
api_base_url: "https://fieldlens.arrowstack.dev".into(),
issuer: "https://auth.arrowstack.dev/realms/dev".into(),
client_id: "fieldlens-print-desktop".into(),
station_id: String::new(),
installation_id: Uuid::new_v4().to_string(),
device_id: None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DecodedBarcode {
pub format: String,
pub value: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
pub struct PalletSnapshot {
pub pallet_id: String,
pub origin: Option<String>,
pub variety: Option<String>,
pub brand: Option<String>,
pub class: Option<String>,
pub base: Option<String>,
pub pack: Option<String>,
pub grower: Option<String>,
pub packrun: Option<String>,
pub size: Option<String>,
pub qty: Option<String>,
pub pick_date: Option<String>,
pub pack_date: Option<String>,
pub total: Option<String>,
pub printed_time: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PalletFieldChange {
pub field: String,
pub previous: String,
pub current: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "kebab-case")]
pub enum PalletPrintStatus {
NewPallet,
ReprintSame,
ReprintChanged,
ReprintUnreadable,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PalletPrintComparison {
pub pallet_id: String,
pub status: PalletPrintStatus,
pub occurrence: usize,
pub previous_captured_at: Option<String>,
pub changes: Vec<PalletFieldChange>,
pub snapshot: PalletSnapshot,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PalletPrintRecord {
pub source_key: String,
pub job_id: String,
pub captured_at: String,
pub comparison: PalletPrintComparison,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JobSummary {
pub id: String,
pub source: String,
pub label: String,
pub bytes: usize,
pub barcodes: Vec<DecodedBarcode>,
pub pallet_print: Option<PalletPrintComparison>,
pub captured_at: String,
pub forwarded: bool,
pub error: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ScanEvent {
pub id: String,
pub raw_value: String,
pub format: String,
pub duplicate: bool,
pub captured_at: String,
pub source: String,
pub source_metadata: Value,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CaptureStatus {
pub running: bool,
pub mode: CaptureMode,
pub pending: usize,
pub jobs: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AuthState {
pub device_code: Option<String>,
pub access_token: Option<String>,
pub refresh_token: Option<String>,
pub expires_at_unix: Option<i64>,
pub poll_interval: u64,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct LoginStart {
pub user_code: String,
pub verification_uri: String,
pub verification_uri_complete: Option<String>,
pub expires_in: u64,
pub interval: u64,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct LoginPoll {
pub status: String,
pub access_status: Option<String>,
pub role: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AuthStatus {
pub signed_in: bool,
pub access_status: String,
pub role: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct SyncResult {
pub synced: usize,
pub pending: usize,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RecentCapture {
pub name: String,
pub mime: String,
pub data_base64: String,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DebugCheck {
pub name: String,
pub ok: bool,
pub detail: String,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DebugSnapshot {
pub platform: String,
pub arch: String,
pub app_version: String,
pub data_dir: String,
pub capture_storage: String,
pub capture_running: bool,
pub capture_mode: CaptureMode,
pub pending: usize,
pub jobs: usize,
pub signed_in: bool,
pub forward_printer: String,
pub listen_addr: String,
pub forward_addr: String,
pub client_id: String,
pub virtual_printer: String,
pub installed_printers: usize,
pub recent_errors: Vec<String>,
pub checks: Vec<DebugCheck>,
}