diff --git a/CHANGELOG.md b/CHANGELOG.md index bb84566d..821fa08e 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,6 +104,22 @@ see the notices in the README. ### Fixed +- **CI on `main` is green again.** The usage statistics page (#383) gives + its table headers a `scope` (accessibility check), its background and + reporting functions are named in the audit guard's `NOT_AUDITED` list with + their reasons, the web module list is in rustfmt's order, and the error + page test expects the escaped `/` MiniJinja writes (#381). +- **SolidCraft plugin: *status* and *check* run again, and each button has + its own label.** SolidCraft refused both with *permission denied: edit + command document.metadata from read entry*, because it classes the + commands they read with as edit commands, so they are now declared `edit` + (they still change nothing). The four ribbon buttons, all labelled + *TeamCraft* before, now read *TeamCraft status*, *Check for TeamCraft*, + *Link to TeamCraft item* and *Unlink from TeamCraft*. + Failures explain themselves: bad input names the field, damaged TeamCraft + data in a design is reported with the fix, and *check* never reports + *ready* when it could not read the BOM or the linked designs. All four + entries were run on SolidCraft 0.45.0 (flatpak) through `solidcraft-cli`. - **Desktop: a slow STEP export no longer holds the check-in hostage** (#342). With *Create STEP exports* ticked, the files are uploaded first (parked), then exported, then checked in with the STEP files. *Cancel* diff --git a/docs/src/research/solidcraft-design.md b/docs/src/research/solidcraft-design.md index 574fa83a..6a1cb19b 100644 --- a/docs/src/research/solidcraft-design.md +++ b/docs/src/research/solidcraft-design.md @@ -114,6 +114,23 @@ Both are already skipped by the desktop app's `is_ignored`. SolidCraft's plugins are sandboxed WebAssembly components without sockets, HTTP or fetch: an add-in inside SolidCraft cannot talk to a TeamCraft server. +An entry declared `"effect": "read"` may only call commands SolidCraft's +command catalog classes as `read`; anything else fails with *permission +denied: edit command … from read entry*. A command is `edit` unless its +spec says it is read-only, and `document.metadata`, `assembly.bom` and +`component.links` do not (SolidCraft's open source, `crates/engine/src/cmd/` +and `crates/craft-plugin-wasm/src/native.rs`, as of November 2026). So the +plugin's `status` and `check` entries are declared `edit` even though they +only read. A ribbon slot's `name` is the label of the entry's button +(`crates/ui-egui/src/plugin_menu.rs`). + +A command that fails or is refused inside an entry ends the whole run: the +host records the first failure and returns it as the entry's result, even when +the guest handles the error (`crates/craft-plugin-wasm/src/native.rs`, +`fail` and `check`; seen on SolidCraft 0.45.0 with `solidcraft-cli`). A part +without components answers `assembly.bom` with no rows and +`component.links` with no links, so neither fails on a plain part. + ## Decision * Read `.sc` designs on the server with TeamCraft's own bounded ZIP/JSON diff --git a/plugins/solidcraft/Cargo.lock b/plugins/solidcraft/Cargo.lock new file mode 100644 index 00000000..1c652c89 --- /dev/null +++ b/plugins/solidcraft/Cargo.lock @@ -0,0 +1,835 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "auditable-serde" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7bf8143dfc3c0258df908843e169b5cc5fcf76c7718bd66135ef4a9cd558c5" +dependencies = [ + "semver", + "serde", + "serde_json", + "topological-sort", +] + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "crc32fast" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "flate2" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide", + "zlib-rs", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.2", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.119", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59" + +[[package]] +name = "spdx" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e17e880bafaeb362a7b751ec46bdc5b61445a188f80e0606e68167cd540fa3" +dependencies = [ + "smallvec", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "teamcraft-solidcraft-plugin" +version = "0.1.0" +dependencies = [ + "serde_json", + "wit-bindgen", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "topological-sort" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "wasm-encoder" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bb72f02e7fbf07183443b27b0f3d4144abf8c114189f2e088ed95b696a7822" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce1ef0faabbbba6674e97a56bee857ccddf942785a336c8b47b42373c922a91d" +dependencies = [ + "anyhow", + "auditable-serde", + "flate2", + "indexmap", + "serde", + "serde_derive", + "serde_json", + "spdx", + "url", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f51cad774fb3c9461ab9bccc9c62dfb7388397b5deda31bf40e8108ccd678b2" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "wit-bindgen" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10fb6648689b3929d56bbc7eb1acf70c9a42a29eb5358c67c10f54dbd5d695de" +dependencies = [ + "wit-bindgen-rt", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92fa781d4f2ff6d3f27f3cc9b74a73327b31ca0dc4a3ef25a0ce2983e0e5af9b" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db52a11d4dfb0a59f194c064055794ee6564eb1ced88c25da2cf76e50c5621" +dependencies = [ + "bitflags", + "futures", + "once_cell", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0809dc5ba19e2e98661bf32fc0addc5a3ca5bf3a6a7083aa6ba484085ff3ce" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn 2.0.119", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad19eec017904e04c60719592a803ee5da76cb51c81e3f6fbf9457f59db49799" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.119", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "635c3adc595422cbf2341a17fb73a319669cc8d33deed3a48368a841df86b676" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf445ed5157046e4baf56f9138c124a0824d4d1657e7204d71886ad8ce2fc11" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/plugins/solidcraft/README.md b/plugins/solidcraft/README.md index fa0c6120..012e90aa 100644 --- a/plugins/solidcraft/README.md +++ b/plugins/solidcraft/README.md @@ -15,20 +15,43 @@ working folder stay in the TeamCraft desktop app. ## Entries -All four are on the *TeamCraft* ribbon group (Plugins tab) and in the -Plugins menu. +Each has its own button in the ribbon's Plugins group (labelled as in the +table) and a row in the Plugins menu. | Entry | Effect | What it does | |-------|--------|--------------| -| **status** – *TeamCraft status* | read | The TeamCraft item and revision the design belongs to, the page of the revision on the server, and whether the design's part number and revision still say the same. | -| **check** – *Check for TeamCraft* | read | What keeps the design from going into TeamCraft cleanly: no part number, a part number or revision that differs from the linked item, BOM rows without a part number, one part number with two descriptions, quantities SolidCraft cannot add up, linked designs with an absolute path or two linked designs with the same file name. `ready` is true when only notes are left. | +| **status** – *TeamCraft status* | edit¹ | The TeamCraft item and revision the design belongs to, the page of the revision on the server, and whether the design's part number and revision still say the same. | +| **check** – *Check for TeamCraft* | edit¹ | What keeps the design from going into TeamCraft cleanly: no part number, a part number or revision that differs from the linked item, BOM rows without a part number, one part number with two descriptions, quantities SolidCraft cannot add up, linked designs with an absolute path or two linked designs with the same file name. `ready` is true when only notes are left. | | **link** – *Link to TeamCraft item* | edit | Writes item number, revision and (optional) name into the design properties (*Part number*, *Revision*, *Description*) and TeamCraft's object – for designs edited without the desktop app. Ids written by the desktop app are kept while the item stays the same. One undo step; save the design afterwards. | | **unlink** – *Unlink from TeamCraft* | edit | Removes TeamCraft's object; part number and revision stay. | +¹ *status* and *check* only read. They are declared `edit` because SolidCraft +classes `document.metadata`, `assembly.bom` and `component.links` as edit +commands and refuses them from a read entry (*permission denied: edit command +document.metadata from read entry*). + SolidCraft commands it calls (declared in `plugin.json`, none of them reads or writes files): `document.metadata`, `document.metadata.set`, `document.metadata.remove`, `assembly.bom`, `component.links`. +## When something fails + +The plugin needs neither a TeamCraft server nor the desktop app: TeamCraft +not running never makes it fail. What it says when something does go wrong: + +- **Bad input** to *Link to TeamCraft item* names the field and changes + nothing (*Item number is required. Nothing was changed.*). +- **A design without TeamCraft data** is *not linked*, with how to link it. + **Damaged TeamCraft data** (not an object) is reported, with *Link* or + *Unlink* as the fix. +- **A SolidCraft command that fails** ends the run: SolidCraft shows its own + message, prefixed *TeamCraft:*, and keeps the design as it was. The plugin + cannot catch it (SolidCraft 0.45). So the plugin only calls commands that + answer on any design – a part without components gives an empty BOM and no + links – and checks its input before it writes. On a host that hands the + error back, the plugin adds what to do, and *check* reports a BOM or link + list it could not read as a warning instead of *ready*. + ## Build ```sh diff --git a/plugins/solidcraft/plugin.json b/plugins/solidcraft/plugin.json index ae9f94c5..f13e4f5b 100644 --- a/plugins/solidcraft/plugin.json +++ b/plugins/solidcraft/plugin.json @@ -9,15 +9,15 @@ "entries": [ { "name": "status", - "effect": "read", + "effect": "edit", "input_schema": {"type": "object", "properties": {}}, - "slots": [{"kind": "ribbon", "name": "TeamCraft"}] + "slots": [{"kind": "ribbon", "name": "TeamCraft status"}] }, { "name": "check", - "effect": "read", + "effect": "edit", "input_schema": {"type": "object", "properties": {}}, - "slots": [{"kind": "ribbon", "name": "TeamCraft"}] + "slots": [{"kind": "ribbon", "name": "Check for TeamCraft"}] }, { "name": "link", @@ -32,13 +32,13 @@ "server": {"type": "string", "title": "TeamCraft server (https://…)", "maxLength": 256} } }, - "slots": [{"kind": "ribbon", "name": "TeamCraft"}] + "slots": [{"kind": "ribbon", "name": "Link to TeamCraft item"}] }, { "name": "unlink", "effect": "edit", "input_schema": {"type": "object", "properties": {}}, - "slots": [{"kind": "ribbon", "name": "TeamCraft"}] + "slots": [{"kind": "ribbon", "name": "Unlink from TeamCraft"}] } ], "commands": [ diff --git a/plugins/solidcraft/src/lib.rs b/plugins/solidcraft/src/lib.rs index bd9b1bbc..471c240a 100644 --- a/plugins/solidcraft/src/lib.rs +++ b/plugins/solidcraft/src/lib.rs @@ -59,7 +59,7 @@ mod component { let params: serde_json::Value = serde_json::from_str(¶ms).map_err(|e| { PluginError::InvalidInput(FieldFailure { field: "params".into(), - reason: e.to_string(), + reason: format!("the entry's input is not JSON ({e}); nothing was changed"), }) })?; match logic::execute(&mut Commands, &entry, ¶ms) { diff --git a/plugins/solidcraft/src/logic.rs b/plugins/solidcraft/src/logic.rs index 3f3eaea3..2adfa3fd 100644 --- a/plugins/solidcraft/src/logic.rs +++ b/plugins/solidcraft/src/logic.rs @@ -31,18 +31,56 @@ pub enum EntryError { Unsupported(String), } +/// The label of a field of *Link to TeamCraft item*, as its dialog shows it. +fn label(field: &str) -> &str { + match field { + "item_number" => "Item number", + "revision" => "Revision", + "name" => "Item name", + "server" => "TeamCraft server", + other => other, + } +} + +/// A broken input. SolidCraft shows only the reason, so the reason names the +/// field itself (`Item number is required`, not `is required`). fn input(field: &str, reason: &str) -> EntryError { EntryError::Input { field: field.into(), - reason: reason.into(), + reason: format!("{} {reason}. Nothing was changed.", label(field)), } } +/// Why SolidCraft refused or failed `command`, in words a user can act on. +/// The plugin never talks to a TeamCraft server or the desktop app (it has no +/// network), so a failure here is always SolidCraft's answer about the open +/// design – TeamCraft not running is never the cause. +pub fn explain(command: &str, reason: &str) -> String { + let reason = reason.trim(); + let lower = reason.to_ascii_lowercase(); + let hint = if lower.contains("permission denied") || lower.contains("not granted") { + "This SolidCraft version does not let the TeamCraft plugin use it – install the TeamCraft \ + plugin that matches your SolidCraft version." + } else if lower.contains("cancel") { + "The run was stopped." + } else if lower.contains("limit") || lower.contains("fuel") || lower.contains("deadline") { + "The design is too large for the plugin's limits." + } else { + "Is a design open? Nothing in the design was changed." + }; + let reason = if reason.is_empty() { + "no reason given" + } else { + reason + }; + format!("SolidCraft could not run {command} ({reason}). {hint}") +} + fn call(host: &mut dyn Host, command: &str, args: Value) -> Result { host.run(command, args) .map_err(|reason| EntryError::Command { command: command.into(), - reason, + reason: explain(command, &reason), }) } @@ -84,6 +122,16 @@ fn text<'a>(map: &'a Map, key: &str) -> &'a str { .unwrap_or("") } +/// The message for a design whose TeamCraft data is not an object (written +/// by hand or by another tool), with what to do about it. +const DAMAGED: &str = "The design's TeamCraft data (teamcraft.pdm) is damaged. Use *Link to \ + TeamCraft item* to write it again, or *Unlink from TeamCraft* to remove it."; + +/// Whether the design has a TeamCraft entry that is not an object. +fn damaged(metadata: &Map) -> bool { + metadata.get(KEY).is_some_and(|v| !v.is_object()) +} + /// TeamCraft's object in the design, if there is one. fn teamcraft(metadata: &Map) -> Option<&Map> { metadata.get(KEY).and_then(Value::as_object) @@ -104,6 +152,15 @@ pub fn status(host: &mut dyn Host) -> Result { let (metadata, props) = properties(host)?; let part_number = text(&props, "part_number"); let revision = text(&props, "revision"); + if damaged(&metadata) { + return Ok(json!({ + "managed": false, + "damaged": true, + "part_number": part_number, + "revision": revision, + "message": DAMAGED, + })); + } let Some(tc) = teamcraft(&metadata) else { return Ok(json!({ "managed": false, @@ -179,6 +236,7 @@ pub fn check(host: &mut dyn Host) -> Result { )); } match teamcraft(&metadata) { + None if damaged(&metadata) => findings.push(finding("warning", DAMAGED.into())), None => findings.push(finding( "info", "Not linked to a TeamCraft item yet.".into(), @@ -221,9 +279,20 @@ pub fn check(host: &mut dyn Host) -> Result { /// BOM rows TeamCraft cannot match: no part number, a quantity SolidCraft /// cannot count, one part number with different descriptions. fn check_bom(host: &mut dyn Host, findings: &mut Vec) { - // a part without components has no rows; a failure is no finding - let Ok(bom) = host.run("assembly.bom", json!({"levels": "all"})) else { - return; + // a part without components answers with no rows; a failure means the + // rows were not checked, which must not read as "ready" + let bom = match host.run("assembly.bom", json!({"levels": "all"})) { + Ok(bom) => bom, + Err(reason) => { + findings.push(finding( + "warning", + format!( + "The bill of materials was not checked: {}", + explain("assembly.bom", &reason) + ), + )); + return; + } }; let rows = bom .get("rows") @@ -277,8 +346,18 @@ fn check_bom(host: &mut dyn Host, findings: &mut Vec) { /// working folder) or two links with the same file name in different /// folders (TeamCraft finds references by file name). fn check_links(host: &mut dyn Host, findings: &mut Vec) { - let Ok(links) = host.run("component.links", json!({})) else { - return; + let links = match host.run("component.links", json!({})) { + Ok(links) => links, + Err(reason) => { + findings.push(finding( + "warning", + format!( + "The linked designs were not checked: {}", + explain("component.links", &reason) + ), + )); + return; + } }; let links = links .get("links") @@ -401,11 +480,16 @@ mod tests { rows: Vec, links: Vec, calls: Vec<(String, Value)>, + /// Commands that fail, with SolidCraft's reason. + fail: Vec<(&'static str, &'static str)>, } impl Host for Fake { fn run(&mut self, command: &str, args: Value) -> Result { self.calls.push((command.to_string(), args.clone())); + if let Some((_, why)) = self.fail.iter().find(|(c, _)| *c == command) { + return Err((*why).to_string()); + } let props = |m: &Map| { let mut p = Map::new(); for k in [ @@ -442,9 +526,6 @@ mod tests { let was = self.metadata.remove(key).is_some(); Ok(json!({"removed": if was { vec![key] } else { vec![] }})) } - "assembly.bom" if self.rows.is_empty() => { - Err("the design has no components".into()) - } "assembly.bom" => Ok(json!({"rows": self.rows})), "component.links" => Ok(json!({"links": self.links})), other => Err(format!("unknown command {other}")), @@ -595,7 +676,11 @@ mod tests { ), ] { match link(&mut f, ¶ms) { - Err(EntryError::Input { field: got, .. }) => assert_eq!(got, field, "{params}"), + Err(EntryError::Input { field: got, reason }) => { + assert_eq!(got, field, "{params}"); + // SolidCraft shows only the reason: it names the field + assert!(reason.starts_with(label(field)), "{reason}"); + } other => panic!("{params}: {other:?}"), } } @@ -605,6 +690,70 @@ mod tests { ); } + /// No hard, unexplained failure: a refused or failed SolidCraft command + /// says which command, SolidCraft's reason and what to do. + #[test] + fn a_failed_command_is_explained() { + let mut refused = linked(); + refused.fail = vec![( + "document.metadata", + "permission denied: edit command document.metadata from read entry", + )]; + let Err(EntryError::Command { command, reason }) = status(&mut refused) else { + panic!("status must fail when the properties cannot be read"); + }; + assert_eq!(command, "document.metadata"); + assert!(reason.contains("permission denied") && reason.contains("matches your SolidCraft")); + let mut closed = Fake { + fail: vec![("document.metadata", "no design is open")], + ..Fake::default() + }; + let Err(EntryError::Command { reason, .. }) = check(&mut closed) else { + panic!("check must fail without properties"); + }; + assert!(reason.contains("no design is open") && reason.contains("Nothing in the design")); + assert!(explain("x", " ").contains("no reason given")); + let mut write = linked(); + write.fail = vec![("document.metadata.set", "the design is read-only")]; + let params = json!({"item_number": "TC-1", "revision": "A"}); + assert!(matches!( + link(&mut write, ¶ms), + Err(EntryError::Command { reason, .. }) if reason.contains("read-only") + )); + } + + /// A BOM or link list SolidCraft cannot give is a warning, never "ready". + #[test] + fn unread_bom_and_links_are_not_ready() { + let mut f = linked(); + f.fail = vec![ + ("assembly.bom", "evaluation failed"), + ("component.links", "evaluation failed"), + ]; + let c = check(&mut f).unwrap(); + assert_eq!(c["ready"], false); + let text = c["findings"].to_string(); + assert!(text.contains("bill of materials was not checked"), "{text}"); + assert!(text.contains("linked designs were not checked"), "{text}"); + // a plain part answers with no rows and no links: ready + assert_eq!(check(&mut linked()).unwrap()["ready"], true); + } + + /// TeamCraft data that is not an object is reported, and link repairs it. + #[test] + fn damaged_teamcraft_data_is_reported_and_repaired() { + let mut f = linked(); + f.metadata.insert(KEY.into(), json!("garbage")); + let s = status(&mut f).unwrap(); + assert_eq!(s["damaged"], true); + assert!(s["message"].as_str().unwrap().contains("damaged")); + let c = check(&mut f).unwrap(); + assert_eq!(c["ready"], false); + let params = json!({"item_number": "TC-1042", "revision": "B"}); + link(&mut f, ¶ms).unwrap(); + assert_eq!(status(&mut f).unwrap()["managed"], true); + } + #[test] fn unlink_removes_only_teamcrafts_object() { let mut f = linked(); @@ -644,5 +793,23 @@ mod tests { assert!(commands.contains(&command), "{command} not declared"); } assert_eq!(manifest["id"], "teamcraft"); + // A ribbon slot's name is the button's label: four different ones, + // not four buttons that all read "TeamCraft". + let entries = manifest["runtime"]["entries"].as_array().unwrap(); + let mut labels: Vec<&str> = entries + .iter() + .map(|e| e["slots"][0]["name"].as_str().unwrap()) + .collect(); + assert!(labels.iter().all(|l| *l != "TeamCraft"), "{labels:?}"); + labels.sort_unstable(); + labels.dedup(); + assert_eq!(labels.len(), ENTRIES.len(), "one label per entry"); + // SolidCraft refuses a command it does not class as `read` from a + // read entry, and it classes document.metadata, assembly.bom and + // component.links as edit commands. So every entry is `edit`; status + // and check only read. + for e in entries { + assert_eq!(e["effect"], "edit", "{}", e["name"]); + } } } diff --git a/src/services/usage.rs b/src/services/usage.rs index 041032ba..32fbe10d 100644 --- a/src/services/usage.rs +++ b/src/services/usage.rs @@ -131,7 +131,7 @@ fn counts(value: &Value, known: &[&str]) -> AppResult> { } /// Checks a desktop report: exactly the documented fields, version 1, a day -/// in the last [`MAX_AGE_DAYS`] days, known OS and architecture. +/// in the last `MAX_AGE_DAYS` (7) days, known OS and architecture. pub fn check_report(report: &Value, today: NaiveDate) -> AppResult { let Some(map) = report.as_object() else { return Err(bad("not an object")); diff --git a/src/templates.rs b/src/templates.rs index e2a0a487..d2f3201e 100755 --- a/src/templates.rs +++ b/src/templates.rs @@ -630,9 +630,10 @@ mod tests { "flash": null, "local_login": true, "path": "/items/PRT-000042", "time": "2026-11-22 08:00:00 UTC", "version": "0.2.12" }), ); + // (MiniJinja escapes `/` in text as `/`; the copied text is decoded) assert!( html.contains("data-copy=\"error-details\"") - && html.contains("Page: /items/PRT-000042") + && html.contains("Page: /items/PRT-000042") ); assert!(html.contains("Something went wrong <b>"), "escaped"); // a hosted live demo: the account on the login page, the banner on every page diff --git a/src/web/mod.rs b/src/web/mod.rs index cd6c57d5..4b7e4a6b 100755 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -17,7 +17,6 @@ mod attributes; mod auth_pages; mod bom; mod branding; -mod usage; mod changes; mod dashboard; mod desktop; @@ -35,6 +34,7 @@ mod revisions; mod season; mod simulations; mod uploads; +mod usage; mod webhooks; // posted by the identity provider: mounted outside the cross-site guard diff --git a/templates/admin/usage.html b/templates/admin/usage.html index 17a5307c..8f3110eb 100644 --- a/templates/admin/usage.html +++ b/templates/admin/usage.html @@ -55,16 +55,16 @@

