0.1.6 • Published 1 year ago

deepsource-node v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

DeepSource Node

A JavaScript API to fetch data from DeepSource.

Usage

Start by importing the library:

import DeepSource from "deepsource-node";
// or require("deepsource-node")

Then use your Personal Access Token to create a driver.

const deepsource = new DeepSourceAPI("<your personal access token>");

Now, you can use fetch data from the API using the driver:

const repo = await deepsource.getRepo("repo-name", "user-name");
console.log(repo);

repo will look like this:

{
  defaultBranch: 'master',
  dsn: 'https://a945758ecdbf4ce4872a6da96e3f90b4@deepsource.io',
  isPrivate: false,
  runIds: [Array]
}

To fetch all active issues in the repo:

// All issues raised by DeepSource:
const allIssues = await deepsource.getAllIssuesInRepo("repo-name", "user-name");
console.log(allIssues);

Output:

 [{
    issue: {
      code: 'JS-D023',
      title: 'Unsafe `child_process` non-literal',
      category: 'SECURITY',
      tags: [Array]
    },
    path: 'index.js',
    beginColumn: 1,
    beginLine: 35,
    endColumn: 20,
    endLine: 35
  },
  ... 100 more items
]

Or, you can make an arbitrary GraphQL query by following the schema in the docs. For such requests, the response will be a Record<string, any>, instead of having proper type definitions.

deepsource.fetch(`query {
  run(runUid:"") {
    checks {
      totalCount
      edges {
        node {
          analyzer { name }
        }
      }
    }
  }
}`);
0.1.6

1 year ago

0.1.5

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago