metadata-store: exorcise paths

This commit is contained in:
Liam Fitzgerald 2021-01-12 14:26:19 +10:00
parent ef289cf282
commit 98324445c1
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
11 changed files with 150 additions and 562 deletions

View File

@ -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=metadata-action |= act=*
^- card ^- card
[%pass / %agent [our.bol %metadata-store] %poke %metadata-action !>(act)] *card
:: ::
++ metadata-hook-poke ++ metadata-hook-poke
|= act=metadata-hook-action |= act=metadata-hook-action

View File

@ -25,12 +25,13 @@
^- ? ^- ?
=/ grp ~(. group bowl) =/ grp ~(. group bowl)
=/ met ~(. metadata bowl) =/ met ~(. metadata bowl)
=/ group-paths (groups-from-resource:met [%graph (en-path:res resource)]) =/ groups
?~ group-paths %.n (groups-from-resource:met [%graph resource])
?~ groups %.n
?: requires-admin ?: requires-admin
(is-admin:grp src.bowl i.group-paths) (is-admin:grp src.bowl i.groups)
?| (is-member:grp src.bowl i.group-paths) ?| (is-member:grp src.bowl i.groups)
(is-admin:grp src.bowl i.group-paths) (is-admin:grp src.bowl i.groups)
== ==
:: ::
++ is-allowed-remove ++ is-allowed-remove

View File

