Reference
Classes
Query
Defined in: index.ts:222
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): QueryDefined in: index.ts:276
Parameters
| Parameter | Type |
|---|---|
__namedParameters | QueryOptions |
Returns
Methods
search()
search(query, __namedParameters): Promise<QueryResponse>Defined in: index.ts:480
Search the graph for nodes and edges that match the given query.
Parameters
| Parameter | Type |
|---|---|
query | string |
__namedParameters | SearchOptions |
Returns
Promise<QueryResponse>
getQueryTokens()
static getQueryTokens(query): ParsedSelectorToken[]Defined in: index.ts:573
Parses a query string in order to retrieve an array of tokens.
Parameters
| Parameter | Type |
|---|---|
query | string |
Returns
hasSecuritySelectors()
static hasSecuritySelectors(query): booleanDefined in: index.ts:238
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
| Parameter | Type |
|---|---|
query | string |
Returns
boolean
specificitySort()
static specificitySort(responses): QueryResponse[]Defined in: index.ts:253
Sorts an array of QueryResponse objects by specificity. Objects with higher idCounter values come first, if idCounter values are equal, then objects with higher commonCounter values come first. Otherwise, the original order is preserved.
Parameters
| Parameter | Type |
|---|---|
responses | QueryResponse[] |
Returns
Type Aliases
DiffFilesProvider()
type DiffFilesProvider = (commitish) => Set<string>;Defined in: types.ts:37
Callback that returns changed file paths for a given commitish reference. Used by the :diff() pseudo selector. The returned paths should be relative to the project root.
Parameters
| Parameter | Type |
|---|---|
commitish | string |
Returns
Set<string>
GetAuthHeader()
type GetAuthHeader = (url) => Promise<string | undefined>;Defined in: types.ts:45
Callback that returns the authorization header value to use when
fetching data from a registry URL, e.g. by the :outdated() pseudo
selector. Keeps the browser-safe query package free of any direct
keychain / registry-client dependency.
Parameters
| Parameter | Type |
|---|---|
url | string |
Returns
Promise<string | undefined>
GraphSelectionState
type GraphSelectionState = object;Defined in: types.ts:27
Type declaration
HostContextsMap
type HostContextsMap = Map<string, () => Promise<HostContextsMapResult>>;Defined in: types.ts:17
HostContextsMapResult
type HostContextsMapResult = object;Defined in: types.ts:9
Type declaration
| Name | Type |
|---|---|
edges | EdgeLike[] |
initialEdges | EdgeLike[] |
initialNodes | NodeLike[] |
nodes | NodeLike[] |
securityArchive | | SecurityArchiveLike | undefined |
Insights
type Insights = object;Defined in: types.ts:110
Type declaration
| Name | Type |
|---|---|
abandoned? | boolean |
confused? | boolean |
cve? | `CVE-${string}`[] |
cwe? | `CWE-${string}`[] |
debug? | boolean |
deprecated? | boolean |
dynamic? | boolean |
entropic? | boolean |
env? | boolean |
eval? | boolean |
fs? | boolean |
license? | LicenseInsights |
malware? | boolean |
minified? | boolean |
native? | boolean |
network? | boolean |
obfuscated? | boolean |
scanned | boolean |
score? | PackageScore |
scripts? | boolean |
severity? | SeverityInsights |
shell? | boolean |
shrinkwrap? | boolean |
squat? | SquatInsights |
suspicious? | boolean |
tracker? | boolean |
trivial? | boolean |
undesirable? | boolean |
unknown? | boolean |
unmaintained? | boolean |
unpopular? | boolean |
unstable? | boolean |
vuln? | VulnInsights |
LeveledInsights
type LeveledInsights = object;Defined in: types.ts:157
Type declaration
| Name | Type |
|---|---|
critical | boolean |
high | boolean |
low | boolean |
medium | boolean |
LicenseInsights
type LicenseInsights = object;Defined in: types.ts:146
Type declaration
| Name | Type |
|---|---|
ambiguous | boolean |
copyleft | boolean |
exception | boolean |
misc | boolean |
none | boolean |
restricted | boolean |
unknown | boolean |
unlicensed | boolean |
ParsedSelectorToken
type ParsedSelectorToken = PostcssNode & object;Defined in: types.ts:174
Type declaration
| Name | Type |
|---|---|
token | string |
ParserFn()
type ParserFn = (opt) => Promise<ParserState>;Defined in: types.ts:172
Parameters
| Parameter | Type |
|---|---|
opt | ParserState |
Returns
Promise<ParserState>
ParserState
type ParserState = object;Defined in: types.ts:49
Type declaration
| Name | Type |
|---|---|
cancellable | () => Promise<void> |
collect | GraphSelectionState |
comment | string |
current | PostcssNode |
diffFiles? | DiffFilesProvider |
getAuthHeader? | GetAuthHeader |
hostContexts? | HostContextsMap |
importers | Set<NodeLike> |
initial | GraphSelectionState |
loose? | boolean |
next? | PostcssNode |
partial | GraphSelectionState |
prev? | PostcssNode |
result? | NodeLike[] |
retries | number |
scopeIDs? | DepID[] |
securityArchive | | SecurityArchiveLike | undefined |
signal | AbortSignal |
specificity | Specificity |
walk | ParserFn |
QueryOptions
type QueryOptions = object;Defined in: index.ts:159
Type declaration
| Name | Type |
|---|---|
diffFiles? | DiffFilesProvider |
edges | Set<EdgeLike> |
getAuthHeader? | GetAuthHeader |
hostContexts? | HostContextsMap |
importers | Set<NodeLike> |
nodes | Set<NodeLike> |
retries? | number |
securityArchive | | SecurityArchiveLike | undefined |
QueryResponse
type QueryResponse = object;Defined in: types.ts:72
Type declaration
| Name | Type |
|---|---|
comment | string |
edges | QueryResponseEdge[] |
importers | QueryResponseNode[] |
nodes | QueryResponseNode[] |
specificity | Specificity |
QueryResponseEdge
type QueryResponseEdge = Omit<EdgeLike, "from" | "to"> & object;Defined in: types.ts:80
Type declaration
| Name | Type |
|---|---|
from | QueryResponseNode |
to? | QueryResponseNode |
QueryResponseNode
type QueryResponseNode = Omit<NodeLike, "edgesIn" | "edgesOut"> & object;Defined in: types.ts:85
Type declaration
| Name | Type |
|---|---|
edgesIn | Set<QueryResponseEdge> |
edgesOut | Map<string, QueryResponseEdge> |
insights | Insights |
toJSON | () => Pick<QueryResponseNode, | "id" | "name" | "version" | "location" | "importer" | "manifest" | "projectRoot" | "integrity" | "resolved" | "dev" | "optional" | "insights" | "confused"> |
SearchOptions
type SearchOptions = object;Defined in: index.ts:37
Type declaration
| Name | Type |
|---|---|
scopeIDs? | DepID[] |
signal | AbortSignal |
SeverityInsights
type SeverityInsights = LeveledInsights;Defined in: types.ts:164
Specificity
type Specificity = object;Defined in: types.ts:22
Type declaration
| Name | Type |
|---|---|
commonCounter | number |
idCounter | number |
SquatInsights
type SquatInsights = object;Defined in: types.ts:167
Type declaration
| Name | Type |
|---|---|
critical | boolean |
medium | boolean |
VulnInsights
type VulnInsights = LeveledInsights;Defined in: types.ts:165
Functions
walk()
function walk(state): Promise<ParserState>Defined in: index.ts:103
Parameters
| Parameter | Type |
|---|---|
state | ParserState |
Returns
Promise<ParserState>