Skip to content

Classes

Query

Defined in: index.ts:189

The Query class is used to search the graph for nodes and edges using the Dependency Selector Syntax (DSS).

Constructors

new Query()
new Query(__namedParameters): Query

Defined in: index.ts:210

Parameters
__namedParameters

QueryOptions

Returns

Query

Methods

search(query, __namedParameters): Promise<QueryResponse>

Defined in: index.ts:403

Search the graph for nodes and edges that match the given query.

Parameters
query

string

__namedParameters

SearchOptions

Returns

Promise<QueryResponse>

getQueryTokens()
static getQueryTokens(query): ParsedSelectorToken[]

Defined in: index.ts:469

Parses a query string in order to retrieve an array of tokens.

Parameters
query

string

Returns

ParsedSelectorToken[]

hasSecuritySelectors()
static hasSecuritySelectors(query): boolean

Defined in: index.ts:201

Helper method to determine if a given query string is using any of the known security selectors. This is useful so that operations can skip hydrating the security archive if it’s not needed.

Parameters
query

string

Returns

boolean

Type Aliases

GraphSelectionState

type GraphSelectionState = object

Defined in: types.ts:40

Type declaration

edges
edges: Set<EdgeLike>
nodes
nodes: Set<NodeLike>

Insights

type Insights = object

Defined in: types.ts:98

Type declaration

abandoned?
optional abandoned: boolean;
confused?
optional confused: boolean;
cve?
optional cve: `CVE-${string}`[];
cwe?
optional cwe: `CWE-${string}`[];
debug?
optional debug: boolean;
deprecated?
optional deprecated: boolean;
dynamic?
optional dynamic: boolean;
entropic?
optional entropic: boolean;
env?
optional env: boolean;
eval?
optional eval: boolean;
fs?
optional fs: boolean;
license?
optional license: LicenseInsights;
malware?
optional malware: MalwareInsights;
minified?
optional minified: boolean;
native?
optional native: boolean;
network?
optional network: boolean;
obfuscated?
optional obfuscated: boolean;
scanned
scanned: boolean
score?
optional score: PackageScore;
scripts?
optional scripts: boolean;
severity?
optional severity: SeverityInsights;
shell?
optional shell: boolean;
shrinkwrap?
optional shrinkwrap: boolean;
squat?
optional squat: SquatInsights;
suspicious?
optional suspicious: boolean;
tracker?
optional tracker: boolean;
trivial?
optional trivial: boolean;
undesirable?
optional undesirable: boolean;
unknown?
optional unknown: boolean;
unmaintained?
optional unmaintained: boolean;
unpopular?
optional unpopular: boolean;
unstable?
optional unstable: boolean;

LeveledInsights

type LeveledInsights = object

Defined in: types.ts:144

Type declaration

critical
critical: boolean
high
high: boolean
low
low: boolean
medium
medium: boolean

LicenseInsights

type LicenseInsights = object

Defined in: types.ts:133

Type declaration

ambiguous
ambiguous: boolean
copyleft
copyleft: boolean
exception
exception: boolean
misc
misc: boolean
none
none: boolean
restricted
restricted: boolean
unknown
unknown: boolean
unlicensed
unlicensed: boolean

MalwareInsights

type MalwareInsights = LeveledInsights

Defined in: types.ts:151


ParsedSelectorToken

type ParsedSelectorToken = PostcssNode & object

Defined in: types.ts:161

Type declaration

token
token: string

ParserFn()

type ParserFn = (opt) => Promise<ParserState>

Defined in: types.ts:159

Parameters

opt

ParserState

Returns

Promise<ParserState>


ParserState

type ParserState = object

Defined in: types.ts:45

Type declaration

cancellable()
cancellable: () => Promise<void>
Returns

Promise<void>

collect
collect: GraphSelectionState
current
current: PostcssNode
initial
initial: GraphSelectionState
loose?
optional loose: boolean;
next?
optional next: PostcssNode;
partial
partial: GraphSelectionState
prev?
optional prev: PostcssNode;
result?
optional result: NodeLike[];
retries
retries: number
scopeIDs?
optional scopeIDs: DepID[];
securityArchive
securityArchive:
| SecurityArchiveLike
| undefined;
signal
signal: AbortSignal
specOptions
specOptions: SpecOptions
walk
walk: ParserFn

PostcssNode

type PostcssNode =
| Tag
| String
| Selector
| Root
| Pseudo
| Nesting
| Identifier
| Comment
| Combinator
| ClassName
| Attribute
| Universal

Defined in: types.ts:24


PostcssNodeWithChildren

type PostcssNodeWithChildren = Selector | Root | Pseudo

Defined in: types.ts:38


