Skip to content

Commit 66c38b7

Browse files
authored
Merge pull request #36 from WindowsAppCommunity/arlo/esh-repositories/nomadkubo/0.16.0
Refactored root event stream handler repositories, update to OwlCore.Nomad.Kubo 0.16.0
2 parents d7cbd95 + 05b80b7 commit 66c38b7

35 files changed

Lines changed: 520 additions & 374 deletions

src/Models/IImages.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Ipfs;
2-
31
namespace WindowsAppCommunity.Sdk.Models;
42

53
/// <summary>

src/Models/IProjectRoleCollection.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,21 @@ public interface IProjectRoleCollection
1010
/// <summary>
1111
/// Represents a list of registered projects along with the role on each.
1212
/// </summary>
13-
(Cid ProjectId, DagCid RoleCid)[] Projects { get; set; }
13+
ProjectRole[] Projects { get; set; }
1414
}
15+
16+
/// <summary>
17+
/// A container for a project and a corresponding role.
18+
/// </summary>
19+
public record ProjectRole
20+
{
21+
/// <summary>
22+
/// The project ID.
23+
/// </summary>
24+
public required Cid ProjectId { get; init; }
25+
26+
/// <summary>
27+
/// The role of the project.
28+
/// </summary>
29+
public required DagCid Role { get; init; }
30+
}

src/Models/IPublisherRoleCollection.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,21 @@ public interface IPublisherRoleCollection
1010
/// <summary>
1111
/// Represents a list of registered publishers along with the role on each.
1212
/// </summary>
13-
public (Cid PublisherId, DagCid RoleCid)[] Publishers { get; set; }
13+
public PublisherRole[] Publishers { get; set; }
14+
}
15+
16+
/// <summary>
17+
/// A container for a Publisher and a corresponding role.
18+
/// </summary>
19+
public record PublisherRole
20+
{
21+
/// <summary>
22+
/// The publisher ID.
23+
/// </summary>
24+
public required Cid PublisherId { get; init; }
25+
26+
/// <summary>
27+
/// The role of the publisher.
28+
/// </summary>
29+
public required DagCid Role { get; init; }
1430
}

src/Models/IUserRoleCollection.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,21 @@ public interface IUserRoleCollection
1010
/// <summary>
1111
/// Represents a list of registered users along with the role on each.
1212
/// </summary>
13-
public (Cid UserId, DagCid RoleCid)[] Users { get; set; }
13+
public UserRole[] Users { get; set; }
14+
}
15+
16+
/// <summary>
17+
/// A container for a user and a corresponding role.
18+
/// </summary>
19+
public record UserRole
20+
{
21+
/// <summary>
22+
/// The user ID.
23+
/// </summary>
24+
public required Cid UserId { get; init; }
25+
26+
/// <summary>
27+
/// The role of the user.
28+
/// </summary>
29+
public required DagCid Role { get; init; }
1430
}

src/Models/Project.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ public record Project : IEntity, IUserRoleCollection, IAccentColor, IProjectColl
1717
/// <summary>
1818
/// The name of this project.
1919
/// </summary>
20-
public required string Name { get; set; }
20+
public string Name { get; set; } = string.Empty;
2121

2222
/// <summary>
2323
/// A description of this project.
2424
/// </summary>
25-
public required string Description { get; set; }
25+
public string Description { get; set; } = string.Empty;
2626

2727
/// <summary>
2828
/// An extended description of this project.
2929
/// </summary>
30-
public required string ExtendedDescription { get; set; }
30+
public string ExtendedDescription { get; set; } = string.Empty;
3131

3232
/// <summary>
3333
/// A list of <see cref="Image"/>s demonstrating this project.
@@ -47,7 +47,7 @@ public record Project : IEntity, IUserRoleCollection, IAccentColor, IProjectColl
4747
/// <summary>
4848
/// The category defining this project, as found in an app store.
4949
/// </summary>
50-
public required string Category { get; set; }
50+
public string Category { get; set; } = string.Empty;
5151

5252
/// <summary>
5353
/// Other projects which this project may depend on for various reasons.
@@ -57,7 +57,7 @@ public record Project : IEntity, IUserRoleCollection, IAccentColor, IProjectColl
5757
/// <summary>
5858
/// The <see cref="User"/>s who collaborate on this project, and their corresponding roles.
5959
/// </summary>
60-
public (Cid, DagCid)[] Users { get; set; } = [];
60+
public UserRole[] Users { get; set; } = [];
6161

6262
/// <summary>
6363
/// Represents links to external profiles or resources added by the user.

src/Models/Publisher.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ public record Publisher : IEntity, ILinkCollection, IProjectCollection, IUserRol
1212
/// <summary>
1313
/// The name of the publisher.
1414
/// </summary>
15-
public required string Name { get; set; }
15+
public string Name { get; set; } = string.Empty;
1616

1717
/// <summary>
1818
/// A description of the publisher.
1919
/// </summary>
20-
public required string Description { get; set; }
20+
public string Description { get; set; } = string.Empty;
2121

2222
/// <summary>
2323
/// An extended description of the publisher.
2424
/// </summary>
25-
public required string ExtendedDescription { get; set; }
25+
public string ExtendedDescription { get; set; } = string.Empty;
2626

