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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@anyshift/graph-sdk

v0.5.7

Published

TypeScript SDK for the Anyshift Graph API

Readme

Anyshift Graph SDK for TypeScript

The TypeScript SDK is the first public Anyshift Graph SDK. It provides a small, typed client for querying the Anyshift Graph API from Node.js applications, automation, CI checks, dashboards, and developer tools.

Install

npm install @anyshift/graph-sdk

The package is ESM-only and targets Node.js 18+ or runtimes that provide fetch.

Authenticate

import { GraphAnswer } from "@anyshift/graph-sdk";

const graph = new GraphAnswer({
  token: process.env.ANYSHIFT_TOKEN!,
  project: process.env.ANYSHIFT_PROJECT_ID!,
});

The default endpoint is https://graph.anyshift.io.

Query Helpers

Resolve a resource name before opening a drill-down:

const matches = await graph.resolve({ term: "checkout", limit: 10 });
if (matches.intent === "resolve") {
  console.log(matches.resolve?.candidates);
}
const recent = await graph.events({ since: "1h", limit: 10 });
console.log(recent.summary);
const changes = await graph.cloudEvents({
  provider: "aws",
  resource: "arn:aws:ecs:eu-west-3:123456789012:service/prod/api",
  since: "1d",
  limit: 20,
});
const resources = await graph.cloudResources({
  provider: "aws",
  type: "EC2_INSTANCE",
  lifecycle: "alive",
  maxAge: "24h",
});
const provenance = await graph.iac({ resource: "aws_ecs_service.api" });
const drift = await graph.iacDrift({ resource: "aws_ecs_service.api" });
const impact = await graph.impact({ resource: "checkout-db", depth: 2 });
const releases = await graph.deliveryEvents({ stage: "release", since: "7d" });
const releaseProvenance = await graph.provenance({ resource: "checkout" });
const owners = await graph.ownership({ resource: "anyshift-io/checkout" });
const dynatraceCoverage = await graph.graphCoverage({ source: "dynatrace" });

Join scanner evidence to the exact image digest observed in running containers:

const runtime = await graph.image({
  digest: "sha256:776129790f01a675bb6e98447c2a28d43a07144d5410691823dbf9a21d256b1e",
  limit: 50,
});

if (runtime.intent === "image" && runtime.image?.mode === "bydigest") {
  for (const match of runtime.image.byDigest?.matches ?? []) {
    console.log(match.clusterName, match.clusterID, match.clusterHashedID);
  }
}

Digest lookup accepts a canonical digest, repository digest, or runtime-prefixed image ID. It matches the canonical digest exactly against live container image_id evidence. It cannot be combined with target, workload, kind, or namespace. Each match separates the configured human cluster name from its provider-native ID and stable Anyshift graph identity.

const blast = await graph.blast({ resource: "checkout" });
console.log(blast.summary);
const path = await graph.path({
  from: { name: "checkout-api", type: "K8S_DEPLOYMENT" },
  to: { name: "postgresql", type: "TEMPO_DATASTORE" },
  scope: "operational",
});
console.log(path.summary);

Typed selectors are deterministic when multiple resource types share the same name. Use { id: candidate.id } with an id returned by graph.resolve() when name, type, namespace, and cluster still do not identify one node. Existing string selectors retain fuzzy-name resolution.

Tempo-backed APM helpers accept source: "tempo":

const calls = await graph.calls({ target: "checkout-api", source: "tempo" });
const datastore = await graph.datastore({ target: "postgresql", source: "tempo" });
const topology = await graph.topology({
  service: "checkout-api",
  source: "tempo",
  level: "container",
});

ECS configuration evidence is explicit and read-only. Supply a reviewed endpoint alias; when a dependency name is present the endpoint is required:

const topology = await graph.topology({
  service: "developer-portal-production",
  source: "configuration",
  endpoint: "api.anyshift.io",
  dependency: "anyshift-backend",
  level: "context",
});

Matching edges use CONFIGURES_ENDPOINT and include the environment key and task-definition identity. Environment values are never returned, and configured edges are not marked as causal impact edges.

The datastore, flow, externalDep, calls, serviceTree, and topology helpers support source: "auto" | "datadog" | "tempo" | "dynatrace". Topology additionally supports the explicit configuration source. Omitting it preserves the source-agnostic default.

Topology Diagrams

Use toMermaid() to render topology results as Mermaid text.

import { GraphAnswer, toMermaid } from "@anyshift/graph-sdk";

const topology = await graph.topology({
  service: "checkout",
  level: "container",
});

console.log(toMermaid(topology));

level: "dynamic" renders a sequence diagram. Other topology levels render flowcharts.

Raw Queries

For advanced workflows, call the Graph API query endpoint directly with graph SQL:

const result = await graph.query(
  "SELECT * FROM connections WHERE resource = checkout"
);

console.log(result.summary);

See the complete Graph Query Language reference for every target, filter, accepted value, alias, and valid query form.

Environment

export ANYSHIFT_TOKEN="anys_api_..."
export ANYSHIFT_PROJECT_ID="00000000-0000-0000-0000-000000000000"

Advanced users can override the endpoint in client configuration when needed.

Every SDK request includes the package version and a random invocation ID so operators can correlate product analytics with Graph API traces. Typed helpers identify only their fixed query target. Query text, questions, resource names, namespaces, response bodies, and bearer tokens are never copied into telemetry headers.

To correlate several calls as one application workflow, pass a UUID as invocationId when constructing GraphAnswer.

Contract

Public SDK response types come from the OpenAPI contract pinned in this repository. AskResult is a discriminated union, so checking intent exposes the matching payload without a cast:

const result = await graph.inventory({ type: "K8S_SERVICE" });

if (result.intent === "inventory") {
  console.log(result.inventory?.total);
}

Use AskResultFor<"inventory"> when a function accepts the response for one known intent.

Examples

Runnable examples are available in examples/:

  • recent-events.ts
  • blast-radius.ts
  • path.ts
  • raw-query.ts
  • topology-mermaid.ts

Documentation

See the Anyshift Graph SDK guide for product documentation and troubleshooting.

See CAPABILITIES.md for the canonical capability matrix: every typed helper, the graph query target, primary parameters, and what each capability answers.

Development

npm install
npm run generate
npm run typecheck
npm test
npm run build