2020-09-01 04:54:39 +03:00
|
|
|
:: metadata-store [landscape]:
|
|
|
|
::
|
|
|
|
:: data store for application metadata and mappings
|
2020-02-15 01:59:22 +03:00
|
|
|
:: between groups and resources within applications
|
|
|
|
::
|
|
|
|
:: group-paths are expected to be an existing group path
|
|
|
|
:: resources are expected to correspond to existing app paths
|
|
|
|
::
|
2020-02-15 03:37:49 +03:00
|
|
|
:: note: when scrying for metadata, to make the arguments safe in paths,
|
|
|
|
:: encode group-path and app-path using (scot %t (spat group-path))
|
|
|
|
::
|
2020-02-15 01:59:22 +03:00
|
|
|
:: +watch paths:
|
|
|
|
:: /all assocations + updates
|
|
|
|
:: /updates just updates
|
|
|
|
:: /app-name/%app-name specific app's associations + updates
|
|
|
|
::
|
|
|
|
:: +peek paths:
|
2020-02-15 03:37:49 +03:00
|
|
|
:: /associations all associations
|
|
|
|
:: /group-indices all group indices
|
|
|
|
:: /app-indices all app indices
|
|
|
|
:: /resource-indices all resource indices
|
|
|
|
:: /metadata/%group-path/%app-name/%app-path specific metadatum
|
|
|
|
:: /app-name/%app-name associations for app
|
2020-02-21 01:55:46 +03:00
|
|
|
:: /group/%group-path associations for group
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-07-23 08:02:54 +03:00
|
|
|
/- *metadata-store, *metadata-hook
|
|
|
|
/+ *metadata-json, default-agent, verb, dbug, resource
|
2020-02-13 03:45:01 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
::
|
|
|
|
::
|
2020-06-24 03:28:57 +03:00
|
|
|
+$ state-base
|
|
|
|
$: =associations
|
2020-06-08 10:53:16 +03:00
|
|
|
group-indices=(jug group-path md-resource)
|
2020-02-15 01:59:22 +03:00
|
|
|
app-indices=(jug app-name [group-path app-path])
|
2020-06-08 10:53:16 +03:00
|
|
|
resource-indices=(jug md-resource group-path)
|
2020-02-13 03:45:01 +03:00
|
|
|
==
|
2020-06-24 03:28:57 +03:00
|
|
|
::
|
|
|
|
+$ state-zero
|
|
|
|
$: %0
|
|
|
|
state-base
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state-one
|
|
|
|
$: %1
|
|
|
|
state-base
|
|
|
|
==
|
|
|
|
::
|
2020-07-23 08:02:54 +03:00
|
|
|
+$ state-two
|
|
|
|
$: %2
|
|
|
|
state-base
|
|
|
|
==
|
|
|
|
::
|
2020-06-24 03:28:57 +03:00
|
|
|
+$ versioned-state
|
|
|
|
$% state-zero
|
|
|
|
state-one
|
2020-07-23 08:02:54 +03:00
|
|
|
state-two
|
2020-06-24 03:28:57 +03:00
|
|
|
==
|
2020-02-13 03:45:01 +03:00
|
|
|
--
|
|
|
|
::
|
2020-07-23 08:02:54 +03:00
|
|
|
=| state-two
|
2020-02-13 03:45:01 +03:00
|
|
|
=* state -
|
2020-02-26 00:23:07 +03:00
|
|
|
%+ verb |
|
2020-02-21 00:27:09 +03:00
|
|
|
%- agent:dbug
|
2020-02-13 03:45:01 +03:00
|
|
|
^- agent:gall
|
|
|
|
=<
|
|
|
|
|_ =bowl:gall
|
2020-02-13 03:50:24 +03:00
|
|
|
+* this .
|
2020-02-13 03:45:01 +03:00
|
|
|
metadata-core +>
|
2020-02-13 03:50:24 +03:00
|
|
|
mc ~(. metadata-core bowl)
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-02-14 04:22:52 +03:00
|
|
|
++ on-init on-init:def
|
|
|
|
++ on-save !>(state)
|
2020-02-13 03:45:01 +03:00
|
|
|
++ on-load
|
2020-06-24 03:28:57 +03:00
|
|
|
|= =vase
|
|
|
|
^- (quip card _this)
|
|
|
|
=/ old
|
|
|
|
!<(versioned-state vase)
|
2020-07-23 08:02:54 +03:00
|
|
|
=| cards=(list card)
|
|
|
|
|-
|
2020-06-24 03:28:57 +03:00
|
|
|
|^
|
2020-07-23 08:02:54 +03:00
|
|
|
?: ?=(%2 -.old)
|
|
|
|
[cards this(state old)]
|
|
|
|
?: ?=(%1 -.old)
|
|
|
|
%_ $
|
|
|
|
old [%2 +.old]
|
|
|
|
::
|
|
|
|
cards
|
2020-07-24 04:43:19 +03:00
|
|
|
%+ murn
|
2020-07-23 08:02:54 +03:00
|
|
|
~(tap in ~(key by group-indices.old))
|
|
|
|
|= =group-path
|
2020-07-24 04:43:19 +03:00
|
|
|
^- (unit card)
|
|
|
|
=/ rid=(unit resource)
|
|
|
|
(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)
|
2020-07-23 08:02:54 +03:00
|
|
|
==
|
2020-06-24 03:28:57 +03:00
|
|
|
=/ new-state=state-one
|
|
|
|
%* . *state-one
|
|
|
|
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)
|
|
|
|
==
|
2020-07-23 08:02:54 +03:00
|
|
|
$(old new-state)
|
|
|
|
::
|
|
|
|
++ poke-md-hook
|
|
|
|
|= act=metadata-hook-action
|
|
|
|
^- card
|
|
|
|
=/ =cage
|
|
|
|
:_ !>(act)
|
|
|
|
%metadata-hook-action
|
|
|
|
[%pass / %agent [our.bowl %metadata-hook] %poke cage]
|
2020-06-24 03:28:57 +03:00
|
|
|
::
|
|
|
|
++ 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
|
|
|
|
::
|
|
|
|
++ migrate-md-resource
|
|
|
|
|= md-resource
|
|
|
|
^- md-resource
|
2020-07-21 04:08:58 +03:00
|
|
|
?: =(%chat app-name)
|
|
|
|
[%chat (new-app-path app-path)]
|
|
|
|
?: =(%contacts app-name)
|
|
|
|
[%contacts ship+app-path]
|
|
|
|
[app-name app-path]
|
2020-06-24 03:28:57 +03:00
|
|
|
::
|
|
|
|
++ 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)]
|
|
|
|
:_ (~(run in paths) new-group-path)
|
|
|
|
(migrate-md-resource md-resource)
|
|
|
|
::
|
|
|
|
++ 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)
|
2020-07-21 04:08:58 +03:00
|
|
|
?: =(%chat app)
|
|
|
|
(new-app-path app-path)
|
|
|
|
?: =(%contacts app)
|
|
|
|
ship+app-path
|
|
|
|
app-path
|
2020-06-24 03:28:57 +03:00
|
|
|
::
|
|
|
|
++ 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
|
|
|
|
%- malt
|
|
|
|
%+ turn
|
|
|
|
~(tap by associations)
|
|
|
|
|= [[=group-path =md-resource] =metadata]
|
|
|
|
:_ metadata
|
|
|
|
:_ (migrate-md-resource md-resource)
|
|
|
|
(new-group-path group-path)
|
|
|
|
--
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
=^ cards state
|
2020-06-29 06:12:46 +03:00
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%metadata-action
|
2020-02-13 03:45:01 +03:00
|
|
|
(poke-metadata-action:mc !<(metadata-action vase))
|
2020-06-29 06:12:46 +03:00
|
|
|
%noun
|
|
|
|
=/ val=(each [%cleanup path] tang)
|
|
|
|
(mule |.(!<([%cleanup path] vase)))
|
|
|
|
?. ?=(%& -.val)
|
|
|
|
(on-poke:def mark vase)
|
|
|
|
=/ group=path +.p.val
|
2020-07-02 06:08:47 +03:00
|
|
|
=/ res=(set md-resource) (~(get ju group-indices) group)
|
2020-06-29 06:12:46 +03:00
|
|
|
=. group-indices (~(del by group-indices) group)
|
|
|
|
:- ~
|
|
|
|
%+ roll ~(tap in res)
|
2020-07-02 06:08:47 +03:00
|
|
|
|= [r=md-resource out=_state]
|
2020-06-29 06:12:46 +03:00
|
|
|
=. resource-indices.out (~(del by resource-indices.out) r)
|
|
|
|
=. app-indices.out
|
|
|
|
%- ~(del ju app-indices.out)
|
|
|
|
[app-name.r group app-path.r]
|
|
|
|
=. associations.out (~(del by associations.out) group r)
|
|
|
|
out
|
|
|
|
==
|
2020-02-13 03:45:01 +03:00
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
|^
|
|
|
|
=/ cards=(list card)
|
|
|
|
?+ path (on-watch:def path)
|
2020-02-27 06:43:40 +03:00
|
|
|
[%all ~] (give %metadata-update !>([%associations associations]))
|
2020-02-13 03:50:24 +03:00
|
|
|
[%updates ~] ~
|
2020-02-14 04:22:52 +03:00
|
|
|
[%app-name @ ~]
|
|
|
|
=/ =app-name i.t.path
|
|
|
|
=/ app-indices (metadata-for-app:mc app-name)
|
2020-02-15 01:59:22 +03:00
|
|
|
(give %metadata-update !>([%associations app-indices]))
|
2020-02-13 03:45:01 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ give
|
|
|
|
|= =cage
|
|
|
|
^- (list card)
|
|
|
|
[%give %fact ~ cage]~
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
::
|
|
|
|
++ on-peek
|
|
|
|
|= =path
|
|
|
|
^- (unit (unit cage))
|
|
|
|
?+ path (on-peek:def path)
|
2020-02-15 01:59:22 +03:00
|
|
|
[%y %group-indices ~] ``noun+!>(group-indices)
|
|
|
|
[%y %app-indices ~] ``noun+!>(app-indices)
|
|
|
|
[%y %resource-indices ~] ``noun+!>(resource-indices)
|
2020-02-15 03:37:49 +03:00
|
|
|
[%x %associations ~] ``noun+!>(associations)
|
2020-02-14 04:22:52 +03:00
|
|
|
[%x %app-name @ ~]
|
|
|
|
=/ =app-name i.t.t.path
|
|
|
|
``noun+!>((metadata-for-app:mc app-name))
|
2020-02-21 01:55:46 +03:00
|
|
|
::
|
|
|
|
[%x %group *]
|
|
|
|
=/ =group-path t.t.path
|
|
|
|
``noun+!>((metadata-for-group:mc group-path))
|
2020-02-15 03:37:49 +03:00
|
|
|
::
|
|
|
|
[%x %metadata @ @ @ ~]
|
|
|
|
=/ =group-path (stab (slav %t i.t.t.path))
|
2020-06-08 10:53:16 +03:00
|
|
|
=/ =md-resource [`@tas`i.t.t.t.path (stab (slav %t i.t.t.t.t.path))]
|
|
|
|
``noun+!>((~(get by associations) [group-path md-resource]))
|
2020-07-28 03:41:30 +03:00
|
|
|
::
|
|
|
|
[%x %resource @ *]
|
|
|
|
=/ app=@tas i.t.t.path
|
|
|
|
=/ app-path=^path t.t.t.path
|
|
|
|
``noun+!>((~(get by resource-indices) app app-path))
|
2020-02-13 03:45:01 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-agent on-agent:def
|
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
::
|
2020-02-14 04:22:52 +03:00
|
|
|
|_ =bowl:gall
|
2020-02-13 03:45:01 +03:00
|
|
|
++ poke-metadata-action
|
|
|
|
|= act=metadata-action
|
|
|
|
^- (quip card _state)
|
2020-02-14 04:22:52 +03:00
|
|
|
?> (team:title our.bowl src.bowl)
|
2020-02-13 03:45:01 +03:00
|
|
|
?- -.act
|
|
|
|
%add
|
2020-02-15 01:59:22 +03:00
|
|
|
(handle-add group-path.act resource.act metadata.act)
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
|
|
|
%remove
|
2020-02-15 01:59:22 +03:00
|
|
|
(handle-remove group-path.act resource.act)
|
2020-02-13 03:45:01 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-add
|
2020-06-08 10:53:16 +03:00
|
|
|
|= [=group-path =md-resource =metadata]
|
2020-02-13 03:45:01 +03:00
|
|
|
^- (quip card _state)
|
2020-06-08 10:53:16 +03:00
|
|
|
:- %+ send-diff app-name.md-resource
|
|
|
|
?. (~(has by resource-indices) md-resource)
|
|
|
|
[%add group-path md-resource metadata]
|
|
|
|
[%update-metadata group-path md-resource metadata]
|
2020-02-13 03:45:01 +03:00
|
|
|
%= state
|
2020-02-15 01:59:22 +03:00
|
|
|
associations
|
2020-06-08 10:53:16 +03:00
|
|
|
(~(put by associations) [group-path md-resource] metadata)
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
|
|
|
group-indices
|
2020-06-08 10:53:16 +03:00
|
|
|
(~(put ju group-indices) group-path md-resource)
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-02-15 01:59:22 +03:00
|
|
|
app-indices
|
2020-06-08 10:53:16 +03:00
|
|
|
(~(put ju app-indices) app-name.md-resource [group-path app-path.md-resource])
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-02-15 01:59:22 +03:00
|
|
|
resource-indices
|
2020-06-08 10:53:16 +03:00
|
|
|
(~(put ju resource-indices) md-resource group-path)
|
2020-02-13 03:45:01 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-remove
|
2020-06-08 10:53:16 +03:00
|
|
|
|= [=group-path =md-resource]
|
2020-02-13 03:45:01 +03:00
|
|
|
^- (quip card _state)
|
2020-06-08 10:53:16 +03:00
|
|
|
:- (send-diff app-name.md-resource [%remove group-path md-resource])
|
2020-02-13 03:45:01 +03:00
|
|
|
%= state
|
2020-02-15 01:59:22 +03:00
|
|
|
associations
|
2020-06-08 10:53:16 +03:00
|
|
|
(~(del by associations) [group-path md-resource])
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
|
|
|
group-indices
|
2020-06-08 10:53:16 +03:00
|
|
|
(~(del ju group-indices) group-path md-resource)
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-02-15 01:59:22 +03:00
|
|
|
app-indices
|
2020-06-08 10:53:16 +03:00
|
|
|
(~(del ju app-indices) app-name.md-resource [group-path app-path.md-resource])
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-02-15 01:59:22 +03:00
|
|
|
resource-indices
|
2020-06-08 10:53:16 +03:00
|
|
|
(~(del ju resource-indices) md-resource group-path)
|
2020-02-13 03:45:01 +03:00
|
|
|
==
|
|
|
|
::
|
2020-02-14 04:22:52 +03:00
|
|
|
++ metadata-for-app
|
|
|
|
|= =app-name
|
2020-02-28 01:54:03 +03:00
|
|
|
^- ^associations
|
2020-02-22 03:13:22 +03:00
|
|
|
%- ~(gas by *^associations)
|
2020-02-28 02:16:09 +03:00
|
|
|
%+ turn ~(tap in (~(gut by app-indices) app-name ~))
|
2020-02-14 04:22:52 +03:00
|
|
|
|= [=group-path =app-path]
|
2020-02-15 01:59:22 +03:00
|
|
|
:- [group-path [app-name app-path]]
|
|
|
|
(~(got by associations) [group-path [app-name app-path]])
|
2020-02-14 04:22:52 +03:00
|
|
|
::
|
2020-02-21 01:55:46 +03:00
|
|
|
++ metadata-for-group
|
|
|
|
|= =group-path
|
2020-02-28 01:54:03 +03:00
|
|
|
^- ^associations
|
2020-02-22 03:13:22 +03:00
|
|
|
%- ~(gas by *^associations)
|
2020-03-01 03:40:06 +03:00
|
|
|
%+ turn ~(tap in (~(gut by group-indices) group-path ~))
|
2020-06-08 10:53:16 +03:00
|
|
|
|= =md-resource
|
|
|
|
:- [group-path md-resource]
|
|
|
|
(~(got by associations) [group-path md-resource])
|
2020-02-21 01:55:46 +03:00
|
|
|
::
|
2020-02-13 03:45:01 +03:00
|
|
|
++ send-diff
|
2020-02-14 04:22:52 +03:00
|
|
|
|= [=app-name upd=metadata-update]
|
2020-02-13 03:45:01 +03:00
|
|
|
^- (list card)
|
|
|
|
|^
|
|
|
|
%- zing
|
2020-02-14 04:22:52 +03:00
|
|
|
:~ (update-subscribers /all upd)
|
|
|
|
(update-subscribers /updates upd)
|
|
|
|
(update-subscribers [%app-name app-name ~] upd)
|
2020-02-13 03:45:01 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ update-subscribers
|
2020-02-14 04:22:52 +03:00
|
|
|
|= [pax=path upd=metadata-update]
|
2020-02-13 03:45:01 +03:00
|
|
|
^- (list card)
|
2020-02-14 04:22:52 +03:00
|
|
|
[%give %fact ~[pax] %metadata-update !>(upd)]~
|
2020-02-13 03:45:01 +03:00
|
|
|
--
|
|
|
|
--
|