From 8a634b10560a392b4cbf72ddda4766e45def7cdf Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Thu, 2 Oct 2025 06:04:27 -0700 Subject: [PATCH] Add back environment.base (#260) --- src-tauri/yaak-models/bindings/gen_util.ts | 2 +- src-tauri/yaak-models/src/models.rs | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src-tauri/yaak-models/bindings/gen_util.ts b/src-tauri/yaak-models/bindings/gen_util.ts index f1bf4fa2..f87c220c 100644 --- a/src-tauri/yaak-models/bindings/gen_util.ts +++ b/src-tauri/yaak-models/bindings/gen_util.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Environment, Folder, GrpcRequest, HttpRequest, WebsocketRequest, Workspace } from "./gen_models"; +import type { Environment, Folder, GrpcRequest, HttpRequest, WebsocketRequest, Workspace } from "./gen_models.js"; export type BatchUpsertResult = { workspaces: Array, environments: Array, folders: Array, httpRequests: Array, grpcRequests: Array, websocketRequests: Array, }; diff --git a/src-tauri/yaak-models/src/models.rs b/src-tauri/yaak-models/src/models.rs index 1d07ec31..96a14f59 100644 --- a/src-tauri/yaak-models/src/models.rs +++ b/src-tauri/yaak-models/src/models.rs @@ -541,10 +541,15 @@ pub struct Environment { pub name: String, pub public: bool, - pub variables: Vec, - pub color: Option, + #[deprecated( + note = "parent_model is used instead. This field will be removed when schema field is added for sync/export." + )] + #[ts(skip)] + pub base: bool, pub parent_model: String, pub parent_id: Option, + pub variables: Vec, + pub color: Option, } impl UpsertModelInfo for Environment { @@ -603,6 +608,8 @@ impl UpsertModelInfo for Environment { Self: Sized, { let variables: String = row.get("variables")?; + let parent_model = row.get("parent_model")?; + let base = parent_model == "workspace"; Ok(Self { id: row.get("id")?, model: row.get("model")?, @@ -610,11 +617,16 @@ impl UpsertModelInfo for Environment { created_at: row.get("created_at")?, updated_at: row.get("updated_at")?, parent_id: row.get("parent_id")?, - parent_model: row.get("parent_model")?, + parent_model, color: row.get("color")?, name: row.get("name")?, public: row.get("public")?, variables: serde_json::from_str(variables.as_str()).unwrap_or_default(), + + // Deprecated field, but we need to keep it around for a couple of versions + // for compatibility because sync/export don't have a schema field + #[allow(deprecated)] + base, }) } }