# @salmonui/data/json API reference

> 88 exported symbols of @salmonui/data/json: 22 functions, 5 classes, 44 interfaces, 16 types and 1 constant.

Canonical: https://salmonui.dev/docs/reference/data/json

```ts
import { … } from '@salmonui/data/json';
```

## Functions

### createBatchingFetchTransport

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/createBatchingFetchTransport

```ts
function createBatchingFetchTransport(options: FetchTransportOptions & {
    readonly maxBatch?: number;
}): UniversalJsonTransport;
```

Batching HTTP transport: same-tick requests share one POST.

### createBatchingTransport

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/createBatchingTransport

```ts
function createBatchingTransport(send: (batch: WireBatchRequest, ctx: TransportContext) => Promise<WireBatchResponse>, options?: {
    readonly maxBatch?: number;
}): UniversalJsonTransport;
```

Multiplexes every request issued in the same tick into one
`{ v: 1, batch: [...] }` call (lazy group children, facets, prefetch).
A consumer that aborts is rejected immediately; the shared call is aborted
only when every consumer in it has aborted.

### createFetchTransport

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/createFetchTransport

```ts
function createFetchTransport(options: FetchTransportOptions): UniversalJsonTransport;
```

One HTTP request per protocol request.

### createJsonDataSource

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/createJsonDataSource

```ts
function createJsonDataSource<Row = readonly unknown[]>(options: JsonDataSourceOptions): JsonDataSource<Row>;
```

### createJsonPivotSource

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/createJsonPivotSource

```ts
function createJsonPivotSource(options: JsonPivotSourceOptions): JsonPivotSource;
```

Remote pivot source over the Salmon UI JSON protocol.

### decodeTuples

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/decodeTuples

```ts
function decodeTuples(rows: readonly WireTuple[], fields: readonly string[], expected: readonly string[] | null, dict: Readonly<Record<string, readonly string[]>> | undefined): unknown[][];
```

Brings response tuples into the client's field order and expands
dictionary-encoded cells. Works in place on the freshly parsed arrays: when
the server already used the requested order and no dictionary, this is a
no-op (no per-row work at all). Returns the tuples.

### encodeRows

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/encodeRows

```ts
function encodeRows(rows: readonly unknown[], options: EncodeRowsOptions): {
    rows: unknown[][];
    dict?: Record<string, string[]>;
};
```

Encodes object rows as tuples (+ dictionaries); dates become epoch ms.

### fieldIndex

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/fieldIndex

```ts
function fieldIndex(fields: readonly string[]): ReadonlyMap<string, number>;
```

Index of each field in the tuple header.

### isRetryableError

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/isRetryableError

```ts
function isRetryableError(error: unknown): boolean;
```

Default retry predicate: network failures, 408, 429, and 5xx. Never aborts, 4xx, or protocol errors.

### isWirePivotRequest

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/isWirePivotRequest

```ts
function isWirePivotRequest(request: WireAnyRequest): request is WirePivotRequest;
```

### isWireWriteRequest

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/isWireWriteRequest

```ts
function isWireWriteRequest(request: WireAnyRequest): request is WireWriteRequest;
```

### normalizeFilterOperator

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/normalizeFilterOperator

```ts
function normalizeFilterOperator(name: string): FilterOperator | null;
```

Canonical built-in operator name, or null for a custom operator (sent verbatim).

### objectToTuple

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/objectToTuple

```ts
function objectToTuple(row: unknown, fields: readonly string[]): unknown[];
```

Inverse of `tuplesToObjects` for one row (writes).

### serializeDataGridQuery

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/serializeDataGridQuery

```ts
function serializeDataGridQuery(query: DataQuery): string;
```

Deterministic query serialization; identical to `serializeDataGridQuery` of `@salmonui/data-grid/engine`.

### structuralQueryKey

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/structuralQueryKey

```ts
function structuralQueryKey(query: DataQuery): string;
```

Query identity without paging and expansion: cursor chains and infinite blocks are cached under it.

### toWherePredicate

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/toWherePredicate

```ts
function toWherePredicate(filters: readonly FilterEntry[], fieldOf?: (id: string) => string): WirePredicate | undefined;
```

Top level: conditions on the same column fold left to right by their
`predicate`; columns and groups are ANDed (Data Grid engine filter semantics).

### toWirePivotModel

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/toWirePivotModel

```ts
function toWirePivotModel(model: WirePivotModel): WirePivotModel;
```

The model as it travels: rejects client-only aggregators, drops formats and
conditional formats, omits defaults. Throws `ProtocolError` with code
`pivot/unsupported-aggregate` for a value field whose aggregate is
`custom` or a function.

### toWireQuery

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/toWireQuery

```ts
function toWireQuery(query: DataQuery, options?: WireQueryOptions): WireQuery;
```

DataQuery to wire query. Paging is supplied by the caller (offset, cursor, or block).

### tupleColumns

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/tupleColumns

```ts
function tupleColumns<Def extends TupleColumnDefLike>(defs: readonly Def[], fields: readonly string[]): (Def & TupleColumnHooks)[];
```

Returns column definitions whose `field` reads a tuple slot: `valueGetter`
is `row => row[i]` and `valueSetter` copies the tuple once. The `id`
defaults to the field so column identity does not change. Definitions
without a known field are returned unchanged; group headers recurse.

### tupleRowId

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/tupleRowId

```ts
function tupleRowId(fields: readonly string[], key: string): (row: TupleRow) => RowId;
```

`getRowId` for tuple rows: the key slot as a string.

### tuplesToObjects

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/tuplesToObjects

```ts
function tuplesToObjects<Row>(rows: readonly WireTuple[], fields: readonly string[]): Row[];
```

Materializes tuples as objects (object row mode). One allocation per row.

### wirePivotModelKey

Kind: function

Page: https://salmonui.dev/docs/reference/data/json/wirePivotModelKey

```ts
function wirePivotModelKey(model: WirePivotModel): string;
```

Canonical JSON of the wire model: equal models give equal bodies and cache keys.

## Classes

### CursorUnknownError

Kind: class

Page: https://salmonui.dev/docs/reference/data/json/CursorUnknownError

```ts
class CursorUnknownError extends Error {
    readonly name = "CursorUnknownError";
    readonly reason = "cursorUnknown";
    constructor(page: number);
}
```

The cursor of the requested page is not known (jump without walking the chain).

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `name` | `readonly name = "CursorUnknownError";` |  |  |
| `reason` | `readonly reason = "cursorUnknown";` |  |  |

### HttpError

Kind: class

Page: https://salmonui.dev/docs/reference/data/json/HttpError

```ts
class HttpError extends Error {
    readonly name = "HttpError";
    readonly status: number;
    readonly body: string;
    constructor(status: number, statusText: string, body: string);
}
```

Non-2xx HTTP response. 4xx are not retried by default.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `name` | `readonly name = "HttpError";` |  |  |
| `status` | `readonly status: number;` |  |  |
| `body` | `readonly body: string;` |  |  |

### ProtocolError

Kind: class

Page: https://salmonui.dev/docs/reference/data/json/ProtocolError

```ts
class ProtocolError extends Error {
    readonly name = "ProtocolError";
    readonly code: string;
    constructor(code: string, message: string);
}
```

`error` member of a protocol response.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `name` | `readonly name = "ProtocolError";` |  |  |
| `code` | `readonly code: string;` |  |  |

### RequestCanceledError

Kind: class

Page: https://salmonui.dev/docs/reference/data/json/RequestCanceledError

```ts
class RequestCanceledError extends Error {
    readonly name = "RequestCanceledError";
}
```