Desktop apps, last {{ desktop.days }} days

{{ desktop.active_minutes }} active minutes in all.

- + {% for v, n in desktop.versions|dictsort %}{% endfor %}
VersionInstallations
VersionInstallations
{{ v }}{{ n }}
- + {% for v, n in desktop.os|dictsort %}{% endfor %} {% for v, n in desktop.packages|dictsort %}{% endfor %}
SystemInstallations
SystemInstallations
{{ v }}{{ n }}
package: {{ v }}{{ n }}
- + {% for a in actions %}{% endfor %} {% for p, n in desktop.cad_exports|dictsort %}{% endfor %}
ActionCount
ActionCount
{{ a }}{{ desktop.actions[a] or 0 }}
STEP export: {{ p }}{{ n }}
diff --git a/tests/architecture_guards.rs b/tests/architecture_guards.rs index 9e6ff557..c96447c1 100755 --- a/tests/architecture_guards.rs +++ b/tests/architecture_guards.rs @@ -257,6 +257,18 @@ const NOT_AUDITED: &[(&str, &str)] = &[ "request_digests::spawn", "starts the background task of request_digests::run_once", ), + ( + "usage::record", + "an anonymous desktop usage report (#383): no actor, nothing names the user", + ), + ( + "usage::overview", + "a read for the admin page; its only write creates the one usage_sharing row (default off)", + ), + ( + "usage::spawn", + "housekeeping of old usage reports and the stamp of what was shared last; no actor", + ), ]; #[derive(Debug, Default, Clone)]