@ -73,6 +73,8 @@
++ on-load ++ on-load
|= =old=vase |= =old=vase
^- (quip card _this) ^- (quip card _this)
?: =(1 1)
`this
=/ old =/ old
!<(versioned-state old-vase) !<(versioned-state old-vase)
=| cards=(list card) =| cards=(list card)

View File

@ -29,292 +29,4 @@
%- agent:dbug %- agent:dbug
%+ verb | %+ verb |
^- agent:gall ^- agent:gall
=< (default-agent *agent:gall %|)
|_ =bowl:gall
+* this .
hc ~(. +> bowl)
def ~(. (default-agent this %|) bowl)
::
++ on-init
[[%pass /updates %agent [our.bowl %metadata-store] %watch /updates]~ this]
::
++ on-save !>(state)
++ on-load
|= =vase
=/ old
!<(versioned-state vase)
?: ?=(%1 -.old)
`this(state old)
:: groups OTA did not migrate metadata syncs
:: we clear our syncs, and wait for metadata-store
:: to poke us with the syncs
`this
::
++ on-leave on-leave:def
++ on-peek
|= =path
^- (unit (unit cage))
?+ path (on-peek:def path)
[%x %export ~]
``noun+!>(state)
==
::
++ on-arvo
|= [=wire =sign-arvo]
^- (quip card _this)
?. ?=([%try-rejoin @ @ *] wire)
(on-arvo:def wire sign-arvo)
=/ nack-count=@ud (slav %ud i.t.wire)
=/ who=@p (slav %p i.t.t.wire)
=/ pax t.t.t.wire
?> ?=([%behn %wake *] sign-arvo)
~? ?=(^ error.sign-arvo)
"behn errored in backoff timers, continuing anyway"
:_ this
[(try-rejoin:hc who pax +(nack-count))]~
::
++ on-fail on-fail:def
::
++ on-poke
|= [=mark =vase]
^- (quip card _this)
?+ mark (on-poke:def mark vase)
%metadata-hook-action
=^ cards state
(poke-hook-action:hc !<(metadata-hook-action vase))
[cards this]
::
%metadata-action
[(poke-action:hc !<(metadata-action vase)) this]
::
%import
?> (team:title our.bowl src.bowl)
=^ cards state
(poke-import:hc q.vase)
[cards this]
==
::
++ on-watch
|= =path
^- (quip card _this)
?+ path (on-watch:def path)
[%group *] [(watch-group:hc t.path) this]
==
::
++ on-agent
|= [=wire =sign:agent:gall]
^- (quip card _this)
?+ -.sign (on-agent:def wire sign)
%kick =^(cards state (kick:hc wire) [cards this])
%watch-ack =^(cards state (watch-ack:hc wire p.sign) [cards this])
%fact
?+ p.cage.sign (on-agent:def wire sign)
%metadata-update
=^ cards state
(fact-metadata-update:hc wire !<(metadata-update q.cage.sign))
[cards this]
==
==
--
::
|_ =bowl:gall
+* grp ~(. grpl bowl)
++ poke-hook-action
|= act=metadata-hook-action
^- (quip card _state)
|^
?- -.act
%add-owned
?> (team:title our.bowl src.bowl)
:- ~
?: (~(has by synced) path.act) state
state(synced (~(put by synced) path.act our.bowl))
::
%add-synced
?> (team:title our.bowl src.bowl)
=/ =path [%group path.act]
?: (~(has by synced) path.act) [~ state]
:_ state(synced (~(put by synced) path.act ship.act))
[%pass path %agent [ship.act %metadata-hook] %watch path]~
::
%remove
=/ ship (~(get by synced) path.act)
?~ ship [~ state]
?: &(!=(u.ship src.bowl) ?!((team:title our.bowl src.bowl)))
[~ state]
:_ state(synced (~(del by synced) path.act))
%- zing
:~ (unsubscribe [%group path.act] u.ship)
[%give %kick ~[[%group path.act]] ~]~
==
==
::
++ unsubscribe
|= [=path =ship]
^- (list card)
?: =(ship our.bowl)
[%pass path %agent [our.bowl %metadata-store] %leave ~]~
[%pass path %agent [ship %metadata-hook] %leave ~]~
--
::
++ poke-action
|= act=metadata-action
^- (list card)
|^
?: (team:title our.bowl src.bowl)
?- -.act
%add (send group-path.act)
%remove (send group-path.act)
==
?> (is-member:grp src.bowl group-path.act)
?- -.act
%add (metadata-poke our.bowl %metadata-store)
%remove (metadata-poke our.bowl %metadata-store)
==
::
++ send
|= =group-path
^- (list card)
=/ =ship
%+ slav %p
(snag 1 group-path)
=/ app ?:(=(ship our.bowl) %metadata-store %metadata-hook)
(metadata-poke ship app)
::
++ metadata-poke
|= [=ship app=@tas]
^- (list card)
[%pass / %agent [ship app] %poke %metadata-action !>(act)]~
::
++ is-managed
|= =path
^- ?
?> ?=(^ path)
!=(i.path '~')
--
::
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-one
[%1 (remake-map ;;((tree [group-path ship]) +.arc))]
:_ sty
%+ murn ~(tap by synced.sty)
|= [=group-path =ship]
?: =(ship our.bowl)
~
=/ =path [%group group-path]
`(try-rejoin ship path 0)
::
++ try-rejoin
|= [who=@p pax=path nack-count=@ud]
^- card
=/ =wire
[%try-rejoin (scot %ud nack-count) (scot %p who) pax]
[%pass wire %agent [who %metadata-hook] %watch pax]
::
++ watch-group
|= =path
^- (list card)
|^
?> =(our.bowl (~(got by synced) path))
?> (is-member:grp src.bowl path)
%+ turn ~(tap by (metadata-scry path))
|= [[=group-path =md-resource] =metadata]
^- card
[%give %fact ~ %metadata-update !>([%add group-path md-resource metadata])]
::
++ metadata-scry
|= pax=^path
^- associations
=. pax
;: weld
/(scot %p our.bowl)/metadata-store/(scot %da now.bowl)/group
pax
/noun
==
.^(associations %gx pax)
--
::
++ fact-metadata-update
|= [wir=wire fact=metadata-update]
^- (quip card _state)
|^
[?:((team:title our.bowl src.bowl) handle-local handle-foreign) state]
::
++ handle-local
?+ -.fact ~
%add
?. (~(has by synced) group-path.fact) ~
(give group-path.fact fact)
::
%update-metadata
?. (~(has by synced) group-path.fact) ~
(give group-path.fact fact)
::
%remove
?. (~(has by synced) group-path.fact) ~
(give group-path.fact fact)
==
::
++ handle-foreign
?+ -.fact ~
%add
?. =(src.bowl (~(got by synced) group-path.fact)) ~
(poke fact)
::
%update-metadata
?. =(src.bowl (~(got by synced) group-path.fact)) ~
(poke [%add +.fact])
::
%remove
?. =(src.bowl (~(got by synced) group-path.fact)) ~
(poke fact)
==
::
++ give
|= [=path upd=metadata-update]
^- (list card)
[%give %fact ~[[%group path]] %metadata-update !>(upd)]~
::
++ poke
|= act=metadata-action
^- (list card)
[%pass / %agent [our.bowl %metadata-store] %poke %metadata-action !>(act)]~
--
::
++ kick
|= wir=wire
^- (quip card _state)
:_ state
|-
?+ wir !!
[%try-rejoin @ @ *]
$(wir t.t.t.wir)
::
[%updates ~]
[%pass /updates %agent [our.bowl %metadata-store] %watch /updates]~
::
[%group @ *]
?. (~(has by synced) t.wir) ~
=/ =ship (~(got by synced) t.wir)
?: =(ship our.bowl)
[%pass wir %agent [our.bowl %metadata-store] %watch wir]~
[%pass wir %agent [ship %metadata-hook] %watch wir]~
==
::
++ watch-ack
|= [wir=wire saw=(unit tang)]
^- (quip card _state)
?: ?=([%try-rejoin @ *] wir)
?~ saw
[~ state]
=/ nack-count=@ud (slav %ud i.t.wir)
=/ wakeup=@da
(add now.bowl (mul ~s1 (bex (min 19 nack-count))))
:_ state
[%pass wir %arvo %b %wait wakeup]~
?> ?=(^ wir)
[~ ?~(saw state state(synced (~(del by synced) t.wir)))]
::
--

