Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace AnyValye by serde_json::Value #5

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions builders/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serverless_workflow_builders"
version = "1.0.0-alpha6.2"
version = "1.0.0-alpha6.3"
edition = "2021"
authors = ["The Serverless Workflow Authors <[email protected]>"]
description = "Contains services used to build ServerlessWorkflow workflow definitions programatically"
Expand All @@ -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.2" }
serverless_workflow_core = { path = "../core", version = "1.0.0-alpha6.3" }
serde_json = "1.0"
serde_yaml = "0.9"
32 changes: 16 additions & 16 deletions builders/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, AnyValue> = vec![
("key1".to_string(), AnyValue::String("value1".to_string())),
("key2".to_string(), AnyValue::String("value2".to_string()))]
let call_task_with: HashMap<String, Value> = 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<String, AnyValue> = vec![
("key1".to_string(), AnyValue::String("value1".to_string())),
("key2".to_string(), AnyValue::String("value2".to_string()))]
let emit_event_attributes: HashMap<String, Value> = 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";
Expand All @@ -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";
Expand Down Expand Up @@ -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<String, AnyValue> = vec![
("var1-name".to_string(), AnyValue::String("var1-value".to_string())),
("var2-name".to_string(), AnyValue::UInt64(69))]
let set_task_variables : HashMap<String, Value> = 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";
Expand All @@ -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<String, AnyValue> = vec![
("var1-name".to_string(), AnyValue::String("var1-value".to_string())),
("var2-name".to_string(), AnyValue::UInt64(69))]
let catch_errors_attributes: HashMap<String, Value> = 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";
Expand Down Expand Up @@ -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| {
Expand Down
32 changes: 16 additions & 16 deletions builders/src/services/task.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -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());
}
Expand All @@ -272,7 +272,7 @@ impl CalltaskDefinitionBuilder {
}

/// Sets the arguments to call the function with
pub fn with_arguments(&mut self, arguments: HashMap<String, AnyValue>) -> &mut Self{
pub fn with_arguments(&mut self, arguments: HashMap<String, Value>) -> &mut Self{
self.task.with = Some(arguments);
self
}
Expand Down Expand Up @@ -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<String, AnyValue>) -> &mut Self{
pub fn variables(&mut self, variables: HashMap<String, Value>) -> &mut Self{
self.task.set = variables;
self
}
Expand Down Expand Up @@ -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<String, AnyValue>) -> &mut Self{
pub fn with_attributes(&mut self, attributes: HashMap<String, Value>) -> &mut Self{
self.event.with = attributes;
self
}
Expand Down Expand Up @@ -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());
}
Expand All @@ -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<String, AnyValue>) -> &mut Self{
pub fn with_attributes(&mut self, attributes: HashMap<String, Value>) -> &mut Self{
self.filter.with = Some(attributes);
self
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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());
}
Expand All @@ -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<String, AnyValue>) -> &mut Self{
pub fn with_attributes(&mut self, attributes: HashMap<String, Value>) -> &mut Self{
self.filter.with = Some(attributes);
self
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serverless_workflow_core"
version = "1.0.0-alpha6.2"
version = "1.0.0-alpha6.3"
edition = "2021"
authors = ["The Serverless Workflow Authors <[email protected]>"]
description = "Contains Serverless Workflow DSL models"
Expand Down
31 changes: 0 additions & 31 deletions core/src/models/any.rs

This file was deleted.

6 changes: 3 additions & 3 deletions core/src/models/error.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -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")]
Expand All @@ -29,7 +29,7 @@ pub struct ErrorDefinition{
impl ErrorDefinition{

/// Initializes a new ErrorDefinition
pub fn new(type_: &str, title: &str, status: AnyValue, detail: Option<String>, instance: Option<String>) -> Self{
pub fn new(type_: &str, title: &str, status: Value, detail: Option<String>, instance: Option<String>) -> Self{
Self {
type_: type_.to_string(),
title: title.to_string(),
Expand Down
8 changes: 4 additions & 4 deletions core/src/models/event.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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<HashMap<String, AnyValue>>,
pub with : Option<HashMap<String, Value>>,

/// Gets/sets a name/definition mapping of the correlation to attempt when filtering events.
#[serde(rename = "correlate", skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -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<String, AnyValue>
pub with: HashMap<String, Value>

}
impl EventDefinition {
pub fn new(with: HashMap<String, AnyValue>) -> Self{
pub fn new(with: HashMap<String, Value>) -> Self{
Self{
with
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/models/input.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<AnyValue>
pub from : Option<Value>

}
1 change: 0 additions & 1 deletion core/src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod any;
pub mod authentication;
pub mod catalog;
pub mod duration;
Expand Down
4 changes: 2 additions & 2 deletions core/src/models/output.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<AnyValue>
pub as_: Option<Value>

}
Loading
Loading