graph-store: stubbed out json encoding

This commit is contained in:
Logan Allen 2020-06-10 14:45:00 -04:00
parent c9ccbdabef
commit 81deb6247f
4 changed files with 139 additions and 11 deletions

View File

@ -1,11 +1,10 @@
/- sur=graph-store, pos=post, res=resource
^?
/- sur=graph-store, pos=post
/+ res=resource
=< [sur .]
=< [pos .]
=< [res .]
=, sur
=, pos
=, res
|%
++ enjs
=, enjs:format
@ -13,12 +12,98 @@
++ update
|= upd=^update
^- json
|^ (frond %graph-update (pairs ~[(encode upd)]))
?> ?=(%0 -.upd)
|^ (frond %graph-update (pairs ~[(encode +.upd)]))
::
++ encode
|= upd=^update
|= upd=update-0
^- [cord json]
[*cord *json]
?- -.upd
%keys
[%keys [%a (turn ~(tap in resources.upd) enjs:res)]]
::
%add-graph
:- %add-graph
%- pairs
:~ [%resource (enjs:res resource.upd)]
[%graph (graph graph.upd)]
==
::
%remove-graph
[%remove-graph (enjs:res resource.upd)]
::
%add-nodes
:- %add-nodes
%- pairs
:~ [%resource (enjs:res resource.upd)]
[%nodes (nodes nodes.upd)]
==
::
%remove-nodes
:- %remove-nodes
%- pairs
:~ [%resource (enjs:res resource.upd)]
[%indices (indices indices.upd)]
==
::
%add-signatures
:- %add-signatures
%- pairs
:~ [%uid (uid uid.upd)]
[%signatures (signatures signatures.upd)]
==
::
%remove-signatures
:- %remove-signatures
%- pairs
:~ [%uid (uid uid.upd)]
[%signatures (signatures signatures.upd)]
==
::
%add-tag
:- %add-tag
%- pairs
:~ [%term s+term.upd]
[%resource (enjs:res resource.upd)]
==
::
%remove-tag
:- %remove-tag
%- pairs
:~ [%term s+term.upd]
[%resource (enjs:res resource.upd)]
==
==
::
++ graph
|= g=^graph
^- json
*json
::
++ index
|= i=^index
^- json
*json
::
++ nodes
|= n=(map ^index node)
^- json
*json
::
++ indices
|= i=(set ^index)
^- json
*json
::
++ uid
|= u=^uid
^- json
*json
::
++ signatures
|= s=^signatures
^- json
*json
--
--
::

View File

@ -0,0 +1,46 @@
/- sur=resource
=< resource
|%
+$ resource resource:sur
++ en-path
|= =resource
^- path
~[%ship (scot %p entity.resource) name.resource]
::
++ de-path
|= =path
^- resource
(need (de-path-soft path))
::
++ de-path-soft
|= =path
^- (unit resource)
?. ?=([%ship @ @ *] path)
~
=/ ship
(slaw %p i.t.path)
?~ ship
~
`[u.ship i.t.t.path]
::
++ enjs
|= =resource
^- json
=, enjs:format
%- pairs
:~ ship+(ship entity.resource)
name+s+name.resource
==
::
++ enjs-path
|= =resource
%- spat
(en-path resource)
::
++ dejs
=, dejs:format
%- ot
:~ ship+(su ;~(pfix sig fed:ag))
name+so
==
--

View File

@ -52,7 +52,6 @@
::
+$ update-0
$% [%keys =resources]
[%initial =graphs =tag-queries]
action-0
==
--

View File

@ -1,11 +1,9 @@
|%
+$ resource [=entity =term]
+$ resource [=entity name=term]
+$ resources (set resource)
::
+$ entity
$@ ship
$% [%empty ~]
:: [%ships ships=(set ship)]
:: [%ring ...]
$% !!
==
--