Skip to content

Commit 485fd84

Browse files
committed
Add Serverless Workflow Specification v0.5 definition models
1 parent 2947d37 commit 485fd84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3969
-0
lines changed

Diff for: .gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.vscode
2+
.vs
3+
obj/
4+
bin/
5+
**/TestResults
6+
7+
# User-specific VS files
8+
*.suo
9+
*.user
10+
*.userosscache
11+
*.sln.docstates
12+
13+
# JetBrains Rider
14+
.idea/
15+
*.sln.iml

Diff for: media/logos/icon.png

37.2 KB
Loading

Diff for: src/ServerlessWorkflow.Sdk.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31019.35
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerlessWorkflow.Sdk", "ServerlessWorkflow.Sdk\ServerlessWorkflow.Sdk.csproj", "{E174F5CC-F3DC-4370-AAC1-AC1D7724C792}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E174F5CC-F3DC-4370-AAC1-AC1D7724C792}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E174F5CC-F3DC-4370-AAC1-AC1D7724C792}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E174F5CC-F3DC-4370-AAC1-AC1D7724C792}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E174F5CC-F3DC-4370-AAC1-AC1D7724C792}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {1402FB0B-4169-41A6-A372-DA260E79481B}
24+
EndGlobalSection
25+
EndGlobal

Diff for: src/ServerlessWorkflow.Sdk/ActionExecutionMode.cs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
using System.Runtime.Serialization;
18+
19+
namespace ServerlessWorkflow.Sdk.Models
20+
{
21+
22+
/// <summary>
23+
/// Enumerates all types of actions
24+
/// </summary>
25+
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
26+
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Converters.StringEnumConverterFactory))]
27+
public enum ActionExecutionMode
28+
{
29+
/// <summary>
30+
/// Indicates a sequential execution of actions
31+
/// </summary>
32+
[EnumMember(Value = "sequential")]
33+
Sequential,
34+
/// <summary>
35+
/// Indicates a parallel execution of actions
36+
/// </summary>
37+
[EnumMember(Value = "parallel")]
38+
Parallel
39+
}
40+
41+
}

Diff for: src/ServerlessWorkflow.Sdk/ActionType.cs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
using System.Runtime.Serialization;
18+
19+
namespace ServerlessWorkflow.Sdk
20+
{
21+
22+
/// <summary>
23+
/// Enumerates all types of actions
24+
/// </summary>
25+
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
26+
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Converters.StringEnumConverterFactory))]
27+
public enum ActionType
28+
{
29+
/// <summary>
30+
/// Indicates an action that invokes a function
31+
/// </summary>
32+
[EnumMember(Value = "function")]
33+
InvokeFunction,
34+
/// <summary>
35+
/// Indicates an action that produces a cloud event
36+
/// </summary>
37+
[EnumMember(Value = "event")]
38+
PublishEvent
39+
}
40+
41+
}

Diff for: src/ServerlessWorkflow.Sdk/ConditionType.cs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
using System.Runtime.Serialization;
18+
19+
namespace ServerlessWorkflow.Sdk
20+
{
21+
/// <summary>
22+
/// Enumerates all types of conditions
23+
/// </summary>
24+
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
25+
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Converters.StringEnumConverterFactory))]
26+
public enum ConditionType
27+
{
28+
/// <summary>
29+
/// Indicates a transition condition
30+
/// </summary>
31+
[EnumMember(Value = "transition")]
32+
Transition,
33+
/// <summary>
34+
/// Indicates an end condition
35+
/// </summary>
36+
[EnumMember(Value = "end")]
37+
End
38+
}
39+
40+
}