View File

@ -44,11 +44,26 @@
creator=@p creator=@p
== ==
:: ::
+$ md-resource-1 [=app-name =app-path]
::
+$ associations-1 (map [group-path md-resource-1] metadata)
::
+$ base-state-1 +$ base-state-1
$: associations=associations $: associations=associations-1
group-indices=(jug group-path md-resource) group-indices=(jug group-path md-resource-1)
app-indices=(jug app-name [group-path app-path]) app-indices=(jug app-name [group-path app-path])
resource-indices=(jug md-resource group-path) resource-indices=(jug md-resource-1 group-path)
==
::
+$ cached-indices
$: group-indices=(jug resource md-resource)
app-indices=(jug app-name [group=resource =resource])
resource-indices=(jug md-resource resource)
==
::
+$ base-state-2
$: =associations
~
== ==
:: ::
+$ state-0 [%0 base-state-0] +$ state-0 [%0 base-state-0]
@ -58,6 +73,7 @@
+$ state-4 [%4 base-state-1] +$ state-4 [%4 base-state-1]
+$ state-5 [%5 base-state-1] +$ state-5 [%5 base-state-1]
+$ state-6 [%6 base-state-1] +$ state-6 [%6 base-state-1]
+$ state-7 [%7 base-state-2]
+$ versioned-state +$ versioned-state
$% state-0 $% state-0
state-1 state-1
@ -66,10 +82,16 @@
state-4 state-4
state-5 state-5
state-6 state-6
state-7
==
::
+$ inflated-state
$: state-7
cached-indices
== ==
-- --
:: ::
=| state-6 =| inflated-state
=* state - =* state -
%+ verb | %+ verb |
%- agent:dbug %- agent:dbug
@ -81,7 +103,7 @@
def ~(. (default-agent this %|) bowl) def ~(. (default-agent this %|) bowl)
:: ::
++ on-init on-init:def ++ on-init on-init:def
++ on-save !>(state) ++ on-save !>(-.state)
++ on-load ++ on-load
|= =vase |= =vase
^- (quip card _this) ^- (quip card _this)
@ -97,25 +119,6 @@
?+ mark (on-poke:def mark vase) ?+ mark (on-poke:def mark vase)
%metadata-action %metadata-action
(poke-metadata-action:mc !<(metadata-action vase)) (poke-metadata-action:mc !<(metadata-action vase))
::
%noun
=/ val=(each [%cleanup path] tang)
(mule |.(!<([%cleanup path] vase)))
?. ?=(%& -.val)
(on-poke:def mark vase)
=/ group=path +.p.val
=/ res=(set md-resource) (~(get ju group-indices) group)
=. group-indices (~(del by group-indices) group)
:- ~
%+ roll ~(tap in res)
|= [r=md-resource out=_state]
=: resource-indices.out (~(del by resource-indices.out) r)
associations.out (~(del by associations.out) group r)
app-indices.out
%- ~(del ju app-indices.out)
[app-name.r group app-path.r]
==
out
:: ::
%import %import
(poke-import:mc q.vase) (poke-import:mc q.vase)
@ -161,21 +164,21 @@
``noun+!>((metadata-for-app:mc app-name)) ``noun+!>((metadata-for-app:mc app-name))
:: ::
[%x %group *] [%x %group *]
=/ =group-path t.t.path =/ group=resource (de-path:resource t.t.path)
``noun+!>((metadata-for-group:mc group-path)) ``noun+!>((metadata-for-group:mc group))
:: ::
[%x %metadata @ @ @ ~] [%x %metadata @ @ @ ~]
=/ =group-path (stab (slav %t i.t.t.path)) =/ group=resource (de-path:resource (stab (slav %t i.t.t.path)))
=/ =md-resource [`term`i.t.t.t.path (stab (slav %t i.t.t.t.t.path))] =/ =md-resource [`term`i.t.t.t.path (de-path:resource (stab (slav %t i.t.t.t.t.path)))]
``noun+!>((~(get by associations) [group-path md-resource])) ``noun+!>((~(get by associations) [group md-resource]))
:: ::
[%x %resource @ *] [%x %resource @ *]
=/ app=term i.t.t.path =/ app=term i.t.t.path
=/ app-path=^path t.t.t.path =/ rid=resource (de-path:resource t.t.t.path)
``noun+!>((~(get by resource-indices) app app-path)) ``noun+!>((~(get by resource-indices) app rid))
:: ::
[%x %export ~] [%x %export ~]
``noun+!>(state) ``noun+!>(-.state)
== ==
:: ::
++ on-leave on-leave:def ++ on-leave on-leave:def
@ -192,118 +195,68 @@
=/ old !<(versioned-state vase) =/ old !<(versioned-state vase)
=| cards=(list card) =| cards=(list card)
|^ |^
?: ?=(%6 -.old) ?: ?=(%7 -.old)
=/ =^associations
(migrate-app-to-graph-store %chat associations.old)
:- cards :- cards
%_ state %_ state
associations associations associations
associations.old
:: ::
resource-indices resource-indices
(rebuild-resource-indices associations) (rebuild-resource-indices associations.old)
:: ::
app-indices app-indices
(rebuild-app-indices associations) (rebuild-app-indices associations.old)
:: ::
group-indices group-indices
(rebuild-group-indices associations) (rebuild-group-indices associations.old)
== ==
?: ?=(%6 -.old)
=/ old-assoc=associations-1
(migrate-app-to-graph-store %chat associations.old)
$(old [%7 (associations-1-to-2 old-assoc) ~])
::
?: ?=(%5 -.old) ?: ?=(%5 -.old)
=/ =^associations =/ associations=associations-1
(migrate-app-to-graph-store %publish associations.old) (migrate-app-to-graph-store %publish associations.old)
%_ $ %_ $
-.old %6 -.old %6
associations.old associations associations.old associations
::
resource-indices.old
(rebuild-resource-indices associations)
::
app-indices.old
(rebuild-app-indices associations)
::
group-indices.old
(rebuild-group-indices associations)
== ==
:: pre-breach, can safely throw away
?: ?=(%4 -.old) $(old *state-7)
%_ $ ++ associations-1-to-2
-.old %5 |= assoc=*
:: *^associations
resource-indices.old
(rebuild-resource-indices associations.old)
::
app-indices.old
(rebuild-app-indices associations.old)
::
group-indices.old
(rebuild-group-indices associations.old)
==
?: ?=(%3 -.old)
$(old [%4 +.old])
?: ?=(%2 -.old)
=/ new-state=state-3
%* . *state-3
associations
%- malt
%+ murn ~(tap by associations.old)
|= [[=group-path =md-resource] m=metadata-0]
^- (unit [[^group-path ^md-resource] metadata])
?: =(app-name.md-resource %link) ~
`[[group-path md-resource] (old-md-to-new m)]
==
$(old new-state)
?: ?=(%1 -.old)
%_ $
old [%2 +.old]
::
cards
%+ murn ~(tap in ~(key by group-indices.old))
|= =group-path
^- (unit card)
=/ rid (de-path-soft:resource group-path)
?~ rid ~
?: =(our.bowl entity.u.rid)
`(poke-md-hook %add-owned group-path)
`(poke-md-hook %add-synced entity.u.rid group-path)
==
=/ new-state-1=state-1
%* . *state-1
associations (migrate-associations associations.old)
group-indices (migrate-group-indices group-indices.old)
app-indices (migrate-app-indices app-indices.old)
resource-indices (migrate-resource-indices resource-indices.old)
==
$(old new-state-1)
:: ::
++ rebuild-resource-indices ++ rebuild-resource-indices
|= =^associations |= =^associations
%- ~(gas ju *(jug md-resource group-path)) %- ~(gas ju *(jug md-resource resource))
%+ turn ~(tap in ~(key by associations)) %+ turn ~(tap in ~(key by associations))
|= [g=group-path r=md-resource] |= [g=resource r=md-resource]
^- [md-resource group-path] ^- [md-resource resource]
[r g] [r g]
:: ::
++ rebuild-group-indices ++ rebuild-group-indices
|= =^associations |= =^associations
%- ~(gas ju *(jug group-path md-resource)) %- ~(gas ju *(jug resource md-resource))
~(tap in ~(key by associations)) ~(tap in ~(key by associations))
:: ::
++ rebuild-app-indices ++ rebuild-app-indices
|= =^associations |= =^associations
%- ~(gas ju *(jug app-name [group-path app-path])) %- ~(gas ju *(jug app-name [group=resource resource]))
%+ turn ~(tap in ~(key by associations)) %+ turn ~(tap in ~(key by associations))
|= [g=group-path r=md-resource] |= [g=resource r=md-resource]
^- [app-name [group-path app-path]] ^- [app-name [resource resource]]
[app-name.r [g app-path.r]] [app-name.r [g resource.r]]
:: ::
++ migrate-app-to-graph-store ++ migrate-app-to-graph-store
|= [app=@tas =^associations] |= [app=@tas associations=associations-1]
^+ associations ^- associations-1
%- malt %- malt
%+ turn ~(tap by associations) %+ turn ~(tap by associations)
|= [[=group-path =md-resource] m=metadata] |= [[=group-path md-resource=md-resource-1] m=metadata]
^- [[^group-path ^md-resource] 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
@ -311,155 +264,76 @@
app-path.md-resource app-path.md-resource
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-md-hook
|= act=metadata-hook-action
^- card
=/ =cage metadata-hook-action+!>(act)
[%pass / %agent [our.bowl %metadata-hook] %poke cage]
::
++ new-group-path
|= =group-path
ship+(new-app-path group-path)
::
++ new-app-path
|= =app-path
^- path
?> ?=(^ app-path)
?:(=('~' i.app-path) t.app-path app-path)
::
++ old-md-to-new
|= m=metadata-0
^- metadata
%* . *metadata
title title.m
description description.m
color color.m
date-created date-created.m
creator creator.m
module *term
==
::
++ migrate-md-resource
|= md-resource
^- md-resource
?: =(%chat app-name) [%chat (new-app-path app-path)]
?: =(%contacts app-name) [%contacts ship+app-path]
[app-name app-path]
::
++ migrate-resource-indices
|= resource-indices=(jug md-resource group-path)
^- (jug md-resource group-path)
%- malt
%+ turn ~(tap by resource-indices)
|= [=md-resource paths=(set group-path)]
:- (migrate-md-resource md-resource)
(~(run in paths) new-group-path)
::
++ migrate-app-indices
|= app-indices=(jug app-name [group-path app-path])
%- malt
%+ turn ~(tap by app-indices)
|= [app=term indices=(set [=group-path =app-path])]
:- app
%- ~(run in indices)
|= [=group-path =app-path]
:- (new-group-path group-path)
?: =(%chat app) (new-app-path app-path)
?: =(%contacts app) ship+app-path
app-path
::
++ migrate-group-indices
|= group-indices=(jug group-path md-resource)
%- malt
%+ turn ~(tap by group-indices)
|= [=group-path resources=(set md-resource)]
:- (new-group-path group-path)
%- sy
%+ turn ~(tap in resources)
migrate-md-resource
::
++ migrate-associations
|= associations=associations-0
%- malt
%+ turn ~(tap by associations)
|= [[g=group-path r=md-resource] m=metadata-0]
:_ m
[(new-group-path g) (migrate-md-resource r)]
-- --
++ poke-metadata-action ++ poke-metadata-action
|= act=metadata-action |= act=metadata-action
^- (quip card _state) ^- (quip card _state)
?> (team:title our.bowl src.bowl) ?> (team:title our.bowl src.bowl)
?- -.act ?- -.act
%add (handle-add group-path.act resource.act metadata.act) %add (handle-add group.act resource.act metadata.act)
%remove (handle-remove group-path.act resource.act) %remove (handle-remove group.act resource.act)
== ==
:: ::
++ poke-import ++ poke-import
|= arc=* |= arc=*
^- (quip card _state) ^- (quip card _state)
|^ |^
(on-load !>([%5 (remake-metadata ;;(tree-metadata +.arc))])) (on-load !>([%7 (remake-metadata ;;(tree-metadata +.arc))]))
:: ::
+$ tree-metadata +$ tree-metadata
$: associations=(tree [[group-path md-resource] metadata]) $: associations=(tree [[resource md-resource] metadata])
group-indices=(tree [group-path (tree md-resource)]) ~
app-indices=(tree [app-name (tree [group-path app-path])])
resource-indices=(tree [md-resource (tree group-path)])
== ==
:: ::
++ remake-metadata ++ remake-metadata
|= tm=tree-metadata |= tm=tree-metadata
^- base-state-1 ^- base-state-2
:* (remake-map associations.tm) :* (remake-map associations.tm)
(remake-jug group-indices.tm) ~
(remake-jug app-indices.tm)
(remake-jug resource-indices.tm)
== ==
-- --
:: ::
++ handle-add ++ handle-add
|= [=group-path =md-resource =metadata] |= [group=resource =md-resource =metadata]
^- (quip card _state) ^- (quip card _state)
:- %+ send-diff app-name.md-resource :- %+ send-diff app-name.md-resource
?: (~(has by resource-indices) md-resource) ?: (~(has by resource-indices) md-resource)
[%update-metadata group-path md-resource metadata] [%update-metadata group md-resource metadata]
[%add group-path md-resource metadata] [%add group md-resource metadata]
%= state %= state
associations associations
(~(put by associations) [group-path md-resource] metadata) (~(put by associations) [group md-resource] metadata)
:: ::
group-indices group-indices
(~(put ju group-indices) group-path md-resource) (~(put ju group-indices) group md-resource)
:: ::
app-indices app-indices
%+ ~(put ju app-indices) %+ ~(put ju app-indices)
app-name.md-resource app-name.md-resource
[group-path app-path.md-resource] [group resource.md-resource]
:: ::
resource-indices resource-indices
(~(put ju resource-indices) md-resource group-path) (~(put ju resource-indices) md-resource group)
== ==
:: ::
++ handle-remove ++ handle-remove
|= [=group-path =md-resource] |= [group=resource =md-resource]
^- (quip card _state) ^- (quip card _state)
:- (send-diff app-name.md-resource [%remove group-path md-resource]) :- (send-diff app-name.md-resource [%remove group md-resource])
%= state %= state
associations associations
(~(del by associations) [group-path md-resource]) (~(del by associations) [group md-resource])
:: ::
group-indices group-indices
(~(del ju group-indices) group-path md-resource) (~(del ju group-indices) group md-resource)
:: ::
app-indices app-indices
%+ ~(del ju app-indices) %+ ~(del ju app-indices)
app-name.md-resource app-name.md-resource
[group-path app-path.md-resource] [group resource.md-resource]
:: ::
resource-indices resource-indices
(~(del ju resource-indices) md-resource group-path) (~(del ju resource-indices) md-resource group)
== ==
:: ::
++ metadata-for-app ++ metadata-for-app
@ -467,18 +341,18 @@
^- ^associations ^- ^associations
%- ~(gas by *^associations) %- ~(gas by *^associations)
%+ turn ~(tap in (~(gut by app-indices) app-name ~)) %+ turn ~(tap in (~(gut by app-indices) app-name ~))
|= [=group-path =app-path] |= [group=resource rid=resource]
:- [group-path [app-name app-path]] :- [group [app-name rid]]
(~(got by associations) [group-path [app-name app-path]]) (~(got by associations) [group [app-name rid]])
:: ::
++ metadata-for-group ++ metadata-for-group
|= =group-path |= group=resource
^- ^associations ^- ^associations
%- ~(gas by *^associations) %- ~(gas by *^associations)
%+ turn ~(tap in (~(gut by group-indices) group-path ~)) %+ turn ~(tap in (~(gut by group-indices) group ~))
|= =md-resource |= =md-resource
:- [group-path md-resource] :- [group md-resource]
(~(got by associations) [group-path md-resource]) (~(got by associations) [group md-resource])
:: ::
++ send-diff ++ send-diff
|= [=app-name upd=metadata-update] |= [=app-name upd=metadata-update]

View File

@ -44,15 +44,15 @@
(scry-group-path group-path) (scry-group-path group-path)
:: ::
++ is-member ++ is-member
|= [=ship =group-path] |= [=ship group=resource]
^- ? ^- ?
=- (~(has in -) ship) =- (~(has in -) ship)
(members-from-path group-path) (members group)
:: ::
++ is-admin ++ is-admin
|= [=ship =group-path] |= [=ship group=resource]
^- ? ^- ?
=/ tags tags:(fall (scry-group-path group-path) *group) =/ tags tags:(fall (scry-group group) *^group)
=/ admins=(set ^ship) (~(gut by tags) %admin ~) =/ admins=(set ^ship) (~(gut by tags) %admin ~)
(~(has in admins) ship) (~(has in admins) ship)
:: +role-for-ship: get role for user :: +role-for-ship: get role for user

View File

@ -245,11 +245,9 @@
|= =(list ^group-contents) |= =(list ^group-contents)
^- json ^- json
:- %a :- %a
%+ murn list %+ turn list
|= =^group-contents |= =^group-contents
?. ?=(?(%add-members %remove-members) -.group-contents) (update:enjs:group-store group-contents)
~
`(update:enjs:group-store group-contents)
-- --
:: ::
++ indexed-notification ++ indexed-notification

