From 6a86cbcd0d30bd6324a57c626c04567447ca0e4c Mon Sep 17 00:00:00 2001 From: Thomas Devisscher Date: Mon, 17 Mar 2025 12:50:25 -0400 Subject: [PATCH 1/5] Update rust functions --- .../default/shopify.extension.toml.liquid | 6 ++- .../default/shopify.extension.toml.liquid | 6 ++- .../default/src/generate_cart_fetch.rs | 36 ++++++++++------ .../network/default/src/generate_cart_run.rs | 41 ++++++++++--------- .../default/src/generate_delivery_fetch.rs | 36 ++++++++++------ .../default/src/generate_delivery_run.rs | 35 ++++++++-------- discounts/rust/network/default/src/main.rs | 4 +- 7 files changed, 99 insertions(+), 65 deletions(-) diff --git a/discounts/rust/discount/default/shopify.extension.toml.liquid b/discounts/rust/discount/default/shopify.extension.toml.liquid index a75ec515..a18e6fdc 100644 --- a/discounts/rust/discount/default/shopify.extension.toml.liquid +++ b/discounts/rust/discount/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-04" +api_version = "unstable" [[extensions]] name = "t:name" @@ -19,6 +19,8 @@ description = "t:description" [extensions.build] command = "cargo build --target=wasm32-wasip1 --release" - path = "target/wasm32-wasip1/release/{{handle | replace: " ", "-" | downcase}}.wasm" + path = "target/wasm32-wasip1/release/discount-function-rust.wasm/{{handle | replace: " ", "-" | downcase}}.wasm" watch = [ "src/**/*.rs" ] + [extensions.ui] + handle = "{{handle}}" diff --git a/discounts/rust/network/default/shopify.extension.toml.liquid b/discounts/rust/network/default/shopify.extension.toml.liquid index bc62ca2d..7aa7dbee 100644 --- a/discounts/rust/network/default/shopify.extension.toml.liquid +++ b/discounts/rust/network/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-04" +api_version = "unstable" [[extensions]] name = "t:name" @@ -29,6 +29,8 @@ description = "t:description" [extensions.build] command = "cargo build --target=wasm32-wasip1 --release" - path = "target/wasm32-wasip1/release/{{handle | replace: " ", "-" | downcase}}.wasm" + path = "target/wasm32-wasip1/release/function-network-rust.wasm/{{handle | replace: " ", "-" | downcase}}.wasm" watch = [ "src/**/*.rs" ] + [extensions.ui] + handle = "{{handle}}" diff --git a/discounts/rust/network/default/src/generate_cart_fetch.rs b/discounts/rust/network/default/src/generate_cart_fetch.rs index 1d88ded5..e68552a1 100644 --- a/discounts/rust/network/default/src/generate_cart_fetch.rs +++ b/discounts/rust/network/default/src/generate_cart_fetch.rs @@ -22,15 +22,21 @@ fn generate_cart_fetch( let json_body = json!({ "enteredDiscountCodes": entered_discount_codes }); let request = CartFetchHttpRequest { - headers: vec![CartFetchHttpRequestHeader { - name: "accept".to_string(), - value: "application/json".to_string(), - }], - method: CartFetchHttpRequestMethod::GET, + headers: vec![ + CartFetchHttpRequestHeader { + name: "accept".to_string(), + value: "application/json".to_string(), + }, + CartFetchHttpRequestHeader { + name: "Content-Type".to_string(), + value: "application/json".to_string(), + } + ], + method: CartFetchHttpRequestMethod::POST, policy: CartFetchHttpRequestPolicy { read_timeout_ms: 2000, }, - url: "".to_string(), + url: "".to_string(), body: Some(json_body.to_string()), json_body: Some(json_body.clone()), }; @@ -59,15 +65,21 @@ mod tests { let json_body = json!({ "enteredDiscountCodes": [] }); let expected = FunctionCartFetchResult { request: Some(CartFetchHttpRequest { - headers: vec![CartFetchHttpRequestHeader { - name: "accept".to_string(), - value: "application/json".to_string(), - }], - method: CartFetchHttpRequestMethod::GET, + headers: vec![ + CartFetchHttpRequestHeader { + name: "accept".to_string(), + value: "application/json".to_string(), + }, + CartFetchHttpRequestHeader { + name: "Content-Type".to_string(), + value: "application/json".to_string(), + } + ], + method: CartFetchHttpRequestMethod::POST, policy: CartFetchHttpRequestPolicy { read_timeout_ms: 2000, }, - url: "".to_string(), + url: "".to_string(), json_body: Some(json_body.clone()), body: Some(json_body.to_string()), }), diff --git a/discounts/rust/network/default/src/generate_cart_run.rs b/discounts/rust/network/default/src/generate_cart_run.rs index 81ffda10..b4859ee8 100644 --- a/discounts/rust/network/default/src/generate_cart_run.rs +++ b/discounts/rust/network/default/src/generate_cart_run.rs @@ -10,19 +10,16 @@ use cart_lines_discounts_generate_run::input::ResponseData; #[derive(Deserialize)] #[serde(rename_all = "camelCase")] -struct DiscountResponse { - operations: Operations, -} - -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct Operations { +struct OperationItem { #[serde(default)] add_product_discounts: Option, #[serde(default)] add_order_discounts: Option, #[serde(default)] add_discount_code_validations: Option, + // Ignore other operation types that might be in the response but we don't use in cart context + #[serde(flatten)] + _other: std::collections::HashMap, } #[shopify_function_target( @@ -32,25 +29,31 @@ struct Operations { )] fn generate_cart_run(input: ResponseData) -> Result { let fetch_result = input.fetch_result.ok_or("Missing fetch result")?; - let body = fetch_result.body.ok_or("Missing response body")?; - // Parse the response body directly into our types - let response: DiscountResponse = - serde_json::from_str(&body).map_err(|e| format!("Failed to parse JSON: {}", e))?; + // Use jsonBody which is the only available property + let json_body = fetch_result.json_body.ok_or("Missing json_body in response")?; + + // Parse using the JSON value + let operation_items = serde_json::from_value::>(json_body) + .map_err(|e| format!("Failed to convert jsonBody: {}", e))?; // Convert the response into operations let mut operations = Vec::new(); - if let Some(validations) = response.operations.add_discount_code_validations { - operations.push(CartOperation::AddDiscountCodeValidations(validations)); - } + // Process each operation item + for item in operation_items { + if let Some(validations) = item.add_discount_code_validations { + operations.push(CartOperation::AddDiscountCodeValidations(validations)); + } - if let Some(product_discounts) = response.operations.add_product_discounts { - operations.push(CartOperation::AddProductDiscounts(product_discounts)); - } + if let Some(product_discounts) = item.add_product_discounts { + operations.push(CartOperation::AddProductDiscounts(product_discounts)); + } - if let Some(order_discounts) = response.operations.add_order_discounts { - operations.push(CartOperation::AddOrderDiscounts(order_discounts)); + if let Some(order_discounts) = item.add_order_discounts { + operations.push(CartOperation::AddOrderDiscounts(order_discounts)); + } + // Ignore delivery discounts for cart operations } Ok(FunctionCartRunResult { operations }) diff --git a/discounts/rust/network/default/src/generate_delivery_fetch.rs b/discounts/rust/network/default/src/generate_delivery_fetch.rs index 8123fb38..ff2a1804 100644 --- a/discounts/rust/network/default/src/generate_delivery_fetch.rs +++ b/discounts/rust/network/default/src/generate_delivery_fetch.rs @@ -22,15 +22,21 @@ fn generate_delivery_fetch( let json_body = json!({ "enteredDiscountCodes": entered_discount_codes }); let request = DeliveryFetchHttpRequest { - headers: vec![DeliveryFetchHttpRequestHeader { - name: "accept".to_string(), - value: "application/json".to_string(), - }], - method: DeliveryFetchHttpRequestMethod::GET, + headers: vec![ + DeliveryFetchHttpRequestHeader { + name: "accept".to_string(), + value: "application/json".to_string(), + }, + DeliveryFetchHttpRequestHeader { + name: "Content-Type".to_string(), + value: "application/json".to_string(), + } + ], + method: DeliveryFetchHttpRequestMethod::POST, policy: DeliveryFetchHttpRequestPolicy { read_timeout_ms: 2000, }, - url: "".to_string(), + url: "".to_string(), body: Some(json_body.to_string()), json_body: Some(json_body.clone()), }; @@ -59,15 +65,21 @@ mod tests { let json_body = json!({ "enteredDiscountCodes": ["ABC"] }); let expected = FunctionDeliveryFetchResult { request: Some(DeliveryFetchHttpRequest { - headers: vec![DeliveryFetchHttpRequestHeader { - name: "accept".to_string(), - value: "application/json".to_string(), - }], - method: DeliveryFetchHttpRequestMethod::GET, + headers: vec![ + DeliveryFetchHttpRequestHeader { + name: "accept".to_string(), + value: "application/json".to_string(), + }, + DeliveryFetchHttpRequestHeader { + name: "Content-Type".to_string(), + value: "application/json".to_string(), + } + ], + method: DeliveryFetchHttpRequestMethod::POST, policy: DeliveryFetchHttpRequestPolicy { read_timeout_ms: 2000, }, - url: "".to_string(), + url: "".to_string(), json_body: Some(json_body.clone()), body: Some(json_body.to_string()), }), diff --git a/discounts/rust/network/default/src/generate_delivery_run.rs b/discounts/rust/network/default/src/generate_delivery_run.rs index ea7a8d02..c3d764a8 100644 --- a/discounts/rust/network/default/src/generate_delivery_run.rs +++ b/discounts/rust/network/default/src/generate_delivery_run.rs @@ -10,17 +10,14 @@ use cart_delivery_options_discounts_generate_run::input::ResponseData; #[derive(Deserialize)] #[serde(rename_all = "camelCase")] -struct DiscountResponse { - operations: Operations, -} - -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct Operations { +struct OperationItem { #[serde(default)] add_delivery_discounts: Option, #[serde(default)] add_discount_code_validations: Option, + // Ignore any other fields we don't need + #[serde(flatten)] + _other: std::collections::HashMap, } #[shopify_function_target( @@ -30,21 +27,27 @@ struct Operations { )] fn generate_delivery_run(input: ResponseData) -> Result { let fetch_result = input.fetch_result.ok_or("Missing fetch result")?; - let body = fetch_result.body.ok_or("Missing response body")?; - // Parse the response body directly into our types - let response: DiscountResponse = - serde_json::from_str(&body).map_err(|e| format!("Failed to parse JSON: {}", e))?; + // Use jsonBody which is the only available property + let json_body = fetch_result.json_body.ok_or("Missing json_body in response")?; + + // Parse using the JSON value + let operation_items = serde_json::from_value::>(json_body) + .map_err(|e| format!("Failed to convert jsonBody: {}", e))?; // Convert the response into operations let mut operations = Vec::new(); - if let Some(validations) = response.operations.add_discount_code_validations { - operations.push(DeliveryOperation::AddDiscountCodeValidations(validations)); - } + // Process each operation item + for item in operation_items { + if let Some(validations) = item.add_discount_code_validations { + operations.push(DeliveryOperation::AddDiscountCodeValidations(validations)); + } - if let Some(delivery_discounts) = response.operations.add_delivery_discounts { - operations.push(DeliveryOperation::AddDeliveryDiscounts(delivery_discounts)); + if let Some(delivery_discounts) = item.add_delivery_discounts { + operations.push(DeliveryOperation::AddDeliveryDiscounts(delivery_discounts)); + } + // Ignore cart/order discounts for delivery operations } Ok(FunctionDeliveryRunResult { operations }) diff --git a/discounts/rust/network/default/src/main.rs b/discounts/rust/network/default/src/main.rs index e3dc67e8..70a921a6 100644 --- a/discounts/rust/network/default/src/main.rs +++ b/discounts/rust/network/default/src/main.rs @@ -1,8 +1,8 @@ use std::process; -pub mod generate_cart_fetch; pub mod generate_cart_run; -pub mod generate_delivery_fetch; pub mod generate_delivery_run; +pub mod generate_cart_fetch; +pub mod generate_delivery_fetch; fn main() { eprintln!("Please invoke a named export."); From 6686e78853fe98b64a69beac83f1012ba6dfa5e2 Mon Sep 17 00:00:00 2001 From: Thomas Devisscher Date: Mon, 17 Mar 2025 13:27:39 -0400 Subject: [PATCH 2/5] Run cargo fmt --- Cargo.lock | 224 ++++++++++-------- .../default/src/generate_cart_fetch.rs | 4 +- .../network/default/src/generate_cart_run.rs | 4 +- .../default/src/generate_delivery_fetch.rs | 4 +- .../default/src/generate_delivery_run.rs | 4 +- discounts/rust/network/default/src/main.rs | 4 +- 6 files changed, 133 insertions(+), 111 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 791d6276..c31ab60c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,21 +20,60 @@ dependencies = [ ] [[package]] -name = "bundles_cart_transform" +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "checkout-cart-checkout-validation-default" version = "1.0.0" dependencies = [ "graphql_client", "serde", "serde_json", - "serde_with", "shopify_function", ] [[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +name = "checkout-cart-transform-bundles" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] + +[[package]] +name = "checkout-cart-transform-default" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] + +[[package]] +name = "checkout-delivery-customization-default" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] + +[[package]] +name = "checkout-payment-customization-default" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] [[package]] name = "combine" @@ -103,6 +142,66 @@ dependencies = [ "shopify_function", ] +[[package]] +name = "discounts-discount-default" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] + +[[package]] +name = "discounts-discounts-allocator-default" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] + +[[package]] +name = "discounts-network-default" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] + +[[package]] +name = "discounts-order-discounts-default" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] + +[[package]] +name = "discounts-product-discounts-default" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] + +[[package]] +name = "discounts-shipping-discounts-default" +version = "1.0.0" +dependencies = [ + "graphql_client", + "serde", + "serde_json", + "shopify_function", +] + [[package]] name = "either" version = "1.8.1" @@ -214,66 +313,7 @@ dependencies = [ ] [[package]] -name = "payment-customization" -version = "1.0.0" -dependencies = [ - "graphql_client", - "serde", - "serde_json", - "shopify_function", -] - -[[package]] -name = "proc-macro2" -version = "1.0.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "product-discount-rust" -version = "1.0.0" -dependencies = [ - "graphql_client", - "serde", - "serde_json", - "shopify_function", -] - -[[package]] -name = "quote" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rust-checkout-cart-checkout-va" -version = "1.0.0" -dependencies = [ - "graphql_client", - "serde", - "serde_json", - "shopify_function", -] - -[[package]] -name = "rust-checkout-cart-transform-d" -version = "1.0.0" -dependencies = [ - "graphql_client", - "serde", - "serde_json", - "serde_with", - "shopify_function", -] - -[[package]] -name = "rust-checkout-delivery-customi" +name = "order-routing-fulfillment-constraints-default" version = "1.0.0" dependencies = [ "graphql_client", @@ -283,7 +323,7 @@ dependencies = [ ] [[package]] -name = "rust-checkout-payment-customiz" +name = "order-routing-local-pickup-delivery-option-generators-default" version = "1.0.0" dependencies = [ "graphql_client", @@ -293,7 +333,7 @@ dependencies = [ ] [[package]] -name = "rust-discounts-discounts-alloc" +name = "order-routing-location-rules-default" version = "1.0.0" dependencies = [ "graphql_client", @@ -303,7 +343,7 @@ dependencies = [ ] [[package]] -name = "rust-discounts-order-discounts" +name = "order-routing-pickup-point-delivery-option-generators-default" version = "1.0.0" dependencies = [ "graphql_client", @@ -313,27 +353,7 @@ dependencies = [ ] [[package]] -name = "rust-discounts-product-discoun" -version = "1.0.0" -dependencies = [ - "graphql_client", - "serde", - "serde_json", - "shopify_function", -] - -[[package]] -name = "rust-discounts-shipping-discou" -version = "1.0.0" -dependencies = [ - "graphql_client", - "serde", - "serde_json", - "shopify_function", -] - -[[package]] -name = "rust-order-routing-fulfillment" +name = "payment-customization" version = "1.0.0" dependencies = [ "graphql_client", @@ -343,17 +363,16 @@ dependencies = [ ] [[package]] -name = "rust-order-routing-local-pickup-delivery-option-generators-default" -version = "1.0.0" +name = "proc-macro2" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ - "graphql_client", - "serde", - "serde_json", - "shopify_function", + "unicode-ident", ] [[package]] -name = "rust-order-routing-location-ru" +name = "product-discount-rust" version = "1.0.0" dependencies = [ "graphql_client", @@ -363,13 +382,12 @@ dependencies = [ ] [[package]] -name = "rust-order-routing-pickup-poin" -version = "1.0.0" +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ - "graphql_client", - "serde", - "serde_json", - "shopify_function", + "proc-macro2", ] [[package]] diff --git a/discounts/rust/network/default/src/generate_cart_fetch.rs b/discounts/rust/network/default/src/generate_cart_fetch.rs index e68552a1..82548256 100644 --- a/discounts/rust/network/default/src/generate_cart_fetch.rs +++ b/discounts/rust/network/default/src/generate_cart_fetch.rs @@ -30,7 +30,7 @@ fn generate_cart_fetch( CartFetchHttpRequestHeader { name: "Content-Type".to_string(), value: "application/json".to_string(), - } + }, ], method: CartFetchHttpRequestMethod::POST, policy: CartFetchHttpRequestPolicy { @@ -73,7 +73,7 @@ mod tests { CartFetchHttpRequestHeader { name: "Content-Type".to_string(), value: "application/json".to_string(), - } + }, ], method: CartFetchHttpRequestMethod::POST, policy: CartFetchHttpRequestPolicy { diff --git a/discounts/rust/network/default/src/generate_cart_run.rs b/discounts/rust/network/default/src/generate_cart_run.rs index b4859ee8..5d28447a 100644 --- a/discounts/rust/network/default/src/generate_cart_run.rs +++ b/discounts/rust/network/default/src/generate_cart_run.rs @@ -31,7 +31,9 @@ fn generate_cart_run(input: ResponseData) -> Result { let fetch_result = input.fetch_result.ok_or("Missing fetch result")?; // Use jsonBody which is the only available property - let json_body = fetch_result.json_body.ok_or("Missing json_body in response")?; + let json_body = fetch_result + .json_body + .ok_or("Missing json_body in response")?; // Parse using the JSON value let operation_items = serde_json::from_value::>(json_body) diff --git a/discounts/rust/network/default/src/generate_delivery_fetch.rs b/discounts/rust/network/default/src/generate_delivery_fetch.rs index ff2a1804..11735ab5 100644 --- a/discounts/rust/network/default/src/generate_delivery_fetch.rs +++ b/discounts/rust/network/default/src/generate_delivery_fetch.rs @@ -30,7 +30,7 @@ fn generate_delivery_fetch( DeliveryFetchHttpRequestHeader { name: "Content-Type".to_string(), value: "application/json".to_string(), - } + }, ], method: DeliveryFetchHttpRequestMethod::POST, policy: DeliveryFetchHttpRequestPolicy { @@ -73,7 +73,7 @@ mod tests { DeliveryFetchHttpRequestHeader { name: "Content-Type".to_string(), value: "application/json".to_string(), - } + }, ], method: DeliveryFetchHttpRequestMethod::POST, policy: DeliveryFetchHttpRequestPolicy { diff --git a/discounts/rust/network/default/src/generate_delivery_run.rs b/discounts/rust/network/default/src/generate_delivery_run.rs index c3d764a8..f590da3e 100644 --- a/discounts/rust/network/default/src/generate_delivery_run.rs +++ b/discounts/rust/network/default/src/generate_delivery_run.rs @@ -29,7 +29,9 @@ fn generate_delivery_run(input: ResponseData) -> Result>(json_body) diff --git a/discounts/rust/network/default/src/main.rs b/discounts/rust/network/default/src/main.rs index 70a921a6..e3dc67e8 100644 --- a/discounts/rust/network/default/src/main.rs +++ b/discounts/rust/network/default/src/main.rs @@ -1,8 +1,8 @@ use std::process; -pub mod generate_cart_run; -pub mod generate_delivery_run; pub mod generate_cart_fetch; +pub mod generate_cart_run; pub mod generate_delivery_fetch; +pub mod generate_delivery_run; fn main() { eprintln!("Please invoke a named export."); From 4966c8108e7f85af2731250074d1fc2d74843cd4 Mon Sep 17 00:00:00 2001 From: Thomas Devisscher Date: Mon, 17 Mar 2025 14:05:37 -0400 Subject: [PATCH 3/5] Update schema --- discounts/rust/network/default/schema.graphql | 62 +++++-------------- 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/discounts/rust/network/default/schema.graphql b/discounts/rust/network/default/schema.graphql index f57d2769..751e21de 100644 --- a/discounts/rust/network/default/schema.graphql +++ b/discounts/rust/network/default/schema.graphql @@ -1889,10 +1889,7 @@ enum CurrencyCode { """ Belarusian Ruble (BYR). """ - BYR - @deprecated( - reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead." - ) + BYR @deprecated(reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead.") """ Belize Dollar (BZD). @@ -2417,10 +2414,7 @@ enum CurrencyCode { """ Sao Tome And Principe Dobra (STD). """ - STD - @deprecated( - reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead." - ) + STD @deprecated(reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead.") """ Sao Tome And Principe Dobra (STN). @@ -2515,10 +2509,7 @@ enum CurrencyCode { """ Venezuelan Bolivares (VEF). """ - VEF - @deprecated( - reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead." - ) + VEF @deprecated(reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead.") """ Venezuelan Bolivares Soberanos (VES). @@ -3051,8 +3042,7 @@ type GateSubject { """ The appId of the gate configurations to search for. """ - appId: String - @deprecated(reason: "Use GateSubject.handle to filter gates instead.") + appId: String @deprecated(reason: "Use GateSubject.handle to filter gates instead.") ): GateConfiguration! """ @@ -3080,7 +3070,7 @@ interface HasGates { The handle of the gate configurations to search for. """ handle: Handle - ): [GateSubject!]! + ): [GateSubject!]! @deprecated(reason: "Gates API is being sunset and will be removed in a future version. Use `metafields` instead for gate configuration.") } """ @@ -3226,9 +3216,9 @@ type HttpResponse { headers: [HttpResponseHeader!]! @deprecated(reason: "Use `header` instead.") """ - The HTTP response body parsed as JSON. - If the body is valid JSON, it will be parsed and returned as a JSON object. - If parsing fails, then raw body is returned as a string. + The HTTP response body parsed as JSON. + If the body is valid JSON, it will be parsed and returned as a JSON object. + If parsing fails, then raw body is returned as a string. Use this field when you expect the response to be JSON, or when you're dealing with mixed response types, meaning both JSON and non-JSON. Using this field reduces function instruction consumption and ensures that the data is formatted in logs. @@ -3284,25 +3274,13 @@ type Input { Discount codes entered by the buyer as an array of strings, excluding gift cards. Codes are not validated in any way other than gift card filtering. """ - enteredDiscountCodes: [String!]! - @restrictTarget( - only: [ - "cart.lines.discounts.generate.fetch" - "cart.delivery-options.discounts.generate.fetch" - ] - ) + enteredDiscountCodes: [String!]! @restrictTarget(only: ["cart.lines.discounts.generate.fetch", "cart.delivery-options.discounts.generate.fetch"]) """ The result of the fetch target. Refer to [network access](https://shopify.dev/apps/build/functions/input-output/network-access/graphql) for Shopify Functions. """ - fetchResult: HttpResponse - @restrictTarget( - only: [ - "cart.lines.discounts.generate.run" - "cart.delivery-options.discounts.generate.run" - ] - ) + fetchResult: HttpResponse @restrictTarget(only: ["cart.lines.discounts.generate.run", "cart.delivery-options.discounts.generate.run"]) """ The localization of the Function execution context. @@ -3324,13 +3302,7 @@ type Input { This input is only available in the cart.lines.discounts.generate.run and cart.delivery-options.discounts.generate.run extension targets. """ - triggeringDiscountCode: String - @restrictTarget( - only: [ - "cart.lines.discounts.generate.run" - "cart.delivery-options.discounts.generate.run" - ] - ) + triggeringDiscountCode: String @restrictTarget(only: ["cart.lines.discounts.generate.run", "cart.delivery-options.discounts.generate.run"]) } """ @@ -4167,10 +4139,7 @@ type Localization { """ The market of the active localized experience. """ - market: Market! - @deprecated( - reason: "This `market` field will be removed in a future version of the API." - ) + market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.") } """ @@ -4438,10 +4407,7 @@ type MailingAddress { """ The market of the address. """ - market: Market - @deprecated( - reason: "This `market` field will be removed in a future version of the API." - ) + market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.") """ The full name of the customer, based on firstName and lastName. @@ -4755,7 +4721,7 @@ type Product implements HasGates & HasMetafields { The handle of the gate configurations to search for. """ handle: Handle - ): [GateSubject!]! + ): [GateSubject!]! @deprecated(reason: "Gates API is being sunset and will be removed in a future version. Use `metafields` instead for gate configuration.") """ A unique human-friendly string of the product's title. From 817fa80c8bcb43f41fad78e25e1cce88cccc2fe5 Mon Sep 17 00:00:00 2001 From: Thomas Devisscher Date: Mon, 17 Mar 2025 15:21:43 -0400 Subject: [PATCH 4/5] Update toml files --- .../rust/discount/default/shopify.extension.toml.liquid | 4 ++-- .../rust/network/default/shopify.extension.toml.liquid | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/discounts/rust/discount/default/shopify.extension.toml.liquid b/discounts/rust/discount/default/shopify.extension.toml.liquid index a18e6fdc..746f1216 100644 --- a/discounts/rust/discount/default/shopify.extension.toml.liquid +++ b/discounts/rust/discount/default/shopify.extension.toml.liquid @@ -2,7 +2,7 @@ api_version = "unstable" [[extensions]] name = "t:name" -handle = "{{handle}}" +handle = "{{handle | replace: " ", "-" | downcase}}" type = "function" {% if uid %}uid = "{{ uid }}"{% endif %} description = "t:description" @@ -19,7 +19,7 @@ description = "t:description" [extensions.build] command = "cargo build --target=wasm32-wasip1 --release" - path = "target/wasm32-wasip1/release/discount-function-rust.wasm/{{handle | replace: " ", "-" | downcase}}.wasm" + path = "{{handle | replace: " ", "-" | downcase}}.wasm" watch = [ "src/**/*.rs" ] [extensions.ui] diff --git a/discounts/rust/network/default/shopify.extension.toml.liquid b/discounts/rust/network/default/shopify.extension.toml.liquid index 7aa7dbee..952d7117 100644 --- a/discounts/rust/network/default/shopify.extension.toml.liquid +++ b/discounts/rust/network/default/shopify.extension.toml.liquid @@ -2,7 +2,7 @@ api_version = "unstable" [[extensions]] name = "t:name" -handle = "{{handle}}" +handle = "{{handle | replace: " ", "-" | downcase}}" type = "function" {% if uid %}uid = "{{ uid }}"{% endif %} description = "t:description" @@ -29,8 +29,5 @@ description = "t:description" [extensions.build] command = "cargo build --target=wasm32-wasip1 --release" - path = "target/wasm32-wasip1/release/function-network-rust.wasm/{{handle | replace: " ", "-" | downcase}}.wasm" + path = "{{handle | replace: " ", "-" | downcase}}.wasm" watch = [ "src/**/*.rs" ] - - [extensions.ui] - handle = "{{handle}}" From d2ee5029ccf0b3da228654bbda57238694eb4694 Mon Sep 17 00:00:00 2001 From: Thomas Devisscher Date: Mon, 17 Mar 2025 15:22:19 -0400 Subject: [PATCH 5/5] Use jsonBody --- .../rust/network/default/src/generate_cart_run.graphql.liquid | 2 +- .../network/default/src/generate_delivery_run.graphql.liquid | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/discounts/rust/network/default/src/generate_cart_run.graphql.liquid b/discounts/rust/network/default/src/generate_cart_run.graphql.liquid index b0a15fa9..005ae400 100644 --- a/discounts/rust/network/default/src/generate_cart_run.graphql.liquid +++ b/discounts/rust/network/default/src/generate_cart_run.graphql.liquid @@ -1,6 +1,6 @@ query Input { fetchResult { - body + jsonBody status } cart { diff --git a/discounts/rust/network/default/src/generate_delivery_run.graphql.liquid b/discounts/rust/network/default/src/generate_delivery_run.graphql.liquid index 3f136325..2b73d7d8 100644 --- a/discounts/rust/network/default/src/generate_delivery_run.graphql.liquid +++ b/discounts/rust/network/default/src/generate_delivery_run.graphql.liquid @@ -1,6 +1,6 @@ query Input { fetchResult { - body + jsonBody status } cart {