`onRequest` returned false.

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `name` | `readonly name = "RequestCanceledError";` |  |  |

### StaleResponseError

Kind: class

Page: https://salmonui.dev/docs/reference/data/json/StaleResponseError

```ts
class StaleResponseError extends Error {
    readonly name = "StaleResponseError";
    readonly version: number;
    constructor(version: number, applied: number);
}
```

A response arrived for a version older than one already applied on the same channel.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `name` | `readonly name = "StaleResponseError";` |  |  |
| `version` | `readonly version: number;` |  |  |

## Interfaces

### EncodeRowsOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/EncodeRowsOptions

```ts
interface EncodeRowsOptions {
    readonly fields: readonly string[];
    readonly types?: readonly WireType[];
    readonly dict?: readonly string[] | 'auto';
    readonly autoDictRatio?: number;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `fields` | `readonly fields: readonly string[];` |  |  |
| `types` | `readonly types?: readonly WireType[];` | optional |  |
| `dict` | `readonly dict?: readonly string[] \| 'auto';` | optional | Fields to dictionary encode. `'auto'` encodes string fields whose distinct count is at most `autoDictRatio` of the rows (default 0.25). |
| `autoDictRatio` | `readonly autoDictRatio?: number;` | optional |  |

### FetchTransportOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/FetchTransportOptions

```ts
interface FetchTransportOptions {
    readonly url: string;
    readonly fetch?: FetchLike;
    readonly headers?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>);
    readonly requestInit?: Omit<FetchRequestInit, 'method' | 'body' | 'signal' | 'headers'>;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `url` | `readonly url: string;` |  |  |
| `fetch` | `readonly fetch?: FetchLike;` | optional | Injected fetch. Defaults to `globalThis.fetch`, read lazily per request. |
| `headers` | `readonly headers?: Readonly<Record<string, string>> \| (() => Readonly<Record<string, string>>);` | optional |  |
| `requestInit` | `readonly requestInit?: Omit<FetchRequestInit, 'method' \| 'body' \| 'signal' \| 'headers'>;` | optional |  |

### JsonDataSource

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/JsonDataSource

```ts
interface JsonDataSource<Row> extends DataSource<Row> {
    readonly mode: 'remote';
    read(request: DataSourceRequest & {
        readonly groupPath: readonly GroupPathSegment[];
    }): Promise<GroupLoadResult<Row>>;
    read(request: DataSourceRequest & {
        readonly parentRowId: RowId | null;
    }): Promise<TreeLoadResult<Row>>;
    read(request: DataSourceRequest): Promise<DataSourceResult<Row>>;
    write(request: WriteRequest<Row>): Promise<WriteResult<Row>>;
    subscribe(listener: (event: DataSourceEvent<Row>) => void): () => void;
    readonly capabilities: Partial<DataSourceCapabilities>;
    invalidate(scope?: 'rows' | 'counts' | 'facets' | 'all'): void;
    canReload(): boolean;
    reload(signal?: AbortSignalLike): Promise<DataSourceResult<Row>>;
    getRows(): readonly Row[];
    getWriteState(): WriteStateSnapshot<Row>;
    subscribeWriteState(listener: (event: WriteStateEvent) => void): () => void;
    dismissConflict(rowId: RowId): void;
    getStats(): Readonly<RunnerStats>;
}
```

Members (13):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `mode` | `readonly mode: 'remote';` |  |  |
| `read` | `read(request: DataSourceRequest & {     readonly groupPath: readonly GroupPathSegment[]; }): Promise<GroupLoadResult<Row>>; read(request: DataSourceRequest & {     readonly parentRowId: RowId \| null; }): Promise<TreeLoadResult<Row>>; read(request: DataSourceRequest): Promise<DataSourceResult<Row>>;` |  |  |
| `write` | `write(request: WriteRequest<Row>): Promise<WriteResult<Row>>;` |  |  |
| `subscribe` | `subscribe(listener: (event: DataSourceEvent<Row>) => void): () => void;` |  |  |
| `capabilities` | `readonly capabilities: Partial<DataSourceCapabilities>;` |  |  |
| `invalidate` | `invalidate(scope?: 'rows' \| 'counts' \| 'facets' \| 'all'): void;` |  | Clears cached rows/counts/facets (or everything), cursor chains, infinite blocks, and lazy group loads. Does not notify. |
| `canReload` | `canReload(): boolean;` |  | True when no foreground read is in flight. |
| `reload` | `reload(signal?: AbortSignalLike): Promise<DataSourceResult<Row>>;` |  | Repeats the last foreground read, bypassing the cache. |
| `getRows` | `getRows(): readonly Row[];` |  | Rows of the last foreground result, including optimistic edits. |
| `getWriteState` | `getWriteState(): WriteStateSnapshot<Row>;` |  |  |
| `subscribeWriteState` | `subscribeWriteState(listener: (event: WriteStateEvent) => void): () => void;` |  |  |
| `dismissConflict` | `dismissConflict(rowId: RowId): void;` |  | Drops a conflict after review. |
| `getStats` | `getStats(): Readonly<RunnerStats>;` |  |  |

### JsonDataSourceOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/JsonDataSourceOptions

```ts
interface JsonDataSourceOptions {
    readonly url?: string;
    readonly fetch?: FetchLike;
    readonly headers?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>);
    readonly batch?: boolean;
    readonly transport?: JsonTransport;
    readonly key: string;
    readonly fields?: readonly string[];
    readonly rowShape?: 'tuple' | 'object';
    readonly fieldOf?: (columnId: ColumnId) => string;
    readonly columnIdOf?: (field: string) => ColumnId;
    readonly paging?: PagingStrategy;
    readonly policy?: RequestPolicy;
    readonly scheduler?: Scheduler;
    readonly optimistic?: boolean;
    readonly versionField?: string;
    readonly capabilities?: Partial<DataSourceCapabilities>;
    readonly onRequest?: (event: RequestEvent) => boolean | void;
    readonly onResponse?: (event: ResponseEvent) => WireResponse | void;
    readonly onError?: (event: RequestErrorEvent) => void;
}
```

Members (19):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `url` | `readonly url?: string;` | optional | Endpoint for the default fetch transport. Ignored when `transport` is set. |
| `fetch` | `readonly fetch?: FetchLike;` | optional |  |
| `headers` | `readonly headers?: Readonly<Record<string, string>> \| (() => Readonly<Record<string, string>>);` | optional |  |
| `batch` | `readonly batch?: boolean;` | optional | Multiplex same-tick requests into one `{ v: 1, batch }` POST. Default true. |
| `transport` | `readonly transport?: JsonTransport;` | optional | Custom transport (GraphQL bridge, WebSocket, in-process handler, ...). |
| `key` | `readonly key: string;` |  | Primary key field. |
| `fields` | `readonly fields?: readonly string[];` | optional | Requested field list (`select`). Required for tuple rows: rows are the decoded tuples in this order. Without it rows are objects. |
| `rowShape` | `readonly rowShape?: 'tuple' \| 'object';` | optional | Default `tuple` when `fields` is set, else `object`. |
| `fieldOf` | `readonly fieldOf?: (columnId: ColumnId) => string;` | optional | columnId to server field. Default identity. |
| `columnIdOf` | `readonly columnIdOf?: (field: string) => ColumnId;` | optional | server field to columnId, for errors and aggregates. Default: inverse of `fieldOf` over the query, else identity. |
| `paging` | `readonly paging?: PagingStrategy;` | optional |  |
| `policy` | `readonly policy?: RequestPolicy;` | optional |  |
| `scheduler` | `readonly scheduler?: Scheduler;` | optional |  |
| `optimistic` | `readonly optimistic?: boolean;` | optional | Default: true for `batch` and `cell` writes, false otherwise. |
| `versionField` | `readonly versionField?: string;` | optional | Row field holding the row version (ETag); forwarded as expected version on change/remove. |
| `capabilities` | `readonly capabilities?: Partial<DataSourceCapabilities>;` | optional |  |
| `onRequest` | `readonly onRequest?: (event: RequestEvent) => boolean \| void;` | optional | Cancelable (`return false`): the request rejects with `RequestCanceledError`. |
| `onResponse` | `readonly onResponse?: (event: ResponseEvent) => WireResponse \| void;` | optional | Called with every successful protocol response before the source decodes it. Returning a response object replaces the response for this request (e.g. to rewrite rows or `total`); any other return value keeps it. Return a new object: the cache keeps the original response and a cache hit runs the hook again. |
| `onError` | `readonly onError?: (event: RequestErrorEvent) => void;` | optional |  |

