diff --git a/README.md b/README.md index f0257f3..63869af 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,6 @@ ## License -Copyright (c) 2025 Modulewise Inc and the Modulewise Demos contributors. +Copyright (c) 2026 Modulewise Inc and the Modulewise Demos contributors. Apache License v2.0: see [LICENSE](./LICENSE) for details. diff --git a/components/Cargo.lock b/components/Cargo.lock index 70a8649..c9978ae 100644 --- a/components/Cargo.lock +++ b/components/Cargo.lock @@ -4,19 +4,19 @@ version = 4 [[package]] name = "anyhow" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "bitflags" -version = "2.9.4" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "counter" -version = "0.1.0" +version = "0.2.0" dependencies = [ "wit-bindgen", ] @@ -29,7 +29,7 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "flights" -version = "0.1.0" +version = "0.2.0" dependencies = [ "serde", "serde_json", @@ -42,98 +42,9 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" -[[package]] -name = "futures" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" - -[[package]] -name = "futures-executor" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" - -[[package]] -name = "futures-macro" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" - -[[package]] -name = "futures-task" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" - -[[package]] -name = "futures-util" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - [[package]] name = "greeter" -version = "0.1.0" +version = "0.2.0" dependencies = [ "wit-bindgen", ] @@ -147,6 +58,12 @@ dependencies = [ "foldhash", ] +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + [[package]] name = "heck" version = "0.5.0" @@ -155,13 +72,20 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hotels" -version = "0.1.0" +version = "0.2.0" dependencies = [ "serde", "serde_json", "wit-bindgen", ] +[[package]] +name = "http-client" +version = "0.2.0" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -170,25 +94,26 @@ checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" [[package]] name = "incrementor" -version = "0.1.0" +version = "0.2.0" dependencies = [ "wit-bindgen", ] [[package]] name = "indexmap" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.16.0", "serde", + "serde_core", ] [[package]] name = "intercepting-greeter" -version = "0.1.0" +version = "0.2.0" dependencies = [ "wit-bindgen", ] @@ -213,27 +138,9 @@ checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "memchr" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "pin-project-lite" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "prettyplease" @@ -247,29 +154,22 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] -[[package]] -name = "rest-client" -version = "0.1.0" -dependencies = [ - "wit-bindgen", -] - [[package]] name = "ryu" version = "1.0.20" @@ -278,24 +178,34 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "semver" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -304,27 +214,22 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.143" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] -[[package]] -name = "slab" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" - [[package]] name = "syn" -version = "2.0.106" +version = "2.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" dependencies = [ "proc-macro2", "quote", @@ -333,9 +238,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.19" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unicode-xid" @@ -345,16 +250,16 @@ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "valkey-publisher" -version = "0.1.0" +version = "0.2.0" dependencies = [ "wit-bindgen", ] [[package]] name = "wasm-encoder" -version = "0.236.1" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "724fccfd4f3c24b7e589d333fc0429c68042897a7e8a5f8694f31792471841e7" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" dependencies = [ "leb128fmt", "wasmparser", @@ -362,9 +267,9 @@ dependencies = [ [[package]] name = "wasm-metadata" -version = "0.236.1" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c909f94a49a8de3365f3c0344f064818f1e369ff1740c5b04f455f85d454768e" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" dependencies = [ "anyhow", "indexmap", @@ -374,53 +279,42 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.236.1" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9b1e81f3eb254cf7404a82cee6926a4a3ccc5aad80cc3d43608a070c67aa1d7" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ "bitflags", - "hashbrown", + "hashbrown 0.15.5", "indexmap", "semver", ] [[package]] name = "wit-bindgen" -version = "0.44.0" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04bd9ed271234163b18c92783b0d406f08ca32c232e972f207a68c7b324c44bf" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" dependencies = [ - "wit-bindgen-rt", + "bitflags", "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" -version = "0.44.0" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4103c7a3e178b75cd8b0b574fa199ed015e8399c9859b003865cc28834b474b" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" dependencies = [ "anyhow", "heck", "wit-parser", ] -[[package]] -name = "wit-bindgen-rt" -version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653c85dd7aee6fe6f4bded0d242406deadae9819029ce6f7d258c920c384358a" -dependencies = [ - "bitflags", - "futures", - "once_cell", -] - [[package]] name = "wit-bindgen-rust" -version = "0.44.0" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95d164b3b6fbd2b0dd8b639b1012110c0bc256519a0a6def410d4020fa8ae106" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" dependencies = [ "anyhow", "heck", @@ -434,9 +328,9 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.44.0" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9100a5e1ac85e526dcd4ef49c3ff7689e026fa5e56e2a2047fd377fc682e02" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" dependencies = [ "anyhow", "prettyplease", @@ -449,9 +343,9 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.236.1" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3622959ed7ed6341c38e5aa35af243632534b0a36226852faa802939ce11e00f" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", "bitflags", @@ -468,9 +362,9 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.236.1" +version = "0.244.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e4833a20cd6e85d6abfea0e63a399472d6f88c6262957c17f546879a80ba15" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" dependencies = [ "anyhow", "id-arena", diff --git a/components/Cargo.toml b/components/Cargo.toml index 95e82c1..1166273 100644 --- a/components/Cargo.toml +++ b/components/Cargo.toml @@ -4,12 +4,12 @@ members = [ "flights", "greeter", "hotels", + "http-client", "incrementor", "intercepting-greeter", - "rest-client", "valkey-publisher", ] resolver = "3" [workspace.dependencies] -wit-bindgen = "0.44" +wit-bindgen = "0.51" diff --git a/components/README.md b/components/README.md index 214ed5b..00a0d7e 100644 --- a/components/README.md +++ b/components/README.md @@ -37,6 +37,6 @@ Invoke the `greeter` and `calculator` components via [`wasmtime`](https://github ## License -Copyright (c) 2025 Modulewise Inc and the Modulewise Demos contributors. +Copyright (c) 2026 Modulewise Inc and the Modulewise Demos contributors. Apache License v2.0: see [LICENSE](./LICENSE) for details. diff --git a/components/build.sh b/components/build.sh index 18fd9a2..3ee0bee 100755 --- a/components/build.sh +++ b/components/build.sh @@ -21,7 +21,7 @@ wac plug ./lib/greeter.wasm --plug ./lib/empty-config.wasm -o ./lib/hello.wasm static-config -p greeting="Aloha" -o ./lib/aloha-config.wasm wac plug ./lib/greeter.wasm --plug ./lib/aloha-config.wasm -o ./lib/aloha.wasm -wkg oci pull -o ./lib/valkey-client.wasm ghcr.io/componentized/valkey/valkey-client:v0.1.1 +wkg oci pull -o ./lib/valkey-client.wasm ghcr.io/componentized/valkey/valkey-client:v0.2.0 wac plug ./lib/incrementor.wasm --plug ./lib/valkey-client.wasm -o ./lib/valkey-incrementor.wasm wac plug ./lib/valkey-incrementor.wasm --plug ./lib/empty-config.wasm -o ./lib/default-incrementor.wasm diff --git a/components/calculator/calculator.wat b/components/calculator/calculator.wat index 87b664c..7474e0b 100644 --- a/components/calculator/calculator.wat +++ b/components/calculator/calculator.wat @@ -1,22 +1,22 @@ (module - (func (export "add") (param f32 f32) (result f32) + (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 - f32.add + i32.add ) - (func (export "subtract") (param f32 f32) (result f32) + (func (export "subtract") (param i32 i32) (result i32) local.get 0 local.get 1 - f32.sub + i32.sub ) - (func (export "multiply") (param f32 f32) (result f32) + (func (export "multiply") (param i32 i32) (result i32) local.get 0 local.get 1 - f32.mul + i32.mul ) - (func (export "divide") (param f32 f32) (result f32) + (func (export "divide") (param i32 i32) (result i32) local.get 0 local.get 1 - f32.div + i32.div_s ) ) diff --git a/components/calculator/componentize.sh b/components/calculator/componentize.sh index 0f391f0..9258195 100755 --- a/components/calculator/componentize.sh +++ b/components/calculator/componentize.sh @@ -2,7 +2,5 @@ wat2wasm calculator.wat -o calculator.core.wasm -sed 's/(export "\([^"]*\)")/(export "modulewise:demo\/calculator@0.1.0#\1")/g' calculator.wat | \ -wat2wasm /dev/stdin --output=- | \ -wasm-tools component embed ../wit -w calculator-world - | \ +wasm-tools component embed ../wit -w calculator calculator.core.wasm | \ wasm-tools component new - -o calculator.wasm diff --git a/components/calculator/invoke.sh b/components/calculator/invoke.sh index c2e0b88..18a98c7 100755 --- a/components/calculator/invoke.sh +++ b/components/calculator/invoke.sh @@ -2,14 +2,14 @@ echo ">>> invoking calculator core module..." -wasmtime --invoke add calculator.core.wasm 7 6 2>/dev/null -wasmtime --invoke subtract calculator.core.wasm 7 6 2>/dev/null -wasmtime --invoke multiply calculator.core.wasm 7 6 2>/dev/null -wasmtime --invoke divide calculator.core.wasm 7 6 2>/dev/null +wasmtime --invoke add calculator.core.wasm 3 4 2>/dev/null +wasmtime --invoke subtract calculator.core.wasm 10 5 2>/dev/null +wasmtime --invoke multiply calculator.core.wasm 6 7 2>/dev/null +wasmtime --invoke divide calculator.core.wasm 52 13 2>/dev/null echo "\n>>> invoking calculator component..." -wasmtime --invoke 'add(7, 6)' calculator.wasm -wasmtime --invoke 'subtract(7, 6)' calculator.wasm -wasmtime --invoke 'multiply(7, 6)' calculator.wasm -wasmtime --invoke 'divide(7, 6)' calculator.wasm +wasmtime --invoke 'add(3, 4)' calculator.wasm +wasmtime --invoke 'subtract(10, 5)' calculator.wasm +wasmtime --invoke 'multiply(6, 7)' calculator.wasm +wasmtime --invoke 'divide(52, 13)' calculator.wasm diff --git a/components/counter/Cargo.toml b/components/counter/Cargo.toml index 11d4f8a..738a32a 100644 --- a/components/counter/Cargo.toml +++ b/components/counter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "counter" -version = "0.1.0" +version = "0.2.0" edition = "2024" [lib] diff --git a/components/flights/Cargo.toml b/components/flights/Cargo.toml index b3bc832..8b84f8b 100644 --- a/components/flights/Cargo.toml +++ b/components/flights/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "flights" -version = "0.1.0" +version = "0.2.0" edition = "2024" [lib] crate-type = ["cdylib"] [dependencies] -wit-bindgen = { workspace = true } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +wit-bindgen = { workspace = true } diff --git a/components/flights/src/lib.rs b/components/flights/src/lib.rs index a16203d..ef26dda 100644 --- a/components/flights/src/lib.rs +++ b/components/flights/src/lib.rs @@ -1,7 +1,7 @@ #![no_main] use exports::modulewise::demo::flights; -use modulewise::demo::rest_client; +use modulewise::demo::http_client; wit_bindgen::generate!({ path: "../wit", @@ -33,7 +33,7 @@ impl Flights { impl flights::Guest for Flights { fn get_flight_by_id(id: String) -> Option { let url = format!("{}/flights/{id}", Self::base_url()); - match rest_client::get(&url, &[]) { + match http_client::get(&url, &[]) { Ok(response) => serde_json::from_str(&response.body).ok(), Err(_) => None, } @@ -41,7 +41,7 @@ impl flights::Guest for Flights { fn get_flights() -> Vec { let url = format!("{}/flights", Self::base_url()); - match rest_client::get(&url, &[]) { + match http_client::get(&url, &[]) { Ok(response) => serde_json::from_str(&response.body).unwrap_or_else(|_| vec![]), Err(_) => vec![], } @@ -64,7 +64,7 @@ impl flights::Guest for Flights { let url = format!("{}/flights/search", Self::base_url()); let json = serde_json::to_string(&search_request).unwrap_or_default(); let headers = vec![("Content-Type".to_string(), "application/json".to_string())]; - match rest_client::post(&url, &headers, &json) { + match http_client::post(&url, &headers, &json) { Ok(response) => serde_json::from_str(&response.body).unwrap_or_else(|_| vec![]), Err(_) => vec![], } diff --git a/components/greeter/Cargo.toml b/components/greeter/Cargo.toml index 89b884d..46d1cb1 100644 --- a/components/greeter/Cargo.toml +++ b/components/greeter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "greeter" -version = "0.1.0" +version = "0.2.0" edition = "2024" [lib] diff --git a/components/hotels/Cargo.toml b/components/hotels/Cargo.toml index cba28ba..2c0bcbb 100644 --- a/components/hotels/Cargo.toml +++ b/components/hotels/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "hotels" -version = "0.1.0" +version = "0.2.0" edition = "2024" [lib] crate-type = ["cdylib"] [dependencies] -wit-bindgen = { workspace = true } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +wit-bindgen = { workspace = true } diff --git a/components/hotels/src/lib.rs b/components/hotels/src/lib.rs index e87d9ba..be54f46 100644 --- a/components/hotels/src/lib.rs +++ b/components/hotels/src/lib.rs @@ -1,7 +1,7 @@ #![no_main] use exports::modulewise::demo::hotels; -use modulewise::demo::rest_client; +use modulewise::demo::http_client; wit_bindgen::generate!({ path: "../wit", @@ -33,7 +33,7 @@ impl Hotels { impl hotels::Guest for Hotels { fn get_hotel_by_id(id: String) -> Option { let url = format!("{}/hotels/{id}", Self::base_url()); - match rest_client::get(&url, &[]) { + match http_client::get(&url, &[]) { Ok(response) => serde_json::from_str(&response.body).ok(), Err(_) => None, } @@ -41,7 +41,7 @@ impl hotels::Guest for Hotels { fn get_hotels() -> Vec { let url = format!("{}/hotels", Self::base_url()); - match rest_client::get(&url, &[]) { + match http_client::get(&url, &[]) { Ok(response) => serde_json::from_str(&response.body).unwrap_or_else(|_| vec![]), Err(_) => vec![], } @@ -64,7 +64,7 @@ impl hotels::Guest for Hotels { let url = format!("{}/hotels/search", Self::base_url()); let json = serde_json::to_string(&search_request).unwrap_or_default(); let headers = vec![("Content-Type".to_string(), "application/json".to_string())]; - match rest_client::post(&url, &headers, &json) { + match http_client::post(&url, &headers, &json) { Ok(response) => serde_json::from_str(&response.body).unwrap_or_else(|_| vec![]), Err(_) => vec![], } diff --git a/components/rest-client/Cargo.toml b/components/http-client/Cargo.toml similarity index 73% rename from components/rest-client/Cargo.toml rename to components/http-client/Cargo.toml index e4ac4df..0c5f67d 100644 --- a/components/rest-client/Cargo.toml +++ b/components/http-client/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "rest-client" -version = "0.1.0" +name = "http-client" +version = "0.2.0" edition = "2024" [lib] diff --git a/components/rest-client/src/lib.rs b/components/http-client/src/lib.rs similarity index 93% rename from components/rest-client/src/lib.rs rename to components/http-client/src/lib.rs index 3f43e2c..c5b1afa 100644 --- a/components/rest-client/src/lib.rs +++ b/components/http-client/src/lib.rs @@ -1,17 +1,17 @@ #![no_main] -use exports::modulewise::demo::rest_client::{Guest, HttpResponse}; +use exports::modulewise::demo::http_client::{Guest, HttpResponse}; use wasi::http::types::{Headers, OutgoingBody, OutgoingRequest, Scheme}; wit_bindgen::generate!({ path: "../wit", - world: "rest-client-world", + world: "http-client-world", generate_all }); -struct RestClient; +struct HttpClient; -impl RestClient { +impl HttpClient { fn request( url: &str, headers: Vec<(String, String)>, @@ -84,7 +84,7 @@ impl RestClient { .map_err(|()| "Failed to get response stream".to_string())?; let mut body_string = String::new(); - while let Ok(v) = stream.blocking_read(1024) { + while let Ok(v) = stream.blocking_read(8192) { if v.is_empty() { break; } @@ -103,7 +103,7 @@ impl RestClient { } } -impl Guest for RestClient { +impl Guest for HttpClient { fn get(url: String, headers: Vec<(String, String)>) -> Result { Self::request(&url, headers, &wasi::http::types::Method::Get, None) } @@ -117,4 +117,4 @@ impl Guest for RestClient { } } -export!(RestClient); +export!(HttpClient); diff --git a/components/incrementor/Cargo.toml b/components/incrementor/Cargo.toml index 7392e31..47441e4 100644 --- a/components/incrementor/Cargo.toml +++ b/components/incrementor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "incrementor" -version = "0.1.0" +version = "0.2.0" edition = "2024" [lib] diff --git a/components/intercepting-greeter/Cargo.toml b/components/intercepting-greeter/Cargo.toml index 7790680..f62f60d 100644 --- a/components/intercepting-greeter/Cargo.toml +++ b/components/intercepting-greeter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "intercepting-greeter" -version = "0.1.0" +version = "0.2.0" edition = "2024" [lib] diff --git a/components/publish.sh b/components/publish.sh index db6056d..114aedb 100755 --- a/components/publish.sh +++ b/components/publish.sh @@ -5,7 +5,7 @@ set -euo pipefail COMPONENTS=("calculator" "hello") for COMPONENT in "${COMPONENTS[@]}"; do - VERSION=0.1.0 + VERSION=0.2.0 wkg oci push \ --annotation "org.opencontainers.image.title=${COMPONENT}" \ --annotation "org.opencontainers.image.description=${COMPONENT} component for modulewise demos" \ diff --git a/components/valkey-publisher/Cargo.toml b/components/valkey-publisher/Cargo.toml index 431d6e1..c04c8d6 100644 --- a/components/valkey-publisher/Cargo.toml +++ b/components/valkey-publisher/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "valkey-publisher" -version = "0.1.0" +version = "0.2.0" edition = "2024" [lib] diff --git a/components/wit/calculator.wit b/components/wit/calculator.wit index 712acfa..5254da9 100644 --- a/components/wit/calculator.wit +++ b/components/wit/calculator.wit @@ -1,20 +1,13 @@ -/// calculator operations -interface calculator { - +world calculator { /// add two numbers - add: func(a: f32, b: f32) -> f32; + export add: func(a: s32, b: s32) -> s32; /// subtract the second number from the first - subtract: func(a: f32, b: f32) -> f32; + export subtract: func(a: s32, b: s32) -> s32; /// multiply two numbers - multiply: func(a: f32, b: f32) -> f32; + export multiply: func(a: s32, b: s32) -> s32; /// divide the first number by the second - divide: func(a: f32, b: f32) -> f32; -} - -/// the calculator world -world calculator-world { - export calculator; + export divide: func(a: s32, b: s32) -> s32; } diff --git a/components/wit/counter.wit b/components/wit/counter.wit index 7911708..9abce7a 100644 --- a/components/wit/counter.wit +++ b/components/wit/counter.wit @@ -6,7 +6,7 @@ interface counter { /// the counter world world counter-world { - include wasi:config/imports@0.2.0-draft; + import wasi:config/store@0.2.0-rc.1; import incrementor; export counter; } diff --git a/components/wit/deps/componentized-valkey/package.wit b/components/wit/deps/componentized-valkey/package.wit index c489d56..3748758 100644 --- a/components/wit/deps/componentized-valkey/package.wit +++ b/components/wit/deps/componentized-valkey/package.wit @@ -19,7 +19,7 @@ interface resp { big-number(string), bulk-error(string), verbatim-string(tuple), - map(list>), + %map(list>), set(list), push(list), } diff --git a/components/wit/deps/wasi-cli-0.2.3/package.wit b/components/wit/deps/wasi-cli-0.2.6/package.wit similarity index 53% rename from components/wit/deps/wasi-cli-0.2.3/package.wit rename to components/wit/deps/wasi-cli-0.2.6/package.wit index 3c4deca..81e1df3 100644 --- a/components/wit/deps/wasi-cli-0.2.3/package.wit +++ b/components/wit/deps/wasi-cli-0.2.6/package.wit @@ -1,19 +1,19 @@ -package wasi:cli@0.2.3; +package wasi:cli@0.2.6; interface stdout { - use wasi:io/streams@0.2.3.{output-stream}; + use wasi:io/streams@0.2.6.{output-stream}; get-stdout: func() -> output-stream; } interface stderr { - use wasi:io/streams@0.2.3.{output-stream}; + use wasi:io/streams@0.2.6.{output-stream}; get-stderr: func() -> output-stream; } interface stdin { - use wasi:io/streams@0.2.3.{input-stream}; + use wasi:io/streams@0.2.6.{input-stream}; get-stdin: func() -> input-stream; } diff --git a/components/wit/deps/wasi-clocks-0.2.3/package.wit b/components/wit/deps/wasi-clocks-0.2.3/package.wit deleted file mode 100644 index 92f2662..0000000 --- a/components/wit/deps/wasi-clocks-0.2.3/package.wit +++ /dev/null @@ -1,29 +0,0 @@ -package wasi:clocks@0.2.3; - -interface monotonic-clock { - use wasi:io/poll@0.2.3.{pollable}; - - type instant = u64; - - type duration = u64; - - now: func() -> instant; - - resolution: func() -> duration; - - subscribe-instant: func(when: instant) -> pollable; - - subscribe-duration: func(when: duration) -> pollable; -} - -interface wall-clock { - record datetime { - seconds: u64, - nanoseconds: u32, - } - - now: func() -> datetime; - - resolution: func() -> datetime; -} - diff --git a/components/wit/deps/wasi-clocks-0.2.6/package.wit b/components/wit/deps/wasi-clocks-0.2.6/package.wit new file mode 100644 index 0000000..d638f1a --- /dev/null +++ b/components/wit/deps/wasi-clocks-0.2.6/package.wit @@ -0,0 +1,157 @@ +package wasi:clocks@0.2.6; + +/// WASI Monotonic Clock is a clock API intended to let users measure elapsed +/// time. +/// +/// It is intended to be portable at least between Unix-family platforms and +/// Windows. +/// +/// A monotonic clock is a clock which has an unspecified initial value, and +/// successive reads of the clock will produce non-decreasing values. +@since(version = 0.2.0) +interface monotonic-clock { + @since(version = 0.2.0) + use wasi:io/poll@0.2.6.{pollable}; + + /// An instant in time, in nanoseconds. An instant is relative to an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + @since(version = 0.2.0) + type instant = u64; + + /// A duration of time, in nanoseconds. + @since(version = 0.2.0) + type duration = u64; + + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + @since(version = 0.2.0) + now: func() -> instant; + + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + @since(version = 0.2.0) + resolution: func() -> duration; + + /// Create a `pollable` which will resolve once the specified instant + /// has occurred. + @since(version = 0.2.0) + subscribe-instant: func(when: instant) -> pollable; + + /// Create a `pollable` that will resolve after the specified duration has + /// elapsed from the time this function is invoked. + @since(version = 0.2.0) + subscribe-duration: func(when: duration) -> pollable; +} + +/// WASI Wall Clock is a clock API intended to let users query the current +/// time. The name "wall" makes an analogy to a "clock on the wall", which +/// is not necessarily monotonic as it may be reset. +/// +/// It is intended to be portable at least between Unix-family platforms and +/// Windows. +/// +/// A wall clock is a clock which measures the date and time according to +/// some external reference. +/// +/// External references may be reset, so this clock is not necessarily +/// monotonic, making it unsuitable for measuring elapsed time. +/// +/// It is intended for reporting the current date and time for humans. +@since(version = 0.2.0) +interface wall-clock { + /// A time and date in seconds plus nanoseconds. + @since(version = 0.2.0) + record datetime { + seconds: u64, + nanoseconds: u32, + } + + /// Read the current value of the clock. + /// + /// This clock is not monotonic, therefore calling this function repeatedly + /// will not necessarily produce a sequence of non-decreasing values. + /// + /// The returned timestamps represent the number of seconds since + /// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch], + /// also known as [Unix Time]. + /// + /// The nanoseconds field of the output is always less than 1000000000. + /// + /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 + /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time + @since(version = 0.2.0) + now: func() -> datetime; + + /// Query the resolution of the clock. + /// + /// The nanoseconds field of the output is always less than 1000000000. + @since(version = 0.2.0) + resolution: func() -> datetime; +} + +@unstable(feature = clocks-timezone) +interface timezone { + @unstable(feature = clocks-timezone) + use wall-clock.{datetime}; + + /// Information useful for displaying the timezone of a specific `datetime`. + /// + /// This information may vary within a single `timezone` to reflect daylight + /// saving time adjustments. + @unstable(feature = clocks-timezone) + record timezone-display { + /// The number of seconds difference between UTC time and the local + /// time of the timezone. + /// + /// The returned value will always be less than 86400 which is the + /// number of seconds in a day (24*60*60). + /// + /// In implementations that do not expose an actual time zone, this + /// should return 0. + utc-offset: s32, + /// The abbreviated name of the timezone to display to a user. The name + /// `UTC` indicates Coordinated Universal Time. Otherwise, this should + /// reference local standards for the name of the time zone. + /// + /// In implementations that do not expose an actual time zone, this + /// should be the string `UTC`. + /// + /// In time zones that do not have an applicable name, a formatted + /// representation of the UTC offset may be returned, such as `-04:00`. + name: string, + /// Whether daylight saving time is active. + /// + /// In implementations that do not expose an actual time zone, this + /// should return false. + in-daylight-saving-time: bool, + } + + /// Return information needed to display the given `datetime`. This includes + /// the UTC offset, the time zone name, and a flag indicating whether + /// daylight saving time is active. + /// + /// If the timezone cannot be determined for the given `datetime`, return a + /// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight + /// saving time. + @unstable(feature = clocks-timezone) + display: func(when: datetime) -> timezone-display; + + /// The same as `display`, but only return the UTC offset. + @unstable(feature = clocks-timezone) + utc-offset: func(when: datetime) -> s32; +} + +@since(version = 0.2.0) +world imports { + @since(version = 0.2.0) + import wasi:io/poll@0.2.6; + @since(version = 0.2.0) + import monotonic-clock; + @since(version = 0.2.0) + import wall-clock; + @unstable(feature = clocks-timezone) + import timezone; +} diff --git a/components/wit/deps/wasi-config-0.2.0-draft/package.wit b/components/wit/deps/wasi-config-0.2.0-rc.1/package.wit similarity index 97% rename from components/wit/deps/wasi-config-0.2.0-draft/package.wit rename to components/wit/deps/wasi-config-0.2.0-rc.1/package.wit index a4cdf94..d8950ee 100644 --- a/components/wit/deps/wasi-config-0.2.0-draft/package.wit +++ b/components/wit/deps/wasi-config-0.2.0-rc.1/package.wit @@ -1,4 +1,4 @@ -package wasi:config@0.2.0-draft; +package wasi:config@0.2.0-rc.1; interface store { /// An error type that encapsulates the different errors that can occur fetching configuration values. diff --git a/components/wit/deps/wasi-http-0.2.3/package.wit b/components/wit/deps/wasi-http-0.2.6/package.wit similarity index 94% rename from components/wit/deps/wasi-http-0.2.3/package.wit rename to components/wit/deps/wasi-http-0.2.6/package.wit index 932f089..eb1b25f 100644 --- a/components/wit/deps/wasi-http-0.2.3/package.wit +++ b/components/wit/deps/wasi-http-0.2.6/package.wit @@ -1,4 +1,4 @@ -package wasi:http@0.2.3; +package wasi:http@0.2.6; /// This interface defines all of the types and methods for implementing /// HTTP Requests and Responses, both incoming and outgoing, as well as @@ -6,13 +6,13 @@ package wasi:http@0.2.3; @since(version = 0.2.0) interface types { @since(version = 0.2.0) - use wasi:clocks/monotonic-clock@0.2.3.{duration}; + use wasi:clocks/monotonic-clock@0.2.6.{duration}; @since(version = 0.2.0) - use wasi:io/streams@0.2.3.{input-stream, output-stream}; + use wasi:io/streams@0.2.6.{input-stream, output-stream}; @since(version = 0.2.0) - use wasi:io/error@0.2.3.{error as io-error}; + use wasi:io/error@0.2.6.{error as io-error}; @since(version = 0.2.0) - use wasi:io/poll@0.2.3.{pollable}; + use wasi:io/poll@0.2.6.{pollable}; /// This type corresponds to HTTP standard Methods. @since(version = 0.2.0) @@ -59,7 +59,7 @@ interface types { } /// These cases are inspired by the IANA HTTP Proxy Error Types: - /// + /// @since(version = 0.2.0) variant error-code { DNS-timeout, @@ -156,7 +156,7 @@ interface types { /// A `fields` may be mutable or immutable. A `fields` created using the /// constructor, `from-list`, or `clone` will be mutable, but a `fields` /// resource given by other means (including, but not limited to, - /// `incoming-request.headers`, `outgoing-request.headers`) might be be + /// `incoming-request.headers`, `outgoing-request.headers`) might be /// immutable. In an immutable fields, the `set`, `append`, and `delete` /// operations will fail with `header-error.immutable`. @since(version = 0.2.0) @@ -389,6 +389,18 @@ interface types { /// other argument to `incoming-handler.handle`. @since(version = 0.2.0) resource response-outparam { + /// Send an HTTP 1xx response. + /// + /// Unlike `response-outparam.set`, this does not consume the + /// `response-outparam`, allowing the guest to send an arbitrary number of + /// informational responses before sending the final response using + /// `response-outparam.set`. + /// + /// This will return an `HTTP-protocol-error` if `status` is not in the + /// range [100-199], or an `internal-error` if the implementation does not + /// support informational responses. + @unstable(feature = informational-outbound-responses) + send-informational: func(status: u16, headers: headers) -> result<_, error-code>; /// Set the value of the `response-outparam` to either send a response, /// or indicate an error. /// @@ -665,23 +677,23 @@ interface outgoing-handler { @since(version = 0.2.0) world imports { @since(version = 0.2.0) - import wasi:io/poll@0.2.3; + import wasi:io/poll@0.2.6; @since(version = 0.2.0) - import wasi:clocks/monotonic-clock@0.2.3; + import wasi:clocks/monotonic-clock@0.2.6; @since(version = 0.2.0) - import wasi:clocks/wall-clock@0.2.3; + import wasi:clocks/wall-clock@0.2.6; @since(version = 0.2.0) - import wasi:random/random@0.2.3; + import wasi:random/random@0.2.6; @since(version = 0.2.0) - import wasi:io/error@0.2.3; + import wasi:io/error@0.2.6; @since(version = 0.2.0) - import wasi:io/streams@0.2.3; + import wasi:io/streams@0.2.6; @since(version = 0.2.0) - import wasi:cli/stdout@0.2.3; + import wasi:cli/stdout@0.2.6; @since(version = 0.2.0) - import wasi:cli/stderr@0.2.3; + import wasi:cli/stderr@0.2.6; @since(version = 0.2.0) - import wasi:cli/stdin@0.2.3; + import wasi:cli/stdin@0.2.6; @since(version = 0.2.0) import types; @since(version = 0.2.0) @@ -694,23 +706,23 @@ world imports { @since(version = 0.2.0) world proxy { @since(version = 0.2.0) - import wasi:io/poll@0.2.3; + import wasi:io/poll@0.2.6; @since(version = 0.2.0) - import wasi:clocks/monotonic-clock@0.2.3; + import wasi:clocks/monotonic-clock@0.2.6; @since(version = 0.2.0) - import wasi:clocks/wall-clock@0.2.3; + import wasi:clocks/wall-clock@0.2.6; @since(version = 0.2.0) - import wasi:random/random@0.2.3; + import wasi:random/random@0.2.6; @since(version = 0.2.0) - import wasi:io/error@0.2.3; + import wasi:io/error@0.2.6; @since(version = 0.2.0) - import wasi:io/streams@0.2.3; + import wasi:io/streams@0.2.6; @since(version = 0.2.0) - import wasi:cli/stdout@0.2.3; + import wasi:cli/stdout@0.2.6; @since(version = 0.2.0) - import wasi:cli/stderr@0.2.3; + import wasi:cli/stderr@0.2.6; @since(version = 0.2.0) - import wasi:cli/stdin@0.2.3; + import wasi:cli/stdin@0.2.6; @since(version = 0.2.0) import types; @since(version = 0.2.0) diff --git a/components/wit/deps/wasi-io-0.2.3/package.wit b/components/wit/deps/wasi-io-0.2.6/package.wit similarity index 98% rename from components/wit/deps/wasi-io-0.2.3/package.wit rename to components/wit/deps/wasi-io-0.2.6/package.wit index adcf1f4..c66abac 100644 --- a/components/wit/deps/wasi-io-0.2.3/package.wit +++ b/components/wit/deps/wasi-io-0.2.6/package.wit @@ -1,4 +1,4 @@ -package wasi:io@0.2.3; +package wasi:io@0.2.6; interface poll { resource pollable { diff --git a/components/wit/deps/wasi-logging-0.1.0-draft/package.wit b/components/wit/deps/wasi-logging-0.1.0-draft/package.wit new file mode 100644 index 0000000..164cb5b --- /dev/null +++ b/components/wit/deps/wasi-logging-0.1.0-draft/package.wit @@ -0,0 +1,36 @@ +package wasi:logging@0.1.0-draft; + +/// WASI Logging is a logging API intended to let users emit log messages with +/// simple priority levels and context values. +interface logging { + /// A log level, describing a kind of message. + enum level { + /// Describes messages about the values of variables and the flow of + /// control within a program. + trace, + /// Describes messages likely to be of interest to someone debugging a + /// program. + debug, + /// Describes messages likely to be of interest to someone monitoring a + /// program. + info, + /// Describes messages indicating hazardous situations. + warn, + /// Describes messages indicating serious errors. + error, + /// Describes messages indicating fatal errors. + critical, + } + + /// Emit a log message. + /// + /// A log message has a `level` describing what kind of message is being + /// sent, a context, which is an uninterpreted string meant to help + /// consumers group similar messages, and a string containing the message + /// text. + log: func(level: level, context: string, message: string); +} + +world imports { + import logging; +} diff --git a/components/wit/deps/wasi-random-0.2.3/package.wit b/components/wit/deps/wasi-random-0.2.6/package.wit similarity index 79% rename from components/wit/deps/wasi-random-0.2.3/package.wit rename to components/wit/deps/wasi-random-0.2.6/package.wit index 4be137c..dfb249c 100644 --- a/components/wit/deps/wasi-random-0.2.3/package.wit +++ b/components/wit/deps/wasi-random-0.2.6/package.wit @@ -1,4 +1,4 @@ -package wasi:random@0.2.3; +package wasi:random@0.2.6; interface random { get-random-bytes: func(len: u64) -> list; diff --git a/components/wit/flights.wit b/components/wit/flights.wit index 8945bb4..aab8a33 100644 --- a/components/wit/flights.wit +++ b/components/wit/flights.wit @@ -23,7 +23,7 @@ interface flights { } world flights-world { - include wasi:config/imports@0.2.0-draft; - import rest-client; + import wasi:config/store@0.2.0-rc.1; + import http-client; export flights; } diff --git a/components/wit/greeter.wit b/components/wit/greeter.wit index 4868ef4..45e6baa 100644 --- a/components/wit/greeter.wit +++ b/components/wit/greeter.wit @@ -4,6 +4,6 @@ interface greeter { } world greeter-world { - include wasi:config/imports@0.2.0-draft; + import wasi:config/store@0.2.0-rc.1; export greeter; } diff --git a/components/wit/hotels.wit b/components/wit/hotels.wit index 65d403b..c9e103c 100644 --- a/components/wit/hotels.wit +++ b/components/wit/hotels.wit @@ -21,7 +21,7 @@ interface hotels { } world hotels-world { - include wasi:config/imports@0.2.0-draft; - import rest-client; + import wasi:config/store@0.2.0-rc.1; + import http-client; export hotels; } diff --git a/components/wit/rest-client.wit b/components/wit/http-client.wit similarity index 76% rename from components/wit/rest-client.wit rename to components/wit/http-client.wit index 21464e1..b19f17c 100644 --- a/components/wit/rest-client.wit +++ b/components/wit/http-client.wit @@ -1,4 +1,4 @@ -interface rest-client { +interface http-client { record http-response { status: u16, headers: list>, @@ -12,7 +12,7 @@ interface rest-client { post: func(url: string, headers: list>, body: string) -> result; } -world rest-client-world { - export rest-client; - import wasi:http/outgoing-handler@0.2.3; +world http-client-world { + export http-client; + import wasi:http/outgoing-handler@0.2.6; } diff --git a/components/wit/incrementor.wit b/components/wit/incrementor.wit index a246dfd..8f22d17 100644 --- a/components/wit/incrementor.wit +++ b/components/wit/incrementor.wit @@ -3,7 +3,7 @@ interface incrementor { } world incrementor-world { - import wasi:config/store@0.2.0-draft; + import wasi:config/store@0.2.0-rc.1; import wasi:keyvalue/atomics@0.2.0-draft2; export incrementor; } diff --git a/components/wit/intercepting-greeter.wit b/components/wit/intercepting-greeter.wit index 2f88b72..ab47b42 100644 --- a/components/wit/intercepting-greeter.wit +++ b/components/wit/intercepting-greeter.wit @@ -1,5 +1,5 @@ world intercepting-greeter-world { export greeter; import greeter; - import wasi:config/store@0.2.0-draft; + import wasi:config/store@0.2.0-rc.1; } diff --git a/components/wit/overrides/wasi-config/store.wit b/components/wit/overrides/wasi-config/store.wit deleted file mode 100644 index 794379a..0000000 --- a/components/wit/overrides/wasi-config/store.wit +++ /dev/null @@ -1,30 +0,0 @@ -interface store { - /// An error type that encapsulates the different errors that can occur fetching configuration values. - variant error { - /// This indicates an error from an "upstream" config source. - /// As this could be almost _anything_ (such as Vault, Kubernetes ConfigMaps, KeyValue buckets, etc), - /// the error message is a string. - upstream(string), - /// This indicates an error from an I/O operation. - /// As this could be almost _anything_ (such as a file read, network connection, etc), - /// the error message is a string. - /// Depending on how this ends up being consumed, - /// we may consider moving this to use the `wasi:io/error` type instead. - /// For simplicity right now in supporting multiple implementations, it is being left as a string. - io(string), - } - - /// Gets a configuration value of type `string` associated with the `key`. - /// - /// The value is returned as an `option`. If the key is not found, - /// `Ok(none)` is returned. If an error occurs, an `Err(error)` is returned. - get: func( - /// A string key to fetch - key: string - ) -> result, error>; - - /// Gets a list of configuration key-value pairs of type `string`. - /// - /// If an error occurs, an `Err(error)` is returned. - get-all: func() -> result>, error>; -} diff --git a/components/wit/overrides/wasi-config/world.wit b/components/wit/overrides/wasi-config/world.wit deleted file mode 100644 index 1dc56d1..0000000 --- a/components/wit/overrides/wasi-config/world.wit +++ /dev/null @@ -1,6 +0,0 @@ -package wasi:config@0.2.0-draft; - -world imports { - /// The interface for wasi:config/store - import store; -} diff --git a/components/wit/package.wit b/components/wit/package.wit index 9b880ed..a072270 100644 --- a/components/wit/package.wit +++ b/components/wit/package.wit @@ -1 +1 @@ -package modulewise:demo@0.1.0; +package modulewise:demo@0.2.0; diff --git a/components/wit/publisher.wit b/components/wit/publisher.wit index 847c2bd..ef6c02f 100644 --- a/components/wit/publisher.wit +++ b/components/wit/publisher.wit @@ -3,7 +3,7 @@ interface publisher { } world valkey-publisher-world { - include wasi:config/imports@0.2.0-draft; + import wasi:config/store@0.2.0-rc.1; import componentized:valkey/store; export publisher; } diff --git a/components/wkg.lock b/components/wkg.lock index a782ccc..5cdf7f0 100644 --- a/components/wkg.lock +++ b/components/wkg.lock @@ -2,11 +2,38 @@ # It is not intended for manual editing. version = 1 +[[packages]] +name = "wasi:clocks" +registry = "wasi.dev" + +[[packages.versions]] +requirement = "=0.2.6" +version = "0.2.6" +digest = "sha256:569984cc45d3f5a362a3b2897aabbaa3cc4184a6113bfcbbf03c1bd7fc20338c" + +[[packages]] +name = "wasi:config" +registry = "wasi.dev" + +[[packages.versions]] +requirement = "=0.2.0-rc.1" +version = "0.2.0-rc.1" +digest = "sha256:1b7f1b0fd07bb4cede16c6a6ec8852815dfb924639a78735fc7bdffdc164485d" + [[packages]] name = "wasi:http" registry = "wasi.dev" [[packages.versions]] -requirement = "=0.2.3" -version = "0.2.3" -digest = "sha256:e526c1586efc94cd148e33725139be05c4bb58ba20466d348282bd8dc3999f1d" +requirement = "=0.2.6" +version = "0.2.6" +digest = "sha256:26a636620af0485dfcfc9a0563a0606564eedcf3fcabda031ab4d4ec0e505ff1" + +[[packages]] +name = "wasi:logging" +registry = "wasi.dev" + +[[packages.versions]] +requirement = "=0.1.0-draft" +version = "0.1.0-draft" +digest = "sha256:09621a45b12b0a9cddc798517f778aac0e5ae4bd234077b3d70758d6cf625580" diff --git a/components/wkg.toml b/components/wkg.toml index 1e2ab99..6b158c9 100644 --- a/components/wkg.toml +++ b/components/wkg.toml @@ -1,4 +1,3 @@ [overrides] -"wasi:config" = { path = "./wit/overrides/wasi-config" } -"wasi:keyvalue" = { path = "./wit/overrides/wasi-keyvalue" } "componentized:valkey" = { path = "./wit/overrides/componentized-valkey" } +"wasi:keyvalue" = { path = "./wit/overrides/wasi-keyvalue" } diff --git a/hello-world/README.md b/hello-world/README.md index 0289339..171fc1e 100644 --- a/hello-world/README.md +++ b/hello-world/README.md @@ -42,12 +42,15 @@ With the session established, you can list available tools: ./list_tools.sh ``` -You should see two tools: `hello_greet` and `aloha_greet` +You should see three tools: +- `hello.greeter.greet` +- `aloha.greeter.greet` +- `pirate.greeter.greet` -First, call the `hello_greet` tool with a `name` parameter: +First, call the `hello.greeter.greet` tool with a `name` parameter: ```sh -./call_tool.sh hello_greet name=World +./call_tool.sh hello.greeter.greet name=World ``` You will see the greeting in the response: @@ -55,7 +58,7 @@ You will see the greeting in the response: ```json { "jsonrpc": "2.0", - "id": 2, + "id": 3, "result": { "content": [ { @@ -68,10 +71,10 @@ You will see the greeting in the response: } ``` -If you take a look at the `hello-world.toml` file passed to the `toolbelt` server above, you will see that the `aloha_greet` variant uses the same `greeter.wasm` but includes `config.greeting = "Aloha"` to override the default "Hello" greeting: +If you take a look at the `hello-world.toml` file passed to the `toolbelt` server above, you will see that the `aloha` variant uses the same `greeter.wasm` but includes `config.greeting = "Aloha"` to override the default "Hello" greeting: ```sh -./call_tool.sh aloha_greet name=World +./call_tool.sh aloha.greeter.greet name=World ``` And indeed, it responds with that greeting: @@ -79,7 +82,7 @@ And indeed, it responds with that greeting: ```json { "jsonrpc": "2.0", - "id": 3, + "id": 4, "result": { "content": [ { @@ -92,10 +95,48 @@ And indeed, it responds with that greeting: } ``` -If you want to explore the Wasm Component, have a look at the greeter [project](./../components/greeter) and its WebAssembly Interface Type (WIT) [definition](./../components/wit/greeter.wit). +Finally, notice in `hello-world.toml` that the `pirate` variant is an interceptor. +It adds a prefix and suffix, but otherwise composes with the `aloha` component. + +```toml +[pirate] +uri = "../components/lib/intercepting-greeter.wasm" +config.prefix = "Ahoy and " +config.suffix = " Arrr!" +intercepts = ["aloha"] +exposed = true +``` + +Call it just like the others: + +```sh +./call_tool.sh pirate.greeter.greet name=World +``` + +And see the result of the composed interception: + +```json +{ + "jsonrpc": "2.0", + "id": 5, + "result": { + "content": [ + { + "type": "text", + "text": "Ahoy and Aloha World! Arrr!" + } + ], + "isError": false + } +} +``` + +If you want to explore the Wasm Components, have a look at the greeter [project](./../components/greeter) and its WebAssembly Interface Type (WIT) [definition](./../components/wit/greeter.wit) as well as the +[intercepting-greeter](./../components/intercepting-greeter) and its +[WIT](./../components/wit/intercepting-greeter.wit). ## License -Copyright (c) 2025 Modulewise Inc and the Modulewise Demos contributors. +Copyright (c) 2026 Modulewise Inc and the Modulewise Demos contributors. Apache License v2.0: see [LICENSE](./LICENSE) for details. diff --git a/hello-world/hello-world.toml b/hello-world/hello-world.toml index ae4fa6c..d9f31d7 100644 --- a/hello-world/hello-world.toml +++ b/hello-world/hello-world.toml @@ -5,4 +5,12 @@ exposed = true [aloha] uri = "../components/lib/greeter.wasm" config.greeting = "Aloha" +enables = "exposed" +exposed = true + +[pirate] +uri = "../components/lib/intercepting-greeter.wasm" +config.prefix = "Ahoy and " +config.suffix = " Arrr!" +intercepts = ["aloha"] exposed = true diff --git a/travel/README.md b/travel/README.md index 619fa38..57b2838 100644 --- a/travel/README.md +++ b/travel/README.md @@ -30,6 +30,10 @@ Generate sample data and post it to the REST API: ) ``` +That will create several dummy hotel and flight entries in the keyvalue store. +By default, flights will be in the date range of 2026-03-01 to 2026-03-10. +See the documentation in the generate scripts for more details. + ## Run In a separate terminal, start the Toolbelt with the Travel Demo Tools: @@ -43,6 +47,6 @@ the Streamable HTTP MCP transport and ask about flights and hotels. ## License -Copyright (c) 2025 Modulewise Inc and the Modulewise Demos contributors. +Copyright (c) 2026 Modulewise Inc and the Modulewise Demos contributors. Apache License v2.0: see [LICENSE](./LICENSE) for details. diff --git a/travel/sample-data/generate-flights.py b/travel/sample-data/generate-flights.py index 969f669..58313dd 100644 --- a/travel/sample-data/generate-flights.py +++ b/travel/sample-data/generate-flights.py @@ -19,8 +19,8 @@ import random # Configuration -FIRST_DAY = "2025-10-01" -LAST_DAY = "2025-10-10" +FIRST_DAY = "2026-03-01" +LAST_DAY = "2026-03-10" # Airlines and their operating airports AIRLINES = { @@ -175,7 +175,7 @@ def main(): print(f"Generated {len(flights)} flights") # Write to JSON file - output_file = f"flights_{first_day}_{last_day}.json" + output_file = "flights.json" with open(output_file, 'w') as f: json.dump(flights, f, indent=2) diff --git a/travel/sample-data/post-flights.sh b/travel/sample-data/post-flights.sh index e5eeb42..c0b5909 100755 --- a/travel/sample-data/post-flights.sh +++ b/travel/sample-data/post-flights.sh @@ -1,3 +1,3 @@ #!/bin/sh -curl -v -d @flights_2025-10-01_2025-10-10.json -H "Content-Type: application/json" http://localhost:8080/flights +curl -v -d @flights.json -H "Content-Type: application/json" http://localhost:8080/flights diff --git a/travel/travel-demo.toml b/travel/travel-demo.toml index fcd2a53..b156167 100644 --- a/travel/travel-demo.toml +++ b/travel/travel-demo.toml @@ -1,15 +1,15 @@ [flights] uri = "../components/lib/flights.wasm" -expects = ["rest-client"] +expects = ["http-client"] exposed = true [hotels] uri = "../components/lib/hotels.wasm" -expects = ["rest-client"] +expects = ["http-client"] exposed = true -[rest-client] -uri = "../components/lib/rest-client.wasm" +[http-client] +uri = "../components/lib/http-client.wasm" expects = ["wasip2", "http"] enables = "exposed"