@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.
Files changed (113) hide show
  1. package/dist/{codes-AX8XkMNY.d.cts → codes-4sYQv_7J.d.cts} +36 -10
  2. package/dist/{codes-AX8XkMNY.d.ts → codes-4sYQv_7J.d.ts} +36 -10
  3. package/dist/column-filters.d.cts +2 -2
  4. package/dist/column-filters.d.ts +2 -2
  5. package/dist/diagnostics/build.cjs +1 -1
  6. package/dist/diagnostics/build.cjs.map +1 -1
  7. package/dist/diagnostics/build.js +2 -2
  8. package/dist/diagnostics/build.js.map +1 -1
  9. package/dist/diagnostics/console.cjs +15 -4
  10. package/dist/diagnostics/console.cjs.map +1 -1
  11. package/dist/diagnostics/console.js +15 -4
  12. package/dist/diagnostics/console.js.map +1 -1
  13. package/dist/diagnostics/prose.cjs +10 -1
  14. package/dist/diagnostics/prose.cjs.map +1 -1
  15. package/dist/diagnostics/prose.js +9 -1
  16. package/dist/diagnostics/prose.js.map +1 -1
  17. package/dist/{explain-pKAnnxEW.d.cts → explain-DmwN_RG9.d.cts} +11 -4
  18. package/dist/{explain-BVE3ln3G.d.ts → explain-Dr3SmMNY.d.ts} +11 -4
  19. package/dist/feature/install.cjs +2 -1
  20. package/dist/feature/install.cjs.map +1 -1
  21. package/dist/feature/install.js +2 -1
  22. package/dist/feature/install.js.map +1 -1
  23. package/dist/feature/slice-guard.cjs +76 -0
  24. package/dist/feature/slice-guard.cjs.map +1 -0
  25. package/dist/feature/slice-guard.js +50 -0
  26. package/dist/feature/slice-guard.js.map +1 -0
  27. package/dist/features/column-filters/codes.cjs +2 -19
  28. package/dist/features/column-filters/codes.cjs.map +1 -1
  29. package/dist/features/column-filters/codes.js +2 -19
  30. package/dist/features/column-filters/codes.js.map +1 -1
  31. package/dist/features/column-filters/column-filters.cjs +37 -22
  32. package/dist/features/column-filters/column-filters.cjs.map +1 -1
  33. package/dist/features/column-filters/column-filters.js +37 -22
  34. package/dist/features/column-filters/column-filters.js.map +1 -1
  35. package/dist/features/column-filters/match.cjs +6 -2
  36. package/dist/features/column-filters/match.cjs.map +1 -1
  37. package/dist/features/column-filters/match.js +6 -2
  38. package/dist/features/column-filters/match.js.map +1 -1
  39. package/dist/features/pagination/pagination.cjs +2 -2
  40. package/dist/features/pagination/pagination.cjs.map +1 -1
  41. package/dist/features/pagination/pagination.js +2 -2
  42. package/dist/features/pagination/pagination.js.map +1 -1
  43. package/dist/features/search/codes.cjs +18 -2
  44. package/dist/features/search/codes.cjs.map +1 -1
  45. package/dist/features/search/codes.js +16 -1
  46. package/dist/features/search/codes.js.map +1 -1
  47. package/dist/features/search/search-engine.cjs +24 -5
  48. package/dist/features/search/search-engine.cjs.map +1 -1
  49. package/dist/features/search/search-engine.js +25 -6
  50. package/dist/features/search/search-engine.js.map +1 -1
  51. package/dist/features/sorting/sorting.cjs +55 -24
  52. package/dist/features/sorting/sorting.cjs.map +1 -1
  53. package/dist/features/sorting/sorting.js +55 -24
  54. package/dist/features/sorting/sorting.js.map +1 -1
  55. package/dist/index.d.cts +26 -17
  56. package/dist/index.d.ts +26 -17
  57. package/dist/intercept/runtime.cjs +3 -2
  58. package/dist/intercept/runtime.cjs.map +1 -1
  59. package/dist/intercept/runtime.js +3 -2
  60. package/dist/intercept/runtime.js.map +1 -1
  61. package/dist/messages/index.cjs +2 -0
  62. package/dist/messages/index.cjs.map +1 -1
  63. package/dist/messages/index.js +2 -0
  64. package/dist/messages/index.js.map +1 -1
  65. package/dist/pagination.d.cts +2 -2
  66. package/dist/pagination.d.ts +2 -2
  67. package/dist/schema.d.cts +2 -2
  68. package/dist/schema.d.ts +2 -2
  69. package/dist/{search-async-entry-ByMJbHjc.d.cts → search-async-entry-BiemO3JT.d.cts} +2 -2
  70. package/dist/{search-async-entry-CFQODE08.d.ts → search-async-entry-GRj0E06n.d.ts} +2 -2
  71. package/dist/search-async.d.cts +3 -3
  72. package/dist/search-async.d.ts +3 -3
  73. package/dist/search.d.cts +4 -4
  74. package/dist/search.d.ts +4 -4
  75. package/dist/server.d.cts +3 -3
  76. package/dist/server.d.ts +3 -3
  77. package/dist/sorting.d.cts +2 -2
  78. package/dist/sorting.d.ts +2 -2
  79. package/dist/source/async-control.cjs +2 -1
  80. package/dist/source/async-control.cjs.map +1 -1
  81. package/dist/source/async-control.js +2 -1
  82. package/dist/source/async-control.js.map +1 -1
  83. package/dist/source/fetcher.cjs.map +1 -1
  84. package/dist/source/fetcher.js.map +1 -1
  85. package/dist/source/server.cjs +58 -5
  86. package/dist/source/server.cjs.map +1 -1
  87. package/dist/source/server.js +58 -5
  88. package/dist/source/server.js.map +1 -1
  89. package/dist/table/create-table.cjs +30 -20
  90. package/dist/table/create-table.cjs.map +1 -1
  91. package/dist/table/create-table.js +30 -20
  92. package/dist/table/create-table.js.map +1 -1
  93. package/dist/table/index.cjs +3 -0
  94. package/dist/table/index.cjs.map +1 -1
  95. package/dist/table/index.js +5 -1
  96. package/dist/table/index.js.map +1 -1
  97. package/dist/table/state-codes.cjs +72 -0
  98. package/dist/table/state-codes.cjs.map +1 -0
  99. package/dist/table/state-codes.js +45 -0
  100. package/dist/table/state-codes.js.map +1 -0
  101. package/dist/table/types.cjs.map +1 -1
  102. package/dist/table/types.js.map +1 -1
  103. package/dist/validity.d.cts +2 -2
  104. package/dist/validity.d.ts +2 -2
  105. package/dist/version.cjs +1 -1
  106. package/dist/version.cjs.map +1 -1
  107. package/dist/version.js +1 -1
  108. package/dist/version.js.map +1 -1
  109. package/package.json +1 -1
  110. package/dist/ingest/test-schemas.cjs +0 -73
  111. package/dist/ingest/test-schemas.cjs.map +0 -1
  112. package/dist/ingest/test-schemas.js +0 -46
  113. package/dist/ingest/test-schemas.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,15 +1,15 @@
1
- import { D as Diagnostic, c as DiagnosticCode, d as DiagnosticDetails, a as EmitOptions, T as Trigger, P as Phase, j as DiagnosticStateSummary, f as RedactLevel, k as RedactionOptions, l as DiagnosticDefinition, I as InvalidRowsMode, e as TableSchema, S as StandardSchemaV1, E as Emit } from './codes-AX8XkMNY.cjs';
2
- export { B as BadResponse, m as BuildInput, n as DK_UNSAFE_REDACTION, o as DatakableConfigError, p as DatakableError, q as DatakableSchemaError, r as DiagnosticCatalog, s as DiagnosticContext, t as DiagnosticLevel, u as DiagnosticMessages, v as DiagnosticMeta, w as DiagnosticText, x as FlaggedInvalidRow, F as FlaggedRow, h as InvalidRow, L as Location, y as REDACTED, z as RedactField, g as RedactFn, A as Redactor, b as Row, R as RowIssue, i as RowKey, C as SCHEMA_INGEST, G as SENSITIVE, H as SchemaIssueColumn, J as SchemaOutcome, K as SlotDefinition, M as SlotReturns, V as ValidRow, N as asyncDiagnostics, O as boundaryDiagnostics, Q as buildDiagnostic, U as columnFiltersDiagnostics, W as comparatorDiagnostics, X as coreDiagnostics, Y as dataCheckDiagnostics, Z as dataMutationDiagnostics, _ as defineDiagnostic, $ as defineSlot, a0 as describeReturn, a1 as describeValue, a2 as envDiagnostics, a3 as featureDiagnostics, a4 as fetchDiagnostics, a5 as formatSlot, a6 as formatWhere, a7 as getDiagnosticDefinition, a8 as getDiagnosticText, a9 as getSlot, aa as hasMessages, ab as hashRowKey, ac as installMessages, ad as isStandardSchema, ae as keepDiagnostics, af as listDiagnosticCodes, ag as matchesSlot, ah as optionDiagnostics, ai as paginationDiagnostics, aj as pipelineDiagnostics, ak as resolveRedaction, al as rowKeyDiagnostics, am as schemaDiagnostics, an as scrubError, ao as scrubSchemaIssue, ap as searchDiagnostics, aq as slotDiagnostics, ar as sortingDiagnostics, as as ssrDiagnostics, at as stepDiagnostics, au as tableDiagnostics, av as throwConfigError, aw as validityDiagnostics, ax as versioningDiagnostics } from './codes-AX8XkMNY.cjs';
3
- import { S as Stage, A as AnyFeature, I as InterceptorRuntime, a as Interceptor, F as Feature, b as FixedTypes, c as FeatureContext, R as RowModelContext, d as AnyRow, e as FeatureTypes, O as OpName, f as InterceptorContext, g as OpResult, T as TableState, h as TableOptions, i as ServerFetcher, j as TableStateFor, k as Table, l as ApiOf } from './explain-pKAnnxEW.cjs';
4
- export { m as AccessorColumn, n as Apply, B as BuiltinOperations, C as CELL_FALLBACK, o as CellContext, p as CellFailures, q as CellSlot, r as ColumnDef, s as ColumnValues, t as ContextBase, u as ContextPool, v as ControlledState, w as Core, E as ExplainStep, x as FetchOutcome, y as FetchParams, z as FetchResult, D as Fetcher, G as FilterFor, H as HotOpWarning, J as InterceptorRuntimeOptions, K as InvalidCellContext, L as IsAny, M as KeyColumn, N as Listener, P as LooseRow, Q as OpInput, U as OpKind, V as OpOutput, W as OpSpec, X as OperationInfo, Y as Operations, Z as OptionRule, _ as OptionType, $ as OptionsDefinition, a0 as OptionsSchema, a1 as Path, a2 as PathValue, a3 as Primitive, a4 as RenderReq, a5 as RowExplanation, a6 as RowModel, a7 as RowModelStatus, a8 as RowOf, a9 as RowStep, aa as RowStepOutcome, ab as SERVER_SOURCE, ac as SliceUpdater, ad as SortAlgorithm, ae as StateOf, af as TableDiagnosticsOptions, ag as TableExplanation, ah as UPDATE_DEPTH_LIMIT, ai as Updater, aj as createContext, ak as createContextPool, al as createInterceptorRuntime, am as defineInterceptor, an as defineOptions, ao as emitTableDiagnostic, ap as getOperation, aq as isOptionsDefinition, ar as listOperations, as as registerOperation, at as runCells } from './explain-pKAnnxEW.cjs';
1
+ import { D as Diagnostic, c as DiagnosticCode, d as DiagnosticDetails, a as EmitOptions, T as Trigger, P as Phase, j as DiagnosticStateSummary, f as RedactLevel, k as RedactionOptions, l as DiagnosticDefinition, I as InvalidRowsMode, e as TableSchema, S as StandardSchemaV1, E as Emit } from './codes-4sYQv_7J.cjs';
2
+ export { B as BadResponse, m as BuildInput, n as DK_UNSAFE_REDACTION, o as DatakableConfigError, p as DatakableError, q as DatakableSchemaError, r as DiagnosticCatalog, s as DiagnosticContext, t as DiagnosticLevel, u as DiagnosticMessages, v as DiagnosticMeta, w as DiagnosticText, x as FlaggedInvalidRow, F as FlaggedRow, h as InvalidRow, L as Location, y as REDACTED, z as RedactField, g as RedactFn, A as Redactor, b as Row, R as RowIssue, i as RowKey, C as SCHEMA_INGEST, G as SENSITIVE, H as SchemaIssueColumn, J as SchemaOutcome, K as SlotDefinition, M as SlotReturns, V as ValidRow, N as asyncDiagnostics, O as boundaryDiagnostics, Q as buildDiagnostic, U as columnFiltersDiagnostics, W as comparatorDiagnostics, X as coreDiagnostics, Y as dataCheckDiagnostics, Z as dataMutationDiagnostics, _ as defineDiagnostic, $ as defineSlot, a0 as describeReturn, a1 as describeValue, a2 as envDiagnostics, a3 as featureDiagnostics, a4 as fetchDiagnostics, a5 as formatSlot, a6 as formatWhere, a7 as getDiagnosticDefinition, a8 as getDiagnosticText, a9 as getSlot, aa as hasMessages, ab as hashRowKey, ac as installMessages, ad as isStandardSchema, ae as keepDiagnostics, af as listDiagnosticCodes, ag as matchesSlot, ah as optionDiagnostics, ai as paginationDiagnostics, aj as pipelineDiagnostics, ak as resolveRedaction, al as rowKeyDiagnostics, am as schemaDiagnostics, an as scrubError, ao as scrubSchemaIssue, ap as searchDiagnostics, aq as slotDiagnostics, ar as sortingDiagnostics, as as ssrDiagnostics, at as stateDiagnostics, au as stepDiagnostics, av as tableDiagnostics, aw as throwConfigError, ax as validityDiagnostics, ay as versioningDiagnostics } from './codes-4sYQv_7J.cjs';
3
+ import { S as Stage, A as AnyFeature, I as InterceptorRuntime, a as Interceptor, F as Feature, b as FixedTypes, c as FeatureContext, R as RowModelContext, d as AnyRow, e as FeatureTypes, O as OpName, f as InterceptorContext, g as OpResult, T as TableState, h as TableOptions, i as ServerFetcher, j as TableStateFor, k as Table, l as ApiOf } from './explain-DmwN_RG9.cjs';
4
+ export { m as AccessorColumn, n as Apply, B as BuiltinOperations, C as CELL_FALLBACK, o as CellContext, p as CellFailures, q as CellSlot, r as ColumnDef, s as ColumnValues, t as ContextBase, u as ContextPool, v as ControlledState, w as Core, E as ExplainStep, x as FetchOutcome, y as FetchParams, z as FetchResult, D as Fetcher, G as FilterFor, H as HotOpWarning, J as InterceptorRuntimeOptions, K as InvalidCellContext, L as IsAny, M as KeyColumn, N as Listener, P as LooseRow, Q as OpInput, U as OpKind, V as OpOutput, W as OpSpec, X as OperationInfo, Y as Operations, Z as OptionRule, _ as OptionType, $ as OptionsDefinition, a0 as OptionsSchema, a1 as Path, a2 as PathValue, a3 as Primitive, a4 as RenderReq, a5 as RowExplanation, a6 as RowModel, a7 as RowModelStatus, a8 as RowOf, a9 as RowStep, aa as RowStepOutcome, ab as SERVER_SOURCE, ac as SliceUpdater, ad as SortAlgorithm, ae as StateOf, af as TableDiagnosticsOptions, ag as TableExplanation, ah as UPDATE_DEPTH_LIMIT, ai as Updater, aj as createContext, ak as createContextPool, al as createInterceptorRuntime, am as defineInterceptor, an as defineOptions, ao as emitTableDiagnostic, ap as getOperation, aq as isOptionsDefinition, ar as listOperations, as as registerOperation, at as runCells } from './explain-DmwN_RG9.cjs';
5
5
  import { ColumnFiltersTypes } from './column-filters.cjs';