### JsonPivotSource

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/JsonPivotSource

```ts
interface JsonPivotSource {
    readonly mode: 'remote';
    readonly kind: 'pivot';
    query(query: PivotWindowQuery): Promise<WirePivotResponse>;
    drillThrough(query: PivotDrillThroughQuery): Promise<PivotDrillThroughPage>;
    members(field: string, options?: {
        readonly where?: WirePredicate;
        readonly search?: string;
        readonly limit?: number;
        readonly signal?: AbortSignalLike;
    }): Promise<{
        readonly members: readonly RemotePivotMember[];
        readonly complete: boolean;
    }>;
    createEngine(options?: RemotePivotEngineOptions): RemotePivotEngine;
    invalidate(): void;
    getStats(): Readonly<RunnerStats>;
}
```

Members (8):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `mode` | `readonly mode: 'remote';` |  |  |
| `kind` | `readonly kind: 'pivot';` |  |  |
| `query` | `query(query: PivotWindowQuery): Promise<WirePivotResponse>;` |  | One result window. Rejects with `ProtocolError` `pivot/unsupported-aggregate` before sending a model with a client-side aggregator. |
| `drillThrough` | `drillThrough(query: PivotDrillThroughQuery): Promise<PivotDrillThroughPage>;` |  | Raw rows behind one cell, paged. |
| `members` | `members(field: string, options?: {     readonly where?: WirePredicate;     readonly search?: string;     readonly limit?: number;     readonly signal?: AbortSignalLike; }): Promise<{     readonly members: readonly RemotePivotMember[];     readonly complete: boolean; }>;` |  | Members of a field through the `facet` request (member editor, filter axis). |
| `createEngine` | `createEngine(options?: RemotePivotEngineOptions): RemotePivotEngine;` |  | The window-based remote engine (one per `PivotTable`). |
| `invalidate` | `invalidate(): void;` |  | Clears cached responses. |
| `getStats` | `getStats(): Readonly<RunnerStats>;` |  |  |

### JsonPivotSourceOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/JsonPivotSourceOptions

```ts
interface JsonPivotSourceOptions {
    readonly url?: string;
    readonly fetch?: FetchLike;
    readonly headers?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>);
    readonly batch?: boolean;
    readonly transport?: PivotJsonTransport;
    readonly policy?: RequestPolicy;
    readonly scheduler?: Scheduler;
    readonly onRequest?: (event: PivotRequestEvent) => boolean | void;
    readonly onResponse?: (event: PivotResponseEvent) => WireAnyResponse | void;
    readonly onError?: (event: PivotRequestErrorEvent) => void;
}
```

Members (10):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `url` | `readonly url?: string;` | optional | Endpoint for the default fetch transport. Ignored when `transport` is set. |
| `fetch` | `readonly fetch?: FetchLike;` | optional |  |
| `headers` | `readonly headers?: Readonly<Record<string, string>> \| (() => Readonly<Record<string, string>>);` | optional | Request headers (auth), or a function read per request. |
| `batch` | `readonly batch?: boolean;` | optional | Multiplex same-tick requests into one `{ v: 1, batch }` POST. Default true. |
| `transport` | `readonly transport?: PivotJsonTransport;` | optional | Custom transport (auth refresh, signing, WebSocket, in-process handler). |
| `policy` | `readonly policy?: RequestPolicy;` | optional | Cache, dedupe and retry, as `createJsonDataSource`. |
| `scheduler` | `readonly scheduler?: Scheduler;` | optional |  |
| `onRequest` | `readonly onRequest?: (event: PivotRequestEvent) => boolean \| void;` | optional | Called before every request; `return false` cancels it (`RequestCanceledError`). Mutate nothing: replace through `transport`. |
| `onResponse` | `readonly onResponse?: (event: PivotResponseEvent) => WireAnyResponse \| void;` | optional | Called with every successful response; returning an object replaces it. |
| `onError` | `readonly onError?: (event: PivotRequestErrorEvent) => void;` | optional |  |

### PivotDrillThroughPage

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/PivotDrillThroughPage

```ts
interface PivotDrillThroughPage {
    readonly rows: readonly Record<string, unknown>[];
    readonly fields: readonly string[];
    readonly total: number;
}
```

