From 2e5bbd74236c52e1a907b27d9de3102eadc26b25 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 11 Jun 2020 15:30:35 -0400 Subject: [PATCH] wip: graph-store JS api --- pkg/interface/src/api/graph.js | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 pkg/interface/src/api/graph.js diff --git a/pkg/interface/src/api/graph.js b/pkg/interface/src/api/graph.js new file mode 100644 index 0000000000..86e28af8c2 --- /dev/null +++ b/pkg/interface/src/api/graph.js @@ -0,0 +1,80 @@ +import BaseApi from './base'; + +class PrivateHelper extends BaseApi { + graphAction(data) { + this.action('graph-store', 'graph-action', data); + } + + addGraph(resource, graph) { + this.graphAction({ + 'add-graph': { + resource, + graph + } + }); + } + + removeGraph(resource) { + this.graphAction({ + 'remove-graph': { + resource + } + }); + } + + addNodes(resource, nodes) { + this.graphAction({ + 'add-nodes': { + resource, + nodes + } + }); + } + + removeNodes(resource, indices) { + this.graphAction({ + 'remove-nodes': { + resource, + indices + } + }); + } + + addSignatures() { + this.graphAction(); + } + + removeSignatures() { + this.graphAction(); + } + + addTag() { + this.graphAction(); + } + + removeTag() { + this.graphAction(); + } +} + +export default class GraphApi { + constructor(ship, channel, store) { + const helper = new PrivateHelper(ship, channel, store); + + this.ship = ship; + this.subscribe = helper.subscribe.bind(helper); + + this.addGraph = helper.addGraph.bind(helper); + this.removeGraph = helper.removeGraph.bind(helper); + + this.addNodes = helper.addNodes.bind(helper); + this.removeNodes = helper.removeNodes.bind(helper); + + this.addSignatures = helper.addSignatures.bind(helper); + this.removeSignatures = helper.removeSignatures.bind(helper); + + this.addTag = helper.addTag.bind(helper); + this.removeTag = helper.removeTag.bind(helper); + } +} +