Skip to content
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
46 changes: 21 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ $\color{skyblue}{Syntax}$
[partial] set <variablename> = expression
```


#### Data Types
**Simple Types:**
###### Number
Expand All @@ -111,7 +110,7 @@ let hasValue = true
let allow = false
```
###### Date
Simpleflow does not recognize date type directly, but this can be declared by using built-in date function.
Use date function to declare a variable as date type.
```csharp
let birthday = $date(y:1980, m: 1, d: 1 )
```
Expand Down Expand Up @@ -157,6 +156,7 @@ rule when <predicate> then
> <small> condition does not allow expression. If you need to write expression
declare variable and write expression and use that variable in predicate. This does not support nested rules to avoid code complexity</small>


#### Emitters

$\color{skyblue}{Syntax}$
Expand All @@ -178,34 +178,36 @@ $<function_name>(param_name1: value1, param_name2: value2, ...)

###### Date Functions

* $\color{green}{\$Date(y: int, m: int, d: int, [h:int, mn: int, s: int])}$
* $\color{#4686f2}{\$Date(y: int, m: int, d: int, [h:int, mn: int, s: int])}$
```csharp
// Examples
let d1 = $Date(y: 2022, m: 7, d:11)
let d2 = $Date(m: 10, d:25, y: 2022 )
let t1 = $Date(m: 10, d:25, y: 2022, h:13, mn:30 )
```
* $\color{green}{\$GetCurrentDate()}$
* $\color{green}{\$GetCurrentTime()}$
* $\color{green}{\$GetCurrentDateTime(timeZone: "")}$
<br>
Check supported time zones here:
https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11#time-zones
* $\color{#4686f2}{\$GetCurrentDate()}$
* $\color{#4686f2}{\$GetCurrentTime()}$
* $\color{#4686f2}{\$GetCurrentDateTime(timeZone: "")}$

Check available list of time zones here: <br>
Windows: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11#time-zones <br>
Ubuntu: https://manpages.ubuntu.com/manpages/bionic/man3/DateTime::TimeZone::Catalog.3pm.html <br>

```csharp
let today = $GetCurrentDateTime()
let todayEst = $GetCurrentDateTime ( timezone: "Eastern Standard Time" )
```

###### String Functions
* $\color{green}{\$Substring(input: string, startIndex:int, length: int)}$
* $\color{green}{\$IndexOf(input: string, value:string, startIndex: int) }$
* $\color{green}{\$Length(input: string) }$
* $\color{green}{\$Contains(input: string, value:string) }$
* $\color{green}{\$StartsWith(input: string, value:string) }$
* $\color{green}{\$EndsWith(input: string, value:string) }$
* $\color{green}{\$Trim(input: string, value:string) }$
* $\color{green}{\$Match(input: string, pattern:string) }$
* $\color{green}{\$Concat(value1: string, value2:string, value3:string, value4:string, value5:string)}$
* $\color{#4686f2}{\$Substring(input: string, startIndex:int, length: int)}$
* $\color{#4686f2}{\$IndexOf(input: string, value:string, startIndex: int) }$
* $\color{#4686f2}{\$Length(input: string) }$
* $\color{#4686f2}{\$Contains(input: string, value:string) }$
* $\color{#4686f2}{\$StartsWith(input: string, value:string) }$
* $\color{#4686f2}{\$EndsWith(input: string, value:string) }$
* $\color{#4686f2}{\$Trim(input: string, value:string) }$
* $\color{#4686f2}{\$Match(input: string, pattern:string) }$
* $\color{#4686f2}{\$Concat(value1: string, value2:string, value3:string, value4:string, value5:string)}$
```csharp
let value = $Concat ( value1: "I ", value2: "got it" )
```
Expand All @@ -226,7 +228,7 @@ It supports only one style of comment can be used for single or multiline using
#### Simpleflow Execution
<a name="simpleflow-pipeline"></a>

<!-- ![Simpleflow Pipeline](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/navtech-io/Simpleflow/main/SimpleflowDiagram.puml) -->
![Simpleflow Pipeline](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/navtech-io/Simpleflow/main/SimpleflowDiagram.puml)

Sample code to create, build and run pipeline
```csharp
Expand Down Expand Up @@ -397,9 +399,3 @@ Below statement throws exception:
let address = {City: "Ny"}
let o = {Id: 2, Name: "John", Address: address }
```






13 changes: 6 additions & 7 deletions SimpleflowDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,27 @@ skinparam linetype ortho

skinparam component {
FontSize 15

FontName Courier
BorderColor black
BackgroundColor white
ArrowFontName Impact
ArrowColor #db691d
ArrowColor #1d3ddb
}

skinparam package {
FontSize 13
FontSize 15
FontName Courier
BorderColor white
BackgroundColor #fadd93
BackgroundColor #dee9fa
ArrowFontName Impact

}

package "Default Execution Pipeline" {
Script -right- [Cache Component]
[Cache Component] -right-> [Parser Component]
[Cache Component] -right-> [Execution Component]
[Parser Component] -right-> [Execution Component]
[Cache Component] -right-> [Parser/Compiler Component]
[Cache Component] .right.> [Execution Component]
[Parser/Compiler Component] -right-> [Execution Component]

[Execution Component] - Output
}
Expand Down
2 changes: 1 addition & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Build : NukeBuild
.SetPackageProjectUrl("https://github.com/navtech-io/Simpleflow")
.AddProperty("PackageLicenseExpression", "Apache-2.0")
.SetIncludeSymbols(true)
.SetVersion("0.1.0-beta03" /*NuGetVersionCustom*/)
.SetVersion("0.1.0-beta04" /*NuGetVersionCustom*/)
.SetDescription("Lightweight rule engine")
.SetPackageTags("Simpleflow.NET Workflow RuleEngine DynamicExpressionEvaluator")
.SetNoDependencies(true)
Expand Down
2 changes: 1 addition & 1 deletion src/Simpleflow/FlowOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class FlowOptions : IOptions
/// <summary>
/// Gets or sets AllowArgumentToMutate
/// </summary>
public bool AllowArgumentToMutate { get; set; }
// public bool AllowArgumentToMutate { get; set; } // Implement in next release

/// <summary>
/// Gets or sets AllowFunctions
Expand Down
2 changes: 1 addition & 1 deletion src/Simpleflow/IOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IOptions
/// <summary>
/// Gets or sets AllowArgumentToMutate
/// </summary>
bool AllowArgumentToMutate { get; }
//bool AllowArgumentToMutate { get; } // Implement in next release Check CacheService related impl

/// <summary>
/// Gets or sets AllowFunctions
Expand Down
7 changes: 4 additions & 3 deletions src/Simpleflow/Services/CacheService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,17 @@ protected virtual string GetScriptUniqueId(string script)

private string GetFlowContextOptionsId(IContextOptions options)
{
if (options.AllowArgumentToMutate == false
&& (options.AllowFunctions == null || options.AllowFunctions.Length == 0)
if (
//options.AllowArgumentToMutate == false &&
(options.AllowFunctions == null || options.AllowFunctions.Length == 0)
&& (options.DenyFunctions == null || options.DenyFunctions.Length == 0)
)
{
return string.Empty;
}

StringBuilder sb = new StringBuilder();
sb.Append(string.Join(' ', options.AllowArgumentToMutate));
//sb.Append(string.Join(' ', options.AllowArgumentToMutate));

if (options.AllowFunctions != null && options.AllowFunctions.Length > 0)
{
Expand Down
10 changes: 0 additions & 10 deletions src/Simpleflow/Simpleflow.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ message d

// Act & Assert
Assert.Throws<AccessDeniedException>(
() => new SimpleflowPipelineBuilder()
.AddCorePipelineServices(FunctionRegister.Default)
.AddPipelineServices(new LoggingService())
.Build()
.Run(script, new object(), options));
() => SimpleflowEngine.Run(script, new object(), options));
}

[Fact]
Expand Down