Raw rows behind one cell: objects, dates as `Date`.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rows` | `readonly rows: readonly Record<string, unknown>[];` |  |  |
| `fields` | `readonly fields: readonly string[];` |  |  |
| `total` | `readonly total: number;` |  |  |

### PivotDrillThroughQuery

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/PivotDrillThroughQuery

```ts
interface PivotDrillThroughQuery {
    readonly model: WirePivotModel;
    readonly where?: WirePredicate;
    readonly rowPath: readonly Json[];
    readonly columnPath: readonly Json[];
    readonly value?: string;
    readonly page: {
        readonly offset: number;
        readonly limit: number;
    };
    readonly select?: readonly string[];
    readonly signal?: AbortSignalLike;
}
```

Members (8):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `model` | `readonly model: WirePivotModel;` |  |  |
| `where` | `readonly where?: WirePredicate;` | optional |  |
| `rowPath` | `readonly rowPath: readonly Json[];` |  |  |
| `columnPath` | `readonly columnPath: readonly Json[];` |  |  |
| `value` | `readonly value?: string;` | optional |  |
| `page` | `readonly page: {     readonly offset: number;     readonly limit: number; };` |  |  |
| `select` | `readonly select?: readonly string[];` | optional |  |
| `signal` | `readonly signal?: AbortSignalLike;` | optional |  |

### PivotRequestErrorEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/PivotRequestErrorEvent

```ts
interface PivotRequestErrorEvent extends PivotRequestEvent {
    readonly error: unknown;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `error` | `readonly error: unknown;` |  |  |
| `kind` | `kind: PivotRequestKind;` | inherited |  |
| `request` | `request: WireAnyRequest;` | inherited |  |

### PivotRequestEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/PivotRequestEvent

```ts
interface PivotRequestEvent {
    readonly kind: PivotRequestKind;
    readonly request: WireAnyRequest;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `kind` | `readonly kind: PivotRequestKind;` |  |  |
| `request` | `readonly request: WireAnyRequest;` |  |  |

### PivotResponseEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/PivotResponseEvent

```ts
interface PivotResponseEvent extends PivotRequestEvent {
    readonly response: WireAnyResponse;
    readonly durationMs: number;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `response` | `readonly response: WireAnyResponse;` |  |  |
| `durationMs` | `readonly durationMs: number;` |  |  |
| `kind` | `kind: PivotRequestKind;` | inherited |  |
| `request` | `request: WireAnyRequest;` | inherited |  |

### PivotWindowQuery

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/PivotWindowQuery

```ts
interface PivotWindowQuery {
    readonly model: WirePivotModel;
    readonly where?: WirePredicate;
    readonly window: WirePivotWindow;
    readonly headers?: boolean;
    readonly signal?: AbortSignalLike;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `model` | `readonly model: WirePivotModel;` |  |  |
| `where` | `readonly where?: WirePredicate;` | optional |  |
| `window` | `readonly window: WirePivotWindow;` |  |  |
| `headers` | `readonly headers?: boolean;` | optional | Default true. |
| `signal` | `readonly signal?: AbortSignalLike;` | optional |  |

### RemotePivotCell

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/RemotePivotCell

```ts
interface RemotePivotCell {
    readonly rowIndex: number;
    readonly columnIndex: number;
    readonly rowKey: string;
    readonly columnKey: string;
    readonly measure: string | null;
    readonly value: number | null;
    readonly rawValue: number | null;
    readonly formattedValue: string;
    readonly kind: 'value' | 'subtotal' | 'grandTotal';
    readonly rowCount: number;
}
```

A cell as `PivotCell`. `rawValue` equals `value` and `rowCount` is 0: use `drillThrough`.

Members (10):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rowIndex` | `readonly rowIndex: number;` |  |  |
| `columnIndex` | `readonly columnIndex: number;` |  |  |
| `rowKey` | `readonly rowKey: string;` |  |  |
| `columnKey` | `readonly columnKey: string;` |  |  |
| `measure` | `readonly measure: string \| null;` |  |  |
| `value` | `readonly value: number \| null;` |  |  |
| `rawValue` | `readonly rawValue: number \| null;` |  |  |
| `formattedValue` | `readonly formattedValue: string;` |  |  |
| `kind` | `readonly kind: 'value' \| 'subtotal' \| 'grandTotal';` |  |  |
| `rowCount` | `readonly rowCount: number;` |  |  |

### RemotePivotEngine

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/RemotePivotEngine

```ts
interface RemotePivotEngine {
    readonly remote: true;
    subscribe(listener: () => void): () => void;
    getSnapshot(): RemotePivotResult;
    getStatus(): RemotePivotStatus;
    getError(): unknown;
    getModel(): WirePivotModel;
    setModel(input: WirePivotModel | ((model: WirePivotModel) => WirePivotModel)): Promise<RemotePivotResult>;
    setWhere(where: WirePredicate | undefined): Promise<RemotePivotResult>;
    setWindow(window: WirePivotWindow): Promise<RemotePivotResult>;
    expand(path: readonly Json[]): Promise<RemotePivotResult>;
    collapse(path: readonly Json[]): Promise<RemotePivotResult>;
    expandAll(): Promise<RemotePivotResult>;
    collapseAll(axis?: 'rows' | 'columns'): Promise<RemotePivotResult>;
    getMembers(field: string, options?: {
        readonly search?: string;
        readonly limit?: number;
    }): Promise<readonly RemotePivotMember[]>;
    drillThrough(rowIndex: number, columnIndex: number, options?: {
        readonly page?: {
            readonly offset: number;
            readonly limit: number;
        };
        readonly select?: readonly string[];
    }): Promise<PivotDrillThroughPage>;
    loadWindow(window: WirePivotWindow, options?: {
        readonly signal?: AbortSignalLike;
    }): Promise<RemotePivotResult>;
    refresh(): Promise<RemotePivotResult>;
    destroy(): void;
}
```

Members (18):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `remote` | `readonly remote: true;` |  |  |
| `subscribe` | `subscribe(listener: () => void): () => void;` |  |  |
| `getSnapshot` | `getSnapshot(): RemotePivotResult;` |  |  |
| `getStatus` | `getStatus(): RemotePivotStatus;` |  |  |
| `getError` | `getError(): unknown;` |  |  |
| `getModel` | `getModel(): WirePivotModel;` |  |  |
| `setModel` | `setModel(input: WirePivotModel \| ((model: WirePivotModel) => WirePivotModel)): Promise<RemotePivotResult>;` |  | New model (drill, filter, sort, field moves): one `pivot` request; aborts its predecessor. |
| `setWhere` | `setWhere(where: WirePredicate \| undefined): Promise<RemotePivotResult>;` |  |  |
| `setWindow` | `setWindow(window: WirePivotWindow): Promise<RemotePivotResult>;` |  | Visible window (overscan added); cells only while the headers are held. |
| `expand` | `expand(path: readonly Json[]): Promise<RemotePivotResult>;` |  |  |
| `collapse` | `collapse(path: readonly Json[]): Promise<RemotePivotResult>;` |  |  |
| `expandAll` | `expandAll(): Promise<RemotePivotResult>;` |  |  |
| `collapseAll` | `collapseAll(axis?: 'rows' \| 'columns'): Promise<RemotePivotResult>;` |  |  |
| `getMembers` | `getMembers(field: string, options?: {     readonly search?: string;     readonly limit?: number; }): Promise<readonly RemotePivotMember[]>;` |  |  |
| `drillThrough` | `drillThrough(rowIndex: number, columnIndex: number, options?: {     readonly page?: {         readonly offset: number;         readonly limit: number;     };     readonly select?: readonly string[]; }): Promise<PivotDrillThroughPage>;` |  |  |
| `loadWindow` | `loadWindow(window: WirePivotWindow, options?: {     readonly signal?: AbortSignalLike; }): Promise<RemotePivotResult>;` |  | A standalone result of one window of the current model (export paging); not merged into the view. |
| `refresh` | `refresh(): Promise<RemotePivotResult>;` |  |  |
| `destroy` | `destroy(): void;` |  |  |

### RemotePivotEngineOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/RemotePivotEngineOptions

```ts
interface RemotePivotEngineOptions {
    readonly model?: WirePivotModel;
    readonly where?: WirePredicate;
    readonly locale?: string;
    readonly window?: WirePivotWindow;
    readonly overscan?: {
        readonly rows?: number;
        readonly columns?: number;
    };
    readonly maxBlocks?: number;
    readonly formatValue?: (value: number, measure: string | null, model: WirePivotModel) => string;
}
```

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `model` | `readonly model?: WirePivotModel;` | optional |  |
| `where` | `readonly where?: WirePredicate;` | optional | Pre-aggregation filter over raw rows. |
| `locale` | `readonly locale?: string;` | optional |  |
| `window` | `readonly window?: WirePivotWindow;` | optional | First window. Default 100 rows × 50 columns. |
| `overscan` | `readonly overscan?: {     readonly rows?: number;     readonly columns?: number; };` | optional | Positions loaded beyond a requested window on each side. Default 40 rows, 10 columns. |
| `maxBlocks` | `readonly maxBlocks?: number;` | optional | Loaded windows kept per result. Default 16. |
| `formatValue` | `readonly formatValue?: (value: number, measure: string \| null, model: WirePivotModel) => string;` | optional | Cell text (default: `Intl.NumberFormat` with `model.formats[measure].number`). |

### RemotePivotHeader

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/RemotePivotHeader

```ts
interface RemotePivotHeader {
    readonly key: string;
    readonly axis: 'rows' | 'columns';
    readonly kind: 'member' | 'subtotal' | 'grandTotal' | 'value';
    readonly path: readonly Json[];
    readonly field: string | null;
    readonly measure: string | null;
    readonly label: string;
    readonly depth: number;
    readonly position: number;
    readonly span: number;
    readonly expandable: boolean;
    readonly expanded: boolean;
    readonly children?: readonly RemotePivotHeader[];
}
```

A header node as `PivotHeaderNode`.

Members (13):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `key` | `readonly key: string;` |  |  |
| `axis` | `readonly axis: 'rows' \| 'columns';` |  |  |
| `kind` | `readonly kind: 'member' \| 'subtotal' \| 'grandTotal' \| 'value';` |  |  |
| `path` | `readonly path: readonly Json[];` |  |  |
| `field` | `readonly field: string \| null;` |  |  |
| `measure` | `readonly measure: string \| null;` |  |  |
| `label` | `readonly label: string;` |  |  |
| `depth` | `readonly depth: number;` |  |  |
| `position` | `readonly position: number;` |  |  |
| `span` | `readonly span: number;` |  |  |
| `expandable` | `readonly expandable: boolean;` |  |  |
| `expanded` | `readonly expanded: boolean;` |  |  |
| `children` | `readonly children?: readonly RemotePivotHeader[];` | optional |  |

### RemotePivotMember

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/RemotePivotMember

```ts
interface RemotePivotMember {
    readonly key: Json;
    readonly label: string;
    readonly count: number;
}
```

A member of a field (`PivotMember`).

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `key` | `readonly key: Json;` |  |  |
| `label` | `readonly label: string;` |  |  |
| `count` | `readonly count: number;` |  |  |

### RemotePivotResult

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/RemotePivotResult

```ts
interface RemotePivotResult {
    readonly remote: true;
    readonly version: number;
    readonly resultVersion: string;
    readonly model: WirePivotModel;
    readonly rowCount: number;
    readonly columnCount: number;
    readonly rowTree: readonly RemotePivotHeader[];
    readonly columnTree: readonly RemotePivotHeader[];
    readonly columnDepth: number;
    readonly rowDepth: number;
    memberAt(axis: 'rows' | 'columns', index: number): RemotePivotHeader;
    valueAt(rowIndex: number, columnIndex: number): number | null;
    cellAt(rowIndex: number, columnIndex: number): RemotePivotCell;
    rowsAt(rowIndex: number, columnIndex: number): readonly number[];
    isLoaded(rowIndex: number, columnIndex: number): boolean;
}
```

The snapshot of a remote engine: a `PivotResult` over the loaded windows.
Trees hold the header nodes of the loaded windows only; `memberAt` of a
position outside them returns a placeholder (`key: ''`, `label: ''`) and
`valueAt` returns null (check `isLoaded`); `rowsAt` is empty (raw rows stay
on the server).

Members (15):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `remote` | `readonly remote: true;` |  |  |
| `version` | `readonly version: number;` |  |  |
| `resultVersion` | `readonly resultVersion: string;` |  | Server result version; '' before the first response. |
| `model` | `readonly model: WirePivotModel;` |  |  |
| `rowCount` | `readonly rowCount: number;` |  |  |
| `columnCount` | `readonly columnCount: number;` |  |  |
| `rowTree` | `readonly rowTree: readonly RemotePivotHeader[];` |  |  |
| `columnTree` | `readonly columnTree: readonly RemotePivotHeader[];` |  |  |
| `columnDepth` | `readonly columnDepth: number;` |  |  |
| `rowDepth` | `readonly rowDepth: number;` |  |  |
| `memberAt` | `memberAt(axis: 'rows' \| 'columns', index: number): RemotePivotHeader;` |  |  |
| `valueAt` | `valueAt(rowIndex: number, columnIndex: number): number \| null;` |  |  |
| `cellAt` | `cellAt(rowIndex: number, columnIndex: number): RemotePivotCell;` |  |  |
| `rowsAt` | `rowsAt(rowIndex: number, columnIndex: number): readonly number[];` |  |  |
| `isLoaded` | `isLoaded(rowIndex: number, columnIndex: number): boolean;` |  |  |

### RequestErrorEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/RequestErrorEvent

```ts
interface RequestErrorEvent extends RequestEvent {
    readonly error: unknown;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `error` | `readonly error: unknown;` |  |  |
| `kind` | `kind: RequestKind;` | inherited |  |
| `request` | `request: WireRequest;` | inherited |  |

### RequestEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/RequestEvent

```ts
interface RequestEvent {
    readonly kind: RequestKind;
    readonly request: WireRequest;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `kind` | `readonly kind: RequestKind;` |  |  |
| `request` | `readonly request: WireRequest;` |  |  |

### ResponseEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/ResponseEvent

```ts
interface ResponseEvent extends RequestEvent {
    readonly response: WireResponse;
    readonly durationMs: number;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `response` | `readonly response: WireResponse;` |  |  |
| `durationMs` | `readonly durationMs: number;` |  |  |
| `kind` | `kind: RequestKind;` | inherited |  |
| `request` | `request: WireRequest;` | inherited |  |

### TransportContext

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/TransportContext

```ts
interface TransportContext {
    readonly signal: AbortSignalLike;
}
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `signal` | `readonly signal: AbortSignalLike;` |  |  |

### TupleColumnDefLike

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/TupleColumnDefLike

```ts
interface TupleColumnDefLike {
    readonly id?: string;
    readonly field?: string;
    readonly columns?: readonly TupleColumnDefLike[];
}
```

Minimal structural view of a Data Grid engine `ColumnDef` (only the members tuple mode fills).

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id?: string;` | optional |  |
| `field` | `readonly field?: string;` | optional |  |
| `columns` | `readonly columns?: readonly TupleColumnDefLike[];` | optional |  |

### TupleColumnHooks

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/TupleColumnHooks

```ts
interface TupleColumnHooks {
    readonly id?: string;
    readonly valueGetter?: (row: TupleRow) => unknown;
    readonly valueSetter?: (row: TupleRow, value: unknown) => TupleRow;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id?: string;` | optional |  |
| `valueGetter` | `readonly valueGetter?: (row: TupleRow) => unknown;` | optional |  |
| `valueSetter` | `readonly valueSetter?: (row: TupleRow, value: unknown) => TupleRow;` | optional |  |

### WireBatchRequest

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireBatchRequest

```ts
interface WireBatchRequest {
    readonly v: 1;
    readonly batch: readonly WireAnyRequest[];
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `v` | `readonly v: 1;` |  |  |
| `batch` | `readonly batch: readonly WireAnyRequest[];` |  |  |

### WireBatchResponse

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireBatchResponse

```ts
interface WireBatchResponse {
    readonly v: 1;
    readonly batch: readonly WireAnyResponse[];
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `v` | `readonly v: 1;` |  |  |
| `batch` | `readonly batch: readonly WireAnyResponse[];` |  |  |

### WireCondition

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireCondition

```ts
interface WireCondition {
    readonly field: string;
    readonly op: string;
    readonly value?: Json;
    readonly matchCase?: boolean;
    readonly ignoreAccent?: boolean;
}
```

Built-in operators use the Data Grid engine names (`startsWith`, `greaterThanOrEqual`, ...).

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `field` | `readonly field: string;` |  |  |
| `op` | `readonly op: string;` |  |  |
| `value` | `readonly value?: Json;` | optional |  |
| `matchCase` | `readonly matchCase?: boolean;` | optional |  |
| `ignoreAccent` | `readonly ignoreAccent?: boolean;` | optional |  |

### WireError

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireError

```ts
interface WireError {
    readonly code: string;
    readonly message: string;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `code` | `readonly code: string;` |  |  |
| `message` | `readonly message: string;` |  |  |

### WireGroup

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireGroup

```ts
interface WireGroup {
    readonly key: Json;
    readonly count: number;
    readonly aggregates?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `key` | `readonly key: Json;` |  |  |
| `count` | `readonly count: number;` |  |  |
| `aggregates` | `readonly aggregates?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;` | optional |  |

### WirePivotAxisField

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WirePivotAxisField

```ts
interface WirePivotAxisField {
    readonly field: string;
    readonly caption?: string;
    readonly showSubTotals?: boolean;
}
```

An axis field of a wire pivot model.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `field` | `readonly field: string;` |  |  |
| `caption` | `readonly caption?: string;` | optional |  |
| `showSubTotals` | `readonly showSubTotals?: boolean;` | optional |  |

### WirePivotHeader

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WirePivotHeader

```ts
interface WirePivotHeader {
    readonly key: string;
    readonly path: readonly Json[];
    readonly label: string;
    readonly depth: number;
    readonly position: number;
    readonly span: number;
    readonly kind: 'member' | 'subtotal' | 'grandTotal' | 'value';
    readonly field?: string;
    readonly measure?: string;
    readonly expandable?: true;
    readonly expanded?: true;
}
```

A header node of the window (`PivotHeaderNode` without `axis` and `children`).

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `key` | `readonly key: string;` |  | `PivotHeaderNode.key`. |
| `path` | `readonly path: readonly Json[];` |  |  |
| `label` | `readonly label: string;` |  |  |
| `depth` | `readonly depth: number;` |  |  |
| `position` | `readonly position: number;` |  |  |
| `span` | `readonly span: number;` |  |  |
| `kind` | `readonly kind: 'member' \| 'subtotal' \| 'grandTotal' \| 'value';` |  |  |
| `field` | `readonly field?: string;` | optional | Field of the innermost member; omitted when null. |
| `measure` | `readonly measure?: string;` | optional | Measure of value headers and leaves under them; omitted when null. |
| `expandable` | `readonly expandable?: true;` | optional | Has children (expanded or not). |
| `expanded` | `readonly expanded?: true;` | optional |  |

### WirePivotModel

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WirePivotModel

```ts
interface WirePivotModel {
    readonly rows?: readonly WirePivotAxisField[];
    readonly columns?: readonly WirePivotAxisField[];
    readonly values?: readonly WirePivotValueField[];
    readonly filters?: readonly WirePivotAxisField[];
    readonly filterBy?: unknown;
    readonly sort?: unknown;
    readonly valueSort?: unknown;
    readonly groups?: unknown;
    readonly calculatedFields?: readonly {
        readonly name: string;
        readonly formula: string;
        readonly caption?: string;
        readonly format?: unknown;
    }[];
    readonly formats?: unknown;
    readonly conditionalFormats?: unknown;
    readonly expanded?: readonly (readonly Json[])[] | 'all';
    readonly totals?: unknown;
    readonly valuesPlacement?: unknown;
    readonly showEmptyMembers?: boolean;
    readonly showValueHeader?: boolean;
}
```

The pivot engine's `PivotModel` (`@salmonui/pivot-table/engine`), typed
structurally so this package keeps no package imports. Plain JSON; the
client sends it with defaults omitted and without the client-only parts
(`formats`, `conditionalFormats`, calculated field `format`).

Members (16):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rows` | `readonly rows?: readonly WirePivotAxisField[];` | optional |  |
| `columns` | `readonly columns?: readonly WirePivotAxisField[];` | optional |  |
| `values` | `readonly values?: readonly WirePivotValueField[];` | optional |  |
| `filters` | `readonly filters?: readonly WirePivotAxisField[];` | optional |  |
| `filterBy` | `readonly filterBy?: unknown;` | optional |  |
| `sort` | `readonly sort?: unknown;` | optional |  |
| `valueSort` | `readonly valueSort?: unknown;` | optional |  |
| `groups` | `readonly groups?: unknown;` | optional |  |
| `calculatedFields` | `readonly calculatedFields?: readonly {     readonly name: string;     readonly formula: string;     readonly caption?: string;     readonly format?: unknown; }[];` | optional |  |
| `formats` | `readonly formats?: unknown;` | optional |  |
| `conditionalFormats` | `readonly conditionalFormats?: unknown;` | optional |  |
| `expanded` | `readonly expanded?: readonly (readonly Json[])[] \| 'all';` | optional | Member paths (`['rows', ...keys]`) or `'all'`. |
| `totals` | `readonly totals?: unknown;` | optional |  |
| `valuesPlacement` | `readonly valuesPlacement?: unknown;` | optional |  |
| `showEmptyMembers` | `readonly showEmptyMembers?: boolean;` | optional |  |
| `showValueHeader` | `readonly showValueHeader?: boolean;` | optional |  |

### WirePivotRequest

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WirePivotRequest

```ts
interface WirePivotRequest {
    readonly v: 1;
    readonly id: string;
    readonly pivot: {
        readonly model: WirePivotModel;
        readonly where?: WirePredicate;
        readonly window?: WirePivotWindow;
        readonly headers?: boolean;
        readonly drillThrough?: {
            readonly rowPath: readonly Json[];
            readonly columnPath: readonly Json[];
            readonly value?: string;
            readonly page: {
                readonly offset: number;
                readonly limit: number;
            };
            readonly select?: readonly string[];
        };
    };
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `v` | `readonly v: 1;` |  |  |
| `id` | `readonly id: string;` |  |  |
| `pivot` | `readonly pivot: {     readonly model: WirePivotModel;     readonly where?: WirePredicate;     readonly window?: WirePivotWindow;     readonly headers?: boolean;     readonly drillThrough?: {         readonly rowPath: readonly Json[];         readonly columnPath: readonly Json[];         readonly value?: string;         readonly page: {             readonly offset: number;             readonly limit: number;         };         readonly select?: readonly string[];     }; };` |  |  |

### WirePivotResponse

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WirePivotResponse

```ts
interface WirePivotResponse {
    readonly v: 1;
    readonly id: string;
    readonly resultVersion?: string;
    readonly rowCount?: number;
    readonly columnCount?: number;
    readonly columnDepth?: number;
    readonly rowDepth?: number;
    readonly rowHeaders?: readonly WirePivotHeader[];
    readonly columnHeaders?: readonly WirePivotHeader[];
    readonly cells?: readonly (readonly (number | null)[])[];
    readonly kinds?: readonly string[];
    readonly fields?: readonly string[];
    readonly types?: readonly WireType[];
    readonly rows?: readonly WireTuple[];
    readonly dict?: Readonly<Record<string, readonly string[]>>;
    readonly total?: number;
    readonly error?: WireError;
}
```

Members (17):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `v` | `readonly v: 1;` |  |  |
| `id` | `readonly id: string;` |  |  |
| `resultVersion` | `readonly resultVersion?: string;` | optional | Opaque; changes when the model or the data change. |
| `rowCount` | `readonly rowCount?: number;` | optional | Leaf rows and columns of the full result. |
| `columnCount` | `readonly columnCount?: number;` | optional |  |
| `columnDepth` | `readonly columnDepth?: number;` | optional | Header row count of the column tree and level count of the row tree. |
| `rowDepth` | `readonly rowDepth?: number;` | optional |  |
| `rowHeaders` | `readonly rowHeaders?: readonly WirePivotHeader[];` | optional | The window's header nodes with their ancestors, depth-first. |
| `columnHeaders` | `readonly columnHeaders?: readonly WirePivotHeader[];` | optional |  |
| `cells` | `readonly cells?: readonly (readonly (number \| null)[])[];` | optional | `[row - window.rows[0]][column - window.columns[0]]`; formatted on the client. |
| `kinds` | `readonly kinds?: readonly string[];` | optional | Cell kinds parallel to `cells`, one character per cell (`0` value, `1` subtotal, `2` grand total); omitted when every cell is a value. |
| `fields` | `readonly fields?: readonly string[];` | optional |  |
| `types` | `readonly types?: readonly WireType[];` | optional |  |
| `rows` | `readonly rows?: readonly WireTuple[];` | optional |  |
| `dict` | `readonly dict?: Readonly<Record<string, readonly string[]>>;` | optional |  |
| `total` | `readonly total?: number;` | optional |  |
| `error` | `readonly error?: WireError;` | optional |  |

### WirePivotValueField

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WirePivotValueField

```ts
interface WirePivotValueField {
    readonly field: string;
    readonly caption?: string;
    readonly aggregate: string;
    readonly customId?: string;
    readonly showAs?: unknown;
}
```

A value field of a wire pivot model; `aggregate: 'custom'` (a client function) cannot travel.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `field` | `readonly field: string;` |  |  |
| `caption` | `readonly caption?: string;` | optional |  |
| `aggregate` | `readonly aggregate: string;` |  |  |
| `customId` | `readonly customId?: string;` | optional |  |
| `showAs` | `readonly showAs?: unknown;` | optional |  |

### WirePivotWindow

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WirePivotWindow

```ts
interface WirePivotWindow {
    readonly rows: readonly [
        start: number,
        end: number
    ];
    readonly columns: readonly [
        start: number,
        end: number
    ];
}
```

A leaf-position window, end exclusive.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rows` | `readonly rows: readonly [     start: number,     end: number ];` |  |  |
| `columns` | `readonly columns: readonly [     start: number,     end: number ];` |  |  |

### WireQuery

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireQuery

```ts
interface WireQuery {
    readonly where?: WirePredicate;
    readonly sort?: readonly {
        readonly field: string;
        readonly dir: 'asc' | 'desc';
    }[];
    readonly search?: {
        readonly text: string;
        readonly fields: readonly string[] | '*';
        readonly op: string;
        readonly ignoreCase?: boolean;
        readonly ignoreAccent?: boolean;
    };
    readonly page?: WirePage;
    readonly group?: readonly {
        readonly field: string;
        readonly format?: string;
    }[];
    readonly aggregates?: readonly {
        readonly field: string;
        readonly type: string;
    }[];
    readonly select?: readonly string[];
}
```

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `where` | `readonly where?: WirePredicate;` | optional |  |
| `sort` | `readonly sort?: readonly {     readonly field: string;     readonly dir: 'asc' \| 'desc'; }[];` | optional |  |
| `search` | `readonly search?: {     readonly text: string;     readonly fields: readonly string[] \| '*';     readonly op: string;     readonly ignoreCase?: boolean;     readonly ignoreAccent?: boolean; };` | optional |  |
| `page` | `readonly page?: WirePage;` | optional |  |
| `group` | `readonly group?: readonly {     readonly field: string;     readonly format?: string; }[];` | optional |  |
| `aggregates` | `readonly aggregates?: readonly {     readonly field: string;     readonly type: string; }[];` | optional |  |
| `select` | `readonly select?: readonly string[];` | optional |  |

### WireQueryOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireQueryOptions

```ts
interface WireQueryOptions {
    readonly fieldOf?: (columnId: ColumnId) => string;
    readonly page?: WirePage;
    readonly select?: readonly string[];
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `fieldOf` | `readonly fieldOf?: (columnId: ColumnId) => string;` | optional | Maps a columnId to the server field name. Default identity. |
| `page` | `readonly page?: WirePage;` | optional |  |
| `select` | `readonly select?: readonly string[];` | optional |  |

### WireReadRequest

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireReadRequest

```ts
interface WireReadRequest {
    readonly v: 1;
    readonly id: string;
    readonly query: WireQuery;
    readonly groupPath?: readonly {
        readonly field: string;
        readonly key: Json;
    }[];
    readonly parent?: Json;
    readonly facet?: {
        readonly field: string;
        readonly search?: string;
        readonly limit?: number;
    };
    readonly count?: boolean;
}
```

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `v` | `readonly v: 1;` |  |  |
| `id` | `readonly id: string;` |  |  |
| `query` | `readonly query: WireQuery;` |  |  |
| `groupPath` | `readonly groupPath?: readonly {     readonly field: string;     readonly key: Json; }[];` | optional | Lazy group load: `[]` = root level, otherwise the children of that group. |
| `parent` | `readonly parent?: Json;` | optional | Tree read: key of the parent row; `null` reads the root level. |
| `facet` | `readonly facet?: {     readonly field: string;     readonly search?: string;     readonly limit?: number; };` | optional |  |
| `count` | `readonly count?: boolean;` | optional | Default true; false skips the total count. |

### WireReadResponse

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireReadResponse

```ts
interface WireReadResponse {
    readonly v: 1;
    readonly id: string;
    readonly fields: readonly string[];
    readonly types?: readonly WireType[];
    readonly rows: readonly WireTuple[];
    readonly dict?: Readonly<Record<string, readonly string[]>>;
    readonly total?: number;
    readonly next?: string | null;
    readonly prev?: string | null;
    readonly aggregates?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
    readonly groups?: readonly WireGroup[];
    readonly childCounts?: readonly number[];
    readonly parents?: readonly Json[];
    readonly depths?: readonly number[];
    readonly facet?: {
        readonly field: string;
        readonly entries: readonly (readonly [
            key: string,
            label: string,
            count: number
        ])[];
        readonly complete: boolean;
    };
    readonly error?: WireError;
}
```

Members (16):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `v` | `readonly v: 1;` |  |  |
| `id` | `readonly id: string;` |  |  |
| `fields` | `readonly fields: readonly string[];` |  |  |
| `types` | `readonly types?: readonly WireType[];` | optional |  |
| `rows` | `readonly rows: readonly WireTuple[];` |  |  |
| `dict` | `readonly dict?: Readonly<Record<string, readonly string[]>>;` | optional | Dictionary encoding: that field's cells are indexes into the list. |
| `total` | `readonly total?: number;` | optional |  |
| `next` | `readonly next?: string \| null;` | optional | Cursor of the next page; null on the last page. |
| `prev` | `readonly prev?: string \| null;` | optional |  |
| `aggregates` | `readonly aggregates?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;` | optional |  |
| `groups` | `readonly groups?: readonly WireGroup[];` | optional | Group level of a lazy group load (instead of rows). |
| `childCounts` | `readonly childCounts?: readonly number[];` | optional | Tree loads: child count per row (0 = leaf), parallel to `rows`; filtered reads count the kept children only. |
| `parents` | `readonly parents?: readonly Json[];` | optional | Tree loads that return more than one level (a filtered read with the ancestor chain, or a whole subtree): the parent key per row (null: a root), parallel to `rows`, in pre-order. Omitted: every row is a child of the requested `parent`. |
| `depths` | `readonly depths?: readonly number[];` | optional | Depth per row relative to the requested level (0: a child of `parent`), parallel to `rows`. |
| `facet` | `readonly facet?: {     readonly field: string;     readonly entries: readonly (readonly [         key: string,         label: string,         count: number     ])[];     readonly complete: boolean; };` | optional |  |
| `error` | `readonly error?: WireError;` | optional |  |

### WireWriteRequest

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireWriteRequest

```ts
interface WireWriteRequest {
    readonly v: 1;
    readonly id: string;
    readonly write: {
        readonly fields: readonly string[];
        readonly added: readonly WireTuple[];
        readonly changed: readonly {
            readonly key: Json;
            readonly set: Readonly<Record<string, unknown>>;
            readonly version?: string;
        }[];
        readonly removed: readonly {
            readonly key: Json;
            readonly version?: string;
        }[];
        readonly parents?: readonly Json[];
        readonly moved?: {
            readonly keys: readonly Json[];
            readonly parent: Json;
            readonly target: Json;
            readonly position: 'before' | 'after';
        };
    };
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `v` | `readonly v: 1;` |  |  |
| `id` | `readonly id: string;` |  |  |
| `write` | `readonly write: {     readonly fields: readonly string[];     readonly added: readonly WireTuple[];     readonly changed: readonly {         readonly key: Json;         readonly set: Readonly<Record<string, unknown>>;         readonly version?: string;     }[];     readonly removed: readonly {         readonly key: Json;         readonly version?: string;     }[];     readonly parents?: readonly Json[];     readonly moved?: {         readonly keys: readonly Json[];         readonly parent: Json;         readonly target: Json;         readonly position: 'before' \| 'after';     }; };` |  |  |

### WireWriteResponse

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WireWriteResponse

```ts
interface WireWriteResponse {
    readonly v: 1;
    readonly id: string;
    readonly fields?: readonly string[];
    readonly ok?: readonly {
        readonly key: Json;
        readonly index?: number;
        readonly version?: string;
        readonly row?: WireTuple;
    }[];
    readonly errors?: readonly {
        readonly key?: Json;
        readonly index?: number;
        readonly field?: string;
        readonly code: string;
        readonly message: string;
    }[];
    readonly conflicts?: readonly {
        readonly key: Json;
        readonly server: WireTuple;
        readonly version?: string;
    }[];
    readonly total?: number;
    readonly error?: WireError;
}
```

Members (8):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `v` | `readonly v: 1;` |  |  |
| `id` | `readonly id: string;` |  |  |
| `fields` | `readonly fields?: readonly string[];` | optional | Header for the tuples echoed in `ok[].row` and `conflicts[].server`. Defaults to the request's fields. |
| `ok` | `readonly ok?: readonly {     readonly key: Json;     readonly index?: number;     readonly version?: string;     readonly row?: WireTuple; }[];` | optional | Applied rows. `index` identifies an added tuple; `row` is the server echo (real key, computed fields). |
| `errors` | `readonly errors?: readonly {     readonly key?: Json;     readonly index?: number;     readonly field?: string;     readonly code: string;     readonly message: string; }[];` | optional |  |
| `conflicts` | `readonly conflicts?: readonly {     readonly key: Json;     readonly server: WireTuple;     readonly version?: string; }[];` | optional |  |
| `total` | `readonly total?: number;` | optional |  |
| `error` | `readonly error?: WireError;` | optional |  |

### WriteStateEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WriteStateEvent

```ts
interface WriteStateEvent {
    readonly rows: readonly RowId[];
    readonly cells: readonly CellKey[];
}
```

Which rows and cells a write-state change touched.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rows` | `readonly rows: readonly RowId[];` |  |  |
| `cells` | `readonly cells: readonly CellKey[];` |  |  |

### WriteStateSnapshot

Kind: interface

Page: https://salmonui.dev/docs/reference/data/json/WriteStateSnapshot

```ts
interface WriteStateSnapshot<Row> {
    readonly pending: ReadonlySet<RowId>;
    readonly rowErrors: Readonly<Record<RowId, readonly string[]>>;
    readonly cellErrors: Readonly<Record<CellKey, readonly string[]>>;
    readonly conflicts: readonly ConflictSnapshot<Row>[];
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `pending` | `readonly pending: ReadonlySet<RowId>;` |  |  |
| `rowErrors` | `readonly rowErrors: Readonly<Record<RowId, readonly string[]>>;` |  |  |
| `cellErrors` | `readonly cellErrors: Readonly<Record<CellKey, readonly string[]>>;` |  |  |
| `conflicts` | `readonly conflicts: readonly ConflictSnapshot<Row>[];` |  |  |

## Types

### JsonTransport

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/JsonTransport

```ts
type JsonTransport = (request: WireRequest, ctx: TransportContext) => Promise<WireResponse>;
```

Sends one protocol request and resolves with its response. Must honor `signal`.

### PivotJsonTransport

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/PivotJsonTransport

```ts
type PivotJsonTransport = (request: WireAnyRequest, ctx: TransportContext) => Promise<WireAnyResponse>;
```

A transport that also carries `pivot` requests (`createJsonPivotSource`).

### PivotRequestKind

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/PivotRequestKind

```ts
type PivotRequestKind = 'pivot' | 'facet';
```

### RemotePivotStatus

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/RemotePivotStatus

```ts
type RemotePivotStatus = 'idle' | 'computing' | 'ready' | 'error';
```

### RequestKind

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/RequestKind

```ts
type RequestKind = 'read' | 'prefetch' | 'group' | 'tree' | 'facet' | 'write';
```

### TupleRow

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/TupleRow

```ts
type TupleRow = readonly unknown[];
```

### UniversalJsonTransport

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/UniversalJsonTransport

```ts
type UniversalJsonTransport = JsonTransport & PivotJsonTransport;
```

The built-in transports carry every request kind: usable as either transport type.

### WireAnyRequest

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/WireAnyRequest

```ts
type WireAnyRequest = WireRequest | WirePivotRequest;
```

Every request kind, pivot included: what a `PivotJsonTransport` (pivot sources) carries.

### WireAnyResponse

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/WireAnyResponse

```ts
type WireAnyResponse = WireResponse | WirePivotResponse;
```

### WireLiveMessage

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/WireLiveMessage

```ts
type WireLiveMessage = {
    readonly v: 1;
    readonly type: 'replace';
    readonly fields: readonly string[];
    readonly types?: readonly WireType[];
    readonly rows: readonly WireTuple[];
    readonly dict?: Readonly<Record<string, readonly string[]>>;
    readonly total?: number;
} | {
    readonly v: 1;
    readonly type: 'patch';
    readonly fields?: readonly string[];
    readonly dict?: Readonly<Record<string, readonly string[]>>;
    readonly upsert?: readonly WireTuple[];
    readonly append?: readonly WireTuple[];
    readonly remove?: readonly Json[];
};
```

Live push message (any subscription channel: SSE, WebSocket, polling).

### WirePage

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/WirePage

```ts
type WirePage = {
    readonly offset: number;
    readonly limit: number;
} | {
    readonly cursor: string | null;
    readonly limit: number;
};
```

### WirePredicate

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/WirePredicate

```ts
type WirePredicate = WireCondition | {
    readonly and: readonly WirePredicate[];
} | {
    readonly or: readonly WirePredicate[];
} | {
    readonly not: WirePredicate;
};
```

### WireRequest

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/WireRequest

```ts
type WireRequest = WireReadRequest | WireWriteRequest;
```

Read and write requests: what a `JsonTransport` (Data Grid sources) carries.

### WireResponse

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/WireResponse

```ts
type WireResponse = WireReadResponse | WireWriteResponse;
```

### WireTuple

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/WireTuple

```ts
type WireTuple = readonly unknown[];
```

### WireType

Kind: type

Page: https://salmonui.dev/docs/reference/data/json/WireType

```ts
type WireType = 'string' | 'number' | 'boolean' | 'date' | 'json';
```

## Constants

### PROTOCOL_VERSION

Kind: const

Page: https://salmonui.dev/docs/reference/data/json/PROTOCOL_VERSION

```ts
const PROTOCOL_VERSION = 1;
```
