Add Chart Builder: no-JSON Vega-Lite composer from a dataset (M4)

This commit is contained in:
2026-06-05 23:46:21 +03:00
parent 693f5d7073
commit c11afc273d
16 changed files with 1856 additions and 26 deletions
+11 -2
View File
@@ -14,6 +14,13 @@
/** Current schema version for a Snippet record (read-time migration target). */
export const CURRENT_SNIPPET_VERSION = 1;
/**
* The Vega-Lite schema URL stamped into generated specs (`$schema`). Shared so the
* sample template and the Chart Builder agree on one version; the Monaco schema
* service pins the same URI independently (infrastructure/monaco-schema.ts).
*/
export const VEGA_LITE_SCHEMA_URL = 'https://vega.github.io/schema/vega-lite/v6.json';
export interface Snippet {
/** Unique, stable identifier. */
id: string;
@@ -45,7 +52,7 @@ export interface Snippet {
* Inline data only — datasets arrive in M3.
*/
export const SAMPLE_SPEC = {
$schema: 'https://vega.github.io/schema/vega-lite/v6.json',
$schema: VEGA_LITE_SCHEMA_URL,
description: 'A simple bar chart.',
data: {
values: [
@@ -92,6 +99,8 @@ export interface CreateSnippetOptions {
now?: Date;
/** Id injection for deterministic tests; defaults to a random UUID. */
id?: string;
/** Seed the extensible metadata bag (e.g. Chart Builder provenance). */
meta?: Record<string, unknown>;
}
/**
@@ -113,7 +122,7 @@ export function createSnippet(options: CreateSnippetOptions = {}): Snippet {
comment: '',
tags: [],
datasetRefs: [],
meta: {},
meta: options.meta ?? {},
};
}