diff --git a/migrations/542_2023-06-26_component.model b/migrations/542_2023-06-26_component.model new file mode 100644 index 0000000..e32139e --- /dev/null +++ b/migrations/542_2023-06-26_component.model @@ -0,0 +1,252 @@ +Component + project ProjectId + +ComponentOriginAdd + component ComponentId + + UniqueComponentOriginAdd component + +ComponentOriginInvite + component ComponentId + + UniqueComponentOriginInvite component + +ComponentGestureLocal + origin ComponentOriginAddId + add OutboxItemId + + UniqueComponentGestureLocal origin + UniqueComponentGestureLocalAdd add + +ComponentGestureRemote + origin ComponentOriginAddId + actor RemoteActorId + add RemoteActivityId + + UniqueComponentGestureRemote origin + UniqueComponentGestureRemoteAdd add + +ComponentAcceptLocal + ident ComponentLocalId + accept OutboxItemId + + UniqueComponentAcceptLocal ident + UniqueComponentAcceptLocalAccept accept + +ComponentAcceptRemote + ident ComponentRemoteId + accept RemoteActivityId + + UniqueComponentAcceptRemote ident + UniqueComponentAcceptRemoteAccept accept + +ComponentProjectGestureLocal + component ComponentId + activity OutboxItemId + + UniqueComponentProjectGestureLocal component + UniqueComponentProjectGestureLocalActivity activity + +ComponentProjectGestureRemote + component ComponentId + actor RemoteActorId + activity RemoteActivityId + + UniqueComponentProjectGestureRemote component + UniqueComponentProjectGestureRemoteActivity activity + +ComponentProjectAccept + origin ComponentOriginInviteId + accept OutboxItemId + + UniqueComponentProjectAccept origin + UniqueComponentProjectAcceptAccept accept + +ComponentLocal + component ComponentId + + UniqueComponentLocal component + +ComponentLocalRepo + component ComponentLocalId + repo RepoId + + UniqueComponentLocalRepo component + +ComponentLocalDeck + component ComponentLocalId + deck DeckId + + UniqueComponentLocalDeck component + +ComponentLocalLoom + component ComponentLocalId + loom LoomId + + UniqueComponentLocalLoom component + +ComponentRemote + component ComponentId + actor RemoteActorId + object RemoteObjectId + + UniqueComponentRemote component + +ComponentEnable + component ComponentId + grant OutboxItemId + + UniqueComponentEnable component + UniqueComponentEnableGrant grant + +ComponentDelegateLocal + component ComponentLocalId + grant OutboxItemId + + UniqueComponentDelegateLocal component + UniqueComponentDelegateLocalGrant grant + +ComponentDelegateRemote + component ComponentRemoteId + grant RemoteActivityId + + UniqueComponentDelegateRemote component + UniqueComponentDelegateRemoteGrant grant + +ComponentFurtherLocal + component ComponentEnableId + collab CollabRecipLocalId + grant OutboxItemId + + UniqueComponentFurtherLocal component collab + UniqueComponentFurtherLocalGrant grant + +ComponentFurtherRemote + component ComponentEnableId + collab CollabRecipRemoteId + grant OutboxItemId + + UniqueComponentFurtherRemote component collab + UniqueComponentFurtherRemoteGrant grant + +Stem + +StemIdentRepo + stem StemId + repo RepoId + + UniqueStemIdentRepo stem + +StemIdentDeck + stem StemId + deck DeckId + + UniqueStemIdentDeck stem + +StemIdentLoom + stem StemId + loom LoomId + + UniqueStemIdentLoom stem + +StemProjectLocal + stem StemId + project ProjectId + + UniqueStemProjectLocal stem + +StemProjectRemote + stem StemId + project RemoteActorId + + UniqueStemProjectRemote stem + +StemOriginAdd + stem StemId + + UniqueStemOriginAdd stem + +StemOriginInvite + stem StemId + + UniqueStemOriginInvite stem + +StemComponentGestureLocal + stem StemId + activity OutboxItemId + + UniqueStemComponentGestureLocal stem + UniqueStemComponentGestureLocalActivity activity + +StemComponentGestureRemote + stem StemId + actor RemoteActorId + activity RemoteActivityId + + UniqueStemComponentGestureRemote stem + UniqueStemComponentGestureRemoteActivity activity + +StemComponentAccept + stem StemId + accept OutboxItemId + + UniqueStemComponentAccept stem + UniqueStemComponentAcceptAccept accept + +StemProjectGestureLocal + origin StemOriginInviteId + invite OutboxItemId + + UniqueStemProjectGestureLocal origin + UniqueStemProjectGestureLocalInvite invite + +StemProjectGestureRemote + origin StemOriginInviteId + actor RemoteActorId + invite RemoteActivityId + + UniqueStemProjectGestureRemote origin + UniqueStemProjectGestureRemoteInvite invite + +StemProjectAcceptLocal + origin StemOriginInviteId + project StemProjectLocalId + accept OutboxItemId + + UniqueStemProjectAcceptLocal origin + UniqueStemProjectAcceptLocalProject project + UniqueStemProjectAcceptLocalAccept accept + +StemProjectAcceptRemote + origin StemOriginInviteId + project StemProjectRemoteId + accept RemoteActivityId + + UniqueStemProjectAcceptRemote origin + UniqueStemProjectAcceptRemoteProject project + UniqueStemProjectAcceptRemoteAccept accept + +StemProjectGrantLocal + stem StemComponentAcceptId + project StemProjectLocalId + grant OutboxItemId + + UniqueStemProjectGrantLocal stem + UniqueStemProjectGrantLocalProject project + UniqueStemProjectGrantLocalGrant grant + +StemProjectGrantRemote + stem StemComponentAcceptId + project StemProjectRemoteId + grant RemoteActivityId + + UniqueStemProjectGrantRemote stem + UniqueStemProjectGrantRemoteProject project + UniqueStemProjectGrantRemoteGrant grant + +StemDelegateLocal + stem StemComponentAcceptId + grant OutboxItemId + + UniqueStemDelegateLocal stem + UniqueStemDelegateLocalGrant grant diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index 357d575..4d6e11b 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -2958,6 +2958,8 @@ changes hLocal ctx = , addFieldRefOptional "Actor" Nothing "justCreatedBy" "Actor" -- 541 , addEntities model_541_project + -- 542 + , addEntities model_542_component ] migrateDB diff --git a/src/Vervis/Migration/Entities.hs b/src/Vervis/Migration/Entities.hs index 8e1daf5..1a5dcac 100644 --- a/src/Vervis/Migration/Entities.hs +++ b/src/Vervis/Migration/Entities.hs @@ -63,6 +63,7 @@ module Vervis.Migration.Entities , model_530_join , model_531_follow_request , model_541_project + , model_542_component ) where @@ -244,3 +245,6 @@ model_531_follow_request = $(schema "531_2023-06-15_follow_request") model_541_project :: [Entity SqlBackend] model_541_project = $(schema "541_2023-06-26_project") + +model_542_component :: [Entity SqlBackend] +model_542_component = $(schema "542_2023-06-26_component") diff --git a/th/models b/th/models index 7d87833..7ec0149 100644 --- a/th/models +++ b/th/models @@ -709,3 +709,341 @@ CollabRecipRemoteAccept UniqueCollabRecipRemoteAcceptCollab collab UniqueCollabRecipRemoteAcceptInvite invite UniqueCollabRecipRemoteAcceptAccept accept + +------------------------------------------------------------------------------ +-- Components, from project perspective +------------------------------------------------------------------------------ + +Component + project ProjectId + +------------------------------ Component reason ------------------------------ + +ComponentOriginAdd + component ComponentId + + UniqueComponentOriginAdd component + +ComponentOriginInvite + component ComponentId + + UniqueComponentOriginInvite component + +-- Component collaborators's gesture +-- +-- Add: Witnesses the initial Add that started the sequence +-- Invite: N/A (they send their Accept but we don't record it) + +ComponentGestureLocal + origin ComponentOriginAddId + add OutboxItemId + + UniqueComponentGestureLocal origin + UniqueComponentGestureLocalAdd add + +ComponentGestureRemote + origin ComponentOriginAddId + actor RemoteActorId + add RemoteActivityId + + UniqueComponentGestureRemote origin + UniqueComponentGestureRemoteAdd add + +-- Component's accept +-- +-- Add: Witnesses that the component saw and approved the Add +-- Invite: Witnesses that the component saw project's accept and component +-- collaborator's accept, and sent its own accept + +ComponentAcceptLocal + ident ComponentLocalId + accept OutboxItemId + + UniqueComponentAcceptLocal ident + UniqueComponentAcceptLocalAccept accept + +ComponentAcceptRemote + ident ComponentRemoteId + accept RemoteActivityId + + UniqueComponentAcceptRemote ident + UniqueComponentAcceptRemoteAccept accept + +-- Project collaborator's gesture +-- +-- Add: Witnesses their approval, seeing the component's accept +-- Invite: Witnesses the initial Invite that started the sequence + +ComponentProjectGestureLocal + component ComponentId + activity OutboxItemId + + UniqueComponentProjectGestureLocal component + UniqueComponentProjectGestureLocalActivity activity + +ComponentProjectGestureRemote + component ComponentId + actor RemoteActorId + activity RemoteActivityId + + UniqueComponentProjectGestureRemote component + UniqueComponentProjectGestureRemoteActivity activity + +-- Project's accept +-- +-- Add: N/A +-- Invite: Witnesses that the project saw and approved the Invite + +ComponentProjectAccept + origin ComponentOriginInviteId + accept OutboxItemId + + UniqueComponentProjectAccept origin + UniqueComponentProjectAcceptAccept accept + +----------------------------- Component identity ----------------------------- + +ComponentLocal + component ComponentId + + UniqueComponentLocal component + +ComponentLocalRepo + component ComponentLocalId + repo RepoId + + UniqueComponentLocalRepo component + +ComponentLocalDeck + component ComponentLocalId + deck DeckId + + UniqueComponentLocalDeck component + +ComponentLocalLoom + component ComponentLocalId + loom LoomId + + UniqueComponentLocalLoom component + +ComponentRemote + component ComponentId + actor RemoteActorId + object RemoteObjectId + + UniqueComponentRemote component + +------------------------------ Component enable ------------------------------ + +-- Witnesses that, seeing the project collaborator approval on the Add or the +-- component approval on the Invite, the project has sent the component a Grant +-- with the "delegator" role and now officially considering it a component of +-- the project +ComponentEnable + component ComponentId + grant OutboxItemId + + UniqueComponentEnable component + UniqueComponentEnableGrant grant + +-- Witnesses that the component used the delegator Grant to send an admin +-- delegation to the project, to extend the delegation further +ComponentDelegateLocal + component ComponentLocalId + grant OutboxItemId + + UniqueComponentDelegateLocal component + UniqueComponentDelegateLocalGrant grant + +-- Witnesses that the component used the delegator Grant to send an admin +-- delegation to the project, to extend the delegation further +ComponentDelegateRemote + component ComponentRemoteId + grant RemoteActivityId + + UniqueComponentDelegateRemote component + UniqueComponentDelegateRemoteGrant grant + +-- Witnesses that the project has extended a given delegation to a given +-- direct collaborator +ComponentFurtherLocal + component ComponentEnableId + collab CollabRecipLocalId + grant OutboxItemId + + UniqueComponentFurtherLocal component collab + UniqueComponentFurtherLocalGrant grant + +-- Witnesses that the project has extended a given delegation to a given +-- direct collaborator +ComponentFurtherRemote + component ComponentEnableId + collab CollabRecipRemoteId + grant OutboxItemId + + UniqueComponentFurtherRemote component collab + UniqueComponentFurtherRemoteGrant grant + +------------------------------------------------------------------------------ +-- Components, from component perspective +------------------------------------------------------------------------------ + +Stem + +-------------------------------- Stem identity ------------------------------- + +StemIdentRepo + stem StemId + repo RepoId + + UniqueStemIdentRepo stem + +StemIdentDeck + stem StemId + deck DeckId + + UniqueStemIdentDeck stem + +StemIdentLoom + stem StemId + loom LoomId + + UniqueStemIdentLoom stem + +-------------------------------- Stem project -------------------------------- + +StemProjectLocal + stem StemId + project ProjectId + + UniqueStemProjectLocal stem + +StemProjectRemote + stem StemId + project RemoteActorId + + UniqueStemProjectRemote stem + +--------------------------------- Stem reason -------------------------------- + +StemOriginAdd + stem StemId + + UniqueStemOriginAdd stem + +StemOriginInvite + stem StemId + + UniqueStemOriginInvite stem + +-- Component collaborators's gesture +-- +-- Add: Witnesses the initial Add that started the sequence +-- Invite: Witnesses their approval, seeing the project's accept + +StemComponentGestureLocal + stem StemId + activity OutboxItemId + + UniqueStemComponentGestureLocal stem + UniqueStemComponentGestureLocalActivity activity + +StemComponentGestureRemote + stem StemId + actor RemoteActorId + activity RemoteActivityId + + UniqueStemComponentGestureRemote stem + UniqueStemComponentGestureRemoteActivity activity + +-- Component's accept +-- +-- Add: Witnesses that the component saw and approved the initial Add +-- Invite: Witnesses that the component saw project's accept and component +-- collaborator's accept, and sent its own accept + +StemComponentAccept + stem StemId + accept OutboxItemId + + UniqueStemComponentAccept stem + UniqueStemComponentAcceptAccept accept + +-- Project collaborator's gesture +-- +-- Add: N/A (it happens but we don't record it) +-- Invite: Witnesses the initial Invite that started the sequence + +StemProjectGestureLocal + origin StemOriginInviteId + invite OutboxItemId + + UniqueStemProjectGestureLocal origin + UniqueStemProjectGestureLocalInvite invite + +StemProjectGestureRemote + origin StemOriginInviteId + actor RemoteActorId + invite RemoteActivityId + + UniqueStemProjectGestureRemote origin + UniqueStemProjectGestureRemoteInvite invite + +-- Project's accept +-- +-- Add: N/A +-- Invite: Witnesses that the project saw and approved the Invite + +StemProjectAcceptLocal + origin StemOriginInviteId + project StemProjectLocalId + accept OutboxItemId + + UniqueStemProjectAcceptLocal origin + UniqueStemProjectAcceptLocalProject project + UniqueStemProjectAcceptLocalAccept accept + +StemProjectAcceptRemote + origin StemOriginInviteId + project StemProjectRemoteId + accept RemoteActivityId + + UniqueStemProjectAcceptRemote origin + UniqueStemProjectAcceptRemoteProject project + UniqueStemProjectAcceptRemoteAccept accept + +------------------------------ Stem enable ------------------------------ + +-- Project's grant +-- +-- Add: Seeing component's accept and project collaborator's accept, the +-- project has made the link official and sent a delegator grant +-- Invite: Seeing project collaborator's Invite and component's accept, the +-- project has made the link official and sent a delegator grant + +StemProjectGrantLocal + stem StemComponentAcceptId + project StemProjectLocalId + grant OutboxItemId + + UniqueStemProjectGrantLocal stem + UniqueStemProjectGrantLocalProject project + UniqueStemProjectGrantLocalGrant grant + +StemProjectGrantRemote + stem StemComponentAcceptId + project StemProjectRemoteId + grant RemoteActivityId + + UniqueStemProjectGrantRemote stem + UniqueStemProjectGrantRemoteProject project + UniqueStemProjectGrantRemoteGrant grant + +-- Witnesses that the stem used the delegator Grant to send an admin +-- delegation to the project, to extend the delegation further +StemDelegateLocal + stem StemComponentAcceptId + grant OutboxItemId + + UniqueStemDelegateLocal stem + UniqueStemDelegateLocalGrant grant