0.0.256 • Published 1 year ago

@kineviz/graphxr-api v0.0.256

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
1 year ago

graphxr-api

npm version

graphxr-api is a module which provides an API to GraphXR internals

Documentation

Documentation is hosted on GitHub

Table of Contents

Examples

// Latest
GraphXR = (await require('graphxr-api')).getApi()

// Target a version
GraphXR = (await require('graphxr-api@0.0.3')).getApi()

// Get nodes
GraphXR.getLayoutGraph().getNodes()

// Apply Layout
const view = GraphXR.getLayoutGraph()
view.applyLayout(GraphXR.line({
  sort: 'price',
  filter: (node: Node) => node.properties.price > 13,
}))
view.applyLayout(GraphXR.rotate({
  dimension: 'x',
  theta: 90,
}))
view.applyLayout(GraphXR.parametric({
  x: 'price',
}))
view.applyLayout(GraphXR.distributionBy({
  dimension: 'y',
  bin: 'seasonNumber',
}))

// Apply Transform
const view = GraphXR.getLayoutGraph()
view.applyTransform(GraphXR.extract({
  category: "Episodes",
  props: [
    {
      name: "seasonNumber",
      newName: "seasonNumber",
      isSplit: false,
      splitChar: "",
      isKey: true,
    }
  ],
  newCategory: "Season Number",
  newRelationship: "inSeason",
  inheritLinks: false,
  skipEmpty: true,
}))

Minimum Version Requirements

If a version of the API depends on a version of GraphXR which has not been released, please increase the minimum required version in src/minimumRequirements.ts. For example:

export const MINIMUM_GRAPHXR_VERSION = "2.11.0";

On init, the API will ask GraphXR for its version by fetching /api/install/version. If the version is greater than the minimum version, the API will throw an exception.

If GraphXR cannot be detected, init will log a warning to the console.

If the minimum requirements are met, init will return the API.

Build

yarn build

Testing

Integration (cypress/)

The integration tests run the API against a local GraphXR instance.

It assumes auth is disabled. Comment out adminEmail in GraphXR's config.js to disable auth.

First create file .env in the root folder (web/api/.env) with contents.

# Points at a GraphXR instance
CYPRESS_baseUrl=https://localhost:3000

Run once: yarn test or yarn test:integration

Coverage

Running the tests will result in a text report:

-------------------|---------|----------|---------|---------|-------------------
File               | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files          |     100 |      100 |     100 |     100 |
 addNodes.ts       |     100 |      100 |     100 |     100 |
 clearGraph.ts     |     100 |      100 |     100 |     100 |
 getNodes.ts       |     100 |      100 |     100 |     100 |
 getScene.ts       |     100 |      100 |     100 |     100 |
 index.ts          |     100 |      100 |     100 |     100 |
 makeNode.ts       |     100 |      100 |     100 |     100 |
 removeNodeById.ts |     100 |      100 |     100 |     100 |
 setRuntime.ts     |     100 |      100 |     100 |     100 |
-------------------|---------|----------|---------|---------|-------------------

This project tries to have as near 100% code coverage as possible.

A more detailed report is located at coverage/lcov-report/index.html.

Note: some code is ignored. e.g. anything using observablehq.

Documentation

yarn build:docs will run tsdoc and generate html at docs/index.html

Publishing to NPM

This process will do the following

  • ensure you are logged into npm
  • ensure working directory is clean
  • run tests
  • build the API bundle
  • build the documentation
  • bump the package.json version
  • commit the bundle, docs, and package.json
  • tag the commit with the new version
  • push the commits
  • push the tag
  • publish the package to npm

In a terminal:

  1. yarn login
  2. yarn release

Most of the time you will run yarn release

Optional arguments to yarn release

  • --no-verify Skips the tests.
  • --no-publish-docs Skips building and publishing docs.
  • --beta Publishes a new version tagged "beta" so that require("graphxr-api@beta") loads that version, and require("graphxr-api") does not.
  • -v, --version <version> Release type: v1.0.34 | patch | minor | major.
  • -m, --tag-message <message> Tag message. Default is "".
0.0.256

1 year ago

0.0.252

1 year ago

0.0.253

1 year ago

0.0.238

1 year ago

0.0.237

1 year ago

0.0.236

1 year ago

0.0.235

1 year ago

0.0.239

1 year ago

0.0.234

1 year ago

0.0.249

1 year ago

0.0.248

1 year ago

0.0.246

1 year ago

0.0.241

1 year ago

0.0.240

1 year ago

0.0.245

1 year ago

0.0.244

1 year ago

0.0.243

1 year ago

0.0.242

1 year ago

0.0.230

2 years ago

0.0.233

2 years ago

0.0.232

2 years ago

0.0.231

2 years ago

0.0.216

2 years ago

0.0.215

2 years ago

0.0.214

2 years ago

0.0.213

2 years ago

0.0.219

2 years ago

0.0.218

2 years ago

0.0.217

2 years ago

0.0.212

2 years ago

0.0.227

2 years ago

0.0.226

2 years ago

0.0.225

2 years ago

0.0.224

2 years ago

0.0.229

2 years ago

0.0.228

2 years ago

0.0.223

2 years ago

0.0.222

2 years ago

0.0.221

2 years ago

0.0.220

2 years ago

0.0.211

2 years ago

0.0.210

2 years ago

0.0.209

2 years ago

0.0.208

2 years ago

0.0.205

2 years ago

0.0.204

2 years ago

0.0.203

2 years ago

0.0.207

2 years ago

0.0.206

2 years ago

0.0.197

2 years ago

0.0.196

2 years ago

0.0.195

2 years ago

0.0.194

2 years ago

0.0.199

2 years ago

0.0.198

2 years ago

0.0.193

2 years ago

0.0.192

2 years ago

0.0.191

2 years ago

0.0.190

2 years ago

0.0.202

2 years ago

0.0.201

2 years ago

0.0.200

2 years ago

0.0.189

2 years ago

0.0.188

2 years ago

0.0.187

2 years ago

0.0.186

2 years ago

0.0.185

2 years ago

0.0.184

2 years ago

0.0.183

2 years ago

0.0.182

2 years ago

0.0.181

2 years ago

0.0.180

2 years ago

0.0.179

2 years ago

0.0.178

2 years ago

0.0.177

2 years ago

0.0.176

2 years ago

0.0.175

2 years ago

0.0.174

2 years ago