---
title: "@vltpkg/query: Reference — vlt docs"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/api-reference/query/reference"
image: "https://docs.vlt.io/og/client/api-reference/query/reference"
lang: "en"
---

# Reference

## Classes

### Query

Defined in: index.ts:240

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

#### Constructors

##### new Query()

```ts
new Query(__namedParameters): Query
```

Defined in: index.ts:296

###### Parameters

| Parameter           | Type                                                                                       |
| ------------------- | ------------------------------------------------------------------------------------------ |
| `__namedParameters` | [`QueryOptions`](https://docs.vlt.io/client/api-reference/query/reference.md#queryoptions) |

###### Returns

[`Query`](https://docs.vlt.io/client/api-reference/query/reference.md#query)

#### Methods

##### search()

```ts
search(query, __namedParameters): Promise<QueryResponse>
```

Defined in: index.ts:504

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

###### Parameters

| Parameter           | Type                                                                                         |
| ------------------- | -------------------------------------------------------------------------------------------- |
| `query`             | `string`                                                                                     |
| `__namedParameters` | [`SearchOptions`](https://docs.vlt.io/client/api-reference/query/reference.md#searchoptions) |

###### Returns

`Promise`<[`QueryResponse`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponse)>

##### getQueryTokens()

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

Defined in: index.ts:604

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

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `query`   | `string` |

###### Returns

[`ParsedSelectorToken`](https://docs.vlt.io/client/api-reference/query/reference.md#parsedselectortoken)\[]

##### hasSecuritySelectors()

```ts
static hasSecuritySelectors(query): boolean
```

Defined in: index.ts:258

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

```ts
static specificitySort(responses): QueryResponse[]
```

Defined in: index.ts:273

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`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponse)\[] |

###### Returns

[`QueryResponse`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponse)\[]

## Type Aliases

### DiffFilesProvider()

```ts
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()

```ts
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

```ts
type GraphSelectionState = object;
```

Defined in: types.ts:27

#### Type declaration

| Name    | Type                                                                                      |
| ------- | ----------------------------------------------------------------------------------------- |
| `edges` | `Set`<[`EdgeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#edgelike)> |
| `nodes` | `Set`<[`NodeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike)> |

---

### HasSkills()

```ts
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`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike) |

#### Returns

`Promise`<`boolean`>

---

### HostContextsMap

```ts
type HostContextsMap = Map<string, () => Promise<HostContextsMapResult>>;
```

Defined in: types.ts:17

---

### HostContextsMapResult

```ts
type HostContextsMapResult = object;
```

Defined in: types.ts:9

#### Type declaration

| Name              | Type                                                                                                                                     |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `edges`           | [`EdgeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#edgelike)\[]                                                    |
| `initialEdges`    | [`EdgeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#edgelike)\[]                                                    |
| `initialNodes`    | [`NodeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike)\[]                                                    |
| `nodes`           | [`NodeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike)\[]                                                    |
| `securityArchive` | \| [`SecurityArchiveLike`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchivelike) \| `undefined` |

---

### Insights

```ts
type Insights = object;
```

Defined in: types.ts:145

#### 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`](https://docs.vlt.io/client/api-reference/query/reference.md#licenseinsights)         |
| `malware`?      | `boolean`                                                                                                |
| `minified`?     | `boolean`                                                                                                |
| `native`?       | `boolean`                                                                                                |
| `network`?      | `boolean`                                                                                                |
| `obfuscated`?   | `boolean`                                                                                                |
| `scanned`       | `boolean`                                                                                                |
| `score`?        | [`PackageScore`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#packagescore) |
| `scripts`?      | `boolean`                                                                                                |
| `severity`?     | [`SeverityInsights`](https://docs.vlt.io/client/api-reference/query/reference.md#severityinsights)       |
| `shell`?        | `boolean`                                                                                                |
| `shrinkwrap`?   | `boolean`                                                                                                |
| `squat`?        | [`SquatInsights`](https://docs.vlt.io/client/api-reference/query/reference.md#squatinsights)             |
| `suspicious`?   | `boolean`                                                                                                |
| `tracker`?      | `boolean`                                                                                                |
| `trivial`?      | `boolean`                                                                                                |
| `undesirable`?  | `boolean`                                                                                                |
| `unknown`?      | `boolean`                                                                                                |
| `unmaintained`? | `boolean`                                                                                                |
| `unpopular`?    | `boolean`                                                                                                |
| `unstable`?     | `boolean`                                                                                                |
| `vuln`?         | [`VulnInsights`](https://docs.vlt.io/client/api-reference/query/reference.md#vulninsights)               |

---

### LeveledInsights

```ts
type LeveledInsights = object;
```

Defined in: types.ts:192

#### Type declaration

| Name       | Type      |
| ---------- | --------- |
| `critical` | `boolean` |
| `high`     | `boolean` |
| `low`      | `boolean` |
| `medium`   | `boolean` |

---

### LicenseInsights

```ts
type LicenseInsights = object;
```

Defined in: types.ts:181

#### Type declaration

| Name         | Type      |
| ------------ | --------- |
| `ambiguous`  | `boolean` |
| `copyleft`   | `boolean` |
| `exception`  | `boolean` |
| `misc`       | `boolean` |
| `none`       | `boolean` |
| `restricted` | `boolean` |
| `unknown`    | `boolean` |
| `unlicensed` | `boolean` |

---

### ParsedSelectorToken

```ts
type ParsedSelectorToken = PostcssNode & object;
```

Defined in: types.ts:209

#### Type declaration

| Name    | Type     |
| ------- | -------- |
| `token` | `string` |

---

### ParserFn()

```ts
type ParserFn = (opt) => Promise<ParserState>;
```

Defined in: types.ts:207

#### Parameters

| Parameter | Type                                                                                     |
| --------- | ---------------------------------------------------------------------------------------- |
| `opt`     | [`ParserState`](https://docs.vlt.io/client/api-reference/query/reference.md#parserstate) |

#### Returns

`Promise`<[`ParserState`](https://docs.vlt.io/client/api-reference/query/reference.md#parserstate)>

---

### ParserState

```ts
type ParserState = object;
```

Defined in: types.ts:67

#### Type declaration

| Name              | Type                                                                                                                                                                         | Description                                                                                     |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `cancellable`     | () => `Promise`<`void`>                                                                                                                                                      | -                                                                                               |
| `collect`         | [`GraphSelectionState`](https://docs.vlt.io/client/api-reference/query/reference.md#graphselectionstate)                                                                     | -                                                                                               |
| `comment`         | `string`                                                                                                                                                                     | -                                                                                               |
| `current`         | [`PostcssNode`](https://docs.vlt.io/client/api-reference/dss-parser/reference.md#postcssnode)                                                                                | -                                                                                               |
| `diffFiles`?      | [`DiffFilesProvider`](https://docs.vlt.io/client/api-reference/query/reference.md#difffilesprovider)                                                                         | -                                                                                               |
| `getAuthHeader`?  | [`GetAuthHeader`](https://docs.vlt.io/client/api-reference/query/reference.md#getauthheader)                                                                                 | -                                                                                               |
| `hasSkills`?      | [`HasSkills`](https://docs.vlt.io/client/api-reference/query/reference.md#hasskills)                                                                                         | -                                                                                               |
| `hostContexts`?   | [`HostContextsMap`](https://docs.vlt.io/client/api-reference/query/reference.md#hostcontextsmap)                                                                             | -                                                                                               |
| `importers`       | `Set`<[`NodeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike)>                                                                                    | -                                                                                               |
| `initial`         | [`GraphSelectionState`](https://docs.vlt.io/client/api-reference/query/reference.md#graphselectionstate)                                                                     | -                                                                                               |
| `invalid`?        | `boolean`                                                                                                                                                                    | set once loose mode ignores an invalid part of the selector being walked, see `ignoreInvalid()` |
| `loose`?          | `boolean`                                                                                                                                                                    | -                                                                                               |
| `next`?           | [`PostcssNode`](https://docs.vlt.io/client/api-reference/dss-parser/reference.md#postcssnode)                                                                                | -                                                                                               |
| `part`?           | `Pick`<[`QueryPart`](https://docs.vlt.io/client/api-reference/query/reference.md#querypartn), `"name"` \| `"patterns"`>                                                      | set by `:skill()`, read and cleared by `walk()`                                                 |
| `partial`         | [`GraphSelectionState`](https://docs.vlt.io/client/api-reference/query/reference.md#graphselectionstate)                                                                     | -                                                                                               |
| `parts`?          | [`QueryPart`](https://docs.vlt.io/client/api-reference/query/reference.md#querypartn)<[`NodeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike)>\[] | one entry per top-level selector, only when opted in                                            |
| `partSelectors`?  | `ReadonlySet`<[`PartPseudoName`](https://docs.vlt.io/client/api-reference/dss-parser/reference.md#partpseudoname)>                                                           | part selectors this consumer allows                                                             |
| `prev`?           | [`PostcssNode`](https://docs.vlt.io/client/api-reference/dss-parser/reference.md#postcssnode)                                                                                | -                                                                                               |
| `result`?         | [`NodeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike)\[]                                                                                        | -                                                                                               |
| `retries`         | `number`                                                                                                                                                                     | -                                                                                               |
| `scopeIDs`?       | [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid)\[]                                                                                               | -                                                                                               |
| `securityArchive` | \| [`SecurityArchiveLike`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchivelike) \| `undefined`                                     | -                                                                                               |
| `signal`          | `AbortSignal`                                                                                                                                                                | -                                                                                               |
| `specificity`     | [`Specificity`](https://docs.vlt.io/client/api-reference/query/reference.md#specificity-2)                                                                                   | -                                                                                               |
| `walk`            | [`ParserFn`](https://docs.vlt.io/client/api-reference/query/reference.md#parserfn)                                                                                           | -                                                                                               |

---

### QueryOptions

```ts
type QueryOptions = object;
```

Defined in: index.ts:173

#### Type declaration

| Name              | Type                                                                                                                                     | Description                                             |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| `diffFiles`?      | [`DiffFilesProvider`](https://docs.vlt.io/client/api-reference/query/reference.md#difffilesprovider)                                     | -                                                       |
| `edges`           | `Set`<[`EdgeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#edgelike)>                                                | -                                                       |
| `getAuthHeader`?  | [`GetAuthHeader`](https://docs.vlt.io/client/api-reference/query/reference.md#getauthheader)                                             | -                                                       |
| `hasSkills`?      | [`HasSkills`](https://docs.vlt.io/client/api-reference/query/reference.md#hasskills)                                                     | for `:skills`; unset: `:skills` throws                  |
| `hostContexts`?   | [`HostContextsMap`](https://docs.vlt.io/client/api-reference/query/reference.md#hostcontextsmap)                                         | -                                                       |
| `importers`       | `Set`<[`NodeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike)>                                                | -                                                       |
| `nodes`           | `Set`<[`NodeLike`](https://docs.vlt.io/client/api-reference/types/reference.md#nodelike)>                                                | -                                                       |
| `partSelectors`?  | readonly [`PartPseudoName`](https://docs.vlt.io/client/api-reference/dss-parser/reference.md#partpseudoname)\[]                          | part selectors to allow, e.g. `['skill']`; others throw |
| `retries`?        | `number`                                                                                                                                 | -                                                       |
| `securityArchive` | \| [`SecurityArchiveLike`](https://docs.vlt.io/client/api-reference/security-archive/module_index.md#securityarchivelike) \| `undefined` | -                                                       |

---

### QueryPart\<N>

```ts
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`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponsenode) |

#### Type declaration

| Name        | Type                                                                                                | Description                                          |
| ----------- | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `name`?     | [`PartPseudoName`](https://docs.vlt.io/client/api-reference/dss-parser/reference.md#partpseudoname) | -                                                    |
| `nodes`     | `N`\[]                                                                                              | -                                                    |
| `patterns`? | `string`\[]                                                                                         | as typed, `*` = glob; for matching only, never paths |

---

### QueryResponse

```ts
type QueryResponse = object;
```

Defined in: types.ts:102

#### Type declaration

| Name          | Type                                                                                                    | Description                                                                       |
| ------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `comment`     | `string`                                                                                                | -                                                                                 |
| `edges`       | [`QueryResponseEdge`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponseedge)\[] | -                                                                                 |
| `importers`   | [`QueryResponseNode`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponsenode)\[] | -                                                                                 |
| `nodes`       | [`QueryResponseNode`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponsenode)\[] | -                                                                                 |
| `parts`?      | [`QueryPart`](https://docs.vlt.io/client/api-reference/query/reference.md#querypartn)\[]                | one entry per top-level selector, only with `partSelectors` and a non-empty query |
| `specificity` | [`Specificity`](https://docs.vlt.io/client/api-reference/query/reference.md#specificity-2)              | -                                                                                 |

---

### QueryResponseEdge

```ts
type QueryResponseEdge = Omit<EdgeLike, "from" | "to"> & object;
```

Defined in: types.ts:115

#### Type declaration

| Name   | Type                                                                                                 |
| ------ | ---------------------------------------------------------------------------------------------------- |
| `from` | [`QueryResponseNode`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponsenode) |
| `to`?  | [`QueryResponseNode`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponsenode) |

---

### QueryResponseNode

```ts
type QueryResponseNode = Omit<NodeLike, "edgesIn" | "edgesOut"> & object;
```

Defined in: types.ts:120

#### Type declaration

| Name       | Type                                                                                                                                                                                                                                                                                                                    |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `edgesIn`  | `Set`<[`QueryResponseEdge`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponseedge)>                                                                                                                                                                                                             |
| `edgesOut` | `Map`<`string`, [`QueryResponseEdge`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponseedge)>                                                                                                                                                                                                   |
| `insights` | [`Insights`](https://docs.vlt.io/client/api-reference/query/reference.md#insights)                                                                                                                                                                                                                                      |
| `toJSON`   | () => `Pick`<[`QueryResponseNode`](https://docs.vlt.io/client/api-reference/query/reference.md#queryresponsenode), \| `"id"` \| `"name"` \| `"version"` \| `"location"` \| `"importer"` \| `"manifest"` \| `"projectRoot"` \| `"integrity"` \| `"resolved"` \| `"dev"` \| `"optional"` \| `"insights"` \| `"confused"`> |

---

### SearchOptions

```ts
type SearchOptions = object;
```

Defined in: index.ts:42

#### Type declaration

| Name        | Type                                                                           |
| ----------- | ------------------------------------------------------------------------------ |
| `scopeIDs`? | [`DepID`](https://docs.vlt.io/client/api-reference/dep-id/browser.md#depid)\[] |
| `signal`    | `AbortSignal`                                                                  |

---

### SeverityInsights

```ts
type SeverityInsights = LeveledInsights;
```

Defined in: types.ts:199

---

### Specificity

```ts
type Specificity = object;
```

Defined in: types.ts:22

#### Type declaration

| Name            | Type     |
| --------------- | -------- |
| `commonCounter` | `number` |
| `idCounter`     | `number` |

---

### SquatInsights

```ts
type SquatInsights = object;
```

Defined in: types.ts:202

#### Type declaration

| Name       | Type      |
| ---------- | --------- |
| `critical` | `boolean` |
| `medium`   | `boolean` |

---

### VulnInsights

```ts
type VulnInsights = LeveledInsights;
```

Defined in: types.ts:200

## Functions

### walk()

```ts
function walk(state): Promise<ParserState>
```

Defined in: index.ts:110

#### Parameters

| Parameter | Type                                                                                     |
| --------- | ---------------------------------------------------------------------------------------- |
| `state`   | [`ParserState`](https://docs.vlt.io/client/api-reference/query/reference.md#parserstate) |

#### Returns

`Promise`<[`ParserState`](https://docs.vlt.io/client/api-reference/query/reference.md#parserstate)>
