@datakable/core 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{codes-AX8XkMNY.d.cts → codes-4sYQv_7J.d.cts} +36 -10
- package/dist/{codes-AX8XkMNY.d.ts → codes-4sYQv_7J.d.ts} +36 -10
- package/dist/column-filters.d.cts +2 -2
- package/dist/column-filters.d.ts +2 -2
- package/dist/diagnostics/build.cjs +1 -1
- package/dist/diagnostics/build.cjs.map +1 -1
- package/dist/diagnostics/build.js +2 -2
- package/dist/diagnostics/build.js.map +1 -1
- package/dist/diagnostics/console.cjs +15 -4
- package/dist/diagnostics/console.cjs.map +1 -1
- package/dist/diagnostics/console.js +15 -4
- package/dist/diagnostics/console.js.map +1 -1
- package/dist/diagnostics/prose.cjs +10 -1
- package/dist/diagnostics/prose.cjs.map +1 -1
- package/dist/diagnostics/prose.js +9 -1
- package/dist/diagnostics/prose.js.map +1 -1
- package/dist/{explain-pKAnnxEW.d.cts → explain-DmwN_RG9.d.cts} +11 -4
- package/dist/{explain-BVE3ln3G.d.ts → explain-Dr3SmMNY.d.ts} +11 -4
- package/dist/feature/install.cjs +2 -1
- package/dist/feature/install.cjs.map +1 -1
- package/dist/feature/install.js +2 -1
- package/dist/feature/install.js.map +1 -1
- package/dist/feature/slice-guard.cjs +76 -0
- package/dist/feature/slice-guard.cjs.map +1 -0
- package/dist/feature/slice-guard.js +50 -0
- package/dist/feature/slice-guard.js.map +1 -0
- package/dist/features/column-filters/codes.cjs +2 -19
- package/dist/features/column-filters/codes.cjs.map +1 -1
- package/dist/features/column-filters/codes.js +2 -19
- package/dist/features/column-filters/codes.js.map +1 -1
- package/dist/features/column-filters/column-filters.cjs +37 -22
- package/dist/features/column-filters/column-filters.cjs.map +1 -1
- package/dist/features/column-filters/column-filters.js +37 -22
- package/dist/features/column-filters/column-filters.js.map +1 -1
- package/dist/features/column-filters/match.cjs +6 -2
- package/dist/features/column-filters/match.cjs.map +1 -1
- package/dist/features/column-filters/match.js +6 -2
- package/dist/features/column-filters/match.js.map +1 -1
- package/dist/features/pagination/pagination.cjs +2 -2
- package/dist/features/pagination/pagination.cjs.map +1 -1
- package/dist/features/pagination/pagination.js +2 -2
- package/dist/features/pagination/pagination.js.map +1 -1
- package/dist/features/search/codes.cjs +18 -2
- package/dist/features/search/codes.cjs.map +1 -1
- package/dist/features/search/codes.js +16 -1
- package/dist/features/search/codes.js.map +1 -1
- package/dist/features/search/search-engine.cjs +24 -5
- package/dist/features/search/search-engine.cjs.map +1 -1
- package/dist/features/search/search-engine.js +25 -6
- package/dist/features/search/search-engine.js.map +1 -1
- package/dist/features/sorting/sorting.cjs +55 -24
- package/dist/features/sorting/sorting.cjs.map +1 -1
- package/dist/features/sorting/sorting.js +55 -24
- package/dist/features/sorting/sorting.js.map +1 -1
- package/dist/index.d.cts +26 -17
- package/dist/index.d.ts +26 -17
- package/dist/intercept/runtime.cjs +3 -2
- package/dist/intercept/runtime.cjs.map +1 -1
- package/dist/intercept/runtime.js +3 -2
- package/dist/intercept/runtime.js.map +1 -1
- package/dist/messages/index.cjs +2 -0
- package/dist/messages/index.cjs.map +1 -1
- package/dist/messages/index.js +2 -0
- package/dist/messages/index.js.map +1 -1
- package/dist/pagination.d.cts +2 -2
- package/dist/pagination.d.ts +2 -2
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/{search-async-entry-ByMJbHjc.d.cts → search-async-entry-BiemO3JT.d.cts} +2 -2
- package/dist/{search-async-entry-CFQODE08.d.ts → search-async-entry-GRj0E06n.d.ts} +2 -2
- package/dist/search-async.d.cts +3 -3
- package/dist/search-async.d.ts +3 -3
- package/dist/search.d.cts +4 -4
- package/dist/search.d.ts +4 -4
- package/dist/server.d.cts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/sorting.d.cts +2 -2
- package/dist/sorting.d.ts +2 -2
- package/dist/source/async-control.cjs +2 -1
- package/dist/source/async-control.cjs.map +1 -1
- package/dist/source/async-control.js +2 -1
- package/dist/source/async-control.js.map +1 -1
- package/dist/source/fetcher.cjs.map +1 -1
- package/dist/source/fetcher.js.map +1 -1
- package/dist/source/server.cjs +58 -5
- package/dist/source/server.cjs.map +1 -1
- package/dist/source/server.js +58 -5
- package/dist/source/server.js.map +1 -1
- package/dist/table/create-table.cjs +30 -20
- package/dist/table/create-table.cjs.map +1 -1
- package/dist/table/create-table.js +30 -20
- package/dist/table/create-table.js.map +1 -1
- package/dist/table/index.cjs +3 -0
- package/dist/table/index.cjs.map +1 -1
- package/dist/table/index.js +5 -1
- package/dist/table/index.js.map +1 -1
- package/dist/table/state-codes.cjs +72 -0
- package/dist/table/state-codes.cjs.map +1 -0
- package/dist/table/state-codes.js +45 -0
- package/dist/table/state-codes.js.map +1 -0
- package/dist/table/types.cjs.map +1 -1
- package/dist/table/types.js.map +1 -1
- package/dist/validity.d.cts +2 -2
- package/dist/validity.d.ts +2 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/dist/ingest/test-schemas.cjs +0 -73
- package/dist/ingest/test-schemas.cjs.map +0 -1
- package/dist/ingest/test-schemas.js +0 -46
- package/dist/ingest/test-schemas.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/table/create-table.ts"],"sourcesContent":["import { optionDiagnostics } from '../catalog/codes'\nimport { validateOptionChange, validateOptions } from '../catalog/validator'\nimport { DatakableError, defaultPhase, throwConfigError } from '../diagnostics/build'\nimport { keepDiagnostics } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\nimport { type ExplainHost, explainRow, explainTable } from '../diagnostics/explain'\nimport { createDiagnostics } from '../diagnostics/hub'\nimport { pathsOverlap, type RedactionOptions } from '../diagnostics/redact'\nimport { tracer } from '../diagnostics/tracer'\nimport type { Trigger } from '../diagnostics/types'\nimport { runtimeFor } from '../feature/runtime'\nimport type { AnyFeature, ApiOf, SliceUpdater, TableStateFor } from '../feature/types'\nimport { createDataChecks } from '../ingest/data-checks'\nimport { createDerivedColumns } from '../ingest/derive-columns'\nimport type { SchemaOutcome } from '../ingest/schema'\nimport { SCHEMA_INGEST, type TableSchema } from '../ingest/schema-brand'\nimport type { InvalidRowsMode } from '../ingest/schema-codes'\nimport type { StandardSchemaV1 } from '../ingest/standard-schema'\nimport { errorBoundary } from '../intercept/boundary'\nimport { callUser, errorName } from '../intercept/classify'\nimport { type ContextBase, createContext } from '../intercept/context'\nimport type { Interceptor } from '../intercept/define'\nimport { FAILED, FALLBACK } from '../intercept/fallbacks'\nimport type { OpInput, OpName, OpResult } from '../intercept/operations'\nimport { type Core, createInterceptorRuntime } from '../intercept/runtime'\nimport { createPipeline } from '../pipeline/runner'\nimport type { RowModel, RowModelStatus } from '../pipeline/types'\nimport { checkModeOrder, type FetchOutcome } from '../source/fetcher'\nimport type { ServerSource } from '../source/server'\nimport { SERVER_SOURCE, type ServerFetcher } from '../source/server-brand'\nimport { checkVersions } from '../versioning/registry'\nimport { tableDiagnostics } from './codes'\nimport { createDataMutationCheck, dataMutationDiagnostics } from './data-mutation'\nimport {\n deferral,\n type ExtensionFactory,\n setTableInternals,\n type TableExtension,\n type TableHost,\n} from './internals'\nimport { keepReadOnce } from './read-once'\nimport { createStateFeedbackCheck, stateFeedbackDiagnostics } from './state-feedback'\nimport {\n type ControlledState,\n type Listener,\n type Table,\n type TableOptions,\n type TableState,\n UPDATE_DEPTH_LIMIT,\n type Updater,\n} from './types'\n\nkeepDiagnostics(\n tableDiagnostics,\n dataMutationDiagnostics,\n stateFeedbackDiagnostics,\n optionDiagnostics,\n)\n\nconst EMPTY: readonly never[] = []\n\n/** §6.6 status precedence, lowest first: the table shows the highest of its sources. */\nconst RANK: readonly RowModelStatus[] = [\n 'idle',\n 'pending',\n 'validating',\n 'searching',\n 'fetching',\n 'error',\n]\n\nconst isThenable = (v: unknown): v is PromiseLike<unknown> =>\n v != null && typeof (v as { then?: unknown }).then === 'function'\n\n/** Objects already deep-frozen (dev): an unchanged slice is not walked again on the next commit. */\nconst deepFrozen = (process.env.NODE_ENV !== \"production\") ? new WeakSet<object>() : undefined\n\n/**\n * Freezes plain objects and arrays reachable from `v` (dev). Class instances (Date, Map, typed\n * arrays, user classes) are left alone: freezing them would break their own methods.\n */\nfunction deepFreeze(v: unknown): void {\n if (v === null || typeof v !== 'object' || deepFrozen?.has(v)) return\n const isArray = Array.isArray(v)\n if (!isArray) {\n const proto = Object.getPrototypeOf(v)\n if (proto !== Object.prototype && proto !== null) return\n }\n deepFrozen?.add(v)\n Object.freeze(v)\n if (isArray) for (let i = 0; i < v.length; i++) deepFreeze(v[i])\n else for (const k in v) deepFreeze((v as Record<string, unknown>)[k])\n}\n\n/** Snapshots and their slices are immutable in development (#20); production skips the walk. */\nconst freeze = <S extends object>(s: S): S => {\n if ((process.env.NODE_ENV !== \"production\")) deepFreeze(s)\n return s\n}\n\n/** The row type: the schema output with a `schema` (§5.1), else `T`. */\nexport type SchemaRow<T, Sch> = [Sch] extends [TableSchema] ? StandardSchemaV1.InferOutput<Sch> : T\n\n/**\n * `createTable` options: with a `schema`, the row type is its output and `data` is the raw input\n * (`unknown[]`, e.g. parsed JSON), validated per row.\n */\nexport type CreateTableOptions<T, S extends TableState, Sch, M extends InvalidRowsMode> = Omit<\n TableOptions<SchemaRow<T, Sch>, S>,\n 'data' | 'schema' | 'invalidRows' | 'fetcher' | 'initialData'\n> & {\n data?: readonly ([Sch] extends [TableSchema] ? unknown : T)[]\n /** With a schema, the raw rows (validated like `data`). */\n initialData?: readonly ([Sch] extends [TableSchema] ? unknown : T)[]\n /** With a schema, the fetcher returns raw rows (validated like `data`). */\n fetcher?: ServerFetcher<[Sch] extends [TableSchema] ? unknown : T>\n // Without an inferred schema (explicit type arguments, a `TableOptions<T>` object) these keep\n // their `TableOptions` types.\n schema?: [Sch] extends [TableSchema] ? Sch : TableSchema<unknown, T>\n invalidRows?: [Sch] extends [TableSchema] ? M : InvalidRowsMode\n}\n\n/** Column id: `key` for key columns, `id` for accessor columns. */\nconst columnId = (c: { key?: unknown; id?: unknown }): unknown => c.key ?? c.id\n\n/**\n * Creates the table store (§3.2): immutable state snapshots, controlled slices, isolated listeners,\n * a re-entrancy guard and `destroy()`. Every unit of work runs as an operation (§3.4) through the\n * table's interceptor runtime, with the errorBoundary outermost and diagnostics on a per-table hub.\n *\n * `ctx.where` is always a constant option path or method name (`options`, `options.data`,\n * `setState`, `destroy`): it reaches fingerprints, docs URLs and issue links unredacted, so it must\n * never carry row keys or cell values.\n */\nexport function createTable<\n T,\n S extends TableState = never,\n const Fs extends readonly AnyFeature[] = [],\n const Sch extends TableSchema | undefined = undefined,\n const M extends InvalidRowsMode = 'drop',\n>(\n options: CreateTableOptions<T, TableStateFor<S, Fs, SchemaRow<T, Sch>>, Sch, M> & {\n features?: Fs\n },\n): Table<\n SchemaRow<T, Sch>,\n TableStateFor<S, Fs, SchemaRow<T, Sch>>,\n M,\n [Sch] extends [TableSchema] ? unknown : T\n> &\n ApiOf<Fs, SchemaRow<T, Sch>>\nexport function createTable<T, S extends TableState>(\n initialOptions: TableOptions<T, S>,\n): Table<T, S> {\n let options: TableOptions<T, S> = { ...initialOptions }\n let destroyed = false\n let trigger: Trigger = 'init'\n /** Pipeline run id; each `pipeline:run` increments it. */\n let run = 0\n let data: readonly T[] = EMPTY\n let ingestSeq = 0\n /** Data given by the user has been applied once (`RowModel.isInitialLoad`, §6.6). */\n let loaded = false\n /** The last `data:ingest` failed (op fallback): `status: 'error'` until one succeeds (§6.6). */\n let ingestFailed = false\n /** The ingest whose async schema validation is in flight (`status: 'validating'`); 0: none. */\n let validatingSeq = 0\n /** Rows of the current data that failed the schema (`getInvalidRows`, §5.1). */\n let schemaOutcome: SchemaOutcome | undefined\n /**\n * SSR (§7.2): `options.initialData` until the creation ingest read it (`undefined` with `data`),\n * then its ingested rows while they are the table's data (`initialRows`).\n */\n let initialInput = options.data === undefined ? options.initialData : undefined\n let initialRows: readonly unknown[] | undefined\n /** Created inside `createDeferred` (§7.2): async work waits for `startTable`. */\n let deferring = deferral.depth > 0\n /**\n * Opt-in parts of the store (`TableInternals.use`): the async request machinery and the server\n * source. A table without an async source creates none (§9.3).\n */\n const extensions = new Map<ExtensionFactory<TableExtension>, TableExtension>()\n /** The server source (`withFetcher`, §7.1), once a fetcher was given. */\n let server: ServerSource | undefined\n\n let controlled = new Set<string>()\n let snapshot: S\n /** The snapshot listeners last saw (`prev` of the next notification). */\n let notified: S\n /** A committed change (state or data) not yet notified. */\n let pending = false\n let notifying = false\n let rounds = 0\n let loopReported = false\n let current: number | undefined\n let listenerSeq = 0\n const listeners = new Map<number, Listener<S>>()\n /** Depth of feature API calls in progress: listeners are notified when the outermost returns. */\n let apiDepth = 0\n /** Data, state or columns changed since the row model was computed. */\n let rowModelDirty = true\n /** Diagnostic context (§8.1): the data mode of each pipeline feature (set once features load). */\n const modes: Record<string, 'client' | 'server'> = {}\n\n const table: Table<T, S> = {\n getState: () => snapshot,\n setState,\n subscribe,\n setOptions,\n getOptions: () => options,\n getData: () => data,\n // Core method: on the literal before installApis, so no feature can take the name.\n getRowModel,\n getInvalidRows: () => schemaOutcome?.invalid ?? EMPTY,\n getDiagnostics: () => hub.getDiagnostics(),\n // Core methods (§8.4), read-only: also on the literal before installApis.\n explain: () => explainTable(explainHost),\n explainRow: (key) => explainRow(explainHost, key),\n refetch,\n destroy,\n }\n\n // Redaction (§8.2): `diagnostics.redact` gives the level or a custom rule; column defs give the\n // sensitive columns and whether the rowKey column is sensitive. Both are read per emit, so\n // `setOptions({ columns })` is followed.\n const redactOption = options.diagnostics?.redact\n const redaction: RedactionOptions = {\n ...(typeof redactOption === 'string' ? { level: redactOption } : {}),\n ...(typeof redactOption === 'function' ? { redact: redactOption } : {}),\n sensitiveColumns,\n // A rowKey path into (or above) a sensitive column reads its data too (#45).\n rowKeySensitive: () => {\n const k = options.rowKey\n return typeof k === 'string' && sensitiveColumns().some((c) => pathsOverlap(k, c))\n },\n }\n const hub = createDiagnostics({\n ...(options.name === undefined ? {} : { name: options.name }),\n table,\n onDiagnostic: (d) => options.onDiagnostic?.(d),\n ...(options.strict === undefined ? {} : { strict: options.strict }),\n getContext: () => ({ trigger, run, mode: modes }),\n getDataRef: () => data,\n redaction,\n })\n // Option validator (§3.4, `table:init`), development only: before anything reads the options.\n // Invalid values throw DK_INVALID_OPTION; unknown / no-effect options are reported on the hub.\n if ((process.env.NODE_ENV !== \"production\")) validateOptions(options, { table: hub.table, emit: hub.emit })\n // Features (§3.3) are read once, at creation. `features` is the listed order (API install, conflict\n // reports); `pipeline` is stage order for the runner. Duplicates throw here (config error).\n const features: readonly AnyFeature[] = options.features ?? EMPTY\n // The feature runtime comes with the features (`defineFeature`): none for a table without.\n const rt = runtimeFor(features)\n const pipeline = rt ? rt.orderFeatures(features, hub.table) : EMPTY\n // Data modes (§7.1): DK_MODE_ORDER (a config error, development). A fetcher without a server-mode\n // feature (DK_FETCHER_WITHOUT_SERVER_MODE) is checked by the server source.\n if ((process.env.NODE_ENV !== \"production\")) checkModeOrder(pipeline, hub.table)\n for (const f of pipeline) if (f.stage !== 'none') modes[f.name] = f.mode ?? 'client'\n // Extension interceptors come first (asyncControl, one per table, installed with the first async\n // source: user / feature interceptors and the core see its signal); the boundary stays\n // outermost. Feature interceptors (pipeline order) come next, then the user's.\n const front: Interceptor<OpName>[] = []\n const featureInterceptors = pipeline.flatMap((f) => f.interceptors ?? EMPTY)\n // The tracer (§3.4, explain timings) is development-only: `(process.env.NODE_ENV !== \"production\")` folds to `false` in production\n // builds, which drops it from the bundle; there it is opt-in with `interceptors: [tracer()]`.\n const traced = (process.env.NODE_ENV !== \"production\") ? [tracer() as Interceptor<OpName>] : EMPTY\n const withFront = (list: readonly Interceptor<OpName>[] | undefined) => [\n ...front,\n ...traced,\n ...featureInterceptors,\n ...(list ?? EMPTY),\n ]\n const runtime = createInterceptorRuntime({\n interceptors: withFront(options.interceptors),\n emit: hub.emit,\n })\n runtime.installBoundary(errorBoundary)\n hub.attach(runtime)\n // Dev check (§5.3): the same `data` array passed again with changed contents (DK_DATA_MUTATED).\n const dataCheck = (process.env.NODE_ENV !== \"production\") ? createDataMutationCheck(hub.emit) : undefined\n // Feature `requires.core` (throws DK_FEATURE_INCOMPATIBLE), duplicate cores, version mismatch\n // (§8.5): development checks (changed 2026-10-13 for §9.3).\n if ((process.env.NODE_ENV !== \"production\")) checkVersions(features, hub.emit, hub.table)\n // Ingest data checks (§5.3) and zero-config columns (§4.1): both read only the first rows.\n // The data checks are developer hints: development only (changed 2026-10-13 for §9.3).\n const dataChecks = (process.env.NODE_ENV !== \"production\") ? createDataChecks(hub.emit) : undefined\n /** Controlled changes not fed back (DK_CONTROLLED_NOT_FED_BACK, development). */\n const feedback = (process.env.NODE_ENV !== \"production\") ? createStateFeedbackCheck(hub.emit) : undefined\n const derivedColumns = createDerivedColumns()\n // Schema ingest (§5.1): `schema` and `invalidRows` are read once (validated above). The step\n // comes with the schema (`withSchema`, `@datakable/core/schema`): a table without one never\n // bundles it.\n const schemaIngest = (options.schema as Partial<TableSchema> | undefined)?.[SCHEMA_INGEST]?.(\n options.invalidRows ?? 'drop',\n () => options.columns,\n )\n // Never silent (§8.6): in production (no option validator) an unwrapped schema would be ignored.\n if (options.schema && !schemaIngest) unwrapped('schema', options.schema, 'withSchema')\n\n function sensitiveColumns(): string[] {\n const out: string[] = []\n for (const c of options.columns ?? EMPTY) {\n const id = columnId(c as { key?: unknown; id?: unknown })\n if (c.sensitive && typeof id === 'string') out.push(id)\n }\n return out\n }\n\n function base(): ContextBase {\n return { table, run, trigger, phase: defaultPhase(), emit: hub.emit }\n }\n\n function op<O extends OpName>(\n name: O,\n input: OpInput<O>,\n where: string,\n core: Core<O>,\n fallback?: unknown,\n ): OpResult<O> {\n const ctx = createContext(name, input, where, base())\n if (fallback !== undefined) ctx.meta.set(FALLBACK, fallback)\n return runtime.run(name, ctx, core)\n }\n\n function withTrigger<R>(t: Trigger, fn: () => R): R {\n const prev = trigger\n trigger = t\n try {\n return fn()\n } finally {\n trigger = prev\n }\n }\n\n // --- state -------------------------------------------------------------------------------------\n\n function controlledKeys(state: ControlledState<S> | undefined): Set<string> {\n const keys = new Set<string>()\n if (state) for (const k of Object.keys(state)) if (state[k] !== undefined) keys.add(k)\n return keys\n }\n\n /** `s` with the controlled slices from `options.state`; `s` itself when none differ. */\n function overlay(s: S): S {\n let next: TableState | undefined\n const state = options.state as TableState | undefined\n if (state) {\n for (const k of controlled) {\n if (!Object.is(s[k], state[k])) {\n next ??= { ...s }\n next[k] = state[k]\n }\n }\n }\n return next ? freeze(next as S) : s\n }\n\n function commit(next: S) {\n snapshot = next\n pending = true\n rowModelDirty = true\n }\n\n function warnControlled(dropped: string[] | undefined) {\n if (options.onStateChange || controlled.size === 0) return\n const slices = dropped ?? [...controlled]\n hub.emit('DK_CONTROLLED_WITHOUT_HANDLER', { slices, dropped: dropped !== undefined })\n }\n\n function syncControlled() {\n controlled = controlledKeys(options.state)\n const next = overlay(snapshot)\n if (next !== snapshot) commit(next)\n if ((process.env.NODE_ENV !== \"production\")) feedback?.settle(options.state as TableState | undefined, controlled)\n warnControlled(undefined)\n }\n\n function dispatch(updater: Updater<S>, slot: string) {\n // A method argument, not an option: `where` = `operation table.setState at updater`.\n const partial: Partial<S> =\n typeof updater === 'function'\n ? callUser(\n 'updater',\n updater,\n snapshot,\n undefined,\n slot === 'setState' ? 'table.setState' : `${slot}.setState`,\n )\n : updater\n if (partial === null || typeof partial !== 'object') return\n let next: TableState | undefined\n let changes: TableState | undefined\n let dropped: string[] | undefined\n for (const k of Object.keys(partial)) {\n const v = (partial as TableState)[k]\n if (Object.is(snapshot[k], v)) continue\n if (controlled.has(k)) {\n if (options.onStateChange) {\n changes ??= {}\n changes[k] = v\n } else {\n dropped ??= []\n dropped.push(k)\n }\n continue\n }\n next ??= { ...snapshot }\n next[k] = v\n }\n // The owner is told first: if onStateChange throws, nothing is committed (state unchanged).\n if (changes && options.onStateChange) {\n const c = changes as Partial<S>\n if ((process.env.NODE_ENV !== \"production\")) feedback?.ask(Object.keys(changes), trigger)\n callUser('onStateChange', options.onStateChange, (prev: Partial<S>) => ({ ...prev, ...c }))\n if ((process.env.NODE_ENV !== \"production\")) feedback?.asked()\n }\n if (next) commit(freeze(next as S))\n if (dropped) warnControlled(dropped)\n }\n\n /**\n * Notifies listeners until no change is pending. Updates made by listeners are committed at once\n * and notified in the next round (not nested), so every listener sees rounds in order.\n */\n function flush() {\n if (notifying) return\n sync()\n if (!pending) return\n notifying = true\n let rethrow: unknown\n try {\n while (pending && !destroyed) {\n // Server state changed (this round's state): the fetch starts in the same notification.\n sync()\n pending = false\n rounds++\n const prev = notified\n const state = snapshot\n notified = state\n // Listeners read the row model of the state they are notified with.\n ensureRowModel()\n for (const [id, listener] of [...listeners]) {\n // A listener may destroy the table: the rest of the round is not notified.\n if (destroyed) break\n current = id\n try {\n listener(state, prev)\n } catch (e) {\n // strict: a DatakableError (e.g. DK_UPDATE_LOOP) thrown inside the listener.\n if (e instanceof DatakableError) {\n rethrow ??= e\n continue\n }\n try {\n const name = errorName(e)\n hub.emit(\n 'DK_LISTENER_FAILED',\n { listener: id, ...(name === undefined ? {} : { errorName: name }) },\n { cause: e },\n )\n } catch (strictError) {\n rethrow ??= strictError\n }\n }\n }\n }\n } finally {\n notifying = false\n rounds = 0\n loopReported = false\n current = undefined\n }\n if (rethrow !== undefined) throw rethrow\n }\n\n /** `false` (and one `DK_UPDATE_LOOP`) when a re-entrant update would exceed the depth limit. */\n function admit(slices: string[]): boolean {\n if (!notifying || rounds < UPDATE_DEPTH_LIMIT) return true\n if (!loopReported) {\n loopReported = true\n hub.emit('DK_UPDATE_LOOP', {\n limit: UPDATE_DEPTH_LIMIT,\n slices,\n ...(current === undefined ? {} : { listener: current }),\n })\n }\n return false\n }\n\n function destroyedCall(method: string) {\n withTrigger(`api:${method}`, () => hub.emit('DK_TABLE_DESTROYED', { method }))\n }\n\n // --- data --------------------------------------------------------------------------------------\n\n /** Applies ingested data; `given`: it came from a user `options.data` (marks the first load). */\n function setData(next: readonly T[], given: boolean) {\n if (given && !loaded) {\n // isInitialLoad flips: a new row model and a notification even for the same reference.\n loaded = true\n pending = true\n rowModelDirty = true\n }\n if (next === data) return\n data = next\n pending = true\n // After `data` is set: diagnostics dedupe per data reference.\n if ((process.env.NODE_ENV !== \"production\")) dataChecks?.check(data, options.columns)\n // The pipeline runs before the next notification (or on getRowModel), as `pipeline:run` with\n // ctx.meta[FALLBACK] = the last good row model (pipeline/runner.ts).\n rowModelDirty = true\n }\n\n // --- row model ---------------------------------------------------------------------------------\n\n const runner = createPipeline<T>({\n runtime,\n featureRuntime: rt,\n emit: hub.emit,\n features: pipeline,\n listed: features,\n base,\n nextRun: () => ++run,\n getData: () => data,\n getState: () => snapshot,\n getColumns: () => options.columns ?? derivedColumns(data),\n getRowKey: () => options.rowKey,\n isInitialLoad: () => !loaded,\n status,\n issues: (index) => schemaOutcome?.flagged?.get(index),\n flagMode: schemaIngest !== undefined && options.invalidRows === 'flag',\n // Time-sliced work ended (§9.1): 'pending' → the finished row model, never silent (§6.6).\n refresh: (t) => {\n if (destroyed) return\n withTrigger(t, () => {\n touch()\n if (apiDepth === 0) flush()\n })\n },\n })\n\n const explainHost: ExplainHost = {\n table,\n features: pipeline,\n rowModel: getRowModel as () => RowModel<unknown>,\n lastRun: runner.lastRun,\n replay: runner.replayContext,\n data: () => data,\n state: () => snapshot,\n rowKey: () => options.rowKey,\n schemaMode: () => (schemaIngest ? (options.invalidRows ?? 'drop') : undefined),\n schema: () => schemaOutcome,\n diagnostics: () => hub.getDiagnostics(),\n redaction,\n ...(rt ? { detail: rt.explainDetail } : {}),\n }\n\n /**\n * Status from outside the pipeline (§6.6): a failed ingest, a running async schema, the search\n * slice (`pending` / `searching` / `error`), and the extensions' (a failed fetch, an in-flight\n * fetcher / `searchFn`, deferred async work). Precedence: error > fetching > searching >\n * validating > pending > idle.\n */\n function status(): RowModelStatus {\n const search = searchStatus()\n let s: RowModelStatus =\n ingestFailed || search === 'error'\n ? 'error'\n : search === 'searching'\n ? 'searching'\n : validatingSeq !== 0\n ? 'validating'\n : search === 'pending'\n ? 'pending'\n : 'idle'\n for (const e of extensions.values()) {\n const x = e.status?.()\n if (x !== undefined && RANK.indexOf(x) > RANK.indexOf(s)) s = x\n }\n return s\n }\n\n /** Extensions start work that follows state (the fetcher on server state, §7.1). */\n function sync() {\n for (const e of extensions.values()) e.sync?.()\n }\n\n /** The `status` of the first search-stage slice that reports one (§6.3). */\n function searchStatus(): unknown {\n for (const f of pipeline) {\n if (f.stage !== 'search') continue\n const s = (snapshot as Record<string, unknown> | undefined)?.[f.name]\n if (s !== null && typeof s === 'object' && 'status' in s) {\n const v = (s as { status: unknown }).status\n if (v !== 'idle') return v\n }\n }\n return 'idle'\n }\n\n /** A row model change not caused by state: recompute and notify on the next flush. */\n function touch() {\n pending = true\n rowModelDirty = true\n }\n\n /** Recomputes the row model if data, state or columns changed (never after destroy). */\n function ensureRowModel() {\n if (!rowModelDirty || destroyed) return\n rowModelDirty = false\n runner.run()\n }\n\n function getRowModel(): RowModel<T> {\n ensureRowModel()\n // Only empty when destroyed before the first run.\n return (\n runner.current() ?? {\n rows: EMPTY,\n filteredCount: 0,\n totalCount: 0,\n status: status(),\n isInitialLoad: !loaded,\n }\n )\n }\n\n /**\n * Applies the result of the latest `data:ingest`. A fallback (the boundary set `FAILED`) keeps\n * the previous data, sets `status: 'error'` and never marks the table loaded (§6.6, §8.6).\n */\n function applyIngest(out: readonly unknown[], failed: boolean, given: boolean, initial = false) {\n if (validatingSeq !== 0) {\n validatingSeq = 0\n touch()\n }\n if (failed) {\n ingestFailed = true\n touch()\n return\n }\n if (ingestFailed) {\n ingestFailed = false\n touch()\n }\n schemaOutcome = schemaIngest?.outcome(out)\n setData(out as readonly T[], given)\n // `initialData` is the initial async result only while it is the data (§7.2).\n initialRows = initial ? out : undefined\n }\n\n /**\n * `data:ingest` with the previous data as fallback: the schema step (§5.1) runs in its core. An\n * async result is applied if still latest. `fetched`: rows of an applied fetcher result (§7.1),\n * ingested like `options.data` (schema, data checks) and marking the table loaded.\n */\n function ingest(fetched?: readonly unknown[]) {\n const seq = ++ingestSeq\n // At creation, `initialData` stands in for a missing `data` (§7.2); read once.\n const initial = fetched === undefined && initialInput !== undefined\n const input = fetched ?? (initial ? initialInput : options.data)\n initialInput = undefined\n const given = input !== undefined\n const source: Trigger = fetched ? 'fetch' : 'data-change'\n // A validation still in flight is superseded (its result is discarded): not 'validating' now,\n // unless this ingest's own schema step goes async.\n if (validatingSeq !== 0) {\n validatingSeq = 0\n touch()\n }\n try {\n withTrigger(source, () => {\n const ctx = createContext(\n 'data:ingest',\n { data: input ?? EMPTY },\n fetched ? 'fetcher' : initial ? 'options.initialData' : 'options.data',\n base(),\n )\n ctx.meta.set(FALLBACK, data)\n let sync = true\n const out = runtime.run('data:ingest', ctx, (c) => {\n const input = c.input.data as readonly unknown[]\n if (!schemaIngest) return input\n const r = schemaIngest.validate(input, c.emit)\n if (isThenable(r) && seq === ingestSeq && !destroyed) {\n // 'validating' is never silent: a new row model and a notification now (§6.6).\n validatingSeq = seq\n touch()\n if (!sync) flush()\n }\n return r\n })\n sync = false\n if (!isThenable(out)) {\n applyIngest(out, ctx.meta.has(FAILED), given, initial)\n return\n }\n const settle = (d: readonly unknown[], failed: boolean) => {\n if (seq !== ingestSeq || destroyed) return\n withTrigger(source, () => {\n applyIngest(d, failed, given, initial)\n flush()\n })\n }\n Promise.resolve(out).then(\n (d) => settle(d, ctx.meta.has(FAILED)),\n // A DatakableError the boundary rethrew (strict, or `invalidRows: 'throw'` with an async\n // schema, already reported): the previous data is kept with 'error'. No unhandled\n // rejection either way (§8.6).\n () => settle(data, true),\n )\n })\n } finally {\n // Dev (§5.3): fingerprint `data` after the core read it, so the check never takes reads\n // first; also when the ingest threw, so a later same-reference check compares this data.\n if ((process.env.NODE_ENV !== \"production\") && !fetched) dataCheck?.remember(options.data)\n }\n }\n\n // --- API ---------------------------------------------------------------------------------------\n\n /** `state:dispatch` (where = `slot`, a constant method / feature name); notifies unless batched. */\n function update(updater: Updater<S>, slot: string) {\n void op('state:dispatch', { updater }, slot, (): undefined => {\n dispatch(updater, slot)\n })\n if (apiDepth === 0) flush()\n }\n\n function setState(updater: Updater<S>) {\n if (destroyed) return destroyedCall('setState')\n if (!admit(typeof updater === 'function' ? [] : Object.keys(updater ?? {}))) return\n withTrigger('api:setState', () => update(updater, 'setState'))\n }\n\n // --- features ----------------------------------------------------------------------------------\n\n /** A feature's `ctx.setState`: replaces its own slice (trigger: the API call's, if any). */\n function setSlice(name: string, updater: SliceUpdater<unknown>) {\n if (destroyed) return destroyedCall(`${name}.setState`)\n if (!admit([name])) return\n const slice: Updater<S> =\n typeof updater === 'function'\n ? (prev) => ({ [name]: (updater as (p: unknown) => unknown)(prev[name]) }) as Partial<S>\n : ({ [name]: updater } as Partial<S>)\n update(slice, name)\n }\n\n /** Runs a feature API method (wrapped once by `installApis`). */\n function callApi(method: string, fn: () => unknown, ifDestroyed?: () => unknown): unknown {\n if (destroyed) {\n destroyedCall(method)\n return ifDestroyed?.()\n }\n return withTrigger(`api:${method}`, () => {\n apiDepth++\n try {\n return fn()\n } finally {\n apiDepth--\n if (apiDepth === 0) flush()\n }\n })\n }\n\n function subscribe(listener: Listener<S>): () => void {\n if (destroyed) {\n destroyedCall('subscribe')\n return () => {}\n }\n const id = ++listenerSeq\n listeners.set(id, listener)\n return () => {\n listeners.delete(id)\n }\n }\n\n function setOptions(partial: Partial<TableOptions<T, S>>) {\n if (destroyed) return destroyedCall('setOptions')\n if (!admit(Object.keys(partial.state ?? {}))) return\n withTrigger('setOptions', () => {\n const previous = options\n const next = { ...options, ...partial }\n // Option validator (§3.4, `table:setOptions`, development): an invalid value throws before\n // anything changes. Read-once options (`features`, `timeout`, `diagnostics`, …) keep their\n // value in every build.\n if ((process.env.NODE_ENV !== \"production\")) validateOptionChange(partial, next, previous, { table: hub.table, emit: hub.emit })\n else keepReadOnce(partial, next, previous)\n if ('fetcher' in partial) useServer(next.fetcher, 'setOptions')?.check(next.fetcher)\n void op('table:setOptions', { options: next, previous }, 'options', (): undefined => {\n options = next\n if (next.interceptors !== previous.interceptors) {\n runtime.setInterceptors(withFront(next.interceptors))\n }\n if ('state' in partial || 'onStateChange' in partial) syncControlled()\n if (next.columns !== previous.columns || next.rowKey !== previous.rowKey) {\n rowModelDirty = true\n pending = true\n }\n // The page count changed (§6.5): listeners re-read it (and pagination clamps).\n if (next.rowCount !== previous.rowCount) pending = true\n // A new fetcher reference runs at once, even with the same params (flush → sync).\n if (next.fetcher !== previous.fetcher) server?.reset()\n // New data is checked when applied (setData); same data with new columns is checked here.\n if (next.data !== previous.data) ingest()\n else if ((process.env.NODE_ENV !== \"production\")) {\n if ('data' in partial) dataCheck?.check(next.data)\n if (next.columns !== previous.columns) dataChecks?.check(data, next.columns)\n }\n })\n flush()\n })\n }\n\n function destroy() {\n if (destroyed) return\n withTrigger('api:destroy', () => {\n try {\n void op('table:destroy', undefined, 'destroy', (): undefined => {\n destroyed = true\n })\n } finally {\n // Even if an interceptor skipped the core: the table is destroyed.\n destroyed = true\n ingestSeq++\n listeners.clear()\n runner.dispose()\n if ((process.env.NODE_ENV !== \"production\")) feedback?.dispose()\n }\n })\n }\n\n // --- extensions (§9.3) ---------------------------------------------------------------------\n\n function batch<R>(t: Trigger, fn: () => R): R {\n return withTrigger(t, () => {\n apiDepth++\n try {\n return fn()\n } finally {\n apiDepth--\n if (apiDepth === 0) flush()\n }\n })\n }\n\n const host: TableHost = {\n table: table as unknown as Table<unknown, TableState>,\n name: hub.table,\n emit: hub.emit,\n runtime,\n features: pipeline,\n options: () => options as TableOptions<unknown>,\n state: () => snapshot,\n base,\n destroyed: () => destroyed,\n loaded: () => loaded,\n status,\n touch,\n notify: () => {\n if (apiDepth === 0) flush()\n },\n batch,\n ingest: (rows) => ingest(rows),\n intercept(interceptor) {\n front.push(interceptor)\n runtime.setInterceptors(withFront(options.interceptors))\n },\n deferring: () => deferring,\n use,\n }\n\n function use<E extends TableExtension>(factory: ExtensionFactory<E>): E {\n let e = extensions.get(factory as ExtensionFactory<TableExtension>) as E | undefined\n if (!e) {\n e = factory(host)\n extensions.set(factory as ExtensionFactory<TableExtension>, e)\n }\n return e\n }\n\n /** The server source a `withFetcher` fetcher brings (created once); else the current one. */\n function useServer(fetcher: unknown, phase?: 'setOptions'): ServerSource | undefined {\n const factory = (fetcher as Partial<ServerFetcher<unknown>> | undefined)?.[SERVER_SOURCE]\n if (factory) server = use(factory)\n // Never silent (§8.6): in production an unwrapped fetcher would never run.\n else if (fetcher) unwrapped('fetcher', fetcher, 'withFetcher', 'server', phase)\n return server\n }\n\n /**\n * `DK_INVALID_OPTION` for a schema / fetcher not wrapped with its opt-in import (§5.1, §7.1). A\n * production check: in development the option validator reports it first, with the full text.\n */\n function unwrapped(\n path: 'schema' | 'fetcher',\n value: unknown,\n wrap: string,\n entry: string = path,\n phase: 'init' | 'setOptions' = 'init',\n ): never {\n return throwConfigError(\n 'DK_INVALID_OPTION',\n {\n path,\n expected: `wrapped|${wrap}|${path}|${entry}`, // prose key (diagnostics/prose.ts)\n received: typeof value,\n suggestions: [],\n phase,\n },\n { table: hub.table, trigger: phase },\n )\n }\n\n /**\n * Runs the fetcher again with the current params (§7.1); never rejects. Without a fetcher:\n * `{ status: 'applied' }` at once.\n */\n function refetch(): Promise<FetchOutcome> {\n if (destroyed) {\n destroyedCall('refetch')\n return Promise.resolve({ status: 'superseded' })\n }\n return (\n withTrigger('api:refetch', () => server?.sync(true)) ?? Promise.resolve({ status: 'applied' })\n )\n }\n\n /** `startTable` (§7.2): the deferred work starts; listeners see the new status at once. */\n function start() {\n if (!deferring || destroyed) return\n deferring = false\n let had = false\n for (const e of extensions.values()) if (e.start?.()) had = true\n if (!had) return\n // The pipeline re-runs: 'pending' ends and the search feature's check starts its searchFn.\n touch()\n withTrigger('hydrate', () => flush())\n }\n\n setTableInternals(table, {\n features: pipeline,\n name: options.name,\n rowCount: () => (typeof options.fetcher === 'function' ? server?.rowCount() : options.rowCount),\n hasFetcher: () => typeof options.fetcher === 'function',\n emit: hub.emit,\n use,\n peek: (factory) => extensions.get(factory as ExtensionFactory<TableExtension>) as never,\n extensions: () => extensions.values(),\n start,\n initialRows: () =>\n initialRows !== undefined && initialRows === data ? initialRows : undefined,\n })\n\n // --- init --------------------------------------------------------------------------------------\n\n controlled = controlledKeys(options.state)\n if ((process.env.NODE_ENV !== \"production\")) feedback?.settle(options.state as TableState | undefined, controlled)\n // Feature `initialState()` slices, with `options.initialState` on top per slice.\n snapshot = overlay(\n freeze(\n (rt\n ? rt.initialSlices(features, options.initialState, hub.emit)\n : { ...options.initialState }) as S,\n ),\n )\n notified = snapshot\n // Merges the feature APIs onto the table; a name clash throws DK_FEATURE_API_CONFLICT.\n rt?.installApis(features, {\n table: table as unknown as Table<unknown, TableState>,\n tableName: hub.table,\n emit: hub.emit,\n getSlice: (name) => snapshot[name],\n setSlice,\n call: callApi,\n })\n // Server source (§7.1): with a `withFetcher` fetcher (throws DK_FETCHER_WITHOUT_SERVER_MODE).\n useServer(options.fetcher)\n withTrigger('init', () => {\n // `void`: sync ops never return a promise (op kinds, §3.4).\n void op('table:init', { options }, 'options', (): undefined => {\n // Ingest first: dedupe is per data reference, so warnings follow the initial data.\n ingest()\n warnControlled(undefined)\n })\n // Server source (§7.1): the first request starts now ('fetching', isInitialLoad: true), unless\n // initialData answered the initial server state (§7.2).\n sync()\n })\n pending = false\n return table\n}\n"],"mappings":";AAAA,SAAS,yBAAyB;AAClC,SAAS,sBAAsB,uBAAuB;AACtD,SAAS,gBAAgB,cAAc,wBAAwB;AAC/D,SAAS,uBAAuB;AAChC,OAAO;AACP,SAA2B,YAAY,oBAAoB;AAC3D,SAAS,yBAAyB;AAClC,SAAS,oBAA2C;AACpD,SAAS,cAAc;AAEvB,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,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ChC;AAAA,EACF;AACA,aAAW;AAEX,MAAI,YAAY,UAAU;AAAA,IACxB;AAAA,IACA,WAAW,IAAI;AAAA,IACf,MAAM,IAAI;AAAA,IACV,UAAU,CAAC,SAAS,SAAS,IAAI;AAAA,IACjC;AAAA,IACA,MAAM;AAAA,EACR,CAAC;AAED,YAAU,QAAQ,OAAO;AACzB,cAAY,QAAQ,MAAM;AAExB,SAAK,GAAG,cAAc,EAAE,QAAQ,GAAG,WAAW,MAAiB;AAE7D,aAAO;AACP,qBAAe,MAAS;AAAA,IAC1B,CAAC;AAGD,SAAK;AAAA,EACP,CAAC;AACD,YAAU;AACV,SAAO;AACT;","names":["sync","input"]}
|
|
1
|
+
{"version":3,"sources":["../../src/table/create-table.ts"],"sourcesContent":["import { optionDiagnostics } from '../catalog/codes'\nimport { validateOptionChange, validateOptions } from '../catalog/validator'\nimport { DatakableError, defaultPhase, throwConfigError } from '../diagnostics/build'\nimport { keepDiagnostics } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\nimport { type ExplainHost, explainRow, explainTable } from '../diagnostics/explain'\nimport { createDiagnostics } from '../diagnostics/hub'\nimport { pathsOverlap, type RedactionOptions } from '../diagnostics/redact'\nimport { tracer } from '../diagnostics/tracer'\nimport type { Trigger } from '../diagnostics/types'\nimport { runtimeFor } from '../feature/runtime'\nimport type { AnyFeature, ApiOf, SliceUpdater, TableStateFor } from '../feature/types'\nimport { createDataChecks } from '../ingest/data-checks'\nimport { createDerivedColumns } from '../ingest/derive-columns'\nimport type { SchemaOutcome } from '../ingest/schema'\nimport { SCHEMA_INGEST, type TableSchema } from '../ingest/schema-brand'\nimport type { InvalidRowsMode } from '../ingest/schema-codes'\nimport type { StandardSchemaV1 } from '../ingest/standard-schema'\nimport { errorBoundary } from '../intercept/boundary'\nimport { callUser, errorName } from '../intercept/classify'\nimport { type ContextBase, createContext } from '../intercept/context'\nimport type { Interceptor } from '../intercept/define'\nimport { FAILED, FALLBACK } from '../intercept/fallbacks'\nimport type { OpInput, OpName, OpResult } from '../intercept/operations'\nimport { type Core, createInterceptorRuntime } from '../intercept/runtime'\nimport { createPipeline } from '../pipeline/runner'\nimport type { RowModel, RowModelStatus } from '../pipeline/types'\nimport { checkModeOrder, type FetchOutcome } from '../source/fetcher'\nimport type { ServerSource } from '../source/server'\nimport { SERVER_SOURCE, type ServerFetcher } from '../source/server-brand'\nimport { checkVersions } from '../versioning/registry'\nimport { tableDiagnostics } from './codes'\nimport { createDataMutationCheck, dataMutationDiagnostics } from './data-mutation'\nimport {\n deferral,\n type ExtensionFactory,\n setTableInternals,\n type TableExtension,\n type TableHost,\n} from './internals'\nimport { keepReadOnce } from './read-once'\nimport { PROTO_KEY, stateDiagnostics } from './state-codes'\nimport { createStateFeedbackCheck, stateFeedbackDiagnostics } from './state-feedback'\nimport {\n type ControlledState,\n type Listener,\n type Table,\n type TableOptions,\n type TableState,\n UPDATE_DEPTH_LIMIT,\n type Updater,\n} from './types'\n\nkeepDiagnostics(\n tableDiagnostics,\n dataMutationDiagnostics,\n stateFeedbackDiagnostics,\n optionDiagnostics,\n stateDiagnostics,\n)\n\nconst EMPTY: readonly never[] = []\n\n/** §6.6 status precedence, lowest first: the table shows the highest of its sources. */\nconst RANK: readonly RowModelStatus[] = [\n 'idle',\n 'pending',\n 'validating',\n 'searching',\n 'fetching',\n 'error',\n]\n\nconst isThenable = (v: unknown): v is PromiseLike<unknown> =>\n v != null && typeof (v as { then?: unknown }).then === 'function'\n\n/** Objects already deep-frozen (dev): an unchanged slice is not walked again on the next commit. */\nconst deepFrozen = (process.env.NODE_ENV !== \"production\") ? new WeakSet<object>() : undefined\n\n/**\n * Freezes plain objects and arrays reachable from `root` (dev). Class instances (Date, Map, typed\n * arrays, user classes) are left alone: freezing them would break their own methods. Iterative (an\n * explicit stack): restored state can be nested deeper than the call stack allows (#103).\n */\nfunction deepFreeze(root: unknown): void {\n const stack = [root]\n while (stack.length > 0) {\n const v = stack.pop()\n if (v === null || typeof v !== 'object' || deepFrozen?.has(v)) continue\n const isArray = Array.isArray(v)\n if (!isArray) {\n const proto = Object.getPrototypeOf(v)\n if (proto !== Object.prototype && proto !== null) continue\n }\n deepFrozen?.add(v)\n Object.freeze(v)\n if (isArray) for (let i = 0; i < v.length; i++) stack.push(v[i])\n else for (const k in v) stack.push((v as Record<string, unknown>)[k])\n }\n}\n\n/** Snapshots and their slices are immutable in development (#20); production skips the walk. */\nconst freeze = <S extends object>(s: S): S => {\n if ((process.env.NODE_ENV !== \"production\")) deepFreeze(s)\n return s\n}\n\n/** `undefined` exactly (not `any`, `never` or a union with it). */\ntype IsUndefined<X> =\n (<G>() => G extends X ? 1 : 2) extends <G>() => G extends undefined ? 1 : 2 ? true : false\n\n/**\n * `true` when `Sch` (the inferred `schema` option) is a schema. Its default, `undefined` (no\n * schema), is excluded explicitly: without `strictNullChecks` `undefined` is assignable to every\n * type, `TableSchema` included, which typed `data` as `unknown[]` and `T` as `unknown` (#93).\n */\nexport type HasSchema<Sch> = [Sch] extends [TableSchema]\n ? IsUndefined<Sch> extends true\n ? false\n : true\n : false\n\n/** The row type: the schema output with a `schema` (§5.1), else `T`. */\nexport type SchemaRow<T, Sch> = [Sch] extends [TableSchema]\n ? IsUndefined<Sch> extends true\n ? T\n : StandardSchemaV1.InferOutput<Sch>\n : T\n\n/**\n * `createTable` options: with a `schema`, the row type is its output and `data` is the raw input\n * (`unknown[]`, e.g. parsed JSON), validated per row.\n */\nexport type CreateTableOptions<T, S extends TableState, Sch, M extends InvalidRowsMode> = Omit<\n TableOptions<SchemaRow<T, Sch>, S>,\n 'data' | 'schema' | 'invalidRows' | 'fetcher' | 'initialData'\n> & {\n data?: readonly (HasSchema<Sch> extends true ? unknown : T)[]\n /** With a schema, the raw rows (validated like `data`). */\n initialData?: readonly (HasSchema<Sch> extends true ? unknown : T)[]\n /** With a schema, the fetcher returns raw rows (validated like `data`). */\n fetcher?: ServerFetcher<HasSchema<Sch> extends true ? unknown : T>\n // Without an inferred schema (explicit type arguments, a `TableOptions<T>` object) these keep\n // their `TableOptions` types.\n schema?: HasSchema<Sch> extends true ? Sch : TableSchema<unknown, T>\n invalidRows?: HasSchema<Sch> extends true ? M : InvalidRowsMode\n}\n\n/** Column id: `key` for key columns, `id` for accessor columns. */\nconst columnId = (c: { key?: unknown; id?: unknown }): unknown => c.key ?? c.id\n\n/**\n * Creates the table store (§3.2): immutable state snapshots, controlled slices, isolated listeners,\n * a re-entrancy guard and `destroy()`. Every unit of work runs as an operation (§3.4) through the\n * table's interceptor runtime, with the errorBoundary outermost and diagnostics on a per-table hub.\n *\n * `ctx.where` is always a constant option path or method name (`options`, `options.data`,\n * `setState`, `destroy`): it reaches fingerprints, docs URLs and issue links unredacted, so it must\n * never carry row keys or cell values.\n */\nexport function createTable<\n T,\n S extends TableState = never,\n const Fs extends readonly AnyFeature[] = [],\n const Sch extends TableSchema | undefined = undefined,\n const M extends InvalidRowsMode = 'drop',\n>(\n options: CreateTableOptions<T, TableStateFor<S, Fs, SchemaRow<T, Sch>>, Sch, M> & {\n features?: Fs\n },\n): Table<\n SchemaRow<T, Sch>,\n TableStateFor<S, Fs, SchemaRow<T, Sch>>,\n M,\n HasSchema<Sch> extends true ? unknown : T\n> &\n ApiOf<Fs, SchemaRow<T, Sch>>\nexport function createTable<T, S extends TableState>(\n initialOptions: TableOptions<T, S>,\n): Table<T, S> {\n let options: TableOptions<T, S> = { ...initialOptions }\n let destroyed = false\n let trigger: Trigger = 'init'\n /** Pipeline run id; each `pipeline:run` increments it. */\n let run = 0\n let data: readonly T[] = EMPTY\n let ingestSeq = 0\n /** Data given by the user has been applied once (`RowModel.isInitialLoad`, §6.6). */\n let loaded = false\n /** The last `data:ingest` failed (op fallback): `status: 'error'` until one succeeds (§6.6). */\n let ingestFailed = false\n /** The ingest whose async schema validation is in flight (`status: 'validating'`); 0: none. */\n let validatingSeq = 0\n /** Rows of the current data that failed the schema (`getInvalidRows`, §5.1). */\n let schemaOutcome: SchemaOutcome | undefined\n /**\n * SSR (§7.2): `options.initialData` until the creation ingest read it (`undefined` with `data`),\n * then its ingested rows while they are the table's data (`initialRows`).\n */\n let initialInput = options.data == null ? options.initialData : undefined\n let initialRows: readonly unknown[] | undefined\n /** Created inside `createDeferred` (§7.2): async work waits for `startTable`. */\n let deferring = deferral.depth > 0\n /**\n * Opt-in parts of the store (`TableInternals.use`): the async request machinery and the server\n * source. A table without an async source creates none (§9.3).\n */\n const extensions = new Map<ExtensionFactory<TableExtension>, TableExtension>()\n /** The server source (`withFetcher`, §7.1), once a fetcher was given. */\n let server: ServerSource | undefined\n\n let controlled = new Set<string>()\n let snapshot: S\n /** The snapshot listeners last saw (`prev` of the next notification). */\n let notified: S\n /** A committed change (state or data) not yet notified. */\n let pending = false\n let notifying = false\n let rounds = 0\n let loopReported = false\n let current: number | undefined\n let listenerSeq = 0\n const listeners = new Map<number, Listener<S>>()\n /** Depth of feature API calls in progress: listeners are notified when the outermost returns. */\n let apiDepth = 0\n /** Data, state or columns changed since the row model was computed. */\n let rowModelDirty = true\n /** Diagnostic context (§8.1): the data mode of each pipeline feature (set once features load). */\n const modes: Record<string, 'client' | 'server'> = {}\n\n const table: Table<T, S> = {\n getState: () => snapshot,\n setState,\n subscribe,\n setOptions,\n getOptions: () => options,\n getData: () => data,\n // Core method: on the literal before installApis, so no feature can take the name.\n getRowModel,\n getInvalidRows: () => schemaOutcome?.invalid ?? EMPTY,\n getDiagnostics: () => hub.getDiagnostics(),\n // Core methods (§8.4), read-only: also on the literal before installApis.\n explain: () => explainTable(explainHost),\n explainRow: (key) => explainRow(explainHost, key),\n refetch,\n destroy,\n }\n\n // Redaction (§8.2): `diagnostics.redact` gives the level or a custom rule; column defs give the\n // sensitive columns and whether the rowKey column is sensitive. Both are read per emit, so\n // `setOptions({ columns })` is followed.\n const redactOption = options.diagnostics?.redact\n const redaction: RedactionOptions = {\n ...(typeof redactOption === 'string' ? { level: redactOption } : {}),\n ...(typeof redactOption === 'function' ? { redact: redactOption } : {}),\n sensitiveColumns,\n // A rowKey path into (or above) a sensitive column reads its data too (#45).\n rowKeySensitive: () => {\n const k = options.rowKey\n return typeof k === 'string' && sensitiveColumns().some((c) => pathsOverlap(k, c))\n },\n }\n const hub = createDiagnostics({\n ...(options.name === undefined ? {} : { name: options.name }),\n table,\n onDiagnostic: (d) => options.onDiagnostic?.(d),\n ...(options.strict === undefined ? {} : { strict: options.strict }),\n getContext: () => ({ trigger, run, mode: modes }),\n getDataRef: () => data,\n redaction,\n })\n // Option validator (§3.4, `table:init`), development only: before anything reads the options.\n // Invalid values throw DK_INVALID_OPTION; unknown / no-effect options are reported on the hub.\n if ((process.env.NODE_ENV !== \"production\")) validateOptions(options, { table: hub.table, emit: hub.emit })\n // Features (§3.3) are read once, at creation. `features` is the listed order (API install, conflict\n // reports); `pipeline` is stage order for the runner. Duplicates throw here (config error).\n const features: readonly AnyFeature[] = options.features ?? EMPTY\n // The feature runtime comes with the features (`defineFeature`): none for a table without.\n const rt = runtimeFor(features)\n const pipeline = rt ? rt.orderFeatures(features, hub.table) : EMPTY\n // Data modes (§7.1): DK_MODE_ORDER (a config error, development). A fetcher without a server-mode\n // feature (DK_FETCHER_WITHOUT_SERVER_MODE) is checked by the server source.\n if ((process.env.NODE_ENV !== \"production\")) checkModeOrder(pipeline, hub.table)\n for (const f of pipeline) if (f.stage !== 'none') modes[f.name] = f.mode ?? 'client'\n // Extension interceptors come first (asyncControl, one per table, installed with the first async\n // source: user / feature interceptors and the core see its signal); the boundary stays\n // outermost. Feature interceptors (pipeline order) come next, then the user's.\n const front: Interceptor<OpName>[] = []\n const featureInterceptors = pipeline.flatMap((f) => f.interceptors ?? EMPTY)\n // The tracer (§3.4, explain timings) is development-only: `(process.env.NODE_ENV !== \"production\")` folds to `false` in production\n // builds, which drops it from the bundle; there it is opt-in with `interceptors: [tracer()]`.\n const traced = (process.env.NODE_ENV !== \"production\") ? [tracer() as Interceptor<OpName>] : EMPTY\n const withFront = (list: readonly Interceptor<OpName>[] | undefined) => [\n ...front,\n ...traced,\n ...featureInterceptors,\n ...(list ?? EMPTY),\n ]\n const runtime = createInterceptorRuntime({\n interceptors: withFront(options.interceptors),\n emit: hub.emit,\n })\n runtime.installBoundary(errorBoundary)\n hub.attach(runtime)\n // Dev check (§5.3): the same `data` array passed again with changed contents (DK_DATA_MUTATED).\n const dataCheck = (process.env.NODE_ENV !== \"production\") ? createDataMutationCheck(hub.emit) : undefined\n // Feature `requires.core` (throws DK_FEATURE_INCOMPATIBLE), duplicate cores, version mismatch\n // (§8.5): development checks (changed 2026-10-13 for §9.3).\n if ((process.env.NODE_ENV !== \"production\")) checkVersions(features, hub.emit, hub.table)\n // Ingest data checks (§5.3) and zero-config columns (§4.1): both read only the first rows.\n // The data checks are developer hints: development only (changed 2026-10-13 for §9.3).\n const dataChecks = (process.env.NODE_ENV !== \"production\") ? createDataChecks(hub.emit) : undefined\n /** Controlled changes not fed back (DK_CONTROLLED_NOT_FED_BACK, development). */\n const feedback = (process.env.NODE_ENV !== \"production\") ? createStateFeedbackCheck(hub.emit) : undefined\n const derivedColumns = createDerivedColumns()\n // Schema ingest (§5.1): `schema` and `invalidRows` are read once (validated above). The step\n // comes with the schema (`withSchema`, `@datakable/core/schema`): a table without one never\n // bundles it.\n const schemaIngest = (options.schema as Partial<TableSchema> | undefined)?.[SCHEMA_INGEST]?.(\n options.invalidRows ?? 'drop',\n () => options.columns,\n )\n // Never silent (§8.6): in production (no option validator) an unwrapped schema would be ignored.\n if (options.schema && !schemaIngest) unwrapped('schema', options.schema, 'withSchema')\n\n function sensitiveColumns(): string[] {\n const out: string[] = []\n for (const c of options.columns ?? EMPTY) {\n const id = columnId(c as { key?: unknown; id?: unknown })\n if (c.sensitive && typeof id === 'string') out.push(id)\n }\n return out\n }\n\n function base(): ContextBase {\n return { table, run, trigger, phase: defaultPhase(), emit: hub.emit }\n }\n\n function op<O extends OpName>(\n name: O,\n input: OpInput<O>,\n where: string,\n core: Core<O>,\n fallback?: unknown,\n ): OpResult<O> {\n const ctx = createContext(name, input, where, base())\n if (fallback !== undefined) ctx.meta.set(FALLBACK, fallback)\n return runtime.run(name, ctx, core)\n }\n\n function withTrigger<R>(t: Trigger, fn: () => R): R {\n const prev = trigger\n trigger = t\n try {\n return fn()\n } finally {\n trigger = prev\n }\n }\n\n // --- state -------------------------------------------------------------------------------------\n\n /** A `__proto__` key (JSON.parse makes it own) is never written into state (#102). */\n function protoKey(k: string): boolean {\n if (k !== PROTO_KEY) return false\n hub.emit('DK_STATE_UNKNOWN_KEY', { slice: '', key: k, known: EMPTY })\n return true\n }\n\n function controlledKeys(state: ControlledState<S> | undefined): Set<string> {\n const keys = new Set<string>()\n if (state) {\n for (const k of Object.keys(state)) if (state[k] !== undefined && !protoKey(k)) keys.add(k)\n }\n return keys\n }\n\n /** `s` with the controlled slices from `options.state`; `s` itself when none differ. */\n function overlay(s: S): S {\n let next: TableState | undefined\n const state = options.state as TableState | undefined\n if (state) {\n for (const k of controlled) {\n if (!Object.is(s[k], state[k])) {\n next ??= { ...s }\n next[k] = state[k]\n }\n }\n }\n return next ? freeze(next as S) : s\n }\n\n function commit(next: S) {\n snapshot = next\n pending = true\n rowModelDirty = true\n }\n\n function warnControlled(dropped: string[] | undefined) {\n if (options.onStateChange || controlled.size === 0) return\n const slices = dropped ?? [...controlled]\n hub.emit('DK_CONTROLLED_WITHOUT_HANDLER', { slices, dropped: dropped !== undefined })\n }\n\n function syncControlled() {\n controlled = controlledKeys(options.state)\n const next = overlay(snapshot)\n if (next !== snapshot) commit(next)\n if ((process.env.NODE_ENV !== \"production\")) feedback?.settle(options.state as TableState | undefined, controlled)\n warnControlled(undefined)\n }\n\n function dispatch(updater: Updater<S>, slot: string) {\n // A method argument, not an option: `where` = `operation table.setState at updater`.\n const partial: Partial<S> =\n typeof updater === 'function'\n ? callUser(\n 'updater',\n updater,\n snapshot,\n undefined,\n slot === 'setState' ? 'table.setState' : `${slot}.setState`,\n )\n : updater\n if (partial === null || typeof partial !== 'object') return\n let next: TableState | undefined\n let changes: TableState | undefined\n let dropped: string[] | undefined\n for (const k of Object.keys(partial)) {\n if (protoKey(k)) continue\n const v = (partial as TableState)[k]\n if (Object.is(snapshot[k], v)) continue\n if (controlled.has(k)) {\n if (options.onStateChange) {\n changes ??= {}\n changes[k] = v\n } else {\n dropped ??= []\n dropped.push(k)\n }\n continue\n }\n next ??= { ...snapshot }\n next[k] = v\n }\n // The owner is told first: if onStateChange throws, nothing is committed (state unchanged).\n if (changes && options.onStateChange) {\n const c = changes as Partial<S>\n if ((process.env.NODE_ENV !== \"production\")) feedback?.ask(Object.keys(changes), trigger)\n callUser('onStateChange', options.onStateChange, (prev: Partial<S>) => ({ ...prev, ...c }))\n if ((process.env.NODE_ENV !== \"production\")) feedback?.asked()\n }\n if (next) commit(freeze(next as S))\n if (dropped) warnControlled(dropped)\n }\n\n /**\n * Notifies listeners until no change is pending. Updates made by listeners are committed at once\n * and notified in the next round (not nested), so every listener sees rounds in order.\n */\n function flush() {\n if (notifying) return\n sync()\n if (!pending) return\n notifying = true\n let rethrow: unknown\n try {\n while (pending && !destroyed) {\n // Server state changed (this round's state): the fetch starts in the same notification.\n sync()\n pending = false\n rounds++\n const prev = notified\n const state = snapshot\n notified = state\n // Listeners read the row model of the state they are notified with.\n ensureRowModel()\n for (const [id, listener] of [...listeners]) {\n // A listener may destroy the table: the rest of the round is not notified.\n if (destroyed) break\n current = id\n try {\n listener(state, prev)\n } catch (e) {\n // strict: a DatakableError (e.g. DK_UPDATE_LOOP) thrown inside the listener.\n if (e instanceof DatakableError) {\n rethrow ??= e\n continue\n }\n try {\n const name = errorName(e)\n hub.emit(\n 'DK_LISTENER_FAILED',\n { listener: id, ...(name === undefined ? {} : { errorName: name }) },\n { cause: e },\n )\n } catch (strictError) {\n rethrow ??= strictError\n }\n }\n }\n }\n } finally {\n notifying = false\n rounds = 0\n loopReported = false\n current = undefined\n }\n if (rethrow !== undefined) throw rethrow\n }\n\n /** `false` (and one `DK_UPDATE_LOOP`) when a re-entrant update would exceed the depth limit. */\n function admit(slices: string[]): boolean {\n if (!notifying || rounds < UPDATE_DEPTH_LIMIT) return true\n if (!loopReported) {\n loopReported = true\n hub.emit('DK_UPDATE_LOOP', {\n limit: UPDATE_DEPTH_LIMIT,\n slices,\n ...(current === undefined ? {} : { listener: current }),\n })\n }\n return false\n }\n\n function destroyedCall(method: string) {\n withTrigger(`api:${method}`, () => hub.emit('DK_TABLE_DESTROYED', { method }))\n }\n\n // --- data --------------------------------------------------------------------------------------\n\n /** Applies ingested data; `given`: it came from a user `options.data` (marks the first load). */\n function setData(next: readonly T[], given: boolean) {\n if (given && !loaded) {\n // isInitialLoad flips: a new row model and a notification even for the same reference.\n loaded = true\n pending = true\n rowModelDirty = true\n }\n if (next === data) return\n data = next\n pending = true\n // After `data` is set: diagnostics dedupe per data reference.\n if ((process.env.NODE_ENV !== \"production\")) dataChecks?.check(data, options.columns)\n // The pipeline runs before the next notification (or on getRowModel), as `pipeline:run` with\n // ctx.meta[FALLBACK] = the last good row model (pipeline/runner.ts).\n rowModelDirty = true\n }\n\n // --- row model ---------------------------------------------------------------------------------\n\n const runner = createPipeline<T>({\n runtime,\n featureRuntime: rt,\n emit: hub.emit,\n features: pipeline,\n listed: features,\n base,\n nextRun: () => ++run,\n getData: () => data,\n getState: () => snapshot,\n getColumns: () => options.columns ?? derivedColumns(data),\n getRowKey: () => options.rowKey,\n isInitialLoad: () => !loaded,\n status,\n issues: (index) => schemaOutcome?.flagged?.get(index),\n flagMode: schemaIngest !== undefined && options.invalidRows === 'flag',\n // Time-sliced work ended (§9.1): 'pending' → the finished row model, never silent (§6.6).\n refresh: (t) => {\n if (destroyed) return\n withTrigger(t, () => {\n touch()\n if (apiDepth === 0) flush()\n })\n },\n })\n\n const explainHost: ExplainHost = {\n table,\n features: pipeline,\n rowModel: getRowModel as () => RowModel<unknown>,\n lastRun: runner.lastRun,\n replay: runner.replayContext,\n data: () => data,\n state: () => snapshot,\n rowKey: () => options.rowKey,\n schemaMode: () => (schemaIngest ? (options.invalidRows ?? 'drop') : undefined),\n schema: () => schemaOutcome,\n diagnostics: () => hub.getDiagnostics(),\n redaction,\n ...(rt ? { detail: rt.explainDetail } : {}),\n }\n\n /**\n * Status from outside the pipeline (§6.6): a failed ingest, a running async schema, the search\n * slice (`pending` / `searching` / `error`), and the extensions' (a failed fetch, an in-flight\n * fetcher / `searchFn`, deferred async work). Precedence: error > fetching > searching >\n * validating > pending > idle.\n */\n function status(): RowModelStatus {\n const search = searchStatus()\n let s: RowModelStatus =\n ingestFailed || search === 'error'\n ? 'error'\n : search === 'searching'\n ? 'searching'\n : validatingSeq !== 0\n ? 'validating'\n : search === 'pending'\n ? 'pending'\n : 'idle'\n for (const e of extensions.values()) {\n const x = e.status?.()\n if (x !== undefined && RANK.indexOf(x) > RANK.indexOf(s)) s = x\n }\n return s\n }\n\n /** Extensions start work that follows state (the fetcher on server state, §7.1). */\n function sync() {\n for (const e of extensions.values()) e.sync?.()\n }\n\n /** The `status` of the first search-stage slice that reports one (§6.3). */\n function searchStatus(): unknown {\n for (const f of pipeline) {\n if (f.stage !== 'search') continue\n const s = (snapshot as Record<string, unknown> | undefined)?.[f.name]\n if (s !== null && typeof s === 'object' && 'status' in s) {\n const v = (s as { status: unknown }).status\n if (v !== 'idle') return v\n }\n }\n return 'idle'\n }\n\n /** A row model change not caused by state: recompute and notify on the next flush. */\n function touch() {\n pending = true\n rowModelDirty = true\n }\n\n /** Recomputes the row model if data, state or columns changed (never after destroy). */\n function ensureRowModel() {\n if (!rowModelDirty || destroyed) return\n rowModelDirty = false\n runner.run()\n }\n\n function getRowModel(): RowModel<T> {\n ensureRowModel()\n // Only empty when destroyed before the first run.\n return (\n runner.current() ?? {\n rows: EMPTY,\n filteredCount: 0,\n totalCount: 0,\n status: status(),\n isInitialLoad: !loaded,\n }\n )\n }\n\n /**\n * Applies the result of the latest `data:ingest`. A fallback (the boundary set `FAILED`) keeps\n * the previous data, sets `status: 'error'` and never marks the table loaded (§6.6, §8.6).\n */\n function applyIngest(out: readonly unknown[], failed: boolean, given: boolean, initial = false) {\n if (validatingSeq !== 0) {\n validatingSeq = 0\n touch()\n }\n if (failed) {\n ingestFailed = true\n touch()\n return\n }\n if (ingestFailed) {\n ingestFailed = false\n touch()\n }\n schemaOutcome = schemaIngest?.outcome(out)\n setData(out as readonly T[], given)\n // `initialData` is the initial async result only while it is the data (§7.2).\n initialRows = initial ? out : undefined\n }\n\n /**\n * `data:ingest` with the previous data as fallback: the schema step (§5.1) runs in its core. An\n * async result is applied if still latest. `fetched`: rows of an applied fetcher result (§7.1),\n * ingested like `options.data` (schema, data checks) and marking the table loaded.\n */\n function ingest(fetched?: readonly unknown[]) {\n const seq = ++ingestSeq\n // At creation, `initialData` stands in for a missing `data` (§7.2); read once.\n const initial = fetched === undefined && initialInput !== undefined\n const input = fetched ?? (initial ? initialInput : options.data)\n initialInput = undefined\n // `data: null` counts as not given (production has no option validator, #94).\n const given = input != null\n const source: Trigger = fetched ? 'fetch' : 'data-change'\n // A validation still in flight is superseded (its result is discarded): not 'validating' now,\n // unless this ingest's own schema step goes async.\n if (validatingSeq !== 0) {\n validatingSeq = 0\n touch()\n }\n try {\n withTrigger(source, () => {\n const ctx = createContext(\n 'data:ingest',\n { data: input ?? EMPTY },\n fetched ? 'fetcher' : initial ? 'options.initialData' : 'options.data',\n base(),\n )\n ctx.meta.set(FALLBACK, data)\n let sync = true\n const out = runtime.run('data:ingest', ctx, (c) => {\n const input = c.input.data as readonly unknown[]\n if (!schemaIngest) return input\n const r = schemaIngest.validate(input, c.emit)\n if (isThenable(r) && seq === ingestSeq && !destroyed) {\n // 'validating' is never silent: a new row model and a notification now (§6.6).\n validatingSeq = seq\n touch()\n if (!sync) flush()\n }\n return r\n })\n sync = false\n if (!isThenable(out)) {\n applyIngest(out, ctx.meta.has(FAILED), given, initial)\n return\n }\n const settle = (d: readonly unknown[], failed: boolean) => {\n if (seq !== ingestSeq || destroyed) return\n withTrigger(source, () => {\n applyIngest(d, failed, given, initial)\n flush()\n })\n }\n Promise.resolve(out).then(\n (d) => settle(d, ctx.meta.has(FAILED)),\n // A DatakableError the boundary rethrew (strict, or `invalidRows: 'throw'` with an async\n // schema, already reported): the previous data is kept with 'error'. No unhandled\n // rejection either way (§8.6).\n () => settle(data, true),\n )\n })\n } finally {\n // Dev (§5.3): fingerprint `data` after the core read it, so the check never takes reads\n // first; also when the ingest threw, so a later same-reference check compares this data.\n if ((process.env.NODE_ENV !== \"production\") && !fetched) dataCheck?.remember(options.data)\n }\n }\n\n // --- API ---------------------------------------------------------------------------------------\n\n /** `state:dispatch` (where = `slot`, a constant method / feature name); notifies unless batched. */\n function update(updater: Updater<S>, slot: string) {\n void op('state:dispatch', { updater }, slot, (): undefined => {\n dispatch(updater, slot)\n })\n if (apiDepth === 0) flush()\n }\n\n function setState(updater: Updater<S>) {\n if (destroyed) return destroyedCall('setState')\n if (!admit(typeof updater === 'function' ? [] : Object.keys(updater ?? {}))) return\n withTrigger('api:setState', () => update(updater, 'setState'))\n }\n\n // --- features ----------------------------------------------------------------------------------\n\n /** A feature's `ctx.setState`: replaces its own slice (trigger: the API call's, if any). */\n function setSlice(name: string, updater: SliceUpdater<unknown>) {\n if (destroyed) return destroyedCall(`${name}.setState`)\n if (!admit([name])) return\n const slice: Updater<S> =\n typeof updater === 'function'\n ? (prev) => ({ [name]: (updater as (p: unknown) => unknown)(prev[name]) }) as Partial<S>\n : ({ [name]: updater } as Partial<S>)\n update(slice, name)\n }\n\n /** Runs a feature API method (wrapped once by `installApis`). */\n function callApi(method: string, fn: () => unknown, ifDestroyed?: () => unknown): unknown {\n if (destroyed) {\n destroyedCall(method)\n return ifDestroyed?.()\n }\n return withTrigger(`api:${method}`, () => {\n apiDepth++\n try {\n return fn()\n } finally {\n apiDepth--\n if (apiDepth === 0) flush()\n }\n })\n }\n\n function subscribe(listener: Listener<S>): () => void {\n if (destroyed) {\n destroyedCall('subscribe')\n return () => {}\n }\n const id = ++listenerSeq\n listeners.set(id, listener)\n return () => {\n listeners.delete(id)\n }\n }\n\n function setOptions(partial: Partial<TableOptions<T, S>>) {\n if (destroyed) return destroyedCall('setOptions')\n if (!admit(Object.keys(partial.state ?? {}))) return\n withTrigger('setOptions', () => {\n const previous = options\n const next = { ...options, ...partial }\n // Option validator (§3.4, `table:setOptions`, development): an invalid value throws before\n // anything changes. Read-once options (`features`, `timeout`, `diagnostics`, …) keep their\n // value in every build.\n if ((process.env.NODE_ENV !== \"production\")) validateOptionChange(partial, next, previous, { table: hub.table, emit: hub.emit })\n else keepReadOnce(partial, next, previous)\n if ('fetcher' in partial) useServer(next.fetcher, 'setOptions')?.check(next.fetcher)\n void op('table:setOptions', { options: next, previous }, 'options', (): undefined => {\n options = next\n if (next.interceptors !== previous.interceptors) {\n runtime.setInterceptors(withFront(next.interceptors))\n }\n if ('state' in partial || 'onStateChange' in partial) syncControlled()\n if (next.columns !== previous.columns || next.rowKey !== previous.rowKey) {\n rowModelDirty = true\n pending = true\n }\n // The page count changed (§6.5): listeners re-read it (and pagination clamps).\n if (next.rowCount !== previous.rowCount) pending = true\n // A new fetcher reference runs at once, even with the same params (flush → sync).\n if (next.fetcher !== previous.fetcher) server?.reset()\n // New data is checked when applied (setData); same data with new columns is checked here.\n if (next.data !== previous.data) ingest()\n else if ((process.env.NODE_ENV !== \"production\")) {\n if ('data' in partial) dataCheck?.check(next.data)\n if (next.columns !== previous.columns) dataChecks?.check(data, next.columns)\n }\n })\n flush()\n })\n }\n\n function destroy() {\n if (destroyed) return\n withTrigger('api:destroy', () => {\n try {\n void op('table:destroy', undefined, 'destroy', (): undefined => {\n destroyed = true\n })\n } finally {\n // Even if an interceptor skipped the core: the table is destroyed.\n destroyed = true\n ingestSeq++\n listeners.clear()\n runner.dispose()\n if ((process.env.NODE_ENV !== \"production\")) feedback?.dispose()\n }\n })\n }\n\n // --- extensions (§9.3) ---------------------------------------------------------------------\n\n function batch<R>(t: Trigger, fn: () => R): R {\n return withTrigger(t, () => {\n apiDepth++\n try {\n return fn()\n } finally {\n apiDepth--\n if (apiDepth === 0) flush()\n }\n })\n }\n\n const host: TableHost = {\n table: table as unknown as Table<unknown, TableState>,\n name: hub.table,\n emit: hub.emit,\n runtime,\n features: pipeline,\n options: () => options as TableOptions<unknown>,\n state: () => snapshot,\n base,\n destroyed: () => destroyed,\n loaded: () => loaded,\n status,\n touch,\n notify: () => {\n if (apiDepth === 0) flush()\n },\n batch,\n ingest: (rows) => ingest(rows),\n intercept(interceptor) {\n front.push(interceptor)\n runtime.setInterceptors(withFront(options.interceptors))\n },\n deferring: () => deferring,\n use,\n }\n\n function use<E extends TableExtension>(factory: ExtensionFactory<E>): E {\n let e = extensions.get(factory as ExtensionFactory<TableExtension>) as E | undefined\n if (!e) {\n e = factory(host)\n extensions.set(factory as ExtensionFactory<TableExtension>, e)\n }\n return e\n }\n\n /** The server source a `withFetcher` fetcher brings (created once); else the current one. */\n function useServer(fetcher: unknown, phase?: 'setOptions'): ServerSource | undefined {\n const factory = (fetcher as Partial<ServerFetcher<unknown>> | undefined)?.[SERVER_SOURCE]\n if (factory) server = use(factory)\n // Never silent (§8.6): in production an unwrapped fetcher would never run.\n else if (fetcher) unwrapped('fetcher', fetcher, 'withFetcher', 'server', phase)\n return server\n }\n\n /**\n * `DK_INVALID_OPTION` for a schema / fetcher not wrapped with its opt-in import (§5.1, §7.1). A\n * production check: in development the option validator reports it first, with the full text.\n */\n function unwrapped(\n path: 'schema' | 'fetcher',\n value: unknown,\n wrap: string,\n entry: string = path,\n phase: 'init' | 'setOptions' = 'init',\n ): never {\n return throwConfigError(\n 'DK_INVALID_OPTION',\n {\n path,\n expected: `wrapped|${wrap}|${path}|${entry}`, // prose key (diagnostics/prose.ts)\n received: typeof value,\n suggestions: [],\n phase,\n },\n { table: hub.table, trigger: phase },\n )\n }\n\n /**\n * Runs the fetcher again with the current params (§7.1); never rejects. Without a fetcher:\n * `{ status: 'applied' }` at once. Deferred: settles after `startTable` (#90, `server.sync`).\n */\n function refetch(): Promise<FetchOutcome> {\n if (destroyed) {\n destroyedCall('refetch')\n return Promise.resolve({ status: 'superseded' })\n }\n return (\n withTrigger('api:refetch', () => server?.sync(true)) ?? Promise.resolve({ status: 'applied' })\n )\n }\n\n /** `startTable` (§7.2): the deferred work starts; listeners see the new status at once. */\n function start() {\n if (!deferring || destroyed) return\n deferring = false\n let had = false\n for (const e of extensions.values()) if (e.start?.()) had = true\n if (!had) return\n // The pipeline re-runs: 'pending' ends and the search feature's check starts its searchFn.\n touch()\n withTrigger('hydrate', () => flush())\n }\n\n setTableInternals(table, {\n features: pipeline,\n name: options.name,\n rowCount: () => (typeof options.fetcher === 'function' ? server?.rowCount() : options.rowCount),\n hasFetcher: () => typeof options.fetcher === 'function',\n emit: hub.emit,\n use,\n peek: (factory) => extensions.get(factory as ExtensionFactory<TableExtension>) as never,\n extensions: () => extensions.values(),\n start,\n initialRows: () =>\n initialRows !== undefined && initialRows === data ? initialRows : undefined,\n })\n\n // --- init --------------------------------------------------------------------------------------\n\n controlled = controlledKeys(options.state)\n if ((process.env.NODE_ENV !== \"production\")) feedback?.settle(options.state as TableState | undefined, controlled)\n // Feature `initialState()` slices, with `options.initialState` on top per slice.\n // A copy without a `__proto__` key (#102): safe for `Object.assign` in initialSlices.\n const restored: TableState = { ...options.initialState }\n if (Object.hasOwn(restored, PROTO_KEY) && protoKey(PROTO_KEY)) delete restored[PROTO_KEY]\n snapshot = overlay(freeze((rt ? rt.initialSlices(features, restored, hub.emit) : restored) as S))\n notified = snapshot\n // Merges the feature APIs onto the table; a name clash throws DK_FEATURE_API_CONFLICT.\n rt?.installApis(features, {\n table: table as unknown as Table<unknown, TableState>,\n tableName: hub.table,\n emit: hub.emit,\n getSlice: (name) => snapshot[name],\n setSlice,\n call: callApi,\n })\n // Server source (§7.1): with a `withFetcher` fetcher (throws DK_FETCHER_WITHOUT_SERVER_MODE).\n useServer(options.fetcher)\n withTrigger('init', () => {\n // `void`: sync ops never return a promise (op kinds, §3.4).\n void op('table:init', { options }, 'options', (): undefined => {\n // Ingest first: dedupe is per data reference, so warnings follow the initial data.\n ingest()\n warnControlled(undefined)\n })\n // Server source (§7.1): the first request starts now ('fetching', isInitialLoad: true), unless\n // initialData answered the initial server state (§7.2).\n sync()\n })\n pending = false\n return table\n}\n"],"mappings":";AAAA,SAAS,yBAAyB;AAClC,SAAS,sBAAsB,uBAAuB;AACtD,SAAS,gBAAgB,cAAc,wBAAwB;AAC/D,SAAS,uBAAuB;AAChC,OAAO;AACP,SAA2B,YAAY,oBAAoB;AAC3D,SAAS,yBAAyB;AAClC,SAAS,oBAA2C;AACpD,SAAS,cAAc;AAEvB,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAErC,SAAS,qBAAuC;AAGhD,SAAS,qBAAqB;AAC9B,SAAS,UAAU,iBAAiB;AACpC,SAA2B,qBAAqB;AAEhD,SAAS,QAAQ,gBAAgB;AAEjC,SAAoB,gCAAgC;AACpD,SAAS,sBAAsB;AAE/B,SAAS,sBAAyC;AAElD,SAAS,qBAAyC;AAClD,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB,+BAA+B;AACjE;AAAA,EACE;AAAA,EAEA;AAAA,OAGK;AACP,SAAS,oBAAoB;AAC7B,SAAS,WAAW,wBAAwB;AAC5C,SAAS,0BAA0B,gCAAgC;AACnE;AAAA,EAME;AAAA,OAEK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,QAA0B,CAAC;AAGjC,IAAM,OAAkC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,aAAa,CAAC,MAClB,KAAK,QAAQ,OAAQ,EAAyB,SAAS;AAGzD,IAAM,aAAc,QAAQ,IAAI,aAAa,eAAgB,oBAAI,QAAgB,IAAI;AAOrF,SAAS,WAAW,MAAqB;AACvC,QAAM,QAAQ,CAAC,IAAI;AACnB,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AAA,EACP,CAAC;AACD,YAAU;AACV,SAAO;AACT;","names":["sync","input"]}
|
package/dist/table/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ __export(table_exports, {
|
|
|
27
27
|
emitTableDiagnostic: () => import_internals.emitTableDiagnostic,
|
|
28
28
|
ssrDiagnostics: () => import_ssr_codes.ssrDiagnostics,
|
|
29
29
|
startTable: () => import_ssr.startTable,
|
|
30
|
+
stateDiagnostics: () => import_state_codes.stateDiagnostics,
|
|
30
31
|
tableDiagnostics: () => import_codes.tableDiagnostics
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(table_exports);
|
|
@@ -36,6 +37,7 @@ var import_data_mutation = require("./data-mutation.cjs");
|
|
|
36
37
|
var import_internals = require("./internals.cjs");
|
|
37
38
|
var import_ssr = require("./ssr.cjs");
|
|
38
39
|
var import_ssr_codes = require("./ssr-codes.cjs");
|
|
40
|
+
var import_state_codes = require("./state-codes.cjs");
|
|
39
41
|
var import_types = require("./types.cjs");
|
|
40
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
43
|
0 && (module.exports = {
|
|
@@ -46,6 +48,7 @@ var import_types = require("./types.cjs");
|
|
|
46
48
|
emitTableDiagnostic,
|
|
47
49
|
ssrDiagnostics,
|
|
48
50
|
startTable,
|
|
51
|
+
stateDiagnostics,
|
|
49
52
|
tableDiagnostics
|
|
50
53
|
});
|
|
51
54
|
//# sourceMappingURL=index.cjs.map
|
package/dist/table/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/table/index.ts"],"sourcesContent":["export { tableDiagnostics } from './codes'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/table/index.ts"],"sourcesContent":["export { tableDiagnostics } from './codes'\nexport {\n type CreateTableOptions,\n createTable,\n type HasSchema,\n type SchemaRow,\n} from './create-table'\nexport { dataMutationDiagnostics } from './data-mutation'\nexport { emitTableDiagnostic } from './internals'\nexport { createDeferred, startTable } from './ssr'\nexport { ssrDiagnostics } from './ssr-codes'\nexport { stateDiagnostics } from './state-codes'\nexport {\n type ControlledState,\n type Listener,\n type Table,\n type TableDiagnosticsOptions,\n type TableOptions,\n type TableState,\n UPDATE_DEPTH_LIMIT,\n type Updater,\n} from './types'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AACjC,0BAKO;AACP,2BAAwC;AACxC,uBAAoC;AACpC,iBAA2C;AAC3C,uBAA+B;AAC/B,yBAAiC;AACjC,mBASO;","names":[]}
|
package/dist/table/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// src/table/index.ts
|
|
2
2
|
import { tableDiagnostics } from "./codes.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createTable
|
|
5
|
+
} from "./create-table.js";
|
|
4
6
|
import { dataMutationDiagnostics } from "./data-mutation.js";
|
|
5
7
|
import { emitTableDiagnostic } from "./internals.js";
|
|
6
8
|
import { createDeferred, startTable } from "./ssr.js";
|
|
7
9
|
import { ssrDiagnostics } from "./ssr-codes.js";
|
|
10
|
+
import { stateDiagnostics } from "./state-codes.js";
|
|
8
11
|
import {
|
|
9
12
|
UPDATE_DEPTH_LIMIT
|
|
10
13
|
} from "./types.js";
|
|
@@ -16,6 +19,7 @@ export {
|
|
|
16
19
|
emitTableDiagnostic,
|
|
17
20
|
ssrDiagnostics,
|
|
18
21
|
startTable,
|
|
22
|
+
stateDiagnostics,
|
|
19
23
|
tableDiagnostics
|
|
20
24
|
};
|
|
21
25
|
//# sourceMappingURL=index.js.map
|
package/dist/table/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/table/index.ts"],"sourcesContent":["export { tableDiagnostics } from './codes'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/table/index.ts"],"sourcesContent":["export { tableDiagnostics } from './codes'\nexport {\n type CreateTableOptions,\n createTable,\n type HasSchema,\n type SchemaRow,\n} from './create-table'\nexport { dataMutationDiagnostics } from './data-mutation'\nexport { emitTableDiagnostic } from './internals'\nexport { createDeferred, startTable } from './ssr'\nexport { ssrDiagnostics } from './ssr-codes'\nexport { stateDiagnostics } from './state-codes'\nexport {\n type ControlledState,\n type Listener,\n type Table,\n type TableDiagnosticsOptions,\n type TableOptions,\n type TableState,\n UPDATE_DEPTH_LIMIT,\n type Updater,\n} from './types'\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC;AAAA,EAEE;AAAA,OAGK;AACP,SAAS,+BAA+B;AACxC,SAAS,2BAA2B;AACpC,SAAS,gBAAgB,kBAAkB;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC;AAAA,EAOE;AAAA,OAEK;","names":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/table/state-codes.ts
|
|
21
|
+
var state_codes_exports = {};
|
|
22
|
+
__export(state_codes_exports, {
|
|
23
|
+
PROTO_KEY: () => PROTO_KEY,
|
|
24
|
+
stateDiagnostics: () => stateDiagnostics,
|
|
25
|
+
stateMessages: () => stateMessages
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(state_codes_exports);
|
|
28
|
+
var import_suggest = require("../catalog/suggest.cjs");
|
|
29
|
+
var import_catalog = require("../diagnostics/catalog.cjs");
|
|
30
|
+
var import_process_guard = require("../diagnostics/process-guard.cjs");
|
|
31
|
+
var PROTO_KEY = "__proto__";
|
|
32
|
+
var stateMessages = {
|
|
33
|
+
DK_STATE_UNKNOWN_KEY: {
|
|
34
|
+
problem: (d) => d.key === PROTO_KEY ? `${d.slice ? `state.${d.slice}` : "the state"} has a "__proto__" key` : `state.${d.slice} has an entry for "${d.key}", which is not a column`,
|
|
35
|
+
impact: (d) => d.key === PROTO_KEY ? "the key is ignored: writing it would replace the prototype of the state object (JSON.parse of untrusted input creates such keys)" : "the entry is ignored (the other entries still apply); it may come from an older URL or saved state, or the column was renamed or removed",
|
|
36
|
+
fix: (d) => {
|
|
37
|
+
if (d.key === PROTO_KEY) {
|
|
38
|
+
return [`drop "__proto__" when parsing initialState / state (e.g. from the URL or storage)`];
|
|
39
|
+
}
|
|
40
|
+
const near = (0, import_suggest.suggest)(d.key, d.known);
|
|
41
|
+
return [
|
|
42
|
+
near.length > 0 ? `did you mean "${near[0]}"? (state.${d.slice}["${near[0]}"])` : `use one of the column ids: ${d.known.map((k) => `"${k}"`).join(", ")}`,
|
|
43
|
+
`drop "${d.key}" when parsing initialState / state (e.g. from the URL), or add the column`
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
DK_INVALID_STATE: {
|
|
48
|
+
problem: (d) => `state.${d.slice} is malformed (${d.received})`,
|
|
49
|
+
impact: (d) => `the slice was replaced with ${d.fallback}; the table keeps working`,
|
|
50
|
+
fix: (d) => [
|
|
51
|
+
`write state.${d.slice} in the shape the feature uses (check initialState, setState and the controlled options.state, e.g. a value restored from the URL or storage)`,
|
|
52
|
+
`validate restored state before passing it, or drop ${d.slice} when it does not parse`
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var stateDiagnostics = [
|
|
57
|
+
(0, import_catalog.defineDiagnostic)(
|
|
58
|
+
{
|
|
59
|
+
code: "DK_STATE_UNKNOWN_KEY",
|
|
60
|
+
level: "warn",
|
|
61
|
+
where: (d) => ({ kind: "option", path: `state.${d.slice && `${d.slice}.`}${d.key}` })
|
|
62
|
+
},
|
|
63
|
+
process.env.NODE_ENV !== "production" && stateMessages.DK_STATE_UNKNOWN_KEY
|
|
64
|
+
)
|
|
65
|
+
];
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
PROTO_KEY,
|
|
69
|
+
stateDiagnostics,
|
|
70
|
+
stateMessages
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=state-codes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/table/state-codes.ts"],"sourcesContent":["import { suggest } from '../catalog/suggest'\nimport { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_STATE_UNKNOWN_KEY: {\n /** The state slice holding the key, e.g. `columnFilters`; `''` for a top-level state key. */\n slice: string\n /** The key that names no column (or `__proto__`, which is never applied, #102). */\n key: string\n /** The table's column ids (did-you-mean); empty for `__proto__`. */\n known: readonly string[]\n }\n DK_INVALID_STATE: {\n /** The feature slice, e.g. `sorting`. */\n slice: string\n /** What the slice was (`describeValue`), or what was wrong with it, e.g. `by[1] null`. */\n received: string\n /** What was stored instead. */\n fallback: string\n }\n }\n}\n\n/** The one key a plain `=` / `Object.assign` write turns into a prototype change (#102). */\nexport const PROTO_KEY = '__proto__'\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const stateMessages: DiagnosticMessages<'DK_STATE_UNKNOWN_KEY' | 'DK_INVALID_STATE'> = {\n DK_STATE_UNKNOWN_KEY: {\n problem: (d) =>\n d.key === PROTO_KEY\n ? `${d.slice ? `state.${d.slice}` : 'the state'} has a \"__proto__\" key`\n : `state.${d.slice} has an entry for \"${d.key}\", which is not a column`,\n impact: (d) =>\n d.key === PROTO_KEY\n ? 'the key is ignored: writing it would replace the prototype of the state object ' +\n '(JSON.parse of untrusted input creates such keys)'\n : 'the entry is ignored (the other entries still apply); it may come from an older URL or ' +\n 'saved state, or the column was renamed or removed',\n fix: (d) => {\n if (d.key === PROTO_KEY) {\n return [`drop \"__proto__\" when parsing initialState / state (e.g. from the URL or storage)`]\n }\n const near = suggest(d.key, d.known)\n return [\n near.length > 0\n ? `did you mean \"${near[0]}\"? (state.${d.slice}[\"${near[0]}\"])`\n : `use one of the column ids: ${d.known.map((k) => `\"${k}\"`).join(', ')}`,\n `drop \"${d.key}\" when parsing initialState / state (e.g. from the URL), or add the column`,\n ]\n },\n },\n DK_INVALID_STATE: {\n problem: (d) => `state.${d.slice} is malformed (${d.received})`,\n impact: (d) => `the slice was replaced with ${d.fallback}; the table keeps working`,\n fix: (d) => [\n `write state.${d.slice} in the shape the feature uses (check initialState, setState and ` +\n 'the controlled options.state, e.g. a value restored from the URL or storage)',\n `validate restored state before passing it, or drop ${d.slice} when it does not parse`,\n ],\n },\n}\n\n/**\n * Codes about the state itself, shared by core and features (§7.2, §8.3). `DK_INVALID_STATE` is\n * reported by the development-only slice guard (`feature/slice-guard.ts`), which defines it.\n */\nexport const stateDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_STATE_UNKNOWN_KEY',\n level: 'warn',\n where: (d) => ({ kind: 'option', path: `state.${d.slice && `${d.slice}.`}${d.key}` }),\n },\n (process.env.NODE_ENV !== \"production\") && stateMessages.DK_STATE_UNKNOWN_KEY,\n ),\n]\n"],"mappings":";;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GAAG;AAAA,IACrF;AAAA,IACC,QAAQ,IAAI,aAAa,gBAAiB,cAAc;AAAA,EAC3D;AACF;","names":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/table/state-codes.ts
|
|
2
|
+
import { suggest } from "../catalog/suggest.js";
|
|
3
|
+
import { defineDiagnostic } from "../diagnostics/catalog.js";
|
|
4
|
+
import "../diagnostics/process-guard.js";
|
|
5
|
+
var PROTO_KEY = "__proto__";
|
|
6
|
+
var stateMessages = {
|
|
7
|
+
DK_STATE_UNKNOWN_KEY: {
|
|
8
|
+
problem: (d) => d.key === PROTO_KEY ? `${d.slice ? `state.${d.slice}` : "the state"} has a "__proto__" key` : `state.${d.slice} has an entry for "${d.key}", which is not a column`,
|
|
9
|
+
impact: (d) => d.key === PROTO_KEY ? "the key is ignored: writing it would replace the prototype of the state object (JSON.parse of untrusted input creates such keys)" : "the entry is ignored (the other entries still apply); it may come from an older URL or saved state, or the column was renamed or removed",
|
|
10
|
+
fix: (d) => {
|
|
11
|
+
if (d.key === PROTO_KEY) {
|
|
12
|
+
return [`drop "__proto__" when parsing initialState / state (e.g. from the URL or storage)`];
|
|
13
|
+
}
|
|
14
|
+
const near = suggest(d.key, d.known);
|
|
15
|
+
return [
|
|
16
|
+
near.length > 0 ? `did you mean "${near[0]}"? (state.${d.slice}["${near[0]}"])` : `use one of the column ids: ${d.known.map((k) => `"${k}"`).join(", ")}`,
|
|
17
|
+
`drop "${d.key}" when parsing initialState / state (e.g. from the URL), or add the column`
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
DK_INVALID_STATE: {
|
|
22
|
+
problem: (d) => `state.${d.slice} is malformed (${d.received})`,
|
|
23
|
+
impact: (d) => `the slice was replaced with ${d.fallback}; the table keeps working`,
|
|
24
|
+
fix: (d) => [
|
|
25
|
+
`write state.${d.slice} in the shape the feature uses (check initialState, setState and the controlled options.state, e.g. a value restored from the URL or storage)`,
|
|
26
|
+
`validate restored state before passing it, or drop ${d.slice} when it does not parse`
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var stateDiagnostics = [
|
|
31
|
+
defineDiagnostic(
|
|
32
|
+
{
|
|
33
|
+
code: "DK_STATE_UNKNOWN_KEY",
|
|
34
|
+
level: "warn",
|
|
35
|
+
where: (d) => ({ kind: "option", path: `state.${d.slice && `${d.slice}.`}${d.key}` })
|
|
36
|
+
},
|
|
37
|
+
process.env.NODE_ENV !== "production" && stateMessages.DK_STATE_UNKNOWN_KEY
|
|
38
|
+
)
|
|
39
|
+
];
|
|
40
|
+
export {
|
|
41
|
+
PROTO_KEY,
|
|
42
|
+
stateDiagnostics,
|
|
43
|
+
stateMessages
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=state-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/table/state-codes.ts"],"sourcesContent":["import { suggest } from '../catalog/suggest'\nimport { type DiagnosticMessages, defineDiagnostic } from '../diagnostics/catalog'\nimport '../diagnostics/process-guard'\n\ndeclare module '../diagnostics/catalog' {\n interface DiagnosticCatalog {\n DK_STATE_UNKNOWN_KEY: {\n /** The state slice holding the key, e.g. `columnFilters`; `''` for a top-level state key. */\n slice: string\n /** The key that names no column (or `__proto__`, which is never applied, #102). */\n key: string\n /** The table's column ids (did-you-mean); empty for `__proto__`. */\n known: readonly string[]\n }\n DK_INVALID_STATE: {\n /** The feature slice, e.g. `sorting`. */\n slice: string\n /** What the slice was (`describeValue`), or what was wrong with it, e.g. `by[1] null`. */\n received: string\n /** What was stored instead. */\n fallback: string\n }\n }\n}\n\n/** The one key a plain `=` / `Object.assign` write turns into a prototype change (#102). */\nexport const PROTO_KEY = '__proto__'\n\n/** Message text (§8.2): development builds, or production via `@datakable/core/messages`. */\nexport const stateMessages: DiagnosticMessages<'DK_STATE_UNKNOWN_KEY' | 'DK_INVALID_STATE'> = {\n DK_STATE_UNKNOWN_KEY: {\n problem: (d) =>\n d.key === PROTO_KEY\n ? `${d.slice ? `state.${d.slice}` : 'the state'} has a \"__proto__\" key`\n : `state.${d.slice} has an entry for \"${d.key}\", which is not a column`,\n impact: (d) =>\n d.key === PROTO_KEY\n ? 'the key is ignored: writing it would replace the prototype of the state object ' +\n '(JSON.parse of untrusted input creates such keys)'\n : 'the entry is ignored (the other entries still apply); it may come from an older URL or ' +\n 'saved state, or the column was renamed or removed',\n fix: (d) => {\n if (d.key === PROTO_KEY) {\n return [`drop \"__proto__\" when parsing initialState / state (e.g. from the URL or storage)`]\n }\n const near = suggest(d.key, d.known)\n return [\n near.length > 0\n ? `did you mean \"${near[0]}\"? (state.${d.slice}[\"${near[0]}\"])`\n : `use one of the column ids: ${d.known.map((k) => `\"${k}\"`).join(', ')}`,\n `drop \"${d.key}\" when parsing initialState / state (e.g. from the URL), or add the column`,\n ]\n },\n },\n DK_INVALID_STATE: {\n problem: (d) => `state.${d.slice} is malformed (${d.received})`,\n impact: (d) => `the slice was replaced with ${d.fallback}; the table keeps working`,\n fix: (d) => [\n `write state.${d.slice} in the shape the feature uses (check initialState, setState and ` +\n 'the controlled options.state, e.g. a value restored from the URL or storage)',\n `validate restored state before passing it, or drop ${d.slice} when it does not parse`,\n ],\n },\n}\n\n/**\n * Codes about the state itself, shared by core and features (§7.2, §8.3). `DK_INVALID_STATE` is\n * reported by the development-only slice guard (`feature/slice-guard.ts`), which defines it.\n */\nexport const stateDiagnostics = [\n defineDiagnostic(\n {\n code: 'DK_STATE_UNKNOWN_KEY',\n level: 'warn',\n where: (d) => ({ kind: 'option', path: `state.${d.slice && `${d.slice}.`}${d.key}` }),\n },\n (process.env.NODE_ENV !== \"production\") && stateMessages.DK_STATE_UNKNOWN_KEY,\n ),\n]\n"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAkC,wBAAwB;AAC1D,OAAO;AAwBA,IAAM,YAAY;AAGlB,IAAM,gBAAiF;AAAA,EAC5F,sBAAsB;AAAA,IACpB,SAAS,CAAC,MAC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, LooseRow, Path } from '../column'\nimport type { RowExplanation, TableExplanation } from '../diagnostics/explain'\nimport type { RedactFn, RedactLevel } from '../diagnostics/redact'\nimport type { Diagnostic } from '../diagnostics/types'\nimport type { AnyFeature } from '../feature/types'\nimport type { InvalidRow } from '../ingest/schema'\nimport type { TableSchema } from '../ingest/schema-brand'\nimport type { InvalidRowsMode } from '../ingest/schema-codes'\nimport type { Interceptor } from '../intercept/define'\nimport type { OpName } from '../intercept/operations'\nimport type { RowKey } from '../pipeline/row'\nimport type { RowModel } from '../pipeline/types'\nimport type { FetchOutcome } from '../source/fetcher'\nimport type { ServerFetcher } from '../source/server-brand'\n\n/** Table state: one entry per slice (feature state is typed by `StateOf`, T08). */\nexport type TableState = Record<string, unknown>\n\n/** A partial state merged per slice, or a function of the current state returning one. */\nexport type Updater<S> = Partial<S> | ((prev: S) => Partial<S>)\n\n/** `options.state`: a slice given as `undefined` counts as not passed (owned by the store). */\nexport type ControlledState<S> = { [K in keyof S]?: S[K] | undefined }\n\n/** Called after each committed change with the new and the previously notified snapshot. */\nexport type Listener<S> = (state: S, prev: S) => void\n\n/**\n * Max consecutive re-entrant notification rounds (a listener updating state, whose listeners\n * update state, …). The update that would start the next round is dropped (`DK_UPDATE_LOOP`).\n */\nexport const UPDATE_DEPTH_LIMIT = 50\n\nexport interface TableDiagnosticsOptions {\n /**\n * Redaction (§8.2): a level, or a custom `redact(path, value)` on top of the default level\n * (`'keys'` in development, `'safe'` in production). Columns with `sensitive: true` are never\n * logged; a `rowKey` path into a sensitive column is logged as `[sensitive]` (no hash) at every level.\n */\n redact?: RedactLevel | RedactFn\n}\n\nexport interface TableOptions<T, S extends TableState = TableState> {\n /** Names the table in diagnostics; default `table#n`. */\n name?: string\n data?: readonly T[]\n columns?: readonly ColumnDef<T>[]\n /**\n * A Standard Schema v1 (zod, valibot, arktype, …) every row is validated with (§5.1), opted in\n * with `withSchema(UserSchema)` from `@datakable/core/schema`; the row type is its output. An\n * async schema sets `status: 'validating'` while it runs. Read once, at creation.\n */\n schema?: TableSchema<unknown, T>\n /**\n * What happens to rows that fail `schema` (§5.1): `'drop'` (default) removes them, `'flag'` keeps\n * them with `row.valid === false`, `'throw'` throws `DatakableSchemaError`. All three list them in\n * `getInvalidRows()`. Read once, at creation; no effect without `schema`.\n */\n invalidRows?: InvalidRowsMode\n /** Row identity (§5.2). Read by redaction here; key handling is the ingest's. */\n rowKey?: Path<LooseRow<T>> | ((row: T) => string | number)\n /**\n * Installed features (§3.3), in any order: the pipeline runs them by `stage`. Each adds its state\n * slice and merges its API onto the table. Read once, at creation (`setOptions` ignores it).\n */\n features?: readonly AnyFeature[]\n /** Starting values of owned slices; a feature slice given here replaces its `initialState()`. */\n initialState?: Partial<S>\n /**\n * Controlled slices (§3.2): every key with a defined value is owned by the caller, who feeds\n * changes back through `setOptions({ state })`. Slices not passed are owned by the store.\n */\n state?: ControlledState<S>\n /**\n * Receives changes to controlled slices as an updater that merges only the changed slices into\n * the caller's state: `onStateChange: (u) => setControlled(u)`. Not called for owned slices.\n */\n onStateChange?: (updater: (prev: Partial<S>) => Partial<S>) => void\n /** User / feature interceptors (§3.4). The errorBoundary is always installed outermost. */\n interceptors?: readonly Interceptor<OpName>[]\n /** User sink for every diagnostic (e.g. Sentry). */\n onDiagnostic?: (d: Diagnostic) => void\n /**\n * ms before an async request (`fetcher`, `searchFn`) is aborted with `DK_ASYNC_TIMEOUT`.\n * Default 30 000; `Infinity` disables it. Read once, at creation.\n */\n timeout?: number\n /**\n * Server source (§7.1): `fetcher({ query, filters, sort, pageIndex, pageSize, signal })` →\n * `{ rows, rowCount }`. It receives only the state of the server-mode features and runs at\n * creation and whenever that state changes (`status: 'fetching'`), through `async:request`\n * (latest wins, abort, `timeout`). Needs at least one feature with `mode: 'server'`\n * (`DK_FETCHER_WITHOUT_SERVER_MODE`). The returned rows go through `schema` and the data checks.\n * Opt in with `withFetcher(fetchUsers)` from `@datakable/core/server`: a table without a fetcher\n * does not bundle the server source (changed 2026-10-13 for §9.3).\n */\n fetcher?: ServerFetcher<T>\n /**\n * Server mode without a fetcher (§7.1): the total number of rows on the server, while `data` is\n * only the current page. Server-mode pagination counts pages from it (`DK_ROW_COUNT_MISSING`\n * when missing).\n */\n rowCount?: number\n /**\n * SSR (§7.2): the rows the server already produced for the initial state (e.g. its fetcher\n * result). Ingested at creation like `data` when `data` is not given, and counts as the result of\n * the initial async work: the fetcher's first request is skipped (a later server-state change\n * fetches), a `searchFn` is not called for the initial query, and hydration does not re-fetch.\n * With server pagination, `rowCount` gives its total. Read once, at creation.\n */\n initialData?: readonly T[]\n /** Rethrow error-level diagnostics as `DatakableError`. */\n strict?: boolean\n diagnostics?: TableDiagnosticsOptions\n}\n\nexport interface Table<\n T,\n S extends TableState = TableState,\n M extends InvalidRowsMode = 'drop',\n /** The element type `setOptions({ data })` accepts: `unknown` (raw input) with a schema. */\n In = T,\n> {\n /** The current immutable snapshot; the same reference until a slice changes. */\n getState(): S\n setState(updater: Updater<S>): void\n /** Returns the unsubscribe function. One throwing listener never stops the others. */\n subscribe(listener: Listener<S>): () => void\n /** Merges `options` into the current ones (`table:setOptions`). */\n setOptions(\n options: Partial<Omit<TableOptions<T, S>, 'features' | 'data'>> & { data?: readonly In[] },\n ): void\n getOptions(): Readonly<TableOptions<T, S>>\n /** The ingested data (the previous data while an async ingest is pending or failed). */\n getData(): readonly T[]\n /**\n * The row model (§6.6): the visible rows (`Row` objects for the current page only), the counts\n * and the status. The same object until data, state or columns change the result.\n */\n getRowModel(): RowModel<T, M>\n /**\n * The rows that failed `schema` in the current data (§5.1), in every `invalidRows` mode:\n * `{ index, raw, issues }` with `index` into `options.data`. Empty without a schema.\n */\n getInvalidRows(): readonly InvalidRow[]\n /** Oldest first, at most 100 entries. */\n getDiagnostics(): Diagnostic[]\n /**\n * The last pipeline run (§8.4): rows per step, schema drops, the page, open diagnostics, and\n * timings when traced (the tracer runs in development). `String(table.explain())` is a one-line\n * summary. Read-only.\n */\n explain(): TableExplanation\n /**\n * Replays the row with key `key` through the schema and every step (§8.4): which step kept it\n * where, and the step that removed it, with a fix. Values are redacted like diagnostics (§8.2).\n * `String(table.explainRow(key))` is the console report. Read-only.\n */\n explainRow(key: RowKey): RowExplanation\n /**\n * Runs `options.fetcher` again with the current params (§7.1), e.g. a Retry button after\n * `DK_FETCH_FAILED`. Never rejects. Without a fetcher: `{ status: 'applied' }` at once.\n */\n refetch(): Promise<FetchOutcome>\n /** Releases listeners. Later mutating calls are no-ops that report `DK_TABLE_DESTROYED`. */\n destroy(): void\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,IAAM,qBAAqB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/table/types.ts"],"sourcesContent":["import type { ColumnDef, LooseRow, Path } from '../column'\nimport type { RowExplanation, TableExplanation } from '../diagnostics/explain'\nimport type { RedactFn, RedactLevel } from '../diagnostics/redact'\nimport type { Diagnostic } from '../diagnostics/types'\nimport type { AnyFeature } from '../feature/types'\nimport type { InvalidRow } from '../ingest/schema'\nimport type { TableSchema } from '../ingest/schema-brand'\nimport type { InvalidRowsMode } from '../ingest/schema-codes'\nimport type { Interceptor } from '../intercept/define'\nimport type { OpName } from '../intercept/operations'\nimport type { RowKey } from '../pipeline/row'\nimport type { RowModel } from '../pipeline/types'\nimport type { FetchOutcome } from '../source/fetcher'\nimport type { ServerFetcher } from '../source/server-brand'\n\n/** Table state: one entry per slice (feature state is typed by `StateOf`, T08). */\nexport type TableState = Record<string, unknown>\n\n/** A partial state merged per slice, or a function of the current state returning one. */\nexport type Updater<S> = Partial<S> | ((prev: S) => Partial<S>)\n\n/** `options.state`: a slice given as `undefined` counts as not passed (owned by the store). */\nexport type ControlledState<S> = { [K in keyof S]?: S[K] | undefined }\n\n/** Called after each committed change with the new and the previously notified snapshot. */\nexport type Listener<S> = (state: S, prev: S) => void\n\n/**\n * Max consecutive re-entrant notification rounds (a listener updating state, whose listeners\n * update state, …). The update that would start the next round is dropped (`DK_UPDATE_LOOP`).\n */\nexport const UPDATE_DEPTH_LIMIT = 50\n\nexport interface TableDiagnosticsOptions {\n /**\n * Redaction (§8.2): a level, or a custom `redact(path, value)` on top of the default level\n * (`'keys'` in development, `'safe'` in production). Columns with `sensitive: true` are never\n * logged; a `rowKey` path into a sensitive column is logged as `[sensitive]` (no hash) at every level.\n */\n redact?: RedactLevel | RedactFn\n}\n\nexport interface TableOptions<T, S extends TableState = TableState> {\n /** Names the table in diagnostics; default `table#n`. */\n name?: string\n data?: readonly T[]\n columns?: readonly ColumnDef<T>[]\n /**\n * A Standard Schema v1 (zod, valibot, arktype, …) every row is validated with (§5.1), opted in\n * with `withSchema(UserSchema)` from `@datakable/core/schema`; the row type is its output. An\n * async schema sets `status: 'validating'` while it runs. Read once, at creation.\n */\n schema?: TableSchema<unknown, T>\n /**\n * What happens to rows that fail `schema` (§5.1): `'drop'` (default) removes them, `'flag'` keeps\n * them with `row.valid === false`, `'throw'` throws `DatakableSchemaError`. All three list them in\n * `getInvalidRows()`. Read once, at creation; no effect without `schema`.\n */\n invalidRows?: InvalidRowsMode\n /** Row identity (§5.2). Read by redaction here; key handling is the ingest's. */\n rowKey?: Path<LooseRow<T>> | ((row: T) => string | number)\n /**\n * Installed features (§3.3), in any order: the pipeline runs them by `stage`. Each adds its state\n * slice and merges its API onto the table. Read once, at creation (`setOptions` ignores it).\n */\n features?: readonly AnyFeature[]\n /** Starting values of owned slices; a feature slice given here replaces its `initialState()`. */\n initialState?: Partial<S>\n /**\n * Controlled slices (§3.2): every key with a defined value is owned by the caller, who feeds\n * changes back through `setOptions({ state })`. Slices not passed are owned by the store.\n */\n state?: ControlledState<S>\n /**\n * Receives changes to controlled slices as an updater that merges only the changed slices into\n * the caller's state: `onStateChange: (u) => setControlled(u)`. Not called for owned slices.\n */\n onStateChange?: (updater: (prev: Partial<S>) => Partial<S>) => void\n /** User / feature interceptors (§3.4). The errorBoundary is always installed outermost. */\n interceptors?: readonly Interceptor<OpName>[]\n /** User sink for every diagnostic (e.g. Sentry). */\n onDiagnostic?: (d: Diagnostic) => void\n /**\n * ms before an async request (`fetcher`, `searchFn`) is aborted with `DK_ASYNC_TIMEOUT`.\n * Default 30 000; `Infinity` disables it. Read once, at creation.\n */\n timeout?: number\n /**\n * Server source (§7.1): `fetcher({ query, filters, sort, pageIndex, pageSize, signal })` →\n * `{ rows, rowCount }`. It receives only the state of the server-mode features and runs at\n * creation and whenever that state changes (`status: 'fetching'`), through `async:request`\n * (latest wins, abort, `timeout`). Needs at least one feature with `mode: 'server'`\n * (`DK_FETCHER_WITHOUT_SERVER_MODE`). The returned rows go through `schema` and the data checks.\n * Opt in with `withFetcher(fetchUsers)` from `@datakable/core/server`: a table without a fetcher\n * does not bundle the server source (changed 2026-10-13 for §9.3).\n */\n fetcher?: ServerFetcher<T>\n /**\n * Server mode without a fetcher (§7.1): the total number of rows on the server, while `data` is\n * only the current page. Server-mode pagination counts pages from it (`DK_ROW_COUNT_MISSING`\n * when missing).\n */\n rowCount?: number\n /**\n * SSR (§7.2): the rows the server already produced for the initial state (e.g. its fetcher\n * result). Ingested at creation like `data` when `data` is not given, and counts as the result of\n * the initial async work: the fetcher's first request is skipped (a later server-state change\n * fetches), a `searchFn` is not called for the initial query, and hydration does not re-fetch.\n * With server pagination, `rowCount` gives its total. Read once, at creation.\n */\n initialData?: readonly T[]\n /** Rethrow error-level diagnostics as `DatakableError`. */\n strict?: boolean\n diagnostics?: TableDiagnosticsOptions\n}\n\nexport interface Table<\n T,\n S extends TableState = TableState,\n M extends InvalidRowsMode = 'drop',\n /** The element type `setOptions({ data })` accepts: `unknown` (raw input) with a schema. */\n In = T,\n> {\n /** The current immutable snapshot; the same reference until a slice changes. */\n getState(): S\n setState(updater: Updater<S>): void\n /** Returns the unsubscribe function. One throwing listener never stops the others. */\n subscribe(listener: Listener<S>): () => void\n /** Merges `options` into the current ones (`table:setOptions`). */\n setOptions(\n options: Partial<Omit<TableOptions<T, S>, 'features' | 'data'>> & { data?: readonly In[] },\n ): void\n getOptions(): Readonly<TableOptions<T, S>>\n /** The ingested data (the previous data while an async ingest is pending or failed). */\n getData(): readonly T[]\n /**\n * The row model (§6.6): the visible rows (`Row` objects for the current page only), the counts\n * and the status. The same object until data, state or columns change the result.\n */\n getRowModel(): RowModel<T, M>\n /**\n * The rows that failed `schema` in the current data (§5.1), in every `invalidRows` mode:\n * `{ index, raw, issues }` with `index` into `options.data`. Empty without a schema.\n */\n getInvalidRows(): readonly InvalidRow[]\n /** Oldest first, at most 100 entries. */\n getDiagnostics(): Diagnostic[]\n /**\n * The last pipeline run (§8.4): rows per step, schema drops, the page, open diagnostics, and\n * timings when traced (the tracer runs in development). `String(table.explain())` is a one-line\n * summary. Read-only.\n */\n explain(): TableExplanation\n /**\n * Replays the row with key `key` through the schema and every step (§8.4): which step kept it\n * where, and the step that removed it, with a fix. Values are redacted like diagnostics (§8.2).\n * `String(table.explainRow(key))` is the console report. Read-only.\n */\n explainRow(key: RowKey): RowExplanation\n /**\n * Runs `options.fetcher` again with the current params (§7.1), e.g. a Retry button after\n * `DK_FETCH_FAILED`. Never rejects. Without a fetcher: `{ status: 'applied' }` at once. On a\n * `createDeferred` table it settles with the request that runs after `startTable`\n * (`'superseded'` when the table is destroyed first, #90).\n */\n refetch(): Promise<FetchOutcome>\n /** Releases listeners. Later mutating calls are no-ops that report `DK_TABLE_DESTROYED`. */\n destroy(): void\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,IAAM,qBAAqB;","names":[]}
|
package/dist/table/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/table/types.ts"],"sourcesContent":["import type { ColumnDef, LooseRow, Path } from '../column'\nimport type { RowExplanation, TableExplanation } from '../diagnostics/explain'\nimport type { RedactFn, RedactLevel } from '../diagnostics/redact'\nimport type { Diagnostic } from '../diagnostics/types'\nimport type { AnyFeature } from '../feature/types'\nimport type { InvalidRow } from '../ingest/schema'\nimport type { TableSchema } from '../ingest/schema-brand'\nimport type { InvalidRowsMode } from '../ingest/schema-codes'\nimport type { Interceptor } from '../intercept/define'\nimport type { OpName } from '../intercept/operations'\nimport type { RowKey } from '../pipeline/row'\nimport type { RowModel } from '../pipeline/types'\nimport type { FetchOutcome } from '../source/fetcher'\nimport type { ServerFetcher } from '../source/server-brand'\n\n/** Table state: one entry per slice (feature state is typed by `StateOf`, T08). */\nexport type TableState = Record<string, unknown>\n\n/** A partial state merged per slice, or a function of the current state returning one. */\nexport type Updater<S> = Partial<S> | ((prev: S) => Partial<S>)\n\n/** `options.state`: a slice given as `undefined` counts as not passed (owned by the store). */\nexport type ControlledState<S> = { [K in keyof S]?: S[K] | undefined }\n\n/** Called after each committed change with the new and the previously notified snapshot. */\nexport type Listener<S> = (state: S, prev: S) => void\n\n/**\n * Max consecutive re-entrant notification rounds (a listener updating state, whose listeners\n * update state, …). The update that would start the next round is dropped (`DK_UPDATE_LOOP`).\n */\nexport const UPDATE_DEPTH_LIMIT = 50\n\nexport interface TableDiagnosticsOptions {\n /**\n * Redaction (§8.2): a level, or a custom `redact(path, value)` on top of the default level\n * (`'keys'` in development, `'safe'` in production). Columns with `sensitive: true` are never\n * logged; a `rowKey` path into a sensitive column is logged as `[sensitive]` (no hash) at every level.\n */\n redact?: RedactLevel | RedactFn\n}\n\nexport interface TableOptions<T, S extends TableState = TableState> {\n /** Names the table in diagnostics; default `table#n`. */\n name?: string\n data?: readonly T[]\n columns?: readonly ColumnDef<T>[]\n /**\n * A Standard Schema v1 (zod, valibot, arktype, …) every row is validated with (§5.1), opted in\n * with `withSchema(UserSchema)` from `@datakable/core/schema`; the row type is its output. An\n * async schema sets `status: 'validating'` while it runs. Read once, at creation.\n */\n schema?: TableSchema<unknown, T>\n /**\n * What happens to rows that fail `schema` (§5.1): `'drop'` (default) removes them, `'flag'` keeps\n * them with `row.valid === false`, `'throw'` throws `DatakableSchemaError`. All three list them in\n * `getInvalidRows()`. Read once, at creation; no effect without `schema`.\n */\n invalidRows?: InvalidRowsMode\n /** Row identity (§5.2). Read by redaction here; key handling is the ingest's. */\n rowKey?: Path<LooseRow<T>> | ((row: T) => string | number)\n /**\n * Installed features (§3.3), in any order: the pipeline runs them by `stage`. Each adds its state\n * slice and merges its API onto the table. Read once, at creation (`setOptions` ignores it).\n */\n features?: readonly AnyFeature[]\n /** Starting values of owned slices; a feature slice given here replaces its `initialState()`. */\n initialState?: Partial<S>\n /**\n * Controlled slices (§3.2): every key with a defined value is owned by the caller, who feeds\n * changes back through `setOptions({ state })`. Slices not passed are owned by the store.\n */\n state?: ControlledState<S>\n /**\n * Receives changes to controlled slices as an updater that merges only the changed slices into\n * the caller's state: `onStateChange: (u) => setControlled(u)`. Not called for owned slices.\n */\n onStateChange?: (updater: (prev: Partial<S>) => Partial<S>) => void\n /** User / feature interceptors (§3.4). The errorBoundary is always installed outermost. */\n interceptors?: readonly Interceptor<OpName>[]\n /** User sink for every diagnostic (e.g. Sentry). */\n onDiagnostic?: (d: Diagnostic) => void\n /**\n * ms before an async request (`fetcher`, `searchFn`) is aborted with `DK_ASYNC_TIMEOUT`.\n * Default 30 000; `Infinity` disables it. Read once, at creation.\n */\n timeout?: number\n /**\n * Server source (§7.1): `fetcher({ query, filters, sort, pageIndex, pageSize, signal })` →\n * `{ rows, rowCount }`. It receives only the state of the server-mode features and runs at\n * creation and whenever that state changes (`status: 'fetching'`), through `async:request`\n * (latest wins, abort, `timeout`). Needs at least one feature with `mode: 'server'`\n * (`DK_FETCHER_WITHOUT_SERVER_MODE`). The returned rows go through `schema` and the data checks.\n * Opt in with `withFetcher(fetchUsers)` from `@datakable/core/server`: a table without a fetcher\n * does not bundle the server source (changed 2026-10-13 for §9.3).\n */\n fetcher?: ServerFetcher<T>\n /**\n * Server mode without a fetcher (§7.1): the total number of rows on the server, while `data` is\n * only the current page. Server-mode pagination counts pages from it (`DK_ROW_COUNT_MISSING`\n * when missing).\n */\n rowCount?: number\n /**\n * SSR (§7.2): the rows the server already produced for the initial state (e.g. its fetcher\n * result). Ingested at creation like `data` when `data` is not given, and counts as the result of\n * the initial async work: the fetcher's first request is skipped (a later server-state change\n * fetches), a `searchFn` is not called for the initial query, and hydration does not re-fetch.\n * With server pagination, `rowCount` gives its total. Read once, at creation.\n */\n initialData?: readonly T[]\n /** Rethrow error-level diagnostics as `DatakableError`. */\n strict?: boolean\n diagnostics?: TableDiagnosticsOptions\n}\n\nexport interface Table<\n T,\n S extends TableState = TableState,\n M extends InvalidRowsMode = 'drop',\n /** The element type `setOptions({ data })` accepts: `unknown` (raw input) with a schema. */\n In = T,\n> {\n /** The current immutable snapshot; the same reference until a slice changes. */\n getState(): S\n setState(updater: Updater<S>): void\n /** Returns the unsubscribe function. One throwing listener never stops the others. */\n subscribe(listener: Listener<S>): () => void\n /** Merges `options` into the current ones (`table:setOptions`). */\n setOptions(\n options: Partial<Omit<TableOptions<T, S>, 'features' | 'data'>> & { data?: readonly In[] },\n ): void\n getOptions(): Readonly<TableOptions<T, S>>\n /** The ingested data (the previous data while an async ingest is pending or failed). */\n getData(): readonly T[]\n /**\n * The row model (§6.6): the visible rows (`Row` objects for the current page only), the counts\n * and the status. The same object until data, state or columns change the result.\n */\n getRowModel(): RowModel<T, M>\n /**\n * The rows that failed `schema` in the current data (§5.1), in every `invalidRows` mode:\n * `{ index, raw, issues }` with `index` into `options.data`. Empty without a schema.\n */\n getInvalidRows(): readonly InvalidRow[]\n /** Oldest first, at most 100 entries. */\n getDiagnostics(): Diagnostic[]\n /**\n * The last pipeline run (§8.4): rows per step, schema drops, the page, open diagnostics, and\n * timings when traced (the tracer runs in development). `String(table.explain())` is a one-line\n * summary. Read-only.\n */\n explain(): TableExplanation\n /**\n * Replays the row with key `key` through the schema and every step (§8.4): which step kept it\n * where, and the step that removed it, with a fix. Values are redacted like diagnostics (§8.2).\n * `String(table.explainRow(key))` is the console report. Read-only.\n */\n explainRow(key: RowKey): RowExplanation\n /**\n * Runs `options.fetcher` again with the current params (§7.1), e.g. a Retry button after\n * `DK_FETCH_FAILED`. Never rejects. Without a fetcher: `{ status: 'applied' }` at once.\n */\n refetch(): Promise<FetchOutcome>\n /** Releases listeners. Later mutating calls are no-ops that report `DK_TABLE_DESTROYED`. */\n destroy(): void\n}\n"],"mappings":";AA+BO,IAAM,qBAAqB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/table/types.ts"],"sourcesContent":["import type { ColumnDef, LooseRow, Path } from '../column'\nimport type { RowExplanation, TableExplanation } from '../diagnostics/explain'\nimport type { RedactFn, RedactLevel } from '../diagnostics/redact'\nimport type { Diagnostic } from '../diagnostics/types'\nimport type { AnyFeature } from '../feature/types'\nimport type { InvalidRow } from '../ingest/schema'\nimport type { TableSchema } from '../ingest/schema-brand'\nimport type { InvalidRowsMode } from '../ingest/schema-codes'\nimport type { Interceptor } from '../intercept/define'\nimport type { OpName } from '../intercept/operations'\nimport type { RowKey } from '../pipeline/row'\nimport type { RowModel } from '../pipeline/types'\nimport type { FetchOutcome } from '../source/fetcher'\nimport type { ServerFetcher } from '../source/server-brand'\n\n/** Table state: one entry per slice (feature state is typed by `StateOf`, T08). */\nexport type TableState = Record<string, unknown>\n\n/** A partial state merged per slice, or a function of the current state returning one. */\nexport type Updater<S> = Partial<S> | ((prev: S) => Partial<S>)\n\n/** `options.state`: a slice given as `undefined` counts as not passed (owned by the store). */\nexport type ControlledState<S> = { [K in keyof S]?: S[K] | undefined }\n\n/** Called after each committed change with the new and the previously notified snapshot. */\nexport type Listener<S> = (state: S, prev: S) => void\n\n/**\n * Max consecutive re-entrant notification rounds (a listener updating state, whose listeners\n * update state, …). The update that would start the next round is dropped (`DK_UPDATE_LOOP`).\n */\nexport const UPDATE_DEPTH_LIMIT = 50\n\nexport interface TableDiagnosticsOptions {\n /**\n * Redaction (§8.2): a level, or a custom `redact(path, value)` on top of the default level\n * (`'keys'` in development, `'safe'` in production). Columns with `sensitive: true` are never\n * logged; a `rowKey` path into a sensitive column is logged as `[sensitive]` (no hash) at every level.\n */\n redact?: RedactLevel | RedactFn\n}\n\nexport interface TableOptions<T, S extends TableState = TableState> {\n /** Names the table in diagnostics; default `table#n`. */\n name?: string\n data?: readonly T[]\n columns?: readonly ColumnDef<T>[]\n /**\n * A Standard Schema v1 (zod, valibot, arktype, …) every row is validated with (§5.1), opted in\n * with `withSchema(UserSchema)` from `@datakable/core/schema`; the row type is its output. An\n * async schema sets `status: 'validating'` while it runs. Read once, at creation.\n */\n schema?: TableSchema<unknown, T>\n /**\n * What happens to rows that fail `schema` (§5.1): `'drop'` (default) removes them, `'flag'` keeps\n * them with `row.valid === false`, `'throw'` throws `DatakableSchemaError`. All three list them in\n * `getInvalidRows()`. Read once, at creation; no effect without `schema`.\n */\n invalidRows?: InvalidRowsMode\n /** Row identity (§5.2). Read by redaction here; key handling is the ingest's. */\n rowKey?: Path<LooseRow<T>> | ((row: T) => string | number)\n /**\n * Installed features (§3.3), in any order: the pipeline runs them by `stage`. Each adds its state\n * slice and merges its API onto the table. Read once, at creation (`setOptions` ignores it).\n */\n features?: readonly AnyFeature[]\n /** Starting values of owned slices; a feature slice given here replaces its `initialState()`. */\n initialState?: Partial<S>\n /**\n * Controlled slices (§3.2): every key with a defined value is owned by the caller, who feeds\n * changes back through `setOptions({ state })`. Slices not passed are owned by the store.\n */\n state?: ControlledState<S>\n /**\n * Receives changes to controlled slices as an updater that merges only the changed slices into\n * the caller's state: `onStateChange: (u) => setControlled(u)`. Not called for owned slices.\n */\n onStateChange?: (updater: (prev: Partial<S>) => Partial<S>) => void\n /** User / feature interceptors (§3.4). The errorBoundary is always installed outermost. */\n interceptors?: readonly Interceptor<OpName>[]\n /** User sink for every diagnostic (e.g. Sentry). */\n onDiagnostic?: (d: Diagnostic) => void\n /**\n * ms before an async request (`fetcher`, `searchFn`) is aborted with `DK_ASYNC_TIMEOUT`.\n * Default 30 000; `Infinity` disables it. Read once, at creation.\n */\n timeout?: number\n /**\n * Server source (§7.1): `fetcher({ query, filters, sort, pageIndex, pageSize, signal })` →\n * `{ rows, rowCount }`. It receives only the state of the server-mode features and runs at\n * creation and whenever that state changes (`status: 'fetching'`), through `async:request`\n * (latest wins, abort, `timeout`). Needs at least one feature with `mode: 'server'`\n * (`DK_FETCHER_WITHOUT_SERVER_MODE`). The returned rows go through `schema` and the data checks.\n * Opt in with `withFetcher(fetchUsers)` from `@datakable/core/server`: a table without a fetcher\n * does not bundle the server source (changed 2026-10-13 for §9.3).\n */\n fetcher?: ServerFetcher<T>\n /**\n * Server mode without a fetcher (§7.1): the total number of rows on the server, while `data` is\n * only the current page. Server-mode pagination counts pages from it (`DK_ROW_COUNT_MISSING`\n * when missing).\n */\n rowCount?: number\n /**\n * SSR (§7.2): the rows the server already produced for the initial state (e.g. its fetcher\n * result). Ingested at creation like `data` when `data` is not given, and counts as the result of\n * the initial async work: the fetcher's first request is skipped (a later server-state change\n * fetches), a `searchFn` is not called for the initial query, and hydration does not re-fetch.\n * With server pagination, `rowCount` gives its total. Read once, at creation.\n */\n initialData?: readonly T[]\n /** Rethrow error-level diagnostics as `DatakableError`. */\n strict?: boolean\n diagnostics?: TableDiagnosticsOptions\n}\n\nexport interface Table<\n T,\n S extends TableState = TableState,\n M extends InvalidRowsMode = 'drop',\n /** The element type `setOptions({ data })` accepts: `unknown` (raw input) with a schema. */\n In = T,\n> {\n /** The current immutable snapshot; the same reference until a slice changes. */\n getState(): S\n setState(updater: Updater<S>): void\n /** Returns the unsubscribe function. One throwing listener never stops the others. */\n subscribe(listener: Listener<S>): () => void\n /** Merges `options` into the current ones (`table:setOptions`). */\n setOptions(\n options: Partial<Omit<TableOptions<T, S>, 'features' | 'data'>> & { data?: readonly In[] },\n ): void\n getOptions(): Readonly<TableOptions<T, S>>\n /** The ingested data (the previous data while an async ingest is pending or failed). */\n getData(): readonly T[]\n /**\n * The row model (§6.6): the visible rows (`Row` objects for the current page only), the counts\n * and the status. The same object until data, state or columns change the result.\n */\n getRowModel(): RowModel<T, M>\n /**\n * The rows that failed `schema` in the current data (§5.1), in every `invalidRows` mode:\n * `{ index, raw, issues }` with `index` into `options.data`. Empty without a schema.\n */\n getInvalidRows(): readonly InvalidRow[]\n /** Oldest first, at most 100 entries. */\n getDiagnostics(): Diagnostic[]\n /**\n * The last pipeline run (§8.4): rows per step, schema drops, the page, open diagnostics, and\n * timings when traced (the tracer runs in development). `String(table.explain())` is a one-line\n * summary. Read-only.\n */\n explain(): TableExplanation\n /**\n * Replays the row with key `key` through the schema and every step (§8.4): which step kept it\n * where, and the step that removed it, with a fix. Values are redacted like diagnostics (§8.2).\n * `String(table.explainRow(key))` is the console report. Read-only.\n */\n explainRow(key: RowKey): RowExplanation\n /**\n * Runs `options.fetcher` again with the current params (§7.1), e.g. a Retry button after\n * `DK_FETCH_FAILED`. Never rejects. Without a fetcher: `{ status: 'applied' }` at once. On a\n * `createDeferred` table it settles with the request that runs after `startTable`\n * (`'superseded'` when the table is destroyed first, #90).\n */\n refetch(): Promise<FetchOutcome>\n /** Releases listeners. Later mutating calls are no-ops that report `DK_TABLE_DESTROYED`. */\n destroy(): void\n}\n"],"mappings":";AA+BO,IAAM,qBAAqB;","names":[]}
|
package/dist/validity.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import { F as Feature, b as FixedTypes } from './explain-
|
|
1
|
+
export { ax as validityDiagnostics } from './codes-4sYQv_7J.cjs';
|
|
2
|
+
import { F as Feature, b as FixedTypes } from './explain-DmwN_RG9.cjs';
|
|
3
3
|
|
|
4
4
|
/** Which rows the `validity` step keeps (§6.2). */
|
|
5
5
|
type ValidityState = 'all' | 'valid' | 'invalid';
|
package/dist/validity.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import { F as Feature, b as FixedTypes } from './explain-
|
|
1
|
+
export { ax as validityDiagnostics } from './codes-4sYQv_7J.js';
|
|
2
|
+
import { F as Feature, b as FixedTypes } from './explain-Dr3SmMNY.js';
|
|
3
3
|
|
|
4
4
|
/** Which rows the `validity` step keeps (§6.2). */
|
|
5
5
|
type ValidityState = 'all' | 'valid' | 'invalid';
|