QueryOptions

type QueryOptions = object

Defined in: index.ts:131

Type declaration

graph
graph: GraphLike
retries?
optional retries: number;
securityArchive
securityArchive:
| SecurityArchiveLike
| undefined;
specOptions
specOptions: SpecOptions

QueryResponse

type QueryResponse = object

Defined in: types.ts:63

Type declaration

edges
edges: QueryResponseEdge[];
nodes
nodes: QueryResponseNode[];

QueryResponseEdge

type QueryResponseEdge = Omit<EdgeLike, 'from' | 'to'> & object

Defined in: types.ts:68

Type declaration

from
from: QueryResponseNode
to?
optional to: QueryResponseNode;

QueryResponseNode

type QueryResponseNode = Omit<NodeLike, 'edgesIn' | 'edgesOut'> &
object

Defined in: types.ts:73

Type declaration

edgesIn
edgesIn: Set<QueryResponseEdge>
edgesOut
edgesOut: Map<string, QueryResponseEdge>
insights
insights: Insights
toJSON()
toJSON: () =>
Pick<
QueryResponseNode,
| 'id'
| 'name'
| 'version'
| 'location'
| 'importer'
| 'manifest'
| 'projectRoot'
| 'integrity'
| 'resolved'
| 'dev'
| 'optional'
| 'insights'
| 'confused'
>
Returns

Pick<QueryResponseNode, | "id" | "name" | "version" | "location" | "importer" | "manifest" | "projectRoot" | "integrity" | "resolved" | "dev" | "optional" | "insights" | "confused">


SearchOptions

type SearchOptions = object

Defined in: index.ts:33

Type declaration

scopeIDs?
optional scopeIDs: DepID[];
signal
signal: AbortSignal

SeverityInsights

type SeverityInsights = LeveledInsights

Defined in: types.ts:152


SquatInsights

type SquatInsights = object

Defined in: types.ts:154

Type declaration

critical
critical: boolean
medium
medium: boolean

Functions

asAttributeNode()

function asAttributeNode(node?): Attribute

Defined in: types.ts:191

Parameters

node?

PostcssNode

Returns

Attribute


asCombinatorNode()

function asCombinatorNode(node?): Combinator

Defined in: types.ts:208

Parameters

node?

PostcssNode

Returns

Combinator


asIdentifierNode()

function asIdentifierNode(node?): Identifier

Defined in: types.ts:225

Parameters

node?

PostcssNode

Returns

Identifier


asPostcssNodeWithChildren()

function asPostcssNodeWithChildren(node?): PostcssNodeWithChildren

Defined in: types.ts:170

Parameters

node?

PostcssNode

Returns

PostcssNodeWithChildren


asPseudoNode()

function asPseudoNode(node?): Pseudo

Defined in: types.ts:259

Parameters

node?

PostcssNode

Returns

Pseudo


asSelectorNode()

function asSelectorNode(node?): Selector

Defined in: types.ts:242

Parameters

node?

PostcssNode

Returns

Selector


asStringNode()

function asStringNode(node?): String

Defined in: types.ts:294

Parameters

node?

PostcssNode

Returns

String


asTagNode()

function asTagNode(node?): Tag

Defined in: types.ts:276

Parameters

node?

PostcssNode

Returns

Tag


isAttributeNode()

function isAttributeNode(node): node is Attribute

Defined in: types.ts:188

Parameters

node

unknown

Returns

node is Attribute


isCombinatorNode()

function isCombinatorNode(node): node is Combinator

Defined in: types.ts:205

Parameters

node

unknown

Returns

node is Combinator


isIdentifierNode()

function isIdentifierNode(node): node is Identifier

Defined in: types.ts:222

Parameters

node

any

Returns

node is Identifier


isPostcssNodeWithChildren()

function isPostcssNodeWithChildren(
node,
): node is PostcssNodeWithChildren

Defined in: types.ts:165

Parameters

node

any

Returns

node is PostcssNodeWithChildren


isPseudoNode()

function isPseudoNode(node): node is Pseudo

Defined in: types.ts:256

Parameters

node

unknown

Returns

node is Pseudo


isSelectorNode()

function isSelectorNode(node): node is Selector

Defined in: types.ts:239

Parameters

node

any

Returns

node is Selector


isStringNode()

function isStringNode(node): node is String

Defined in: types.ts:291

Parameters

node

unknown

Returns

node is String


isTagNode()

function isTagNode(node): node is Tag

Defined in: types.ts:273

Parameters

node

unknown

Returns

node is Tag


walk()

function walk(state): Promise<ParserState>

Defined in: index.ts:73

Parameters

state

ParserState

Returns

Promise<ParserState>