View File

@ -1,4 +1,5 @@
/- *metadata-store /- *metadata-store
/+ resource
|% |%
++ associations-to-json ++ associations-to-json
|= =associations |= =associations
@ -6,19 +7,19 @@
^- json ^- json
%- pairs %- pairs
%+ turn ~(tap by associations) %+ turn ~(tap by associations)
|= [[=group-path =md-resource] =metadata] |= [[group=resource =md-resource] =metadata]
^- [cord json] ^- [cord json]
:- :-
%- crip %- crip
;: weld ;: weld
(trip (spat group-path)) (trip (spat (en-path:resource group)))
(weld "/" (trip app-name.md-resource)) (weld "/" (trip app-name.md-resource))
(trip (spat app-path.md-resource)) (trip (spat (en-path:resource resource.md-resource)))
== ==
%- pairs %- pairs
:~ [%group-path (path group-path)] :~ [%group s+(enjs-path:resource group)]
[%app-name s+app-name.md-resource] [%app-name s+app-name.md-resource]
[%app-path (path app-path.md-resource)] [%resource s+(enjs-path:resource resource.md-resource)]
[%metadata (metadata-to-json metadata)] [%metadata (metadata-to-json metadata)]
== ==
:: ::
@ -36,13 +37,13 @@
:: ::
++ add ++ add
%- ot %- ot
:~ [%group-path pa] :~ [%group dejs-path:resource]
[%resource md-resource] [%resource md-resource]
[%metadata metadata] [%metadata metadata]
== ==
++ remove ++ remove
%- ot %- ot
:~ [%group-path pa] :~ [%group dejs-path:resource]
[%resource md-resource] [%resource md-resource]
== ==
:: ::
@ -60,10 +61,12 @@
[%creator (su ;~(pfix sig fed:ag))] [%creator (su ;~(pfix sig fed:ag))]
[%module so] [%module so]
== ==
::
++ md-resource ++ md-resource
^- $-(json ^md-resource)
%- ot %- ot
:~ [%app-name so] :~ [%app-name so]
[%app-path pa] [%resource dejs-path:resource]
== ==
-- --
:: ::
@ -90,27 +93,27 @@
%add %add
:- %add :- %add
%- pairs %- pairs
:~ [%group-path (path group-path.upd)] :~ [%group s+(enjs-path:resource group.upd)]
[%app-name s+app-name.resource.upd] [%app-name s+app-name.resource.upd]
[%app-path (path app-path.resource.upd)] [%resource s+(enjs-path:resource resource.resource.upd)]
[%metadata (metadata-to-json metadata.upd)] [%metadata (metadata-to-json metadata.upd)]
== ==
:: ::
%update-metadata %update-metadata
:- %update-metadata :- %update-metadata
%- pairs %- pairs
:~ [%group-path (path group-path.upd)] :~ [%group s+(enjs-path:resource group.upd)]
[%app-name s+app-name.resource.upd] [%app-name s+app-name.resource.upd]
[%app-path (path app-path.resource.upd)] [%resource s+(enjs-path:resource resource.resource.upd)]
[%metadata (metadata-to-json metadata.upd)] [%metadata (metadata-to-json metadata.upd)]
== ==
:: ::
%remove %remove
:- %remove :- %remove
%- pairs %- pairs
:~ [%group-path (path group-path.upd)] :~ [%group s+(enjs-path:resource group.upd)]
[%app-name s+app-name.resource.upd] [%app-name s+app-name.resource.upd]
[%app-path (path app-path.resource.upd)] [%resource s+(enjs-path:resource resource.resource.upd)]
== ==
:: ::
%associations %associations

