diff --git a/Cargo.lock b/Cargo.lock index 9c8de1e1..1eaf2633 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1980,6 +1980,7 @@ dependencies = [ "serde_json", "slog", "tabled", + "ts-rs", "uuid", "webrtc", ] @@ -4347,6 +4348,31 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "ts-rs" +version = "10.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e640d9b0964e9d39df633548591090ab92f7a4567bc31d3891af23471a3365c6" +dependencies = [ + "lazy_static", + "serde_json", + "thiserror 2.0.9", + "ts-rs-macros", + "uuid", +] + +[[package]] +name = "ts-rs-macros" +version = "10.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9d8656589772eeec2cf7a8264d9cda40fb28b9bc53118ceb9e8c07f8f38730" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.93", + "termcolor", +] + [[package]] name = "tungstenite" version = "0.24.0" diff --git a/modeling-cmds-macros-impl/src/modeling_cmd_enum.rs b/modeling-cmds-macros-impl/src/modeling_cmd_enum.rs index 3573827f..88762581 100644 --- a/modeling-cmds-macros-impl/src/modeling_cmd_enum.rs +++ b/modeling-cmds-macros-impl/src/modeling_cmd_enum.rs @@ -54,9 +54,11 @@ pub fn generate(input: ItemMod) -> TokenStream { /// Definition of each modeling command. #input /// Commands that the KittyCAD engine can execute. - #[derive(Debug, Clone, Serialize, Deserialize)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[cfg_attr(feature = "derive-jsonschema-on-enums", derive(schemars::JsonSchema))] #[serde(rename_all = "snake_case", tag = "type")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] #[cfg_attr(not(feature = "unstable_exhaustive"), non_exhaustive)] pub enum ModelingCmd {#( #[doc = #docs] diff --git a/modeling-cmds/Cargo.toml b/modeling-cmds/Cargo.toml index 81877b54..f136385d 100644 --- a/modeling-cmds/Cargo.toml +++ b/modeling-cmds/Cargo.toml @@ -36,6 +36,11 @@ serde_bytes = "0.11.15" serde_json = { version = "1.0.134", optional = true } slog = { version = "2.7.0", optional = true } tabled = { version = "0.17", optional = true } +ts-rs = { version = "10.1.0", optional = true, features = [ + "uuid-impl", + "no-serde-warnings", + "serde-json-impl", +] } uuid = { version = "1.11.0", features = ["serde", "v4", "js"] } webrtc = { version = "0.11", optional = true } @@ -46,6 +51,7 @@ workspace = true default = [] derive-jsonschema-on-enums = [] tabled = ["dep:tabled"] +ts-rs = ["dep:ts-rs"] slog = ["dep:slog"] cxx = ["dep:cxx"] convert_client_crate = ["dep:kittycad"] diff --git a/modeling-cmds/src/coord.rs b/modeling-cmds/src/coord.rs index 7b382f82..d9781873 100644 --- a/modeling-cmds/src/coord.rs +++ b/modeling-cmds/src/coord.rs @@ -10,6 +10,8 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[serde(rename_all = "snake_case")] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum Axis { /// 'Y' axis. Y = 1, @@ -21,6 +23,8 @@ pub enum Axis { #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[serde(rename_all = "snake_case")] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum Direction { /// Increasing numbers. Positive = 1, @@ -42,6 +46,8 @@ impl std::ops::Mul for Direction { /// An [`Axis`] paired with a [`Direction`]. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[display("({axis}, {direction})")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct AxisDirectionPair { /// Axis specifier. pub axis: Axis, @@ -59,6 +65,8 @@ pub struct AxisDirectionPair { /// [cglearn.eu](https://cglearn.eu/pub/computer-graphics/introduction-to-geometry#material-coordinate-systems-1) #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[display("forward: {forward}, up: {up}")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct System { /// Axis the front face of a model looks along. pub forward: AxisDirectionPair, diff --git a/modeling-cmds/src/def_enum.rs b/modeling-cmds/src/def_enum.rs index 62803d24..41ed5c1b 100644 --- a/modeling-cmds/src/def_enum.rs +++ b/modeling-cmds/src/def_enum.rs @@ -44,8 +44,10 @@ define_modeling_cmd_enum! { /// Evaluates the position of a path in one shot (engine utility for kcl executor) #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EngineUtilEvaluatePath { /// The path in json form (the serialized result of the kcl Sketch/Path object pub path_json: String, @@ -56,9 +58,16 @@ define_modeling_cmd_enum! { /// Start a new path. #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] - pub struct StartPath; + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct StartPath { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Move the path's "pen". /// If you're in sketch mode, these coordinates are in the local coordinate system, @@ -68,8 +77,10 @@ define_modeling_cmd_enum! { /// to (1, 1, 0) with this command uses local coordinates. So, it would move the pen to /// (1, 1, 50) in global coordinates. #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct MovePathPen { /// The ID of the command which created the path. pub path: ModelingCmdId, @@ -80,8 +91,10 @@ define_modeling_cmd_enum! { /// Extend a path by adding a new segment which starts at the path's "pen". /// If no "pen" location has been set before (via `MovePen`), then the pen is at the origin. #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ExtendPath { /// The ID of the command which created the path. pub path: ModelingCmdId, @@ -92,8 +105,10 @@ define_modeling_cmd_enum! { /// Command for extruding a solid 2d. #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Extrude { /// Which sketch to extrude. /// Must be a closed 2D solid. @@ -108,8 +123,10 @@ define_modeling_cmd_enum! { /// Extrude the object along a path. #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, + Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Sweep { /// Which sketch to sweep. /// Must be a closed 2D solid. @@ -124,8 +141,10 @@ define_modeling_cmd_enum! { /// Command for revolving a solid 2d. #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Revolve { /// Which sketch to revolve. /// Must be a closed 2D solid. @@ -144,8 +163,10 @@ define_modeling_cmd_enum! { /// Command for shelling a solid3d face #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid3dShellFace { /// Which Solid3D is being shelled. pub object_id: Uuid, @@ -161,8 +182,10 @@ define_modeling_cmd_enum! { /// Command for revolving a solid 2d about a brep edge #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct RevolveAboutEdge { /// Which sketch to revolve. /// Must be a closed 2D solid. @@ -177,8 +200,10 @@ define_modeling_cmd_enum! { /// Command for lofting sections to create a solid #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Loft { /// The closed section curves to create a lofted solid from. /// Currently, these must be Solid2Ds @@ -199,15 +224,19 @@ define_modeling_cmd_enum! { /// Closes a path, converting it to a 2D solid. #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ClosePath { /// Which path to close. pub path_id: Uuid, } /// Camera drag started. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct CameraDragStart { /// The type of camera drag interaction. pub interaction: CameraDragInteractionType, @@ -216,7 +245,9 @@ define_modeling_cmd_enum! { } /// Camera drag continued. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct CameraDragMove { /// The type of camera drag interaction. pub interaction: CameraDragInteractionType, @@ -230,7 +261,9 @@ define_modeling_cmd_enum! { } /// Camera drag ended - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct CameraDragEnd { /// The type of camera drag interaction. pub interaction: CameraDragInteractionType, @@ -239,11 +272,20 @@ define_modeling_cmd_enum! { } /// Gets the default camera's camera settings - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] - pub struct DefaultCameraGetSettings; + #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct DefaultCameraGetSettings { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Change what the default camera is looking at. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct DefaultCameraLookAt { /// Where the camera is positioned pub vantage: Point3d, @@ -259,7 +301,9 @@ define_modeling_cmd_enum! { } /// Change what the default camera is looking at. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct DefaultCameraPerspectiveSettings { /// Where the camera is positioned pub vantage: Point3d, @@ -281,7 +325,9 @@ define_modeling_cmd_enum! { } /// Adjust zoom of the default camera. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct DefaultCameraZoom { /// Move the camera forward along the vector it's looking at, /// by this magnitudedefaultCameraZoom. @@ -290,7 +336,9 @@ define_modeling_cmd_enum! { } /// Export the scene to a file. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Export { /// IDs of the entities to be exported. If this is empty, then all entities are exported. pub entity_ids: Vec, @@ -299,21 +347,27 @@ define_modeling_cmd_enum! { } /// What is this entity's parent? - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityGetParentId { /// ID of the entity being queried. pub entity_id: Uuid, } /// How many children does the entity have? - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityGetNumChildren { /// ID of the entity being queried. pub entity_id: Uuid, } /// What is the UUID of this entity's n-th child? - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityGetChildUuid { /// ID of the entity being queried. pub entity_id: Uuid, @@ -322,21 +376,27 @@ define_modeling_cmd_enum! { } /// What are all UUIDs of this entity's children? - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityGetAllChildUuids { /// ID of the entity being queried. pub entity_id: Uuid, } /// What are all UUIDs of all the paths sketched on top of this entity? - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityGetSketchPaths { /// ID of the entity being queried. pub entity_id: Uuid, } /// What is the distance between these two entities? - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityGetDistance { /// ID of the first entity being queried. pub entity_id1: Uuid, @@ -348,7 +408,9 @@ define_modeling_cmd_enum! { /// Create a pattern using this entity by specifying the transform for each desired repetition. /// Transformations are performed in the following order (first applied to last applied): scale, rotate, translate. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityLinearPatternTransform { /// ID of the entity being copied. pub entity_id: Uuid, @@ -365,7 +427,9 @@ define_modeling_cmd_enum! { } /// Create a linear pattern using this entity. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityLinearPattern { /// ID of the entity being copied. pub entity_id: Uuid, @@ -378,7 +442,9 @@ define_modeling_cmd_enum! { pub spacing: LengthUnit, } /// Create a circular pattern using this entity. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityCircularPattern { /// ID of the entity being copied. pub entity_id: Uuid, @@ -397,7 +463,9 @@ define_modeling_cmd_enum! { } /// Create a helix using the input cylinder and other specified parameters. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityMakeHelix { /// ID of the cylinder. pub cylinder_id: Uuid, @@ -413,7 +481,9 @@ define_modeling_cmd_enum! { } /// Create a helix using the specified parameters. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityMakeHelixFromParams { /// Radius of the helix. pub radius: f64, @@ -433,7 +503,9 @@ define_modeling_cmd_enum! { } /// Mirror the input entities over the specified axis. (Currently only supports sketches) - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityMirror { /// ID of the mirror entities. pub ids: Vec, @@ -445,9 +517,11 @@ define_modeling_cmd_enum! { /// Mirror the input entities over the specified edge. (Currently only supports sketches) #[derive( - Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, + Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant, )] - pub struct EntityMirrorAcrossEdge { + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct EntityMirrorAcrossEdge { /// ID of the mirror entities. pub ids: Vec, /// The edge to use as the mirror axis, must be linear and lie in the plane of the solid @@ -456,7 +530,9 @@ define_modeling_cmd_enum! { /// Modifies the selection by simulating a "mouse click" at the given x,y window coordinate /// Returns ID of whatever was selected. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SelectWithPoint { /// Where in the window was selected pub selected_at_window: Point2d, @@ -465,25 +541,38 @@ define_modeling_cmd_enum! { } /// Adds one or more entities (by UUID) to the selection. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SelectAdd { /// Which entities to select pub entities: Vec, } /// Removes one or more entities (by UUID) from the selection. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SelectRemove { /// Which entities to unselect pub entities: Vec, } /// Removes all of the Objects in the scene - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] - pub struct SceneClearAll; + #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct SceneClearAll { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Replaces current selection with these entities (by UUID). - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SelectReplace { /// Which entities to select pub entities: Vec, @@ -491,7 +580,9 @@ define_modeling_cmd_enum! { /// Changes the current highlighted entity to whichever one is at the given window coordinate. /// If there's no entity at this location, clears the highlight. - #[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct HighlightSetEntity { /// Coordinates of the window being clicked pub selected_at_window: Point2d, @@ -503,14 +594,18 @@ define_modeling_cmd_enum! { } /// Changes the current highlighted entity to these entities. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct HighlightSetEntities { /// Highlight these entities. pub entities: Vec, } /// Create a new annotation - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct NewAnnotation { /// What should the annotation contain? pub options: AnnotationOptions, @@ -521,7 +616,9 @@ define_modeling_cmd_enum! { } /// Update an annotation - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct UpdateAnnotation { /// Which annotation to update pub annotation_id: Uuid, @@ -531,14 +628,18 @@ define_modeling_cmd_enum! { } /// Changes visibility of scene-wide edge lines on brep solids - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EdgeLinesVisible { /// Whether or not the edge lines should be hidden. pub hidden: bool, } /// Hide or show an object - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ObjectVisible { /// Which object to change pub object_id: Uuid, @@ -547,14 +648,18 @@ define_modeling_cmd_enum! { } /// Bring an object to the front of the scene - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ObjectBringToFront { /// Which object to change pub object_id: Uuid, } /// Set the material properties of an object - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ObjectSetMaterialParamsPbr { /// Which object to change pub object_id: Uuid, @@ -568,14 +673,18 @@ define_modeling_cmd_enum! { pub ambient_occlusion: f32, } /// What type of entity is this? - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct GetEntityType { /// ID of the entity being queried. pub entity_id: Uuid, } /// Gets all faces which use the given edge. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid3dGetAllEdgeFaces { /// Which object is being queried. pub object_id: Uuid, @@ -584,7 +693,9 @@ define_modeling_cmd_enum! { } /// Add a hole to a Solid2d object before extruding it. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid2dAddHole { /// Which object to add the hole to. pub object_id: Uuid, @@ -593,7 +704,9 @@ define_modeling_cmd_enum! { } /// Gets all edges which are opposite the given edge, across all possible faces. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid3dGetAllOppositeEdges { /// Which object is being queried. pub object_id: Uuid, @@ -604,7 +717,9 @@ define_modeling_cmd_enum! { } /// Gets the edge opposite the given edge, along the given face. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid3dGetOppositeEdge { /// Which object is being queried. pub object_id: Uuid, @@ -615,7 +730,9 @@ define_modeling_cmd_enum! { } /// Gets the next adjacent edge for the given edge, along the given face. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid3dGetNextAdjacentEdge { /// Which object is being queried. pub object_id: Uuid, @@ -626,7 +743,9 @@ define_modeling_cmd_enum! { } /// Gets the previous adjacent edge for the given edge, along the given face. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid3dGetPrevAdjacentEdge { /// Which object is being queried. pub object_id: Uuid, @@ -637,7 +756,9 @@ define_modeling_cmd_enum! { } /// Gets the shared edge between these two faces if it exists - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid3dGetCommonEdge { /// Which object is being queried. pub object_id: Uuid, @@ -646,7 +767,9 @@ define_modeling_cmd_enum! { } /// Fillets the given edge with the specified radius. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid3dFilletEdge { /// Which object is being filletted. pub object_id: Uuid, @@ -666,14 +789,18 @@ define_modeling_cmd_enum! { } /// Determines whether a brep face is planar and returns its surface-local planar axes if so - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct FaceIsPlanar { /// Which face is being queried. pub object_id: Uuid, } /// Determines a position on a brep face evaluated by parameters u,v - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct FaceGetPosition { /// Which face is being queried. pub object_id: Uuid, @@ -683,14 +810,18 @@ define_modeling_cmd_enum! { } ///Obtains the surface "center of mass" - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct FaceGetCenter { /// Which face is being queried. pub object_id: Uuid, } /// Determines the gradient (dFdu, dFdv) + normal vector on a brep face evaluated by parameters u,v - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct FaceGetGradient { /// Which face is being queried. pub object_id: Uuid, @@ -700,7 +831,9 @@ define_modeling_cmd_enum! { } /// Send object to front or back. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SendObject { /// Which object is being changed. pub object_id: Uuid, @@ -708,7 +841,9 @@ define_modeling_cmd_enum! { pub front: bool, } /// Set opacity of the entity. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntitySetOpacity { /// Which entity is being changed. pub entity_id: Uuid, @@ -719,7 +854,9 @@ define_modeling_cmd_enum! { } /// Fade entity in or out. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EntityFade { /// Which entity is being changed. pub entity_id: Uuid, @@ -731,7 +868,9 @@ define_modeling_cmd_enum! { } /// Make a new plane - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct MakePlane { /// Origin of the plane pub origin: Point3d, @@ -750,7 +889,9 @@ define_modeling_cmd_enum! { } /// Set the color of a plane. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct PlaneSetColor { /// Which plane is being changed. pub plane_id: Uuid, @@ -759,14 +900,18 @@ define_modeling_cmd_enum! { } /// Set the current tool. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SetTool { /// What tool should be active. pub tool: SceneToolType, } /// Send a mouse move event - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct MouseMove { /// Where the mouse is pub window: Point2d, @@ -779,7 +924,9 @@ define_modeling_cmd_enum! { /// Send a mouse click event /// Updates modified/selected entities. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct MouseClick { /// Where the mouse is pub window: Point2d, @@ -788,15 +935,31 @@ define_modeling_cmd_enum! { /// Disable sketch mode. /// If you are sketching on a face, be sure to not disable sketch mode until you have extruded. /// Otherwise, your object will not be fused with the face. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] - pub struct SketchModeDisable; + #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct SketchModeDisable { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Get the plane for sketch mode. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] - pub struct GetSketchModePlane; + #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct GetSketchModePlane { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Get the plane for sketch mode. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct CurveSetConstraint { /// Which curve to constrain. pub object_id: Uuid, @@ -807,7 +970,9 @@ define_modeling_cmd_enum! { } /// Sketch on some entity (e.g. a plane, a face). - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct EnableSketchMode { /// Which entity to sketch on. pub entity_id: Uuid, @@ -826,54 +991,80 @@ define_modeling_cmd_enum! { /// Sets whether or not changes to the scene or its objects will be done as a "dry run" /// In a dry run, successful commands won't actually change the model. /// This is useful for catching errors before actually making the change. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] - pub struct EnableDryRun; + #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct EnableDryRun { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Sets whether or not changes to the scene or its objects will be done as a "dry run" /// In a dry run, successful commands won't actually change the model. /// This is useful for catching errors before actually making the change. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] - pub struct DisableDryRun; + #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct DisableDryRun { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Set the background color of the scene. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SetBackgroundColor { /// The color to set the background to. pub color: Color, } /// Set the properties of the tool lines for the scene. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SetCurrentToolProperties { /// The color to set the tool line to. pub color: Option, } /// Set the default system properties used when a specific property isn't set. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SetDefaultSystemProperties { /// The default system color. pub color: Option, } /// Get type of the given curve. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct CurveGetType { /// Which curve to query. pub curve_id: Uuid, } /// Get control points of the given curve. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct CurveGetControlPoints { /// Which curve to query. pub curve_id: Uuid, } /// Enum containing the variety of image formats snapshots may be exported to. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, FromStr, Display)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, FromStr, Display)] #[serde(rename_all = "snake_case")] #[display(style = "snake_case")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum ImageFormat { /// .png format Png, @@ -882,14 +1073,18 @@ define_modeling_cmd_enum! { } /// Take a snapshot of the current view. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct TakeSnapshot { /// What image format to return. pub format: ImageFormat, } /// Add a gizmo showing the axes. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct MakeAxesGizmo { /// If true, axes gizmo will be placed in the corner of the screen. /// If false, it will be placed at the origin of the scene. @@ -899,14 +1094,18 @@ define_modeling_cmd_enum! { } /// Query the given path. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct PathGetInfo { /// Which path to query pub path_id: Uuid, } /// Obtain curve ids for vertex ids - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct PathGetCurveUuidsForVertices { /// Which path to query pub path_id: Uuid, @@ -916,7 +1115,9 @@ define_modeling_cmd_enum! { } /// Obtain curve id by index - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct PathGetCurveUuid { /// Which path to query pub path_id: Uuid, @@ -926,28 +1127,36 @@ define_modeling_cmd_enum! { } /// Obtain vertex ids for a path - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct PathGetVertexUuids { /// Which path to query pub path_id: Uuid, } /// Obtain the sketch target id (if the path was drawn in sketchmode) for a path - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct PathGetSketchTargetUuid { /// Which path to query pub path_id: Uuid, } /// Start dragging the mouse. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct HandleMouseDragStart { /// The mouse position. pub window: Point2d, } /// Continue dragging the mouse. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct HandleMouseDragMove { /// The mouse position. pub window: Point2d, @@ -959,14 +1168,18 @@ define_modeling_cmd_enum! { } /// Stop dragging the mouse. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct HandleMouseDragEnd { /// The mouse position. pub window: Point2d, } /// Remove scene objects. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct RemoveSceneObjects { /// Objects to remove. pub object_ids: HashSet, @@ -974,7 +1187,9 @@ define_modeling_cmd_enum! { /// Utility method. Performs both a ray cast and projection to plane-local coordinates. /// Returns the plane coordinates for the given window coordinates. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct PlaneIntersectAndProject { /// The plane you're intersecting against. pub plane_id: Uuid, @@ -983,14 +1198,18 @@ define_modeling_cmd_enum! { } /// Find the start and end of a curve. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct CurveGetEndPoints { /// ID of the curve being queried. pub curve_id: Uuid, } /// Reconfigure the stream. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ReconfigureStream { /// Width of the stream. pub width: u32, @@ -1005,6 +1224,8 @@ define_modeling_cmd_enum! { /// Import files to the current model. #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ImportFiles { /// Files to import. pub files: Vec, @@ -1014,14 +1235,18 @@ define_modeling_cmd_enum! { /// Set the units of the scene. /// For all following commands, the units will be interpreted as the given units. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SetSceneUnits { /// Which units the scene uses. pub unit: units::UnitLength, } /// Get the mass of entities in the scene or the default scene. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Mass { /// IDs of the entities to get the mass of. If this is empty, then the default scene is included in /// the mass. @@ -1035,7 +1260,9 @@ define_modeling_cmd_enum! { } /// Get the density of entities in the scene or the default scene. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Density { /// IDs of the entities to get the density of. If this is empty, then the default scene is included in /// the density. @@ -1049,7 +1276,9 @@ define_modeling_cmd_enum! { } /// Get the volume of entities in the scene or the default scene. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Volume { /// IDs of the entities to get the volume of. If this is empty, then the default scene is included in /// the volume. @@ -1059,7 +1288,9 @@ define_modeling_cmd_enum! { } /// Get the center of mass of entities in the scene or the default scene. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct CenterOfMass { /// IDs of the entities to get the center of mass of. If this is empty, then the default scene is included in /// the center of mass. @@ -1069,7 +1300,9 @@ define_modeling_cmd_enum! { } /// Get the surface area of entities in the scene or the default scene. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SurfaceArea { /// IDs of the entities to get the surface area of. If this is empty, then the default scene is included in /// the surface area. @@ -1080,16 +1313,20 @@ define_modeling_cmd_enum! { /// Focus the default camera upon an object in the scene. #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, + Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct DefaultCameraFocusOn { /// UUID of object to focus on. pub uuid: Uuid, } /// When you select some entity with the current tool, what should happen to the entity? #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, + Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SetSelectionType { /// What type of selection should occur when you select something? pub selection_type: SceneSelectionType, @@ -1097,8 +1334,10 @@ define_modeling_cmd_enum! { /// What kind of entities can be selected? #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, + Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SetSelectionFilter { /// If vector is empty, clear all filters. /// If vector is non-empty, only the given entity types will be selectable. @@ -1107,14 +1346,23 @@ define_modeling_cmd_enum! { /// Use orthographic projection. #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, + Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, )] - pub struct DefaultCameraSetOrthographic; + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct DefaultCameraSetOrthographic { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Use perspective projection. #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, + Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct DefaultCameraSetPerspective { /// If this is not given, use the same parameters as last time the perspective camera was used. pub parameters: Option, @@ -1123,8 +1371,10 @@ define_modeling_cmd_enum! { ///Updates the camera to center to the center of the current selection ///(or the origin if nothing is selected) #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, + Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct DefaultCameraCenterToSelection { /// Dictates whether or not the camera position should be adjusted during this operation /// If no movement is requested, the camera will orbit around the new center from its current position @@ -1134,8 +1384,10 @@ define_modeling_cmd_enum! { ///Updates the camera to center to the center of the current scene's bounds #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, + Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, )] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct DefaultCameraCenterToScene { /// Dictates whether or not the camera position should be adjusted during this operation /// If no movement is requested, the camera will orbit around the new center from its current position @@ -1144,7 +1396,9 @@ define_modeling_cmd_enum! { } /// Fit the view to the specified object(s). - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ZoomToFit { /// Which objects to fit camera to; if empty, fit to all non-default objects. Defaults to empty vector. #[serde(default = "default_uuid_vector")] @@ -1161,7 +1415,9 @@ define_modeling_cmd_enum! { } /// Fit the view to the scene with an isometric view. - #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ViewIsometric { /// How much to pad the view frame by, as a fraction of the object(s) bounding box size. /// Negative padding will crop the view of the object proportionally. @@ -1172,7 +1428,9 @@ define_modeling_cmd_enum! { } /// Get a concise description of all of an extrusion's faces. - #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] + #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Solid3dGetExtrusionFaceInfo { /// The Solid3d object whose extrusion is being queried. pub object_id: Uuid, @@ -1181,24 +1439,45 @@ define_modeling_cmd_enum! { } /// Clear the selection - #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, - )] - pub struct SelectClear; + #[derive(Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct SelectClear { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Find all IDs of selected entities - #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] - pub struct SelectGet; + #[derive(Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct SelectGet { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Get the number of objects in the scene #[derive( - Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, + Clone, Debug, Default, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant, )] - pub struct GetNumObjects; + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] + pub struct GetNumObjects { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + } /// Make a new path by offsetting an object by a given distance. /// The new path's ID will be the ID of this command. - #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] + #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct MakeOffsetPath { /// The object that will be offset (can be a path, sketch, or a solid) pub object_id: Uuid, @@ -1213,7 +1492,9 @@ define_modeling_cmd_enum! { } /// Add a hole to a closed path by offsetting it a uniform distance inward. - #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] + #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema, Serialize, ModelingCmdVariant)] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct AddHoleFromOffset { /// The closed path to add a hole to. pub object_id: Uuid, @@ -1251,6 +1532,8 @@ impl ModelingCmd { /// If you are sending binary data for a file, be sure to send the WebSocketRequest as /// binary/bson, not text/json. #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Eq, PartialEq)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ImportFile { /// The file's full path, including file extension. pub path: String, diff --git a/modeling-cmds/src/format/fbx.rs b/modeling-cmds/src/format/fbx.rs index cc664aa5..a46b6f03 100644 --- a/modeling-cmds/src/format/fbx.rs +++ b/modeling-cmds/src/format/fbx.rs @@ -24,6 +24,8 @@ pub mod import { )] #[display("")] #[serde(rename = "FbxImportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options {} } @@ -34,6 +36,8 @@ pub mod export { /// Options for exporting FBX. #[derive(Clone, Debug, Default, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(rename = "FbxExportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Specifies which kind of FBX will be exported. pub storage: Storage, @@ -80,6 +84,8 @@ pub mod export { )] #[display(style = "snake_case")] #[serde(rename = "FbxStorage", rename_all = "snake_case")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum Storage { /// ASCII FBX encoding. Ascii, diff --git a/modeling-cmds/src/format/gltf.rs b/modeling-cmds/src/format/gltf.rs index e9ea9627..857d5cd6 100644 --- a/modeling-cmds/src/format/gltf.rs +++ b/modeling-cmds/src/format/gltf.rs @@ -24,6 +24,8 @@ pub mod import { )] #[display("")] #[serde(rename = "GltfImportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options {} } @@ -34,6 +36,8 @@ pub mod export { #[derive(Default, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[display("storage: {storage}, presentation: {presentation}")] #[serde(rename = "GltfExportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Specifies which kind of glTF 2.0 will be exported. pub storage: Storage, @@ -47,6 +51,8 @@ pub mod export { )] #[display(style = "snake_case")] #[serde(rename = "GltfStorage", rename_all = "snake_case")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum Storage { /// Binary glTF 2.0. /// @@ -75,6 +81,8 @@ pub mod export { )] #[display(style = "snake_case")] #[serde(rename = "GltfPresentation", rename_all = "snake_case")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum Presentation { /// Condense the JSON into the smallest possible size. Compact, diff --git a/modeling-cmds/src/format/mod.rs b/modeling-cmds/src/format/mod.rs index 4d04a56f..df404138 100644 --- a/modeling-cmds/src/format/mod.rs +++ b/modeling-cmds/src/format/mod.rs @@ -27,6 +27,8 @@ pub mod sldprt; #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[serde(tag = "type", rename_all = "snake_case")] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum OutputFormat { /// Autodesk Filmbox (FBX) format. #[display("{}: {0}")] @@ -55,6 +57,8 @@ pub enum OutputFormat { #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[serde(tag = "type", rename_all = "snake_case")] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum InputFormat { /// Autodesk Filmbox (FBX) format. #[display("{}: {0}")] @@ -85,6 +89,8 @@ pub enum InputFormat { #[derive(Clone, Debug, Default, Display, Eq, FromStr, Hash, PartialEq, JsonSchema, Deserialize, Serialize)] #[display(style = "snake_case")] #[serde(rename_all = "snake_case", tag = "type")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum Selection { /// Visit the default scene. #[default] diff --git a/modeling-cmds/src/format/obj.rs b/modeling-cmds/src/format/obj.rs index d922bf4f..5f609078 100644 --- a/modeling-cmds/src/format/obj.rs +++ b/modeling-cmds/src/format/obj.rs @@ -15,6 +15,8 @@ pub mod import { )] #[display("coords: {coords}, units: {units}")] #[serde(rename = "ObjImportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Co-ordinate system of input data. /// @@ -48,6 +50,8 @@ pub mod export { #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[display("coords: {coords}, units: {units}")] #[serde(rename = "ObjExportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Co-ordinate system of output data. /// diff --git a/modeling-cmds/src/format/ply.rs b/modeling-cmds/src/format/ply.rs index d45293db..006cec0a 100644 --- a/modeling-cmds/src/format/ply.rs +++ b/modeling-cmds/src/format/ply.rs @@ -15,6 +15,8 @@ pub mod import { )] #[display("coords: {coords}, units: {units}")] #[serde(rename = "PlyImportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Co-ordinate system of input data. /// @@ -48,6 +50,8 @@ pub mod export { #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[display("coords: {coords}, selection: {selection}, storage: {storage}, units: {units}")] #[serde(rename = "PlyExportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Co-ordinate system of output data. /// @@ -83,6 +87,8 @@ pub mod export { #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr, Default)] #[display(style = "snake_case")] #[serde(rename = "PlyStorage", rename_all = "snake_case")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum Storage { /// Write numbers in their ascii representation (e.g. -13, 6.28, etc.). Properties are separated by spaces and elements are separated by line breaks. #[default] diff --git a/modeling-cmds/src/format/sldprt.rs b/modeling-cmds/src/format/sldprt.rs index 78a0cc0f..aaba58ca 100644 --- a/modeling-cmds/src/format/sldprt.rs +++ b/modeling-cmds/src/format/sldprt.rs @@ -22,6 +22,8 @@ pub mod import { )] #[display("split_closed_faces: {split_closed_faces}")] #[serde(default, rename = "SldprtImportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Splits all closed faces into two open faces. /// diff --git a/modeling-cmds/src/format/step.rs b/modeling-cmds/src/format/step.rs index 2c599ade..20f3c0f7 100644 --- a/modeling-cmds/src/format/step.rs +++ b/modeling-cmds/src/format/step.rs @@ -25,6 +25,8 @@ pub mod import { )] #[display("split_closed_faces: {split_closed_faces}")] #[serde(default, rename = "StepImportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Splits all closed faces into two open faces. /// @@ -40,6 +42,8 @@ pub mod export { /// Options for exporting STEP format. #[derive(Clone, Debug, Deserialize, Eq, Hash, JsonSchema, PartialEq, Serialize)] #[serde(rename = "StepExportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Co-ordinate system of output data. /// diff --git a/modeling-cmds/src/format/stl.rs b/modeling-cmds/src/format/stl.rs index c3631947..a719b998 100644 --- a/modeling-cmds/src/format/stl.rs +++ b/modeling-cmds/src/format/stl.rs @@ -15,6 +15,8 @@ pub mod import { )] #[display("coords: {coords}, units: {units}")] #[serde(rename = "StlImportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Co-ordinate system of input data. /// @@ -47,6 +49,8 @@ pub mod export { #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, JsonSchema, Display, FromStr)] #[display("coords: {coords}, selection: {selection}, storage: {storage}, units: {units}")] #[serde(rename = "StlExportOptions")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Options { /// Co-ordinate system of output data. /// @@ -84,6 +88,8 @@ pub mod export { )] #[display(style = "snake_case")] #[serde(rename = "StlStorage", rename_all = "snake_case")] + #[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] + #[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum Storage { /// Plaintext encoding. Ascii, diff --git a/modeling-cmds/src/id.rs b/modeling-cmds/src/id.rs index 476f82e3..ae8a298b 100644 --- a/modeling-cmds/src/id.rs +++ b/modeling-cmds/src/id.rs @@ -7,6 +7,8 @@ use uuid::Uuid; /// All commands have unique IDs. These should be randomly generated. #[derive(Debug, Clone, Copy, Hash, Ord, PartialOrd, Eq, PartialEq, JsonSchema, Serialize)] #[cfg_attr(test, derive(Default))] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ModelingCmdId(pub Uuid); impl AsRef for ModelingCmdId { diff --git a/modeling-cmds/src/length_unit.rs b/modeling-cmds/src/length_unit.rs index 2a4fb56d..2fb6213a 100644 --- a/modeling-cmds/src/length_unit.rs +++ b/modeling-cmds/src/length_unit.rs @@ -7,6 +7,8 @@ use crate::shared::{Point2d, Point3d, Point4d}; /// A length unit is wrapper around an f64 that represents a length in some unit. #[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Serialize, Deserialize, Default)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct LengthUnit(pub f64); impl LengthUnit { diff --git a/modeling-cmds/src/shared.rs b/modeling-cmds/src/shared.rs index 2fa1dada..8b8521a7 100644 --- a/modeling-cmds/src/shared.rs +++ b/modeling-cmds/src/shared.rs @@ -13,8 +13,10 @@ pub use point::{Point2d, Point3d, Point4d, Quaternion}; mod point; /// What kind of cut to do -#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, Default)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum CutType { /// Round off an edge. #[default] @@ -24,8 +26,10 @@ pub enum CutType { } /// A rotation defined by an axis, origin of rotation, and an angle. -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Rotation { /// Rotation axis. /// Defaults to (0, 0, 1) (i.e. the Z axis). @@ -49,8 +53,10 @@ impl Default for Rotation { } /// Ways to transform each solid being replicated in a repeating pattern. -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Transform { /// Translate the replica this far along each dimension. /// Defaults to zero vector (i.e. same position as the original). @@ -81,8 +87,10 @@ impl Default for Transform { } /// Options for annotations -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct AnnotationOptions { /// Text displayed on the annotation pub text: Option, @@ -97,8 +105,10 @@ pub struct AnnotationOptions { } /// Options for annotation text -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct AnnotationLineEndOptions { /// How to style the start of the annotation line. pub start: AnnotationLineEnd, @@ -107,8 +117,10 @@ pub struct AnnotationLineEndOptions { } /// Options for annotation text -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct AnnotationTextOptions { /// Alignment along the X axis pub x: AnnotationTextAlignmentX, @@ -123,11 +135,18 @@ pub struct AnnotationTextOptions { /// The type of distance /// Distances can vary depending on /// the objects used as input. -#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)] #[serde(rename_all = "snake_case", tag = "type")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum DistanceType { /// Euclidean Distance. - Euclidean {}, + Euclidean { + #[cfg(feature = "ts-rs")] + /// Work around issue with ts-rs not allowing tag on an empty variant. + #[serde(default, skip)] + _fix_ts_rs: (), + }, /// The distance between objects along the specified axis OnAxis { /// Global axis @@ -136,8 +155,10 @@ pub enum DistanceType { } /// The type of origin -#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, Default)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema, Default)] #[serde(rename_all = "snake_case", tag = "type")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum OriginType { /// Local Origin (center of object bounding box). #[default] @@ -152,7 +173,9 @@ pub enum OriginType { } /// An RGBA color -#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Color { /// Red pub r: f32, @@ -170,6 +193,8 @@ pub struct Color { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum AnnotationTextAlignmentX { Left, Center, @@ -182,6 +207,8 @@ pub enum AnnotationTextAlignmentX { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum AnnotationTextAlignmentY { Bottom, Center, @@ -194,6 +221,8 @@ pub enum AnnotationTextAlignmentY { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum AnnotationLineEnd { None, Arrow, @@ -204,6 +233,8 @@ pub enum AnnotationLineEnd { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum AnnotationType { /// 2D annotation type (screen or planar space) T2D, @@ -216,6 +247,8 @@ pub enum AnnotationType { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum CameraDragInteractionType { /// Camera pan Pan, @@ -231,6 +264,8 @@ pub enum CameraDragInteractionType { /// Paths are composed of many segments. #[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq)] #[serde(rename_all = "snake_case", tag = "type")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum PathSegment { /// A straight line segment. /// Goes from the current path "pen" to the given endpoint. @@ -298,6 +333,8 @@ pub enum PathSegment { /// An angle, with a specific unit. #[derive(Clone, Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Angle { /// What unit is the measurement? pub unit: UnitAngle, @@ -400,6 +437,8 @@ impl std::ops::AddAssign for Angle { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum SceneSelectionType { /// Replaces the selection Replace, @@ -415,6 +454,8 @@ pub enum SceneSelectionType { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum SceneToolType { CameraRevolve, Select, @@ -444,6 +485,8 @@ pub enum SceneToolType { Default, )] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum PathComponentConstraintBound { #[default] Unconstrained, @@ -470,6 +513,8 @@ pub enum PathComponentConstraintBound { Default, )] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum PathComponentConstraintType { #[default] Unconstrained, @@ -486,6 +531,8 @@ pub enum PathComponentConstraintType { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum PathCommand { MoveTo, LineTo, @@ -500,6 +547,8 @@ pub enum PathCommand { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] #[repr(u8)] pub enum EntityType { Entity, @@ -520,6 +569,8 @@ pub enum EntityType { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum CurveType { Line, Arc, @@ -541,6 +592,8 @@ pub struct ExportFile { )] #[serde(rename_all = "lowercase")] #[display(style = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum FileExportFormat { /// Autodesk Filmbox (FBX) format. Fbx, @@ -580,6 +633,8 @@ pub enum FileExportFormat { )] #[serde(rename_all = "lowercase")] #[display(style = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum FileImportFormat { /// Autodesk Filmbox (FBX) format. Fbx, @@ -602,6 +657,8 @@ pub enum FileImportFormat { /// The type of error sent by the KittyCAD graphics engine. #[derive(Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, Ord, PartialOrd)] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum EngineErrorCode { /// User requested something geometrically or graphically impossible. /// Don't retry this request, as it's inherently impossible. Instead, read the error message @@ -621,7 +678,9 @@ impl From for http::StatusCode { } /// IDs for the extruded faces. -#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)] +#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct ExtrudedFaceInfo { /// The face made from the original 2D shape being extruded. /// If the solid is extruded from a shape which already has an ID @@ -635,7 +694,9 @@ pub struct ExtrudedFaceInfo { } /// IDs for a side face, extruded from the path of some sketch/2D shape. -#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)] +#[derive(Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct SideFace { /// ID of the path this face is being extruded from. pub path_id: Uuid, @@ -645,6 +706,8 @@ pub struct SideFace { /// Camera settings including position, center, fov etc #[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct CameraSettings { ///Camera position (vantage) pub pos: Point3d, @@ -702,6 +765,8 @@ impl From for crate::output::ViewIsometric { /// Defines a perspective view. #[derive(Copy, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Clone, PartialOrd, Default)] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct PerspectiveCameraParameters { /// Camera frustum vertical field of view. pub fov_y: Option, @@ -729,6 +794,8 @@ pub struct PerspectiveCameraParameters { PartialOrd, )] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum CameraMovement { /// Adjusts the camera position during the camera operation #[default] @@ -742,6 +809,8 @@ pub enum CameraMovement { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum GlobalAxis { /// The X axis X, @@ -756,6 +825,8 @@ pub enum GlobalAxis { Display, FromStr, Copy, Eq, PartialEq, Debug, JsonSchema, Deserialize, Serialize, Sequence, Clone, Ord, PartialOrd, )] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] #[repr(u8)] pub enum ExtrusionFaceCapType { /// Uncapped. @@ -787,6 +858,8 @@ pub enum ExtrusionFaceCapType { Default, )] #[serde(rename_all = "lowercase")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum PostEffectType { Phosphor, Ssao, diff --git a/modeling-cmds/src/shared/point.rs b/modeling-cmds/src/shared/point.rs index b6b23f51..b9b475d1 100644 --- a/modeling-cmds/src/shared/point.rs +++ b/modeling-cmds/src/shared/point.rs @@ -10,6 +10,8 @@ mod zero; #[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, Default)] #[serde(rename = "Point2d")] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Point2d { #[allow(missing_docs)] pub x: T, @@ -56,6 +58,8 @@ impl Point2d { #[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq, Default)] #[serde(rename = "Point3d")] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Point3d { #[allow(missing_docs)] pub x: T, @@ -113,6 +117,8 @@ impl Point3d { #[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)] #[serde(rename = "Point4d")] #[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub struct Point4d { #[allow(missing_docs)] pub x: T, diff --git a/modeling-cmds/src/units.rs b/modeling-cmds/src/units.rs index a63acd24..47b3ef13 100644 --- a/modeling-cmds/src/units.rs +++ b/modeling-cmds/src/units.rs @@ -23,6 +23,8 @@ use serde::{Deserialize, Serialize}; )] #[cfg_attr(feature = "tabled", derive(tabled::Tabled))] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum UnitLength { /// Centimeters #[serde(rename = "cm")] @@ -84,6 +86,8 @@ impl UnitLength { #[cfg_attr(feature = "tabled", derive(tabled::Tabled))] #[serde(rename_all = "snake_case")] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum UnitAngle { /// Degrees Degrees, @@ -112,6 +116,8 @@ pub enum UnitAngle { #[cfg_attr(feature = "tabled", derive(tabled::Tabled))] #[serde(rename_all = "snake_case")] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum UnitArea { /// Square centimeters #[serde(rename = "cm2")] @@ -184,6 +190,8 @@ impl UnitArea { )] #[cfg_attr(feature = "tabled", derive(tabled::Tabled))] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum UnitDensity { /// Pounds per cubic feet. #[serde(rename = "lb:ft3")] @@ -228,6 +236,8 @@ impl UnitDensity { #[cfg_attr(feature = "tabled", derive(tabled::Tabled))] #[serde(rename_all = "snake_case")] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum UnitMass { /// Grams #[default] @@ -275,6 +285,8 @@ impl UnitMass { )] #[cfg_attr(feature = "tabled", derive(tabled::Tabled))] #[display(style = "snake_case")] +#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts-rs", ts(export_to = "ModelingCmd.ts"))] pub enum UnitVolume { /// Cubic centimeters (cc or cm³) #[serde(rename = "cm3")] diff --git a/modeling-session/examples/cube_png.rs b/modeling-session/examples/cube_png.rs index c31d3f00..625de92d 100644 --- a/modeling-session/examples/cube_png.rs +++ b/modeling-session/examples/cube_png.rs @@ -44,7 +44,7 @@ async fn main() -> Result<()> { let path_id = Uuid::new_v4(); let path = path_id.into(); session - .run_command(path, ModelingCmd::StartPath(StartPath {})) + .run_command(path, ModelingCmd::StartPath(StartPath::default())) .await .context("could not create path")?; diff --git a/modeling-session/examples/cube_png_batch.rs b/modeling-session/examples/cube_png_batch.rs index 4fd3340f..210459b8 100644 --- a/modeling-session/examples/cube_png_batch.rs +++ b/modeling-session/examples/cube_png_batch.rs @@ -45,7 +45,7 @@ async fn main() -> Result<()> { let path_id = Uuid::new_v4(); let path = path_id.into(); session - .run_command(path, StartPath {}.into()) + .run_command(path, StartPath::default().into()) .await .context("could not create path")?; diff --git a/modeling-session/examples/lsystem_png_batch.rs b/modeling-session/examples/lsystem_png_batch.rs index c2a8a265..842ee4cc 100644 --- a/modeling-session/examples/lsystem_png_batch.rs +++ b/modeling-session/examples/lsystem_png_batch.rs @@ -52,7 +52,7 @@ async fn main() -> Result<()> { let path_id = Uuid::new_v4(); let path = path_id.into(); session - .run_command(path, ModelingCmd::from(StartPath {})) + .run_command(path, ModelingCmd::from(StartPath::default())) .await .context("could not create path")?;