Diff for: src/ServerlessWorkflow.Sdk/EventKind.cs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
using System.Runtime.Serialization;
18+
19+
namespace ServerlessWorkflow.Sdk
20+
{
21+
22+
/// <summary>
23+
/// Enumerates all kinds of workflow events
24+
/// </summary>
25+
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
26+
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Converters.StringEnumConverterFactory))]
27+
public enum EventKind
28+
{
29+
/// <summary>
30+
/// Indicates an event to consume
31+
/// </summary>
32+
[EnumMember(Value = "consumed")]
33+
Consumed,
34+
/// <summary>
35+
/// Indicates an event to produce
36+
/// </summary>
37+
[EnumMember(Value = "produced")]
38+
Produced
39+
}
40+
41+
}
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
using System;
18+
using System.Reflection;
19+
20+
namespace ServerlessWorkflow.Sdk
21+
{
22+
23+
/// <summary>
24+
/// Exposes extensions for <see cref="Type"/>s
25+
/// </summary>
26+
public static class TypeExtensions
27+
{
28+
29+
/// <summary>
30+
/// Gets a boolean indicating whether or not the type is a nullable type
31+
/// </summary>
32+
/// <param name="extended">The extended type</param>
33+
/// <returns>A boolean indicating whether or not the type is a nullable type</returns>
34+
public static bool IsNullable(this Type extended)
35+
{
36+
Type type = extended;
37+
do
38+
{
39+
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
40+
return true;
41+
type = type.BaseType;
42+
}
43+
while (type != null);
44+
return false;
45+
}
46+
47+
/// <summary>
48+
/// Attempts to get a custom attribute of the specified type
49+
/// </summary>
50+
/// <typeparam name="TAttribute">The type of the custom attribute to get</typeparam>
51+
/// <param name="extended">The extended type</param>
52+
/// <param name="attribute">The resulting custom attribute</param>
53+
/// <returns>A boolean indicating whether or not the custom attribute of the specified type could be found</returns>
54+
public static bool TryGetCustomAttribute<TAttribute>(this Type extended, out TAttribute attribute)
55+
where TAttribute : Attribute
56+
{
57+
attribute = extended.GetCustomAttribute<TAttribute>();
58+
return attribute != null;
59+
}
60+
61+
/// <summary>
62+
/// Gets the type's default value
63+
/// </summary>
64+
/// <param name="extended">The extended type</param>
65+
/// <returns>The type's default value</returns>
66+
public static object GetDefaultValue(this Type extended)
67+
{
68+
if (extended.IsValueType)
69+
return Activator.CreateInstance(extended);
70+
else
71+
return null;
72+
}
73+
74+
}
75+
76+
}

Diff for: src/ServerlessWorkflow.Sdk/FunctionType.cs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
using System.Runtime.Serialization;
18+
namespace ServerlessWorkflow.Sdk
19+
{
20+
/// <summary>
21+
/// Enumerates all types of functions
22+
/// </summary>
23+
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
24+
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.Converters.StringEnumConverterFactory))]
25+
public enum FunctionType
26+
{
27+
/// <summary>
28+
/// Indicates a REST function
29+
/// </summary>
30+
[EnumMember(Value = "rest")]
31+
Rest,
32+
/// <summary>
33+
/// Indicates an expression
34+
/// </summary>
35+
[EnumMember(Value = "expression")]
36+
Expression
37+
}
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
namespace ServerlessWorkflow.Sdk.Models
18+
{
19+
20+
/// <summary>
21+
/// Represents the object used to configure how actions filter the state data for both input and output
22+
/// </summary>
23+
public class ActionDataFilterDefinition
24+
{
25+
26+
/// <summary>
27+
/// Gets/sets an expression that filters state data that can be used by the action
28+
/// </summary>
29+
public virtual string FromStateData { get; set; }
30+
31+
/// <summary>
32+
/// Gets/sets an expression that filters the actions data results
33+
/// </summary>
34+
public virtual string Results { get; set; }
35+
36+
/// <summary>
37+
/// Gets/sets an expression that selects a state data element to which the action results should be added/merged into. If not specified denotes the top-level state data element
38+
/// </summary>
39+
public virtual string ToStateData { get; set; }
40+
41+
}
42+
43+
}

0 commit comments

Comments
 (0)