View File

@ -5,12 +5,12 @@
:: ::
|_ =bowl:gall |_ =bowl:gall
++ app-paths-from-group ++ app-paths-from-group
|= [=app-name =group-path] |= [=app-name group=resource]
^- (list app-path) ^- (list resource)
%+ murn %+ murn
%~ tap in %~ tap in
=- (~(gut by -) group-path ~) =- (~(gut by -) group ~)
.^ (jug ^group-path md-resource) .^ (jug resource md-resource)
%gy %gy
(scot %p our.bowl) (scot %p our.bowl)
%metadata-store %metadata-store
@ -18,9 +18,9 @@
/group-indices /group-indices
== ==
|= =md-resource |= =md-resource
^- (unit app-path) ^- (unit resource)
?. =(app-name.md-resource app-name) ~ ?. =(app-name.md-resource app-name) ~
`app-path.md-resource `resource.md-resource
:: ::
++ peek-metadata ++ peek-metadata
|= [app-name=term =group=resource:res =app=resource:res] |= [app-name=term =group=resource:res =app=resource:res]
@ -35,23 +35,21 @@
== ==
:: ::
++ group-from-app-resource ++ group-from-app-resource
|= [app=term =app=resource:res] |= =md-resource
^- (unit resource:res) ^- (unit resource:res)
=/ app-path (en-path:res app-resource) =/ groups (groups-from-resource md-resource)
=/ group-paths (groups-from-resource app app-path) ?~ groups ~
?~ group-paths `i.groups
~
`(de-path:res i.group-paths)
:: ::
++ groups-from-resource ++ groups-from-resource
|= =md-resource |= =md-resource
^- (list group-path) ^- (list resource)
=; resources =; resources
%~ tap in %~ tap in
%+ ~(gut by resources) %+ ~(gut by resources)
md-resource md-resource
*(set group-path) *(set resource)
.^ (jug ^md-resource group-path) .^ (jug ^md-resource resource)
%gy %gy
(scot %p our.bowl) (scot %p our.bowl)
%metadata-store %metadata-store

