@orkestrel/table 0.0.5 → 0.0.6

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.
@@ -56,7 +56,7 @@ var TableError = class extends Error {
56
56
  * @returns True if the value is a {@link TableError} instance; false otherwise.
57
57
  */
58
58
  function isTableError(input) {
59
- return input instanceof TableError;
59
+ return (0, _orkestrel_contract.isInstance)(input, TableError);
60
60
  }
61
61
  //#endregion
62
62
  //#region src/core/helpers.ts
@@ -95,7 +95,7 @@ function extractKey(schema, row) {
95
95
  * set when membership changes.
96
96
  */
97
97
  function computeKeys(known, current, input, include) {
98
- const requested = input === void 0 ? known : Array.isArray(input) ? input : [input];
98
+ const requested = input === void 0 ? known : (0, _orkestrel_contract.isArray)(input) ? input : [input];
99
99
  const population = new Set(known);
100
100
  if (requested.some((key) => !population.has(key))) return void 0;
101
101
  const next = new Set(current);
@@ -802,7 +802,7 @@ var FilterManager = class {
802
802
  /** Filters one column or several. */
803
803
  set(input) {
804
804
  this.#gate();
805
- const requested = Array.isArray(input) ? input : [input];
805
+ const requested = (0, _orkestrel_contract.isArray)(input) ? input : [input];
806
806
  for (const filter of requested) this.#validate(filter);
807
807
  const next = mergeTerms(this.#read(), requested);
808
808
  if (matchesTerms(next, this.#read(), (filter, other) => this.#operands(filter, other))) return;
@@ -814,7 +814,7 @@ var FilterManager = class {
814
814
  /** Stops filtering by one or more columns. */
815
815
  remove(input) {
816
816
  this.#gate();
817
- const columns = input === void 0 ? this.#schema.columns.map((column) => column.key) : Array.isArray(input) ? input : [input];
817
+ const columns = input === void 0 ? this.#schema.columns.map((column) => column.key) : (0, _orkestrel_contract.isArray)(input) ? input : [input];
818
818
  for (const column of columns) if (extractColumn(this.#schema, column) === void 0) return false;
819
819
  const next = removeTerms(this.#read(), columns);
820
820
  if (next.length !== this.#read().length) {
@@ -909,7 +909,7 @@ var PaginationManager = class {
909
909
  this.#emitter.emit("paginate", nextPage);
910
910
  }
911
911
  #normalize(value) {
912
- return Number.isFinite(value) ? Math.max(1, Math.trunc(value)) : 1;
912
+ return (0, _orkestrel_contract.isFiniteNumber)(value) ? Math.max(1, Math.trunc(value)) : 1;
913
913
  }
914
914
  };
915
915
  //#endregion
@@ -955,7 +955,7 @@ var RowManager = class {
955
955
  /** Appends one row or several. */
956
956
  add(input) {
957
957
  this.#gate();
958
- const rows = Array.isArray(input) ? input : [input];
958
+ const rows = (0, _orkestrel_contract.isArray)(input) ? input : [input];
959
959
  const keys = /* @__PURE__ */ new Set();
960
960
  for (const row of this.#read()) {
961
961
  const key = extractKey(this.#schema, row);
@@ -974,7 +974,7 @@ var RowManager = class {
974
974
  /** Merges one row or several into the rows their keys name. */
975
975
  update(input) {
976
976
  this.#gate();
977
- const updates = (Array.isArray(input) ? input : [input]).map((row) => cloneRow(row));
977
+ const updates = ((0, _orkestrel_contract.isArray)(input) ? input : [input]).map((row) => cloneRow(row));
978
978
  const current = this.#read();
979
979
  const locations = [];
980
980
  for (const update of updates) {
@@ -1034,7 +1034,7 @@ var RowManager = class {
1034
1034
  const requested = input === void 0 ? current.flatMap((row) => {
1035
1035
  const key = extractKey(this.#schema, row);
1036
1036
  return key === void 0 ? [] : [key];
1037
- }) : Array.isArray(input) ? input : [input];
1037
+ }) : (0, _orkestrel_contract.isArray)(input) ? input : [input];
1038
1038
  const keys = new Set(requested);
1039
1039
  const known = new Set(current.flatMap((row) => {
1040
1040
  const key = extractKey(this.#schema, row);
@@ -1157,7 +1157,7 @@ var SortManager = class {
1157
1157
  /** Sorts by one column or several. */
1158
1158
  set(input) {
1159
1159
  this.#gate();
1160
- const requested = Array.isArray(input) ? input : [input];
1160
+ const requested = (0, _orkestrel_contract.isArray)(input) ? input : [input];
1161
1161
  for (const order of requested) this.#require(order.column);
1162
1162
  const next = mergeTerms(this.#read(), requested);
1163
1163
  if (matchesTerms(next, this.#read(), (order, other) => order.direction === other.direction)) return;
@@ -1167,7 +1167,7 @@ var SortManager = class {
1167
1167
  /** Stops sorting by one or more columns. */
1168
1168
  remove(input) {
1169
1169
  this.#gate();
1170
- const columns = input === void 0 ? this.#schema.columns.map((column) => column.key) : Array.isArray(input) ? input : [input];
1170
+ const columns = input === void 0 ? this.#schema.columns.map((column) => column.key) : (0, _orkestrel_contract.isArray)(input) ? input : [input];
1171
1171
  for (const column of columns) if (extractColumn(this.#schema, column) === void 0) return false;
1172
1172
  const next = removeTerms(this.#read(), columns);
1173
1173
  if (next.length !== this.#read().length) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"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/KeyManager.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/** Lists 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/** Names the maximum number of columns one schema may declare: 256. */\nexport const COLUMN_LIMIT = 256\n\n/** Names the maximum number of choices one `choice` column may offer: 1024. */\nexport const CHOICE_LIMIT = 1024\n\n/** Names the maximum length of a schema name or column key: 128 UTF-16 code units. */\nexport const NAME_LIMIT = 128\n\n/** Names the maximum length of any single retained string: 65536 UTF-16 code units. */\nexport const STRING_LIMIT = 65536\n\n/**\n * Names the maximum total length of every string one schema retains: 1048576 UTF-16 code units.\n */\nexport const TEXT_LIMIT = 1048576\n\n/** Names the maximum total number of records, arrays, and leaves one schema retains: 16384. */\nexport const NODE_LIMIT = 16384\n","import type { JSONRecord } from '@orkestrel/contract'\nimport type { TableErrorCode } from './types.js'\n\n/**\n * Represents an error raised by the table domain — a machine-readable `code` and optional\n * structured `context`.\n */\nexport class TableError extends Error {\n\t/** Holds the machine-readable reason for this failure. */\n\treadonly code: TableErrorCode\n\n\t/** Holds structured values that locate or explain this failure. */\n\treadonly context?: JSONRecord\n\n\t/**\n\t * Creates 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 * Determines whether a caught value is a table error, so a `catch` branches on `code` without an\n * assertion.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a {@link TableError} instance; false otherwise.\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\tTableTerm,\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 * Finds one column by key; `undefined` when the schema declares no such column.\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 * Reads one row's declared identity; `undefined` when its key cell is missing, empty, or not a\n * string.\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 * Computes one atomic 0/1/N membership change over the keys a caller may address — the engine\n * selection and expansion share.\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 * Merges lens terms into a column-keyed list, replacing the entry that names the same column —\n * the `set` write.\n *\n * @param current - The list as it stands.\n * @param requested - The terms to write, in the order they are written.\n * @returns A frozen list holding one owned entry per column, in the order the columns first\n * appeared.\n */\nexport function mergeTerms<Term extends TableTerm>(\n\tcurrent: readonly Term[],\n\trequested: readonly Term[],\n): readonly Term[] {\n\tconst next = [...current]\n\tfor (const term of requested) {\n\t\tconst owned = Object.freeze({ ...term })\n\t\tconst index = next.findIndex((candidate) => candidate.column === term.column)\n\t\tif (index === -1) next.push(owned)\n\t\telse next[index] = owned\n\t}\n\n\treturn Object.freeze(next)\n}\n\n/**\n * Removes every lens term naming one of the given columns — the drop `sort.remove` and\n * `filter.remove` share.\n *\n * @param current - The list as it stands.\n * @param columns - The column keys to drop.\n * @returns A frozen list holding the entries no named column matched, in their original order.\n */\nexport function removeTerms<Term extends TableTerm>(\n\tcurrent: readonly Term[],\n\tcolumns: readonly string[],\n): readonly Term[] {\n\tconst removed = new Set(columns)\n\treturn Object.freeze(current.filter((term) => !removed.has(term.column)))\n}\n\n/**\n * Checks whether two lens lists hold the same terms in the same order, with the supplied test\n * deciding the operands.\n *\n * @param left - The first list.\n * @param right - The second list.\n * @param equal - Decide whether two terms naming one column carry the same operands.\n * @returns True if the lists are the same length and every position names the same column and\n * carries the same operands; false otherwise.\n */\nexport function matchesTerms<Term extends TableTerm>(\n\tleft: readonly Term[],\n\tright: readonly Term[],\n\tequal: (left: Term, right: Term) => boolean,\n): boolean {\n\treturn (\n\t\tleft.length === right.length &&\n\t\tleft.every((term, index) => {\n\t\t\tconst other = right[index]\n\t\t\treturn other !== undefined && term.column === other.column && equal(term, other)\n\t\t})\n\t)\n}\n\n/**\n * Checks whether one column can hold a value — the shape gate every write and every seed passes\n * through.\n *\n * @param column - The column that owns the cell.\n * @param value - The unknown value to inspect.\n * @returns True if the column can hold the value; false otherwise.\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 * Compares two of one column's cells the way its `cell` fixes, describing ascending order.\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 * Checks whether one column admits a filter and every operand it carries — the gate `filter.set`\n * and {@link matchesFilter} share.\n *\n * @param column - The column that fixes the accepted operators and cell shapes.\n * @param filter - The filter to inspect.\n * @returns True if the filter belongs to the column and the column can apply it; false otherwise.\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 * Tests one of a column's cells against one filter the way its `cell` fixes.\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 True if the filter accepts the cell; false otherwise.\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 * Keeps the rows every filter accepts, in the order given; a supplied {@link CellMatcher}\n * replaces the default per column.\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 * Orders rows by the terms given, stably; a supplied {@link CellComparator} replaces the default\n * per column.\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 * Audits a structurally valid schema for domain faults and budget breaches, returning human\n * diagnostics.\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 * Projects a schema into JSON in declaration order, dropping every absent member; raises `SCHEMA`\n * for a `meta` it cannot own.\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 * Projects rows into JSON with each row's cells in the schema's column order, dropping every\n * absent cell.\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 * Determines whether an unknown value has a table cell shape — a string, a finite number, or a\n * boolean.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a string, finite number, or boolean; false otherwise.\n */\nexport function isTableCell(input: unknown): input is TableCell {\n\treturn unionOf(isString, isFiniteNumber, isBoolean)(input)\n}\n\n/**\n * Determines whether an unknown value is a record whose every own key is a string and every value\n * a {@link TableCell}.\n *\n * @param input - The value to inspect.\n * @returns True if every own key is a string and every value is a table cell; false otherwise.\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 * Determines whether an unknown value is a declared column cell.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a declared column cell; false otherwise.\n */\nexport function isColumnCell(input: unknown): input is ColumnCell {\n\treturn COLUMN_CELLS.some((cell) => cell === input)\n}\n\n/**\n * Determines whether an unknown value is one exact {@link ColumnChoice} record; an unknown member\n * refuses it.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a column choice; false otherwise.\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 * Determines whether an unknown value is one exact discriminated {@link TableColumn}, checked\n * against its cell's own options.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a structurally valid table column; false otherwise.\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 * Determines whether an unknown value has the exact shape of a {@link TableSchema} — the shape\n * alone, with no domain check.\n *\n * @param input - The value to inspect.\n * @returns True if the value has the exact structure of a table schema; false otherwise.\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 * Determines whether an unknown value is a {@link TableSchema} a table can be opened against —\n * the exact shape, and an audit that finds nothing.\n *\n * @param input - The value to inspect.\n * @returns True if the value has valid structure, domain relationships, and\n * budgets; false otherwise.\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 * Clones 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 * Clones a whole schema into an owned frozen snapshot, freezing every nested column, choice list,\n * choice, and `meta`; raises `SCHEMA` for a `meta` it cannot own.\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 * Parses unknown wire data into an owned, structurally valid, 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 * Parses unknown wire data into owned rows against one table schema, coercing a numeric string\n * and `'true'` / `'false'`.\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 { TableEventMap, TableKey } from '../types.js'\nimport { computeKeys } from '../helpers.js'\n\n/** Manages the key set one table axis holds, and the event it announces when that set moves. */\nexport class KeyManager {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #event: 'select' | 'expand'\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 * Creates a key-set shell over one table's private store.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param event - The event this axis announces when its key set moves.\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 held keys.\n\t * @param write - The held-key commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tevent: 'select' | 'expand',\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.#event = event\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/** Returns the keys held right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn new Set(this.#read())\n\t}\n\n\t/**\n\t * Applies one atomic 0/1/N membership change, announcing it only when the set moves.\n\t *\n\t * @param input - Every known key, one key, or a key list.\n\t * @param include - Decides the next membership from each key's membership at that step.\n\t * @returns `undefined` for the no-argument form, `false` when any requested key names no row\n\t * the table holds, and `true` otherwise.\n\t */\n\tchange(\n\t\tinput: TableKey | readonly TableKey[] | undefined,\n\t\tinclude: (included: boolean) => boolean,\n\t): void | boolean {\n\t\tthis.#gate()\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(this.#event, 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 { ExpansionManagerInterface, TableEventMap, TableKey } from '../types.js'\nimport { KeyManager } from './KeyManager.js'\n\n/** Manages the keys of the rows somebody has opened. */\nexport class ExpansionManager implements ExpansionManagerInterface {\n\treadonly #keys: KeyManager\n\n\t/**\n\t * Creates 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.#keys = new KeyManager(emitter, 'expand', gate, rows, read, write)\n\t}\n\n\t/** Returns the keys of the rows opened right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn this.#keys.keys\n\t}\n\n\t/** Opens every row the table holds. */\n\texpand(): void\n\t/** Opens one row. */\n\texpand(key: TableKey): boolean\n\t/** Opens several rows. */\n\texpand(keys: readonly TableKey[]): boolean\n\t/** Opens one or more rows. */\n\texpand(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => true)\n\t}\n\n\t/** Closes every row. */\n\tclear(): void\n\t/** Closes one row. */\n\tclear(key: TableKey): boolean\n\t/** Closes several rows. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Closes one or more rows. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => false)\n\t}\n\n\t/** Opens one row or closes it when already open. */\n\ttoggle(key: TableKey): boolean\n\t/** Turns several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turns one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\treturn this.#keys.change(input, (included) => !included) === 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, matchesTerms, mergeTerms, removeTerms } from '../helpers.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Filters several columns. */\n\tset(filters: readonly TableFilter[]): void\n\t/** Filters one column. */\n\tset(filter: TableFilter): void\n\t/** Filters 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 = mergeTerms(this.#read(), requested)\n\t\tif (matchesTerms(next, this.#read(), (filter, other) => this.#operands(filter, other))) return\n\t\tthis.#write(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/** Stops filtering by every column. */\n\tremove(): void\n\t/** Stops filtering by one column. */\n\tremove(column: string): boolean\n\t/** Stops filtering by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stops 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 next = removeTerms(this.#read(), columns)\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(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#operands(left: TableFilter, right: TableFilter): boolean {\n\t\tif (left.operator !== right.operator) return false\n\t\tif (left.operator === 'contains' && right.operator === 'contains') {\n\t\t\treturn left.text === right.text\n\t\t}\n\t\tif (left.operator === 'between' && right.operator === 'between') {\n\t\t\treturn left.minimum === right.minimum && left.maximum === right.maximum\n\t\t}\n\t\treturn left.operator === 'equals' && right.operator === 'equals' && left.value === right.value\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { PaginationManagerInterface, TableEventMap } from '../types.js'\n\n/** Manages 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 * Creates 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/** Returns the page shown, counted from one. */\n\tget page(): number {\n\t\treturn this.#readLimit() === undefined ? 1 : this.#readPage()\n\t}\n\n\t/** Returns the number of rows one page holds. */\n\tget limit(): number | undefined {\n\t\treturn this.#readLimit()\n\t}\n\n\t/** Returns 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/** Returns 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/** Shows another page, clamped to the pages that exist. */\n\tmove(page: number): void {\n\t\tthis.#gate()\n\t\tconst next =\n\t\t\tthis.#readLimit() === undefined || Number.isNaN(page)\n\t\t\t\t? 1\n\t\t\t\t: Math.min(this.count, Math.max(1, Math.trunc(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/** Changes 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/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Appends several rows. */\n\tadd(rows: readonly TableRow[]): void\n\t/** Appends one row. */\n\tadd(row: TableRow): void\n\t/** Appends 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/** Merges several rows into the rows their keys name. */\n\tupdate(rows: readonly TableRow[]): boolean\n\t/** Merges one row into the row its key names. */\n\tupdate(row: TableRow): boolean\n\t/** Merges 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/** Moves 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.isNaN(index) ? 0 : Math.max(0, Math.trunc(index)),\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/** Removes every row. */\n\tremove(): void\n\t/** Removes one row. */\n\tremove(key: TableKey): boolean\n\t/** Removes several rows. */\n\tremove(keys: readonly TableKey[]): boolean\n\t/** Removes 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 { KeyManager } from './KeyManager.js'\n\n/** Manages the keys of the rows somebody has picked. */\nexport class SelectionManager implements SelectionManagerInterface {\n\treadonly #keys: KeyManager\n\n\t/**\n\t * Creates 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.#keys = new KeyManager(emitter, 'select', gate, rows, read, write)\n\t}\n\n\t/** Returns the keys of the rows picked right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn this.#keys.keys\n\t}\n\n\t/** Picks every row the table holds. */\n\tselect(): void\n\t/** Picks one row. */\n\tselect(key: TableKey): boolean\n\t/** Picks several rows. */\n\tselect(keys: readonly TableKey[]): boolean\n\t/** Picks one or more rows. */\n\tselect(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => true)\n\t}\n\n\t/** Drops every pick. */\n\tclear(): void\n\t/** Drops one pick. */\n\tclear(key: TableKey): boolean\n\t/** Drops several picks. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Drops one or more picks. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => false)\n\t}\n\n\t/** Picks one row or drops it when already picked. */\n\ttoggle(key: TableKey): boolean\n\t/** Turns several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turns one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\treturn this.#keys.change(input, (included) => !included) === 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, matchesTerms, mergeTerms, removeTerms } from '../helpers.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Sorts by several columns. */\n\tset(orders: readonly TableOrder[]): void\n\t/** Sorts by one column. */\n\tset(order: TableOrder): void\n\t/** Sorts 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 = mergeTerms(this.#read(), requested)\n\t\tif (matchesTerms(next, this.#read(), (order, other) => order.direction === other.direction)) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.#write(next)\n\t\tthis.#emitter.emit('sort', this.orders())\n\t}\n\n\t/** Stops sorting by every column. */\n\tremove(): void\n\t/** Stops sorting by one column. */\n\tremove(column: string): boolean\n\t/** Stops sorting by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stops 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 next = removeTerms(this.#read(), columns)\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(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","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 { attempt } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { cloneRow, cloneSchema } from './cloners.js'\nimport { isTableError, 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/**\n * Holds a schema, its rows, and the lens through which they are read, implementing\n * {@link TableInterface} exactly.\n */\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 * Opens 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 unusable = 'The schema is not a table schema'\n\t\tconst owned = isStructuralTableSchema(schema) ? attempt(() => cloneSchema(schema)) : undefined\n\t\tif (owned !== undefined && !owned.success && isTableError(owned.error)) throw owned.error\n\t\tif (owned === undefined || !owned.success) {\n\t\t\tthrow new TableError('SCHEMA', `The table schema is unusable: ${unusable}`, {\n\t\t\t\tproblems: [unusable],\n\t\t\t})\n\t\t}\n\n\t\tconst problems = isStructuralTableSchema(owned.value) ? auditTable(owned.value) : [unusable]\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 = owned.value\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/** Holds the table's event emitter. */\n\tget emitter(): EmitterInterface<TableEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\t/** Holds the owned frozen schema. */\n\tget schema(): TableSchema {\n\t\treturn this.#schema\n\t}\n\n\t/** Manages the rows the table holds. */\n\tget rows(): RowManagerInterface {\n\t\treturn this.#rows\n\t}\n\n\t/** Manages the ordered sort terms. */\n\tget sort(): SortManagerInterface {\n\t\treturn this.#sort\n\t}\n\n\t/** Manages the filters applied with and-only composition. */\n\tget filter(): FilterManagerInterface {\n\t\treturn this.#filter\n\t}\n\n\t/** Manages the selected row keys. */\n\tget selection(): SelectionManagerInterface {\n\t\treturn this.#selection\n\t}\n\n\t/** Manages the expanded row keys. */\n\tget expansion(): ExpansionManagerInterface {\n\t\treturn this.#expansion\n\t}\n\n\t/** Manages the page arithmetic. */\n\tget pagination(): PaginationManagerInterface {\n\t\treturn this.#pagination\n\t}\n\n\t/** Returns 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/** Returns the number of rows admitted by the filters. */\n\tget count(): number {\n\t\treturn this.#filtered().length\n\t}\n\n\t/** Reports whether the table has been torn down. */\n\tget destroyed(): boolean {\n\t\treturn this.#destroyed\n\t}\n\n\t/** Resets 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/** Tears 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 * Opens a table against a schema. The schema is copied, and the copy is what the table declares.\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 Open a table\n * ```ts\n * import { createTable } from '@orkestrel/table'\n *\n * const table = createTable(\n * \t{\n * \t\tlabel: 'People',\n * \t\tkey: 'id',\n * \t\tcolumns: [\n * \t\t\t{ cell: 'text', key: 'id', label: 'Reference' },\n * \t\t\t{ cell: 'text', key: 'name', label: 'Name' },\n * \t\t\t{ cell: 'number', key: 'age', label: 'Age' },\n * \t\t],\n * \t},\n * \t{\n * \t\trows: [\n * \t\t\t{ id: '1', name: 'Ada', age: 36 },\n * \t\t\t{ id: '2', name: 'Grace', age: 45 },\n * \t\t\t{ id: '3', name: 'Alan', age: 41 },\n * \t\t],\n * \t\tlimit: 2,\n * \t},\n * )\n *\n * table.filter.set({ column: 'name', operator: 'contains', text: 'a' })\n * table.sort.set({ column: 'age', direction: 'descending' })\n *\n * table.count // 3 — every name holds a lowercase 'a'\n * table.pagination.count // 2 — two pages of two\n * table.view.map((row) => row.name) // ['Grace', 'Alan'] — page one, oldest first\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;;;;AAK5B,IAAa,aAAa;;AAG1B,IAAa,aAAa;;;;;;;ACrB1B,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;;;;;;;;AASA,SAAgB,aAAa,OAAqC;CACjE,OAAO,iBAAiB;AACzB;;;;;;;;;;ACGA,SAAgB,cAAc,QAAqB,KAAsC;CACxF,OAAO,OAAO,QAAQ,MAAM,WAAW,OAAO,QAAQ,GAAG;AAC1D;;;;;;;;;AAUA,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;;;;;;;;;;;;AAaA,SAAgB,YACf,OACA,SACA,OACA,SACoC;CACpC,MAAM,YAAY,UAAU,KAAA,IAAY,QAAQ,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;CACrF,MAAM,aAAa,IAAI,IAAI,KAAK;CAChC,IAAI,UAAU,MAAM,QAAQ,CAAC,WAAW,IAAI,GAAG,CAAC,GAAG,OAAO,KAAA;CAE1D,MAAM,OAAO,IAAI,IAAI,OAAO;CAC5B,KAAK,MAAM,OAAO,WACjB,IAAI,QA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;CACF;CAEA,QAAQ,SAA8B,UAA4B;EACjE,MAAM,OAAO,IAAI,IAAI,OAAO;EAC5B,MAAM,WAAW,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,QAAQ,QAAQ,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;EAC5E,MAAM,WAAW,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,QAAQ,QAAQ,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;EAC5E,MAAM,kBAAkB,SAAS,SAAS,KAAK,UAAU;EACzD,MAAM,kBAAkB,SAAS,SAAS,KAAK,UAAU;EAEzD,IAAI,iBAAiB,KAAK,YAAY;EACtC,IAAI,iBAAiB,KAAK,YAAY;EACtC,MAAM,OAAO,KAAK,OAAO;EAEzB,SAAS;EACT,IAAI,iBAAiB,KAAK,SAAS,KAAK,UAAU,IAAI,IAAI,QAAQ,CAAC;EACnE,IAAI,iBAAiB,KAAK,SAAS,KAAK,UAAU,IAAI,IAAI,QAAQ,CAAC;EACnE,IAAI,SAAS,KAAA,GAAW,KAAK,SAAS,KAAK,YAAY,IAAI;CAC5D;CAEA,SAA6B;EAC5B,MAAM,OAAO,KAAK,IAAI,KAAK,OAAO,KAAK,YAAY,KAAK;EACxD,IAAI,SAAS,KAAK,OAAO,OAAO,KAAA;EAChC,KAAK,QAAQ;EACb,OAAO;CACR;CAEA,QAAc;EACb,IAAI,KAAK,YACR,MAAM,IAAI,WAAW,aAAa,2CAA2C;CAE/E;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrPA,SAAgB,YAAY,QAAqB,SAAwC;CACxF,OAAO,IAAI,MAAM,QAAQ,OAAO;AACjC"}
1
+ {"version":3,"file":"index.cjs","names":[],"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/KeyManager.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/** Lists 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/** Names the maximum number of columns one schema may declare: 256. */\nexport const COLUMN_LIMIT = 256\n\n/** Names the maximum number of choices one `choice` column may offer: 1024. */\nexport const CHOICE_LIMIT = 1024\n\n/** Names the maximum length of a schema name or column key: 128 UTF-16 code units. */\nexport const NAME_LIMIT = 128\n\n/** Names the maximum length of any single retained string: 65536 UTF-16 code units. */\nexport const STRING_LIMIT = 65536\n\n/**\n * Names the maximum total length of every string one schema retains: 1048576 UTF-16 code units.\n */\nexport const TEXT_LIMIT = 1048576\n\n/** Names the maximum total number of records, arrays, and leaves one schema retains: 16384. */\nexport const NODE_LIMIT = 16384\n","import type { JSONRecord } from '@orkestrel/contract'\nimport { isInstance } from '@orkestrel/contract'\nimport type { TableErrorCode } from './types.js'\n\n/**\n * Represents an error raised by the table domain — a machine-readable `code` and optional\n * structured `context`.\n */\nexport class TableError extends Error {\n\t/** Holds the machine-readable reason for this failure. */\n\treadonly code: TableErrorCode\n\n\t/** Holds structured values that locate or explain this failure. */\n\treadonly context?: JSONRecord\n\n\t/**\n\t * Creates 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 * Determines whether a caught value is a table error, so a `catch` branches on `code` without an\n * assertion.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a {@link TableError} instance; false otherwise.\n */\nexport function isTableError(input: unknown): input is TableError {\n\treturn isInstance(input, 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\tTableTerm,\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 * Finds one column by key; `undefined` when the schema declares no such column.\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 * Reads one row's declared identity; `undefined` when its key cell is missing, empty, or not a\n * string.\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 * Computes one atomic 0/1/N membership change over the keys a caller may address — the engine\n * selection and expansion share.\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 : 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 * Merges lens terms into a column-keyed list, replacing the entry that names the same column —\n * the `set` write.\n *\n * @param current - The list as it stands.\n * @param requested - The terms to write, in the order they are written.\n * @returns A frozen list holding one owned entry per column, in the order the columns first\n * appeared.\n */\nexport function mergeTerms<Term extends TableTerm>(\n\tcurrent: readonly Term[],\n\trequested: readonly Term[],\n): readonly Term[] {\n\tconst next = [...current]\n\tfor (const term of requested) {\n\t\tconst owned = Object.freeze({ ...term })\n\t\tconst index = next.findIndex((candidate) => candidate.column === term.column)\n\t\tif (index === -1) next.push(owned)\n\t\telse next[index] = owned\n\t}\n\n\treturn Object.freeze(next)\n}\n\n/**\n * Removes every lens term naming one of the given columns — the drop `sort.remove` and\n * `filter.remove` share.\n *\n * @param current - The list as it stands.\n * @param columns - The column keys to drop.\n * @returns A frozen list holding the entries no named column matched, in their original order.\n */\nexport function removeTerms<Term extends TableTerm>(\n\tcurrent: readonly Term[],\n\tcolumns: readonly string[],\n): readonly Term[] {\n\tconst removed = new Set(columns)\n\treturn Object.freeze(current.filter((term) => !removed.has(term.column)))\n}\n\n/**\n * Checks whether two lens lists hold the same terms in the same order, with the supplied test\n * deciding the operands.\n *\n * @param left - The first list.\n * @param right - The second list.\n * @param equal - Decide whether two terms naming one column carry the same operands.\n * @returns True if the lists are the same length and every position names the same column and\n * carries the same operands; false otherwise.\n */\nexport function matchesTerms<Term extends TableTerm>(\n\tleft: readonly Term[],\n\tright: readonly Term[],\n\tequal: (left: Term, right: Term) => boolean,\n): boolean {\n\treturn (\n\t\tleft.length === right.length &&\n\t\tleft.every((term, index) => {\n\t\t\tconst other = right[index]\n\t\t\treturn other !== undefined && term.column === other.column && equal(term, other)\n\t\t})\n\t)\n}\n\n/**\n * Checks whether one column can hold a value — the shape gate every write and every seed passes\n * through.\n *\n * @param column - The column that owns the cell.\n * @param value - The unknown value to inspect.\n * @returns True if the column can hold the value; false otherwise.\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 * Compares two of one column's cells the way its `cell` fixes, describing ascending order.\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 * Checks whether one column admits a filter and every operand it carries — the gate `filter.set`\n * and {@link matchesFilter} share.\n *\n * @param column - The column that fixes the accepted operators and cell shapes.\n * @param filter - The filter to inspect.\n * @returns True if the filter belongs to the column and the column can apply it; false otherwise.\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 * Tests one of a column's cells against one filter the way its `cell` fixes.\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 True if the filter accepts the cell; false otherwise.\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 * Keeps the rows every filter accepts, in the order given; a supplied {@link CellMatcher}\n * replaces the default per column.\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 * Orders rows by the terms given, stably; a supplied {@link CellComparator} replaces the default\n * per column.\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 * Audits a structurally valid schema for domain faults and budget breaches, returning human\n * diagnostics.\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 * Projects a schema into JSON in declaration order, dropping every absent member; raises `SCHEMA`\n * for a `meta` it cannot own.\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 * Projects rows into JSON with each row's cells in the schema's column order, dropping every\n * absent cell.\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 * Determines whether an unknown value has a table cell shape — a string, a finite number, or a\n * boolean.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a string, finite number, or boolean; false otherwise.\n */\nexport function isTableCell(input: unknown): input is TableCell {\n\treturn unionOf(isString, isFiniteNumber, isBoolean)(input)\n}\n\n/**\n * Determines whether an unknown value is a record whose every own key is a string and every value\n * a {@link TableCell}.\n *\n * @param input - The value to inspect.\n * @returns True if every own key is a string and every value is a table cell; false otherwise.\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 * Determines whether an unknown value is a declared column cell.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a declared column cell; false otherwise.\n */\nexport function isColumnCell(input: unknown): input is ColumnCell {\n\treturn COLUMN_CELLS.some((cell) => cell === input)\n}\n\n/**\n * Determines whether an unknown value is one exact {@link ColumnChoice} record; an unknown member\n * refuses it.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a column choice; false otherwise.\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 * Determines whether an unknown value is one exact discriminated {@link TableColumn}, checked\n * against its cell's own options.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a structurally valid table column; false otherwise.\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 * Determines whether an unknown value has the exact shape of a {@link TableSchema} — the shape\n * alone, with no domain check.\n *\n * @param input - The value to inspect.\n * @returns True if the value has the exact structure of a table schema; false otherwise.\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 * Determines whether an unknown value is a {@link TableSchema} a table can be opened against —\n * the exact shape, and an audit that finds nothing.\n *\n * @param input - The value to inspect.\n * @returns True if the value has valid structure, domain relationships, and\n * budgets; false otherwise.\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 * Clones 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 * Clones a whole schema into an owned frozen snapshot, freezing every nested column, choice list,\n * choice, and `meta`; raises `SCHEMA` for a `meta` it cannot own.\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 * Parses unknown wire data into an owned, structurally valid, 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 * Parses unknown wire data into owned rows against one table schema, coercing a numeric string\n * and `'true'` / `'false'`.\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 { TableEventMap, TableKey } from '../types.js'\nimport { computeKeys } from '../helpers.js'\n\n/** Manages the key set one table axis holds, and the event it announces when that set moves. */\nexport class KeyManager {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #event: 'select' | 'expand'\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 * Creates a key-set shell over one table's private store.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param event - The event this axis announces when its key set moves.\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 held keys.\n\t * @param write - The held-key commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tevent: 'select' | 'expand',\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.#event = event\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/** Returns the keys held right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn new Set(this.#read())\n\t}\n\n\t/**\n\t * Applies one atomic 0/1/N membership change, announcing it only when the set moves.\n\t *\n\t * @param input - Every known key, one key, or a key list.\n\t * @param include - Decides the next membership from each key's membership at that step.\n\t * @returns `undefined` for the no-argument form, `false` when any requested key names no row\n\t * the table holds, and `true` otherwise.\n\t */\n\tchange(\n\t\tinput: TableKey | readonly TableKey[] | undefined,\n\t\tinclude: (included: boolean) => boolean,\n\t): void | boolean {\n\t\tthis.#gate()\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(this.#event, 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 { ExpansionManagerInterface, TableEventMap, TableKey } from '../types.js'\nimport { KeyManager } from './KeyManager.js'\n\n/** Manages the keys of the rows somebody has opened. */\nexport class ExpansionManager implements ExpansionManagerInterface {\n\treadonly #keys: KeyManager\n\n\t/**\n\t * Creates 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.#keys = new KeyManager(emitter, 'expand', gate, rows, read, write)\n\t}\n\n\t/** Returns the keys of the rows opened right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn this.#keys.keys\n\t}\n\n\t/** Opens every row the table holds. */\n\texpand(): void\n\t/** Opens one row. */\n\texpand(key: TableKey): boolean\n\t/** Opens several rows. */\n\texpand(keys: readonly TableKey[]): boolean\n\t/** Opens one or more rows. */\n\texpand(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => true)\n\t}\n\n\t/** Closes every row. */\n\tclear(): void\n\t/** Closes one row. */\n\tclear(key: TableKey): boolean\n\t/** Closes several rows. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Closes one or more rows. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => false)\n\t}\n\n\t/** Opens one row or closes it when already open. */\n\ttoggle(key: TableKey): boolean\n\t/** Turns several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turns one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\treturn this.#keys.change(input, (included) => !included) === true\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { FilterManagerInterface, TableEventMap, TableFilter, TableSchema } from '../types.js'\nimport { isArray } from '@orkestrel/contract'\nimport { TableError } from '../errors.js'\nimport { admitsFilter, extractColumn, matchesTerms, mergeTerms, removeTerms } from '../helpers.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Filters several columns. */\n\tset(filters: readonly TableFilter[]): void\n\t/** Filters one column. */\n\tset(filter: TableFilter): void\n\t/** Filters one column or several. */\n\tset(input: TableFilter | readonly TableFilter[]): void {\n\t\tthis.#gate()\n\t\tconst requested = isArray(input) ? input : [input]\n\t\tfor (const filter of requested) this.#validate(filter)\n\n\t\tconst next = mergeTerms(this.#read(), requested)\n\t\tif (matchesTerms(next, this.#read(), (filter, other) => this.#operands(filter, other))) return\n\t\tthis.#write(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/** Stops filtering by every column. */\n\tremove(): void\n\t/** Stops filtering by one column. */\n\tremove(column: string): boolean\n\t/** Stops filtering by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stops 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: 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 next = removeTerms(this.#read(), columns)\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(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#operands(left: TableFilter, right: TableFilter): boolean {\n\t\tif (left.operator !== right.operator) return false\n\t\tif (left.operator === 'contains' && right.operator === 'contains') {\n\t\t\treturn left.text === right.text\n\t\t}\n\t\tif (left.operator === 'between' && right.operator === 'between') {\n\t\t\treturn left.minimum === right.minimum && left.maximum === right.maximum\n\t\t}\n\t\treturn left.operator === 'equals' && right.operator === 'equals' && left.value === right.value\n\t}\n}\n","import { isFiniteNumber } from '@orkestrel/contract'\nimport type { Emitter } from '@orkestrel/emitter'\nimport type { PaginationManagerInterface, TableEventMap } from '../types.js'\n\n/** Manages 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 * Creates 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/** Returns the page shown, counted from one. */\n\tget page(): number {\n\t\treturn this.#readLimit() === undefined ? 1 : this.#readPage()\n\t}\n\n\t/** Returns the number of rows one page holds. */\n\tget limit(): number | undefined {\n\t\treturn this.#readLimit()\n\t}\n\n\t/** Returns 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/** Returns 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/** Shows another page, clamped to the pages that exist. */\n\tmove(page: number): void {\n\t\tthis.#gate()\n\t\tconst next =\n\t\t\tthis.#readLimit() === undefined || Number.isNaN(page)\n\t\t\t\t? 1\n\t\t\t\t: Math.min(this.count, Math.max(1, Math.trunc(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/** Changes 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 isFiniteNumber(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 { isArray } from '@orkestrel/contract'\nimport { cloneRow } from '../cloners.js'\nimport { TableError } from '../errors.js'\nimport { extractColumn, extractKey, matchesCell } from '../helpers.js'\nimport { isTableRow } from '../validators.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Appends several rows. */\n\tadd(rows: readonly TableRow[]): void\n\t/** Appends one row. */\n\tadd(row: TableRow): void\n\t/** Appends one row or several. */\n\tadd(input: TableRow | readonly TableRow[]): void {\n\t\tthis.#gate()\n\t\tconst rows = 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/** Merges several rows into the rows their keys name. */\n\tupdate(rows: readonly TableRow[]): boolean\n\t/** Merges one row into the row its key names. */\n\tupdate(row: TableRow): boolean\n\t/** Merges 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 = (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/** Moves 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.isNaN(index) ? 0 : Math.max(0, Math.trunc(index)),\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/** Removes every row. */\n\tremove(): void\n\t/** Removes one row. */\n\tremove(key: TableKey): boolean\n\t/** Removes several rows. */\n\tremove(keys: readonly TableKey[]): boolean\n\t/** Removes 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: 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 { KeyManager } from './KeyManager.js'\n\n/** Manages the keys of the rows somebody has picked. */\nexport class SelectionManager implements SelectionManagerInterface {\n\treadonly #keys: KeyManager\n\n\t/**\n\t * Creates 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.#keys = new KeyManager(emitter, 'select', gate, rows, read, write)\n\t}\n\n\t/** Returns the keys of the rows picked right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn this.#keys.keys\n\t}\n\n\t/** Picks every row the table holds. */\n\tselect(): void\n\t/** Picks one row. */\n\tselect(key: TableKey): boolean\n\t/** Picks several rows. */\n\tselect(keys: readonly TableKey[]): boolean\n\t/** Picks one or more rows. */\n\tselect(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => true)\n\t}\n\n\t/** Drops every pick. */\n\tclear(): void\n\t/** Drops one pick. */\n\tclear(key: TableKey): boolean\n\t/** Drops several picks. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Drops one or more picks. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => false)\n\t}\n\n\t/** Picks one row or drops it when already picked. */\n\ttoggle(key: TableKey): boolean\n\t/** Turns several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turns one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\treturn this.#keys.change(input, (included) => !included) === true\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { SortManagerInterface, TableEventMap, TableOrder, TableSchema } from '../types.js'\nimport { isArray } from '@orkestrel/contract'\nimport { TableError } from '../errors.js'\nimport { extractColumn, matchesTerms, mergeTerms, removeTerms } from '../helpers.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Sorts by several columns. */\n\tset(orders: readonly TableOrder[]): void\n\t/** Sorts by one column. */\n\tset(order: TableOrder): void\n\t/** Sorts by one column or several. */\n\tset(input: TableOrder | readonly TableOrder[]): void {\n\t\tthis.#gate()\n\t\tconst requested = isArray(input) ? input : [input]\n\t\tfor (const order of requested) this.#require(order.column)\n\n\t\tconst next = mergeTerms(this.#read(), requested)\n\t\tif (matchesTerms(next, this.#read(), (order, other) => order.direction === other.direction)) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.#write(next)\n\t\tthis.#emitter.emit('sort', this.orders())\n\t}\n\n\t/** Stops sorting by every column. */\n\tremove(): void\n\t/** Stops sorting by one column. */\n\tremove(column: string): boolean\n\t/** Stops sorting by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stops 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: 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 next = removeTerms(this.#read(), columns)\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(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","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 { attempt } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { cloneRow, cloneSchema } from './cloners.js'\nimport { isTableError, 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/**\n * Holds a schema, its rows, and the lens through which they are read, implementing\n * {@link TableInterface} exactly.\n */\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 * Opens 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 unusable = 'The schema is not a table schema'\n\t\tconst owned = isStructuralTableSchema(schema) ? attempt(() => cloneSchema(schema)) : undefined\n\t\tif (owned !== undefined && !owned.success && isTableError(owned.error)) throw owned.error\n\t\tif (owned === undefined || !owned.success) {\n\t\t\tthrow new TableError('SCHEMA', `The table schema is unusable: ${unusable}`, {\n\t\t\t\tproblems: [unusable],\n\t\t\t})\n\t\t}\n\n\t\tconst problems = isStructuralTableSchema(owned.value) ? auditTable(owned.value) : [unusable]\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 = owned.value\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/** Holds the table's event emitter. */\n\tget emitter(): EmitterInterface<TableEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\t/** Holds the owned frozen schema. */\n\tget schema(): TableSchema {\n\t\treturn this.#schema\n\t}\n\n\t/** Manages the rows the table holds. */\n\tget rows(): RowManagerInterface {\n\t\treturn this.#rows\n\t}\n\n\t/** Manages the ordered sort terms. */\n\tget sort(): SortManagerInterface {\n\t\treturn this.#sort\n\t}\n\n\t/** Manages the filters applied with and-only composition. */\n\tget filter(): FilterManagerInterface {\n\t\treturn this.#filter\n\t}\n\n\t/** Manages the selected row keys. */\n\tget selection(): SelectionManagerInterface {\n\t\treturn this.#selection\n\t}\n\n\t/** Manages the expanded row keys. */\n\tget expansion(): ExpansionManagerInterface {\n\t\treturn this.#expansion\n\t}\n\n\t/** Manages the page arithmetic. */\n\tget pagination(): PaginationManagerInterface {\n\t\treturn this.#pagination\n\t}\n\n\t/** Returns 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/** Returns the number of rows admitted by the filters. */\n\tget count(): number {\n\t\treturn this.#filtered().length\n\t}\n\n\t/** Reports whether the table has been torn down. */\n\tget destroyed(): boolean {\n\t\treturn this.#destroyed\n\t}\n\n\t/** Resets 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/** Tears 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 * Opens a table against a schema. The schema is copied, and the copy is what the table declares.\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 Open a table\n * ```ts\n * import { createTable } from '@orkestrel/table'\n *\n * const table = createTable(\n * \t{\n * \t\tlabel: 'People',\n * \t\tkey: 'id',\n * \t\tcolumns: [\n * \t\t\t{ cell: 'text', key: 'id', label: 'Reference' },\n * \t\t\t{ cell: 'text', key: 'name', label: 'Name' },\n * \t\t\t{ cell: 'number', key: 'age', label: 'Age' },\n * \t\t],\n * \t},\n * \t{\n * \t\trows: [\n * \t\t\t{ id: '1', name: 'Ada', age: 36 },\n * \t\t\t{ id: '2', name: 'Grace', age: 45 },\n * \t\t\t{ id: '3', name: 'Alan', age: 41 },\n * \t\t],\n * \t\tlimit: 2,\n * \t},\n * )\n *\n * table.filter.set({ column: 'name', operator: 'contains', text: 'a' })\n * table.sort.set({ column: 'age', direction: 'descending' })\n *\n * table.count // 3 — every name holds a lowercase 'a'\n * table.pagination.count // 2 — two pages of two\n * table.view.map((row) => row.name) // ['Grace', 'Alan'] — page one, oldest first\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;;;;AAK5B,IAAa,aAAa;;AAG1B,IAAa,aAAa;;;;;;;ACpB1B,IAAa,aAAb,cAAgC,MAAM;;CAErC;;CAG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W,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,QAAQ,QAAQ,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;EAC5E,MAAM,kBAAkB,SAAS,SAAS,KAAK,UAAU;EACzD,MAAM,kBAAkB,SAAS,SAAS,KAAK,UAAU;EAEzD,IAAI,iBAAiB,KAAK,YAAY;EACtC,IAAI,iBAAiB,KAAK,YAAY;EACtC,MAAM,OAAO,KAAK,OAAO;EAEzB,SAAS;EACT,IAAI,iBAAiB,KAAK,SAAS,KAAK,UAAU,IAAI,IAAI,QAAQ,CAAC;EACnE,IAAI,iBAAiB,KAAK,SAAS,KAAK,UAAU,IAAI,IAAI,QAAQ,CAAC;EACnE,IAAI,SAAS,KAAA,GAAW,KAAK,SAAS,KAAK,YAAY,IAAI;CAC5D;CAEA,SAA6B;EAC5B,MAAM,OAAO,KAAK,IAAI,KAAK,OAAO,KAAK,YAAY,KAAK;EACxD,IAAI,SAAS,KAAK,OAAO,OAAO,KAAA;EAChC,KAAK,QAAQ;EACb,OAAO;CACR;CAEA,QAAc;EACb,IAAI,KAAK,YACR,MAAM,IAAI,WAAW,aAAa,2CAA2C;CAE/E;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrPA,SAAgB,YAAY,QAAqB,SAAwC;CACxF,OAAO,IAAI,MAAM,QAAQ,OAAO;AACjC"}
@@ -1,4 +1,4 @@
1
- import { arrayOf, attempt, cloneJSONRecord, isArray, isBoolean, isBoundedJSONRecord, isContractError, isFiniteNumber, isRecord, isString, parseNumber, readArrayEntries, recordOf, unionOf } from "@orkestrel/contract";
1
+ import { arrayOf, attempt, cloneJSONRecord, isArray, isBoolean, isBoundedJSONRecord, isContractError, isFiniteNumber, isInstance, isRecord, isString, parseNumber, readArrayEntries, recordOf, unionOf } from "@orkestrel/contract";
2
2
  import { Emitter } from "@orkestrel/emitter";
3
3
  //#region src/core/constants.ts
4
4
  /** Lists every column cell, in the order declared by the public contract. */
@@ -55,7 +55,7 @@ var TableError = class extends Error {
55
55
  * @returns True if the value is a {@link TableError} instance; false otherwise.
56
56
  */
57
57
  function isTableError(input) {
58
- return input instanceof TableError;
58
+ return isInstance(input, TableError);
59
59
  }
60
60
  //#endregion
61
61
  //#region src/core/helpers.ts
@@ -94,7 +94,7 @@ function extractKey(schema, row) {
94
94
  * set when membership changes.
95
95
  */
96
96
  function computeKeys(known, current, input, include) {
97
- const requested = input === void 0 ? known : Array.isArray(input) ? input : [input];
97
+ const requested = input === void 0 ? known : isArray(input) ? input : [input];
98
98
  const population = new Set(known);
99
99
  if (requested.some((key) => !population.has(key))) return void 0;
100
100
  const next = new Set(current);
@@ -801,7 +801,7 @@ var FilterManager = class {
801
801
  /** Filters one column or several. */
802
802
  set(input) {
803
803
  this.#gate();
804
- const requested = Array.isArray(input) ? input : [input];
804
+ const requested = isArray(input) ? input : [input];
805
805
  for (const filter of requested) this.#validate(filter);
806
806
  const next = mergeTerms(this.#read(), requested);
807
807
  if (matchesTerms(next, this.#read(), (filter, other) => this.#operands(filter, other))) return;
@@ -813,7 +813,7 @@ var FilterManager = class {
813
813
  /** Stops filtering by one or more columns. */
814
814
  remove(input) {
815
815
  this.#gate();
816
- const columns = input === void 0 ? this.#schema.columns.map((column) => column.key) : Array.isArray(input) ? input : [input];
816
+ const columns = input === void 0 ? this.#schema.columns.map((column) => column.key) : isArray(input) ? input : [input];
817
817
  for (const column of columns) if (extractColumn(this.#schema, column) === void 0) return false;
818
818
  const next = removeTerms(this.#read(), columns);
819
819
  if (next.length !== this.#read().length) {
@@ -908,7 +908,7 @@ var PaginationManager = class {
908
908
  this.#emitter.emit("paginate", nextPage);
909
909
  }
910
910
  #normalize(value) {
911
- return Number.isFinite(value) ? Math.max(1, Math.trunc(value)) : 1;
911
+ return isFiniteNumber(value) ? Math.max(1, Math.trunc(value)) : 1;
912
912
  }
913
913
  };
914
914
  //#endregion
@@ -954,7 +954,7 @@ var RowManager = class {
954
954
  /** Appends one row or several. */
955
955
  add(input) {
956
956
  this.#gate();
957
- const rows = Array.isArray(input) ? input : [input];
957
+ const rows = isArray(input) ? input : [input];
958
958
  const keys = /* @__PURE__ */ new Set();
959
959
  for (const row of this.#read()) {
960
960
  const key = extractKey(this.#schema, row);
@@ -973,7 +973,7 @@ var RowManager = class {
973
973
  /** Merges one row or several into the rows their keys name. */
974
974
  update(input) {
975
975
  this.#gate();
976
- const updates = (Array.isArray(input) ? input : [input]).map((row) => cloneRow(row));
976
+ const updates = (isArray(input) ? input : [input]).map((row) => cloneRow(row));
977
977
  const current = this.#read();
978
978
  const locations = [];
979
979
  for (const update of updates) {
@@ -1033,7 +1033,7 @@ var RowManager = class {
1033
1033
  const requested = input === void 0 ? current.flatMap((row) => {
1034
1034
  const key = extractKey(this.#schema, row);
1035
1035
  return key === void 0 ? [] : [key];
1036
- }) : Array.isArray(input) ? input : [input];
1036
+ }) : isArray(input) ? input : [input];
1037
1037
  const keys = new Set(requested);
1038
1038
  const known = new Set(current.flatMap((row) => {
1039
1039
  const key = extractKey(this.#schema, row);
@@ -1156,7 +1156,7 @@ var SortManager = class {
1156
1156
  /** Sorts by one column or several. */
1157
1157
  set(input) {
1158
1158
  this.#gate();
1159
- const requested = Array.isArray(input) ? input : [input];
1159
+ const requested = isArray(input) ? input : [input];
1160
1160
  for (const order of requested) this.#require(order.column);
1161
1161
  const next = mergeTerms(this.#read(), requested);
1162
1162
  if (matchesTerms(next, this.#read(), (order, other) => order.direction === other.direction)) return;
@@ -1166,7 +1166,7 @@ var SortManager = class {
1166
1166
  /** Stops sorting by one or more columns. */
1167
1167
  remove(input) {
1168
1168
  this.#gate();
1169
- const columns = input === void 0 ? this.#schema.columns.map((column) => column.key) : Array.isArray(input) ? input : [input];
1169
+ const columns = input === void 0 ? this.#schema.columns.map((column) => column.key) : isArray(input) ? input : [input];
1170
1170
  for (const column of columns) if (extractColumn(this.#schema, column) === void 0) return false;
1171
1171
  const next = removeTerms(this.#read(), columns);
1172
1172
  if (next.length !== this.#read().length) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"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/KeyManager.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/** Lists 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/** Names the maximum number of columns one schema may declare: 256. */\nexport const COLUMN_LIMIT = 256\n\n/** Names the maximum number of choices one `choice` column may offer: 1024. */\nexport const CHOICE_LIMIT = 1024\n\n/** Names the maximum length of a schema name or column key: 128 UTF-16 code units. */\nexport const NAME_LIMIT = 128\n\n/** Names the maximum length of any single retained string: 65536 UTF-16 code units. */\nexport const STRING_LIMIT = 65536\n\n/**\n * Names the maximum total length of every string one schema retains: 1048576 UTF-16 code units.\n */\nexport const TEXT_LIMIT = 1048576\n\n/** Names the maximum total number of records, arrays, and leaves one schema retains: 16384. */\nexport const NODE_LIMIT = 16384\n","import type { JSONRecord } from '@orkestrel/contract'\nimport type { TableErrorCode } from './types.js'\n\n/**\n * Represents an error raised by the table domain — a machine-readable `code` and optional\n * structured `context`.\n */\nexport class TableError extends Error {\n\t/** Holds the machine-readable reason for this failure. */\n\treadonly code: TableErrorCode\n\n\t/** Holds structured values that locate or explain this failure. */\n\treadonly context?: JSONRecord\n\n\t/**\n\t * Creates 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 * Determines whether a caught value is a table error, so a `catch` branches on `code` without an\n * assertion.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a {@link TableError} instance; false otherwise.\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\tTableTerm,\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 * Finds one column by key; `undefined` when the schema declares no such column.\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 * Reads one row's declared identity; `undefined` when its key cell is missing, empty, or not a\n * string.\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 * Computes one atomic 0/1/N membership change over the keys a caller may address — the engine\n * selection and expansion share.\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 * Merges lens terms into a column-keyed list, replacing the entry that names the same column —\n * the `set` write.\n *\n * @param current - The list as it stands.\n * @param requested - The terms to write, in the order they are written.\n * @returns A frozen list holding one owned entry per column, in the order the columns first\n * appeared.\n */\nexport function mergeTerms<Term extends TableTerm>(\n\tcurrent: readonly Term[],\n\trequested: readonly Term[],\n): readonly Term[] {\n\tconst next = [...current]\n\tfor (const term of requested) {\n\t\tconst owned = Object.freeze({ ...term })\n\t\tconst index = next.findIndex((candidate) => candidate.column === term.column)\n\t\tif (index === -1) next.push(owned)\n\t\telse next[index] = owned\n\t}\n\n\treturn Object.freeze(next)\n}\n\n/**\n * Removes every lens term naming one of the given columns — the drop `sort.remove` and\n * `filter.remove` share.\n *\n * @param current - The list as it stands.\n * @param columns - The column keys to drop.\n * @returns A frozen list holding the entries no named column matched, in their original order.\n */\nexport function removeTerms<Term extends TableTerm>(\n\tcurrent: readonly Term[],\n\tcolumns: readonly string[],\n): readonly Term[] {\n\tconst removed = new Set(columns)\n\treturn Object.freeze(current.filter((term) => !removed.has(term.column)))\n}\n\n/**\n * Checks whether two lens lists hold the same terms in the same order, with the supplied test\n * deciding the operands.\n *\n * @param left - The first list.\n * @param right - The second list.\n * @param equal - Decide whether two terms naming one column carry the same operands.\n * @returns True if the lists are the same length and every position names the same column and\n * carries the same operands; false otherwise.\n */\nexport function matchesTerms<Term extends TableTerm>(\n\tleft: readonly Term[],\n\tright: readonly Term[],\n\tequal: (left: Term, right: Term) => boolean,\n): boolean {\n\treturn (\n\t\tleft.length === right.length &&\n\t\tleft.every((term, index) => {\n\t\t\tconst other = right[index]\n\t\t\treturn other !== undefined && term.column === other.column && equal(term, other)\n\t\t})\n\t)\n}\n\n/**\n * Checks whether one column can hold a value — the shape gate every write and every seed passes\n * through.\n *\n * @param column - The column that owns the cell.\n * @param value - The unknown value to inspect.\n * @returns True if the column can hold the value; false otherwise.\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 * Compares two of one column's cells the way its `cell` fixes, describing ascending order.\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 * Checks whether one column admits a filter and every operand it carries — the gate `filter.set`\n * and {@link matchesFilter} share.\n *\n * @param column - The column that fixes the accepted operators and cell shapes.\n * @param filter - The filter to inspect.\n * @returns True if the filter belongs to the column and the column can apply it; false otherwise.\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 * Tests one of a column's cells against one filter the way its `cell` fixes.\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 True if the filter accepts the cell; false otherwise.\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 * Keeps the rows every filter accepts, in the order given; a supplied {@link CellMatcher}\n * replaces the default per column.\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 * Orders rows by the terms given, stably; a supplied {@link CellComparator} replaces the default\n * per column.\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 * Audits a structurally valid schema for domain faults and budget breaches, returning human\n * diagnostics.\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 * Projects a schema into JSON in declaration order, dropping every absent member; raises `SCHEMA`\n * for a `meta` it cannot own.\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 * Projects rows into JSON with each row's cells in the schema's column order, dropping every\n * absent cell.\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 * Determines whether an unknown value has a table cell shape — a string, a finite number, or a\n * boolean.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a string, finite number, or boolean; false otherwise.\n */\nexport function isTableCell(input: unknown): input is TableCell {\n\treturn unionOf(isString, isFiniteNumber, isBoolean)(input)\n}\n\n/**\n * Determines whether an unknown value is a record whose every own key is a string and every value\n * a {@link TableCell}.\n *\n * @param input - The value to inspect.\n * @returns True if every own key is a string and every value is a table cell; false otherwise.\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 * Determines whether an unknown value is a declared column cell.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a declared column cell; false otherwise.\n */\nexport function isColumnCell(input: unknown): input is ColumnCell {\n\treturn COLUMN_CELLS.some((cell) => cell === input)\n}\n\n/**\n * Determines whether an unknown value is one exact {@link ColumnChoice} record; an unknown member\n * refuses it.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a column choice; false otherwise.\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 * Determines whether an unknown value is one exact discriminated {@link TableColumn}, checked\n * against its cell's own options.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a structurally valid table column; false otherwise.\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 * Determines whether an unknown value has the exact shape of a {@link TableSchema} — the shape\n * alone, with no domain check.\n *\n * @param input - The value to inspect.\n * @returns True if the value has the exact structure of a table schema; false otherwise.\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 * Determines whether an unknown value is a {@link TableSchema} a table can be opened against —\n * the exact shape, and an audit that finds nothing.\n *\n * @param input - The value to inspect.\n * @returns True if the value has valid structure, domain relationships, and\n * budgets; false otherwise.\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 * Clones 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 * Clones a whole schema into an owned frozen snapshot, freezing every nested column, choice list,\n * choice, and `meta`; raises `SCHEMA` for a `meta` it cannot own.\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 * Parses unknown wire data into an owned, structurally valid, 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 * Parses unknown wire data into owned rows against one table schema, coercing a numeric string\n * and `'true'` / `'false'`.\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 { TableEventMap, TableKey } from '../types.js'\nimport { computeKeys } from '../helpers.js'\n\n/** Manages the key set one table axis holds, and the event it announces when that set moves. */\nexport class KeyManager {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #event: 'select' | 'expand'\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 * Creates a key-set shell over one table's private store.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param event - The event this axis announces when its key set moves.\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 held keys.\n\t * @param write - The held-key commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tevent: 'select' | 'expand',\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.#event = event\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/** Returns the keys held right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn new Set(this.#read())\n\t}\n\n\t/**\n\t * Applies one atomic 0/1/N membership change, announcing it only when the set moves.\n\t *\n\t * @param input - Every known key, one key, or a key list.\n\t * @param include - Decides the next membership from each key's membership at that step.\n\t * @returns `undefined` for the no-argument form, `false` when any requested key names no row\n\t * the table holds, and `true` otherwise.\n\t */\n\tchange(\n\t\tinput: TableKey | readonly TableKey[] | undefined,\n\t\tinclude: (included: boolean) => boolean,\n\t): void | boolean {\n\t\tthis.#gate()\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(this.#event, 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 { ExpansionManagerInterface, TableEventMap, TableKey } from '../types.js'\nimport { KeyManager } from './KeyManager.js'\n\n/** Manages the keys of the rows somebody has opened. */\nexport class ExpansionManager implements ExpansionManagerInterface {\n\treadonly #keys: KeyManager\n\n\t/**\n\t * Creates 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.#keys = new KeyManager(emitter, 'expand', gate, rows, read, write)\n\t}\n\n\t/** Returns the keys of the rows opened right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn this.#keys.keys\n\t}\n\n\t/** Opens every row the table holds. */\n\texpand(): void\n\t/** Opens one row. */\n\texpand(key: TableKey): boolean\n\t/** Opens several rows. */\n\texpand(keys: readonly TableKey[]): boolean\n\t/** Opens one or more rows. */\n\texpand(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => true)\n\t}\n\n\t/** Closes every row. */\n\tclear(): void\n\t/** Closes one row. */\n\tclear(key: TableKey): boolean\n\t/** Closes several rows. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Closes one or more rows. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => false)\n\t}\n\n\t/** Opens one row or closes it when already open. */\n\ttoggle(key: TableKey): boolean\n\t/** Turns several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turns one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\treturn this.#keys.change(input, (included) => !included) === 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, matchesTerms, mergeTerms, removeTerms } from '../helpers.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Filters several columns. */\n\tset(filters: readonly TableFilter[]): void\n\t/** Filters one column. */\n\tset(filter: TableFilter): void\n\t/** Filters 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 = mergeTerms(this.#read(), requested)\n\t\tif (matchesTerms(next, this.#read(), (filter, other) => this.#operands(filter, other))) return\n\t\tthis.#write(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/** Stops filtering by every column. */\n\tremove(): void\n\t/** Stops filtering by one column. */\n\tremove(column: string): boolean\n\t/** Stops filtering by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stops 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 next = removeTerms(this.#read(), columns)\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(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#operands(left: TableFilter, right: TableFilter): boolean {\n\t\tif (left.operator !== right.operator) return false\n\t\tif (left.operator === 'contains' && right.operator === 'contains') {\n\t\t\treturn left.text === right.text\n\t\t}\n\t\tif (left.operator === 'between' && right.operator === 'between') {\n\t\t\treturn left.minimum === right.minimum && left.maximum === right.maximum\n\t\t}\n\t\treturn left.operator === 'equals' && right.operator === 'equals' && left.value === right.value\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { PaginationManagerInterface, TableEventMap } from '../types.js'\n\n/** Manages 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 * Creates 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/** Returns the page shown, counted from one. */\n\tget page(): number {\n\t\treturn this.#readLimit() === undefined ? 1 : this.#readPage()\n\t}\n\n\t/** Returns the number of rows one page holds. */\n\tget limit(): number | undefined {\n\t\treturn this.#readLimit()\n\t}\n\n\t/** Returns 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/** Returns 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/** Shows another page, clamped to the pages that exist. */\n\tmove(page: number): void {\n\t\tthis.#gate()\n\t\tconst next =\n\t\t\tthis.#readLimit() === undefined || Number.isNaN(page)\n\t\t\t\t? 1\n\t\t\t\t: Math.min(this.count, Math.max(1, Math.trunc(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/** Changes 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/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Appends several rows. */\n\tadd(rows: readonly TableRow[]): void\n\t/** Appends one row. */\n\tadd(row: TableRow): void\n\t/** Appends 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/** Merges several rows into the rows their keys name. */\n\tupdate(rows: readonly TableRow[]): boolean\n\t/** Merges one row into the row its key names. */\n\tupdate(row: TableRow): boolean\n\t/** Merges 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/** Moves 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.isNaN(index) ? 0 : Math.max(0, Math.trunc(index)),\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/** Removes every row. */\n\tremove(): void\n\t/** Removes one row. */\n\tremove(key: TableKey): boolean\n\t/** Removes several rows. */\n\tremove(keys: readonly TableKey[]): boolean\n\t/** Removes 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 { KeyManager } from './KeyManager.js'\n\n/** Manages the keys of the rows somebody has picked. */\nexport class SelectionManager implements SelectionManagerInterface {\n\treadonly #keys: KeyManager\n\n\t/**\n\t * Creates 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.#keys = new KeyManager(emitter, 'select', gate, rows, read, write)\n\t}\n\n\t/** Returns the keys of the rows picked right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn this.#keys.keys\n\t}\n\n\t/** Picks every row the table holds. */\n\tselect(): void\n\t/** Picks one row. */\n\tselect(key: TableKey): boolean\n\t/** Picks several rows. */\n\tselect(keys: readonly TableKey[]): boolean\n\t/** Picks one or more rows. */\n\tselect(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => true)\n\t}\n\n\t/** Drops every pick. */\n\tclear(): void\n\t/** Drops one pick. */\n\tclear(key: TableKey): boolean\n\t/** Drops several picks. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Drops one or more picks. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => false)\n\t}\n\n\t/** Picks one row or drops it when already picked. */\n\ttoggle(key: TableKey): boolean\n\t/** Turns several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turns one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\treturn this.#keys.change(input, (included) => !included) === 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, matchesTerms, mergeTerms, removeTerms } from '../helpers.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Sorts by several columns. */\n\tset(orders: readonly TableOrder[]): void\n\t/** Sorts by one column. */\n\tset(order: TableOrder): void\n\t/** Sorts 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 = mergeTerms(this.#read(), requested)\n\t\tif (matchesTerms(next, this.#read(), (order, other) => order.direction === other.direction)) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.#write(next)\n\t\tthis.#emitter.emit('sort', this.orders())\n\t}\n\n\t/** Stops sorting by every column. */\n\tremove(): void\n\t/** Stops sorting by one column. */\n\tremove(column: string): boolean\n\t/** Stops sorting by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stops 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 next = removeTerms(this.#read(), columns)\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(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","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 { attempt } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { cloneRow, cloneSchema } from './cloners.js'\nimport { isTableError, 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/**\n * Holds a schema, its rows, and the lens through which they are read, implementing\n * {@link TableInterface} exactly.\n */\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 * Opens 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 unusable = 'The schema is not a table schema'\n\t\tconst owned = isStructuralTableSchema(schema) ? attempt(() => cloneSchema(schema)) : undefined\n\t\tif (owned !== undefined && !owned.success && isTableError(owned.error)) throw owned.error\n\t\tif (owned === undefined || !owned.success) {\n\t\t\tthrow new TableError('SCHEMA', `The table schema is unusable: ${unusable}`, {\n\t\t\t\tproblems: [unusable],\n\t\t\t})\n\t\t}\n\n\t\tconst problems = isStructuralTableSchema(owned.value) ? auditTable(owned.value) : [unusable]\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 = owned.value\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/** Holds the table's event emitter. */\n\tget emitter(): EmitterInterface<TableEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\t/** Holds the owned frozen schema. */\n\tget schema(): TableSchema {\n\t\treturn this.#schema\n\t}\n\n\t/** Manages the rows the table holds. */\n\tget rows(): RowManagerInterface {\n\t\treturn this.#rows\n\t}\n\n\t/** Manages the ordered sort terms. */\n\tget sort(): SortManagerInterface {\n\t\treturn this.#sort\n\t}\n\n\t/** Manages the filters applied with and-only composition. */\n\tget filter(): FilterManagerInterface {\n\t\treturn this.#filter\n\t}\n\n\t/** Manages the selected row keys. */\n\tget selection(): SelectionManagerInterface {\n\t\treturn this.#selection\n\t}\n\n\t/** Manages the expanded row keys. */\n\tget expansion(): ExpansionManagerInterface {\n\t\treturn this.#expansion\n\t}\n\n\t/** Manages the page arithmetic. */\n\tget pagination(): PaginationManagerInterface {\n\t\treturn this.#pagination\n\t}\n\n\t/** Returns 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/** Returns the number of rows admitted by the filters. */\n\tget count(): number {\n\t\treturn this.#filtered().length\n\t}\n\n\t/** Reports whether the table has been torn down. */\n\tget destroyed(): boolean {\n\t\treturn this.#destroyed\n\t}\n\n\t/** Resets 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/** Tears 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 * Opens a table against a schema. The schema is copied, and the copy is what the table declares.\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 Open a table\n * ```ts\n * import { createTable } from '@orkestrel/table'\n *\n * const table = createTable(\n * \t{\n * \t\tlabel: 'People',\n * \t\tkey: 'id',\n * \t\tcolumns: [\n * \t\t\t{ cell: 'text', key: 'id', label: 'Reference' },\n * \t\t\t{ cell: 'text', key: 'name', label: 'Name' },\n * \t\t\t{ cell: 'number', key: 'age', label: 'Age' },\n * \t\t],\n * \t},\n * \t{\n * \t\trows: [\n * \t\t\t{ id: '1', name: 'Ada', age: 36 },\n * \t\t\t{ id: '2', name: 'Grace', age: 45 },\n * \t\t\t{ id: '3', name: 'Alan', age: 41 },\n * \t\t],\n * \t\tlimit: 2,\n * \t},\n * )\n *\n * table.filter.set({ column: 'name', operator: 'contains', text: 'a' })\n * table.sort.set({ column: 'age', direction: 'descending' })\n *\n * table.count // 3 — every name holds a lowercase 'a'\n * table.pagination.count // 2 — two pages of two\n * table.view.map((row) => row.name) // ['Grace', 'Alan'] — page one, oldest first\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;;;;AAK5B,IAAa,aAA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BAAkB,SAAS,SAAS,KAAK,UAAU;EACzD,MAAM,kBAAkB,SAAS,SAAS,KAAK,UAAU;EAEzD,IAAI,iBAAiB,KAAK,YAAY;EACtC,IAAI,iBAAiB,KAAK,YAAY;EACtC,MAAM,OAAO,KAAK,OAAO;EAEzB,SAAS;EACT,IAAI,iBAAiB,KAAK,SAAS,KAAK,UAAU,IAAI,IAAI,QAAQ,CAAC;EACnE,IAAI,iBAAiB,KAAK,SAAS,KAAK,UAAU,IAAI,IAAI,QAAQ,CAAC;EACnE,IAAI,SAAS,KAAA,GAAW,KAAK,SAAS,KAAK,YAAY,IAAI;CAC5D;CAEA,SAA6B;EAC5B,MAAM,OAAO,KAAK,IAAI,KAAK,OAAO,KAAK,YAAY,KAAK;EACxD,IAAI,SAAS,KAAK,OAAO,OAAO,KAAA;EAChC,KAAK,QAAQ;EACb,OAAO;CACR;CAEA,QAAc;EACb,IAAI,KAAK,YACR,MAAM,IAAI,WAAW,aAAa,2CAA2C;CAE/E;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrPA,SAAgB,YAAY,QAAqB,SAAwC;CACxF,OAAO,IAAI,MAAM,QAAQ,OAAO;AACjC"}
1
+ {"version":3,"file":"index.js","names":[],"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/KeyManager.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/** Lists 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/** Names the maximum number of columns one schema may declare: 256. */\nexport const COLUMN_LIMIT = 256\n\n/** Names the maximum number of choices one `choice` column may offer: 1024. */\nexport const CHOICE_LIMIT = 1024\n\n/** Names the maximum length of a schema name or column key: 128 UTF-16 code units. */\nexport const NAME_LIMIT = 128\n\n/** Names the maximum length of any single retained string: 65536 UTF-16 code units. */\nexport const STRING_LIMIT = 65536\n\n/**\n * Names the maximum total length of every string one schema retains: 1048576 UTF-16 code units.\n */\nexport const TEXT_LIMIT = 1048576\n\n/** Names the maximum total number of records, arrays, and leaves one schema retains: 16384. */\nexport const NODE_LIMIT = 16384\n","import type { JSONRecord } from '@orkestrel/contract'\nimport { isInstance } from '@orkestrel/contract'\nimport type { TableErrorCode } from './types.js'\n\n/**\n * Represents an error raised by the table domain — a machine-readable `code` and optional\n * structured `context`.\n */\nexport class TableError extends Error {\n\t/** Holds the machine-readable reason for this failure. */\n\treadonly code: TableErrorCode\n\n\t/** Holds structured values that locate or explain this failure. */\n\treadonly context?: JSONRecord\n\n\t/**\n\t * Creates 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 * Determines whether a caught value is a table error, so a `catch` branches on `code` without an\n * assertion.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a {@link TableError} instance; false otherwise.\n */\nexport function isTableError(input: unknown): input is TableError {\n\treturn isInstance(input, 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\tTableTerm,\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 * Finds one column by key; `undefined` when the schema declares no such column.\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 * Reads one row's declared identity; `undefined` when its key cell is missing, empty, or not a\n * string.\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 * Computes one atomic 0/1/N membership change over the keys a caller may address — the engine\n * selection and expansion share.\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 : 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 * Merges lens terms into a column-keyed list, replacing the entry that names the same column —\n * the `set` write.\n *\n * @param current - The list as it stands.\n * @param requested - The terms to write, in the order they are written.\n * @returns A frozen list holding one owned entry per column, in the order the columns first\n * appeared.\n */\nexport function mergeTerms<Term extends TableTerm>(\n\tcurrent: readonly Term[],\n\trequested: readonly Term[],\n): readonly Term[] {\n\tconst next = [...current]\n\tfor (const term of requested) {\n\t\tconst owned = Object.freeze({ ...term })\n\t\tconst index = next.findIndex((candidate) => candidate.column === term.column)\n\t\tif (index === -1) next.push(owned)\n\t\telse next[index] = owned\n\t}\n\n\treturn Object.freeze(next)\n}\n\n/**\n * Removes every lens term naming one of the given columns — the drop `sort.remove` and\n * `filter.remove` share.\n *\n * @param current - The list as it stands.\n * @param columns - The column keys to drop.\n * @returns A frozen list holding the entries no named column matched, in their original order.\n */\nexport function removeTerms<Term extends TableTerm>(\n\tcurrent: readonly Term[],\n\tcolumns: readonly string[],\n): readonly Term[] {\n\tconst removed = new Set(columns)\n\treturn Object.freeze(current.filter((term) => !removed.has(term.column)))\n}\n\n/**\n * Checks whether two lens lists hold the same terms in the same order, with the supplied test\n * deciding the operands.\n *\n * @param left - The first list.\n * @param right - The second list.\n * @param equal - Decide whether two terms naming one column carry the same operands.\n * @returns True if the lists are the same length and every position names the same column and\n * carries the same operands; false otherwise.\n */\nexport function matchesTerms<Term extends TableTerm>(\n\tleft: readonly Term[],\n\tright: readonly Term[],\n\tequal: (left: Term, right: Term) => boolean,\n): boolean {\n\treturn (\n\t\tleft.length === right.length &&\n\t\tleft.every((term, index) => {\n\t\t\tconst other = right[index]\n\t\t\treturn other !== undefined && term.column === other.column && equal(term, other)\n\t\t})\n\t)\n}\n\n/**\n * Checks whether one column can hold a value — the shape gate every write and every seed passes\n * through.\n *\n * @param column - The column that owns the cell.\n * @param value - The unknown value to inspect.\n * @returns True if the column can hold the value; false otherwise.\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 * Compares two of one column's cells the way its `cell` fixes, describing ascending order.\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 * Checks whether one column admits a filter and every operand it carries — the gate `filter.set`\n * and {@link matchesFilter} share.\n *\n * @param column - The column that fixes the accepted operators and cell shapes.\n * @param filter - The filter to inspect.\n * @returns True if the filter belongs to the column and the column can apply it; false otherwise.\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 * Tests one of a column's cells against one filter the way its `cell` fixes.\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 True if the filter accepts the cell; false otherwise.\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 * Keeps the rows every filter accepts, in the order given; a supplied {@link CellMatcher}\n * replaces the default per column.\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 * Orders rows by the terms given, stably; a supplied {@link CellComparator} replaces the default\n * per column.\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 * Audits a structurally valid schema for domain faults and budget breaches, returning human\n * diagnostics.\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 * Projects a schema into JSON in declaration order, dropping every absent member; raises `SCHEMA`\n * for a `meta` it cannot own.\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 * Projects rows into JSON with each row's cells in the schema's column order, dropping every\n * absent cell.\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 * Determines whether an unknown value has a table cell shape — a string, a finite number, or a\n * boolean.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a string, finite number, or boolean; false otherwise.\n */\nexport function isTableCell(input: unknown): input is TableCell {\n\treturn unionOf(isString, isFiniteNumber, isBoolean)(input)\n}\n\n/**\n * Determines whether an unknown value is a record whose every own key is a string and every value\n * a {@link TableCell}.\n *\n * @param input - The value to inspect.\n * @returns True if every own key is a string and every value is a table cell; false otherwise.\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 * Determines whether an unknown value is a declared column cell.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a declared column cell; false otherwise.\n */\nexport function isColumnCell(input: unknown): input is ColumnCell {\n\treturn COLUMN_CELLS.some((cell) => cell === input)\n}\n\n/**\n * Determines whether an unknown value is one exact {@link ColumnChoice} record; an unknown member\n * refuses it.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a column choice; false otherwise.\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 * Determines whether an unknown value is one exact discriminated {@link TableColumn}, checked\n * against its cell's own options.\n *\n * @param input - The value to inspect.\n * @returns True if the value is a structurally valid table column; false otherwise.\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 * Determines whether an unknown value has the exact shape of a {@link TableSchema} — the shape\n * alone, with no domain check.\n *\n * @param input - The value to inspect.\n * @returns True if the value has the exact structure of a table schema; false otherwise.\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 * Determines whether an unknown value is a {@link TableSchema} a table can be opened against —\n * the exact shape, and an audit that finds nothing.\n *\n * @param input - The value to inspect.\n * @returns True if the value has valid structure, domain relationships, and\n * budgets; false otherwise.\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 * Clones 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 * Clones a whole schema into an owned frozen snapshot, freezing every nested column, choice list,\n * choice, and `meta`; raises `SCHEMA` for a `meta` it cannot own.\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 * Parses unknown wire data into an owned, structurally valid, 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 * Parses unknown wire data into owned rows against one table schema, coercing a numeric string\n * and `'true'` / `'false'`.\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 { TableEventMap, TableKey } from '../types.js'\nimport { computeKeys } from '../helpers.js'\n\n/** Manages the key set one table axis holds, and the event it announces when that set moves. */\nexport class KeyManager {\n\treadonly #emitter: Emitter<TableEventMap>\n\treadonly #event: 'select' | 'expand'\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 * Creates a key-set shell over one table's private store.\n\t *\n\t * @param emitter - The table's event emitter.\n\t * @param event - The event this axis announces when its key set moves.\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 held keys.\n\t * @param write - The held-key commit boundary.\n\t */\n\tconstructor(\n\t\temitter: Emitter<TableEventMap>,\n\t\tevent: 'select' | 'expand',\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.#event = event\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/** Returns the keys held right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn new Set(this.#read())\n\t}\n\n\t/**\n\t * Applies one atomic 0/1/N membership change, announcing it only when the set moves.\n\t *\n\t * @param input - Every known key, one key, or a key list.\n\t * @param include - Decides the next membership from each key's membership at that step.\n\t * @returns `undefined` for the no-argument form, `false` when any requested key names no row\n\t * the table holds, and `true` otherwise.\n\t */\n\tchange(\n\t\tinput: TableKey | readonly TableKey[] | undefined,\n\t\tinclude: (included: boolean) => boolean,\n\t): void | boolean {\n\t\tthis.#gate()\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(this.#event, 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 { ExpansionManagerInterface, TableEventMap, TableKey } from '../types.js'\nimport { KeyManager } from './KeyManager.js'\n\n/** Manages the keys of the rows somebody has opened. */\nexport class ExpansionManager implements ExpansionManagerInterface {\n\treadonly #keys: KeyManager\n\n\t/**\n\t * Creates 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.#keys = new KeyManager(emitter, 'expand', gate, rows, read, write)\n\t}\n\n\t/** Returns the keys of the rows opened right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn this.#keys.keys\n\t}\n\n\t/** Opens every row the table holds. */\n\texpand(): void\n\t/** Opens one row. */\n\texpand(key: TableKey): boolean\n\t/** Opens several rows. */\n\texpand(keys: readonly TableKey[]): boolean\n\t/** Opens one or more rows. */\n\texpand(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => true)\n\t}\n\n\t/** Closes every row. */\n\tclear(): void\n\t/** Closes one row. */\n\tclear(key: TableKey): boolean\n\t/** Closes several rows. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Closes one or more rows. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => false)\n\t}\n\n\t/** Opens one row or closes it when already open. */\n\ttoggle(key: TableKey): boolean\n\t/** Turns several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turns one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\treturn this.#keys.change(input, (included) => !included) === true\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { FilterManagerInterface, TableEventMap, TableFilter, TableSchema } from '../types.js'\nimport { isArray } from '@orkestrel/contract'\nimport { TableError } from '../errors.js'\nimport { admitsFilter, extractColumn, matchesTerms, mergeTerms, removeTerms } from '../helpers.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Filters several columns. */\n\tset(filters: readonly TableFilter[]): void\n\t/** Filters one column. */\n\tset(filter: TableFilter): void\n\t/** Filters one column or several. */\n\tset(input: TableFilter | readonly TableFilter[]): void {\n\t\tthis.#gate()\n\t\tconst requested = isArray(input) ? input : [input]\n\t\tfor (const filter of requested) this.#validate(filter)\n\n\t\tconst next = mergeTerms(this.#read(), requested)\n\t\tif (matchesTerms(next, this.#read(), (filter, other) => this.#operands(filter, other))) return\n\t\tthis.#write(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/** Stops filtering by every column. */\n\tremove(): void\n\t/** Stops filtering by one column. */\n\tremove(column: string): boolean\n\t/** Stops filtering by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stops 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: 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 next = removeTerms(this.#read(), columns)\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(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#operands(left: TableFilter, right: TableFilter): boolean {\n\t\tif (left.operator !== right.operator) return false\n\t\tif (left.operator === 'contains' && right.operator === 'contains') {\n\t\t\treturn left.text === right.text\n\t\t}\n\t\tif (left.operator === 'between' && right.operator === 'between') {\n\t\t\treturn left.minimum === right.minimum && left.maximum === right.maximum\n\t\t}\n\t\treturn left.operator === 'equals' && right.operator === 'equals' && left.value === right.value\n\t}\n}\n","import { isFiniteNumber } from '@orkestrel/contract'\nimport type { Emitter } from '@orkestrel/emitter'\nimport type { PaginationManagerInterface, TableEventMap } from '../types.js'\n\n/** Manages 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 * Creates 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/** Returns the page shown, counted from one. */\n\tget page(): number {\n\t\treturn this.#readLimit() === undefined ? 1 : this.#readPage()\n\t}\n\n\t/** Returns the number of rows one page holds. */\n\tget limit(): number | undefined {\n\t\treturn this.#readLimit()\n\t}\n\n\t/** Returns 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/** Returns 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/** Shows another page, clamped to the pages that exist. */\n\tmove(page: number): void {\n\t\tthis.#gate()\n\t\tconst next =\n\t\t\tthis.#readLimit() === undefined || Number.isNaN(page)\n\t\t\t\t? 1\n\t\t\t\t: Math.min(this.count, Math.max(1, Math.trunc(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/** Changes 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 isFiniteNumber(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 { isArray } from '@orkestrel/contract'\nimport { cloneRow } from '../cloners.js'\nimport { TableError } from '../errors.js'\nimport { extractColumn, extractKey, matchesCell } from '../helpers.js'\nimport { isTableRow } from '../validators.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Appends several rows. */\n\tadd(rows: readonly TableRow[]): void\n\t/** Appends one row. */\n\tadd(row: TableRow): void\n\t/** Appends one row or several. */\n\tadd(input: TableRow | readonly TableRow[]): void {\n\t\tthis.#gate()\n\t\tconst rows = 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/** Merges several rows into the rows their keys name. */\n\tupdate(rows: readonly TableRow[]): boolean\n\t/** Merges one row into the row its key names. */\n\tupdate(row: TableRow): boolean\n\t/** Merges 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 = (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/** Moves 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.isNaN(index) ? 0 : Math.max(0, Math.trunc(index)),\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/** Removes every row. */\n\tremove(): void\n\t/** Removes one row. */\n\tremove(key: TableKey): boolean\n\t/** Removes several rows. */\n\tremove(keys: readonly TableKey[]): boolean\n\t/** Removes 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: 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 { KeyManager } from './KeyManager.js'\n\n/** Manages the keys of the rows somebody has picked. */\nexport class SelectionManager implements SelectionManagerInterface {\n\treadonly #keys: KeyManager\n\n\t/**\n\t * Creates 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.#keys = new KeyManager(emitter, 'select', gate, rows, read, write)\n\t}\n\n\t/** Returns the keys of the rows picked right now. */\n\tget keys(): ReadonlySet<TableKey> {\n\t\treturn this.#keys.keys\n\t}\n\n\t/** Picks every row the table holds. */\n\tselect(): void\n\t/** Picks one row. */\n\tselect(key: TableKey): boolean\n\t/** Picks several rows. */\n\tselect(keys: readonly TableKey[]): boolean\n\t/** Picks one or more rows. */\n\tselect(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => true)\n\t}\n\n\t/** Drops every pick. */\n\tclear(): void\n\t/** Drops one pick. */\n\tclear(key: TableKey): boolean\n\t/** Drops several picks. */\n\tclear(keys: readonly TableKey[]): boolean\n\t/** Drops one or more picks. */\n\tclear(input?: TableKey | readonly TableKey[]): void | boolean {\n\t\treturn this.#keys.change(input, () => false)\n\t}\n\n\t/** Picks one row or drops it when already picked. */\n\ttoggle(key: TableKey): boolean\n\t/** Turns several rows around independently. */\n\ttoggle(keys: readonly TableKey[]): boolean\n\t/** Turns one or more rows around independently. */\n\ttoggle(input: TableKey | readonly TableKey[]): boolean {\n\t\treturn this.#keys.change(input, (included) => !included) === true\n\t}\n}\n","import type { Emitter } from '@orkestrel/emitter'\nimport type { SortManagerInterface, TableEventMap, TableOrder, TableSchema } from '../types.js'\nimport { isArray } from '@orkestrel/contract'\nimport { TableError } from '../errors.js'\nimport { extractColumn, matchesTerms, mergeTerms, removeTerms } from '../helpers.js'\n\n/** Manages 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 * Creates 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/** Finds 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/** Reads 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/** Sorts by several columns. */\n\tset(orders: readonly TableOrder[]): void\n\t/** Sorts by one column. */\n\tset(order: TableOrder): void\n\t/** Sorts by one column or several. */\n\tset(input: TableOrder | readonly TableOrder[]): void {\n\t\tthis.#gate()\n\t\tconst requested = isArray(input) ? input : [input]\n\t\tfor (const order of requested) this.#require(order.column)\n\n\t\tconst next = mergeTerms(this.#read(), requested)\n\t\tif (matchesTerms(next, this.#read(), (order, other) => order.direction === other.direction)) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.#write(next)\n\t\tthis.#emitter.emit('sort', this.orders())\n\t}\n\n\t/** Stops sorting by every column. */\n\tremove(): void\n\t/** Stops sorting by one column. */\n\tremove(column: string): boolean\n\t/** Stops sorting by several columns. */\n\tremove(columns: readonly string[]): boolean\n\t/** Stops 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: 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 next = removeTerms(this.#read(), columns)\n\t\tif (next.length !== this.#read().length) {\n\t\t\tthis.#write(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","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 { attempt } from '@orkestrel/contract'\nimport { Emitter } from '@orkestrel/emitter'\nimport { cloneRow, cloneSchema } from './cloners.js'\nimport { isTableError, 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/**\n * Holds a schema, its rows, and the lens through which they are read, implementing\n * {@link TableInterface} exactly.\n */\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 * Opens 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 unusable = 'The schema is not a table schema'\n\t\tconst owned = isStructuralTableSchema(schema) ? attempt(() => cloneSchema(schema)) : undefined\n\t\tif (owned !== undefined && !owned.success && isTableError(owned.error)) throw owned.error\n\t\tif (owned === undefined || !owned.success) {\n\t\t\tthrow new TableError('SCHEMA', `The table schema is unusable: ${unusable}`, {\n\t\t\t\tproblems: [unusable],\n\t\t\t})\n\t\t}\n\n\t\tconst problems = isStructuralTableSchema(owned.value) ? auditTable(owned.value) : [unusable]\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 = owned.value\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/** Holds the table's event emitter. */\n\tget emitter(): EmitterInterface<TableEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\t/** Holds the owned frozen schema. */\n\tget schema(): TableSchema {\n\t\treturn this.#schema\n\t}\n\n\t/** Manages the rows the table holds. */\n\tget rows(): RowManagerInterface {\n\t\treturn this.#rows\n\t}\n\n\t/** Manages the ordered sort terms. */\n\tget sort(): SortManagerInterface {\n\t\treturn this.#sort\n\t}\n\n\t/** Manages the filters applied with and-only composition. */\n\tget filter(): FilterManagerInterface {\n\t\treturn this.#filter\n\t}\n\n\t/** Manages the selected row keys. */\n\tget selection(): SelectionManagerInterface {\n\t\treturn this.#selection\n\t}\n\n\t/** Manages the expanded row keys. */\n\tget expansion(): ExpansionManagerInterface {\n\t\treturn this.#expansion\n\t}\n\n\t/** Manages the page arithmetic. */\n\tget pagination(): PaginationManagerInterface {\n\t\treturn this.#pagination\n\t}\n\n\t/** Returns 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/** Returns the number of rows admitted by the filters. */\n\tget count(): number {\n\t\treturn this.#filtered().length\n\t}\n\n\t/** Reports whether the table has been torn down. */\n\tget destroyed(): boolean {\n\t\treturn this.#destroyed\n\t}\n\n\t/** Resets 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/** Tears 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 * Opens a table against a schema. The schema is copied, and the copy is what the table declares.\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 Open a table\n * ```ts\n * import { createTable } from '@orkestrel/table'\n *\n * const table = createTable(\n * \t{\n * \t\tlabel: 'People',\n * \t\tkey: 'id',\n * \t\tcolumns: [\n * \t\t\t{ cell: 'text', key: 'id', label: 'Reference' },\n * \t\t\t{ cell: 'text', key: 'name', label: 'Name' },\n * \t\t\t{ cell: 'number', key: 'age', label: 'Age' },\n * \t\t],\n * \t},\n * \t{\n * \t\trows: [\n * \t\t\t{ id: '1', name: 'Ada', age: 36 },\n * \t\t\t{ id: '2', name: 'Grace', age: 45 },\n * \t\t\t{ id: '3', name: 'Alan', age: 41 },\n * \t\t],\n * \t\tlimit: 2,\n * \t},\n * )\n *\n * table.filter.set({ column: 'name', operator: 'contains', text: 'a' })\n * table.sort.set({ column: 'age', direction: 'descending' })\n *\n * table.count // 3 — every name holds a lowercase 'a'\n * table.pagination.count // 2 — two pages of two\n * table.view.map((row) => row.name) // ['Grace', 'Alan'] — page one, oldest first\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;;;;AAK5B,IAAa,aAAa;;AAG1B,IAAa,aAAa;;;;;;;ACpB1B,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;;;;;;;;AASA,SAAgB,aAAa,OAAqC;CACjE,OAAO,WAAW,OAAO,UAAU;AACpC;;;;;;;;;;ACEA,SAAgB,cAAc,QAAqB,KAAsC;CACxF,OAAO,OAAO,QAAQ,MAAM,WAAW,OAAO,QAAQ,GAAG;AA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OAAO,KAAK,YAAY,KAAK;EACxD,IAAI,SAAS,KAAK,OAAO,OAAO,KAAA;EAChC,KAAK,QAAQ;EACb,OAAO;CACR;CAEA,QAAc;EACb,IAAI,KAAK,YACR,MAAM,IAAI,WAAW,aAAa,2CAA2C;CAE/E;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrPA,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.5",
3
+ "version": "0.0.6",
4
4
  "description": "The @orkestrel/table package.",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/orkestrel/table#readme",
@@ -66,16 +66,16 @@
66
66
  "@orkestrel/emitter": "^0.0.10"
67
67
  },
68
68
  "devDependencies": {
69
- "@microsoft/api-extractor": "^7.59.0",
70
- "@orkestrel/guide": "^0.0.17",
71
- "@orkestrel/probe": "^0.0.12",
72
- "@orkestrel/scaffold": "^0.0.63",
73
- "@orkestrel/test": "^0.0.14",
74
- "@types/node": "^26.4.1",
75
- "oxfmt": "^0.66.0",
76
- "oxlint": "^1.81.0",
69
+ "@microsoft/api-extractor": "^7.59.1",
70
+ "@orkestrel/guide": "^0.0.19",
71
+ "@orkestrel/probe": "^0.0.15",
72
+ "@orkestrel/scaffold": "^0.0.70",
73
+ "@orkestrel/test": "^0.0.15",
74
+ "@types/node": "^26.5.1",
75
+ "oxfmt": "^0.68.0",
76
+ "oxlint": "^1.83.0",
77
77
  "typescript": "^6.0.3",
78
- "vite": "^8.2.2",
78
+ "vite": "^8.3.0",
79
79
  "vitest": "^4.1.11"
80
80
  },
81
81
  "engines": {