Add back environment.base (#260)

This commit is contained in:
Gregory Schier
2025-10-02 06:04:27 -07:00
committed by GitHub
parent 57f231ca00
commit 8a634b1056
2 changed files with 16 additions and 4 deletions

View File

@@ -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<Workspace>, environments: Array<Environment>, folders: Array<Folder>, httpRequests: Array<HttpRequest>, grpcRequests: Array<GrpcRequest>, websocketRequests: Array<WebsocketRequest>, };

View File

@@ -541,10 +541,15 @@ pub struct Environment {
pub name: String,
pub public: bool,
pub variables: Vec<EnvironmentVariable>,
pub color: Option<String>,
#[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<String>,
pub variables: Vec<EnvironmentVariable>,
pub color: Option<String>,
}
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,
})
}
}