@snyk/dep-graph

  • Version 2.3.0
  • Published
  • 119 kB
  • 18 dependencies
  • Apache-2.0 license

Install

npm i @snyk/dep-graph
yarn add @snyk/dep-graph
pnpm add @snyk/dep-graph

Overview

Snyk dependency graph library

Index

Functions

function createFromJSON

createFromJSON: (depGraphData: DepGraphData) => DepGraph;
  • Create a DepGraph instance from a JSON representation of a dep graph. This is typically used after passing the graph over the wire as DepGraphData.

Classes

class DepGraphBuilder

class DepGraphBuilder {}

    constructor

    constructor(pkgManager: types.PkgManager, rootPkg?: types.PkgInfo);

      property rootNodeId

      readonly rootNodeId: string;

        method addPkgNode

        addPkgNode: (
        pkgInfo: types.PkgInfo,
        nodeId: string,
        nodeInfo?: types.NodeInfo
        ) => this;

          method build

          build: () => types.DepGraph;

            method connectDep

            connectDep: (parentNodeId: string, depNodeId: string) => this;

              method getPkgs

              getPkgs: () => types.PkgInfo[];

                Interfaces

                interface DepGraph

                interface DepGraph {}

                  property pkgManager

                  readonly pkgManager: PkgManager;

                    property rootPkg

                    readonly rootPkg: PkgInfo;

                      method countPathsToRoot

                      countPathsToRoot: (pkg: Pkg) => number;

                        method directDepsLeadingTo

                        directDepsLeadingTo: (pkg: Pkg) => PkgInfo[];

                          method equals

                          equals: (other: DepGraph, options?: { compareRoot?: boolean }) => boolean;

                            method getDepPkgs

                            getDepPkgs: () => PkgInfo[];

                              method getPkgNodes

                              getPkgNodes: (pkg: Pkg) => Node[];

                                method getPkgs

                                getPkgs: () => PkgInfo[];

                                  method isTransitive

                                  isTransitive: (pkg: Pkg) => boolean;

                                    method pkgPathsToRoot

                                    pkgPathsToRoot: (pkg: Pkg, opts?: { limit?: number }) => PkgInfo[][];

                                      method toJSON

                                      toJSON: () => DepGraphData;

                                        interface DepGraphData

                                        interface DepGraphData {}

                                          property graph

                                          graph: {
                                          rootNodeId: string;
                                          nodes: GraphNode[];
                                          };

                                            property pkgManager

                                            pkgManager: PkgManager;

                                              property pkgs

                                              pkgs: Array<{
                                              id: string;
                                              info: PkgInfo;
                                              }>;

                                                property schemaVersion

                                                schemaVersion: string;

                                                  interface Pkg

                                                  interface Pkg {}

                                                    property name

                                                    name: string;

                                                      property version

                                                      version?: string;

                                                        interface PkgInfo

                                                        interface PkgInfo {}

                                                          property name

                                                          name: string;

                                                            property version

                                                            version?: string;

                                                              interface PkgManager

                                                              interface PkgManager {}

                                                                property name

                                                                name: string;

                                                                  property repositories

                                                                  repositories?: Array<{
                                                                  alias: string;
                                                                  }>;

                                                                    property version

                                                                    version?: string;

                                                                      interface VersionProvenance

                                                                      interface VersionProvenance {}

                                                                        property location

                                                                        location: string;

                                                                          property property

                                                                          property?: {
                                                                          name: string;
                                                                          };

                                                                            property type

                                                                            type: string;

                                                                              Namespaces

                                                                              namespace Errors

                                                                              module 'dist/core/errors/index.d.ts' {}

                                                                                class ValidationError

                                                                                class ValidationError extends CustomError {}

                                                                                  constructor

                                                                                  constructor(message: string);

                                                                                    namespace legacy

                                                                                    module 'dist/legacy/index.d.ts' {}

                                                                                    function depTreeToGraph

                                                                                    depTreeToGraph: (
                                                                                    depTree: DepTree,
                                                                                    pkgManagerName: string
                                                                                    ) => Promise<types.DepGraph>;
                                                                                    • Deprecated

                                                                                      Don't use dep trees as an intermediate step, because they are large structures, resulting in high memory usage and high CPU costs from serializing / deserializing. Instead, create a graph directly with DepGraphBuilder

                                                                                    function graphToDepTree

                                                                                    graphToDepTree: (
                                                                                    depGraphInterface: types.DepGraph,
                                                                                    pkgType: string,
                                                                                    opts?: GraphToTreeOptions
                                                                                    ) => Promise<DepTree>;
                                                                                    • Deprecated

                                                                                      Don't use dep trees. You should adapt your code to use graphs, and enhance the dep-graph library if there is missing functionality from the graph structure

                                                                                    interface DepTree

                                                                                    interface DepTree extends DepTreeDep {}

                                                                                    property packageFormatVersion

                                                                                    packageFormatVersion?: string;

                                                                                      property targetOS

                                                                                      targetOS?: {
                                                                                      name: string;
                                                                                      version: string;
                                                                                      };

                                                                                        property type

                                                                                        type?: string;

                                                                                          interface GraphToTreeOptions

                                                                                          interface GraphToTreeOptions {}

                                                                                            property deduplicateWithinTopLevelDeps

                                                                                            deduplicateWithinTopLevelDeps: boolean;

                                                                                              Package Files (7)

                                                                                              Dependencies (18)

                                                                                              Dev Dependencies (15)

                                                                                              Peer Dependencies (0)

                                                                                              No peer dependencies.

                                                                                              Badge

                                                                                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@snyk/dep-graph.

                                                                                              • Markdown
                                                                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@snyk/dep-graph)
                                                                                              • HTML
                                                                                                <a href="https://www.jsdocs.io/package/@snyk/dep-graph"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>