6
6
  export { ColumnFilter, ColumnFiltersApi, ColumnFiltersOptions, ColumnFiltersState, ContainsFilter, CustomFilter, EqualsFilter, InFilter, RangeFilter, RangeValue, columnFilters } from './column-filters.cjs';
7
7
  import { PaginationState, PaginationApi } from './pagination.cjs';
8
8
  export { PaginationOptions, pagination } from './pagination.cjs';
9
9
  import { SearchApi } from './search.cjs';
10
10
  export { SearchOptions, SearchTyping, SearchWait, search } from './search.cjs';
11
- import { S as SearchState } from './search-async-entry-ByMJbHjc.cjs';
12
- export { A as AsyncSearchFn, a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, d as SearchOutcome, e as SearchResult, f as SearchStatus, w as withSearchFn } from './search-async-entry-ByMJbHjc.cjs';
11
+ import { S as SearchState } from './search-async-entry-BiemO3JT.cjs';
12
+ export { A as AsyncSearchFn, a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, d as SearchOutcome, e as SearchResult, f as SearchStatus, w as withSearchFn } from './search-async-entry-BiemO3JT.cjs';
13
13
  import { SortingTypes } from './sorting.cjs';
14
14
  export { SortAlgorithmOption, SortDirection, SortEntry, SortingApi, SortingOptions, SortingState, compareValues, sorting, typeRank } from './sorting.cjs';
15
15
  import { ValidityState, ValidityApi } from './validity.cjs';
@@ -45,7 +45,10 @@ declare function compilePath(path: string): CompiledPath;
45
45
  */
46
46
  declare function getValue(row: unknown, path: string | CompiledPath, onError?: (error: unknown) => void): unknown;
47
47
 
48
- /** The §8.1 console text: header + aligned body. Also usable by explain() and tests. */
48
+ /**
49
+ * The §8.1 console text: header + aligned body, each line {@link printable}. Also usable by
50
+ * explain() and tests.
51
+ */
49
52
  declare function formatDiagnostic(d: Diagnostic): {
50
53
  header: string;
51
54
  body: string;
@@ -279,20 +282,28 @@ type DefaultFeatures = ReturnType<typeof createDefaultFeatures>;
279
282
  */
280
283
  declare const defaultFeatures: DefaultFeatures;
281
284
 
285
+ /** `undefined` exactly (not `any`, `never` or a union with it). */
286
+ type IsUndefined<X> = (<G>() => G extends X ? 1 : 2) extends <G>() => G extends undefined ? 1 : 2 ? true : false;
287
+ /**
288
+ * `true` when `Sch` (the inferred `schema` option) is a schema. Its default, `undefined` (no
289
+ * schema), is excluded explicitly: without `strictNullChecks` `undefined` is assignable to every
290
+ * type, `TableSchema` included, which typed `data` as `unknown[]` and `T` as `unknown` (#93).
291
+ */
292
+ type HasSchema<Sch> = [Sch] extends [TableSchema] ? IsUndefined<Sch> extends true ? false : true : false;
282
293
  /** The row type: the schema output with a `schema` (§5.1), else `T`. */
283
- type SchemaRow<T, Sch> = [Sch] extends [TableSchema] ? StandardSchemaV1.InferOutput<Sch> : T;
294
+ type SchemaRow<T, Sch> = [Sch] extends [TableSchema] ? IsUndefined<Sch> extends true ? T : StandardSchemaV1.InferOutput<Sch> : T;
284
295
  /**
285
296
  * `createTable` options: with a `schema`, the row type is its output and `data` is the raw input
286
297
  * (`unknown[]`, e.g. parsed JSON), validated per row.
287
298
  */
288
299
  type CreateTableOptions<T, S extends TableState, Sch, M extends InvalidRowsMode> = Omit<TableOptions<SchemaRow<T, Sch>, S>, 'data' | 'schema' | 'invalidRows' | 'fetcher' | 'initialData'> & {
289
- data?: readonly ([Sch] extends [TableSchema] ? unknown : T)[];
300
+ data?: readonly (HasSchema<Sch> extends true ? unknown : T)[];
290
301
  /** With a schema, the raw rows (validated like `data`). */
291
- initialData?: readonly ([Sch] extends [TableSchema] ? unknown : T)[];
302
+ initialData?: readonly (HasSchema<Sch> extends true ? unknown : T)[];
292
303
  /** With a schema, the fetcher returns raw rows (validated like `data`). */
293
- fetcher?: ServerFetcher<[Sch] extends [TableSchema] ? unknown : T>;
294
- schema?: [Sch] extends [TableSchema] ? Sch : TableSchema<unknown, T>;
295
- invalidRows?: [Sch] extends [TableSchema] ? M : InvalidRowsMode;
304
+ fetcher?: ServerFetcher<HasSchema<Sch> extends true ? unknown : T>;
305
+ schema?: HasSchema<Sch> extends true ? Sch : TableSchema<unknown, T>;
306
+ invalidRows?: HasSchema<Sch> extends true ? M : InvalidRowsMode;
296
307
  };
297
308
  /**
298
309
  * Creates the table store (§3.2): immutable state snapshots, controlled slices, isolated listeners,
@@ -305,9 +316,7 @@ type CreateTableOptions<T, S extends TableState, Sch, M extends InvalidRowsMode>
305
316
  */
306
317
  declare function createTable<T, S extends TableState = never, const Fs extends readonly AnyFeature[] = [], const Sch extends TableSchema | undefined = undefined, const M extends InvalidRowsMode = 'drop'>(options: CreateTableOptions<T, TableStateFor<S, Fs, SchemaRow<T, Sch>>, Sch, M> & {
307
318
  features?: Fs;
308
- }): Table<SchemaRow<T, Sch>, TableStateFor<S, Fs, SchemaRow<T, Sch>>, M, [
309
- Sch
310
- ] extends [TableSchema] ? unknown : T> & ApiOf<Fs, SchemaRow<T, Sch>>;
319
+ }): Table<SchemaRow<T, Sch>, TableStateFor<S, Fs, SchemaRow<T, Sch>>, M, HasSchema<Sch> extends true ? unknown : T> & ApiOf<Fs, SchemaRow<T, Sch>>;
311
320
 
312
321
  /**
313
322
  * SSR seam for bindings (§7.2): runs `create` (a `createTable` call) so that the table it creates
@@ -398,4 +407,4 @@ interface VersionRegistry {
398
407
  */
399
408
  declare function registerPackage(name: string, version: string): void;
400
409
 
