@orkestrel/table 0.0.2 → 0.0.3

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 @@
1
+ {"version":3,"file":"index.cjs","names":["#emitter","#gate","#rows","#read","#write","#change","#schema","#emitter","#gate","#read","#write","#clamp","#validate","#same","#emitter","#gate","#rows","#readPage","#writePage","#readLimit","#writeLimit","#normalize","#schema","#emitter","#gate","#read","#write","#settle","#prepare","#validate","#failKey","#same","#emitter","#gate","#rows","#read","#write","#change","#schema","#emitter","#gate","#read","#write","#require","#same","#emitter","#schema","#comparators","#matchers","#initialLimit","#rows","#sort","#filter","#selection","#expansion","#pagination","#limit","#gate","#keys","#selected","#expanded","#page","#orderStore","#filterStore","#clamp","#rowStore","#settle","#filtered","#destroyed"],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/helpers.ts","../../../src/core/validators.ts","../../../src/core/cloners.ts","../../../src/core/parsers.ts","../../../src/core/tables/ExpansionManager.ts","../../../src/core/tables/FilterManager.ts","../../../src/core/tables/PaginationManager.ts","../../../src/core/tables/RowManager.ts","../../../src/core/tables/SelectionManager.ts","../../../src/core/tables/SortManager.ts","../../../src/core/Table.ts","../../../src/core/factories.ts"],"sourcesContent":["import type { ColumnCell } from './types.js'\n\n/** Every column cell, in the order declared by the public contract. */\nexport const COLUMN_CELLS: readonly ColumnCell[] = Object.freeze([\n\t'text',\n\t'number',\n\t'flag',\n\t'choice',\n])\n\n/** The maximum number of columns one schema may declare. */\nexport const COLUMN_LIMIT = 256\n\n/** The maximum number of choices one `choice` column may offer. */\nexport const CHOICE_LIMIT = 1024\n\n/** The maximum length, in UTF-16 code units, of a schema name or column key. */\nexport const NAME_LIMIT = 128\n\n/** The maximum length, in UTF-16 code units, of any single retained string. */\nexport const STRING_LIMIT = 65536\n\n/** The maximum total length, in UTF-16 code units, of every string one schema retains. */\nexport const TEXT_LIMIT = 1048576\n\n/** The maximum total number of records, arrays, and leaves one schema retains. */\nexport const NODE_LIMIT = 16384\n","import type { JSONRecord } from '@orkestrel/contract'\nimport type { TableErrorCode } from './types.js'\n\n/** An error raised by the table domain. */\nexport class TableError extends Error {\n\t/** The machine-readable reason for this failure. */\n\treadonly code: TableErrorCode\n\n\t/** Structured values that locate or explain this failure. */\n\treadonly context?: JSONRecord\n\n\t/**\n\t * Create a table error.\n\t *\n\t * @param code - The machine-readable reason.\n\t * @param message - The human-readable failure text.\n\t * @param context - Optional structured failure details.\n\t */\n\tconstructor(code: TableErrorCode, message: string, context?: JSONRecord) {\n\t\tsuper(message)\n\t\tthis.name = 'TableError'\n\t\tthis.code = code\n\t\tif (context !== undefined) this.context = context\n\t}\n}\n\n/**\n * Determine whether an unknown value is a table error.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is a {@link TableError} instance.\n */\nexport function isTableError(input: unknown): input is TableError {\n\treturn input instanceof TableError\n}\n","import type { JSONPrimitive, JSONRecord, JSONValue } from '@orkestrel/contract'\nimport type {\n\tCellComparator,\n\tCellMatcher,\n\tTableCell,\n\tTableColumn,\n\tTableFilter,\n\tTableKey,\n\tTableOrder,\n\tTableRow,\n\tTableSchema,\n} from './types.js'\nimport {\n\tattempt,\n\tcloneJSONRecord,\n\tisArray,\n\tisBoolean,\n\tisContractError,\n\tisFiniteNumber,\n\tisRecord,\n\tisString,\n\treadArrayEntries,\n} from '@orkestrel/contract'\nimport {\n\tCHOICE_LIMIT,\n\tCOLUMN_LIMIT,\n\tNAME_LIMIT,\n\tNODE_LIMIT,\n\tSTRING_LIMIT,\n\tTEXT_LIMIT,\n} from './constants.js'\nimport { TableError } from './errors.js'\n\n/**\n * Find one column by key.\n *\n * @param schema - The schema whose columns to search.\n * @param key - The column key to find.\n * @returns The declared column, or `undefined` when no column has that key.\n */\nexport function extractColumn(schema: TableSchema, key: string): TableColumn | undefined {\n\treturn schema.columns.find((column) => column.key === key)\n}\n\n/**\n * Read one row's declared identity.\n *\n * @param schema - The schema that names the identity column.\n * @param row - The row whose identity to read.\n * @returns The non-empty string identity, or `undefined` when it is unusable.\n */\nexport function extractKey(schema: TableSchema, row: TableRow): TableKey | undefined {\n\tif (!Object.hasOwn(row, schema.key)) return undefined\n\tconst key = row[schema.key]\n\treturn isString(key) && key.length > 0 ? key : undefined\n}\n\n/**\n * Compute one atomic 0/1/N membership change over known keys.\n *\n * @param known - Every key the caller may change.\n * @param current - The current key set.\n * @param input - Every known key, one key, or a key list.\n * @param include - Decide the next membership from each key's membership at that step.\n * @returns `undefined` when any requested key is unknown, the current set for a no-op, or the next\n * set when membership changes.\n */\nexport function computeKeys(\n\tknown: readonly TableKey[],\n\tcurrent: ReadonlySet<TableKey>,\n\tinput: TableKey | readonly TableKey[] | undefined,\n\tinclude: (included: boolean) => boolean,\n): ReadonlySet<TableKey> | undefined {\n\tconst requested = input === undefined ? known : Array.isArray(input) ? input : [input]\n\tconst population = new Set(known)\n\tif (requested.some((key) => !population.has(key))) return undefined\n\n\tconst next = new Set(current)\n\tfor (const key of requested) {\n\t\tif (include(next.has(key))) next.add(key)\n\t\telse next.delete(key)\n\t}\n\n\tconst changed = next.size !== current.size || [...next].some((key) => !current.has(key))\n\treturn changed ? next : current\n}\n\n/**\n * Check whether a value has the shape required by one column cell.\n *\n * @param column - The column that owns the cell.\n * @param value - The unknown value to inspect.\n * @returns Whether the column can hold the value.\n */\nexport function matchesCell(column: TableColumn, value: unknown): value is TableCell {\n\tif (isString(value) && value.length > STRING_LIMIT) return false\n\n\tswitch (column.cell) {\n\t\tcase 'text':\n\t\t\treturn isString(value)\n\t\tcase 'number':\n\t\t\treturn isFiniteNumber(value)\n\t\tcase 'flag':\n\t\t\treturn isBoolean(value)\n\t\tcase 'choice':\n\t\t\treturn isString(value) && column.choices.some((choice) => choice.value === value)\n\t}\n}\n\n/**\n * Compare two cells in ascending order according to one column.\n *\n * @param column - The column that fixes the comparison.\n * @param left - The first cell, or absence.\n * @param right - The second cell, or absence.\n * @returns A negative number, positive number, or zero in sort-comparator form.\n */\nexport function compareCells(\n\tcolumn: TableColumn,\n\tleft: TableCell | undefined,\n\tright: TableCell | undefined,\n): number {\n\tif (left === undefined) return right === undefined ? 0 : -1\n\tif (right === undefined) return 1\n\n\tswitch (column.cell) {\n\t\tcase 'text':\n\t\t\tif (!isString(left) || !isString(right)) return 0\n\t\t\treturn left < right ? -1 : left > right ? 1 : 0\n\t\tcase 'number':\n\t\t\tif (!isFiniteNumber(left) || !isFiniteNumber(right)) return 0\n\t\t\treturn left - right\n\t\tcase 'flag':\n\t\t\tif (!isBoolean(left) || !isBoolean(right)) return 0\n\t\t\treturn left === right ? 0 : left ? 1 : -1\n\t\tcase 'choice': {\n\t\t\tif (!isString(left) || !isString(right)) return 0\n\t\t\tconst leftIndex = column.choices.findIndex((choice) => choice.value === left)\n\t\t\tconst rightIndex = column.choices.findIndex((choice) => choice.value === right)\n\t\t\treturn leftIndex - rightIndex\n\t\t}\n\t}\n}\n\n/**\n * Check whether one column admits a filter and all its operands.\n *\n * @param column - The column that fixes the accepted operators and cell shapes.\n * @param filter - The filter to inspect.\n * @returns Whether the filter belongs to the column and the column can apply it.\n */\nexport function admitsFilter(column: TableColumn, filter: TableFilter): boolean {\n\tif (filter.column !== column.key) return false\n\n\tswitch (filter.operator) {\n\t\tcase 'contains':\n\t\t\treturn (\n\t\t\t\t(column.cell === 'text' || column.cell === 'choice') && filter.text.length <= STRING_LIMIT\n\t\t\t)\n\t\tcase 'between':\n\t\t\treturn (\n\t\t\t\t(column.cell === 'text' || column.cell === 'number') &&\n\t\t\t\tmatchesCell(column, filter.minimum) &&\n\t\t\t\tmatchesCell(column, filter.maximum)\n\t\t\t)\n\t\tcase 'equals':\n\t\t\treturn matchesCell(column, filter.value)\n\t}\n}\n\n/**\n * Test one cell against a filter according to its column.\n *\n * @param column - The column that fixes the accepted operators.\n * @param cell - The cell to test, or absence.\n * @param filter - The filter to apply.\n * @returns Whether the filter accepts the cell.\n */\nexport function matchesFilter(\n\tcolumn: TableColumn,\n\tcell: TableCell | undefined,\n\tfilter: TableFilter,\n): boolean {\n\tif (cell === undefined || !admitsFilter(column, filter) || !matchesCell(column, cell))\n\t\treturn false\n\n\tswitch (filter.operator) {\n\t\tcase 'contains':\n\t\t\treturn isString(cell) && cell.includes(filter.text)\n\t\tcase 'between':\n\t\t\treturn (\n\t\t\t\tcompareCells(column, cell, filter.minimum) >= 0 &&\n\t\t\t\tcompareCells(column, cell, filter.maximum) <= 0\n\t\t\t)\n\t\tcase 'equals':\n\t\t\treturn cell === filter.value\n\t}\n}\n\n/**\n * Keep the rows accepted by every filter.\n *\n * @param schema - The schema that declares the filtered columns.\n * @param rows - The rows to filter.\n * @param filters - The filters to apply with and-only composition.\n * @param matchers - Optional per-column replacements for the default matcher.\n * @returns A frozen copy of the accepted rows in their original order.\n */\nexport function filterRows(\n\tschema: TableSchema,\n\trows: readonly TableRow[],\n\tfilters: readonly TableFilter[],\n\tmatchers?: Readonly<Record<string, CellMatcher>>,\n): readonly TableRow[] {\n\treturn Object.freeze(\n\t\trows.filter((row) =>\n\t\t\tfilters.every((filter) => {\n\t\t\t\tconst column = extractColumn(schema, filter.column)\n\t\t\t\tif (column === undefined) return false\n\t\t\t\tconst matcher =\n\t\t\t\t\tmatchers !== undefined && Object.hasOwn(matchers, column.key)\n\t\t\t\t\t\t? matchers[column.key]\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst cell = Object.hasOwn(row, column.key) ? row[column.key] : undefined\n\t\t\t\treturn matcher === undefined ? matchesFilter(column, cell, filter) : matcher(cell, filter)\n\t\t\t}),\n\t\t),\n\t)\n}\n\n/**\n * Order rows stably by a sequence of terms.\n *\n * @param schema - The schema that declares the sorted columns.\n * @param rows - The rows to order.\n * @param orders - The ordered sort terms.\n * @param comparators - Optional per-column replacements for the default comparator.\n * @returns A frozen sorted copy that leaves the input untouched.\n */\nexport function sortRows(\n\tschema: TableSchema,\n\trows: readonly TableRow[],\n\torders: readonly TableOrder[],\n\tcomparators?: Readonly<Record<string, CellComparator>>,\n): readonly TableRow[] {\n\tconst indexed = rows.map((row, index) => ({ row, index }))\n\n\tindexed.sort((left, right) => {\n\t\tfor (const order of orders) {\n\t\t\tconst column = extractColumn(schema, order.column)\n\t\t\tif (column === undefined) continue\n\t\t\tconst comparator =\n\t\t\t\tcomparators !== undefined && Object.hasOwn(comparators, column.key)\n\t\t\t\t\t? comparators[column.key]\n\t\t\t\t\t: undefined\n\t\t\tconst leftCell = Object.hasOwn(left.row, column.key) ? left.row[column.key] : undefined\n\t\t\tconst rightCell = Object.hasOwn(right.row, column.key) ? right.row[column.key] : undefined\n\t\t\tconst compared =\n\t\t\t\tcomparator === undefined\n\t\t\t\t\t? compareCells(column, leftCell, rightCell)\n\t\t\t\t\t: comparator(leftCell, rightCell)\n\t\t\tif (compared !== 0 && !Number.isNaN(compared)) {\n\t\t\t\treturn order.direction === 'ascending' ? compared : -compared\n\t\t\t}\n\t\t}\n\n\t\treturn left.index - right.index\n\t})\n\n\treturn Object.freeze(indexed.map((entry) => entry.row))\n}\n\n/**\n * Audit a structurally valid schema for domain and budget faults.\n *\n * @param schema - The table schema to audit.\n * @returns Frozen human-readable diagnostics, or an empty list when the schema is sound.\n */\nexport function auditTable(schema: TableSchema): readonly string[] {\n\tconst faults: string[] = []\n\tconst columns = new Set<string>()\n\tlet choiceExceeded: string | undefined\n\tlet nameExceeded = schema.name !== undefined && schema.name.length > NAME_LIMIT\n\n\tif (schema.columns.length > COLUMN_LIMIT) {\n\t\tfaults.push(`schema declares more than ${COLUMN_LIMIT} columns`)\n\t}\n\n\tconst columnCount = Math.min(schema.columns.length, COLUMN_LIMIT + 1)\n\tfor (let index = 0; index < columnCount; index += 1) {\n\t\tconst column = schema.columns[index]\n\t\tif (column === undefined) continue\n\t\tif (column.key.length > NAME_LIMIT) nameExceeded = true\n\t\tif (\n\t\t\tchoiceExceeded === undefined &&\n\t\t\tcolumn.cell === 'choice' &&\n\t\t\tcolumn.choices.length > CHOICE_LIMIT\n\t\t) {\n\t\t\tchoiceExceeded = column.key\n\t\t}\n\t}\n\n\tif (choiceExceeded !== undefined) {\n\t\tfaults.push(`column \"${choiceExceeded}\" offers more than ${CHOICE_LIMIT} choices`)\n\t}\n\tif (nameExceeded) faults.push(`schema contains a name longer than ${NAME_LIMIT}`)\n\n\tconst pending: unknown[] = [schema]\n\tconst metadata: boolean[] = [false]\n\tlet position = 0\n\tlet stringExceeded = false\n\tlet textExceeded = false\n\tlet nodeExceeded = false\n\tlet text = 0\n\n\twhile (position < pending.length) {\n\t\tconst node = pending[position]\n\t\tconst inMeta = metadata[position] === true\n\t\tposition += 1\n\n\t\tif (isString(node)) {\n\t\t\tif (node.length > STRING_LIMIT) stringExceeded = true\n\t\t\ttext = Math.min(TEXT_LIMIT + 1, text + node.length)\n\t\t\tif (text > TEXT_LIMIT) textExceeded = true\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isArray(node)) {\n\t\t\tconst read = readArrayEntries(node)\n\t\t\tif (!read.success || !read.value.dense) continue\n\t\t\tfor (const entry of read.value.entries) {\n\t\t\t\tif (pending.length >= NODE_LIMIT) {\n\t\t\t\t\tnodeExceeded = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tpending.push(entry)\n\t\t\t\tmetadata.push(inMeta)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif (!isRecord(node)) continue\n\t\tconst keys = attempt(() => Object.keys(node))\n\t\tif (!keys.success) continue\n\n\t\tfor (const key of keys.value) {\n\t\t\tif (inMeta) {\n\t\t\t\tif (key.length > STRING_LIMIT) stringExceeded = true\n\t\t\t\ttext = Math.min(TEXT_LIMIT + 1, text + key.length)\n\t\t\t\tif (text > TEXT_LIMIT) textExceeded = true\n\t\t\t}\n\n\t\t\tconst value = attempt(() => node[key])\n\t\t\tif (!value.success || value.value === undefined) continue\n\t\t\tif (pending.length >= NODE_LIMIT) {\n\t\t\t\tnodeExceeded = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tpending.push(value.value)\n\t\t\tmetadata.push(inMeta || key === 'meta')\n\t\t}\n\t}\n\n\tif (stringExceeded) faults.push(`schema contains a string longer than ${STRING_LIMIT}`)\n\tif (textExceeded) faults.push(`schema retains more than ${TEXT_LIMIT} string code units`)\n\tif (nodeExceeded) faults.push(`schema retains more than ${NODE_LIMIT} nodes`)\n\n\tfor (let index = 0; index < columnCount; index += 1) {\n\t\tconst column = schema.columns[index]\n\t\tif (column === undefined) continue\n\t\tif (!nodeExceeded && column.meta !== undefined) {\n\t\t\tconst owned = attempt(() => cloneJSONRecord(column.meta))\n\t\t\tif (!owned.success) {\n\t\t\t\tfaults.push(`column \"${column.key}\" has metadata that cannot be owned`)\n\t\t\t}\n\t\t}\n\t\tif (column.key.length === 0) faults.push('column \"\" has an empty key')\n\t\tif (columns.has(column.key)) {\n\t\t\tfaults.push(`column \"${column.key}\" is declared more than once`)\n\t\t}\n\t\tcolumns.add(column.key)\n\n\t\tif (column.cell === 'choice') {\n\t\t\tconst choices = new Set<string>()\n\t\t\tconst choiceCount = Math.min(column.choices.length, CHOICE_LIMIT + 1)\n\t\t\tfor (let choiceIndex = 0; choiceIndex < choiceCount; choiceIndex += 1) {\n\t\t\t\tconst choice = column.choices[choiceIndex]\n\t\t\t\tif (choice === undefined) continue\n\t\t\t\tif (choices.has(choice.value)) {\n\t\t\t\t\tfaults.push(`column \"${column.key}\" offers choice \"${choice.value}\" more than once`)\n\t\t\t\t}\n\t\t\t\tchoices.add(choice.value)\n\t\t\t}\n\t\t\tif (column.choices.length === 0) {\n\t\t\t\tfaults.push(`column \"${column.key}\" offers no choices`)\n\t\t\t}\n\t\t}\n\t}\n\n\tconst key = extractColumn(schema, schema.key)\n\tif (key === undefined) {\n\t\tfaults.push(`schema key \"${schema.key}\" names no declared column`)\n\t} else if (key.cell === 'number' || key.cell === 'flag') {\n\t\tfaults.push(`schema key \"${schema.key}\" names a ${key.cell} column, which holds no identity`)\n\t}\n\n\treturn Object.freeze(faults)\n}\n\n/**\n * Project a schema into declaration-ordered JSON.\n *\n * @param schema - The schema to project.\n * @returns A deeply owned JSON record with absent members omitted.\n * @throws A {@link TableError} coded `SCHEMA` when metadata cannot be owned.\n */\nexport function serializeTable(schema: TableSchema): JSONRecord {\n\tconst output: Record<string, JSONValue> = {}\n\tif (schema.name !== undefined) output.name = schema.name\n\tif (schema.label !== undefined) output.label = schema.label\n\tif (schema.help !== undefined) output.help = schema.help\n\toutput.key = schema.key\n\toutput.columns = schema.columns.map((column): JSONRecord => {\n\t\tconst entry: Record<string, JSONValue> = { cell: column.cell, key: column.key }\n\t\tif (column.label !== undefined) entry.label = column.label\n\t\tif (column.help !== undefined) entry.help = column.help\n\t\tif (column.hidden !== undefined) entry.hidden = column.hidden\n\t\tif (column.meta !== undefined) entry.meta = column.meta\n\t\tif (column.cell === 'choice') {\n\t\t\tentry.choices = column.choices.map((choice): JSONRecord => {\n\t\t\t\tconst option: Record<string, JSONValue> = {\n\t\t\t\t\tvalue: choice.value,\n\t\t\t\t\tlabel: choice.label,\n\t\t\t\t}\n\t\t\t\tif (choice.help !== undefined) option.help = choice.help\n\t\t\t\treturn option\n\t\t\t})\n\t\t}\n\t\treturn entry\n\t})\n\n\ttry {\n\t\treturn cloneJSONRecord(output)\n\t} catch (error) {\n\t\tif (!isContractError(error)) throw error\n\t\tthrow new TableError('SCHEMA', 'schema contains metadata that cannot be owned')\n\t}\n}\n\n/**\n * Project rows into schema-column-ordered JSON.\n *\n * @param schema - The schema that fixes cell order.\n * @param rows - The rows to project.\n * @returns A frozen list of owned JSON records with absent cells omitted.\n */\nexport function serializeRows(\n\tschema: TableSchema,\n\trows: readonly TableRow[],\n): readonly JSONRecord[] {\n\tconst output: JSONRecord[] = []\n\n\tfor (const row of rows) {\n\t\tconst entry: Record<string, JSONPrimitive> = {}\n\t\tfor (const column of schema.columns) {\n\t\t\tif (!Object.hasOwn(row, column.key)) continue\n\t\t\tconst value = row[column.key]\n\t\t\tif (value === undefined) continue\n\t\t\tObject.defineProperty(entry, column.key, {\n\t\t\t\tvalue,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t})\n\t\t}\n\t\toutput.push(cloneJSONRecord(entry))\n\t}\n\n\treturn Object.freeze(output)\n}\n","import type {\n\tColumnCell,\n\tColumnChoice,\n\tTableCell,\n\tTableColumn,\n\tTableRow,\n\tTableSchema,\n} from './types.js'\nimport {\n\tarrayOf,\n\tattempt,\n\tcloneJSONRecord,\n\tisBoolean,\n\tisBoundedJSONRecord,\n\tisFiniteNumber,\n\tisRecord,\n\tisString,\n\trecordOf,\n\tunionOf,\n} from '@orkestrel/contract'\nimport { COLUMN_CELLS } from './constants.js'\nimport { auditTable } from './helpers.js'\n\n/**\n * Determine whether an unknown value has a table cell shape.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is a string, finite number, or boolean.\n */\nexport function isTableCell(input: unknown): input is TableCell {\n\treturn unionOf(isString, isFiniteNumber, isBoolean)(input)\n}\n\n/**\n * Determine whether an unknown value is a record of table cells.\n *\n * @param input - The value to inspect.\n * @returns Whether every own key is a string and every value is a table cell.\n */\nexport function isTableRow(input: unknown): input is TableRow {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(input)) return false\n\t\treturn Reflect.ownKeys(input).every(\n\t\t\t(key) => isString(key) && Object.hasOwn(input, key) && isTableCell(input[key]),\n\t\t)\n\t})\n\n\treturn outcome.success && outcome.value\n}\n\n/**\n * Determine whether an unknown value is a declared column cell.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is one of the four column cells.\n */\nexport function isColumnCell(input: unknown): input is ColumnCell {\n\treturn COLUMN_CELLS.some((cell) => cell === input)\n}\n\n/**\n * Determine whether an unknown value is one exact column choice record.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is a column choice.\n */\nexport function isColumnChoice(input: unknown): input is ColumnChoice {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(input) || !Reflect.ownKeys(input).every((key) => isString(key))) return false\n\t\treturn recordOf({ value: isString, label: isString, help: isString }, ['help'])(input)\n\t})\n\n\treturn outcome.success && outcome.value\n}\n\n/**\n * Determine whether an unknown value is one exact discriminated table column.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is a structurally valid table column.\n */\nexport function isTableColumn(input: unknown): input is TableColumn {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(input) || !Object.hasOwn(input, 'cell') || !Object.hasOwn(input, 'key')) {\n\t\t\treturn false\n\t\t}\n\n\t\tconst cell = input.cell\n\t\tif (!isColumnCell(cell)) return false\n\n\t\tconst exact = Reflect.ownKeys(input).every((key) => {\n\t\t\tif (!isString(key)) return false\n\t\t\tif (['cell', 'key', 'label', 'help', 'hidden', 'meta'].includes(key)) return true\n\t\t\treturn cell === 'choice' && key === 'choices'\n\t\t})\n\t\tif (!exact) return false\n\n\t\tconst key = input.key\n\t\tconst hasLabel = Object.hasOwn(input, 'label')\n\t\tconst label = hasLabel ? input.label : undefined\n\t\tconst hasHelp = Object.hasOwn(input, 'help')\n\t\tconst help = hasHelp ? input.help : undefined\n\t\tconst hasHidden = Object.hasOwn(input, 'hidden')\n\t\tconst hidden = hasHidden ? input.hidden : undefined\n\t\tconst hasMeta = Object.hasOwn(input, 'meta')\n\t\tconst meta = hasMeta ? input.meta : undefined\n\t\tif (hasMeta) {\n\t\t\tif (!isBoundedJSONRecord(meta)) return false\n\t\t\tconst owned = attempt(() => cloneJSONRecord(meta))\n\t\t\tif (!owned.success) return false\n\t\t}\n\n\t\tif (\n\t\t\t!isString(key) ||\n\t\t\t(hasLabel && !isString(label)) ||\n\t\t\t(hasHelp && !isString(help)) ||\n\t\t\t(hasHidden && !isBoolean(hidden))\n\t\t) {\n\t\t\treturn false\n\t\t}\n\n\t\tif (cell !== 'choice') return !Object.hasOwn(input, 'choices')\n\t\treturn Object.hasOwn(input, 'choices') && arrayOf(isColumnChoice)(input.choices)\n\t})\n\n\treturn outcome.success && outcome.value\n}\n\n/**\n * Determine whether an unknown value has one exact structural table-schema shape.\n *\n * @param input - The value to inspect.\n * @returns Whether the value has the exact structure of a table schema.\n */\nexport function isStructuralTableSchema(input: unknown): input is TableSchema {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(input) || !Reflect.ownKeys(input).every((key) => isString(key))) return false\n\t\treturn recordOf(\n\t\t\t{\n\t\t\t\tname: isString,\n\t\t\t\tlabel: isString,\n\t\t\t\thelp: isString,\n\t\t\t\tkey: isString,\n\t\t\t\tcolumns: arrayOf(isTableColumn),\n\t\t\t},\n\t\t\t['name', 'label', 'help'],\n\t\t)(input)\n\t})\n\n\treturn outcome.success && outcome.value\n}\n\n/**\n * Determine whether an unknown value is one semantically sound table schema.\n *\n * @param input - The value to inspect.\n * @returns Whether the value has valid structure, domain relationships, and budgets.\n */\nexport function isTableSchema(input: unknown): input is TableSchema {\n\tconst outcome = attempt(() => isStructuralTableSchema(input) && auditTable(input).length === 0)\n\treturn outcome.success && outcome.value\n}\n","import type { JSONRecord } from '@orkestrel/contract'\nimport type { TableRow, TableSchema } from './types.js'\nimport { cloneJSONRecord, isContractError } from '@orkestrel/contract'\nimport { TableError } from './errors.js'\n\n/**\n * Clone one row into an owned frozen snapshot.\n *\n * @param row - The row to own.\n * @returns A frozen copy of the row's cells.\n */\nexport function cloneRow(row: TableRow): TableRow {\n\treturn Object.freeze({ ...row })\n}\n\n/**\n * Clone a table schema into an owned frozen snapshot.\n *\n * @param schema - The schema to own.\n * @returns A frozen schema with every nested column, choice, list, and metadata record owned.\n */\nexport function cloneSchema(schema: TableSchema): TableSchema {\n\treturn Object.freeze({\n\t\t...schema,\n\t\tcolumns: Object.freeze(\n\t\t\tschema.columns.map((column) => {\n\t\t\t\tlet meta: { meta?: JSONRecord } = {}\n\n\t\t\t\tif (column.meta !== undefined) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmeta = { meta: cloneJSONRecord(column.meta) }\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!isContractError(error)) throw error\n\t\t\t\t\t\tthrow new TableError(\n\t\t\t\t\t\t\t'SCHEMA',\n\t\t\t\t\t\t\t`column \"${column.key}\" has metadata that cannot be owned`,\n\t\t\t\t\t\t\t{ column: column.key },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (column.cell === 'choice') {\n\t\t\t\t\treturn Object.freeze({\n\t\t\t\t\t\t...column,\n\t\t\t\t\t\t...meta,\n\t\t\t\t\t\tchoices: Object.freeze(column.choices.map((choice) => Object.freeze({ ...choice }))),\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\treturn Object.freeze({ ...column, ...meta })\n\t\t\t}),\n\t\t),\n\t})\n}\n","import type { TableCell, TableRow, TableSchema } from './types.js'\nimport {\n\tattempt,\n\tisArray,\n\tisRecord,\n\tisString,\n\tparseNumber,\n\treadArrayEntries,\n} from '@orkestrel/contract'\nimport { cloneRow } from './cloners.js'\nimport { STRING_LIMIT } from './constants.js'\nimport { extractColumn, extractKey, matchesCell, serializeTable } from './helpers.js'\nimport { isTableSchema } from './validators.js'\n\n/**\n * Parse unknown wire data into an owned, semantically sound table schema.\n *\n * @param input - The unknown schema value to parse.\n * @returns An owned table schema, or `undefined` on refusal.\n */\nexport function parseTable(input: unknown): TableSchema | undefined {\n\tconst outcome = attempt(() => {\n\t\tif (!isTableSchema(input)) return undefined\n\t\tconst projected = serializeTable(input)\n\t\treturn isTableSchema(projected) ? projected : undefined\n\t})\n\n\treturn outcome.success ? outcome.value : undefined\n}\n\n/**\n * Parse unknown wire rows against one table schema.\n *\n * @param schema - The schema that declares the accepted keys and cell shapes.\n * @param input - The unknown row-list value to parse.\n * @returns Frozen owned rows, or `undefined` when any row is refused.\n */\nexport function parseRows(schema: TableSchema, input: unknown): readonly TableRow[] | undefined {\n\tconst outcome = attempt(() => {\n\t\tif (!isTableSchema(schema) || !isArray(input)) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst read = readArrayEntries(input)\n\t\tif (!read.success || !read.value.dense) return undefined\n\n\t\tconst keys = new Set<string>()\n\t\tconst rows: TableRow[] = []\n\n\t\tfor (const candidate of read.value.entries) {\n\t\t\tif (!isRecord(candidate)) return undefined\n\t\t\tconst row: Record<string, TableCell> = {}\n\n\t\t\tfor (const key of Reflect.ownKeys(candidate)) {\n\t\t\t\tif (!isString(key) || !Object.hasOwn(candidate, key)) return undefined\n\t\t\t\tconst column = extractColumn(schema, key)\n\t\t\t\tif (column === undefined) return undefined\n\t\t\t\tconst inputCell = candidate[key]\n\t\t\t\tlet cell: unknown = inputCell\n\n\t\t\t\tif (column.cell === 'number' && isString(inputCell)) {\n\t\t\t\t\tif (inputCell.length > STRING_LIMIT) return undefined\n\t\t\t\t\tcell = parseNumber(inputCell)\n\t\t\t\t} else if (column.cell === 'flag' && inputCell === 'true') {\n\t\t\t\t\tcell = true\n\t\t\t\t} else if (column.cell === 'flag' && inputCell === 'false') {\n\t\t\t\t\tcell = false\n\t\t\t\t}\n\n\t\t\t\tif (!matchesCell(column, cell)) return undefined\n\t\t\t\tObject.defineProperty(row, key, {\n\t\t\t\t\tvalue: cell,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tconst owned = cloneRow(row)\n\t\t\tconst key = extractKey(schema, owned)\n\t\t\tif (key === undefined || keys.has(key)) return undefined\n\t\t\tkeys.add(key)\n\t\t\trows.push(owned)\n\t\t}\n\n\t\treturn Object.freeze(rows)\n\t})\n\n\treturn outcome.success ? outcome.value : undefined\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { ExpansionManagerInterface, TableEventMap, TableKey } from '../types.js'\nimport { computeKeys } from '../helpers.js'\n\n/** The keys of the rows somebody has opened. */\nexport class ExpansionManager implements ExpansionManagerInterface {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #rows: () => readonly TableKey[]\n\treadonly #read: () => ReadonlySet<TableKey>\n\treadonly #write: (keys: ReadonlySet<TableKey>) => void\n\n\t/**\n\t * Create an expansion manager over one table's private stores.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param rows - A read of every row key.\n\t * @param read - A read of the expanded keys.\n\t * @param write - The expanded-key commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\trows: () => readonly TableKey[],\n\t\tread: () => ReadonlySet<TableKey>,\n\t\twrite: (keys: ReadonlySet<TableKey>) => void,\n\t) {\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#rows = rows\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t}\n\n\t/** The keys of the rows opened right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn new Set(this.#read())\n\t}\n\n\t/** Open every row the table holds. */\n\texpand(): void\n\t/** Open one row. */\n\texpand(key: TableKey): boolean\n\t/** Open several rows. */\n\texpand(keys: readonly TableKey[]): boolean\n\t/** Open one or more rows. */\n\texpand(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, () => true)\n\t}\n\n\t/** Close every row. */\n\tclear(): void\n\t/** Close one row. */\n\tclear(key: TableKey): boolean\n\t/** Close several rows. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Close one or more rows. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, () => false)\n\t}\n\n\t/** Open one row or close it when already open. */\n\ttoggle(key: TableKey): boolean\n\t/** Turn several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turn one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, (included) => !included) === true\n\t}\n\n\t#change(\n\t\tinput: TableKey | readonly TableKey[] | undefined,\n\t\tinclude: (included: boolean) => boolean,\n\t): void | boolean {\n\t\tconst previous = this.#read()\n\t\tconst next = computeKeys(this.#rows(), previous, input, include)\n\t\tif (next === undefined) return false\n\t\tif (next !== previous) {\n\t\t\tthis.#write(next)\n\t\t\tthis.#emitter.emit('expand', new Set(next))\n\t\t}\n\n\t\treturn input === undefined ? undefined : true\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { FilterManagerInterface, TableEventMap, TableFilter, TableSchema } from '../types.js'\nimport { TableError } from '../errors.js'\nimport { admitsFilter, extractColumn } from '../helpers.js'\n\n/** The filters one table applies with and-only composition. */\nexport class FilterManager implements FilterManagerInterface {\n\treadonly #schema: TableSchema\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #read: () => readonly TableFilter[]\n\treadonly #write: (filters: readonly TableFilter[]) => void\n\treadonly #clamp: () => number | undefined\n\n\t/**\n\t * Create a filter manager over one table's private filter store.\n\t *\n\t * @param schema - The table schema.\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param read - A read of the current filters.\n\t * @param write - The filter commit boundary.\n\t * @param clamp - The pagination clamp commit after a filter commit.\n\t */\n\tconstructor(\n\t\tschema: TableSchema,\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\tread: () => readonly TableFilter[],\n\t\twrite: (filters: readonly TableFilter[]) => void,\n\t\tclamp: () => number | undefined,\n\t) {\n\t\tthis.#schema = schema\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t\tthis.#clamp = clamp\n\t}\n\n\t/** Find one column's filter. */\n\tfilter(column: string): TableFilter | undefined {\n\t\tconst filter = this.#read().find((candidate) => candidate.column === column)\n\t\treturn filter === undefined ? undefined : Object.freeze({ ...filter })\n\t}\n\n\t/** Read every filter as an owned frozen snapshot. */\n\tfilters(): readonly TableFilter[] {\n\t\treturn Object.freeze(this.#read().map((filter) => Object.freeze({ ...filter })))\n\t}\n\n\t/** Filter several columns. */\n\tset(filters: readonly TableFilter[]): void\n\t/** Filter one column. */\n\tset(filter: TableFilter): void\n\t/** Filter one column or several. */\n\tset(input: TableFilter | readonly TableFilter[]): void {\n\t\tthis.#gate()\n\t\tconst requested = Array.isArray(input) ? input : [input]\n\t\tfor (const filter of requested) this.#validate(filter)\n\n\t\tconst next = [...this.#read()]\n\t\tfor (const filter of requested) {\n\t\t\tconst owned = Object.freeze({ ...filter })\n\t\t\tconst index = next.findIndex((candidate) => candidate.column === filter.column)\n\t\t\tif (index === -1) next.push(owned)\n\t\t\telse next[index] = owned\n\t\t}\n\n\t\tif (this.#same(next, this.#read())) return\n\t\tthis.#write(Object.freeze(next))\n\t\tconst page = this.#clamp()\n\t\tthis.#emitter.emit('filter', this.filters())\n\t\tif (page !== undefined) this.#emitter.emit('paginate', page)\n\t}\n\n\t/** Stop filtering by every column. */\n\tremove(): void\n\t/** Stop filtering by one column. */\n\tremove(column: string): boolean\n\t/** Stop filtering by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stop filtering by one or more columns. */\n\tremove(input?: string | readonly string[]): void | boolean {\n\t\tthis.#gate()\n\t\tconst columns =\n\t\t\tinput === undefined\n\t\t\t\t? this.#schema.columns.map((column) => column.key)\n\t\t\t\t: Array.isArray(input)\n\t\t\t\t\t? input\n\t\t\t\t\t: [input]\n\t\tfor (const column of columns) {\n\t\t\tif (extractColumn(this.#schema, column) === undefined) return false\n\t\t}\n\n\t\tconst removed = new Set(columns)\n\t\tconst next = this.#read().filter((filter) => !removed.has(filter.column))\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(Object.freeze(next))\n\t\t\tconst page = this.#clamp()\n\t\t\tthis.#emitter.emit('filter', this.filters())\n\t\t\tif (page !== undefined) this.#emitter.emit('paginate', page)\n\t\t}\n\n\t\treturn input === undefined ? undefined : true\n\t}\n\n\t#validate(filter: TableFilter): void {\n\t\tconst column = extractColumn(this.#schema, filter.column)\n\t\tif (column === undefined) {\n\t\t\tthrow new TableError('COLUMN', `The schema declares no column named \"${filter.column}\"`, {\n\t\t\t\tcolumn: filter.column,\n\t\t\t})\n\t\t}\n\n\t\tif (!admitsFilter(column, filter)) {\n\t\t\tthrow new TableError('CELL', `Column \"${filter.column}\" cannot apply that filter`, {\n\t\t\t\tcolumn: filter.column,\n\t\t\t})\n\t\t}\n\t}\n\n\t#same(left: readonly TableFilter[], right: readonly TableFilter[]): boolean {\n\t\treturn (\n\t\t\tleft.length === right.length &&\n\t\t\tleft.every((filter, index) => {\n\t\t\t\tconst other = right[index]\n\t\t\t\tif (\n\t\t\t\t\tother === undefined ||\n\t\t\t\t\tfilter.column !== other.column ||\n\t\t\t\t\tfilter.operator !== other.operator\n\t\t\t\t) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif (filter.operator === 'contains' && other.operator === 'contains')\n\t\t\t\t\treturn filter.text === other.text\n\t\t\t\tif (filter.operator === 'between' && other.operator === 'between') {\n\t\t\t\t\treturn filter.minimum === other.minimum && filter.maximum === other.maximum\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\tfilter.operator === 'equals' &&\n\t\t\t\t\tother.operator === 'equals' &&\n\t\t\t\t\tfilter.value === other.value\n\t\t\t\t)\n\t\t\t})\n\t\t)\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { PaginationManagerInterface, TableEventMap } from '../types.js'\n\n/** The page arithmetic over one table's filtered rows. */\nexport class PaginationManager implements PaginationManagerInterface {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #rows: () => number\n\treadonly #readPage: () => number\n\treadonly #writePage: (page: number) => void\n\treadonly #readLimit: () => number | undefined\n\treadonly #writeLimit: (limit: number | undefined) => void\n\n\t/**\n\t * Create a pagination manager over one table's private stores.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param rows - A read of the filtered row count.\n\t * @param readPage - A read of the current page.\n\t * @param writePage - The page commit boundary.\n\t * @param readLimit - A read of the current page size.\n\t * @param writeLimit - The page-size commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\trows: () => number,\n\t\treadPage: () => number,\n\t\twritePage: (page: number) => void,\n\t\treadLimit: () => number | undefined,\n\t\twriteLimit: (limit: number | undefined) => void,\n\t) {\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#rows = rows\n\t\tthis.#readPage = readPage\n\t\tthis.#writePage = writePage\n\t\tthis.#readLimit = readLimit\n\t\tthis.#writeLimit = writeLimit\n\n\t\tconst limit = this.#readLimit()\n\t\tif (limit !== undefined) this.#writeLimit(this.#normalize(limit))\n\t}\n\n\t/** The page shown, counted from one. */\n\tget page(): number {\n\t\treturn this.#readLimit() === undefined ? 1 : this.#readPage()\n\t}\n\n\t/** The number of rows one page holds. */\n\tget limit(): number | undefined {\n\t\treturn this.#readLimit()\n\t}\n\n\t/** The number of filtered rows skipped before this page. */\n\tget offset(): number {\n\t\tconst limit = this.#readLimit()\n\t\treturn limit === undefined ? 0 : (this.#readPage() - 1) * limit\n\t}\n\n\t/** The number of pages filled by the filtered rows. */\n\tget count(): number {\n\t\tconst limit = this.#readLimit()\n\t\treturn limit === undefined ? 1 : Math.max(1, Math.ceil(this.#rows() / limit))\n\t}\n\n\t/** Show another page, clamped to the pages that exist. */\n\tmove(page: number): void {\n\t\tthis.#gate()\n\t\tconst next = this.#readLimit() === undefined ? 1 : Math.min(this.count, this.#normalize(page))\n\t\tif (next === this.#readPage()) return\n\t\tthis.#writePage(next)\n\t\tthis.#emitter.emit('paginate', next)\n\t}\n\n\t/** Change the page size while keeping the first row previously shown. */\n\tresize(limit?: number): void {\n\t\tthis.#gate()\n\t\tconst previous = this.#readLimit()\n\t\tconst nextLimit = limit === undefined ? undefined : this.#normalize(limit)\n\t\tif (previous === nextLimit) return\n\n\t\tconst anchor = previous === undefined ? 0 : (this.#readPage() - 1) * previous\n\t\tthis.#writeLimit(nextLimit)\n\t\tconst nextPage =\n\t\t\tnextLimit === undefined\n\t\t\t\t? 1\n\t\t\t\t: Math.min(Math.max(1, Math.floor(anchor / nextLimit) + 1), this.count)\n\t\tthis.#writePage(nextPage)\n\t\tthis.#emitter.emit('paginate', nextPage)\n\t}\n\n\t#normalize(value: number): number {\n\t\treturn Number.isFinite(value) ? Math.max(1, Math.trunc(value)) : 1\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type {\n\tRowManagerInterface,\n\tTableEventMap,\n\tTableKey,\n\tTableRow,\n\tTableSchema,\n} from '../types.js'\nimport { cloneRow } from '../cloners.js'\nimport { TableError } from '../errors.js'\nimport { extractColumn, extractKey, matchesCell } from '../helpers.js'\nimport { isTableRow } from '../validators.js'\n\n/** The rows one table holds in its own order. */\nexport class RowManager implements RowManagerInterface {\n\treadonly #schema: TableSchema\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #read: () => readonly TableRow[]\n\treadonly #write: (rows: readonly TableRow[]) => void\n\treadonly #settle: (removed: readonly TableKey[], announce: () => void) => void\n\n\t/**\n\t * Create a row manager over one table's private row store.\n\t *\n\t * @param schema - The table schema.\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param read - A read of the current rows.\n\t * @param write - The row commit boundary.\n\t * @param settle - Commit dependent state, then order row and dependent announcements.\n\t * @param rows - Rows to seed without announcements.\n\t */\n\tconstructor(\n\t\tschema: TableSchema,\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\tread: () => readonly TableRow[],\n\t\twrite: (rows: readonly TableRow[]) => void,\n\t\tsettle: (removed: readonly TableKey[], announce: () => void) => void,\n\t\trows: readonly TableRow[] = [],\n\t) {\n\t\tthis.#schema = schema\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t\tthis.#settle = settle\n\n\t\tconst seeded = this.#prepare(rows, new Set())\n\t\tif (seeded.length > 0) this.#write(Object.freeze(seeded))\n\t}\n\n\t/** Find one row by key as an owned frozen snapshot. */\n\trow(key: TableKey): TableRow | undefined {\n\t\tconst row = this.#read().find((candidate) => extractKey(this.#schema, candidate) === key)\n\t\treturn row === undefined ? undefined : cloneRow(row)\n\t}\n\n\t/** Read every row as owned frozen snapshots in table order. */\n\trows(): readonly TableRow[] {\n\t\treturn Object.freeze(this.#read().map((row) => cloneRow(row)))\n\t}\n\n\t/** Append several rows. */\n\tadd(rows: readonly TableRow[]): void\n\t/** Append one row. */\n\tadd(row: TableRow): void\n\t/** Append one row or several. */\n\tadd(input: TableRow | readonly TableRow[]): void {\n\t\tthis.#gate()\n\t\tconst rows = Array.isArray(input) ? input : [input]\n\t\tconst keys = new Set<TableKey>()\n\t\tfor (const row of this.#read()) {\n\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\tif (key !== undefined) keys.add(key)\n\t\t}\n\t\tconst added = this.#prepare(rows, keys)\n\t\tif (added.length === 0) return\n\n\t\tthis.#write(Object.freeze([...this.#read(), ...added]))\n\t\tthis.#settle([], () => {\n\t\t\tfor (const row of added) {\n\t\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\t\tif (key !== undefined) this.#emitter.emit('write', key)\n\t\t\t}\n\t\t})\n\t}\n\n\t/** Merge several rows into the rows their keys name. */\n\tupdate(rows: readonly TableRow[]): boolean\n\t/** Merge one row into the row its key names. */\n\tupdate(row: TableRow): boolean\n\t/** Merge one row or several into the rows their keys name. */\n\tupdate(input: TableRow | readonly TableRow[]): boolean {\n\t\tthis.#gate()\n\t\tconst updates = (Array.isArray(input) ? input : [input]).map((row) => cloneRow(row))\n\t\tconst current = this.#read()\n\t\tconst locations: number[] = []\n\n\t\tfor (const update of updates) {\n\t\t\tthis.#validate(update)\n\t\t\tconst key = extractKey(this.#schema, update)\n\t\t\tif (key === undefined) this.#failKey('A row has no usable identity')\n\t\t\tconst index = current.findIndex((row) => extractKey(this.#schema, row) === key)\n\t\t\tif (index === -1) return false\n\t\t\tlocations.push(index)\n\t\t}\n\n\t\tconst next = [...current]\n\t\tconst moved: TableKey[] = []\n\t\tfor (let index = 0; index < updates.length; index += 1) {\n\t\t\tconst update = updates[index]\n\t\t\tconst location = locations[index]\n\t\t\tif (update === undefined || location === undefined) continue\n\t\t\tconst previous = next[location]\n\t\t\tif (previous === undefined) continue\n\t\t\tconst merged = cloneRow({ ...previous, ...update })\n\t\t\tif (!this.#same(previous, merged)) {\n\t\t\t\tnext[location] = merged\n\t\t\t\tconst key = extractKey(this.#schema, merged)\n\t\t\t\tif (key !== undefined) moved.push(key)\n\t\t\t}\n\t\t}\n\n\t\tif (moved.length === 0) return true\n\t\tthis.#write(Object.freeze(next))\n\t\tthis.#settle([], () => {\n\t\t\tfor (const key of moved) this.#emitter.emit('write', key)\n\t\t})\n\t\treturn true\n\t}\n\n\t/** Move one row to a clamped index in table order. */\n\tmove(key: TableKey, index: number): boolean {\n\t\tthis.#gate()\n\t\tconst current = this.#read()\n\t\tconst origin = current.findIndex((row) => extractKey(this.#schema, row) === key)\n\t\tif (origin === -1) return false\n\t\tconst target = Math.min(\n\t\t\tcurrent.length - 1,\n\t\t\tNumber.isFinite(index) ? Math.max(0, Math.trunc(index)) : 0,\n\t\t)\n\t\tif (origin === target) return true\n\n\t\tconst row = current[origin]\n\t\tif (row === undefined) return false\n\t\tconst next = [...current]\n\t\tnext.splice(origin, 1)\n\t\tnext.splice(target, 0, row)\n\t\tthis.#write(Object.freeze(next))\n\t\tthis.#settle([], () => this.#emitter.emit('write', key))\n\t\treturn true\n\t}\n\n\t/** Remove every row. */\n\tremove(): void\n\t/** Remove one row. */\n\tremove(key: TableKey): boolean\n\t/** Remove several rows. */\n\tremove(keys: readonly TableKey[]): boolean\n\t/** Remove one or more rows. */\n\tremove(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\tconst current = this.#read()\n\t\tconst requested =\n\t\t\tinput === undefined\n\t\t\t\t? current.flatMap((row) => {\n\t\t\t\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\t\t\t\treturn key === undefined ? [] : [key]\n\t\t\t\t\t})\n\t\t\t\t: Array.isArray(input)\n\t\t\t\t\t? input\n\t\t\t\t\t: [input]\n\t\tconst keys = new Set(requested)\n\t\tconst known = new Set(\n\t\t\tcurrent.flatMap((row) => {\n\t\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\t\treturn key === undefined ? [] : [key]\n\t\t\t}),\n\t\t)\n\t\tif ([...keys].some((key) => !known.has(key))) return false\n\t\tif (keys.size === 0) return input === undefined ? undefined : true\n\n\t\tconst removed = current.flatMap((row) => {\n\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\treturn key !== undefined && keys.has(key) ? [key] : []\n\t\t})\n\t\tthis.#write(\n\t\t\tObject.freeze(\n\t\t\t\tcurrent.filter((row) => {\n\t\t\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\t\t\treturn key === undefined || !keys.has(key)\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t\tthis.#settle(removed, () => {\n\t\t\tfor (const key of removed) this.#emitter.emit('remove', key)\n\t\t})\n\t\treturn input === undefined ? undefined : true\n\t}\n\n\t#prepare(rows: readonly TableRow[], existing: Set<TableKey>): readonly TableRow[] {\n\t\tconst owned: TableRow[] = []\n\t\tfor (const row of rows) {\n\t\t\tconst snapshot = cloneRow(row)\n\t\t\tthis.#validate(snapshot)\n\t\t\tconst key = extractKey(this.#schema, snapshot)\n\t\t\tif (key === undefined) this.#failKey('A row has no usable identity')\n\t\t\tif (existing.has(key)) this.#failKey(`Row key \"${key}\" is already taken`, key)\n\t\t\texisting.add(key)\n\t\t\towned.push(snapshot)\n\t\t}\n\t\treturn owned\n\t}\n\n\t#validate(row: TableRow): void {\n\t\tif (extractKey(this.#schema, row) === undefined) this.#failKey('A row has no usable identity')\n\t\tif (!isTableRow(row)) {\n\t\t\tthrow new TableError('CELL', 'A row contains a value no table cell can hold')\n\t\t}\n\t\tfor (const key of Object.keys(row)) {\n\t\t\tconst column = extractColumn(this.#schema, key)\n\t\t\tif (column === undefined || !matchesCell(column, row[key])) {\n\t\t\t\tthrow new TableError('CELL', `Column \"${key}\" cannot hold that cell`, { column: key })\n\t\t\t}\n\t\t}\n\t}\n\n\t#failKey(message: string, key?: TableKey): never {\n\t\tif (key === undefined) throw new TableError('KEY', message)\n\t\tthrow new TableError('KEY', message, { key })\n\t}\n\n\t#same(left: TableRow, right: TableRow): boolean {\n\t\tconst leftKeys = Object.keys(left)\n\t\tconst rightKeys = Object.keys(right)\n\t\treturn (\n\t\t\tleftKeys.length === rightKeys.length &&\n\t\t\tleftKeys.every((key) => Object.hasOwn(right, key) && left[key] === right[key])\n\t\t)\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { SelectionManagerInterface, TableEventMap, TableKey } from '../types.js'\nimport { computeKeys } from '../helpers.js'\n\n/** The keys of the rows somebody has picked. */\nexport class SelectionManager implements SelectionManagerInterface {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #rows: () => readonly TableKey[]\n\treadonly #read: () => ReadonlySet<TableKey>\n\treadonly #write: (keys: ReadonlySet<TableKey>) => void\n\n\t/**\n\t * Create a selection manager over one table's private stores.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param rows - A read of every row key.\n\t * @param read - A read of the selected keys.\n\t * @param write - The selected-key commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\trows: () => readonly TableKey[],\n\t\tread: () => ReadonlySet<TableKey>,\n\t\twrite: (keys: ReadonlySet<TableKey>) => void,\n\t) {\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#rows = rows\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t}\n\n\t/** The keys of the rows picked right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn new Set(this.#read())\n\t}\n\n\t/** Pick every row the table holds. */\n\tselect(): void\n\t/** Pick one row. */\n\tselect(key: TableKey): boolean\n\t/** Pick several rows. */\n\tselect(keys: readonly TableKey[]): boolean\n\t/** Pick one or more rows. */\n\tselect(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, () => true)\n\t}\n\n\t/** Drop every pick. */\n\tclear(): void\n\t/** Drop one pick. */\n\tclear(key: TableKey): boolean\n\t/** Drop several picks. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Drop one or more picks. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, () => false)\n\t}\n\n\t/** Pick one row or drop it when already picked. */\n\ttoggle(key: TableKey): boolean\n\t/** Turn several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turn one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, (included) => !included) === true\n\t}\n\n\t#change(\n\t\tinput: TableKey | readonly TableKey[] | undefined,\n\t\tinclude: (included: boolean) => boolean,\n\t): void | boolean {\n\t\tconst previous = this.#read()\n\t\tconst next = computeKeys(this.#rows(), previous, input, include)\n\t\tif (next === undefined) return false\n\t\tif (next !== previous) {\n\t\t\tthis.#write(next)\n\t\t\tthis.#emitter.emit('select', new Set(next))\n\t\t}\n\n\t\treturn input === undefined ? undefined : true\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { SortManagerInterface, TableEventMap, TableOrder, TableSchema } from '../types.js'\nimport { TableError } from '../errors.js'\nimport { extractColumn } from '../helpers.js'\n\n/** The ordered sort terms of one table. */\nexport class SortManager implements SortManagerInterface {\n\treadonly #schema: TableSchema\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #read: () => readonly TableOrder[]\n\treadonly #write: (orders: readonly TableOrder[]) => void\n\n\t/**\n\t * Create a sort manager over one table's private term store.\n\t *\n\t * @param schema - The table schema.\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param read - A read of the current terms.\n\t * @param write - The term commit boundary.\n\t */\n\tconstructor(\n\t\tschema: TableSchema,\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\tread: () => readonly TableOrder[],\n\t\twrite: (orders: readonly TableOrder[]) => void,\n\t) {\n\t\tthis.#schema = schema\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t}\n\n\t/** Find one column's sort term. */\n\torder(column: string): TableOrder | undefined {\n\t\tconst order = this.#read().find((candidate) => candidate.column === column)\n\t\treturn order === undefined ? undefined : Object.freeze({ ...order })\n\t}\n\n\t/** Read every sort term as an owned frozen snapshot. */\n\torders(): readonly TableOrder[] {\n\t\treturn Object.freeze(this.#read().map((order) => Object.freeze({ ...order })))\n\t}\n\n\t/** Sort by several columns. */\n\tset(orders: readonly TableOrder[]): void\n\t/** Sort by one column. */\n\tset(order: TableOrder): void\n\t/** Sort by one column or several. */\n\tset(input: TableOrder | readonly TableOrder[]): void {\n\t\tthis.#gate()\n\t\tconst requested = Array.isArray(input) ? input : [input]\n\t\tfor (const order of requested) this.#require(order.column)\n\n\t\tconst next = [...this.#read()]\n\t\tfor (const order of requested) {\n\t\t\tconst owned = Object.freeze({ ...order })\n\t\t\tconst index = next.findIndex((candidate) => candidate.column === order.column)\n\t\t\tif (index === -1) next.push(owned)\n\t\t\telse next[index] = owned\n\t\t}\n\n\t\tif (this.#same(next, this.#read())) return\n\t\tconst committed = Object.freeze(next)\n\t\tthis.#write(committed)\n\t\tthis.#emitter.emit('sort', this.orders())\n\t}\n\n\t/** Stop sorting by every column. */\n\tremove(): void\n\t/** Stop sorting by one column. */\n\tremove(column: string): boolean\n\t/** Stop sorting by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stop sorting by one or more columns. */\n\tremove(input?: string | readonly string[]): void | boolean {\n\t\tthis.#gate()\n\t\tconst columns =\n\t\t\tinput === undefined\n\t\t\t\t? this.#schema.columns.map((column) => column.key)\n\t\t\t\t: Array.isArray(input)\n\t\t\t\t\t? input\n\t\t\t\t\t: [input]\n\t\tfor (const column of columns) {\n\t\t\tif (extractColumn(this.#schema, column) === undefined) return false\n\t\t}\n\n\t\tconst removed = new Set(columns)\n\t\tconst next = this.#read().filter((order) => !removed.has(order.column))\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(Object.freeze(next))\n\t\t\tthis.#emitter.emit('sort', this.orders())\n\t\t}\n\n\t\treturn input === undefined ? undefined : true\n\t}\n\n\t#require(column: string): void {\n\t\tif (extractColumn(this.#schema, column) === undefined) {\n\t\t\tthrow new TableError('COLUMN', `The schema declares no column named \"${column}\"`, { column })\n\t\t}\n\t}\n\n\t#same(left: readonly TableOrder[], right: readonly TableOrder[]): boolean {\n\t\treturn (\n\t\t\tleft.length === right.length &&\n\t\t\tleft.every((order, index) => {\n\t\t\t\tconst other = right[index]\n\t\t\t\treturn (\n\t\t\t\t\tother !== undefined &&\n\t\t\t\t\torder.column === other.column &&\n\t\t\t\t\torder.direction === other.direction\n\t\t\t\t)\n\t\t\t})\n\t\t)\n\t}\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tCellComparator,\n\tCellMatcher,\n\tExpansionManagerInterface,\n\tFilterManagerInterface,\n\tPaginationManagerInterface,\n\tRowManagerInterface,\n\tSelectionManagerInterface,\n\tSortManagerInterface,\n\tTableEventMap,\n\tTableFilter,\n\tTableInterface,\n\tTableKey,\n\tTableOptions,\n\tTableOrder,\n\tTableRow,\n\tTableSchema,\n} from './types.js'\nimport { Emitter } from '@orkestrel/emitter'\nimport { cloneRow, cloneSchema } from './cloners.js'\nimport { TableError } from './errors.js'\nimport { auditTable, extractKey, filterRows, sortRows } from './helpers.js'\nimport { ExpansionManager } from './tables/ExpansionManager.js'\nimport { FilterManager } from './tables/FilterManager.js'\nimport { PaginationManager } from './tables/PaginationManager.js'\nimport { RowManager } from './tables/RowManager.js'\nimport { SelectionManager } from './tables/SelectionManager.js'\nimport { SortManager } from './tables/SortManager.js'\nimport { isStructuralTableSchema } from './validators.js'\n\n/** A schema, its rows, and the lens through which they are read. */\nexport class Table implements TableInterface {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #schema: TableSchema\n\treadonly #comparators: Readonly<Record<string, CellComparator>> | undefined\n\treadonly #matchers: Readonly<Record<string, CellMatcher>> | undefined\n\treadonly #initialLimit: number | undefined\n\t#rowStore: readonly TableRow[] = Object.freeze([])\n\t#orderStore: readonly TableOrder[] = Object.freeze([])\n\t#filterStore: readonly TableFilter[] = Object.freeze([])\n\t#selected: ReadonlySet<TableKey> = new Set()\n\t#expanded: ReadonlySet<TableKey> = new Set()\n\t#page = 1\n\t#limit: number | undefined\n\t#destroyed = false\n\treadonly #rows: RowManager\n\treadonly #sort: SortManager\n\treadonly #filter: FilterManager\n\treadonly #selection: SelectionManager\n\treadonly #expansion: ExpansionManager\n\treadonly #pagination: PaginationManager\n\n\t/**\n\t * Open a table against a schema.\n\t *\n\t * @param schema - The table declaration to own.\n\t * @param options - Initial rows, lens overrides, pagination, and emitter wiring.\n\t * @throws A {@link TableError} coded `SCHEMA` when the schema is unusable, `KEY` when a seeded\n\t * identity is unusable or repeated, and `CELL` when a seeded cell is invalid.\n\t */\n\tconstructor(schema: TableSchema, options?: TableOptions) {\n\t\tconst problems = isStructuralTableSchema(schema)\n\t\t\t? auditTable(schema)\n\t\t\t: ['The schema is not a table schema']\n\t\tif (problems.length > 0) {\n\t\t\tthrow new TableError('SCHEMA', `The table schema is unusable: ${problems.join('; ')}`, {\n\t\t\t\tproblems: [...problems],\n\t\t\t})\n\t\t}\n\n\t\tthis.#schema = cloneSchema(schema)\n\t\tthis.#comparators =\n\t\t\toptions?.comparators === undefined ? undefined : Object.freeze({ ...options.comparators })\n\t\tthis.#matchers =\n\t\t\toptions?.matchers === undefined ? undefined : Object.freeze({ ...options.matchers })\n\t\tthis.#limit = options?.limit\n\t\tthis.#emitter = new Emitter<TableEventMap>({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\n\t\tthis.#selection = new SelectionManager(\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#keys(),\n\t\t\t() => this.#selected,\n\t\t\t(keys) => {\n\t\t\t\tthis.#selected = keys\n\t\t\t},\n\t\t)\n\t\tthis.#expansion = new ExpansionManager(\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#keys(),\n\t\t\t() => this.#expanded,\n\t\t\t(keys) => {\n\t\t\t\tthis.#expanded = keys\n\t\t\t},\n\t\t)\n\t\tthis.#pagination = new PaginationManager(\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.count,\n\t\t\t() => this.#page,\n\t\t\t(page) => {\n\t\t\t\tthis.#page = page\n\t\t\t},\n\t\t\t() => this.#limit,\n\t\t\t(limit) => {\n\t\t\t\tthis.#limit = limit\n\t\t\t},\n\t\t)\n\t\tthis.#initialLimit = this.#limit\n\t\tthis.#sort = new SortManager(\n\t\t\tthis.#schema,\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#orderStore,\n\t\t\t(orders) => {\n\t\t\t\tthis.#orderStore = orders\n\t\t\t},\n\t\t)\n\t\tthis.#filter = new FilterManager(\n\t\t\tthis.#schema,\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#filterStore,\n\t\t\t(filters) => {\n\t\t\t\tthis.#filterStore = filters\n\t\t\t},\n\t\t\t() => this.#clamp(),\n\t\t)\n\t\tthis.#rows = new RowManager(\n\t\t\tthis.#schema,\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#rowStore,\n\t\t\t(rows) => {\n\t\t\t\tthis.#rowStore = rows\n\t\t\t},\n\t\t\t(removed, announce) => this.#settle(removed, announce),\n\t\t\toptions?.rows,\n\t\t)\n\t}\n\n\t/** The table's event emitter. */\n\tget emitter(): EmitterInterface<TableEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\t/** The owned frozen schema. */\n\tget schema(): TableSchema {\n\t\treturn this.#schema\n\t}\n\n\t/** The rows the table holds. */\n\tget rows(): RowManagerInterface {\n\t\treturn this.#rows\n\t}\n\n\t/** The ordered sort terms. */\n\tget sort(): SortManagerInterface {\n\t\treturn this.#sort\n\t}\n\n\t/** The filters applied with and-only composition. */\n\tget filter(): FilterManagerInterface {\n\t\treturn this.#filter\n\t}\n\n\t/** The selected row keys. */\n\tget selection(): SelectionManagerInterface {\n\t\treturn this.#selection\n\t}\n\n\t/** The expanded row keys. */\n\tget expansion(): ExpansionManagerInterface {\n\t\treturn this.#expansion\n\t}\n\n\t/** The page arithmetic. */\n\tget pagination(): PaginationManagerInterface {\n\t\treturn this.#pagination\n\t}\n\n\t/** The filtered, sorted, and paged rows as owned frozen snapshots. */\n\tget view(): readonly TableRow[] {\n\t\tconst ordered = sortRows(this.#schema, this.#filtered(), this.#orderStore, this.#comparators)\n\t\tconst limit = this.#limit\n\t\tconst page =\n\t\t\tlimit === undefined\n\t\t\t\t? ordered\n\t\t\t\t: ordered.slice(this.#pagination.offset, this.#pagination.offset + limit)\n\t\treturn Object.freeze(page.map((row) => cloneRow(row)))\n\t}\n\n\t/** The number of rows admitted by the filters. */\n\tget count(): number {\n\t\treturn this.#filtered().length\n\t}\n\n\t/** Whether the table has been torn down. */\n\tget destroyed(): boolean {\n\t\treturn this.#destroyed\n\t}\n\n\t/** Reset every moving axis to its opening state. */\n\tclear(): void {\n\t\tthis.#gate()\n\t\tconst changed =\n\t\t\tthis.#rowStore.length > 0 ||\n\t\t\tthis.#orderStore.length > 0 ||\n\t\t\tthis.#filterStore.length > 0 ||\n\t\t\tthis.#selected.size > 0 ||\n\t\t\tthis.#expanded.size > 0 ||\n\t\t\tthis.#page !== 1 ||\n\t\t\tthis.#limit !== this.#initialLimit\n\t\tif (!changed) return\n\n\t\tthis.#rowStore = Object.freeze([])\n\t\tthis.#orderStore = Object.freeze([])\n\t\tthis.#filterStore = Object.freeze([])\n\t\tthis.#selected = new Set()\n\t\tthis.#expanded = new Set()\n\t\tthis.#page = 1\n\t\tthis.#limit = this.#initialLimit\n\t\tthis.#emitter.emit('clear')\n\t}\n\n\t/** Tear the table down while leaving every getter readable. */\n\tdestroy(): void {\n\t\tif (this.#destroyed) return\n\t\tthis.#destroyed = true\n\t\tthis.#emitter.destroy()\n\t}\n\n\t#filtered(): readonly TableRow[] {\n\t\treturn filterRows(this.#schema, this.#rowStore, this.#filterStore, this.#matchers)\n\t}\n\n\t#keys(): readonly TableKey[] {\n\t\treturn this.#rowStore.flatMap((row) => {\n\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\treturn key === undefined ? [] : [key]\n\t\t})\n\t}\n\n\t#settle(removed: readonly TableKey[], announce: () => void): void {\n\t\tconst keys = new Set(removed)\n\t\tconst selected = new Set([...this.#selected].filter((key) => !keys.has(key)))\n\t\tconst expanded = new Set([...this.#expanded].filter((key) => !keys.has(key)))\n\t\tconst selectedChanged = selected.size !== this.#selected.size\n\t\tconst expandedChanged = expanded.size !== this.#expanded.size\n\n\t\tif (selectedChanged) this.#selected = selected\n\t\tif (expandedChanged) this.#expanded = expanded\n\t\tconst page = this.#clamp()\n\n\t\tannounce()\n\t\tif (selectedChanged) this.#emitter.emit('select', new Set(selected))\n\t\tif (expandedChanged) this.#emitter.emit('expand', new Set(expanded))\n\t\tif (page !== undefined) this.#emitter.emit('paginate', page)\n\t}\n\n\t#clamp(): number | undefined {\n\t\tconst page = Math.min(this.#page, this.#pagination.count)\n\t\tif (page === this.#page) return undefined\n\t\tthis.#page = page\n\t\treturn page\n\t}\n\n\t#gate(): void {\n\t\tif (this.#destroyed) {\n\t\t\tthrow new TableError('DESTROYED', 'The table was destroyed and cannot change')\n\t\t}\n\t}\n}\n","import type { TableInterface, TableOptions, TableSchema } from './types.js'\nimport { Table } from './Table.js'\n\n/**\n * Open a table against a schema.\n *\n * @param schema - The table declaration to own.\n * @param options - Initial rows, lens overrides, pagination, and emitter wiring.\n * @returns A live table interface.\n * @throws A {@link TableError} coded `SCHEMA` when the schema is unusable, `KEY` when a seeded\n * identity is unusable or repeated, and `CELL` when a seeded cell is invalid.\n * @example\n * ```ts\n * const table = createTable({ key: 'id', columns: [{ cell: 'text', key: 'id' }] })\n * table.rows.add({ id: '1' })\n * ```\n */\nexport function createTable(schema: TableSchema, options?: TableOptions): TableInterface {\n\treturn new Table(schema, options)\n}\n"],"mappings":";;;;;AAGA,IAAa,eAAsC,OAAO,OAAO;CAChE;CACA;CACA;CACA;AACD,CAAC;;AAGD,IAAa,eAAe;;AAG5B,IAAa,eAAe;;AAG5B,IAAa,aAAa;;AAG1B,IAAa,eAAe;;AAG5B,IAAa,aAAa;;AAG1B,IAAa,aAAa;;;;ACtB1B,IAAa,aAAb,cAAgC,MAAM;;CAErC;;CAGA;;;;;;;;CASA,YAAY,MAAsB,SAAiB,SAAsB;EACxE,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,IAAI,YAAY,KAAA,GAAW,KAAK,UAAU;CAC3C;AACD;;;;;;;AAQA,SAAgB,aAAa,OAAqC;CACjE,OAAO,iBAAiB;AACzB;;;;;;;;;;ACMA,SAAgB,cAAc,QAAqB,KAAsC;CACxF,OAAO,OAAO,QAAQ,MAAM,WAAW,OAAO,QAAQ,GAAG;AAC1D;;;;;;;;AASA,SAAgB,WAAW,QAAqB,KAAqC;CACpF,IAAI,CAAC,OAAO,OAAO,KAAK,OAAO,GAAG,GAAG,OAAO,KAAA;CAC5C,MAAM,MAAM,IAAI,OAAO;CACvB,QAAA,GAAO,oBAAA,SAAA,CAAS,GAAG,KAAK,IAAI,SAAS,IAAI,MAAM,KAAA;AAChD;;;;;;;;;;;AAYA,SAAgB,YACf,OACA,SACA,OACA,SAC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IAAI,iBAAiB,KAAKA,SAAS,KAAK,UAAU,IAAI,IAAI,QAAQ,CAAC;EACnE,IAAI,SAAS,KAAA,GAAW,KAAKA,SAAS,KAAK,YAAY,IAAI;CAC5D;CAEA,SAA6B;EAC5B,MAAM,OAAO,KAAK,IAAI,KAAKgB,OAAO,KAAKN,YAAY,KAAK;EACxD,IAAI,SAAS,KAAKM,OAAO,OAAO,KAAA;EAChC,KAAKA,QAAQ;EACb,OAAO;CACR;CAEA,QAAc;EACb,IAAI,KAAKO,YACR,MAAM,IAAI,WAAW,aAAa,2CAA2C;CAE/E;AACD;;;;;;;;;;;;;;;;;ACpQA,SAAgB,YAAY,QAAqB,SAAwC;CACxF,OAAO,IAAI,MAAM,QAAQ,OAAO;AACjC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["#emitter","#gate","#rows","#read","#write","#change","#schema","#emitter","#gate","#read","#write","#clamp","#validate","#same","#emitter","#gate","#rows","#readPage","#writePage","#readLimit","#writeLimit","#normalize","#schema","#emitter","#gate","#read","#write","#settle","#prepare","#validate","#failKey","#same","#emitter","#gate","#rows","#read","#write","#change","#schema","#emitter","#gate","#read","#write","#require","#same","#emitter","#schema","#comparators","#matchers","#initialLimit","#rows","#sort","#filter","#selection","#expansion","#pagination","#limit","#gate","#keys","#selected","#expanded","#page","#orderStore","#filterStore","#clamp","#rowStore","#settle","#filtered","#destroyed"],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/helpers.ts","../../../src/core/validators.ts","../../../src/core/cloners.ts","../../../src/core/parsers.ts","../../../src/core/tables/ExpansionManager.ts","../../../src/core/tables/FilterManager.ts","../../../src/core/tables/PaginationManager.ts","../../../src/core/tables/RowManager.ts","../../../src/core/tables/SelectionManager.ts","../../../src/core/tables/SortManager.ts","../../../src/core/Table.ts","../../../src/core/factories.ts"],"sourcesContent":["import type { ColumnCell } from './types.js'\n\n/** Every column cell, in the order declared by the public contract. */\nexport const COLUMN_CELLS: readonly ColumnCell[] = Object.freeze([\n\t'text',\n\t'number',\n\t'flag',\n\t'choice',\n])\n\n/** The maximum number of columns one schema may declare. */\nexport const COLUMN_LIMIT = 256\n\n/** The maximum number of choices one `choice` column may offer. */\nexport const CHOICE_LIMIT = 1024\n\n/** The maximum length, in UTF-16 code units, of a schema name or column key. */\nexport const NAME_LIMIT = 128\n\n/** The maximum length, in UTF-16 code units, of any single retained string. */\nexport const STRING_LIMIT = 65536\n\n/** The maximum total length, in UTF-16 code units, of every string one schema retains. */\nexport const TEXT_LIMIT = 1048576\n\n/** The maximum total number of records, arrays, and leaves one schema retains. */\nexport const NODE_LIMIT = 16384\n","import type { JSONRecord } from '@orkestrel/contract'\nimport type { TableErrorCode } from './types.js'\n\n/** An error raised by the table domain. */\nexport class TableError extends Error {\n\t/** The machine-readable reason for this failure. */\n\treadonly code: TableErrorCode\n\n\t/** Structured values that locate or explain this failure. */\n\treadonly context?: JSONRecord\n\n\t/**\n\t * Create a table error.\n\t *\n\t * @param code - The machine-readable reason.\n\t * @param message - The human-readable failure text.\n\t * @param context - Optional structured failure details.\n\t */\n\tconstructor(code: TableErrorCode, message: string, context?: JSONRecord) {\n\t\tsuper(message)\n\t\tthis.name = 'TableError'\n\t\tthis.code = code\n\t\tif (context !== undefined) this.context = context\n\t}\n}\n\n/**\n * Determine whether an unknown value is a table error.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is a {@link TableError} instance.\n */\nexport function isTableError(input: unknown): input is TableError {\n\treturn input instanceof TableError\n}\n","import type { JSONPrimitive, JSONRecord, JSONValue } from '@orkestrel/contract'\nimport type {\n\tCellComparator,\n\tCellMatcher,\n\tTableCell,\n\tTableColumn,\n\tTableFilter,\n\tTableKey,\n\tTableOrder,\n\tTableRow,\n\tTableSchema,\n} from './types.js'\nimport {\n\tattempt,\n\tcloneJSONRecord,\n\tisArray,\n\tisBoolean,\n\tisContractError,\n\tisFiniteNumber,\n\tisRecord,\n\tisString,\n\treadArrayEntries,\n} from '@orkestrel/contract'\nimport {\n\tCHOICE_LIMIT,\n\tCOLUMN_LIMIT,\n\tNAME_LIMIT,\n\tNODE_LIMIT,\n\tSTRING_LIMIT,\n\tTEXT_LIMIT,\n} from './constants.js'\nimport { TableError } from './errors.js'\n\n/**\n * Find one column by key.\n *\n * @param schema - The schema whose columns to search.\n * @param key - The column key to find.\n * @returns The declared column, or `undefined` when no column has that key.\n */\nexport function extractColumn(schema: TableSchema, key: string): TableColumn | undefined {\n\treturn schema.columns.find((column) => column.key === key)\n}\n\n/**\n * Read one row's declared identity.\n *\n * @param schema - The schema that names the identity column.\n * @param row - The row whose identity to read.\n * @returns The non-empty string identity, or `undefined` when it is unusable.\n */\nexport function extractKey(schema: TableSchema, row: TableRow): TableKey | undefined {\n\tif (!Object.hasOwn(row, schema.key)) return undefined\n\tconst key = row[schema.key]\n\treturn isString(key) && key.length > 0 ? key : undefined\n}\n\n/**\n * Compute one atomic 0/1/N membership change over known keys.\n *\n * @param known - Every key the caller may change.\n * @param current - The current key set.\n * @param input - Every known key, one key, or a key list.\n * @param include - Decide the next membership from each key's membership at that step.\n * @returns `undefined` when any requested key is unknown, the current set for a no-op, or the next\n * set when membership changes.\n */\nexport function computeKeys(\n\tknown: readonly TableKey[],\n\tcurrent: ReadonlySet<TableKey>,\n\tinput: TableKey | readonly TableKey[] | undefined,\n\tinclude: (included: boolean) => boolean,\n): ReadonlySet<TableKey> | undefined {\n\tconst requested = input === undefined ? known : Array.isArray(input) ? input : [input]\n\tconst population = new Set(known)\n\tif (requested.some((key) => !population.has(key))) return undefined\n\n\tconst next = new Set(current)\n\tfor (const key of requested) {\n\t\tif (include(next.has(key))) next.add(key)\n\t\telse next.delete(key)\n\t}\n\n\tconst changed = next.size !== current.size || [...next].some((key) => !current.has(key))\n\treturn changed ? next : current\n}\n\n/**\n * Check whether a value has the shape required by one column cell.\n *\n * @param column - The column that owns the cell.\n * @param value - The unknown value to inspect.\n * @returns Whether the column can hold the value.\n */\nexport function matchesCell(column: TableColumn, value: unknown): value is TableCell {\n\tif (isString(value) && value.length > STRING_LIMIT) return false\n\n\tswitch (column.cell) {\n\t\tcase 'text':\n\t\t\treturn isString(value)\n\t\tcase 'number':\n\t\t\treturn isFiniteNumber(value)\n\t\tcase 'flag':\n\t\t\treturn isBoolean(value)\n\t\tcase 'choice':\n\t\t\treturn isString(value) && column.choices.some((choice) => choice.value === value)\n\t}\n}\n\n/**\n * Compare two cells in ascending order according to one column.\n *\n * @param column - The column that fixes the comparison.\n * @param left - The first cell, or absence.\n * @param right - The second cell, or absence.\n * @returns A negative number, positive number, or zero in sort-comparator form.\n */\nexport function compareCells(\n\tcolumn: TableColumn,\n\tleft: TableCell | undefined,\n\tright: TableCell | undefined,\n): number {\n\tif (left === undefined) return right === undefined ? 0 : -1\n\tif (right === undefined) return 1\n\n\tswitch (column.cell) {\n\t\tcase 'text':\n\t\t\tif (!isString(left) || !isString(right)) return 0\n\t\t\treturn left < right ? -1 : left > right ? 1 : 0\n\t\tcase 'number':\n\t\t\tif (!isFiniteNumber(left) || !isFiniteNumber(right)) return 0\n\t\t\treturn left - right\n\t\tcase 'flag':\n\t\t\tif (!isBoolean(left) || !isBoolean(right)) return 0\n\t\t\treturn left === right ? 0 : left ? 1 : -1\n\t\tcase 'choice': {\n\t\t\tif (!isString(left) || !isString(right)) return 0\n\t\t\tconst leftIndex = column.choices.findIndex((choice) => choice.value === left)\n\t\t\tconst rightIndex = column.choices.findIndex((choice) => choice.value === right)\n\t\t\treturn leftIndex - rightIndex\n\t\t}\n\t}\n}\n\n/**\n * Check whether one column admits a filter and all its operands.\n *\n * @param column - The column that fixes the accepted operators and cell shapes.\n * @param filter - The filter to inspect.\n * @returns Whether the filter belongs to the column and the column can apply it.\n */\nexport function admitsFilter(column: TableColumn, filter: TableFilter): boolean {\n\tif (filter.column !== column.key) return false\n\n\tswitch (filter.operator) {\n\t\tcase 'contains':\n\t\t\treturn (\n\t\t\t\t(column.cell === 'text' || column.cell === 'choice') && filter.text.length <= STRING_LIMIT\n\t\t\t)\n\t\tcase 'between':\n\t\t\treturn (\n\t\t\t\t(column.cell === 'text' || column.cell === 'number') &&\n\t\t\t\tmatchesCell(column, filter.minimum) &&\n\t\t\t\tmatchesCell(column, filter.maximum)\n\t\t\t)\n\t\tcase 'equals':\n\t\t\treturn matchesCell(column, filter.value)\n\t}\n}\n\n/**\n * Test one cell against a filter according to its column.\n *\n * @param column - The column that fixes the accepted operators.\n * @param cell - The cell to test, or absence.\n * @param filter - The filter to apply.\n * @returns Whether the filter accepts the cell.\n */\nexport function matchesFilter(\n\tcolumn: TableColumn,\n\tcell: TableCell | undefined,\n\tfilter: TableFilter,\n): boolean {\n\tif (cell === undefined || !admitsFilter(column, filter) || !matchesCell(column, cell))\n\t\treturn false\n\n\tswitch (filter.operator) {\n\t\tcase 'contains':\n\t\t\treturn isString(cell) && cell.includes(filter.text)\n\t\tcase 'between':\n\t\t\treturn (\n\t\t\t\tcompareCells(column, cell, filter.minimum) >= 0 &&\n\t\t\t\tcompareCells(column, cell, filter.maximum) <= 0\n\t\t\t)\n\t\tcase 'equals':\n\t\t\treturn cell === filter.value\n\t}\n}\n\n/**\n * Keep the rows accepted by every filter.\n *\n * @param schema - The schema that declares the filtered columns.\n * @param rows - The rows to filter.\n * @param filters - The filters to apply with and-only composition.\n * @param matchers - Optional per-column replacements for the default matcher.\n * @returns A frozen copy of the accepted rows in their original order.\n */\nexport function filterRows(\n\tschema: TableSchema,\n\trows: readonly TableRow[],\n\tfilters: readonly TableFilter[],\n\tmatchers?: Readonly<Record<string, CellMatcher>>,\n): readonly TableRow[] {\n\treturn Object.freeze(\n\t\trows.filter((row) =>\n\t\t\tfilters.every((filter) => {\n\t\t\t\tconst column = extractColumn(schema, filter.column)\n\t\t\t\tif (column === undefined) return false\n\t\t\t\tconst matcher =\n\t\t\t\t\tmatchers !== undefined && Object.hasOwn(matchers, column.key)\n\t\t\t\t\t\t? matchers[column.key]\n\t\t\t\t\t\t: undefined\n\t\t\t\tconst cell = Object.hasOwn(row, column.key) ? row[column.key] : undefined\n\t\t\t\treturn matcher === undefined ? matchesFilter(column, cell, filter) : matcher(cell, filter)\n\t\t\t}),\n\t\t),\n\t)\n}\n\n/**\n * Order rows stably by a sequence of terms.\n *\n * @param schema - The schema that declares the sorted columns.\n * @param rows - The rows to order.\n * @param orders - The ordered sort terms.\n * @param comparators - Optional per-column replacements for the default comparator.\n * @returns A frozen sorted copy that leaves the input untouched.\n */\nexport function sortRows(\n\tschema: TableSchema,\n\trows: readonly TableRow[],\n\torders: readonly TableOrder[],\n\tcomparators?: Readonly<Record<string, CellComparator>>,\n): readonly TableRow[] {\n\tconst indexed = rows.map((row, index) => ({ row, index }))\n\n\tindexed.sort((left, right) => {\n\t\tfor (const order of orders) {\n\t\t\tconst column = extractColumn(schema, order.column)\n\t\t\tif (column === undefined) continue\n\t\t\tconst comparator =\n\t\t\t\tcomparators !== undefined && Object.hasOwn(comparators, column.key)\n\t\t\t\t\t? comparators[column.key]\n\t\t\t\t\t: undefined\n\t\t\tconst leftCell = Object.hasOwn(left.row, column.key) ? left.row[column.key] : undefined\n\t\t\tconst rightCell = Object.hasOwn(right.row, column.key) ? right.row[column.key] : undefined\n\t\t\tconst compared =\n\t\t\t\tcomparator === undefined\n\t\t\t\t\t? compareCells(column, leftCell, rightCell)\n\t\t\t\t\t: comparator(leftCell, rightCell)\n\t\t\tif (compared !== 0 && !Number.isNaN(compared)) {\n\t\t\t\treturn order.direction === 'ascending' ? compared : -compared\n\t\t\t}\n\t\t}\n\n\t\treturn left.index - right.index\n\t})\n\n\treturn Object.freeze(indexed.map((entry) => entry.row))\n}\n\n/**\n * Audit a structurally valid schema for domain and budget faults.\n *\n * @param schema - The table schema to audit.\n * @returns Frozen human-readable diagnostics, or an empty list when the schema is sound.\n */\nexport function auditTable(schema: TableSchema): readonly string[] {\n\tconst faults: string[] = []\n\tconst columns = new Set<string>()\n\tlet choiceExceeded: string | undefined\n\tlet nameExceeded = schema.name !== undefined && schema.name.length > NAME_LIMIT\n\n\tif (schema.columns.length > COLUMN_LIMIT) {\n\t\tfaults.push(`schema declares more than ${COLUMN_LIMIT} columns`)\n\t}\n\n\tconst columnCount = Math.min(schema.columns.length, COLUMN_LIMIT + 1)\n\tfor (let index = 0; index < columnCount; index += 1) {\n\t\tconst column = schema.columns[index]\n\t\tif (column === undefined) continue\n\t\tif (column.key.length > NAME_LIMIT) nameExceeded = true\n\t\tif (\n\t\t\tchoiceExceeded === undefined &&\n\t\t\tcolumn.cell === 'choice' &&\n\t\t\tcolumn.choices.length > CHOICE_LIMIT\n\t\t) {\n\t\t\tchoiceExceeded = column.key\n\t\t}\n\t}\n\n\tif (choiceExceeded !== undefined) {\n\t\tfaults.push(`column \"${choiceExceeded}\" offers more than ${CHOICE_LIMIT} choices`)\n\t}\n\tif (nameExceeded) faults.push(`schema contains a name longer than ${NAME_LIMIT}`)\n\n\tconst pending: unknown[] = [schema]\n\tconst metadata: boolean[] = [false]\n\tlet position = 0\n\tlet stringExceeded = false\n\tlet textExceeded = false\n\tlet nodeExceeded = false\n\tlet text = 0\n\n\twhile (position < pending.length) {\n\t\tconst node = pending[position]\n\t\tconst inMeta = metadata[position] === true\n\t\tposition += 1\n\n\t\tif (isString(node)) {\n\t\t\tif (node.length > STRING_LIMIT) stringExceeded = true\n\t\t\ttext = Math.min(TEXT_LIMIT + 1, text + node.length)\n\t\t\tif (text > TEXT_LIMIT) textExceeded = true\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isArray(node)) {\n\t\t\tconst read = readArrayEntries(node)\n\t\t\tif (!read.success || !read.value.dense) continue\n\t\t\tfor (const entry of read.value.entries) {\n\t\t\t\tif (pending.length >= NODE_LIMIT) {\n\t\t\t\t\tnodeExceeded = true\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tpending.push(entry)\n\t\t\t\tmetadata.push(inMeta)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif (!isRecord(node)) continue\n\t\tconst keys = attempt(() => Object.keys(node))\n\t\tif (!keys.success) continue\n\n\t\tfor (const key of keys.value) {\n\t\t\tif (inMeta) {\n\t\t\t\tif (key.length > STRING_LIMIT) stringExceeded = true\n\t\t\t\ttext = Math.min(TEXT_LIMIT + 1, text + key.length)\n\t\t\t\tif (text > TEXT_LIMIT) textExceeded = true\n\t\t\t}\n\n\t\t\tconst value = attempt(() => node[key])\n\t\t\tif (!value.success || value.value === undefined) continue\n\t\t\tif (pending.length >= NODE_LIMIT) {\n\t\t\t\tnodeExceeded = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tpending.push(value.value)\n\t\t\tmetadata.push(inMeta || key === 'meta')\n\t\t}\n\t}\n\n\tif (stringExceeded) faults.push(`schema contains a string longer than ${STRING_LIMIT}`)\n\tif (textExceeded) faults.push(`schema retains more than ${TEXT_LIMIT} string code units`)\n\tif (nodeExceeded) faults.push(`schema retains more than ${NODE_LIMIT} nodes`)\n\n\tfor (let index = 0; index < columnCount; index += 1) {\n\t\tconst column = schema.columns[index]\n\t\tif (column === undefined) continue\n\t\tif (!nodeExceeded && column.meta !== undefined) {\n\t\t\tconst owned = attempt(() => cloneJSONRecord(column.meta))\n\t\t\tif (!owned.success) {\n\t\t\t\tfaults.push(`column \"${column.key}\" has metadata that cannot be owned`)\n\t\t\t}\n\t\t}\n\t\tif (column.key.length === 0) faults.push('column \"\" has an empty key')\n\t\tif (columns.has(column.key)) {\n\t\t\tfaults.push(`column \"${column.key}\" is declared more than once`)\n\t\t}\n\t\tcolumns.add(column.key)\n\n\t\tif (column.cell === 'choice') {\n\t\t\tconst choices = new Set<string>()\n\t\t\tconst choiceCount = Math.min(column.choices.length, CHOICE_LIMIT + 1)\n\t\t\tfor (let choiceIndex = 0; choiceIndex < choiceCount; choiceIndex += 1) {\n\t\t\t\tconst choice = column.choices[choiceIndex]\n\t\t\t\tif (choice === undefined) continue\n\t\t\t\tif (choices.has(choice.value)) {\n\t\t\t\t\tfaults.push(`column \"${column.key}\" offers choice \"${choice.value}\" more than once`)\n\t\t\t\t}\n\t\t\t\tchoices.add(choice.value)\n\t\t\t}\n\t\t\tif (column.choices.length === 0) {\n\t\t\t\tfaults.push(`column \"${column.key}\" offers no choices`)\n\t\t\t}\n\t\t}\n\t}\n\n\tconst key = extractColumn(schema, schema.key)\n\tif (key === undefined) {\n\t\tfaults.push(`schema key \"${schema.key}\" names no declared column`)\n\t} else if (key.cell === 'number' || key.cell === 'flag') {\n\t\tfaults.push(`schema key \"${schema.key}\" names a ${key.cell} column, which holds no identity`)\n\t}\n\n\treturn Object.freeze(faults)\n}\n\n/**\n * Project a schema into declaration-ordered JSON.\n *\n * @param schema - The schema to project.\n * @returns A deeply owned JSON record with absent members omitted.\n * @throws A {@link TableError} coded `SCHEMA` when metadata cannot be owned.\n */\nexport function serializeTable(schema: TableSchema): JSONRecord {\n\tconst output: Record<string, JSONValue> = {}\n\tif (schema.name !== undefined) output.name = schema.name\n\tif (schema.label !== undefined) output.label = schema.label\n\tif (schema.help !== undefined) output.help = schema.help\n\toutput.key = schema.key\n\toutput.columns = schema.columns.map((column): JSONRecord => {\n\t\tconst entry: Record<string, JSONValue> = { cell: column.cell, key: column.key }\n\t\tif (column.label !== undefined) entry.label = column.label\n\t\tif (column.help !== undefined) entry.help = column.help\n\t\tif (column.hidden !== undefined) entry.hidden = column.hidden\n\t\tif (column.meta !== undefined) entry.meta = column.meta\n\t\tif (column.cell === 'choice') {\n\t\t\tentry.choices = column.choices.map((choice): JSONRecord => {\n\t\t\t\tconst option: Record<string, JSONValue> = {\n\t\t\t\t\tvalue: choice.value,\n\t\t\t\t\tlabel: choice.label,\n\t\t\t\t}\n\t\t\t\tif (choice.help !== undefined) option.help = choice.help\n\t\t\t\treturn option\n\t\t\t})\n\t\t}\n\t\treturn entry\n\t})\n\n\ttry {\n\t\treturn cloneJSONRecord(output)\n\t} catch (error) {\n\t\tif (!isContractError(error)) throw error\n\t\tthrow new TableError('SCHEMA', 'schema contains metadata that cannot be owned')\n\t}\n}\n\n/**\n * Project rows into schema-column-ordered JSON.\n *\n * @param schema - The schema that fixes cell order.\n * @param rows - The rows to project.\n * @returns A frozen list of owned JSON records with absent cells omitted.\n */\nexport function serializeRows(\n\tschema: TableSchema,\n\trows: readonly TableRow[],\n): readonly JSONRecord[] {\n\tconst output: JSONRecord[] = []\n\n\tfor (const row of rows) {\n\t\tconst entry: Record<string, JSONPrimitive> = {}\n\t\tfor (const column of schema.columns) {\n\t\t\tif (!Object.hasOwn(row, column.key)) continue\n\t\t\tconst value = row[column.key]\n\t\t\tif (value === undefined) continue\n\t\t\tObject.defineProperty(entry, column.key, {\n\t\t\t\tvalue,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t})\n\t\t}\n\t\toutput.push(cloneJSONRecord(entry))\n\t}\n\n\treturn Object.freeze(output)\n}\n","import type {\n\tColumnCell,\n\tColumnChoice,\n\tTableCell,\n\tTableColumn,\n\tTableRow,\n\tTableSchema,\n} from './types.js'\nimport {\n\tarrayOf,\n\tattempt,\n\tcloneJSONRecord,\n\tisBoolean,\n\tisBoundedJSONRecord,\n\tisFiniteNumber,\n\tisRecord,\n\tisString,\n\trecordOf,\n\tunionOf,\n} from '@orkestrel/contract'\nimport { COLUMN_CELLS } from './constants.js'\nimport { auditTable } from './helpers.js'\n\n/**\n * Determine whether an unknown value has a table cell shape.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is a string, finite number, or boolean.\n */\nexport function isTableCell(input: unknown): input is TableCell {\n\treturn unionOf(isString, isFiniteNumber, isBoolean)(input)\n}\n\n/**\n * Determine whether an unknown value is a record of table cells.\n *\n * @param input - The value to inspect.\n * @returns Whether every own key is a string and every value is a table cell.\n */\nexport function isTableRow(input: unknown): input is TableRow {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(input)) return false\n\t\treturn Reflect.ownKeys(input).every(\n\t\t\t(key) => isString(key) && Object.hasOwn(input, key) && isTableCell(input[key]),\n\t\t)\n\t})\n\n\treturn outcome.success && outcome.value\n}\n\n/**\n * Determine whether an unknown value is a declared column cell.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is one of the four column cells.\n */\nexport function isColumnCell(input: unknown): input is ColumnCell {\n\treturn COLUMN_CELLS.some((cell) => cell === input)\n}\n\n/**\n * Determine whether an unknown value is one exact column choice record.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is a column choice.\n */\nexport function isColumnChoice(input: unknown): input is ColumnChoice {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(input) || !Reflect.ownKeys(input).every((key) => isString(key))) return false\n\t\treturn recordOf({ value: isString, label: isString, help: isString }, ['help'])(input)\n\t})\n\n\treturn outcome.success && outcome.value\n}\n\n/**\n * Determine whether an unknown value is one exact discriminated table column.\n *\n * @param input - The value to inspect.\n * @returns Whether the value is a structurally valid table column.\n */\nexport function isTableColumn(input: unknown): input is TableColumn {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(input) || !Object.hasOwn(input, 'cell') || !Object.hasOwn(input, 'key')) {\n\t\t\treturn false\n\t\t}\n\n\t\tconst cell = input.cell\n\t\tif (!isColumnCell(cell)) return false\n\n\t\tconst exact = Reflect.ownKeys(input).every((key) => {\n\t\t\tif (!isString(key)) return false\n\t\t\tif (['cell', 'key', 'label', 'help', 'hidden', 'meta'].includes(key)) return true\n\t\t\treturn cell === 'choice' && key === 'choices'\n\t\t})\n\t\tif (!exact) return false\n\n\t\tconst key = input.key\n\t\tconst hasLabel = Object.hasOwn(input, 'label')\n\t\tconst label = hasLabel ? input.label : undefined\n\t\tconst hasHelp = Object.hasOwn(input, 'help')\n\t\tconst help = hasHelp ? input.help : undefined\n\t\tconst hasHidden = Object.hasOwn(input, 'hidden')\n\t\tconst hidden = hasHidden ? input.hidden : undefined\n\t\tconst hasMeta = Object.hasOwn(input, 'meta')\n\t\tconst meta = hasMeta ? input.meta : undefined\n\t\tif (hasMeta) {\n\t\t\tif (!isBoundedJSONRecord(meta)) return false\n\t\t\tconst owned = attempt(() => cloneJSONRecord(meta))\n\t\t\tif (!owned.success) return false\n\t\t}\n\n\t\tif (\n\t\t\t!isString(key) ||\n\t\t\t(hasLabel && !isString(label)) ||\n\t\t\t(hasHelp && !isString(help)) ||\n\t\t\t(hasHidden && !isBoolean(hidden))\n\t\t) {\n\t\t\treturn false\n\t\t}\n\n\t\tif (cell !== 'choice') return !Object.hasOwn(input, 'choices')\n\t\treturn Object.hasOwn(input, 'choices') && arrayOf(isColumnChoice)(input.choices)\n\t})\n\n\treturn outcome.success && outcome.value\n}\n\n/**\n * Determine whether an unknown value has one exact structural table-schema shape.\n *\n * @param input - The value to inspect.\n * @returns Whether the value has the exact structure of a table schema.\n */\nexport function isStructuralTableSchema(input: unknown): input is TableSchema {\n\tconst outcome = attempt(() => {\n\t\tif (!isRecord(input) || !Reflect.ownKeys(input).every((key) => isString(key))) return false\n\t\treturn recordOf(\n\t\t\t{\n\t\t\t\tname: isString,\n\t\t\t\tlabel: isString,\n\t\t\t\thelp: isString,\n\t\t\t\tkey: isString,\n\t\t\t\tcolumns: arrayOf(isTableColumn),\n\t\t\t},\n\t\t\t['name', 'label', 'help'],\n\t\t)(input)\n\t})\n\n\treturn outcome.success && outcome.value\n}\n\n/**\n * Determine whether an unknown value is one semantically sound table schema.\n *\n * @param input - The value to inspect.\n * @returns Whether the value has valid structure, domain relationships, and budgets.\n */\nexport function isTableSchema(input: unknown): input is TableSchema {\n\tconst outcome = attempt(() => isStructuralTableSchema(input) && auditTable(input).length === 0)\n\treturn outcome.success && outcome.value\n}\n","import type { JSONRecord } from '@orkestrel/contract'\nimport type { TableRow, TableSchema } from './types.js'\nimport { cloneJSONRecord, isContractError } from '@orkestrel/contract'\nimport { TableError } from './errors.js'\n\n/**\n * Clone one row into an owned frozen snapshot.\n *\n * @param row - The row to own.\n * @returns A frozen copy of the row's cells.\n */\nexport function cloneRow(row: TableRow): TableRow {\n\treturn Object.freeze({ ...row })\n}\n\n/**\n * Clone a table schema into an owned frozen snapshot.\n *\n * @param schema - The schema to own.\n * @returns A frozen schema with every nested column, choice, list, and metadata record owned.\n */\nexport function cloneSchema(schema: TableSchema): TableSchema {\n\treturn Object.freeze({\n\t\t...schema,\n\t\tcolumns: Object.freeze(\n\t\t\tschema.columns.map((column) => {\n\t\t\t\tlet meta: { meta?: JSONRecord } = {}\n\n\t\t\t\tif (column.meta !== undefined) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmeta = { meta: cloneJSONRecord(column.meta) }\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!isContractError(error)) throw error\n\t\t\t\t\t\tthrow new TableError(\n\t\t\t\t\t\t\t'SCHEMA',\n\t\t\t\t\t\t\t`column \"${column.key}\" has metadata that cannot be owned`,\n\t\t\t\t\t\t\t{ column: column.key },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (column.cell === 'choice') {\n\t\t\t\t\treturn Object.freeze({\n\t\t\t\t\t\t...column,\n\t\t\t\t\t\t...meta,\n\t\t\t\t\t\tchoices: Object.freeze(column.choices.map((choice) => Object.freeze({ ...choice }))),\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\treturn Object.freeze({ ...column, ...meta })\n\t\t\t}),\n\t\t),\n\t})\n}\n","import type { TableCell, TableRow, TableSchema } from './types.js'\nimport {\n\tattempt,\n\tisArray,\n\tisRecord,\n\tisString,\n\tparseNumber,\n\treadArrayEntries,\n} from '@orkestrel/contract'\nimport { cloneRow } from './cloners.js'\nimport { STRING_LIMIT } from './constants.js'\nimport { extractColumn, extractKey, matchesCell, serializeTable } from './helpers.js'\nimport { isTableSchema } from './validators.js'\n\n/**\n * Parse unknown wire data into an owned, semantically sound table schema.\n *\n * @param input - The unknown schema value to parse.\n * @returns An owned table schema, or `undefined` on refusal.\n */\nexport function parseTable(input: unknown): TableSchema | undefined {\n\tconst outcome = attempt(() => {\n\t\tif (!isTableSchema(input)) return undefined\n\t\tconst projected = serializeTable(input)\n\t\treturn isTableSchema(projected) ? projected : undefined\n\t})\n\n\treturn outcome.success ? outcome.value : undefined\n}\n\n/**\n * Parse unknown wire rows against one table schema.\n *\n * @param schema - The schema that declares the accepted keys and cell shapes.\n * @param input - The unknown row-list value to parse.\n * @returns Frozen owned rows, or `undefined` when any row is refused.\n */\nexport function parseRows(schema: TableSchema, input: unknown): readonly TableRow[] | undefined {\n\tconst outcome = attempt(() => {\n\t\tif (!isTableSchema(schema) || !isArray(input)) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst read = readArrayEntries(input)\n\t\tif (!read.success || !read.value.dense) return undefined\n\n\t\tconst keys = new Set<string>()\n\t\tconst rows: TableRow[] = []\n\n\t\tfor (const candidate of read.value.entries) {\n\t\t\tif (!isRecord(candidate)) return undefined\n\t\t\tconst row: Record<string, TableCell> = {}\n\n\t\t\tfor (const key of Reflect.ownKeys(candidate)) {\n\t\t\t\tif (!isString(key) || !Object.hasOwn(candidate, key)) return undefined\n\t\t\t\tconst column = extractColumn(schema, key)\n\t\t\t\tif (column === undefined) return undefined\n\t\t\t\tconst inputCell = candidate[key]\n\t\t\t\tlet cell: unknown = inputCell\n\n\t\t\t\tif (column.cell === 'number' && isString(inputCell)) {\n\t\t\t\t\tif (inputCell.length > STRING_LIMIT) return undefined\n\t\t\t\t\tcell = parseNumber(inputCell)\n\t\t\t\t} else if (column.cell === 'flag' && inputCell === 'true') {\n\t\t\t\t\tcell = true\n\t\t\t\t} else if (column.cell === 'flag' && inputCell === 'false') {\n\t\t\t\t\tcell = false\n\t\t\t\t}\n\n\t\t\t\tif (!matchesCell(column, cell)) return undefined\n\t\t\t\tObject.defineProperty(row, key, {\n\t\t\t\t\tvalue: cell,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tconst owned = cloneRow(row)\n\t\t\tconst key = extractKey(schema, owned)\n\t\t\tif (key === undefined || keys.has(key)) return undefined\n\t\t\tkeys.add(key)\n\t\t\trows.push(owned)\n\t\t}\n\n\t\treturn Object.freeze(rows)\n\t})\n\n\treturn outcome.success ? outcome.value : undefined\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { ExpansionManagerInterface, TableEventMap, TableKey } from '../types.js'\nimport { computeKeys } from '../helpers.js'\n\n/** The keys of the rows somebody has opened. */\nexport class ExpansionManager implements ExpansionManagerInterface {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #rows: () => readonly TableKey[]\n\treadonly #read: () => ReadonlySet<TableKey>\n\treadonly #write: (keys: ReadonlySet<TableKey>) => void\n\n\t/**\n\t * Create an expansion manager over one table's private stores.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param rows - A read of every row key.\n\t * @param read - A read of the expanded keys.\n\t * @param write - The expanded-key commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\trows: () => readonly TableKey[],\n\t\tread: () => ReadonlySet<TableKey>,\n\t\twrite: (keys: ReadonlySet<TableKey>) => void,\n\t) {\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#rows = rows\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t}\n\n\t/** The keys of the rows opened right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn new Set(this.#read())\n\t}\n\n\t/** Open every row the table holds. */\n\texpand(): void\n\t/** Open one row. */\n\texpand(key: TableKey): boolean\n\t/** Open several rows. */\n\texpand(keys: readonly TableKey[]): boolean\n\t/** Open one or more rows. */\n\texpand(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, () => true)\n\t}\n\n\t/** Close every row. */\n\tclear(): void\n\t/** Close one row. */\n\tclear(key: TableKey): boolean\n\t/** Close several rows. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Close one or more rows. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, () => false)\n\t}\n\n\t/** Open one row or close it when already open. */\n\ttoggle(key: TableKey): boolean\n\t/** Turn several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turn one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, (included) => !included) === true\n\t}\n\n\t#change(\n\t\tinput: TableKey | readonly TableKey[] | undefined,\n\t\tinclude: (included: boolean) => boolean,\n\t): void | boolean {\n\t\tconst previous = this.#read()\n\t\tconst next = computeKeys(this.#rows(), previous, input, include)\n\t\tif (next === undefined) return false\n\t\tif (next !== previous) {\n\t\t\tthis.#write(next)\n\t\t\tthis.#emitter.emit('expand', new Set(next))\n\t\t}\n\n\t\treturn input === undefined ? undefined : true\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { FilterManagerInterface, TableEventMap, TableFilter, TableSchema } from '../types.js'\nimport { TableError } from '../errors.js'\nimport { admitsFilter, extractColumn } from '../helpers.js'\n\n/** The filters one table applies with and-only composition. */\nexport class FilterManager implements FilterManagerInterface {\n\treadonly #schema: TableSchema\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #read: () => readonly TableFilter[]\n\treadonly #write: (filters: readonly TableFilter[]) => void\n\treadonly #clamp: () => number | undefined\n\n\t/**\n\t * Create a filter manager over one table's private filter store.\n\t *\n\t * @param schema - The table schema.\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param read - A read of the current filters.\n\t * @param write - The filter commit boundary.\n\t * @param clamp - The pagination clamp commit after a filter commit.\n\t */\n\tconstructor(\n\t\tschema: TableSchema,\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\tread: () => readonly TableFilter[],\n\t\twrite: (filters: readonly TableFilter[]) => void,\n\t\tclamp: () => number | undefined,\n\t) {\n\t\tthis.#schema = schema\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t\tthis.#clamp = clamp\n\t}\n\n\t/** Find one column's filter. */\n\tfilter(column: string): TableFilter | undefined {\n\t\tconst filter = this.#read().find((candidate) => candidate.column === column)\n\t\treturn filter === undefined ? undefined : Object.freeze({ ...filter })\n\t}\n\n\t/** Read every filter as an owned frozen snapshot. */\n\tfilters(): readonly TableFilter[] {\n\t\treturn Object.freeze(this.#read().map((filter) => Object.freeze({ ...filter })))\n\t}\n\n\t/** Filter several columns. */\n\tset(filters: readonly TableFilter[]): void\n\t/** Filter one column. */\n\tset(filter: TableFilter): void\n\t/** Filter one column or several. */\n\tset(input: TableFilter | readonly TableFilter[]): void {\n\t\tthis.#gate()\n\t\tconst requested = Array.isArray(input) ? input : [input]\n\t\tfor (const filter of requested) this.#validate(filter)\n\n\t\tconst next = [...this.#read()]\n\t\tfor (const filter of requested) {\n\t\t\tconst owned = Object.freeze({ ...filter })\n\t\t\tconst index = next.findIndex((candidate) => candidate.column === filter.column)\n\t\t\tif (index === -1) next.push(owned)\n\t\t\telse next[index] = owned\n\t\t}\n\n\t\tif (this.#same(next, this.#read())) return\n\t\tthis.#write(Object.freeze(next))\n\t\tconst page = this.#clamp()\n\t\tthis.#emitter.emit('filter', this.filters())\n\t\tif (page !== undefined) this.#emitter.emit('paginate', page)\n\t}\n\n\t/** Stop filtering by every column. */\n\tremove(): void\n\t/** Stop filtering by one column. */\n\tremove(column: string): boolean\n\t/** Stop filtering by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stop filtering by one or more columns. */\n\tremove(input?: string | readonly string[]): void | boolean {\n\t\tthis.#gate()\n\t\tconst columns =\n\t\t\tinput === undefined\n\t\t\t\t? this.#schema.columns.map((column) => column.key)\n\t\t\t\t: Array.isArray(input)\n\t\t\t\t\t? input\n\t\t\t\t\t: [input]\n\t\tfor (const column of columns) {\n\t\t\tif (extractColumn(this.#schema, column) === undefined) return false\n\t\t}\n\n\t\tconst removed = new Set(columns)\n\t\tconst next = this.#read().filter((filter) => !removed.has(filter.column))\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(Object.freeze(next))\n\t\t\tconst page = this.#clamp()\n\t\t\tthis.#emitter.emit('filter', this.filters())\n\t\t\tif (page !== undefined) this.#emitter.emit('paginate', page)\n\t\t}\n\n\t\treturn input === undefined ? undefined : true\n\t}\n\n\t#validate(filter: TableFilter): void {\n\t\tconst column = extractColumn(this.#schema, filter.column)\n\t\tif (column === undefined) {\n\t\t\tthrow new TableError('COLUMN', `The schema declares no column named \"${filter.column}\"`, {\n\t\t\t\tcolumn: filter.column,\n\t\t\t})\n\t\t}\n\n\t\tif (!admitsFilter(column, filter)) {\n\t\t\tthrow new TableError('CELL', `Column \"${filter.column}\" cannot apply that filter`, {\n\t\t\t\tcolumn: filter.column,\n\t\t\t})\n\t\t}\n\t}\n\n\t#same(left: readonly TableFilter[], right: readonly TableFilter[]): boolean {\n\t\treturn (\n\t\t\tleft.length === right.length &&\n\t\t\tleft.every((filter, index) => {\n\t\t\t\tconst other = right[index]\n\t\t\t\tif (\n\t\t\t\t\tother === undefined ||\n\t\t\t\t\tfilter.column !== other.column ||\n\t\t\t\t\tfilter.operator !== other.operator\n\t\t\t\t) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tif (filter.operator === 'contains' && other.operator === 'contains')\n\t\t\t\t\treturn filter.text === other.text\n\t\t\t\tif (filter.operator === 'between' && other.operator === 'between') {\n\t\t\t\t\treturn filter.minimum === other.minimum && filter.maximum === other.maximum\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\tfilter.operator === 'equals' &&\n\t\t\t\t\tother.operator === 'equals' &&\n\t\t\t\t\tfilter.value === other.value\n\t\t\t\t)\n\t\t\t})\n\t\t)\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { PaginationManagerInterface, TableEventMap } from '../types.js'\n\n/** The page arithmetic over one table's filtered rows. */\nexport class PaginationManager implements PaginationManagerInterface {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #rows: () => number\n\treadonly #readPage: () => number\n\treadonly #writePage: (page: number) => void\n\treadonly #readLimit: () => number | undefined\n\treadonly #writeLimit: (limit: number | undefined) => void\n\n\t/**\n\t * Create a pagination manager over one table's private stores.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param rows - A read of the filtered row count.\n\t * @param readPage - A read of the current page.\n\t * @param writePage - The page commit boundary.\n\t * @param readLimit - A read of the current page size.\n\t * @param writeLimit - The page-size commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\trows: () => number,\n\t\treadPage: () => number,\n\t\twritePage: (page: number) => void,\n\t\treadLimit: () => number | undefined,\n\t\twriteLimit: (limit: number | undefined) => void,\n\t) {\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#rows = rows\n\t\tthis.#readPage = readPage\n\t\tthis.#writePage = writePage\n\t\tthis.#readLimit = readLimit\n\t\tthis.#writeLimit = writeLimit\n\n\t\tconst limit = this.#readLimit()\n\t\tif (limit !== undefined) this.#writeLimit(this.#normalize(limit))\n\t}\n\n\t/** The page shown, counted from one. */\n\tget page(): number {\n\t\treturn this.#readLimit() === undefined ? 1 : this.#readPage()\n\t}\n\n\t/** The number of rows one page holds. */\n\tget limit(): number | undefined {\n\t\treturn this.#readLimit()\n\t}\n\n\t/** The number of filtered rows skipped before this page. */\n\tget offset(): number {\n\t\tconst limit = this.#readLimit()\n\t\treturn limit === undefined ? 0 : (this.#readPage() - 1) * limit\n\t}\n\n\t/** The number of pages filled by the filtered rows. */\n\tget count(): number {\n\t\tconst limit = this.#readLimit()\n\t\treturn limit === undefined ? 1 : Math.max(1, Math.ceil(this.#rows() / limit))\n\t}\n\n\t/** Show another page, clamped to the pages that exist. */\n\tmove(page: number): void {\n\t\tthis.#gate()\n\t\tconst next = this.#readLimit() === undefined ? 1 : Math.min(this.count, this.#normalize(page))\n\t\tif (next === this.#readPage()) return\n\t\tthis.#writePage(next)\n\t\tthis.#emitter.emit('paginate', next)\n\t}\n\n\t/** Change the page size while keeping the first row previously shown. */\n\tresize(limit?: number): void {\n\t\tthis.#gate()\n\t\tconst previous = this.#readLimit()\n\t\tconst nextLimit = limit === undefined ? undefined : this.#normalize(limit)\n\t\tif (previous === nextLimit) return\n\n\t\tconst anchor = previous === undefined ? 0 : (this.#readPage() - 1) * previous\n\t\tthis.#writeLimit(nextLimit)\n\t\tconst nextPage =\n\t\t\tnextLimit === undefined\n\t\t\t\t? 1\n\t\t\t\t: Math.min(Math.max(1, Math.floor(anchor / nextLimit) + 1), this.count)\n\t\tthis.#writePage(nextPage)\n\t\tthis.#emitter.emit('paginate', nextPage)\n\t}\n\n\t#normalize(value: number): number {\n\t\treturn Number.isFinite(value) ? Math.max(1, Math.trunc(value)) : 1\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type {\n\tRowManagerInterface,\n\tTableEventMap,\n\tTableKey,\n\tTableRow,\n\tTableSchema,\n} from '../types.js'\nimport { cloneRow } from '../cloners.js'\nimport { TableError } from '../errors.js'\nimport { extractColumn, extractKey, matchesCell } from '../helpers.js'\nimport { isTableRow } from '../validators.js'\n\n/** The rows one table holds in its own order. */\nexport class RowManager implements RowManagerInterface {\n\treadonly #schema: TableSchema\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #read: () => readonly TableRow[]\n\treadonly #write: (rows: readonly TableRow[]) => void\n\treadonly #settle: (removed: readonly TableKey[], announce: () => void) => void\n\n\t/**\n\t * Create a row manager over one table's private row store.\n\t *\n\t * @param schema - The table schema.\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param read - A read of the current rows.\n\t * @param write - The row commit boundary.\n\t * @param settle - Commit dependent state, then order row and dependent announcements.\n\t * @param rows - Rows to seed without announcements.\n\t */\n\tconstructor(\n\t\tschema: TableSchema,\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\tread: () => readonly TableRow[],\n\t\twrite: (rows: readonly TableRow[]) => void,\n\t\tsettle: (removed: readonly TableKey[], announce: () => void) => void,\n\t\trows: readonly TableRow[] = [],\n\t) {\n\t\tthis.#schema = schema\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t\tthis.#settle = settle\n\n\t\tconst seeded = this.#prepare(rows, new Set())\n\t\tif (seeded.length > 0) this.#write(Object.freeze(seeded))\n\t}\n\n\t/** Find one row by key as an owned frozen snapshot. */\n\trow(key: TableKey): TableRow | undefined {\n\t\tconst row = this.#read().find((candidate) => extractKey(this.#schema, candidate) === key)\n\t\treturn row === undefined ? undefined : cloneRow(row)\n\t}\n\n\t/** Read every row as owned frozen snapshots in table order. */\n\trows(): readonly TableRow[] {\n\t\treturn Object.freeze(this.#read().map((row) => cloneRow(row)))\n\t}\n\n\t/** Append several rows. */\n\tadd(rows: readonly TableRow[]): void\n\t/** Append one row. */\n\tadd(row: TableRow): void\n\t/** Append one row or several. */\n\tadd(input: TableRow | readonly TableRow[]): void {\n\t\tthis.#gate()\n\t\tconst rows = Array.isArray(input) ? input : [input]\n\t\tconst keys = new Set<TableKey>()\n\t\tfor (const row of this.#read()) {\n\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\tif (key !== undefined) keys.add(key)\n\t\t}\n\t\tconst added = this.#prepare(rows, keys)\n\t\tif (added.length === 0) return\n\n\t\tthis.#write(Object.freeze([...this.#read(), ...added]))\n\t\tthis.#settle([], () => {\n\t\t\tfor (const row of added) {\n\t\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\t\tif (key !== undefined) this.#emitter.emit('write', key)\n\t\t\t}\n\t\t})\n\t}\n\n\t/** Merge several rows into the rows their keys name. */\n\tupdate(rows: readonly TableRow[]): boolean\n\t/** Merge one row into the row its key names. */\n\tupdate(row: TableRow): boolean\n\t/** Merge one row or several into the rows their keys name. */\n\tupdate(input: TableRow | readonly TableRow[]): boolean {\n\t\tthis.#gate()\n\t\tconst updates = (Array.isArray(input) ? input : [input]).map((row) => cloneRow(row))\n\t\tconst current = this.#read()\n\t\tconst locations: number[] = []\n\n\t\tfor (const update of updates) {\n\t\t\tthis.#validate(update)\n\t\t\tconst key = extractKey(this.#schema, update)\n\t\t\tif (key === undefined) this.#failKey('A row has no usable identity')\n\t\t\tconst index = current.findIndex((row) => extractKey(this.#schema, row) === key)\n\t\t\tif (index === -1) return false\n\t\t\tlocations.push(index)\n\t\t}\n\n\t\tconst next = [...current]\n\t\tconst moved: TableKey[] = []\n\t\tfor (let index = 0; index < updates.length; index += 1) {\n\t\t\tconst update = updates[index]\n\t\t\tconst location = locations[index]\n\t\t\tif (update === undefined || location === undefined) continue\n\t\t\tconst previous = next[location]\n\t\t\tif (previous === undefined) continue\n\t\t\tconst merged = cloneRow({ ...previous, ...update })\n\t\t\tif (!this.#same(previous, merged)) {\n\t\t\t\tnext[location] = merged\n\t\t\t\tconst key = extractKey(this.#schema, merged)\n\t\t\t\tif (key !== undefined) moved.push(key)\n\t\t\t}\n\t\t}\n\n\t\tif (moved.length === 0) return true\n\t\tthis.#write(Object.freeze(next))\n\t\tthis.#settle([], () => {\n\t\t\tfor (const key of moved) this.#emitter.emit('write', key)\n\t\t})\n\t\treturn true\n\t}\n\n\t/** Move one row to a clamped index in table order. */\n\tmove(key: TableKey, index: number): boolean {\n\t\tthis.#gate()\n\t\tconst current = this.#read()\n\t\tconst origin = current.findIndex((row) => extractKey(this.#schema, row) === key)\n\t\tif (origin === -1) return false\n\t\tconst target = Math.min(\n\t\t\tcurrent.length - 1,\n\t\t\tNumber.isFinite(index) ? Math.max(0, Math.trunc(index)) : 0,\n\t\t)\n\t\tif (origin === target) return true\n\n\t\tconst row = current[origin]\n\t\tif (row === undefined) return false\n\t\tconst next = [...current]\n\t\tnext.splice(origin, 1)\n\t\tnext.splice(target, 0, row)\n\t\tthis.#write(Object.freeze(next))\n\t\tthis.#settle([], () => this.#emitter.emit('write', key))\n\t\treturn true\n\t}\n\n\t/** Remove every row. */\n\tremove(): void\n\t/** Remove one row. */\n\tremove(key: TableKey): boolean\n\t/** Remove several rows. */\n\tremove(keys: readonly TableKey[]): boolean\n\t/** Remove one or more rows. */\n\tremove(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\tconst current = this.#read()\n\t\tconst requested =\n\t\t\tinput === undefined\n\t\t\t\t? current.flatMap((row) => {\n\t\t\t\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\t\t\t\treturn key === undefined ? [] : [key]\n\t\t\t\t\t})\n\t\t\t\t: Array.isArray(input)\n\t\t\t\t\t? input\n\t\t\t\t\t: [input]\n\t\tconst keys = new Set(requested)\n\t\tconst known = new Set(\n\t\t\tcurrent.flatMap((row) => {\n\t\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\t\treturn key === undefined ? [] : [key]\n\t\t\t}),\n\t\t)\n\t\tif ([...keys].some((key) => !known.has(key))) return false\n\t\tif (keys.size === 0) return input === undefined ? undefined : true\n\n\t\tconst removed = current.flatMap((row) => {\n\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\treturn key !== undefined && keys.has(key) ? [key] : []\n\t\t})\n\t\tthis.#write(\n\t\t\tObject.freeze(\n\t\t\t\tcurrent.filter((row) => {\n\t\t\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\t\t\treturn key === undefined || !keys.has(key)\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t\tthis.#settle(removed, () => {\n\t\t\tfor (const key of removed) this.#emitter.emit('remove', key)\n\t\t})\n\t\treturn input === undefined ? undefined : true\n\t}\n\n\t#prepare(rows: readonly TableRow[], existing: Set<TableKey>): readonly TableRow[] {\n\t\tconst owned: TableRow[] = []\n\t\tfor (const row of rows) {\n\t\t\tconst snapshot = cloneRow(row)\n\t\t\tthis.#validate(snapshot)\n\t\t\tconst key = extractKey(this.#schema, snapshot)\n\t\t\tif (key === undefined) this.#failKey('A row has no usable identity')\n\t\t\tif (existing.has(key)) this.#failKey(`Row key \"${key}\" is already taken`, key)\n\t\t\texisting.add(key)\n\t\t\towned.push(snapshot)\n\t\t}\n\t\treturn owned\n\t}\n\n\t#validate(row: TableRow): void {\n\t\tif (extractKey(this.#schema, row) === undefined) this.#failKey('A row has no usable identity')\n\t\tif (!isTableRow(row)) {\n\t\t\tthrow new TableError('CELL', 'A row contains a value no table cell can hold')\n\t\t}\n\t\tfor (const key of Object.keys(row)) {\n\t\t\tconst column = extractColumn(this.#schema, key)\n\t\t\tif (column === undefined || !matchesCell(column, row[key])) {\n\t\t\t\tthrow new TableError('CELL', `Column \"${key}\" cannot hold that cell`, { column: key })\n\t\t\t}\n\t\t}\n\t}\n\n\t#failKey(message: string, key?: TableKey): never {\n\t\tif (key === undefined) throw new TableError('KEY', message)\n\t\tthrow new TableError('KEY', message, { key })\n\t}\n\n\t#same(left: TableRow, right: TableRow): boolean {\n\t\tconst leftKeys = Object.keys(left)\n\t\tconst rightKeys = Object.keys(right)\n\t\treturn (\n\t\t\tleftKeys.length === rightKeys.length &&\n\t\t\tleftKeys.every((key) => Object.hasOwn(right, key) && left[key] === right[key])\n\t\t)\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { SelectionManagerInterface, TableEventMap, TableKey } from '../types.js'\nimport { computeKeys } from '../helpers.js'\n\n/** The keys of the rows somebody has picked. */\nexport class SelectionManager implements SelectionManagerInterface {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #rows: () => readonly TableKey[]\n\treadonly #read: () => ReadonlySet<TableKey>\n\treadonly #write: (keys: ReadonlySet<TableKey>) => void\n\n\t/**\n\t * Create a selection manager over one table's private stores.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param rows - A read of every row key.\n\t * @param read - A read of the selected keys.\n\t * @param write - The selected-key commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\trows: () => readonly TableKey[],\n\t\tread: () => ReadonlySet<TableKey>,\n\t\twrite: (keys: ReadonlySet<TableKey>) => void,\n\t) {\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#rows = rows\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t}\n\n\t/** The keys of the rows picked right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn new Set(this.#read())\n\t}\n\n\t/** Pick every row the table holds. */\n\tselect(): void\n\t/** Pick one row. */\n\tselect(key: TableKey): boolean\n\t/** Pick several rows. */\n\tselect(keys: readonly TableKey[]): boolean\n\t/** Pick one or more rows. */\n\tselect(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, () => true)\n\t}\n\n\t/** Drop every pick. */\n\tclear(): void\n\t/** Drop one pick. */\n\tclear(key: TableKey): boolean\n\t/** Drop several picks. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Drop one or more picks. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, () => false)\n\t}\n\n\t/** Pick one row or drop it when already picked. */\n\ttoggle(key: TableKey): boolean\n\t/** Turn several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turn one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\tthis.#gate()\n\t\treturn this.#change(input, (included) => !included) === true\n\t}\n\n\t#change(\n\t\tinput: TableKey | readonly TableKey[] | undefined,\n\t\tinclude: (included: boolean) => boolean,\n\t): void | boolean {\n\t\tconst previous = this.#read()\n\t\tconst next = computeKeys(this.#rows(), previous, input, include)\n\t\tif (next === undefined) return false\n\t\tif (next !== previous) {\n\t\t\tthis.#write(next)\n\t\t\tthis.#emitter.emit('select', new Set(next))\n\t\t}\n\n\t\treturn input === undefined ? undefined : true\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { SortManagerInterface, TableEventMap, TableOrder, TableSchema } from '../types.js'\nimport { TableError } from '../errors.js'\nimport { extractColumn } from '../helpers.js'\n\n/** The ordered sort terms of one table. */\nexport class SortManager implements SortManagerInterface {\n\treadonly #schema: TableSchema\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #gate: () => void\n\treadonly #read: () => readonly TableOrder[]\n\treadonly #write: (orders: readonly TableOrder[]) => void\n\n\t/**\n\t * Create a sort manager over one table's private term store.\n\t *\n\t * @param schema - The table schema.\n\t * @param emitter - The table's event emitter.\n\t * @param gate - The table lifecycle gate.\n\t * @param read - A read of the current terms.\n\t * @param write - The term commit boundary.\n\t */\n\tconstructor(\n\t\tschema: TableSchema,\n\t\temitter: Emitter<TableEventMap>,\n\t\tgate: () => void,\n\t\tread: () => readonly TableOrder[],\n\t\twrite: (orders: readonly TableOrder[]) => void,\n\t) {\n\t\tthis.#schema = schema\n\t\tthis.#emitter = emitter\n\t\tthis.#gate = gate\n\t\tthis.#read = read\n\t\tthis.#write = write\n\t}\n\n\t/** Find one column's sort term. */\n\torder(column: string): TableOrder | undefined {\n\t\tconst order = this.#read().find((candidate) => candidate.column === column)\n\t\treturn order === undefined ? undefined : Object.freeze({ ...order })\n\t}\n\n\t/** Read every sort term as an owned frozen snapshot. */\n\torders(): readonly TableOrder[] {\n\t\treturn Object.freeze(this.#read().map((order) => Object.freeze({ ...order })))\n\t}\n\n\t/** Sort by several columns. */\n\tset(orders: readonly TableOrder[]): void\n\t/** Sort by one column. */\n\tset(order: TableOrder): void\n\t/** Sort by one column or several. */\n\tset(input: TableOrder | readonly TableOrder[]): void {\n\t\tthis.#gate()\n\t\tconst requested = Array.isArray(input) ? input : [input]\n\t\tfor (const order of requested) this.#require(order.column)\n\n\t\tconst next = [...this.#read()]\n\t\tfor (const order of requested) {\n\t\t\tconst owned = Object.freeze({ ...order })\n\t\t\tconst index = next.findIndex((candidate) => candidate.column === order.column)\n\t\t\tif (index === -1) next.push(owned)\n\t\t\telse next[index] = owned\n\t\t}\n\n\t\tif (this.#same(next, this.#read())) return\n\t\tconst committed = Object.freeze(next)\n\t\tthis.#write(committed)\n\t\tthis.#emitter.emit('sort', this.orders())\n\t}\n\n\t/** Stop sorting by every column. */\n\tremove(): void\n\t/** Stop sorting by one column. */\n\tremove(column: string): boolean\n\t/** Stop sorting by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stop sorting by one or more columns. */\n\tremove(input?: string | readonly string[]): void | boolean {\n\t\tthis.#gate()\n\t\tconst columns =\n\t\t\tinput === undefined\n\t\t\t\t? this.#schema.columns.map((column) => column.key)\n\t\t\t\t: Array.isArray(input)\n\t\t\t\t\t? input\n\t\t\t\t\t: [input]\n\t\tfor (const column of columns) {\n\t\t\tif (extractColumn(this.#schema, column) === undefined) return false\n\t\t}\n\n\t\tconst removed = new Set(columns)\n\t\tconst next = this.#read().filter((order) => !removed.has(order.column))\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(Object.freeze(next))\n\t\t\tthis.#emitter.emit('sort', this.orders())\n\t\t}\n\n\t\treturn input === undefined ? undefined : true\n\t}\n\n\t#require(column: string): void {\n\t\tif (extractColumn(this.#schema, column) === undefined) {\n\t\t\tthrow new TableError('COLUMN', `The schema declares no column named \"${column}\"`, { column })\n\t\t}\n\t}\n\n\t#same(left: readonly TableOrder[], right: readonly TableOrder[]): boolean {\n\t\treturn (\n\t\t\tleft.length === right.length &&\n\t\t\tleft.every((order, index) => {\n\t\t\t\tconst other = right[index]\n\t\t\t\treturn (\n\t\t\t\t\tother !== undefined &&\n\t\t\t\t\torder.column === other.column &&\n\t\t\t\t\torder.direction === other.direction\n\t\t\t\t)\n\t\t\t})\n\t\t)\n\t}\n}\n","import type { EmitterInterface } from '@orkestrel/emitter'\nimport type {\n\tCellComparator,\n\tCellMatcher,\n\tExpansionManagerInterface,\n\tFilterManagerInterface,\n\tPaginationManagerInterface,\n\tRowManagerInterface,\n\tSelectionManagerInterface,\n\tSortManagerInterface,\n\tTableEventMap,\n\tTableFilter,\n\tTableInterface,\n\tTableKey,\n\tTableOptions,\n\tTableOrder,\n\tTableRow,\n\tTableSchema,\n} from './types.js'\nimport { Emitter } from '@orkestrel/emitter'\nimport { cloneRow, cloneSchema } from './cloners.js'\nimport { TableError } from './errors.js'\nimport { auditTable, extractKey, filterRows, sortRows } from './helpers.js'\nimport { ExpansionManager } from './tables/ExpansionManager.js'\nimport { FilterManager } from './tables/FilterManager.js'\nimport { PaginationManager } from './tables/PaginationManager.js'\nimport { RowManager } from './tables/RowManager.js'\nimport { SelectionManager } from './tables/SelectionManager.js'\nimport { SortManager } from './tables/SortManager.js'\nimport { isStructuralTableSchema } from './validators.js'\n\n/** A schema, its rows, and the lens through which they are read. */\nexport class Table implements TableInterface {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #schema: TableSchema\n\treadonly #comparators: Readonly<Record<string, CellComparator>> | undefined\n\treadonly #matchers: Readonly<Record<string, CellMatcher>> | undefined\n\treadonly #initialLimit: number | undefined\n\t#rowStore: readonly TableRow[] = Object.freeze([])\n\t#orderStore: readonly TableOrder[] = Object.freeze([])\n\t#filterStore: readonly TableFilter[] = Object.freeze([])\n\t#selected: ReadonlySet<TableKey> = new Set()\n\t#expanded: ReadonlySet<TableKey> = new Set()\n\t#page = 1\n\t#limit: number | undefined\n\t#destroyed = false\n\treadonly #rows: RowManager\n\treadonly #sort: SortManager\n\treadonly #filter: FilterManager\n\treadonly #selection: SelectionManager\n\treadonly #expansion: ExpansionManager\n\treadonly #pagination: PaginationManager\n\n\t/**\n\t * Open a table against a schema.\n\t *\n\t * @param schema - The table declaration to own.\n\t * @param options - Initial rows, lens overrides, pagination, and emitter wiring.\n\t * @throws A {@link TableError} coded `SCHEMA` when the schema is unusable, `KEY` when a seeded\n\t * identity is unusable or repeated, and `CELL` when a seeded cell is invalid.\n\t */\n\tconstructor(schema: TableSchema, options?: TableOptions) {\n\t\tconst problems = isStructuralTableSchema(schema)\n\t\t\t? auditTable(schema)\n\t\t\t: ['The schema is not a table schema']\n\t\tif (problems.length > 0) {\n\t\t\tthrow new TableError('SCHEMA', `The table schema is unusable: ${problems.join('; ')}`, {\n\t\t\t\tproblems: [...problems],\n\t\t\t})\n\t\t}\n\n\t\tthis.#schema = cloneSchema(schema)\n\t\tthis.#comparators =\n\t\t\toptions?.comparators === undefined ? undefined : Object.freeze({ ...options.comparators })\n\t\tthis.#matchers =\n\t\t\toptions?.matchers === undefined ? undefined : Object.freeze({ ...options.matchers })\n\t\tthis.#limit = options?.limit\n\t\tthis.#emitter = new Emitter<TableEventMap>({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\n\t\tthis.#selection = new SelectionManager(\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#keys(),\n\t\t\t() => this.#selected,\n\t\t\t(keys) => {\n\t\t\t\tthis.#selected = keys\n\t\t\t},\n\t\t)\n\t\tthis.#expansion = new ExpansionManager(\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#keys(),\n\t\t\t() => this.#expanded,\n\t\t\t(keys) => {\n\t\t\t\tthis.#expanded = keys\n\t\t\t},\n\t\t)\n\t\tthis.#pagination = new PaginationManager(\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.count,\n\t\t\t() => this.#page,\n\t\t\t(page) => {\n\t\t\t\tthis.#page = page\n\t\t\t},\n\t\t\t() => this.#limit,\n\t\t\t(limit) => {\n\t\t\t\tthis.#limit = limit\n\t\t\t},\n\t\t)\n\t\tthis.#initialLimit = this.#limit\n\t\tthis.#sort = new SortManager(\n\t\t\tthis.#schema,\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#orderStore,\n\t\t\t(orders) => {\n\t\t\t\tthis.#orderStore = orders\n\t\t\t},\n\t\t)\n\t\tthis.#filter = new FilterManager(\n\t\t\tthis.#schema,\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#filterStore,\n\t\t\t(filters) => {\n\t\t\t\tthis.#filterStore = filters\n\t\t\t},\n\t\t\t() => this.#clamp(),\n\t\t)\n\t\tthis.#rows = new RowManager(\n\t\t\tthis.#schema,\n\t\t\tthis.#emitter,\n\t\t\t() => this.#gate(),\n\t\t\t() => this.#rowStore,\n\t\t\t(rows) => {\n\t\t\t\tthis.#rowStore = rows\n\t\t\t},\n\t\t\t(removed, announce) => this.#settle(removed, announce),\n\t\t\toptions?.rows,\n\t\t)\n\t}\n\n\t/** The table's event emitter. */\n\tget emitter(): EmitterInterface<TableEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\t/** The owned frozen schema. */\n\tget schema(): TableSchema {\n\t\treturn this.#schema\n\t}\n\n\t/** The rows the table holds. */\n\tget rows(): RowManagerInterface {\n\t\treturn this.#rows\n\t}\n\n\t/** The ordered sort terms. */\n\tget sort(): SortManagerInterface {\n\t\treturn this.#sort\n\t}\n\n\t/** The filters applied with and-only composition. */\n\tget filter(): FilterManagerInterface {\n\t\treturn this.#filter\n\t}\n\n\t/** The selected row keys. */\n\tget selection(): SelectionManagerInterface {\n\t\treturn this.#selection\n\t}\n\n\t/** The expanded row keys. */\n\tget expansion(): ExpansionManagerInterface {\n\t\treturn this.#expansion\n\t}\n\n\t/** The page arithmetic. */\n\tget pagination(): PaginationManagerInterface {\n\t\treturn this.#pagination\n\t}\n\n\t/** The filtered, sorted, and paged rows as owned frozen snapshots. */\n\tget view(): readonly TableRow[] {\n\t\tconst ordered = sortRows(this.#schema, this.#filtered(), this.#orderStore, this.#comparators)\n\t\tconst limit = this.#limit\n\t\tconst page =\n\t\t\tlimit === undefined\n\t\t\t\t? ordered\n\t\t\t\t: ordered.slice(this.#pagination.offset, this.#pagination.offset + limit)\n\t\treturn Object.freeze(page.map((row) => cloneRow(row)))\n\t}\n\n\t/** The number of rows admitted by the filters. */\n\tget count(): number {\n\t\treturn this.#filtered().length\n\t}\n\n\t/** Whether the table has been torn down. */\n\tget destroyed(): boolean {\n\t\treturn this.#destroyed\n\t}\n\n\t/** Reset every moving axis to its opening state. */\n\tclear(): void {\n\t\tthis.#gate()\n\t\tconst changed =\n\t\t\tthis.#rowStore.length > 0 ||\n\t\t\tthis.#orderStore.length > 0 ||\n\t\t\tthis.#filterStore.length > 0 ||\n\t\t\tthis.#selected.size > 0 ||\n\t\t\tthis.#expanded.size > 0 ||\n\t\t\tthis.#page !== 1 ||\n\t\t\tthis.#limit !== this.#initialLimit\n\t\tif (!changed) return\n\n\t\tthis.#rowStore = Object.freeze([])\n\t\tthis.#orderStore = Object.freeze([])\n\t\tthis.#filterStore = Object.freeze([])\n\t\tthis.#selected = new Set()\n\t\tthis.#expanded = new Set()\n\t\tthis.#page = 1\n\t\tthis.#limit = this.#initialLimit\n\t\tthis.#emitter.emit('clear')\n\t}\n\n\t/** Tear the table down while leaving every getter readable. */\n\tdestroy(): void {\n\t\tif (this.#destroyed) return\n\t\tthis.#destroyed = true\n\t\tthis.#emitter.destroy()\n\t}\n\n\t#filtered(): readonly TableRow[] {\n\t\treturn filterRows(this.#schema, this.#rowStore, this.#filterStore, this.#matchers)\n\t}\n\n\t#keys(): readonly TableKey[] {\n\t\treturn this.#rowStore.flatMap((row) => {\n\t\t\tconst key = extractKey(this.#schema, row)\n\t\t\treturn key === undefined ? [] : [key]\n\t\t})\n\t}\n\n\t#settle(removed: readonly TableKey[], announce: () => void): void {\n\t\tconst keys = new Set(removed)\n\t\tconst selected = new Set([...this.#selected].filter((key) => !keys.has(key)))\n\t\tconst expanded = new Set([...this.#expanded].filter((key) => !keys.has(key)))\n\t\tconst selectedChanged = selected.size !== this.#selected.size\n\t\tconst expandedChanged = expanded.size !== this.#expanded.size\n\n\t\tif (selectedChanged) this.#selected = selected\n\t\tif (expandedChanged) this.#expanded = expanded\n\t\tconst page = this.#clamp()\n\n\t\tannounce()\n\t\tif (selectedChanged) this.#emitter.emit('select', new Set(selected))\n\t\tif (expandedChanged) this.#emitter.emit('expand', new Set(expanded))\n\t\tif (page !== undefined) this.#emitter.emit('paginate', page)\n\t}\n\n\t#clamp(): number | undefined {\n\t\tconst page = Math.min(this.#page, this.#pagination.count)\n\t\tif (page === this.#page) return undefined\n\t\tthis.#page = page\n\t\treturn page\n\t}\n\n\t#gate(): void {\n\t\tif (this.#destroyed) {\n\t\t\tthrow new TableError('DESTROYED', 'The table was destroyed and cannot change')\n\t\t}\n\t}\n}\n","import type { TableInterface, TableOptions, TableSchema } from './types.js'\nimport { Table } from './Table.js'\n\n/**\n * Open a table against a schema.\n *\n * @param schema - The table declaration to own.\n * @param options - Initial rows, lens overrides, pagination, and emitter wiring.\n * @returns A live table interface.\n * @throws A {@link TableError} coded `SCHEMA` when the schema is unusable, `KEY` when a seeded\n * identity is unusable or repeated, and `CELL` when a seeded cell is invalid.\n * @example\n * ```ts\n * const table = createTable({ key: 'id', columns: [{ cell: 'text', key: 'id' }] })\n * table.rows.add({ id: '1' })\n * ```\n */\nexport function createTable(schema: TableSchema, options?: TableOptions): TableInterface {\n\treturn new Table(schema, options)\n}\n"],"mappings":";;;;AAGA,IAAa,eAAsC,OAAO,OAAO;CAChE;CACA;CACA;CACA;AACD,CAAC;;AAGD,IAAa,eAAe;;AAG5B,IAAa,eAAe;;AAG5B,IAAa,aAAa;;AAG1B,IAAa,eAAe;;AAG5B,IAAa,aAAa;;AAG1B,IAAa,aAAa;;;;ACtB1B,IAAa,aAAb,cAAgC,MAAM;;CAErC;;CAGA;;;;;;;;CASA,YAAY,MAAsB,SAAiB,SAAsB;EACxE,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,IAAI,YAAY,KAAA,GAAW,KAAK,UAAU;CAC3C;AACD;;;;;;;AAQA,SAAgB,aAAa,OAAqC;CACjE,OAAO,iBAAiB;AACzB;;;;;;;;;;ACMA,SAAgB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,QAAQ,QAAQ,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;EAC5E,MAAM,kBAAkB,SAAS,SAAS,KAAKD,UAAU;EACzD,MAAM,kBAAkB,SAAS,SAAS,KAAKC,UAAU;EAEzD,IAAI,iBAAiB,KAAKD,YAAY;EACtC,IAAI,iBAAiB,KAAKC,YAAY;EACtC,MAAM,OAAO,KAAKI,OAAO;EAEzB,SAAS;EACT,IAAI,iBAAiB,KAAKnB,SAAS,KAAK,UAAU,IAAI,IAAI,QAAQ,CAAC;EACnE,IAAI,iBAAiB,KAAKA,SAAS,KAAK,UAAU,IAAI,IAAI,QAAQ,CAAC;EACnE,IAAI,SAAS,KAAA,GAAW,KAAKA,SAAS,KAAK,YAAY,IAAI;CAC5D;CAEA,SAA6B;EAC5B,MAAM,OAAO,KAAK,IAAI,KAAKgB,OAAO,KAAKN,YAAY,KAAK;EACxD,IAAI,SAAS,KAAKM,OAAO,OAAO,KAAA;EAChC,KAAKA,QAAQ;EACb,OAAO;CACR;CAEA,QAAc;EACb,IAAI,KAAKO,YACR,MAAM,IAAI,WAAW,aAAa,2CAA2C;CAE/E;AACD;;;;;;;;;;;;;;;;;ACpQA,SAAgB,YAAY,QAAqB,SAAwC;CACxF,OAAO,IAAI,MAAM,QAAQ,OAAO;AACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orkestrel/table",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "The @orkestrel/table package.",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/orkestrel/table#readme",
@@ -58,21 +58,22 @@
58
58
  "prepublishOnly": "npm run format:check && npm run lint:check && npm run check && npm run build && npm test"
59
59
  },
60
60
  "dependencies": {
61
- "@orkestrel/contract": "^0.0.12",
62
- "@orkestrel/emitter": "^0.0.7"
61
+ "@orkestrel/contract": "^0.0.13",
62
+ "@orkestrel/emitter": "^0.0.8"
63
63
  },
64
64
  "devDependencies": {
65
- "@microsoft/api-extractor": "^7.58.12",
66
- "@orkestrel/guide": "^0.0.11",
67
- "@orkestrel/scaffold": "^0.0.38",
68
- "@orkestrel/test": "^0.0.6",
65
+ "@microsoft/api-extractor": "^7.59.0",
66
+ "@orkestrel/guide": "^0.0.12",
67
+ "@orkestrel/probe": "^0.0.3",
68
+ "@orkestrel/scaffold": "^0.0.49",
69
+ "@orkestrel/test": "^0.0.11",
69
70
  "@types/node": "^26.2.0",
70
- "oxfmt": "^0.62.0",
71
- "oxlint": "^1.77.0",
71
+ "oxfmt": "^0.64.0",
72
+ "oxlint": "^1.79.0",
72
73
  "typescript": "^6.0.3",
73
- "vite": "~8.2.0",
74
+ "vite": "^8.2.2",
74
75
  "vite-plugin-dts": "^5.0.3",
75
- "vitest": "^4.1.10"
76
+ "vitest": "^4.1.11"
76
77
  },
77
78
  "engines": {
78
79
  "node": ">=22.12.0"