diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ce999a0..59108ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,6 @@ jobs: dotnet-version: | 3.1.x 6.0.x - 8.0.x - name: Cleaning run: dotnet clean diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8dd4359..1497297 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,6 @@ jobs: dotnet-version: | 3.1.x 6.0.x - 8.0.x - name: Cleaning run: dotnet clean diff --git a/sdk/DTO/ActionDefinition.cs b/sdk/DTO/ActionDefinition.cs new file mode 100644 index 0000000..650645d --- /dev/null +++ b/sdk/DTO/ActionDefinition.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public class ActionDefinition + { + [JsonPropertyName("text")] public string Text { get; set; } + [JsonPropertyName("workflow")] public string Workflow { get; set; } + + /// + /// Exclusively used to capture non-spec items + /// + [JsonExtensionData] + public Dictionary AdditionalFields { get; set; } + } +} diff --git a/sdk/DTO/AttributeDefinition.cs b/sdk/DTO/AttributeDefinition.cs new file mode 100644 index 0000000..bdd193b --- /dev/null +++ b/sdk/DTO/AttributeDefinition.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public class AttributeConverter : JsonConverter + { + public override AttributeDefinitionBase Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case JsonTokenType.String: + return new AttributeStringDefinition { Value = reader.GetString() ?? "" }; + case JsonTokenType.StartObject: + var node = JsonNode.Parse(ref reader); + var t = node.Deserialize(); + return t; + default: + throw new Exception($"{reader.TokenType} is not supported as AttributeDefinition"); + } + } + + public override void Write(Utf8JsonWriter writer, AttributeDefinitionBase value, JsonSerializerOptions options) + { + var jsonString = value switch + { + AttributeObjectDefinition attributeObjectDefinition => + JsonSerializer.Serialize(attributeObjectDefinition), + AttributeStringDefinition attributeStringDefinition => + JsonSerializer.Serialize(attributeStringDefinition), + _ => throw new ArgumentException($"{value.GetType()} is not supported") + }; + + var jsonNode = JsonNode.Parse(jsonString); + jsonNode?.WriteTo(writer, options); + } + } + + [JsonConverter(typeof(AttributeConverter))] + public abstract class AttributeDefinitionBase + { + } + + public class AttributeStringDefinition : AttributeDefinitionBase + { + public string Value { get; set; } + } + + public class AttributeObjectDefinition : AttributeDefinitionBase + { + [JsonPropertyName("isPrimaryField")] public bool IsPrimaryField { get; set; } + + [JsonPropertyName("moduleSource")] public string ModuleSource { get; set; } + + [JsonPropertyName("moduleLocation")] public string ModuleLocation { get; set; } + + [JsonPropertyName("type")] public TypeDefinition AttributeType { get; set; } + + /// + /// Exclusively used to capture non-spec items + /// + [JsonExtensionData] + public Dictionary AdditionalFields { get; set; } + } + + public class TypeDefinition + { + [JsonPropertyName("type")] public string Type { get; set; } + [JsonPropertyName("referenceType")] public string ReferenceType { get; set; } + + [JsonPropertyName("options")] public Dictionary Options { get; set; } + + /// + /// Exclusively used to capture non-spec items + /// + [JsonExtensionData] + public Dictionary AdditionalFields { get; set; } + } +} diff --git a/sdk/DTO/EntityDefinition.cs b/sdk/DTO/EntityDefinition.cs new file mode 100644 index 0000000..836264c --- /dev/null +++ b/sdk/DTO/EntityDefinition.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public class EntityDefinition + { + [JsonPropertyName("pluralName")] public string PluralName { get; set; } + [JsonPropertyName("description")] public string Description { get; set; } + [JsonPropertyName("attributes")] public Dictionary Attributes { get; set; } + [JsonPropertyName("wizards")] public Dictionary Wizards { get; set; } + + /// + /// Exclusively used to capture non-spec items + /// + [JsonExtensionData] + public Dictionary AdditionalFields { get; set; } + } +} diff --git a/sdk/DTO/ManifestDefinition.cs b/sdk/DTO/ManifestDefinition.cs new file mode 100644 index 0000000..14868b4 --- /dev/null +++ b/sdk/DTO/ManifestDefinition.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public class ManifestDefinition + { + [JsonPropertyName("entities")] public Dictionary Entities { get; set; } + } +} diff --git a/sdk/DTO/MessageDefinition.cs b/sdk/DTO/MessageDefinition.cs new file mode 100644 index 0000000..8a3ed1d --- /dev/null +++ b/sdk/DTO/MessageDefinition.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public class MessageDefinition + { + [JsonPropertyName("title")] public string? Title { get; set; } + } +} diff --git a/sdk/DTO/StringOrBoolean.cs b/sdk/DTO/StringOrBoolean.cs new file mode 100644 index 0000000..037d16c --- /dev/null +++ b/sdk/DTO/StringOrBoolean.cs @@ -0,0 +1,30 @@ +namespace EAVFW.Extensions.Manifest.SDK +{ + public struct StringOrBoolean + { + public StringOrBoolean(string stringValue) + { + StringValue = stringValue; + IsBool = false; + BooleanValue = default; + } + + public StringOrBoolean(bool booleanValue) + { + StringValue = default; + IsBool = false; + BooleanValue = booleanValue; + } + + public string StringValue { get; } + + public bool BooleanValue { get; } + + public bool IsBool { get; } + + public override string ToString() + { + return IsBool ? BooleanValue.ToString() : StringValue; + } + } +} diff --git a/sdk/DTO/TabDefinition.cs b/sdk/DTO/TabDefinition.cs new file mode 100644 index 0000000..e48fb1d --- /dev/null +++ b/sdk/DTO/TabDefinition.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public class TabDefinition + { + [JsonPropertyName("columns")] public JsonElement Columns { get; set; } + + [JsonConverter(typeof(StringOrBooleanTabConverter))] + [JsonPropertyName("visible")] + public StringOrBoolean Visible { get; set; } + + [JsonPropertyName("onTransitionOut")] public TransitionDefinition OnTransitionOut { get; set; } + + [JsonPropertyName("onTransitionIn")] public TransitionDefinition OnTransitionIn { get; set; } + + [JsonPropertyName("actions")] public Dictionary Actions { get; set; } + } +} diff --git a/sdk/DTO/TransitionDefinition.cs b/sdk/DTO/TransitionDefinition.cs new file mode 100644 index 0000000..506789c --- /dev/null +++ b/sdk/DTO/TransitionDefinition.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public class TransitionDefinition + { + [JsonPropertyName("workflow")] public string Workflow { get; set; } + + [JsonPropertyName("message")] public MessageDefinition Message { get; set; } + + [JsonExtensionData] public Dictionary AdditionalData { get; set; } = new Dictionary(); + } +} diff --git a/sdk/DTO/TriggerDefinition.cs b/sdk/DTO/TriggerDefinition.cs new file mode 100644 index 0000000..2b72e01 --- /dev/null +++ b/sdk/DTO/TriggerDefinition.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public struct TriggerDefinition + { + [JsonPropertyName("form")] public string Form { get; set; } + + [JsonPropertyName("ribbon")] public string Ribbon { get; set; } + } +} diff --git a/sdk/DTO/WizardDefinition.cs b/sdk/DTO/WizardDefinition.cs new file mode 100644 index 0000000..593bac5 --- /dev/null +++ b/sdk/DTO/WizardDefinition.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public class WizardDefinition + { + [JsonPropertyName("title")] public string Title { get; set; } + + [JsonPropertyName("triggers")] public Dictionary Triggers { get; set; } + + [JsonPropertyName("tabs")] public Dictionary Tabs { get; set; } + } +} diff --git a/sdk/EAVFW.Extensions.Manifest.SDK.csproj b/sdk/EAVFW.Extensions.Manifest.SDK.csproj index 6b5df2a..d83c851 100644 --- a/sdk/EAVFW.Extensions.Manifest.SDK.csproj +++ b/sdk/EAVFW.Extensions.Manifest.SDK.csproj @@ -20,6 +20,7 @@ + diff --git a/sdk/JsonConverters/StringOrBooleanTabConverter.cs b/sdk/JsonConverters/StringOrBooleanTabConverter.cs new file mode 100644 index 0000000..d5b6895 --- /dev/null +++ b/sdk/JsonConverters/StringOrBooleanTabConverter.cs @@ -0,0 +1,30 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace EAVFW.Extensions.Manifest.SDK +{ + public class StringOrBooleanTabConverter : JsonConverter + { + public override StringOrBoolean Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options) + { + return reader.TokenType switch + { + JsonTokenType.String => new StringOrBoolean(reader.GetString() ?? ""), + JsonTokenType.False => new StringOrBoolean(false), + JsonTokenType.True => new StringOrBoolean(true), + _ => new StringOrBoolean() + }; + } + + public override void Write(Utf8JsonWriter writer, StringOrBoolean value, JsonSerializerOptions options) + { + if (value.IsBool) + writer.WriteBooleanValue(value.BooleanValue); + writer.WriteStringValue(value.StringValue); + } + } +} diff --git a/src/EAVFramework.csproj b/src/EAVFramework.csproj index be1cc95..4aa4183 100644 --- a/src/EAVFramework.csproj +++ b/src/EAVFramework.csproj @@ -29,9 +29,8 @@ - - + @@ -49,5 +48,5 @@ - - + + \ No newline at end of file