various, metadata: update metadata interactions

This commit is contained in:
Liam Fitzgerald 2021-01-14 08:50:39 +10:00
parent 2384b902b0
commit 541efa5ff9
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
10 changed files with 90 additions and 50 deletions

View File

@ -152,7 +152,7 @@
(contact-poke [%create path])
(contact-hook-poke [%add-owned path])
==
(create-metadata path title.act description.act)
(create-metadata rid title.act description.act)
?. ?=(%invite -.policy.act)
~
%+ turn
@ -200,7 +200,7 @@
(contact-poke [%create path])
(contact-hook-poke [%add-owned path])
==
(create-metadata path title.act description.act)
(create-metadata resource.act title.act description.act)
==
++ poke-handle-http-request
|= =inbound-request:eyre
@ -234,7 +234,7 @@
(de-path:resource path)
:~ (group-pull-poke [%add entity.rid rid])
(contact-hook-poke [%add-synced entity.rid path])
(sync-metadata entity.rid path)
(pull-metadata rid)
==
::
:: +utilities
@ -297,9 +297,9 @@
[%pass / %agent [our.bol %group-pull-hook] %poke %pull-hook-action !>(act)]
::
++ metadata-poke
|= act=*
|= act=metadata-action
^- card
*card
[%pass / %agent [our.bol %metadata-store] %poke metadata-action+!>(act)]
::
++ metadata-hook-poke
|= act=metadata-hook-action
@ -312,7 +312,7 @@
(metadata-hook-poke %add-synced ship path)
::
++ create-metadata
|= [=path title=@t description=@t]
|= [rid=resource title=@t description=@t]
^- (list card)
=/ =metadata
%* . *metadata
@ -321,10 +321,22 @@
date-created now.bol
creator our.bol
==
:~ (metadata-poke [%add path [%contacts path] metadata])
(metadata-hook-poke [%add-owned path])
:~ (metadata-poke [%add rid [%contacts rid] metadata])
(push-metadata rid)
==
::
++ push-metadata
|= rid=resource
^- card
=- [%pass / %agent [our.bol %metadata-push-hook] %poke -]
push-hook-action+!>([%add rid])
::
++ pull-metadata
|= rid=resource
^- card
=- [%pass / %agent [our.bol %metadata-pull-hook] %poke -]
pull-hook-action+!>([%add [entity .]:rid])
::
++ all-scry
^- rolodex
.^(rolodex %gx /(scot %p our.bol)/contact-store/(scot %da now.bol)/all/noun)

View File

@ -35,6 +35,7 @@
++ on-pull-nack
|= [=resource =tang]
^- (quip card _this)
~& nacked+resource
:_ this
?. (~(has in get-keys:gra) resource) ~
=- [%pass /pull-nack %agent [our.bowl %graph-store] %poke %graph-update -]~

View File

@ -26,7 +26,7 @@
=/ grp ~(. group bowl)
=/ met ~(. metadata bowl)
=/ group=(unit resource:res)
(peek-group:met [%graph resource])
(peek-group:met %graph resource)
?~ group %.n
?: requires-admin
(is-admin:grp src.bowl u.group)

View File

@ -43,6 +43,7 @@
++ on-pull-nack
|= [=resource =tang]
^- (quip card _this)
~& nacked+resource
`this
::
++ on-pull-kick

View File

@ -24,7 +24,7 @@
:: /group/%group-path associations for group
::
/- *metadata-store, *metadata-hook
/+ *metadata-json, default-agent, verb, dbug, resource, *migrate, bi
/+ *metadata-json, default-agent, verb, dbug, resource, *migrate
|%
+$ card card:agent:gall
+$ base-state-0
@ -117,11 +117,13 @@
?> (team:title our.bowl src.bowl)
=^ cards state
?+ mark (on-poke:def mark vase)
%metadata-action
(poke-metadata-action:mc !<(metadata-action vase))
?(%metadata-action %metadata-update)
(poke-metadata-update:mc !<(metadata-update vase))
::
%import
(poke-import:mc q.vase)
::
%noun ~& +.state `state
==
[cards this]
::
@ -155,7 +157,7 @@
|= =path
^- (unit (unit cage))
?+ path (on-peek:def path)
:: [%y %group-indices ~] ``noun+!>(group-indices)
[%y %group-indices ~] ``noun+!>(group-indices)
[%y %app-indices ~] ``noun+!>(app-indices)
[%y %resource-indices ~] ``noun+!>(resource-indices)
[%x %associations ~] ``noun+!>(associations)
@ -169,13 +171,14 @@
::
[%x %metadata @ @ @ @ ~]
=/ =md-resource
[i.t.t.t.path (de-path:resource t.t.t.t.path)]
[i.t.t.path (de-path:resource t.t.t.path)]
``noun+!>((~(get by associations) md-resource))
::
[%x %resource @ *]
=/ app=term i.t.t.path
=/ rid=resource (de-path:resource t.t.t.path)
``noun+!>((~(get by associations) [app rid]))
``noun+!>((~(get by resource-indices) [app rid]))
::
[%x %export ~]
``noun+!>(-.state)
@ -257,7 +260,6 @@
%+ turn ~(tap by associations)
|= [[=group-path md-resource=md-resource-1] m=metadata]
^- [[^group-path md-resource-1] metadata]
~! md-resource
?. =(app-name.md-resource app)
[[group-path md-resource] m]
=/ new-app-path=path
@ -266,13 +268,14 @@
ship+app-path.md-resource
[[group-path [%graph new-app-path]] m(module app)]
--
++ poke-metadata-action
|= act=metadata-action
++ poke-metadata-update
|= upd=metadata-update
^- (quip card _state)
?> (team:title our.bowl src.bowl)
?+ -.act !!
%add (handle-add group.act resource.act metadata.act)
%remove (handle-remove group.act resource.act)
?> (team:title [our src]:bowl)
?+ -.upd !!
%add (handle-add +.upd)
%remove (handle-remove +.upd)
%initial-group (handle-initial-group +.upd)
==
::
++ poke-import
@ -312,6 +315,9 @@
::
resource-indices
(~(put by resource-indices) md-resource group)
::
group-indices
(~(put ju group-indices) group md-resource)
==
::
++ handle-remove
@ -329,8 +335,25 @@
::
resource-indices
(~(del by resource-indices) md-resource)
::
group-indices
(~(del ju group-indices) group md-resource)
==
::
++ handle-initial-group
|= [group=resource =^associations]
=/ assocs=(list [=md-resource grp=resource =metadata])
~(tap by associations)
=| cards=(list card)
|-
?~ assocs
[cards state]
=, assocs
?> =(group grp.i)
=^ new-cards state
(handle-add group [md-resource metadata]:i)
$(cards (weld cards new-cards), assocs t)
::
++ metadata-for-app
|= =app-name
^+ associations

