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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -238,6 +238,13 @@
`[%done ~] `[%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 ++ poke-our
|= [=term =cage] |= [=term =cage]
=/ m (strand ,~) =/ m (strand ,~)

View File

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

View File

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

View File

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