Profile per-column cardinality and extent; add data-aware chart warnings (M4, A3/A4)

This commit is contained in:
2026-06-07 23:03:17 +03:00
parent dcb7037a71
commit 39555322e4
13 changed files with 552 additions and 90 deletions
+8 -4
View File
@@ -18,7 +18,7 @@
*/
import type { DataFormat } from './format-detection';
import { profileData, type DatasetProfile } from './profile';
import { profileData, type ColumnStats, type DatasetProfile } from './profile';
import type { ColumnType } from './type-inference';
/** Current schema version for a Dataset record (read-time migration target). */
@@ -53,6 +53,8 @@ export interface Dataset {
columns: string[];
/** Per-column inferred type. */
columnTypes: Array<{ name: string; type: ColumnType }>;
/** Per-column cardinality + numeric range (empty for URL / non-tabular). */
columnStats: ColumnStats[];
/** Approximate payload size in bytes. */
size: number;
/** ISO timestamp — when first added. */
@@ -243,9 +245,10 @@ export interface CreateDatasetOptions {
/**
* Create a Dataset: stamps version/timestamps and runs `computeDatasetProfile` to
* fill the derived summary fields. `id` defaults to `Date.now()` (numeric;
* collision-prone for batch creation — see the DatasetStore.add TODO) and is
* injectable for tests.
* fill the derived summary fields. `id` defaults to `Date.now()` (numeric) and is
* injectable for tests; note that `DatasetStore` is the id authority and reassigns
* a collision-free id on insertion (`nextDatasetId`), so this default never reaches
* storage through the normal create paths.
*/
export function createDataset(options: CreateDatasetOptions): Dataset {
const now = options.now ?? new Date();
@@ -264,6 +267,7 @@ export function createDataset(options: CreateDatasetOptions): Dataset {
columnCount: profile.columnCount,
columns: profile.columns,
columnTypes: profile.columnTypes,
columnStats: profile.columnStats,
size: profile.size,
created: iso,
modified: iso,