-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jssbg-69_display-nodes
- Loading branch information
Showing
130 changed files
with
2,126 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/FileIdConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class FileIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<FileAssetId, FileAssetId>().ConstructUsing(src => FileAssetId.Of(src.Value)); | ||
} |
16 changes: 9 additions & 7 deletions
16
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NodeIdConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class NodeIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<NodeId, NodeId>().ConstructUsing(src => NodeId.Of(src.Value)); | ||
} | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class NodeIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<NodeId, NodeId>().ConstructUsing(src => NodeId.Of(src.Value)); | ||
} |
9 changes: 9 additions & 0 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/NoteIdConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class NoteIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<NoteId, NoteId>().ConstructUsing(src => NoteId.Of(src.Value)); | ||
} |
9 changes: 9 additions & 0 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/ReminderIdConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class ReminderIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<ReminderId, ReminderId>().ConstructUsing(src => ReminderId.Of(src.Value)); | ||
} |
9 changes: 9 additions & 0 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Api/Converters/TimelineIdConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Api.Converters; | ||
|
||
public class TimelineIdConverter : IRegister | ||
{ | ||
public void Register(TypeAdapterConfig config) => | ||
config.NewConfig<TimelineId, TimelineId>().ConstructUsing(src => TimelineId.Of(src.Value)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
global using Mapster; | ||
global using BuildingBlocks.Domain.ValueObjects.Ids; | ||
global using Mapster; |
9 changes: 3 additions & 6 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/FileAssetId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(FileAssetIdJsonConverter))] | ||
public record FileAssetId : StronglyTypedId | ||
public class FileAssetId : StronglyTypedId | ||
{ | ||
private FileAssetId(Guid value) : base(value) { } | ||
|
||
public static FileAssetId Of(Guid value) => new(value); | ||
|
||
private class FileAssetIdJsonConverter : StronglyTypedIdJsonConverter<FileAssetId>; | ||
public override string ToString() => Value.ToString(); | ||
} |
48 changes: 45 additions & 3 deletions
48
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NodeId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,55 @@ | ||
using System.Text.Json.Serialization; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(NodeIdJsonConverter))] | ||
public record NodeId : StronglyTypedId | ||
public class NodeId : StronglyTypedId | ||
{ | ||
private NodeId(Guid value) : base(value) { } | ||
|
||
public static NodeId Of(Guid value) => new(value); | ||
|
||
private class NodeIdJsonConverter : StronglyTypedIdJsonConverter<NodeId>; | ||
public override string ToString() => Value.ToString(); | ||
} | ||
|
||
public class NodeIdJsonConverter : JsonConverter<NodeId> | ||
{ | ||
public override NodeId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
// ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault | ||
switch (reader.TokenType) | ||
{ | ||
case JsonTokenType.String: | ||
{ | ||
var guidString = reader.GetString(); | ||
if (!Guid.TryParse(guidString, out var guid)) | ||
throw new JsonException($"Invalid GUID format for NodeId: {guidString}"); | ||
|
||
return NodeId.Of(guid); | ||
} | ||
case JsonTokenType.StartObject: | ||
{ | ||
using var jsonDoc = JsonDocument.ParseValue(ref reader); | ||
|
||
if (!jsonDoc.RootElement.TryGetProperty("id", out JsonElement idElement)) | ||
throw new JsonException("Expected property 'id' not found."); | ||
|
||
var guidString = idElement.GetString(); | ||
|
||
if (!Guid.TryParse(guidString, out var guid)) | ||
throw new JsonException($"Invalid GUID format for NodeId: {guidString}"); | ||
|
||
return NodeId.Of(guid); | ||
} | ||
default: | ||
throw new JsonException( | ||
$"Unexpected token parsing NodeId. Expected String or StartObject, got {reader.TokenType}."); | ||
} | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, NodeId value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.ToString()); | ||
} | ||
} |
11 changes: 4 additions & 7 deletions
11
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/NoteId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(NoteIdJsonConverter))] | ||
public record NoteId : StronglyTypedId | ||
public class NoteId : StronglyTypedId | ||
{ | ||
private NoteId(Guid value) : base(value) { } | ||
|
||
public static NoteId Of(Guid value) => new(value); | ||
|
||
private class NoteIdJsonConverter : StronglyTypedIdJsonConverter<NoteId>; | ||
public override string ToString() => Value.ToString(); | ||
} |
9 changes: 3 additions & 6 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/ReminderId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(ReminderIdJsonConverter))] | ||
public record ReminderId : StronglyTypedId | ||
public class ReminderId : StronglyTypedId | ||
{ | ||
private ReminderId(Guid value) : base(value) { } | ||
|
||
public static ReminderId Of(Guid value) => new(value); | ||
|
||
private class ReminderIdJsonConverter : StronglyTypedIdJsonConverter<ReminderId>; | ||
public override string ToString() => Value.ToString(); | ||
} |
9 changes: 3 additions & 6 deletions
9
Backend/src/BuildingBlocks/BuildingBlocks.Domain/ValueObjects/Ids/TimelineId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
namespace BuildingBlocks.Domain.ValueObjects.Ids; | ||
|
||
[JsonConverter(typeof(TimelineIdJsonConverter))] | ||
public record TimelineId : StronglyTypedId | ||
public class TimelineId : StronglyTypedId | ||
{ | ||
private TimelineId(Guid value) : base(value) { } | ||
|
||
public static TimelineId Of(Guid value) => new(value); | ||
|
||
private class TimelineIdJsonConverter : StronglyTypedIdJsonConverter<TimelineId>; | ||
public override string ToString() => Value.ToString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...es/Files.Api/Endpoints/CreateFileAsset.cs → ...es.Api/Endpoints/Files/CreateFileAsset.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Backend/src/Modules/Files/Files.Api/Endpoints/Files/GetFileAssetById.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Text.Json.Serialization; | ||
using Files.Application.Entities.Files.Queries.GetFileAssetById; | ||
|
||
namespace Files.Api.Endpoints.Files; | ||
|
||
// ReSharper disable once UnusedType.Global | ||
public class GetFileAssetById : ICarterModule | ||
{ | ||
public void AddRoutes(IEndpointRouteBuilder app) | ||
{ | ||
app.MapGet("/Files/{fileId}", async (string fileId, ISender sender) => | ||
{ | ||
var result = await sender.Send(new GetFileAssetByIdQuery(fileId)); | ||
var response = result.Adapt<GetFileAssetByIdResponse>(); | ||
|
||
return Results.Ok(response); | ||
}) | ||
.WithName("GetFileAssetById") | ||
.Produces<GetFileAssetByIdResponse>() | ||
.ProducesProblem(StatusCodes.Status400BadRequest) | ||
.ProducesProblem(StatusCodes.Status404NotFound) | ||
.WithSummary("Get File Asset by Id") | ||
.WithDescription("Get File Asset by Id"); | ||
} | ||
} | ||
|
||
// ReSharper disable once ClassNeverInstantiated.Global | ||
// ReSharper disable once NotAccessedPositionalProperty.Global | ||
public record GetFileAssetByIdResponse([property: JsonPropertyName("file")] FileAssetDto FileAssetDto); |
27 changes: 27 additions & 0 deletions
27
Backend/src/Modules/Files/Files.Api/Endpoints/Files/ListFileAssets.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using BuildingBlocks.Application.Pagination; | ||
using Files.Application.Entities.Files.Queries.ListFileAssets; | ||
|
||
namespace Files.Api.Endpoints.Files; | ||
|
||
public class ListFileAssets : ICarterModule | ||
{ | ||
public void AddRoutes(IEndpointRouteBuilder app) | ||
{ | ||
app.MapGet("/Files", async ([AsParameters] PaginationRequest query, ISender sender) => | ||
{ | ||
var result = await sender.Send(new ListFileAssetsQuery(query)); | ||
var response = result.Adapt<ListFileAssetsResponse>(); | ||
|
||
return Results.Ok(response); | ||
}) | ||
.WithName("ListFileAssets") | ||
.Produces<ListFileAssetsResponse>() | ||
.ProducesProblem(StatusCodes.Status400BadRequest) | ||
.WithSummary("List File Assets") | ||
.WithDescription("List File Assets"); | ||
} | ||
} | ||
|
||
// ReSharper disable once ClassNeverInstantiated.Global | ||
// ReSharper disable once NotAccessedPositionalProperty.Global | ||
public record ListFileAssetsResponse(PaginatedResult<FileAssetDto> FileAssets); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...CreateFileAsset/CreateFileAssetCommand.cs → ...CreateFileAsset/CreateFileAssetCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.