metadata-store: sanitized paths and %y to %x
:: group-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))
+::
:: +watch paths:
:: /all assocations + updates
:: /updates just updates
:: /group-indices all group indices
:: /app-indices all app indices
:: /resource-indices all resource indices
-:: /metadata/(spat group-path)/%app-name/(spat app-path) specific metadatum
+:: /metadata/%group-path/%app-name/%app-path specific metadatum
:: /app-name/%app-name associations for app
::
/- *metadata-store
|= =path
^- (unit (unit cage))
?+ path (on-peek:def path)
- [%y %associations ~] ``noun+!>(associations)
[%y %group-indices ~] ``noun+!>(group-indices)
[%y %app-indices ~] ``noun+!>(app-indices)
[%y %resource-indices ~] ``noun+!>(resource-indices)
- [%x %metadata @ @ @ ~]
- =/ =group-path (stab i.t.t.path)
- =/ =resource [`@tas`i.t.t.t.path (stab i.t.t.t.t.path)]
- ``noun+!>((~(got by associations) [group-path resource]))
- ::
+ [%x %associations ~] ``noun+!>(associations)
[%x %app-name @ ~]
=/ =app-name i.t.t.path
``noun+!>((metadata-for-app:mc app-name))
+ ::
+ [%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))]
+ ``noun+!>((~(got by associations) [group-path resource]))
==
::
++ on-agent on-agent:def
--
::
|_ =bowl:gall
-::
++ poke-metadata-action
|= act=metadata-action
^- (quip card _state)
?. (~(has by resource-indices) resource)
[%add group-path resource metadata]
[%update-metadata group-path resource metadata]
-
%= state
associations
(~(put by associations) [group-path resource] metadata)
