2020-02-27 06:43:40 +03:00
|
|
|
:: metadata-store: 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-02-26 00:23:07 +03:00
|
|
|
/+ *metadata-json, default-agent, verb, dbug
|
2020-02-13 03:45:01 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
::
|
|
|
|
+$ versioned-state
|
|
|
|
$% state-zero
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state-zero
|
|
|
|
$: %0
|
2020-02-15 01:59:22 +03:00
|
|
|
=associations
|
|
|
|
group-indices=(jug group-path resource)
|
|
|
|
app-indices=(jug app-name [group-path app-path])
|
|
|
|
resource-indices=(jug resource group-path)
|
2020-02-13 03:45:01 +03:00
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
=| state-zero
|
|
|
|
=* 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
|
|
|
|
|= old=vase
|
|
|
|
`this(state !<(state-zero old))
|
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
=^ cards state
|
|
|
|
?: ?=(%metadata-action mark)
|
|
|
|
(poke-metadata-action:mc !<(metadata-action vase))
|
|
|
|
(on-poke:def mark vase)
|
|
|
|
[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))
|
|
|
|
=/ =resource [`@tas`i.t.t.t.path (stab (slav %t i.t.t.t.t.path))]
|
2020-03-04 05:04:00 +03:00
|
|
|
``noun+!>((~(get by associations) [group-path resource]))
|
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-02-15 01:59:22 +03:00
|
|
|
|= [=group-path =resource =metadata]
|
2020-02-13 03:45:01 +03:00
|
|
|
^- (quip card _state)
|
2020-02-15 01:59:22 +03:00
|
|
|
:- %+ send-diff app-name.resource
|
|
|
|
?. (~(has by resource-indices) resource)
|
|
|
|
[%add group-path resource metadata]
|
|
|
|
[%update-metadata group-path resource metadata]
|
2020-02-13 03:45:01 +03:00
|
|
|
%= state
|
2020-02-15 01:59:22 +03:00
|
|
|
associations
|
|
|
|
(~(put by associations) [group-path resource] metadata)
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
|
|
|
group-indices
|
2020-02-15 01:59:22 +03:00
|
|
|
(~(put ju group-indices) group-path resource)
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-02-15 01:59:22 +03:00
|
|
|
app-indices
|
|
|
|
(~(put ju app-indices) app-name.resource [group-path app-path.resource])
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-02-15 01:59:22 +03:00
|
|
|
resource-indices
|
|
|
|
(~(put ju resource-indices) resource group-path)
|
2020-02-13 03:45:01 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-remove
|
2020-02-15 01:59:22 +03:00
|
|
|
|= [=group-path =resource]
|
2020-02-13 03:45:01 +03:00
|
|
|
^- (quip card _state)
|
2020-02-15 01:59:22 +03:00
|
|
|
:- (send-diff app-name.resource [%remove group-path resource])
|
2020-02-13 03:45:01 +03:00
|
|
|
%= state
|
2020-02-15 01:59:22 +03:00
|
|
|
associations
|
|
|
|
(~(del by associations) [group-path resource])
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
|
|
|
group-indices
|
2020-02-15 01:59:22 +03:00
|
|
|
(~(del ju group-indices) group-path resource)
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-02-15 01:59:22 +03:00
|
|
|
app-indices
|
|
|
|
(~(del ju app-indices) app-name.resource [group-path app-path.resource])
|
2020-02-13 03:45:01 +03:00
|
|
|
::
|
2020-02-15 01:59:22 +03:00
|
|
|
resource-indices
|
|
|
|
(~(del ju resource-indices) 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-02-21 01:55:46 +03:00
|
|
|
|= =resource
|
|
|
|
:- [group-path resource]
|
|
|
|
(~(got by associations) [group-path resource])
|
|
|
|
::
|
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
|
|
|
--
|
|
|
|
--
|