2727
/// <summary>
2828
/// A hex-encoded accent color for this publisher.
@@ -42,7 +42,7 @@ public record Publisher : IEntity, ILinkCollection, IProjectCollection, IUserRol
4242
/// <summary>
4343
/// Users who are registered to participate in this publisher, along with their roles.
4444
/// </summary>
45-
public (Cid, DagCid)[] Users { get; set; } = [];
45+
public UserRole[] Users { get; set; } = [];
4646

4747
/// <summary>
4848
/// Projects who are registered under this publisher.

src/Models/User.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ public record User : IEntity, IConnections, ILinkCollection, IProjectRoleCollect
1212
/// <summary>
1313
/// The name of the user.
1414
/// </summary>
15-
public required string Name { get; set; }
15+
public string Name { get; set; } = string.Empty;
1616

1717
/// <summary>
1818
/// A description of the user. Supports markdown.
1919
/// </summary>
20-
public required string Description { get; set; }
20+
public string Description { get; set; } = string.Empty;
2121

2222
/// <summary>
2323
/// An extended description of the user. Supports markdown.
2424
/// </summary>
25-
public required string ExtendedDescription { get; set; }
25+
public string ExtendedDescription { get; set; } = string.Empty;
2626

2727
/// <summary>
2828
/// Represents application connections added by the user.
@@ -42,12 +42,12 @@ public record User : IEntity, IConnections, ILinkCollection, IProjectRoleCollect
4242
/// <summary>
4343
/// A list of all the projects the user is registered with, along with their role on the project.
4444
/// </summary>
45-
public (Cid, DagCid)[] Projects { get; set; } = [];
45+
public ProjectRole[] Projects { get; set; } = [];
4646

4747
/// <summary>
4848
/// Represents all publishers the user is registered with, along with their roles.
4949
/// </summary>
50-
public (Cid, DagCid)[] Publishers { get; set; } = [];
50+
public PublisherRole[] Publishers { get; set; } = [];
5151

5252
/// <summary>
5353
/// A flag that indicates whether the profile has requested to be forgotten.

src/Nomad/ModifiableEntity.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Generic;
2-
using System.Diagnostics;
32
using CommunityToolkit.Diagnostics;
43
using Ipfs;
54
using OwlCore.ComponentModel;

src/Nomad/ModifiableProject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ModifiableProject : NomadKuboEventStreamHandler<ValueUpdateEvent>,
2727
/// <param name="client">The client used to interact with the ipfs network.</param>
2828
/// <param name="kuboOptions">The options used to read and write data to and from Kubo.</param>
2929
/// <returns>A new instance of <see cref="ModifiableProject"/>.</returns>
30-
public static ModifiableProject FromHandlerConfig(NomadKuboEventStreamHandlerConfig<Project> handlerConfig, NomadKuboRepository<ModifiableProject, IReadOnlyProject, Project, ValueUpdateEvent> projectDependencyRepository, NomadKuboRepository<ModifiablePublisher, IReadOnlyPublisher, Publisher, ValueUpdateEvent> publisherRepository, NomadKuboRepository<ModifiableUser, IReadOnlyUser, User, ValueUpdateEvent> userRepository, ICoreApi client, IKuboOptions kuboOptions)
30+
public static ModifiableProject FromHandlerConfig(NomadKuboEventStreamHandlerConfig<Project> handlerConfig, INomadKuboRepositoryBase<ModifiableProject, IReadOnlyProject> projectDependencyRepository, INomadKuboRepositoryBase<ModifiablePublisher, IReadOnlyPublisher> publisherRepository, INomadKuboRepositoryBase<ModifiableUser, IReadOnlyUser> userRepository, ICoreApi client, IKuboOptions kuboOptions)
3131
{
3232
Guard.IsNotNull(handlerConfig.RoamingValue);
3333
Guard.IsNotNull(handlerConfig.RoamingKey);
@@ -168,7 +168,7 @@ public static ModifiableProject FromHandlerConfig(NomadKuboEventStreamHandlerCon
168168
/// <summary>
169169
/// A repository to get modifiable or readonly project instances from.
170170
/// </summary>
171-
public required NomadKuboRepository<ModifiablePublisher, IReadOnlyPublisher, Publisher, ValueUpdateEvent> PublisherRepository { get; init; }
171+
public required INomadKuboRepositoryBase<ModifiablePublisher, IReadOnlyPublisher> PublisherRepository { get; init; }
172172

173173
/// <inheritdoc/>
174174
public string Category => InnerProject.Category;

src/Nomad/ModifiableProjectCollection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using OwlCore.Nomad;
66
using OwlCore.Nomad.Kubo;
77
using OwlCore.Nomad.Kubo.Events;
8-
using WindowsAppCommunity.Sdk.Models;
98

109
namespace WindowsAppCommunity.Sdk.Nomad;
1110

@@ -23,7 +22,7 @@ public class ModifiableProjectCollection : NomadKuboEventStreamHandler<ValueUpda
2322
/// <summary>
2423
/// The repository to use for getting modifiable or readonly project instances.
2524
/// </summary>
26-
public required NomadKuboRepository<ModifiableProject, IReadOnlyProject, Project, ValueUpdateEvent> ProjectRepository { get; init; }
25+
public required INomadKuboRepositoryBase<ModifiableProject, IReadOnlyProject> ProjectRepository { get; init; }
2726

2827
/// <inheritdoc/>
2928
public event EventHandler<IReadOnlyProject[]>? ProjectsAdded;

0 commit comments

Comments
 (0)