diff --git a/.github/labels.yml b/.github/labels.yml index 5f06e59..260e833 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -113,7 +113,7 @@ color: "D8A094" - name: "r:problem" - description: "r:problem" + description: "Resolution: There is a problem which has no solution yet." color: "D8A094" - name: "r:research" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c1721e0..6702858 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -160,6 +160,8 @@ jobs: cargo deb -p reactive-graph-sys-config --target=${{ matrix.target }} --deb-version ${{steps.tag.outputs.tag}} cd ../../../file/crates/plugin cargo deb -p reactive-graph-sys-file --target=${{ matrix.target }} --deb-version ${{steps.tag.outputs.tag}} + cd ../../../json/crates/plugin + cargo deb -p reactive-graph-sys-json --target=${{ matrix.target }} --deb-version ${{steps.tag.outputs.tag}} cd ../../../system-environment/crates/plugin cargo deb -p reactive-graph-sys-system-environment --target=${{ matrix.target }} --deb-version ${{steps.tag.outputs.tag}} env: diff --git a/CHANGELOG.md b/CHANGELOG.md index b7a3def..ba406d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refactored into new mono repo `reactive-graph/sys` - Moved plugins binary, config, file and system-environment from `reactive-graph/std` -> `reactive-graph/sys` - Prefix plugins with `sys` (e.g. `libreactive_graph_sys_binary`) +- Refactored usages of `std` to its new namespace ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 71fd2cb..a2581ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -239,7 +239,7 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -399,7 +399,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -420,7 +420,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -561,7 +561,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -572,7 +572,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -686,7 +686,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -953,7 +953,7 @@ dependencies = [ "libflate", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1396,7 +1396,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1473,7 +1473,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79528bef70da112116feb5ecb6b64f1394e5360660d6474a760789ea07885501" dependencies = [ "proc-macro2", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1558,7 +1558,7 @@ dependencies = [ "proc-macro2", "proc_macro2_helper", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1692,48 +1692,6 @@ dependencies = [ "async-trait", ] -[[package]] -name = "reactive-graph-model-base" -version = "0.10.0" -source = "git+https://github.com/reactive-graph/std.git#7a975674a650b95dcf361caa8802862fbefa35e5" -dependencies = [ - "license", - "paste", - "reactive-graph-graph", - "semver", - "serde", - "serde_json", - "strum_macros", -] - -[[package]] -name = "reactive-graph-model-result" -version = "0.10.0" -source = "git+https://github.com/reactive-graph/std.git#7a975674a650b95dcf361caa8802862fbefa35e5" -dependencies = [ - "reactive-graph-graph", - "serde", - "serde_json", - "strum_macros", -] - -[[package]] -name = "reactive-graph-model-value" -version = "0.10.0" -source = "git+https://github.com/reactive-graph/std.git#7a975674a650b95dcf361caa8802862fbefa35e5" -dependencies = [ - "dashmap", - "paste", - "reactive-graph-graph", - "reactive-graph-reactive-model-api", - "reactive-graph-reactive-model-impl", - "reactive-graph-reactive-service-api", - "serde", - "serde_json", - "strum_macros", - "uuid", -] - [[package]] name = "reactive-graph-plugin-api" version = "0.10.0" @@ -1772,7 +1730,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1857,6 +1815,48 @@ dependencies = [ "toml", ] +[[package]] +name = "reactive-graph-std-base-model" +version = "0.10.0" +source = "git+https://github.com/reactive-graph/std.git#541482687961939869eb053fff34de5abe2f0223" +dependencies = [ + "license", + "paste", + "reactive-graph-graph", + "semver", + "serde", + "serde_json", + "strum_macros", +] + +[[package]] +name = "reactive-graph-std-result-model" +version = "0.10.0" +source = "git+https://github.com/reactive-graph/std.git#541482687961939869eb053fff34de5abe2f0223" +dependencies = [ + "reactive-graph-graph", + "serde", + "serde_json", + "strum_macros", +] + +[[package]] +name = "reactive-graph-std-value-model" +version = "0.10.0" +source = "git+https://github.com/reactive-graph/std.git#541482687961939869eb053fff34de5abe2f0223" +dependencies = [ + "dashmap", + "paste", + "reactive-graph-graph", + "reactive-graph-reactive-model-api", + "reactive-graph-reactive-model-impl", + "reactive-graph-reactive-service-api", + "serde", + "serde_json", + "strum_macros", + "uuid", +] + [[package]] name = "reactive-graph-sys-binary" version = "0.10.0" @@ -1880,11 +1880,9 @@ dependencies = [ "reactive-graph-sys-file-model", "reactive-graph-type-system-api", "rust-embed", - "serde", "serde_json", "shellexpand", "springtime-di", - "strum", "strum_macros", "uuid", ] @@ -1898,12 +1896,11 @@ dependencies = [ "paste", "reactive-graph-behaviour-model-api", "reactive-graph-graph", - "reactive-graph-model-base", "reactive-graph-reactive-model-api", "reactive-graph-reactive-model-impl", "reactive-graph-runtime-model", + "reactive-graph-std-base-model", "reactive-graph-sys-file-model", - "serde", "serde_json", "strum_macros", ] @@ -1918,16 +1915,15 @@ dependencies = [ "reactive-graph-behaviour-model-api", "reactive-graph-behaviour-model-impl", "reactive-graph-graph", - "reactive-graph-model-result", "reactive-graph-plugin-api", "reactive-graph-reactive-model-api", "reactive-graph-reactive-model-impl", "reactive-graph-runtime-model", + "reactive-graph-std-result-model", "reactive-graph-sys-config-model", "reactive-graph-sys-file-model", "reactive-graph-type-system-api", "rust-embed", - "serde", "serde_json", "shellexpand", "springtime-di", @@ -1942,12 +1938,11 @@ dependencies = [ "lazy_static", "reactive-graph-behaviour-model-api", "reactive-graph-graph", - "reactive-graph-model-result", "reactive-graph-reactive-model-api", "reactive-graph-reactive-model-impl", "reactive-graph-runtime-model", + "reactive-graph-std-result-model", "reactive-graph-sys-file-model", - "serde", "serde_json", ] @@ -1971,7 +1966,6 @@ dependencies = [ "reactive-graph-sys-file-model", "reactive-graph-type-system-api", "rust-embed", - "serde", "serde_json", "shellexpand", "springtime-di", @@ -1989,7 +1983,48 @@ dependencies = [ "reactive-graph-reactive-model-api", "reactive-graph-reactive-model-impl", "reactive-graph-runtime-model", - "serde", + "serde_json", + "strum_macros", +] + +[[package]] +name = "reactive-graph-sys-json" +version = "0.10.0" +dependencies = [ + "async-trait", + "log", + "log4rs", + "reactive-graph-behaviour-model-api", + "reactive-graph-behaviour-model-impl", + "reactive-graph-graph", + "reactive-graph-plugin-api", + "reactive-graph-reactive-model-api", + "reactive-graph-reactive-model-impl", + "reactive-graph-runtime-model", + "reactive-graph-std-result-model", + "reactive-graph-sys-file-model", + "reactive-graph-sys-json-model", + "reactive-graph-type-system-api", + "rust-embed", + "serde_json", + "shellexpand", + "springtime-di", + "uuid", +] + +[[package]] +name = "reactive-graph-sys-json-model" +version = "0.10.0" +dependencies = [ + "lazy_static", + "reactive-graph-behaviour-model-api", + "reactive-graph-graph", + "reactive-graph-reactive-model-api", + "reactive-graph-reactive-model-impl", + "reactive-graph-runtime-model", + "reactive-graph-std-base-model", + "reactive-graph-std-result-model", + "reactive-graph-sys-file-model", "serde_json", "strum_macros", ] @@ -2002,12 +2037,12 @@ dependencies = [ "log", "log4rs", "reactive-graph-graph", - "reactive-graph-model-base", - "reactive-graph-model-value", "reactive-graph-plugin-api", "reactive-graph-reactive-model-impl", "reactive-graph-reactive-service-api", "reactive-graph-runtime-model", + "reactive-graph-std-base-model", + "reactive-graph-std-value-model", "reactive-graph-sys-system-environment-model", "reactive-graph-type-system-api", "rust-embed", @@ -2068,7 +2103,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2108,7 +2143,7 @@ checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2147,7 +2182,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.100", + "syn 2.0.101", "walkdir", ] @@ -2186,7 +2221,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2231,7 +2266,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2273,7 +2308,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2284,7 +2319,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2393,7 +2428,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2421,7 +2456,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2437,9 +2472,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.100" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", @@ -2472,7 +2507,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2483,7 +2518,7 @@ checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2577,7 +2612,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2606,7 +2641,7 @@ checksum = "3c36781cc0e46a83726d9879608e4cf6c2505237e263a8eb8c24502989cfdb28" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2739,7 +2774,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", "wasm-bindgen-shared", ] @@ -2774,7 +2809,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2826,7 +2861,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2856,7 +2891,7 @@ checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2867,7 +2902,7 @@ checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -3020,7 +3055,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -3031,5 +3066,5 @@ checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] diff --git a/Cargo.toml b/Cargo.toml index 737397e..27d83b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,8 @@ members = [ "plugins/config/crates/plugin", "plugins/file/crates/model", "plugins/file/crates/plugin", + "plugins/json/crates/model", + "plugins/json/crates/plugin", "plugins/system-environment/crates/model", "plugins/system-environment/crates/plugin", "deployment" @@ -44,7 +46,6 @@ serde_json = "1.0" springtime = "1.0" springtime-di = { version = "1.0", default-features = false, features = ["threadsafe", "derive"] } shellexpand = "3.0" -strum = { version = "0.27", features = ["derive"] } strum_macros = "0.27" thiserror = "2.0" toml = "0.8" @@ -54,23 +55,17 @@ uuid = { version = "1.2", features = ["serde", "v4", "v5"] } reactive-graph-behaviour-model-api = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } reactive-graph-behaviour-model-impl = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } -reactive-graph-behaviour-service-api = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } -reactive-graph-config-model = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } reactive-graph-graph = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } reactive-graph-runtime-model = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } reactive-graph-plugin-api = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } -reactive-graph-plugin-derive = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } reactive-graph-reactive-model-api = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } reactive-graph-reactive-model-impl = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } reactive-graph-reactive-service-api = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git", features = ["derive"] } -reactive-graph-reactive-service-impl = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } reactive-graph-type-system-api = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git", features = ["json5", "toml"] } -reactive-graph-lifecycle = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } -reactive-graph-test-utils = { version = "0.10.0", git = "https://github.com/reactive-graph/reactive-graph.git" } -reactive-graph-model-base = { version = "0.10.0", git = "https://github.com/reactive-graph/std.git" } -reactive-graph-model-result = { version = "0.10.0", git = "https://github.com/reactive-graph/std.git" } -reactive-graph-model-value = { version = "0.10.0", git = "https://github.com/reactive-graph/std.git" } +reactive-graph-std-base-model = { version = "0.10.0", git = "https://github.com/reactive-graph/std.git" } +reactive-graph-std-result-model = { version = "0.10.0", git = "https://github.com/reactive-graph/std.git" } +reactive-graph-std-value-model = { version = "0.10.0", git = "https://github.com/reactive-graph/std.git" } [profile.dev] opt-level = 0 diff --git a/plugins/binary/crates/model/Cargo.toml b/plugins/binary/crates/model/Cargo.toml index b6e8be3..52ae3b5 100644 --- a/plugins/binary/crates/model/Cargo.toml +++ b/plugins/binary/crates/model/Cargo.toml @@ -13,7 +13,6 @@ readme = "../../../../README.md" data-url = { workspace = true } lazy_static = { workspace = true } paste = { workspace = true } -serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } strum_macros = { workspace = true } @@ -22,8 +21,8 @@ reactive-graph-graph = { workspace = true } reactive-graph-reactive-model-api = { workspace = true } reactive-graph-reactive-model-impl = { workspace = true } reactive-graph-runtime-model = { workspace = true } +reactive-graph-std-base-model = { workspace = true } -reactive-graph-model-base = { version = "0.10.0", git = "https://github.com/reactive-graph/std.git" } reactive-graph-sys-file-model = { version = "0.10.0", path = "../../../file/crates/model" } [lib] diff --git a/plugins/binary/crates/model/src/entity/load_binary_data.rs b/plugins/binary/crates/model/src/entity/load_binary_data.rs index 875d063..7b69e1f 100644 --- a/plugins/binary/crates/model/src/entity/load_binary_data.rs +++ b/plugins/binary/crates/model/src/entity/load_binary_data.rs @@ -2,9 +2,9 @@ use crate::BinaryData; use crate::BinaryDataUrl; use crate::NAMESPACE_BINARY; use reactive_graph_graph::entity_ty; -use reactive_graph_model_base::Named; use reactive_graph_reactive_model_api::entity_model; use reactive_graph_runtime_model::Action; +use reactive_graph_std_base_model::Named; use reactive_graph_sys_file_model::File; // All properties are defined in the component(s) diff --git a/plugins/binary/crates/model/src/entity/save_binary_data.rs b/plugins/binary/crates/model/src/entity/save_binary_data.rs index 478898e..3d8d50b 100644 --- a/plugins/binary/crates/model/src/entity/save_binary_data.rs +++ b/plugins/binary/crates/model/src/entity/save_binary_data.rs @@ -2,9 +2,9 @@ use crate::BinaryData; use crate::BinaryDataUrl; use crate::NAMESPACE_BINARY; use reactive_graph_graph::entity_ty; -use reactive_graph_model_base::Named; use reactive_graph_reactive_model_api::entity_model; use reactive_graph_runtime_model::Action; +use reactive_graph_std_base_model::Named; use reactive_graph_sys_file_model::File; // All properties are defined in the component(s) diff --git a/plugins/binary/crates/plugin/Cargo.toml b/plugins/binary/crates/plugin/Cargo.toml index 002ddd6..d30e605 100644 --- a/plugins/binary/crates/plugin/Cargo.toml +++ b/plugins/binary/crates/plugin/Cargo.toml @@ -26,11 +26,9 @@ log4rs = { workspace = true, features = ["console_appender", "file_appender", "t matchit = { workspace = true } mime_guess = { workspace = true } rust-embed = { workspace = true, features = ["debug-embed", "compression"] } -serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } shellexpand = { workspace = true } springtime-di = { workspace = true, default-features = false, features = ["threadsafe", "derive"] } -strum = { workspace = true, features = ["derive"] } strum_macros = { workspace = true } uuid = { workspace = true, features = ["serde", "v4"] } diff --git a/plugins/binary/crates/plugin/src/plugin.rs b/plugins/binary/crates/plugin/src/plugin.rs index d4a40ee..995565d 100644 --- a/plugins/binary/crates/plugin/src/plugin.rs +++ b/plugins/binary/crates/plugin/src/plugin.rs @@ -12,8 +12,8 @@ use reactive_graph_sys_binary_model::COMPONENT_BEHAVIOUR_SAVE_BINARY_DATA; export_plugin!({ "dependencies": [ - { "name": "reactive-graph-plugin-base", "version": ">=0.10.0, <0.11.0" }, - { "name": "reactive-graph-plugin-trigger", "version": ">=0.10.0, <0.11.0" }, + { "name": "reactive-graph-std-base", "version": ">=0.10.0, <0.11.0" }, + { "name": "reactive-graph-std-trigger", "version": ">=0.10.0, <0.11.0" }, { "name": "reactive-graph-sys-file", "version": ">=0.10.0, <0.11.0" } ] }); diff --git a/plugins/config/crates/model/Cargo.toml b/plugins/config/crates/model/Cargo.toml index 59a10e3..9c06066 100644 --- a/plugins/config/crates/model/Cargo.toml +++ b/plugins/config/crates/model/Cargo.toml @@ -11,7 +11,6 @@ readme = "../../../../README.md" [dependencies] lazy_static = { workspace = true } -serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } reactive-graph-behaviour-model-api = { workspace = true } @@ -19,7 +18,7 @@ reactive-graph-graph = { workspace = true } reactive-graph-reactive-model-api = { workspace = true } reactive-graph-reactive-model-impl = { workspace = true } reactive-graph-runtime-model = { workspace = true } -reactive-graph-model-result = { workspace = true } +reactive-graph-std-result-model = { workspace = true } reactive-graph-sys-file-model = { version = "0.10.0", path = "../../../file/crates/model" } diff --git a/plugins/config/crates/model/src/entity/config_file.rs b/plugins/config/crates/model/src/entity/config_file.rs index a190b1b..e08158f 100644 --- a/plugins/config/crates/model/src/entity/config_file.rs +++ b/plugins/config/crates/model/src/entity/config_file.rs @@ -1,8 +1,8 @@ use crate::NAMESPACE_CONFIG; use reactive_graph_graph::entity_ty; -use reactive_graph_model_result::ResultObject; use reactive_graph_reactive_model_api::entity_model; use reactive_graph_runtime_model::Action; +use reactive_graph_std_result_model::ResultObject; use reactive_graph_sys_file_model::File; // All properties are defined in the component(s) diff --git a/plugins/config/crates/plugin/Cargo.toml b/plugins/config/crates/plugin/Cargo.toml index c465104..f41cc6e 100644 --- a/plugins/config/crates/plugin/Cargo.toml +++ b/plugins/config/crates/plugin/Cargo.toml @@ -21,7 +21,6 @@ async-trait = { workspace = true } log = { workspace = true, features = ["std", "serde"] } log4rs = { workspace = true, features = ["console_appender", "file_appender", "toml_format"] } rust-embed = { workspace = true, features = ["debug-embed", "compression"] } -serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } shellexpand = { workspace = true } springtime-di = { workspace = true, default-features = false, features = ["threadsafe", "derive"] } @@ -38,7 +37,7 @@ reactive-graph-reactive-model-impl = { workspace = true } reactive-graph-runtime-model = { workspace = true } reactive-graph-type-system-api = { workspace = true } -reactive-graph-model-result = { workspace = true } +reactive-graph-std-result-model = { workspace = true } reactive-graph-sys-config-model = { version = "0.10.0", path = "../../crates/model" } reactive-graph-sys-file-model = { version = "0.10.0", path = "../../../file/crates/model" } diff --git a/plugins/config/crates/plugin/src/behaviour/component/config_file.rs b/plugins/config/crates/plugin/src/behaviour/component/config_file.rs index a4cf0e0..b8b4828 100644 --- a/plugins/config/crates/plugin/src/behaviour/component/config_file.rs +++ b/plugins/config/crates/plugin/src/behaviour/component/config_file.rs @@ -10,7 +10,7 @@ use reactive_graph_runtime_model::ActionProperties::TRIGGER; use serde_json::Value; use uuid::Uuid; -use reactive_graph_model_result::ResultObjectProperties::RESULT; +use reactive_graph_std_result_model::ResultObjectProperties::RESULT; use reactive_graph_sys_file_model::FileProperties::FILENAME; entity_behaviour!(ConfigFile, ConfigFileFactory, ConfigFileFsm, ConfigFileBehaviourTransitions, ConfigFileValidator); diff --git a/plugins/config/crates/plugin/src/plugin.rs b/plugins/config/crates/plugin/src/plugin.rs index f7b6f1e..a9c0ac3 100644 --- a/plugins/config/crates/plugin/src/plugin.rs +++ b/plugins/config/crates/plugin/src/plugin.rs @@ -7,9 +7,9 @@ use reactive_graph_sys_config_model::COMPONENT_BEHAVIOUR_CONFIG_FILE; export_plugin!({ "dependencies": [ - { "name": "reactive-graph-plugin-base", "version": ">=0.10.0, <0.11.0" }, - { "name": "reactive-graph-plugin-trigger", "version": ">=0.10.0, <0.11.0" }, - { "name": "reactive-graph-plugin-result", "version": ">=0.10.0, <0.11.0" }, + { "name": "reactive-graph-std-base", "version": ">=0.10.0, <0.11.0" }, + { "name": "reactive-graph-std-trigger", "version": ">=0.10.0, <0.11.0" }, + { "name": "reactive-graph-std-result", "version": ">=0.10.0, <0.11.0" }, { "name": "reactive-graph-sys-file", "version": ">=0.10.0, <0.11.0" } ] }); diff --git a/plugins/file/crates/model/Cargo.toml b/plugins/file/crates/model/Cargo.toml index e70b669..6476041 100644 --- a/plugins/file/crates/model/Cargo.toml +++ b/plugins/file/crates/model/Cargo.toml @@ -12,7 +12,6 @@ readme = "../../../../README.md" [dependencies] lazy_static = { workspace = true } paste = { workspace = true } -serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } strum_macros = { workspace = true } diff --git a/plugins/file/crates/plugin/Cargo.toml b/plugins/file/crates/plugin/Cargo.toml index 0fa6ac5..655552c 100644 --- a/plugins/file/crates/plugin/Cargo.toml +++ b/plugins/file/crates/plugin/Cargo.toml @@ -24,7 +24,6 @@ log = { workspace = true, features = ["std", "serde"] } log4rs = { workspace = true, features = ["console_appender", "file_appender", "toml_format"] } notify = { workspace = true } rust-embed = { workspace = true, features = ["debug-embed", "compression"] } -serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } shellexpand = { workspace = true } springtime-di = { workspace = true, default-features = false, features = ["threadsafe", "derive"] } diff --git a/plugins/file/crates/plugin/src/plugin.rs b/plugins/file/crates/plugin/src/plugin.rs index de971f9..fc47f90 100644 --- a/plugins/file/crates/plugin/src/plugin.rs +++ b/plugins/file/crates/plugin/src/plugin.rs @@ -7,8 +7,8 @@ use reactive_graph_sys_file_model::COMPONENT_BEHAVIOUR_FS_NOTIFY; export_plugin!({ "dependencies": [ - { "name": "reactive-graph-plugin-base", "version": ">=0.10.0, <0.11.0" } - { "name": "reactive-graph-plugin-trigger", "version": ">=0.10.0, <0.11.0" } + { "name": "reactive-graph-std-base", "version": ">=0.10.0, <0.11.0" } + { "name": "reactive-graph-std-trigger", "version": ">=0.10.0, <0.11.0" } ] }); diff --git a/plugins/json/README.md b/plugins/json/README.md new file mode 100644 index 0000000..7d4a6cf --- /dev/null +++ b/plugins/json/README.md @@ -0,0 +1,20 @@ +# Plugin JSON + +Loading from JSON files and saving to JSON files + +## Entity Types + +Load Json +Save Json + +| Name | Property | Data Type | Socket Type | +|----------------------|-------------------|-----------|-------------| +| | + +## Platform Compatibility + +| Platform | Compatibility | +|----------|---------------| +| Linux | ✓ | +| MacOS | ✓ | +| Windows | ✓ | diff --git a/plugins/json/crates/model/Cargo.toml b/plugins/json/crates/model/Cargo.toml new file mode 100644 index 0000000..0a04c75 --- /dev/null +++ b/plugins/json/crates/model/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "reactive-graph-sys-json-model" +description = "Reactive Graph - SYS - JSON - Model" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +readme = "../../../../README.md" + +[dependencies] +lazy_static = { workspace = true } +serde_json = { workspace = true } +strum_macros = { workspace = true } + +reactive-graph-behaviour-model-api = { workspace = true } +reactive-graph-graph = { workspace = true } +reactive-graph-reactive-model-api = { workspace = true } +reactive-graph-reactive-model-impl = { workspace = true } +reactive-graph-runtime-model = { workspace = true } +reactive-graph-std-base-model = { workspace = true } +reactive-graph-std-result-model = { workspace = true } + +reactive-graph-sys-file-model = { version = "0.10.0", path = "../../../file/crates/model" } + +[lib] +crate-type = ["lib"] diff --git a/plugins/json/crates/model/src/component/load_json.rs b/plugins/json/crates/model/src/component/load_json.rs new file mode 100644 index 0000000..787b175 --- /dev/null +++ b/plugins/json/crates/model/src/component/load_json.rs @@ -0,0 +1,11 @@ +use crate::NAMESPACE_JSON; +use reactive_graph_behaviour_model_api::behaviour_ty; +use reactive_graph_behaviour_model_api::component_behaviour_ty; +use reactive_graph_graph::component_model; +use reactive_graph_graph::component_ty; + +component_ty!(COMPONENT_LOAD_JSON, NAMESPACE_JSON, COMPONENT_NAME_LOAD_JSON, "load_json"); +behaviour_ty!(BEHAVIOUR_LOAD_JSON, NAMESPACE_JSON, BEHAVIOUR_NAME_LOAD_JSON, "load_json"); +component_behaviour_ty!(COMPONENT_BEHAVIOUR_LOAD_JSON, COMPONENT_LOAD_JSON, BEHAVIOUR_LOAD_JSON); + +component_model!(ComponentLoadJson); diff --git a/plugins/json/crates/model/src/component/mod.rs b/plugins/json/crates/model/src/component/mod.rs new file mode 100644 index 0000000..f908d24 --- /dev/null +++ b/plugins/json/crates/model/src/component/mod.rs @@ -0,0 +1,5 @@ +pub use load_json::*; +pub use save_json::*; + +pub mod load_json; +pub mod save_json; diff --git a/plugins/json/crates/model/src/component/save_json.rs b/plugins/json/crates/model/src/component/save_json.rs new file mode 100644 index 0000000..487ac16 --- /dev/null +++ b/plugins/json/crates/model/src/component/save_json.rs @@ -0,0 +1,17 @@ +use crate::NAMESPACE_JSON; +use reactive_graph_behaviour_model_api::behaviour_ty; +use reactive_graph_behaviour_model_api::component_behaviour_ty; +use reactive_graph_graph::component_model; +use reactive_graph_graph::component_ty; +use reactive_graph_graph::properties; + +properties!(SaveJsonProperties, (PAYLOAD, "payload", {})); + +component_ty!(COMPONENT_SAVE_JSON, NAMESPACE_JSON, COMPONENT_NAME_SAVE_JSON, "save_json"); +behaviour_ty!(BEHAVIOUR_SAVE_JSON, NAMESPACE_JSON, BEHAVIOUR_NAME_SAVE_JSON, "save_json"); +component_behaviour_ty!(COMPONENT_BEHAVIOUR_SAVE_JSON, COMPONENT_SAVE_JSON, BEHAVIOUR_SAVE_JSON); + +component_model!( + ComponentSaveJson, + set payload value +); diff --git a/plugins/json/crates/model/src/entity/load_json.rs b/plugins/json/crates/model/src/entity/load_json.rs new file mode 100644 index 0000000..5f4522d --- /dev/null +++ b/plugins/json/crates/model/src/entity/load_json.rs @@ -0,0 +1,19 @@ +use crate::ComponentLoadJson; +use crate::NAMESPACE_JSON; +use reactive_graph_graph::entity_ty; +use reactive_graph_reactive_model_api::entity_model; +use reactive_graph_runtime_model::Action; +use reactive_graph_std_base_model::Named; +use reactive_graph_std_result_model::ResultAny; +use reactive_graph_sys_file_model::File; + +// All properties are defined in the component(s) + +entity_ty!(ENTITY_TYPE_LOAD_JSON, NAMESPACE_JSON, ENTITY_TYPE_NAME_LOAD_JSON, "load_json"); + +entity_model!(LoadJson); +impl ComponentLoadJson for LoadJson {} +impl File for LoadJson {} +impl Action for LoadJson {} +impl Named for LoadJson {} +impl ResultAny for LoadJson {} diff --git a/plugins/json/crates/model/src/entity/mod.rs b/plugins/json/crates/model/src/entity/mod.rs new file mode 100644 index 0000000..f908d24 --- /dev/null +++ b/plugins/json/crates/model/src/entity/mod.rs @@ -0,0 +1,5 @@ +pub use load_json::*; +pub use save_json::*; + +pub mod load_json; +pub mod save_json; diff --git a/plugins/json/crates/model/src/entity/save_json.rs b/plugins/json/crates/model/src/entity/save_json.rs new file mode 100644 index 0000000..eee8f93 --- /dev/null +++ b/plugins/json/crates/model/src/entity/save_json.rs @@ -0,0 +1,20 @@ +use crate::ComponentSaveJson; +use crate::NAMESPACE_JSON; +use reactive_graph_graph::entity_ty; +use reactive_graph_reactive_model_api::entity_model; +use reactive_graph_runtime_model::Action; +use reactive_graph_std_base_model::Named; +use reactive_graph_sys_file_model::File; + +// All properties are defined in the component(s) + +entity_ty!(ENTITY_TYPE_SAVE_JSON, NAMESPACE_JSON, ENTITY_TYPE_NAME_SAVE_JSON, "save_json"); + +entity_model!( + SaveJson, + set payload value, +); +impl ComponentSaveJson for SaveJson {} +impl File for SaveJson {} +impl Named for SaveJson {} +impl Action for SaveJson {} diff --git a/plugins/json/crates/model/src/lib.rs b/plugins/json/crates/model/src/lib.rs new file mode 100644 index 0000000..066fefd --- /dev/null +++ b/plugins/json/crates/model/src/lib.rs @@ -0,0 +1,9 @@ +pub use component::load_json::*; +pub use component::save_json::*; +pub use entity::load_json::*; +pub use entity::save_json::*; + +pub mod component; +pub mod entity; + +pub const NAMESPACE_JSON: &str = "json"; diff --git a/plugins/json/crates/plugin/Cargo.toml b/plugins/json/crates/plugin/Cargo.toml new file mode 100644 index 0000000..8e7b30c --- /dev/null +++ b/plugins/json/crates/plugin/Cargo.toml @@ -0,0 +1,54 @@ +[package] +name = "reactive-graph-sys-json" +description = "Reactive Graph - SYS - JSON" +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +rust-version.workspace = true +readme = "../../../../README.md" + +[package.metadata.deb] +name = "libreactive-graph-sys-json" +depends = "reactive-graph, libreactive-graph-std-base, libreactive-graph-sys-file, libreactive-graph-std-result, libreactive-graph-std-trigger" +assets = [ + ["target/release/libreactive_graph_sys_json.so", "usr/share/reactive-graph/default/plugins/installed/libreactive_graph_sys_json.so", "755"], +] + +[dependencies] +async-trait = { workspace = true } +log = { workspace = true, features = ["std", "serde"] } +log4rs = { workspace = true, features = ["console_appender", "file_appender", "toml_format"] } +rust-embed = { workspace = true, features = ["debug-embed", "compression"] } +serde_json = { workspace = true } +shellexpand = { workspace = true } +springtime-di = { workspace = true, default-features = false, features = ["threadsafe", "derive"] } +uuid = { workspace = true, features = ["serde", "v4"] } + +reactive-graph-behaviour-model-api = { workspace = true } +reactive-graph-behaviour-model-impl = { workspace = true } +reactive-graph-graph = { workspace = true } +reactive-graph-plugin-api = { workspace = true } +reactive-graph-reactive-model-api = { workspace = true } +reactive-graph-reactive-model-impl = { workspace = true } +reactive-graph-runtime-model = { workspace = true } +reactive-graph-type-system-api = { workspace = true } +reactive-graph-std-result-model = { workspace = true } + +reactive-graph-sys-file-model = { version = "0.10.0", path = "../../../file/crates/model" } +reactive-graph-sys-json-model = { version = "0.10.0", path = "../../crates/model" } + +[dev-dependencies] +reactive-graph-graph = { workspace = true, features = ["test"] } + +[lib] +# Plugins use crate-type cdylib +# https://doc.rust-lang.org/reference/linkage.html +# https://users.rust-lang.org/t/what-is-the-difference-between-dylib-and-cdylib/28847/3 +crate-type = ["cdylib"] + +[package.metadata.cargo-post.dependencies] +toml = "0.8" +serde = { version = "1.0", features = ["derive"] } +glob = "0.3" diff --git a/plugins/json/crates/plugin/build.rs b/plugins/json/crates/plugin/build.rs new file mode 100644 index 0000000..8f7525a --- /dev/null +++ b/plugins/json/crates/plugin/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rerun-if-changed=types"); +} diff --git a/plugins/json/crates/plugin/post_build.rs b/plugins/json/crates/plugin/post_build.rs new file mode 100644 index 0000000..3b6a36e --- /dev/null +++ b/plugins/json/crates/plugin/post_build.rs @@ -0,0 +1,42 @@ +use serde::Deserialize; +use std::env; +use std::fs; +use std::path::PathBuf; + +#[derive(Deserialize)] +struct Deployment { + pub target_dirs: Vec, +} + +fn main() { + match fs::read_to_string("./.deployment.toml") { + Ok(toml_string) => { + let deployment: Result = toml::from_str(&toml_string); + match deployment { + Ok(deployment) => { + let mut crate_out_dir = env::var("CRATE_OUT_DIR").unwrap(); + crate_out_dir.push_str("/libreactive_graph_plugin_json.*"); + for target_dir in deployment.target_dirs { + for entry in glob::glob(crate_out_dir.as_str()).unwrap() { + if let Ok(source_path) = entry { + let file_name = source_path.file_name().unwrap().to_str().unwrap(); + if file_name.ends_with(".so") || file_name.ends_with(".dll") { + let mut target_path = PathBuf::from(&target_dir); + target_path.push(file_name); + println!("Copy plugin from {} to {}", source_path.display(), target_path.display()); + let _ = fs::copy(source_path, target_path); + } + } + } + } + } + Err(e) => { + eprintln!("Failed to parse .deployment.toml: {}", e); + } + } + } + Err(e) => { + eprintln!("Could not read .deployment.toml: {}", e); + } + } +} diff --git a/plugins/json/crates/plugin/src/behaviour/component/load_json.rs b/plugins/json/crates/plugin/src/behaviour/component/load_json.rs new file mode 100644 index 0000000..d4f9784 --- /dev/null +++ b/plugins/json/crates/plugin/src/behaviour/component/load_json.rs @@ -0,0 +1,58 @@ +use std::fs::File; +use std::path::Path; + +use reactive_graph_behaviour_model_api::behaviour_validator; +use reactive_graph_behaviour_model_api::prelude::*; +use reactive_graph_behaviour_model_impl::entity_behaviour; +use reactive_graph_graph::prelude::*; +use reactive_graph_reactive_model_impl::ReactiveEntity; +use reactive_graph_runtime_model::ActionProperties::TRIGGER; +use serde_json::Value; +use uuid::Uuid; + +use reactive_graph_std_result_model::ResultAnyProperties::RESULT; +use reactive_graph_sys_file_model::FileProperties::FILENAME; + +entity_behaviour!(LoadJson, LoadJsonFactory, LoadJsonFsm, LoadJsonBehaviourTransitions, LoadJsonValidator); + +behaviour_validator!(LoadJsonValidator, Uuid, ReactiveEntity, TRIGGER.as_ref(), RESULT.as_ref()); + +impl BehaviourInit for LoadJsonBehaviourTransitions { + fn init(&self) -> Result<(), BehaviourInitializationFailed> { + if self.reactive_instance.as_bool(TRIGGER).unwrap_or(false) { + if let Some(filename) = self.reactive_instance.as_string(FILENAME) { + if let Some(value) = load_json(filename) { + self.reactive_instance.set(RESULT, value); + } + } + } + Ok(()) + } +} + +impl BehaviourConnect for LoadJsonBehaviourTransitions { + fn connect(&self) -> Result<(), BehaviourConnectFailed> { + let reactive_instance = self.reactive_instance.clone(); + self.property_observers.observe_with_handle(TRIGGER.as_ref(), move |trigger: &Value| { + if !trigger.as_bool().unwrap_or(false) { + return; + } + if let Some(filename) = reactive_instance.as_string(FILENAME) { + if let Some(value) = load_json(filename) { + reactive_instance.set(RESULT, value); + } + } + }); + Ok(()) + } +} + +impl BehaviourShutdown for LoadJsonBehaviourTransitions {} +impl BehaviourTransitions for LoadJsonBehaviourTransitions {} + +fn load_json(filename: String) -> Option { + match File::open(Path::new(shellexpand::tilde(&filename).as_ref())) { + Ok(file) => serde_json::from_reader(file).ok(), + Err(_) => None, + } +} diff --git a/plugins/json/crates/plugin/src/behaviour/component/mod.rs b/plugins/json/crates/plugin/src/behaviour/component/mod.rs new file mode 100644 index 0000000..33b5d8b --- /dev/null +++ b/plugins/json/crates/plugin/src/behaviour/component/mod.rs @@ -0,0 +1,2 @@ +pub mod load_json; +pub mod save_json; diff --git a/plugins/json/crates/plugin/src/behaviour/component/save_json.rs b/plugins/json/crates/plugin/src/behaviour/component/save_json.rs new file mode 100644 index 0000000..6376aec --- /dev/null +++ b/plugins/json/crates/plugin/src/behaviour/component/save_json.rs @@ -0,0 +1,55 @@ +use std::fs::File; + +use log::trace; +use reactive_graph_behaviour_model_api::behaviour_validator; +use reactive_graph_behaviour_model_api::prelude::*; +use reactive_graph_behaviour_model_impl::entity_behaviour; +use reactive_graph_graph::prelude::*; +use reactive_graph_reactive_model_impl::ReactiveEntity; +use reactive_graph_runtime_model::ActionProperties::TRIGGER; +use serde_json::Value; +use uuid::Uuid; + +use reactive_graph_sys_file_model::FileProperties::FILENAME; +use reactive_graph_sys_json_model::SaveJsonProperties::PAYLOAD; + +entity_behaviour!(SaveJson, SaveJsonFactory, SaveJsonFsm, SaveJsonBehaviourTransitions, SaveJsonValidator); + +behaviour_validator!(SaveJsonValidator, Uuid, ReactiveEntity, TRIGGER.as_ref(), FILENAME.as_ref(), PAYLOAD.as_ref()); + +impl BehaviourInit for SaveJsonBehaviourTransitions {} + +impl BehaviourConnect for SaveJsonBehaviourTransitions { + fn connect(&self) -> Result<(), BehaviourConnectFailed> { + let reactive_instance = self.reactive_instance.clone(); + self.property_observers.observe_with_handle(TRIGGER.as_ref(), move |trigger: &Value| { + if !trigger.as_bool().unwrap_or(false) { + return; + } + if let Some(filename) = reactive_instance.get(FILENAME).and_then(|v| v.as_str().map(String::from)) { + match File::open(&filename) { + Ok(file) => { + if let Some(value) = reactive_instance.get(PAYLOAD) { + if serde_json::to_writer_pretty(file, &value).is_ok() { + trace!("Wrote payload to existing file {filename}"); + } + } + } + Err(_) => { + if let Ok(file) = File::create(&filename) { + if let Some(value) = reactive_instance.get(PAYLOAD) { + if serde_json::to_writer_pretty(file, &value).is_ok() { + trace!("Wrote payload to new file {filename}"); + } + } + } + } + } + } + }); + Ok(()) + } +} + +impl BehaviourShutdown for SaveJsonBehaviourTransitions {} +impl BehaviourTransitions for SaveJsonBehaviourTransitions {} diff --git a/plugins/json/crates/plugin/src/behaviour/mod.rs b/plugins/json/crates/plugin/src/behaviour/mod.rs new file mode 100644 index 0000000..9cea807 --- /dev/null +++ b/plugins/json/crates/plugin/src/behaviour/mod.rs @@ -0,0 +1 @@ +pub mod component; diff --git a/plugins/json/crates/plugin/src/lib.rs b/plugins/json/crates/plugin/src/lib.rs new file mode 100644 index 0000000..372ef53 --- /dev/null +++ b/plugins/json/crates/plugin/src/lib.rs @@ -0,0 +1,3 @@ +pub mod behaviour; +pub mod plugin; +pub mod providers; diff --git a/plugins/json/crates/plugin/src/plugin.rs b/plugins/json/crates/plugin/src/plugin.rs new file mode 100644 index 0000000..cd2bc6d --- /dev/null +++ b/plugins/json/crates/plugin/src/plugin.rs @@ -0,0 +1,70 @@ +use reactive_graph_plugin_api::EntityComponentBehaviourRegistry; +use reactive_graph_plugin_api::prelude::plugin::*; +use reactive_graph_plugin_api::prelude::providers::*; + +use crate::behaviour::component::load_json::LoadJsonFactory; +use crate::behaviour::component::save_json::SaveJsonFactory; +use reactive_graph_sys_json_model::BEHAVIOUR_LOAD_JSON; +use reactive_graph_sys_json_model::BEHAVIOUR_SAVE_JSON; +use reactive_graph_sys_json_model::COMPONENT_BEHAVIOUR_LOAD_JSON; +use reactive_graph_sys_json_model::COMPONENT_BEHAVIOUR_SAVE_JSON; + +export_plugin!({ + "dependencies": [ + { "name": "reactive-graph-std-base", "version": ">=0.10.0, <0.11.0" }, + { "name": "reactive-graph-std-result", "version": ">=0.10.0, <0.11.0" }, + { "name": "reactive-graph-std-trigger", "version": ">=0.10.0, <0.11.0" }, + { "name": "reactive-graph-sys-file", "version": ">=0.10.0, <0.11.0" } + ] +}); + +#[injectable] +pub trait JsonPlugin: Plugin + Send + Sync {} + +#[derive(Component)] +pub struct JsonPluginImpl { + component_provider: Arc + Send + Sync>, + + #[component(default = "component_provider_registry")] + component_provider_registry: Arc, + + entity_types_provider: Arc + Send + Sync>, + + #[component(default = "entity_types_provider_registry")] + entity_type_provider_registry: Arc, + + #[component(default = "entity_component_behaviour_registry")] + entity_component_behaviour_registry: Arc, +} + +#[async_trait] +#[component_alias] +impl Plugin for JsonPluginImpl { + async fn activate(&self) -> Result<(), PluginActivationError> { + self.component_provider_registry.register_provider(self.component_provider.clone()).await; + self.entity_type_provider_registry.register_provider(self.entity_types_provider.clone()).await; + + // Load Json + let factory = Arc::new(LoadJsonFactory::new(BEHAVIOUR_LOAD_JSON.clone())); + self.entity_component_behaviour_registry + .register(COMPONENT_BEHAVIOUR_LOAD_JSON.clone(), factory) + .await; + + // Save Json + let factory = Arc::new(SaveJsonFactory::new(BEHAVIOUR_SAVE_JSON.clone())); + self.entity_component_behaviour_registry + .register(COMPONENT_BEHAVIOUR_SAVE_JSON.clone(), factory) + .await; + + Ok(()) + } + + async fn deactivate(&self) -> Result<(), PluginDeactivationError> { + self.entity_component_behaviour_registry.unregister(&COMPONENT_BEHAVIOUR_LOAD_JSON).await; + self.entity_component_behaviour_registry.unregister(&COMPONENT_BEHAVIOUR_SAVE_JSON).await; + + self.entity_type_provider_registry.unregister_provider(self.entity_types_provider.id()).await; + self.component_provider_registry.unregister_provider(self.component_provider.id()).await; + Ok(()) + } +} diff --git a/plugins/json/crates/plugin/src/providers.rs b/plugins/json/crates/plugin/src/providers.rs new file mode 100644 index 0000000..99d4743 --- /dev/null +++ b/plugins/json/crates/plugin/src/providers.rs @@ -0,0 +1,9 @@ +use reactive_graph_plugin_api::prelude::providers::*; + +#[derive(TypeProvider, Component)] +#[type_provider(tys = "Components", path = "types/components")] +pub struct JsonComponentsProvider {} + +#[derive(TypeProvider, Component)] +#[type_provider(tys = "EntityTypes", path = "types/entities")] +pub struct JsonEntityTypesProvider {} diff --git a/plugins/json/crates/plugin/src/tests/component_provider_test.rs b/plugins/json/crates/plugin/src/tests/component_provider_test.rs new file mode 100644 index 0000000..728701c --- /dev/null +++ b/plugins/json/crates/plugin/src/tests/component_provider_test.rs @@ -0,0 +1,17 @@ +use crate::plugins::ComponentProvider; +use crate::providers::JsonComponentProviderImpl; +use reactive_graph_graph::NamespacedTypeGetter; + +#[test] +fn components_should_exist() { + let expected_components = vec!["load_json", "save_json"]; + let component_provider = JsonComponentProviderImpl {}; + let components = component_provider.get_components(); + assert_eq!( + expected_components.len(), + components + .into_iter() + .filter(|component| expected_components.contains(&component.type_name().as_str())) + .count() + ); +} diff --git a/plugins/json/crates/plugin/src/tests/entity_type_provider_test.rs b/plugins/json/crates/plugin/src/tests/entity_type_provider_test.rs new file mode 100644 index 0000000..6a427b2 --- /dev/null +++ b/plugins/json/crates/plugin/src/tests/entity_type_provider_test.rs @@ -0,0 +1,33 @@ +use crate::plugins::EntityTypeProvider; +use crate::providers::JsonEntityTypeProviderImpl; +use reactive_graph_model_json::ENTITY_TYPE_ARRAY_CONTAINS; +use reactive_graph_model_json::ENTITY_TYPE_ARRAY_GET_BY_INDEX; +use reactive_graph_model_json::ENTITY_TYPE_ARRAY_LENGTH; +use reactive_graph_model_json::ENTITY_TYPE_ARRAY_POP; +use reactive_graph_model_json::ENTITY_TYPE_ARRAY_PUSH; +use reactive_graph_model_json::ENTITY_TYPE_ARRAY_REVERSE; +use reactive_graph_model_json::ENTITY_TYPE_LOAD_JSON; +use reactive_graph_model_json::ENTITY_TYPE_OBJECT_GET_PROPERTY; +use reactive_graph_model_json::ENTITY_TYPE_OBJECT_KEYS; +use reactive_graph_model_json::ENTITY_TYPE_OBJECT_REMOVE_PROPERTY; +use reactive_graph_model_json::ENTITY_TYPE_OBJECT_SET_PROPERTY; +use reactive_graph_model_json::ENTITY_TYPE_SAVE_JSON; + +#[test] +fn entity_types_should_exist() { + let expected_entity_types = vec![ + ENTITY_TYPE_LOAD_JSON.clone(), + ENTITY_TYPE_SAVE_JSON.clone(), + ]; + let entity_type_provider = JsonEntityTypeProviderImpl {}; + let entity_types = entity_type_provider.get_entity_types(); + assert_eq!(expected_entity_types.len(), entity_types.len()); + assert_eq!( + expected_entity_types.len(), + entity_types + .into_iter() + .map(|entity_type| entity_type.ty) + .filter(|ty| expected_entity_types.contains(&ty)) + .count() + ); +} diff --git a/plugins/json/crates/plugin/src/tests/load_json_test.rs b/plugins/json/crates/plugin/src/tests/load_json_test.rs new file mode 100644 index 0000000..bf5a79e --- /dev/null +++ b/plugins/json/crates/plugin/src/tests/load_json_test.rs @@ -0,0 +1,49 @@ +use std::path::PathBuf; + +use serde_json::json; +use serde_json::to_string_pretty; + +use crate::behaviour::component::load_json::LoadJsonFactory; +use crate::builder::ReactiveEntityInstanceBuilder; +use crate::reactive::BehaviourFactory; +use crate::reactive::BehaviourState; +use reactive_graph_model_file::FileProperties::FILENAME; +use reactive_graph_model_json::LoadJson; +use reactive_graph_model_json::BEHAVIOUR_LOAD_JSON; +use reactive_graph_model_json::ENTITY_TYPE_LOAD_JSON; +use reactive_graph_std_result_model::ResultAny; +use reactive_graph_std_result_model::ResultObjectProperties::RESULT; +use reactive_graph_runtime_model::Action; +use reactive_graph_runtime_model::ActionProperties::TRIGGER; + +#[test] +fn rx_load_json_test() { + let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + path.push("types/components/load_json.json"); + path = path.canonicalize().unwrap(); + + let reactive_instance = ReactiveEntityInstanceBuilder::new(ENTITY_TYPE_LOAD_JSON.clone()) + .property(RESULT, json!({})) + .property_with_default(&TRIGGER) + .property(FILENAME, json!(path.to_str().unwrap())) + .build(); + + let load_json = LoadJson::from(reactive_instance.clone()); + + load_json.trigger(); + let json = load_json.result().unwrap(); + let json_pretty_str = to_string_pretty(&json).unwrap(); + assert_eq!(2, json_pretty_str.len()); + + { + let factory = LoadJsonFactory::new(BEHAVIOUR_LOAD_JSON.clone()); + let behaviour = factory.create(reactive_instance.clone()).expect("Failed to create behaviour"); + assert_eq!(BehaviourState::Connected, behaviour.get_state()); + + load_json.trigger(); + let json = load_json.result().unwrap(); + let json_pretty_str = to_string_pretty(&json).unwrap(); + assert!(json_pretty_str.len() > 2); + println!("{}", json_pretty_str); + } +} diff --git a/plugins/json/crates/plugin/src/tests/mod.rs b/plugins/json/crates/plugin/src/tests/mod.rs new file mode 100644 index 0000000..1724040 --- /dev/null +++ b/plugins/json/crates/plugin/src/tests/mod.rs @@ -0,0 +1,7 @@ +mod array_contains_test; +mod array_get_by_index_test; +mod array_length_test; +mod array_reverse_test; +mod component_provider_test; +mod entity_type_provider_test; +mod load_json_test; diff --git a/plugins/json/crates/plugin/types/components/load_json.json b/plugins/json/crates/plugin/types/components/load_json.json new file mode 100644 index 0000000..b40dc5d --- /dev/null +++ b/plugins/json/crates/plugin/types/components/load_json.json @@ -0,0 +1,18 @@ +{ + "namespace": "json", + "type_name": "load_json", + "description": "Loads a JSON file", + "properties": [ + ], + "extensions": [ + { + "namespace": "metadata", + "type_name": "dublin-core", + "extension":{ + "title": "Load JSON", + "subject": "Loads a JSON file", + "creator": "Hanack" + } + } + ] +} diff --git a/plugins/json/crates/plugin/types/components/save_json.json b/plugins/json/crates/plugin/types/components/save_json.json new file mode 100644 index 0000000..5c15da1 --- /dev/null +++ b/plugins/json/crates/plugin/types/components/save_json.json @@ -0,0 +1,23 @@ +{ + "namespace": "json", + "type_name": "save_json", + "description": "Saves an object as JSON file", + "properties": [ + { + "name": "payload", + "data_type": "object", + "socket_type": "input" + } + ], + "extensions": [ + { + "namespace": "metadata", + "type_name": "dublin-core", + "extension":{ + "title": "Save JSON", + "subject": "Saves an object as JSON file", + "creator": "Hanack" + } + } + ] +} diff --git a/plugins/json/crates/plugin/types/entities/load_json.json b/plugins/json/crates/plugin/types/entities/load_json.json new file mode 100644 index 0000000..d446005 --- /dev/null +++ b/plugins/json/crates/plugin/types/entities/load_json.json @@ -0,0 +1,40 @@ +{ + "namespace": "json", + "type_name": "load_json", + "description": "Loads a JSON file", + "components": [ + { + "namespace": "base", + "name": "named" + }, + { + "namespace": "core", + "name": "action" + }, + { + "namespace": "result", + "name": "result_any" + }, + { + "namespace": "file", + "name": "file" + }, + { + "namespace": "json", + "name": "load_json" + } + ], + "properties": [ + ], + "extensions": [ + { + "namespace": "metadata", + "type_name": "dublin-core", + "extension":{ + "title": "Load JSON", + "subject": "Loads a JSON file", + "creator": "Hanack" + } + } + ] +} diff --git a/plugins/json/crates/plugin/types/entities/save_json.json b/plugins/json/crates/plugin/types/entities/save_json.json new file mode 100644 index 0000000..168bab1 --- /dev/null +++ b/plugins/json/crates/plugin/types/entities/save_json.json @@ -0,0 +1,36 @@ +{ + "namespace": "json", + "type_name": "save_json", + "description": "Saves an object as JSON file", + "components": [ + { + "namespace": "base", + "name": "named" + }, + { + "namespace": "core", + "name": "action" + }, + { + "namespace": "file", + "name": "file" + }, + { + "namespace": "json", + "name": "save_json" + } + ], + "properties": [ + ], + "extensions": [ + { + "namespace": "metadata", + "type_name": "dublin-core", + "extension":{ + "title": "Save JSON", + "subject": "Saves an object as JSON file", + "creator": "Hanack" + } + } + ] +} diff --git a/plugins/json/graphql/create_load_json.graphql b/plugins/json/graphql/create_load_json.graphql new file mode 100644 index 0000000..29acd45 --- /dev/null +++ b/plugins/json/graphql/create_load_json.graphql @@ -0,0 +1,39 @@ +mutation { + instances { + entities { + create( + type: { + namespace: "json" + name: "load_json" + } + id: "8400d16f-1e08-4ec1-a071-f36f7e365a35" + properties: [ + { + name: "filename" + value: "assets/graphql/.graphqlconfig" + } + { + name: "trigger" + value: true + } + ] + ) { + id + type { + namespace + name + } + properties( + names: [ + "trigger" + "filename" + "result" + ] + ) { + name + value + } + } + } + } +} diff --git a/plugins/json/graphql/create_save_json.graphql b/plugins/json/graphql/create_save_json.graphql new file mode 100644 index 0000000..8ead138 --- /dev/null +++ b/plugins/json/graphql/create_save_json.graphql @@ -0,0 +1,35 @@ +mutation { + instances { + entities { + create( + type: { + namespace: "json" + name: "save_json" + } + id: "418c575a-3fb3-4b84-abe4-829c8b6763c9" + properties: [ + { + name: "filename" + value: "assets/test.json" + } + ] + ) { + id + type { + namespace + name + } + properties( + names: [ + "trigger" + "filename" + "payload" + ] + ) { + name + value + } + } + } + } +} diff --git a/plugins/json/graphql/delete_load_json.graphql b/plugins/json/graphql/delete_load_json.graphql new file mode 100644 index 0000000..c900ae4 --- /dev/null +++ b/plugins/json/graphql/delete_load_json.graphql @@ -0,0 +1,7 @@ +mutation { + instances { + entities { + delete(id: "8400d16f-1e08-4ec1-a071-f36f7e365a35") + } + } +} diff --git a/plugins/json/graphql/get_load_json_with_fs_notify.graphql b/plugins/json/graphql/get_load_json_with_fs_notify.graphql new file mode 100644 index 0000000..2b7f3e8 --- /dev/null +++ b/plugins/json/graphql/get_load_json_with_fs_notify.graphql @@ -0,0 +1,22 @@ +# After editing assets/graphql/.graphqlconfig execute this query +# Expected: The property result should reflect the changes on the file +query { + instances { + entities(id: "8400d16f-1e08-4ec1-a071-f36f7e365a35") { + id + type { + name + } + properties( + names: [ + "trigger" + "filename" + "result" + ] + ) { + name + value + } + } + } +} diff --git a/plugins/json/graphql/update_load_json.graphql b/plugins/json/graphql/update_load_json.graphql new file mode 100644 index 0000000..7b2dcd6 --- /dev/null +++ b/plugins/json/graphql/update_load_json.graphql @@ -0,0 +1,31 @@ +mutation { + instances { + entities { + update( + id: "8400d16f-1e08-4ec1-a071-f36f7e365a35" + properties: [ + { + name: "trigger" + value: true + } + ] + ) { + id + type { + namespace + name + } + properties( + names: [ + "trigger" + "filename" + "result" + ] + ) { + name + value + } + } + } + } +} diff --git a/plugins/json/graphql/update_load_json_add_component_fs_notify.graphql b/plugins/json/graphql/update_load_json_add_component_fs_notify.graphql new file mode 100644 index 0000000..0291ef5 --- /dev/null +++ b/plugins/json/graphql/update_load_json_add_component_fs_notify.graphql @@ -0,0 +1,36 @@ +mutation { + instances { + entities { + update( + id: "8400d16f-1e08-4ec1-a071-f36f7e365a35" + addComponents: [ + "fs_notify" + ] + ) { + id + type { + namespace + name + } + components { + namespace + name + } + behaviours { + namespace + name + } + properties( + names: [ + "trigger" + "filename" + "result" + ] + ) { + name + value + } + } + } + } +} diff --git a/plugins/json/graphql/update_load_json_remove_component_fs_notify.graphql b/plugins/json/graphql/update_load_json_remove_component_fs_notify.graphql new file mode 100644 index 0000000..8227166 --- /dev/null +++ b/plugins/json/graphql/update_load_json_remove_component_fs_notify.graphql @@ -0,0 +1,36 @@ +mutation { + instances { + entities { + update( + id: "8400d16f-1e08-4ec1-a071-f36f7e365a35" + removeComponents: [ + "fs_notify" + ] + ) { + id + type { + namespace + name + } + components { + namespace + name + } + behaviours { + namespace + name + } + properties( + names: [ + "trigger" + "filename" + "result" + ] + ) { + name + value + } + } + } + } +} diff --git a/plugins/json/graphql/update_save_json.graphql b/plugins/json/graphql/update_save_json.graphql new file mode 100644 index 0000000..26e5707 --- /dev/null +++ b/plugins/json/graphql/update_save_json.graphql @@ -0,0 +1,37 @@ +mutation { + instances { + entities { + update( + id: "418c575a-3fb3-4b84-abe4-829c8b6763c9" + properties: [ + { + name: "payload" + value: { + hello: "world" + } + } + { + name: "trigger" + value: true + } + ] + ) { + id + type { + namespace + name + } + properties( + names: [ + "trigger" + "filename" + "payload" + ] + ) { + name + value + } + } + } + } +} diff --git a/plugins/system-environment/crates/plugin/Cargo.toml b/plugins/system-environment/crates/plugin/Cargo.toml index 591729e..945a459 100644 --- a/plugins/system-environment/crates/plugin/Cargo.toml +++ b/plugins/system-environment/crates/plugin/Cargo.toml @@ -33,8 +33,8 @@ reactive-graph-reactive-service-api = { workspace = true, features = ["derive"] reactive-graph-runtime-model = { workspace = true } reactive-graph-type-system-api = { workspace = true } -reactive-graph-model-base = { workspace = true } -reactive-graph-model-value = { workspace = true } +reactive-graph-std-base-model = { workspace = true } +reactive-graph-std-value-model = { workspace = true } reactive-graph-sys-system-environment-model = { version = "0.10.0", path = "../../crates/model" } diff --git a/plugins/system-environment/crates/plugin/src/factory.rs b/plugins/system-environment/crates/plugin/src/factory.rs index 58ecfb4..747231e 100644 --- a/plugins/system-environment/crates/plugin/src/factory.rs +++ b/plugins/system-environment/crates/plugin/src/factory.rs @@ -15,10 +15,10 @@ use serde_json::json; use thiserror::Error; use uuid::Uuid; -use reactive_graph_model_base::COMPONENT_NAMED; -use reactive_graph_model_base::NamedProperties::NAME; -use reactive_graph_model_value::COMPONENT_VALUE; -use reactive_graph_model_value::ValueProperties::VALUE; +use reactive_graph_std_base_model::COMPONENT_NAMED; +use reactive_graph_std_base_model::NamedProperties::NAME; +use reactive_graph_std_value_model::COMPONENT_VALUE; +use reactive_graph_std_value_model::ValueProperties::VALUE; use reactive_graph_sys_system_environment_model::ENTITY_TYPE_SYSTEM_ENV_VAR; use reactive_graph_sys_system_environment_model::NAMESPACE_SYSTEM_ENVIRONMENT_ID; diff --git a/plugins/system-environment/crates/plugin/src/plugin.rs b/plugins/system-environment/crates/plugin/src/plugin.rs index 1cdbbf3..b200a21 100644 --- a/plugins/system-environment/crates/plugin/src/plugin.rs +++ b/plugins/system-environment/crates/plugin/src/plugin.rs @@ -4,8 +4,8 @@ use reactive_graph_plugin_api::prelude::providers::*; export_plugin!({ "dependencies": [ - { "name": "reactive-graph-plugin-base", "version": ">=0.10.0, <0.11.0" }, - { "name": "reactive-graph-plugin-value", "version": ">=0.10.0, <0.11.0" } + { "name": "reactive-graph-std-base", "version": ">=0.10.0, <0.11.0" }, + { "name": "reactive-graph-std-value", "version": ">=0.10.0, <0.11.0" } ] });