• Version 1.28.0
  • Published
  • 110 kB
  • 19 dependencies
  • Apache-2.0 license


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


Snyk dependency graph library



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.


class DepGraphBuilder

class DepGraphBuilder {}


    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[];


                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 pkgPathsToRoot

                                  pkgPathsToRoot: (pkg: Pkg) => 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;


                                                                            namespace Errors

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

                                                                              class ValidationError

                                                                              class ValidationError extends CustomError {}


                                                                                constructor(message: string);

                                                                                  namespace legacy

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

                                                                                    function depTreeToGraph

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

                                                                                      function graphToDepTree

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

                                                                                        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 (19)

                                                                                                    Dev Dependencies (15)

                                                                                                    Peer Dependencies (0)

                                                                                                    No peer dependencies.


                                                                                                    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
                                                                                                    • 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>