npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kineviz/graphxr-api

v0.0.256

Published

[![npm version](https://badge.fury.io/js/@kineviz%2Fgraphxr-api.svg)](https://badge.fury.io/js/@kineviz%2Fgraphxr-api)

Downloads

181

Readme

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('[email protected]')).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: [v]1.0.34 | patch | minor | major.
  • -m, --tag-message <message> Tag message. Default is "".