401
- export { AnyFeature, ApiOf, CallbackError, ColumnFiltersTypes, type ColumnKey, type CompiledPath, type CreateTableOptions, type DefaultFeatures, type DependencyCapability, type Deprecation, type DerivedColumn, Diagnostic, DiagnosticCode, DiagnosticDefinition, DiagnosticDetails, DiagnosticStateSummary, type Diagnostics, type DiagnosticsOptions, Emit, EmitOptions, type ErrorClass, FALLBACK, type Fallback, Feature, FeatureContext, FeatureTypes, type FixedFeatureDefinition, FixedTypes, INGEST_SAMPLE, Interceptor, InterceptorContext, InterceptorRuntime, InvalidRowsMode, type LiveDiagnosticContext, OpName, OpResult, PaginationApi, PaginationState, Phase, REGISTRY_KEY, RedactLevel, RedactionOptions, type RowData, RowModelContext, STAGES, type SchemaRow, SearchApi, SearchState, ServerFetcher, SortingTypes, Stage, StandardSchemaV1, Table, TableOptions, TableSchema, TableState, TableStateFor, Trigger, VERSION, ValidityApi, ValidityState, type VersionRegistry, callUser, classifyError, compilePath, createDefaultFeatures, createDeferred, createDiagnostics, createTable, defaultFeatures, defaultFormat, defineDeprecation, defineFeature, deriveColumns, detectCapability, errorBoundary, formatDiagnostic, getFallback, getValue, orderFeatures, perfDiagnostics, registerFallback, registerPackage, startTable, toSafeJson, tracer, warnDeprecated };
410
+ export { AnyFeature, ApiOf, CallbackError, ColumnFiltersTypes, type ColumnKey, type CompiledPath, type CreateTableOptions, type DefaultFeatures, type DependencyCapability, type Deprecation, type DerivedColumn, Diagnostic, DiagnosticCode, DiagnosticDefinition, DiagnosticDetails, DiagnosticStateSummary, type Diagnostics, type DiagnosticsOptions, Emit, EmitOptions, type ErrorClass, FALLBACK, type Fallback, Feature, FeatureContext, FeatureTypes, type FixedFeatureDefinition, FixedTypes, type HasSchema, INGEST_SAMPLE, Interceptor, InterceptorContext, InterceptorRuntime, InvalidRowsMode, type LiveDiagnosticContext, OpName, OpResult, PaginationApi, PaginationState, Phase, REGISTRY_KEY, RedactLevel, RedactionOptions, type RowData, RowModelContext, STAGES, type SchemaRow, SearchApi, SearchState, ServerFetcher, SortingTypes, Stage, StandardSchemaV1, Table, TableOptions, TableSchema, TableState, TableStateFor, Trigger, VERSION, ValidityApi, ValidityState, type VersionRegistry, callUser, classifyError, compilePath, createDefaultFeatures, createDeferred, createDiagnostics, createTable, defaultFeatures, defaultFormat, defineDeprecation, defineFeature, deriveColumns, detectCapability, errorBoundary, formatDiagnostic, getFallback, getValue, orderFeatures, perfDiagnostics, registerFallback, registerPackage, startTable, toSafeJson, tracer, warnDeprecated };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { D as Diagnostic, c as DiagnosticCode, d as DiagnosticDetails, a as EmitOptions, T as Trigger, P as Phase, j as DiagnosticStateSummary, f as RedactLevel, k as RedactionOptions, l as DiagnosticDefinition, I as InvalidRowsMode, e as TableSchema, S as StandardSchemaV1, E as Emit } from './codes-AX8XkMNY.js';
2
- export { B as BadResponse, m as BuildInput, n as DK_UNSAFE_REDACTION, o as DatakableConfigError, p as DatakableError, q as DatakableSchemaError, r as DiagnosticCatalog, s as DiagnosticContext, t as DiagnosticLevel, u as DiagnosticMessages, v as DiagnosticMeta, w as DiagnosticText, x as FlaggedInvalidRow, F as FlaggedRow, h as InvalidRow, L as Location, y as REDACTED, z as RedactField, g as RedactFn, A as Redactor, b as Row, R as RowIssue, i as RowKey, C as SCHEMA_INGEST, G as SENSITIVE, H as SchemaIssueColumn, J as SchemaOutcome, K as SlotDefinition, M as SlotReturns, V as ValidRow, N as asyncDiagnostics, O as boundaryDiagnostics, Q as buildDiagnostic, U as columnFiltersDiagnostics, W as comparatorDiagnostics, X as coreDiagnostics, Y as dataCheckDiagnostics, Z as dataMutationDiagnostics, _ as defineDiagnostic, $ as defineSlot, a0 as describeReturn, a1 as describeValue, a2 as envDiagnostics, a3 as featureDiagnostics, a4 as fetchDiagnostics, a5 as formatSlot, a6 as formatWhere, a7 as getDiagnosticDefinition, a8 as getDiagnosticText, a9 as getSlot, aa as hasMessages, ab as hashRowKey, ac as installMessages, ad as isStandardSchema, ae as keepDiagnostics, af as listDiagnosticCodes, ag as matchesSlot, ah as optionDiagnostics, ai as paginationDiagnostics, aj as pipelineDiagnostics, ak as resolveRedaction, al as rowKeyDiagnostics, am as schemaDiagnostics, an as scrubError, ao as scrubSchemaIssue, ap as searchDiagnostics, aq as slotDiagnostics, ar as sortingDiagnostics, as as ssrDiagnostics, at as stepDiagnostics, au as tableDiagnostics, av as throwConfigError, aw as validityDiagnostics, ax as versioningDiagnostics } from './codes-AX8XkMNY.js';
3
- import { S as Stage, A as AnyFeature, I as InterceptorRuntime, a as Interceptor, F as Feature, b as FixedTypes, c as FeatureContext, R as RowModelContext, d as AnyRow, e as FeatureTypes, O as OpName, f as InterceptorContext, g as OpResult, T as TableState, h as TableOptions, i as ServerFetcher, j as TableStateFor, k as Table, l as ApiOf } from './explain-BVE3ln3G.js';
4
- export { m as AccessorColumn, n as Apply, B as BuiltinOperations, C as CELL_FALLBACK, o as CellContext, p as CellFailures, q as CellSlot, r as ColumnDef, s as ColumnValues, t as ContextBase, u as ContextPool, v as ControlledState, w as Core, E as ExplainStep, x as FetchOutcome, y as FetchParams, z as FetchResult, D as Fetcher, G as FilterFor, H as HotOpWarning, J as InterceptorRuntimeOptions, K as InvalidCellContext, L as IsAny, M as KeyColumn, N as Listener, P as LooseRow, Q as OpInput, U as OpKind, V as OpOutput, W as OpSpec, X as OperationInfo, Y as Operations, Z as OptionRule, _ as OptionType, $ as OptionsDefinition, a0 as OptionsSchema, a1 as Path, a2 as PathValue, a3 as Primitive, a4 as RenderReq, a5 as RowExplanation, a6 as RowModel, a7 as RowModelStatus, a8 as RowOf, a9 as RowStep, aa as RowStepOutcome, ab as SERVER_SOURCE, ac as SliceUpdater, ad as SortAlgorithm, ae as StateOf, af as TableDiagnosticsOptions, ag as TableExplanation, ah as UPDATE_DEPTH_LIMIT, ai as Updater, aj as createContext, ak as createContextPool, al as createInterceptorRuntime, am as defineInterceptor, an as defineOptions, ao as emitTableDiagnostic, ap as getOperation, aq as isOptionsDefinition, ar as listOperations, as as registerOperation, at as runCells } from './explain-BVE3ln3G.js';
1
+ import { D as Diagnostic, c as DiagnosticCode, d as DiagnosticDetails, a as EmitOptions, T as Trigger, P as Phase, j as DiagnosticStateSummary, f as RedactLevel, k as RedactionOptions, l as DiagnosticDefinition, I as InvalidRowsMode, e as TableSchema, S as StandardSchemaV1, E as Emit } from './codes-4sYQv_7J.js';
2
+ export { B as BadResponse, m as BuildInput, n as DK_UNSAFE_REDACTION, o as DatakableConfigError, p as DatakableError, q as DatakableSchemaError, r as DiagnosticCatalog, s as DiagnosticContext, t as DiagnosticLevel, u as DiagnosticMessages, v as DiagnosticMeta, w as DiagnosticText, x as FlaggedInvalidRow, F as FlaggedRow, h as InvalidRow, L as Location, y as REDACTED, z as RedactField, g as RedactFn, A as Redactor, b as Row, R as RowIssue, i as RowKey, C as SCHEMA_INGEST, G as SENSITIVE, H as SchemaIssueColumn, J as SchemaOutcome, K as SlotDefinition, M as SlotReturns, V as ValidRow, N as asyncDiagnostics, O as boundaryDiagnostics, Q as buildDiagnostic, U as columnFiltersDiagnostics, W as comparatorDiagnostics, X as coreDiagnostics, Y as dataCheckDiagnostics, Z as dataMutationDiagnostics, _ as defineDiagnostic, $ as defineSlot, a0 as describeReturn, a1 as describeValue, a2 as envDiagnostics, a3 as featureDiagnostics, a4 as fetchDiagnostics, a5 as formatSlot, a6 as formatWhere, a7 as getDiagnosticDefinition, a8 as getDiagnosticText, a9 as getSlot, aa as hasMessages, ab as hashRowKey, ac as installMessages, ad as isStandardSchema, ae as keepDiagnostics, af as listDiagnosticCodes, ag as matchesSlot, ah as optionDiagnostics, ai as paginationDiagnostics, aj as pipelineDiagnostics, ak as resolveRedaction, al as rowKeyDiagnostics, am as schemaDiagnostics, an as scrubError, ao as scrubSchemaIssue, ap as searchDiagnostics, aq as slotDiagnostics, ar as sortingDiagnostics, as as ssrDiagnostics, at as stateDiagnostics, au as stepDiagnostics, av as tableDiagnostics, aw as throwConfigError, ax as validityDiagnostics, ay as versioningDiagnostics } from './codes-4sYQv_7J.js';
3
+ import { S as Stage, A as AnyFeature, I as InterceptorRuntime, a as Interceptor, F as Feature, b as FixedTypes, c as FeatureContext, R as RowModelContext, d as AnyRow, e as FeatureTypes, O as OpName, f as InterceptorContext, g as OpResult, T as TableState, h as TableOptions, i as ServerFetcher, j as TableStateFor, k as Table, l as ApiOf } from './explain-Dr3SmMNY.js';
4
+ export { m as AccessorColumn, n as Apply, B as BuiltinOperations, C as CELL_FALLBACK, o as CellContext, p as CellFailures, q as CellSlot, r as ColumnDef, s as ColumnValues, t as ContextBase, u as ContextPool, v as ControlledState, w as Core, E as ExplainStep, x as FetchOutcome, y as FetchParams, z as FetchResult, D as Fetcher, G as FilterFor, H as HotOpWarning, J as InterceptorRuntimeOptions, K as InvalidCellContext, L as IsAny, M as KeyColumn, N as Listener, P as LooseRow, Q as OpInput, U as OpKind, V as OpOutput, W as OpSpec, X as OperationInfo, Y as Operations, Z as OptionRule, _ as OptionType, $ as OptionsDefinition, a0 as OptionsSchema, a1 as Path, a2 as PathValue, a3 as Primitive, a4 as RenderReq, a5 as RowExplanation, a6 as RowModel, a7 as RowModelStatus, a8 as RowOf, a9 as RowStep, aa as RowStepOutcome, ab as SERVER_SOURCE, ac as SliceUpdater, ad as SortAlgorithm, ae as StateOf, af as TableDiagnosticsOptions, ag as TableExplanation, ah as UPDATE_DEPTH_LIMIT, ai as Updater, aj as createContext, ak as createContextPool, al as createInterceptorRuntime, am as defineInterceptor, an as defineOptions, ao as emitTableDiagnostic, ap as getOperation, aq as isOptionsDefinition, ar as listOperations, as as registerOperation, at as runCells } from './explain-Dr3SmMNY.js';
5
5
  import { ColumnFiltersTypes } from './column-filters.js';
6
6
  export { ColumnFilter, ColumnFiltersApi, ColumnFiltersOptions, ColumnFiltersState, ContainsFilter, CustomFilter, EqualsFilter, InFilter, RangeFilter, RangeValue, columnFilters } from './column-filters.js';
7
7
  import { PaginationState, PaginationApi } from './pagination.js';
8
8
  export { PaginationOptions, pagination } from './pagination.js';
9
9
  import { SearchApi } from './search.js';
10
10
  export { SearchOptions, SearchTyping, SearchWait, search } from './search.js';
11
- import { S as SearchState } from './search-async-entry-CFQODE08.js';
12
- export { A as AsyncSearchFn, a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, d as SearchOutcome, e as SearchResult, f as SearchStatus, w as withSearchFn } from './search-async-entry-CFQODE08.js';
11
+ import { S as SearchState } from './search-async-entry-GRj0E06n.js';
12
+ export { A as AsyncSearchFn, a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, d as SearchOutcome, e as SearchResult, f as SearchStatus, w as withSearchFn } from './search-async-entry-GRj0E06n.js';
13
13
  import { SortingTypes } from './sorting.js';
14
14
  export { SortAlgorithmOption, SortDirection, SortEntry, SortingApi, SortingOptions, SortingState, compareValues, sorting, typeRank } from './sorting.js';
15
15
  import { ValidityState, ValidityApi } from './validity.js';
@@ -45,7 +45,10 @@ declare function compilePath(path: string): CompiledPath;
45
45
  */
46
46
  declare function getValue(row: unknown, path: string | CompiledPath, onError?: (error: unknown) => void): unknown;
47
47
 
48
- /** The §8.1 console text: header + aligned body. Also usable by explain() and tests. */
48
+ /**
49
+ * The §8.1 console text: header + aligned body, each line {@link printable}. Also usable by
50
+ * explain() and tests.
51
+ */
49
52
  declare function formatDiagnostic(d: Diagnostic): {
50
53
  header: string;
51
54
  body: string;
@@ -279,20 +282,28 @@ type DefaultFeatures = ReturnType<typeof createDefaultFeatures>;
279
282
  */
280
283
  declare const defaultFeatures: DefaultFeatures;
281
284
 
285
+ /** `undefined` exactly (not `any`, `never` or a union with it). */
286
+ type IsUndefined<X> = (<G>() => G extends X ? 1 : 2) extends <G>() => G extends undefined ? 1 : 2 ? true : false;
287
+ /**
288
+ * `true` when `Sch` (the inferred `schema` option) is a schema. Its default, `undefined` (no
289
+ * schema), is excluded explicitly: without `strictNullChecks` `undefined` is assignable to every
290
+ * type, `TableSchema` included, which typed `data` as `unknown[]` and `T` as `unknown` (#93).
291
+ */
292
+ type HasSchema<Sch> = [Sch] extends [TableSchema] ? IsUndefined<Sch> extends true ? false : true : false;
282
293
  /** The row type: the schema output with a `schema` (§5.1), else `T`. */
283
- type SchemaRow<T, Sch> = [Sch] extends [TableSchema] ? StandardSchemaV1.InferOutput<Sch> : T;
294
+ type SchemaRow<T, Sch> = [Sch] extends [TableSchema] ? IsUndefined<Sch> extends true ? T : StandardSchemaV1.InferOutput<Sch> : T;
284
295
  /**
285
296
  * `createTable` options: with a `schema`, the row type is its output and `data` is the raw input
286
297
  * (`unknown[]`, e.g. parsed JSON), validated per row.
287
298
  */
288
299
  type CreateTableOptions<T, S extends TableState, Sch, M extends InvalidRowsMode> = Omit<TableOptions<SchemaRow<T, Sch>, S>, 'data' | 'schema' | 'invalidRows' | 'fetcher' | 'initialData'> & {
289
- data?: readonly ([Sch] extends [TableSchema] ? unknown : T)[];
300
+ data?: readonly (HasSchema<Sch> extends true ? unknown : T)[];
290
301
  /** With a schema, the raw rows (validated like `data`). */
291
- initialData?: readonly ([Sch] extends [TableSchema] ? unknown : T)[];
302
+ initialData?: readonly (HasSchema<Sch> extends true ? unknown : T)[];
292
303
  /** With a schema, the fetcher returns raw rows (validated like `data`). */
293
- fetcher?: ServerFetcher<[Sch] extends [TableSchema] ? unknown : T>;
294
- schema?: [Sch] extends [TableSchema] ? Sch : TableSchema<unknown, T>;
295
- invalidRows?: [Sch] extends [TableSchema] ? M : InvalidRowsMode;
304
+ fetcher?: ServerFetcher<HasSchema<Sch> extends true ? unknown : T>;
305
+ schema?: HasSchema<Sch> extends true ? Sch : TableSchema<unknown, T>;
306
+ invalidRows?: HasSchema<Sch> extends true ? M : InvalidRowsMode;
296
307
  };
297
308
  /**
298
309
  * Creates the table store (§3.2): immutable state snapshots, controlled slices, isolated listeners,
@@ -305,9 +316,7 @@ type CreateTableOptions<T, S extends TableState, Sch, M extends InvalidRowsMode>
305
316
  */
306
317
  declare function createTable<T, S extends TableState = never, const Fs extends readonly AnyFeature[] = [], const Sch extends TableSchema | undefined = undefined, const M extends InvalidRowsMode = 'drop'>(options: CreateTableOptions<T, TableStateFor<S, Fs, SchemaRow<T, Sch>>, Sch, M> & {
307
318
  features?: Fs;
308
- }): Table<SchemaRow<T, Sch>, TableStateFor<S, Fs, SchemaRow<T, Sch>>, M, [
309
- Sch
310
- ] extends [TableSchema] ? unknown : T> & ApiOf<Fs, SchemaRow<T, Sch>>;
319
+ }): Table<SchemaRow<T, Sch>, TableStateFor<S, Fs, SchemaRow<T, Sch>>, M, HasSchema<Sch> extends true ? unknown : T> & ApiOf<Fs, SchemaRow<T, Sch>>;
311
320
 
312
321
  /**
313
322
  * SSR seam for bindings (§7.2): runs `create` (a `createTable` call) so that the table it creates
@@ -398,4 +407,4 @@ interface VersionRegistry {
398
407
  */
399
408
  declare function registerPackage(name: string, version: string): void;
400
409
 
