metadata-store,hook: add OTA adapter

This commit is contained in:
Liam Fitzgerald 2021-01-14 13:10:32 +10:00
parent 3fa761aaf3
commit 55c2991a9b
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 96 additions and 8 deletions

View File

@ -6,13 +6,14 @@
:: /group/%group-path all updates related to this group
::
/- *metadata-store, *metadata-hook
/+ default-agent, dbug, verb, grpl=group, *migrate
/+ default-agent, dbug, verb, grpl=group, *migrate, resource
~% %metadata-hook-top ..part ~
|%
+$ card card:agent:gall
+$ versioned-state
$% state-zero
state-one
state-two
==
::
+$ state-zero
@ -23,10 +24,60 @@
$: %1
synced=(map group-path ship)
==
+$ state-two
[%2 ~]
--
=| state-one
=* state -
%- agent:dbug
%+ verb |
^- agent:gall
(default-agent *agent:gall %|)
|_ =bowl:gall
+* this .
def ~(. (default-agent *agent:gall %|) bowl)
++ on-init on-init:def
++ on-save !>(state)
++ on-load
|= =vase
=+ !<(old=versioned-state vase)
|^
?: ?=(%2 -.old)
`this
:_ this
%+ murn
~(tap by synced.old)
|= [group=path =ship]
%+ bind
(de-path-soft:resource group)
|= rid=resource
?: =(our.bowl ship)
(push-metadata rid)
(pull-metadata rid ship)
::
++ poke-our
|= [app=term =cage]
^- card
[%pass / %agent [our.bowl app] %poke cage]
::
++ push-metadata
|= rid=resource
^- card
(poke-our %metadata-push-hook push-hook-action+!>([%add rid]))
::
++ pull-metadata
|= [rid=resource =ship]
^- card
(poke-our %metadata-pull-hook pull-hook-action+!>([%add ship rid]))
--
++ on-poke on-poke:def
++ on-watch on-watch:def
++ on-peek on-peek:def
++ on-leave on-leave:def
++ on-agent on-agent:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
--
::

View File

@ -44,9 +44,18 @@
creator=@p
==
::
+$ metadata-1
$: title=@t
description=@t
color=@ux
date-created=@da
creator=@p
module=term
==
::
+$ md-resource-1 [=app-name =app-path]
::
+$ associations-1 (map [group-path md-resource-1] metadata)
+$ associations-1 (map [group-path md-resource-1] metadata-1)
::
+$ base-state-1
$: associations=associations-1
@ -198,6 +207,7 @@
=/ old !<(versioned-state vase)
=| cards=(list card)
|^
=* loop $
?: ?=(%7 -.old)
:- cards
%_ state
@ -226,10 +236,37 @@
associations.old associations
==
:: pre-breach, can safely throw away
$(old *state-7)
loop(old *state-7)
::
++ associations-1-to-2
|= assoc=*
*^associations
|= assoc=associations-1
^- ^associations
%- ~(gas by *^associations)
%+ 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 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)
|=(rid=resource [app-name.m rid])
::
++ metadata-1-to-2
|= m=metadata-1
%* . *metadata
title title.m
description description.m
color color.m
date-created date-created.m
creator creator.m
module module.m
==
::
++ rebuild-resource-indices
|= =^associations
@ -258,8 +295,8 @@
^- associations-1
%- malt
%+ turn ~(tap by associations)
|= [[=group-path md-resource=md-resource-1] m=metadata]
^- [[^group-path md-resource-1] metadata]
|= [[=group-path md-resource=md-resource-1] m=metadata-1]
^- [[^group-path md-resource-1] metadata-1]
?. =(app-name.md-resource app)
[[group-path md-resource] m]
=/ new-app-path=path