Reference
Classes
Query
Defined in: index.ts:239
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:295
Parameters
| Parameter | Type |
|---|---|
__namedParameters | QueryOptions |
Returns
Methods
search()
search(query, __namedParameters): Promise<QueryResponse>Defined in: index.ts:503
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:603
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:257
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:272
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
HasSkills()
type HasSkills = (node) => Promise<boolean>;Defined in: types.ts:53
Whether an installed package ships agent skills; for :skills.
Keeps fs out of this package.
Parameters
| Parameter | Type |
|---|---|
node | NodeLike |
Returns
Promise<boolean>
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:140
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:187
Type declaration
| Name | Type |
|---|---|
critical | boolean |
high | boolean |
low | boolean |
medium | boolean |
LicenseInsights
type LicenseInsights = object;Defined in: types.ts:176
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:204
Type declaration
| Name | Type |
|---|---|
token | string |
ParserFn()
type ParserFn = (opt) => Promise<ParserState>;Defined in: types.ts:202
Parameters
| Parameter | Type |
|---|---|
opt | ParserState |
Returns
Promise<ParserState>
ParserState
type ParserState = object;Defined in: types.ts:67
Type declaration
| Name | Type | Description |
|---|---|---|
cancellable | () => Promise<void> | - |
collect | GraphSelectionState | - |
comment | string | - |
current | PostcssNode | - |
diffFiles? | DiffFilesProvider | - |
getAuthHeader? | GetAuthHeader | - |
hasSkills? | HasSkills | - |
hostContexts? | HostContextsMap | - |
importers | Set<NodeLike> | - |
initial | GraphSelectionState | - |
loose? | boolean | - |
next? | PostcssNode | - |
part? | Pick<QueryPart, "name" | "patterns"> | set by :skill(), read and cleared by walk() |
partial | GraphSelectionState | - |
parts? | QueryPart<NodeLike>[] | one entry per top-level selector, only when opted in |
partSelectors? | ReadonlySet<PartPseudoName> | part selectors this consumer allows |
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:172
Type declaration
| Name | Type | Description |
|---|---|---|
diffFiles? | DiffFilesProvider | - |
edges | Set<EdgeLike> | - |
getAuthHeader? | GetAuthHeader | - |
hasSkills? | HasSkills | for :skills; unset: :skills throws |
hostContexts? | HostContextsMap | - |
importers | Set<NodeLike> | - |
nodes | Set<NodeLike> | - |
partSelectors? | readonly PartPseudoName[] | part selectors to allow, e.g. ['skill']; others throw |
retries? | number | - |
securityArchive | | SecurityArchiveLike | undefined | - |
QueryPart<N>
type QueryPart<N> = object;Defined in: types.ts:60
One top-level selector of a query and the nodes it matched. name
and patterns are set when it ends in a part selector, e.g.
#a:skill(x, y*).
Type Parameters
| Type Parameter | Default type |
|---|---|
N | QueryResponseNode |
Type declaration
| Name | Type | Description |
|---|---|---|
name? | PartPseudoName | - |
nodes | N[] | - |
patterns? | string[] | as typed, * = glob; for matching only, never paths |
QueryResponse
type QueryResponse = object;Defined in: types.ts:97
Type declaration
| Name | Type | Description |
|---|---|---|
comment | string | - |
edges | QueryResponseEdge[] | - |
importers | QueryResponseNode[] | - |
nodes | QueryResponseNode[] | - |
parts? | QueryPart[] | one entry per top-level selector, only with partSelectors and a non-empty query |
specificity | Specificity | - |
QueryResponseEdge
type QueryResponseEdge = Omit<EdgeLike, "from" | "to"> & object;Defined in: types.ts:110
Type declaration
| Name | Type |
|---|---|
from | QueryResponseNode |
to? | QueryResponseNode |
QueryResponseNode
type QueryResponseNode = Omit<NodeLike, "edgesIn" | "edgesOut"> & object;Defined in: types.ts:115
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:41
Type declaration
| Name | Type |
|---|---|
scopeIDs? | DepID[] |
signal | AbortSignal |
SeverityInsights
type SeverityInsights = LeveledInsights;Defined in: types.ts:194
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:197
Type declaration
| Name | Type |
|---|---|
critical | boolean |
medium | boolean |
VulnInsights
type VulnInsights = LeveledInsights;Defined in: types.ts:195
Functions
walk()
function walk(state): Promise<ParserState>Defined in: index.ts:109
Parameters
| Parameter | Type |
|---|---|
state | ParserState |
Returns
Promise<ParserState>