401
- export { AnyFeature, ApiOf, CallbackError, ColumnFiltersTypes, type ColumnKey, type CompiledPath, type CreateTableOptions, type DefaultFeatures, type DependencyCapability, type Deprecation, type DerivedColumn, Diagnostic, DiagnosticCode, DiagnosticDefinition, DiagnosticDetails, DiagnosticStateSummary, type Diagnostics, type DiagnosticsOptions, Emit, EmitOptions, type ErrorClass, FALLBACK, type Fallback, Feature, FeatureContext, FeatureTypes, type FixedFeatureDefinition, FixedTypes, INGEST_SAMPLE, Interceptor, InterceptorContext, InterceptorRuntime, InvalidRowsMode, type LiveDiagnosticContext, OpName, OpResult, PaginationApi, PaginationState, Phase, REGISTRY_KEY, RedactLevel, RedactionOptions, type RowData, RowModelContext, STAGES, type SchemaRow, SearchApi, SearchState, ServerFetcher, SortingTypes, Stage, StandardSchemaV1, Table, TableOptions, TableSchema, TableState, TableStateFor, Trigger, VERSION, ValidityApi, ValidityState, type VersionRegistry, callUser, classifyError, compilePath, createDefaultFeatures, createDeferred, createDiagnostics, createTable, defaultFeatures, defaultFormat, defineDeprecation, defineFeature, deriveColumns, detectCapability, errorBoundary, formatDiagnostic, getFallback, getValue, orderFeatures, perfDiagnostics, registerFallback, registerPackage, startTable, toSafeJson, tracer, warnDeprecated };
410
+ export { AnyFeature, ApiOf, CallbackError, ColumnFiltersTypes, type ColumnKey, type CompiledPath, type CreateTableOptions, type DefaultFeatures, type DependencyCapability, type Deprecation, type DerivedColumn, Diagnostic, DiagnosticCode, DiagnosticDefinition, DiagnosticDetails, DiagnosticStateSummary, type Diagnostics, type DiagnosticsOptions, Emit, EmitOptions, type ErrorClass, FALLBACK, type Fallback, Feature, FeatureContext, FeatureTypes, type FixedFeatureDefinition, FixedTypes, type HasSchema, INGEST_SAMPLE, Interceptor, InterceptorContext, InterceptorRuntime, InvalidRowsMode, type LiveDiagnosticContext, OpName, OpResult, PaginationApi, PaginationState, Phase, REGISTRY_KEY, RedactLevel, RedactionOptions, type RowData, RowModelContext, STAGES, type SchemaRow, SearchApi, SearchState, ServerFetcher, SortingTypes, Stage, StandardSchemaV1, Table, TableOptions, TableSchema, TableState, TableStateFor, Trigger, VERSION, ValidityApi, ValidityState, type VersionRegistry, callUser, classifyError, compilePath, createDefaultFeatures, createDeferred, createDiagnostics, createTable, defaultFeatures, defaultFormat, defineDeprecation, defineFeature, deriveColumns, detectCapability, errorBoundary, formatDiagnostic, getFallback, getValue, orderFeatures, perfDiagnostics, registerFallback, registerPackage, startTable, toSafeJson, tracer, warnDeprecated };
@@ -25,6 +25,7 @@ __export(runtime_exports, {
25
25
  module.exports = __toCommonJS(runtime_exports);
26
26
  var import_build = require("../diagnostics/build.cjs");
27
27
  var import_process_guard = require("../diagnostics/process-guard.cjs");
28
+ var import_prose = require("../diagnostics/prose.cjs");
28
29
  var import_operations = require("./operations.cjs");
29
30
  var NOT_CALLED = 0;
30
31
  var CALLED = 1;
@@ -122,7 +123,7 @@ function createInterceptorRuntime(options = {}) {
122
123
  function compile(op) {
123
124
  const info = (0, import_operations.getOperation)(op);
124
125
  if (!info) {
125
- throw (0, import_build.internalError)(op, `unknown-op|${op}`);
126
+ throw (0, import_build.internalError)(op, `unknown-op|${(0, import_prose.proseArg)(op)}`);
126
127
  }
127
128
  const mine = list.filter((i) => attaches(i, op));
128
129
  if (boundary && attaches(boundary, op)) mine.unshift(boundary);
@@ -152,7 +153,7 @@ function createInterceptorRuntime(options = {}) {
152
153
  setInterceptors,
153
154
  installBoundary(b) {
154
155
  if (boundary) {
155
- throw (0, import_build.internalError)("*", `boundary-twice|${boundary.name}|${b.name}`);
156
+ throw (0, import_build.internalError)("*", `boundary-twice|${(0, import_prose.proseArg)(boundary.name)}|${(0, import_prose.proseArg)(b.name)}`);
156
157
  }
157
158
  boundary = b;
158
159
  compileAll();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/intercept/runtime.ts"],"sourcesContent":["import { DatakableError, internalError } from '../diagnostics/build'\nimport '../diagnostics/process-guard'\nimport type { Emit } from '../diagnostics/types'\nimport type { InterceptorContext } from './context'\nimport type { Interceptor } from './define'\nimport { getOperation, listOperations, type OpName, type OpResult } from './operations'\n\nexport type Core<O extends OpName> = (ctx: InterceptorContext<O>) => OpResult<O>\n\nexport interface HotOpWarning {\n interceptor: Interceptor<OpName>\n op: string\n message: string\n}\n\nexport interface InterceptorRuntimeOptions {\n interceptors?: readonly Interceptor<OpName>[]\n /**\n * The table's diagnostic emitter. When given, the default hooks below report through it:\n * `DK_INTERCEPTOR_FAILED` and (dev only) `DK_HOT_INTERCEPTOR`. Without it they use the console.\n */\n emit?: Emit\n /**\n * An interceptor threw (or its promise rejected); it was skipped. Overrides the default report\n * (`DK_INTERCEPTOR_FAILED` via `emit`, else console.error).\n */\n onInterceptorError?: (\n error: unknown,\n interceptor: Interceptor<OpName>,\n ctx: InterceptorContext,\n ) => void\n /**\n * An interceptor is attached to a hot op without `hot: true` (checked when the op's chain is\n * compiled, once per interceptor + op). Overrides the default (`DK_HOT_INTERCEPTOR` via `emit`).\n */\n onHotWarning?: (warning: HotOpWarning) => void\n /** Called each time a chain is compiled (tracing / tests). `length` counts the boundary too. */\n onCompile?: (op: string, length: number) => void\n}\n\nexport interface InterceptorRuntime {\n /** Runs `core` for `op` through the compiled chain. */\n run<O extends OpName>(op: O, ctx: InterceptorContext<O>, core: NoInfer<Core<O>>): OpResult<O>\n /** Replaces the user / feature interceptors and recompiles. The boundary slot is kept. */\n setInterceptors(interceptors: readonly Interceptor<OpName>[]): void\n /** Installs the outermost, non-removable interceptor (errorBoundary, T06). Once only. */\n installBoundary(boundary: Interceptor<OpName>): void\n}\n\ntype AnyCtx = InterceptorContext\ntype AnyCore = (ctx: AnyCtx) => unknown\ntype Chain = (ctx: AnyCtx, core: AnyCore) => unknown\n\nconst NOT_CALLED = 0\nconst CALLED = 1\nconst FAILED_INSIDE = 2\n\nconst direct: Chain = (ctx, core) => core(ctx)\n\nconst isThenable = (v: unknown): v is PromiseLike<unknown> =>\n v != null && typeof (v as { then?: unknown }).then === 'function'\n\nconst attaches = (i: Interceptor<OpName>, op: string) =>\n i.on === '*' || (i.on as readonly string[]).includes(op)\n\n/**\n * Wraps one interceptor around `inner`. Skip semantics (§3.4): if the interceptor throws before\n * calling `next`, `next` runs directly; if it throws after, the result `next` produced is kept so\n * the core never runs twice. An error that came out of `next` belongs to an inner layer and is\n * rethrown untouched. Async results get the same rules on rejection.\n */\nfunction wrap(\n i: Interceptor<OpName>,\n inner: Chain,\n mayBeAsync: boolean,\n report: (error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => void,\n): Chain {\n const intercept = i.intercept as (ctx: AnyCtx, next: () => unknown) => unknown\n return (ctx, core) => {\n let state = NOT_CALLED\n let out: unknown\n const next = () => {\n state = CALLED\n try {\n out = inner(ctx, core)\n } catch (e) {\n state = FAILED_INSIDE\n throw e\n }\n if (mayBeAsync && isThenable(out)) {\n const p = Promise.resolve(out).then(undefined, (e: unknown) => {\n state = FAILED_INSIDE\n throw e\n })\n // Handled here so an interceptor that drops `next()` never causes an unhandled rejection;\n // whoever awaits `p` still sees the rejection.\n p.catch(() => {})\n out = p\n }\n return out\n }\n const recover = (e: unknown) => {\n if (state === FAILED_INSIDE) throw e\n report(e, i, ctx)\n return state === CALLED ? out : inner(ctx, core)\n }\n let r: unknown\n try {\n r = intercept(ctx, next)\n } catch (e) {\n return recover(e)\n }\n return mayBeAsync && isThenable(r) ? Promise.resolve(r).then(undefined, recover) : r\n }\n}\n\nexport function createInterceptorRuntime(\n options: InterceptorRuntimeOptions = {},\n): InterceptorRuntime {\n const { emit, onCompile } = options\n const onError =\n options.onInterceptorError ??\n ((error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => {\n if (emit) {\n emit(\n 'DK_INTERCEPTOR_FAILED',\n { interceptor: i.name, op: ctx.op, slot: ctx.where },\n { cause: error, run: ctx.run, trigger: ctx.trigger, phase: ctx.phase },\n )\n } else {\n console.error(\n `[DataKable] interceptor \"${i.name}\" failed on ${ctx.op} and was skipped`,\n error,\n )\n }\n })\n // Dev-only (DK_HOT_INTERCEPTOR): `undefined` in production, with the code and its text.\n const onHotWarning = (process.env.NODE_ENV !== \"production\")\n ? (options.onHotWarning ??\n ((w: HotOpWarning) => {\n if (emit) emit('DK_HOT_INTERCEPTOR', { interceptor: w.interceptor.name, op: w.op })\n else console.warn(`[DataKable] ${w.message}`)\n }))\n : undefined\n const report = (error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => {\n try {\n onError(error, i, ctx)\n } catch (e) {\n // The reporter must never break the operation it reports on — except `strict: true`, whose\n // DatakableError is the requested behaviour.\n if (e instanceof DatakableError) throw e\n }\n }\n\n let list: readonly Interceptor<OpName>[] = []\n let boundary: Interceptor<OpName> | undefined\n const chains = new Map<string, Chain>()\n /** (interceptor, op) pairs already warned about, so recompiles do not repeat the warning. */\n const warned = (process.env.NODE_ENV !== \"production\") ? new WeakMap<Interceptor<OpName>, Set<string>>() : undefined\n\n function warnHot(i: Interceptor<OpName>, op: string) {\n if (!(process.env.NODE_ENV !== \"production\") || !warned || !onHotWarning) return // dev-only: production bundles drop the text below\n let ops = warned.get(i)\n if (ops?.has(op)) return\n if (!ops) {\n ops = new Set()\n warned.set(i, ops)\n }\n ops.add(op)\n try {\n onHotWarning({\n interceptor: i,\n op,\n message:\n `Interceptor \"${i.name}\" is attached to hot op \"${op}\" without hot: true. ` +\n // Measured by intercept/chain.bench.ts (Apple M4 Pro, Node 25.2.1). Inline here, inside\n // the (process.env.NODE_ENV !== \"production\")-only function, so production bundles carry none of it.\n 'It runs once per column per pipeline run; measured cost: ~10 ns per call per ' +\n 'interceptor (+15% on a per-cell format call, spec §9.2) on top of the interceptor ' +\n 'body, which runs columns × pipeline runs times. ' +\n 'Never loop per cell inside it. Set hot: true to accept the cost, ' +\n 'or attach it to a cold op.',\n })\n } catch {\n // A warning must never break compilation.\n }\n }\n\n function compile(op: string): Chain {\n const info = getOperation(op)\n if (!info) {\n throw internalError(op, `unknown-op|${op}`)\n }\n const mine = list.filter((i) => attaches(i, op))\n if (boundary && attaches(boundary, op)) mine.unshift(boundary)\n // Checked here, not when the list is set, so ops registered after creation are covered too.\n if ((process.env.NODE_ENV !== \"production\") && info.hot) for (const i of mine) if (!i.hot) warnHot(i, op)\n const mayBeAsync = info.kind !== 'sync'\n const chain = mine.reduceRight<Chain>((inner, i) => wrap(i, inner, mayBeAsync, report), direct)\n chains.set(op, chain)\n onCompile?.(op, mine.length)\n return chain\n }\n\n function compileAll() {\n chains.clear()\n for (const op of listOperations()) compile(op)\n }\n\n function setInterceptors(next: readonly Interceptor<OpName>[]) {\n list = [...next]\n compileAll()\n }\n\n setInterceptors(options.interceptors ?? [])\n\n return {\n run(op, ctx, core) {\n const chain = chains.get(op) ?? compile(op)\n return chain(ctx, core as AnyCore) as OpResult<typeof op>\n },\n setInterceptors,\n installBoundary(b) {\n if (boundary) {\n throw internalError('*', `boundary-twice|${boundary.name}|${b.name}`)\n }\n boundary =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AACZ,kBAAM,4BAAc,KAAK,kBAAkB,SAAS,IAAI,IAAI,EAAE,IAAI,EAAE;AAAA,MACtE;AACA,iBAAW;AACX,iBAAW;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/intercept/runtime.ts"],"sourcesContent":["import { DatakableError, internalError } from '../diagnostics/build'\nimport '../diagnostics/process-guard'\nimport { proseArg } from '../diagnostics/prose'\nimport type { Emit } from '../diagnostics/types'\nimport type { InterceptorContext } from './context'\nimport type { Interceptor } from './define'\nimport { getOperation, listOperations, type OpName, type OpResult } from './operations'\n\nexport type Core<O extends OpName> = (ctx: InterceptorContext<O>) => OpResult<O>\n\nexport interface HotOpWarning {\n interceptor: Interceptor<OpName>\n op: string\n message: string\n}\n\nexport interface InterceptorRuntimeOptions {\n interceptors?: readonly Interceptor<OpName>[]\n /**\n * The table's diagnostic emitter. When given, the default hooks below report through it:\n * `DK_INTERCEPTOR_FAILED` and (dev only) `DK_HOT_INTERCEPTOR`. Without it they use the console.\n */\n emit?: Emit\n /**\n * An interceptor threw (or its promise rejected); it was skipped. Overrides the default report\n * (`DK_INTERCEPTOR_FAILED` via `emit`, else console.error).\n */\n onInterceptorError?: (\n error: unknown,\n interceptor: Interceptor<OpName>,\n ctx: InterceptorContext,\n ) => void\n /**\n * An interceptor is attached to a hot op without `hot: true` (checked when the op's chain is\n * compiled, once per interceptor + op). Overrides the default (`DK_HOT_INTERCEPTOR` via `emit`).\n */\n onHotWarning?: (warning: HotOpWarning) => void\n /** Called each time a chain is compiled (tracing / tests). `length` counts the boundary too. */\n onCompile?: (op: string, length: number) => void\n}\n\nexport interface InterceptorRuntime {\n /** Runs `core` for `op` through the compiled chain. */\n run<O extends OpName>(op: O, ctx: InterceptorContext<O>, core: NoInfer<Core<O>>): OpResult<O>\n /** Replaces the user / feature interceptors and recompiles. The boundary slot is kept. */\n setInterceptors(interceptors: readonly Interceptor<OpName>[]): void\n /** Installs the outermost, non-removable interceptor (errorBoundary, T06). Once only. */\n installBoundary(boundary: Interceptor<OpName>): void\n}\n\ntype AnyCtx = InterceptorContext\ntype AnyCore = (ctx: AnyCtx) => unknown\ntype Chain = (ctx: AnyCtx, core: AnyCore) => unknown\n\nconst NOT_CALLED = 0\nconst CALLED = 1\nconst FAILED_INSIDE = 2\n\nconst direct: Chain = (ctx, core) => core(ctx)\n\nconst isThenable = (v: unknown): v is PromiseLike<unknown> =>\n v != null && typeof (v as { then?: unknown }).then === 'function'\n\nconst attaches = (i: Interceptor<OpName>, op: string) =>\n i.on === '*' || (i.on as readonly string[]).includes(op)\n\n/**\n * Wraps one interceptor around `inner`. Skip semantics (§3.4): if the interceptor throws before\n * calling `next`, `next` runs directly; if it throws after, the result `next` produced is kept so\n * the core never runs twice. An error that came out of `next` belongs to an inner layer and is\n * rethrown untouched. Async results get the same rules on rejection.\n */\nfunction wrap(\n i: Interceptor<OpName>,\n inner: Chain,\n mayBeAsync: boolean,\n report: (error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => void,\n): Chain {\n const intercept = i.intercept as (ctx: AnyCtx, next: () => unknown) => unknown\n return (ctx, core) => {\n let state = NOT_CALLED\n let out: unknown\n const next = () => {\n state = CALLED\n try {\n out = inner(ctx, core)\n } catch (e) {\n state = FAILED_INSIDE\n throw e\n }\n if (mayBeAsync && isThenable(out)) {\n const p = Promise.resolve(out).then(undefined, (e: unknown) => {\n state = FAILED_INSIDE\n throw e\n })\n // Handled here so an interceptor that drops `next()` never causes an unhandled rejection;\n // whoever awaits `p` still sees the rejection.\n p.catch(() => {})\n out = p\n }\n return out\n }\n const recover = (e: unknown) => {\n if (state === FAILED_INSIDE) throw e\n report(e, i, ctx)\n return state === CALLED ? out : inner(ctx, core)\n }\n let r: unknown\n try {\n r = intercept(ctx, next)\n } catch (e) {\n return recover(e)\n }\n return mayBeAsync && isThenable(r) ? Promise.resolve(r).then(undefined, recover) : r\n }\n}\n\nexport function createInterceptorRuntime(\n options: InterceptorRuntimeOptions = {},\n): InterceptorRuntime {\n const { emit, onCompile } = options\n const onError =\n options.onInterceptorError ??\n ((error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => {\n if (emit) {\n emit(\n 'DK_INTERCEPTOR_FAILED',\n { interceptor: i.name, op: ctx.op, slot: ctx.where },\n { cause: error, run: ctx.run, trigger: ctx.trigger, phase: ctx.phase },\n )\n } else {\n console.error(\n `[DataKable] interceptor \"${i.name}\" failed on ${ctx.op} and was skipped`,\n error,\n )\n }\n })\n // Dev-only (DK_HOT_INTERCEPTOR): `undefined` in production, with the code and its text.\n const onHotWarning = (process.env.NODE_ENV !== \"production\")\n ? (options.onHotWarning ??\n ((w: HotOpWarning) => {\n if (emit) emit('DK_HOT_INTERCEPTOR', { interceptor: w.interceptor.name, op: w.op })\n else console.warn(`[DataKable] ${w.message}`)\n }))\n : undefined\n const report = (error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => {\n try {\n onError(error, i, ctx)\n } catch (e) {\n // The reporter must never break the operation it reports on — except `strict: true`, whose\n // DatakableError is the requested behaviour.\n if (e instanceof DatakableError) throw e\n }\n }\n\n let list: readonly Interceptor<OpName>[] = []\n let boundary: Interceptor<OpName> | undefined\n const chains = new Map<string, Chain>()\n /** (interceptor, op) pairs already warned about, so recompiles do not repeat the warning. */\n const warned = (process.env.NODE_ENV !== \"production\") ? new WeakMap<Interceptor<OpName>, Set<string>>() : undefined\n\n function warnHot(i: Interceptor<OpName>, op: string) {\n if (!(process.env.NODE_ENV !== \"production\") || !warned || !onHotWarning) return // dev-only: production bundles drop the text below\n let ops = warned.get(i)\n if (ops?.has(op)) return\n if (!ops) {\n ops = new Set()\n warned.set(i, ops)\n }\n ops.add(op)\n try {\n onHotWarning({\n interceptor: i,\n op,\n message:\n `Interceptor \"${i.name}\" is attached to hot op \"${op}\" without hot: true. ` +\n // Measured by intercept/chain.bench.ts (Apple M4 Pro, Node 25.2.1). Inline here, inside\n // the (process.env.NODE_ENV !== \"production\")-only function, so production bundles carry none of it.\n 'It runs once per column per pipeline run; measured cost: ~10 ns per call per ' +\n 'interceptor (+15% on a per-cell format call, spec §9.2) on top of the interceptor ' +\n 'body, which runs columns × pipeline runs times. ' +\n 'Never loop per cell inside it. Set hot: true to accept the cost, ' +\n 'or attach it to a cold op.',\n })\n } catch {\n // A warning must never break compilation.\n }\n }\n\n function compile(op: string): Chain {\n const info = getOperation(op)\n if (!info) {\n throw internalError(op, `unknown-op|${proseArg(op)}`)\n }\n const mine = list.filter((i) => attaches(i, op))\n if (boundary && attaches(boundary, op)) mine.unshift(boundary)\n // Checked here, not when the list is set, so ops registered after creation are covered too.\n if ((process.env.NODE_ENV !== \"production\") && info.hot) for (const i of mine) if (!i.hot) warnHot(i, op)\n const mayBeAsync = info.kind !== 'sync'\n const chain = mine.reduceRight<Chain>((inner, i) => wrap(i, inner, mayBeAsync, report), direct)\n chains.set(op, chain)\n onCompile?.(op, mine.length)\n return chain\n }\n\n function compileAll() {\n chains.clear()\n for (const op of listOperations()) compile(op)\n }\n\n function setInterceptors(next: readonly Interceptor<OpName>[]) {\n list = [...next]\n compileAll()\n }\n\n setInterceptors(options.interceptors ?? [])\n\n return {\n run(op, ctx, core) {\n const chain = chains.get(op) ?? compile(op)\n return chain(ctx, core as AnyCore) as OpResult<typeof op>\n },\n setInterceptors,\n installBoundary(b) {\n if (boundary) {\n throw internalError('*', `boundary-twice|${proseArg(boundary.name)}|${proseArg(b.name)}`)\n }\n boundary = b\n compileAll()\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA8C;AAC9C,2BAAO;AACP,mBAAyB;AAIzB,wBAAyE;AAgDzE,IAAM,aAAa;AACnB,IAAM,SAAS;AACf,IAAM,gBAAgB;AAEtB,IAAM,SAAgB,CAAC,KAAK,SAAS,KAAK,GAAG;AAE7C,IAAM,aAAa,CAAC,MAClB,KAAK,QAAQ,OAAQ,EAAyB,SAAS;AAEzD,IAAM,WAAW,CAAC,GAA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uBAAS,EAAE,CAAC,EAAE;AAAA,IACtD;AACA,UAAM,OAAO,KAAK,OAAO,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAC/C,QAAI,YAAY,SAAS,UAAU,EAAE,EAAG,MAAK,QAAQ,QAAQ;AAE7D,QAAK,QAAQ,IAAI,aAAa,gBAAiB,KAAK;AAAK,iBAAW,KAAK,KAAM,KAAI,CAAC,EAAE,IAAK,SAAQ,GAAG,EAAE;AAAA;AACxG,UAAM,aAAa,KAAK,SAAS;AACjC,UAAM,QAAQ,KAAK,YAAmB,CAAC,OAAO,MAAM,KAAK,GAAG,OAAO,YAAY,MAAM,GAAG,MAAM;AAC9F,WAAO,IAAI,IAAI,KAAK;AACpB,gBAAY,IAAI,KAAK,MAAM;AAC3B,WAAO;AAAA,EACT;AAEA,WAAS,aAAa;AACpB,WAAO,MAAM;AACb,eAAW,UAAM,kCAAe,EAAG,SAAQ,EAAE;AAAA,EAC/C;AAEA,WAAS,gBAAgB,MAAsC;AAC7D,WAAO,CAAC,GAAG,IAAI;AACf,eAAW;AAAA,EACb;AAEA,kBAAgB,QAAQ,gBAAgB,CAAC,CAAC;AAE1C,SAAO;AAAA,IACL,IAAI,IAAI,KAAK,MAAM;AACjB,YAAM,QAAQ,OAAO,IAAI,EAAE,KAAK,QAAQ,EAAE;AAC1C,aAAO,MAAM,KAAK,IAAe;AAAA,IACnC;AAAA,IACA;AAAA,IACA,gBAAgB,GAAG;AACjB,UAAI,UAAU;AACZ,kBAAM,4BAAc,KAAK,sBAAkB,uBAAS,SAAS,IAAI,CAAC,QAAI,uBAAS,EAAE,IAAI,CAAC,EAAE;AAAA,MAC1F;AACA,iBAAW;AACX,iBAAW;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
@@ -1,6 +1,7 @@
1
1
  // src/intercept/runtime.ts
2
2
  import { DatakableError, internalError } from "../diagnostics/build.js";
3
3
  import "../diagnostics/process-guard.js";
4
+ import { proseArg } from "../diagnostics/prose.js";
4
5
  import { getOperation, listOperations } from "./operations.js";
5
6
  var NOT_CALLED = 0;
6
7
  var CALLED = 1;
@@ -98,7 +99,7 @@ function createInterceptorRuntime(options = {}) {
98
99
  function compile(op) {
99
100
  const info = getOperation(op);
100
101
  if (!info) {
101
- throw internalError(op, `unknown-op|${op}`);
102
+ throw internalError(op, `unknown-op|${proseArg(op)}`);
102
103
  }
103
104
  const mine = list.filter((i) => attaches(i, op));
104
105
  if (boundary && attaches(boundary, op)) mine.unshift(boundary);
@@ -128,7 +129,7 @@ function createInterceptorRuntime(options = {}) {
128
129
  setInterceptors,
129
130
  installBoundary(b) {
130
131
  if (boundary) {
131
- throw internalError("*", `boundary-twice|${boundary.name}|${b.name}`);
132
+ throw internalError("*", `boundary-twice|${proseArg(boundary.name)}|${proseArg(b.name)}`);
132
133
  }
133
134
  boundary = b;
134
135
  compileAll();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/intercept/runtime.ts"],"sourcesContent":["import { DatakableError, internalError } from '../diagnostics/build'\nimport '../diagnostics/process-guard'\nimport type { Emit } from '../diagnostics/types'\nimport type { InterceptorContext } from './context'\nimport type { Interceptor } from './define'\nimport { getOperation, listOperations, type OpName, type OpResult } from './operations'\n\nexport type Core<O extends OpName> = (ctx: InterceptorContext<O>) => OpResult<O>\n\nexport interface HotOpWarning {\n interceptor: Interceptor<OpName>\n op: string\n message: string\n}\n\nexport interface InterceptorRuntimeOptions {\n interceptors?: readonly Interceptor<OpName>[]\n /**\n * The table's diagnostic emitter. When given, the default hooks below report through it:\n * `DK_INTERCEPTOR_FAILED` and (dev only) `DK_HOT_INTERCEPTOR`. Without it they use the console.\n */\n emit?: Emit\n /**\n * An interceptor threw (or its promise rejected); it was skipped. Overrides the default report\n * (`DK_INTERCEPTOR_FAILED` via `emit`, else console.error).\n */\n onInterceptorError?: (\n error: unknown,\n interceptor: Interceptor<OpName>,\n ctx: InterceptorContext,\n ) => void\n /**\n * An interceptor is attached to a hot op without `hot: true` (checked when the op's chain is\n * compiled, once per interceptor + op). Overrides the default (`DK_HOT_INTERCEPTOR` via `emit`).\n */\n onHotWarning?: (warning: HotOpWarning) => void\n /** Called each time a chain is compiled (tracing / tests). `length` counts the boundary too. */\n onCompile?: (op: string, length: number) => void\n}\n\nexport interface InterceptorRuntime {\n /** Runs `core` for `op` through the compiled chain. */\n run<O extends OpName>(op: O, ctx: InterceptorContext<O>, core: NoInfer<Core<O>>): OpResult<O>\n /** Replaces the user / feature interceptors and recompiles. The boundary slot is kept. */\n setInterceptors(interceptors: readonly Interceptor<OpName>[]): void\n /** Installs the outermost, non-removable interceptor (errorBoundary, T06). Once only. */\n installBoundary(boundary: Interceptor<OpName>): void\n}\n\ntype AnyCtx = InterceptorContext\ntype AnyCore = (ctx: AnyCtx) => unknown\ntype Chain = (ctx: AnyCtx, core: AnyCore) => unknown\n\nconst NOT_CALLED = 0\nconst CALLED = 1\nconst FAILED_INSIDE = 2\n\nconst direct: Chain = (ctx, core) => core(ctx)\n\nconst isThenable = (v: unknown): v is PromiseLike<unknown> =>\n v != null && typeof (v as { then?: unknown }).then === 'function'\n\nconst attaches = (i: Interceptor<OpName>, op: string) =>\n i.on === '*' || (i.on as readonly string[]).includes(op)\n\n/**\n * Wraps one interceptor around `inner`. Skip semantics (§3.4): if the interceptor throws before\n * calling `next`, `next` runs directly; if it throws after, the result `next` produced is kept so\n * the core never runs twice. An error that came out of `next` belongs to an inner layer and is\n * rethrown untouched. Async results get the same rules on rejection.\n */\nfunction wrap(\n i: Interceptor<OpName>,\n inner: Chain,\n mayBeAsync: boolean,\n report: (error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => void,\n): Chain {\n const intercept = i.intercept as (ctx: AnyCtx, next: () => unknown) => unknown\n return (ctx, core) => {\n let state = NOT_CALLED\n let out: unknown\n const next = () => {\n state = CALLED\n try {\n out = inner(ctx, core)\n } catch (e) {\n state = FAILED_INSIDE\n throw e\n }\n if (mayBeAsync && isThenable(out)) {\n const p = Promise.resolve(out).then(undefined, (e: unknown) => {\n state = FAILED_INSIDE\n throw e\n })\n // Handled here so an interceptor that drops `next()` never causes an unhandled rejection;\n // whoever awaits `p` still sees the rejection.\n p.catch(() => {})\n out = p\n }\n return out\n }\n const recover = (e: unknown) => {\n if (state === FAILED_INSIDE) throw e\n report(e, i, ctx)\n return state === CALLED ? out : inner(ctx, core)\n }\n let r: unknown\n try {\n r = intercept(ctx, next)\n } catch (e) {\n return recover(e)\n }\n return mayBeAsync && isThenable(r) ? Promise.resolve(r).then(undefined, recover) : r\n }\n}\n\nexport function createInterceptorRuntime(\n options: InterceptorRuntimeOptions = {},\n): InterceptorRuntime {\n const { emit, onCompile } = options\n const onError =\n options.onInterceptorError ??\n ((error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => {\n if (emit) {\n emit(\n 'DK_INTERCEPTOR_FAILED',\n { interceptor: i.name, op: ctx.op, slot: ctx.where },\n { cause: error, run: ctx.run, trigger: ctx.trigger, phase: ctx.phase },\n )\n } else {\n console.error(\n `[DataKable] interceptor \"${i.name}\" failed on ${ctx.op} and was skipped`,\n error,\n )\n }\n })\n // Dev-only (DK_HOT_INTERCEPTOR): `undefined` in production, with the code and its text.\n const onHotWarning = (process.env.NODE_ENV !== \"production\")\n ? (options.onHotWarning ??\n ((w: HotOpWarning) => {\n if (emit) emit('DK_HOT_INTERCEPTOR', { interceptor: w.interceptor.name, op: w.op })\n else console.warn(`[DataKable] ${w.message}`)\n }))\n : undefined\n const report = (error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => {\n try {\n onError(error, i, ctx)\n } catch (e) {\n // The reporter must never break the operation it reports on — except `strict: true`, whose\n // DatakableError is the requested behaviour.\n if (e instanceof DatakableError) throw e\n }\n }\n\n let list: readonly Interceptor<OpName>[] = []\n let boundary: Interceptor<OpName> | undefined\n const chains = new Map<string, Chain>()\n /** (interceptor, op) pairs already warned about, so recompiles do not repeat the warning. */\n const warned = (process.env.NODE_ENV !== \"production\") ? new WeakMap<Interceptor<OpName>, Set<string>>() : undefined\n\n function warnHot(i: Interceptor<OpName>, op: string) {\n if (!(process.env.NODE_ENV !== \"production\") || !warned || !onHotWarning) return // dev-only: production bundles drop the text below\n let ops = warned.get(i)\n if (ops?.has(op)) return\n if (!ops) {\n ops = new Set()\n warned.set(i, ops)\n }\n ops.add(op)\n try {\n onHotWarning({\n interceptor: i,\n op,\n message:\n `Interceptor \"${i.name}\" is attached to hot op \"${op}\" without hot: true. ` +\n // Measured by intercept/chain.bench.ts (Apple M4 Pro, Node 25.2.1). Inline here, inside\n // the (process.env.NODE_ENV !== \"production\")-only function, so production bundles carry none of it.\n 'It runs once per column per pipeline run; measured cost: ~10 ns per call per ' +\n 'interceptor (+15% on a per-cell format call, spec §9.2) on top of the interceptor ' +\n 'body, which runs columns × pipeline runs times. ' +\n 'Never loop per cell inside it. Set hot: true to accept the cost, ' +\n 'or attach it to a cold op.',\n })\n } catch {\n // A warning must never break compilation.\n }\n }\n\n function compile(op: string): Chain {\n const info = getOperation(op)\n if (!info) {\n throw internalError(op, `unknown-op|${op}`)\n }\n const mine = list.filter((i) => attaches(i, op))\n if (boundary && attaches(boundary, op)) mine.unshift(boundary)\n // Checked here, not when the list is set, so ops registered after creation are covered too.\n if ((process.env.NODE_ENV !== \"production\") && info.hot) for (const i of mine) if (!i.hot) warnHot(i, op)\n const mayBeAsync = info.kind !== 'sync'\n const chain = mine.reduceRight<Chain>((inner, i) => wrap(i, inner, mayBeAsync, report), direct)\n chains.set(op, chain)\n onCompile?.(op, mine.length)\n return chain\n }\n\n function compileAll() {\n chains.clear()\n for (const op of listOperations()) compile(op)\n }\n\n function setInterceptors(next: readonly Interceptor<OpName>[]) {\n list = [...next]\n compileAll()\n }\n\n setInterceptors(options.interceptors ?? [])\n\n return {\n run(op, ctx, core) {\n const chain = chains.get(op) ?? compile(op)\n return chain(ctx, core as AnyCore) as OpResult<typeof op>\n },\n setInterceptors,\n installBoundary(b) {\n if (boundary) {\n throw internalError('*', `boundary-twice|${boundary.name}|${b.name}`)\n }\n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kB,SAAS,IAAI,IAAI,EAAE,IAAI,EAAE;AAAA,MACtE;AACA,iBAAW;AACX,iBAAW;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/intercept/runtime.ts"],"sourcesContent":["import { DatakableError, internalError } from '../diagnostics/build'\nimport '../diagnostics/process-guard'\nimport { proseArg } from '../diagnostics/prose'\nimport type { Emit } from '../diagnostics/types'\nimport type { InterceptorContext } from './context'\nimport type { Interceptor } from './define'\nimport { getOperation, listOperations, type OpName, type OpResult } from './operations'\n\nexport type Core<O extends OpName> = (ctx: InterceptorContext<O>) => OpResult<O>\n\nexport interface HotOpWarning {\n interceptor: Interceptor<OpName>\n op: string\n message: string\n}\n\nexport interface InterceptorRuntimeOptions {\n interceptors?: readonly Interceptor<OpName>[]\n /**\n * The table's diagnostic emitter. When given, the default hooks below report through it:\n * `DK_INTERCEPTOR_FAILED` and (dev only) `DK_HOT_INTERCEPTOR`. Without it they use the console.\n */\n emit?: Emit\n /**\n * An interceptor threw (or its promise rejected); it was skipped. Overrides the default report\n * (`DK_INTERCEPTOR_FAILED` via `emit`, else console.error).\n */\n onInterceptorError?: (\n error: unknown,\n interceptor: Interceptor<OpName>,\n ctx: InterceptorContext,\n ) => void\n /**\n * An interceptor is attached to a hot op without `hot: true` (checked when the op's chain is\n * compiled, once per interceptor + op). Overrides the default (`DK_HOT_INTERCEPTOR` via `emit`).\n */\n onHotWarning?: (warning: HotOpWarning) => void\n /** Called each time a chain is compiled (tracing / tests). `length` counts the boundary too. */\n onCompile?: (op: string, length: number) => void\n}\n\nexport interface InterceptorRuntime {\n /** Runs `core` for `op` through the compiled chain. */\n run<O extends OpName>(op: O, ctx: InterceptorContext<O>, core: NoInfer<Core<O>>): OpResult<O>\n /** Replaces the user / feature interceptors and recompiles. The boundary slot is kept. */\n setInterceptors(interceptors: readonly Interceptor<OpName>[]): void\n /** Installs the outermost, non-removable interceptor (errorBoundary, T06). Once only. */\n installBoundary(boundary: Interceptor<OpName>): void\n}\n\ntype AnyCtx = InterceptorContext\ntype AnyCore = (ctx: AnyCtx) => unknown\ntype Chain = (ctx: AnyCtx, core: AnyCore) => unknown\n\nconst NOT_CALLED = 0\nconst CALLED = 1\nconst FAILED_INSIDE = 2\n\nconst direct: Chain = (ctx, core) => core(ctx)\n\nconst isThenable = (v: unknown): v is PromiseLike<unknown> =>\n v != null && typeof (v as { then?: unknown }).then === 'function'\n\nconst attaches = (i: Interceptor<OpName>, op: string) =>\n i.on === '*' || (i.on as readonly string[]).includes(op)\n\n/**\n * Wraps one interceptor around `inner`. Skip semantics (§3.4): if the interceptor throws before\n * calling `next`, `next` runs directly; if it throws after, the result `next` produced is kept so\n * the core never runs twice. An error that came out of `next` belongs to an inner layer and is\n * rethrown untouched. Async results get the same rules on rejection.\n */\nfunction wrap(\n i: Interceptor<OpName>,\n inner: Chain,\n mayBeAsync: boolean,\n report: (error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => void,\n): Chain {\n const intercept = i.intercept as (ctx: AnyCtx, next: () => unknown) => unknown\n return (ctx, core) => {\n let state = NOT_CALLED\n let out: unknown\n const next = () => {\n state = CALLED\n try {\n out = inner(ctx, core)\n } catch (e) {\n state = FAILED_INSIDE\n throw e\n }\n if (mayBeAsync && isThenable(out)) {\n const p = Promise.resolve(out).then(undefined, (e: unknown) => {\n state = FAILED_INSIDE\n throw e\n })\n // Handled here so an interceptor that drops `next()` never causes an unhandled rejection;\n // whoever awaits `p` still sees the rejection.\n p.catch(() => {})\n out = p\n }\n return out\n }\n const recover = (e: unknown) => {\n if (state === FAILED_INSIDE) throw e\n report(e, i, ctx)\n return state === CALLED ? out : inner(ctx, core)\n }\n let r: unknown\n try {\n r = intercept(ctx, next)\n } catch (e) {\n return recover(e)\n }\n return mayBeAsync && isThenable(r) ? Promise.resolve(r).then(undefined, recover) : r\n }\n}\n\nexport function createInterceptorRuntime(\n options: InterceptorRuntimeOptions = {},\n): InterceptorRuntime {\n const { emit, onCompile } = options\n const onError =\n options.onInterceptorError ??\n ((error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => {\n if (emit) {\n emit(\n 'DK_INTERCEPTOR_FAILED',\n { interceptor: i.name, op: ctx.op, slot: ctx.where },\n { cause: error, run: ctx.run, trigger: ctx.trigger, phase: ctx.phase },\n )\n } else {\n console.error(\n `[DataKable] interceptor \"${i.name}\" failed on ${ctx.op} and was skipped`,\n error,\n )\n }\n })\n // Dev-only (DK_HOT_INTERCEPTOR): `undefined` in production, with the code and its text.\n const onHotWarning = (process.env.NODE_ENV !== \"production\")\n ? (options.onHotWarning ??\n ((w: HotOpWarning) => {\n if (emit) emit('DK_HOT_INTERCEPTOR', { interceptor: w.interceptor.name, op: w.op })\n else console.warn(`[DataKable] ${w.message}`)\n }))\n : undefined\n const report = (error: unknown, i: Interceptor<OpName>, ctx: AnyCtx) => {\n try {\n onError(error, i, ctx)\n } catch (e) {\n // The reporter must never break the operation it reports on — except `strict: true`, whose\n // DatakableError is the requested behaviour.\n if (e instanceof DatakableError) throw e\n }\n }\n\n let list: readonly Interceptor<OpName>[] = []\n let boundary: Interceptor<OpName> | undefined\n const chains = new Map<string, Chain>()\n /** (interceptor, op) pairs already warned about, so recompiles do not repeat the warning. */\n const warned = (process.env.NODE_ENV !== \"production\") ? new WeakMap<Interceptor<OpName>, Set<string>>() : undefined\n\n function warnHot(i: Interceptor<OpName>, op: string) {\n if (!(process.env.NODE_ENV !== \"production\") || !warned || !onHotWarning) return // dev-only: production bundles drop the text below\n let ops = warned.get(i)\n if (ops?.has(op)) return\n if (!ops) {\n ops = new Set()\n warned.set(i, ops)\n }\n ops.add(op)\n try {\n onHotWarning({\n interceptor: i,\n op,\n message:\n `Interceptor \"${i.name}\" is attached to hot op \"${op}\" without hot: true. ` +\n // Measured by intercept/chain.bench.ts (Apple M4 Pro, Node 25.2.1). Inline here, inside\n // the (process.env.NODE_ENV !== \"production\")-only function, so production bundles carry none of it.\n 'It runs once per column per pipeline run; measured cost: ~10 ns per call per ' +\n 'interceptor (+15% on a per-cell format call, spec §9.2) on top of the interceptor ' +\n 'body, which runs columns × pipeline runs times. ' +\n 'Never loop per cell inside it. Set hot: true to accept the cost, ' +\n 'or attach it to a cold op.',\n })\n } catch {\n // A warning must never break compilation.\n }\n }\n\n function compile(op: string): Chain {\n const info = getOperation(op)\n if (!info) {\n throw internalError(op, `unknown-op|${proseArg(op)}`)\n }\n const mine = list.filter((i) => attaches(i, op))\n if (boundary && attaches(boundary, op)) mine.unshift(boundary)\n // Checked here, not when the list is set, so ops registered after creation are covered too.\n if ((process.env.NODE_ENV !== \"production\") && info.hot) for (const i of mine) if (!i.hot) warnHot(i, op)\n const mayBeAsync = info.kind !== 'sync'\n const chain = mine.reduceRight<Chain>((inner, i) => wrap(i, inner, mayBeAsync, report), direct)\n chains.set(op, chain)\n onCompile?.(op, mine.length)\n return chain\n }\n\n function compileAll() {\n chains.clear()\n for (const op of listOperations()) compile(op)\n }\n\n function setInterceptors(next: readonly Interceptor<OpName>[]) {\n list = [...next]\n compileAll()\n }\n\n setInterceptors(options.interceptors ?? [])\n\n return {\n run(op, ctx, core) {\n const chain = chains.get(op) ?? compile(op)\n return chain(ctx, core as AnyCore) as OpResult<typeof op>\n },\n setInterceptors,\n installBoundary(b) {\n if (boundary) {\n throw internalError('*', `boundary-twice|${proseArg(boundary.name)}|${proseArg(b.name)}`)\n }\n boundary = b\n compileAll()\n },\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAgB,qBAAqB;AAC9C,OAAO;AACP,SAAS,gBAAgB;AAIzB,SAAS,cAAc,sBAAkD;AAgDzE,IAAM,aAAa;AACnB,IAAM,SAAS;AACf,IAAM,gBAAgB;AAEtB,IAAM,SAAgB,CAAC,KAAK,SAAS,KAAK,GAAG;AAE7C,IAAM,aAAa,CAAC,MAClB,KAAK,QAAQ,OAAQ,EAAyB,SAAS;AAEzD,IAAM,WAAW,CAAC,GAAwB,OACxC,EAAE,OAAO,OAAQ,EAAE,GAAyB,SAAS,EAAE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OAAO,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC;AAC/C,QAAI,YAAY,SAAS,UAAU,EAAE,EAAG,MAAK,QAAQ,QAAQ;AAE7D,QAAK,QAAQ,IAAI,aAAa,gBAAiB,KAAK;AAAK,iBAAW,KAAK,KAAM,KAAI,CAAC,EAAE,IAAK,SAAQ,GAAG,EAAE;AAAA;AACxG,UAAM,aAAa,KAAK,SAAS;AACjC,UAAM,QAAQ,KAAK,YAAmB,CAAC,OAAO,MAAM,KAAK,GAAG,OAAO,YAAY,MAAM,GAAG,MAAM;AAC9F,WAAO,IAAI,IAAI,KAAK;AACpB,gBAAY,IAAI,KAAK,MAAM;AAC3B,WAAO;AAAA,EACT;AAEA,WAAS,aAAa;AACpB,WAAO,MAAM;AACb,eAAW,MAAM,eAAe,EAAG,SAAQ,EAAE;AAAA,EAC/C;AAEA,WAAS,gBAAgB,MAAsC;AAC7D,WAAO,CAAC,GAAG,IAAI;AACf,eAAW;AAAA,EACb;AAEA,kBAAgB,QAAQ,gBAAgB,CAAC,CAAC;AAE1C,SAAO;AAAA,IACL,IAAI,IAAI,KAAK,MAAM;AACjB,YAAM,QAAQ,OAAO,IAAI,EAAE,KAAK,QAAQ,EAAE;AAC1C,aAAO,MAAM,KAAK,IAAe;AAAA,IACnC;AAAA,IACA;AAAA,IACA,gBAAgB,GAAG;AACjB,UAAI,UAAU;AACZ,cAAM,cAAc,KAAK,kBAAkB,SAAS,SAAS,IAAI,CAAC,IAAI,SAAS,EAAE,IAAI,CAAC,EAAE;AAAA,MAC1F;AACA,iBAAW;AACX,iBAAW;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
@@ -44,6 +44,7 @@ var import_codes11 = require("../source/codes.cjs");
44
44
  var import_fetch_codes = require("../source/fetch-codes.cjs");
45
45
  var import_codes12 = require("../table/codes.cjs");
46
46
  var import_ssr_codes = require("../table/ssr-codes.cjs");
47
+ var import_state_codes = require("../table/state-codes.cjs");
47
48
  var import_codes13 = require("../versioning/codes.cjs");
48
49
  var allMessages = [
49
50
  import_codes2.coreMessages,
@@ -54,6 +55,7 @@ var allMessages = [
54
55
  import_codes10.pipelineMessages,
55
56
  import_codes12.tableMessages,
56
57
  import_ssr_codes.ssrMessages,
58
+ import_state_codes.stateMessages,
57
59
  import_codes11.asyncMessages,
58
60
  import_fetch_codes.fetchMessages,
59
61
  import_row_key_codes.rowKeyMessages,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/messages/index.ts"],"sourcesContent":["/**\n * `@datakable/core/messages` (`datakable/messages`): full diagnostic text in production (§8.2).\n *\n * Production builds strip `problem` / `impact` / `fix` and keep `code`, `where`, `context` and a\n * docs URL. `import '@datakable/core/messages'` once (e.g. in the app entry) installs the text of\n * every code a production build can emit. Development builds already have it. This module is the\n * package's only side effect (`sideEffects` in package.json).\n */\nimport { optionMessages } from '../catalog/codes'\nimport { installMessages } from '../diagnostics/catalog'\nimport { coreMessages } from '../diagnostics/codes'\nimport { proseMessages } from '../diagnostics/prose'\nimport { redactionMessages } from '../diagnostics/redact'\nimport { featureMessages } from '../feature/codes'\nimport { columnFiltersMessages } from '../features/column-filters/codes'\nimport { paginationMessages } from '../features/pagination/codes'\nimport { searchMessages } from '../features/search/codes'\nimport { sortingMessages } from '../features/sorting/codes'\nimport { validityMessages } from '../features/validity/codes'\nimport { dataCheckMessages } from '../ingest/data-check-codes'\nimport { rowKeyMessages } from '../ingest/row-key-codes'\nimport { schemaMessages } from '../ingest/schema-codes'\nimport { boundaryMessages } from '../intercept/codes'\nimport { pipelineMessages } from '../pipeline/codes'\nimport { envMessages } from '../pipeline/env-codes'\nimport { asyncMessages } from '../source/codes'\nimport { fetchMessages } from '../source/fetch-codes'\nimport { tableMessages } from '../table/codes'\nimport { ssrMessages } from '../table/ssr-codes'\nimport { versioningMessages } from '../versioning/codes'\n\n/** Every message object core ships, one per module that owns codes. */\nexport const allMessages: ReadonlyArray<Readonly<Record<string, unknown>>> = [\n coreMessages,\n redactionMessages,\n optionMessages,\n featureMessages,\n boundaryMessages,\n pipelineMessages,\n tableMessages,\n ssrMessages,\n asyncMessages,\n fetchMessages,\n rowKeyMessages,\n schemaMessages,\n dataCheckMessages,\n versioningMessages,\n columnFiltersMessages,\n validityMessages,\n searchMessages,\n sortingMessages,\n paginationMessages,\n envMessages,\n // The detail sentences production keeps as keys (`fallback: 'cells-undefined'`).\n proseMessages,\n]\n\ninstallMessages(...allMessages)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,mBAA+B;AAC/B,qBAAgC;AAChC,IAAAA,gBAA6B;AAC7B,mBAA8B;AAC9B,oBAAkC;AAClC,IAAAA,gBAAgC;AAChC,IAAAA,gBAAsC;AACtC,IAAAA,gBAAmC;AACnC,IAAAA,gBAA+B;AAC/B,IAAAA,gBAAgC;AAChC,IAAAA,gBAAiC;AACjC,8BAAkC;AAClC,2BAA+B;AAC/B,0BAA+B;AAC/B,IAAAA,gBAAiC;AACjC,IAAAA,iBAAiC;AACjC,uBAA4B;AAC5B,IAAAA,iBAA8B;AAC9B,yBAA8B;AAC9B,IAAAA,iBAA8B;AAC9B,uBAA4B;AAC5B,IAAAA,iBAAmC;AAG5B,IAAM,cAAgE;AAAA,EAC3E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AACF;AAAA,IAEA,gCAAgB,GAAG,WAAW;","names":["import_codes"]}
1
+ {"version":3,"sources":["../../src/messages/index.ts"],"sourcesContent":["/**\n * `@datakable/core/messages` (`datakable/messages`): full diagnostic text in production (§8.2).\n *\n * Production builds strip `problem` / `impact` / `fix` and keep `code`, `where`, `context` and a\n * docs URL. `import '@datakable/core/messages'` once (e.g. in the app entry) installs the text of\n * every code a production build can emit. Development builds already have it. This module is the\n * package's only side effect (`sideEffects` in package.json).\n */\nimport { optionMessages } from '../catalog/codes'\nimport { installMessages } from '../diagnostics/catalog'\nimport { coreMessages } from '../diagnostics/codes'\nimport { proseMessages } from '../diagnostics/prose'\nimport { redactionMessages } from '../diagnostics/redact'\nimport { featureMessages } from '../feature/codes'\nimport { columnFiltersMessages } from '../features/column-filters/codes'\nimport { paginationMessages } from '../features/pagination/codes'\nimport { searchMessages } from '../features/search/codes'\nimport { sortingMessages } from '../features/sorting/codes'\nimport { validityMessages } from '../features/validity/codes'\nimport { dataCheckMessages } from '../ingest/data-check-codes'\nimport { rowKeyMessages } from '../ingest/row-key-codes'\nimport { schemaMessages } from '../ingest/schema-codes'\nimport { boundaryMessages } from '../intercept/codes'\nimport { pipelineMessages } from '../pipeline/codes'\nimport { envMessages } from '../pipeline/env-codes'\nimport { asyncMessages } from '../source/codes'\nimport { fetchMessages } from '../source/fetch-codes'\nimport { tableMessages } from '../table/codes'\nimport { ssrMessages } from '../table/ssr-codes'\nimport { stateMessages } from '../table/state-codes'\nimport { versioningMessages } from '../versioning/codes'\n\n/** Every message object core ships, one per module that owns codes. */\nexport const allMessages: ReadonlyArray<Readonly<Record<string, unknown>>> = [\n coreMessages,\n redactionMessages,\n optionMessages,\n featureMessages,\n boundaryMessages,\n pipelineMessages,\n tableMessages,\n ssrMessages,\n stateMessages,\n asyncMessages,\n fetchMessages,\n rowKeyMessages,\n schemaMessages,\n dataCheckMessages,\n versioningMessages,\n columnFiltersMessages,\n validityMessages,\n searchMessages,\n sortingMessages,\n paginationMessages,\n envMessages,\n // The detail sentences production keeps as keys (`fallback: 'cells-undefined'`).\n proseMessages,\n]\n\ninstallMessages(...allMessages)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,mBAA+B;AAC/B,qBAAgC;AAChC,IAAAA,gBAA6B;AAC7B,mBAA8B;AAC9B,oBAAkC;AAClC,IAAAA,gBAAgC;AAChC,IAAAA,gBAAsC;AACtC,IAAAA,gBAAmC;AACnC,IAAAA,gBAA+B;AAC/B,IAAAA,gBAAgC;AAChC,IAAAA,gBAAiC;AACjC,8BAAkC;AAClC,2BAA+B;AAC/B,0BAA+B;AAC/B,IAAAA,gBAAiC;AACjC,IAAAA,iBAAiC;AACjC,uBAA4B;AAC5B,IAAAA,iBAA8B;AAC9B,yBAA8B;AAC9B,IAAAA,iBAA8B;AAC9B,uBAA4B;AAC5B,yBAA8B;AAC9B,IAAAA,iBAAmC;AAG5B,IAAM,cAAgE;AAAA,EAC3E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AACF;AAAA,IAEA,gCAAgB,GAAG,WAAW;","names":["import_codes"]}
@@ -20,6 +20,7 @@ import { asyncMessages } from "../source/codes.js";
20
20
  import { fetchMessages } from "../source/fetch-codes.js";
21
21
  import { tableMessages } from "../table/codes.js";
22
22
  import { ssrMessages } from "../table/ssr-codes.js";
23
+ import { stateMessages } from "../table/state-codes.js";
23
24
  import { versioningMessages } from "../versioning/codes.js";
24
25
  var allMessages = [
25
26
  coreMessages,
@@ -30,6 +31,7 @@ var allMessages = [
30
31
  pipelineMessages,
31
32
  tableMessages,
32
33
  ssrMessages,
34
+ stateMessages,
33
35
  asyncMessages,
34
36
  fetchMessages,
35
37
  rowKeyMessages,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/messages/index.ts"],"sourcesContent":["/**\n * `@datakable/core/messages` (`datakable/messages`): full diagnostic text in production (§8.2).\n *\n * Production builds strip `problem` / `impact` / `fix` and keep `code`, `where`, `context` and a\n * docs URL. `import '@datakable/core/messages'` once (e.g. in the app entry) installs the text of\n * every code a production build can emit. Development builds already have it. This module is the\n * package's only side effect (`sideEffects` in package.json).\n */\nimport { optionMessages } from '../catalog/codes'\nimport { installMessages } from '../diagnostics/catalog'\nimport { coreMessages } from '../diagnostics/codes'\nimport { proseMessages } from '../diagnostics/prose'\nimport { redactionMessages } from '../diagnostics/redact'\nimport { featureMessages } from '../feature/codes'\nimport { columnFiltersMessages } from '../features/column-filters/codes'\nimport { paginationMessages } from '../features/pagination/codes'\nimport { searchMessages } from '../features/search/codes'\nimport { sortingMessages } from '../features/sorting/codes'\nimport { validityMessages } from '../features/validity/codes'\nimport { dataCheckMessages } from '../ingest/data-check-codes'\nimport { rowKeyMessages } from '../ingest/row-key-codes'\nimport { schemaMessages } from '../ingest/schema-codes'\nimport { boundaryMessages } from '../intercept/codes'\nimport { pipelineMessages } from '../pipeline/codes'\nimport { envMessages } from '../pipeline/env-codes'\nimport { asyncMessages } from '../source/codes'\nimport { fetchMessages } from '../source/fetch-codes'\nimport { tableMessages } from '../table/codes'\nimport { ssrMessages } from '../table/ssr-codes'\nimport { versioningMessages } from '../versioning/codes'\n\n/** Every message object core ships, one per module that owns codes. */\nexport const allMessages: ReadonlyArray<Readonly<Record<string, unknown>>> = [\n coreMessages,\n redactionMessages,\n optionMessages,\n featureMessages,\n boundaryMessages,\n pipelineMessages,\n tableMessages,\n ssrMessages,\n asyncMessages,\n fetchMessages,\n rowKeyMessages,\n schemaMessages,\n dataCheckMessages,\n versioningMessages,\n columnFiltersMessages,\n validityMessages,\n searchMessages,\n sortingMessages,\n paginationMessages,\n envMessages,\n // The detail sentences production keeps as keys (`fallback: 'cells-undefined'`).\n proseMessages,\n]\n\ninstallMessages(...allMessages)\n"],"mappings":";AAQA,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAG5B,IAAM,cAAgE;AAAA,EAC3E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AACF;AAEA,gBAAgB,GAAG,WAAW;","names":[]}
1
+ {"version":3,"sources":["../../src/messages/index.ts"],"sourcesContent":["/**\n * `@datakable/core/messages` (`datakable/messages`): full diagnostic text in production (§8.2).\n *\n * Production builds strip `problem` / `impact` / `fix` and keep `code`, `where`, `context` and a\n * docs URL. `import '@datakable/core/messages'` once (e.g. in the app entry) installs the text of\n * every code a production build can emit. Development builds already have it. This module is the\n * package's only side effect (`sideEffects` in package.json).\n */\nimport { optionMessages } from '../catalog/codes'\nimport { installMessages } from '../diagnostics/catalog'\nimport { coreMessages } from '../diagnostics/codes'\nimport { proseMessages } from '../diagnostics/prose'\nimport { redactionMessages } from '../diagnostics/redact'\nimport { featureMessages } from '../feature/codes'\nimport { columnFiltersMessages } from '../features/column-filters/codes'\nimport { paginationMessages } from '../features/pagination/codes'\nimport { searchMessages } from '../features/search/codes'\nimport { sortingMessages } from '../features/sorting/codes'\nimport { validityMessages } from '../features/validity/codes'\nimport { dataCheckMessages } from '../ingest/data-check-codes'\nimport { rowKeyMessages } from '../ingest/row-key-codes'\nimport { schemaMessages } from '../ingest/schema-codes'\nimport { boundaryMessages } from '../intercept/codes'\nimport { pipelineMessages } from '../pipeline/codes'\nimport { envMessages } from '../pipeline/env-codes'\nimport { asyncMessages } from '../source/codes'\nimport { fetchMessages } from '../source/fetch-codes'\nimport { tableMessages } from '../table/codes'\nimport { ssrMessages } from '../table/ssr-codes'\nimport { stateMessages } from '../table/state-codes'\nimport { versioningMessages } from '../versioning/codes'\n\n/** Every message object core ships, one per module that owns codes. */\nexport const allMessages: ReadonlyArray<Readonly<Record<string, unknown>>> = [\n coreMessages,\n redactionMessages,\n optionMessages,\n featureMessages,\n boundaryMessages,\n pipelineMessages,\n tableMessages,\n ssrMessages,\n stateMessages,\n asyncMessages,\n fetchMessages,\n rowKeyMessages,\n schemaMessages,\n dataCheckMessages,\n versioningMessages,\n columnFiltersMessages,\n validityMessages,\n searchMessages,\n sortingMessages,\n paginationMessages,\n envMessages,\n // The detail sentences production keeps as keys (`fallback: 'cells-undefined'`).\n proseMessages,\n]\n\ninstallMessages(...allMessages)\n"],"mappings":";AAQA,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AAG5B,IAAM,cAAgE;AAAA,EAC3E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AACF;AAEA,gBAAgB,GAAG,WAAW;","names":[]}
@@ -1,5 +1,5 @@
1
- export { ai as paginationDiagnostics } from './codes-AX8XkMNY.cjs';
2
- import { F as Feature, b as FixedTypes } from './explain-pKAnnxEW.cjs';
1
+ export { ai as paginationDiagnostics } from './codes-4sYQv_7J.cjs';
2
+ import { F as Feature, b as FixedTypes } from './explain-DmwN_RG9.cjs';
3
3
  import { a as DataMode } from './mode-DFV8ryXo.cjs';
4
4
 
5
5
  interface PaginationState {
@@ -1,5 +1,5 @@
1
- export { ai as paginationDiagnostics } from './codes-AX8XkMNY.js';
2
- import { F as Feature, b as FixedTypes } from './explain-BVE3ln3G.js';
1
+ export { ai as paginationDiagnostics } from './codes-4sYQv_7J.js';
2
+ import { F as Feature, b as FixedTypes } from './explain-Dr3SmMNY.js';
3
3
  import { a as DataMode } from './mode-DFV8ryXo.js';
4
4
 
5
5
  interface PaginationState {
package/dist/schema.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as StandardSchemaV1, e as TableSchema } from './codes-AX8XkMNY.cjs';
2
- export { q as DatakableSchemaError, h as InvalidRow, I as InvalidRowsMode, C as SCHEMA_INGEST, H as SchemaIssueColumn, J as SchemaOutcome, ad as isStandardSchema, am as schemaDiagnostics } from './codes-AX8XkMNY.cjs';
1
+ import { S as StandardSchemaV1, e as TableSchema } from './codes-4sYQv_7J.cjs';
2
+ export { q as DatakableSchemaError, h as InvalidRow, I as InvalidRowsMode, C as SCHEMA_INGEST, H as SchemaIssueColumn, J as SchemaOutcome, ad as isStandardSchema, am as schemaDiagnostics } from './codes-4sYQv_7J.cjs';
3
3
 
4
4
  /**
5
5
  * Opts a Standard Schema v1 (zod, valibot, arktype, …) into table validation (§5.1):
package/dist/schema.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as StandardSchemaV1, e as TableSchema } from './codes-AX8XkMNY.js';
2
- export { q as DatakableSchemaError, h as InvalidRow, I as InvalidRowsMode, C as SCHEMA_INGEST, H as SchemaIssueColumn, J as SchemaOutcome, ad as isStandardSchema, am as schemaDiagnostics } from './codes-AX8XkMNY.js';
1
+ import { S as StandardSchemaV1, e as TableSchema } from './codes-4sYQv_7J.js';
2
+ export { q as DatakableSchemaError, h as InvalidRow, I as InvalidRowsMode, C as SCHEMA_INGEST, H as SchemaIssueColumn, J as SchemaOutcome, ad as isStandardSchema, am as schemaDiagnostics } from './codes-4sYQv_7J.js';
3
3
 
4
4
  /**
5
5
  * Opts a Standard Schema v1 (zod, valibot, arktype, …) into table validation (§5.1):
@@ -1,5 +1,5 @@
1
- import { i as RowKey } from './codes-AX8XkMNY.cjs';
2
- import { R as RowModelContext, c as FeatureContext } from './explain-pKAnnxEW.cjs';
1
+ import { i as RowKey } from './codes-4sYQv_7J.cjs';
2
+ import { R as RowModelContext, c as FeatureContext } from './explain-DmwN_RG9.cjs';
3
3
 
4
4
  /** What `setSearch` / `flushSearch` resolve to; they never reject. */
5
5
  interface SearchOutcome {
@@ -1,5 +1,5 @@
1
- import { i as RowKey } from './codes-AX8XkMNY.js';
2
- import { R as RowModelContext, c as FeatureContext } from './explain-BVE3ln3G.js';
1
+ import { i as RowKey } from './codes-4sYQv_7J.js';
2
+ import { R as RowModelContext, c as FeatureContext } from './explain-Dr3SmMNY.js';
3
3
 
4
4
  /** What `setSearch` / `flushSearch` resolve to; they never reject. */
5
5
  interface SearchOutcome {
@@ -1,3 +1,3 @@
1
- export { ap as searchDiagnostics } from './codes-AX8XkMNY.cjs';
2
- export { A as AsyncSearchFn, a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, e as SearchResult, w as withSearchFn } from './search-async-entry-ByMJbHjc.cjs';
3
- import './explain-pKAnnxEW.cjs';
1
+ export { ap as searchDiagnostics } from './codes-4sYQv_7J.cjs';
2
+ export { A as AsyncSearchFn, a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, e as SearchResult, w as withSearchFn } from './search-async-entry-BiemO3JT.cjs';
3
+ import './explain-DmwN_RG9.cjs';
@@ -1,3 +1,3 @@
1
- export { ap as searchDiagnostics } from './codes-AX8XkMNY.js';
2
- export { A as AsyncSearchFn, a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, e as SearchResult, w as withSearchFn } from './search-async-entry-CFQODE08.js';
3
- import './explain-BVE3ln3G.js';
1
+ export { ap as searchDiagnostics } from './codes-4sYQv_7J.js';
2
+ export { A as AsyncSearchFn, a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, e as SearchResult, w as withSearchFn } from './search-async-entry-GRj0E06n.js';
3
+ import './explain-Dr3SmMNY.js';
package/dist/search.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- export { ap as searchDiagnostics } from './codes-AX8XkMNY.cjs';
2
- import { d as AnyRow, F as Feature, b as FixedTypes } from './explain-pKAnnxEW.cjs';
1
+ export { ap as searchDiagnostics } from './codes-4sYQv_7J.cjs';
2
+ import { d as AnyRow, F as Feature, b as FixedTypes } from './explain-DmwN_RG9.cjs';
3
3
  import { a as DataMode } from './mode-DFV8ryXo.cjs';
4
- import { d as SearchOutcome, A as AsyncSearchFn, S as SearchState } from './search-async-entry-ByMJbHjc.cjs';
5
- export { a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, e as SearchResult, f as SearchStatus, w as withSearchFn } from './search-async-entry-ByMJbHjc.cjs';
4
+ import { d as SearchOutcome, A as AsyncSearchFn, S as SearchState } from './search-async-entry-BiemO3JT.cjs';
5
+ export { a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, e as SearchResult, f as SearchStatus, w as withSearchFn } from './search-async-entry-BiemO3JT.cjs';
6
6
 
7
7
  interface SearchApi {
8
8
  /** Sets `input` (and `query`, with the client's immediate typing strategy). */
package/dist/search.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { ap as searchDiagnostics } from './codes-AX8XkMNY.js';
2
- import { d as AnyRow, F as Feature, b as FixedTypes } from './explain-BVE3ln3G.js';
1
+ export { ap as searchDiagnostics } from './codes-4sYQv_7J.js';
2
+ import { d as AnyRow, F as Feature, b as FixedTypes } from './explain-Dr3SmMNY.js';
3
3
  import { a as DataMode } from './mode-DFV8ryXo.js';
4
- import { d as SearchOutcome, A as AsyncSearchFn, S as SearchState } from './search-async-entry-CFQODE08.js';
5
- export { a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, e as SearchResult, f as SearchStatus, w as withSearchFn } from './search-async-entry-CFQODE08.js';
4
+ import { d as SearchOutcome, A as AsyncSearchFn, S as SearchState } from './search-async-entry-GRj0E06n.js';
5
+ export { a as SEARCH_ENGINE, b as SearchFn, c as SearchFnContext, e as SearchResult, f as SearchStatus, w as withSearchFn } from './search-async-entry-GRj0E06n.js';
6
6
 
7
7
  interface SearchApi {
8
8
  /** Sets `input` (and `query`, with the client's immediate typing strategy). */
package/dist/server.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as Interceptor, D as Fetcher, i as ServerFetcher } from './explain-pKAnnxEW.cjs';
2
- export { x as FetchOutcome, y as FetchParams, z as FetchResult, ab as SERVER_SOURCE } from './explain-pKAnnxEW.cjs';
3
- export { B as BadResponse, N as asyncDiagnostics, a4 as fetchDiagnostics } from './codes-AX8XkMNY.cjs';
1
+ import { a as Interceptor, D as Fetcher, i as ServerFetcher } from './explain-DmwN_RG9.cjs';
2
+ export { x as FetchOutcome, y as FetchParams, z as FetchResult, ab as SERVER_SOURCE } from './explain-DmwN_RG9.cjs';
3
+ export { B as BadResponse, N as asyncDiagnostics, a4 as fetchDiagnostics } from './codes-4sYQv_7J.cjs';
4
4
 
5
5
  /** Spec §7.1: a request that has not settled after 30 s is aborted (`DK_ASYNC_TIMEOUT`). */
6
6
  declare const DEFAULT_ASYNC_TIMEOUT = 30000;
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as Interceptor, D as Fetcher, i as ServerFetcher } from './explain-BVE3ln3G.js';
2
- export { x as FetchOutcome, y as FetchParams, z as FetchResult, ab as SERVER_SOURCE } from './explain-BVE3ln3G.js';
3
- export { B as BadResponse, N as asyncDiagnostics, a4 as fetchDiagnostics } from './codes-AX8XkMNY.js';
1
+ import { a as Interceptor, D as Fetcher, i as ServerFetcher } from './explain-Dr3SmMNY.js';
2
+ export { x as FetchOutcome, y as FetchParams, z as FetchResult, ab as SERVER_SOURCE } from './explain-Dr3SmMNY.js';
3
+ export { B as BadResponse, N as asyncDiagnostics, a4 as fetchDiagnostics } from './codes-4sYQv_7J.js';
4
4
 
5
5
  /** Spec §7.1: a request that has not settled after 30 s is aborted (`DK_ASYNC_TIMEOUT`). */
6
6
  declare const DEFAULT_ASYNC_TIMEOUT = 30000;
@@ -1,5 +1,5 @@
1
- export { W as comparatorDiagnostics, ar as sortingDiagnostics } from './codes-AX8XkMNY.cjs';
2
- import { ad as SortAlgorithm, a1 as Path, e as FeatureTypes, F as Feature } from './explain-pKAnnxEW.cjs';
1
+ export { W as comparatorDiagnostics, ar as sortingDiagnostics } from './codes-4sYQv_7J.cjs';
2
+ import { ad as SortAlgorithm, a1 as Path, e as FeatureTypes, F as Feature } from './explain-DmwN_RG9.cjs';
3
3
  import { a as DataMode } from './mode-DFV8ryXo.cjs';
4
4
 
5
5
  /** The rank of `v` in {@link RANK}. */