@orkestrel/table 0.0.2 → 0.0.4
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.
- package/README.md +6 -6
- package/dist/src/core/index.cjs +228 -196
- package/dist/src/core/index.cjs.map +1 -0
- package/dist/src/core/index.d.cts +237 -382
- package/dist/src/core/index.d.ts +237 -382
- package/dist/src/core/index.js +226 -191
- package/dist/src/core/index.js.map +1 -0
- package/package.json +20 -15
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { Emitter } from '@orkestrel/emitter';
|
|
2
1
|
import { EmitterErrorHandler } from '@orkestrel/emitter';
|
|
3
2
|
import { EmitterHooks } from '@orkestrel/emitter';
|
|
4
3
|
import { EmitterInterface } from '@orkestrel/emitter';
|
|
5
4
|
import { JSONRecord } from '@orkestrel/contract';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Checks whether one column admits a filter and all its operands.
|
|
9
8
|
*
|
|
10
9
|
* @param column - The column that fixes the accepted operators and cell shapes.
|
|
11
10
|
* @param filter - The filter to inspect.
|
|
12
|
-
* @returns
|
|
11
|
+
* @returns True if the filter belongs to the column and the column can apply it; false otherwise.
|
|
13
12
|
*/
|
|
14
13
|
export declare function admitsFilter(column: TableColumn, filter: TableFilter): boolean;
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
16
|
+
* Audits a structurally valid schema for domain and budget faults.
|
|
18
17
|
*
|
|
19
18
|
* @param schema - The table schema to audit.
|
|
20
19
|
* @returns Frozen human-readable diagnostics, or an empty list when the schema is sound.
|
|
@@ -22,7 +21,7 @@ export declare function admitsFilter(column: TableColumn, filter: TableFilter):
|
|
|
22
21
|
export declare function auditTable(schema: TableSchema): readonly string[];
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
24
|
+
* Keeps the rows whose cell falls between these bounds, both included.
|
|
26
25
|
*
|
|
27
26
|
* @remarks
|
|
28
27
|
* The bounds compare the way the column compares, so a `text` column holding ISO strings takes a
|
|
@@ -36,7 +35,7 @@ export declare interface BetweenFilter {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
38
|
+
* Compares two cells of one column.
|
|
40
39
|
*
|
|
41
40
|
* @remarks
|
|
42
41
|
* It replaces the comparison the column's {@link ColumnCell} fixes, for that column alone, and it
|
|
@@ -56,7 +55,7 @@ export declare interface BetweenFilter {
|
|
|
56
55
|
export declare type CellComparator = (left: TableCell | undefined, right: TableCell | undefined) => number;
|
|
57
56
|
|
|
58
57
|
/**
|
|
59
|
-
*
|
|
58
|
+
* Tests one column's cell against a filter.
|
|
60
59
|
*
|
|
61
60
|
* @remarks
|
|
62
61
|
* It replaces the test the column's {@link ColumnCell} fixes, for that column alone, and it
|
|
@@ -64,7 +63,7 @@ export declare type CellComparator = (left: TableCell | undefined, right: TableC
|
|
|
64
63
|
*
|
|
65
64
|
* @param cell - The row's cell, or `undefined` when it carries none.
|
|
66
65
|
* @param filter - The filter the table is applying.
|
|
67
|
-
* @returns
|
|
66
|
+
* @returns True if the filter accepts the cell; false otherwise.
|
|
68
67
|
* @example
|
|
69
68
|
* ```ts
|
|
70
69
|
* const loose: CellMatcher = (cell, filter) =>
|
|
@@ -73,11 +72,11 @@ export declare type CellComparator = (left: TableCell | undefined, right: TableC
|
|
|
73
72
|
*/
|
|
74
73
|
export declare type CellMatcher = (cell: TableCell | undefined, filter: TableFilter) => boolean;
|
|
75
74
|
|
|
76
|
-
/**
|
|
75
|
+
/** Names the maximum number of choices one `choice` column may offer. */
|
|
77
76
|
export declare const CHOICE_LIMIT = 1024;
|
|
78
77
|
|
|
79
78
|
/**
|
|
80
|
-
*
|
|
79
|
+
* Represents a column drawn from a declared list, compared by the order that list declares.
|
|
81
80
|
*
|
|
82
81
|
* @remarks
|
|
83
82
|
* A cell holding a value the list does not offer is refused at admission.
|
|
@@ -88,7 +87,7 @@ export declare interface ChoiceColumn extends ColumnBase {
|
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
/**
|
|
91
|
-
*
|
|
90
|
+
* Clones one row into an owned frozen snapshot.
|
|
92
91
|
*
|
|
93
92
|
* @param row - The row to own.
|
|
94
93
|
* @returns A frozen copy of the row's cells.
|
|
@@ -96,21 +95,21 @@ export declare interface ChoiceColumn extends ColumnBase {
|
|
|
96
95
|
export declare function cloneRow(row: TableRow): TableRow;
|
|
97
96
|
|
|
98
97
|
/**
|
|
99
|
-
*
|
|
98
|
+
* Clones a table schema into an owned frozen snapshot.
|
|
100
99
|
*
|
|
101
100
|
* @param schema - The schema to own.
|
|
102
101
|
* @returns A frozen schema with every nested column, choice, list, and metadata record owned.
|
|
103
102
|
*/
|
|
104
103
|
export declare function cloneSchema(schema: TableSchema): TableSchema;
|
|
105
104
|
|
|
106
|
-
/**
|
|
105
|
+
/** Lists every column cell, in the order declared by the public contract. */
|
|
107
106
|
export declare const COLUMN_CELLS: readonly ColumnCell[];
|
|
108
107
|
|
|
109
|
-
/**
|
|
108
|
+
/** Names the maximum number of columns one schema may declare. */
|
|
110
109
|
export declare const COLUMN_LIMIT = 256;
|
|
111
110
|
|
|
112
111
|
/**
|
|
113
|
-
*
|
|
112
|
+
* Describes what every column carries, whatever its cells hold.
|
|
114
113
|
*
|
|
115
114
|
* @remarks
|
|
116
115
|
* `key` names the column, and it is the name a row uses for that column's cell. `label` is the
|
|
@@ -135,7 +134,7 @@ export declare interface ColumnBase {
|
|
|
135
134
|
}
|
|
136
135
|
|
|
137
136
|
/**
|
|
138
|
-
*
|
|
137
|
+
* Names what a column's cells hold.
|
|
139
138
|
*
|
|
140
139
|
* @remarks
|
|
141
140
|
* The cell is the discriminant of every {@link TableColumn} variant, so choosing it fixes what the
|
|
@@ -153,7 +152,7 @@ export declare interface ColumnBase {
|
|
|
153
152
|
export declare type ColumnCell = 'text' | 'number' | 'flag' | 'choice';
|
|
154
153
|
|
|
155
154
|
/**
|
|
156
|
-
*
|
|
155
|
+
* Represents one value a `choice` column offers.
|
|
157
156
|
*
|
|
158
157
|
* @remarks
|
|
159
158
|
* `value` is what the cell holds and `label` is what a reader sees. `help` explains the choice.
|
|
@@ -167,7 +166,7 @@ export declare interface ColumnChoice {
|
|
|
167
166
|
}
|
|
168
167
|
|
|
169
168
|
/**
|
|
170
|
-
*
|
|
169
|
+
* Compares two cells in ascending order according to one column.
|
|
171
170
|
*
|
|
172
171
|
* @param column - The column that fixes the comparison.
|
|
173
172
|
* @param left - The first cell, or absence.
|
|
@@ -177,7 +176,7 @@ export declare interface ColumnChoice {
|
|
|
177
176
|
export declare function compareCells(column: TableColumn, left: TableCell | undefined, right: TableCell | undefined): number;
|
|
178
177
|
|
|
179
178
|
/**
|
|
180
|
-
*
|
|
179
|
+
* Computes one atomic 0/1/N membership change over known keys.
|
|
181
180
|
*
|
|
182
181
|
* @param known - Every key the caller may change.
|
|
183
182
|
* @param current - The current key set.
|
|
@@ -188,7 +187,7 @@ export declare function compareCells(column: TableColumn, left: TableCell | unde
|
|
|
188
187
|
*/
|
|
189
188
|
export declare function computeKeys(known: readonly TableKey[], current: ReadonlySet<TableKey>, input: TableKey | readonly TableKey[] | undefined, include: (included: boolean) => boolean): ReadonlySet<TableKey> | undefined;
|
|
190
189
|
|
|
191
|
-
/**
|
|
190
|
+
/** Keeps the rows whose cell holds this text somewhere inside it. */
|
|
192
191
|
export declare interface ContainsFilter {
|
|
193
192
|
readonly column: string;
|
|
194
193
|
readonly operator: 'contains';
|
|
@@ -196,7 +195,7 @@ export declare interface ContainsFilter {
|
|
|
196
195
|
}
|
|
197
196
|
|
|
198
197
|
/**
|
|
199
|
-
*
|
|
198
|
+
* Opens a table against a schema.
|
|
200
199
|
*
|
|
201
200
|
* @param schema - The table declaration to own.
|
|
202
201
|
* @param options - Initial rows, lens overrides, pagination, and emitter wiring.
|
|
@@ -211,48 +210,15 @@ export declare interface ContainsFilter {
|
|
|
211
210
|
*/
|
|
212
211
|
export declare function createTable(schema: TableSchema, options?: TableOptions): TableInterface;
|
|
213
212
|
|
|
214
|
-
/**
|
|
213
|
+
/** Keeps the rows whose cell holds exactly this value. */
|
|
215
214
|
export declare interface EqualsFilter {
|
|
216
215
|
readonly column: string;
|
|
217
216
|
readonly operator: 'equals';
|
|
218
217
|
readonly value: TableCell;
|
|
219
218
|
}
|
|
220
219
|
|
|
221
|
-
/** The keys of the rows somebody has opened. */
|
|
222
|
-
export declare class ExpansionManager implements ExpansionManagerInterface {
|
|
223
|
-
#private;
|
|
224
|
-
/**
|
|
225
|
-
* Create an expansion manager over one table's private stores.
|
|
226
|
-
*
|
|
227
|
-
* @param emitter - The table's event emitter.
|
|
228
|
-
* @param gate - The table lifecycle gate.
|
|
229
|
-
* @param rows - A read of every row key.
|
|
230
|
-
* @param read - A read of the expanded keys.
|
|
231
|
-
* @param write - The expanded-key commit boundary.
|
|
232
|
-
*/
|
|
233
|
-
constructor(emitter: Emitter<TableEventMap>, gate: () => void, rows: () => readonly TableKey[], read: () => ReadonlySet<TableKey>, write: (keys: ReadonlySet<TableKey>) => void);
|
|
234
|
-
/** The keys of the rows opened right now. */
|
|
235
|
-
get keys(): ReadonlySet<TableKey>;
|
|
236
|
-
/** Open every row the table holds. */
|
|
237
|
-
expand(): void;
|
|
238
|
-
/** Open one row. */
|
|
239
|
-
expand(key: TableKey): boolean;
|
|
240
|
-
/** Open several rows. */
|
|
241
|
-
expand(keys: readonly TableKey[]): boolean;
|
|
242
|
-
/** Close every row. */
|
|
243
|
-
clear(): void;
|
|
244
|
-
/** Close one row. */
|
|
245
|
-
clear(key: TableKey): boolean;
|
|
246
|
-
/** Close several rows. */
|
|
247
|
-
clear(keys: readonly TableKey[]): boolean;
|
|
248
|
-
/** Open one row or close it when already open. */
|
|
249
|
-
toggle(key: TableKey): boolean;
|
|
250
|
-
/** Turn several rows around independently. */
|
|
251
|
-
toggle(keys: readonly TableKey[]): boolean;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
220
|
/**
|
|
255
|
-
*
|
|
221
|
+
* Manages the rows somebody has opened up.
|
|
256
222
|
*
|
|
257
223
|
* @remarks
|
|
258
224
|
* Expansion holds keys exactly as selection does, and what an opened row shows beside it is the
|
|
@@ -265,61 +231,62 @@ export declare class ExpansionManager implements ExpansionManagerInterface {
|
|
|
265
231
|
* ```
|
|
266
232
|
*/
|
|
267
233
|
export declare interface ExpansionManagerInterface {
|
|
268
|
-
/**
|
|
234
|
+
/** Holds the keys of the rows opened right now. */
|
|
269
235
|
readonly keys: ReadonlySet<TableKey>;
|
|
270
|
-
/**
|
|
236
|
+
/** Opens every row the table holds. */
|
|
271
237
|
expand(): void;
|
|
272
238
|
/**
|
|
273
|
-
*
|
|
239
|
+
* Opens one row.
|
|
274
240
|
*
|
|
275
241
|
* @param key - The row's key.
|
|
276
|
-
* @returns
|
|
242
|
+
* @returns True if the key named a row the table holds; false otherwise.
|
|
277
243
|
*/
|
|
278
244
|
expand(key: TableKey): boolean;
|
|
279
245
|
/**
|
|
280
|
-
*
|
|
246
|
+
* Opens several rows.
|
|
281
247
|
*
|
|
282
248
|
* @param keys - The rows' keys.
|
|
283
|
-
* @returns
|
|
284
|
-
* row opens.
|
|
249
|
+
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
250
|
+
* checked before any row opens.
|
|
285
251
|
*/
|
|
286
252
|
expand(keys: readonly TableKey[]): boolean;
|
|
287
|
-
/**
|
|
253
|
+
/** Closes every row. */
|
|
288
254
|
clear(): void;
|
|
289
255
|
/**
|
|
290
|
-
*
|
|
256
|
+
* Closes one row.
|
|
291
257
|
*
|
|
292
258
|
* @param key - The row's key.
|
|
293
|
-
* @returns
|
|
259
|
+
* @returns True if the key named a row the table holds, whether or not it was
|
|
260
|
+
* open; false otherwise.
|
|
294
261
|
*/
|
|
295
262
|
clear(key: TableKey): boolean;
|
|
296
263
|
/**
|
|
297
|
-
*
|
|
264
|
+
* Closes several rows.
|
|
298
265
|
*
|
|
299
266
|
* @param keys - The rows' keys.
|
|
300
|
-
* @returns
|
|
301
|
-
* row closes.
|
|
267
|
+
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
268
|
+
* checked before any row closes.
|
|
302
269
|
*/
|
|
303
270
|
clear(keys: readonly TableKey[]): boolean;
|
|
304
271
|
/**
|
|
305
|
-
*
|
|
272
|
+
* Opens one row, or closes it when it is already open.
|
|
306
273
|
*
|
|
307
274
|
* @param key - The row's key.
|
|
308
|
-
* @returns
|
|
275
|
+
* @returns True if the key named a row the table holds; false otherwise.
|
|
309
276
|
*/
|
|
310
277
|
toggle(key: TableKey): boolean;
|
|
311
278
|
/**
|
|
312
|
-
*
|
|
279
|
+
* Turns several rows around, each on its own.
|
|
313
280
|
*
|
|
314
281
|
* @param keys - The rows' keys.
|
|
315
|
-
* @returns
|
|
316
|
-
* row turns.
|
|
282
|
+
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
283
|
+
* checked before any row turns.
|
|
317
284
|
*/
|
|
318
285
|
toggle(keys: readonly TableKey[]): boolean;
|
|
319
286
|
}
|
|
320
287
|
|
|
321
288
|
/**
|
|
322
|
-
*
|
|
289
|
+
* Finds one column by key.
|
|
323
290
|
*
|
|
324
291
|
* @param schema - The schema whose columns to search.
|
|
325
292
|
* @param key - The column key to find.
|
|
@@ -328,7 +295,7 @@ export declare interface ExpansionManagerInterface {
|
|
|
328
295
|
export declare function extractColumn(schema: TableSchema, key: string): TableColumn | undefined;
|
|
329
296
|
|
|
330
297
|
/**
|
|
331
|
-
*
|
|
298
|
+
* Reads one row's declared identity.
|
|
332
299
|
*
|
|
333
300
|
* @param schema - The schema that names the identity column.
|
|
334
301
|
* @param row - The row whose identity to read.
|
|
@@ -336,38 +303,8 @@ export declare function extractColumn(schema: TableSchema, key: string): TableCo
|
|
|
336
303
|
*/
|
|
337
304
|
export declare function extractKey(schema: TableSchema, row: TableRow): TableKey | undefined;
|
|
338
305
|
|
|
339
|
-
/** The filters one table applies with and-only composition. */
|
|
340
|
-
export declare class FilterManager implements FilterManagerInterface {
|
|
341
|
-
#private;
|
|
342
|
-
/**
|
|
343
|
-
* Create a filter manager over one table's private filter store.
|
|
344
|
-
*
|
|
345
|
-
* @param schema - The table schema.
|
|
346
|
-
* @param emitter - The table's event emitter.
|
|
347
|
-
* @param gate - The table lifecycle gate.
|
|
348
|
-
* @param read - A read of the current filters.
|
|
349
|
-
* @param write - The filter commit boundary.
|
|
350
|
-
* @param clamp - The pagination clamp commit after a filter commit.
|
|
351
|
-
*/
|
|
352
|
-
constructor(schema: TableSchema, emitter: Emitter<TableEventMap>, gate: () => void, read: () => readonly TableFilter[], write: (filters: readonly TableFilter[]) => void, clamp: () => number | undefined);
|
|
353
|
-
/** Find one column's filter. */
|
|
354
|
-
filter(column: string): TableFilter | undefined;
|
|
355
|
-
/** Read every filter as an owned frozen snapshot. */
|
|
356
|
-
filters(): readonly TableFilter[];
|
|
357
|
-
/** Filter several columns. */
|
|
358
|
-
set(filters: readonly TableFilter[]): void;
|
|
359
|
-
/** Filter one column. */
|
|
360
|
-
set(filter: TableFilter): void;
|
|
361
|
-
/** Stop filtering by every column. */
|
|
362
|
-
remove(): void;
|
|
363
|
-
/** Stop filtering by one column. */
|
|
364
|
-
remove(column: string): boolean;
|
|
365
|
-
/** Stop filtering by several columns. */
|
|
366
|
-
remove(columns: readonly string[]): boolean;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
306
|
/**
|
|
370
|
-
*
|
|
307
|
+
* Manages which rows a table keeps.
|
|
371
308
|
*
|
|
372
309
|
* @remarks
|
|
373
310
|
* The table holds at most one filter per column and keeps the rows every filter accepts.
|
|
@@ -380,20 +317,20 @@ export declare class FilterManager implements FilterManagerInterface {
|
|
|
380
317
|
*/
|
|
381
318
|
export declare interface FilterManagerInterface {
|
|
382
319
|
/**
|
|
383
|
-
*
|
|
320
|
+
* Finds one column's filter.
|
|
384
321
|
*
|
|
385
322
|
* @param column - The column's key.
|
|
386
323
|
* @returns The filter, or `undefined` when nothing filters that column.
|
|
387
324
|
*/
|
|
388
325
|
filter(column: string): TableFilter | undefined;
|
|
389
326
|
/**
|
|
390
|
-
*
|
|
327
|
+
* Reads every filter the table keeps rows by.
|
|
391
328
|
*
|
|
392
329
|
* @returns The filters, in the order they were set.
|
|
393
330
|
*/
|
|
394
331
|
filters(): readonly TableFilter[];
|
|
395
332
|
/**
|
|
396
|
-
*
|
|
333
|
+
* Filters several columns.
|
|
397
334
|
*
|
|
398
335
|
* @param filters - The filters to set. A filter for a column already filtered replaces that
|
|
399
336
|
* column's filter; every other one joins the end of the list.
|
|
@@ -403,34 +340,34 @@ export declare interface FilterManagerInterface {
|
|
|
403
340
|
*/
|
|
404
341
|
set(filters: readonly TableFilter[]): void;
|
|
405
342
|
/**
|
|
406
|
-
*
|
|
343
|
+
* Filters one column.
|
|
407
344
|
*
|
|
408
345
|
* @param filter - The filter to set.
|
|
409
346
|
* @throws A {@link TableError} coded `COLUMN` when the filter names a column the schema does
|
|
410
347
|
* not declare, and `CELL` when an operand is one the column cannot hold.
|
|
411
348
|
*/
|
|
412
349
|
set(filter: TableFilter): void;
|
|
413
|
-
/**
|
|
350
|
+
/** Stops filtering by anything. */
|
|
414
351
|
remove(): void;
|
|
415
352
|
/**
|
|
416
|
-
*
|
|
353
|
+
* Stops filtering one column.
|
|
417
354
|
*
|
|
418
355
|
* @param column - The column's key.
|
|
419
|
-
* @returns
|
|
356
|
+
* @returns True if the schema declares that column; false otherwise.
|
|
420
357
|
*/
|
|
421
358
|
remove(column: string): boolean;
|
|
422
359
|
/**
|
|
423
|
-
*
|
|
360
|
+
* Stops filtering several columns.
|
|
424
361
|
*
|
|
425
362
|
* @param columns - The columns' keys.
|
|
426
|
-
* @returns
|
|
427
|
-
* filter goes.
|
|
363
|
+
* @returns True if the schema declares every one of them; false otherwise. Every key is
|
|
364
|
+
* checked before any filter goes.
|
|
428
365
|
*/
|
|
429
366
|
remove(columns: readonly string[]): boolean;
|
|
430
367
|
}
|
|
431
368
|
|
|
432
369
|
/**
|
|
433
|
-
*
|
|
370
|
+
* Names how a filter tests a cell.
|
|
434
371
|
*
|
|
435
372
|
* @remarks
|
|
436
373
|
* `contains` looks for text inside a `text` or `choice` cell. `between` accepts a cell inside a
|
|
@@ -443,7 +380,7 @@ export declare interface FilterManagerInterface {
|
|
|
443
380
|
export declare type FilterOperator = 'contains' | 'between' | 'equals';
|
|
444
381
|
|
|
445
382
|
/**
|
|
446
|
-
*
|
|
383
|
+
* Keeps the rows accepted by every filter.
|
|
447
384
|
*
|
|
448
385
|
* @param schema - The schema that declares the filtered columns.
|
|
449
386
|
* @param rows - The rows to filter.
|
|
@@ -453,136 +390,129 @@ export declare type FilterOperator = 'contains' | 'between' | 'equals';
|
|
|
453
390
|
*/
|
|
454
391
|
export declare function filterRows(schema: TableSchema, rows: readonly TableRow[], filters: readonly TableFilter[], matchers?: Readonly<Record<string, CellMatcher>>): readonly TableRow[];
|
|
455
392
|
|
|
456
|
-
/**
|
|
393
|
+
/** Represents a column of yes-or-no answers, compared false before true. */
|
|
457
394
|
export declare interface FlagColumn extends ColumnBase {
|
|
458
395
|
readonly cell: 'flag';
|
|
459
396
|
}
|
|
460
397
|
|
|
461
398
|
/**
|
|
462
|
-
*
|
|
399
|
+
* Determines whether an unknown value is a declared column cell.
|
|
463
400
|
*
|
|
464
401
|
* @param input - The value to inspect.
|
|
465
|
-
* @returns
|
|
402
|
+
* @returns True if the value is a declared column cell; false otherwise.
|
|
466
403
|
*/
|
|
467
404
|
export declare function isColumnCell(input: unknown): input is ColumnCell;
|
|
468
405
|
|
|
469
406
|
/**
|
|
470
|
-
*
|
|
407
|
+
* Determines whether an unknown value is one exact column choice record.
|
|
471
408
|
*
|
|
472
409
|
* @param input - The value to inspect.
|
|
473
|
-
* @returns
|
|
410
|
+
* @returns True if the value is a column choice; false otherwise.
|
|
474
411
|
*/
|
|
475
412
|
export declare function isColumnChoice(input: unknown): input is ColumnChoice;
|
|
476
413
|
|
|
477
414
|
/**
|
|
478
|
-
*
|
|
415
|
+
* Determines whether an unknown value has one exact structural table-schema shape.
|
|
479
416
|
*
|
|
480
417
|
* @param input - The value to inspect.
|
|
481
|
-
* @returns
|
|
418
|
+
* @returns True if the value has the exact structure of a table schema; false otherwise.
|
|
482
419
|
*/
|
|
483
420
|
export declare function isStructuralTableSchema(input: unknown): input is TableSchema;
|
|
484
421
|
|
|
485
422
|
/**
|
|
486
|
-
*
|
|
423
|
+
* Determines whether an unknown value has a table cell shape.
|
|
487
424
|
*
|
|
488
425
|
* @param input - The value to inspect.
|
|
489
|
-
* @returns
|
|
426
|
+
* @returns True if the value is a string, finite number, or boolean; false otherwise.
|
|
490
427
|
*/
|
|
491
428
|
export declare function isTableCell(input: unknown): input is TableCell;
|
|
492
429
|
|
|
493
430
|
/**
|
|
494
|
-
*
|
|
431
|
+
* Determines whether an unknown value is one exact discriminated table column.
|
|
495
432
|
*
|
|
496
433
|
* @param input - The value to inspect.
|
|
497
|
-
* @returns
|
|
434
|
+
* @returns True if the value is a structurally valid table column; false otherwise.
|
|
498
435
|
*/
|
|
499
436
|
export declare function isTableColumn(input: unknown): input is TableColumn;
|
|
500
437
|
|
|
501
438
|
/**
|
|
502
|
-
*
|
|
439
|
+
* Determines whether an unknown value is a table error.
|
|
503
440
|
*
|
|
504
441
|
* @param input - The value to inspect.
|
|
505
|
-
* @returns
|
|
442
|
+
* @returns True if the value is a {@link TableError} instance; false otherwise.
|
|
506
443
|
*/
|
|
507
444
|
export declare function isTableError(input: unknown): input is TableError;
|
|
508
445
|
|
|
509
446
|
/**
|
|
510
|
-
*
|
|
447
|
+
* Determines whether an unknown value is a record of table cells.
|
|
511
448
|
*
|
|
512
449
|
* @param input - The value to inspect.
|
|
513
|
-
* @returns
|
|
450
|
+
* @returns True if every own key is a string and every value is a table cell; false otherwise.
|
|
514
451
|
*/
|
|
515
452
|
export declare function isTableRow(input: unknown): input is TableRow;
|
|
516
453
|
|
|
517
454
|
/**
|
|
518
|
-
*
|
|
455
|
+
* Determines whether an unknown value is one semantically sound table schema.
|
|
519
456
|
*
|
|
520
457
|
* @param input - The value to inspect.
|
|
521
|
-
* @returns
|
|
458
|
+
* @returns True if the value has valid structure, domain relationships, and
|
|
459
|
+
* budgets; false otherwise.
|
|
522
460
|
*/
|
|
523
461
|
export declare function isTableSchema(input: unknown): input is TableSchema;
|
|
524
462
|
|
|
525
463
|
/**
|
|
526
|
-
*
|
|
464
|
+
* Checks whether a value has the shape required by one column cell.
|
|
527
465
|
*
|
|
528
466
|
* @param column - The column that owns the cell.
|
|
529
467
|
* @param value - The unknown value to inspect.
|
|
530
|
-
* @returns
|
|
468
|
+
* @returns True if the column can hold the value; false otherwise.
|
|
531
469
|
*/
|
|
532
470
|
export declare function matchesCell(column: TableColumn, value: unknown): value is TableCell;
|
|
533
471
|
|
|
534
472
|
/**
|
|
535
|
-
*
|
|
473
|
+
* Tests one cell against a filter according to its column.
|
|
536
474
|
*
|
|
537
475
|
* @param column - The column that fixes the accepted operators.
|
|
538
476
|
* @param cell - The cell to test, or absence.
|
|
539
477
|
* @param filter - The filter to apply.
|
|
540
|
-
* @returns
|
|
478
|
+
* @returns True if the filter accepts the cell; false otherwise.
|
|
541
479
|
*/
|
|
542
480
|
export declare function matchesFilter(column: TableColumn, cell: TableCell | undefined, filter: TableFilter): boolean;
|
|
543
481
|
|
|
544
|
-
/**
|
|
482
|
+
/**
|
|
483
|
+
* Checks whether two lens lists hold the same terms in the same order.
|
|
484
|
+
*
|
|
485
|
+
* @param left - The first list.
|
|
486
|
+
* @param right - The second list.
|
|
487
|
+
* @param equal - Decide whether two terms naming one column carry the same operands.
|
|
488
|
+
* @returns True if the lists are the same length and every position names the same column and
|
|
489
|
+
* carries the same operands; false otherwise.
|
|
490
|
+
*/
|
|
491
|
+
export declare function matchesTerms<Term extends TableTerm>(left: readonly Term[], right: readonly Term[], equal: (left: Term, right: Term) => boolean): boolean;
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Merges lens terms into a column-keyed list, replacing the entry that names the same column.
|
|
495
|
+
*
|
|
496
|
+
* @param current - The list as it stands.
|
|
497
|
+
* @param requested - The terms to write, in the order they are written.
|
|
498
|
+
* @returns A frozen list holding one owned entry per column, in the order the columns first
|
|
499
|
+
* appeared.
|
|
500
|
+
*/
|
|
501
|
+
export declare function mergeTerms<Term extends TableTerm>(current: readonly Term[], requested: readonly Term[]): readonly Term[];
|
|
502
|
+
|
|
503
|
+
/** Names the maximum length, in UTF-16 code units, of a schema name or column key. */
|
|
545
504
|
export declare const NAME_LIMIT = 128;
|
|
546
505
|
|
|
547
|
-
/**
|
|
506
|
+
/** Names the maximum total number of records, arrays, and leaves one schema retains. */
|
|
548
507
|
export declare const NODE_LIMIT = 16384;
|
|
549
508
|
|
|
550
|
-
/**
|
|
509
|
+
/** Represents a column of numbers, compared by magnitude. */
|
|
551
510
|
export declare interface NumberColumn extends ColumnBase {
|
|
552
511
|
readonly cell: 'number';
|
|
553
512
|
}
|
|
554
513
|
|
|
555
|
-
/** The page arithmetic over one table's filtered rows. */
|
|
556
|
-
export declare class PaginationManager implements PaginationManagerInterface {
|
|
557
|
-
#private;
|
|
558
|
-
/**
|
|
559
|
-
* Create a pagination manager over one table's private stores.
|
|
560
|
-
*
|
|
561
|
-
* @param emitter - The table's event emitter.
|
|
562
|
-
* @param gate - The table lifecycle gate.
|
|
563
|
-
* @param rows - A read of the filtered row count.
|
|
564
|
-
* @param readPage - A read of the current page.
|
|
565
|
-
* @param writePage - The page commit boundary.
|
|
566
|
-
* @param readLimit - A read of the current page size.
|
|
567
|
-
* @param writeLimit - The page-size commit boundary.
|
|
568
|
-
*/
|
|
569
|
-
constructor(emitter: Emitter<TableEventMap>, gate: () => void, rows: () => number, readPage: () => number, writePage: (page: number) => void, readLimit: () => number | undefined, writeLimit: (limit: number | undefined) => void);
|
|
570
|
-
/** The page shown, counted from one. */
|
|
571
|
-
get page(): number;
|
|
572
|
-
/** The number of rows one page holds. */
|
|
573
|
-
get limit(): number | undefined;
|
|
574
|
-
/** The number of filtered rows skipped before this page. */
|
|
575
|
-
get offset(): number;
|
|
576
|
-
/** The number of pages filled by the filtered rows. */
|
|
577
|
-
get count(): number;
|
|
578
|
-
/** Show another page, clamped to the pages that exist. */
|
|
579
|
-
move(page: number): void;
|
|
580
|
-
/** Change the page size while keeping the first row previously shown. */
|
|
581
|
-
resize(limit?: number): void;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
514
|
/**
|
|
585
|
-
*
|
|
515
|
+
* Manages which stretch of the filtered rows the view shows.
|
|
586
516
|
*
|
|
587
517
|
* @remarks
|
|
588
518
|
* `page` is the state, counted from one. `offset` and `count` are worked out from it and from the
|
|
@@ -599,22 +529,23 @@ export declare class PaginationManager implements PaginationManagerInterface {
|
|
|
599
529
|
* ```
|
|
600
530
|
*/
|
|
601
531
|
export declare interface PaginationManagerInterface {
|
|
602
|
-
/**
|
|
532
|
+
/** Holds the page the view shows, counted from one, and `1` when the table is not paged. */
|
|
603
533
|
readonly page: number;
|
|
604
|
-
/**
|
|
534
|
+
/** Holds the number of rows one page shows, or `undefined` when the table is not paged. */
|
|
605
535
|
readonly limit: number | undefined;
|
|
606
|
-
/**
|
|
536
|
+
/** Holds the number of rows the view skips before the page it shows, counted from zero. */
|
|
607
537
|
readonly offset: number;
|
|
608
|
-
/**
|
|
538
|
+
/** Counts the pages the rows admitted by the filter fill, and `1` when the table is not paged. */
|
|
609
539
|
readonly count: number;
|
|
610
540
|
/**
|
|
611
|
-
*
|
|
541
|
+
* Shows another page.
|
|
612
542
|
*
|
|
613
|
-
* @param page - The page to show, counted from one and clamped to the pages that exist.
|
|
543
|
+
* @param page - The page to show, counted from one and clamped to the pages that exist. `NaN`
|
|
544
|
+
* shows the first page.
|
|
614
545
|
*/
|
|
615
546
|
move(page: number): void;
|
|
616
547
|
/**
|
|
617
|
-
*
|
|
548
|
+
* Sets how many rows a page holds.
|
|
618
549
|
*
|
|
619
550
|
* @remarks
|
|
620
551
|
* The view keeps showing the first of the rows it was showing, so the page moves to wherever
|
|
@@ -627,7 +558,7 @@ export declare interface PaginationManagerInterface {
|
|
|
627
558
|
}
|
|
628
559
|
|
|
629
560
|
/**
|
|
630
|
-
*
|
|
561
|
+
* Parses unknown wire rows against one table schema.
|
|
631
562
|
*
|
|
632
563
|
* @param schema - The schema that declares the accepted keys and cell shapes.
|
|
633
564
|
* @param input - The unknown row-list value to parse.
|
|
@@ -636,52 +567,24 @@ export declare interface PaginationManagerInterface {
|
|
|
636
567
|
export declare function parseRows(schema: TableSchema, input: unknown): readonly TableRow[] | undefined;
|
|
637
568
|
|
|
638
569
|
/**
|
|
639
|
-
*
|
|
570
|
+
* Parses unknown wire data into an owned, semantically sound table schema.
|
|
640
571
|
*
|
|
641
572
|
* @param input - The unknown schema value to parse.
|
|
642
573
|
* @returns An owned table schema, or `undefined` on refusal.
|
|
643
574
|
*/
|
|
644
575
|
export declare function parseTable(input: unknown): TableSchema | undefined;
|
|
645
576
|
|
|
646
|
-
/**
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
* @param gate - The table lifecycle gate.
|
|
655
|
-
* @param read - A read of the current rows.
|
|
656
|
-
* @param write - The row commit boundary.
|
|
657
|
-
* @param settle - Commit dependent state, then order row and dependent announcements.
|
|
658
|
-
* @param rows - Rows to seed without announcements.
|
|
659
|
-
*/
|
|
660
|
-
constructor(schema: TableSchema, emitter: Emitter<TableEventMap>, gate: () => void, read: () => readonly TableRow[], write: (rows: readonly TableRow[]) => void, settle: (removed: readonly TableKey[], announce: () => void) => void, rows?: readonly TableRow[]);
|
|
661
|
-
/** Find one row by key as an owned frozen snapshot. */
|
|
662
|
-
row(key: TableKey): TableRow | undefined;
|
|
663
|
-
/** Read every row as owned frozen snapshots in table order. */
|
|
664
|
-
rows(): readonly TableRow[];
|
|
665
|
-
/** Append several rows. */
|
|
666
|
-
add(rows: readonly TableRow[]): void;
|
|
667
|
-
/** Append one row. */
|
|
668
|
-
add(row: TableRow): void;
|
|
669
|
-
/** Merge several rows into the rows their keys name. */
|
|
670
|
-
update(rows: readonly TableRow[]): boolean;
|
|
671
|
-
/** Merge one row into the row its key names. */
|
|
672
|
-
update(row: TableRow): boolean;
|
|
673
|
-
/** Move one row to a clamped index in table order. */
|
|
674
|
-
move(key: TableKey, index: number): boolean;
|
|
675
|
-
/** Remove every row. */
|
|
676
|
-
remove(): void;
|
|
677
|
-
/** Remove one row. */
|
|
678
|
-
remove(key: TableKey): boolean;
|
|
679
|
-
/** Remove several rows. */
|
|
680
|
-
remove(keys: readonly TableKey[]): boolean;
|
|
681
|
-
}
|
|
577
|
+
/**
|
|
578
|
+
* Removes every lens term naming one of the given columns.
|
|
579
|
+
*
|
|
580
|
+
* @param current - The list as it stands.
|
|
581
|
+
* @param columns - The column keys to drop.
|
|
582
|
+
* @returns A frozen list holding the entries no named column matched, in their original order.
|
|
583
|
+
*/
|
|
584
|
+
export declare function removeTerms<Term extends TableTerm>(current: readonly Term[], columns: readonly string[]): readonly Term[];
|
|
682
585
|
|
|
683
586
|
/**
|
|
684
|
-
*
|
|
587
|
+
* Manages the rows a table holds, in the order it holds them.
|
|
685
588
|
*
|
|
686
589
|
* @remarks
|
|
687
590
|
* This order is the table's own, and it is what the view shows when no sort term separates two
|
|
@@ -695,20 +598,20 @@ export declare class RowManager implements RowManagerInterface {
|
|
|
695
598
|
*/
|
|
696
599
|
export declare interface RowManagerInterface {
|
|
697
600
|
/**
|
|
698
|
-
*
|
|
601
|
+
* Finds one row by key.
|
|
699
602
|
*
|
|
700
603
|
* @param key - The row's key.
|
|
701
604
|
* @returns The row, or `undefined` when the table holds no such key.
|
|
702
605
|
*/
|
|
703
606
|
row(key: TableKey): TableRow | undefined;
|
|
704
607
|
/**
|
|
705
|
-
*
|
|
608
|
+
* Reads every row the table holds, in its own order.
|
|
706
609
|
*
|
|
707
610
|
* @returns The rows, unfiltered, unsorted, and unpaged.
|
|
708
611
|
*/
|
|
709
612
|
rows(): readonly TableRow[];
|
|
710
613
|
/**
|
|
711
|
-
*
|
|
614
|
+
* Takes in several rows, appending them in the order given.
|
|
712
615
|
*
|
|
713
616
|
* @param rows - The rows to admit.
|
|
714
617
|
* @throws A {@link TableError} coded `KEY` when a row's key is missing, unusable, already
|
|
@@ -717,7 +620,7 @@ export declare interface RowManagerInterface {
|
|
|
717
620
|
*/
|
|
718
621
|
add(rows: readonly TableRow[]): void;
|
|
719
622
|
/**
|
|
720
|
-
*
|
|
623
|
+
* Takes in one row, appending it.
|
|
721
624
|
*
|
|
722
625
|
* @param row - The row to admit.
|
|
723
626
|
* @throws A {@link TableError} coded `KEY` when the row's key is missing, unusable, or already
|
|
@@ -725,93 +628,61 @@ export declare interface RowManagerInterface {
|
|
|
725
628
|
*/
|
|
726
629
|
add(row: TableRow): void;
|
|
727
630
|
/**
|
|
728
|
-
*
|
|
631
|
+
* Writes over several rows, each found by the key it carries.
|
|
729
632
|
*
|
|
730
633
|
* @param rows - The rows to write, each carrying the key of the row it writes over.
|
|
731
|
-
* @returns
|
|
634
|
+
* @returns True if every key named a row the table holds; false otherwise.
|
|
732
635
|
* @throws A {@link TableError} coded `CELL` when a cell is one its column cannot hold. Every
|
|
733
636
|
* row is checked before any is written, so one refusal writes none of them.
|
|
734
637
|
*/
|
|
735
638
|
update(rows: readonly TableRow[]): boolean;
|
|
736
639
|
/**
|
|
737
|
-
*
|
|
640
|
+
* Writes over one row, found by the key it carries.
|
|
738
641
|
*
|
|
739
642
|
* @remarks
|
|
740
643
|
* The cells given replace the cells held; the cells left out stay as they are. A row's key
|
|
741
644
|
* therefore cannot move, because a different key names a different row.
|
|
742
645
|
*
|
|
743
646
|
* @param row - The cells to write, carrying the key of the row they belong to.
|
|
744
|
-
* @returns
|
|
647
|
+
* @returns True if the key named a row the table holds; false otherwise.
|
|
745
648
|
* @throws A {@link TableError} coded `CELL` when a cell is one its column cannot hold.
|
|
746
649
|
*/
|
|
747
650
|
update(row: TableRow): boolean;
|
|
748
651
|
/**
|
|
749
|
-
*
|
|
652
|
+
* Moves one row to another place in the table's own order.
|
|
750
653
|
*
|
|
751
654
|
* @param key - The row's key.
|
|
752
|
-
* @param index - Where to put it, counted from zero and clamped to the rows that exist.
|
|
753
|
-
*
|
|
655
|
+
* @param index - Where to put it, counted from zero and clamped to the rows that exist. `NaN`
|
|
656
|
+
* puts the row first.
|
|
657
|
+
* @returns True if the key named a row the table holds; false otherwise.
|
|
754
658
|
*/
|
|
755
659
|
move(key: TableKey, index: number): boolean;
|
|
756
660
|
/**
|
|
757
|
-
*
|
|
661
|
+
* Takes out every row.
|
|
758
662
|
*
|
|
759
663
|
* @remarks
|
|
760
664
|
* Selection and expansion drop the keys they held, because those rows are gone.
|
|
761
665
|
*/
|
|
762
666
|
remove(): void;
|
|
763
667
|
/**
|
|
764
|
-
*
|
|
668
|
+
* Takes out one row.
|
|
765
669
|
*
|
|
766
670
|
* @param key - The row's key.
|
|
767
|
-
* @returns
|
|
671
|
+
* @returns True if the key named a row the table holds; false otherwise.
|
|
768
672
|
*/
|
|
769
673
|
remove(key: TableKey): boolean;
|
|
770
674
|
/**
|
|
771
|
-
*
|
|
675
|
+
* Takes out several rows.
|
|
772
676
|
*
|
|
773
677
|
* @param keys - The rows' keys.
|
|
774
|
-
* @returns
|
|
775
|
-
* row goes, so one unknown key leaves the whole call undone.
|
|
678
|
+
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
679
|
+
* checked before any row goes, so one unknown key leaves the whole call undone.
|
|
776
680
|
*/
|
|
777
681
|
remove(keys: readonly TableKey[]): boolean;
|
|
778
682
|
}
|
|
779
683
|
|
|
780
|
-
/** The keys of the rows somebody has picked. */
|
|
781
|
-
export declare class SelectionManager implements SelectionManagerInterface {
|
|
782
|
-
#private;
|
|
783
|
-
/**
|
|
784
|
-
* Create a selection manager over one table's private stores.
|
|
785
|
-
*
|
|
786
|
-
* @param emitter - The table's event emitter.
|
|
787
|
-
* @param gate - The table lifecycle gate.
|
|
788
|
-
* @param rows - A read of every row key.
|
|
789
|
-
* @param read - A read of the selected keys.
|
|
790
|
-
* @param write - The selected-key commit boundary.
|
|
791
|
-
*/
|
|
792
|
-
constructor(emitter: Emitter<TableEventMap>, gate: () => void, rows: () => readonly TableKey[], read: () => ReadonlySet<TableKey>, write: (keys: ReadonlySet<TableKey>) => void);
|
|
793
|
-
/** The keys of the rows picked right now. */
|
|
794
|
-
get keys(): ReadonlySet<TableKey>;
|
|
795
|
-
/** Pick every row the table holds. */
|
|
796
|
-
select(): void;
|
|
797
|
-
/** Pick one row. */
|
|
798
|
-
select(key: TableKey): boolean;
|
|
799
|
-
/** Pick several rows. */
|
|
800
|
-
select(keys: readonly TableKey[]): boolean;
|
|
801
|
-
/** Drop every pick. */
|
|
802
|
-
clear(): void;
|
|
803
|
-
/** Drop one pick. */
|
|
804
|
-
clear(key: TableKey): boolean;
|
|
805
|
-
/** Drop several picks. */
|
|
806
|
-
clear(keys: readonly TableKey[]): boolean;
|
|
807
|
-
/** Pick one row or drop it when already picked. */
|
|
808
|
-
toggle(key: TableKey): boolean;
|
|
809
|
-
/** Turn several rows around independently. */
|
|
810
|
-
toggle(keys: readonly TableKey[]): boolean;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
684
|
/**
|
|
814
|
-
*
|
|
685
|
+
* Manages the rows somebody has picked.
|
|
815
686
|
*
|
|
816
687
|
* @remarks
|
|
817
688
|
* Selection holds keys, never rows or positions, so a pick survives a sort, a filter, and a page
|
|
@@ -824,10 +695,10 @@ export declare class SelectionManager implements SelectionManagerInterface {
|
|
|
824
695
|
* ```
|
|
825
696
|
*/
|
|
826
697
|
export declare interface SelectionManagerInterface {
|
|
827
|
-
/**
|
|
698
|
+
/** Holds the keys of the rows picked right now. */
|
|
828
699
|
readonly keys: ReadonlySet<TableKey>;
|
|
829
700
|
/**
|
|
830
|
-
*
|
|
701
|
+
* Picks every row the table holds.
|
|
831
702
|
*
|
|
832
703
|
* @remarks
|
|
833
704
|
* Every row, not every visible one. A host picking one page hands that page's keys over
|
|
@@ -835,56 +706,57 @@ export declare interface SelectionManagerInterface {
|
|
|
835
706
|
*/
|
|
836
707
|
select(): void;
|
|
837
708
|
/**
|
|
838
|
-
*
|
|
709
|
+
* Picks one row.
|
|
839
710
|
*
|
|
840
711
|
* @param key - The row's key.
|
|
841
|
-
* @returns
|
|
712
|
+
* @returns True if the key named a row the table holds; false otherwise.
|
|
842
713
|
*/
|
|
843
714
|
select(key: TableKey): boolean;
|
|
844
715
|
/**
|
|
845
|
-
*
|
|
716
|
+
* Picks several rows.
|
|
846
717
|
*
|
|
847
718
|
* @param keys - The rows' keys.
|
|
848
|
-
* @returns
|
|
849
|
-
* row is picked.
|
|
719
|
+
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
720
|
+
* checked before any row is picked.
|
|
850
721
|
*/
|
|
851
722
|
select(keys: readonly TableKey[]): boolean;
|
|
852
|
-
/**
|
|
723
|
+
/** Drops every pick. */
|
|
853
724
|
clear(): void;
|
|
854
725
|
/**
|
|
855
|
-
*
|
|
726
|
+
* Drops one pick.
|
|
856
727
|
*
|
|
857
728
|
* @param key - The row's key.
|
|
858
|
-
* @returns
|
|
729
|
+
* @returns True if the key named a row the table holds, whether or not it was
|
|
730
|
+
* picked; false otherwise.
|
|
859
731
|
*/
|
|
860
732
|
clear(key: TableKey): boolean;
|
|
861
733
|
/**
|
|
862
|
-
*
|
|
734
|
+
* Drops several picks.
|
|
863
735
|
*
|
|
864
736
|
* @param keys - The rows' keys.
|
|
865
|
-
* @returns
|
|
866
|
-
* pick is dropped.
|
|
737
|
+
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
738
|
+
* checked before any pick is dropped.
|
|
867
739
|
*/
|
|
868
740
|
clear(keys: readonly TableKey[]): boolean;
|
|
869
741
|
/**
|
|
870
|
-
*
|
|
742
|
+
* Picks one row, or drops it when it is already picked.
|
|
871
743
|
*
|
|
872
744
|
* @param key - The row's key.
|
|
873
|
-
* @returns
|
|
745
|
+
* @returns True if the key named a row the table holds; false otherwise.
|
|
874
746
|
*/
|
|
875
747
|
toggle(key: TableKey): boolean;
|
|
876
748
|
/**
|
|
877
|
-
*
|
|
749
|
+
* Turns several rows around, each on its own.
|
|
878
750
|
*
|
|
879
751
|
* @param keys - The rows' keys.
|
|
880
|
-
* @returns
|
|
881
|
-
* row turns.
|
|
752
|
+
* @returns True if every key named a row the table holds; false otherwise. Every key is
|
|
753
|
+
* checked before any row turns.
|
|
882
754
|
*/
|
|
883
755
|
toggle(keys: readonly TableKey[]): boolean;
|
|
884
756
|
}
|
|
885
757
|
|
|
886
758
|
/**
|
|
887
|
-
*
|
|
759
|
+
* Projects rows into schema-column-ordered JSON.
|
|
888
760
|
*
|
|
889
761
|
* @param schema - The schema that fixes cell order.
|
|
890
762
|
* @param rows - The rows to project.
|
|
@@ -893,7 +765,7 @@ export declare interface SelectionManagerInterface {
|
|
|
893
765
|
export declare function serializeRows(schema: TableSchema, rows: readonly TableRow[]): readonly JSONRecord[];
|
|
894
766
|
|
|
895
767
|
/**
|
|
896
|
-
*
|
|
768
|
+
* Projects a schema into declaration-ordered JSON.
|
|
897
769
|
*
|
|
898
770
|
* @param schema - The schema to project.
|
|
899
771
|
* @returns A deeply owned JSON record with absent members omitted.
|
|
@@ -901,37 +773,8 @@ export declare function serializeRows(schema: TableSchema, rows: readonly TableR
|
|
|
901
773
|
*/
|
|
902
774
|
export declare function serializeTable(schema: TableSchema): JSONRecord;
|
|
903
775
|
|
|
904
|
-
/** The ordered sort terms of one table. */
|
|
905
|
-
export declare class SortManager implements SortManagerInterface {
|
|
906
|
-
#private;
|
|
907
|
-
/**
|
|
908
|
-
* Create a sort manager over one table's private term store.
|
|
909
|
-
*
|
|
910
|
-
* @param schema - The table schema.
|
|
911
|
-
* @param emitter - The table's event emitter.
|
|
912
|
-
* @param gate - The table lifecycle gate.
|
|
913
|
-
* @param read - A read of the current terms.
|
|
914
|
-
* @param write - The term commit boundary.
|
|
915
|
-
*/
|
|
916
|
-
constructor(schema: TableSchema, emitter: Emitter<TableEventMap>, gate: () => void, read: () => readonly TableOrder[], write: (orders: readonly TableOrder[]) => void);
|
|
917
|
-
/** Find one column's sort term. */
|
|
918
|
-
order(column: string): TableOrder | undefined;
|
|
919
|
-
/** Read every sort term as an owned frozen snapshot. */
|
|
920
|
-
orders(): readonly TableOrder[];
|
|
921
|
-
/** Sort by several columns. */
|
|
922
|
-
set(orders: readonly TableOrder[]): void;
|
|
923
|
-
/** Sort by one column. */
|
|
924
|
-
set(order: TableOrder): void;
|
|
925
|
-
/** Stop sorting by every column. */
|
|
926
|
-
remove(): void;
|
|
927
|
-
/** Stop sorting by one column. */
|
|
928
|
-
remove(column: string): boolean;
|
|
929
|
-
/** Stop sorting by several columns. */
|
|
930
|
-
remove(columns: readonly string[]): boolean;
|
|
931
|
-
}
|
|
932
|
-
|
|
933
776
|
/**
|
|
934
|
-
*
|
|
777
|
+
* Manages the order a table reads its rows in.
|
|
935
778
|
*
|
|
936
779
|
* @remarks
|
|
937
780
|
* The table holds one term per column and applies them in the order they were set. Which
|
|
@@ -946,20 +789,20 @@ export declare class SortManager implements SortManagerInterface {
|
|
|
946
789
|
*/
|
|
947
790
|
export declare interface SortManagerInterface {
|
|
948
791
|
/**
|
|
949
|
-
*
|
|
792
|
+
* Finds one column's term.
|
|
950
793
|
*
|
|
951
794
|
* @param column - The column's key.
|
|
952
795
|
* @returns The term, or `undefined` when nothing sorts that column.
|
|
953
796
|
*/
|
|
954
797
|
order(column: string): TableOrder | undefined;
|
|
955
798
|
/**
|
|
956
|
-
*
|
|
799
|
+
* Reads every term the table sorts by.
|
|
957
800
|
*
|
|
958
801
|
* @returns The terms, first to last, in the order they decide.
|
|
959
802
|
*/
|
|
960
803
|
orders(): readonly TableOrder[];
|
|
961
804
|
/**
|
|
962
|
-
*
|
|
805
|
+
* Sorts by several columns.
|
|
963
806
|
*
|
|
964
807
|
* @param orders - The terms to set. A term for a column already sorted replaces that column's
|
|
965
808
|
* direction in place; every other term joins the end of the list.
|
|
@@ -968,34 +811,34 @@ export declare interface SortManagerInterface {
|
|
|
968
811
|
*/
|
|
969
812
|
set(orders: readonly TableOrder[]): void;
|
|
970
813
|
/**
|
|
971
|
-
*
|
|
814
|
+
* Sorts by one column.
|
|
972
815
|
*
|
|
973
816
|
* @param order - The term to set.
|
|
974
817
|
* @throws A {@link TableError} coded `COLUMN` when the term names a column the schema does not
|
|
975
818
|
* declare.
|
|
976
819
|
*/
|
|
977
820
|
set(order: TableOrder): void;
|
|
978
|
-
/**
|
|
821
|
+
/** Stops sorting by anything. */
|
|
979
822
|
remove(): void;
|
|
980
823
|
/**
|
|
981
|
-
*
|
|
824
|
+
* Stops sorting by one column.
|
|
982
825
|
*
|
|
983
826
|
* @param column - The column's key.
|
|
984
|
-
* @returns
|
|
827
|
+
* @returns True if the schema declares that column; false otherwise.
|
|
985
828
|
*/
|
|
986
829
|
remove(column: string): boolean;
|
|
987
830
|
/**
|
|
988
|
-
*
|
|
831
|
+
* Stops sorting by several columns.
|
|
989
832
|
*
|
|
990
833
|
* @param columns - The columns' keys.
|
|
991
|
-
* @returns
|
|
992
|
-
* term goes.
|
|
834
|
+
* @returns True if the schema declares every one of them; false otherwise. Every key is
|
|
835
|
+
* checked before any term goes.
|
|
993
836
|
*/
|
|
994
837
|
remove(columns: readonly string[]): boolean;
|
|
995
838
|
}
|
|
996
839
|
|
|
997
840
|
/**
|
|
998
|
-
*
|
|
841
|
+
* Orders rows stably by a sequence of terms.
|
|
999
842
|
*
|
|
1000
843
|
* @param schema - The schema that declares the sorted columns.
|
|
1001
844
|
* @param rows - The rows to order.
|
|
@@ -1005,14 +848,14 @@ export declare interface SortManagerInterface {
|
|
|
1005
848
|
*/
|
|
1006
849
|
export declare function sortRows(schema: TableSchema, rows: readonly TableRow[], orders: readonly TableOrder[], comparators?: Readonly<Record<string, CellComparator>>): readonly TableRow[];
|
|
1007
850
|
|
|
1008
|
-
/**
|
|
851
|
+
/** Names the maximum length, in UTF-16 code units, of any single retained string. */
|
|
1009
852
|
export declare const STRING_LIMIT = 65536;
|
|
1010
853
|
|
|
1011
|
-
/**
|
|
854
|
+
/** Holds a schema, its rows, and the lens through which they are read. */
|
|
1012
855
|
export declare class Table implements TableInterface {
|
|
1013
856
|
#private;
|
|
1014
857
|
/**
|
|
1015
|
-
*
|
|
858
|
+
* Opens a table against a schema.
|
|
1016
859
|
*
|
|
1017
860
|
* @param schema - The table declaration to own.
|
|
1018
861
|
* @param options - Initial rows, lens overrides, pagination, and emitter wiring.
|
|
@@ -1020,36 +863,36 @@ export declare class Table implements TableInterface {
|
|
|
1020
863
|
* identity is unusable or repeated, and `CELL` when a seeded cell is invalid.
|
|
1021
864
|
*/
|
|
1022
865
|
constructor(schema: TableSchema, options?: TableOptions);
|
|
1023
|
-
/**
|
|
866
|
+
/** Holds the table's event emitter. */
|
|
1024
867
|
get emitter(): EmitterInterface<TableEventMap>;
|
|
1025
|
-
/**
|
|
868
|
+
/** Holds the owned frozen schema. */
|
|
1026
869
|
get schema(): TableSchema;
|
|
1027
|
-
/**
|
|
870
|
+
/** Manages the rows the table holds. */
|
|
1028
871
|
get rows(): RowManagerInterface;
|
|
1029
|
-
/**
|
|
872
|
+
/** Manages the ordered sort terms. */
|
|
1030
873
|
get sort(): SortManagerInterface;
|
|
1031
|
-
/**
|
|
874
|
+
/** Manages the filters applied with and-only composition. */
|
|
1032
875
|
get filter(): FilterManagerInterface;
|
|
1033
|
-
/**
|
|
876
|
+
/** Manages the selected row keys. */
|
|
1034
877
|
get selection(): SelectionManagerInterface;
|
|
1035
|
-
/**
|
|
878
|
+
/** Manages the expanded row keys. */
|
|
1036
879
|
get expansion(): ExpansionManagerInterface;
|
|
1037
|
-
/**
|
|
880
|
+
/** Manages the page arithmetic. */
|
|
1038
881
|
get pagination(): PaginationManagerInterface;
|
|
1039
|
-
/**
|
|
882
|
+
/** Returns the filtered, sorted, and paged rows as owned frozen snapshots. */
|
|
1040
883
|
get view(): readonly TableRow[];
|
|
1041
|
-
/**
|
|
884
|
+
/** Returns the number of rows admitted by the filters. */
|
|
1042
885
|
get count(): number;
|
|
1043
|
-
/**
|
|
886
|
+
/** Reports whether the table has been torn down. */
|
|
1044
887
|
get destroyed(): boolean;
|
|
1045
|
-
/**
|
|
888
|
+
/** Resets every moving axis to its opening state. */
|
|
1046
889
|
clear(): void;
|
|
1047
|
-
/**
|
|
890
|
+
/** Tears the table down while leaving every getter readable. */
|
|
1048
891
|
destroy(): void;
|
|
1049
892
|
}
|
|
1050
893
|
|
|
1051
894
|
/**
|
|
1052
|
-
*
|
|
895
|
+
* Represents every value a cell can hold.
|
|
1053
896
|
*
|
|
1054
897
|
* @remarks
|
|
1055
898
|
* The variant follows the column: `text` and `choice` hold a `string`, `number` holds a `number`,
|
|
@@ -1059,7 +902,7 @@ export declare class Table implements TableInterface {
|
|
|
1059
902
|
export declare type TableCell = string | number | boolean;
|
|
1060
903
|
|
|
1061
904
|
/**
|
|
1062
|
-
*
|
|
905
|
+
* Represents any column a schema can declare.
|
|
1063
906
|
*
|
|
1064
907
|
* @remarks
|
|
1065
908
|
* The union discriminates on `cell`, so narrowing on that member reaches each variant's own
|
|
@@ -1075,7 +918,7 @@ export declare type TableCell = string | number | boolean;
|
|
|
1075
918
|
export declare type TableColumn = TextColumn | NumberColumn | FlagColumn | ChoiceColumn;
|
|
1076
919
|
|
|
1077
920
|
/**
|
|
1078
|
-
*
|
|
921
|
+
* Names which way a column sorts.
|
|
1079
922
|
*
|
|
1080
923
|
* @remarks
|
|
1081
924
|
* A column nobody has sorted has no {@link TableOrder} at all, so there is no third member
|
|
@@ -1083,14 +926,14 @@ export declare type TableColumn = TextColumn | NumberColumn | FlagColumn | Choic
|
|
|
1083
926
|
*/
|
|
1084
927
|
export declare type TableDirection = 'ascending' | 'descending';
|
|
1085
928
|
|
|
1086
|
-
/**
|
|
929
|
+
/** Represents an error raised by the table domain. */
|
|
1087
930
|
export declare class TableError extends Error {
|
|
1088
|
-
/**
|
|
931
|
+
/** Holds the machine-readable reason for this failure. */
|
|
1089
932
|
readonly code: TableErrorCode;
|
|
1090
|
-
/**
|
|
933
|
+
/** Holds structured values that locate or explain this failure. */
|
|
1091
934
|
readonly context?: JSONRecord;
|
|
1092
935
|
/**
|
|
1093
|
-
*
|
|
936
|
+
* Creates a table error.
|
|
1094
937
|
*
|
|
1095
938
|
* @param code - The machine-readable reason.
|
|
1096
939
|
* @param message - The human-readable failure text.
|
|
@@ -1100,7 +943,7 @@ export declare class TableError extends Error {
|
|
|
1100
943
|
}
|
|
1101
944
|
|
|
1102
945
|
/**
|
|
1103
|
-
*
|
|
946
|
+
* Names the machine-readable code a table error carries.
|
|
1104
947
|
*
|
|
1105
948
|
* @remarks
|
|
1106
949
|
* `SCHEMA` rejects a malformed schema, including a `key` naming no declared column. `COLUMN`
|
|
@@ -1111,7 +954,7 @@ export declare class TableError extends Error {
|
|
|
1111
954
|
export declare type TableErrorCode = 'SCHEMA' | 'COLUMN' | 'KEY' | 'CELL' | 'DESTROYED';
|
|
1112
955
|
|
|
1113
956
|
/**
|
|
1114
|
-
*
|
|
957
|
+
* Lists everything a table announces.
|
|
1115
958
|
*
|
|
1116
959
|
* @remarks
|
|
1117
960
|
* Every event fires after the state it reports is committed, and only when something actually
|
|
@@ -1141,7 +984,7 @@ export declare type TableEventMap = {
|
|
|
1141
984
|
};
|
|
1142
985
|
|
|
1143
986
|
/**
|
|
1144
|
-
*
|
|
987
|
+
* Represents any filter a table can hold.
|
|
1145
988
|
*
|
|
1146
989
|
* @remarks
|
|
1147
990
|
* The union discriminates on `operator`, so each operator carries only the operands it uses and a
|
|
@@ -1158,15 +1001,15 @@ export declare type TableEventMap = {
|
|
|
1158
1001
|
export declare type TableFilter = ContainsFilter | BetweenFilter | EqualsFilter;
|
|
1159
1002
|
|
|
1160
1003
|
/**
|
|
1161
|
-
*
|
|
1004
|
+
* Represents a table: what it declares, the rows it holds, and the lens it reads them through.
|
|
1162
1005
|
*
|
|
1163
1006
|
* @remarks
|
|
1164
1007
|
* The table owns values, not pixels. It renders nothing, reads no document, and names no host
|
|
1165
1008
|
* type, so one table serves a browser, a terminal, a report, and an export equally.
|
|
1166
1009
|
*
|
|
1167
|
-
*
|
|
1168
|
-
* `
|
|
1169
|
-
*
|
|
1010
|
+
* One manager holds each axis that moves: `rows`, `sort`, `filter`, `selection`, `expansion`, and
|
|
1011
|
+
* `pagination`. Nothing else is stored. `view` and `count` are worked out when they are read, so no
|
|
1012
|
+
* second copy of the answer can go stale.
|
|
1170
1013
|
*
|
|
1171
1014
|
* A write validates all of itself before any of it lands, and announces itself once it has.
|
|
1172
1015
|
*
|
|
@@ -1178,35 +1021,35 @@ export declare type TableFilter = ContainsFilter | BetweenFilter | EqualsFilter;
|
|
|
1178
1021
|
* ```
|
|
1179
1022
|
*/
|
|
1180
1023
|
export declare interface TableInterface {
|
|
1181
|
-
/**
|
|
1024
|
+
/** Holds the table's event emitter. */
|
|
1182
1025
|
readonly emitter: EmitterInterface<TableEventMap>;
|
|
1183
|
-
/**
|
|
1026
|
+
/** Holds what this table declares. */
|
|
1184
1027
|
readonly schema: TableSchema;
|
|
1185
|
-
/**
|
|
1028
|
+
/** Manages the rows the table holds. */
|
|
1186
1029
|
readonly rows: RowManagerInterface;
|
|
1187
|
-
/**
|
|
1030
|
+
/** Manages the order the table reads them in. */
|
|
1188
1031
|
readonly sort: SortManagerInterface;
|
|
1189
|
-
/**
|
|
1032
|
+
/** Manages which of them the table keeps. */
|
|
1190
1033
|
readonly filter: FilterManagerInterface;
|
|
1191
|
-
/**
|
|
1034
|
+
/** Manages the ones somebody has picked. */
|
|
1192
1035
|
readonly selection: SelectionManagerInterface;
|
|
1193
|
-
/**
|
|
1036
|
+
/** Manages the ones somebody has opened up. */
|
|
1194
1037
|
readonly expansion: ExpansionManagerInterface;
|
|
1195
|
-
/**
|
|
1038
|
+
/** Manages which stretch of them the view shows. */
|
|
1196
1039
|
readonly pagination: PaginationManagerInterface;
|
|
1197
1040
|
/**
|
|
1198
|
-
*
|
|
1041
|
+
* Returns the rows to draw right now: filtered, then sorted, then paged.
|
|
1199
1042
|
*
|
|
1200
1043
|
* @remarks
|
|
1201
1044
|
* It is worked out on every read and never stored, so it is right the instant anything moves.
|
|
1202
1045
|
*/
|
|
1203
1046
|
readonly view: readonly TableRow[];
|
|
1204
|
-
/**
|
|
1047
|
+
/** Counts the rows the filter admits, before the page narrows them. */
|
|
1205
1048
|
readonly count: number;
|
|
1206
|
-
/**
|
|
1049
|
+
/** Reports whether the table has been torn down. */
|
|
1207
1050
|
readonly destroyed: boolean;
|
|
1208
1051
|
/**
|
|
1209
|
-
*
|
|
1052
|
+
* Puts the table back the way it opened, holding nothing.
|
|
1210
1053
|
*
|
|
1211
1054
|
* @remarks
|
|
1212
1055
|
* Every row goes, and sort, filter, selection, expansion, and the page all reset. The table
|
|
@@ -1214,7 +1057,7 @@ export declare interface TableInterface {
|
|
|
1214
1057
|
*/
|
|
1215
1058
|
clear(): void;
|
|
1216
1059
|
/**
|
|
1217
|
-
*
|
|
1060
|
+
* Tears the table down.
|
|
1218
1061
|
*
|
|
1219
1062
|
* @remarks
|
|
1220
1063
|
* Calling it twice does what calling it once did. Afterwards every write throws a
|
|
@@ -1225,7 +1068,7 @@ export declare interface TableInterface {
|
|
|
1225
1068
|
}
|
|
1226
1069
|
|
|
1227
1070
|
/**
|
|
1228
|
-
*
|
|
1071
|
+
* Represents a row's identity.
|
|
1229
1072
|
*
|
|
1230
1073
|
* @remarks
|
|
1231
1074
|
* Every row carries its own identity in the cell named by {@link TableSchema.key}, as a non-empty
|
|
@@ -1240,9 +1083,8 @@ export declare interface TableInterface {
|
|
|
1240
1083
|
export declare type TableKey = string;
|
|
1241
1084
|
|
|
1242
1085
|
/**
|
|
1243
|
-
*
|
|
1086
|
+
* Describes how to open a table.
|
|
1244
1087
|
*
|
|
1245
|
-
* @param options - The table's settings.
|
|
1246
1088
|
* @remarks
|
|
1247
1089
|
* `on` wires listeners at construction and `error` receives any throw from one of them.
|
|
1248
1090
|
*
|
|
@@ -1275,7 +1117,7 @@ export declare interface TableOptions {
|
|
|
1275
1117
|
}
|
|
1276
1118
|
|
|
1277
1119
|
/**
|
|
1278
|
-
*
|
|
1120
|
+
* Represents one column's place in the sort.
|
|
1279
1121
|
*
|
|
1280
1122
|
* @remarks
|
|
1281
1123
|
* The order list is read left to right: the first term decides, and each later term breaks the
|
|
@@ -1292,7 +1134,7 @@ export declare interface TableOrder {
|
|
|
1292
1134
|
}
|
|
1293
1135
|
|
|
1294
1136
|
/**
|
|
1295
|
-
*
|
|
1137
|
+
* Represents one row, keyed by column.
|
|
1296
1138
|
*
|
|
1297
1139
|
* @remarks
|
|
1298
1140
|
* A row declares a cell for the columns it carries and omits the rest. It carries no key the
|
|
@@ -1307,7 +1149,7 @@ export declare interface TableOrder {
|
|
|
1307
1149
|
export declare type TableRow = Readonly<Record<string, TableCell>>;
|
|
1308
1150
|
|
|
1309
1151
|
/**
|
|
1310
|
-
*
|
|
1152
|
+
* Holds everything a table declares about itself.
|
|
1311
1153
|
*
|
|
1312
1154
|
* @remarks
|
|
1313
1155
|
* The schema is data. It carries no function, so all of it crosses a wire and nothing is dropped
|
|
@@ -1342,10 +1184,23 @@ export declare interface TableSchema {
|
|
|
1342
1184
|
readonly columns: readonly TableColumn[];
|
|
1343
1185
|
}
|
|
1344
1186
|
|
|
1345
|
-
/**
|
|
1187
|
+
/**
|
|
1188
|
+
* Represents one entry of a lens list, held against one declared column.
|
|
1189
|
+
*
|
|
1190
|
+
* @remarks
|
|
1191
|
+
* A table holds at most one sort term and at most one filter per column, so `column` is what
|
|
1192
|
+
* places an entry in either list. {@link mergeTerms}, {@link removeTerms}, and
|
|
1193
|
+
* {@link matchesTerms} work over this shape alone, which is how sorting and filtering share one
|
|
1194
|
+
* list engine while keeping their own operands.
|
|
1195
|
+
*/
|
|
1196
|
+
export declare interface TableTerm {
|
|
1197
|
+
readonly column: string;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/** Names the maximum total length, in UTF-16 code units, of every string one schema retains. */
|
|
1346
1201
|
export declare const TEXT_LIMIT = 1048576;
|
|
1347
1202
|
|
|
1348
|
-
/**
|
|
1203
|
+
/** Represents a column of text, compared lexically. */
|
|
1349
1204
|
export declare interface TextColumn extends ColumnBase {
|
|
1350
1205
|
readonly cell: 'text';
|
|
1351
1206
|
}
|