mirror of
https://github.com/status-im/sourcecred.git
synced 2025-03-01 20:50:40 +00:00
Summary: For convenient import by scripts and Observable notebooks that want to use SourceCred code outside its normal build system. We export a subset of the codebase, including some core data structures and algorithms and also some plugin metadata, but no plugin loading code. To build, run `yarn backend` (or `yarn backend --watch`), then grab the new `bin/api.js` file. Test Plan: Sample usage, with normal Node: ```javascript const { core: { graph: {Graph, NodeAddress, EdgeAddress}, }, } = require("./api").default; function node(address) { return { address, description: "blurgh", timestampMs: -1, }; } const g = new Graph(); g.addNode(node(NodeAddress.fromParts(["people", "alice"]))); g.addNode(node(NodeAddress.fromParts(["people", "bob"]))); g.addEdge({ address: EdgeAddress.fromParts(["friendship"]), src: NodeAddress.fromParts(["people", "alice"]), dst: NodeAddress.fromParts(["people", "bob"]), timestampMs: 0, }); console.log(require("json-stable-stringify")(g)); ``` This prints a valid graph JSON object. wchargin-branch: api-bundle