@ex-grid/pivot-engine 0.0.0-stage → 0.2.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2206 @@
1
+ /**
2
+ * ExPivot's engine in TypeScript (ADR-0370, section 2): Excel's PivotTable over a Snapshot or records in
3
+ * memory. A Pivot Source answers a question with the Leaf Aggregates; the engine builds from them the row
4
+ * and column trees and every total, exactly where the numbers are exact (ADR-0060), and lays them out into
5
+ * a Pivot Report in the Compact, Outline or Tabular form. It is the C# engine's port, held to it by shared
6
+ * cases and a differential run.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+
11
+ import { ChangeBatch } from '@ex-grid/data';
12
+ import { Snapshot } from '@ex-grid/data';
13
+ import { SnapshotChange } from '@ex-grid/data';
14
+ import type { SnapshotColumn } from '@ex-grid/data';
15
+ import { SnapshotDecimal } from '@ex-grid/data';
16
+
17
+ /**
18
+ * The cube of a layout over records in memory, on the calling thread: the bundled source answers the
19
+ * layout's question with no cap on leaves, and the cube is built from its leaves. Refuses by name what
20
+ * {@link validateLayout} refuses, and a field list that declares a name twice.
21
+ */
22
+ export declare function aggregatePivot<TRecord>(records: readonly TRecord[], fields: readonly PivotRecordField<TRecord>[], layout: PivotLayout): PivotCube;
23
+
24
+ /** The C# engine's name of an Aggregation, as its messages write it: `Sum`, `CountNumbers`, `StdDevp`. */
25
+ export declare function aggregationTitle(aggregation: PivotAggregation): string;
26
+
27
+ /** The Item `(blank)`. */
28
+ export declare const blankItemKey: PivotItemKey;
29
+
30
+ /** The key of a Boolean Item. */
31
+ export declare function booleanItemKey(value: boolean): PivotItemKey;
32
+
33
+ /**
34
+ * A Layout menu choice applied (ADR-0061), as Excel's Design tab applies it. The Subtotals choices set
35
+ * every field in Rows and Columns — Automatic, or None — and, for the two that show them, where they stand;
36
+ * the Grand Totals choices set the two switches; the Report Layout choices set the form, or whether the
37
+ * Outline and Tabular forms repeat their outer Items' labels. Everything else in the layout is kept, and a
38
+ * choice that changes nothing returns the layout it was given.
39
+ */
40
+ export declare function chooseLayout(layout: PivotLayout, choice: PivotLayoutChoice): PivotLayout;
41
+
42
+ /** Aggregates and lays out in one step: {@link aggregatePivot} then {@link pivotReport}. */
43
+ export declare function computePivot<TRecord>(records: readonly TRecord[], fields: readonly PivotRecordField<TRecord>[], layout: PivotLayout, options?: PivotOptions): PivotReport;
44
+
45
+ /** A placement of the field, its settings checked and frozen. */
46
+ export declare function createPivotFieldPlacement(input: string | PivotFieldPlacementInput): PivotFieldPlacement;
47
+
48
+ /** A layout, every setting left out taking its default, and every placement and Value Field made by
49
+ * {@link createPivotFieldPlacement} and {@link createPivotValueField}. */
50
+ export declare function createPivotLayout({ filters, rows, columns, values, valuesAxis, form, subtotalsAtTop, grandTotalRow, grandTotalColumn, repeatItemLabels, }?: PivotLayoutInput): PivotLayout;
51
+
52
+ /** A Value Field of the field, its settings checked and frozen. */
53
+ export declare function createPivotValueField(input: string | PivotValueFieldInput): PivotValueField;
54
+
55
+ /** The key of a date Item, by its clock value in DateTime ticks. */
56
+ export declare function dateItemKey(ticks: bigint): PivotItemKey;
57
+
58
+ /** A field that is a part of a Date column (ADR-0060): its year, quarter or month, labelled `2026`, `Qtr3`,
59
+ * `Sep` in the report's words and ordered by the calendar. */
60
+ export declare function datePartField(name: string, column: string, part: PivotDatePart, caption?: string): PivotField;
61
+
62
+ /** The Aggregation a new Value Field of a field takes: Sum for a field declared Number, Count for any
63
+ * other (ADR-0060). */
64
+ export declare function defaultAggregation(field: PivotFieldInfo): PivotAggregation;
65
+
66
+ /** The default most Items a page lists. */
67
+ export declare const defaultMaxItems = 10000;
68
+
69
+ /** The default cap on leaves: "this layout needs more than 200,000 cells". */
70
+ export declare const defaultMaxLeaves = 200000;
71
+
72
+ /** No field anywhere: the report is empty and asks for fields. */
73
+ export declare const emptyPivotLayout: PivotLayout;
74
+
75
+ /** The Item `#NUM!`. */
76
+ export declare const errorItemKey: PivotItemKey;
77
+
78
+ /** A label's text estimated under the geometry, both sides' padding included, without reading a browser's
79
+ * layout. A lone surrogate is a character of the other class, as .NET reads it. */
80
+ export declare function estimateLabelPx(metrics: PivotLabelMetrics, text: string): number;
81
+
82
+ /**
83
+ * A source whose answers a Consumer fetches from a server (ADR-0066). The engine refuses what every source
84
+ * refuses before asking, and holds what comes back to the question: an answer to another question, more
85
+ * Items or records than were asked for, or records of other fields fail by name.
86
+ *
87
+ * **Live data** (ADR-0370 section 3): the Consumer's transport, started by {@link PivotFetchers.subscribe},
88
+ * tells the source that the server's data moved on, or hands it a Change Batch of the records the data lost
89
+ * and gained. Each listener {@link FetchingPivotSource.subscribe}d is told the new Source Version. Asked the
90
+ * question it answered last again, the source answers from the Leaf Aggregates it holds with the batches
91
+ * folded in, where subtraction and addition keep every part they touch exactly; otherwise — a notice, a batch
92
+ * out of chain, a sum that is a double, a product, a variance, an extreme a number left, Level Aggregates — it
93
+ * asks the server again. An answer fetched while a notice or a batch arrived is not held.
94
+ */
95
+ export declare class FetchingPivotSource implements PivotSource {
96
+ #private;
97
+ /** The fields the server has. */
98
+ readonly fields: readonly PivotField[];
99
+ /** The Aggregations the server answers. */
100
+ readonly features: PivotSourceFeatures;
101
+ /** A source of the server's fields and Aggregations, asked through the fetchers; the features declare
102
+ * that it counts Items exactly when a fetcher counts them. */
103
+ constructor(fields: readonly PivotField[], features: PivotSourceFeatures, fetch: PivotFetchers);
104
+ /** The server's Leaf Aggregates, held to the question; for the question answered last, the answer held
105
+ * with the batches heard since folded in, where they fold. */
106
+ aggregate(query: PivotQuery, signal?: AbortSignal): Promise<PivotAnswer>;
107
+ /** Tells `listener` each new Source Version the Consumer's transport reports, after the source has moved on
108
+ * to it; the function returned stops telling it. The transport runs while a listener is subscribed. */
109
+ subscribe(listener: (changed: PivotSourceChanged) => void): () => void;
110
+ /** Refresh: lets go of the answer held, so the next question is asked of the server. */
111
+ refresh(): void;
112
+ /** The server's page of Items, held to the most asked for. */
113
+ items(query: PivotItemsQuery, signal?: AbortSignal): Promise<PivotItemPage>;
114
+ /** The server's count of each field's Items (ADR-0370 section 3). Counts naming a field the source does
115
+ * not declare are refused by name. */
116
+ itemCounts(signal?: AbortSignal): Promise<PivotItemCounts>;
117
+ /** The server's page of records, held to the fields and the page asked for. */
118
+ details(query: PivotDetailsQuery, signal?: AbortSignal): Promise<PivotDetailPage>;
119
+ }
120
+
121
+ /** A template word with its arguments put in, as .NET's `string.Format` puts them in under the invariant
122
+ * culture: `{n}`, `{n,width}`, `{n:format}` (a text takes no format), and `{{` and `}}` for a brace. A
123
+ * template .NET refuses throws a PivotFormatError. */
124
+ export declare function fillPivotWord(template: string, ...args: readonly string[]): string;
125
+
126
+ /**
127
+ * A count written as the report writes a whole number in `locale`, a BCP 47 tag or `invariant`, with its
128
+ * group separators: `1,020,000` in en-US, `1.020.000` in de-DE, as C#'s `count.ToString("N0", culture)`
129
+ * writes it. The Field List writes a field's count of Items with it, and the leaf cap's refusal its figures
130
+ * (ADR-0370 section 3). A count that is not a whole number of at least 0 is refused.
131
+ */
132
+ export declare function formatPivotCount(count: number, locale: string): string;
133
+
134
+ /**
135
+ * A value of a record behind a cell, `value`, written as Show Details shows it in its field's column: in `format`,
136
+ * the field's own format, where it is a number or a date, under `locale`, a BCP 47 tag or `invariant`. A Blank is
137
+ * written as nothing.
138
+ */
139
+ export declare function formatPivotDetailValue(value: PivotDetailValue, format: string | undefined, locale: string): string;
140
+
141
+ /**
142
+ * A figure written in a number format in `locale`, as C#'s `ToString(format, culture)` writes the decimal or the
143
+ * double it is: a Selection Summary's figure in the Focus value's format, as the report shows that value (ADR-0130).
144
+ * A format .NET cannot format a number with throws a `PivotFormatError`.
145
+ */
146
+ export declare function formatPivotFigure(value: PivotNumber, format: string, locale: string): string;
147
+
148
+ /**
149
+ * A number written in a number format in `locale`, as C#'s `value.ToString(format, culture)` writes it: what a
150
+ * Value Field's number format makes of a figure, which Value Field Settings… shows as its sample (ADR-0061).
151
+ * A format .NET cannot format a number with throws a `PivotFormatError`; `pivotNumberFormatProblem` says so
152
+ * first.
153
+ */
154
+ export declare function formatPivotNumber(value: number, format: string, locale: string): string;
155
+
156
+ /** Whether the layout places no field at all. */
157
+ export declare function isEmptyLayout(layout: PivotLayout): boolean;
158
+
159
+ /** Whether the placement's Item is collapsed. */
160
+ export declare function isItemCollapsed(placement: PivotFieldPlacement, item: PivotItemKey): boolean;
161
+
162
+ /**
163
+ * Whether a choice is what the report shows now — the Layout menu marks it (ADR-0061). Read from what is
164
+ * painted: in the Tabular form, which puts every subtotal at the bottom, Show at Bottom is the current
165
+ * Subtotals choice whatever the layout's setting; in the Compact form, which has no outer label columns,
166
+ * neither label choice is. With no field in Rows or Columns no Subtotals choice is current, and with fields
167
+ * that disagree, none is.
168
+ */
169
+ export declare function isLayoutChosen(layout: PivotLayout, choice: PivotLayoutChoice): boolean;
170
+
171
+ /** Whether the groups below `item` are shown under `rule`. */
172
+ export declare function isLevelExpanded(rule: PivotLevelRule, item: PivotItemKey): boolean;
173
+
174
+ /** Whether an entry is Σ Values. */
175
+ export declare function isValuesPseudoField(entry: PivotEntry): boolean;
176
+
177
+ /** Whether two keys name one Item: the same kind and text, text compared ignoring case. */
178
+ export declare function itemKeysEqual(a: PivotItemKey, b: PivotItemKey): boolean;
179
+
180
+ /**
181
+ * Every Item of a placed field over all the records, in the field's order — what Filter… lists (ADR-0061)
182
+ * — each with its label and whether it is hidden now. For a cube built by {@link aggregatePivot}; a cube
183
+ * built from a source's answer asks the source for a page and lays it out with {@link itemsOfPage}.
184
+ */
185
+ export declare function itemsOfCube(cube: PivotCube, layout: PivotLayout, field: string, options?: PivotOptions): readonly PivotItemInfo[];
186
+
187
+ /**
188
+ * A page of a field's Items as Filter… and the report filter band list them (ADR-0061): in the field's
189
+ * order under the layout — its declared Items first, then by kind and label under the report's locale,
190
+ * descending when the field is — each with its label and whether the layout hides it now.
191
+ */
192
+ export declare function itemsOfPage(page: PivotItemPage, layout: PivotLayout, field: PivotField, options?: PivotOptions): readonly PivotItemInfo[];
193
+
194
+ /** The words of Excel's Japanese edition: `行ラベル`, `総計`, `合計 / 金額`, `(空白)`, a date part's
195
+ * `2026年`, `第3四半期`, `9月`. A {@link PivotLabel} to hand to a report's options in one line. */
196
+ export declare const japanesePivotWords: PivotLabel;
197
+
198
+ /**
199
+ * Whether a choice would change what the report shows (ADR-0061): the Layout menu disables one that would
200
+ * not. The current choice never would. Nor would a Subtotals choice with no field in Rows or Columns, Show
201
+ * at Top in the Tabular form, nor a label choice in the Compact form.
202
+ */
203
+ export declare function layoutChoiceChanges(layout: PivotLayout, choice: PivotLayoutChoice): boolean;
204
+
205
+ /** The question {@link queryForLayout} asks, with the groups the layout shows (ADR-0370 section 3): what
206
+ * ExPivot asks a source that answers Level Aggregates. With a `window`, each row field whose Items show no groups
207
+ * below them — the innermost, or one collapsed with none toggled — and that the layout sorts by a value shown as it
208
+ * is computed carries that order, so a set of it too large to answer whole is answered as a Sibling Window; a value
209
+ * shown as a percentage, a sort by label, or a field with groups shown below it carries none. */
210
+ export declare function levelQueryForLayout(layout: PivotLayout, maxLeaves?: number, window?: PivotLevelWindowInput): PivotQuery;
211
+
212
+ /** The groups a layout shows: each row and column field's collapse state. */
213
+ export declare function levelsOfLayout(layout: PivotLayout): PivotLevels;
214
+
215
+ /**
216
+ * A report source over a Pivot Source in memory — a Snapshot's, records', or a server's behind a fetching
217
+ * source (ADR-0151). Each request lays the report out afresh where its question, layout or data changed,
218
+ * answers the Window asked for with every row projected from the newest report, and holds the last
219
+ * `versionsKept` Report Versions for the operations that name one. A row the held Window shows alike is the
220
+ * very row it holds. A cell whose shown text a change of the data moved is marked with the version that
221
+ * published the change, for as long as the settings' highlight lasts (ADR-0068, ADR-0153).
222
+ *
223
+ * Requests are answered one at a time, in the order made. Each runs its pass, cube, report and label widths
224
+ * on one Slicer (PV-40), and a cancelled one rejects with its signal's reason, leaving the versions held as
225
+ * they were. A versioned operation reads the version it names and never waits on a newer computation.
226
+ */
227
+ export declare class LocalPivotReportSource implements PivotReportSource {
228
+ #private;
229
+ /** A report source over `source`, which it does not own. Refuses, with a RangeError, a `versionsKept` that
230
+ * is not a whole number of at least 1. */
231
+ constructor(source: PivotSource, options?: LocalPivotReportSourceOptions);
232
+ /** The Pivot Source's fields. */
233
+ get fields(): readonly PivotField[];
234
+ /** The Pivot Source's Aggregations. */
235
+ get features(): PivotSourceFeatures;
236
+ /** `incremental` over a Snapshot, whose Change Batches name what changed; `fullRefresh` otherwise. */
237
+ get updateMode(): PivotReportUpdateMode;
238
+ /** Tells `listener` each new Source Version the Pivot Source reports — over a Snapshot, or from a server's
239
+ * transport (ADR-0370 section 3); the function returned stops telling it. */
240
+ subscribe(listener: (changed: PivotSourceChanged) => void): () => void;
241
+ /**
242
+ * A Window of the report the request's layout makes from the newest data — or, for a layout gesture that
243
+ * names the Window it holds, from the data that Window shows — or a refusal by name: of the Pivot Source,
244
+ * of an Order Key policy not registered, or of an Order Key that failed on an Item. Rejects with what a
245
+ * layout the source cannot lay out throws, and with the signal's reason once it is aborted.
246
+ */
247
+ window(request: PivotReportRequest, signal?: AbortSignal): Promise<PivotReportUpdate>;
248
+ /** A field's Items as the Pivot Source lists them, under a Source Version. */
249
+ rawItems(query: PivotItemsQuery, signal?: AbortSignal): Promise<PivotItemPage>;
250
+ /** A field's Items labelled and ordered as a held Report Version shows them, under its Source Version; refused
251
+ * by name for a version not held, a field not declared, the Pivot Source's refusal, and an Order Key that
252
+ * fails on an Item. */
253
+ items(query: PivotReportItemsQuery, signal?: AbortSignal): Promise<PivotReportItemsResult>;
254
+ /** A page of the records behind a cell under the Source Version its question names (ADR-0151): answered while
255
+ * the Pivot Source holds that version, however many layouts came since, and refused by it once it does not. */
256
+ details(query: PivotDetailsQuery, signal?: AbortSignal): Promise<PivotDetailPage>;
257
+ /** Every selected cell of a held Report Version, each rectangle whole, in the order asked; refused by name for
258
+ * a version not held, a column not the report's or named twice, a rectangle outside the report, and a copy
259
+ * past `maxCells` — never cut short (spine 1). */
260
+ copy(query: PivotReportCopyQuery, signal?: AbortSignal): Promise<PivotReportCopyResult>;
261
+ /** The Selection Summary of a held Report Version: Count, Numerical Count, Sum, Min and Max, a cell under two
262
+ * rectangles counted once, shown in the Focus value's format (ADR-0130). */
263
+ summary(query: PivotReportSummaryQuery, signal?: AbortSignal): Promise<PivotReportSummaryResult>;
264
+ /** Releases the report's state and stops hearing the Pivot Source, which it does not own: every later call
265
+ * throws. */
266
+ dispose(): void;
267
+ }
268
+
269
+ /** What a local report source is made with. */
270
+ export declare interface LocalPivotReportSourceOptions {
271
+ /** The Order Keys a request's settings may name for a field, by name (ADR-0152). */
272
+ readonly orderKeys?: Readonly<Record<string, PivotOrderKey>>;
273
+ /** How many Report Versions are held for the versioned operations; 2 when left out. The reports the
274
+ * Change Highlight compares are held as well, for as long as they are marked (ADR-0153). */
275
+ readonly versionsKept?: number;
276
+ /** The clock that times how long a change stays marked, in milliseconds; `Date.now` when left out. It
277
+ * only bounds what is kept: when a highlight starts is the Consumer's ({@link PivotChangeTimes}). */
278
+ readonly now?: () => number;
279
+ /** How the work shares the thread (PV-40). */
280
+ readonly slicing?: PivotSlicing;
281
+ }
282
+
283
+ /**
284
+ * A placed entry dropped on an Area at `index` (ADR-0061). Within its own Area it is a reorder. A field
285
+ * moving between Filters, Rows and Columns keeps its settings; one moving to Values leaves its Area and
286
+ * becomes a Value Field; a Value Field moving to another Area leaves Values and its field is placed there.
287
+ * Σ Values moves between Rows and Columns only — anywhere else it stays — and always stands last. `field`
288
+ * is the dragged entry's field, whose declared type decides a new Value Field's Aggregation; it is not read
289
+ * for Σ Values.
290
+ */
291
+ export declare function moveEntry(layout: PivotLayout, entry: PivotEntry, area: PivotArea, index: number, field: PivotFieldInfo | undefined): PivotLayout;
292
+
293
+ /** The key of a number Item; a number that is not finite is `#NUM!`, and -0 is 0. */
294
+ export declare function numberItemKey(number: number): PivotItemKey;
295
+
296
+ /** How a Value Field summarises the records at a cell: Excel's "Summarize Values By" (ADR-0060). */
297
+ export declare type PivotAggregation = 'sum' | 'count' | 'average' | 'max' | 'min' | 'product' | 'countNumbers' | 'stdDev' | 'stdDevp' | 'var' | 'varp';
298
+
299
+ /** The id of an Aggregation's name: `aggregation-sum` is `Sum`. */
300
+ export declare function pivotAggregationNameId(aggregation: PivotAggregation): string;
301
+
302
+ /** Every Aggregation, in the C# engine's order. */
303
+ export declare const pivotAggregations: readonly PivotAggregation[];
304
+
305
+ /** A Pivot Source's answer: the Leaf Aggregates under a Source Version, or a refusal. */
306
+ export declare class PivotAnswer {
307
+ #private;
308
+ /** The refusal, when the source refused. */
309
+ readonly refusal: PivotSourceRefusal | undefined;
310
+ /** How many leaves the answer has. */
311
+ readonly leafCount: number;
312
+ /** Whether the answer holds the cells of the groups shown — Level Aggregates — rather than the leaves
313
+ * (ADR-0370 section 3). */
314
+ readonly isLevels: boolean;
315
+ private constructor();
316
+ /** A refusal, as an answer. */
317
+ static refused(refusal: PivotSourceRefusal): PivotAnswer;
318
+ /** Whether the source refused. */
319
+ get isRefused(): boolean;
320
+ /** The Source Version the answer was computed at. A refusal has none, and throws. */
321
+ get sourceVersion(): string;
322
+ /** The row fields, in the question's order. */
323
+ get rows(): readonly PivotAnswerAxis[];
324
+ /** The column fields, in the question's order. */
325
+ get columns(): readonly PivotAnswerAxis[];
326
+ /** Each field in Values, in the question's order. */
327
+ get values(): readonly PivotAnswerValues[];
328
+ /** The included records at a leaf. */
329
+ recordsAt(leaf: number): number;
330
+ /** The sibling sets answered as windows (ADR-0370 section 3); none in an answer of leaves. */
331
+ get windows(): readonly PivotAnswerWindow[];
332
+ /** The window and side a rest cell merges, or `undefined` for a cell of a group. */
333
+ restAt(cell: number): PivotAnswerRest | undefined;
334
+ /** What does not answer the question, in words, or `undefined` when the answer answers it. */
335
+ mismatch(query: PivotQuery): string | undefined;
336
+ }
337
+
338
+ /** One row or column field of an answer: its Items, and each leaf's Item among them. */
339
+ export declare class PivotAnswerAxis {
340
+ #private;
341
+ /** The field. */
342
+ readonly field: string;
343
+ /** Its Items that some leaf carries. */
344
+ readonly items: readonly PivotItemKey[];
345
+ /** @internal */
346
+ constructor(field: string, items: readonly PivotItemKey[], itemOfLeaf: readonly number[]);
347
+ /** The index among {@link PivotAnswerAxis.items} of a leaf's Item; in a level answer, −1 for a cell above
348
+ * this field, which stands for every Item of it. */
349
+ itemAt(leaf: number): number;
350
+ }
351
+
352
+ /**
353
+ * Builds an answer a leaf at a time, as a server's rows arrive (ADR-0066): each leaf named by its Items, one
354
+ * per row and column field, with its record count, and the parts asked for of each field in Values set on
355
+ * it. Two leaves for one combination of Items are refused, and so is a part the question did not ask for.
356
+ *
357
+ * A server that answers Level Aggregates (ADR-0370 section 3) adds the cells of the groups shown with
358
+ * {@link PivotAnswerBuilder.addCell} instead, from `GROUPING SETS` for instance, and gives a sum that is a
359
+ * double with the sum of its magnitudes; an answer holds leaves or cells, never both.
360
+ */
361
+ export declare class PivotAnswerBuilder {
362
+ #private;
363
+ /** A builder for the answer to `query`, under `sourceVersion`. */
364
+ constructor(query: PivotQuery, sourceVersion: string);
365
+ /** How many leaves have been added. */
366
+ get leafCount(): number;
367
+ /** Adds a leaf of `records` records (at least 1) at one Item per row and column field, outermost row
368
+ * field first; its index. */
369
+ addLeaf(items: readonly PivotItemKey[], records: number): number;
370
+ /**
371
+ * Adds the cell of a shown row group crossed with a shown column group, and returns its index (ADR-0370
372
+ * section 3): an answer of Level Aggregates, to a question carrying levels. Each group is named by its
373
+ * Items, outermost first, down to its depth — none for a grand total. Refuses a cell of no records, more
374
+ * Items than an axis has fields, and a second cell for the same Items. Which cells are shown, and that each
375
+ * has its parent, is checked when the answer is read against the question.
376
+ */
377
+ addCell(rowItems: readonly PivotItemKey[], columnItems: readonly PivotItemKey[], records: number): number;
378
+ /**
379
+ * Adds a sibling set answered as a window, and returns its index (ADR-0370 section 3): the children of the
380
+ * row group `parentRows` names, of which `before` come before the first one shown and `after` after the
381
+ * last, each count taking in its margin. The margins and the siblings shown are added as cells; the siblings
382
+ * beyond each margin as rest cells with {@link PivotAnswerBuilder.addRest}. Refuses a second window for one
383
+ * parent; whether the window answers the question is checked when the answer is read against it.
384
+ */
385
+ addWindow(parentRows: readonly PivotItemKey[], before: number, after: number): number;
386
+ /**
387
+ * Adds a rest cell of a window, and returns its index (ADR-0370 section 3): the siblings on one side beyond
388
+ * its margin, merged, crossed with the shown column group `columnItems` names. Its parts are set as a cell's.
389
+ * Refuses one of no records and a second one for the same side and column group.
390
+ */
391
+ addRest(window: number, side: PivotRestSide, columnItems: readonly PivotItemKey[], records: number): number;
392
+ /** Sets a leaf's counts for a field in Values. */
393
+ setCounts(leaf: number, value: number, values: number, numbers: number, nonFinite?: boolean): void;
394
+ /** Sets a leaf's sum for a field in Values. */
395
+ setSum(leaf: number, value: number, sum: PivotNumber): void;
396
+ /** Sets a cell's sum of Level Aggregates with the sum of its numbers' magnitudes, which a sum that is a
397
+ * double carries (ADR-0370 section 3): what bounds its rounding when the cell is checked against its
398
+ * parent. */
399
+ setLevelSum(leaf: number, value: number, sum: PivotNumber, absoluteSum: number): void;
400
+ /** Sets a leaf's extremes for a field in Values: both exact or both doubles. */
401
+ setExtremes(leaf: number, value: number, min: PivotNumber, max: PivotNumber): void;
402
+ /** Sets a leaf's product for a field in Values. */
403
+ setProduct(leaf: number, value: number, product: number): void;
404
+ /** Sets a leaf's running variance for a field in Values. */
405
+ setVariance(leaf: number, value: number, mean: number, m2: number): void;
406
+ /** The answer, once: one with more leaves than the question allows is refused. */
407
+ build(): PivotAnswer;
408
+ }
409
+
410
+ /** A rest cell's window, by its place among the answer's windows, and its side. */
411
+ export declare interface PivotAnswerRest {
412
+ /** The window, by its place among {@link PivotAnswer.windows}. */
413
+ readonly window: number;
414
+ /** The side whose siblings beyond the margin it merges. */
415
+ readonly side: PivotRestSide;
416
+ }
417
+
418
+ /** One field in Values of an answer: the parts at each leaf. */
419
+ export declare class PivotAnswerValues {
420
+ #private;
421
+ /** The field. */
422
+ readonly field: string;
423
+ private constructor();
424
+ /** The parts carried beyond the counts. */
425
+ get parts(): readonly PivotPart[];
426
+ /** The values at a leaf that are not Blank. */
427
+ valuesAt(leaf: number): number;
428
+ /** The numbers at a leaf, non-finite ones included. */
429
+ numbersAt(leaf: number): number;
430
+ /** Whether a non-finite number is among a leaf's values. */
431
+ nonFiniteAt(leaf: number): boolean;
432
+ /** The sum of a leaf's numbers. */
433
+ sumAt(leaf: number): PivotNumber;
434
+ /** The smallest of a leaf's numbers. */
435
+ minAt(leaf: number): PivotNumber;
436
+ /** The largest of a leaf's numbers. */
437
+ maxAt(leaf: number): PivotNumber;
438
+ /** The sum of the magnitudes of a cell's numbers, which a level answer carries beside a sum that is a
439
+ * double: what bounds its rounding when it is checked against its parent (ADR-0370 section 3).
440
+ * `undefined` for an exact sum, and in an answer of leaves. */
441
+ absoluteSumAt(leaf: number): number | undefined;
442
+ /** The product of a leaf's numbers. */
443
+ productAt(leaf: number): number;
444
+ /** The running mean of a leaf's numbers. */
445
+ meanAt(leaf: number): number;
446
+ /** The running sum of squared deviations of a leaf's numbers. */
447
+ m2At(leaf: number): number;
448
+ }
449
+
450
+ /**
451
+ * A sibling set answered as a window (ADR-0370 section 3): its parent row group, and how many of its siblings
452
+ * come before the first one shown and after the last. Each count, when above 0, takes in a margin — the
453
+ * nearest sibling on that side, answered as any shown group is and not shown — and the siblings beyond it,
454
+ * merged into the window's rest cells on that side.
455
+ */
456
+ export declare interface PivotAnswerWindow {
457
+ /** The parent's Item at each row field above the set, as an index among that axis's Items: none for the
458
+ * grand total. */
459
+ readonly parent: readonly number[];
460
+ /** The siblings before the first one shown, its margin among them. */
461
+ readonly before: number;
462
+ /** The siblings after the last one shown, its margin among them. */
463
+ readonly after: number;
464
+ }
465
+
466
+ /** The four places a Pivot Field stands, in Excel's words (ADR-0061). */
467
+ export declare type PivotArea = 'filters' | 'columns' | 'rows' | 'values';
468
+
469
+ /** Where Σ Values stands, when there are two or more Value Fields: innermost in Columns, Excel's default,
470
+ * or in Rows (ADR-0060). */
471
+ export declare type PivotAxis = 'columns' | 'rows';
472
+
473
+ /** The id of a Value Field's default caption: `caption-sum` is `Sum of {0}`, `{0}` the field's caption. */
474
+ export declare function pivotCaptionId(aggregation: PivotAggregation): string;
475
+
476
+ /**
477
+ * When this Consumer first showed each change a report source marks. A source marks each changed cell with
478
+ * the Report Version whose data changed it ({@link PivotDisplayRow.changedIn}) and lists the changes it still
479
+ * marks ({@link PivotReportMetadata.changeMarks}). A listed change is stamped the first time a Window of a
480
+ * report listing it is adopted — whether or not that Window holds one of its cells — so a row first asked for
481
+ * later, by a scroll, shows it as of that first time, and its highlight ends with the others of the change. A
482
+ * change no longer listed is never stamped; a stamp is kept while the source lists its change or its highlight
483
+ * has not ended, and once forgotten the change is never listed again, so none is stamped twice. One instance
484
+ * serves a view for its lifetime, across new sources.
485
+ */
486
+ export declare class PivotChangeTimes {
487
+ #private;
488
+ /** Takes a Window up as it is shown at `now`, on the Consumer's clock in milliseconds: each change its
489
+ * report lists that is not stamped yet is stamped `now`, and each stamp whose change is no longer listed
490
+ * and whose highlight of `highlightMs` has ended is forgotten. */
491
+ adopt(state: PivotReportState, now: number, highlightMs: number): void;
492
+ /** When the change `mark` names was first shown, or `undefined` for no mark or one not stamped. */
493
+ at(mark: string | undefined): number | undefined;
494
+ /** When the shown text of a row's value cell last changed with the data, as this Consumer first showed
495
+ * it; `undefined` when it did not change recently. */
496
+ changedAt(row: PivotDisplayRow, valueColumn: number): number | undefined;
497
+ }
498
+
499
+ /** What a value column of a report stands for (ADR-0060). */
500
+ export declare type PivotColumnRole = 'item' | 'subtotal' | 'grandTotal';
501
+
502
+ /** The cube a report is laid out from (ADR-0060/0066): the answer's leaves, each axis's tree of Items, and
503
+ * every total merged from the leaves beneath it. Made by {@link pivotCube} or {@link aggregatePivot}. */
504
+ export declare class PivotCube {
505
+ #private;
506
+ /** The question the cube answers. */
507
+ readonly query: PivotQuery;
508
+ /** The Source Version its answer was computed at. */
509
+ readonly sourceVersion: string;
510
+ /** How many records its leaves hold: those no Hidden Item left out. */
511
+ readonly includedRecordCount: number;
512
+ /** Whether it was made from Level Aggregates (ADR-0370 section 3): it holds the groups the question's levels
513
+ * show and no others, so a layout that shows others is asked again. */
514
+ readonly isLevels: boolean;
515
+ private constructor();
516
+ /** Whether the cube was aggregated under the layout's placed fields, Hidden Items and Value Fields, with
517
+ * the parts each of its Aggregations reads; one made from Level Aggregates, also under the groups the layout
518
+ * shows, and one that answered Sibling Windows, also under the orders and collapse the layout asks them by. */
519
+ holds(layout: PivotLayout): boolean;
520
+ }
521
+
522
+ /**
523
+ * The cube of a Pivot Source's answer (ADR-0066): the row and column trees its leaves form, and every
524
+ * subtotal and grand total merged from the leaves' parts — each total from its records, never from the
525
+ * totals below it (ADR-0060). Refuses by name an answer to another question, a refusal, and a field
526
+ * neither declared nor named by the question.
527
+ */
528
+ export declare function pivotCube(query: PivotQuery, answer: PivotAnswer, fields: readonly PivotField[]): PivotCube;
529
+
530
+ /**
531
+ * {@link pivotCube} in slices (PV-40): the same steps over the answer's leaves and cells, a piece at a time,
532
+ * yielding between slices as `slicing` paces them, so that a large answer's cube leaves the page painting. It
533
+ * gives the cube {@link pivotCube} gives, and rejects with what it throws. Once `signal` is aborted, it stops at
534
+ * the next slice and rejects with the signal's reason. A call begins a slice of its own, and its last slice ends
535
+ * without a yield, as a source's question does: a caller that asks, makes the cube and lays out the report one
536
+ * after another yields between them where the page must paint.
537
+ */
538
+ export declare function pivotCubeAsync(query: PivotQuery, answer: PivotAnswer, fields: readonly PivotField[], slicing?: PivotSlicing, signal?: AbortSignal): Promise<PivotCube>;
539
+
540
+ /** A part of a Date column a Pivot Field can be declared as: its year, quarter or month (ADR-0060). */
541
+ export declare type PivotDatePart = 'year' | 'quarter' | 'month';
542
+
543
+ /** A page of the records behind a cell (ADR-0063/0066), or a refusal. */
544
+ export declare class PivotDetailPage {
545
+ #private;
546
+ /** The refusal, when the source refused. */
547
+ readonly refusal: PivotSourceRefusal | undefined;
548
+ private constructor();
549
+ /** A page: the fields, where it starts, how many records there are in all, and the records. */
550
+ static of(sourceVersion: string, fields: readonly PivotField[], start: number, total: number, records: readonly PivotDetailRecord[]): PivotDetailPage;
551
+ /** The source's refusal to show the records. */
552
+ static refused(refusal: PivotSourceRefusal): PivotDetailPage;
553
+ /** Whether the source refused. */
554
+ get isRefused(): boolean;
555
+ /** The Source Version the records were read at. */
556
+ get sourceVersion(): string;
557
+ /** The fields each record carries a value of, in order. */
558
+ get fields(): readonly PivotField[];
559
+ /** The place of the page's first record among all of them. */
560
+ get start(): number;
561
+ /** How many records are behind the cell in all. */
562
+ get total(): number;
563
+ /** The page's records. */
564
+ get records(): readonly PivotDetailRecord[];
565
+ }
566
+
567
+ /** One record behind a cell: each field's value, in the page's field order, and the Consumer's record where
568
+ * the source holds one. */
569
+ export declare interface PivotDetailRecord {
570
+ /** Each field's value, in the page's field order. */
571
+ readonly values: readonly PivotDetailValue[];
572
+ /** The Consumer's record, where the source holds one. */
573
+ readonly record?: unknown;
574
+ }
575
+
576
+ /** One page of the records behind a cell (ADR-0063/0066): those carrying every Item of its paths and no
577
+ * Hidden Item of any placed field, under a Source Version. */
578
+ export declare interface PivotDetailsQuery {
579
+ /** The Source Version the records are asked for under. */
580
+ readonly sourceVersion: string;
581
+ /** The row's Items, outermost first. */
582
+ readonly rowItems: readonly PivotFieldItem[];
583
+ /** The column's Items, outermost first. */
584
+ readonly columnItems: readonly PivotFieldItem[];
585
+ /** Every placed field's Hidden Items. */
586
+ readonly hiddenItems: readonly PivotQueryField[];
587
+ /** The place of the page's first record. */
588
+ readonly start: number;
589
+ /** The most records the page holds; every one, 2^31 − 1 as the C# engine's `int.MaxValue`, when the
590
+ * question was made without one, so that it crosses to a C# server as it is. */
591
+ readonly count: number;
592
+ }
593
+
594
+ /** A question for the records behind a cell, checked: a path naming a field twice, or Hidden Items given
595
+ * twice for one field, are refused by name. */
596
+ export declare function pivotDetailsQuery({ sourceVersion, rowItems, columnItems, hiddenItems, start, count }: {
597
+ readonly sourceVersion: string;
598
+ readonly rowItems?: readonly PivotFieldItem[];
599
+ readonly columnItems?: readonly PivotFieldItem[];
600
+ readonly hiddenItems?: readonly PivotQueryField[];
601
+ readonly start?: number;
602
+ readonly count?: number;
603
+ }): PivotDetailsQuery;
604
+
605
+ /** A value a record behind a cell carries: text, an exact number, a double, a date by its clock ticks, a
606
+ * Boolean, or `null` for a Blank. A date part is the part's number. */
607
+ export declare type PivotDetailValue = string | SnapshotDecimal | number | bigint | boolean | null;
608
+
609
+ /** A value column of a report, with its Items. */
610
+ export declare interface PivotDisplayColumn {
611
+ /** Its stable name. */
612
+ readonly name: string;
613
+ /** Its leaf header. */
614
+ readonly header: string;
615
+ /** An Item's column, a subtotal's, or the grand total's. */
616
+ readonly role: PivotColumnRole;
617
+ /** The Value Field it shows, or −1 when its rows say. */
618
+ readonly valueField: number;
619
+ /** The column's Items, each with its field. */
620
+ readonly columnPath: readonly PivotFieldItem[];
621
+ }
622
+
623
+ /** A row of a Window, detached from the report, the cube and the source. */
624
+ export declare interface PivotDisplayRow {
625
+ /** What the row stands for. */
626
+ readonly role: PivotRowRole;
627
+ /** The Value Field the row shows, or −1 when its columns say. */
628
+ readonly valueField: number;
629
+ /** The row's Items, outermost first: with its role and Value Field, what it stands for across reports. */
630
+ readonly items: readonly PivotItemKey[];
631
+ /** Whether the row carries values: a group row whose subtotal stands at the bottom carries none. */
632
+ readonly carriesValues: boolean;
633
+ /** Its label in each label column. */
634
+ readonly labels: readonly PivotRowLabel[];
635
+ /** Its value in each value column, `undefined` for an empty cell. */
636
+ readonly values: readonly (PivotValue | undefined)[];
637
+ /** The row's Items, each with its field. */
638
+ readonly rowPath: readonly PivotFieldItem[];
639
+ /**
640
+ * Per value cell, the change that last moved its shown text: the Report Version whose data changed it,
641
+ * or `undefined` for a cell with no recent change and for every cell a layout gesture laid out. A cell keeps
642
+ * its mark while its text does not change, after the source stops listing the change, so that its row
643
+ * stays the same row. It says which change, never when: when a Change Highlight starts is the Consumer's,
644
+ * on its own clock ({@link PivotChangeTimes}, ADR-0068).
645
+ */
646
+ readonly changedIn: readonly (string | undefined)[];
647
+ }
648
+
649
+ /** An edit that may be refused: the layout it produced, or the unchanged layout and why not. */
650
+ export declare interface PivotEditResult {
651
+ /** The new layout, or the one given when refused. */
652
+ readonly layout: PivotLayout;
653
+ /** Why the edit was refused. */
654
+ readonly refusal?: PivotRefusal;
655
+ }
656
+
657
+ /** A placed entry of an Area, as the Field List shows it (ADR-0061): a field in Filters, Rows or Columns,
658
+ * a Value Field, or Σ Values, whose index is −1 and which stands last in its Area. */
659
+ export declare interface PivotEntry {
660
+ /** The Area it stands in. */
661
+ readonly area: PivotArea;
662
+ /** Its index in that Area's list; −1 for Σ Values. */
663
+ readonly index: number;
664
+ }
665
+
666
+ /** The text of `#NUM!`, the Item of a number no one can hold. */
667
+ export declare const pivotErrorText = "#NUM!";
668
+
669
+ /** How a fetching source asks its server. */
670
+ export declare interface PivotFetchers {
671
+ /** Asks the server for the Leaf Aggregates of a question. */
672
+ readonly aggregate: (query: PivotQuery, signal?: AbortSignal) => Promise<PivotAnswer>;
673
+ /** Asks the server for a page of a field's Items. */
674
+ readonly items: (query: PivotItemsQuery, signal?: AbortSignal) => Promise<PivotItemPage>;
675
+ /** Asks the server for a page of the records behind a cell. */
676
+ readonly details: (query: PivotDetailsQuery, signal?: AbortSignal) => Promise<PivotDetailPage>;
677
+ /** Asks the server for each field's count of Items, when the features declare that it counts them. */
678
+ readonly itemCounts?: (signal?: AbortSignal) => Promise<PivotItemCounts>;
679
+ /**
680
+ * Starts the Consumer's transport telling the source that the server's data moved on (ADR-0370 section 3):
681
+ * WebSocket, server-sent events, SignalR or polling, the Consumer's own. The source calls it when its first
682
+ * listener subscribes, with the function the transport calls for each notice or Change Batch, and calls the
683
+ * function it returns when its last listener leaves.
684
+ */
685
+ readonly subscribe?: (notify: (notice: PivotServerNotice) => void) => () => void;
686
+ }
687
+
688
+ /** A Pivot Field as a source offers it: everything but how it is read from a record. */
689
+ export declare interface PivotField {
690
+ /** What a Pivot Layout addresses it by; unique among the fields. */
691
+ readonly name: string;
692
+ /** What the Field List and the report call it. */
693
+ readonly caption: string;
694
+ /** The declared type, which decides the defaults (ADR-0060). */
695
+ readonly type: PivotFieldType;
696
+ /** A .NET format string an Item's number or date is labelled with, under the report's locale; absent for
697
+ * the value's own text. */
698
+ readonly format?: string;
699
+ /** Values whose Items come first, in this order, when the field is sorted by label. */
700
+ readonly itemOrder: readonly unknown[];
701
+ /** The Snapshot column the field reads, when it is not the column of its own name. */
702
+ readonly column?: string;
703
+ /** The part of a Date column the field is: its year, quarter or month. */
704
+ readonly datePart?: PivotDatePart;
705
+ /** The field's Order Key. */
706
+ readonly orderKey?: PivotOrderKey;
707
+ }
708
+
709
+ /** A field, its declaration checked and frozen. Refuses, with a TypeError, an empty name, an empty caption,
710
+ * an empty column, a format that cannot format the field's values and a date part of a field not declared
711
+ * Date; with a RangeError an unknown type or date part. */
712
+ export declare function pivotField(input: PivotFieldInput): PivotField;
713
+
714
+ /** What the Field List reads of a field: its name, caption and declared type. */
715
+ export declare type PivotFieldInfo = Pick<PivotField, 'name' | 'caption' | 'type'>;
716
+
717
+ /** A field's declaration, each setting left out taking its default: the name for the caption, no format,
718
+ * no declared order, the column of its own name, no Order Key. */
719
+ export declare interface PivotFieldInput {
720
+ /** What a Pivot Layout addresses it by. */
721
+ readonly name: string;
722
+ /** The declared type. */
723
+ readonly type: PivotFieldType;
724
+ /** What the Field List and the report call it; its name when left out. */
725
+ readonly caption?: string;
726
+ /** A .NET format string its Items are labelled with. */
727
+ readonly format?: string;
728
+ /** Values whose Items come first, in this order. */
729
+ readonly itemOrder?: readonly unknown[];
730
+ /** The Snapshot column it reads; the column of its own name when left out. */
731
+ readonly column?: string;
732
+ /** The part of a Date column it is. */
733
+ readonly datePart?: PivotDatePart;
734
+ /** Its Order Key. */
735
+ readonly orderKey?: PivotOrderKey;
736
+ }
737
+
738
+ /** An Item of a field, as a cell's path names it. */
739
+ export declare interface PivotFieldItem {
740
+ /** The field's name. */
741
+ readonly field: string;
742
+ /** The Item. */
743
+ readonly item: PivotItemKey;
744
+ }
745
+
746
+ /** A Pivot Field standing in Filters, Rows or Columns, with its settings, which travel with it when it
747
+ * moves between those Areas (ADR-0060/0061). */
748
+ export declare interface PivotFieldPlacement {
749
+ /** The Pivot Field's name. */
750
+ readonly field: string;
751
+ /** The Item order. */
752
+ readonly sort: PivotSort;
753
+ /** The Items the user unticked: every record carrying one is left out of the report, totals included. */
754
+ readonly hiddenItems: readonly PivotItemKey[];
755
+ /** Whether an outer Item of this field has a subtotal (Excel's Automatic) or none. */
756
+ readonly subtotals: boolean;
757
+ /** The field-wide collapse state: true when every Item is collapsed but the toggled ones. */
758
+ readonly collapsed: boolean;
759
+ /** The Items whose collapse state is the opposite of `collapsed`. */
760
+ readonly toggledItems: readonly PivotItemKey[];
761
+ }
762
+
763
+ /** A placement's settings, each its default when left out: by label ascending, nothing hidden, subtotals
764
+ * Automatic, expanded. */
765
+ export declare interface PivotFieldPlacementInput {
766
+ /** The Pivot Field's name. */
767
+ readonly field: string;
768
+ /** The Item order. */
769
+ readonly sort?: PivotSort;
770
+ /** The Items unticked. */
771
+ readonly hiddenItems?: readonly PivotItemKey[];
772
+ /** Whether an outer Item has a subtotal. */
773
+ readonly subtotals?: boolean;
774
+ /** The field-wide collapse state. */
775
+ readonly collapsed?: boolean;
776
+ /** The Items whose collapse state is the opposite of `collapsed`. */
777
+ readonly toggledItems?: readonly PivotItemKey[];
778
+ }
779
+
780
+ /** The type a Consumer declares for a Pivot Field (ADR-0060). It decides the defaults only: where a
781
+ * ticked field goes, which Aggregation a new Value Field takes. Each Item's kind comes from the data. */
782
+ export declare type PivotFieldType = 'text' | 'number' | 'date' | 'boolean';
783
+
784
+ /** Text that is not in the form it must be: a .NET format string .NET does not read, a word's template
785
+ * with a brace out of place, a Pivot Layout's JSON that is not one. The C# engine's FormatException. */
786
+ export declare class PivotFormatError extends Error {
787
+ constructor(message: string, options?: ErrorOptions);
788
+ }
789
+
790
+ /** A Header Group span: a label over `columnCount` value columns from `firstColumn`, at a tier of the
791
+ * header, `tierSpan` tiers tall. */
792
+ export declare interface PivotHeaderSpan {
793
+ /** The text over the span. */
794
+ readonly label: string;
795
+ /** The first value column under it. */
796
+ readonly firstColumn: number;
797
+ /** How many value columns it spans. */
798
+ readonly columnCount: number;
799
+ /** Its tier, from 0 at the top. */
800
+ readonly tier: number;
801
+ /** How many tiers tall it is. */
802
+ readonly tierSpan: number;
803
+ }
804
+
805
+ /**
806
+ * Each field's count of Items, under the Source Version it was counted at (ADR-0370 section 3): what a
807
+ * server's source answers when its features declare {@link PivotSourceFeatures.countsItems}, so that the
808
+ * Field List shows the count beside a field and a layout's leaves are bounded before it is asked
809
+ * ({@link pivotLeafBound}). A field the source did not count is absent, never zero.
810
+ */
811
+ export declare class PivotItemCounts {
812
+ /** The Source Version the Items were counted at. */
813
+ readonly sourceVersion: string;
814
+ /** Each counted field's count of Items, by the field's name. */
815
+ readonly counts: ReadonlyMap<string, number>;
816
+ /** The counts of a Source Version, refusing a count that is not a whole number of at least 0. */
817
+ constructor(sourceVersion: string, counts: Iterable<readonly [string, number]>);
818
+ /** The field's count of Items, or `undefined` when the source did not count it. */
819
+ countOf(field: string): number | undefined;
820
+ }
821
+
822
+ /** One Item as Filter… lists it (ADR-0061): its key as a layout writes it, what it is painted as, and
823
+ * whether the layout hides it now. */
824
+ export declare interface PivotItemInfo {
825
+ /** The Item's key, as a layout writes it. */
826
+ readonly key: PivotItemKey;
827
+ /** What it is painted as. */
828
+ readonly label: string;
829
+ /** Whether the layout hides it now. */
830
+ readonly isHidden: boolean;
831
+ }
832
+
833
+ /** An Item as a Pivot Layout writes it: its kind and its invariant text, which a Blank has none of. */
834
+ export declare interface PivotItemKey {
835
+ /** The Item's kind. */
836
+ readonly kind: PivotItemKind;
837
+ /** Its invariant text; absent only for a Blank. */
838
+ readonly value?: string;
839
+ }
840
+
841
+ /**
842
+ * Names one Item, refusing a value that is not the invariant text of its kind: a key that could not name
843
+ * any Item is a mapping bug, not an Item nobody has. A number's text is read as .NET reads a float (spaces,
844
+ * a sign, a point and an exponent), and a date's as `yyyy-MM-ddTHH:mm:ss` with up to seven digits of a
845
+ * second; the text is kept as it was given.
846
+ */
847
+ export declare function pivotItemKey(kind: PivotItemKind, value?: string): PivotItemKey;
848
+
849
+ /** The Item the value of `column` at `row` belongs to, as the engine groups a field over that column: a number
850
+ * by its double, a Decimal by the double C# converts it to, a date by its clock value, and a Blank as Blank. */
851
+ export declare function pivotItemKeyAt(column: SnapshotColumn, row: number): PivotItemKey;
852
+
853
+ /** What a public key compares as, as a Map key: its kind, and its text folded where text is compared
854
+ * ignoring case. Two keys equal by {@link itemKeysEqual} have one. */
855
+ export declare function pivotItemKeyId(key: PivotItemKey): string;
856
+
857
+ /** The kind of an Item, which comes from its value (ADR-0060). {@link pivotItemKinds} is the ascending
858
+ * order across kinds. */
859
+ export declare type PivotItemKind = 'number' | 'date' | 'text' | 'boolean' | 'error' | 'blank';
860
+
861
+ /** Every Item kind, in the ascending order across kinds: numbers, dates, text, Booleans, `#NUM!`, then
862
+ * `(blank)`. */
863
+ export declare const pivotItemKinds: readonly PivotItemKind[];
864
+
865
+ /** A page of a field's Items (ADR-0066), under the Source Version they were listed at, or a refusal. */
866
+ export declare class PivotItemPage {
867
+ #private;
868
+ /** The refusal, when the source refused. */
869
+ readonly refusal: PivotSourceRefusal | undefined;
870
+ private constructor();
871
+ /** A page: the Items listed, and how many match in all. */
872
+ static of(sourceVersion: string, items: readonly PivotItemKey[], total: number): PivotItemPage;
873
+ /** The source's refusal to list the Items. */
874
+ static refused(refusal: PivotSourceRefusal): PivotItemPage;
875
+ /** Whether the source refused. */
876
+ get isRefused(): boolean;
877
+ /** The Source Version the Items were listed at. */
878
+ get sourceVersion(): string;
879
+ /** The Items listed. */
880
+ get items(): readonly PivotItemKey[];
881
+ /** How many Items match in all, the listed ones included. */
882
+ get total(): number;
883
+ }
884
+
885
+ /** A field's Items over all the data, under a Source Version (ADR-0066). */
886
+ export declare interface PivotItemsQuery {
887
+ /** The field whose Items are asked for. */
888
+ readonly field: string;
889
+ /** The Source Version they are asked for under. */
890
+ readonly sourceVersion: string;
891
+ /** Only the Items whose invariant text holds this, ignoring case. */
892
+ readonly search?: string;
893
+ /** The most Items the page lists. */
894
+ readonly max: number;
895
+ }
896
+
897
+ /** A question for a field's Items, checked: an empty search is no search. */
898
+ export declare function pivotItemsQuery(input: {
899
+ readonly field: string;
900
+ readonly sourceVersion: string;
901
+ readonly search?: string;
902
+ readonly max?: number;
903
+ }): PivotItemsQuery;
904
+
905
+ /** The value the Item `key` names hands an Order Key (ADR-0060): a text Item's text, a number's number, a date's
906
+ * clock ticks, a Boolean's Boolean; `undefined` for a Blank and for #NUM!. A source that answers an Order Key's
907
+ * keys for the Items it names files them under this. */
908
+ export declare function pivotItemValue(key: PivotItemKey): string | number | bigint | boolean | undefined;
909
+
910
+ /**
911
+ * Every Pivot Source question and answer as JSON (ADR-0066), so it crosses to a server unchanged — the C#
912
+ * engine's `PivotJson`, which writes each document as the same text. Each document names its format's
913
+ * `version` and its `type`; a reader refuses, with a {@link PivotVersionError}, a version it does not know
914
+ * rather than half-read it, and, with a {@link PivotFormatError}, a document of another type or one that
915
+ * cannot be, naming what is wrong. An exact decimal crosses as its digits and a double as its shortest
916
+ * round-trip text, a non-finite one by name (`"NaN"`, `"Infinity"`, `"-Infinity"`); a part that is exact or
917
+ * not, a sum or an extreme, is a JSON number when it is exact and a JSON string when it is a double. An
918
+ * answer's leaves are written column by column: one array per level and per part, never an object per leaf.
919
+ */
920
+ export declare const PivotJson: Readonly<{
921
+ /** The format version this writer writes and the only one this reader reads. */
922
+ version: 1;
923
+ /** A question for the Leaf Aggregates, as JSON. */
924
+ writeQuery(query: PivotQuery): string;
925
+ /** The Leaf Aggregates, or a refusal, as JSON: the leaves column by column. */
926
+ writeAnswer(answer: PivotAnswer): string;
927
+ /** A question for a field's Items, as JSON. */
928
+ writeItemsQuery(query: PivotItemsQuery): string;
929
+ /** A page of Items, or a refusal, as JSON. */
930
+ writeItemPage(page: PivotItemPage): string;
931
+ /** A question for the records behind a cell, as JSON. */
932
+ writeDetailsQuery(query: PivotDetailsQuery): string;
933
+ /** A page of the records behind a cell, or a refusal, as JSON. Each value is written by its field's
934
+ * declared type, and one of another type tagged with its own; the Consumer's own record objects are not
935
+ * written. */
936
+ writeDetailPage(page: PivotDetailPage): string;
937
+ /** A source's notice that its data moved on, as JSON. */
938
+ writeSourceChanged(change: PivotSourceChanged): string;
939
+ /**
940
+ * A server's Change Batch (ADR-0370 section 3), as JSON: the records its data lost and gained between two
941
+ * Source Versions, each value by its field's declared type, under the names and types of the fields they
942
+ * are in, so a reader whose fields differ refuses the batch rather than place its values in the wrong ones.
943
+ */
944
+ writeChangeBatch(batch: PivotServerChangeBatch, fields: readonly PivotField[]): string;
945
+ /** Each field's count of Items (ADR-0370 section 3), as JSON: `counts` holds a member per counted field. */
946
+ writeItemCounts(counts: PivotItemCounts): string;
947
+ /** A question read back from {@link PivotJson.writeQuery}'s JSON. */
948
+ readQuery(json: string): PivotQuery;
949
+ /**
950
+ * An answer read back from {@link PivotJson.writeAnswer}'s JSON. Refuses by name a leaf array of the wrong
951
+ * length, an Item index out of range, two Items of one field that are one Item, counts that cannot be —
952
+ * more numbers than values, more values than records — and a part in a form it cannot be: an exact
953
+ * number no decimal holds exactly among them, which is refused rather than rounded.
954
+ */
955
+ readAnswer(json: string): PivotAnswer;
956
+ /** A question for a field's Items read back from {@link PivotJson.writeItemsQuery}'s JSON. */
957
+ readItemsQuery(json: string): PivotItemsQuery;
958
+ /** A page of Items read back from {@link PivotJson.writeItemPage}'s JSON. */
959
+ readItemPage(json: string): PivotItemPage;
960
+ /** A question for the records behind a cell read back from {@link PivotJson.writeDetailsQuery}'s JSON. */
961
+ readDetailsQuery(json: string): PivotDetailsQuery;
962
+ /** A page of the records behind a cell read back from {@link PivotJson.writeDetailPage}'s JSON, each value
963
+ * read by its field's declared type. The records carry no object of the Consumer's: those never left the
964
+ * process. */
965
+ readDetailPage(json: string): PivotDetailPage;
966
+ /** A source's notice read back from {@link PivotJson.writeSourceChanged}'s JSON. */
967
+ readSourceChanged(json: string): PivotSourceChanged;
968
+ /**
969
+ * A notice a server sent a fetching source (ADR-0370 section 3), read back from
970
+ * {@link PivotJson.writeSourceChanged}'s or {@link PivotJson.writeChangeBatch}'s JSON, to hand to the fetchers'
971
+ * `notify`. A batch is read against the source's `fields`: one written under other names or types, or in
972
+ * another order, is refused by name.
973
+ */
974
+ readServerNotice(json: string, fields: readonly PivotField[]): PivotServerNotice;
975
+ /** Each field's count of Items read back from {@link PivotJson.writeItemCounts}'s JSON; a field named twice
976
+ * is refused. */
977
+ readItemCounts(json: string): PivotItemCounts;
978
+ }>;
979
+
980
+ /** The Consumer's word for an id, or `undefined` to keep the English. */
981
+ export declare type PivotLabel = (id: string) => string | undefined;
982
+
983
+ /** A label column: `row-labels` in the Compact form, `row:<field>` a field in the others. */
984
+ export declare interface PivotLabelColumn {
985
+ /** Its name, stable across reports, so a width survives. */
986
+ readonly name: string;
987
+ /** Its header's text. */
988
+ readonly header: string;
989
+ /** The row field it labels, or `undefined` for Compact's one column and for Σ Values's. */
990
+ readonly field: string | undefined;
991
+ }
992
+
993
+ /** The widths of the grid's character classes and of single glyphs, in pixels. Plain data, so it crosses
994
+ * to a Worker as it is. */
995
+ export declare interface PivotLabelMetrics {
996
+ /** `%`, `€`, `−`, `+`, `#`. */
997
+ readonly wideWidthPx: number;
998
+ /** Digits, currency signs, `E`, `-`, the apostrophes and spaces numbers are grouped with, and the marks of
999
+ * direction. */
1000
+ readonly digitWidthPx: number;
1001
+ /** `.`, `,`, `(`, `)`, `/`, `:` and the space. */
1002
+ readonly narrowWidthPx: number;
1003
+ /** A full-width character: CJK, kana, Hangul, full-width forms. */
1004
+ readonly fullWidthPx: number;
1005
+ /** Any other character. */
1006
+ readonly otherWidthPx: number;
1007
+ /** The padding on one side of a cell. */
1008
+ readonly cellHorizontalPaddingPx: number;
1009
+ /** The width of single glyphs outside the classes, by code point. */
1010
+ readonly glyphWidths?: Readonly<Record<number, number>>;
1011
+ }
1012
+
1013
+ /** Which Pivot Fields stand in which Areas, and the report's form and totals (ADR-0059). */
1014
+ export declare interface PivotLayout {
1015
+ /** The report filter's fields, in order. */
1016
+ readonly filters: readonly PivotFieldPlacement[];
1017
+ /** The row fields, outermost first. */
1018
+ readonly rows: readonly PivotFieldPlacement[];
1019
+ /** The column fields, outermost first. */
1020
+ readonly columns: readonly PivotFieldPlacement[];
1021
+ /** The Value Fields, in order. */
1022
+ readonly values: readonly PivotValueField[];
1023
+ /** Where Σ Values stands when there are two or more Value Fields. */
1024
+ readonly valuesAxis: PivotAxis;
1025
+ /** How the row labels are set out. */
1026
+ readonly form: PivotReportForm;
1027
+ /** Whether a subtotal is carried on its group row (Excel's default) or has a row of its own at the
1028
+ * bottom. The Tabular form always puts it at the bottom. */
1029
+ readonly subtotalsAtTop: boolean;
1030
+ /** Whether the `Grand Total` row is painted at the bottom: Excel's "grand totals for columns". */
1031
+ readonly grandTotalRow: boolean;
1032
+ /** Whether the `Grand Total` column is painted at the right: Excel's "grand totals for rows". */
1033
+ readonly grandTotalColumn: boolean;
1034
+ /** Whether every row of the Outline and Tabular forms repeats its outer Items' labels. */
1035
+ readonly repeatItemLabels: boolean;
1036
+ }
1037
+
1038
+ /**
1039
+ * One choice of the Layout menu on the Pivot Toolbar (ADR-0061): Excel's Design tab settings, under
1040
+ * Excel's names, in Excel's order — Subtotals, Grand Totals, then Report Layout. Excel's Blank Rows is left
1041
+ * out: the engine has no blank row.
1042
+ */
1043
+ export declare type PivotLayoutChoice = 'doNotShowSubtotals' | 'showSubtotalsAtBottom' | 'showSubtotalsAtTop' | 'grandTotalsOff' | 'grandTotalsOn' | 'grandTotalsOnRowsOnly' | 'grandTotalsOnColumnsOnly' | 'compactForm' | 'outlineForm' | 'tabularForm' | 'repeatItemLabels' | 'doNotRepeatItemLabels';
1044
+
1045
+ /** The Layout menu's choices, in Excel's order. */
1046
+ export declare const pivotLayoutChoices: readonly PivotLayoutChoice[];
1047
+
1048
+ /** A layout's settings, each its default when left out: no field anywhere, Σ Values in Columns, the
1049
+ * Compact form, subtotals at the top, both grand totals, labels not repeated. A placement or a Value Field
1050
+ * may be given by its field's name alone. */
1051
+ export declare interface PivotLayoutInput {
1052
+ /** The report filter's fields. */
1053
+ readonly filters?: readonly (string | PivotFieldPlacementInput)[];
1054
+ /** The row fields, outermost first. */
1055
+ readonly rows?: readonly (string | PivotFieldPlacementInput)[];
1056
+ /** The column fields, outermost first. */
1057
+ readonly columns?: readonly (string | PivotFieldPlacementInput)[];
1058
+ /** The Value Fields. */
1059
+ readonly values?: readonly (string | PivotValueFieldInput)[];
1060
+ /** Where Σ Values stands. */
1061
+ readonly valuesAxis?: PivotAxis;
1062
+ /** How the row labels are set out. */
1063
+ readonly form?: PivotReportForm;
1064
+ /** Whether a subtotal is carried on its group row. */
1065
+ readonly subtotalsAtTop?: boolean;
1066
+ /** Whether the `Grand Total` row is painted. */
1067
+ readonly grandTotalRow?: boolean;
1068
+ /** Whether the `Grand Total` column is painted. */
1069
+ readonly grandTotalColumn?: boolean;
1070
+ /** Whether the Outline and Tabular forms repeat outer labels. */
1071
+ readonly repeatItemLabels?: boolean;
1072
+ }
1073
+
1074
+ /** The version this writer writes and the only one this reader reads. */
1075
+ export declare const pivotLayoutJsonVersion = 1;
1076
+
1077
+ /**
1078
+ * The most leaves `layout` can make, at most {@link pivotLeafBoundMost}: the product, over the fields in
1079
+ * Rows and Columns, of each field's count less the Items the layout hides of it. The leaves are the
1080
+ * combinations of those Items that some record carries, so they are never more while the counts are the
1081
+ * data's and every Hidden Item is among them; Filters and the Values add none. `undefined` when a field the
1082
+ * layout places in Rows or Columns was not counted. The bound is a hint for the drop target's mark only: a
1083
+ * count gone stale, or a Hidden Item the data no longer holds, moves the mark, never the answer, and the
1084
+ * question is asked with its `maxLeaves` all the same.
1085
+ */
1086
+ export declare function pivotLeafBound(layout: PivotLayout, counts: PivotItemCounts): number | undefined;
1087
+
1088
+ /** Where a bound stops growing: 2^53 − 1, the largest whole number held exactly, as the C# engine stops. */
1089
+ export declare const pivotLeafBoundMost: number;
1090
+
1091
+ /**
1092
+ * How a row field's Items are ordered among their siblings (ADR-0370 section 3): by a field in Values under an
1093
+ * Aggregation, read at the grand total of the columns, as the report sorts them. A sibling whose value is not
1094
+ * a number follows every number, in either direction. What a window of a sibling set is cut from.
1095
+ */
1096
+ export declare interface PivotLevelOrder {
1097
+ /** The field in Values, by its place in the question's `values`. */
1098
+ readonly value: number;
1099
+ /** The Aggregation read of it. */
1100
+ readonly aggregation: PivotAggregation;
1101
+ /** Whether the largest comes first. */
1102
+ readonly descending: boolean;
1103
+ }
1104
+
1105
+ /**
1106
+ * One field's rule of a question's levels (ADR-0370 section 3): whether its Items are collapsed, and the
1107
+ * Items whose state is the other. Item `x` is expanded when `collapsed` is not `x ∈ toggledItems`; the Items
1108
+ * of the innermost field have nothing below them, and their rule changes nothing.
1109
+ */
1110
+ export declare interface PivotLevelRule {
1111
+ /** Whether its Items are collapsed, but for the toggled ones. */
1112
+ readonly collapsed: boolean;
1113
+ /** The Items whose state is the other of `collapsed`. */
1114
+ readonly toggledItems: readonly PivotItemKey[];
1115
+ /** How a row field's Items are ordered by a value, for a question with a window; none for a field
1116
+ * ordered by label, and for a column field. */
1117
+ readonly order?: PivotLevelOrder;
1118
+ }
1119
+
1120
+ /** A rule, checked and frozen. */
1121
+ export declare function pivotLevelRule(input?: PivotLevelRuleInput): PivotLevelRule;
1122
+
1123
+ /** A rule's settings, each left out taking its default: every Item expanded, ordered by label. */
1124
+ export declare interface PivotLevelRuleInput {
1125
+ /** Whether the Items are collapsed, but for the toggled ones. */
1126
+ readonly collapsed?: boolean;
1127
+ /** The Items whose state is the other. */
1128
+ readonly toggledItems?: readonly PivotItemKey[];
1129
+ /** How the Items are ordered by a value. */
1130
+ readonly order?: PivotLevelOrder;
1131
+ }
1132
+
1133
+ /**
1134
+ * Which groups a report shows, as a question for Level Aggregates carries them (ADR-0370 section 3): one
1135
+ * rule a row field and one a column field. A group is shown when every Item above it is expanded, and the
1136
+ * grand total always is; a cell is a shown row group crossed with a shown column group. A server can turn
1137
+ * them into `GROUPING SETS` without knowing the report.
1138
+ */
1139
+ export declare interface PivotLevels {
1140
+ /** The row fields' rules, outermost first. */
1141
+ readonly rows: readonly PivotLevelRule[];
1142
+ /** The column fields' rules, outermost first. */
1143
+ readonly columns: readonly PivotLevelRule[];
1144
+ /** The window of the sets ordered by a value; none, and every set is answered whole. */
1145
+ readonly window?: PivotLevelWindow;
1146
+ }
1147
+
1148
+ /**
1149
+ * The window of a question's levels (ADR-0370 section 3): a sibling set ordered by a value with more than
1150
+ * `limit` siblings is answered as a window of them, starting where `starts` says for its parent, or at the
1151
+ * first, and no further than `limit` from the end; with what lies on either side merged.
1152
+ */
1153
+ export declare interface PivotLevelWindow {
1154
+ /** The most siblings a set ordered by a value is answered with whole. */
1155
+ readonly limit: number;
1156
+ /** Where the windows start, one a parent at most. */
1157
+ readonly starts: readonly PivotWindowStart[];
1158
+ }
1159
+
1160
+ /** A window's settings: its limit, and where its windows start, none by default. */
1161
+ export declare interface PivotLevelWindowInput {
1162
+ /** The most siblings a set ordered by a value is answered with whole. */
1163
+ readonly limit: number;
1164
+ /** Where the windows start. */
1165
+ readonly starts?: readonly PivotWindowStart[];
1166
+ }
1167
+
1168
+ /** The locales the engine formats in, by their .NET names. */
1169
+ export declare function pivotLocales(): readonly string[];
1170
+
1171
+ /** A number a part carries: exact while every number it was made of was, a double otherwise. */
1172
+ export declare type PivotNumber = {
1173
+ readonly kind: 'exact';
1174
+ readonly value: SnapshotDecimal;
1175
+ } | {
1176
+ readonly kind: 'double';
1177
+ readonly value: number;
1178
+ };
1179
+
1180
+ /** The Average of `count` numbers whose sum is `sum`: exact where the sum is, divided as C#'s decimal divides by a
1181
+ * whole count, and a double otherwise, as a Selection Summary's Average over the report reads it (ADR-0130). */
1182
+ export declare function pivotNumberAverage(sum: PivotNumber, count: number): PivotNumber;
1183
+
1184
+ /** The number without trailing zeros where it is exact, as C#'s accumulator finishes a figure (`AggregateArithmetic.Canonical`). */
1185
+ export declare function pivotNumberCanonical(number: PivotNumber): PivotNumber;
1186
+
1187
+ /**
1188
+ * What is wrong with a number format, or `undefined` when nothing is (PivotNumberFormat.Check): empty,
1189
+ * longer than 64 characters, a standard format asking for more than 30 digits, or one .NET cannot format
1190
+ * a number with.
1191
+ */
1192
+ export declare function pivotNumberFormatProblem(format: string): string | undefined;
1193
+
1194
+ /** The number as a double: the exact one converted as C# converts a decimal. */
1195
+ export declare function pivotNumberValue(number: PivotNumber): number;
1196
+
1197
+ /** What a report is laid out in: a locale — a BCP 47 tag or `invariant` — and the words it is written in. */
1198
+ export declare interface PivotOptions {
1199
+ /** The locale numbers and dates are written in and text is ordered by (ADR-0370 §10); the browser's
1200
+ * language when left out. */
1201
+ readonly locale?: string;
1202
+ /** The report's words by id, for those the Consumer translates; English for the rest. */
1203
+ readonly label?: PivotLabel;
1204
+ }
1205
+
1206
+ /**
1207
+ * A field's Order Key (ADR-0060): from an Item's value — the text of a text Item (its first spelling), the
1208
+ * number of a number Item, the clock ticks of a date, the Boolean of a Boolean — to what the Items are
1209
+ * ordered by. Called once per Item where the report is laid out; one that throws is refused, naming the
1210
+ * field and the Item.
1211
+ */
1212
+ export declare type PivotOrderKey = (value: string | number | bigint | boolean) => PivotOrderKeyValue | null | undefined;
1213
+
1214
+ /** A field's Order Key failed on an Item, or gave its Items keys of two types (ADR-0060): the order is
1215
+ * refused, naming the field and the value, rather than fall back to the labels. */
1216
+ export declare class PivotOrderKeyError extends Error {
1217
+ /** The name of the field whose Order Key failed. */
1218
+ readonly field: string;
1219
+ constructor(field: string, message: string, options?: ErrorOptions);
1220
+ }
1221
+
1222
+ /** What an Order Key gives an Item: a value Items are ordered by, ascending; one field's keys are all of
1223
+ * one type. `null` or `undefined` gives the Item no key. */
1224
+ export declare type PivotOrderKeyValue = string | number | bigint | boolean;
1225
+
1226
+ /** A part of a Leaf Aggregate beyond the counts, which always travel (ADR-0066). */
1227
+ export declare type PivotPart = 'sum' | 'extremes' | 'product' | 'variance';
1228
+
1229
+ /** The parts in their order. */
1230
+ export declare const pivotParts: readonly PivotPart[];
1231
+
1232
+ /** The question for a report's Leaf Aggregates. */
1233
+ export declare interface PivotQuery {
1234
+ /** The row fields, outermost first. */
1235
+ readonly rows: readonly PivotQueryField[];
1236
+ /** The column fields, outermost first. */
1237
+ readonly columns: readonly PivotQueryField[];
1238
+ /** The Filters that hide something; one that hides nothing leaves every record in. */
1239
+ readonly filters: readonly PivotQueryField[];
1240
+ /** Each field in Values, once, with the parts its Value Fields read. */
1241
+ readonly values: readonly PivotQueryValue[];
1242
+ /** The most leaves the answer may have; one more refuses the question. */
1243
+ readonly maxLeaves: number;
1244
+ /**
1245
+ * Which groups the report shows, for a source that answers Level Aggregates (ADR-0370 section 3): it may
1246
+ * then answer, when the leaves would pass the cap, with the cells of the groups shown instead
1247
+ * (an answer's `isLevels`). Left out, the question asks for the leaves alone.
1248
+ */
1249
+ readonly levels?: PivotLevels;
1250
+ }
1251
+
1252
+ /**
1253
+ * A question, checked and frozen: a field placed twice among Filters, Rows and Columns, or asked for twice in
1254
+ * Values, is refused with a TypeError naming it; a cap below 1 with a RangeError.
1255
+ */
1256
+ export declare function pivotQuery(input?: PivotQueryInput): PivotQuery;
1257
+
1258
+ /** A field placed in Rows, Columns or Filters, with the Items it hides. */
1259
+ export declare interface PivotQueryField {
1260
+ /** The field's name. */
1261
+ readonly field: string;
1262
+ /** The Items whose records are left out. */
1263
+ readonly hiddenItems: readonly PivotItemKey[];
1264
+ }
1265
+
1266
+ /** A question's settings, each left out taking its default: no field anywhere and the default cap. */
1267
+ export declare interface PivotQueryInput {
1268
+ /** The row fields, by name or with their Hidden Items. */
1269
+ readonly rows?: readonly (string | {
1270
+ readonly field: string;
1271
+ readonly hiddenItems?: readonly PivotItemKey[];
1272
+ })[];
1273
+ /** The column fields. */
1274
+ readonly columns?: readonly (string | {
1275
+ readonly field: string;
1276
+ readonly hiddenItems?: readonly PivotItemKey[];
1277
+ })[];
1278
+ /** The Filters that hide something. */
1279
+ readonly filters?: readonly (string | {
1280
+ readonly field: string;
1281
+ readonly hiddenItems?: readonly PivotItemKey[];
1282
+ })[];
1283
+ /** The fields in Values, by name or with their parts. */
1284
+ readonly values?: readonly (string | {
1285
+ readonly field: string;
1286
+ readonly parts?: readonly PivotPart[];
1287
+ })[];
1288
+ /** The cap on leaves; {@link defaultMaxLeaves} when left out. */
1289
+ readonly maxLeaves?: number;
1290
+ /** Which groups the report shows, one rule a row and a column field, and the window of the sets ordered by a
1291
+ * value; none when left out. */
1292
+ readonly levels?: {
1293
+ readonly rows?: readonly PivotLevelRuleInput[];
1294
+ readonly columns?: readonly PivotLevelRuleInput[];
1295
+ readonly window?: PivotLevelWindowInput;
1296
+ };
1297
+ }
1298
+
1299
+ /** A field in Values, and the parts its Value Fields' Aggregations read. */
1300
+ export declare interface PivotQueryValue {
1301
+ /** The field's name. */
1302
+ readonly field: string;
1303
+ /** The parts asked for beyond the counts. */
1304
+ readonly parts: readonly PivotPart[];
1305
+ }
1306
+
1307
+ /** A Pivot Field over records in memory: a field and how it is read from one record. */
1308
+ export declare interface PivotRecordField<TRecord> extends PivotField {
1309
+ /** Reads the field from a record; `null` or `undefined` is a Blank. */
1310
+ readonly value: (record: TRecord) => unknown;
1311
+ }
1312
+
1313
+ /** A record field, its declaration checked as {@link pivotField} checks it, and its accessor a function. */
1314
+ export declare function pivotRecordField<TRecord>(input: PivotRecordFieldInput<TRecord>): PivotRecordField<TRecord>;
1315
+
1316
+ /** A record field's declaration. */
1317
+ export declare interface PivotRecordFieldInput<TRecord> extends PivotFieldInput {
1318
+ /** Reads the field from a record; `null` or `undefined` is a Blank. */
1319
+ readonly value: (record: TRecord) => unknown;
1320
+ }
1321
+
1322
+ /** Why the Field List refused an edit (ADR-0060/0061). */
1323
+ export declare type PivotRefusal = 'hidesEveryItem' | 'captionTaken' | 'captionEmpty' | 'numberFormatInvalid';
1324
+
1325
+ /** The refusals, worded as the C# engine words them. */
1326
+ export declare const PivotRefusals: Readonly<{
1327
+ /** "This layout needs more than 200,000 cells." */
1328
+ tooManyLeaves: (maxLeaves: number) => PivotSourceRefusal;
1329
+ /** A field the source does not have. */
1330
+ unknownField: (field: string) => PivotSourceRefusal;
1331
+ /** A part that only Aggregations the source does not offer read. */
1332
+ aggregationNotOffered: (field: string, aggregations: readonly PivotAggregation[]) => PivotSourceRefusal;
1333
+ /** A question asked under a Source Version the source no longer holds. */
1334
+ sourceVersionNotHeld: (sourceVersion: string) => PivotSourceRefusal;
1335
+ }>;
1336
+
1337
+ /** A report: its columns, its rows, and the value at each row and column. */
1338
+ export declare class PivotReport {
1339
+ #private;
1340
+ /** The layout it was laid out under. */
1341
+ readonly layout: PivotLayout;
1342
+ /** The label columns, left to right. */
1343
+ readonly labelColumns: readonly PivotLabelColumn[];
1344
+ /** The value columns, left to right. */
1345
+ readonly valueColumns: readonly PivotReportColumn[];
1346
+ /** The Header Group spans over the value columns. */
1347
+ readonly headerSpans: readonly PivotHeaderSpan[];
1348
+ /** How many tiers the column header has above the leaf headers. */
1349
+ readonly headerTierCount: number;
1350
+ /** The rows, top to bottom. */
1351
+ readonly rows: readonly PivotReportRow[];
1352
+ /** Each Value Field's caption. */
1353
+ readonly valueCaptions: readonly string[];
1354
+ /** The cube it was laid out from. */
1355
+ readonly cube: PivotCube;
1356
+ private constructor();
1357
+ /** The locale the report is written in. */
1358
+ get locale(): string;
1359
+ /** Whether the layout places no field at all. */
1360
+ get isEmpty(): boolean;
1361
+ /** Whether the other report's rows stand, one for one, for what this one's do. */
1362
+ hasSameRowsAs(other: PivotReport | undefined): boolean;
1363
+ /**
1364
+ * {@link PivotReport.hasSameRowsAs} in slices (ADR-0066, PV-40): the rows compared a piece at a time, yielding
1365
+ * between slices as `slicing` paces them — a refresh of a large report compares every row. Once `signal` is
1366
+ * aborted, it stops at the next slice and rejects with the signal's reason.
1367
+ */
1368
+ hasSameRowsAsAsync(other: PivotReport | undefined, slicing?: PivotSlicing, signal?: AbortSignal): Promise<boolean>;
1369
+ /** The row's Items, outermost first, each with its field. */
1370
+ rowPath(row: PivotReportRow): readonly PivotFieldItem[];
1371
+ /** The value column's Items, outermost first, each with its field. */
1372
+ columnPath(valueColumn: number): readonly PivotFieldItem[];
1373
+ /** The question for the records behind a cell (ADR-0063): its row's and its column's Items, and every
1374
+ * placed field's Hidden Items, under the cube's Source Version. A column of −1 asks for the row's. */
1375
+ detailsQuery(row: PivotReportRow, valueColumn: number, start?: number, count?: number): PivotDetailsQuery;
1376
+ /** The Value Field a cell shows: its row's, its column's, the one Value Field, or −1 for none. */
1377
+ valueFieldAt(row: PivotReportRow, valueColumn: number): number;
1378
+ /** The value at a row and a value column as the report shows it, or `undefined` for an empty cell. */
1379
+ valueAt(row: PivotReportRow, valueColumn: number): PivotValue | undefined;
1380
+ }
1381
+
1382
+ /**
1383
+ * Lays a cube out under a layout (ADR-0060): the rows, the label columns, the value columns and their
1384
+ * Header Group spans. Cheap — nothing is asked of the source. Refuses a layout the cube does not hold.
1385
+ */
1386
+ export declare function pivotReport(cube: PivotCube, layout: PivotLayout, options?: PivotOptions): PivotReport;
1387
+
1388
+ /** A Window answered. */
1389
+ export declare interface PivotReportAnswer extends PivotReportState {
1390
+ /** The request answered. */
1391
+ readonly requestId: string;
1392
+ /** None: the Window was answered. */
1393
+ readonly refusal?: undefined;
1394
+ }
1395
+
1396
+ /**
1397
+ * {@link pivotReport} in slices (PV-40): each tree walked a node at a time and thousands of siblings ordered
1398
+ * a piece at a time, yielding between slices as `slicing` paces them. It gives the report {@link pivotReport}
1399
+ * gives, and rejects with what it throws, an Order Key that fails included. Once `signal` is aborted, it stops at
1400
+ * the next slice and rejects with the signal's reason.
1401
+ */
1402
+ export declare function pivotReportAsync(cube: PivotCube, layout: PivotLayout, options?: PivotOptions, slicing?: PivotSlicing, signal?: AbortSignal): Promise<PivotReport>;
1403
+
1404
+ /** A value column of a report. */
1405
+ export declare class PivotReportColumn {
1406
+ #private;
1407
+ /** Its role, its Items and its Value Field's caption: stable across reports, so a width survives. */
1408
+ readonly name: string;
1409
+ /** Its leaf header's text. */
1410
+ readonly header: string;
1411
+ /** An Item's column, a subtotal's, or the grand total's. */
1412
+ readonly role: PivotColumnRole;
1413
+ /** The Value Field it shows, or −1 when its rows say. */
1414
+ readonly valueField: number;
1415
+ /** The number a number column Item's leaf header shows, in full, for its copy. */
1416
+ readonly headerNumber: number | undefined;
1417
+ private constructor();
1418
+ }
1419
+
1420
+ /** One copied rectangle, with its headers. */
1421
+ export declare interface PivotReportCopyBlock {
1422
+ /** The headers, in the rectangle's column order. */
1423
+ readonly headers: readonly string[];
1424
+ /** Each header's raw form for a copy's HTML flavour: a number column Item's header carries its number in
1425
+ * full (ADR-0005's note of 2026-10-13), any other `undefined`. Absent when no header has one. */
1426
+ readonly headerRaws?: readonly (string | undefined)[];
1427
+ /** Every cell of its rows. */
1428
+ readonly rows: readonly (readonly PivotReportCopyCell[])[];
1429
+ }
1430
+
1431
+ /** A copied cell: its text, and its locale-free form. */
1432
+ export declare interface PivotReportCopyCell {
1433
+ /** The shown text. */
1434
+ readonly text: string;
1435
+ /** The raw, locale-free text — a number in full — or absent for a blank. */
1436
+ readonly raw?: string;
1437
+ /** Whether the raw text is a number. */
1438
+ readonly isNumber: boolean;
1439
+ }
1440
+
1441
+ /** A versioned Copy: each rectangle copied whole, in the order given. */
1442
+ export declare interface PivotReportCopyQuery {
1443
+ /** The report the selection was made on. */
1444
+ readonly version: string;
1445
+ /** The columns' names, in the Consumer's order. */
1446
+ readonly columns: readonly string[];
1447
+ /** The selected rectangles. */
1448
+ readonly ranges: readonly PivotReportRange[];
1449
+ /** The most cells copied; 1,000,000 when left out. A copy past it is refused, never cut short (spine 1). */
1450
+ readonly maxCells?: number;
1451
+ }
1452
+
1453
+ /** A Copy, or a refusal. */
1454
+ export declare interface PivotReportCopyResult {
1455
+ /** The report answered. */
1456
+ readonly version: string;
1457
+ /** One block per rectangle asked for. */
1458
+ readonly blocks: readonly PivotReportCopyBlock[];
1459
+ /** Why it was not copied. */
1460
+ readonly refusal?: PivotReportRefusal;
1461
+ }
1462
+
1463
+ /**
1464
+ * The question for the records behind a cell of a report — Show Details (ADR-0063, ADR-0151) — from a row of
1465
+ * its Window and the report's own layout and columns: the row's Items, the value column's (none for a label
1466
+ * cell, column −1), the Hidden Items the report was computed under, the page, and its Source Version. Made of
1467
+ * values, it stays the same question after any later layout, and is answered while the Pivot Source holds that
1468
+ * Source Version.
1469
+ */
1470
+ export declare function pivotReportDetailsQuery(metadata: PivotReportMetadata, row: PivotDisplayRow, valueColumn: number, start?: number, count?: number): PivotDetailsQuery;
1471
+
1472
+ /** How a report sets out its row labels: Excel's "Report Layout" (ADR-0060). */
1473
+ export declare type PivotReportForm = 'compact' | 'outline' | 'tabular';
1474
+
1475
+ /** A field's Items as the report labels and orders them, under a Report Version. */
1476
+ export declare interface PivotReportItemsQuery {
1477
+ /** The report the Items are listed for. */
1478
+ readonly version: string;
1479
+ /** The field. */
1480
+ readonly field: string;
1481
+ /** What the Items' text holds, where the source searches. */
1482
+ readonly search?: string;
1483
+ /** The most Items listed; 10,000 when left out. */
1484
+ readonly max?: number;
1485
+ }
1486
+
1487
+ /** A field's Items in the report's order, or a refusal. */
1488
+ export declare interface PivotReportItemsResult {
1489
+ /** The report answered. */
1490
+ readonly version: string;
1491
+ /** Its Source Version, or `''` where the version is not held. */
1492
+ readonly sourceVersion: string;
1493
+ /** The Items, labelled, in the field's order. */
1494
+ readonly items: readonly PivotItemInfo[];
1495
+ /** How many Items matched before the cap. */
1496
+ readonly total: number;
1497
+ /** Why they were not listed. */
1498
+ readonly refusal?: PivotReportRefusal;
1499
+ }
1500
+
1501
+ /** The whole report's extent and columns, without its rows or its data. */
1502
+ export declare interface PivotReportMetadata {
1503
+ /** The Report Version: one report, immutable, under its layout and settings. */
1504
+ readonly version: string;
1505
+ /** The Source Version the report was computed from. */
1506
+ readonly sourceVersion: string;
1507
+ /** Changes when the ordered sequence of the rows' identities changes. */
1508
+ readonly rowSequenceVersion: string;
1509
+ /** The layout it was laid out under. */
1510
+ readonly layout: PivotLayout;
1511
+ /** The settings it was laid out under. */
1512
+ readonly settings: PivotReportSettings;
1513
+ /** The whole report's row count, rows outside the Window included. */
1514
+ readonly rowCount: number;
1515
+ /** The label columns. */
1516
+ readonly labelColumns: readonly PivotLabelColumn[];
1517
+ /** The value columns. */
1518
+ readonly valueColumns: readonly PivotDisplayColumn[];
1519
+ /** The Header Group spans. */
1520
+ readonly headerSpans: readonly PivotHeaderSpan[];
1521
+ /** How many tiers the column header has above the leaf headers. */
1522
+ readonly headerTierCount: number;
1523
+ /** Each Value Field's caption. */
1524
+ readonly valueCaptions: readonly string[];
1525
+ /** The widest label of each label column under the settings' label geometry, in pixels; none without it. */
1526
+ readonly labelWidths: readonly number[];
1527
+ /** The changes the source still marks, newest first: a cell marked with one changed recently, and a
1528
+ * Consumer stamps each the first time it shows a Window listing it ({@link PivotChangeTimes}). A change
1529
+ * leaves the list once it is older than the settings' highlight duration, and never comes back. */
1530
+ readonly changeMarks: readonly string[];
1531
+ }
1532
+
1533
+ /** A rectangle of a selection, its edges included: rows of the report, columns among the query's columns. */
1534
+ export declare interface PivotReportRange {
1535
+ /** The first row. */
1536
+ readonly top: number;
1537
+ /** The first column. */
1538
+ readonly left: number;
1539
+ /** The last row. */
1540
+ readonly bottom: number;
1541
+ /** The last column. */
1542
+ readonly right: number;
1543
+ }
1544
+
1545
+ /** A refusal by name; an empty answer is never given in its place. */
1546
+ export declare interface PivotReportRefusal {
1547
+ /** Why. */
1548
+ readonly kind: PivotReportRefusalKind;
1549
+ /** A sentence a person can read. */
1550
+ readonly message: string;
1551
+ /** The field it concerns, where one does. */
1552
+ readonly field?: string;
1553
+ /** The Pivot Source's own refusal, when it refused the question. */
1554
+ readonly sourceRefusal?: PivotSourceRefusal;
1555
+ }
1556
+
1557
+ /** Why a report source did not answer: `rowsNotAnswered` is a Copy or a Selection Summary that reaches Pending
1558
+ * Rows, the siblings a Pivot Source answered a Sibling Window beside (ADR-0370 section 3). */
1559
+ export declare type PivotReportRefusalKind = 'reportVersionNotHeld' | 'unknownOrderKeyPolicy' | 'sourceRefused' | 'invalidRequest' | 'orderKeyFailed' | 'rowsNotAnswered';
1560
+
1561
+ /** A Window refused. */
1562
+ export declare interface PivotReportRefused {
1563
+ /** The request refused. */
1564
+ readonly requestId: string;
1565
+ /** The Window asked for. */
1566
+ readonly window: PivotReportWindow;
1567
+ /** Why. */
1568
+ readonly refusal: PivotReportRefusal;
1569
+ }
1570
+
1571
+ /** What a report source is asked: a Window of the report a layout makes, under display settings. */
1572
+ export declare interface PivotReportRequest {
1573
+ /** The request's identity, which its answer names back. */
1574
+ readonly requestId: string;
1575
+ /** The report's View State. */
1576
+ readonly layout: PivotLayout;
1577
+ /** Its locale, words, label geometry and Order Key policies. */
1578
+ readonly settings: PivotReportSettings;
1579
+ /** The rows wanted. */
1580
+ readonly window: PivotReportWindow;
1581
+ /** The Report Version of the Window the Consumer holds — the data it shows — or none. A request that
1582
+ * marks no changes (a layout gesture) lays out the data of that version, while the source holds it, and
1583
+ * not newer data the Consumer has not been shown; a row of the answer that the held Window shows alike is
1584
+ * the very row it holds (ADR-0152, ADR-0153). */
1585
+ readonly baseline?: string;
1586
+ /** The cap on the answer's leaves; 200,000 when left out (ADR-0066). */
1587
+ readonly maxLeaves?: number;
1588
+ /** Whether this gesture can mark changes of the data; a layout or display-setting gesture cannot. True
1589
+ * when left out. */
1590
+ readonly markChanges?: boolean;
1591
+ /** Asks a source that cannot tell its data changed again, though it said nothing: an explicit Refresh or
1592
+ * Retry (ADR-0153). */
1593
+ readonly refreshData?: boolean;
1594
+ }
1595
+
1596
+ /** A row of a report. */
1597
+ export declare class PivotReportRow {
1598
+ #private;
1599
+ /** A group row, an Item's, a subtotal's or the grand total's. */
1600
+ readonly role: PivotRowRole;
1601
+ /** The Value Field the row shows, or −1 when its columns say. */
1602
+ readonly valueField: number;
1603
+ /** Its label in each label column. */
1604
+ readonly labels: readonly PivotRowLabel[];
1605
+ /** Whether the row carries values: a group row whose subtotal stands at the bottom carries none. */
1606
+ readonly carriesValues: boolean;
1607
+ private constructor();
1608
+ /** What the row stands for, across reports. */
1609
+ get key(): PivotRowKey;
1610
+ }
1611
+
1612
+ /** A report's display settings, chosen explicitly: a locale never chooses the words (ADR-0151). */
1613
+ export declare interface PivotReportSettings {
1614
+ /** The locale numbers and dates are written in and text is ordered by; the browser's language when left
1615
+ * out (ADR-0370 section 10). */
1616
+ readonly locale?: string;
1617
+ /** The report's words by id, for those the Consumer translates; English for the rest. */
1618
+ readonly words?: Readonly<Record<string, string>>;
1619
+ /** How long a change of the data stays marked for a cell first asked for after it, in milliseconds;
1620
+ * 1,000 when left out (ADR-0068). */
1621
+ readonly changeHighlightMs?: number;
1622
+ /** The label geometry the label columns' widths are estimated under, or none when no widths are wanted. */
1623
+ readonly labelMetrics?: PivotLabelMetrics;
1624
+ /** The Order Key a field's Items are ordered by, by the field's name: one of those the report source was
1625
+ * given, by its name (ADR-0152). */
1626
+ readonly orderKeyPolicies?: Readonly<Record<string, string>>;
1627
+ }
1628
+
1629
+ /** The report boundary a Script Core asks (ADR-0151, ADR-0370 section 4): a Window of the report, and the
1630
+ * operations a Report Version names. An Engine Host that runs the engine in a Worker answers it across. */
1631
+ export declare interface PivotReportSource {
1632
+ /** The fields offered to the Field List. */
1633
+ readonly fields: readonly PivotField[];
1634
+ /** The Aggregations offered. */
1635
+ readonly features: PivotSourceFeatures;
1636
+ /** How the source learns its data changed. */
1637
+ readonly updateMode: PivotReportUpdateMode;
1638
+ /** A Window of the report a request's layout makes, or a refusal by name. */
1639
+ window(request: PivotReportRequest, signal?: AbortSignal): Promise<PivotReportUpdate>;
1640
+ /** A field's Items, labelled and ordered as a held Report Version shows them. */
1641
+ items(query: PivotReportItemsQuery, signal?: AbortSignal): Promise<PivotReportItemsResult>;
1642
+ /** A field's Items as the Pivot Source lists them, under a Source Version. */
1643
+ rawItems(query: PivotItemsQuery, signal?: AbortSignal): Promise<PivotItemPage>;
1644
+ /** Every selected cell of a held Report Version, off-screen cells included. */
1645
+ copy(query: PivotReportCopyQuery, signal?: AbortSignal): Promise<PivotReportCopyResult>;
1646
+ /** The Selection Summary of a held Report Version. */
1647
+ summary(query: PivotReportSummaryQuery, signal?: AbortSignal): Promise<PivotReportSummaryResult>;
1648
+ /** A page of the records behind a cell, under the Source Version its question names (ADR-0151). */
1649
+ details(query: PivotDetailsQuery, signal?: AbortSignal): Promise<PivotDetailPage>;
1650
+ /** Tells `listener` each time the Pivot Source's data moves on; the function returned stops it. */
1651
+ subscribe(listener: (changed: PivotSourceChanged) => void): () => void;
1652
+ /** Releases the report's state; the Pivot Source is not its to release. */
1653
+ dispose(): void;
1654
+ }
1655
+
1656
+ /** A Window as the Consumer holds it: the report's metadata, the Window answered, and its rows. */
1657
+ export declare interface PivotReportState {
1658
+ /** The whole report's metadata. */
1659
+ readonly metadata: PivotReportMetadata;
1660
+ /** The Window answered. */
1661
+ readonly window: PivotReportWindow;
1662
+ /** Its rows, in order. */
1663
+ readonly rows: readonly PivotDisplayRow[];
1664
+ }
1665
+
1666
+ /** A versioned Selection Summary; a cell under two rectangles is counted once. */
1667
+ export declare interface PivotReportSummaryQuery {
1668
+ /** The report the selection was made on. */
1669
+ readonly version: string;
1670
+ /** The columns' names, in the Consumer's order. */
1671
+ readonly columns: readonly string[];
1672
+ /** The selected rectangles. */
1673
+ readonly ranges: readonly PivotReportRange[];
1674
+ /** The Focus row, whose number format the figures are shown in. */
1675
+ readonly focusRow?: number;
1676
+ /** The Focus column among the columns. */
1677
+ readonly focusColumn?: number;
1678
+ }
1679
+
1680
+ /** The figures of a Selection Summary, or a refusal (ADR-0130). */
1681
+ export declare interface PivotReportSummaryResult {
1682
+ /** The report answered. */
1683
+ readonly version: string;
1684
+ /** The cells that are not blank: Count. */
1685
+ readonly values: number;
1686
+ /** The cells that are numbers: Numerical Count. An error is not one. */
1687
+ readonly numbers: number;
1688
+ /** The sum, exact wherever every number was; absent with no number. */
1689
+ readonly sum?: PivotNumber;
1690
+ /** The smallest number; absent with no number. */
1691
+ readonly min?: PivotNumber;
1692
+ /** The largest number; absent with no number. */
1693
+ readonly max?: PivotNumber;
1694
+ /** An error was selected: Average, Min, Max and Sum are not shown, and Count and Numerical Count are. */
1695
+ readonly hasError: boolean;
1696
+ /** The Focus value's number format, where it has one. */
1697
+ readonly numberFormat?: string;
1698
+ /** The report's locale. */
1699
+ readonly locale: string;
1700
+ /** Why it was not summed. */
1701
+ readonly refusal?: PivotReportRefusal;
1702
+ }
1703
+
1704
+ /** A Window answered, or refused by name. */
1705
+ export declare type PivotReportUpdate = PivotReportAnswer | PivotReportRefused;
1706
+
1707
+ /** How a report source learns that its data changed (ADR-0153), declared: `incremental` when the Pivot
1708
+ * Source names its changes — Change Batches — and `fullRefresh` when it cannot, and a notice of newer data
1709
+ * asks it again ({@link PivotReportRequest.refreshData}). */
1710
+ export declare type PivotReportUpdateMode = 'incremental' | 'fullRefresh';
1711
+
1712
+ /** The rows of a report asked for: from `start`, at most `count` of them. The whole report's row count is
1713
+ * the metadata's. */
1714
+ export declare interface PivotReportWindow {
1715
+ /** The first row, from 0. */
1716
+ readonly start: number;
1717
+ /** The most rows. */
1718
+ readonly count: number;
1719
+ }
1720
+
1721
+ /** Which side of a window a rest cell merges. */
1722
+ export declare type PivotRestSide = 'before' | 'after';
1723
+
1724
+ /** What a row of a report stands for, across reports: its role, its Value Field and its Items. */
1725
+ export declare class PivotRowKey {
1726
+ /** The row's role. */
1727
+ readonly role: PivotRowRole;
1728
+ /** The Value Field the row shows, or −1 when its columns say. */
1729
+ readonly valueField: number;
1730
+ /** The row's Items, outermost first. */
1731
+ readonly items: readonly PivotItemKey[];
1732
+ /** A key of a row's role, Value Field and Items. */
1733
+ constructor(role: PivotRowRole, valueField: number, items: readonly PivotItemKey[]);
1734
+ /** Whether two keys stand for one row: the same role, Value Field and Items. */
1735
+ equals(other: PivotRowKey): boolean;
1736
+ /** `item -1 [Text:East / Text:Apples]`, for messages and logs. */
1737
+ toString(): string;
1738
+ }
1739
+
1740
+ /** A row's label in one label column: its text, its indent in levels, and its button. */
1741
+ export declare interface PivotRowLabel {
1742
+ /** The text, or `undefined` for an empty label cell. */
1743
+ readonly text: string | undefined;
1744
+ /** The indent, in levels. */
1745
+ readonly indent: number;
1746
+ /** The collapse button, beside an outer Item that has Items under it. */
1747
+ readonly toggle?: PivotToggle;
1748
+ /** The number a number Item's label shows, in full, which its copy carries. */
1749
+ readonly number?: number;
1750
+ }
1751
+
1752
+ /** What a row of a report stands for (ADR-0059/0060): an Item of the innermost field, a group row, a
1753
+ * subtotal, or the grand total; or a Pending Row, kept for a sibling outside a Sibling Window and never shown
1754
+ * (ADR-0370 section 3). */
1755
+ export declare type PivotRowRole = 'item' | 'group' | 'subtotal' | 'grandTotal' | 'pending';
1756
+
1757
+ /**
1758
+ * A server's Change Batch (ADR-0370 section 3): the records its data lost and the records it gained between two
1759
+ * Source Versions, each with its values in the source's field order, as a record behind a cell carries them —
1760
+ * a date by its ticks, a date part by its number. A changed record is the old one lost and the new one
1761
+ * gained.
1762
+ */
1763
+ export declare interface PivotServerChangeBatch {
1764
+ /** Names the notice: the records the data lost and gained are told. */
1765
+ readonly kind: 'changeBatch';
1766
+ /** The Source Version the batch starts from. */
1767
+ readonly from: string;
1768
+ /** The Source Version it makes. */
1769
+ readonly to: string;
1770
+ /** The records the data lost, each with the values it had. */
1771
+ readonly removed: readonly (readonly PivotDetailValue[])[];
1772
+ /** The records the data gained. */
1773
+ readonly added: readonly (readonly PivotDetailValue[])[];
1774
+ }
1775
+
1776
+ /** That a server's data moved on, however the Consumer learned it (ADR-0370 section 3): the question is asked
1777
+ * again. */
1778
+ export declare interface PivotServerChanged {
1779
+ /** Names the notice: the data moved on, and its changes are not told. */
1780
+ readonly kind: 'changed';
1781
+ /** The Source Version the server answers under now, where the Consumer knows it. */
1782
+ readonly sourceVersion?: string;
1783
+ }
1784
+
1785
+ /** What the Consumer's transport tells a fetching source: that the data moved on, or how. */
1786
+ export declare type PivotServerNotice = PivotServerChanged | PivotServerChangeBatch;
1787
+
1788
+ /** How a Value Field's values are shown after aggregation (ADR-0060). */
1789
+ export declare type PivotShowValuesAs = 'noCalculation' | 'percentOfGrandTotal' | 'percentOfColumnTotal' | 'percentOfRowTotal';
1790
+
1791
+ /** Every Show Values As, in the C# engine's order: what Value Field Settings… offers. */
1792
+ export declare const pivotShowValuesAsList: readonly PivotShowValuesAs[];
1793
+
1794
+ /** The id of a Show Values As choice's name: `show-percent-of-grand-total` is `% of Grand Total`. */
1795
+ export declare function pivotShowValuesAsNameId(showValuesAs: PivotShowValuesAs): string;
1796
+
1797
+ /** How the engine's work paces itself (PV-40). */
1798
+ export declare interface PivotSlicing {
1799
+ /** How long one slice works, in milliseconds, before it yields; 30 when left out, within the 50 a page
1800
+ * may be blocked for. A slice always does some work, so 0 yields after every step. */
1801
+ readonly sliceBudgetMs?: number;
1802
+ /** What the work awaits between slices; a macrotask (`setTimeout(…, 0)`) when left out, which gives a
1803
+ * browser a turn of its event loop to paint in. */
1804
+ readonly yield?: () => Promise<void>;
1805
+ }
1806
+
1807
+ /** An Item order: by label, ascending or descending, or by a Value Field's value at each Item's total;
1808
+ * `(blank)` is last either way (ADR-0060). */
1809
+ export declare interface PivotSort {
1810
+ /** Ascending or descending. */
1811
+ readonly direction: PivotSortDirection;
1812
+ /** The index in the layout's Values of the Value Field to order by; absent to order by label. */
1813
+ readonly byValue?: number;
1814
+ }
1815
+
1816
+ /** A sort, checked and frozen. */
1817
+ export declare function pivotSort(direction?: PivotSortDirection, byValue?: number): PivotSort;
1818
+
1819
+ /** Ascending or descending, for an Item order; `(blank)` is last either way (ADR-0060). */
1820
+ export declare type PivotSortDirection = 'ascending' | 'descending';
1821
+
1822
+ /** What a report asks its data (ADR-0066). Each question is answered under a Source Version, or refused. */
1823
+ export declare interface PivotSource {
1824
+ /** The fields the source has. */
1825
+ readonly fields: readonly PivotField[];
1826
+ /** The Aggregations it answers. */
1827
+ readonly features: PivotSourceFeatures;
1828
+ /** The Leaf Aggregates of a question. */
1829
+ aggregate(query: PivotQuery, signal?: AbortSignal): Promise<PivotAnswer>;
1830
+ /** A page of a field's Items over all the data. */
1831
+ items(query: PivotItemsQuery, signal?: AbortSignal): Promise<PivotItemPage>;
1832
+ /** A page of the records behind a cell. */
1833
+ details(query: PivotDetailsQuery, signal?: AbortSignal): Promise<PivotDetailPage>;
1834
+ /** Each field's count of Items now (ADR-0370 section 3), asked of a source whose features declare
1835
+ * {@link PivotSourceFeatures.countsItems}. The bundled sources answer it, for a server that answers from
1836
+ * one, and do not declare it: in the page, a layout past the cap is refused as soon as a count would be
1837
+ * known. */
1838
+ itemCounts?(signal?: AbortSignal): Promise<PivotItemCounts>;
1839
+ /** Tells `listener` each time the source's data moves on (ADR-0067, ADR-0370 section 3); the function
1840
+ * returned stops telling it. A source whose data never moves has none. */
1841
+ subscribe?(listener: (changed: PivotSourceChanged) => void): () => void;
1842
+ /** Refresh: lets go of whatever the source holds for its questions, so the next one is asked of its data.
1843
+ * A source that holds nothing past its data has none; a source that wraps another passes it on. */
1844
+ refresh?(): void;
1845
+ }
1846
+
1847
+ /** What a source says when its data moved on (ADR-0067): the Source Version it answers under now. */
1848
+ export declare interface PivotSourceChanged {
1849
+ /** The Source Version the source answers under from now; absent where the source does not know it yet,
1850
+ * as a server's notice may not, and the next answer carries it. A source over a Snapshot always knows it. */
1851
+ readonly sourceVersion?: string;
1852
+ }
1853
+
1854
+ /** The Aggregations a source answers, whether it can be refreshed, and whether it counts its fields' Items. */
1855
+ export declare class PivotSourceFeatures {
1856
+ /** Every Aggregation, in the declared order. */
1857
+ static readonly all: PivotSourceFeatures;
1858
+ /** The Aggregations offered, in the declared order. */
1859
+ readonly aggregations: readonly PivotAggregation[];
1860
+ /** Whether Refresh asks the source again. */
1861
+ readonly canRefresh: boolean;
1862
+ /** Whether the source answers each field's count of Items ({@link PivotSource.itemCounts}, ADR-0370
1863
+ * section 3): the report then asks it once when the source is opened and again under a new Source
1864
+ * Version. */
1865
+ readonly countsItems: boolean;
1866
+ /** Whether the source answers a question carrying levels whose leaves pass its cap with the cells of the
1867
+ * groups shown ({@link PivotAnswer.isLevels}, ADR-0370 section 3): a report source over it then asks with the
1868
+ * groups its layout shows, and again when an expand shows groups the answer did not hold. */
1869
+ readonly answersLevels: boolean;
1870
+ /** The features of the Aggregations given, refusing one the engine does not know. */
1871
+ constructor(aggregations: Iterable<PivotAggregation>, canRefresh?: boolean, countsItems?: boolean, answersLevels?: boolean);
1872
+ /** Whether the source answers an Aggregation. */
1873
+ offers(aggregation: PivotAggregation): boolean;
1874
+ /** The Aggregations that read a part, when the source offers none of them; empty otherwise. */
1875
+ missingFor(part: number): readonly PivotAggregation[];
1876
+ }
1877
+
1878
+ /** A Pivot Source's refusal to answer: its kind, a sentence a person can read, and the field or the cap it
1879
+ * concerns. The report stays on the layout it had and says why. */
1880
+ export declare interface PivotSourceRefusal {
1881
+ /** Why the source refused. */
1882
+ readonly kind: PivotSourceRefusalKind;
1883
+ /** A sentence a person can read. */
1884
+ readonly message: string;
1885
+ /** The field the refusal concerns. */
1886
+ readonly field?: string;
1887
+ /** The cap a `tooManyLeaves` refusal passed. */
1888
+ readonly limit?: number;
1889
+ }
1890
+
1891
+ /** Why a Pivot Source refused a question (ADR-0066). */
1892
+ export declare type PivotSourceRefusalKind = 'tooManyLeaves' | 'unknownField' | 'aggregationNotOffered' | 'sourceVersionNotHeld';
1893
+
1894
+ /** The button beside an outer row Item, which collapses or expands it. */
1895
+ export declare interface PivotToggle {
1896
+ /** The row field whose Item it is. */
1897
+ readonly field: string;
1898
+ /** The Item it collapses or expands. */
1899
+ readonly item: PivotItemKey;
1900
+ /** The Item's label, for the button's accessible name. */
1901
+ readonly itemLabel: string;
1902
+ /** Whether the Item is collapsed now. */
1903
+ readonly isCollapsed: boolean;
1904
+ }
1905
+
1906
+ /** A value cell of a report: its text, its number, and its exact decimal where it was computed in one. */
1907
+ export declare interface PivotValue {
1908
+ /** The text the cell shows. */
1909
+ readonly text: string;
1910
+ /** The number, as a double: the exact one converted where there is one; 0 for an error. */
1911
+ readonly number: number;
1912
+ /** The exact decimal, where the Aggregation was computed in one. */
1913
+ readonly exact?: SnapshotDecimal;
1914
+ /** The error value's text, `#DIV/0!` or `#NUM!`, when the cell is one. */
1915
+ readonly error?: string;
1916
+ }
1917
+
1918
+ /**
1919
+ * Each Value Field's caption as the Field List shows it in Values, and the report heads its columns (ADR-0060):
1920
+ * its own caption, or the default in the report's words, `Sum of Amount`, numbered to stay unique. A layout
1921
+ * not yet answered is captioned as the report will caption it.
1922
+ */
1923
+ export declare function pivotValueCaptions(layout: PivotLayout, fields: readonly PivotField[], options?: PivotOptions): readonly string[];
1924
+
1925
+ /** A Pivot Field standing in Values (ADR-0060). */
1926
+ export declare interface PivotValueField {
1927
+ /** The Pivot Field's name. */
1928
+ readonly field: string;
1929
+ /** How the records at a cell are summarised. */
1930
+ readonly aggregation: PivotAggregation;
1931
+ /** A caption of the Value Field's own (Excel's Custom Name), or absent for `<Aggregation> of <field>`. */
1932
+ readonly caption?: string;
1933
+ /** How the aggregated values are shown. */
1934
+ readonly showValuesAs: PivotShowValuesAs;
1935
+ /** A .NET format string the values are shown in under the report's locale, or absent for General,
1936
+ * at most eleven characters besides a minus sign, or `0.00%` for a percentage. */
1937
+ readonly numberFormat?: string;
1938
+ }
1939
+
1940
+ /** A Value Field's settings, each its default when left out: Sum, the default caption, no calculation,
1941
+ * General. */
1942
+ export declare interface PivotValueFieldInput {
1943
+ /** The Pivot Field's name. */
1944
+ readonly field: string;
1945
+ /** How the records at a cell are summarised. */
1946
+ readonly aggregation?: PivotAggregation;
1947
+ /** A caption of the Value Field's own. */
1948
+ readonly caption?: string;
1949
+ /** How the aggregated values are shown. */
1950
+ readonly showValuesAs?: PivotShowValuesAs;
1951
+ /** A .NET format string the values are shown in. */
1952
+ readonly numberFormat?: string;
1953
+ }
1954
+
1955
+ /** A Pivot Layout written by a version this reader does not read: the C# engine's NotSupportedException. */
1956
+ export declare class PivotVersionError extends Error {
1957
+ constructor(message: string);
1958
+ }
1959
+
1960
+ /** Where one parent's window starts: the parent row group, by its Items, and the sibling it starts at. */
1961
+ export declare interface PivotWindowStart {
1962
+ /** The parent's Items, outermost first: none for the grand total. */
1963
+ readonly rows: readonly PivotItemKey[];
1964
+ /** The place among the siblings, from 0, of the first one asked for. */
1965
+ readonly start: number;
1966
+ }
1967
+
1968
+ /** The word for an id: the Consumer's, the English where it says nothing, and the id itself where neither
1969
+ * knows it — an id painted is a missing word seen, never a blank. */
1970
+ export declare function pivotWord(id: string, label: PivotLabel | undefined): string;
1971
+
1972
+ /** Every id the engine has an English word for, a date part's included: what a Consumer replaces to give
1973
+ * ExPivot another language. */
1974
+ export declare function pivotWordIdList(): readonly string[];
1975
+
1976
+ /** The ids of the words a report paints, by what they name. */
1977
+ export declare const pivotWordIds: Readonly<{
1978
+ /** The Compact form's label column header: `Row Labels`. */
1979
+ rowLabels: "row-labels";
1980
+ /** The Σ Values pseudo-field's header, and a report's lone value column when the values stand in
1981
+ * rows: `Values`. */
1982
+ values: "values";
1983
+ /** The grand total row and column: `Grand Total`. */
1984
+ grandTotal: "grand-total";
1985
+ /** An outer Item's subtotal: `{0} Total`, `{0}` the Item's label. */
1986
+ itemTotal: "item-total";
1987
+ /** A Value Field's grand total row, with the values in rows: `Total {0}`, `{0}` its caption. */
1988
+ totalOf: "total-of";
1989
+ /** An outer Item's subtotal row for one Value Field: `{0} {1}`, the Item's label and the caption. */
1990
+ itemValue: "item-value";
1991
+ /** The Blank Item: `(blank)`. */
1992
+ blank: "blank";
1993
+ /** A report filter with nothing hidden: `(All)`. */
1994
+ all: "all";
1995
+ /** A report filter showing several Items: `(Multiple Items)`. */
1996
+ multipleItems: "multiple-items";
1997
+ /** The Σ Values entry in an Area: `Σ Values`. */
1998
+ valuesPseudoField: "values-pseudo-field";
1999
+ /** A year's Item: `{0}`, the year. */
2000
+ dateYear: "date-year";
2001
+ /** A quarter's Item: `Qtr{0}`, the quarter from 1 to 4. */
2002
+ dateQuarter: "date-quarter";
2003
+ /** A server's layout over the leaf cap, refused at the drop (ADR-0370 section 3), `{0}` the field moved,
2004
+ * `{1}` its Area's word and `{2}` the cap:
2005
+ * `{0} in {1} makes more than {2} combinations, the most server data allows.` */
2006
+ tooManyCombinations: "refused-too-many-combinations";
2007
+ /** The same refusal where the source counted the field, `{1}` the field's count of Items:
2008
+ * `{0} ({1} items) in {2} makes more than {3} combinations, the most server data allows.` */
2009
+ tooManyCombinationsCounted: "refused-too-many-combinations-counted";
2010
+ /** The ways that remain after that refusal, `{0}` the field: `Put {0} in Filters, or filter {0} first.` */
2011
+ tooManyCombinationsRemedy: "refused-too-many-combinations-remedy";
2012
+ }>;
2013
+
2014
+ /** A field dropped from the list of fields on an Area at `index` (ADR-0061): in Values it is a new Value
2015
+ * Field, whatever else it stands in; in Filters, Rows or Columns it is placed there, moving out of
2016
+ * whichever of them it stood in, with its settings. */
2017
+ export declare function placeField(layout: PivotLayout, field: PivotFieldInfo, area: PivotArea, index: number): PivotLayout;
2018
+
2019
+ /** Where a field stands among Filters, Rows and Columns, or `undefined` when it stands in none of them. */
2020
+ export declare function placementOf(layout: PivotLayout, field: string): {
2021
+ readonly area: PivotArea;
2022
+ readonly index: number;
2023
+ } | undefined;
2024
+
2025
+ /** The placements of Filters, Rows or Columns. */
2026
+ export declare function placementsIn(layout: PivotLayout, area: PivotArea): readonly PivotFieldPlacement[];
2027
+
2028
+ /** Whether the field stands anywhere, Values included: a ticked field. */
2029
+ export declare function placesField(layout: PivotLayout, field: string): boolean;
2030
+
2031
+ /** The question a layout asks (ADR-0066): its row and column fields, the Filters that hide something, and
2032
+ * each field in Values once, with the parts of every Value Field of it. */
2033
+ export declare function queryForLayout(layout: PivotLayout, maxLeaves?: number): PivotQuery;
2034
+
2035
+ /**
2036
+ * A layout read back from {@link writePivotLayoutJson}'s JSON. Refuses by name, with a PivotFormatError, a
2037
+ * document that is not an object, an unknown name for a form, an axis, an Aggregation, a Show Values As, a
2038
+ * sort direction or an Item kind, and a member of the wrong type; and with a PivotVersionError a document of
2039
+ * another version.
2040
+ */
2041
+ export declare function readPivotLayoutJson(json: string): PivotLayout;
2042
+
2043
+ /** The bundled source over records in memory (ADR-0066): read into a Snapshot on the first question, each
2044
+ * field through its accessor; it answers every Aggregation under one version, the records being fixed. */
2045
+ export declare class RecordPivotSource<TRecord> implements PivotSource {
2046
+ #private;
2047
+ /** The fields, each read through its accessor. */
2048
+ readonly fields: readonly PivotRecordField<TRecord>[];
2049
+ /** Every Aggregation. */
2050
+ readonly features: PivotSourceFeatures;
2051
+ /** The one version the source answers under. */
2052
+ readonly sourceVersion: string;
2053
+ /** The records, as given. */
2054
+ readonly records: readonly TRecord[];
2055
+ /** A source over records, refusing a name declared twice among the fields. */
2056
+ constructor(records: readonly TRecord[], fields: readonly PivotRecordField<TRecord>[]);
2057
+ /** The Leaf Aggregates of a question, or a refusal. */
2058
+ aggregate(query: PivotQuery, signal?: AbortSignal): Promise<PivotAnswer>;
2059
+ /** The Leaf Aggregates of a question, on the calling thread; past the cap, for a question carrying levels,
2060
+ * the cells of the groups shown (ADR-0370 section 3). */
2061
+ aggregateNow(query: PivotQuery): PivotAnswer;
2062
+ /** A page of a field's Items. */
2063
+ items(query: PivotItemsQuery, signal?: AbortSignal): Promise<PivotItemPage>;
2064
+ /** Each field's count of Items over the records (ADR-0370 section 3). */
2065
+ itemCounts(signal?: AbortSignal): Promise<PivotItemCounts>;
2066
+ /** A page of the records behind a cell, each carrying its record. */
2067
+ details(query: PivotDetailsQuery, signal?: AbortSignal): Promise<PivotDetailPage>;
2068
+ /** The records behind a cell, in their order, refusing by name a field the source does not have. */
2069
+ recordsBehind(query: PivotDetailsQuery): readonly TRecord[];
2070
+ }
2071
+
2072
+ /**
2073
+ * The records behind one cell of a report — Show Details (ADR-0063) — in their order: those no Hidden Item
2074
+ * leaves out, carrying the row's Items and the column's. A label cell is value column −1, and is every
2075
+ * record of its row.
2076
+ */
2077
+ export declare function recordsBehind<TRecord>(records: readonly TRecord[], fields: readonly PivotRecordField<TRecord>[], report: PivotReport, row: PivotReportRow, valueColumn: number): readonly TRecord[];
2078
+
2079
+ /** The id of a refusal's sentence among the report's words. */
2080
+ export declare function refusalWord(refusal: PivotRefusal): string;
2081
+
2082
+ /** Removing an entry — Remove Field, or dragging it back to the list of fields (ADR-0061). Σ Values cannot
2083
+ * be removed: it leaves when fewer than two Value Fields remain. */
2084
+ export declare function removeEntry(layout: PivotLayout, entry: PivotEntry): PivotLayout;
2085
+
2086
+ /** One Item collapsed or expanded, wherever it appears (ADR-0060). */
2087
+ export declare function setCollapsed(layout: PivotLayout, field: string, item: PivotItemKey, collapsed: boolean): PivotLayout;
2088
+
2089
+ /** Expand or Collapse Entire Field: every Item of the field, with no exception. */
2090
+ export declare function setFieldCollapsed(layout: PivotLayout, field: string, collapsed: boolean): PivotLayout;
2091
+
2092
+ /**
2093
+ * A field's Hidden Items, as Filter… applies them (ADR-0060/0061): refused when they would hide every one
2094
+ * of `items` — the field's Items in the data — because a report of nothing reads as "no data". A key hidden
2095
+ * that no Item carries is kept: it hides the Item if later data brings it.
2096
+ */
2097
+ export declare function setHiddenItems(layout: PivotLayout, field: string, hidden: Iterable<PivotItemKey>, items: readonly PivotItemKey[]): PivotEditResult;
2098
+
2099
+ /** A field's Item order — Sort A to Z, Z to A, or by a Value Field. */
2100
+ export declare function setSort(layout: PivotLayout, field: string, sort: PivotSort): PivotLayout;
2101
+
2102
+ /** A field's subtotals: Automatic (true) or None. */
2103
+ export declare function setSubtotals(layout: PivotLayout, field: string, subtotals: boolean): PivotLayout;
2104
+
2105
+ /**
2106
+ * A Value Field's settings, as Value Field Settings… applies them (ADR-0060/0061): refused when its own
2107
+ * caption is empty, or is another Value Field's caption or a Pivot Field's, or when its number format
2108
+ * cannot be used. A caption is compared with the captions the report shows, in its words.
2109
+ */
2110
+ export declare function setValueField(layout: PivotLayout, index: number, value: PivotValueFieldInput, fields: readonly PivotField[], options?: PivotOptions): PivotEditResult;
2111
+
2112
+ /**
2113
+ * The bundled source over a Snapshot (ADR-0066): it answers every Aggregation under the version
2114
+ * `{identity}:{snapshot version}`, in slices (PV-40).
2115
+ *
2116
+ * **Live data** (ADR-0067): {@link SnapshotPivotSource.apply} takes a Change Batch. The Snapshot makes the next one, the answer the
2117
+ * source holds for its last question is brought up to date from what the batch removed and added rather than
2118
+ * read again — the exact parts by subtraction and addition, every other part recomputed for the leaves the
2119
+ * batch touched — and each listener {@link SnapshotPivotSource.subscribe}d is told the new Source Version. Asked the same question
2120
+ * again, the source answers from what it holds: after any sequence of batches, what a fresh source over the
2121
+ * Snapshot they made answers, read in that Snapshot's order, to the last bit. A batch applied while an answer
2122
+ * is assembled from what it holds waits until the answer is made, so that no answer is half a batch.
2123
+ *
2124
+ * It answers a field's Items and a cell's records under its current version and under the versions of its
2125
+ * last {@link SnapshotPivotSource.answersHeld} answers — a Snapshot is immutable, so their records still add
2126
+ * up — and refuses an older one.
2127
+ */
2128
+ export declare class SnapshotPivotSource implements PivotSource {
2129
+ #private;
2130
+ /** How many of its latest answers' versions the source keeps answering Items and records under, besides
2131
+ * its current one. */
2132
+ static readonly answersHeld = 4;
2133
+ /** The fields bound to the Snapshot's columns. */
2134
+ readonly fields: readonly PivotField[];
2135
+ /** Every Aggregation. */
2136
+ readonly features: PivotSourceFeatures;
2137
+ /** A source over a Snapshot: `fields` bound to its columns, or one field per column; its work paced by
2138
+ * `slicing`. */
2139
+ constructor(snapshot: Snapshot, fields?: readonly PivotField[], slicing?: PivotSlicing);
2140
+ /** The Snapshot the source answers from now: the one it was made with, or the one the last Change Batch
2141
+ * made. */
2142
+ get snapshot(): Snapshot;
2143
+ /** The version the source answers under now. */
2144
+ get sourceVersion(): string;
2145
+ /** Tells `listener` each new Source Version, after the source has moved on to it; the function returned
2146
+ * stops telling it. */
2147
+ subscribe(listener: (changed: PivotSourceChanged) => void): () => void;
2148
+ /**
2149
+ * Applies a Change Batch (ADR-0067): the Snapshot makes the next one, whole or not at all; the answer held
2150
+ * for the last question is brought up to date from what the batch removed and added; and each listener is
2151
+ * told the new Source Version, after the source has moved on. A batch the Snapshot refuses throws its
2152
+ * `SnapshotError`, and nothing of it is applied. An error a listener throws does not stop the others being
2153
+ * told, nor make the batch look refused: it is thrown again from a microtask, as an event listener's is.
2154
+ */
2155
+ apply(batch: ChangeBatch): SnapshotChange;
2156
+ /**
2157
+ * The Leaf Aggregates of a question, or a refusal, read in slices — or, for the question it answered last,
2158
+ * from the pass it holds and has folded every batch into since. Past the cap, a question carrying levels
2159
+ * is answered with the cells of the groups shown, at most that many (ADR-0370 section 3), though the source
2160
+ * does not declare it, for a server that answers from it. The answer is assembled in slices too, and a
2161
+ * cancelled question rejects with the signal's reason at the next slice.
2162
+ */
2163
+ aggregate(query: PivotQuery, signal?: AbortSignal): Promise<PivotAnswer>;
2164
+ /** A page of a field's Items over all the data of the version asked, read in slices; refused under a
2165
+ * version the source no longer holds. */
2166
+ items(query: PivotItemsQuery, signal?: AbortSignal): Promise<PivotItemPage>;
2167
+ /** Each field's count of Items in the current Snapshot, read in slices, field after field (ADR-0370
2168
+ * section 3): what a server answering from this source answers its Field List with. A count is the
2169
+ * length of the field's whole page of Items. */
2170
+ itemCounts(signal?: AbortSignal): Promise<PivotItemCounts>;
2171
+ /** A page of the records behind a cell in the version asked, in the Snapshot's order, read in slices;
2172
+ * refused under a version the source no longer holds. */
2173
+ details(query: PivotDetailsQuery, signal?: AbortSignal): Promise<PivotDetailPage>;
2174
+ }
2175
+
2176
+ /** Whether two sorts are one. */
2177
+ export declare function sortsEqual(a: PivotSort, b: PivotSort): boolean;
2178
+
2179
+ /** The key of a text Item. */
2180
+ export declare function textItemKey(text: string): PivotItemKey;
2181
+
2182
+ /** Ticking a field (ADR-0061): one standing nowhere goes to the end of Values when it is declared Number,
2183
+ * and to the end of Rows otherwise. A field already standing somewhere is left where it is. */
2184
+ export declare function tickField(layout: PivotLayout, field: PivotFieldInfo): PivotLayout;
2185
+
2186
+ /** The words of Excel's English (United Kingdom) edition where they differ from the English (United
2187
+ * States) edition's: `Max.`, `Max. of {0}`, `Summarise value field by`. */
2188
+ export declare const unitedKingdomPivotWords: PivotLabel;
2189
+
2190
+ /** Unticking a field: it leaves every Area it stands in, each of its Value Fields included (ADR-0061). */
2191
+ export declare function untickField(layout: PivotLayout, field: string): PivotLayout;
2192
+
2193
+ /** Refuses by name a layout that names an undeclared field, stands a field in two of Filters, Rows and
2194
+ * Columns, orders by a Value Field it does not have, or carries a setting the engine does not know. */
2195
+ export declare function validateLayout(layout: PivotLayout, declared: ReadonlyMap<string, unknown>): void;
2196
+
2197
+ /** Whether two Value Fields are one, member by member, as the C# engine's record equality says. */
2198
+ export declare function valueFieldsEqual(a: PivotValueField, b: PivotValueField): boolean;
2199
+
2200
+ /** Σ Values, standing in the Area its axis names. */
2201
+ export declare function valuesPseudoField(axis: PivotAxis): PivotEntry;
2202
+
2203
+ /** The layout as JSON, its members in the C# writer's order. */
2204
+ export declare function writePivotLayoutJson(layout: PivotLayout): string;
2205
+
2206
+ export { }