From 55eaf3e789bc30b71b4eeb9e577beebc7b86bfca Mon Sep 17 00:00:00 2001 From: Tom Pipinic Date: Thu, 29 Dec 2022 10:24:01 +0100 Subject: [PATCH] Workspace project added --- .../Connected.Common.Workspace.Model.csproj | 20 +++ .../IWorkspaceEntity.cs | 114 ++++++++++++++++++ .../Identities/IIdentity.cs | 22 ++++ .../Identities/IIdentityService.cs | 15 +++ .../Identities/IdentityArgs.cs | 9 ++ .../Messaging/IMessage.cs | 5 + .../Messaging/IMessagesService.cs | 15 +++ .../Messaging/MessageArgs.cs | 21 ++++ .../WorkspaceArgs.cs | 67 ++++++++++ 9 files changed, 288 insertions(+) create mode 100644 src/Connected.Common.Workspace/Connected.Common.Workspace.Model.csproj create mode 100644 src/Connected.Common.Workspace/IWorkspaceEntity.cs create mode 100644 src/Connected.Common.Workspace/Identities/IIdentity.cs create mode 100644 src/Connected.Common.Workspace/Identities/IIdentityService.cs create mode 100644 src/Connected.Common.Workspace/Identities/IdentityArgs.cs create mode 100644 src/Connected.Common.Workspace/Messaging/IMessage.cs create mode 100644 src/Connected.Common.Workspace/Messaging/IMessagesService.cs create mode 100644 src/Connected.Common.Workspace/Messaging/MessageArgs.cs create mode 100644 src/Connected.Common.Workspace/WorkspaceArgs.cs diff --git a/src/Connected.Common.Workspace/Connected.Common.Workspace.Model.csproj b/src/Connected.Common.Workspace/Connected.Common.Workspace.Model.csproj new file mode 100644 index 0000000..331aba1 --- /dev/null +++ b/src/Connected.Common.Workspace/Connected.Common.Workspace.Model.csproj @@ -0,0 +1,20 @@ + + + + net7.0 + enable + enable + + + + + + + + + + + + + + diff --git a/src/Connected.Common.Workspace/IWorkspaceEntity.cs b/src/Connected.Common.Workspace/IWorkspaceEntity.cs new file mode 100644 index 0000000..563f24e --- /dev/null +++ b/src/Connected.Common.Workspace/IWorkspaceEntity.cs @@ -0,0 +1,114 @@ +using Connected.Common.Workspace.Messaging; +using Connected.Entities.Consistency; +using Connected.Security.Identity; + +namespace Connected.Common.Workspace; +/// +/// Specifies the read state of the entity. +/// +public enum ReadStatus +{ + /// + /// The entity has not been read by the . + /// + New = 0, + /// + /// The entity has been read by the . + /// + Read = 1 +} +/// +/// Specifies what kind of actions can be performed by the identity on each entity. +/// +[Flags] +public enum IdentityVerbs +{ + /// + /// The entity is read only. Identity cannot perform any actions on it + /// except reading. + /// + ReadOnly = 0, + /// + /// The entity can be deleted from the workspace by the identity. + /// + AllowDelete = 1 +} +/// +/// Represents a base entity for all workspace related entities. +/// +/// +/// Digital Workspace offers many different services serving different purposes. Each service introduces +/// its own set of entities. All top level entities inherits from this entity, for example . +/// +public interface IWorkspaceEntity : IConsistentEntity +{ + /// + /// The type of identity to which workspace entity belongs to (like Recipient). + /// + /// + /// The most common type of the identity entity is . + /// + string IdentityEntity { get; init; } + /// + /// The id of the identity to which workspace entity belongs. This could be the id of the user, + /// device, organization unit or any other entity id. + /// + string IdentityId { get; init; } + /// + /// The date and time the workspace entity has been created. + /// + /// + /// This value can represent the value when the origin entity has been created or when + /// the workspace entity has been created. This value is specific to the service implementation. + /// + DateTimeOffset Created { get; init; } + /// + /// The date and time the workspace entity expires. + /// + /// + /// Expired workspace entities are automatically deleted from the system. If this value is null, + /// workspace entity never expires. + /// + DateTimeOffset? Expires { get; init; } + /// + /// The title of the entity. + /// + /// + /// This should be as short as possible so user can quickly recognize the nature of the entity. + /// + string Title { get; init; } + /// + /// The short description of the entity. Can be null. + /// + string? Description { get; init; } + /// + /// The read status of the entity. This serves primary for a UI purpose to enable visual feedback + /// to the user. + /// + ReadStatus Status { get; init; } + /// + /// The domain to which this entity belongs. + /// + /// + /// Each workspace entity should have one and only one domain to which it originates. + /// + string Domain { get; init; } + /// + /// Zero or more tags that represents additional meta data of the workspace entity. + /// + string? Tags { get; init; } + /// + /// The entity which triggered this workspace entity to be created. Can be null if it was + /// automatically generated by the underlying system. + /// + string? AuthorEntity { get; init; } + /// + /// The id of the entity which created this workspace entity. Can be null if it was + /// automatically generated by the underlying system. + /// + string? AuthorId { get; init; } + /// + /// Actions that can be performed by the identity on the workspace entity. + /// + IdentityVerbs Verbs { get; init; } +} diff --git a/src/Connected.Common.Workspace/Identities/IIdentity.cs b/src/Connected.Common.Workspace/Identities/IIdentity.cs new file mode 100644 index 0000000..5e888a6 --- /dev/null +++ b/src/Connected.Common.Workspace/Identities/IIdentity.cs @@ -0,0 +1,22 @@ +using Connected.Data; + +namespace Connected.Common.Workspace.Identities; +/// +/// Represents the workspace identity. +/// +/// +/// Workspace supports identities through the . There could +/// be any number of different identities, such as users or devices which are provided via +/// different identity providers. +/// +public interface IIdentity : IPrimaryKey +{ + /// + /// The display name of the identity. This should be short and descriptive. + /// + string DisplayName { get; init; } + /// + /// The Url of the identity's avatar if it is supported. + /// + string Avatar { get; init; } +} diff --git a/src/Connected.Common.Workspace/Identities/IIdentityService.cs b/src/Connected.Common.Workspace/Identities/IIdentityService.cs new file mode 100644 index 0000000..88f97d7 --- /dev/null +++ b/src/Connected.Common.Workspace/Identities/IIdentityService.cs @@ -0,0 +1,15 @@ +using System.Collections.Immutable; + +namespace Connected.Common.Workspace.Identities; +/// +/// The provider service used for providing identity descriptors. +/// +public interface IIdentityService +{ + /// + /// Queries identities for the specified set of entity types and their ids. + /// + /// The arguments containing entity types and their ids. + /// The list of identities that matches the specified criteria. + Task> Query(QueryIdentitiesArgs args); +} diff --git a/src/Connected.Common.Workspace/Identities/IdentityArgs.cs b/src/Connected.Common.Workspace/Identities/IdentityArgs.cs new file mode 100644 index 0000000..7fd272e --- /dev/null +++ b/src/Connected.Common.Workspace/Identities/IdentityArgs.cs @@ -0,0 +1,9 @@ +using Connected.Annotations; +using Connected.ServiceModel; + +namespace Connected.Common.Workspace.Identities; +public sealed class QueryIdentitiesArgs : QueryArgs +{ + [NonDefault] + public Dictionary Items { get; set; } = default!; +} diff --git a/src/Connected.Common.Workspace/Messaging/IMessage.cs b/src/Connected.Common.Workspace/Messaging/IMessage.cs new file mode 100644 index 0000000..845d352 --- /dev/null +++ b/src/Connected.Common.Workspace/Messaging/IMessage.cs @@ -0,0 +1,5 @@ +namespace Connected.Common.Workspace.Messaging; +public interface IMessage : IWorkspaceEntity +{ + +} diff --git a/src/Connected.Common.Workspace/Messaging/IMessagesService.cs b/src/Connected.Common.Workspace/Messaging/IMessagesService.cs new file mode 100644 index 0000000..86f1c40 --- /dev/null +++ b/src/Connected.Common.Workspace/Messaging/IMessagesService.cs @@ -0,0 +1,15 @@ +using System.Collections.Immutable; +using Connected.Notifications; +using Connected.ServiceModel; + +namespace Connected.Common.Workspace.Messaging; +public interface IMessagesService : IServiceNotifications +{ + Task> Query(QueryMessageArgs args); + Task Select(PrimaryKeyArgs args); + + Task Insert(InsertMessageArgs args); + Task Update(UpdateMessageArgs args); + Task Patch(PatchArgs args); + Task Delete(PrimaryKeyArgs args); +} diff --git a/src/Connected.Common.Workspace/Messaging/MessageArgs.cs b/src/Connected.Common.Workspace/Messaging/MessageArgs.cs new file mode 100644 index 0000000..3e44b76 --- /dev/null +++ b/src/Connected.Common.Workspace/Messaging/MessageArgs.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations; +using Connected.ServiceModel; + +namespace Connected.Common.Workspace.Messaging; +public sealed class QueryMessageArgs : QueryArgs +{ + [Required, MaxLength(128)] + public string IdentityEntity { get; set; } = default!; + [Required, MaxLength(128)] + public string IdentityId { get; set; } = default!; +} + +public sealed class InsertMessageArgs : InsertWorkspaceArgs +{ + +} + +public sealed class UpdateMessageArgs : UpdateWorkspaceArgs +{ + +} diff --git a/src/Connected.Common.Workspace/WorkspaceArgs.cs b/src/Connected.Common.Workspace/WorkspaceArgs.cs new file mode 100644 index 0000000..df57c24 --- /dev/null +++ b/src/Connected.Common.Workspace/WorkspaceArgs.cs @@ -0,0 +1,67 @@ +using System.ComponentModel.DataAnnotations; +using Connected.ServiceModel; + +namespace Connected.Common.Workspace; +/// +/// The base class for the arguments used when inserting one of the +/// implementations of the entity. +/// +public abstract class InsertWorkspaceArgs : Dto +{ + /// + [Required, MaxLength(128)] + public string IdentityEntity { get; set; } = default!; + /// + [Required, MaxLength(128)] + public string IdentityId { get; set; } = default!; + /// + public DateTimeOffset? Created { get; set; } + /// + public DateTimeOffset? Expires { get; set; } + /// + [Required, MaxLength(128)] + public string Title { get; set; } = default!; + /// + [MaxLength(256)] + public string? Description { get; set; } + /// + public ReadStatus? Status { get; set; } + /// + [Required, MaxLength(128)] + public string Domain { get; init; } = default!; + /// + [MaxLength(256)] + public string? Tags { get; init; } + /// + [MaxLength(128)] + public string? AuthorEntity { get; init; } + /// + [MaxLength(128)] + public string? AuthorId { get; init; } + /// + public IdentityVerbs? Verbs { get; init; } +} +/// +/// The base class used when updating one of the +/// implementations of the entity. +/// +public abstract class UpdateWorkspaceArgs : PrimaryKeyArgs +{ + /// + public DateTimeOffset? Created { get; set; } + /// + public DateTimeOffset? Expires { get; set; } + /// + [Required, MaxLength(128)] + public string Title { get; set; } = default!; + /// + [MaxLength(256)] + public string? Description { get; set; } + /// + public ReadStatus? Status { get; set; } + /// + [MaxLength(256)] + public string? Tags { get; init; } + /// + public IdentityVerbs? Verbs { get; init; } +} -- 2.36.3