diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index b869555..c8c494a 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -45,7 +45,7 @@ jobs: ${{ runner.os }}-cargo-build- - name: Build the project - run: cargo build --workspace --all-targets + run: cargo build --workspace --all-targets --features "serde/derive" - name: Run tests run: cargo test --workspace --all-targets diff --git a/Cargo.lock b/Cargo.lock index acdf282..e21af0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "serverless_workflow_builders" -version = "1.0.0-alpha6.1" +version = "1.0.0-alpha6.3" dependencies = [ "serde_json", "serde_yaml", @@ -116,7 +116,7 @@ dependencies = [ [[package]] name = "serverless_workflow_core" -version = "1.0.0-alpha6.1" +version = "1.0.0-alpha6.3" dependencies = [ "serde", "serde_derive", diff --git a/builders/Cargo.toml b/builders/Cargo.toml index d315f47..5315040 100644 --- a/builders/Cargo.toml +++ b/builders/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serverless_workflow_builders" -version = "1.0.0-alpha6.1" +version = "1.0.0-alpha6.3" edition = "2021" authors = ["The Serverless Workflow Authors "] description = "Contains services used to build ServerlessWorkflow workflow definitions programatically" @@ -12,6 +12,6 @@ keywords = ["serverless-workflow", "sdk", "builders"] categories = ["config", "parsing", "data-structures", "api-bindings"] [dependencies] -serverless_workflow_core = { path = "../core", version = "1.0.0-alpha6.1" } +serverless_workflow_core = { path = "../core", version = "1.0.0-alpha6.3" } serde_json = "1.0" serde_yaml = "0.9" \ No newline at end of file diff --git a/builders/src/lib.rs b/builders/src/lib.rs index f955bfd..e110667 100644 --- a/builders/src/lib.rs +++ b/builders/src/lib.rs @@ -3,7 +3,7 @@ pub mod services; #[cfg(test)] mod unit_tests { - use serverless_workflow_core::models::any::*; + use serde_json::Value; use serverless_workflow_core::models::duration::*; use serverless_workflow_core::models::error::OneOfErrorDefinitionOrReference; use crate::services::workflow::WorkflowBuilder; @@ -33,16 +33,16 @@ mod unit_tests { let password = "fake-password"; let call_task_name = "call-task"; let call_function_name = "fake-function"; - let call_task_with: HashMap = vec![ - ("key1".to_string(), AnyValue::String("value1".to_string())), - ("key2".to_string(), AnyValue::String("value2".to_string()))] + let call_task_with: HashMap = vec![ + ("key1".to_string(), Value::String("value1".to_string())), + ("key2".to_string(), Value::String("value2".to_string()))] .into_iter() .collect(); let do_task_name = "do-task"; let emit_task_name = "emit-task"; - let emit_event_attributes: HashMap = vec![ - ("key1".to_string(), AnyValue::String("value1".to_string())), - ("key2".to_string(), AnyValue::String("value2".to_string()))] + let emit_event_attributes: HashMap = vec![ + ("key1".to_string(), Value::String("value1".to_string())), + ("key2".to_string(), Value::String("value2".to_string()))] .into_iter() .collect(); let for_task_name = "for-task"; @@ -53,7 +53,7 @@ mod unit_tests { let listen_task_name = "listen-task"; let raise_task_name = "raise-task-name"; let raise_error_type = "error-type"; - let raise_error_status = AnyValue::Int16(400); + let raise_error_status = json!(400); let raise_error_title = "error-title"; let raise_error_detail = "error-detail"; let raise_error_instance = "error-instance"; @@ -82,11 +82,11 @@ mod unit_tests { let workflow_namespace = "workflow-namespace"; let workflow_name = "workflow-name"; let workflow_version = "workflow-version"; - let workflow_input = AnyValue::Json(json!({"hello": "world"})); + let workflow_input = json!({"hello": "world"}); let set_task_name = "set-task-name"; - let set_task_variables : HashMap = vec![ - ("var1-name".to_string(), AnyValue::String("var1-value".to_string())), - ("var2-name".to_string(), AnyValue::UInt64(69))] + let set_task_variables : HashMap = vec![ + ("var1-name".to_string(), json!("var1-value".to_string())), + ("var2-name".to_string(), json!(69))] .into_iter() .collect(); let switch_task_name = "switch-task-name"; @@ -95,9 +95,9 @@ mod unit_tests { let switch_case_then = "continue"; let try_task_name = "try-task-name"; let catch_when = "catch-when"; - let catch_errors_attributes: HashMap = vec![ - ("var1-name".to_string(), AnyValue::String("var1-value".to_string())), - ("var2-name".to_string(), AnyValue::UInt64(69))] + let catch_errors_attributes: HashMap = vec![ + ("var1-name".to_string(), json!("var1-value".to_string())), + ("var2-name".to_string(), json!(69))] .into_iter() .collect(); let retry_except_when = "retry-except-when"; @@ -154,7 +154,7 @@ mod unit_tests { task.listen() .to(|e|{ e.one() - .with("key", AnyValue::String("value".to_string())); + .with("key", Value::String("value".to_string())); }); }) .do_(raise_task_name, |task| { diff --git a/builders/src/services/task.rs b/builders/src/services/task.rs index b894e8c..a0e3017 100644 --- a/builders/src/services/task.rs +++ b/builders/src/services/task.rs @@ -1,6 +1,6 @@ use crate::services::authentication::*; use crate::services::timeout::*; -use serverless_workflow_core::models::any::*; +use serde_json::Value; use serverless_workflow_core::models::duration::*; use serverless_workflow_core::models::error::*; use serverless_workflow_core::models::event::*; @@ -261,7 +261,7 @@ impl CalltaskDefinitionBuilder { } /// Adds a new argument to call the function with - pub fn with(&mut self, name: &str, value: AnyValue) -> &mut Self{ + pub fn with(&mut self, name: &str, value: Value) -> &mut Self{ if self.task.with.is_none(){ self.task.with = Some(HashMap::new()); } @@ -272,7 +272,7 @@ impl CalltaskDefinitionBuilder { } /// Sets the arguments to call the function with - pub fn with_arguments(&mut self, arguments: HashMap) -> &mut Self{ + pub fn with_arguments(&mut self, arguments: HashMap) -> &mut Self{ self.task.with = Some(arguments); self } @@ -1041,13 +1041,13 @@ impl SetTaskDefinitionBuilder{ } /// Sets the specified variable - pub fn variable(&mut self, name: &str, value: AnyValue) -> &mut Self{ + pub fn variable(&mut self, name: &str, value: Value) -> &mut Self{ self.task.set.insert(name.to_string(), value); self } /// Configures the task to set the specified variables - pub fn variables(&mut self, variables: HashMap) -> &mut Self{ + pub fn variables(&mut self, variables: HashMap) -> &mut Self{ self.task.set = variables; self } @@ -1385,13 +1385,13 @@ impl EventDefinitionBuilder{ } /// Adds a new attribute to the event - pub fn with(&mut self, name: &str, value: AnyValue) -> &mut Self{ + pub fn with(&mut self, name: &str, value: Value) -> &mut Self{ self.event.with.insert(name.to_string(), value); self } /// Sets the event's attributes - pub fn with_attributes(&mut self, attributes: HashMap) -> &mut Self{ + pub fn with_attributes(&mut self, attributes: HashMap) -> &mut Self{ self.event.with = attributes; self } @@ -1561,7 +1561,7 @@ impl EventFilterDefinitionBuilder{ } /// Adds a new attribute to filter events by - pub fn with(&mut self, name: &str, value: AnyValue) -> &mut Self{ + pub fn with(&mut self, name: &str, value: Value) -> &mut Self{ if self.filter.with.is_none(){ self.filter.with = Some(HashMap::new()); } @@ -1572,7 +1572,7 @@ impl EventFilterDefinitionBuilder{ } /// Sets a name/value mapping of the attributes to filter events by - pub fn with_attributes(&mut self, attributes: HashMap) -> &mut Self{ + pub fn with_attributes(&mut self, attributes: HashMap) -> &mut Self{ self.filter.with = Some(attributes); self } @@ -1659,7 +1659,7 @@ impl ErrorDefinitionBuilder{ } /// Sets the error's status - pub fn with_status(&mut self, status: AnyValue) -> &mut Self{ + pub fn with_status(&mut self, status: Value) -> &mut Self{ self.error.status = status; self } @@ -1952,7 +1952,7 @@ impl WorkflowProcessDefinitionBuilder{ } /// Sets the input of the workflow to run - pub fn with_input(&mut self, input: AnyValue) -> &mut Self{ + pub fn with_input(&mut self, input: Value) -> &mut Self{ self.process.input = Some(input); self } @@ -2151,7 +2151,7 @@ impl ErrroFilterDefinitionBuilder{ } /// Adds a new attribute filter - pub fn with(&mut self, name: &str, value: AnyValue) -> &mut Self{ + pub fn with(&mut self, name: &str, value: Value) -> &mut Self{ if self.filter.with.is_none(){ self.filter.with = Some(HashMap::new()); } @@ -2162,7 +2162,7 @@ impl ErrroFilterDefinitionBuilder{ } /// Sets a name/value mapping of the attributes to filter errors by - pub fn with_attributes(&mut self, attributes: HashMap) -> &mut Self{ + pub fn with_attributes(&mut self, attributes: HashMap) -> &mut Self{ self.filter.with = Some(attributes); self } @@ -2485,7 +2485,7 @@ impl InputDataModelDefinitionBuilder{ } /// Configures the expression used to filter the input - pub fn from(&mut self, expression: AnyValue) -> &mut Self{ + pub fn from(&mut self, expression: Value) -> &mut Self{ self.input.from = Some(expression); self } @@ -2509,7 +2509,7 @@ impl OutputDataModelDefinitionBuilder{ } /// Sets a runtime expression, if any, used to output specific data to the scope data - pub fn as_(&mut self, expression: AnyValue) -> &mut Self{ + pub fn as_(&mut self, expression: Value) -> &mut Self{ self.output.as_ = Some(expression); self } @@ -2548,7 +2548,7 @@ impl SchemaDefinitionBuilder{ } /// Sets the schema document - pub fn with_document(&mut self, document: AnyValue) -> &mut Self{ + pub fn with_document(&mut self, document: Value) -> &mut Self{ self.schema.document = Some(document); self } diff --git a/core/Cargo.toml b/core/Cargo.toml index 8f83379..589be9d 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serverless_workflow_core" -version = "1.0.0-alpha6.1" +version = "1.0.0-alpha6.3" edition = "2021" authors = ["The Serverless Workflow Authors "] description = "Contains Serverless Workflow DSL models" diff --git a/core/src/models/any.rs b/core/src/models/any.rs deleted file mode 100644 index 2a974d4..0000000 --- a/core/src/models/any.rs +++ /dev/null @@ -1,31 +0,0 @@ -use serde_derive::{Deserialize, Serialize}; -use serde_json::Value as JsonValue; -use serde_yaml::Value as YamlValue; - -/// Represents any possible value -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AnyValue { - String(String), - Bool(bool), - Int8(i8), - Int16(i16), - Int32(i32), - Int64(i64), - UInt8(u8), - UInt16(u16), - UInt32(u32), - UInt64(u64), - Float32(f32), - Float64(f64), - Vec(Vec), - HashMap(std::collections::HashMap), - Json(JsonValue), - Yaml(YamlValue) -} -impl Default for AnyValue { - fn default() -> Self { - // Choose a default variant. For example, default to an empty Uri. - AnyValue::String(String::new()) - } -} \ No newline at end of file diff --git a/core/src/models/error.rs b/core/src/models/error.rs index ee8686f..946fc63 100644 --- a/core/src/models/error.rs +++ b/core/src/models/error.rs @@ -1,5 +1,5 @@ use serde_derive::{Deserialize, Serialize}; -use crate::models::any::*; +use serde_json::Value; /// Represents the definition an error to raise #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -15,7 +15,7 @@ pub struct ErrorDefinition{ /// Gets/sets the status code produced by the described error #[serde(rename = "status")] - pub status: AnyValue, + pub status: Value, /// Gets/sets a human-readable explanation specific to this occurrence of the error. #[serde(rename = "detail", skip_serializing_if = "Option::is_none")] @@ -29,7 +29,7 @@ pub struct ErrorDefinition{ impl ErrorDefinition{ /// Initializes a new ErrorDefinition - pub fn new(type_: &str, title: &str, status: AnyValue, detail: Option, instance: Option) -> Self{ + pub fn new(type_: &str, title: &str, status: Value, detail: Option, instance: Option) -> Self{ Self { type_: type_.to_string(), title: title.to_string(), diff --git a/core/src/models/event.rs b/core/src/models/event.rs index fac9c82..8e69434 100644 --- a/core/src/models/event.rs +++ b/core/src/models/event.rs @@ -1,6 +1,6 @@ use serde_derive::{Deserialize, Serialize}; +use serde_json::Value; use std::collections::HashMap; -use crate::models::any::*; /// Represents the configuration of an event consumption strategy #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -30,7 +30,7 @@ pub struct EventFilterDefinition{ /// Gets/sets a name/value mapping of the attributes filtered events must define. Supports both regular expressions and runtime expressions #[serde(rename = "with", skip_serializing_if = "Option::is_none")] - pub with : Option>, + pub with : Option>, /// Gets/sets a name/definition mapping of the correlation to attempt when filtering events. #[serde(rename = "correlate", skip_serializing_if = "Option::is_none")] @@ -66,11 +66,11 @@ pub struct EventDefinition{ /// Gets/sets a key/value mapping of the attributes of the configured event #[serde(rename = "with")] - pub with: HashMap + pub with: HashMap } impl EventDefinition { - pub fn new(with: HashMap) -> Self{ + pub fn new(with: HashMap) -> Self{ Self{ with } diff --git a/core/src/models/input.rs b/core/src/models/input.rs index 5099d4d..0fd4efa 100644 --- a/core/src/models/input.rs +++ b/core/src/models/input.rs @@ -1,5 +1,5 @@ use serde_derive::{Deserialize, Serialize}; -use crate::models::any::*; +use serde_json::Value; use crate::models::schema::*; /// Represents the definition of an input data model @@ -12,6 +12,6 @@ pub struct InputDataModelDefinition{ /// Gets/sets a runtime expression, if any, used to build the workflow or task input data based on both input and scope data #[serde(rename = "from", skip_serializing_if = "Option::is_none")] - pub from : Option + pub from : Option } \ No newline at end of file diff --git a/core/src/models/map.rs b/core/src/models/map.rs index 44e0d16..ac08657 100644 --- a/core/src/models/map.rs +++ b/core/src/models/map.rs @@ -1,10 +1,9 @@ use serde::{Serialize, Deserialize}; -use serde_derive::{Deserialize, Serialize}; use std::collections::HashMap; use std::hash::Hash; /// Represents an ordered key/value map array -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)] #[serde(bound( serialize = "TKey: Serialize, TValue: Serialize", deserialize = "TKey: for<'d> Deserialize<'d> + Eq + Hash + Clone + PartialEq, TValue: for<'d> Deserialize<'d> + Clone + PartialEq" diff --git a/core/src/models/mod.rs b/core/src/models/mod.rs index 8abb65b..557475d 100644 --- a/core/src/models/mod.rs +++ b/core/src/models/mod.rs @@ -1,4 +1,3 @@ -pub mod any; pub mod authentication; pub mod catalog; pub mod duration; diff --git a/core/src/models/output.rs b/core/src/models/output.rs index 0afbc25..bf90c44 100644 --- a/core/src/models/output.rs +++ b/core/src/models/output.rs @@ -1,5 +1,5 @@ use serde_derive::{Deserialize, Serialize}; -use crate::models::any::*; +use serde_json::Value; use crate::models::schema::*; /// Represents the definition of an output data model @@ -12,6 +12,6 @@ pub struct OutputDataModelDefinition{ /// Gets/sets a runtime expression, if any, used to output specific data to the scope data #[serde(rename = "as", skip_serializing_if = "Option::is_none")] - pub as_: Option + pub as_: Option } \ No newline at end of file diff --git a/core/src/models/schema.rs b/core/src/models/schema.rs index d8d310c..2998af1 100644 --- a/core/src/models/schema.rs +++ b/core/src/models/schema.rs @@ -1,5 +1,5 @@ use serde_derive::{Deserialize, Serialize}; -use crate::models::any::*; +use serde_json::Value; use crate::models::resource::*; /// Provvides the default schema format @@ -32,6 +32,6 @@ pub struct SchemaDefinition{ /// Gets/sets the inline definition of the schema to use. Required if has not been set. #[serde(rename = "document", skip_serializing_if = "Option::is_none")] - pub document : Option + pub document : Option } \ No newline at end of file diff --git a/core/src/models/task.rs b/core/src/models/task.rs index 89ae21f..544de34 100644 --- a/core/src/models/task.rs +++ b/core/src/models/task.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; use serde_derive::{Deserialize, Serialize}; -use crate::models::any::*; +use serde_json::Value; use crate::models::duration::*; use crate::models::event::*; use crate::models::error::*; @@ -120,7 +120,7 @@ pub struct TaskDefinitionFields{ /// Gets/sets a key/value mapping of additional information associated with the task #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] - pub metadata: Option> + pub metadata: Option> } impl Default for TaskDefinitionFields{ @@ -155,7 +155,7 @@ pub struct CallTaskDefinition{ /// Gets/sets a key/value mapping of the call's arguments, if any #[serde(rename = "with", skip_serializing_if = "Option::is_none")] - pub with: Option>, + pub with: Option>, /// Gets/sets a boolean indicating whether or not to wait for the called function to return. Defaults to true #[serde(rename = "await", skip_serializing_if = "Option::is_none")] @@ -174,7 +174,7 @@ impl TaskDefinitionBase for CallTaskDefinition { impl CallTaskDefinition { /// Initializes a new CalltaskDefinition - pub fn new(call: &str, with: Option>, await_: Option) -> Self{ + pub fn new(call: &str, with: Option>, await_: Option) -> Self{ Self { call: call.to_string(), with, @@ -737,11 +737,11 @@ pub struct WorkflowProcessDefinition{ /// Gets/sets the data, if any, to pass as input to the workflow to execute. The value should be validated against the target workflow's input schema, if specified #[serde(rename = "input", skip_serializing_if = "Option::is_none")] - pub input: Option + pub input: Option } impl WorkflowProcessDefinition { - pub fn new(namespace: &str, name: &str, version: &str, input: Option) -> Self{ + pub fn new(namespace: &str, name: &str, version: &str, input: Option) -> Self{ Self { namespace: namespace.to_string(), name: name.to_string(), @@ -757,7 +757,7 @@ pub struct SetTaskDefinition{ /// Gets/sets the data to set #[serde(rename = "set")] - pub set: HashMap, + pub set: HashMap, /// Gets/sets the task's common fields #[serde(flatten)] @@ -892,7 +892,7 @@ pub struct ErrorFilterDefinition{ /// Gets/sets a key/value mapping of the properties errors to filter must define #[serde(rename = "with", skip_serializing_if = "Option::is_none")] - pub with: Option> + pub with: Option> } diff --git a/core/src/models/workflow.rs b/core/src/models/workflow.rs index 6e5eff2..8493c7e 100644 --- a/core/src/models/workflow.rs +++ b/core/src/models/workflow.rs @@ -1,6 +1,6 @@ use serde_derive::{Deserialize, Serialize}; +use serde_json::Value; use std::collections::HashMap; -use crate::models::any::*; use crate::models::authentication::*; use crate::models::catalog::*; use crate::models::duration::*; @@ -80,7 +80,7 @@ pub struct WorkflowDefinition{ /// Gets/sets a key/value mapping, if any, of additional information associated with the workflow #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] - pub metadata: Option> + pub metadata: Option> } impl WorkflowDefinition { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy