diff --git a/.claude/settings.local.json b/.claude/settings.local.json
new file mode 100644
index 0000000..566f08b
--- /dev/null
+++ b/.claude/settings.local.json
@@ -0,0 +1,54 @@
+{
+ "permissions": {
+ "allow": [
+ "Bash(xargs grep:*)",
+ "Bash(xargs cat:*)",
+ "Bash(grep -E \"\\\\.cs$\")",
+ "Bash(dotnet build:*)",
+ "Bash(dotnet test:*)",
+ "Bash(ls -la src/ServerlessWorkflow.Sdk/Models/*.cs)",
+ "Bash(grep -h \"^namespace\" \"C:\\\\Users\\\\User\\\\source\\\\repos\\\\sdk-net/src/ServerlessWorkflow.Sdk/Models\"/*.cs)",
+ "Bash(find \"C:\\\\Users\\\\User\\\\source\\\\repos\\\\sdk-net/src/ServerlessWorkflow.Sdk/Models\" -name \"*.cs\" -type f -exec grep -h \"^namespace\" {})",
+ "Bash(find \"C:\\\\Users\\\\User\\\\source\\\\repos\\\\sdk-net/src/\" -name \"*.cs\" -type f -exec grep -l \"JsonConverter\\\\|JsonSerializable\" {})",
+ "Bash(ls /c/Users/User/source/repos/sdk-net/src/ServerlessWorkflow.Sdk/bin/*/net*/)",
+ "Bash(ls /c/Users/User/source/repos/sdk-net/src/ServerlessWorkflow.Sdk/bin/Release/net9.0/*.dll)",
+ "Bash(ls /c/Users/User/source/repos/sdk-net/src/ServerlessWorkflow.Sdk/bin/Release/net8.0/*.dll)",
+ "Bash(dotnet nuget:*)",
+ "Bash(dotnet package:*)",
+ "Bash(find \"C:\\\\Users\\\\User\\\\source\\\\repos\\\\sdk-net\\\\src\\\\ServerlessWorkflow.Sdk\" -name \"*.cs\" -type f -exec grep -l \"EquatableDictionary\" {})",
+ "Bash(xargs -I {} head -50 {})",
+ "Bash(dotnet run:*)",
+ "Bash(dotnet list:*)",
+ "Bash(find:*)",
+ "Bash(grep -r \"public.*class\" /c/Dev/ServerlessWorkflow/sdk-net/src/ServerlessWorkflow.Sdk.Runtime/Services/*.cs)",
+ "Bash(cp -r /c/Users/User/source/repos/sdk-net/src/ServerlessWorkflow.Sdk.Builders/Interfaces /c/Dev/ServerlessWorkflow/sdk-net/src/ServerlessWorkflow.Sdk.Builders/Interfaces)",
+ "Bash(cp /c/Users/User/source/repos/sdk-net/src/ServerlessWorkflow.Sdk.Builders/*.cs /c/Dev/ServerlessWorkflow/sdk-net/src/ServerlessWorkflow.Sdk.Builders/)",
+ "Bash(grep -oP '[^\\\\\\\\]+\\\\.cs')",
+ "Bash(dotnet add:*)",
+ "Bash(taskkill //F //PID 8608)",
+ "Bash(taskkill //F //IM ServerlessWorkflow.Sdk.UnitTests.exe)",
+ "Bash(ls src/ServerlessWorkflow.Sdk.Builders/*.cs)",
+ "Bash(ls tests/ServerlessWorkflow.Sdk.UnitTests/Cases/Builders/*.cs)",
+ "Bash(grep -v '//')",
+ "Bash(grep -v '^\\\\s*//')",
+ "Bash(ls tests/ServerlessWorkflow.Sdk.UnitTests/Cases/Runtime/Services/*.cs)",
+ "Bash(sed 's|.*/||')",
+ "Bash(ls src/ServerlessWorkflow.Sdk.IO/*.cs)",
+ "Bash(ls src/ServerlessWorkflow.Sdk.Runtime.Abstractions/*.cs src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/*.cs)",
+ "Bash(taskkill /F /PID 14212)",
+ "Bash(taskkill /F /IM \"ServerlessWorkflow.Sdk.UnitTests.exe\")",
+ "Bash(cmd.exe:*)",
+ "Bash(grep -i \"\\\\.cs$\")",
+ "Bash(taskkill //F //IM \"ServerlessWorkflow.Sdk.UnitTests.exe\")",
+ "Bash(taskkill //F //IM \"testhost.exe\")",
+ "Bash(grep -n \"class.*Expressions\\\\|EvaluateAsync\\\\|EvaluateConditionAsync\" /c/Dev/ServerlessWorkflow/sdk-net/src/ServerlessWorkflow.Sdk.Runtime/Services/*.cs)",
+ "Bash(grep -rn \"JsonPointer\\\\.\" C:/Dev/ServerlessWorkflow/sdk-net/src/ServerlessWorkflow.Sdk.Runtime/Services/Executors/*.cs)",
+ "Bash(taskkill //f //im \"ServerlessWorkflow.Sdk.UnitTests.exe\")",
+ "Bash(taskkill //f //im dotnet.exe)",
+ "Bash(git -C \"C:/Dev/CNCF/ServerlessWorkflow/sdk-net\" status -s)",
+ "Bash(git:*)",
+ "Bash(sed:*)",
+ "Bash(grep -l \"IWorkflowRuntime\\\\|IWorkflowDefinitionStore\\\\|IWorkflowProcess\" \"C:\\\\Dev\\\\ServerlessWorkflow\\\\sdk-net\\\\src\\\\ServerlessWorkflow.Sdk.Runtime\"/**/*.cs)"
+ ]
+ }
+}
diff --git a/.github/workflows/build-dotnet.yml b/.github/workflows/build-dotnet.yml
index 4ad7306..852709d 100644
--- a/.github/workflows/build-dotnet.yml
+++ b/.github/workflows/build-dotnet.yml
@@ -11,7 +11,7 @@ on:
workflow_call:
env:
- SOLUTION: ./ServerlessWorkflow.Sdk.sln
+ SOLUTION: ./ServerlessWorkflow.Sdk.slnx
jobs:
build:
@@ -32,8 +32,7 @@ jobs:
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
- 8.0.x
- 9.0.x
+ 10.0.x
- name: Restore dependencies
run: dotnet restore "${{ env.SOLUTION }}"
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 92fcc69..1c22c8f 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -6,7 +6,7 @@ on:
workflow_dispatch:
env:
- SOLUTION: ./ServerlessWorkflow.Sdk.sln
+ SOLUTION: ./ServerlessWorkflow.Sdk.slnx
REGISTRY: ghcr.io
jobs:
@@ -18,8 +18,7 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
- 8.0.x
- 9.0.x
+ 10.0.x
- name: Restore dependencies
run: dotnet restore "${{ env.SOLUTION }}"
- name: Build
diff --git a/.github/workflows/test-dotnet.yml b/.github/workflows/test-dotnet.yml
index 88a2a30..ee82637 100644
--- a/.github/workflows/test-dotnet.yml
+++ b/.github/workflows/test-dotnet.yml
@@ -11,7 +11,7 @@ on:
workflow_call:
env:
- SOLUTION: ./ServerlessWorkflow.Sdk.sln
+ SOLUTION: ./ServerlessWorkflow.Sdk.slnx
jobs:
build:
@@ -24,8 +24,7 @@ jobs:
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
- 8.0.x
- 9.0.x
+ 10.0.x
- name: Restore dependencies
run: dotnet restore "${{ env.SOLUTION }}"
diff --git a/code-of-conduct.md b/CODE_OF_CONDUCT.md
similarity index 100%
rename from code-of-conduct.md
rename to CODE_OF_CONDUCT.md
diff --git a/ServerlessWorkflow.Sdk.sln b/ServerlessWorkflow.Sdk.sln
deleted file mode 100644
index efd9280..0000000
--- a/ServerlessWorkflow.Sdk.sln
+++ /dev/null
@@ -1,87 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.4.33213.308
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9016CF88-4100-425F-9E1A-B6099F55A35B}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{60FE2678-84CF-492C-950D-3485582F6712}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{0CD38EC5-C4AB-491A-B6EA-D6C608F68157}"
- ProjectSection(SolutionItems) = preProject
- code-of-conduct.md = code-of-conduct.md
- CONTRIBUTING.md = CONTRIBUTING.md
- LICENSE = LICENSE
- MAINTAINERS.md = MAINTAINERS.md
- maintainer_guidelines.md = maintainer_guidelines.md
- README.md = README.md
- EndProjectSection
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{F3B6D944-46DA-4CAF-A8BE-0C8F230869F9}"
- ProjectSection(SolutionItems) = preProject
- .editorconfig = .editorconfig
- EndProjectSection
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerlessWorkflow.Sdk", "src\ServerlessWorkflow.Sdk\ServerlessWorkflow.Sdk.csproj", "{8D4E5FB8-79BC-442B-852F-5891B39A5A1C}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerlessWorkflow.Sdk.Builders", "src\ServerlessWorkflow.Sdk.Builders\ServerlessWorkflow.Sdk.Builders.csproj", "{53A4A0D8-E2F4-43BC-808F-37B1EB7837DE}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerlessWorkflow.Sdk.IO", "src\ServerlessWorkflow.Sdk.IO\ServerlessWorkflow.Sdk.IO.csproj", "{9993989F-B8D6-481C-A59C-A76070CA32F4}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerlessWorkflow.Sdk.UnitTests", "tests\ServerlessWorkflow.Sdk.UnitTests\ServerlessWorkflow.Sdk.UnitTests.csproj", "{7BFC0DDB-7864-4C5A-AC91-EB7B3E93242E}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{A8E842C3-60C4-46A7-A2D7-57C28BA151E6}"
- ProjectSection(SolutionItems) = preProject
- .github\PULL_REQUEST_TEMPLATE.md = .github\PULL_REQUEST_TEMPLATE.md
- EndProjectSection
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ISSUE_TEMPLATE", "ISSUE_TEMPLATE", "{3327DDB8-87C1-4A08-9221-A8CD1450DD12}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{8BA94EDE-CE8B-4476-A58F-50162B06EE71}"
- ProjectSection(SolutionItems) = preProject
- .github\workflows\build-dotnet.yml = .github\workflows\build-dotnet.yml
- .github\workflows\ci-pipeline.yml = .github\workflows\ci-pipeline.yml
- .github\workflows\publish.yml = .github\workflows\publish.yml
- .github\workflows\release.yml = .github\workflows\release.yml
- .github\workflows\test-dotnet.yml = .github\workflows\test-dotnet.yml
- .github\workflows\versioning.yml = .github\workflows\versioning.yml
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8D4E5FB8-79BC-442B-852F-5891B39A5A1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8D4E5FB8-79BC-442B-852F-5891B39A5A1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8D4E5FB8-79BC-442B-852F-5891B39A5A1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8D4E5FB8-79BC-442B-852F-5891B39A5A1C}.Release|Any CPU.Build.0 = Release|Any CPU
- {53A4A0D8-E2F4-43BC-808F-37B1EB7837DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {53A4A0D8-E2F4-43BC-808F-37B1EB7837DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {53A4A0D8-E2F4-43BC-808F-37B1EB7837DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {53A4A0D8-E2F4-43BC-808F-37B1EB7837DE}.Release|Any CPU.Build.0 = Release|Any CPU
- {9993989F-B8D6-481C-A59C-A76070CA32F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9993989F-B8D6-481C-A59C-A76070CA32F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9993989F-B8D6-481C-A59C-A76070CA32F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9993989F-B8D6-481C-A59C-A76070CA32F4}.Release|Any CPU.Build.0 = Release|Any CPU
- {7BFC0DDB-7864-4C5A-AC91-EB7B3E93242E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7BFC0DDB-7864-4C5A-AC91-EB7B3E93242E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7BFC0DDB-7864-4C5A-AC91-EB7B3E93242E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7BFC0DDB-7864-4C5A-AC91-EB7B3E93242E}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {8D4E5FB8-79BC-442B-852F-5891B39A5A1C} = {9016CF88-4100-425F-9E1A-B6099F55A35B}
- {53A4A0D8-E2F4-43BC-808F-37B1EB7837DE} = {9016CF88-4100-425F-9E1A-B6099F55A35B}
- {9993989F-B8D6-481C-A59C-A76070CA32F4} = {9016CF88-4100-425F-9E1A-B6099F55A35B}
- {7BFC0DDB-7864-4C5A-AC91-EB7B3E93242E} = {60FE2678-84CF-492C-950D-3485582F6712}
- {3327DDB8-87C1-4A08-9221-A8CD1450DD12} = {A8E842C3-60C4-46A7-A2D7-57C28BA151E6}
- {8BA94EDE-CE8B-4476-A58F-50162B06EE71} = {A8E842C3-60C4-46A7-A2D7-57C28BA151E6}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {1402FB0B-4169-41A6-A372-DA260E79481B}
- EndGlobalSection
-EndGlobal
diff --git a/ServerlessWorkflow.Sdk.slnx b/ServerlessWorkflow.Sdk.slnx
new file mode 100644
index 0000000..e12f554
--- /dev/null
+++ b/ServerlessWorkflow.Sdk.slnx
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.editorconfig b/editorconfig
similarity index 100%
rename from .editorconfig
rename to editorconfig
diff --git a/src/ServerlessWorkflow.Sdk.Builders/AuthenticationPolicyDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/AuthenticationPolicyDefinitionBuilder.cs
index 78eb715..275a183 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/AuthenticationPolicyDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/AuthenticationPolicyDefinitionBuilder.cs
@@ -16,83 +16,76 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class AuthenticationPolicyDefinitionBuilder
+public sealed class AuthenticationPolicyDefinitionBuilder
: IAuthenticationPolicyDefinitionBuilder
{
- ///
- /// Gets/sets the name of the to use, if any
- ///
- protected string? Policy { get; set; }
-
- ///
- /// Gets/sets the to use
- ///
- protected IAuthenticationSchemeDefinitionBuilder? SchemeBuilder { get; set; }
+ string? policy;
+ IAuthenticationSchemeDefinitionBuilder? schemeBuilder;
///
- public virtual void Use(string policy)
+ public void Use(string policy)
{
ArgumentException.ThrowIfNullOrWhiteSpace(policy);
- this.Policy = policy;
+ this.policy = policy;
}
///
- public virtual IBasicAuthenticationSchemeDefinitionBuilder Basic()
+ public IBasicAuthenticationSchemeDefinitionBuilder Basic()
{
var builder = new BasicAuthenticationSchemeDefinitionBuilder();
- this.SchemeBuilder = builder;
+ schemeBuilder = builder;
return builder;
}
///
- public virtual IBearerAuthenticationSchemeDefinitionBuilder Bearer()
+ public IBearerAuthenticationSchemeDefinitionBuilder Bearer()
{
var builder = new BearerAuthenticationSchemeDefinitionBuilder();
- this.SchemeBuilder = builder;
+ schemeBuilder = builder;
return builder;
}
///
- public virtual ICertificateAuthenticationSchemeDefinitionBuilder Certificate()
+ public ICertificateAuthenticationSchemeDefinitionBuilder Certificate()
{
var builder = new CertificateAuthenticationSchemeDefinitionBuilder();
- this.SchemeBuilder = builder;
+ schemeBuilder = builder;
return builder;
}
///
- public virtual IDigestAuthenticationSchemeDefinitionBuilder Digest()
+ public IDigestAuthenticationSchemeDefinitionBuilder Digest()
{
var builder = new DigestAuthenticationSchemeDefinitionBuilder();
- this.SchemeBuilder = builder;
+ schemeBuilder = builder;
return builder;
}
///
- public virtual IOAuth2AuthenticationSchemeDefinitionBuilder OAuth2()
+ public IOAuth2AuthenticationSchemeDefinitionBuilder OAuth2()
{
var builder = new OAuth2AuthenticationSchemeDefinitionBuilder();
- this.SchemeBuilder = builder;
+ schemeBuilder = builder;
return builder;
}
///
- public virtual IOpenIDConnectAuthenticationSchemeDefinitionBuilder OpenIDConnect()
+ public IOpenIDConnectAuthenticationSchemeDefinitionBuilder OpenIDConnect()
{
var builder = new OpenIDConnectAuthenticationSchemeDefinitionBuilder();
- this.SchemeBuilder = builder;
+ schemeBuilder = builder;
return builder;
}
///
- public virtual AuthenticationPolicyDefinition Build()
+ public AuthenticationPolicyDefinition Build()
{
- if (this.SchemeBuilder == null) throw new NullReferenceException("The authentication scheme must be set");
- var scheme = this.SchemeBuilder.Build();
+ if (schemeBuilder == null) throw new NullReferenceException("The authentication scheme must be set");
+ var scheme = schemeBuilder.Build();
return new()
{
- Use = this.Policy,
+ Use = policy,
Basic = scheme is BasicAuthenticationSchemeDefinition basic ? basic : null,
Bearer = scheme is BearerAuthenticationSchemeDefinition bearer ? bearer : null,
OAuth2 = scheme is OAuth2AuthenticationSchemeDefinition oauth2 ? oauth2 : null,
diff --git a/src/ServerlessWorkflow.Sdk.Builders/AuthenticationSchemeDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/AuthenticationSchemeDefinitionBuilder.cs
index 8a423ff..fb5d302 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/AuthenticationSchemeDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/AuthenticationSchemeDefinitionBuilder.cs
@@ -31,12 +31,12 @@ public abstract class AuthenticationSchemeDefinitionBuilder
public virtual void Use(string secret)
{
ArgumentException.ThrowIfNullOrWhiteSpace(secret);
- this.Secret = secret;
+ Secret = secret;
}
///
public abstract TDefinition Build();
- AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => this.Build();
+ AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => Build();
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/BackoffStrategyDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/BackoffStrategyDefinitionBuilder.cs
index d117801..f7a33fb 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/BackoffStrategyDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/BackoffStrategyDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,49 +16,47 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class BackoffStrategyDefinitionBuilder
+public sealed class BackoffStrategyDefinitionBuilder
: IBackoffStrategyDefinitionBuilder
{
- ///
- /// Gets the underlying service used to build the to use
- ///
- protected IBackoffDefinitionBuilder? Backoff { get; set; }
+ IBackoffDefinitionBuilder? backoff;
///
- public virtual IConstantBackoffDefinitionBuilder Constant()
+ public IConstantBackoffDefinitionBuilder Constant()
{
var builder = new ConstantBackoffDefinitionBuilder();
- this.Backoff = builder;
+ backoff = builder;
return builder;
}
///
- public virtual IExponentialBackoffDefinitionBuilder Exponential()
+ public IExponentialBackoffDefinitionBuilder Exponential()
{
var builder = new ExponentialBackoffDefinitionBuilder();
- this.Backoff = builder;
+ backoff = builder;
return builder;
}
///
- public virtual ILinearBackoffDefinitionBuilder Linear(Duration? increment = null)
+ public ILinearBackoffDefinitionBuilder Linear(Duration? increment = null)
{
- var builder = new LinearBackoffDefinitionBuilder();
- this.Backoff = builder;
+ var builder = new LinearBackoffDefinitionBuilder(increment);
+ backoff = builder;
return builder;
}
///
- public virtual BackoffStrategyDefinition Build()
+ public BackoffStrategyDefinition Build()
{
- if (this.Backoff == null) throw new NullReferenceException("The backoff strategy must be set");
+ if (backoff == null) throw new NullReferenceException("The backoff strategy must be set");
+ var definition = backoff.Build();
return new()
{
- Constant = this.Backoff is ConstantBackoffDefinition constant ? constant : null,
- Exponential = this.Backoff is ExponentialBackoffDefinition exponential ? exponential : null,
- Linear = this.Backoff is LinearBackoffDefinition linear ? linear : null,
+ Constant = definition is ConstantBackoffDefinition constant ? constant : null,
+ Exponential = definition is ExponentialBackoffDefinition exponential ? exponential : null,
+ Linear = definition is LinearBackoffDefinition linear ? linear : null,
};
}
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/BasicAuthenticationSchemeDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/BasicAuthenticationSchemeDefinitionBuilder.cs
index f022aa3..b371a45 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/BasicAuthenticationSchemeDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/BasicAuthenticationSchemeDefinitionBuilder.cs
@@ -16,49 +16,42 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class BasicAuthenticationSchemeDefinitionBuilder
+public sealed class BasicAuthenticationSchemeDefinitionBuilder
: AuthenticationSchemeDefinitionBuilder, IBasicAuthenticationSchemeDefinitionBuilder
{
- ///
- /// Gets/sets the username to use
- ///
- protected string? Username { get; set; }
-
- ///
- /// Gets/sets the password to use
- ///
- protected string? Password { get; set; }
+ string? username;
+ string? password;
///
- public virtual IBasicAuthenticationSchemeDefinitionBuilder WithUsername(string username)
+ public IBasicAuthenticationSchemeDefinitionBuilder WithUsername(string username)
{
ArgumentException.ThrowIfNullOrWhiteSpace(username);
- this.Username = username;
+ this.username = username;
return this;
}
///
- public virtual IBasicAuthenticationSchemeDefinitionBuilder WithPassword(string password)
+ public IBasicAuthenticationSchemeDefinitionBuilder WithPassword(string password)
{
ArgumentException.ThrowIfNullOrWhiteSpace(password);
- this.Password = password;
+ this.password = password;
return this;
}
///
public override BasicAuthenticationSchemeDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Username)) throw new NullReferenceException("The username must be set");
- if (string.IsNullOrWhiteSpace(this.Password)) throw new NullReferenceException("The password must be set");
+ if (string.IsNullOrWhiteSpace(username)) throw new NullReferenceException("The username must be set");
+ if (string.IsNullOrWhiteSpace(password)) throw new NullReferenceException("The password must be set");
return new()
{
- Use = this.Secret,
- Username = this.Username,
- Password = this.Password
+ Use = Secret,
+ Username = username,
+ Password = password
};
}
- AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => this.Build();
+ AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => Build();
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/BearerAuthenticationSchemeDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/BearerAuthenticationSchemeDefinitionBuilder.cs
index 1975575..1393c94 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/BearerAuthenticationSchemeDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/BearerAuthenticationSchemeDefinitionBuilder.cs
@@ -16,34 +16,31 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class BearerAuthenticationSchemeDefinitionBuilder
+public sealed class BearerAuthenticationSchemeDefinitionBuilder
: AuthenticationSchemeDefinitionBuilder, IBearerAuthenticationSchemeDefinitionBuilder
{
- ///
- /// Gets/sets the bearer token to use
- ///
- protected string? Token { get; set; }
+ string? token;
///
- public virtual IBearerAuthenticationSchemeDefinitionBuilder WithToken(string token)
+ public IBearerAuthenticationSchemeDefinitionBuilder WithToken(string token)
{
ArgumentException.ThrowIfNullOrWhiteSpace(token);
- this.Token = token;
+ this.token = token;
return this;
}
///
public override BearerAuthenticationSchemeDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Token)) throw new NullReferenceException("The token must be set");
+ if (string.IsNullOrWhiteSpace(token)) throw new NullReferenceException("The token must be set");
return new()
{
- Use = this.Secret,
- Token = this.Token
+ Use = Secret,
+ Token = token
};
}
- AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => this.Build();
+ AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => Build();
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/CallTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/CallTaskDefinitionBuilder.cs
index c16f7cf..f4295b6 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/CallTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/CallTaskDefinitionBuilder.cs
@@ -11,61 +11,52 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
/// The name of the function to call
-public class CallTaskDefinitionBuilder(string? functionName = null)
+public sealed class CallTaskDefinitionBuilder(string? functionName = null)
: TaskDefinitionBuilder, ICallTaskDefinitionBuilder
{
- ///
- /// Gets the name of the function to call
- ///
- protected virtual string? FunctionName { get; set; } = functionName;
-
- ///
- /// Gets a name/value mapping of the function's arguments, if any
- ///
- protected virtual EquatableDictionary? FunctionArguments { get; set; }
+ string? functionName = functionName;
+ JsonObject? functionArguments;
///
- public virtual ICallTaskDefinitionBuilder Function(string name)
+ public ICallTaskDefinitionBuilder Function(string name)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.FunctionName = name;
+ functionName = name;
return this;
}
///
- public virtual ICallTaskDefinitionBuilder With(string name, object value)
+ public ICallTaskDefinitionBuilder With(string name, JsonNode value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.FunctionArguments ??= [];
- this.FunctionArguments[name] = value;
+ functionArguments ??= [];
+ functionArguments[name] = value;
return this;
}
///
- public virtual ICallTaskDefinitionBuilder With(IDictionary arguments)
+ public ICallTaskDefinitionBuilder With(JsonObject arguments)
{
ArgumentNullException.ThrowIfNull(arguments);
- this.FunctionArguments = new(arguments);
+ functionArguments = arguments;
return this;
}
///
public override CallTaskDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.FunctionName)) throw new NullReferenceException("The function to call is required");
- return this.Configure(new()
+ if (string.IsNullOrWhiteSpace(functionName)) throw new NullReferenceException("The function to call is required");
+ return Configure(new()
{
- Call = this.FunctionName,
- With = this.FunctionArguments,
+ Call = functionName,
+ With = functionArguments,
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/CertificateAuthenticationSchemeDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/CertificateAuthenticationSchemeDefinitionBuilder.cs
index 688dc4a..5662f62 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/CertificateAuthenticationSchemeDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/CertificateAuthenticationSchemeDefinitionBuilder.cs
@@ -16,7 +16,7 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class CertificateAuthenticationSchemeDefinitionBuilder
+public sealed class CertificateAuthenticationSchemeDefinitionBuilder
: AuthenticationSchemeDefinitionBuilder, ICertificateAuthenticationSchemeDefinitionBuilder
{
@@ -25,10 +25,10 @@ public override CertificateAuthenticationSchemeDefinition Build()
{
return new()
{
- Use = this.Secret
+ Use = Secret
};
}
- AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => this.Build();
+ AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => Build();
}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ConstantBackoffDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ConstantBackoffDefinitionBuilder.cs
index 4c0de1c..2b221c3 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ConstantBackoffDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ConstantBackoffDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,16 +16,13 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ConstantBackoffDefinitionBuilder
+public sealed class ConstantBackoffDefinitionBuilder
: IConstantBackoffDefinitionBuilder
{
///
- public virtual ConstantBackoffDefinition Build() => new()
- {
-
- };
+ public ConstantBackoffDefinition Build() => new() { };
- BackoffDefinition IBackoffDefinitionBuilder.Build() => this.Build();
+ BackoffDefinition IBackoffDefinitionBuilder.Build() => Build();
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ContainerProcessDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ContainerProcessDefinitionBuilder.cs
index 60355d3..4096bf1 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ContainerProcessDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ContainerProcessDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -12,134 +12,110 @@
// limitations under the License.
using ServerlessWorkflow.Sdk.Models.Processes;
-using Neuroglia;
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ContainerProcessDefinitionBuilder
+public sealed class ContainerProcessDefinitionBuilder
: ProcessDefinitionBuilder, IContainerProcessDefinitionBuilder
{
- ///
- /// Gets/sets the name of the container image to run
- ///
- protected virtual string? Image { get; set; }
-
- ///
- /// Gets/sets the name of the container to run
- ///
- protected virtual string? Name { get; set; }
-
- ///
- /// Gets/sets the command, if any, to execute on the container
- ///
- protected virtual string? Command { get; set; }
-
- ///
- /// Gets/sets a list containing the container's port mappings, if any
- ///
- protected virtual EquatableDictionary? Ports { get; set; }
-
- ///
- /// Gets/sets the volumes mapping for the container, if any
- ///
- protected virtual EquatableDictionary? Volumes { get; set; }
-
- ///
- /// Gets/sets a key/value mapping of the environment variables, if any, to use when running the configured process
- ///
- protected virtual EquatableDictionary? Environment { get; set; }
+ string? image;
+ string? name;
+ string? command;
+ EquatableDictionary? ports;
+ EquatableDictionary? volumes;
+ EquatableDictionary? environment;
///
- public virtual IContainerProcessDefinitionBuilder WithImage(string image)
+ public IContainerProcessDefinitionBuilder WithImage(string image)
{
ArgumentException.ThrowIfNullOrWhiteSpace(image);
- this.Image = image;
+ this.image = image;
return this;
}
///
- public virtual IContainerProcessDefinitionBuilder WithName(string name)
+ public IContainerProcessDefinitionBuilder WithName(string name)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Name = name;
+ this.name = name;
return this;
}
///
- public virtual IContainerProcessDefinitionBuilder WithCommand(string command)
+ public IContainerProcessDefinitionBuilder WithCommand(string command)
{
ArgumentException.ThrowIfNullOrWhiteSpace(command);
- this.Command = command;
+ this.command = command;
return this;
}
///
- public virtual IContainerProcessDefinitionBuilder WithPort(ushort hostPort, ushort containerPort)
+ public IContainerProcessDefinitionBuilder WithPort(ushort hostPort, ushort containerPort)
{
- this.Ports ??= [];
- this.Ports[hostPort] = containerPort;
+ ports ??= [];
+ ports[hostPort] = containerPort;
return this;
}
///
- public virtual IContainerProcessDefinitionBuilder WithPorts(IDictionary portMapping)
+ public IContainerProcessDefinitionBuilder WithPorts(IDictionary portMapping)
{
ArgumentNullException.ThrowIfNull(portMapping);
- this.Ports = new(portMapping);
+ ports = [.. portMapping];
return this;
}
///
- public virtual IContainerProcessDefinitionBuilder WithVolume(string key, string value)
+ public IContainerProcessDefinitionBuilder WithVolume(string key, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(key);
- this.Volumes ??= [];
- this.Volumes[key] = value;
+ volumes ??= [];
+ volumes[key] = value;
return this;
}
///
- public virtual IContainerProcessDefinitionBuilder WithVolumes(IDictionary volumes)
+ public IContainerProcessDefinitionBuilder WithVolumes(IDictionary volumes)
{
ArgumentNullException.ThrowIfNull(volumes);
- this.Volumes = new(volumes);
+ this.volumes = [.. volumes];
return this;
}
///
- public virtual IContainerProcessDefinitionBuilder WithEnvironment(string name, string value)
+ public IContainerProcessDefinitionBuilder WithEnvironment(string name, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentException.ThrowIfNullOrWhiteSpace(value);
- this.Environment ??= [];
- this.Environment[name] = value;
+ environment ??= [];
+ environment[name] = value;
return this;
}
///
- public virtual IContainerProcessDefinitionBuilder WithEnvironment(IDictionary environment)
+ public IContainerProcessDefinitionBuilder WithEnvironment(IDictionary environment)
{
ArgumentNullException.ThrowIfNull(environment);
- this.Environment = new(environment);
+ this.environment = [.. environment];
return this;
}
///
public override ContainerProcessDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Image)) throw new NullReferenceException("The image of the container to run must be set");
+ if (string.IsNullOrWhiteSpace(image)) throw new NullReferenceException("The image of the container to run must be set");
return new()
{
- Image = this.Image,
- Name = this.Name,
- Command = this.Command,
- Ports = this.Ports,
- Volumes = this.Volumes,
- Environment = this.Environment
+ Image = image,
+ Name = name,
+ Command = command,
+ Ports = ports,
+ Volumes = volumes,
+ Environment = environment
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/DigestAuthenticationSchemeDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/DigestAuthenticationSchemeDefinitionBuilder.cs
index a239377..7a51d9a 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/DigestAuthenticationSchemeDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/DigestAuthenticationSchemeDefinitionBuilder.cs
@@ -16,49 +16,42 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class DigestAuthenticationSchemeDefinitionBuilder
+public sealed class DigestAuthenticationSchemeDefinitionBuilder
: AuthenticationSchemeDefinitionBuilder, IDigestAuthenticationSchemeDefinitionBuilder
{
- ///
- /// Gets/sets the username to use
- ///
- protected string? Username { get; set; }
-
- ///
- /// Gets/sets the password to use
- ///
- protected string? Password { get; set; }
+ string? username;
+ string? password;
///
- public virtual IDigestAuthenticationSchemeDefinitionBuilder WithUsername(string username)
+ public IDigestAuthenticationSchemeDefinitionBuilder WithUsername(string username)
{
ArgumentException.ThrowIfNullOrWhiteSpace(username);
- this.Username = username;
+ this.username = username;
return this;
}
///
- public virtual IDigestAuthenticationSchemeDefinitionBuilder WithPassword(string password)
+ public IDigestAuthenticationSchemeDefinitionBuilder WithPassword(string password)
{
ArgumentException.ThrowIfNullOrWhiteSpace(password);
- this.Password = password;
+ this.password = password;
return this;
}
///
public override DigestAuthenticationSchemeDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Username)) throw new NullReferenceException("The username must be set");
- if (string.IsNullOrWhiteSpace(this.Password)) throw new NullReferenceException("The password must be set");
+ if (string.IsNullOrWhiteSpace(username)) throw new NullReferenceException("The username must be set");
+ if (string.IsNullOrWhiteSpace(password)) throw new NullReferenceException("The password must be set");
return new()
{
- Use = this.Secret,
- Username = this.Username,
- Password = this.Password
+ Use = Secret,
+ Username = username,
+ Password = password
};
}
- AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => this.Build();
+ AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => Build();
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/DoTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/DoTaskDefinitionBuilder.cs
index 858b17a..2d351c6 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/DoTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/DoTaskDefinitionBuilder.cs
@@ -16,32 +16,29 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class DoTaskDefinitionBuilder
+public sealed class DoTaskDefinitionBuilder
: TaskDefinitionBuilder, IDoTaskDefinitionBuilder
{
- ///
- /// Gets/sets a name/definition mapping of the tasks to execute sequentially, if any
- ///
- protected Map? Tasks { get; set; }
+ Map? tasks;
///
- public virtual IDoTaskDefinitionBuilder Do(Action setup)
+ public IDoTaskDefinitionBuilder Do(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new TaskDefinitionMapBuilder();
setup(builder);
- this.Tasks = builder.Build();
+ tasks = builder.Build();
return this;
}
///
public override DoTaskDefinition Build()
{
- if (this.Tasks == null || this.Tasks.Count < 2) throw new NullReferenceException("The execution strategy must define at least two subtasks");
- return this.Configure(new()
+ if (tasks == null || tasks.Count < 2) throw new NullReferenceException("The execution strategy must define at least two subtasks");
+ return Configure(new()
{
- Do = this.Tasks
+ Do = tasks
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/EmitTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/EmitTaskDefinitionBuilder.cs
index c686ccc..954b33f 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/EmitTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/EmitTaskDefinitionBuilder.cs
@@ -17,42 +17,39 @@ namespace ServerlessWorkflow.Sdk.Builders;
/// Represents the default implementation of the interface
///
/// The definition of the event to emit
-public class EmitTaskDefinitionBuilder(EventDefinition? e = null)
+public sealed class EmitTaskDefinitionBuilder(EventDefinition? e = null)
: TaskDefinitionBuilder, IEmitTaskDefinitionBuilder
{
- ///
- /// Gets/sets the definition of the event to emit
- ///
- protected virtual EventDefinition? EventDefinition { get; set; } = e;
+ EventDefinition? eventDefinition = e;
///
- public virtual IEmitTaskDefinitionBuilder Event(EventDefinition e)
+ public IEmitTaskDefinitionBuilder Event(EventDefinition e)
{
ArgumentNullException.ThrowIfNull(e);
- this.EventDefinition = e;
+ eventDefinition = e;
return this;
}
///
- public virtual IEmitTaskDefinitionBuilder Event(Action setup)
+ public IEmitTaskDefinitionBuilder Event(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new EventDefinitionBuilder();
setup(builder);
- this.EventDefinition = builder.Build();
+ eventDefinition = builder.Build();
return this;
}
///
public override EmitTaskDefinition Build()
{
- if (this.EventDefinition == null) throw new NullReferenceException("The event to emit must be defined");
- return this.Configure(new()
+ if (eventDefinition == null) throw new NullReferenceException("The event to emit must be defined");
+ return Configure(new()
{
Emit = new()
{
- Event = this.EventDefinition
+ Event = eventDefinition
}
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/EndpointDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/EndpointDefinitionBuilder.cs
index fb7bf72..e7ce7b6 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/EndpointDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/EndpointDefinitionBuilder.cs
@@ -16,69 +16,67 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class EndpointDefinitionBuilder
+public sealed class EndpointDefinitionBuilder
: IEndpointDefinitionBuilder
{
- ///
- /// Gets/sets the uri that references the external resource
- ///
- protected virtual Uri? Uri { get; set; }
-
- ///
- /// Gets/sets a reference to the authentication policy to use
- ///
- protected virtual Uri? AuthenticationReference { get; set; }
-
- ///
- /// Gets/sets the authentication policy to use
- ///
- protected virtual AuthenticationPolicyDefinition? Authentication { get; set; }
+ Uri? uri;
+ Uri? authenticationReference;
+ AuthenticationPolicyDefinition? authentication;
///
- public virtual IEndpointDefinitionBuilder WithUri(Uri uri)
+ public IEndpointDefinitionBuilder WithUri(Uri uri)
{
ArgumentNullException.ThrowIfNull(uri);
- this.Uri = uri;
+ this.uri = uri;
return this;
}
///
- public virtual IEndpointDefinitionBuilder UseAuthentication(Uri reference)
+ public IEndpointDefinitionBuilder UseAuthentication(Uri reference)
{
ArgumentNullException.ThrowIfNull(reference);
- this.AuthenticationReference = reference;
+ authenticationReference = reference;
return this;
}
///
- public virtual IEndpointDefinitionBuilder UseAuthentication(AuthenticationPolicyDefinition authentication)
+ public IEndpointDefinitionBuilder UseAuthentication(AuthenticationPolicyDefinition authentication)
{
ArgumentNullException.ThrowIfNull(authentication);
- this.Authentication = authentication;
+ this.authentication = authentication;
return this;
}
///
- public virtual IEndpointDefinitionBuilder UseAuthentication(Action setup)
+ public IEndpointDefinitionBuilder UseAuthentication(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new AuthenticationPolicyDefinitionBuilder();
setup(builder);
- this.Authentication = builder.Build();
+ authentication = builder.Build();
return this;
}
///
- public virtual EndpointDefinition Build()
+ public EndpointDefinition Build()
{
- if (this.Uri == null) throw new NullReferenceException("The uri that references the external resource must be set");
+ if (uri == null) throw new NullReferenceException("The uri that references the external resource must be set");
var endpoint = new EndpointDefinition()
{
- Uri = this.Uri
+ Uri = uri
+ };
+ if (authenticationReference == null) endpoint = endpoint with
+ {
+ Authentication = new()
+ {
+ Ref = authenticationReference
+ }
+ };
+ else if (authentication != null) endpoint = endpoint with
+ {
+ Authentication = authentication
};
- if (this.AuthenticationReference == null) endpoint.Authentication = new() { Ref = this.AuthenticationReference };
- else if (this.Authentication != null) endpoint.Authentication = this.Authentication;
return endpoint;
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ErrorCatcherDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ErrorCatcherDefinitionBuilder.cs
index bedd085..02c7d4a 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ErrorCatcherDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ErrorCatcherDefinitionBuilder.cs
@@ -16,104 +16,79 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ErrorCatcherDefinitionBuilder
+public sealed class ErrorCatcherDefinitionBuilder
: IErrorCatcherDefinitionBuilder
{
- ///
- /// Gets/sets the definition of the errors to catch
- ///
- protected ErrorFilterDefinition? CatchErrors { get; set; }
-
- ///
- /// Gets/sets the name of the runtime expression variable to save the error as. Defaults to 'error'.
- ///
- protected string? CatchAs { get; set; }
-
- ///
- /// Gets/sets a runtime expression used to determine whether or not to catch the filtered error
- ///
- protected string? CatchWhen { get; set; }
-
- ///
- /// Gets/sets a runtime expression used to determine whether or not to catch the filtered error
- ///
- protected string? CatchExceptWhen { get; set; }
-
- ///
- /// Gets/sets a reference to the definition of the retry policy to use when catching errors
- ///
- protected Uri? RetryPolicyReference { get; set; }
-
- ///
- /// Gets/sets the definition of the retry policy to use when catching errors
- ///
- protected RetryPolicyDefinition? RetryPolicy { get; set; }
-
- ///
- /// Gets/sets the definition of the task to run when catching an error
- ///
- protected Map? RetryDo { get; set; }
+ ErrorFilterDefinition? catchErrors;
+ string? catchAs;
+ string? catchWhen;
+ string? catchExceptWhen;
+ OneOf? retryPolicy;
+ Map? retryDo;
///
- public virtual IErrorCatcherDefinitionBuilder Errors(ErrorFilterDefinition filter)
+ public IErrorCatcherDefinitionBuilder Errors(ErrorFilterDefinition filter)
{
ArgumentNullException.ThrowIfNull(filter);
- this.CatchErrors = filter;
+ catchErrors = filter;
return this;
}
///
- public virtual IErrorCatcherDefinitionBuilder Errors(Action setup)
+ public IErrorCatcherDefinitionBuilder Errors(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new ErrorFilterDefinitionBuilder();
setup(builder);
- return this.Errors(builder.Build());
+ return Errors(builder.Build());
}
///
- public virtual IErrorCatcherDefinitionBuilder As(string variableName)
+ public IErrorCatcherDefinitionBuilder As(string variableName)
{
- this.CatchAs = variableName;
+ catchAs = variableName;
return this;
}
///
- public virtual IErrorCatcherDefinitionBuilder When(string expression)
+ public IErrorCatcherDefinitionBuilder When(string expression)
{
- this.CatchWhen = expression;
+ catchWhen = expression;
return this;
}
///
- public virtual IErrorCatcherDefinitionBuilder ExceptWhen(string expression)
+ public IErrorCatcherDefinitionBuilder ExceptWhen(string expression)
{
- this.CatchExceptWhen = expression;
+ catchExceptWhen = expression;
return this;
}
///
- public virtual IErrorCatcherDefinitionBuilder Retry(Uri reference)
+ public IErrorCatcherDefinitionBuilder Retry(Uri reference)
{
- this.RetryPolicyReference = reference;
+ retryPolicy = new RetryPolicyDefinition()
+ {
+ Ref = reference
+ };
return this;
}
///
- public virtual IErrorCatcherDefinitionBuilder Retry(RetryPolicyDefinition retryPolicy)
+ public IErrorCatcherDefinitionBuilder Retry(RetryPolicyDefinition retryPolicy)
{
- this.RetryPolicy = retryPolicy;
+ this.retryPolicy = retryPolicy;
return this;
}
///
- public virtual IErrorCatcherDefinitionBuilder Retry(Action setup)
+ public IErrorCatcherDefinitionBuilder Retry(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new RetryPolicyDefinitionBuilder();
setup(builder);
- return this.Retry(builder.Build());
+ return Retry(builder.Build());
}
///
@@ -122,19 +97,19 @@ public IErrorCatcherDefinitionBuilder Do(Action setup
ArgumentNullException.ThrowIfNull(setup);
var builder = new TaskDefinitionMapBuilder();
setup(builder);
- this.RetryDo = builder.Build();
+ retryDo = builder.Build();
return this;
}
///
- public virtual ErrorCatcherDefinition Build() => new()
+ public ErrorCatcherDefinition Build() => new()
{
- Errors = this.CatchErrors,
- As = this.CatchAs,
- When = this.CatchWhen,
- ExceptWhen = this.CatchExceptWhen,
- Retry = this.RetryPolicyReference == null ? this.RetryPolicy : new() { Ref = this.RetryPolicyReference },
- Do = this.RetryDo
+ Errors = catchErrors,
+ As = catchAs,
+ When = catchWhen,
+ ExceptWhen = catchExceptWhen,
+ Retry = retryPolicy,
+ Do = retryDo
};
}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ErrorDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ErrorDefinitionBuilder.cs
index 8bc33ee..8f1e436 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ErrorDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ErrorDefinitionBuilder.cs
@@ -16,88 +16,69 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ErrorDefinitionBuilder
+public sealed class ErrorDefinitionBuilder
: IErrorDefinitionBuilder
{
- ///
- /// Gets the type of the error to build
- ///
- protected string? Type { get; set; }
-
- ///
- /// Gets the status of the error to build
- ///
- protected string? Status { get; set; }
-
- ///
- /// Gets the title of the error to build
- ///
- protected string? Title { get; set; }
-
- ///
- /// Gets the detail of the error to build
- ///
- protected string? Detail { get; set; }
-
- ///
- /// Gets the instance of the error to build
- ///
- protected string? Instance { get; set; }
+ string? type;
+ string? status;
+ string? title;
+ string? detail;
+ string? instance;
///
- public virtual IErrorDefinitionBuilder WithType(string type)
+ public IErrorDefinitionBuilder WithType(string type)
{
ArgumentException.ThrowIfNullOrWhiteSpace(type);
- this.Type = type;
+ this.type = type;
return this;
}
///
- public virtual IErrorDefinitionBuilder WithStatus(string status)
+ public IErrorDefinitionBuilder WithStatus(string status)
{
ArgumentException.ThrowIfNullOrWhiteSpace(status);
- this.Status = status;
+ this.status = status;
return this;
}
///
- public virtual IErrorDefinitionBuilder WithTitle(string title)
+ public IErrorDefinitionBuilder WithTitle(string title)
{
ArgumentException.ThrowIfNullOrWhiteSpace(title);
- this.Title = title;
+ this.title = title;
return this;
}
///
- public virtual IErrorDefinitionBuilder WithDetail(string detail)
+ public IErrorDefinitionBuilder WithDetail(string detail)
{
ArgumentException.ThrowIfNullOrWhiteSpace(detail);
- this.Detail = detail;
+ this.detail = detail;
return this;
}
///
- public virtual IErrorDefinitionBuilder WithInstance(string instance)
+ public IErrorDefinitionBuilder WithInstance(string instance)
{
ArgumentException.ThrowIfNullOrWhiteSpace(instance);
- this.Instance = instance;
+ this.instance = instance;
return this;
}
///
- public virtual ErrorDefinition Build()
+ public ErrorDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Type)) throw new NullReferenceException("The error type must be set");
- if (string.IsNullOrWhiteSpace(this.Title)) throw new NullReferenceException("The error title must be set");
- if (string.IsNullOrWhiteSpace(this.Status)) throw new NullReferenceException("The error status must be set");
+ if (string.IsNullOrWhiteSpace(type)) throw new NullReferenceException("The error type must be set");
+ if (string.IsNullOrWhiteSpace(title)) throw new NullReferenceException("The error title must be set");
+ if (string.IsNullOrWhiteSpace(status)) throw new NullReferenceException("The error status must be set");
return new()
{
- Type = this.Type,
- Status = this.Status,
- Title = this.Title,
- Detail = this.Detail,
- Instance = this.Instance
+ Type = type,
+ Status = status,
+ Title = title,
+ Detail = detail,
+ Instance = instance
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ErrorFilterDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ErrorFilterDefinitionBuilder.cs
index 61fe52d..821bdce 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ErrorFilterDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ErrorFilterDefinitionBuilder.cs
@@ -11,40 +11,38 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
/// A name/value mapping of the attributes to filter errors by. Supports runtime expressions
-public class ErrorFilterDefinitionBuilder(IDictionary? attributes = null)
+public sealed class ErrorFilterDefinitionBuilder(JsonObject? attributes = null)
: IErrorFilterDefinitionBuilder
{
- ///
- /// Gets a name/value mapping of the attributes to filter errors by
- ///
- protected virtual EquatableDictionary Attributes { get; set; } = [.. attributes];
+ JsonObject attributes = attributes ?? [];
///
- public virtual IErrorFilterDefinitionBuilder With(string name, object value)
+ public IErrorFilterDefinitionBuilder With(string name, JsonNode value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Attributes[name] = value;
+ attributes[name] = value;
return this;
}
///
- public virtual IErrorFilterDefinitionBuilder With(IDictionary attributes)
+ public IErrorFilterDefinitionBuilder With(JsonObject attributes)
{
ArgumentNullException.ThrowIfNull(attributes);
- this.Attributes = new(attributes);
+ this.attributes = [..attributes];
return this;
}
///
- public virtual ErrorFilterDefinition Build() => new() { With = this.Attributes };
+ public ErrorFilterDefinition Build() => new()
+ {
+ With = attributes
+ };
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/EventDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/EventDefinitionBuilder.cs
index 5339262..f10d3b8 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/EventDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/EventDefinitionBuilder.cs
@@ -11,40 +11,38 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
/// A name/value mapping of the event's attributes. Supports runtime expressions
-public class EventDefinitionBuilder(IDictionary? attributes = null)
+public class EventDefinitionBuilder(JsonObject? attributes = null)
: IEventDefinitionBuilder
{
- ///
- /// Gets a name/value mapping of the event's attributes
- ///
- protected virtual EquatableDictionary Attributes { get; set; } = attributes == null ? new() : new(attributes);
+ JsonObject attributes = attributes ?? [];
///
- public virtual IEventDefinitionBuilder With(string name, object value)
+ public virtual IEventDefinitionBuilder With(string name, JsonNode value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Attributes[name] = value;
+ attributes[name] = value;
return this;
}
///
- public virtual IEventDefinitionBuilder With(IDictionary attributes)
+ public virtual IEventDefinitionBuilder With(JsonObject attributes)
{
ArgumentNullException.ThrowIfNull(attributes);
- this.Attributes = new(attributes);
+ this.attributes = attributes;
return this;
}
///
- public virtual EventDefinition Build() => new() { With = this.Attributes };
+ public virtual EventDefinition Build() => new()
+ {
+ With = attributes
+ };
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/EventFilterDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/EventFilterDefinitionBuilder.cs
index 89aa4df..7589513 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/EventFilterDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/EventFilterDefinitionBuilder.cs
@@ -11,40 +11,38 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
/// A name/value mapping of the attributes to filter events by. Supports runtime expressions
-public class EventFilterDefinitionBuilder(IDictionary? attributes = null)
+public sealed class EventFilterDefinitionBuilder(JsonObject? attributes = null)
: IEventFilterDefinitionBuilder
{
- ///
- /// Gets a name/value mapping of the attributes to filter errors by
- ///
- protected virtual EquatableDictionary Attributes { get; set; } = attributes == null ? new() : new(attributes);
+ JsonObject attributes = attributes ?? [];
///
- public virtual IEventFilterDefinitionBuilder With(string name, object value)
+ public IEventFilterDefinitionBuilder With(string name, JsonNode value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Attributes[name] = value;
+ attributes[name] = value;
return this;
}
///
- public virtual IEventFilterDefinitionBuilder With(IDictionary attributes)
+ public IEventFilterDefinitionBuilder With(JsonObject attributes)
{
ArgumentNullException.ThrowIfNull(attributes);
- this.Attributes = new(attributes);
+ this.attributes = attributes;
return this;
}
///
- public virtual EventFilterDefinition Build() => new() { With = this.Attributes };
+ public EventFilterDefinition Build() => new()
+ {
+ With = attributes
+ };
}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Builders/EventFilterDefinitionCollectionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/EventFilterDefinitionCollectionBuilder.cs
index 210481e..144a1ea 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/EventFilterDefinitionCollectionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/EventFilterDefinitionCollectionBuilder.cs
@@ -11,48 +11,43 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class EventFilterDefinitionCollectionBuilder
+public sealed class EventFilterDefinitionCollectionBuilder
: IEventFilterDefinitionCollectionBuilder
{
- ///
- /// Gets/sets the filters the collection to build is made out of
- ///
- protected EquatableList? Filters { get; set; }
+ EquatableList? filters;
///
- public virtual IEventFilterDefinitionCollectionBuilder Event(EventFilterDefinition filter)
+ public IEventFilterDefinitionCollectionBuilder Event(EventFilterDefinition filter)
{
ArgumentNullException.ThrowIfNull(filter);
- this.Filters ??= [];
- this.Filters.Add(filter);
+ filters ??= [];
+ filters.Add(filter);
return this;
}
///
- public virtual IEventFilterDefinitionCollectionBuilder Event(Action setup)
+ public IEventFilterDefinitionCollectionBuilder Event(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new EventFilterDefinitionBuilder();
setup(builder);
var filter = builder.Build();
- this.Filters ??= [];
- this.Filters.Add(filter);
+ filters ??= [];
+ filters.Add(filter);
return this;
}
///
- public virtual EquatableList Build()
+ public EquatableList Build()
{
- if (this.Filters == null || this.Filters.Count < 1) throw new NullReferenceException("The collection must contain at least one event filter");
- return this.Filters;
+ if (filters == null || filters.Count < 1) throw new NullReferenceException("The collection must contain at least one event filter");
+ return filters;
}
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ExponentialBackoffDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ExponentialBackoffDefinitionBuilder.cs
index 21343eb..2fd4350 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ExponentialBackoffDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ExponentialBackoffDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -14,18 +14,15 @@
namespace ServerlessWorkflow.Sdk.Builders;
///
-/// Represents the default implementation of the interface
+/// Represents the default implementation of the interface
///
-public class ExponentialBackoffDefinitionBuilder
+public sealed class ExponentialBackoffDefinitionBuilder
: IExponentialBackoffDefinitionBuilder
{
///
- public virtual ExponentialBackoffDefinition Build() => new()
- {
+ public ExponentialBackoffDefinition Build() => new() { };
- };
+ BackoffDefinition IBackoffDefinitionBuilder.Build() => Build();
- BackoffDefinition IBackoffDefinitionBuilder.Build() => this.Build();
-
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ExtensionDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ExtensionDefinitionBuilder.cs
index 71a518f..b5ddee9 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ExtensionDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ExtensionDefinitionBuilder.cs
@@ -16,76 +16,61 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ExtensionDefinitionBuilder
+public sealed class ExtensionDefinitionBuilder
: IExtensionDefinitionBuilder
{
- ///
- /// Gets/sets the type of the extended task
- ///
- protected string? TaskType { get; set; }
-
- ///
- /// Gets/sets the expression used to evaluate whether or not the extension applies
- ///
- protected string? WhenExpression { get; set; }
-
- ///
- /// Gets/sets the definition of the task to run before the extended one
- ///
- protected Map? BeforeTasks { get; set; }
-
- ///
- /// Gets/sets the definition of the task to run after the extended one
- ///
- protected Map? AfterTasks { get; set; }
+ string? taskType;
+ string? whenExpression;
+ Map? beforeTasks;
+ Map? afterTasks;
///
- public virtual IExtensionDefinitionBuilder Extend(string taskType)
+ public IExtensionDefinitionBuilder Extend(string taskType)
{
ArgumentException.ThrowIfNullOrWhiteSpace(taskType);
- this.TaskType = taskType;
+ this.taskType = taskType;
return this;
}
///
- public virtual IExtensionDefinitionBuilder When(string when)
+ public IExtensionDefinitionBuilder When(string when)
{
ArgumentException.ThrowIfNullOrWhiteSpace(when);
- this.WhenExpression = when;
+ whenExpression = when;
return this;
}
///
- public virtual IExtensionDefinitionBuilder Before(Action setup)
+ public IExtensionDefinitionBuilder Before(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new TaskDefinitionMapBuilder();
setup(builder);
- this.BeforeTasks = builder.Build();
+ beforeTasks = builder.Build();
return this;
}
///
- public virtual IExtensionDefinitionBuilder After(Action setup)
+ public IExtensionDefinitionBuilder After(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new TaskDefinitionMapBuilder();
setup(builder);
- this.AfterTasks = builder.Build();
+ afterTasks = builder.Build();
return this;
}
///
- public virtual ExtensionDefinition Build()
+ public ExtensionDefinition Build()
{
- ArgumentException.ThrowIfNullOrWhiteSpace(this.TaskType);
+ ArgumentException.ThrowIfNullOrWhiteSpace(taskType);
return new()
{
- Extend = this.TaskType,
- When = this.WhenExpression,
- Before = this.BeforeTasks,
- After = this.AfterTasks
+ Extend = taskType,
+ When = whenExpression,
+ Before = beforeTasks,
+ After = afterTasks
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ExternalResourceDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ExternalResourceDefinitionBuilder.cs
index 138b8dd..6ed2829 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ExternalResourceDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ExternalResourceDefinitionBuilder.cs
@@ -16,53 +16,46 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ExternalResourceDefinitionBuilder
+public sealed class ExternalResourceDefinitionBuilder
: IExternalResourceDefinitionBuilder
{
- ///
- /// Gets/sets the external resource's name
- ///
- protected virtual string? Name { get; set; }
-
- ///
- /// Gets/sets the endpoint at which to get the defined resource
- ///
- protected virtual EndpointDefinition? Endpoint { get; set; }
+ string? name;
+ OneOf? endpoint;
///
- public virtual IExternalResourceDefinitionBuilder WithName(string name)
+ public IExternalResourceDefinitionBuilder WithName(string name)
{
- this.Name = name;
+ this.name = name;
return this;
}
///
- public virtual IExternalResourceDefinitionBuilder WithEndpoint(OneOf endpoint)
+ public IExternalResourceDefinitionBuilder WithEndpoint(OneOf endpoint)
{
ArgumentNullException.ThrowIfNull(endpoint);
- this.Endpoint = endpoint;
+ this.endpoint = endpoint;
return this;
}
///
- public virtual IExternalResourceDefinitionBuilder WithEndpoint(Action setup)
+ public IExternalResourceDefinitionBuilder WithEndpoint(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new EndpointDefinitionBuilder();
setup(builder);
- this.Endpoint = builder.Build();
+ this.endpoint = builder.Build();
return this;
}
///
- public virtual ExternalResourceDefinition Build()
+ public ExternalResourceDefinition Build()
{
- if (this.Endpoint == null) throw new NullReferenceException("The endpoint at which to get the defined resource must be set");
+ if (endpoint == null) throw new NullReferenceException("The endpoint at which to get the defined resource must be set");
var externalResource = new ExternalResourceDefinition()
{
- Name = this.Name,
- Endpoint = this.Endpoint
+ Name = name,
+ Endpoint = endpoint
};
return externalResource;
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ForTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ForTaskDefinitionBuilder.cs
index 047d321..7e484f4 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ForTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ForTaskDefinitionBuilder.cs
@@ -16,79 +16,64 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ForTaskDefinitionBuilder
+public sealed class ForTaskDefinitionBuilder
: TaskDefinitionBuilder, IForTaskDefinitionBuilder
{
- ///
- /// Gets/sets the name of the variable that represents each element in the collection during iteration
- ///
- protected virtual string? EachVariableName { get; set; }
-
- ///
- /// Gets/sets the runtime expression used to get the collection to iterate over
- ///
- protected virtual string? InExpression { get; set; }
-
- ///
- /// Gets/sets the name of the variable used to hold the index of each element in the collection during iteration
- ///
- protected virtual string? AtVariableName { get; set; }
-
- ///
- /// Gets/sets a name/definition map of the tasks to perform for each element in the collection to enumerate
- ///
- protected virtual Map? Tasks { get; set; }
+ string? eachVariableName;
+ string? inExpression;
+ string? atVariableName;
+ Map? tasks;
///
- public virtual IForTaskDefinitionBuilder Each(string variableName)
+ public IForTaskDefinitionBuilder Each(string variableName)
{
ArgumentException.ThrowIfNullOrWhiteSpace(variableName);
- this.EachVariableName = variableName;
+ eachVariableName = variableName;
return this;
}
///
- public virtual IForTaskDefinitionBuilder In(string expression)
+ public IForTaskDefinitionBuilder In(string expression)
{
ArgumentException.ThrowIfNullOrWhiteSpace(expression);
- this.InExpression = expression;
+ inExpression = expression;
return this;
}
///
- public virtual IForTaskDefinitionBuilder At(string variableName)
+ public IForTaskDefinitionBuilder At(string variableName)
{
ArgumentException.ThrowIfNullOrWhiteSpace(variableName);
- this.AtVariableName = variableName;
+ atVariableName = variableName;
return this;
}
///
- public virtual IForTaskDefinitionBuilder Do(Action setup)
+ public IForTaskDefinitionBuilder Do(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new TaskDefinitionMapBuilder();
setup(builder);
- this.Tasks = builder.Build();
+ tasks = builder.Build();
return this;
}
///
public override ForTaskDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.EachVariableName)) throw new NullReferenceException("The variable name used to store the iterated items must be set");
- if (string.IsNullOrWhiteSpace(this.InExpression)) throw new NullReferenceException("The runtime expression used to resolve the collection to iterate must be set");
- if (this.Tasks == null || this.Tasks.Count < 1) throw new NullReferenceException("The task to perform at each iteration must be set");
- return this.Configure(new()
+ if (string.IsNullOrWhiteSpace(eachVariableName)) throw new NullReferenceException("The variable name used to store the iterated items must be set");
+ if (string.IsNullOrWhiteSpace(inExpression)) throw new NullReferenceException("The runtime expression used to resolve the collection to iterate must be set");
+ if (tasks == null || tasks.Count < 1) throw new NullReferenceException("The task to perform at each iteration must be set");
+ return Configure(new()
{
For = new()
{
- Each = this.EachVariableName,
- In = this.InExpression,
- At = this.AtVariableName
+ Each = eachVariableName,
+ In = inExpression,
+ At = atVariableName
},
- Do = this.Tasks
+ Do = tasks
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ForkTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ForkTaskDefinitionBuilder.cs
index 49063a8..df19d6d 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ForkTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ForkTaskDefinitionBuilder.cs
@@ -16,47 +16,40 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ForkTaskDefinitionBuilder
+public sealed class ForkTaskDefinitionBuilder
: TaskDefinitionBuilder, IForkTaskDefinitionBuilder
{
- ///
- /// Gets/sets a name/definition mapping of the tasks to execute concurrently, if any
- ///
- protected Map? Tasks { get; set; }
-
- ///
- /// Gets/sets a boolean indicating whether or not the task to execute concurrently should compete each other
- ///
- protected bool ShouldCompete { get; set; }
+ Map? tasks;
+ bool shouldCompete;
///
- public virtual IForkTaskDefinitionBuilder Branch(Action setup)
+ public IForkTaskDefinitionBuilder Branch(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new TaskDefinitionMapBuilder();
setup(builder);
- this.Tasks = builder.Build();
+ tasks = builder.Build();
return this;
}
///
- public virtual IForkTaskDefinitionBuilder Compete()
+ public IForkTaskDefinitionBuilder Compete()
{
- this.ShouldCompete = true;
+ shouldCompete = true;
return this;
}
///
public override ForkTaskDefinition Build()
{
- if (this.Tasks == null || this.Tasks.Count < 2) throw new NullReferenceException("The execution strategy must define at least two subtasks");
- return this.Configure(new()
+ if (tasks == null || tasks.Count < 2) throw new NullReferenceException("The execution strategy must define at least two subtasks");
+ return Configure(new()
{
Fork = new()
{
- Branches = this.Tasks,
- Compete = this.ShouldCompete
+ Branches = tasks,
+ Compete = shouldCompete
}
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/GenericTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/GenericTaskDefinitionBuilder.cs
index 7015245..1ef9ec4 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/GenericTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/GenericTaskDefinitionBuilder.cs
@@ -16,150 +16,150 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class GenericTaskDefinitionBuilder
+public sealed class GenericTaskDefinitionBuilder
: IGenericTaskDefinitionBuilder
{
- ///
- /// Gets the underlying
- ///
- protected ITaskDefinitionBuilder? Builder { get; set; }
+ ITaskDefinitionBuilder? builder;
///
- public virtual ICallTaskDefinitionBuilder Call(string? function = null)
+ public ICallTaskDefinitionBuilder Call(string? function = null)
{
var builder = new CallTaskDefinitionBuilder(function);
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual IDoTaskDefinitionBuilder Do(Action setup)
+ public IDoTaskDefinitionBuilder Do(Action setup)
{
var builder = new DoTaskDefinitionBuilder();
builder.Do(setup);
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual IEmitTaskDefinitionBuilder Emit(EventDefinition e)
+ public IEmitTaskDefinitionBuilder Emit(EventDefinition e)
{
ArgumentNullException.ThrowIfNull(e);
var builder = new EmitTaskDefinitionBuilder(e);
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual IEmitTaskDefinitionBuilder Emit(Action setup)
+ public IEmitTaskDefinitionBuilder Emit(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new EventDefinitionBuilder();
setup(builder);
var e = builder.Build();
- return this.Emit(e);
+ return Emit(e);
}
///
- public virtual IForTaskDefinitionBuilder For()
+ public IForTaskDefinitionBuilder For()
{
var builder = new ForTaskDefinitionBuilder();
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual IForkTaskDefinitionBuilder Fork()
+ public IForkTaskDefinitionBuilder Fork()
{
var builder = new ForkTaskDefinitionBuilder();
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual IListenTaskDefinitionBuilder Listen()
+ public IListenTaskDefinitionBuilder Listen()
{
var builder = new ListenTaskDefinitionBuilder();
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual IDoTaskDefinitionBuilder Execute()
+ public IDoTaskDefinitionBuilder Execute()
{
var builder = new DoTaskDefinitionBuilder();
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual IRaiseTaskDefinitionBuilder Raise(ErrorDefinition error)
+ public IRaiseTaskDefinitionBuilder Raise(ErrorDefinition error)
{
ArgumentNullException.ThrowIfNull(error);
var builder = new RaiseTaskDefinitionBuilder(error);
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual IRaiseTaskDefinitionBuilder Raise(Action setup)
+ public IRaiseTaskDefinitionBuilder Raise(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new ErrorDefinitionBuilder();
setup(builder);
var error = builder.Build();
- return this.Raise(error);
+ return Raise(error);
}
///
- public virtual IRunTaskDefinitionBuilder Run()
+ public IRunTaskDefinitionBuilder Run()
{
var builder = new RunTaskDefinitionBuilder();
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual ISetTaskDefinitionBuilder Set(string name, string value) => this.Set(new Dictionary() { { name, value } });
+ public ISetTaskDefinitionBuilder Set(string name, string value) => Set(new()
+ {
+ { name, value }
+ });
///
- public virtual ISetTaskDefinitionBuilder Set(IDictionary? variables = null)
+ public ISetTaskDefinitionBuilder Set(JsonObject? variables = null)
{
var builder = new SetTaskDefinitionBuilder(variables);
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual ISwitchTaskDefinitionBuilder Switch()
+ public ISwitchTaskDefinitionBuilder Switch()
{
var builder = new SwitchTaskDefinitionBuilder();
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual ITryTaskDefinitionBuilder Try()
+ public ITryTaskDefinitionBuilder Try()
{
var builder = new TryTaskDefinitionBuilder();
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual IWaitTaskDefinitionBuilder Wait(Duration? duration = null)
+ public IWaitTaskDefinitionBuilder Wait(Duration? duration = null)
{
var builder = new WaitTaskDefinitionBuilder(duration);
- this.Builder = builder;
+ this.builder = builder;
return builder;
}
///
- public virtual TaskDefinition Build()
+ public TaskDefinition Build()
{
- if (this.Builder == null) throw new NullReferenceException();
- return this.Builder.Build();
+ if (this.builder == null) throw new NullReferenceException();
+ return this.builder.Build();
}
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/HttpCallDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/HttpCallDefinitionBuilder.cs
index be1b82e..cb5da91 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/HttpCallDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/HttpCallDefinitionBuilder.cs
@@ -11,144 +11,116 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using ServerlessWorkflow.Sdk.Models.Calls;
-using Neuroglia;
-using System.Runtime.Serialization;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-[DataContract]
-public class HttpCallDefinitionBuilder
+public sealed class HttpCallDefinitionBuilder
: IHttpCallDefinitionBuilder
{
- ///
- /// Gets/sets the HTTP method of the request to perform
- ///
- protected string? Method { get; set; }
-
- ///
- /// Gets/sets the definition of the endpoint to request
- ///
- protected EndpointDefinition? Endpoint { get; set; }
-
- ///
- /// Gets/sets a name/value mapping of the headers, if any, of the HTTP request to perform
- ///
- protected EquatableDictionary? Headers { get; set; }
-
- ///
- /// Gets/sets a name/value mapping of the cookies, if any, of the HTTP request to perform
- ///
- protected EquatableDictionary? Cookies { get; set; }
-
- ///
- /// Gets/sets the body, if any, of the HTTP request to perform
- ///
- protected object? Body { get; set; }
-
- ///
- /// Gets/sets the http call output format. Defaults to .
- ///
- protected string? OutputFormat { get; set; }
+ string? method;
+ EndpointDefinition? endpoint;
+ EquatableDictionary? headers;
+ EquatableDictionary? cookies;
+ JsonNode? body;
+ string? outputFormat;
///
- public virtual IHttpCallDefinitionBuilder WithMethod(string method)
+ public IHttpCallDefinitionBuilder WithMethod(string method)
{
ArgumentException.ThrowIfNullOrWhiteSpace(method);
- this.Method = method;
+ this.method = method;
return this;
}
///
- public virtual IHttpCallDefinitionBuilder WithUri(Uri uri)
+ public IHttpCallDefinitionBuilder WithUri(Uri uri)
{
ArgumentNullException.ThrowIfNull(uri);
- this.Endpoint = new() { Uri = uri };
+ endpoint = new() { Uri = uri };
return this;
}
///
- public virtual IHttpCallDefinitionBuilder WithEndpoint(EndpointDefinition endpoint)
+ public IHttpCallDefinitionBuilder WithEndpoint(EndpointDefinition endpoint)
{
ArgumentNullException.ThrowIfNull(endpoint);
- this.Endpoint = endpoint;
+ this.endpoint = endpoint;
return this;
}
///
- public virtual IHttpCallDefinitionBuilder WithEndpoint(Action setup)
+ public IHttpCallDefinitionBuilder WithEndpoint(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
- var builder = (IEndpointDefinitionBuilder)new ExternalResourceDefinitionBuilder();
+ var builder = new EndpointDefinitionBuilder();
setup(builder);
- return this.WithEndpoint(builder.Build());
+ return WithEndpoint(builder.Build());
}
///
- public virtual IHttpCallDefinitionBuilder WithHeader(string name, string value)
+ public IHttpCallDefinitionBuilder WithHeader(string name, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentException.ThrowIfNullOrWhiteSpace(value);
- this.Headers ??= [];
- this.Headers[name] = value;
+ headers ??= [];
+ headers[name] = value;
return this;
}
///
- public virtual IHttpCallDefinitionBuilder WithHeaders(IDictionary headers)
+ public IHttpCallDefinitionBuilder WithHeaders(IDictionary headers)
{
- this.Headers = headers == null ? null : new(headers);
+ this.headers = headers == null ? null : new(headers);
return this;
}
///
- public virtual IHttpCallDefinitionBuilder WithCookie(string name, string value)
+ public IHttpCallDefinitionBuilder WithCookie(string name, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentException.ThrowIfNullOrWhiteSpace(value);
- this.Cookies ??= [];
- this.Cookies[name] = value;
+ cookies ??= [];
+ cookies[name] = value;
return this;
}
///
- public virtual IHttpCallDefinitionBuilder WithCookies(IDictionary cookies)
+ public IHttpCallDefinitionBuilder WithCookies(IDictionary cookies)
{
- this.Cookies = cookies == null ? null : new(cookies);
+ this.cookies = cookies == null ? null : new(cookies);
return this;
}
///
- public virtual IHttpCallDefinitionBuilder WithBody(object body)
+ public IHttpCallDefinitionBuilder WithBody(JsonNode body)
{
- this.Body = body;
+ this.body = body;
return this;
}
///
- public virtual IHttpCallDefinitionBuilder WithOutputFormat(string format)
+ public IHttpCallDefinitionBuilder WithOutputFormat(string format)
{
ArgumentException.ThrowIfNullOrWhiteSpace(format);
- this.OutputFormat = format;
+ outputFormat = format;
return this;
}
///
- public virtual HttpCallDefinition Build()
+ public HttpCallDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Method)) throw new NullReferenceException("The HTTP method must be set");
- if (this.Endpoint == null) throw new NullReferenceException("The HTTP endpoint must be set");
+ if (string.IsNullOrWhiteSpace(method)) throw new NullReferenceException("The HTTP method must be set");
+ if (endpoint == null) throw new NullReferenceException("The HTTP endpoint must be set");
return new()
{
- Method = this.Method,
- Endpoint = this.Endpoint,
- Headers = this.Headers,
- Body = this.Body,
- Output = this.OutputFormat
+ Method = method,
+ Endpoint = endpoint,
+ Headers = headers,
+ Body = body,
+ Output = outputFormat
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/InputDataModelDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/InputDataModelDefinitionBuilder.cs
index 589a4fb..f3adb34 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/InputDataModelDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/InputDataModelDefinitionBuilder.cs
@@ -16,34 +16,37 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class InputDataModelDefinitionBuilder
+public sealed class InputDataModelDefinitionBuilder
: IInputDataModelDefinitionBuilder
{
- ///
- /// Gets the to configure
- ///
- protected InputDataModelDefinition Input { get; } = new();
+ InputDataModelDefinition input = new();
///
- public virtual IInputDataModelDefinitionBuilder From(object expression)
+ public IInputDataModelDefinitionBuilder From(OneOf expression)
{
ArgumentNullException.ThrowIfNull(expression);
- this.Input.From = expression;
+ input = input with
+ {
+ From = expression
+ };
return this;
}
///
- public virtual IInputDataModelDefinitionBuilder WithSchema(Action setup)
+ public IInputDataModelDefinitionBuilder WithSchema(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new SchemaDefinitionBuilder();
setup(builder);
- this.Input.Schema = builder.Build();
+ input = input with
+ {
+ Schema = builder.Build()
+ };
return this;
}
///
- public virtual InputDataModelDefinition Build() => this.Input;
+ public InputDataModelDefinition Build() => input;
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ICallTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ICallTaskDefinitionBuilder.cs
index 554bcb1..20450db 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ICallTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ICallTaskDefinitionBuilder.cs
@@ -33,13 +33,13 @@ public interface ICallTaskDefinitionBuilder
/// The argument's name
/// The argument's value
/// The configured
- ICallTaskDefinitionBuilder With(string name, object value);
+ ICallTaskDefinitionBuilder With(string name, JsonNode value);
///
/// Sets the arguments to call the function with
///
/// A name/value mapping of the arguments to call the function with
/// The configured
- ICallTaskDefinitionBuilder With(IDictionary arguments);
+ ICallTaskDefinitionBuilder With(JsonObject arguments);
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IErrorFilterDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IErrorFilterDefinitionBuilder.cs
index 17b9029..db28691 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IErrorFilterDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IErrorFilterDefinitionBuilder.cs
@@ -25,14 +25,14 @@ public interface IErrorFilterDefinitionBuilder
/// The name of the attribute to filter errors by
/// The value of the attribute to filter errors by. Supports runtime expressions
/// The configured
- IErrorFilterDefinitionBuilder With(string name, object value);
+ IErrorFilterDefinitionBuilder With(string name, JsonNode value);
///
/// Sets a name/value mapping of the attributes to filter errors by
///
/// A name/value mapping of the attributes to filter errors by. Supports runtime expressions
/// The configured
- IErrorFilterDefinitionBuilder With(IDictionary attributes);
+ IErrorFilterDefinitionBuilder With(JsonObject attributes);
///
/// Builds the configured
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventDefinitionBuilder.cs
index 5686b3e..471298f 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventDefinitionBuilder.cs
@@ -25,14 +25,14 @@ public interface IEventDefinitionBuilder
/// The attribute's name
/// The attribute's value. Supports runtime expressions
/// The configured
- IEventDefinitionBuilder With(string name, object value);
+ IEventDefinitionBuilder With(string name, JsonNode value);
///
/// Sets the event's attributes
///
/// A name/value mapping of the event's attributes. Supports runtime expressions
/// The configured
- IEventDefinitionBuilder With(IDictionary attributes);
+ IEventDefinitionBuilder With(JsonObject attributes);
///
/// Builds the configured
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventFilterDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventFilterDefinitionBuilder.cs
index 999cc64..4bfd50a 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventFilterDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventFilterDefinitionBuilder.cs
@@ -25,14 +25,14 @@ public interface IEventFilterDefinitionBuilder
/// The name of the attribute to filter events by
/// The value of the attribute to filter events by. Supports runtime expressions
/// The configured
- IEventFilterDefinitionBuilder With(string name, object value);
+ IEventFilterDefinitionBuilder With(string name, JsonNode value);
///
/// Sets a name/value mapping of the attributes to filter events by
///
/// A name/value mapping of the attributes to filter events by. Supports runtime expressions
/// The configured
- IEventFilterDefinitionBuilder With(IDictionary attributes);
+ IEventFilterDefinitionBuilder With(JsonObject attributes);
///
/// Builds the configured
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventFilterDefinitionCollectionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventFilterDefinitionCollectionBuilder.cs
index b410e26..bb46f73 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventFilterDefinitionCollectionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IEventFilterDefinitionCollectionBuilder.cs
@@ -11,8 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IGenericTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IGenericTaskDefinitionBuilder.cs
index 35b23d7..83539d6 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IGenericTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IGenericTaskDefinitionBuilder.cs
@@ -98,7 +98,7 @@ public interface IGenericTaskDefinitionBuilder
///
/// A name/value mapping of the variables to set. Supports runtime expressions
/// A new
- ISetTaskDefinitionBuilder Set(IDictionary? variables = null);
+ ISetTaskDefinitionBuilder Set(JsonObject? variables = null);
///
/// Configures the task to branch the flow based on defined conditions
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IHttpCallDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IHttpCallDefinitionBuilder.cs
index 222121f..7287222 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IHttpCallDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IHttpCallDefinitionBuilder.cs
@@ -84,7 +84,7 @@ public interface IHttpCallDefinitionBuilder
///
/// The request body
/// The configured
- IHttpCallDefinitionBuilder WithBody(object body);
+ IHttpCallDefinitionBuilder WithBody(JsonNode body);
///
/// Uses the specified output format
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IInputDataModelDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IInputDataModelDefinitionBuilder.cs
index 1be73a4..e81f406 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IInputDataModelDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IInputDataModelDefinitionBuilder.cs
@@ -31,7 +31,7 @@ public interface IInputDataModelDefinitionBuilder
///
/// The runtime expression used to filter the input data
/// The configured
- IInputDataModelDefinitionBuilder From(object expression);
+ IInputDataModelDefinitionBuilder From(OneOf expression);
///
/// Builds the configured
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IOutputDataModelDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IOutputDataModelDefinitionBuilder.cs
index 464deb5..370732e 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IOutputDataModelDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IOutputDataModelDefinitionBuilder.cs
@@ -31,7 +31,7 @@ public interface IOutputDataModelDefinitionBuilder
///
/// The runtime expression used to filter the data to output
/// The configured
- IOutputDataModelDefinitionBuilder As(object expression);
+ IOutputDataModelDefinitionBuilder As(OneOf expression);
///
/// Builds the configured
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ISchemaDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ISchemaDefinitionBuilder.cs
index bacc732..9c3ed35 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ISchemaDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ISchemaDefinitionBuilder.cs
@@ -38,7 +38,7 @@ public interface ISchemaDefinitionBuilder
///
/// The schema document
/// The configured
- ISchemaDefinitionBuilder WithDocument(object document);
+ ISchemaDefinitionBuilder WithDocument(JsonObject document);
///
/// Builds the configured
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ISetTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ISetTaskDefinitionBuilder.cs
index 50f2d6a..e517dbd 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ISetTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/ISetTaskDefinitionBuilder.cs
@@ -26,13 +26,13 @@ public interface ISetTaskDefinitionBuilder
/// The name of the variable to set
/// The value of the variable to set. Supports runtime expressions
/// The configured
- ISetTaskDefinitionBuilder Set(string name, object value);
+ ISetTaskDefinitionBuilder Set(string name, JsonNode value);
///
/// Configures the task to set the specified variable
///
/// A name/value mapping of the variables to set
/// The configured
- ISetTaskDefinitionBuilder Set(IDictionary variables);
+ ISetTaskDefinitionBuilder Set(JsonObject variables);
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IWorkflowProcessDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IWorkflowProcessDefinitionBuilder.cs
index f17c60b..b5032c6 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IWorkflowProcessDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Interfaces/IWorkflowProcessDefinitionBuilder.cs
@@ -11,8 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using ServerlessWorkflow.Sdk.Models.Processes;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
@@ -48,6 +46,6 @@ public interface IWorkflowProcessDefinitionBuilder
///
/// The input of the workflow to run. Supports runtime expressions
/// The configured
- IWorkflowProcessDefinitionBuilder WithInput(object input);
+ IWorkflowProcessDefinitionBuilder WithInput(JsonObject input);
}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Builders/JitterDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/JitterDefinitionBuilder.cs
index ee294d4..4a182ff 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/JitterDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/JitterDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,47 +16,38 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-/// The minimum duration of the jitter range
-/// The maximum duration of the jitter range
-public class JitterDefinitionBuilder(Duration? from = null, Duration? to = null)
+public sealed class JitterDefinitionBuilder(Duration? from = null, Duration? to = null)
: IJitterDefinitionBuilder
{
- ///
- /// Gets the minimum duration of the jitter range
- ///
- protected Duration? JitterFrom { get; set; } = from;
-
- ///
- /// Gets the maximum duration of the jitter range
- ///
- protected Duration? JitterTo { get; set; } = to;
+ Duration? jitterFrom = from;
+ Duration? jitterTo = to;
///
- public virtual IJitterDefinitionBuilder From(Duration from)
+ public IJitterDefinitionBuilder From(Duration from)
{
ArgumentNullException.ThrowIfNull(from);
- this.JitterFrom = from;
+ jitterFrom = from;
return this;
}
///
- public virtual IJitterDefinitionBuilder To(Duration to)
+ public IJitterDefinitionBuilder To(Duration to)
{
ArgumentNullException.ThrowIfNull(to);
- this.JitterTo = to;
+ jitterTo = to;
return this;
}
///
- public virtual JitterDefinition Build()
+ public JitterDefinition Build()
{
- if (this.JitterFrom == null) throw new NullReferenceException("The jitter range's minimum duration must be set");
- if (this.JitterTo == null) throw new NullReferenceException("The jitter range's maximum duration must be set");
+ if (jitterFrom == null) throw new NullReferenceException("The jitter range's minimum duration must be set");
+ if (jitterTo == null) throw new NullReferenceException("The jitter range's maximum duration must be set");
return new()
{
- From = this.JitterFrom,
- To = this.JitterTo,
+ From = jitterFrom,
+ To = jitterTo,
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/LinearBackoffDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/LinearBackoffDefinitionBuilder.cs
index 36f8f7a..15e9516 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/LinearBackoffDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/LinearBackoffDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,30 +16,26 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-/// The linear incrementation to the delay between retry attempts
-public class LinearBackoffDefinitionBuilder(Duration? increment = null)
+public sealed class LinearBackoffDefinitionBuilder(Duration? increment = null)
: ILinearBackoffDefinitionBuilder
{
- ///
- /// Gets/sets the linear incrementation to the delay between retry attempts
- ///
- protected Duration? LinearIncrement { get; set; } = increment;
+ Duration? linearIncrement = increment;
///
- public virtual ILinearBackoffDefinitionBuilder WithIncrement(Duration increment)
+ public ILinearBackoffDefinitionBuilder WithIncrement(Duration increment)
{
ArgumentNullException.ThrowIfNull(increment);
- this.LinearIncrement = increment;
+ linearIncrement = increment;
return this;
}
///
- public virtual LinearBackoffDefinition Build() => new()
+ public LinearBackoffDefinition Build() => new()
{
- Increment = this.LinearIncrement
+ Increment = linearIncrement
};
- BackoffDefinition IBackoffDefinitionBuilder.Build() => this.Build();
+ BackoffDefinition IBackoffDefinitionBuilder.Build() => Build();
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ListenTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ListenTaskDefinitionBuilder.cs
index 3893e1f..2dc1917 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ListenTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ListenTaskDefinitionBuilder.cs
@@ -16,36 +16,42 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ListenTaskDefinitionBuilder
+public sealed class ListenTaskDefinitionBuilder
: TaskDefinitionBuilder, IListenTaskDefinitionBuilder
{
- ///
- /// Gets/sets the to configure
- ///
- protected ListenTaskDefinition Task { get; } = new() { Listen = null! };
+ ListenTaskDefinition task = new()
+ {
+ Listen = null!
+ };
///
- public virtual IListenTaskDefinitionBuilder To(Action setup)
+ public IListenTaskDefinitionBuilder To(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new ListenerDefinitionBuilder();
setup(builder);
- this.Task.Listen = builder.Build();
+ task = task with
+ {
+ Listen = builder.Build()
+ };
return this;
}
///
- public virtual IListenTaskDefinitionBuilder Foreach(Action setup)
+ public IListenTaskDefinitionBuilder Foreach(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new SubscriptionIteratorDefinitionBuilder();
setup(builder);
- this.Task.Foreach = builder.Build();
+ task = task with
+ {
+ Foreach = builder.Build()
+ };
return this;
}
///
- public override ListenTaskDefinition Build() => this.Configure(this.Task);
+ public override ListenTaskDefinition Build() => Configure(task);
}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ListenerDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ListenerDefinitionBuilder.cs
index ebffd54..e74c0c2 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ListenerDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ListenerDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,30 +16,37 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-/// The listener's target
-public class ListenerDefinitionBuilder(EventConsumptionStrategyDefinition? to = null)
+public sealed class ListenerDefinitionBuilder(EventConsumptionStrategyDefinition? to = null)
: ListenerTargetDefinitionBuilder, IListenerDefinitionBuilder
{
///
- /// Gets/sets the to configure
+ /// Gets/sets the initial target value
///
- protected ListenerDefinition Listener { get; } = new() { To = to! };
+ readonly EventConsumptionStrategyDefinition? initialTo = to;
+
+ ///
+ /// Gets/sets the read mode
+ ///
+ string? readMode;
///
- public virtual IListenerDefinitionBuilder Read(string readMode)
+ public IListenerDefinitionBuilder Read(string readMode)
{
ArgumentException.ThrowIfNullOrWhiteSpace(readMode);
- this.Listener.Read = readMode;
- return this;
+ this.readMode = readMode;
+ IListenerDefinitionBuilder self = this; return self;
}
///
- public virtual new ListenerDefinition Build()
+ public new ListenerDefinition Build()
{
- var to = base.Build() ?? throw new NullReferenceException("The listener's target must be set");
- this.Listener.To = to;
- return this.Listener;
+ var target = initialTo ?? base.Build() ?? throw new NullReferenceException("The listener's target must be set");
+ return new()
+ {
+ To = target,
+ Read = readMode
+ };
}
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ListenerTargetDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ListenerTargetDefinitionBuilder.cs
index 6e85dfe..5881d0b 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ListenerTargetDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ListenerTargetDefinitionBuilder.cs
@@ -20,81 +20,64 @@ public class ListenerTargetDefinitionBuilder
: IListenerTargetDefinitionBuilder
{
- ///
- /// Gets/sets a list containing all the events that must be listened to, if any
- ///
- protected IEventFilterDefinitionCollectionBuilder? AllEvents { get; set; }
-
- ///
- /// Gets/sets a list containing any of the events to listen to, if any
- ///
- protected IEventFilterDefinitionCollectionBuilder? AnyEvents { get; set; }
-
- ///
- /// Gets/sets the single event to listen to
- ///
- protected IEventFilterDefinitionBuilder? SingleEvent { get; set; }
-
- ///
- /// Gets the runtime expression that represents the condition that must match for the task to stop consuming events
- ///
- protected string? UntilExpression { get; private set; }
-
- ///
- /// Gets the strategy used to configure the events to consume for the task to stop consuming events
- ///
- protected EventConsumptionStrategyDefinition? UntilEvents { get; private set; }
+ IEventFilterDefinitionCollectionBuilder? allEvents;
+ IEventFilterDefinitionCollectionBuilder? anyEvents;
+ IEventFilterDefinitionBuilder? singleEvent;
+ string? untilExpression;
+ EventConsumptionStrategyDefinition? untilEvents;
///
- public virtual IEventFilterDefinitionCollectionBuilder All()
+ public IEventFilterDefinitionCollectionBuilder All()
{
- this.AllEvents = new EventFilterDefinitionCollectionBuilder();
- return this.AllEvents;
+ allEvents = new EventFilterDefinitionCollectionBuilder();
+ return allEvents;
}
///
- public virtual IEventFilterDefinitionCollectionBuilder Any()
+ public IEventFilterDefinitionCollectionBuilder Any()
{
- this.AnyEvents = new EventFilterDefinitionCollectionBuilder();
- return this.AnyEvents;
+ anyEvents = new EventFilterDefinitionCollectionBuilder();
+ return anyEvents;
}
///
- public virtual IEventFilterDefinitionBuilder One()
+ public IEventFilterDefinitionBuilder One()
{
- this.SingleEvent = new EventFilterDefinitionBuilder();
- return this.SingleEvent;
+ singleEvent = new EventFilterDefinitionBuilder();
+ return singleEvent;
}
///
- public virtual void Until(string expression)
+ public void Until(string expression)
{
ArgumentException.ThrowIfNullOrWhiteSpace(expression);
- if (this.AnyEvents == null) throw new Exception("The until clause can only be specified when the strategy is used to consume any events");
- this.UntilExpression = expression;
+ if (anyEvents == null) throw new Exception("The until clause can only be specified when the strategy is used to consume any events");
+ untilExpression = expression;
}
///
- public virtual void Until(Action setup)
+ public void Until(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
- if (this.AnyEvents == null) throw new Exception("The until clause can only be specified when the strategy is used to consume any events");
+ if (anyEvents == null) throw new Exception("The until clause can only be specified when the strategy is used to consume any events");
var builder = new ListenerTargetDefinitionBuilder();
setup(builder);
- this.UntilEvents = builder.Build();
+ untilEvents = builder.Build();
}
///
- public virtual EventConsumptionStrategyDefinition Build()
+ public EventConsumptionStrategyDefinition Build()
{
- if (this.AllEvents == null && this.AnyEvents == null && this.SingleEvent == null) throw new NullReferenceException("The target must be defined");
+ if (allEvents == null && anyEvents == null && singleEvent == null) throw new NullReferenceException("The target must be defined");
+ OneOf? until = null;
+ if (untilExpression != null) until = untilExpression;
+ else if (untilEvents != null) until = untilEvents;
return new()
{
- All = this.AllEvents?.Build(),
- Any = this.AnyEvents?.Build(),
- One = this.SingleEvent?.Build(),
- UntilExpression = this.UntilExpression,
- Until = this.UntilEvents
+ All = allEvents?.Build(),
+ Any = anyEvents?.Build(),
+ One = singleEvent?.Build(),
+ Until = until
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationClientDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationClientDefinitionBuilder.cs
index 41e5ba2..829cc04 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationClientDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationClientDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,72 +16,54 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class OAuth2AuthenticationClientDefinitionBuilder
+public sealed class OAuth2AuthenticationClientDefinitionBuilder
: IOAuth2AuthenticationClientDefinitionBuilder
{
- ///
- /// Gets/sets the OAUTH2 `client_id` to use
- ///
- protected string? Id { get; set; }
-
- ///
- /// Gets/sets the OAUTH2 `client_secret` to use, if any
- ///
- protected string? Secret { get; set; }
-
- ///
- /// Gets/sets a JWT containing a signed assertion with the application credentials
- ///
- protected string? Assertion { get; set; }
-
- ///
- /// Gets/sets the authentication method to use to authenticate the client
- ///
- protected string? Authentication { get; set; }
+ string? id;
+ string? secret;
+ string? assertion;
+ string? authentication;
///
- public virtual IOAuth2AuthenticationClientDefinitionBuilder WithId(string id)
+ public IOAuth2AuthenticationClientDefinitionBuilder WithId(string id)
{
ArgumentException.ThrowIfNullOrWhiteSpace(id);
- this.Id = id;
+ this.id = id;
return this;
}
///
- public virtual IOAuth2AuthenticationClientDefinitionBuilder WithSecret(string secret)
+ public IOAuth2AuthenticationClientDefinitionBuilder WithSecret(string secret)
{
ArgumentException.ThrowIfNullOrWhiteSpace(secret);
- this.Secret = secret;
+ this.secret = secret;
return this;
}
///
- public virtual IOAuth2AuthenticationClientDefinitionBuilder WithAssertion(string assertion)
+ public IOAuth2AuthenticationClientDefinitionBuilder WithAssertion(string assertion)
{
ArgumentException.ThrowIfNullOrWhiteSpace(assertion);
- this.Assertion = assertion;
+ this.assertion = assertion;
return this;
}
///
- public virtual IOAuth2AuthenticationClientDefinitionBuilder WithAuthenticationMethod(string method)
+ public IOAuth2AuthenticationClientDefinitionBuilder WithAuthenticationMethod(string method)
{
ArgumentException.ThrowIfNullOrWhiteSpace(method);
- this.Authentication = method;
+ authentication = method;
return this;
}
///
- public virtual OAuth2AuthenticationClientDefinition Build()
+ public OAuth2AuthenticationClientDefinition Build() => new()
{
- return new()
- {
- Id = this.Id,
- Secret = this.Secret,
- Assertion = this.Assertion,
- Authentication = this.Authentication
- };
- }
+ Id = id,
+ Secret = secret,
+ Assertion = assertion,
+ Authentication = authentication
+ };
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationEndpointsDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationEndpointsDefinitionBuilder.cs
index 514886f..bf06c9c 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationEndpointsDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationEndpointsDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,64 +16,53 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class OAuth2AuthenticationEndpointsDefinitionBuilder
+public sealed class OAuth2AuthenticationEndpointsDefinitionBuilder
: IOAuth2AuthenticationEndpointsDefinitionBuilder
{
- ///
- /// Gets/sets the relative path to the token endpoint. Defaults to `/oauth2/token`
- ///
- protected Uri Token { get; set; } = new("/oauth2/token");
-
- ///
- /// Gets/sets the relative path to the revocation endpoint. Defaults to `/oauth2/revoke`
- ///
- protected Uri Revocation { get; set; } = new("/oauth2/revoke");
-
- ///
- /// Gets/sets the relative path to the introspection endpoint. Defaults to `/oauth2/introspect`
- ///
- protected Uri Introspection { get; set; } = new("/oauth2/introspect");
+ Uri token = new("/oauth2/token", UriKind.Relative);
+ Uri revocation = new("/oauth2/revoke", UriKind.Relative);
+ Uri introspection = new("/oauth2/introspect", UriKind.Relative);
///
- public virtual IOAuth2AuthenticationEndpointsDefinitionBuilder WithTokenEndpoint(Uri uri)
+ public IOAuth2AuthenticationEndpointsDefinitionBuilder WithTokenEndpoint(Uri uri)
{
ArgumentNullException.ThrowIfNull(uri);
if (uri.IsAbsoluteUri) throw new ArgumentException("The specified uri must be relative to the configured authority", nameof(uri));
- this.Token = uri;
- return this;
+ token = uri;
+ IOAuth2AuthenticationEndpointsDefinitionBuilder self = this; return self;
}
///
- public virtual IOAuth2AuthenticationEndpointsDefinitionBuilder WithRevocationEndpoint(Uri uri)
+ public IOAuth2AuthenticationEndpointsDefinitionBuilder WithRevocationEndpoint(Uri uri)
{
ArgumentNullException.ThrowIfNull(uri);
if (uri.IsAbsoluteUri) throw new ArgumentException("The specified uri must be relative to the configured authority", nameof(uri));
- this.Revocation = uri;
- return this;
+ revocation = uri;
+ IOAuth2AuthenticationEndpointsDefinitionBuilder self = this; return self;
}
///
- public virtual IOAuth2AuthenticationEndpointsDefinitionBuilder WithIntrospectionEndpoint(Uri uri)
+ public IOAuth2AuthenticationEndpointsDefinitionBuilder WithIntrospectionEndpoint(Uri uri)
{
ArgumentNullException.ThrowIfNull(uri);
if (uri.IsAbsoluteUri) throw new ArgumentException("The specified uri must be relative to the configured authority", nameof(uri));
- this.Introspection = uri;
- return this;
+ introspection = uri;
+ IOAuth2AuthenticationEndpointsDefinitionBuilder self = this; return self;
}
///
- public virtual OAuth2AuthenticationEndpointsDefinition Build()
+ public OAuth2AuthenticationEndpointsDefinition Build()
{
- if (this.Token == null) throw new NullReferenceException("The token endpoint must be configured");
- if (this.Revocation == null) throw new NullReferenceException("The revocation endpoint must be configured");
- if (this.Introspection == null) throw new NullReferenceException("The introspection endpoint must be configured");
+ if (token == null) throw new NullReferenceException("The token endpoint must be configured");
+ if (revocation == null) throw new NullReferenceException("The revocation endpoint must be configured");
+ if (introspection == null) throw new NullReferenceException("The introspection endpoint must be configured");
return new()
{
- Token = this.Token,
- Revocation = this.Revocation,
- Introspection = this.Introspection
+ Token = token,
+ Revocation = revocation,
+ Introspection = introspection
};
}
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationRequestDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationRequestDefinitionBuilder.cs
index d40a653..dd32aa0 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationRequestDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationRequestDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,28 +16,28 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class OAuth2AuthenticationRequestDefinitionBuilder
+public sealed class OAuth2AuthenticationRequestDefinitionBuilder
: IOAuth2AuthenticationRequestDefinitionBuilder
{
- ///
- /// Gets/sets the encoding of the authentication request. Defaults to 'application/x-www-form-urlencoded'
- ///
- public virtual string? Encoding { get; set; }
+ string? encoding;
///
- public virtual IOAuth2AuthenticationRequestDefinitionBuilder WithEncoding(string encoding)
+ public IOAuth2AuthenticationRequestDefinitionBuilder WithEncoding(string encoding)
{
ArgumentException.ThrowIfNullOrWhiteSpace(encoding);
- this.Encoding = encoding;
+ this.encoding = encoding;
return this;
}
///
- public virtual OAuth2AuthenticationRequestDefinition Build()
+ public OAuth2AuthenticationRequestDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Encoding)) throw new NullReferenceException("The request encoding must be set");
- return new() { Encoding = this.Encoding };
+ if (string.IsNullOrWhiteSpace(encoding)) throw new NullReferenceException("The request encoding must be set");
+ return new()
+ {
+ Encoding = encoding
+ };
}
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationSchemeDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationSchemeDefinitionBuilder.cs
index ac0ebfc..14eee41 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationSchemeDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/OAuth2AuthenticationSchemeDefinitionBuilder.cs
@@ -11,8 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
@@ -84,7 +82,7 @@ public abstract class OAuth2AuthenticationSchemeDefinitionBuilder
public virtual TBuilder WithScopes(params string[] scopes)
{
- this.Scopes = new(scopes);
+ Scopes = new(scopes);
return (TBuilder)(object)this;
}
@@ -159,32 +157,32 @@ public virtual TBuilder WithScopes(params string[] scopes)
public virtual TBuilder WithActor(OAuth2TokenDefinition actor)
{
ArgumentNullException.ThrowIfNull(actor);
- this.Actor = actor;
+ Actor = actor;
return (TBuilder)(object)this;
}
///
public virtual TBuilder WithUsername(string username)
{
- this.Username = username;
+ Username = username;
return (TBuilder)(object)this;
}
///
public virtual TBuilder WithPassword(string password)
{
- this.Password = password;
+ Password = password;
return (TBuilder)(object)this;
}
///
public virtual TBuilder WithSubject(OAuth2TokenDefinition subject)
{
- this.Subject = subject;
+ Subject = subject;
return (TBuilder)(object)this;
}
- AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => this.Build();
+ AuthenticationSchemeDefinition IAuthenticationSchemeDefinitionBuilder.Build() => Build();
}
@@ -204,7 +202,7 @@ public class OAuth2AuthenticationSchemeDefinitionBuilder
public virtual IOAuth2AuthenticationSchemeDefinitionBuilder WithEndpoints(OAuth2AuthenticationEndpointsDefinition endpoints)
{
ArgumentNullException.ThrowIfNull(endpoints);
- this.Endpoints = endpoints;
+ Endpoints = endpoints;
return this;
}
@@ -214,30 +212,30 @@ public virtual IOAuth2AuthenticationSchemeDefinitionBuilder WithEndpoints(Action
ArgumentNullException.ThrowIfNull(setup);
var builder = new OAuth2AuthenticationEndpointsDefinitionBuilder();
setup(builder);
- this.Endpoints = builder.Build();
+ Endpoints = builder.Build();
return this;
}
///
public override OAuth2AuthenticationSchemeDefinition Build()
{
- if (this.Authority == null) throw new NullReferenceException("The authority must be set");
- if (string.IsNullOrWhiteSpace(this.GrantType)) throw new NullReferenceException("The grant type must be set");
+ if (Authority == null) throw new NullReferenceException("The authority must be set");
+ if (string.IsNullOrWhiteSpace(GrantType)) throw new NullReferenceException("The grant type must be set");
return new()
{
- Use = this.Secret,
- Authority = this.Authority,
- Endpoints = this.Endpoints,
- Grant = this.GrantType,
- Client = this.Client,
- Request = this.Request,
- Issuers = this.Issuers,
- Audiences = this.Audiences,
- Scopes = this.Scopes,
- Actor = this.Actor,
- Username = this.Username,
- Password = this.Password,
- Subject = this.Subject
+ Use = Secret,
+ Authority = Authority,
+ Endpoints = Endpoints,
+ Grant = GrantType,
+ Client = Client,
+ Request = Request,
+ Issuers = Issuers,
+ Audiences = Audiences,
+ Scopes = Scopes,
+ Actor = Actor,
+ Username = Username,
+ Password = Password,
+ Subject = Subject
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/OpenIDConnectAuthenticationSchemeDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/OpenIDConnectAuthenticationSchemeDefinitionBuilder.cs
index 3674d70..396f9dc 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/OpenIDConnectAuthenticationSchemeDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/OpenIDConnectAuthenticationSchemeDefinitionBuilder.cs
@@ -16,29 +16,29 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class OpenIDConnectAuthenticationSchemeDefinitionBuilder
+public sealed class OpenIDConnectAuthenticationSchemeDefinitionBuilder
: OAuth2AuthenticationSchemeDefinitionBuilder, IOpenIDConnectAuthenticationSchemeDefinitionBuilder
{
///
public override OpenIDConnectSchemeDefinition Build()
{
- if (this.Authority == null) throw new NullReferenceException("The authority must be set");
- if (string.IsNullOrWhiteSpace(this.GrantType)) throw new NullReferenceException("The grant type must be set");
+ if (Authority == null) throw new NullReferenceException("The authority must be set");
+ if (string.IsNullOrWhiteSpace(GrantType)) throw new NullReferenceException("The grant type must be set");
return new()
{
- Use = this.Secret,
- Authority = this.Authority,
- Grant = this.GrantType,
- Client = this.Client,
- Request = this.Request,
- Issuers = this.Issuers,
- Audiences = this.Audiences,
- Scopes = this.Scopes,
- Actor = this.Actor,
- Username = this.Username,
- Password = this.Password,
- Subject = this.Subject
+ Use = Secret,
+ Authority = Authority,
+ Grant = GrantType,
+ Client = Client,
+ Request = Request,
+ Issuers = Issuers,
+ Audiences = Audiences,
+ Scopes = Scopes,
+ Actor = Actor,
+ Username = Username,
+ Password = Password,
+ Subject = Subject
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/OutputDataModelDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/OutputDataModelDefinitionBuilder.cs
index 0e39803..51a14cd 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/OutputDataModelDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/OutputDataModelDefinitionBuilder.cs
@@ -16,34 +16,37 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class OutputDataModelDefinitionBuilder
+public sealed class OutputDataModelDefinitionBuilder
: IOutputDataModelDefinitionBuilder
{
- ///
- /// Gets the to configure
- ///
- protected OutputDataModelDefinition Output { get; } = new();
+ OutputDataModelDefinition output = new();
///
- public virtual IOutputDataModelDefinitionBuilder As(object expression)
+ public IOutputDataModelDefinitionBuilder As(OneOf expression)
{
ArgumentNullException.ThrowIfNull(expression);
- this.Output.As = expression;
+ output = output with
+ {
+ As = expression
+ };
return this;
}
///
- public virtual IOutputDataModelDefinitionBuilder WithSchema(Action setup)
+ public IOutputDataModelDefinitionBuilder WithSchema(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new SchemaDefinitionBuilder();
setup(builder);
- this.Output.Schema = builder.Build();
+ output = output with
+ {
+ Schema = builder.Build()
+ };
return this;
}
///
- public virtual OutputDataModelDefinition Build() => this.Output;
+ public OutputDataModelDefinition Build() => output;
}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ProcessDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ProcessDefinitionBuilder.cs
index 0fa8ae6..e699e06 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ProcessDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ProcessDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -25,5 +25,6 @@ public abstract class ProcessDefinitionBuilder
///
public abstract TDefinition Build();
- ProcessDefinition IProcessDefinitionBuilder.Build() => this.Build();
-}
\ No newline at end of file
+ ProcessDefinition IProcessDefinitionBuilder.Build() => Build();
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/RaiseTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/RaiseTaskDefinitionBuilder.cs
index 48e7c39..3766924 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/RaiseTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/RaiseTaskDefinitionBuilder.cs
@@ -17,41 +17,38 @@ namespace ServerlessWorkflow.Sdk.Builders;
/// Represents the default implementation of the interface
///
/// The error to raise
-public class RaiseTaskDefinitionBuilder(ErrorDefinition? errorDefinition = null)
+public sealed class RaiseTaskDefinitionBuilder(ErrorDefinition? errorDefinition = null)
: TaskDefinitionBuilder, IRaiseTaskDefinitionBuilder
{
- ///
- /// Gets/sets the error to raise
- ///
- protected ErrorDefinition? ErrorDefinition { get; set; } = errorDefinition;
+ ErrorDefinition? errorDefinition = errorDefinition;
///
- public virtual IRaiseTaskDefinitionBuilder Error(ErrorDefinition error)
+ public IRaiseTaskDefinitionBuilder Error(ErrorDefinition error)
{
ArgumentNullException.ThrowIfNull(error);
- this.ErrorDefinition = error;
+ errorDefinition = error;
return this;
}
///
- public virtual IRaiseTaskDefinitionBuilder Error(Action setup)
+ public IRaiseTaskDefinitionBuilder Error(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new ErrorDefinitionBuilder();
setup(builder);
- return this.Error(builder.Build());
+ return Error(builder.Build());
}
///
public override RaiseTaskDefinition Build()
{
- if (this.ErrorDefinition == null) throw new NullReferenceException("The error to raise must be set");
- return this.Configure(new()
+ if (errorDefinition == null) throw new NullReferenceException("The error to raise must be set");
+ return Configure(new()
{
Raise = new()
{
- Error = this.ErrorDefinition
+ Error = errorDefinition
}
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/RetryAttemptLimitDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/RetryAttemptLimitDefinitionBuilder.cs
index 3d20f28..6d91477 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/RetryAttemptLimitDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/RetryAttemptLimitDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -14,41 +14,34 @@
namespace ServerlessWorkflow.Sdk.Builders;
///
-/// Represents the default implementation
+/// Represents the default implementation of the interface
///
-public class RetryAttemptLimitDefinitionBuilder
+public sealed class RetryAttemptLimitDefinitionBuilder
: IRetryAttemptLimitDefinitionBuilder
{
- ///
- /// Gets/sets the maximum attempts count
- ///
- protected uint? AttemptCount { get; set; }
-
- ///
- /// Gets/sets the duration limit, if any, for all retry attempts
- ///
- protected Duration? AttemptDuration { get; set; }
+ uint? attemptCount;
+ Duration? attemptDuration;
///
- public virtual IRetryAttemptLimitDefinitionBuilder Count(uint count)
+ public IRetryAttemptLimitDefinitionBuilder Count(uint count)
{
- this.AttemptCount = count;
+ attemptCount = count;
return this;
}
///
- public virtual IRetryAttemptLimitDefinitionBuilder Duration(Duration duration)
+ public IRetryAttemptLimitDefinitionBuilder Duration(Duration duration)
{
- this.AttemptDuration = duration;
+ attemptDuration = duration;
return this;
}
///
- public virtual RetryAttemptLimitDefinition Build() => new()
+ public RetryAttemptLimitDefinition Build() => new()
{
- Count = AttemptCount,
- Duration = AttemptDuration
+ Count = attemptCount,
+ Duration = attemptDuration
};
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/RetryPolicyDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/RetryPolicyDefinitionBuilder.cs
index c8adb67..a11a7ee 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/RetryPolicyDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/RetryPolicyDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,118 +16,95 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class RetryPolicyDefinitionBuilder
+public sealed class RetryPolicyDefinitionBuilder
: IRetryPolicyDefinitionBuilder
{
- ///
- /// Gets/sets a runtime expression used to determine whether or not to retry running the task, in a given context
- ///
- protected string? RetryWhen { get; set; }
-
- ///
- /// Gets/sets a runtime expression used to determine whether or not to retry running the task, in a given context
- ///
- protected string? RetryExceptWhen { get; set; }
-
- ///
- /// Gets/sets the parameters, if any, that control the randomness or variability of the delay between retry attempts
- ///
- protected RetryPolicyLimitDefinition? RetryLimit { get; set; }
-
- ///
- /// Gets/sets the delay duration between retry attempts
- ///
- protected Duration? RetryDelay { get; set; }
-
- ///
- /// Gets/sets the limits, if any, of the retry policy to build
- ///
- protected BackoffStrategyDefinition? RetryBackoff { get; set; }
-
- ///
- /// Gets/sets the backoff strategy to use, if any
- ///
- protected JitterDefinition? RetryJitter { get; set; }
+ string? retryWhen;
+ string? retryExceptWhen;
+ RetryPolicyLimitDefinition? retryLimit;
+ Duration? retryDelay;
+ BackoffStrategyDefinition? retryBackoff;
+ JitterDefinition? retryJitter;
///
- public virtual IRetryPolicyDefinitionBuilder When(string expression)
+ public IRetryPolicyDefinitionBuilder When(string expression)
{
- this.RetryWhen = expression;
+ retryWhen = expression;
return this;
}
///
- public virtual IRetryPolicyDefinitionBuilder ExceptWhen(string expression)
+ public IRetryPolicyDefinitionBuilder ExceptWhen(string expression)
{
- this.RetryExceptWhen = expression;
+ retryExceptWhen = expression;
return this;
}
///
- public virtual IRetryPolicyDefinitionBuilder Limit(RetryPolicyLimitDefinition limits)
+ public IRetryPolicyDefinitionBuilder Limit(RetryPolicyLimitDefinition limits)
{
- this.RetryLimit = limits;
+ retryLimit = limits;
return this;
}
///
- public virtual IRetryPolicyDefinitionBuilder Limit(Action setup)
+ public IRetryPolicyDefinitionBuilder Limit(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new RetryPolicyLimitDefinitionBuilder();
setup(builder);
- return this.Limit(builder.Build());
+ return Limit(builder.Build());
}
///
- public virtual IRetryPolicyDefinitionBuilder Delay(Duration duration)
+ public IRetryPolicyDefinitionBuilder Delay(Duration duration)
{
- this.RetryDelay = duration;
+ retryDelay = duration;
return this;
}
///
- public virtual IRetryPolicyDefinitionBuilder Backoff(BackoffStrategyDefinition backoff)
+ public IRetryPolicyDefinitionBuilder Backoff(BackoffStrategyDefinition backoff)
{
- this.RetryBackoff = backoff;
+ retryBackoff = backoff;
return this;
}
///
- public virtual IRetryPolicyDefinitionBuilder Backoff(Action setup)
+ public IRetryPolicyDefinitionBuilder Backoff(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new BackoffStrategyDefinitionBuilder();
setup(builder);
- return this.Backoff(builder.Build());
+ return Backoff(builder.Build());
}
///
- public virtual IRetryPolicyDefinitionBuilder Jitter(JitterDefinition jitter)
+ public IRetryPolicyDefinitionBuilder Jitter(JitterDefinition jitter)
{
- this.RetryJitter = jitter;
+ retryJitter = jitter;
return this;
}
///
- public virtual IRetryPolicyDefinitionBuilder Jitter(Action setup)
+ public IRetryPolicyDefinitionBuilder Jitter(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new JitterDefinitionBuilder();
setup(builder);
- return this.Jitter(builder.Build());
+ return Jitter(builder.Build());
}
///
- public virtual RetryPolicyDefinition Build() => new()
+ public RetryPolicyDefinition Build() => new()
{
- When = this.RetryWhen,
- ExceptWhen = this.RetryExceptWhen,
- Limit = this.RetryLimit,
- Delay = this.RetryDelay,
- Backoff = this.RetryBackoff,
- Jitter = this.RetryJitter
+ When = retryWhen,
+ ExceptWhen = retryExceptWhen,
+ Limit = retryLimit,
+ Delay = retryDelay,
+ Backoff = retryBackoff,
+ Jitter = retryJitter
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/RetryPolicyLimitDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/RetryPolicyLimitDefinitionBuilder.cs
index 4f0a83a..2b18ccb 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/RetryPolicyLimitDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/RetryPolicyLimitDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,39 +16,32 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class RetryPolicyLimitDefinitionBuilder
+public sealed class RetryPolicyLimitDefinitionBuilder
: IRetryPolicyLimitDefinitionBuilder
{
- ///
- /// Gets the service used to build the definition of the limits for all retry attempts of a given policy
- ///
- protected IRetryAttemptLimitDefinitionBuilder? LimitAttempt { get; set; }
-
- ///
- /// Gets the maximum duration during which retrying is allowed
- ///
- protected Duration? LimitDuration { get; set; }
+ RetryAttemptLimitDefinitionBuilder? limitAttempt;
+ Duration? limitDuration;
///
- public virtual IRetryAttemptLimitDefinitionBuilder Attempt()
+ public IRetryAttemptLimitDefinitionBuilder Attempt()
{
- this.LimitAttempt = new RetryAttemptLimitDefinitionBuilder();
- return this.LimitAttempt;
+ limitAttempt = new RetryAttemptLimitDefinitionBuilder();
+ return limitAttempt;
}
///
- public virtual IRetryPolicyLimitDefinitionBuilder Duration(Duration duration)
+ public IRetryPolicyLimitDefinitionBuilder Duration(Duration duration)
{
- this.LimitDuration = duration;
+ limitDuration = duration;
return this;
}
///
- public virtual RetryPolicyLimitDefinition Build() => new()
+ public RetryPolicyLimitDefinition Build() => new()
{
- Attempt = this.LimitAttempt?.Build(),
- Duration = this.LimitDuration,
+ Attempt = limitAttempt?.Build(),
+ Duration = limitDuration,
};
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/RunTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/RunTaskDefinitionBuilder.cs
index 9fa1b73..ba0973c 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/RunTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/RunTaskDefinitionBuilder.cs
@@ -11,72 +11,63 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using ServerlessWorkflow.Sdk.Models.Processes;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class RunTaskDefinitionBuilder
+public sealed class RunTaskDefinitionBuilder
: TaskDefinitionBuilder, IRunTaskDefinitionBuilder
{
- ///
- /// Gets/sets a boolean indicating whether or not the task to build should await the execution of the defined process
- ///
- protected bool? AwaitProcess { get; set; }
-
- ///
- /// Gets/sets the process to run
- ///
- protected IProcessDefinitionBuilder? ProcessBuilder { get; set; }
+ bool? awaitProcess;
+ IProcessDefinitionBuilder? processBuilder;
///
- public virtual IContainerProcessDefinitionBuilder Container()
+ public IContainerProcessDefinitionBuilder Container()
{
var builder = new ContainerProcessDefinitionBuilder();
- this.ProcessBuilder = builder;
+ processBuilder = builder;
return builder;
}
///
- public virtual IScriptProcessDefinitionBuilder Script()
+ public IScriptProcessDefinitionBuilder Script()
{
var builder = new ScriptProcessDefinitionBuilder();
- this.ProcessBuilder = builder;
+ processBuilder = builder;
return builder;
}
///
- public virtual IShellProcessDefinitionBuilder Shell()
+ public IShellProcessDefinitionBuilder Shell()
{
var builder = new ShellProcessDefinitionBuilder();
- this.ProcessBuilder = builder;
+ processBuilder = builder;
return builder;
}
///
- public virtual IWorkflowProcessDefinitionBuilder Workflow()
+ public IWorkflowProcessDefinitionBuilder Workflow()
{
var builder = new WorkflowProcessDefinitionBuilder();
- this.ProcessBuilder = builder;
+ processBuilder = builder;
return builder;
}
///
- public virtual IRunTaskDefinitionBuilder Await(bool await)
+ public IRunTaskDefinitionBuilder Await(bool await)
{
- this.AwaitProcess = await;
+ awaitProcess = await;
return this;
}
///
public override RunTaskDefinition Build()
{
- if (this.ProcessBuilder == null) throw new NullReferenceException("The process to run must be set");
- var process = this.ProcessBuilder.Build();
- return this.Configure(new()
+ if (processBuilder == null) throw new NullReferenceException("The process to run must be set");
+ var process = processBuilder.Build();
+ return Configure(new()
{
Run = new()
{
@@ -84,7 +75,7 @@ public override RunTaskDefinition Build()
Script = process is ScriptProcessDefinition script ? script : null,
Shell = process is ShellProcessDefinition shell ? shell : null,
Workflow = process is WorkflowProcessDefinition workflow ? workflow : null,
- Await = this.AwaitProcess
+ Await = awaitProcess
}
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/SchemaDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/SchemaDefinitionBuilder.cs
index 40e71bc..62be2f5 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/SchemaDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/SchemaDefinitionBuilder.cs
@@ -16,42 +16,48 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class SchemaDefinitionBuilder
+public sealed class SchemaDefinitionBuilder
: ISchemaDefinitionBuilder
{
- ///
- /// Gets the to configure
- ///
- protected SchemaDefinition Schema { get; } = new();
+ SchemaDefinition schema = new();
///
- public virtual ISchemaDefinitionBuilder WithFormat(string format)
+ public ISchemaDefinitionBuilder WithFormat(string format)
{
ArgumentException.ThrowIfNullOrWhiteSpace(format);
- this.Schema.Format = format;
+ schema = schema with
+ {
+ Format = format
+ };
return this;
}
///
- public virtual ISchemaDefinitionBuilder WithResource(Action setup)
+ public ISchemaDefinitionBuilder WithResource(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new ExternalResourceDefinitionBuilder();
setup(builder);
- this.Schema.Resource = builder.Build();
+ schema = schema with
+ {
+ Resource = builder.Build()
+ };
return this;
}
///
- public virtual ISchemaDefinitionBuilder WithDocument(object document)
+ public ISchemaDefinitionBuilder WithDocument(JsonObject document)
{
ArgumentNullException.ThrowIfNull(document);
- this.Schema.Document = document;
+ schema = schema with
+ {
+ Document = document
+ };
return this;
}
///
- public virtual SchemaDefinition Build() => this.Schema;
+ public SchemaDefinition Build() => schema;
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ScriptProcessDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ScriptProcessDefinitionBuilder.cs
index 7db5d67..6e57e96 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ScriptProcessDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ScriptProcessDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -11,131 +11,108 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-using ServerlessWorkflow.Sdk.Models.Processes;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ScriptProcessDefinitionBuilder
+public sealed class ScriptProcessDefinitionBuilder
: ProcessDefinitionBuilder, IScriptProcessDefinitionBuilder
{
- ///
- /// Gets/sets the language of the script to run
- ///
- public virtual string? Language { get; set; }
-
- ///
- /// Gets/sets the script's code
- ///
- public virtual string? Code { get; set; }
-
- ///
- /// Gets/sets the script's source
- ///
- public ExternalResourceDefinition? Source { get; set; }
-
- ///
- /// Gets/sets the uri that references the script's source.
- ///
- public Uri? SourceUri { get; set; }
-
- ///
- /// Gets the arguments, if any, of the command to execute
- ///
- protected virtual EquatableDictionary? Arguments { get; set; }
-
- ///
- /// Gets/sets the environment variables, if any, of the shell command to execute
- ///
- protected virtual EquatableDictionary? Environment { get; set; }
+ string? language;
+ string? code;
+ ExternalResourceDefinition? source;
+ Uri? sourceUri;
+ EquatableDictionary? arguments;
+ EquatableDictionary? environment;
///
- public virtual IScriptProcessDefinitionBuilder WithLanguage(string language)
+ public IScriptProcessDefinitionBuilder WithLanguage(string language)
{
ArgumentException.ThrowIfNullOrWhiteSpace(language);
- this.Language = language;
+ this.language = language;
return this;
}
///
- public virtual IScriptProcessDefinitionBuilder WithCode(string code)
+ public IScriptProcessDefinitionBuilder WithCode(string code)
{
ArgumentException.ThrowIfNullOrWhiteSpace(code);
- this.Code = code;
+ this.code = code;
return this;
}
///
- public virtual IScriptProcessDefinitionBuilder WithSource(Uri source)
+ public IScriptProcessDefinitionBuilder WithSource(Uri source)
{
ArgumentNullException.ThrowIfNull(source);
- this.SourceUri = source;
+ sourceUri = source;
return this;
}
///
- public virtual IScriptProcessDefinitionBuilder WithSource(Action setup)
+ public IScriptProcessDefinitionBuilder WithSource(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new ExternalResourceDefinitionBuilder();
setup(builder);
- this.Source = builder.Build();
+ source = builder.Build();
return this;
}
///
- public virtual IScriptProcessDefinitionBuilder WithArgument(string name, object value)
+ public IScriptProcessDefinitionBuilder WithArgument(string name, object value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Arguments ??= [];
- this.Arguments[name] = value;
+ arguments ??= [];
+ arguments[name] = value;
return this;
}
///
- public virtual IScriptProcessDefinitionBuilder WithArguments(IDictionary arguments)
+ public IScriptProcessDefinitionBuilder WithArguments(IDictionary arguments)
{
ArgumentNullException.ThrowIfNull(arguments);
- this.Arguments = new(arguments);
+ this.arguments = [.. arguments];
return this;
}
///
- public virtual IScriptProcessDefinitionBuilder WithEnvironment(string name, string value)
+ public IScriptProcessDefinitionBuilder WithEnvironment(string name, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Environment ??= [];
- this.Environment[name] = value;
+ environment ??= [];
+ environment[name] = value;
return this;
}
///
- public virtual IScriptProcessDefinitionBuilder WithEnvironment(IDictionary environment)
+ public IScriptProcessDefinitionBuilder WithEnvironment(IDictionary environment)
{
ArgumentNullException.ThrowIfNull(environment);
- this.Environment = new(environment);
+ this.environment = [.. environment];
return this;
}
///
public override ScriptProcessDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Language)) throw new NullReferenceException("The language in which the script to run is expressed must be set");
- if (string.IsNullOrWhiteSpace(this.Code) && this.Source == null && this.SourceUri == null) throw new NullReferenceException("Either the code or the source properties must be set");
- var process = new ScriptProcessDefinition()
+ if (string.IsNullOrWhiteSpace(language)) throw new NullReferenceException("The language in which the script to run is expressed must be set");
+ if (string.IsNullOrWhiteSpace(code) && this.source == null && sourceUri == null) throw new NullReferenceException("Either the code or the source properties must be set");
+ ExternalResourceDefinition? source = this.source;
+ if (source == null && sourceUri != null) source = new()
+ {
+ Endpoint = sourceUri
+ };
+ return new()
{
- Language = this.Language,
- Code = this.Code,
- Arguments = this.Arguments,
- Environment = this.Environment
+ Language = language,
+ Code = code,
+ Source = source,
+ Arguments = arguments,
+ Environment = environment
};
- if (this.Source != null) process.Source = this.Source;
- else if (this.SourceUri != null) process.Source = new() { EndpointUri = this.SourceUri };
- return process;
}
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj b/src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj
index eccdd43..fc61704 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj
+++ b/src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj
@@ -1,10 +1,11 @@
-
+
- net8.0;net9.0
+ net10.0
enable
enable
- 1.0.1
+ true
+ 1.0.2
$(VersionPrefix)
$(VersionPrefix)
en
@@ -16,7 +17,7 @@
serverless-workflow;serverless;workflow;dsl;sdk;builders
true
Apache-2.0
- readme.md
+ README.md
Copyright © 2024-Present The Serverless Workflow Authors. All rights reserved.
https://github.com/serverlessworkflow/sdk-net
https://github.com/serverlessworkflow/sdk-net
@@ -25,14 +26,18 @@
-
- \
- True
-
+
+
+
+ \
+ True
+
+
+
diff --git a/src/ServerlessWorkflow.Sdk.Builders/SetTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/SetTaskDefinitionBuilder.cs
index 6cf8cf6..8affc7e 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/SetTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/SetTaskDefinitionBuilder.cs
@@ -11,43 +11,38 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
/// A name/value mapping of the variables to set
-public class SetTaskDefinitionBuilder(IDictionary? variables = null)
+public sealed class SetTaskDefinitionBuilder(JsonObject? variables = null)
: TaskDefinitionBuilder, ISetTaskDefinitionBuilder
{
- ///
- /// Gets a name/value mapping of the variables to set
- ///
- protected EquatableDictionary Variables { get; set; } = [..variables];
+ JsonObject variables = variables ?? [];
///
- public virtual ISetTaskDefinitionBuilder Set(string name, object value)
+ public ISetTaskDefinitionBuilder Set(string name, JsonNode value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Variables[name] = value;
+ variables[name] = value;
return this;
}
///
- public virtual ISetTaskDefinitionBuilder Set(IDictionary variables)
+ public ISetTaskDefinitionBuilder Set(JsonObject variables)
{
ArgumentNullException.ThrowIfNull(variables);
- this.Variables = new(variables);
+ this.variables = variables;
return this;
}
///
- public override SetTaskDefinition Build() => this.Configure(new()
+ public override SetTaskDefinition Build() => Configure(new()
{
- Set = this.Variables
+ Set = variables
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/ShellProcessDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/ShellProcessDefinitionBuilder.cs
index d0055ca..d23304b 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/ShellProcessDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/ShellProcessDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -11,84 +11,70 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using ServerlessWorkflow.Sdk.Models.Processes;
-using Neuroglia;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class ShellProcessDefinitionBuilder
+public sealed class ShellProcessDefinitionBuilder
: ProcessDefinitionBuilder, IShellProcessDefinitionBuilder
{
- ///
- /// Gets the command to execute
- ///
- protected virtual string? Command { get; set; }
-
- ///
- /// Gets the arguments, if any, of the command to execute
- ///
- protected virtual EquatableList? Arguments { get; set; }
-
- ///
- /// Gets/sets the environment variables, if any, of the shell command to execute
- ///
- protected virtual EquatableDictionary? Environment { get; set; }
+ string? command;
+ EquatableList? arguments;
+ EquatableDictionary? environment;
///
- public virtual IShellProcessDefinitionBuilder WithCommand(string command)
+ public IShellProcessDefinitionBuilder WithCommand(string command)
{
ArgumentException.ThrowIfNullOrWhiteSpace(command);
- this.Command = command;
+ this.command = command;
return this;
}
///
- public virtual IShellProcessDefinitionBuilder WithArgument(string argument)
+ public IShellProcessDefinitionBuilder WithArgument(string argument)
{
ArgumentException.ThrowIfNullOrWhiteSpace(argument);
- this.Arguments ??= [];
- this.Arguments.Add(argument);
+ this.arguments ??= [];
+ this.arguments.Add(argument);
return this;
}
///
- public virtual IShellProcessDefinitionBuilder WithArguments(IEnumerable arguments)
+ public IShellProcessDefinitionBuilder WithArguments(IEnumerable arguments)
{
ArgumentNullException.ThrowIfNull(arguments);
- this.Arguments = new(arguments);
+ this.arguments = [.. arguments];
return this;
}
///
- public virtual IShellProcessDefinitionBuilder WithEnvironment(string name, string value)
+ public IShellProcessDefinitionBuilder WithEnvironment(string name, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Environment ??= [];
- this.Environment[name] = value;
+ this.environment ??= [];
+ this.environment[name] = value;
return this;
}
///
- public virtual IShellProcessDefinitionBuilder WithEnvironment(IDictionary environment)
+ public IShellProcessDefinitionBuilder WithEnvironment(IDictionary environment)
{
ArgumentNullException.ThrowIfNull(environment);
- this.Environment = new(environment);
+ this.environment = [.. environment];
return this;
}
///
public override ShellProcessDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Command)) throw new NullReferenceException("The shell command to execute must be set");
- return new()
- {
- Command = this.Command,
- Arguments = this.Arguments,
- Environment = this.Environment
+ if (string.IsNullOrWhiteSpace(this.command)) throw new NullReferenceException("The shell command to execute must be set");
+ return new()
+ {
+ Command = this.command,
+ Arguments = this.arguments,
+ Environment = this.environment
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/SubscriptionIteratorDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/SubscriptionIteratorDefinitionBuilder.cs
index 40954c9..5c75e86 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/SubscriptionIteratorDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/SubscriptionIteratorDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -16,62 +16,70 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class SubscriptionIteratorDefinitionBuilder
+public sealed class SubscriptionIteratorDefinitionBuilder
: ISubscriptionIteratorDefinitionBuilder
{
- ///
- /// Gets the to configure
- ///
- protected SubscriptionIteratorDefinition Iterator { get; } = new();
+ string? itemValue;
+ string? atValue;
+ Map? doTasks;
+ OutputDataModelDefinition? outputValue;
+ OutputDataModelDefinition? exportValue;
///
- public virtual ISubscriptionIteratorDefinitionBuilder Item(string item)
+ public ISubscriptionIteratorDefinitionBuilder Item(string item)
{
ArgumentException.ThrowIfNullOrWhiteSpace(item);
- this.Iterator.Item = item;
+ itemValue = item;
return this;
}
///
- public virtual ISubscriptionIteratorDefinitionBuilder At(string at)
+ public ISubscriptionIteratorDefinitionBuilder At(string at)
{
ArgumentException.ThrowIfNullOrWhiteSpace(at);
- this.Iterator.At = at;
+ atValue = at;
return this;
}
///
- public virtual ISubscriptionIteratorDefinitionBuilder Do(Action setup)
+ public ISubscriptionIteratorDefinitionBuilder Do(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new TaskDefinitionMapBuilder();
setup(builder);
- this.Iterator.Do = builder.Build();
+ doTasks = builder.Build();
return this;
}
///
- public virtual ISubscriptionIteratorDefinitionBuilder Output(Action setup)
+ public ISubscriptionIteratorDefinitionBuilder Output(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new OutputDataModelDefinitionBuilder();
setup(builder);
- this.Iterator.Output = builder.Build();
+ outputValue = builder.Build();
return this;
}
///
- public virtual ISubscriptionIteratorDefinitionBuilder Export(Action setup)
+ public ISubscriptionIteratorDefinitionBuilder Export(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new OutputDataModelDefinitionBuilder();
setup(builder);
- this.Iterator.Export = builder.Build();
+ exportValue = builder.Build();
return this;
}
///
- public virtual SubscriptionIteratorDefinition Build() => this.Iterator;
+ public SubscriptionIteratorDefinition Build() => new()
+ {
+ Item = itemValue,
+ At = atValue,
+ Do = doTasks,
+ Output = outputValue,
+ Export = exportValue
+ };
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Suppressions.cs b/src/ServerlessWorkflow.Sdk.Builders/Suppressions.cs
new file mode 100644
index 0000000..f8efb47
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Builders/Suppressions.cs
@@ -0,0 +1,8 @@
+// This file is used by Code Analysis to maintain SuppressMessage
+// attributes that are applied to this project.
+// Project-level suppressions either have no target or are given
+// a specific target and scoped to a namespace, type, member, etc.
+
+using System.Diagnostics.CodeAnalysis;
+
+[assembly: SuppressMessage("Style", "IDE0130:Namespace does not match folder structure", Justification = "", Scope = "namespace", Target = "~N:ServerlessWorkflow.Sdk.Builders")]
diff --git a/src/ServerlessWorkflow.Sdk.Builders/SwitchCaseDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/SwitchCaseDefinitionBuilder.cs
index 59ef137..efbf980 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/SwitchCaseDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/SwitchCaseDefinitionBuilder.cs
@@ -16,42 +16,35 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class SwitchCaseDefinitionBuilder
+public sealed class SwitchCaseDefinitionBuilder
: ISwitchCaseDefinitionBuilder
{
- ///
- /// Gets/sets the runtime expression used to determine whether or not the case to build matches
- ///
- protected virtual string? WhenExpression { get; set; }
-
- ///
- /// Gets/sets the flow directive to execute when the case to build matches
- ///
- protected virtual string? ThenDirective { get; set; }
+ string? whenExpression;
+ string? thenDirective;
///
- public virtual ISwitchCaseDefinitionBuilder When(string expression)
+ public ISwitchCaseDefinitionBuilder When(string expression)
{
- this.WhenExpression = expression;
+ whenExpression = expression;
return this;
}
///
- public virtual ISwitchCaseDefinitionBuilder Then(string directive)
+ public ISwitchCaseDefinitionBuilder Then(string directive)
{
ArgumentException.ThrowIfNullOrWhiteSpace(directive);
- this.ThenDirective = directive;
+ thenDirective = directive;
return this;
}
///
- public virtual SwitchCaseDefinition Build()
+ public SwitchCaseDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.ThenDirective)) throw new NullReferenceException("The flow directive to execute when the switch case matches must be set");
+ if (string.IsNullOrWhiteSpace(thenDirective)) throw new NullReferenceException("The flow directive to execute when the switch case matches must be set");
return new()
{
- When = this.WhenExpression,
- Then = this.ThenDirective
+ When = whenExpression,
+ Then = thenDirective
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/SwitchTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/SwitchTaskDefinitionBuilder.cs
index 1678aa9..4f04ac3 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/SwitchTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/SwitchTaskDefinitionBuilder.cs
@@ -16,14 +16,11 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class SwitchTaskDefinitionBuilder
+public sealed class SwitchTaskDefinitionBuilder
: TaskDefinitionBuilder, ISwitchTaskDefinitionBuilder
{
- ///
- /// Gets a name/value mapping of the cases of the to build
- ///
- protected Map Cases { get; } = [];
+ readonly Map cases = [];
///
public ISwitchTaskDefinitionBuilder Case(string name, Action setup)
@@ -33,14 +30,14 @@ public ISwitchTaskDefinitionBuilder Case(string name, Action
public override SwitchTaskDefinition Build() => this.Configure(new()
{
- Switch = this.Cases
+ Switch = cases
});
}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Builders/TaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/TaskDefinitionBuilder.cs
index 697e67b..0f328a7 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/TaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/TaskDefinitionBuilder.cs
@@ -58,7 +58,7 @@ public abstract class TaskDefinitionBuilder
public virtual TBuilder If(string condition)
{
ArgumentException.ThrowIfNullOrWhiteSpace(condition);
- this.IfExpression = condition;
+ IfExpression = condition;
return (TBuilder)(object)this;
}
@@ -66,7 +66,7 @@ public virtual TBuilder If(string condition)
public virtual TBuilder WithTimeout(string name)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Timeout = name;
+ Timeout = name;
return (TBuilder)(object)this;
}
@@ -74,7 +74,7 @@ public virtual TBuilder WithTimeout(string name)
public virtual TBuilder WithTimeout(TimeoutDefinition timeout)
{
ArgumentNullException.ThrowIfNull(timeout);
- this.Timeout = timeout;
+ Timeout = timeout;
return (TBuilder)(object)this;
}
@@ -84,7 +84,7 @@ public virtual TBuilder WithTimeout(Action setup)
ArgumentNullException.ThrowIfNull(setup);
var builder = new TimeoutDefinitionBuilder();
setup(builder);
- this.Timeout = builder.Build();
+ Timeout = builder.Build();
return (TBuilder)(object)this;
}
@@ -94,7 +94,7 @@ public virtual TBuilder WithInput(Action setup
ArgumentNullException.ThrowIfNull(setup);
var builder = new InputDataModelDefinitionBuilder();
setup(builder);
- this.Input = builder.Build();
+ Input = builder.Build();
return (TBuilder)(object)this;
}
@@ -104,7 +104,7 @@ public virtual TBuilder WithOutput(Action set
ArgumentNullException.ThrowIfNull(setup);
var builder = new OutputDataModelDefinitionBuilder();
setup(builder);
- this.Output = builder.Build();
+ Output = builder.Build();
return (TBuilder)(object)this;
}
@@ -114,7 +114,7 @@ public virtual TBuilder WithExport(Action set
ArgumentNullException.ThrowIfNull(setup);
var builder = new OutputDataModelDefinitionBuilder();
setup(builder);
- this.Export = builder.Build();
+ Export = builder.Build();
return (TBuilder)(object)this;
}
@@ -122,7 +122,7 @@ public virtual TBuilder WithExport(Action set
public virtual TBuilder Then(string directive)
{
ArgumentException.ThrowIfNullOrWhiteSpace(directive);
- this.ThenDirective = directive;
+ ThenDirective = directive;
return (TBuilder)(object)this;
}
@@ -133,22 +133,20 @@ public virtual TBuilder Then(string directive)
/// The configured task definition
protected virtual TDefinition Configure(TDefinition definition)
{
- definition.If = this.IfExpression;
- if (this.Timeout != null)
+ return definition with
{
- if (this.Timeout.T1Value != null) definition.Timeout = this.Timeout.T1Value;
- else definition.TimeoutReference = this.Timeout.T2Value;
- }
- definition.Then = this.ThenDirective;
- definition.Input = this.Input;
- definition.Output = this.Output;
- definition.Export = this.Export;
- return definition;
+ If = IfExpression,
+ Timeout = Timeout,
+ Then = ThenDirective,
+ Input = Input,
+ Output = Output,
+ Export = Export
+ }; ;
}
///
public abstract TDefinition Build();
- TaskDefinition ITaskDefinitionBuilder.Build() => this.Build();
+ TaskDefinition ITaskDefinitionBuilder.Build() => Build();
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/TaskDefinitionMapBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/TaskDefinitionMapBuilder.cs
index e25b342..8ea166d 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/TaskDefinitionMapBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/TaskDefinitionMapBuilder.cs
@@ -16,27 +16,24 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class TaskDefinitionMapBuilder
+public sealed class TaskDefinitionMapBuilder
: ITaskDefinitionMapBuilder
{
- ///
- /// Gets a name/value mapping of the tasks the workflow is made out of
- ///
- protected Map? Tasks { get; set; }
+ Map? tasks;
///
- public virtual ITaskDefinitionMapBuilder Do(string name, TaskDefinition task)
+ public ITaskDefinitionMapBuilder Do(string name, TaskDefinition task)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentNullException.ThrowIfNull(task);
- this.Tasks ??= [];
- this.Tasks[name] = task;
+ tasks ??= [];
+ tasks[name] = task;
return this;
}
///
- public virtual ITaskDefinitionMapBuilder Do(string name, Action setup)
+ public ITaskDefinitionMapBuilder Do(string name, Action setup)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentNullException.ThrowIfNull(setup);
@@ -47,10 +44,10 @@ public virtual ITaskDefinitionMapBuilder Do(string name, Action
- public virtual Map Build()
+ public Map Build()
{
- if (this.Tasks == null || this.Tasks.Count < 1) throw new NullReferenceException("The task must define at least one subtask");
- return this.Tasks;
+ if (tasks == null || tasks.Count < 1) throw new NullReferenceException("The task must define at least one subtask");
+ return tasks;
}
}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Builders/TimeoutDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/TimeoutDefinitionBuilder.cs
index 119da96..83006ec 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/TimeoutDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/TimeoutDefinitionBuilder.cs
@@ -18,38 +18,35 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class TimeoutDefinitionBuilder
+public sealed class TimeoutDefinitionBuilder
: ITimeoutDefinitionBuilder
{
- ///
- /// Gets/sets the duration after which to timeout
- ///
- protected Duration? AfterValue { get; set; }
+ Duration? afterValue;
///
- public virtual ITimeoutDefinitionBuilder After(string duration)
+ public ITimeoutDefinitionBuilder After(string duration)
{
ArgumentException.ThrowIfNullOrWhiteSpace(duration);
- this.AfterValue = XmlConvert.ToTimeSpan(duration);
+ afterValue = XmlConvert.ToTimeSpan(duration);
return this;
}
///
- public virtual ITimeoutDefinitionBuilder After(Duration duration)
+ public ITimeoutDefinitionBuilder After(Duration duration)
{
ArgumentNullException.ThrowIfNull(duration);
- this.AfterValue = duration;
+ afterValue = duration;
return this;
}
///
- public virtual TimeoutDefinition Build()
+ public TimeoutDefinition Build()
{
- if (this.AfterValue == null) throw new NullReferenceException("The duration after which to timeout must be set");
+ if (afterValue == null) throw new NullReferenceException("The duration after which to timeout must be set");
return new()
{
- After = this.AfterValue
+ After = afterValue
};
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/TryTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/TryTaskDefinitionBuilder.cs
index 2eb9566..48e44c8 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/TryTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/TryTaskDefinitionBuilder.cs
@@ -16,48 +16,41 @@ namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class TryTaskDefinitionBuilder
+public sealed class TryTaskDefinitionBuilder
: TaskDefinitionBuilder, ITryTaskDefinitionBuilder
{
- ///
- /// Gets/sets the tasks to try
- ///
- protected Map? TryTasks { get; set; }
-
- ///
- /// Gets/sets the definition of the error catcher to use
- ///
- protected ErrorCatcherDefinition? ErrorCatcher { get; set; }
+ Map? tryTasks;
+ ErrorCatcherDefinition? errorCatcher;
///
- public virtual ITryTaskDefinitionBuilder Do(Action setup)
+ public ITryTaskDefinitionBuilder Do(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new TaskDefinitionMapBuilder();
setup(builder);
- this.TryTasks = builder.Build();
+ tryTasks = builder.Build();
return this;
}
///
- public virtual ITryTaskDefinitionBuilder Catch(Action setup)
+ public ITryTaskDefinitionBuilder Catch(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new ErrorCatcherDefinitionBuilder();
- this.ErrorCatcher = builder.Build();
+ errorCatcher = builder.Build();
return this;
}
///
public override TryTaskDefinition Build()
{
- if (this.TryTasks == null || this.TryTasks.Count < 1) throw new NullReferenceException("The task to try must be set");
- if (this.ErrorCatcher == null) throw new NullReferenceException("The catch clause must be set");
+ if (tryTasks == null || tryTasks.Count < 1) throw new NullReferenceException("The task to try must be set");
+ if (errorCatcher == null) throw new NullReferenceException("The catch clause must be set");
return this.Configure(new()
{
- Try = this.TryTasks,
- Catch = this.ErrorCatcher
+ Try = tryTasks,
+ Catch = errorCatcher
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/Usings.cs b/src/ServerlessWorkflow.Sdk.Builders/Usings.cs
index 03361af..715ef60 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/Usings.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/Usings.cs
@@ -11,6 +11,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+global using Semver;
global using ServerlessWorkflow.Sdk.Models;
global using ServerlessWorkflow.Sdk.Models.Authentication;
-global using ServerlessWorkflow.Sdk.Models.Tasks;
\ No newline at end of file
+global using ServerlessWorkflow.Sdk.Models.Calls;
+global using ServerlessWorkflow.Sdk.Models.Processes;
+global using ServerlessWorkflow.Sdk.Models.Tasks;
+global using System.Text.Json.Nodes;
+global using System.Text.RegularExpressions;
diff --git a/src/ServerlessWorkflow.Sdk.Builders/WaitTaskDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/WaitTaskDefinitionBuilder.cs
index 264d8cc..7944142 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/WaitTaskDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/WaitTaskDefinitionBuilder.cs
@@ -17,30 +17,27 @@ namespace ServerlessWorkflow.Sdk.Builders;
/// Represents the default implementation of the interface
///
/// The amount of time to wait for
-public class WaitTaskDefinitionBuilder(Duration? duration = null)
+public sealed class WaitTaskDefinitionBuilder(Duration? duration = null)
: TaskDefinitionBuilder, IWaitTaskDefinitionBuilder
{
- ///
- /// Gets/sets the amount of time to wait for
- ///
- protected Duration? Duration { get; set; } = duration;
+ Duration? duration = duration;
///
- public virtual IWaitTaskDefinitionBuilder For(Duration duration)
+ public IWaitTaskDefinitionBuilder For(Duration duration)
{
ArgumentNullException.ThrowIfNull(duration);
- this.Duration = duration;
+ this.duration = duration;
return this;
}
///
public override WaitTaskDefinition Build()
{
- if (this.Duration == null) throw new NullReferenceException("The amount of time to wait for must be set");
+ if (duration == null) throw new NullReferenceException("The amount of time to wait for must be set");
return this.Configure(new()
{
- Wait = this.Duration
+ Wait = duration
});
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/WorkflowDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/WorkflowDefinitionBuilder.cs
index 96995be..cc58241 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/WorkflowDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/WorkflowDefinitionBuilder.cs
@@ -11,337 +11,310 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Neuroglia;
-using Semver;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class WorkflowDefinitionBuilder
+public sealed class WorkflowDefinitionBuilder
: IWorkflowDefinitionBuilder
{
- ///
- /// Gets/sets the version of the DSL used to define the workflow
- ///
- protected string Dsl { get; set; } = DslVersion.V1;
-
- ///
- /// Gets/sets the workflow's namespace
- ///
- protected string? Namespace { get; set; }
-
- ///
- /// Gets/sets the workflow's name
- ///
- protected string? Name { get; set; }
-
- ///
- /// Gets the workflow's semantic version
- ///
- protected string? Version { get; set; }
-
- ///
- /// Gets/sets the workflow's title
- ///
- protected string? Title { get; set; }
-
- ///
- /// Gets/sets the workflow's Markdown summary
- ///
- protected string? Summary { get; set; }
-
- ///
- /// Gets/sets the workflow's tags
- ///
- protected EquatableDictionary? Tags { get; set; }
-
- ///
- /// Gets/sets the workflow's timeout, if any
- ///
- protected OneOf? Timeout { get; set; }
-
- ///
- /// Gets/sets the workflow's input data, if any
- ///
- protected InputDataModelDefinition? Input { get; set; }
-
- ///
- /// Gets/sets the workflow's output data, if any
- ///
- protected OutputDataModelDefinition? Output { get; set; }
-
- ///
- /// Gets/sets a name/value mapping of the workflow's reusable components
- ///
- protected ComponentDefinitionCollection? Components { get; set; }
-
- ///
- /// Gets/sets a name/value mapping of the tasks the workflow is made out of
- ///
- protected Map? Tasks { get; set; }
+ string dsl = ServerlessWorkflowSpecificationDefaults.Version;
+ string? @namespace;
+ string? name;
+ string? version;
+ string? title;
+ string? summary;
+ EquatableDictionary? tags;
+ OneOf? timeout;
+ InputDataModelDefinition? input;
+ OutputDataModelDefinition? output;
+ ComponentDefinitionCollection? components;
+ Map? tasks;
///
- public virtual IWorkflowDefinitionBuilder UseDsl(string version)
+ public IWorkflowDefinitionBuilder UseDsl(string version)
{
ArgumentException.ThrowIfNullOrWhiteSpace(version);
if (!SemVersion.TryParse(version, SemVersionStyles.Strict, out _)) throw new ArgumentException($"The specified value '{version}' is not a valid semantic version (SemVer 2.0)", nameof(version));
- this.Dsl = version;
+ dsl = version;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithNamespace(string @namespace)
+ public IWorkflowDefinitionBuilder WithNamespace(string @namespace)
{
ArgumentException.ThrowIfNullOrWhiteSpace(@namespace);
if (!NamingConvention.IsValidName(@namespace)) throw new ArgumentException($"The the specified value '{@namespace}' is not a valid RFC1123 DNS label name", nameof(@namespace));
- this.Namespace = @namespace;
+ this.@namespace = @namespace;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithName(string name)
+ public IWorkflowDefinitionBuilder WithName(string name)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
if (!NamingConvention.IsValidName(name)) throw new ArgumentException($"The the specified value '{name}' is not a valid RFC1123 DNS label name", nameof(name));
- this.Name = name;
+ this.name = name;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithVersion(string version)
+ public IWorkflowDefinitionBuilder WithVersion(string version)
{
ArgumentException.ThrowIfNullOrWhiteSpace(version);
if (!SemVersion.TryParse(version, SemVersionStyles.Strict, out _)) throw new ArgumentException($"The specified value '{version}' is not a valid semantic version (SemVer 2.0)", nameof(version));
- this.Version = version;
+ this.version = version;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithTitle(string title)
+ public IWorkflowDefinitionBuilder WithTitle(string title)
{
- this.Title = title;
+ this.title = title;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithSummary(string description)
+ public IWorkflowDefinitionBuilder WithSummary(string summary)
{
- this.Summary = description;
+ this.summary = summary;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithTag(string name, string value)
+ public IWorkflowDefinitionBuilder WithTag(string name, string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Tags ??= [];
- this.Tags[name] = value;
+ tags ??= [];
+ tags[name] = value;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithTag(IDictionary arguments)
+ public IWorkflowDefinitionBuilder WithTag(IDictionary tags)
{
- ArgumentNullException.ThrowIfNull(arguments);
- this.Tags = new(arguments);
+ ArgumentNullException.ThrowIfNull(tags);
+ this.tags = [.. tags];
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithTimeout(string name)
+ public IWorkflowDefinitionBuilder WithTimeout(string name)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- this.Timeout = name;
+ timeout = name;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithTimeout(TimeoutDefinition timeout)
+ public IWorkflowDefinitionBuilder WithTimeout(TimeoutDefinition timeout)
{
ArgumentNullException.ThrowIfNull(timeout);
- this.Timeout = timeout;
+ this.timeout = timeout;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithTimeout(Action setup)
+ public IWorkflowDefinitionBuilder WithTimeout(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new TimeoutDefinitionBuilder();
setup(builder);
- this.Timeout = builder.Build();
+ timeout = builder.Build();
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithInput(Action setup)
+ public IWorkflowDefinitionBuilder WithInput(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new InputDataModelDefinitionBuilder();
setup(builder);
- this.Input = builder.Build();
+ this.input = builder.Build();
return this;
}
///
- public virtual IWorkflowDefinitionBuilder WithOutput(Action setup)
+ public IWorkflowDefinitionBuilder WithOutput(Action setup)
{
ArgumentNullException.ThrowIfNull(setup);
var builder = new OutputDataModelDefinitionBuilder();
setup(builder);
- this.Output = builder.Build();
+ this.output = builder.Build();
return this;
}
///
- public virtual IWorkflowDefinitionBuilder UseAuthentication(string name, AuthenticationPolicyDefinition authentication)
+ public IWorkflowDefinitionBuilder UseAuthentication(string name, AuthenticationPolicyDefinition authentication)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentNullException.ThrowIfNull(authentication);
- this.Components ??= new();
- this.Components.Authentications ??= [];
- this.Components.Authentications[name] = authentication;
+ components ??= new();
+ var authentications = components.Authentications ?? [];
+ authentications[name] = authentication;
+ components = components with
+ {
+ Authentications = authentications
+ };
return this;
}
///
- public virtual IWorkflowDefinitionBuilder UseAuthentication(string name, Action setup)
+ public IWorkflowDefinitionBuilder UseAuthentication(string name, Action setup)
{
var builder = new AuthenticationPolicyDefinitionBuilder();
setup(builder);
- return this.UseAuthentication(name, builder.Build());
+ return UseAuthentication(name, builder.Build());
}
///
- public virtual IWorkflowDefinitionBuilder UseExtension(string name, ExtensionDefinition extension)
+ public IWorkflowDefinitionBuilder UseExtension(string name, ExtensionDefinition extension)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentNullException.ThrowIfNull(extension);
- this.Components ??= new();
- this.Components.Extensions ??= [];
- this.Components.Extensions[name] = extension;
+ components ??= new();
+ var extensions = components.Extensions ?? [];
+ extensions[name] = extension;
+ components = components with
+ {
+ Extensions = extensions
+ };
return this;
}
///
- public virtual IWorkflowDefinitionBuilder UseExtension(string name, Action setup)
+ public IWorkflowDefinitionBuilder UseExtension(string name, Action setup)
{
var builder = new ExtensionDefinitionBuilder();
setup(builder);
- return this.UseExtension(name, builder.Build());
+ return UseExtension(name, builder.Build());
}
///
- public virtual IWorkflowDefinitionBuilder UseFunction(string name, TaskDefinition task)
+ public IWorkflowDefinitionBuilder UseFunction(string name, TaskDefinition task)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentNullException.ThrowIfNull(task);
- this.Components ??= new();
- this.Components.Functions ??= [];
- this.Components.Functions[name] = task;
+ components ??= new();
+ var functions = components.Functions ?? [];
+ functions[name] = task;
+ components = components with
+ {
+ Functions = functions
+ };
return this;
}
///
- public virtual IWorkflowDefinitionBuilder UseFunction(string name, Action setup)
+ public IWorkflowDefinitionBuilder UseFunction(string name, Action setup)
{
+ ArgumentException.ThrowIfNullOrWhiteSpace(name);
+ ArgumentNullException.ThrowIfNull(setup);
var builder = new GenericTaskDefinitionBuilder();
setup(builder);
- return this.UseFunction(name, builder.Build());
+ return UseFunction(name, builder.Build());
}
///
- public virtual IWorkflowDefinitionBuilder UseRetry(string name, RetryPolicyDefinition retry)
+ public IWorkflowDefinitionBuilder UseRetry(string name, RetryPolicyDefinition retry)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentNullException.ThrowIfNull(retry);
- this.Components ??= new();
- this.Components.Retries ??= [];
- this.Components.Retries[name] = retry;
+ components ??= new();
+ var retries = components.Retries ?? [];
+ retries[name] = retry;
+ components = components with
+ {
+ Retries = retries
+ };
return this;
}
///
- public virtual IWorkflowDefinitionBuilder UseRetry(string name, Action setup)
+ public IWorkflowDefinitionBuilder UseRetry(string name, Action setup)
{
var builder = new RetryPolicyDefinitionBuilder();
setup(builder);
- return this.UseRetry(name, builder.Build());
+ return UseRetry(name, builder.Build());
}
///
- public virtual IWorkflowDefinitionBuilder UseSecret(string secret)
+ public IWorkflowDefinitionBuilder UseSecret(string secret)
{
ArgumentException.ThrowIfNullOrWhiteSpace(secret);
- this.Components ??= new();
- this.Components.Secrets ??= [];
- this.Components.Secrets.Add(secret);
+ components ??= new();
+ var secrets = components.Secrets ?? [];
+ secrets.Add(secret);
+ components = components with
+ {
+ Secrets = secrets
+ };
return this;
}
///
- public virtual IWorkflowDefinitionBuilder UseSecrets(params string[] secrets)
+ public IWorkflowDefinitionBuilder UseSecrets(params string[] secrets)
{
ArgumentNullException.ThrowIfNull(secrets);
- this.Components ??= new();
- this.Components.Secrets = new(secrets);
+ components ??= new();
+ var existingSecrets = components.Secrets ?? [];
+ existingSecrets.AddRange(secrets);
+ components = components with
+ {
+ Secrets = existingSecrets
+ };
return this;
}
///
- public virtual IWorkflowDefinitionBuilder Do(string name, TaskDefinition task)
+ public IWorkflowDefinitionBuilder Do(string name, TaskDefinition task)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentNullException.ThrowIfNull(task);
- this.Tasks ??= [];
- this.Tasks[name] = task;
+ tasks ??= [];
+ tasks[name] = task;
return this;
}
///
- public virtual IWorkflowDefinitionBuilder Do(string name, Action setup)
+ public IWorkflowDefinitionBuilder Do(string name, Action setup)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
ArgumentNullException.ThrowIfNull(setup);
var builder = new GenericTaskDefinitionBuilder();
setup(builder);
var task = builder.Build();
- return this.Do(name, task);
+ return Do(name, task);
}
///
- public virtual WorkflowDefinition Build()
+ public WorkflowDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Dsl)) throw new NullReferenceException("The workflow DSL must be set");
- if (string.IsNullOrWhiteSpace(this.Name)) throw new NullReferenceException("The workflow name must be set");
- if (string.IsNullOrWhiteSpace(this.Version)) throw new NullReferenceException("The workflow version must be set");
- if (this.Tasks == null || this.Tasks.Count < 1) throw new NullReferenceException("The workflow must define at least one task");
+ if (string.IsNullOrWhiteSpace(dsl)) throw new NullReferenceException("The workflow DSL must be set");
+ if (string.IsNullOrWhiteSpace(name)) throw new NullReferenceException("The workflow name must be set");
+ if (string.IsNullOrWhiteSpace(version)) throw new NullReferenceException("The workflow version must be set");
+ if (tasks == null || tasks.Count < 1) throw new NullReferenceException("The workflow must define at least one task");
var definition = new WorkflowDefinition()
{
Document = new()
{
- Dsl = this.Dsl,
- Namespace = string.IsNullOrWhiteSpace(this.Namespace) ? WorkflowDefinitionMetadata.DefaultNamespace : this.Namespace,
- Name = this.Name,
- Version = this.Version,
- Title = this.Title,
- Summary = this.Summary,
- Tags = this.Tags
+ Dsl = dsl,
+ Namespace = string.IsNullOrWhiteSpace(@namespace) ? WorkflowDefinitionMetadata.DefaultNamespace : @namespace,
+ Name = name,
+ Version = version,
+ Title = title,
+ Summary = summary,
+ Tags = tags
},
- Use = this.Components,
- Do = this.Tasks
+ Use = components,
+ Do = tasks,
+ Timeout = timeout
};
- if(this.Timeout != null)
- {
- if (this.Timeout.T1Value != null) definition.Timeout = this.Timeout.T1Value;
- else definition.TimeoutReference = this.Timeout.T2Value;
- }
return definition;
}
- Map ITaskDefinitionMapBuilder.Build() => this.Tasks!;
+ Map ITaskDefinitionMapBuilder.Build() => tasks!;
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/WorkflowProcessDefinitionBuilder.cs b/src/ServerlessWorkflow.Sdk.Builders/WorkflowProcessDefinitionBuilder.cs
index e546c48..4052993 100644
--- a/src/ServerlessWorkflow.Sdk.Builders/WorkflowProcessDefinitionBuilder.cs
+++ b/src/ServerlessWorkflow.Sdk.Builders/WorkflowProcessDefinitionBuilder.cs
@@ -1,4 +1,4 @@
-// Copyright © 2024-Present The Serverless Workflow Specification Authors
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
@@ -11,84 +11,67 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using ServerlessWorkflow.Sdk.Models.Processes;
-using Semver;
-
namespace ServerlessWorkflow.Sdk.Builders;
///
/// Represents the default implementation of the interface
///
-public class WorkflowProcessDefinitionBuilder
+public sealed partial class WorkflowProcessDefinitionBuilder
: ProcessDefinitionBuilder, IWorkflowProcessDefinitionBuilder
{
- ///
- /// Gets/sets the namespace of the workflow to run
- ///
- protected virtual string? Namespace { get; set; }
-
- ///
- /// Gets/sets the name of the workflow to run
- ///
- protected virtual string? Name { get; set; }
-
- ///
- /// Gets/sets the version of the workflow to run. Defaults to `latest`
- ///
- protected virtual string Version { get; set; } = "latest";
-
- ///
- /// 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
- ///
- protected virtual object? Input { get; set; }
+ string? @namespace;
+ string? name;
+ string version = "latest";
+ JsonObject? input;
///
- public virtual IWorkflowProcessDefinitionBuilder WithNamespace(string @namespace)
+ public IWorkflowProcessDefinitionBuilder WithNamespace(string @namespace)
{
ArgumentException.ThrowIfNullOrWhiteSpace(@namespace);
- if (!NamingConvention.IsValidName(@namespace)) throw new ArgumentException($"The the specified value '{@namespace}' is not a valid RFC1123 DNS label name", nameof(@namespace));
- this.Namespace = @namespace;
+ if (!DnsLabelRegex().IsMatch(@namespace)) throw new ArgumentException($"The specified value '{@namespace}' is not a valid RFC1123 DNS label name", nameof(@namespace));
+ this.@namespace = @namespace;
return this;
}
///
- public virtual IWorkflowProcessDefinitionBuilder WithName(string name)
+ public IWorkflowProcessDefinitionBuilder WithName(string name)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
- if (!NamingConvention.IsValidName(name)) throw new ArgumentException($"The the specified value '{name}' is not a valid RFC1123 DNS label name", nameof(name));
- this.Name = name;
+ if (!DnsLabelRegex().IsMatch(name)) throw new ArgumentException($"The specified value '{name}' is not a valid RFC1123 DNS label name", nameof(name));
+ this.name = name;
return this;
}
///
- public virtual IWorkflowProcessDefinitionBuilder WithVersion(string version)
+ public IWorkflowProcessDefinitionBuilder WithVersion(string version)
{
ArgumentException.ThrowIfNullOrWhiteSpace(version);
- if (!SemVersion.TryParse(version, SemVersionStyles.Strict, out _)) throw new ArgumentException($"The specified value '{version}' is not a valid semantic version (SemVer 2.0)", nameof(version));
- this.Version = version;
+ this.version = version;
return this;
}
///
- public virtual IWorkflowProcessDefinitionBuilder WithInput(object input)
+ public IWorkflowProcessDefinitionBuilder WithInput(JsonObject input)
{
- this.Input = input;
+ this.input = input;
return this;
}
///
public override WorkflowProcessDefinition Build()
{
- if (string.IsNullOrWhiteSpace(this.Name)) throw new NullReferenceException("The name of the workflow to run must be set");
- if (string.IsNullOrWhiteSpace(this.Version)) throw new NullReferenceException("The version of the workflow to run must be set");
+ if (string.IsNullOrWhiteSpace(name)) throw new NullReferenceException("The name of the workflow to run must be set");
+ if (string.IsNullOrWhiteSpace(version)) throw new NullReferenceException("The version of the workflow to run must be set");
return new()
{
- Namespace = string.IsNullOrWhiteSpace(this.Namespace) ? WorkflowDefinitionMetadata.DefaultNamespace : this.Namespace,
- Name = this.Name,
- Version = this.Version,
- Input = this.Input
+ Namespace = string.IsNullOrWhiteSpace(@namespace) ? WorkflowDefinitionMetadata.DefaultNamespace : @namespace,
+ Name = name,
+ Version = version,
+ Input = input
};
}
+ [GeneratedRegex(@"^[a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?$", RegexOptions.Compiled)]
+ private static partial Regex DnsLabelRegex();
}
diff --git a/src/ServerlessWorkflow.Sdk.Builders/readme.md b/src/ServerlessWorkflow.Sdk.Builders/readme.md
new file mode 100644
index 0000000..d4fc436
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Builders/readme.md
@@ -0,0 +1,52 @@
+# ServerlessWorkflow.Sdk.Builders
+
+Fluent builders for constructing [Serverless Workflow DSL](https://github.com/serverlessworkflow/specification/blob/main/dsl.md) definitions programmatically in .NET.
+
+This package provides a strongly-typed, chainable API for authoring `WorkflowDefinition` instances without having to hand-write JSON or YAML.
+
+## Installation
+
+```bash
+dotnet add package ServerlessWorkflow.Sdk.Builders
+```
+
+## Usage
+
+```csharp
+using ServerlessWorkflow.Sdk.Builders;
+
+var definition = new WorkflowDefinitionBuilder()
+ .UseDsl("1.0.0")
+ .WithNamespace("samples")
+ .WithName("fake-workflow")
+ .WithVersion("0.1.0")
+ .WithTitle("Fake Workflow")
+ .WithSummary("A sample workflow that calls an HTTP endpoint.")
+ .Do("fetch-data", task => task
+ .Call("http")
+ .With("method", "get")
+ .With("uri", "https://fake-api.com"))
+ .Build();
+```
+
+### Common builder methods
+
+| Method | Purpose |
+|---|---|
+| `UseDsl(version)` | Sets the DSL version. |
+| `WithNamespace(ns)` | RFC1123 DNS label namespace. |
+| `WithName(name)` / `WithVersion(version)` | Identity of the workflow. |
+| `WithTitle` / `WithSummary` / `WithTag` | Metadata. |
+| `WithInput` / `WithOutput` | Input/output schemas. |
+| `UseAuthentication` / `UseExtension` / `UseFunction` / `UseRetry` / `UseSecret` | Reusable components. |
+| `Do(name, task => ...)` | Adds a task to the workflow. |
+| `Build()` | Returns a `WorkflowDefinition`. |
+
+Dedicated builders are available for every DSL construct — call, do, for, fork, listen, raise, run, set, switch, try, wait, retry policies, authentication schemes, and more.
+
+## Related packages
+
+- [ServerlessWorkflow.Sdk](../ServerlessWorkflow.Sdk) — core DSL models
+- [ServerlessWorkflow.Sdk.Runtime](../ServerlessWorkflow.Sdk.Runtime) — workflow runtime
+- [ServerlessWorkflow.Sdk.Runtime.Cli](../ServerlessWorkflow.Sdk.Runtime.Cli) — `swf` command-line runner
+- [Project root](../../README.md)
diff --git a/src/ServerlessWorkflow.Sdk.IO/Extensions/IServiceCollectionExtensions.cs b/src/ServerlessWorkflow.Sdk.IO/Extensions/IServiceCollectionExtensions.cs
index e0cd5b1..8c4cba6 100644
--- a/src/ServerlessWorkflow.Sdk.IO/Extensions/IServiceCollectionExtensions.cs
+++ b/src/ServerlessWorkflow.Sdk.IO/Extensions/IServiceCollectionExtensions.cs
@@ -11,11 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Microsoft.Extensions.DependencyInjection;
-using Neuroglia.Serialization;
-using Neuroglia.Serialization.Yaml;
-using ServerlessWorkflow.Sdk.Serialization.Yaml;
-
+#pragma warning disable IDE0130 // Namespace does not match folder structure
namespace ServerlessWorkflow.Sdk.IO;
///
@@ -31,25 +27,6 @@ public static class IServiceCollectionExtensions
/// The configured
public static IServiceCollection AddServerlessWorkflowIO(this IServiceCollection services)
{
- services.AddJsonSerializer();
- services.AddYamlDotNetSerializer(options =>
- {
- YamlSerializer.DefaultSerializerConfiguration(options.Serializer);
- YamlSerializer.DefaultDeserializerConfiguration(options.Deserializer);
- options.Deserializer.WithNodeDeserializer(
- inner => new TaskDefinitionYamlDeserializer(inner),
- syntax => syntax.InsteadOf());
- options.Deserializer.WithNodeDeserializer(
- inner => new OneOfNodeDeserializer(inner),
- syntax => syntax.InsteadOf());
- options.Deserializer.WithNodeDeserializer(
- inner => new OneOfScalarDeserializer(inner),
- syntax => syntax.InsteadOf());
- var mapEntryConverter = new MapEntryYamlConverter(() => options.Serializer.Build(), () => options.Deserializer.Build());
- options.Deserializer.WithTypeConverter(mapEntryConverter);
- options.Serializer.WithTypeConverter(mapEntryConverter);
- options.Serializer.WithTypeConverter(new OneOfConverter());
- });
services.AddSingleton();
services.AddSingleton();
return services;
diff --git a/src/ServerlessWorkflow.Sdk.IO/Interfaces/IWorkflowDefinitionReader.cs b/src/ServerlessWorkflow.Sdk.IO/IWorkflowDefinitionReader.cs
similarity index 100%
rename from src/ServerlessWorkflow.Sdk.IO/Interfaces/IWorkflowDefinitionReader.cs
rename to src/ServerlessWorkflow.Sdk.IO/IWorkflowDefinitionReader.cs
diff --git a/src/ServerlessWorkflow.Sdk.IO/Interfaces/IWorkflowDefinitionWriter.cs b/src/ServerlessWorkflow.Sdk.IO/IWorkflowDefinitionWriter.cs
similarity index 99%
rename from src/ServerlessWorkflow.Sdk.IO/Interfaces/IWorkflowDefinitionWriter.cs
rename to src/ServerlessWorkflow.Sdk.IO/IWorkflowDefinitionWriter.cs
index dc0f63a..4a99564 100644
--- a/src/ServerlessWorkflow.Sdk.IO/Interfaces/IWorkflowDefinitionWriter.cs
+++ b/src/ServerlessWorkflow.Sdk.IO/IWorkflowDefinitionWriter.cs
@@ -29,4 +29,4 @@ public interface IWorkflowDefinitionWriter
/// A new awaitable
Task WriteAsync(WorkflowDefinition workflow, Stream stream, string format = WorkflowDefinitionFormat.Yaml, CancellationToken cancellationToken = default);
-}
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj b/src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj
index c1a5989..b8813f3 100644
--- a/src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj
+++ b/src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj
@@ -1,10 +1,10 @@
-
+
- net8.0;net9.0
+ net10.0
enable
enable
- 1.0.1
+ 1.0.2
$(VersionPrefix)
$(VersionPrefix)
en
@@ -16,7 +16,7 @@
serverless-workflow;serverless;workflow;dsl;sdk;io
true
Apache-2.0
- readme.md
+ README.md
Copyright © 2024-Present The Serverless Workflow Authors. All rights reserved.
https://github.com/serverlessworkflow/sdk-net
https://github.com/serverlessworkflow/sdk-net
@@ -25,14 +25,19 @@
-
- \
- True
-
+
+
+
+
+
+ \
+ True
+
+
diff --git a/src/ServerlessWorkflow.Sdk.IO/Usings.cs b/src/ServerlessWorkflow.Sdk.IO/Usings.cs
index 34fbf4b..a38ed7d 100644
--- a/src/ServerlessWorkflow.Sdk.IO/Usings.cs
+++ b/src/ServerlessWorkflow.Sdk.IO/Usings.cs
@@ -11,4 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-global using ServerlessWorkflow.Sdk.Models;
\ No newline at end of file
+global using Microsoft.Extensions.DependencyInjection;
+global using ServerlessWorkflow.Sdk.Models;
+global using ServerlessWorkflow.Sdk.Serialization.Json;
+global using System.Text.Json;
+global using Yaml2JsonNode;
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionReader.cs b/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionReader.cs
index 9867cf7..7631f90 100644
--- a/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionReader.cs
+++ b/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionReader.cs
@@ -11,41 +11,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Microsoft.Extensions.DependencyInjection;
-using Neuroglia.Serialization;
-
namespace ServerlessWorkflow.Sdk.IO;
///
/// Represents the default implementation of the interface
///
-/// The service used to serialize/deserialize objects to/from JSON
-/// The service used to serialize/deserialize objects to/from JSON
-public class WorkflowDefinitionReader(IJsonSerializer jsonSerializer, IYamlSerializer yamlSerializer)
+public sealed class WorkflowDefinitionReader
: IWorkflowDefinitionReader
{
- ///
- /// Gets the service used to serialize/deserialize objects to/from JSON
- ///
- protected IJsonSerializer JsonSerializer { get; } = jsonSerializer;
-
- ///
- /// Gets the service used to serialize/deserialize objects to/from YAML
- ///
- protected IYamlSerializer YamlSerializer { get; } = yamlSerializer;
-
///
- public virtual Task ReadAsync(Stream stream, WorkflowDefinitionReaderOptions? options = null, CancellationToken cancellationToken = default)
+ public async Task ReadAsync(Stream stream, WorkflowDefinitionReaderOptions? options = null, CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(stream);
using var reader = new StreamReader(stream);
- var input = reader.ReadToEnd();
- var workflow = (input.TrimStart().StartsWith('{') && input.TrimEnd().EndsWith('}')
- ? this.JsonSerializer.Deserialize(input)
- : this.YamlSerializer.Deserialize(input))
+ var input = (await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false)).Trim();
+ var workflow = (input.StartsWith('{') && input.EndsWith('}')
+ ? JsonSerializer.Deserialize(input, JsonSerializationContext.Default.WorkflowDefinition)
+ : YamlSerializer.Deserialize(input, JsonSerializationContext.Default.Options))
?? throw new NullReferenceException();
- return Task.FromResult(workflow);
+ return workflow;
}
///
diff --git a/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionReaderOptions.cs b/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionReaderOptions.cs
index e0379d8..c14acbd 100644
--- a/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionReaderOptions.cs
+++ b/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionReaderOptions.cs
@@ -16,27 +16,27 @@ namespace ServerlessWorkflow.Sdk.IO;
///
/// Represents the options used to configure an
///
-public class WorkflowDefinitionReaderOptions
+public sealed class WorkflowDefinitionReaderOptions
{
///
/// Gets/sets the base to use to combine to relative s when the property is set to
///
- public virtual Uri? BaseUri { get; set; }
+ public Uri? BaseUri { get; set; }
///
/// Gets/sets the base directory to use when resolving relative when the property is set to . Defaults to
///
- public virtual string BaseDirectory { get; set; } = AppContext.BaseDirectory;
+ public string BaseDirectory { get; set; } = AppContext.BaseDirectory;
///
/// Gets/sets the to use. Defaults to
///
- public virtual string RelativeUriResolutionMode { get; set; } = RelativeUriReferenceResolutionMode.ConvertToRelativeFilePath;
+ public string RelativeUriResolutionMode { get; set; } = RelativeUriReferenceResolutionMode.ConvertToRelativeFilePath;
///
/// Gets/sets a boolean indicating whether or not to load external definitions
///
- public virtual bool LoadExternalDefinitions { get; set; }
+ public bool LoadExternalDefinitions { get; set; }
}
diff --git a/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionWriter.cs b/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionWriter.cs
index 03314fc..6e36989 100644
--- a/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionWriter.cs
+++ b/src/ServerlessWorkflow.Sdk.IO/WorkflowDefinitionWriter.cs
@@ -11,30 +11,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using Microsoft.Extensions.DependencyInjection;
-using Neuroglia.Serialization;
-
namespace ServerlessWorkflow.Sdk.IO;
///
/// Represents the default implementation of the interface
///
-/// /// The service used to serialize/deserialize objects to/from JSON
-/// The service used to serialize/deserialize objects to/from JSON
-public class WorkflowDefinitionWriter(IJsonSerializer jsonSerializer, IYamlSerializer yamlSerializer)
+public class WorkflowDefinitionWriter
: IWorkflowDefinitionWriter
{
- ///
- /// Gets the service used to serialize/deserialize objects to/from JSON
- ///
- protected IJsonSerializer JsonSerializer { get; } = jsonSerializer;
-
- ///
- /// Gets the service used to serialize/deserialize objects to/from YAML
- ///
- protected IYamlSerializer YamlSerializer { get; } = yamlSerializer;
-
///
public virtual async Task WriteAsync(WorkflowDefinition workflow, Stream stream, string format = WorkflowDefinitionFormat.Yaml, CancellationToken cancellationToken = default)
{
@@ -42,8 +27,8 @@ public virtual async Task WriteAsync(WorkflowDefinition workflow, Stream stream,
ArgumentNullException.ThrowIfNull(stream);
var input = format switch
{
- WorkflowDefinitionFormat.Json => this.JsonSerializer.SerializeToText(workflow),
- WorkflowDefinitionFormat.Yaml => this.YamlSerializer.SerializeToText(workflow),
+ WorkflowDefinitionFormat.Json => JsonSerializer.Serialize(workflow, JsonSerializationContext.Default.WorkflowDefinition),
+ WorkflowDefinitionFormat.Yaml => YamlSerializer.Serialize(workflow, JsonSerializationContext.Default.Options),
_ => throw new NotSupportedException($"The specified workflow definition format '{format}' is not supported"),
};
using var streamWriter = new StreamWriter(stream, leaveOpen: true);
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ConcurrentHashSet.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ConcurrentHashSet.cs
new file mode 100644
index 0000000..1ac13eb
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ConcurrentHashSet.cs
@@ -0,0 +1,66 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System.Collections;
+using System.Collections.Concurrent;
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Represents a concurrent
+///
+/// The type of value contained by the
+public sealed class ConcurrentHashSet
+ : ICollection
+ where T : notnull
+{
+
+ readonly ConcurrentDictionary _dictionary = new();
+
+ ///
+ public int Count => _dictionary.Count;
+
+ ///
+ public bool IsReadOnly => false;
+
+ ///
+ public bool Contains(T item) => _dictionary.ContainsKey(item);
+
+ ///
+ public void Add(T item)
+ {
+ if (!_dictionary.TryAdd(item, false)) throw new InvalidOperationException("The specified item already exists in the collection");
+ }
+
+ ///
+ /// Attempts to add the specified item to the hashset
+ ///
+ /// The item to add
+ /// A boolean indicating whether or not the item has been added or if it was already present in the set
+ public bool TryAdd(T item) => _dictionary.TryAdd(item, false);
+
+ ///
+ public bool Remove(T item) => _dictionary.Remove(item, out _);
+
+ ///
+ public void Clear() => _dictionary.Clear();
+
+ ///
+ public void CopyTo(T[] array, int arrayIndex) => _dictionary.Keys.CopyTo(array, arrayIndex);
+
+ ///
+ public IEnumerator GetEnumerator() => _dictionary.Keys.GetEnumerator();
+
+ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Configuration/WorkflowExecutionsOptions.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Configuration/WorkflowExecutionsOptions.cs
new file mode 100644
index 0000000..2c7ba9b
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Configuration/WorkflowExecutionsOptions.cs
@@ -0,0 +1,27 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Configuration;
+
+///
+/// Represents the options used to configure an
+///
+public sealed class WorkflowExecutionsOptions
+{
+
+ ///
+ /// Gets or sets the options used to configure the 's lifecycle events
+ ///
+ public WorkflowProcessLifecycleEventsOptions LifecycleEvents { get; set; } = new();
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Configuration/WorkflowProcessLifecycleEventsOptions.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Configuration/WorkflowProcessLifecycleEventsOptions.cs
new file mode 100644
index 0000000..5d57a5f
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Configuration/WorkflowProcessLifecycleEventsOptions.cs
@@ -0,0 +1,32 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Configuration;
+
+///
+/// Represents the options used to configure the lifecycle events of an
+///
+public sealed class WorkflowProcessLifecycleEventsOptions
+{
+
+ ///
+ /// Gets or sets a boolean value indicating whether or not to publish lifecycle events
+ ///
+ public bool Publish { get; set; } = true;
+
+ ///
+ /// Gets or sets the source to use when publishing lifecycle events.
+ ///
+ public Uri Source { get; set; } = new Uri("https://serverlessworkflow.io/runtime");
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/CorrelationContextStatus.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/CorrelationContextStatus.cs
new file mode 100644
index 0000000..674a65d
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/CorrelationContextStatus.cs
@@ -0,0 +1,51 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Exposes all default statuses of a correlation context
+///
+public static class CorrelationContextStatus
+{
+
+ ///
+ /// Indicates that the context is currently active and in use.
+ ///
+ public const string Active = "active";
+ ///
+ /// Indicates that the context is inactive or paused
+ ///
+ public const string Inactive = "inactive";
+ ///
+ /// Indicates that the correlation process has been successfully completed.
+ ///
+ public const string Completed = "completed";
+ ///
+ /// Indicates that the correlation process has been cancelled.
+ ///
+ public const string Cancelled = "cancelled";
+
+ ///
+ /// Gets a new used to enumerate the default correlation context statuses
+ ///
+ /// A new used to enumerate the default correlation context statuses
+ public static IEnumerable AsEnumerable()
+ {
+ yield return Active;
+ yield return Inactive;
+ yield return Completed;
+ yield return Cancelled;
+ }
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/AuthenticationPolicyDefinitionExtensions.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/AuthenticationPolicyDefinitionExtensions.cs
new file mode 100644
index 0000000..73c4d6b
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/AuthenticationPolicyDefinitionExtensions.cs
@@ -0,0 +1,45 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma warning disable IDE0130 // Namespace does not match folder structure
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines extensions for s
+///
+public static class AuthenticationPolicyDefinitionExtensions
+{
+
+ ///
+ /// Attempts to get the name of the secret, if any, on which the is based
+ ///
+ /// The extended
+ /// The name of the secret, if any, on which the is based
+ /// A boolean indicating whether or not the is secret based
+ public static bool TryGetBaseSecret(this AuthenticationPolicyDefinition authentication, out string? secretName)
+ {
+ secretName = authentication.Scheme switch
+ {
+ AuthenticationScheme.Basic => authentication.Basic?.Use,
+ AuthenticationScheme.Bearer => authentication.Bearer?.Use,
+ AuthenticationScheme.Certificate => authentication.Certificate?.Use,
+ AuthenticationScheme.Digest => authentication.Digest?.Use,
+ AuthenticationScheme.OAuth2 => authentication.OAuth2?.Use,
+ AuthenticationScheme.OpenIDConnect => authentication.Oidc?.Use,
+ _ => throw new NotSupportedException($"The specified authentication schema '{authentication.Scheme}' is not supported")
+ };
+ return !string.IsNullOrWhiteSpace(secretName);
+ }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IHostEnvironmentExtensions.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IHostEnvironmentExtensions.cs
new file mode 100644
index 0000000..1a1e5da
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IHostEnvironmentExtensions.cs
@@ -0,0 +1,40 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma warning disable IDE0130 // Namespace does not match folder structure
+
+using Microsoft.Extensions.Hosting;
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines extensions for s
+///
+public static class IHostEnvironmentExtensions
+{
+
+ ///
+ /// Determines whether or not the runs in Docker
+ ///
+ /// The to check
+ /// A boolean indicating whether or not the runs in Docker
+ public static bool RunsInDocker(this IHostEnvironment env) => File.Exists("/.dockerenv");
+
+ ///
+ /// Determines whether or not the runs in Kubernetes
+ ///
+ /// The to check
+ /// A boolean indicating whether or not the runs in Kubernetes
+ public static bool RunsInKubernetes(this IHostEnvironment env) => !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("KUBERNETES_SERVICE_HOST"));
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IRuntimeExpressionEvaluatorExtensions.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IRuntimeExpressionEvaluatorExtensions.cs
new file mode 100644
index 0000000..8fef8fb
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IRuntimeExpressionEvaluatorExtensions.cs
@@ -0,0 +1,200 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma warning disable IDE0130 // Namespace does not match folder structure
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines extensions for s.
+///
+public static class IRuntimeExpressionEvaluatorExtensions
+{
+
+ ///
+ /// Evaluates the specified expression with the given input and arguments, if any, and returns the result as a boolean value.
+ ///
+ /// The to use to evaluate the expression
+ /// The expression to evaluate
+ /// The input to evaluate the expression with
+ /// The arguments, if any, to evaluate the expression with
+ /// A
+ /// A boolean indicating whether the condition specified by the expression is satisfied or not
+ public static async Task EvaluateConditionAsync(this IRuntimeExpressionEvaluator expressionEvaluator, string expression, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default)
+ {
+ var node = await expressionEvaluator.EvaluateAsync(expression, input, arguments, cancellationToken);
+ if (node is null) return false;
+ return node.GetValue();
+ }
+
+ ///
+ /// Evaluates the specified value, which can be either a , an ISO 8601 duration expression or a runtime expression, with the given input and arguments, if any.
+ ///
+ /// The to use to evaluate the value, if it's a runtime expression
+ /// The value to evaluate, which can be either a , an ISO 8601 duration expression or a runtime expression
+ /// The input to evaluate the value with
+ /// The arguments, if any, to evaluate the value with
+ /// A
+ /// The result, if any, of the value evaluation
+ public static async Task EvaluateAsync(this IRuntimeExpressionEvaluator expressionEvaluator, OneOf? value, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default)
+ {
+ return value is null ? null : await value.MatchAsync
+ (
+ async (timeout, ct) => await expressionEvaluator.EvaluateAsync(timeout.After, input, arguments, ct).ConfigureAwait(false),
+ async (expression, ct) =>
+ {
+ if (!expression.IsRuntimeExpression()) return Duration.FromTimeSpan(System.Xml.XmlConvert.ToTimeSpan(expression));
+ var node = await expressionEvaluator.EvaluateAsync(expression, input, arguments, ct).ConfigureAwait(false);
+ if (node is null) return null!;
+ return JsonSerializer.Deserialize(node, Serialization.Json.JsonSerializationContext.Default.Duration);
+ },
+ cancellationToken
+ );
+ }
+
+ ///
+ /// Evaluates the specified value, which can be either a , an ISO 8601 duration expression or a runtime expression, with the given input and arguments, if any.
+ ///
+ /// The to use to evaluate the value, if it's a runtime expression
+ /// The value to evaluate, which can be either a , an ISO 8601 duration expression or a runtime expression
+ /// The input to evaluate the value with
+ /// The arguments, if any, to evaluate the value with
+ /// A
+ /// The result, if any, of the value evaluation
+ public static async Task EvaluateAsync(this IRuntimeExpressionEvaluator expressionEvaluator, OneOf? value, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default)
+ {
+ return value is null ? null : await value.MatchAsync
+ (
+ (duration, ct) => Task.FromResult(duration),
+ async (expression, ct) =>
+ {
+ if (!expression.IsRuntimeExpression()) return Duration.FromTimeSpan(System.Xml.XmlConvert.ToTimeSpan(expression));
+ var node = await expressionEvaluator.EvaluateAsync(expression, input, arguments, ct).ConfigureAwait(false);
+ if (node is null) return null!;
+ return JsonSerializer.Deserialize(node, Serialization.Json.JsonSerializationContext.Default.Duration);
+ },
+ cancellationToken
+ );
+ }
+
+ ///
+ /// Evaluates the specified value, which can be either a , a JSON string or a runtime expression, with the given input and arguments, if any.
+ ///
+ /// The to use to evaluate the value, if it's a runtime expression
+ /// The value to evaluate, which can be either a , a JSON string or a runtime expression
+ /// The input to evaluate the value with
+ /// The arguments, if any, to evaluate the value with
+ /// A
+ /// The result, if any, of the value evaluation
+ public static async Task EvaluateAsync(this IRuntimeExpressionEvaluator expressionEvaluator, OneOf? value, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default)
+ {
+ if (value is null) return null;
+ return await value.MatchAsync
+ (
+ async (jsonObject, ct) => await expressionEvaluator.EvaluateAsync(jsonObject, input, arguments, cancellationToken).ConfigureAwait(false),
+ async (expression, ct) => await expressionEvaluator.EvaluateAsync(expression, input, arguments, ct).ConfigureAwait(false),
+ cancellationToken
+ );
+ }
+
+ ///
+ /// Evaluates the specified , if any.
+ ///
+ /// The to use to evaluate the value, if it's a runtime expression
+ /// The to evaluate, if any
+ /// The input to evaluate the value with
+ /// The arguments, if any, to evaluate the value with
+ /// A
+ /// The result, if any, of the value evaluation
+ public static async Task EvaluateAsync(this IRuntimeExpressionEvaluator expressionEvaluator, JsonNode? value, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default)
+ {
+ if (value is null) return null;
+ return value switch
+ {
+ JsonArray jsonArray => await expressionEvaluator.EvaluateAsync(jsonArray, input, arguments, cancellationToken).ConfigureAwait(false),
+ JsonObject jsonObject => await expressionEvaluator.EvaluateAsync(jsonObject, input, arguments, cancellationToken).ConfigureAwait(false),
+ JsonValue jsonValue => await expressionEvaluator.EvaluateAsync(jsonValue, input, arguments, cancellationToken).ConfigureAwait(false),
+ _ => value
+ };
+ }
+
+ ///
+ /// Evaluates the specified , if any.
+ ///
+ /// The to use to evaluate the value, if it's a runtime expression
+ /// The to evaluate, if any
+ /// The input to evaluate the value with
+ /// The arguments, if any, to evaluate the value with
+ /// A
+ /// The result, if any, of the value evaluation
+ public static async Task EvaluateAsync(this IRuntimeExpressionEvaluator expressionEvaluator, JsonArray? value, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default)
+ {
+ if (value is null) return null;
+ var nodes = new List(value.Count);
+ foreach (var node in value) nodes.Add(await expressionEvaluator.EvaluateAsync(node, input, arguments, cancellationToken).ConfigureAwait(false) ?? throw new InvalidOperationException("Unexpected null value"));
+ return new JsonArray(nodes.ToArray());
+ }
+
+ ///
+ /// Evaluates the specified , if any.
+ ///
+ /// The to use to evaluate the value, if it's a runtime expression
+ /// The to evaluate, if any
+ /// The input to evaluate the value with
+ /// The arguments, if any, to evaluate the value with
+ /// A
+ /// The result, if any, of the value evaluation
+ public static async Task EvaluateAsync(this IRuntimeExpressionEvaluator expressionEvaluator, JsonObject? value, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default)
+ {
+ if (value is null) return null;
+ var properties = new List>(value.Count);
+ foreach (var property in value) properties.Add(new KeyValuePair(property.Key, (await expressionEvaluator.EvaluateAsync(property.Value, input, arguments, cancellationToken).ConfigureAwait(false) ?? throw new InvalidOperationException("Unexpected null value")).DeepClone()));
+ return new JsonObject(properties);
+ }
+
+ ///
+ /// Evaluates the specified , if any.
+ ///
+ /// The to use to evaluate the value, if it's a runtime expression
+ /// The to evaluate, if any
+ /// The input to evaluate the value with
+ /// The arguments, if any, to evaluate the value with
+ /// A
+ /// The result, if any, of the value evaluation
+ public static async Task EvaluateAsync(this IRuntimeExpressionEvaluator expressionEvaluator, JsonValue? value, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default)
+ {
+ if (value is null) return null;
+ if (value.TryGetValue(out var expression) && expression.IsRuntimeExpression()) return await expressionEvaluator.EvaluateAsync(expression, input, arguments, cancellationToken).ConfigureAwait(false);
+ return value;
+ }
+
+ ///
+ /// Evaluates the specified expression with the given input and arguments, if any, and returns the result as a value of the specified type.
+ ///
+ /// The type to deserialize the result of the expression evaluation to
+ /// The to use to evaluate the expression
+ /// The expression to evaluate
+ /// The input to evaluate the expression with
+ /// The arguments, if any, to evaluate the expression with
+ /// A
+ /// The result of the expression evaluation deserialized to the specified type, if any
+ public static async Task EvaluateAsync(this IRuntimeExpressionEvaluator expressionEvaluator, string expression, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default)
+ {
+ var node = await expressionEvaluator.EvaluateAsync(expression, input, arguments, cancellationToken).ConfigureAwait(false);
+ if (node is null) return default;
+ var typeInfo = Serialization.Json.JsonSerializationContext.Default.GetTypeInfo(typeof(T));
+ if (typeInfo is null) return JsonSerializer.Deserialize(node);
+ return (T?)JsonSerializer.Deserialize(node, typeInfo);
+ }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/ITaskExecutionContextExtensions.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/ITaskExecutionContextExtensions.cs
new file mode 100644
index 0000000..1bc4211
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/ITaskExecutionContextExtensions.cs
@@ -0,0 +1,43 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma warning disable IDE0130 // Namespace does not match folder structure
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines extensions for s
+///
+public static class ITaskExecutionContextExtensions
+{
+
+ ///
+ /// Gets a new used to describe the
+ ///
+ /// The to describe
+ /// A new
+ public static TaskDescriptor GetDescriptor(this ITaskExecutionContext task)
+ {
+ return new()
+ {
+ Id = task.Instance.Id,
+ Name = task.Instance.Name,
+ Reference = task.Instance.Reference,
+ Definition = task.Definition,
+ Input = task.Instance.Input,
+ Output = task.Instance.Output,
+ StartedAt = task.Instance.StartedAt?.GetDescriptor()
+ };
+ }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IWorkflowExecutionContextExtensions.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IWorkflowExecutionContextExtensions.cs
new file mode 100644
index 0000000..39c6334
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IWorkflowExecutionContextExtensions.cs
@@ -0,0 +1,40 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma warning disable IDE0130 // Namespace does not match folder structure
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines extensions for s
+///
+public static class IWorkflowExecutionContextExtensions
+{
+
+ ///
+ /// Gets a new used to describe the
+ ///
+ /// The to describe
+ /// A new
+ public static WorkflowDescriptor GetDescriptor(this IWorkflowExecutionContext workflow)
+ {
+ return new()
+ {
+ Id = workflow.Instance.Id,
+ Definition = workflow.Definition,
+ Input = workflow.Instance.Input,
+ StartedAt = workflow.Instance.StartedAt?.GetDescriptor()
+ };
+ }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IWorkflowStateExtensions.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IWorkflowStateExtensions.cs
new file mode 100644
index 0000000..5bf9440
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Extensions/IWorkflowStateExtensions.cs
@@ -0,0 +1,31 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma warning disable IDE0130 // Namespace does not match folder structure
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines extensions for s
+///
+public static class IWorkflowStateExtensions
+{
+
+ ///
+ /// Gets the qualified name of the 's definition, in the format {namespace}.{name}:{version}
+ ///
+ /// The to get the qualified name of
+ ///
+ public static string GetQualifiedName(this IWorkflowInstance state) => $"{state.Definition}-{state.Id}";
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk/IOneOf.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IAuthenticationResult.cs
similarity index 69%
rename from src/ServerlessWorkflow.Sdk/IOneOf.cs
rename to src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IAuthenticationResult.cs
index 9d2a565..d936418 100644
--- a/src/ServerlessWorkflow.Sdk/IOneOf.cs
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IAuthenticationResult.cs
@@ -11,18 +11,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-namespace ServerlessWorkflow.Sdk;
+namespace ServerlessWorkflow.Sdk.Runtime;
///
-/// Defines the fundamentals of a service that wraps around multiple alternative value types
+/// Defines the fundamentals of an authentication result
///
-public interface IOneOf
+public interface IAuthenticationResult
{
///
- /// Gets the object's current value
+ /// Gets the authentication scheme
///
- /// The object's current value
- object? GetValue();
+ string Scheme { get; }
-}
\ No newline at end of file
+ ///
+ /// Gets the authentication value
+ ///
+ string Value { get; }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ICloudEvent.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ICloudEvent.cs
new file mode 100644
index 0000000..956af25
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ICloudEvent.cs
@@ -0,0 +1,72 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of a Cloud Event
+///
+public interface ICloudEvent
+{
+
+ ///
+ /// Gets/sets the version of the CloudEvents specification which the event uses
+ ///
+ string SpecVersion { get; }
+
+ ///
+ /// Gets/sets the date and time at which the event has been produced
+ ///
+ DateTimeOffset? Time { get; }
+
+ ///
+ /// Gets/sets the cloud event's type
+ ///
+ Uri Source { get; }
+
+ ///
+ /// Gets/sets the cloud event's type
+ ///
+ string Type { get; }
+
+ ///
+ /// Gets/sets a value that describes the subject of the event in the context of the event producer. Used as correlation id by default.
+ ///
+ string? Subject { get; }
+
+ ///
+ /// Gets/sets the cloud event's data content type. Defaults to
+ ///
+ string? DataContentType { get; }
+
+ ///
+ /// Gets/sets an that references the versioned schema of the event's data
+ ///
+ Uri? DataSchema { get; }
+
+ ///
+ /// Gets/sets the event's data, if any. Only used if the event has been formatted using the structured mode
+ ///
+ object? Data { get; }
+
+ ///
+ /// Gets/sets the event's binary data, encoded in base 64. Only used if the event has been formatted using the binary mode
+ ///
+ string? DataBase64 { get; }
+
+ ///
+ /// Gets a that contains the event's extension attributes
+ ///
+ IDictionary? ExtensionAttributes { get; }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ICorrelationContext.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ICorrelationContext.cs
new file mode 100644
index 0000000..30ab3ac
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ICorrelationContext.cs
@@ -0,0 +1,47 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of a correlation context
+///
+public interface ICorrelationContext
+{
+
+ ///
+ /// Gets the context's unique identifier
+ ///
+ string Id { get; }
+
+ ///
+ /// Gets the context's status
+ ///
+ string Status { get; }
+
+ ///
+ /// Gets a key/value mapping of the context's correlation keys
+ ///
+ EquatableDictionary Keys { get; }
+
+ ///
+ /// Gets a key/value mapping of all correlated events, with the key being the index of the matched correlation filter
+ ///
+ EquatableDictionary Events { get; }
+
+ ///
+ /// Gets the offset that serves as the index of the event being processed by the consumer, if streaming has been enabled for the correlation associated with the context.
+ ///
+ uint? Offset { get; init; }
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IOAuth2Token.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IOAuth2Token.cs
new file mode 100644
index 0000000..95ca83c
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IOAuth2Token.cs
@@ -0,0 +1,64 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using System.Reflection.Metadata;
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of an OAUTH2 token
+///
+public interface IOAuth2Token
+{
+
+ ///
+ /// Gets the UTC date and time at which the has been created
+ ///
+ DateTime CreatedAt { get; }
+
+ ///
+ /// Gets the OAUTH2 token type
+ ///
+ string? TokenType { get; }
+
+ ///
+ /// Gets the OAUTH2 token id
+ ///
+ string? TokenId { get; }
+
+ ///
+ /// Gets the OAUTH2 access token
+ ///
+ string? AccessToken { get; }
+
+ ///
+ /// Gets the OAUTH2 refresh token
+ ///
+ string? RefreshToken { get; }
+
+ ///
+ /// Gets the Time To Live, in seconds
+ ///
+ int Ttl { get; }
+
+ ///
+ /// Gets the UTC date and time at which the expires
+ ///
+ DateTime? ExpiresAt { get; }
+
+ ///
+ /// Gets a boolean indicating whether or not the has expired
+ ///
+ bool HasExpired { get; }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ISchemaValidationResult.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ISchemaValidationResult.cs
new file mode 100644
index 0000000..34bbd26
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ISchemaValidationResult.cs
@@ -0,0 +1,32 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of a schema validation result
+///
+public interface ISchemaValidationResult
+{
+
+ ///
+ /// Gets a boolean indicating whether or not the validation result is valid
+ ///
+ bool IsValid { get; }
+
+ ///
+ /// Gets a mapping of errors, if any, that occurred during the validation process. The keys of the mapping represent the paths to the invalid nodes, while the values are lists of error messages related to each path.
+ ///
+ IReadOnlyDictionary>? Errors { get; }
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IStreamedCloudEvent.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IStreamedCloudEvent.cs
new file mode 100644
index 0000000..39d181e
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IStreamedCloudEvent.cs
@@ -0,0 +1,39 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of an object used to wrap a streamed
+///
+public interface IStreamedCloudEvent
+{
+
+ ///
+ /// Gets the streamed
+ ///
+ ICloudEvent Event { get; }
+
+ ///
+ /// Gets the position of the within its originating stream
+ ///
+ uint Offset { get; }
+
+ ///
+ /// Acknowledges that the has been successfully processed
+ ///
+ /// A
+ /// A new awaitable
+ Task AckAsync(CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskInstance.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskInstance.cs
new file mode 100644
index 0000000..2fd8d49
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskInstance.cs
@@ -0,0 +1,174 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of a task instance
+///
+public interface ITaskInstance
+{
+
+ ///
+ /// Gets the task's unique identifier
+ ///
+ string Id { get; }
+
+ ///
+ /// Gets the unique identifier of the workflow the task belongs to.
+ ///
+ string WorkflowId { get; }
+
+ ///
+ /// Gets the task's name, if any
+ ///
+ string? Name { get; }
+
+ ///
+ /// Gets a relative uri that references the task's definition
+ ///
+ JsonPointer Reference { get; }
+
+ ///
+ /// Gets a boolean indicating whether or not the task is part of an extension
+ ///
+ bool IsExtension { get; }
+
+ ///
+ /// Gets the id of the task's parent, if any
+ ///
+ string? ParentId { get; }
+
+ ///
+ /// Gets the date and time the task was created at
+ ///
+ DateTimeOffset CreatedAt { get; }
+
+ ///
+ /// Gets the date and time the task has been started at, if applicable
+ ///
+ DateTimeOffset? StartedAt { get; }
+
+ ///
+ /// Gets the date and time the task has ended, if applicable
+ ///
+ DateTimeOffset? EndedAt { get; }
+
+ ///
+ /// Gets the task's status
+ ///
+ string? Status { get; }
+
+ ///
+ /// Gets the reason, if any, why the task is in its actual status
+ ///
+ string? StatusReason { get; }
+
+ ///
+ /// Gets the error, if any, that has occurred during the task's execution
+ ///
+ Error? Error { get; }
+
+ ///
+ /// Gets the task's input data
+ ///
+ JsonNode Input { get; }
+
+ ///
+ /// Gets the task's output data, if any
+ ///
+ JsonNode? Output { get; }
+
+ ///
+ /// Gets the flow directive that must be performed next, if the task ran to completion
+ ///
+ string? Next { get; }
+
+ ///
+ /// Gets a value indicating whether the task is in an operative state
+ ///
+ bool IsOperative => Status == TaskStatus.Pending || Status == TaskStatus.Running || Status == TaskStatus.Suspended;
+
+ ///
+ /// Gets/sets a list that contains the task's runs, if any
+ ///
+ IReadOnlyCollection? Runs { get; }
+
+ ///
+ /// Gets/sets a list that contains the task's retry attempts, if any
+ ///
+ IReadOnlyCollection? Retries { get; }
+
+ ///
+ /// Starts the task
+ ///
+ /// A
+ /// A new awaitable
+ Task StartAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Suspends the task's execution
+ ///
+ /// A
+ /// A new awaitable
+ Task SuspendAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Resumes the task's execution
+ ///
+ /// A
+ /// A new awaitable
+ Task ResumeAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Retries the task's execution
+ ///
+ /// The error that caused the retry
+ /// A
+ /// A new awaitable
+ Task RetryAsync(Error cause, CancellationToken cancellationToken = default);
+
+ ///
+ /// Skips the task
+ ///
+ /// The task's output, if any
+ /// The flow directive that must be performed next
+ /// A
+ /// A new awaitable
+ Task SkipAsync(JsonNode? output, string next, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the task's output
+ ///
+ /// The task's output
+ /// The flow directive that must be performed next
+ /// A
+ /// A new awaitable
+ Task SetOutputAsync(JsonNode? output, string next, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the error that has occurred during the task's execution
+ ///
+ /// The error that has occurred during the task's execution
+ /// A
+ /// A new awaitable
+ Task SetErrorAsync(Error error, CancellationToken cancellationToken = default);
+
+ ///
+ /// Cancels the task's execution
+ ///
+ /// A
+ /// A new awaitable
+ Task CancelAsync(CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk/Validation/Interfaces/IValidationResult.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskLifeCycleEvent.cs
similarity index 63%
rename from src/ServerlessWorkflow.Sdk/Validation/Interfaces/IValidationResult.cs
rename to src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskLifeCycleEvent.cs
index fe330e5..557e1f9 100644
--- a/src/ServerlessWorkflow.Sdk/Validation/Interfaces/IValidationResult.cs
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskLifeCycleEvent.cs
@@ -11,22 +11,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-namespace ServerlessWorkflow.Sdk.Validation;
+namespace ServerlessWorkflow.Sdk.Runtime;
///
-/// Defines the fundamentals of a validation attempt
+/// Defines the fundamentals of a task life cycle event
///
-public interface IValidationResult
+public interface ITaskLifeCycleEvent
{
///
- /// Gets a boolean indicating whether or not the workflow definition is valid
+ /// Gets the type of task life cycle event
///
- bool IsValid { get; }
+ string Type { get; }
///
- /// Gets an containing the errors, if any, that have occurred during validation
+ /// Gets the task life cycle event's data, if any
///
- IReadOnlyCollection? Errors { get; }
+ object? Data { get; }
}
diff --git a/src/ServerlessWorkflow.Sdk/DslVersion.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskRetryAttempt.cs
similarity index 63%
rename from src/ServerlessWorkflow.Sdk/DslVersion.cs
rename to src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskRetryAttempt.cs
index bf7f259..082c480 100644
--- a/src/ServerlessWorkflow.Sdk/DslVersion.cs
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskRetryAttempt.cs
@@ -11,24 +11,27 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-namespace ServerlessWorkflow.Sdk;
+namespace ServerlessWorkflow.Sdk.Runtime;
///
-/// Exposes supported Serverless Workflow DSL versions
+/// Defines the fundamentals of an object used to describe a task retry attempt
///
-public static class DslVersion
+public interface ITaskRetryAttempt
{
+
///
- /// Gets the Serverless Workflow DSL version '1.0.0-alpha1'
+ /// Gets the retry attempt number
///
- public const string V1Alpha1 = "1.0.0-alpha1";
+ uint Number { get; }
+
///
- /// Gets the Serverless Workflow DSL version '1.0.0-alpha2'
+ /// Gets the date and time at which the retry attempt was performed
///
- public const string V1Alpha2 = "1.0.0-alpha2";
+ DateTimeOffset Time { get; }
+
///
- /// Gets the Serverless Workflow DSL version '1.0.0'
+ /// Gets the that is the cause of the try attempt
///
- public const string V1 = "1.0.0";
+ Error Cause { get; }
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskRun.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskRun.cs
new file mode 100644
index 0000000..88cef1f
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskRun.cs
@@ -0,0 +1,37 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the state of a single run of a task
+///
+public interface ITaskRun
+{
+
+ ///
+ /// Gets the start time of the run
+ ///
+ DateTimeOffset StartedAt { get; }
+
+ ///
+ /// Gets the end time of the run, if the task has completed
+ ///
+ DateTimeOffset? EndedAt { get; }
+
+ ///
+ /// Gets the run's outcome or, in other words, the status of the task when the run ended
+ ///
+ string? Outcome { get; }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskStore.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskStore.cs
new file mode 100644
index 0000000..bdfca80
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ITaskStore.cs
@@ -0,0 +1,64 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of a service used to manage s
+///
+public interface ITaskStore
+{
+
+ ///
+ /// Adds a the specified
+ ///
+ /// The to add
+ /// A
+ /// The added
+ Task AddAsync(ITaskInstance instance, CancellationToken cancellationToken = default);
+
+ ///
+ /// Gets the with the specified unique identifier, belonging to the specified workflow
+ ///
+ /// The unique identifier of the workflow the task to get the of belongs to
+ /// The unique identifier of the task to get the of
+ /// A
+ /// The with the specified unique identifier
+ Task GetAsync(string workflowId, string taskId, CancellationToken cancellationToken = default);
+
+ ///
+ /// Lists the s belonging to the specified workflow
+ ///
+ /// The unique identifier of the workflow to list the s of
+ /// A
+ /// A new used to enumerate the s belonging to the specified workflow
+ IAsyncEnumerable ListAsync(string workflowId, CancellationToken cancellationToken = default);
+
+ ///
+ /// Lists the s belonging to the specified task of the specified workflow
+ ///
+ /// The unique identifier of the workflow to list the s of
+ /// The unique identifier of the task to list the s of
+ /// A
+ /// A new used to enumerate the s belonging to the specified task of the specified workflow
+ IAsyncEnumerable ListAsync(string workflowId, string taskId, CancellationToken cancellationToken = default);
+
+ ///
+ /// Updates the specified
+ ///
+ /// The to update
+ /// A
+ /// The updated
+ Task UpdateAsync(ITaskInstance instance, CancellationToken cancellationToken = default);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowInstance.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowInstance.cs
new file mode 100644
index 0000000..81b941f
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowInstance.cs
@@ -0,0 +1,134 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of a workflow instance
+///
+public interface IWorkflowInstance
+{
+
+ ///
+ /// Gets the workflow's unique identifier
+ ///
+ string Id { get; }
+
+ ///
+ /// Gets a reference to the workflow's definition
+ ///
+ WorkflowDefinitionReference Definition { get; }
+
+ ///
+ /// Gets the workflow's status
+ ///
+ string Status { get; }
+
+ ///
+ /// Gets the date and time at which the workflow has been created
+ ///
+ DateTimeOffset CreatedAt { get; }
+
+ ///
+ /// Gets the date and time the workflow has been started at, if applicable
+ ///
+ DateTimeOffset? StartedAt { get; }
+
+ ///
+ /// Gets the date and time the workflow has ended, if applicable
+ ///
+ DateTimeOffset? EndedAt { get; }
+
+ ///
+ /// Gets the workflow's input data
+ ///
+ JsonObject? Input { get; }
+
+ ///
+ /// Gets the workflow's context data
+ ///
+ JsonObject ContextData { get; }
+
+ ///
+ /// Gets the workflow's output data, if any
+ ///
+ JsonNode? Output { get; }
+
+ ///
+ /// Gets the error, if any, that has occurred during the workflow's execution
+ ///
+ Error? Error { get; }
+
+ ///
+ /// Gets a value indicating whether the workflow is in an operative state
+ ///
+ bool IsOperative => Status == TaskStatus.Pending || Status == TaskStatus.Running || Status == TaskStatus.Suspended;
+
+ ///
+ /// Gets a collection containing the workflow's runs
+ ///
+ IReadOnlyCollection? Runs { get; }
+
+ ///
+ /// Starts the workflow
+ ///
+ /// A
+ /// A new awaitable
+ Task StartAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Suspends the workflow's execution
+ ///
+ /// A
+ /// A new awaitable
+ Task SuspendAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Resumes the workflow's execution
+ ///
+ /// A
+ /// A new awaitable
+ Task ResumeAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the workflow's output
+ ///
+ /// The workflow's output
+ /// A
+ /// A new awaitable
+ Task SetOutputAsync(JsonNode? output, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the error that has occurred during the workflow's execution
+ ///
+ /// The error that has occurred during the workflow's execution
+ /// A
+ /// A new awaitable
+ Task SetErrorAsync(Error error, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the workflow's context data
+ ///
+ /// The workflow's context data
+ /// A
+ /// A new awaitable
+ Task SetContextDataAsync(JsonObject contextData, CancellationToken cancellationToken = default);
+
+ ///
+ /// Cancels the workflow's execution
+ ///
+ /// A
+ /// A new awaitable
+ Task CancelAsync(CancellationToken cancellationToken = default);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk/Validation/ValidationError.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowLifeCycleEvent.cs
similarity index 66%
rename from src/ServerlessWorkflow.Sdk/Validation/ValidationError.cs
rename to src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowLifeCycleEvent.cs
index 953986d..b911b05 100644
--- a/src/ServerlessWorkflow.Sdk/Validation/ValidationError.cs
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowLifeCycleEvent.cs
@@ -11,23 +11,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-namespace ServerlessWorkflow.Sdk.Validation;
+namespace ServerlessWorkflow.Sdk.Runtime;
///
-/// Represents a validation error
+/// Defines the fundamentals of a workflow lifecycle event
///
-[DataContract]
-public record ValidationError
+public interface IWorkflowLifeCycleEvent
{
///
- /// Gets the reference, if any, of the component to which the error applies
+ /// Gets the type of workflow lifecycle event
///
- public virtual string? Reference { get; set; }
+ string Type { get; }
///
- /// Gets detailed information, if any, about the validation error
+ /// Gets the workflow lifecycle event's data, if any
///
- public virtual string? Details { get; set; }
+ object? Data { get; }
}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowProcessFactory.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowProcessFactory.cs
new file mode 100644
index 0000000..9ee4995
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowProcessFactory.cs
@@ -0,0 +1,32 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of a service used to create es
+///
+public interface IWorkflowProcessFactory
+{
+
+ ///
+ /// Creates a new
+ ///
+ /// The to create the process for
+ /// The to create the process for
+ /// The options used to configure the workflow's execution
+ /// A
+ /// A new
+ Task CreateAsync(WorkflowDefinition definition, IWorkflowInstance state, WorkflowExecutionsOptions executionOptions, CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowRun.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowRun.cs
new file mode 100644
index 0000000..5f95826
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowRun.cs
@@ -0,0 +1,32 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of a workflow run
+///
+public interface IWorkflowRun
+{
+
+ ///
+ /// Gets/sets the start time of the run
+ ///
+ DateTimeOffset StartedAt { get; }
+
+ ///
+ /// Gets/sets the end time of the run, if the workflow has completed
+ ///
+ DateTimeOffset? EndedAt { get; }
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowStore.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowStore.cs
new file mode 100644
index 0000000..094c488
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/IWorkflowStore.cs
@@ -0,0 +1,47 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime;
+
+///
+/// Defines the fundamentals of a service used to manage s
+///
+public interface IWorkflowStore
+{
+
+ ///
+ /// Adds a the specified
+ ///
+ /// The definition of the workflow to add
+ /// The input of the workflow to add
+ /// A
+ /// The added
+ Task AddAsync(WorkflowDefinition definition, JsonObject? input = null, CancellationToken cancellationToken = default);
+
+ ///
+ /// Gets the with the specified unique identifier, belonging to the specified workflow
+ ///
+ /// The unique identifier of the workflow to get the state of
+ /// A
+ /// The with the specified unique identifier
+ Task GetAsync(string id, CancellationToken cancellationToken = default);
+
+ ///
+ /// Updates the specified
+ ///
+ /// The to update
+ /// A
+ /// The updated
+ Task UpdateAsync(IWorkflowInstance instance, CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ServerlessWorkflow.Sdk.Runtime.Abstractions.csproj b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ServerlessWorkflow.Sdk.Runtime.Abstractions.csproj
new file mode 100644
index 0000000..0f5b288
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/ServerlessWorkflow.Sdk.Runtime.Abstractions.csproj
@@ -0,0 +1,48 @@
+
+
+
+ net10.0
+ enable
+ enable
+ ServerlessWorkflow.Sdk.Runtime
+ true
+ 1.0.2
+ $(VersionPrefix)
+ $(VersionPrefix)
+ en
+ true
+ True
+ true
+ Serverless Workflow SDK - Runtime Abstractions
+ Contains the abstractions for the runtime services used to execute ServerlessWorkflow workflow definitions
+ serverless-workflow;serverless;workflow;dsl;sdk;runtime;abstractions
+ true
+ Apache-2.0
+ README.md
+ Copyright © 2024-Present The Serverless Workflow Authors. All rights reserved.
+ https://github.com/serverlessworkflow/sdk-net
+ https://github.com/serverlessworkflow/sdk-net
+ git
+ embedded
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ \
+ True
+
+
+
+
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IAuthenticationHandler.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IAuthenticationHandler.cs
new file mode 100644
index 0000000..7994d9f
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IAuthenticationHandler.cs
@@ -0,0 +1,31 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to handle authentication policies
+///
+public interface IAuthenticationHandler
+{
+
+ ///
+ /// Handles the specified authentication policy and returns an that can be used to authenticate requests to external resources
+ ///
+ /// The to handle
+ /// The , if any, that defines the authentication policy to handle
+ /// A
+ /// A new
+ Task HandleAsync(AuthenticationPolicyDefinition policy, WorkflowDefinition? workflow = null, CancellationToken cancellationToken = default);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ICloudEventBus.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ICloudEventBus.cs
new file mode 100644
index 0000000..77b23af
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ICloudEventBus.cs
@@ -0,0 +1,37 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to publish and subscribe to s
+///
+public interface ICloudEventBus
+{
+
+ ///
+ /// Publishes the specified
+ ///
+ /// The to publish
+ /// A
+ /// A new awaitable
+ Task PublishAsync(ICloudEvent e, CancellationToken cancellationToken = default);
+
+ ///
+ /// Subscribes to streamed s
+ ///
+ /// A
+ /// A new used to observe streamed s
+ Task> SubscribeAsync(CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IContainer.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IContainer.cs
new file mode 100644
index 0000000..4fd2114
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IContainer.cs
@@ -0,0 +1,59 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a container
+///
+public interface IContainer
+ : IDisposable, IAsyncDisposable
+{
+
+ ///
+ /// Gets the container's standard output stream
+ ///
+ StreamReader? StandardOutput { get; }
+
+ ///
+ /// Gets the container's standard error stream
+ ///
+ StreamReader? StandardError { get; }
+
+ ///
+ /// Gets the container's exit code
+ ///
+ long? ExitCode { get; }
+
+ ///
+ /// Starts the container
+ ///
+ /// A
+ /// A new awaitable
+ Task StartAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Waits for the container to exit
+ ///
+ /// A
+ /// A new awaitable
+ Task WaitForExitAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Stops the container
+ ///
+ /// A
+ /// A new awaitable
+ Task StopAsync(CancellationToken cancellationToken = default);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IContainerRuntime.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IContainerRuntime.cs
new file mode 100644
index 0000000..dbb5756
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IContainerRuntime.cs
@@ -0,0 +1,32 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+using ServerlessWorkflow.Sdk.Models.Processes;
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to create, run and manage the lifecycle of s.
+///
+public interface IContainerRuntime
+{
+
+ ///
+ /// Creates a new container based on the specified
+ ///
+ /// The that defines the container to create
+ /// A
+ /// A new
+ Task CreateAsync(ContainerProcessDefinition definition, CancellationToken cancellationToken = default);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IExternalResourceReader.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IExternalResourceReader.cs
new file mode 100644
index 0000000..3a8e673
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IExternalResourceReader.cs
@@ -0,0 +1,31 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to read external resources
+///
+public interface IExternalResourceReader
+{
+
+ ///
+ /// Reads the specified external resource
+ ///
+ /// The reference to the external resource to get
+ /// The , if any, in the context of which to read the specified resource
+ /// A
+ /// A used to read the external resource's contents
+ Task ReadAsync(ExternalResourceDefinition resource, WorkflowDefinition? workflow = null, CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk/Validation/Interfaces/IWorkflowDefinitionValidator.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IOAuthTokenManager.cs
similarity index 56%
rename from src/ServerlessWorkflow.Sdk/Validation/Interfaces/IWorkflowDefinitionValidator.cs
rename to src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IOAuthTokenManager.cs
index fc2d36b..fe658f3 100644
--- a/src/ServerlessWorkflow.Sdk/Validation/Interfaces/IWorkflowDefinitionValidator.cs
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IOAuthTokenManager.cs
@@ -11,22 +11,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using ServerlessWorkflow.Sdk.Models;
-
-namespace ServerlessWorkflow.Sdk.Validation;
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
///
-/// Defines the fundamentals of a service used to validate s
+/// Defines the fundamentals of a service used to manage s
///
-public interface IWorkflowDefinitionValidator
+public interface IOAuth2TokenManager
{
///
- /// Validates the specified
+ /// Gets an
///
- /// The to validate
+ /// The configuration that defines how to generate the to get
/// A
- /// An object that describe the result of the validation attempt
- Task ValidateAsync(WorkflowDefinition workflowDefinition, CancellationToken cancellationToken = default);
+ /// An
+ Task GetTokenAsync(OAuth2AuthenticationSchemeDefinitionBase configuration, CancellationToken cancellationToken = default);
-}
\ No newline at end of file
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IRuntimeExpressionEvaluator.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IRuntimeExpressionEvaluator.cs
new file mode 100644
index 0000000..5020a07
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IRuntimeExpressionEvaluator.cs
@@ -0,0 +1,39 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to evaluate runtime expressions
+///
+public interface IRuntimeExpressionEvaluator
+{
+
+ ///
+ /// Determines whether the specified language is supported by the expression evaluator
+ ///
+ /// The expression language to check
+ /// A boolean indicating whether the specified language is supported by the expression evaluator
+ bool Supports(string language);
+
+ ///
+ /// Evaluates the specified expression with the given input and arguments, if any
+ ///
+ /// The expression to evaluate
+ /// The input to evaluate the expression with
+ /// The arguments, if an, to evaluate the expression with
+ /// A
+ /// The result, if any, of the expression evaluation
+ Task EvaluateAsync(string expression, JsonNode input, JsonObject? arguments = null, CancellationToken cancellationToken = default);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IRuntimeExpressionEvaluatorProvider.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IRuntimeExpressionEvaluatorProvider.cs
new file mode 100644
index 0000000..a878f98
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IRuntimeExpressionEvaluatorProvider.cs
@@ -0,0 +1,29 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to provide runtime expression evaluators
+///
+public interface IRuntimeExpressionEvaluatorProvider
+{
+
+ ///
+ /// Gets an that supports the specified language, if any
+ ///
+ /// The expression language to get an for
+ /// The first registered , if any, that supports the specified expression language
+ IRuntimeExpressionEvaluator? GetEvaluator(string language);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ISchemaHandler.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ISchemaHandler.cs
new file mode 100644
index 0000000..a18b1c5
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ISchemaHandler.cs
@@ -0,0 +1,38 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to handle s
+///
+public interface ISchemaHandler
+{
+
+ ///
+ /// Determines whether or not the supports the specified schema format
+ ///
+ /// The format to check
+ /// A boolean indicating whether or not the supports the specified schema format
+ bool Supports(string format);
+
+ ///
+ /// Validates an object against the specified schema
+ ///
+ /// The object to validate
+ /// The schema to validate the graph against
+ /// A
+ /// An object that describes the validation result
+ Task ValidateAsync(JsonNode graph, SchemaDefinition schema, CancellationToken cancellationToken = default);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ISchemaHandlerProvider.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ISchemaHandlerProvider.cs
new file mode 100644
index 0000000..27c3e68
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ISchemaHandlerProvider.cs
@@ -0,0 +1,29 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to provide s
+///
+public interface ISchemaHandlerProvider
+{
+
+ ///
+ /// Gets the first registered that supports the specified schema format
+ ///
+ /// The schema format to get an for
+ /// The first registered , if any, that supports the specified schema format
+ ISchemaHandler? GetHandler(string format);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IScriptExecutor.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IScriptExecutor.cs
new file mode 100644
index 0000000..1184ae7
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IScriptExecutor.cs
@@ -0,0 +1,39 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to execute scripts
+///
+public interface IScriptExecutor
+{
+
+ ///
+ /// Determines whether this supports executing scripts written in the specified language
+ ///
+ /// The language to check for support
+ /// A boolean indicating whether this supports executing scripts written in the specified language
+ bool Supports(string language);
+
+ ///
+ /// Executes a script with the specified code, language, arguments and environment variables, returning the associated
+ ///
+ /// The code of the script to execute
+ /// An optional collection of arguments to pass to the script being executed
+ /// A optional dictionary of environment variables to set for the script being executed
+ /// A
+ /// A new used to execute the script
+ Task ExecuteAsync(string script, IEnumerable? arguments = null, IDictionary? environment = null, CancellationToken cancellationToken = default);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IScriptExecutorProvider.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IScriptExecutorProvider.cs
new file mode 100644
index 0000000..76f6385
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IScriptExecutorProvider.cs
@@ -0,0 +1,29 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to provide s
+///
+public interface IScriptExecutorProvider
+{
+
+ ///
+ /// Gets the for the specified language.
+ ///
+ /// The scripting language.
+ /// The for the specified language.
+ IScriptExecutor? GetExecutor(string language);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ISecretsManager.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ISecretsManager.cs
new file mode 100644
index 0000000..a95703e
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ISecretsManager.cs
@@ -0,0 +1,29 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to manage secrets
+///
+public interface ISecretsManager
+{
+
+ ///
+ /// Gets all available secrets
+ ///
+ /// A
+ /// A new that contains the key/value mappings of all available secrets
+ Task> GetAsync(CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutionContext.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutionContext.cs
new file mode 100644
index 0000000..3efef61
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutionContext.cs
@@ -0,0 +1,150 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of the context of a task's execution
+///
+public interface ITaskExecutionContext
+{
+
+ ///
+ /// Gets the workflow the task to execute belongs to
+ ///
+ IWorkflowExecutionContext Workflow { get; }
+
+ ///
+ /// Gets the of the task to execute
+ ///
+ TaskDefinition Definition { get; }
+
+ ///
+ /// Gets the task to execute
+ ///
+ ITaskInstance Instance { get; }
+
+ ///
+ /// Gets a name/value mapping of the task's arguments, if any
+ ///
+ JsonObject? Arguments { get; }
+
+ ///
+ /// Executes the task
+ ///
+ /// A
+ /// A new awaitable
+ Task StartAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Streams events
+ ///
+ /// A
+ /// A new used to stream s
+ Task> StreamAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Begins correlating events
+ ///
+ /// A
+ /// The resulting
+ Task CorrelateAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Publishes the specified
+ ///
+ /// The to publish
+ /// A
+ /// A new awaitable
+ Task PublishAsync(ICloudEvent e, CancellationToken cancellationToken = default);
+
+ ///
+ /// Suspends the task
+ ///
+ /// A
+ /// A new awaitable
+ Task SuspendAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Retries the task
+ ///
+ /// The to retry the task for
+ /// A
+ /// A new awaitable
+ Task RetryAsync(Error cause, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets an that has occurred during the task's execution
+ ///
+ /// The that has occurred
+ /// A
+ /// A new awaitable
+ Task SetErrorAsync(Error error, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the task's result, if any
+ ///
+ /// The task's result, if any
+ /// The to perform next
+ /// A
+ /// A new awaitable
+ Task SetResultAsync(JsonNode? result, string? then = FlowDirective.Continue, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the task's context data
+ ///
+ /// The task's context data
+ /// A
+ /// A new awaitable
+ Task SetContextDataAsync(JsonObject contextData, CancellationToken cancellationToken = default);
+
+ ///
+ /// Skips the task
+ ///
+ /// The task's result, if any
+ /// The to perform next
+ /// A
+ /// A new awaitable
+ Task SkipAsync(JsonNode? result, string? then = FlowDirective.Continue, CancellationToken cancellationToken = default);
+
+ ///
+ /// Cancels the task
+ ///
+ /// A
+ /// A new awaitable
+ Task CancelAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Gets the subtasks the task is made out of
+ ///
+ /// A
+ /// A new used to enumerate subtasks
+ IAsyncEnumerable GetSubTasksAsync(CancellationToken cancellationToken = default);
+
+}
+
+///
+/// Defines the fundamentals of the context of a task's execution
+///
+/// The type of task to run
+public interface ITaskExecutionContext
+ : ITaskExecutionContext
+ where TDefinition : TaskDefinition
+{
+
+ ///
+ /// Gets the of the task to execute
+ ///
+ new TDefinition Definition { get; }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutionContextFactory.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutionContextFactory.cs
new file mode 100644
index 0000000..9366ecb
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutionContextFactory.cs
@@ -0,0 +1,32 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to create s
+///
+public interface ITaskExecutionContextFactory
+{
+
+ ///
+ /// Creates a new implementation for the
+ ///
+ /// The the belongs to
+ /// The of the to run
+ /// The to run
+ /// A name/value mapping of the task's arguments, if any
+ /// A new
+ ITaskExecutionContext Create(IWorkflowExecutionContext workflow, TaskDefinition definition, ITaskInstance instance, JsonObject? arguments = null);
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutor.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutor.cs
new file mode 100644
index 0000000..4192be0
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutor.cs
@@ -0,0 +1,96 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to execute a task
+///
+public interface ITaskExecutor
+ : IObservable, IDisposable, IAsyncDisposable
+{
+
+ ///
+ /// Gets the to run
+ ///
+ ITaskExecutionContext Task { get; }
+
+ ///
+ /// Initializes the task
+ ///
+ /// A
+ /// A new awaitable
+ Task InitializeAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Runs the task
+ ///
+ /// A
+ /// A new awaitable
+ Task ExecuteAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Suspends the task
+ ///
+ /// A
+ /// A new awaitable
+ Task SuspendAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Retries to run the task
+ ///
+ /// The that caused the retry attempt
+ /// A
+ /// A new awaitable
+ Task RetryAsync(Error cause, CancellationToken cancellationToken = default);
+
+ ///
+ /// Faults the handled task
+ ///
+ ///
+ /// A
+ /// A new awaitable
+ Task SetErrorAsync(Error error, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the task's result and transitions to ''.
+ ///
+ /// The task's result, if any
+ /// The to perform next
+ /// A
+ /// A new awaitable
+ Task SetResultAsync(JsonNode? result = null, string? then = FlowDirective.Continue, CancellationToken cancellationToken = default);
+
+ ///
+ /// Cancels the task
+ ///
+ /// A
+ /// A new awaitable
+ Task CancelAsync(CancellationToken cancellationToken = default);
+
+}
+
+///
+/// Defines the fundamentals of a service used to execute a task
+///
+public interface ITaskExecutor
+ : ITaskExecutor
+ where TDefinition : TaskDefinition
+{
+
+ ///
+ /// Gets the to run
+ ///
+ new ITaskExecutionContext Task { get; }
+
+}
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutorFactory.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutorFactory.cs
new file mode 100644
index 0000000..5724c93
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/ITaskExecutorFactory.cs
@@ -0,0 +1,38 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to create s
+///
+public interface ITaskExecutorFactory
+{
+
+ ///
+ /// Creates a new for the specified task
+ ///
+ /// The to create a new for
+ /// A new for the specified task
+ ITaskExecutor Create(ITaskExecutionContext context);
+
+ ///
+ /// Creates a new for the specified task
+ ///
+ /// The of the task to execute
+ /// The to create a new for
+ /// A new for the specified task
+ ITaskExecutor Create(ITaskExecutionContext context)
+ where TDefinition : TaskDefinition;
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowDefinitionStore.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowDefinitionStore.cs
new file mode 100644
index 0000000..6ef6633
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowDefinitionStore.cs
@@ -0,0 +1,64 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to manage s
+///
+public interface IWorkflowDefinitionStore
+{
+
+ ///
+ /// Adds the specified
+ ///
+ /// The to add
+ /// A
+ /// A new awaitable
+ Task AddAsync(WorkflowDefinition definition, CancellationToken cancellationToken = default);
+
+ ///
+ /// Gets the with the specified namespace, name and version
+ ///
+ /// The namespace the to get belongs to
+ /// The name of the to get
+ /// The version, if any, of the to get. If not set, defaults to latest version
+ /// A
+ /// The with the specified namespace, name and version, or null if not found
+ Task GetAsync(string @namespace, string name, string? version = null, CancellationToken cancellationToken = default);
+
+ ///
+ /// Lists all s
+ ///
+ /// A
+ /// A new used to enumerate s
+ IAsyncEnumerable ListAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Lists all s belonging to the specified namespace
+ ///
+ /// The namespace to list s from
+ /// A
+ /// A new used to enumerate s
+ IAsyncEnumerable ListAsync(string @namespace, CancellationToken cancellationToken = default);
+
+ ///
+ /// Lists all versions of the specified
+ ///
+ /// The namespace the to list versions of belongs to
+ /// The name of the to list versions of
+ /// A
+ /// A new used to enumerate s
+ IAsyncEnumerable ListAsync(string @namespace, string name, CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowExecutionContext.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowExecutionContext.cs
new file mode 100644
index 0000000..9880af1
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowExecutionContext.cs
@@ -0,0 +1,140 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of the context of a workflow's execution
+///
+public interface IWorkflowExecutionContext
+{
+
+ ///
+ /// Gets the of the current workflow
+ ///
+ WorkflowDefinition Definition { get; }
+
+ ///
+ /// Gets the current
+ ///
+ IWorkflowInstance Instance { get; }
+
+ ///
+ /// Gets the current
+ ///
+ IRuntimeExpressionEvaluator Expressions { get; }
+
+ ///
+ /// Gets the service used to run the workflow
+ ///
+ IWorkflowRuntime Runtime { get; }
+
+ ///
+ /// Gets the options used to configure the workflow's execution
+ ///
+ WorkflowExecutionsOptions Options { get; }
+
+ ///
+ /// Gets a new , if any, containing the runtime expression evaluation arguments for the to run
+ ///
+ /// A new , if any, containing the runtime expression evaluation arguments for the to run
+ JsonObject GetExpressionEvaluationArguments();
+
+ ///
+ /// Continues execution with the provided
+ ///
+ /// The to continue with
+ /// A
+ /// A new awaitable
+ Task ContinueWithAsync(TaskDefinition task, CancellationToken cancellationToken = default);
+
+ ///
+ /// Creates a new
+ ///
+ /// The of the to create
+ /// The path used to reference the of the to create
+ /// The input data, if any
+ /// The parent of the to create, if any
+ /// Indicates whether or not the task is part of an extension
+ /// A
+ /// The updated
+ Task CreateTaskAsync(TaskDefinition definition, JsonPointer path, JsonNode input, ITaskExecutionContext? parent = null, bool isExtension = false, CancellationToken cancellationToken = default);
+
+ ///
+ /// Gets the workflow's tasks
+ ///
+ /// A
+ /// A new to asynchronously enumerate the tasks the workflow owns
+ IAsyncEnumerable GetTasksAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Starts the workflow
+ ///
+ /// A
+ /// A new awaitable
+ Task StartAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Suspends the workflow
+ ///
+ /// A
+ /// A new awaitable
+ Task SuspendAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Resumes the workflow
+ ///
+ /// A
+ /// A new awaitable
+ Task ResumeAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Publishes the specified
+ ///
+ /// The to publish
+ /// A
+ /// A new awaitable
+ Task PublishAsync(ICloudEvent e, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the error that has faulted the workflow's execution
+ ///
+ /// The that has faulted the workflow
+ /// A
+ /// A new awaitable
+ Task SetErrorAsync(Error error, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the workflow's result
+ ///
+ /// The workflow's result, if any
+ /// A
+ /// A new awaitable
+ Task SetResultAsync(JsonNode? result, CancellationToken cancellationToken = default);
+
+ ///
+ /// Sets the workflow's context data
+ ///
+ /// The workflow's context data
+ /// A
+ /// A new awaitable
+ Task SetContextDataAsync(JsonObject contextData, CancellationToken cancellationToken = default);
+
+ ///
+ /// Cancels the workflow's execution
+ ///
+ /// A
+ /// A new awaitable
+ Task CancelAsync(CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowExecutionContextFactory.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowExecutionContextFactory.cs
new file mode 100644
index 0000000..234573a
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowExecutionContextFactory.cs
@@ -0,0 +1,31 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to create s
+///
+public interface IWorkflowExecutionContextFactory
+{
+
+ ///
+ /// Creates a new
+ ///
+ /// The to create the context for
+ /// The to create the context for
+ /// The options used to configure the workflow's execution
+ /// A new
+ IWorkflowExecutionContext Create(WorkflowDefinition definition, IWorkflowInstance instance, WorkflowExecutionsOptions executionsOptions);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowProcess.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowProcess.cs
new file mode 100644
index 0000000..f0dec00
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowProcess.cs
@@ -0,0 +1,52 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a workflow process, which holds the methods to manage a workflow's execution
+///
+public interface IWorkflowProcess
+ : IObservable, IAsyncDisposable
+{
+
+ ///
+ /// Waits for the workflow to reach a non-running state, such as completion, suspension, cancellation, or failure.
+ ///
+ /// A
+ /// A new awaitable
+ Task WaitAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Resumes the workflow
+ ///
+ /// A
+ /// A new awaitable
+ Task ResumeAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Suspends the workflow
+ ///
+ /// A
+ /// A new awaitable
+ Task SuspendAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Cancels the workflow's execution
+ ///
+ /// A
+ /// A new awaitable
+ Task CancelAsync(CancellationToken cancellationToken = default);
+
+}
+
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowRuntime.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowRuntime.cs
new file mode 100644
index 0000000..96f6cda
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowRuntime.cs
@@ -0,0 +1,50 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to execute workflows
+///
+public interface IWorkflowRuntime
+ : IAsyncDisposable
+{
+
+ ///
+ /// Gets an object used to describe the current runtime environment
+ ///
+ RuntimeDescriptor Descriptor { get; }
+
+ ///
+ /// Runs a workflow with the specified name and version, using the provided input
+ ///
+ /// The namespace the workflow to run belongs to
+ /// The name of the workflow to run
+ /// The version, if any, of the workflow to run. If not specified, the latest version will be used
+ /// The input to run the workflow with
+ /// The options used to configure the workflow's execution
+ /// A
+ /// A new
+ Task RunAsync(string @namespace, string name, string? version = null, JsonObject? input = null, WorkflowExecutionsOptions? executionOptions = null, CancellationToken cancellationToken = default);
+
+ ///
+ /// Runs the specified workflow
+ ///
+ /// The definition of the workflow to run
+ /// The input to run the workflow with
+ /// The options used to configure the workflow's execution
+ /// A
+ /// A new
+ Task RunAsync(WorkflowDefinition definition, JsonObject? input = null, WorkflowExecutionsOptions? executionOptions = null, CancellationToken cancellationToken = default);
+
+}
\ No newline at end of file
diff --git a/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowRuntimeBuilder.cs b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowRuntimeBuilder.cs
new file mode 100644
index 0000000..22860ca
--- /dev/null
+++ b/src/ServerlessWorkflow.Sdk.Runtime.Abstractions/Services/IWorkflowRuntimeBuilder.cs
@@ -0,0 +1,350 @@
+// Copyright © 2024-Present The Serverless Workflow Specification Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"),
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace ServerlessWorkflow.Sdk.Runtime.Services;
+
+///
+/// Defines the fundamentals of a service used to build and configure s
+///
+public interface IWorkflowRuntimeBuilder
+{
+
+ ///
+ /// Gets the underlying used to register runtime services
+ ///
+ IServiceCollection Services { get; }
+
+ ///
+ /// Gets the application's
+ ///
+ IConfiguration Configuration { get; }
+
+ ///
+ /// Gets the used to register all runtime services
+ ///
+ ServiceLifetime ServiceLifetime { get; }
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseAuthenticationHandler()
+ where THandler : class, IAuthenticationHandler;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseAuthenticationHandler(Func factory);
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseCloudEventBus()
+ where TBus : class, ICloudEventBus;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseCloudEventBus(Func factory);
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseOAuth2TokenManager()
+ where TManager : class, IOAuth2TokenManager;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseOAuth2TokenManager(Func factory);
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseContainerRuntime()
+ where TRuntime : class, IContainerRuntime;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseContainerRuntime(Func factory);
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseExternalResourceReader()
+ where TReader : class, IExternalResourceReader;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseExternalResourceReader(Func factory);
+
+ ///
+ /// Adds an implementation
+ ///
+ /// The type of to add
+ /// The configured
+ IWorkflowRuntimeBuilder UseRuntimeExpressionEvaluator()
+ where TEvaluator : class, IRuntimeExpressionEvaluator;
+
+ ///
+ /// Adds an implementation
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseRuntimeExpressionEvaluator(Func factory);
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseRuntimeExpressionEvaluatorProvider()
+ where TProvider : class, IRuntimeExpressionEvaluatorProvider;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseRuntimeExpressionEvaluatorProvider(Func factory);
+
+ ///
+ /// Adds an implementation
+ ///
+ /// The type of to add
+ /// The configured
+ IWorkflowRuntimeBuilder UseSchemaHandler()
+ where THandler : class, ISchemaHandler;
+
+ ///
+ /// Adds an implementation
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseSchemaHandler(Func factory);
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseSchemaHandlerProvider()
+ where TProvider : class, ISchemaHandlerProvider;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseSchemaHandlerProvider(Func factory);
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseSecretsManager()
+ where TManager : class, ISecretsManager;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseSecretsManager(Func factory);
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseScriptExecutor()
+ where TExecutor : class, IScriptExecutor;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseScriptExecutor(Func factory);
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// The type of to use
+ /// The configured
+ IWorkflowRuntimeBuilder UseScriptExecutorProvider()
+ where TProvider : class, IScriptExecutorProvider;
+
+ ///
+ /// Configures the implementation to use
+ ///
+ /// A factory function used to create the
+ /// The configured
+ IWorkflowRuntimeBuilder UseScriptExecutorProvider(Func factory);
+
+ ///
+ /// Registers a for the specified type
+ ///
+ /// The type of handled by the executor
+ /// The type of to register
+ /// The configured
+ IWorkflowRuntimeBuilder UseTaskExecutor()
+ where TDefinition : TaskDefinition
+ where TExecutor : class, ITaskExecutor;
+
+ ///
+ /// Registers a for the specified call type (e.g. "http", "openapi", "asyncapi", "grpc")
+ ///
+ /// The call type discriminator to register the executor for
+ /// The type of to register
+ /// The configured
+ IWorkflowRuntimeBuilder UseCallTaskExecutor(string callType)
+ where TExecutor : class, ITaskExecutor;
+
+ ///
+ /// Registers a for the specified process type (e.g. "container", "shell", "script", "workflow")
+ ///
+ /// The process type discriminator to register the executor for
+ /// The type of to register
+ /// The configured
+ IWorkflowRuntimeBuilder UseRunTaskExecutor(string processType)
+ where TExecutor : class, ITaskExecutor;
+
+ ///