mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 11:33:41 +03:00
Merge remote-tracking branch 'origin/release/next-userspace' into lf/graph-permissioning
This commit is contained in:
commit
a5f945b5a4
@ -6,8 +6,7 @@
|
||||
/-
|
||||
inv=invite-store,
|
||||
*contact-hook,
|
||||
*metadata-store,
|
||||
*metadata-hook,
|
||||
metadata=metadata-store,
|
||||
pull-hook,
|
||||
push-hook
|
||||
/+ *server, *contact-json, default-agent, dbug, verb,
|
||||
@ -297,31 +296,21 @@
|
||||
[%pass / %agent [our.bol %group-pull-hook] %poke %pull-hook-action !>(act)]
|
||||
::
|
||||
++ metadata-poke
|
||||
|= act=metadata-action
|
||||
|= =action:metadata
|
||||
^- card
|
||||
[%pass / %agent [our.bol %metadata-store] %poke metadata-action+!>(act)]
|
||||
::
|
||||
++ metadata-hook-poke
|
||||
|= act=metadata-hook-action
|
||||
^- card
|
||||
[%pass / %agent [our.bol %metadata-hook] %poke %metadata-hook-action !>(act)]
|
||||
::
|
||||
++ sync-metadata
|
||||
|= [=ship =path]
|
||||
^- card
|
||||
(metadata-hook-poke %add-synced ship path)
|
||||
[%pass / %agent [our.bol %metadata-store] %poke metadata-action+!>(action)]
|
||||
::
|
||||
++ create-metadata
|
||||
|= [rid=resource title=@t description=@t]
|
||||
^- (list card)
|
||||
=/ =metadata
|
||||
%* . *metadata
|
||||
=/ =metadatum:metadata
|
||||
%* . *metadatum:metadata
|
||||
title title
|
||||
description description
|
||||
date-created now.bol
|
||||
creator our.bol
|
||||
==
|
||||
:~ (metadata-poke [%add rid [%contacts rid] metadata])
|
||||
:~ (metadata-poke [%add rid [%contacts rid] metadatum])
|
||||
(push-metadata rid)
|
||||
==
|
||||
::
|
||||
|
@ -1,7 +1,7 @@
|
||||
:: hark-graph-hook: notifications for graph-store [landscape]
|
||||
::
|
||||
/- post, group-store, metadata-store, hook=hark-graph-hook, store=hark-store
|
||||
/+ resource, metadata, default-agent, dbug, graph-store, graph, grouplib=group, store=hark-store
|
||||
/- post, group-store, metadata=metadata-store, hook=hark-graph-hook, store=hark-store
|
||||
/+ resource, mdl=metadata, default-agent, dbug, graph-store, graph, grouplib=group, store=hark-store
|
||||
::
|
||||
::
|
||||
~% %hark-graph-hook-top ..part ~
|
||||
@ -53,7 +53,7 @@
|
||||
+* this .
|
||||
ha ~(. +> bowl)
|
||||
def ~(. (default-agent this %|) bowl)
|
||||
met ~(. metadata bowl)
|
||||
met ~(. mdl bowl)
|
||||
grp ~(. grouplib bowl)
|
||||
gra ~(. graph bowl)
|
||||
::
|
||||
@ -276,10 +276,10 @@
|
||||
?~ group
|
||||
~& no-group+rid
|
||||
`state
|
||||
=/ metadata=(unit metadata:metadata-store)
|
||||
(peek-metadata:met %graph rid)
|
||||
?~ metadata `state
|
||||
abet:check:(abed:handle-update:ha rid nodes u.group module.u.metadata)
|
||||
=/ metadatum=(unit metadatum:metadata)
|
||||
(peek-metadatum:met %graph rid)
|
||||
?~ metadatum `state
|
||||
abet:check:(abed:handle-update:ha rid nodes u.group module.u.metadatum)
|
||||
--
|
||||
::
|
||||
++ on-peek on-peek:def
|
||||
@ -300,7 +300,7 @@
|
||||
--
|
||||
::
|
||||
|_ =bowl:gall
|
||||
+* met ~(. metadata bowl)
|
||||
+* met ~(. mdl bowl)
|
||||
grp ~(. grouplib bowl)
|
||||
gra ~(. graph bowl)
|
||||
::
|
||||
|
@ -1,7 +1,7 @@
|
||||
:: hark-group-hook: notifications for groups [landscape]
|
||||
::
|
||||
/- store=hark-store, post, group-store, metadata-store, hook=hark-group-hook
|
||||
/+ resource, metadata, default-agent, dbug, graph-store
|
||||
/- store=hark-store, post, group-store, metadata=metadata-store, hook=hark-group-hook
|
||||
/+ resource, mdl=metadata, default-agent, dbug, graph-store
|
||||
::
|
||||
~% %hark-group-hook-top ..part ~
|
||||
|%
|
||||
@ -28,7 +28,7 @@
|
||||
+* this .
|
||||
ha ~(. +> bowl)
|
||||
def ~(. (default-agent this %|) bowl)
|
||||
met ~(. metadata bowl)
|
||||
met ~(. mdl bowl)
|
||||
::
|
||||
++ on-init
|
||||
:_ this
|
||||
@ -115,7 +115,7 @@
|
||||
::
|
||||
%metadata-update
|
||||
=^ cards state
|
||||
(metadata-update !<(metadata-update:metadata-store q.cage.sign))
|
||||
(metadata-update !<(update:metadata q.cage.sign))
|
||||
[cards this]
|
||||
==
|
||||
==
|
||||
@ -140,7 +140,7 @@
|
||||
:: - We have no way of retrieving old metadata to e.g. get a
|
||||
:: channel's old name when it is renamed
|
||||
++ metadata-update
|
||||
|= update=metadata-update:metadata-store
|
||||
|= =update:metadata
|
||||
^- (quip card _state)
|
||||
[~ state]
|
||||
::
|
||||
|
@ -2,7 +2,7 @@
|
||||
::
|
||||
:: allow syncing group data from foreign paths to local paths
|
||||
::
|
||||
/- *group, invite-store, *metadata-store
|
||||
/- *group, invite-store, metadata=metadata-store
|
||||
/+ default-agent, verb, dbug, store=group-store, grpl=group, pull-hook
|
||||
/+ resource, mdl=metadata
|
||||
~% %group-hook-top ..part ~
|
||||
@ -12,12 +12,12 @@
|
||||
++ config
|
||||
^- config:pull-hook
|
||||
:* %metadata-store
|
||||
metadata-update
|
||||
update:metadata
|
||||
%metadata-update
|
||||
%metadata-push-hook
|
||||
==
|
||||
+$ state-zero
|
||||
[%0 previews=(map resource group-preview)]
|
||||
[%0 previews=(map resource group-preview:metadata)]
|
||||
::
|
||||
--
|
||||
::
|
||||
@ -81,12 +81,12 @@
|
||||
|= [=mark =vase]
|
||||
?. ?=(%metadata-hook-update mark)
|
||||
(on-poke:def mark vase)
|
||||
=+ !<(upd=metadata-hook-update vase)
|
||||
?. ?=(%preview -.upd)
|
||||
=+ !<(=hook-update:metadata vase)
|
||||
?. ?=(%preview -.hook-update)
|
||||
(on-poke:def mark vase)
|
||||
:_ this(previews (~(put by previews) group.upd +.upd))
|
||||
:_ this(previews (~(put by previews) group.hook-update +.hook-update))
|
||||
=/ paths=(list path)
|
||||
~[preview+(en-path:resource group.upd)]
|
||||
~[preview+(en-path:resource group.hook-update)]
|
||||
:~ [%give %fact paths mark^vase]
|
||||
[%give %kick paths ~]
|
||||
==
|
||||
@ -115,7 +115,7 @@
|
||||
(on-watch:def path)
|
||||
=/ rid=resource
|
||||
(de-path:resource t.path)
|
||||
=/ prev=(unit group-preview)
|
||||
=/ prev=(unit group-preview:metadata)
|
||||
(~(get by previews) rid)
|
||||
:_ this
|
||||
?~ prev
|
||||
@ -130,14 +130,14 @@
|
||||
++ on-pull-nack
|
||||
|= [=resource =tang]
|
||||
^- (quip card _this)
|
||||
=/ =associations
|
||||
=/ =associations:metadata
|
||||
(metadata-for-group:met resource)
|
||||
:_ this
|
||||
%+ turn ~(tap by associations)
|
||||
|= [=md-resource =association]
|
||||
|= [=md-resource:metadata =association:metadata]
|
||||
=- [%pass / %agent [our.bowl %metadata-store] %poke -]
|
||||
:- %metadata-update
|
||||
!> ^- metadata-update
|
||||
!> ^- update:metadata
|
||||
[%remove resource md-resource]
|
||||
::
|
||||
++ on-pull-kick
|
||||
|
@ -1,6 +1,6 @@
|
||||
:: metadata-push-hook [landscape]:
|
||||
::
|
||||
/- *group, *invite-store, *metadata-store
|
||||
/- *group, *invite-store, store=metadata-store
|
||||
/+ default-agent, verb, dbug, grpl=group, push-hook,
|
||||
resource, mdl=metadata, gral=graph
|
||||
~% %group-hook-top ..part ~
|
||||
@ -11,7 +11,7 @@
|
||||
^- config:push-hook
|
||||
:* %metadata-store
|
||||
/all
|
||||
metadata-update
|
||||
update:store
|
||||
%metadata-update
|
||||
%metadata-pull-hook
|
||||
==
|
||||
@ -39,28 +39,28 @@
|
||||
|= [=mark =vase]
|
||||
?. ?=(%metadata-hook-update mark)
|
||||
(on-poke:def mark vase)
|
||||
=+ !<(upd=metadata-hook-update vase)
|
||||
?. ?=(%req-preview -.upd)
|
||||
=+ !<(=hook-update:store vase)
|
||||
?. ?=(%req-preview -.hook-update)
|
||||
(on-poke:def mark vase)
|
||||
=* rid group.upd
|
||||
=* rid group.hook-update
|
||||
|^
|
||||
?> =(entity.rid our.bowl)
|
||||
?> (can-join:grp rid src.bowl)
|
||||
=/ members
|
||||
~(wyt in (members:grp rid))
|
||||
=/ =metadata
|
||||
(need (peek-metadata:met %contacts rid))
|
||||
=/ =metadatum:store
|
||||
(need (peek-metadatum:met %contacts rid))
|
||||
:_ this
|
||||
=; =cage
|
||||
[%pass / %agent [src.bowl %metadata-pull-hook] %poke cage]~
|
||||
:- %metadata-hook-update
|
||||
!> ^- metadata-hook-update
|
||||
[%preview rid channels members channel-count metadata]
|
||||
!> ^- hook-update:store
|
||||
[%preview rid channels members channel-count metadatum]
|
||||
::
|
||||
++ channels
|
||||
%- ~(gas by *associations)
|
||||
%- ~(gas by *associations:store)
|
||||
%+ skim ~(tap by (app-metadata-for-group:met rid %graph))
|
||||
|=([=md-resource group=resource =metadata] preview.metadata)
|
||||
|=([=md-resource:store group=resource =metadatum:store] preview.metadatum)
|
||||
::
|
||||
++ channel-count
|
||||
~(wyt by (app-metadata-for-group:met rid %graph))
|
||||
@ -75,19 +75,19 @@
|
||||
::
|
||||
++ should-proxy-update
|
||||
|= =vase
|
||||
=+ !<(upd=metadata-update vase)
|
||||
?. ?=(?(%add %remove) -.upd)
|
||||
=+ !<(=update:store vase)
|
||||
?. ?=(?(%add %remove) -.update)
|
||||
%.n
|
||||
=/ role=(unit (unit role-tag))
|
||||
(role-for-ship:grp group.upd src.bowl)
|
||||
=/ =metadata
|
||||
(role-for-ship:grp group.update src.bowl)
|
||||
=/ =metadatum:store
|
||||
(need (peek-metadata:met %contacts group.upd))
|
||||
?~ role %.n
|
||||
?^ u.role
|
||||
?=(?(%admin %moderator) u.u.role)
|
||||
?. ?=(%add -.upd) %.n
|
||||
?& =(src.bowl entity.resource.resource.upd)
|
||||
?=(%member-metadata vip.metadata)
|
||||
?=(%member-metadata vip.metadatum)
|
||||
==
|
||||
::
|
||||
++ take-update
|
||||
@ -100,11 +100,11 @@
|
||||
^- vase
|
||||
=/ group
|
||||
(scry-group:grp rid)
|
||||
=/ =associations
|
||||
=/ =associations:store
|
||||
(metadata-for-group:met rid)
|
||||
?> ?=(^ group)
|
||||
?> (~(has in members.u.group) src.bowl)
|
||||
!> ^- metadata-update
|
||||
!> ^- update:store
|
||||
[%initial-group rid associations]
|
||||
::
|
||||
--
|
||||
|
@ -3,11 +3,11 @@
|
||||
:: data store for application metadata and mappings
|
||||
:: between groups and resources within applications
|
||||
::
|
||||
:: group-paths are expected to be an existing group path
|
||||
:: paths are expected to be an existing group path
|
||||
:: resources are expected to correspond to existing app paths
|
||||
::
|
||||
:: note: when scrying for metadata, to make the arguments safe in paths,
|
||||
:: encode group-path and app-path using (scot %t (spat group-path))
|
||||
:: encode path and path using (scot %t (spat path))
|
||||
::
|
||||
:: +watch paths:
|
||||
:: /all associations + updates
|
||||
@ -19,22 +19,22 @@
|
||||
:: /group-indices all group indices
|
||||
:: /app-indices all app indices
|
||||
:: /resource-indices all resource indices
|
||||
:: /metadata/%group-path/%app-name/%app-path specific metadatum
|
||||
:: /metadata/%path/%app-name/%path specific metadatum
|
||||
:: /app-name/%app-name associations for app
|
||||
:: /group/%group-path associations for group
|
||||
:: /group/%path associations for group
|
||||
::
|
||||
/- *metadata-store, *metadata-hook
|
||||
/- store=metadata-store
|
||||
/+ *metadata-json, default-agent, verb, dbug, resource, *migrate
|
||||
|%
|
||||
+$ card card:agent:gall
|
||||
+$ base-state-0
|
||||
$: associations=associations-0
|
||||
group-indices=(jug group-path md-resource)
|
||||
app-indices=(jug app-name [group-path app-path])
|
||||
resource-indices=(jug md-resource group-path)
|
||||
group-indices=(jug path md-resource:store)
|
||||
app-indices=(jug app-name:store [path path])
|
||||
resource-indices=(jug md-resource:store path)
|
||||
==
|
||||
::
|
||||
+$ associations-0 (map [group-path md-resource] metadata-0)
|
||||
+$ associations-0 (map [path md-resource:store] metadata-0)
|
||||
::
|
||||
+$ metadata-0
|
||||
$: title=@t
|
||||
@ -53,25 +53,25 @@
|
||||
module=term
|
||||
==
|
||||
::
|
||||
+$ md-resource-1 [=app-name =app-path]
|
||||
+$ md-resource-1 [=app-name:store =path]
|
||||
::
|
||||
+$ associations-1 (map [group-path md-resource-1] metadata-1)
|
||||
+$ associations-1 (map [path md-resource-1] metadata-1)
|
||||
::
|
||||
+$ base-state-1
|
||||
$: associations=associations-1
|
||||
group-indices=(jug group-path md-resource-1)
|
||||
app-indices=(jug app-name [group-path app-path])
|
||||
resource-indices=(jug md-resource-1 group-path)
|
||||
group-indices=(jug path md-resource-1)
|
||||
app-indices=(jug app-name:store [path path])
|
||||
resource-indices=(jug md-resource-1 path)
|
||||
==
|
||||
::
|
||||
+$ cached-indices
|
||||
$: group-indices=(jug resource md-resource)
|
||||
app-indices=(jug app-name [group=resource =resource])
|
||||
resource-indices=(map md-resource resource)
|
||||
$: group-indices=(jug resource md-resource:store)
|
||||
app-indices=(jug app-name:store [group=resource =resource])
|
||||
resource-indices=(map md-resource:store resource)
|
||||
==
|
||||
::
|
||||
+$ base-state-2
|
||||
$: =associations
|
||||
$: =associations:store
|
||||
~
|
||||
==
|
||||
::
|
||||
@ -127,7 +127,7 @@
|
||||
=^ cards state
|
||||
?+ mark (on-poke:def mark vase)
|
||||
?(%metadata-action %metadata-update)
|
||||
(poke-metadata-update:mc !<(metadata-update vase))
|
||||
(poke-metadata-update:mc !<(update:store vase))
|
||||
::
|
||||
%import
|
||||
(poke-import:mc q.vase)
|
||||
@ -150,7 +150,7 @@
|
||||
~
|
||||
::
|
||||
[%app-name @ ~]
|
||||
=/ =app-name i.t.path
|
||||
=/ =app-name:store i.t.path
|
||||
=/ app-indices (metadata-for-app:mc app-name)
|
||||
(give %metadata-update !>([%associations app-indices]))
|
||||
==
|
||||
@ -171,7 +171,7 @@
|
||||
[%y %resource-indices ~] ``noun+!>(resource-indices)
|
||||
[%x %associations ~] ``noun+!>(associations)
|
||||
[%x %app-name @ ~]
|
||||
=/ =app-name i.t.t.path
|
||||
=/ =app-name:store i.t.t.path
|
||||
``noun+!>((metadata-for-app:mc app-name))
|
||||
::
|
||||
[%x %group *]
|
||||
@ -179,7 +179,7 @@
|
||||
``noun+!>((metadata-for-group:mc group))
|
||||
::
|
||||
[%x %metadata @ @ @ @ ~]
|
||||
=/ =md-resource
|
||||
=/ =md-resource:store
|
||||
[i.t.t.path (de-path:resource t.t.t.path)]
|
||||
``noun+!>((~(get by associations) md-resource))
|
||||
::
|
||||
@ -240,26 +240,26 @@
|
||||
::
|
||||
++ associations-1-to-2
|
||||
|= assoc=associations-1
|
||||
^- ^associations
|
||||
%- ~(gas by *^associations)
|
||||
^- associations:store
|
||||
%- ~(gas by *associations:store)
|
||||
%+ murn
|
||||
~(tap by assoc)
|
||||
|= [[group=path m=md-resource-1] met=metadata-1]
|
||||
%+ biff (de-path-soft:resource group)
|
||||
|= g=resource
|
||||
%+ bind (md-resource-1-to-2 m)
|
||||
|= =md-resource
|
||||
|= =md-resource:store
|
||||
[md-resource g (metadata-1-to-2 met)]
|
||||
::
|
||||
++ md-resource-1-to-2
|
||||
|= m=md-resource-1
|
||||
^- (unit md-resource)
|
||||
%+ bind (de-path-soft:resource app-path.m)
|
||||
^- (unit md-resource:store)
|
||||
%+ bind (de-path-soft:resource path.m)
|
||||
|=(rid=resource [app-name.m rid])
|
||||
::
|
||||
++ metadata-1-to-2
|
||||
|= m=metadata-1
|
||||
%* . *metadata
|
||||
%* . *metadatum:store
|
||||
title title.m
|
||||
description description.m
|
||||
color color.m
|
||||
@ -269,25 +269,25 @@
|
||||
==
|
||||
::
|
||||
++ rebuild-resource-indices
|
||||
|= =^associations
|
||||
%- ~(gas by *(map md-resource resource))
|
||||
|= =associations:store
|
||||
%- ~(gas by *(map md-resource:store resource))
|
||||
%+ turn ~(tap by associations)
|
||||
|= [r=md-resource g=resource =metadata]
|
||||
|= [r=md-resource:store g=resource =metadatum:store]
|
||||
[r g]
|
||||
::
|
||||
++ rebuild-group-indices
|
||||
|= =^associations
|
||||
%- ~(gas ju *(jug resource md-resource))
|
||||
|= =associations:store
|
||||
%- ~(gas ju *(jug resource md-resource:store))
|
||||
%+ turn
|
||||
~(tap by associations)
|
||||
|= [r=md-resource g=resource =metadata]
|
||||
|= [r=md-resource:store g=resource =metadatum:store]
|
||||
[g r]
|
||||
::
|
||||
++ rebuild-app-indices
|
||||
|= =^associations
|
||||
%- ~(gas ju *(jug app-name [group=resource resource]))
|
||||
|= =associations:store
|
||||
%- ~(gas ju *(jug app-name:store [group=resource resource]))
|
||||
%+ turn ~(tap by associations)
|
||||
|= [r=md-resource g=resource =metadata]
|
||||
|= [r=md-resource:store g=resource =metadatum:store]
|
||||
[app-name.r g resource.r]
|
||||
::
|
||||
++ migrate-app-to-graph-store
|
||||
@ -295,18 +295,18 @@
|
||||
^- associations-1
|
||||
%- malt
|
||||
%+ turn ~(tap by associations)
|
||||
|= [[=group-path md-resource=md-resource-1] m=metadata-1]
|
||||
^- [[^group-path md-resource-1] metadata-1]
|
||||
|= [[=path md-resource=md-resource-1] m=metadata-1]
|
||||
^- [[^path md-resource-1] metadata-1]
|
||||
?. =(app-name.md-resource app)
|
||||
[[group-path md-resource] m]
|
||||
=/ new-app-path=path
|
||||
?. ?=([@ @ ~] app-path.md-resource)
|
||||
app-path.md-resource
|
||||
ship+app-path.md-resource
|
||||
[[group-path [%graph new-app-path]] m(module app)]
|
||||
[[path md-resource] m]
|
||||
=/ new-path=^path
|
||||
?. ?=([@ @ ~] path.md-resource)
|
||||
path.md-resource
|
||||
ship+path.md-resource
|
||||
[[path [%graph new-path]] m(module app)]
|
||||
--
|
||||
++ poke-metadata-update
|
||||
|= upd=metadata-update
|
||||
|= upd=update:store
|
||||
^- (quip card _state)
|
||||
?> (team:title [our src]:bowl)
|
||||
?+ -.upd !!
|
||||
@ -338,7 +338,7 @@
|
||||
[%pass / %agent [our.bowl app] %poke cage]
|
||||
::
|
||||
+$ tree-metadata
|
||||
$: associations=(tree [md-resource [resource metadata]])
|
||||
$: associations=(tree [md-resource:store [resource metadatum:store]])
|
||||
~
|
||||
==
|
||||
::
|
||||
@ -351,13 +351,13 @@
|
||||
--
|
||||
::
|
||||
++ handle-add
|
||||
|= [group=resource =md-resource =metadata]
|
||||
|= [group=resource =md-resource:store =metadatum:store]
|
||||
^- (quip card _state)
|
||||
:- %+ send-diff app-name.md-resource
|
||||
[%add group md-resource metadata]
|
||||
[%add group md-resource metadatum]
|
||||
%= state
|
||||
associations
|
||||
(~(put by associations) md-resource [group metadata])
|
||||
(~(put by associations) md-resource [group metadatum])
|
||||
::
|
||||
app-indices
|
||||
%+ ~(put ju app-indices)
|
||||
@ -372,7 +372,7 @@
|
||||
==
|
||||
::
|
||||
++ handle-remove
|
||||
|= [group=resource =md-resource]
|
||||
|= [group=resource =md-resource:store]
|
||||
^- (quip card _state)
|
||||
:- (send-diff app-name.md-resource [%remove group md-resource])
|
||||
%= state
|
||||
@ -392,8 +392,8 @@
|
||||
==
|
||||
::
|
||||
++ handle-initial-group
|
||||
|= [group=resource =^associations]
|
||||
=/ assocs=(list [=md-resource grp=resource =metadata])
|
||||
|= [group=resource =associations:store]
|
||||
=/ assocs=(list [=md-resource:store grp=resource =metadatum:store])
|
||||
~(tap by associations)
|
||||
=| cards=(list card)
|
||||
|-
|
||||
@ -402,44 +402,44 @@
|
||||
=, assocs
|
||||
?> =(group grp.i)
|
||||
=^ new-cards state
|
||||
(handle-add group [md-resource metadata]:i)
|
||||
(handle-add group [md-resource metadatum]:i)
|
||||
$(cards (weld cards new-cards), assocs t)
|
||||
::
|
||||
++ metadata-for-app
|
||||
|= =app-name
|
||||
|= =app-name:store
|
||||
^+ associations
|
||||
%+ roll ~(tap in (~(gut by app-indices) app-name ~))
|
||||
|= [[group=resource rid=resource] out=^associations]
|
||||
=/ =md-resource
|
||||
|= [[group=resource rid=resource] out=associations:store]
|
||||
=/ =md-resource:store
|
||||
[app-name rid]
|
||||
=/ [resource =metadata]
|
||||
=/ [resource =metadatum:store]
|
||||
(~(got by associations) md-resource)
|
||||
(~(put by out) md-resource [group metadata])
|
||||
(~(put by out) md-resource [group metadatum])
|
||||
::
|
||||
++ metadata-for-group
|
||||
|= group=resource
|
||||
=/ resources=(set md-resource)
|
||||
=/ resources=(set md-resource:store)
|
||||
(~(get ju group-indices) group)
|
||||
%+ roll
|
||||
~(tap in resources)
|
||||
|= [=md-resource out=^associations]
|
||||
=/ [resource =metadata]
|
||||
|= [=md-resource:store out=associations:store]
|
||||
=/ [resource =metadatum:store]
|
||||
(~(got by associations) md-resource)
|
||||
(~(put by out) md-resource [group metadata])
|
||||
(~(put by out) md-resource [group metadatum])
|
||||
::
|
||||
++ send-diff
|
||||
|= [=app-name upd=metadata-update]
|
||||
|= [=app-name:store =update:store]
|
||||
^- (list card)
|
||||
|^
|
||||
%- zing
|
||||
:~ (update-subscribers /all upd)
|
||||
(update-subscribers /updates upd)
|
||||
(update-subscribers [%app-name app-name ~] upd)
|
||||
:~ (update-subscribers /all update)
|
||||
(update-subscribers /updates update)
|
||||
(update-subscribers [%app-name app-name ~] update)
|
||||
==
|
||||
::
|
||||
++ update-subscribers
|
||||
|= [pax=path upd=metadata-update]
|
||||
|= [pax=path =update:store]
|
||||
^- (list card)
|
||||
[%give %fact ~[pax] %metadata-update !>(upd)]~
|
||||
[%give %fact ~[pax] %metadata-update !>(update)]~
|
||||
--
|
||||
--
|
||||
|
167
pkg/arvo/app/settings-store.hoon
Normal file
167
pkg/arvo/app/settings-store.hoon
Normal file
@ -0,0 +1,167 @@
|
||||
/- *settings
|
||||
/+ verb, dbug, default-agent
|
||||
|%
|
||||
+$ card card:agent:gall
|
||||
+$ versioned-state
|
||||
$% state-0
|
||||
==
|
||||
+$ state-0
|
||||
$: %0
|
||||
=settings
|
||||
==
|
||||
--
|
||||
=| state-0
|
||||
=* state -
|
||||
::
|
||||
%- agent:dbug
|
||||
%+ verb |
|
||||
^- agent:gall
|
||||
=<
|
||||
|_ bol=bowl:gall
|
||||
+* this .
|
||||
do ~(. +> bol)
|
||||
def ~(. (default-agent this %|) bol)
|
||||
::
|
||||
++ on-init on-init:def
|
||||
::
|
||||
++ on-save !>(state)
|
||||
::
|
||||
++ on-load
|
||||
|= =old=vase
|
||||
^- (quip card _this)
|
||||
=/ old !<(versioned-state old-vase)
|
||||
?- -.old
|
||||
%0 [~ this(state old)]
|
||||
==
|
||||
::
|
||||
++ on-poke
|
||||
|= [mar=mark vas=vase]
|
||||
^- (quip card _this)
|
||||
?> (team:title our.bol src.bol)
|
||||
?. ?=(%settings-event mar)
|
||||
(on-poke:def mar vas)
|
||||
=/ evt=event !<(event vas)
|
||||
=^ cards state
|
||||
?- -.evt
|
||||
%put-bucket (put-bucket:do key.evt bucket.evt)
|
||||
%del-bucket (del-bucket:do key.evt)
|
||||
%put-entry (put-entry:do buc.evt key.evt val.evt)
|
||||
%del-entry (del-entry:do buc.evt key.evt)
|
||||
==
|
||||
[cards this]
|
||||
::
|
||||
++ on-watch
|
||||
|= pax=path
|
||||
^- (quip card _this)
|
||||
?> (team:title our.bol src.bol)
|
||||
?+ pax (on-watch:def pax)
|
||||
[%all ~]
|
||||
[~ this]
|
||||
::
|
||||
[%bucket @ ~]
|
||||
=* bucket-key i.t.pax
|
||||
?> (~(has by settings) bucket-key)
|
||||
[~ this]
|
||||
::
|
||||
[%entry @ @ ~]
|
||||
=* bucket-key i.t.pax
|
||||
=* entry-key i.t.t.pax
|
||||
=/ bucket (~(got by settings) bucket-key)
|
||||
?> (~(has by bucket) entry-key)
|
||||
[~ this]
|
||||
==
|
||||
::
|
||||
++ on-peek
|
||||
|= pax=path
|
||||
^- (unit (unit cage))
|
||||
?+ pax (on-peek:def pax)
|
||||
[%x %all ~]
|
||||
``settings-data+!>(all+settings)
|
||||
::
|
||||
[%x %bucket @ ~]
|
||||
=* buc i.t.t.pax
|
||||
=/ bucket=(unit bucket) (~(get by settings) buc)
|
||||
?~ bucket [~ ~]
|
||||
``settings-data+!>(bucket+u.bucket)
|
||||
::
|
||||
[%x %entry @ @ ~]
|
||||
=* buc i.t.t.pax
|
||||
=* key i.t.t.t.pax
|
||||
=/ =bucket (fall (~(get by settings) buc) ~)
|
||||
=/ entry=(unit val) (~(get by bucket) key)
|
||||
?~ entry [~ ~]
|
||||
``settings-data+!>(entry+u.entry)
|
||||
==
|
||||
::
|
||||
++ on-agent on-agent:def
|
||||
++ on-leave on-leave:def
|
||||
++ on-arvo on-arvo:def
|
||||
++ on-fail on-fail:def
|
||||
--
|
||||
::
|
||||
|_ bol=bowl:gall
|
||||
::
|
||||
:: +put-bucket: put a bucket in the top level settings map, overwriting if it
|
||||
:: already exists
|
||||
::
|
||||
++ put-bucket
|
||||
|= [=key =bucket]
|
||||
^- (quip card _state)
|
||||
=/ pas=(list path)
|
||||
:~ /all
|
||||
/bucket/[key]
|
||||
==
|
||||
:- [(give-event pas %put-bucket key bucket)]~
|
||||
state(settings (~(put by settings) key bucket))
|
||||
::
|
||||
:: +del-bucket: delete a bucket from the top level settings map
|
||||
::
|
||||
++ del-bucket
|
||||
|= =key
|
||||
^- (quip card _state)
|
||||
=/ pas=(list path)
|
||||
:~ /all
|
||||
/bucket/[key]
|
||||
==
|
||||
:- [(give-event pas %del-bucket key)]~
|
||||
state(settings (~(del by settings) key))
|
||||
::
|
||||
:: +put-entry: put an entry in a bucket, overwriting if it already exists
|
||||
:: if bucket does not yet exist, create it
|
||||
::
|
||||
++ put-entry
|
||||
|= [buc=key =key =val]
|
||||
^- (quip card _state)
|
||||
=/ pas=(list path)
|
||||
:~ /all
|
||||
/bucket/[buc]
|
||||
/entry/[buc]/[key]
|
||||
==
|
||||
=/ =bucket (fall (~(get by settings) buc) ~)
|
||||
=. bucket (~(put by bucket) key val)
|
||||
:- [(give-event pas %put-entry buc key val)]~
|
||||
state(settings (~(put by settings) buc bucket))
|
||||
::
|
||||
:: +del-entry: delete an entry from a bucket, fail quietly if bucket does not
|
||||
:: exist
|
||||
::
|
||||
++ del-entry
|
||||
|= [buc=key =key]
|
||||
^- (quip card _state)
|
||||
=/ pas=(list path)
|
||||
:~ /all
|
||||
/bucket/[buc]
|
||||
/entry/[buc]/[key]
|
||||
==
|
||||
=/ bucket=(unit bucket) (~(get by settings) buc)
|
||||
?~ bucket
|
||||
[~ state]
|
||||
=. u.bucket (~(del by u.bucket) key)
|
||||
:- [(give-event pas %del-entry buc key)]~
|
||||
state(settings (~(put by settings) buc u.bucket))
|
||||
::
|
||||
++ give-event
|
||||
|= [pas=(list path) evt=event]
|
||||
^- card
|
||||
[%give %fact pas %settings-event !>(evt)]
|
||||
--
|
@ -1,16 +1,18 @@
|
||||
/- *group, *metadata-store
|
||||
/- *group
|
||||
/+ store=group-store, resource
|
||||
::
|
||||
|_ =bowl:gall
|
||||
+$ card card:agent:gall
|
||||
++ scry-for
|
||||
|* [=mold =path]
|
||||
=. path
|
||||
(snoc path %noun)
|
||||
.^ mold
|
||||
%gx
|
||||
(scot %p our.bowl)
|
||||
%group-store
|
||||
(scot %da now.bowl)
|
||||
(snoc `^path`path %noun)
|
||||
path
|
||||
==
|
||||
++ scry-tag
|
||||
|= [rid=resource =tag]
|
||||
@ -21,27 +23,16 @@
|
||||
~
|
||||
`(~(gut by tags.u.group) tag ~)
|
||||
::
|
||||
++ scry-group-path
|
||||
|= =path
|
||||
%+ scry-for
|
||||
(unit group)
|
||||
[%groups path]
|
||||
::
|
||||
++ scry-group
|
||||
|= rid=resource
|
||||
%- scry-group-path
|
||||
(en-path:resource rid)
|
||||
%+ scry-for ,(unit group)
|
||||
`path`groups+(en-path:resource rid)
|
||||
::
|
||||
++ members
|
||||
|= rid=resource
|
||||
%- members-from-path
|
||||
(en-path:resource rid)
|
||||
::
|
||||
++ members-from-path
|
||||
|= =group-path
|
||||
^- (set ship)
|
||||
=- members:(fall - *group)
|
||||
(scry-group-path group-path)
|
||||
=; =group
|
||||
members.group
|
||||
(fall (scry-group rid) *group)
|
||||
::
|
||||
++ is-member
|
||||
|= [=ship group=resource]
|
||||
@ -85,19 +76,12 @@
|
||||
[~ ~]
|
||||
~
|
||||
::
|
||||
++ can-join-from-path
|
||||
|= [=path =ship]
|
||||
%+ scry-for
|
||||
?
|
||||
%+ welp
|
||||
[%groups path]
|
||||
/join/[(scot %p ship)]
|
||||
::
|
||||
++ can-join
|
||||
|= [rid=resource =ship]
|
||||
%+ can-join-from-path
|
||||
(en-path:resource rid)
|
||||
ship
|
||||
%+ scry-for ,?
|
||||
^- path
|
||||
:- %groups
|
||||
(weld (en-path:resource rid) /join/(scot %p ship))
|
||||
::
|
||||
++ get-tagged-ships
|
||||
|= [rid=resource =tag]
|
||||
@ -107,17 +91,11 @@
|
||||
?~ grp ~
|
||||
(~(get ju tags.u.grp) tag)
|
||||
::
|
||||
++ is-managed-path
|
||||
|= =path
|
||||
^- ?
|
||||
++ is-managed
|
||||
|= rid=resource
|
||||
=/ group=(unit group)
|
||||
(scry-group-path path)
|
||||
(scry-group rid)
|
||||
?~ group %.n
|
||||
!hidden.u.group
|
||||
::
|
||||
++ is-managed
|
||||
|= rid=resource
|
||||
%- is-managed-path
|
||||
(en-path:resource rid)
|
||||
::
|
||||
--
|
||||
|
163
pkg/arvo/lib/metadata-store.hoon
Normal file
163
pkg/arvo/lib/metadata-store.hoon
Normal file
@ -0,0 +1,163 @@
|
||||
/- sur=metadata-store
|
||||
/+ resource
|
||||
^?
|
||||
=< [. sur]
|
||||
=, sur
|
||||
|%
|
||||
++ enjs
|
||||
=, enjs:format
|
||||
|%
|
||||
++ associations
|
||||
|= =^associations
|
||||
=, enjs:format
|
||||
^- json
|
||||
%- pairs
|
||||
%+ turn ~(tap by associations)
|
||||
|= [=md-resource [group=resource =^metadatum]]
|
||||
^- [cord json]
|
||||
:-
|
||||
%- crip
|
||||
;: weld
|
||||
(trip (spat (en-path:resource group)))
|
||||
(weld "/" (trip app-name.md-resource))
|
||||
(trip (spat (en-path:resource resource.md-resource)))
|
||||
==
|
||||
%- pairs
|
||||
:~ [%group s+(enjs-path:resource group)]
|
||||
[%app-name s+app-name.md-resource]
|
||||
[%resource s+(enjs-path:resource resource.md-resource)]
|
||||
[%metadata (^metadatum metadatum)]
|
||||
==
|
||||
::
|
||||
++ metadatum
|
||||
|= met=^metadatum
|
||||
^- json
|
||||
%- pairs
|
||||
:~ [%title s+title.met]
|
||||
[%description s+description.met]
|
||||
[%color s+(scot %ux color.met)]
|
||||
[%date-created s+(scot %da date-created.met)]
|
||||
[%creator s+(scot %p creator.met)]
|
||||
[%module s+module.met]
|
||||
[%picture s+picture.met]
|
||||
[%preview b+preview.met]
|
||||
[%vip s+`@t`vip.met]
|
||||
==
|
||||
::
|
||||
++ update
|
||||
|= upd=^update
|
||||
^- json
|
||||
%+ frond %metadata-update
|
||||
%- pairs
|
||||
:~ ?+ -.upd *[cord json]
|
||||
%add
|
||||
:- %add
|
||||
%- pairs
|
||||
:~ [%group s+(enjs-path:resource group.upd)]
|
||||
[%app-name s+app-name.resource.upd]
|
||||
[%resource s+(enjs-path:resource resource.resource.upd)]
|
||||
[%metadata (metadatum metadatum.upd)]
|
||||
==
|
||||
%updated-metadata
|
||||
:- %add
|
||||
%- pairs
|
||||
:~ [%group s+(enjs-path:resource group.upd)]
|
||||
[%app-name s+app-name.resource.upd]
|
||||
[%resource s+(enjs-path:resource resource.resource.upd)]
|
||||
[%metadata (metadatum metadatum.upd)]
|
||||
==
|
||||
::
|
||||
%remove
|
||||
:- %remove
|
||||
%- pairs
|
||||
:~ [%group s+(enjs-path:resource group.upd)]
|
||||
[%app-name s+app-name.resource.upd]
|
||||
[%resource s+(enjs-path:resource resource.resource.upd)]
|
||||
==
|
||||
::
|
||||
%associations
|
||||
[%associations (associations associations.upd)]
|
||||
::
|
||||
== ==
|
||||
::
|
||||
++ hook-update
|
||||
|= upd=^hook-update
|
||||
%+ frond %metadata-hook-update
|
||||
%+ frond -.upd
|
||||
%- pairs
|
||||
?- -.upd
|
||||
%preview
|
||||
:~ [%group s+(enjs-path:resource group.upd)]
|
||||
[%channels (associations channels.upd)]
|
||||
[%members (numb members.upd)]
|
||||
[%channel-count (numb channel-count.upd)]
|
||||
[%metadata (metadatum metadatum.upd)]
|
||||
==
|
||||
%req-preview
|
||||
~[group+s+(enjs-path:resource group.upd)]
|
||||
==
|
||||
--
|
||||
::
|
||||
++ dejs
|
||||
=, dejs:format
|
||||
|%
|
||||
++ action
|
||||
%- of
|
||||
:~ [%add add]
|
||||
[%remove remove]
|
||||
[%initial-group initial-group]
|
||||
==
|
||||
::
|
||||
++ initial-group
|
||||
|= json
|
||||
[%initial-group *resource *associations]
|
||||
::
|
||||
++ add
|
||||
%- ot
|
||||
:~ [%group dejs-path:resource]
|
||||
[%resource md-resource]
|
||||
[%metadata metadatum]
|
||||
==
|
||||
++ remove
|
||||
%- ot
|
||||
:~ [%group dejs-path:resource]
|
||||
[%resource md-resource]
|
||||
==
|
||||
::
|
||||
++ nu
|
||||
|= jon=json
|
||||
?> ?=([%s *] jon)
|
||||
(rash p.jon hex)
|
||||
::
|
||||
++ vip
|
||||
%- su
|
||||
;~ pose
|
||||
(tag %$)
|
||||
(tag %reader-comments)
|
||||
(tag %member-metadata)
|
||||
==
|
||||
::
|
||||
++ metadatum
|
||||
^- $-(json ^metadatum)
|
||||
%- ot
|
||||
:~ [%title so]
|
||||
[%description so]
|
||||
[%color nu]
|
||||
[%date-created (se %da)]
|
||||
[%creator (su ;~(pfix sig fed:ag))]
|
||||
[%module so]
|
||||
[%picture so]
|
||||
[%preview bo]
|
||||
[%vip vip]
|
||||
==
|
||||
::
|
||||
++ tag |*(a=@tas (cold a (jest a)))
|
||||
::
|
||||
++ md-resource
|
||||
^- $-(json ^md-resource)
|
||||
%- ot
|
||||
:~ [%app-name so]
|
||||
[%resource dejs-path:resource]
|
||||
==
|
||||
--
|
||||
--
|
@ -1,38 +1,39 @@
|
||||
:: metadata: helpers for getting data from the metadata-store
|
||||
::
|
||||
/- *metadata-store
|
||||
/- store=metadata-store
|
||||
/+ resource
|
||||
::
|
||||
|_ =bowl:gall
|
||||
++ app-paths-from-group
|
||||
|= [=app-name group=resource]
|
||||
|= [=app-name:store group=resource]
|
||||
^- (list resource)
|
||||
%+ murn
|
||||
%~ tap in
|
||||
=- (~(gut by -) group ~)
|
||||
.^ (jug resource md-resource)
|
||||
.^ (jug resource md-resource:store)
|
||||
%gy
|
||||
(scot %p our.bowl)
|
||||
%metadata-store
|
||||
(scot %da now.bowl)
|
||||
/group-indices
|
||||
==
|
||||
|= =md-resource
|
||||
|= =md-resource:store
|
||||
^- (unit resource)
|
||||
?. =(app-name.md-resource app-name) ~
|
||||
`resource.md-resource
|
||||
::
|
||||
++ app-metadata-for-group
|
||||
|= [group=resource =app-name]
|
||||
=/ =associations
|
||||
|= [group=resource =app-name:store]
|
||||
=/ =associations:store
|
||||
(metadata-for-group group)
|
||||
%- ~(gas by *^associations)
|
||||
%- ~(gas by *associations:store)
|
||||
%+ skim ~(tap by associations)
|
||||
|=([=md-resource association] =(app-name app-name.md-resource))
|
||||
|= [=md-resource:store association:store]
|
||||
=(app-name app-name.md-resource)
|
||||
::
|
||||
++ metadata-for-group
|
||||
|= group=resource
|
||||
.^ associations
|
||||
.^ associations:store
|
||||
%gx (scot %p our.bowl) %metadata-store (scot %da now.bowl)
|
||||
%group (snoc (en-path:resource group) %noun)
|
||||
==
|
||||
@ -40,7 +41,7 @@
|
||||
++ md-resources-from-group
|
||||
|= group=resource
|
||||
=- (~(get ju -) group)
|
||||
.^ (jug resource md-resource)
|
||||
.^ (jug resource md-resource:store)
|
||||
%gy
|
||||
(scot %p our.bowl)
|
||||
%metadata-store
|
||||
@ -50,19 +51,19 @@
|
||||
::
|
||||
++ peek-association
|
||||
|= [app-name=term rid=resource]
|
||||
.^ (unit association)
|
||||
.^ (unit association:store)
|
||||
%gx (scot %p our.bowl) %metadata-store (scot %da now.bowl)
|
||||
%metadata app-name (snoc (en-path:resource rid) %noun)
|
||||
==
|
||||
::
|
||||
++ peek-metadata
|
||||
|= =md-resource
|
||||
++ peek-metadatum
|
||||
|= =md-resource:store
|
||||
%+ bind (peek-association md-resource)
|
||||
|=(association metadata)
|
||||
|=(association:store metadatum)
|
||||
::
|
||||
++ peek-group
|
||||
|= =md-resource
|
||||
|= =md-resource:store
|
||||
^- (unit resource)
|
||||
%+ bind (peek-association md-resource)
|
||||
|=(association group)
|
||||
|=(association:store group)
|
||||
--
|
||||
|
132
pkg/arvo/lib/settings.hoon
Normal file
132
pkg/arvo/lib/settings.hoon
Normal file
@ -0,0 +1,132 @@
|
||||
/- *settings
|
||||
|%
|
||||
++ enjs
|
||||
=, enjs:format
|
||||
|%
|
||||
++ data
|
||||
|= dat=^data
|
||||
^- json
|
||||
%+ frond -.dat
|
||||
?- -.dat
|
||||
%all (settings +.dat)
|
||||
%bucket (bucket +.dat)
|
||||
%entry (value +.dat)
|
||||
==
|
||||
::
|
||||
++ settings
|
||||
|= s=^settings
|
||||
^- json
|
||||
[%o (~(run by s) bucket)]
|
||||
::
|
||||
++ event
|
||||
|= evt=^event
|
||||
^- json
|
||||
%+ frond -.evt
|
||||
?- -.evt
|
||||
%put-bucket (put-bucket +.evt)
|
||||
%del-bucket (del-bucket +.evt)
|
||||
%put-entry (put-entry +.evt)
|
||||
%del-entry (del-entry +.evt)
|
||||
==
|
||||
::
|
||||
++ put-bucket
|
||||
|= [k=key b=^bucket]
|
||||
^- json
|
||||
%- pairs
|
||||
:~ bucket-key+s+k
|
||||
bucket+(bucket b)
|
||||
==
|
||||
::
|
||||
++ del-bucket
|
||||
|= k=key
|
||||
^- json
|
||||
%- pairs
|
||||
:~ bucket-key+s+k
|
||||
==
|
||||
::
|
||||
++ put-entry
|
||||
|= [b=key k=key v=val]
|
||||
^- json
|
||||
%- pairs
|
||||
:~ bucket-key+s+b
|
||||
entry-key+s+k
|
||||
value+(val v)
|
||||
==
|
||||
::
|
||||
++ del-entry
|
||||
|= [buc=key =key]
|
||||
^- json
|
||||
%- pairs
|
||||
:~ bucket-key+s+buc
|
||||
entry-key+s+key
|
||||
==
|
||||
::
|
||||
++ value
|
||||
|= =val
|
||||
^- json
|
||||
?- -.val
|
||||
%s val
|
||||
%b val
|
||||
%n (numb p.val)
|
||||
==
|
||||
::
|
||||
++ bucket
|
||||
|= b=^bucket
|
||||
^- json
|
||||
[%o (~(run by b) value)]
|
||||
--
|
||||
::
|
||||
++ dejs
|
||||
=, dejs:format
|
||||
|%
|
||||
++ event
|
||||
|= jon=json
|
||||
^- ^event
|
||||
%. jon
|
||||
%- of
|
||||
:~ put-bucket+put-bucket
|
||||
del-bucket+del-bucket
|
||||
put-entry+put-entry
|
||||
del-entry+del-entry
|
||||
==
|
||||
::
|
||||
++ put-bucket
|
||||
%- ot
|
||||
:~ bucket-key+so
|
||||
bucket+bucket
|
||||
==
|
||||
::
|
||||
++ del-bucket
|
||||
%- ot
|
||||
:~ bucket-key+so
|
||||
==
|
||||
::
|
||||
++ put-entry
|
||||
%- ot
|
||||
:~ bucket-key+so
|
||||
entry-key+so
|
||||
value+val
|
||||
==
|
||||
::
|
||||
++ del-entry
|
||||
%- ot
|
||||
:~ bucket-key+so
|
||||
entry-key+so
|
||||
==
|
||||
::
|
||||
++ value
|
||||
|= jon=json
|
||||
^- val
|
||||
?+ -.jon !!
|
||||
%s jon
|
||||
%b jon
|
||||
%n [%n (rash p.jon dem)]
|
||||
==
|
||||
::
|
||||
++ bucket
|
||||
|= jon=json
|
||||
^- ^bucket
|
||||
?> ?=([%o *] jon)
|
||||
(~(run by p.jon) value)
|
||||
--
|
||||
--
|
@ -1,17 +1,14 @@
|
||||
/- *metadata-store
|
||||
/+ *metadata-json
|
||||
=, dejs:format
|
||||
|_ act=metadata-action
|
||||
/+ store=metadata-store
|
||||
|_ =action:store
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun act
|
||||
++ noun action
|
||||
++ json update:enjs:store
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun metadata-action
|
||||
++ json
|
||||
|= jon=^json
|
||||
(json-to-action jon)
|
||||
++ noun action:store
|
||||
++ json action:dejs:store
|
||||
--
|
||||
--
|
||||
|
@ -1,16 +1,15 @@
|
||||
/- *metadata-store
|
||||
/+ *metadata-json
|
||||
|_ upd=metadata-hook-update
|
||||
/+ store=metadata-store
|
||||
|_ =hook-update:store
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun upd
|
||||
++ json (hook-update-to-json upd)
|
||||
++ noun hook-update
|
||||
++ json (hook-update:enjs:store hook-update)
|
||||
--
|
||||
::
|
||||
++ grab
|
||||
|%
|
||||
++ noun metadata-hook-update
|
||||
++ noun hook-update:store
|
||||
--
|
||||
--
|
||||
|
||||
|
@ -1,20 +1,18 @@
|
||||
/- *metadata-store
|
||||
/+ *metadata-json
|
||||
|_ upd=metadata-update
|
||||
/+ store=metadata-store
|
||||
|_ =update:store
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun upd
|
||||
++ noun update
|
||||
++ resource
|
||||
?> ?=(?(%add %remove %initial-group %updated-metadata) -.upd)
|
||||
group.upd
|
||||
++ json (update-to-json upd)
|
||||
?> ?=(?(%add %remove %initial-group) -.update)
|
||||
group.update
|
||||
++ json (update:enjs:store update)
|
||||
--
|
||||
::
|
||||
++ grab
|
||||
|%
|
||||
++ noun metadata-update
|
||||
++ json json-to-action
|
||||
++ noun update:store
|
||||
++ json action:dejs:store
|
||||
--
|
||||
::
|
||||
--
|
||||
|
13
pkg/arvo/mar/settings/data.hoon
Normal file
13
pkg/arvo/mar/settings/data.hoon
Normal file
@ -0,0 +1,13 @@
|
||||
/+ *settings
|
||||
|_ dat=data
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun dat
|
||||
++ json (data:enjs dat)
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun data
|
||||
--
|
||||
--
|
16
pkg/arvo/mar/settings/event.hoon
Normal file
16
pkg/arvo/mar/settings/event.hoon
Normal file
@ -0,0 +1,16 @@
|
||||
/+ *settings
|
||||
|_ evt=event
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun evt
|
||||
++ json
|
||||
%+ frond:enjs:format %settings-event
|
||||
(event:enjs evt)
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun event
|
||||
++ json event:dejs
|
||||
--
|
||||
--
|
@ -2,18 +2,16 @@
|
||||
^?
|
||||
|%
|
||||
::
|
||||
+$ group-path path
|
||||
+$ app-name term
|
||||
+$ app-path path
|
||||
+$ md-resource [=app-name =resource]
|
||||
+$ association [group=resource =metadata]
|
||||
+$ association [group=resource =metadatum]
|
||||
+$ associations (map md-resource association)
|
||||
+$ group-preview
|
||||
$: group=resource
|
||||
channels=associations
|
||||
members=@ud
|
||||
channel-count=@ud
|
||||
=metadata
|
||||
=metadatum
|
||||
==
|
||||
::
|
||||
+$ color @ux
|
||||
@ -30,7 +28,7 @@
|
||||
:: %$: No variation
|
||||
::
|
||||
+$ vip-metadata ?(%reader-comments %member-metadata %$)
|
||||
+$ metadata
|
||||
+$ metadatum
|
||||
$: title=cord
|
||||
description=cord
|
||||
=color
|
||||
@ -42,20 +40,25 @@
|
||||
vip=vip-metadata
|
||||
==
|
||||
::
|
||||
+$ metadata-action
|
||||
$% [%add group=resource resource=md-resource =metadata]
|
||||
+$ action
|
||||
$% [%add group=resource resource=md-resource =metadatum]
|
||||
[%remove group=resource resource=md-resource]
|
||||
[%initial-group group=resource =associations]
|
||||
==
|
||||
::
|
||||
+$ metadata-hook-update
|
||||
+$ hook-update
|
||||
$% [%req-preview group=resource]
|
||||
[%preview group-preview]
|
||||
==
|
||||
::
|
||||
+$ metadata-update
|
||||
$% metadata-action
|
||||
+$ update
|
||||
$% action
|
||||
[%associations =associations]
|
||||
[%updated-metadata group=resource resource=md-resource before=metadata =metadata]
|
||||
$: %updated-metadata
|
||||
group=resource
|
||||
resource=md-resource
|
||||
before=metadatum
|
||||
=metadatum
|
||||
==
|
||||
==
|
||||
--
|
||||
|
21
pkg/arvo/sur/settings.hoon
Normal file
21
pkg/arvo/sur/settings.hoon
Normal file
@ -0,0 +1,21 @@
|
||||
|%
|
||||
+$ settings (map key bucket)
|
||||
+$ bucket (map key val)
|
||||
+$ key term
|
||||
+$ val
|
||||
$% [%s p=@t]
|
||||
[%b p=?]
|
||||
[%n p=@]
|
||||
==
|
||||
+$ event
|
||||
$% [%put-bucket =key =bucket]
|
||||
[%del-bucket =key]
|
||||
[%put-entry buc=key =key =val]
|
||||
[%del-entry buc=key =key]
|
||||
==
|
||||
+$ data
|
||||
$% [%all =settings]
|
||||
[%bucket =bucket]
|
||||
[%entry =val]
|
||||
==
|
||||
--
|
@ -11,6 +11,7 @@ import LaunchApi from './launch';
|
||||
import GraphApi from './graph';
|
||||
import S3Api from './s3';
|
||||
import {HarkApi} from './hark';
|
||||
import SettingsApi from './settings';
|
||||
|
||||
export default class GlobalApi extends BaseApi<StoreState> {
|
||||
local = new LocalApi(this.ship, this.channel, this.store);
|
||||
@ -22,6 +23,7 @@ export default class GlobalApi extends BaseApi<StoreState> {
|
||||
s3 = new S3Api(this.ship, this.channel, this.store);
|
||||
graph = new GraphApi(this.ship, this.channel, this.store);
|
||||
hark = new HarkApi(this.ship, this.channel, this.store);
|
||||
settings = new SettingsApi(this.ship, this.channel, this.store);
|
||||
|
||||
constructor(
|
||||
public ship: Patp,
|
||||
|
74
pkg/interface/src/logic/api/settings.ts
Normal file
74
pkg/interface/src/logic/api/settings.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import BaseApi from './base';
|
||||
import { StoreState } from '../store/type';
|
||||
import {
|
||||
SettingsUpdate,
|
||||
SettingsData,
|
||||
Key,
|
||||
Value,
|
||||
Bucket,
|
||||
} from '~/types/settings';
|
||||
|
||||
|
||||
export default class SettingsApi extends BaseApi<StoreState> {
|
||||
private storeAction(action: SettingsEvent): Promise<any> {
|
||||
return this.action('settings-store', 'settings-event', action);
|
||||
}
|
||||
|
||||
putBucket(key: Key, bucket: Bucket) {
|
||||
this.storeAction({
|
||||
"put-bucket": {
|
||||
"bucket-key": key,
|
||||
"bucket": bucket,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
delBucket(key: Key) {
|
||||
this.storeAction({
|
||||
"del-bucket": {
|
||||
"bucket-key": key,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
putEntry(buc: Key, key: Key, val: Value) {
|
||||
this.storeAction({
|
||||
"put-entry": {
|
||||
"bucket-key": buc,
|
||||
"entry-key": key,
|
||||
"value": val,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
delEntry(buc: Key, key: Key) {
|
||||
this.storeAction({
|
||||
"put-entry": {
|
||||
"bucket-key": buc,
|
||||
"entry-key": key,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async getAll() {
|
||||
const data = await this.scry("settings-store", "/all");
|
||||
this.store.handleEvent({data: {"settings-data": data.all}});
|
||||
}
|
||||
|
||||
async getBucket(bucket: Key) {
|
||||
const data = await this.scry('settings-store', `/bucket/${bucket}`);
|
||||
this.store.handleEvent({data: {"settings-data": {
|
||||
"bucket-key": bucket,
|
||||
"bucket": data.bucket,
|
||||
}}});
|
||||
}
|
||||
|
||||
async getEntry(bucket: Key, entry: Key) {
|
||||
const data = await this.scry('settings-store', `/entry/${bucket}/${entry}`);
|
||||
this.store.handleEvent({data: {"settings-data": {
|
||||
"bucket-key": bucket,
|
||||
"entry-key": entry,
|
||||
"entry": data.entry,
|
||||
}}});
|
||||
}
|
||||
}
|
77
pkg/interface/src/logic/reducers/settings-update.ts
Normal file
77
pkg/interface/src/logic/reducers/settings-update.ts
Normal file
@ -0,0 +1,77 @@
|
||||
import _ from 'lodash';
|
||||
import { StoreState } from '../../store/type';
|
||||
import {
|
||||
SettingsUpdate,
|
||||
} from '~/types/settings';
|
||||
|
||||
type SettingsState = Pick<StoreState, 'settings'>;
|
||||
|
||||
export default class SettingsReducer<S extends SettingsState>{
|
||||
reduce(json: Cage, state: S) {
|
||||
let data = json["settings-event"];
|
||||
if (data) {
|
||||
this.putBucket(data, state);
|
||||
this.delBucket(data, state);
|
||||
this.putEntry(data, state);
|
||||
this.delEntry(data, state);
|
||||
}
|
||||
data = json["settings-data"];
|
||||
if (data) {
|
||||
this.getAll(data, state);
|
||||
this.getBucket(data, state);
|
||||
this.getEntry(data, state);
|
||||
}
|
||||
}
|
||||
|
||||
putBucket(json: SettingsUpdate, state: S) {
|
||||
const data = _.get(json, 'put-bucket', false);
|
||||
if (data) {
|
||||
state.settings[data["bucket-key"]] = data.bucket;
|
||||
}
|
||||
}
|
||||
|
||||
delBucket(json: SettingsUpdate, state: S) {
|
||||
const data = _.get(json, 'del-bucket', false);
|
||||
if (data) {
|
||||
delete state.settings[data["bucket-key"]];
|
||||
}
|
||||
}
|
||||
|
||||
putEntry(json: SettingsUpdate, state: S) {
|
||||
const data = _.get(json, 'put-entry', false);
|
||||
if (data) {
|
||||
if (!state.settings[data["bucket-key"]]) {
|
||||
state.settings[data["bucket-key"]] = {};
|
||||
}
|
||||
state.settings[data["bucket-key"]][data["entry-key"]] = data.value;
|
||||
}
|
||||
}
|
||||
|
||||
delEntry(json: SettingsUpdate, state: S) {
|
||||
const data = _.get(json, 'del-entry', false);
|
||||
if (data) {
|
||||
delete state.settings[data["bucket-key"]][data["entry-key"]];
|
||||
}
|
||||
}
|
||||
|
||||
getAll(json: any, state: S) {
|
||||
state.settings = json;
|
||||
}
|
||||
|
||||
getBucket(json: any, state: S) {
|
||||
const key = _.get(json, 'bucket-key', false);
|
||||
const bucket = _.get(json, 'bucket', false);
|
||||
if (key && bucket) {
|
||||
state.settings[key] = bucket;
|
||||
}
|
||||
}
|
||||
|
||||
getEntry(json: any, state: S) {
|
||||
const bucketKey = _.get(json, 'bucket-key', false);
|
||||
const entryKey = _.get(json, 'entry-key', false);
|
||||
const entry = _.get(json, 'entry', false);
|
||||
if (bucketKey && entryKey && entry) {
|
||||
state.settings[bucketKey][entryKey] = entry;
|
||||
}
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import { HarkReducer } from '../reducers/hark-update';
|
||||
import GroupReducer from '../reducers/group-update';
|
||||
import LaunchReducer from '../reducers/launch-update';
|
||||
import ConnectionReducer from '../reducers/connection';
|
||||
import SettingsReducer from '../reducers/settings-update';
|
||||
import {OrderedMap} from '../lib/OrderedMap';
|
||||
import { BigIntOrderedMap } from '../lib/BigIntOrderedMap';
|
||||
|
||||
@ -26,6 +27,7 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
||||
groupReducer = new GroupReducer();
|
||||
launchReducer = new LaunchReducer();
|
||||
connReducer = new ConnectionReducer();
|
||||
settingsReducer = new SettingsReducer();
|
||||
|
||||
rehydrate() {
|
||||
this.localReducer.rehydrate(this.state);
|
||||
@ -76,7 +78,8 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
||||
graph: {},
|
||||
group: {}
|
||||
},
|
||||
notificationsCount: 0
|
||||
notificationsCount: 0,
|
||||
settings: {}
|
||||
};
|
||||
}
|
||||
|
||||
@ -91,5 +94,6 @@ export default class GlobalStore extends BaseStore<StoreState> {
|
||||
this.connReducer.reduce(data, this.state);
|
||||
GraphReducer(data, this.state);
|
||||
HarkReducer(data, this.state);
|
||||
this.settingsReducer.reduce(data, this.state);
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ export default class GlobalSubscription extends BaseSubscription<StoreState> {
|
||||
this.subscribe('/updates', 'hark-store');
|
||||
this.subscribe('/updates', 'hark-graph-hook');
|
||||
this.subscribe('/updates', 'hark-group-hook');
|
||||
this.subscribe('/all', 'settings-store');
|
||||
}
|
||||
|
||||
restart() {
|
||||
|
@ -5,6 +5,7 @@ import { MetadataUpdate } from "./metadata-update";
|
||||
import { GroupUpdate } from "./group-update";
|
||||
import { LaunchUpdate, WeatherState } from "./launch-update";
|
||||
import { ConnectionStatus } from "./connection";
|
||||
import { SettingsUpdate } from "./settings";
|
||||
|
||||
interface MarksToTypes {
|
||||
readonly json: any;
|
||||
@ -14,6 +15,7 @@ interface MarksToTypes {
|
||||
readonly groupUpdate: GroupUpdate;
|
||||
readonly "launch-update": LaunchUpdate;
|
||||
readonly "link-listen-update": LinkListenUpdate;
|
||||
readonly "settings-event": SettingsUpdate;
|
||||
// not really marks but w/e
|
||||
readonly 'local': LocalUpdate;
|
||||
readonly 'weather': WeatherState | {};
|
||||
|
55
pkg/interface/src/types/settings.ts
Normal file
55
pkg/interface/src/types/settings.ts
Normal file
@ -0,0 +1,55 @@
|
||||
export type Key = string;
|
||||
export type Value = string | boolean | number;
|
||||
export type Bucket = Map<string, Value>;
|
||||
export type Settings = Map<string, Bucket>;
|
||||
|
||||
interface PutBucket {
|
||||
"put-bucket": {
|
||||
"bucket-key": Key;
|
||||
"bucket": Bucket;
|
||||
};
|
||||
}
|
||||
|
||||
interface DelBucket {
|
||||
"del-bucket": {
|
||||
"bucket-key": Key;
|
||||
};
|
||||
}
|
||||
|
||||
interface PutEntry {
|
||||
"put-entry": {
|
||||
"bucket-key": Key;
|
||||
"entry-key": Key;
|
||||
"value": Value;
|
||||
};
|
||||
}
|
||||
|
||||
interface DelEntry {
|
||||
"del-entry": {
|
||||
"bucket-key": Key;
|
||||
"entry-key": Key;
|
||||
};
|
||||
}
|
||||
|
||||
interface AllData {
|
||||
"all": Settings;
|
||||
}
|
||||
|
||||
interface BucketData {
|
||||
"bucket": Bucket;
|
||||
}
|
||||
|
||||
interface EntryData {
|
||||
"entry": Value;
|
||||
}
|
||||
|
||||
export type SettingsUpdate =
|
||||
| PutBucket
|
||||
| DelBucket
|
||||
| PutEntry
|
||||
| DelEntry;
|
||||
|
||||
export type SettingsData =
|
||||
| AllData
|
||||
| BucketData
|
||||
| EntryData;
|
@ -94,6 +94,7 @@ class App extends React.Component {
|
||||
this.updateTheme(this.themeWatcher);
|
||||
}, 500);
|
||||
this.api.local.getBaseHash();
|
||||
this.api.settings.getAll();
|
||||
this.store.rehydrate();
|
||||
Mousetrap.bindGlobal(['command+/', 'ctrl+/'], (e) => {
|
||||
e.preventDefault();
|
||||
|
Loading…
Reference in New Issue
Block a user