Skip to content

Commit

Permalink
feat: all registry resources
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Oct 23, 2023
1 parent b3aa7ae commit 3118bff
Show file tree
Hide file tree
Showing 72 changed files with 7,024 additions and 39 deletions.
1 change: 1 addition & 0 deletions App/App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<PackageReference Include="Flurl" Version="3.0.7" />
<PackageReference Include="Humanizer" Version="2.14.1" />
<PackageReference Include="Kirinnee.Helper" Version="1.2.0" />
<PackageReference Include="LinqKit.Microsoft.EntityFrameworkCore" Version="7.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-preview.3.23177.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0-preview.4.23259.3">
Expand Down
4 changes: 3 additions & 1 deletion App/Config/settings.pichu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Metrics:
Enabled: true

# Infra-based
Database: {}
Database:
MAIN:
AutoMigrate: false
Cache: {}
BlockStorage: {}
# external
Expand Down
38 changes: 38 additions & 0 deletions App/Error/V1/LikeConflict.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using App.Modules.Common;
using NJsonSchema.Annotations;

namespace App.Error.V1;

[
Description(
"Like conflict error occurs when a user tries to like a template, plugin or processor that they have already liked, or unlike a template, plugin or processor that they have not liked.")
]
internal class LikeConflictError : IDomainProblem
{
public LikeConflictError() { }

public LikeConflictError(string detail, string resourceId, string resourceType, string conflictType)
{
this.Detail = detail;
this.ResourceId = resourceId;
this.ResourceType = resourceType;
this.ConflictType = conflictType;
}

[JsonIgnore, JsonSchemaIgnore] public string Id { get; } = "like_conflict";
[JsonIgnore, JsonSchemaIgnore] public string Title { get; } = "Like Conflict";
[JsonIgnore, JsonSchemaIgnore] public string Version { get; } = "v1";
[JsonIgnore, JsonSchemaIgnore] public string Detail { get; } = string.Empty;

[Description("Type of Resource that like conflicted. Can be either 'template', 'plugin' or 'processor'")]
public string ResourceType { get; } = string.Empty;

[Description("ID of the resource that like conflicted")]
public string ResourceId { get; } = string.Empty;

[Description("Conflict type of the like. Can be either 'like' or 'unlike'")]
public string ConflictType { get; } = string.Empty;
}
38 changes: 38 additions & 0 deletions App/Error/V1/LikeRaceCondition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using App.Modules.Common;
using NJsonSchema.Annotations;

namespace App.Error.V1;

[
Description(
"Like race condition error occurs when a user tries to like a template, plugin or processor, when the start of the like query, the like exist and at the end of the like query, the like disappeared.")
]
internal class LikeRaceConditionError : IDomainProblem
{
public LikeRaceConditionError() { }

public LikeRaceConditionError(string detail, string resourceId, string resourceType, string conflictType)
{
this.Detail = detail;
this.ResourceId = resourceId;
this.ResourceType = resourceType;
this.ConflictType = conflictType;
}

[JsonIgnore, JsonSchemaIgnore] public string Id { get; } = "like_race_condition";
[JsonIgnore, JsonSchemaIgnore] public string Title { get; } = "Like Race Condition";
[JsonIgnore, JsonSchemaIgnore] public string Version { get; } = "v1";
[JsonIgnore, JsonSchemaIgnore] public string Detail { get; } = string.Empty;

[Description("Type of Resource that like have race condition. Can be either 'template', 'plugin' or 'processor'")]
public string ResourceType { get; } = string.Empty;

[Description("ID of the resource that like have race condition")]
public string ResourceId { get; } = string.Empty;

[Description("Type of the like of the race condition. Can be either 'like' or 'unlike'")]
public string ConflictType { get; } = string.Empty;
}
41 changes: 41 additions & 0 deletions App/Error/V1/MultipleEntityNotFound.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.ComponentModel;
using Newtonsoft.Json;
using NJsonSchema.Annotations;

namespace App.Error.V1;

[Description("This error represents an error that multiple entities could not be found during a batch request")]
public class MultipleEntityNotFound : IDomainProblem
{
public MultipleEntityNotFound() { }

public MultipleEntityNotFound(string detail, Type type, string[] notfound, string[] found)
{
this.Detail = detail;
this.AssemblyQualifiedName = type.AssemblyQualifiedName ?? "Unknown";
this.TypeName = type.FullName ?? "Unknown";
this.RequestIdentifiers = notfound;
this.FoundRequestIdentifiers = found;
}

[JsonIgnore, JsonSchemaIgnore] public string Id { get; } = "multiple_entity_not_found";

[JsonIgnore, JsonSchemaIgnore] public string Title { get; } = "Multiple Entity Not Found";

[JsonIgnore, JsonSchemaIgnore] public string Version { get; } = "v1";

[JsonIgnore, JsonSchemaIgnore] public string Detail { get; } = string.Empty;


[Description("All identifiers of the requested entity, that could not be found")]
public string[] RequestIdentifiers { get; } = Array.Empty<string>();

[Description("All identifiers of the requested entity, that could be found")]
public string[] FoundRequestIdentifiers { get; } = Array.Empty<string>();

[Description("The Full Name of the type of entities that could not be found")]
public string TypeName { get; } = string.Empty;

[Description("The AssemblyQualifiedName of the entities that could not be found")]
public string AssemblyQualifiedName { get; } = string.Empty;
}
Loading

0 comments on commit 3118bff

Please sign in to comment.