View File

@ -62,9 +62,7 @@
:: ::
+$ group-contents +$ group-contents
$~ [%add-members *resource ~] $~ [%add-members *resource ~]
$% $>(?(%add-members %remove-members) update:group-store) $>(?(%add-members %remove-members) update:group-store)
metadata-action:metadata-store
==
:: ::
+$ notification +$ notification
[date=@da read=? =contents] [date=@da read=? =contents]

View File

@ -1,9 +1,11 @@
/- *resource
|% |%
::
+$ group-path path +$ group-path path
+$ app-name term +$ app-name term
+$ app-path path +$ app-path path
+$ md-resource [=app-name =app-path] +$ md-resource [=app-name =resource]
+$ associations (map [group-path md-resource] metadata) +$ associations (map [group=resource md-resource] metadata)
:: ::
+$ color @ux +$ color @ux
+$ metadata +$ metadata
@ -16,13 +18,13 @@
== ==
:: ::
+$ metadata-action +$ metadata-action
$% [%add =group-path resource=md-resource =metadata] $% [%add group=resource resource=md-resource =metadata]
[%remove =group-path resource=md-resource] [%remove group=resource resource=md-resource]
== ==
:: ::
+$ metadata-update +$ metadata-update
$% metadata-action $% metadata-action
[%associations =associations] [%associations =associations]
[%update-metadata =group-path resource=md-resource =metadata] [%update-metadata group=resource resource=md-resource =metadata]
== ==
-- --