shrub/pkg/arvo/lib/metadata-store.hoon

159 lines
3.5 KiB
Plaintext
Raw Normal View History

/- *metadata-store
2021-01-12 07:26:19 +03:00
/+ resource
^?
|%
2021-01-28 09:13:57 +03:00
::
++ associations-to-json
|= =associations
=, enjs:format
^- json
%- pairs
%+ turn ~(tap by associations)
2021-01-28 09:13:57 +03:00
|= [=md-resource [group=resource =metadatum]]
^- [cord json]
:-
%- crip
;: weld
2021-01-12 07:26:19 +03:00
(trip (spat (en-path:resource group)))
(weld "/" (trip app-name.md-resource))
2021-01-12 07:26:19 +03:00
(trip (spat (en-path:resource resource.md-resource)))
==
%- pairs
2021-01-12 07:26:19 +03:00
:~ [%group s+(enjs-path:resource group)]
[%app-name s+app-name.md-resource]
2021-01-12 07:26:19 +03:00
[%resource s+(enjs-path:resource resource.md-resource)]
2021-01-28 09:13:57 +03:00
[%metadata (metadata-to-json metadatum)]
==
::
++ json-to-action
|= jon=json
2021-01-28 09:13:57 +03:00
^- action
=, dejs:format
=< (parse-json jon)
|%
++ parse-json
%- of
:~ [%add add]
[%remove remove]
==
::
++ add
%- ot
2021-01-12 07:26:19 +03:00
:~ [%group dejs-path:resource]
[%resource md-resource]
2021-01-28 09:13:57 +03:00
[%metadata metadatum]
==
++ remove
%- ot
2021-01-12 07:26:19 +03:00
:~ [%group dejs-path:resource]
[%resource md-resource]
==
::
++ nu
|= jon=json
?> ?=([%s *] jon)
(rash p.jon hex)
::
2021-01-26 04:46:06 +03:00
++ vip
2021-01-20 04:51:07 +03:00
%- su
;~ pose
(tag %$)
(tag %reader-comments)
2021-01-26 04:46:06 +03:00
(tag %member-metadata)
2021-01-20 04:51:07 +03:00
==
::
2021-01-28 09:13:57 +03:00
++ metadatum
%- ot
:~ [%title so]
[%description so]
[%color nu]
[%date-created (se %da)]
[%creator (su ;~(pfix sig fed:ag))]
[%module so]
2021-01-14 04:12:48 +03:00
[%picture so]
[%preview bo]
2021-01-26 04:46:06 +03:00
[%vip vip]
==
2021-01-12 07:26:19 +03:00
::
2021-01-20 04:51:07 +03:00
++ tag |*(a=@tas (cold a (jest a)))
::
++ md-resource
2021-01-12 07:26:19 +03:00
^- $-(json ^md-resource)
%- ot
:~ [%app-name so]
2021-01-12 07:26:19 +03:00
[%resource dejs-path:resource]
==
--
::
++ metadata-to-json
2021-01-28 09:13:57 +03:00
|= met=metadatum
^- json
=, enjs:format
%- 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]
2021-01-14 04:12:48 +03:00
[%picture s+picture.met]
[%preview b+preview.met]
2021-01-26 04:46:06 +03:00
[%vip s+`@t`vip.met]
==
++ hook-update-to-json
2021-01-28 09:13:57 +03:00
|= upd=hook-update
=, enjs:format
%+ frond %metadata-hook-update
%+ frond -.upd
%- pairs
?- -.upd
%preview
:~ [%group s+(enjs-path:resource group.upd)]
[%channels (associations-to-json channels.upd)]
[%members (numb members.upd)]
[%channel-count (numb channel-count.upd)]
2021-01-28 09:13:57 +03:00
[%metadata (metadata-to-json metadatum.upd)]
==
%req-preview
~[group+s+(enjs-path:resource group.upd)]
==
::
++ update-to-json
2021-01-28 09:13:57 +03:00
|= upd=update
^- json
=, enjs:format
%+ 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)]
2021-01-28 09:13:57 +03:00
[%metadata (metadata-to-json metadatum.upd)]
==
%updated-metadata
:- %add
%- pairs
2021-01-12 07:26:19 +03:00
:~ [%group s+(enjs-path:resource group.upd)]
[%app-name s+app-name.resource.upd]
2021-01-12 07:26:19 +03:00
[%resource s+(enjs-path:resource resource.resource.upd)]
2021-01-28 09:13:57 +03:00
[%metadata (metadata-to-json metadatum.upd)]
==
::
%remove
:- %remove
%- pairs
2021-01-12 07:26:19 +03:00
:~ [%group s+(enjs-path:resource group.upd)]
[%app-name s+app-name.resource.upd]
2021-01-12 07:26:19 +03:00
[%resource s+(enjs-path:resource resource.resource.upd)]
==
::
%associations
[%associations (associations-to-json associations.upd)]
::
== ==
--