View File

@ -26,7 +26,7 @@
|= group=resource
.^ associations
%gx (scot %p our.bowl) %metadata-store (scot %da now.bowl)
%group (en-path:resource group) %noun
%group (snoc (en-path:resource group) %noun)
==
::
++ md-resources-from-group
@ -44,7 +44,7 @@
|= [app-name=term rid=resource]
.^ (unit association)
%gx (scot %p our.bowl) %metadata-store (scot %da now.bowl)
%metadata app-name (en-path:resource rid) %noun
%metadata app-name (snoc (en-path:resource rid) %noun)
==
::
++ peek-metadata
@ -54,6 +54,7 @@
::
++ peek-group
|= =md-resource
^- (unit resource)
%+ bind (peek-association md-resource)
|=(association group)
--

View File

@ -238,6 +238,13 @@
`[%done ~]
==
::
++ raw-poke-our
|= [app=term =cage]
=/ m (strand ,~)
^- form:m
;< =bowl:spider bind:m get-bowl
(raw-poke [our.bowl app] cage)
::
++ poke-our
|= [=term =cage]
=/ m (strand ,~)

View File

@ -66,11 +66,11 @@
module module.action
==
=/ =metadata-action
[%add group-path graph+(en-path:resource rid.action) metadata]
[%add group graph+rid.action metadata]
;< ~ bind:m
(poke-our %metadata-hook %metadata-action !>(metadata-action))
(poke-our %metadata-store %metadata-action !>(metadata-action))
;< ~ bind:m
(poke-our %metadata-hook %metadata-hook-action !>([%add-owned group-path]))
(poke-our %metadata-push-hook %push-hook-action !>([%add group]))
::
:: Send invites
::

View File

@ -11,18 +11,15 @@
|= rid=resource
=/ m (strand ,(unit resource))
^- form:m
;< pax=(unit (set path)) bind:m
%+ scry:strandio ,(unit (set path))
;< res=(unit resource) bind:m
%+ scry:strandio ,(unit resource)
;: weld
/gx/metadata-store/resource/graph
(en-path:resource rid)
/noun
==
%- pure:m
?~ pax ~
?~ u.pax ~
`(de-path:resource n.u.pax)
::
(pure:m res)
::
++ wait-for-group-join
|= rid=resource
=/ m (strand ,~)
@ -83,9 +80,8 @@
;< ~ bind:m (wait-for-group-join rid.action)
::
;< ~ bind:m
%+ poke-our %metadata-hook
metadata-hook-action+!>([%add-synced ship.action (en-path:resource rid.action)])
::
%+ poke-our %metadata-pull-hook
pull-hook-action+!>([%add ship.action rid.action])::
;< ~ bind:m (wait-for-md rid.action)
::
;< ~ bind:m

View File

@ -3,6 +3,7 @@
::
=* strand strand:spider
=* raw-poke raw-poke:strandio
=* raw-poke-our raw-poke-our:strandio
=* scry scry:strandio
::
^- thread:spider
@ -51,12 +52,12 @@
:: stop serving or syncing metadata associated with group
::
;< ~ bind:m
%+ raw-poke
[our.bowl %metadata-hook]
:- %metadata-hook-action
!>([%remove (en-path:res resource.update)])
:: get metadata associated with group
::
%- raw-poke-our
?: =(our.bowl entity.resource.update)
:- %metadata-push-hook
push-hook-action+!>([%remove resource.update])
:- %metadata-pull-hook
pull-hook-action+!>([%remove resource.update])
;< =associations:met bind:m
%+ scry associations:met
;: weld
@ -64,8 +65,8 @@
(en-path:res resource.update)
/noun
==
=/ entries=(list [g=group-path:met m=md-resource:met])
~(tap in ~(key by associations))
=/ entries=(list [m=md-resource:met g=resource:res =metadata:met])
~(tap by associations)
|- ^- form:m
=* loop $
?~ entries
@ -80,18 +81,16 @@
[%remove g.i.entries m.i.entries]
:: archive graph associated with group
::
=/ app-resource (de-path-soft:res app-path.m.i.entries)
?~ app-resource
loop(entries t.entries)
=* app-resource resource.m.i.entries
;< ~ bind:m
%+ raw-poke
[our.bowl %graph-store]
:- %graph-update
!> ^- update:gra
[%0 now.bowl [%archive-graph u.app-resource]]
[%0 now.bowl [%archive-graph app-resource]]
;< ~ bind:m
%+ raw-poke
[our.bowl %graph-pull-hook]
:- %pull-hook-action
!>([%remove u.app-resource])
!>([%remove app-resource])
loop(entries t.entries)