From ca388dfc10dc8e45be7c35c68b2e2672014d39b1 Mon Sep 17 00:00:00 2001 From: Katie Macaulay Date: Wed, 12 Mar 2025 15:36:12 +0000 Subject: [PATCH 1/3] Allow created date to be set by the user when exporting STEP --- modeling-cmds/Cargo.toml | 2 +- modeling-cmds/src/datetime.rs | 5 ++++- modeling-cmds/src/format/step.rs | 8 +++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modeling-cmds/Cargo.toml b/modeling-cmds/Cargo.toml index cfcae264..3054f96f 100644 --- a/modeling-cmds/Cargo.toml +++ b/modeling-cmds/Cargo.toml @@ -12,7 +12,7 @@ license = "MIT" [dependencies] anyhow = "1.0.97" -chrono = "0.4.39" +chrono = { version = "0.4.39", features = ["serde"] } cxx = { version = "1.0", optional = true } data-encoding = "2.8.0" enum-iterator = "2.1.0" diff --git a/modeling-cmds/src/datetime.rs b/modeling-cmds/src/datetime.rs index 139e365e..f213edc9 100644 --- a/modeling-cmds/src/datetime.rs +++ b/modeling-cmds/src/datetime.rs @@ -1,5 +1,8 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + /// A wrapper for chrono types, since we need to impl Value for them. -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Default)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Default, Deserialize, Serialize, JsonSchema)] pub struct DateTimeLocal { value: chrono::DateTime, } diff --git a/modeling-cmds/src/format/step.rs b/modeling-cmds/src/format/step.rs index 1f6d61dc..9f25d973 100644 --- a/modeling-cmds/src/format/step.rs +++ b/modeling-cmds/src/format/step.rs @@ -3,6 +3,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::coord; +use crate::datetime::DateTimeLocal; /// Import models in STEP format. pub mod import { @@ -38,12 +39,9 @@ pub mod export { /// /// [KittyCAD co-ordinate system]: ../coord/constant.KITTYCAD.html pub coords: coord::System, + /// Timestamp override. - /// - /// This is intended for local integration testing only; it is not provided as an option - /// in the JSON schema. - #[serde(skip)] - pub created: Option>, + pub created: Option, } impl Default for Options { From 34d03577e4f0a23962297ce9d47bae217260ac3b Mon Sep 17 00:00:00 2001 From: Katie Macaulay Date: Wed, 12 Mar 2025 16:03:01 +0000 Subject: [PATCH 2/3] Allow created date to be set by the user when exporting FBX --- modeling-cmds/src/format/fbx.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modeling-cmds/src/format/fbx.rs b/modeling-cmds/src/format/fbx.rs index f1411d19..e0da67d3 100644 --- a/modeling-cmds/src/format/fbx.rs +++ b/modeling-cmds/src/format/fbx.rs @@ -30,10 +30,6 @@ pub mod export { pub storage: Storage, /// Timestamp override. - /// - /// This is intended for local integration testing only; it is not provided as an option - /// in the JSON schema. - #[serde(skip)] pub created: Option, } From e6a9af4e5cd02cf0f379e14f067526bb0309f2e3 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 12 Mar 2025 12:10:54 -0700 Subject: [PATCH 3/3] cleanup Signed-off-by: Jess Frazelle --- Cargo.lock | 1 + modeling-cmds/Cargo.toml | 1 + modeling-cmds/src/datetime.rs | 5 +---- modeling-cmds/src/format/fbx.rs | 4 +--- modeling-cmds/src/format/step.rs | 3 +-- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ca1decb..dd4d5bcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4340,6 +4340,7 @@ version = "10.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e640d9b0964e9d39df633548591090ab92f7a4567bc31d3891af23471a3365c6" dependencies = [ + "chrono", "lazy_static", "serde_json", "thiserror 2.0.12", diff --git a/modeling-cmds/Cargo.toml b/modeling-cmds/Cargo.toml index 3054f96f..caca8cab 100644 --- a/modeling-cmds/Cargo.toml +++ b/modeling-cmds/Cargo.toml @@ -37,6 +37,7 @@ serde_json = { version = "1.0.139", optional = true } slog = { version = "2.7.0", optional = true } tabled = { version = "0.18", optional = true } ts-rs = { version = "10.1.0", optional = true, features = [ + "chrono-impl", "uuid-impl", "no-serde-warnings", "serde-json-impl", diff --git a/modeling-cmds/src/datetime.rs b/modeling-cmds/src/datetime.rs index f213edc9..139e365e 100644 --- a/modeling-cmds/src/datetime.rs +++ b/modeling-cmds/src/datetime.rs @@ -1,8 +1,5 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - /// A wrapper for chrono types, since we need to impl Value for them. -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Default, Deserialize, Serialize, JsonSchema)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Default)] pub struct DateTimeLocal { value: chrono::DateTime, } diff --git a/modeling-cmds/src/format/fbx.rs b/modeling-cmds/src/format/fbx.rs index e0da67d3..e185113e 100644 --- a/modeling-cmds/src/format/fbx.rs +++ b/modeling-cmds/src/format/fbx.rs @@ -1,5 +1,3 @@ -use crate::datetime::DateTimeLocal; - use parse_display::{Display, FromStr}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -30,7 +28,7 @@ pub mod export { pub storage: Storage, /// Timestamp override. - pub created: Option, + pub created: Option>, } impl std::fmt::Display for Options { diff --git a/modeling-cmds/src/format/step.rs b/modeling-cmds/src/format/step.rs index 9f25d973..4ce831f2 100644 --- a/modeling-cmds/src/format/step.rs +++ b/modeling-cmds/src/format/step.rs @@ -3,7 +3,6 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::coord; -use crate::datetime::DateTimeLocal; /// Import models in STEP format. pub mod import { @@ -41,7 +40,7 @@ pub mod export { pub coords: coord::System, /// Timestamp override. - pub created: Option, + pub created: Option>, } impl Default for Options {