diff --git a/config/paths.js b/config/paths.js index 02c4227..ff90493 100644 --- a/config/paths.js +++ b/config/paths.js @@ -27,6 +27,7 @@ module.exports = { // point within the build directory. backendEntryPoints: { sourcecred: resolveApp("src/cli/main.js"), + api: resolveApp("src/api/index.js"), // generateGithubGraphqlFlowTypes: resolveApp( "src/plugins/github/bin/generateGraphqlFlowTypes.js" diff --git a/src/api/index.js b/src/api/index.js new file mode 100644 index 0000000..22b959f --- /dev/null +++ b/src/api/index.js @@ -0,0 +1,44 @@ +// @flow + +import deepFreeze from "deep-freeze"; + +// Exports for calling SourceCred code programmatically. Both the +// structure and the contents of this API are experimental and subject +// to change. +import * as address from "../core/address"; +import * as discourseAddress from "../plugins/discourse/address"; +import * as discourseDeclaration from "../plugins/discourse/declaration"; +import * as githubDeclaration from "../plugins/github/declaration"; +import * as githubEdges from "../plugins/github/edges"; +import * as githubNodes from "../plugins/github/nodes"; +import * as graph from "../core/graph"; +import * as graphToMarkovChain from "../core/attribution/graphToMarkovChain"; +import * as markovChain from "../core/attribution/markovChain"; +import * as timelineCred from "../analysis/timeline/timelineCred"; + +export default deepFreeze({ + analysis: { + timeline: { + timelineCred, + }, + }, + core: { + address, + attribution: { + markovChain, + graphToMarkovChain, + }, + graph, + }, + plugins: { + github: { + declaration: githubDeclaration, + edges: githubEdges, + nodes: githubNodes, + }, + discourse: { + address: discourseAddress, + declaration: discourseDeclaration, + }, + }, +});