@syncropel/projections 0.4.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/dist/expr.d.ts +53 -0
- package/dist/expr.d.ts.map +1 -0
- package/dist/expr.js +288 -0
- package/dist/expr.js.map +1 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +326 -30
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +21 -6
- package/dist/schema.js.map +1 -1
- package/dist/validators.d.ts +1 -1
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +153 -5
- package/dist/validators.js.map +1 -1
- package/package.json +1 -1
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA6EH;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,QAAQ;IACR,KAAK;IACL,MAAM;IACN,MAAM;IACN,SAAS;IACT,aAAa;IACb,kBAAkB;IAClB,MAAM;IACN,SAAS;IACT,MAAM;IACN,MAAM;IACN,WAAW;IACX,QAAQ;IACR,aAAa;IACb,aAAa;IACb,QAAQ;IACR,aAAa;IACb,aAAa;IACb,UAAU;IACV,6CAA6C;IAC7C,MAAM;IACN,YAAY;IACZ,OAAO;IACP,YAAY;IACZ,MAAM;IACN,4BAA4B;IAC5B,WAAW;IACX,uCAAuC;IACvC,OAAO;IACP,OAAO;IACP,QAAQ;IACR,UAAU;IACV,WAAW;IACX,OAAO;IACP,MAAM;IACN,WAAW;CACH,CAAC","sourcesContent":["/**\n * SRP v0.4 — TypeScript schema types.\n *\n * The Syncropel Rendering Protocol is a narrow JSON schema of block-level\n * primitives for declarative UI documents. See the spec and examples at\n * https://syncropel.com.\n *\n * v0.2 adds five interactive container + input nodes (tabs, data-table,\n * board, text-input, form). v0.3 adds the `segmented` node plus a\n * polished-data-grid increment to `data-table`. v0.4 adds eight\n * visualization + hierarchy nodes — `meter`, `gauge`, `avatar`,\n * `progress`, `sparkline`, `chart`, `tree`, `tag-input` — plus\n * `data-table` row selection and a two-line cell kind. Every addition is\n * additive + backwards-compatible: every v0.1/v0.2/v0.3 document remains\n * valid. See ADR-102, ADR-103, and ADR-104.\n */\n\n// ---------------------------------------------------------------------------\n// Document envelope\n// ---------------------------------------------------------------------------\n\n/**\n * An SRP v0.1 document — the top-level envelope a Tier-1 extension emits.\n */\nexport interface SRPDocument {\n /**\n * Protocol version. A `\"0.2\"` document may use the v0.2 node additions;\n * a `\"0.3\"` document may additionally use `segmented` + the data-grid\n * props; a `\"0.4\"` document may additionally use the visualization +\n * hierarchy nodes. The version is a capability advertisement, not an\n * enforcement boundary — node validity is decided by `NODE_TYPES`\n * membership.\n */\n srp: \"0.1\" | \"0.2\" | \"0.3\" | \"0.4\";\n meta?: SRPMeta;\n root: SRPNode;\n}\n\nexport interface SRPMeta {\n name?: string;\n version?: string;\n description?: string;\n publisher?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Discriminated union of all 33 node types\n// ---------------------------------------------------------------------------\n\nexport type SRPNode =\n // Containers (5)\n | ColumnNode\n | RowNode\n | GridNode\n | CardNode\n | DividerNode\n // Record rendering (3)\n | RecordLineNode\n | RecordLineListNode\n | ChipNode\n // Data display (4)\n | HeadingNode\n | TextNode\n | StatNode\n | KeyValueNode\n // Interactive (4)\n | ButtonNode\n | IconButtonNode\n | CopyButtonNode\n | SelectNode\n // Feedback (3)\n | EmptyStateNode\n | ErrorStateNode\n | SkeletonNode\n // Interactive containers + inputs — SRP v0.2 (5)\n | TabsNode\n | DataTableNode\n | BoardNode\n | TextInputNode\n | FormNode\n // Choice control — SRP v0.3 (1)\n | SegmentedNode\n // Visualization + hierarchy — SRP v0.4 (8)\n | MeterNode\n | GaugeNode\n | AvatarNode\n | ProgressNode\n | SparklineNode\n | ChartNode\n | TreeNode\n | TagInputNode;\n\n/**\n * The 33 canonical node-type discriminator strings (19 v0.1 + 5 v0.2 +\n * 1 v0.3 + 8 v0.4).\n */\nexport const NODE_TYPES = [\n \"column\",\n \"row\",\n \"grid\",\n \"card\",\n \"divider\",\n \"record-line\",\n \"record-line-list\",\n \"chip\",\n \"heading\",\n \"text\",\n \"stat\",\n \"key-value\",\n \"button\",\n \"icon-button\",\n \"copy-button\",\n \"select\",\n \"empty-state\",\n \"error-state\",\n \"skeleton\",\n // SRP v0.2 — interactive containers + inputs\n \"tabs\",\n \"data-table\",\n \"board\",\n \"text-input\",\n \"form\",\n // SRP v0.3 — choice control\n \"segmented\",\n // SRP v0.4 — visualization + hierarchy\n \"meter\",\n \"gauge\",\n \"avatar\",\n \"progress\",\n \"sparkline\",\n \"chart\",\n \"tree\",\n \"tag-input\",\n] as const;\n\nexport type NodeType = (typeof NODE_TYPES)[number];\n\n// ---------------------------------------------------------------------------\n// Fields every node may carry\n// ---------------------------------------------------------------------------\n\ninterface NodeBase {\n when?: string;\n bind?: Record<string, unknown>;\n actions?: Record<string, ActionDesc>;\n}\n\n// ---------------------------------------------------------------------------\n// Token unions (mirror @syncropel/react token scales)\n// ---------------------------------------------------------------------------\n\nexport type Gap = \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type Padding = \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\";\nexport type DividerSpacing = \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\";\nexport type Cols = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;\n\nexport type ColumnAlign = \"start\" | \"center\" | \"end\" | \"stretch\";\nexport type RowAlign = \"start\" | \"center\" | \"end\" | \"stretch\" | \"baseline\";\nexport type Justify =\n | \"start\"\n | \"center\"\n | \"end\"\n | \"between\"\n | \"around\"\n | \"evenly\";\n\nexport type RecordLineVariant =\n | \"feed\"\n | \"compact\"\n | \"detail\"\n | \"search\"\n | \"thread\";\n\nexport type ChipTone = \"default\" | \"info\" | \"warn\" | \"error\";\n\nexport type TextSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\nexport type TextWeight = \"normal\" | \"medium\" | \"semibold\";\nexport type TextTone =\n | \"primary\"\n | \"secondary\"\n | \"muted\"\n | \"success\"\n | \"warning\"\n | \"danger\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"danger\";\nexport type ButtonSize = \"xs\" | \"sm\" | \"md\";\n\nexport type SkeletonShape = \"rect\" | \"circle\" | \"text\";\n\n// --- SRP v0.2 tokens ---\nexport type TableColumnAlign = \"start\" | \"end\";\nexport type DataTableVariant = \"default\" | \"compact\";\nexport type TextInputKind = \"text\" | \"search\";\n/**\n * How a `data-table` column renders its cell value. `text` (default) is a\n * plain string; `chip` renders the value as a compact metadata chip;\n * `lines` (SRP v0.4) renders a two-line cell — the value at `key` as the\n * primary line and the value at the column's `subKey` as a muted subtitle.\n */\nexport type TableCellKind = \"text\" | \"chip\" | \"lines\";\n\n// --- SRP v0.3 tokens ---\n\n/**\n * A row accent tone — `data-table` `rowTone` paints a left-border (and a\n * subtle tint) keyed off a column value. Wider than `ChipTone`: it adds\n * `accent` and `success` so a row can read as \"in progress\" / \"done\".\n */\nexport type RowTone =\n | \"default\"\n | \"accent\"\n | \"success\"\n | \"warn\"\n | \"error\"\n | \"info\";\n\n/** Sort direction for a `data-table` column. */\nexport type SortDirection = \"asc\" | \"desc\";\n\n/** Which side of the row a `data-table` `rowActions` cell sits on. */\nexport type RowActionPosition = \"leading\" | \"trailing\";\n\n/**\n * How a `segmented` control presents. `solid` (default) is a light pill\n * group; `underline` is a borderless tab strip (active option underlined).\n * Added in SRP v0.3.1.\n */\nexport type SegmentedVariant = \"solid\" | \"underline\";\n\n// --- SRP v0.4 tokens ---\n\n/**\n * A visualization tone — shared by `meter`, `gauge`, `progress`,\n * `sparkline`, and `chart`. Drives the fill / stroke colour. Added SRP v0.4.\n */\nexport type VizTone =\n | \"neutral\"\n | \"accent\"\n | \"success\"\n | \"warn\"\n | \"error\"\n | \"info\";\n\n/** A visualization size step — shared by the SRP v0.4 viz nodes. */\nexport type VizSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\n/** How a `meter` renders its fill — one bar, or a row of discrete cells. */\nexport type MeterVariant = \"continuous\" | \"segmented\";\n\n/** How a `sparkline` renders its series. */\nexport type SparklineVariant = \"line\" | \"bar\";\n\n/** The plot kind a `chart` draws. */\nexport type ChartKind = \"line\" | \"area\" | \"bar\" | \"pie\";\n\n/**\n * Glyph kinds — the closed enumeration of semantic symbols the palette renders.\n * Covers act types, domain objects, thread states, and the AITL marker.\n */\nexport type GlyphKind =\n // Act types (coordination)\n | \"INTEND\"\n | \"DO\"\n | \"KNOW\"\n | \"LEARN\"\n // Act types (effects)\n | \"GET\"\n | \"PUT\"\n | \"CALL\"\n | \"MAP\"\n // AITL marker\n | \"AITL\"\n // Domain objects\n | \"thread\"\n | \"fork\"\n | \"record-parent\"\n | \"namespace\"\n | \"actor\"\n | \"file\"\n | \"pattern\"\n | \"page\"\n | \"view\"\n // Thread states\n | \"state-open\"\n | \"state-active\"\n | \"state-converged\"\n | \"state-closed\"\n | \"state-abandoned\";\n\n// ---------------------------------------------------------------------------\n// Actions + queries\n// ---------------------------------------------------------------------------\n\nexport interface ActionDesc {\n intent: string;\n payload?: Record<string, unknown>;\n}\n\n/**\n * VQL (Value Query Language) — the query shape a Syncropel server resolves\n * against its record store. Used by `record-line-list` nodes that bind to\n * a live query rather than a static list of record ids.\n *\n * The shape is deliberately open (index signature) — additional fields\n * are protocol extensions the server understands.\n */\nexport interface VQLQuery {\n act?: string;\n actor?: string;\n thread?: string;\n kind?: string;\n since?: number;\n limit?: number;\n [k: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Container node definitions (5)\n// ---------------------------------------------------------------------------\n\nexport interface ColumnNode extends NodeBase {\n type: \"column\";\n props?: { gap?: Gap; align?: ColumnAlign; justify?: Justify };\n children?: SRPNode[];\n}\n\nexport interface RowNode extends NodeBase {\n type: \"row\";\n props?: {\n gap?: Gap;\n align?: RowAlign;\n justify?: Justify;\n wrap?: boolean;\n };\n children?: SRPNode[];\n}\n\nexport interface GridNode extends NodeBase {\n type: \"grid\";\n props: { cols: Cols; gap?: Gap; rowGap?: Gap; colGap?: Gap };\n children?: SRPNode[];\n}\n\nexport interface CardNode extends NodeBase {\n type: \"card\";\n props?: { padding?: Padding; interactive?: boolean };\n children?: SRPNode[];\n}\n\nexport interface DividerNode extends NodeBase {\n type: \"divider\";\n props?: { orientation?: \"horizontal\" | \"vertical\"; spacing?: DividerSpacing };\n}\n\n// ---------------------------------------------------------------------------\n// Record-rendering (3)\n// ---------------------------------------------------------------------------\n\nexport interface RecordLineNode extends NodeBase {\n type: \"record-line\";\n props: {\n variant: RecordLineVariant;\n /**\n * SRP v0.3 — an optional dotted body path (`body.priority`). When set,\n * the line renders a small chip carrying that field's value. Lets\n * `board` cards (which render through `record-line`) show a priority\n * or status chip.\n */\n chipField?: string;\n };\n bind: { record: string };\n}\n\nexport interface RecordLineListNode extends NodeBase {\n type: \"record-line-list\";\n props: { variant: RecordLineVariant; max?: number; empty?: string };\n bind: { query: VQLQuery } | { items: string[] };\n}\n\nexport interface ChipNode extends NodeBase {\n type: \"chip\";\n props: { label: string; tone?: ChipTone; glyph?: GlyphKind };\n}\n\n// ---------------------------------------------------------------------------\n// Data display (4)\n// ---------------------------------------------------------------------------\n\nexport interface HeadingNode extends NodeBase {\n type: \"heading\";\n props: { level: 1 | 2 | 3 | 4 | 5 | 6; text: string };\n}\n\nexport interface TextNode extends NodeBase {\n type: \"text\";\n props: {\n text: string;\n size?: TextSize;\n weight?: TextWeight;\n tone?: TextTone;\n inline?: boolean;\n };\n}\n\nexport interface StatNode extends NodeBase {\n type: \"stat\";\n props: {\n label: string;\n value: string | number;\n delta?: string | number;\n deltaTone?: \"auto\" | \"neutral\";\n };\n}\n\nexport interface KeyValueNode extends NodeBase {\n type: \"key-value\";\n props: { label: string; value: string };\n}\n\n// ---------------------------------------------------------------------------\n// Interactive (4)\n// ---------------------------------------------------------------------------\n\nexport interface ButtonNode extends NodeBase {\n type: \"button\";\n props: {\n label: string;\n variant?: ButtonVariant;\n size?: ButtonSize;\n disabled?: boolean;\n loading?: boolean;\n };\n actions?: { onClick?: ActionDesc };\n}\n\nexport interface IconButtonNode extends NodeBase {\n type: \"icon-button\";\n props: {\n glyph: GlyphKind;\n ariaLabel: string;\n variant?: ButtonVariant;\n size?: ButtonSize;\n disabled?: boolean;\n loading?: boolean;\n };\n actions?: { onClick?: ActionDesc };\n}\n\nexport interface CopyButtonNode extends NodeBase {\n type: \"copy-button\";\n props: { value: string; label?: string };\n}\n\nexport interface SelectNode extends NodeBase {\n type: \"select\";\n props: { options: { label: string; value: string }[] };\n bind: { value: string };\n actions?: { onChange?: ActionDesc };\n}\n\n// ---------------------------------------------------------------------------\n// Feedback (3)\n// ---------------------------------------------------------------------------\n\nexport interface EmptyStateNode extends NodeBase {\n type: \"empty-state\";\n props: {\n message: string;\n action?: { label: string; intent: string };\n };\n}\n\nexport interface ErrorStateNode extends NodeBase {\n type: \"error-state\";\n props: {\n message: string;\n retry?: { intent: string };\n };\n}\n\nexport interface SkeletonNode extends NodeBase {\n type: \"skeleton\";\n props?: {\n shape?: SkeletonShape;\n width?: string | number | \"full\";\n height?: string | number;\n };\n}\n\n// ---------------------------------------------------------------------------\n// SRP v0.2 — interactive containers + inputs (5)\n//\n// All five reuse the v0.1 contract: `props` is static config, `bind` is\n// host-supplied state, `actions` declares intents the host dispatches. SRP\n// owns layout + shape; the host owns state + behaviour. See ADR-102 and the\n// SRP v0.2 design spec.\n// ---------------------------------------------------------------------------\n\n/**\n * A container whose children are panels; one panel shows at a time. The host\n * supplies the active tab id via `bind.active` and renders the panel whose\n * index matches it in `props.tabs`.\n */\nexport interface TabsNode extends NodeBase {\n type: \"tabs\";\n props: { tabs: { id: string; label: string; glyph?: GlyphKind }[] };\n bind: { active: string };\n actions?: { onTabChange?: ActionDesc };\n /** Panels, parallel to `props.tabs` by index. */\n children?: SRPNode[];\n}\n\n/** A single `data-table` column definition. */\nexport interface DataTableColumnDef {\n /** Dotted path into each row (`body.goal`, `actor`). */\n key: string;\n label: string;\n align?: TableColumnAlign;\n width?: string;\n /** How the cell value renders. Default `text`. */\n kind?: TableCellKind;\n /**\n * SRP v0.3 — for a `kind: \"chip\"` column, a map from cell value to chip\n * tone. A value with no entry renders a `default`-tone chip.\n */\n tones?: Record<string, ChipTone>;\n /**\n * SRP v0.3 — an explicit value order for sorting this column. When the\n * column is the sort key, rows order by each value's index in this list\n * (so `critical` < `high` < `medium` < `low`, not alphabetical). Values\n * absent from the list sort after the listed ones.\n */\n order?: string[];\n /**\n * SRP v0.4 — for a `kind: \"lines\"` column, the dotted path whose value\n * renders as the muted second line beneath the `key` value.\n */\n subKey?: string;\n}\n\n/** SRP v0.3 — a `data-table` sort descriptor. */\nexport interface TableSort {\n key: string;\n direction: SortDirection;\n}\n\n/**\n * SRP v0.3 — a per-row action affordance on a `data-table`. Rendered as a\n * small button in a leading or trailing cell; a click dispatches `intent`\n * with the row merged into the payload as `row`.\n */\nexport interface TableRowAction {\n intent: string;\n /** A semantic glyph for an icon-only affordance. */\n glyph?: GlyphKind;\n /** A text label — used when no `glyph` is given (or as the aria-label). */\n label?: string;\n /** Which side of the row the action cell sits on. Default `leading`. */\n position?: RowActionPosition;\n}\n\n/**\n * SRP v0.3 — a `data-table` row accent. The row paints a left-border (and\n * a subtle tint) whose tone is looked up from `tones` by the value at\n * `key`. A value with no entry gets no accent.\n */\nexport interface TableRowTone {\n /** Dotted path into the row whose value selects the tone. */\n key: string;\n tones: Record<string, RowTone>;\n}\n\n/**\n * A columnar record list — richer than `record-line-list`: explicit columns,\n * alignment, optional sort. `column.key` is a dotted path into each row.\n *\n * SRP v0.3 adds the polished-data-grid props: column `tones` + `order`,\n * `defaultSort`, `rowActions`, and `rowTone`. SRP v0.4 adds `selectable`\n * (a leading checkbox column with multi-select) — all optional + additive.\n */\nexport interface DataTableNode extends NodeBase {\n type: \"data-table\";\n props: {\n columns: DataTableColumnDef[];\n variant?: DataTableVariant;\n sortable?: boolean;\n empty?: string;\n /** SRP v0.3 — the sort applied before any header interaction. */\n defaultSort?: TableSort;\n /** SRP v0.3 — per-row action affordances. */\n rowActions?: TableRowAction[];\n /** SRP v0.3 — a value-keyed row accent. */\n rowTone?: TableRowTone;\n /**\n * SRP v0.4 — render a leading checkbox column with a select-all\n * header. The table owns selection state and dispatches\n * `onSelectionChange` with the selected rows.\n */\n selectable?: boolean;\n };\n bind: { query: VQLQuery } | { rows: Record<string, unknown>[] };\n actions?: {\n onRowClick?: ActionDesc;\n onSort?: ActionDesc;\n /** SRP v0.4 — fired (with `rows`) when the selection changes. */\n onSelectionChange?: ActionDesc;\n };\n}\n\n/**\n * A kanban board — records bucketed into columns by the `props.groupBy` field.\n * A record lands in the column whose `id` equals its `groupBy` value; records\n * matching no column are dropped. `onCardMove` is advisory — a host MAY\n * support drag; a board without drag is read-only and still valid.\n */\nexport interface BoardNode extends NodeBase {\n type: \"board\";\n props: {\n columns: { id: string; label: string }[];\n groupBy: string;\n cardVariant?: RecordLineVariant;\n /**\n * SRP v0.3 — a dotted body path passed through to each card's\n * `record-line` as its `chipField`, so cards show a metadata chip\n * (e.g. `body.priority`).\n */\n cardChipField?: string;\n };\n bind: { query: VQLQuery };\n actions?: { onCardClick?: ActionDesc; onCardMove?: ActionDesc };\n}\n\n/**\n * An editable text field — the `select` of free text. The host owns\n * `bind.value` and re-renders on change (identical ownership model to\n * `select`).\n */\nexport interface TextInputNode extends NodeBase {\n type: \"text-input\";\n props?: {\n placeholder?: string;\n multiline?: boolean;\n inputKind?: TextInputKind;\n size?: TextSize;\n disabled?: boolean;\n };\n bind: { value: string };\n actions?: { onChange?: ActionDesc; onSubmit?: ActionDesc };\n}\n\n/**\n * A container that groups inputs and declares a submit intent. The host\n * collects child input values (by their `bind`) and dispatches `onSubmit`.\n */\nexport interface FormNode extends NodeBase {\n type: \"form\";\n props?: { submitLabel?: string; busy?: boolean };\n actions?: { onSubmit?: ActionDesc };\n children?: SRPNode[];\n}\n\n// ---------------------------------------------------------------------------\n// SRP v0.3 — choice control (1)\n//\n// `segmented` is the third stateful input (alongside `select` + `text-input`)\n// and reuses the same ownership model: `bind.value` is host-supplied, a\n// pick dispatches `onChange`. See ADR-103.\n// ---------------------------------------------------------------------------\n\n/** One option in a `segmented` control. */\nexport interface SegmentedOption {\n value: string;\n label: string;\n /** An optional count/marker rendered as a small badge on the option. */\n badge?: string | number;\n}\n\n/**\n * A row of mutually-exclusive options — a filter/choice control. Distinct\n * from `tabs`: it has no panels, it is purely a bound value. The host owns\n * `bind.value`; picking an option dispatches `onChange` with the new value.\n */\nexport interface SegmentedNode extends NodeBase {\n type: \"segmented\";\n props: {\n options: SegmentedOption[];\n size?: ButtonSize;\n /** Presentation — `solid` (light pill group, default) or `underline`\n * (borderless tab strip). Added in SRP v0.3.1. */\n variant?: SegmentedVariant;\n };\n bind: { value: string };\n actions?: { onChange?: ActionDesc };\n}\n\n// ---------------------------------------------------------------------------\n// SRP v0.4 — visualization + hierarchy nodes (8)\n//\n// `meter`, `gauge`, `progress`, `sparkline`, `chart` are read-only data\n// displays — `props` carries the values, there is no `bind`. `avatar` is a\n// read-only identity token. `tree` + `tag-input` are interactive: they\n// reuse the v0.1 ownership model — `bind` is host state, `actions` declares\n// dispatched intents. Music-specific widgets (waveforms, transition tables)\n// are NOT in SRP — a renderer registers those as plug-in node types. See\n// ADR-104.\n// ---------------------------------------------------------------------------\n\n/**\n * A value→tone threshold for a `meter`. The meter's value selects the\n * highest threshold whose `at` it reaches; that tone recolours the fill.\n * List thresholds in ascending `at` order.\n */\nexport interface VizThreshold {\n at: number;\n tone: VizTone;\n}\n\n/**\n * A horizontal bar gauge — renders a `0..1` reading as a proportional\n * fill. `continuous` is a single bar; `segmented` is a row of discrete\n * cells. `thresholds` recolours the meter by value (energy low→high,\n * trust score, match confidence).\n */\nexport interface MeterNode extends NodeBase {\n type: \"meter\";\n props: {\n /** The reading, clamped to `0..1`. */\n value: number;\n tone?: VizTone;\n variant?: MeterVariant;\n /** Cell count when `variant: \"segmented\"`. Default 5. */\n segments?: number;\n /** Value-keyed recolouring; overrides `tone` for the matched band. */\n thresholds?: VizThreshold[];\n size?: VizSize;\n /** Optional caption rendered beside the bar. */\n label?: string;\n };\n}\n\n/** A coloured band on a `gauge` arc — e.g. a Dial zone. */\nexport interface GaugeZone {\n from: number;\n to: number;\n tone: VizTone;\n label?: string;\n}\n\n/**\n * A radial arc gauge — renders a `0..1` reading on a 270° arc. Doubles as\n * the Syncropel Dial (the `d ∈ [0,1]` control surface, F3): `zones` paints\n * the REPLAY / ADAPT / EXPLORE / CREATE bands.\n */\nexport interface GaugeNode extends NodeBase {\n type: \"gauge\";\n props: {\n /** The reading, clamped to `0..1`. */\n value: number;\n label?: string;\n tone?: VizTone;\n /** Coloured arc bands — drawn behind the value sweep. */\n zones?: GaugeZone[];\n size?: VizSize;\n /** Render the numeric value in the arc centre. Default true. */\n showValue?: boolean;\n /** How the centre value reads. Default `decimal`. */\n format?: \"percent\" | \"decimal\";\n };\n}\n\n/**\n * A compact identity token — an image (`src`), or initials derived from\n * `name`, or a semantic `glyph` fallback. Square, rounded.\n */\nexport interface AvatarNode extends NodeBase {\n type: \"avatar\";\n props: {\n /** Display name — the source of initials + the accessible label. */\n name: string;\n src?: string;\n glyph?: GlyphKind;\n size?: VizSize;\n };\n}\n\n/**\n * A progress bar. With `value` it fills proportionally (determinate);\n * with `indeterminate` it animates with no known extent. Distinct from\n * `meter`: `progress` reads as \"advancing toward done\", `meter` as a\n * static measurement.\n */\nexport interface ProgressNode extends NodeBase {\n type: \"progress\";\n props?: {\n /** The fraction complete, `0..1`. Omit when `indeterminate`. */\n value?: number;\n indeterminate?: boolean;\n tone?: VizTone;\n label?: string;\n /** Render the percentage as text. Default false. */\n showValue?: boolean;\n size?: VizSize;\n };\n}\n\n/**\n * A tiny inline chart — a bare series with no axes or legend, for\n * trend-at-a-glance (cost over time, dispatch throughput, energy shape).\n */\nexport interface SparklineNode extends NodeBase {\n type: \"sparkline\";\n props: {\n values: number[];\n variant?: SparklineVariant;\n tone?: VizTone;\n /** Width in px, or `\"full\"` to fill the container. Default 96. */\n width?: number | \"full\";\n /** Height in px. Default 24. */\n height?: number;\n };\n}\n\n/** One point in a `chart` series. */\nexport interface ChartPoint {\n x: string | number;\n y: number;\n}\n\n/** One series in a `chart` — or, for a `pie`, one ring of slices. */\nexport interface ChartSeries {\n label?: string;\n tone?: VizTone;\n points: ChartPoint[];\n}\n\n/**\n * A labelled chart — a `line` / `area` / `bar` plot, or a `pie` whose\n * slices are `series[0].points`. Richer than `sparkline`: axes, a legend,\n * a title.\n */\nexport interface ChartNode extends NodeBase {\n type: \"chart\";\n props: {\n kind: ChartKind;\n series: ChartSeries[];\n title?: string;\n /** Plot height in px. Default 200. */\n height?: number;\n /** Draw axes + gridlines (ignored for `pie`). Default true. */\n showAxis?: boolean;\n /** Draw a series legend. Default false. */\n showLegend?: boolean;\n };\n}\n\n/** One node in a `tree`. Recursive — `children` nest arbitrarily deep. */\nexport interface TreeItem {\n id: string;\n label: string;\n glyph?: GlyphKind;\n /** A small trailing count / marker. */\n badge?: string | number;\n children?: TreeItem[];\n}\n\n/**\n * A hierarchical, collapsible list — playlist folders, namespace trees,\n * thread forks, file browsers. The host owns `bind.selected` /\n * `bind.expanded`; a click dispatches `onSelect` / `onToggle`. When `bind`\n * is omitted the tree manages expand/collapse internally.\n */\nexport interface TreeNode extends NodeBase {\n type: \"tree\";\n props: {\n items: TreeItem[];\n /** Item ids expanded on first render. */\n defaultExpanded?: string[];\n };\n bind?: { selected?: string; expanded?: string[] };\n actions?: { onSelect?: ActionDesc; onToggle?: ActionDesc };\n}\n\n/**\n * An editable set of tags — type-and-enter to add, click ✕ to remove,\n * optional autocomplete `suggestions`. The fourth stateful input\n * (alongside `select`, `text-input`, `segmented`); the host owns\n * `bind.tags` and re-renders on `onChange`.\n */\nexport interface TagInputNode extends NodeBase {\n type: \"tag-input\";\n props?: {\n placeholder?: string;\n suggestions?: string[];\n size?: TextSize;\n disabled?: boolean;\n };\n bind: { tags: string[] };\n actions?: { onChange?: ActionDesc };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAqFH;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,QAAQ;IACR,KAAK;IACL,MAAM;IACN,MAAM;IACN,SAAS;IACT,aAAa;IACb,kBAAkB;IAClB,MAAM;IACN,SAAS;IACT,MAAM;IACN,MAAM;IACN,WAAW;IACX,QAAQ;IACR,aAAa;IACb,aAAa;IACb,QAAQ;IACR,aAAa;IACb,aAAa;IACb,UAAU;IACV,6CAA6C;IAC7C,MAAM;IACN,YAAY;IACZ,OAAO;IACP,YAAY;IACZ,MAAM;IACN,4BAA4B;IAC5B,WAAW;IACX,uCAAuC;IACvC,OAAO;IACP,OAAO;IACP,QAAQ;IACR,UAAU;IACV,WAAW;IACX,OAAO;IACP,MAAM;IACN,WAAW;IACX,qCAAqC;IACrC,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,yCAAyC;IACzC,YAAY;IACZ,eAAe;CACP,CAAC","sourcesContent":["/**\n * SRP v0.6 — TypeScript schema types.\n *\n * The Syncropel Rendering Protocol is a narrow JSON schema of block-level\n * primitives for declarative UI documents. See the spec and examples at\n * https://syncropel.com.\n *\n * v0.2 adds five interactive container + input nodes (tabs, data-table,\n * board, text-input, form). v0.3 adds the `segmented` node plus a\n * polished-data-grid increment to `data-table`. v0.4 adds eight\n * visualization + hierarchy nodes — `meter`, `gauge`, `avatar`,\n * `progress`, `sparkline`, `chart`, `tree`, `tag-input` — plus\n * `data-table` row selection and a two-line cell kind. v0.5 adds four\n * library-workspace nodes — `popover`, `slider`, `rating`, `thumbnail` —\n * plus `data-table` sticky columns and `meter` / `rating` / `thumbnail`\n * cell kinds. v0.6 adds two configuration-control nodes — `facet-grid`\n * (a faceted filter) and `column-config` (a grid column picker). v0.7\n * adds no node types — it is pure grammar: the host action grammar\n * (`emit` / `set-state` / `navigate` / `open-pane`), the `QueryBinding`\n * forms, and the expression sublanguage in `expr.ts`. Every addition is\n * additive + backwards-compatible: every v0.1–v0.6 document remains\n * valid. See ADR-102 through ADR-109.\n */\n\n// ---------------------------------------------------------------------------\n// Document envelope\n// ---------------------------------------------------------------------------\n\n/**\n * An SRP v0.1 document — the top-level envelope a Tier-1 extension emits.\n */\nexport interface SRPDocument {\n /**\n * Protocol version. A `\"0.2\"` document may use the v0.2 node additions;\n * a `\"0.3\"` document may additionally use `segmented` + the data-grid\n * props; a `\"0.4\"` document may additionally use the visualization +\n * hierarchy nodes. The version is a capability advertisement, not an\n * enforcement boundary — node validity is decided by `NODE_TYPES`\n * membership.\n */\n srp: \"0.1\" | \"0.2\" | \"0.3\" | \"0.4\" | \"0.5\" | \"0.6\" | \"0.7\";\n meta?: SRPMeta;\n root: SRPNode;\n}\n\nexport interface SRPMeta {\n name?: string;\n version?: string;\n description?: string;\n publisher?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Discriminated union of all 33 node types\n// ---------------------------------------------------------------------------\n\nexport type SRPNode =\n // Containers (5)\n | ColumnNode\n | RowNode\n | GridNode\n | CardNode\n | DividerNode\n // Record rendering (3)\n | RecordLineNode\n | RecordLineListNode\n | ChipNode\n // Data display (4)\n | HeadingNode\n | TextNode\n | StatNode\n | KeyValueNode\n // Interactive (4)\n | ButtonNode\n | IconButtonNode\n | CopyButtonNode\n | SelectNode\n // Feedback (3)\n | EmptyStateNode\n | ErrorStateNode\n | SkeletonNode\n // Interactive containers + inputs — SRP v0.2 (5)\n | TabsNode\n | DataTableNode\n | BoardNode\n | TextInputNode\n | FormNode\n // Choice control — SRP v0.3 (1)\n | SegmentedNode\n // Visualization + hierarchy — SRP v0.4 (8)\n | MeterNode\n | GaugeNode\n | AvatarNode\n | ProgressNode\n | SparklineNode\n | ChartNode\n | TreeNode\n | TagInputNode\n // Library-workspace nodes — SRP v0.5 (4)\n | PopoverNode\n | SliderNode\n | RatingNode\n | ThumbnailNode\n // Configuration-control nodes — SRP v0.6 (2)\n | FacetGridNode\n | ColumnConfigNode;\n\n/**\n * The 39 canonical node-type discriminator strings (19 v0.1 + 5 v0.2 +\n * 1 v0.3 + 8 v0.4 + 4 v0.5 + 2 v0.6).\n */\nexport const NODE_TYPES = [\n \"column\",\n \"row\",\n \"grid\",\n \"card\",\n \"divider\",\n \"record-line\",\n \"record-line-list\",\n \"chip\",\n \"heading\",\n \"text\",\n \"stat\",\n \"key-value\",\n \"button\",\n \"icon-button\",\n \"copy-button\",\n \"select\",\n \"empty-state\",\n \"error-state\",\n \"skeleton\",\n // SRP v0.2 — interactive containers + inputs\n \"tabs\",\n \"data-table\",\n \"board\",\n \"text-input\",\n \"form\",\n // SRP v0.3 — choice control\n \"segmented\",\n // SRP v0.4 — visualization + hierarchy\n \"meter\",\n \"gauge\",\n \"avatar\",\n \"progress\",\n \"sparkline\",\n \"chart\",\n \"tree\",\n \"tag-input\",\n // SRP v0.5 — library-workspace nodes\n \"popover\",\n \"slider\",\n \"rating\",\n \"thumbnail\",\n // SRP v0.6 — configuration-control nodes\n \"facet-grid\",\n \"column-config\",\n] as const;\n\nexport type NodeType = (typeof NODE_TYPES)[number];\n\n// ---------------------------------------------------------------------------\n// Fields every node may carry\n// ---------------------------------------------------------------------------\n\ninterface NodeBase {\n when?: string;\n bind?: Record<string, unknown>;\n actions?: Record<string, SRPAction>;\n}\n\n// ---------------------------------------------------------------------------\n// Token unions (mirror @syncropel/react token scales)\n// ---------------------------------------------------------------------------\n\nexport type Gap = \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\nexport type Padding = \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\";\nexport type DividerSpacing = \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\";\nexport type Cols = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;\n\nexport type ColumnAlign = \"start\" | \"center\" | \"end\" | \"stretch\";\nexport type RowAlign = \"start\" | \"center\" | \"end\" | \"stretch\" | \"baseline\";\nexport type Justify =\n | \"start\"\n | \"center\"\n | \"end\"\n | \"between\"\n | \"around\"\n | \"evenly\";\n\nexport type RecordLineVariant =\n | \"feed\"\n | \"compact\"\n | \"detail\"\n | \"search\"\n | \"thread\";\n\nexport type ChipTone = \"default\" | \"info\" | \"warn\" | \"error\";\n\nexport type TextSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\nexport type TextWeight = \"normal\" | \"medium\" | \"semibold\";\nexport type TextTone =\n | \"primary\"\n | \"secondary\"\n | \"muted\"\n | \"success\"\n | \"warning\"\n | \"danger\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"danger\";\nexport type ButtonSize = \"xs\" | \"sm\" | \"md\";\n\nexport type SkeletonShape = \"rect\" | \"circle\" | \"text\";\n\n// --- SRP v0.2 tokens ---\nexport type TableColumnAlign = \"start\" | \"end\";\nexport type DataTableVariant = \"default\" | \"compact\";\nexport type TextInputKind = \"text\" | \"search\";\n/**\n * How a `data-table` column renders its cell value. `text` (default) is a\n * plain string; `chip` renders the value as a compact metadata chip;\n * `lines` (SRP v0.4) renders a two-line cell — the value at `key` as the\n * primary line and the value at the column's `subKey` as a muted subtitle.\n *\n * SRP v0.5 adds three visual cell kinds: `meter` renders a numeric `0..1`\n * value as an inline bar (recoloured by the column's `thresholds`);\n * `rating` renders a numeric value as a row of stars (count from the\n * column's `max`); `thumbnail` renders a URL-valued cell as a small image.\n */\nexport type TableCellKind =\n | \"text\"\n | \"chip\"\n | \"lines\"\n | \"meter\"\n | \"rating\"\n | \"thumbnail\";\n\n// --- SRP v0.3 tokens ---\n\n/**\n * A row accent tone — `data-table` `rowTone` paints a left-border (and a\n * subtle tint) keyed off a column value. Wider than `ChipTone`: it adds\n * `accent` and `success` so a row can read as \"in progress\" / \"done\".\n */\nexport type RowTone =\n | \"default\"\n | \"accent\"\n | \"success\"\n | \"warn\"\n | \"error\"\n | \"info\";\n\n/** Sort direction for a `data-table` column. */\nexport type SortDirection = \"asc\" | \"desc\";\n\n/** Which side of the row a `data-table` `rowActions` cell sits on. */\nexport type RowActionPosition = \"leading\" | \"trailing\";\n\n/**\n * How a `segmented` control presents. `solid` (default) is a light pill\n * group; `underline` is a borderless tab strip (active option underlined).\n * Added in SRP v0.3.1.\n */\nexport type SegmentedVariant = \"solid\" | \"underline\";\n\n// --- SRP v0.4 tokens ---\n\n/**\n * A visualization tone — shared by `meter`, `gauge`, `progress`,\n * `sparkline`, and `chart`. Drives the fill / stroke colour. Added SRP v0.4.\n */\nexport type VizTone =\n | \"neutral\"\n | \"accent\"\n | \"success\"\n | \"warn\"\n | \"error\"\n | \"info\";\n\n/** A visualization size step — shared by the SRP v0.4 viz nodes. */\nexport type VizSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\n/** How a `meter` renders its fill — one bar, or a row of discrete cells. */\nexport type MeterVariant = \"continuous\" | \"segmented\";\n\n/** How a `sparkline` renders its series. */\nexport type SparklineVariant = \"line\" | \"bar\";\n\n/** The plot kind a `chart` draws. */\nexport type ChartKind = \"line\" | \"area\" | \"bar\" | \"pie\";\n\n/**\n * Glyph kinds — the closed enumeration of semantic symbols the palette renders.\n * Covers act types, domain objects, thread states, and the AITL marker.\n */\nexport type GlyphKind =\n // Act types (coordination)\n | \"INTEND\"\n | \"DO\"\n | \"KNOW\"\n | \"LEARN\"\n // Act types (effects)\n | \"GET\"\n | \"PUT\"\n | \"CALL\"\n | \"MAP\"\n // AITL marker\n | \"AITL\"\n // Domain objects\n | \"thread\"\n | \"fork\"\n | \"record-parent\"\n | \"namespace\"\n | \"actor\"\n | \"file\"\n | \"pattern\"\n | \"page\"\n | \"view\"\n // Thread states\n | \"state-open\"\n | \"state-active\"\n | \"state-converged\"\n | \"state-closed\"\n | \"state-abandoned\";\n\n// ---------------------------------------------------------------------------\n// Actions + queries\n// ---------------------------------------------------------------------------\n\n/**\n * The legacy (SRP ≤ v0.6) action form — an opaque intent name dispatched\n * to a host-supplied handler. Still valid in v0.7 as the escape hatch for\n * a non-generic host; new workspace records SHOULD prefer the v0.7 verbs.\n */\nexport interface ActionDesc {\n intent: string;\n payload?: Record<string, unknown>;\n}\n\n// --- SRP v0.7 — the host action grammar (ADR-109 D1) -----------------------\n\n/**\n * A record-emit specification. String values anywhere in `body` (and in\n * `thread`) may carry `{…}` interpolation resolved against the action\n * scope (`form.*`, `row.*`, `state.*`). `thread: \"$new\"` directs the host\n * to allocate a fresh `th_` id.\n */\nexport interface EmitSpec {\n /** Act type — INTEND | DO | KNOW | LEARN | GET | PUT | CALL | MAP. */\n act: string;\n /** Target thread id, or `\"$new\"` for a host-generated fresh thread. */\n thread: string;\n /** The record body. */\n body: Record<string, unknown>;\n}\n\n/**\n * v0.7 — emit a record via the SDK. Capability-checked by the generic\n * host against the workspace record's `meta.capabilities.emit`\n * (ADR-109 D5). An optional `id` keys the mutation lifecycle (ADR-109 D3);\n * `optimistic` supplies a body the host inserts immediately and rolls\n * back on failure.\n */\nexport interface EmitAction {\n emit: EmitSpec;\n id?: string;\n optimistic?: Record<string, unknown>;\n /**\n * v0.7 — actions dispatched *after* the emit resolves successfully.\n * The host runs them in order once the record is emitted (used to\n * close + clear a composer after a create). They do not run on\n * failure — so an error guard inside the still-open form can show.\n */\n onSuccess?: SRPAction[];\n}\n\n/** v0.7 — write the host state bag (ADR-109 D6). */\nexport interface SetStateAction {\n setState: { key: string; value: unknown };\n}\n\n/** v0.7 — route the viewer. Scope-checked against `meta.capabilities.navigate`. */\nexport interface NavigateAction {\n /** Target path; may carry `{…}` interpolation. */\n navigate: string;\n}\n\n/** v0.7 — open a record in a `<WorkspaceShell>` region. */\nexport interface OpenPaneAction {\n openPane: { region: string; record: string };\n}\n\n/**\n * An SRP action — what an event binding triggers. v0.7 adds four\n * self-describing verbs a generic host executes with no workspace-specific\n * code; the legacy `ActionDesc` form remains a member for compatibility.\n */\nexport type SRPAction =\n | ActionDesc\n | EmitAction\n | SetStateAction\n | NavigateAction\n | OpenPaneAction;\n\n/**\n * v0.7 — a named query binding (ADR-109 D4). A node's `bind.query` is\n * either a raw {@link VQLQuery} (legacy) or a `QueryBinding`. `name` lets\n * the host expose a query-count via the expression path\n * `query.<name>.count`. Exactly one of `filter` / `fold` is set:\n * `filter` is a raw ADR-037 VQL query; `fold` names a server-side\n * projection/fold endpoint (e.g. `\"tasks.snapshot\"`).\n */\nexport interface QueryBinding {\n name: string;\n filter?: VQLQuery;\n fold?: string;\n /**\n * v0.7 — an optional client-side row filter: an expression\n * (see `expr.ts`) evaluated per row against `{ row, state }`. Rows for\n * which it is falsy are dropped *after* fetch. This is the host-owned\n * post-fetch transform that lets filter state (`@state.*`) narrow a\n * query without re-hitting the server (ADR-109 D6).\n */\n where?: string;\n}\n\n/**\n * VQL (Value Query Language) — the query shape a Syncropel server resolves\n * against its record store. Used by `record-line-list` nodes that bind to\n * a live query rather than a static list of record ids.\n *\n * The shape is deliberately open (index signature) — additional fields\n * are protocol extensions the server understands.\n */\nexport interface VQLQuery {\n act?: string;\n actor?: string;\n thread?: string;\n kind?: string;\n since?: number;\n limit?: number;\n [k: string]: unknown;\n}\n\n// ---------------------------------------------------------------------------\n// Container node definitions (5)\n// ---------------------------------------------------------------------------\n\nexport interface ColumnNode extends NodeBase {\n type: \"column\";\n props?: { gap?: Gap; align?: ColumnAlign; justify?: Justify };\n children?: SRPNode[];\n}\n\nexport interface RowNode extends NodeBase {\n type: \"row\";\n props?: {\n gap?: Gap;\n align?: RowAlign;\n justify?: Justify;\n wrap?: boolean;\n };\n children?: SRPNode[];\n}\n\nexport interface GridNode extends NodeBase {\n type: \"grid\";\n props: { cols: Cols; gap?: Gap; rowGap?: Gap; colGap?: Gap };\n children?: SRPNode[];\n}\n\nexport interface CardNode extends NodeBase {\n type: \"card\";\n props?: { padding?: Padding; interactive?: boolean };\n children?: SRPNode[];\n}\n\nexport interface DividerNode extends NodeBase {\n type: \"divider\";\n props?: { orientation?: \"horizontal\" | \"vertical\"; spacing?: DividerSpacing };\n}\n\n// ---------------------------------------------------------------------------\n// Record-rendering (3)\n// ---------------------------------------------------------------------------\n\nexport interface RecordLineNode extends NodeBase {\n type: \"record-line\";\n props: {\n variant: RecordLineVariant;\n /**\n * SRP v0.3 — an optional dotted body path (`body.priority`). When set,\n * the line renders a small chip carrying that field's value. Lets\n * `board` cards (which render through `record-line`) show a priority\n * or status chip.\n */\n chipField?: string;\n };\n bind: { record: string };\n}\n\nexport interface RecordLineListNode extends NodeBase {\n type: \"record-line-list\";\n props: { variant: RecordLineVariant; max?: number; empty?: string };\n bind: { query: VQLQuery | QueryBinding } | { items: string[] };\n}\n\nexport interface ChipNode extends NodeBase {\n type: \"chip\";\n props: { label: string; tone?: ChipTone; glyph?: GlyphKind };\n}\n\n// ---------------------------------------------------------------------------\n// Data display (4)\n// ---------------------------------------------------------------------------\n\nexport interface HeadingNode extends NodeBase {\n type: \"heading\";\n props: { level: 1 | 2 | 3 | 4 | 5 | 6; text: string };\n}\n\nexport interface TextNode extends NodeBase {\n type: \"text\";\n props: {\n text: string;\n size?: TextSize;\n weight?: TextWeight;\n tone?: TextTone;\n inline?: boolean;\n };\n}\n\nexport interface StatNode extends NodeBase {\n type: \"stat\";\n props: {\n label: string;\n value: string | number;\n delta?: string | number;\n deltaTone?: \"auto\" | \"neutral\";\n };\n}\n\nexport interface KeyValueNode extends NodeBase {\n type: \"key-value\";\n props: { label: string; value: string };\n}\n\n// ---------------------------------------------------------------------------\n// Interactive (4)\n// ---------------------------------------------------------------------------\n\nexport interface ButtonNode extends NodeBase {\n type: \"button\";\n props: {\n label: string;\n variant?: ButtonVariant;\n size?: ButtonSize;\n disabled?: boolean;\n loading?: boolean;\n };\n actions?: { onClick?: SRPAction };\n}\n\nexport interface IconButtonNode extends NodeBase {\n type: \"icon-button\";\n props: {\n glyph: GlyphKind;\n ariaLabel: string;\n variant?: ButtonVariant;\n size?: ButtonSize;\n disabled?: boolean;\n loading?: boolean;\n };\n actions?: { onClick?: SRPAction };\n}\n\nexport interface CopyButtonNode extends NodeBase {\n type: \"copy-button\";\n props: { value: string; label?: string };\n}\n\nexport interface SelectNode extends NodeBase {\n type: \"select\";\n props: { options: { label: string; value: string }[] };\n bind: { value: string };\n actions?: { onChange?: SRPAction };\n}\n\n// ---------------------------------------------------------------------------\n// Feedback (3)\n// ---------------------------------------------------------------------------\n\nexport interface EmptyStateNode extends NodeBase {\n type: \"empty-state\";\n props: {\n message: string;\n action?: { label: string; intent: string };\n };\n}\n\nexport interface ErrorStateNode extends NodeBase {\n type: \"error-state\";\n props: {\n message: string;\n retry?: { intent: string };\n };\n}\n\nexport interface SkeletonNode extends NodeBase {\n type: \"skeleton\";\n props?: {\n shape?: SkeletonShape;\n width?: string | number | \"full\";\n height?: string | number;\n };\n}\n\n// ---------------------------------------------------------------------------\n// SRP v0.2 — interactive containers + inputs (5)\n//\n// All five reuse the v0.1 contract: `props` is static config, `bind` is\n// host-supplied state, `actions` declares intents the host dispatches. SRP\n// owns layout + shape; the host owns state + behaviour. See ADR-102 and the\n// SRP v0.2 design spec.\n// ---------------------------------------------------------------------------\n\n/**\n * A container whose children are panels; one panel shows at a time. The host\n * supplies the active tab id via `bind.active` and renders the panel whose\n * index matches it in `props.tabs`.\n */\nexport interface TabsNode extends NodeBase {\n type: \"tabs\";\n props: { tabs: { id: string; label: string; glyph?: GlyphKind }[] };\n bind: { active: string };\n actions?: { onTabChange?: SRPAction };\n /** Panels, parallel to `props.tabs` by index. */\n children?: SRPNode[];\n}\n\n/** A single `data-table` column definition. */\nexport interface DataTableColumnDef {\n /** Dotted path into each row (`body.goal`, `actor`). */\n key: string;\n label: string;\n align?: TableColumnAlign;\n width?: string;\n /** How the cell value renders. Default `text`. */\n kind?: TableCellKind;\n /**\n * SRP v0.3 — for a `kind: \"chip\"` column, a map from cell value to chip\n * tone. A value with no entry renders a `default`-tone chip.\n */\n tones?: Record<string, ChipTone>;\n /**\n * SRP v0.3 — an explicit value order for sorting this column. When the\n * column is the sort key, rows order by each value's index in this list\n * (so `critical` < `high` < `medium` < `low`, not alphabetical). Values\n * absent from the list sort after the listed ones.\n */\n order?: string[];\n /**\n * SRP v0.4 — for a `kind: \"lines\"` column, the dotted path whose value\n * renders as the muted second line beneath the `key` value.\n */\n subKey?: string;\n /**\n * SRP v0.5 — for a `kind: \"meter\"` column, value-keyed recolouring of\n * the inline bar (energy low→high, score bands). List in ascending `at`.\n */\n thresholds?: VizThreshold[];\n /**\n * SRP v0.5 — for a `kind: \"rating\"` column, the number of stars. Also\n * the default tone source for a `meter` cell when no `thresholds` match.\n * Default 5.\n */\n max?: number;\n}\n\n/** SRP v0.3 — a `data-table` sort descriptor. */\nexport interface TableSort {\n key: string;\n direction: SortDirection;\n}\n\n/**\n * SRP v0.3 — a per-row action affordance on a `data-table`. Rendered as a\n * small button in a leading or trailing cell; a click dispatches `intent`\n * with the row merged into the payload as `row`.\n */\nexport interface TableRowAction {\n /** Stable identifier for this row action (also the legacy intent name). */\n intent: string;\n /** A semantic glyph for an icon-only affordance. */\n glyph?: GlyphKind;\n /** A text label — used when no `glyph` is given (or as the aria-label). */\n label?: string;\n /** Which side of the row the action cell sits on. Default `leading`. */\n position?: RowActionPosition;\n /**\n * v0.7 — the action a click triggers. When set, the host dispatches\n * this `SRPAction` with the row as runtime context (`{row}`); when\n * omitted, the legacy `{ intent, payload: { row } }` form is dispatched.\n */\n action?: SRPAction;\n}\n\n/**\n * SRP v0.3 — a `data-table` row accent. The row paints a left-border (and\n * a subtle tint) whose tone is looked up from `tones` by the value at\n * `key`. A value with no entry gets no accent.\n */\nexport interface TableRowTone {\n /** Dotted path into the row whose value selects the tone. */\n key: string;\n tones: Record<string, RowTone>;\n}\n\n/**\n * A columnar record list — richer than `record-line-list`: explicit columns,\n * alignment, optional sort. `column.key` is a dotted path into each row.\n *\n * SRP v0.3 adds the polished-data-grid props: column `tones` + `order`,\n * `defaultSort`, `rowActions`, and `rowTone`. SRP v0.4 adds `selectable`\n * (a leading checkbox column with multi-select) — all optional + additive.\n */\nexport interface DataTableNode extends NodeBase {\n type: \"data-table\";\n props: {\n columns: DataTableColumnDef[];\n variant?: DataTableVariant;\n sortable?: boolean;\n empty?: string;\n /** SRP v0.3 — the sort applied before any header interaction. */\n defaultSort?: TableSort;\n /** SRP v0.3 — per-row action affordances. */\n rowActions?: TableRowAction[];\n /** SRP v0.3 — a value-keyed row accent. */\n rowTone?: TableRowTone;\n /**\n * SRP v0.4 — render a leading checkbox column with a select-all\n * header. The table owns selection state and dispatches\n * `onSelectionChange` with the selected rows.\n */\n selectable?: boolean;\n /**\n * SRP v0.5 — pin the first N columns (and the leading checkbox /\n * action cells) so they stay visible while the rest scroll\n * horizontally. Default 0 (no pinned columns).\n */\n stickyColumns?: number;\n };\n bind: { query: VQLQuery | QueryBinding } | { rows: Record<string, unknown>[] };\n actions?: {\n onRowClick?: SRPAction;\n onSort?: SRPAction;\n /** SRP v0.4 — fired (with `rows`) when the selection changes. */\n onSelectionChange?: SRPAction;\n };\n}\n\n/**\n * A kanban board — records bucketed into columns by the `props.groupBy` field.\n * A record lands in the column whose `id` equals its `groupBy` value; records\n * matching no column are dropped. `onCardMove` is advisory — a host MAY\n * support drag; a board without drag is read-only and still valid.\n */\nexport interface BoardNode extends NodeBase {\n type: \"board\";\n props: {\n columns: { id: string; label: string }[];\n groupBy: string;\n cardVariant?: RecordLineVariant;\n /**\n * SRP v0.3 — a dotted body path passed through to each card's\n * `record-line` as its `chipField`, so cards show a metadata chip\n * (e.g. `body.priority`).\n */\n cardChipField?: string;\n };\n bind: { query: VQLQuery | QueryBinding };\n actions?: { onCardClick?: SRPAction; onCardMove?: SRPAction };\n}\n\n/**\n * An editable text field — the `select` of free text. The host owns\n * `bind.value` and re-renders on change (identical ownership model to\n * `select`).\n */\nexport interface TextInputNode extends NodeBase {\n type: \"text-input\";\n props?: {\n placeholder?: string;\n multiline?: boolean;\n inputKind?: TextInputKind;\n size?: TextSize;\n disabled?: boolean;\n };\n bind: { value: string };\n actions?: { onChange?: SRPAction; onSubmit?: SRPAction };\n}\n\n/**\n * A container that groups inputs and declares a submit intent. The host\n * collects child input values (by their `bind`) and dispatches `onSubmit`.\n */\nexport interface FormNode extends NodeBase {\n type: \"form\";\n props?: { submitLabel?: string; busy?: boolean };\n actions?: { onSubmit?: SRPAction };\n children?: SRPNode[];\n}\n\n// ---------------------------------------------------------------------------\n// SRP v0.3 — choice control (1)\n//\n// `segmented` is the third stateful input (alongside `select` + `text-input`)\n// and reuses the same ownership model: `bind.value` is host-supplied, a\n// pick dispatches `onChange`. See ADR-103.\n// ---------------------------------------------------------------------------\n\n/** One option in a `segmented` control. */\nexport interface SegmentedOption {\n value: string;\n label: string;\n /** An optional count/marker rendered as a small badge on the option. */\n badge?: string | number;\n}\n\n/**\n * A row of mutually-exclusive options — a filter/choice control. Distinct\n * from `tabs`: it has no panels, it is purely a bound value. The host owns\n * `bind.value`; picking an option dispatches `onChange` with the new value.\n */\nexport interface SegmentedNode extends NodeBase {\n type: \"segmented\";\n props: {\n options: SegmentedOption[];\n size?: ButtonSize;\n /** Presentation — `solid` (light pill group, default) or `underline`\n * (borderless tab strip). Added in SRP v0.3.1. */\n variant?: SegmentedVariant;\n };\n bind: { value: string };\n actions?: { onChange?: SRPAction };\n}\n\n// ---------------------------------------------------------------------------\n// SRP v0.4 — visualization + hierarchy nodes (8)\n//\n// `meter`, `gauge`, `progress`, `sparkline`, `chart` are read-only data\n// displays — `props` carries the values, there is no `bind`. `avatar` is a\n// read-only identity token. `tree` + `tag-input` are interactive: they\n// reuse the v0.1 ownership model — `bind` is host state, `actions` declares\n// dispatched intents. Music-specific widgets (waveforms, transition tables)\n// are NOT in SRP — a renderer registers those as plug-in node types. See\n// ADR-104.\n// ---------------------------------------------------------------------------\n\n/**\n * A value→tone threshold for a `meter`. The meter's value selects the\n * highest threshold whose `at` it reaches; that tone recolours the fill.\n * List thresholds in ascending `at` order.\n */\nexport interface VizThreshold {\n at: number;\n tone: VizTone;\n}\n\n/**\n * A horizontal bar gauge — renders a `0..1` reading as a proportional\n * fill. `continuous` is a single bar; `segmented` is a row of discrete\n * cells. `thresholds` recolours the meter by value (energy low→high,\n * trust score, match confidence).\n */\nexport interface MeterNode extends NodeBase {\n type: \"meter\";\n props: {\n /** The reading, clamped to `0..1`. */\n value: number;\n tone?: VizTone;\n variant?: MeterVariant;\n /** Cell count when `variant: \"segmented\"`. Default 5. */\n segments?: number;\n /** Value-keyed recolouring; overrides `tone` for the matched band. */\n thresholds?: VizThreshold[];\n size?: VizSize;\n /** Optional caption rendered beside the bar. */\n label?: string;\n };\n}\n\n/** A coloured band on a `gauge` arc — e.g. a Dial zone. */\nexport interface GaugeZone {\n from: number;\n to: number;\n tone: VizTone;\n label?: string;\n}\n\n/**\n * A radial arc gauge — renders a `0..1` reading on a 270° arc. Doubles as\n * the Syncropel Dial (the `d ∈ [0,1]` control surface, F3): `zones` paints\n * the REPLAY / ADAPT / EXPLORE / CREATE bands.\n */\nexport interface GaugeNode extends NodeBase {\n type: \"gauge\";\n props: {\n /** The reading, clamped to `0..1`. */\n value: number;\n label?: string;\n tone?: VizTone;\n /** Coloured arc bands — drawn behind the value sweep. */\n zones?: GaugeZone[];\n size?: VizSize;\n /** Render the numeric value in the arc centre. Default true. */\n showValue?: boolean;\n /** How the centre value reads. Default `decimal`. */\n format?: \"percent\" | \"decimal\";\n };\n}\n\n/**\n * A compact identity token — an image (`src`), or initials derived from\n * `name`, or a semantic `glyph` fallback. Square, rounded.\n */\nexport interface AvatarNode extends NodeBase {\n type: \"avatar\";\n props: {\n /** Display name — the source of initials + the accessible label. */\n name: string;\n src?: string;\n glyph?: GlyphKind;\n size?: VizSize;\n };\n}\n\n/**\n * A progress bar. With `value` it fills proportionally (determinate);\n * with `indeterminate` it animates with no known extent. Distinct from\n * `meter`: `progress` reads as \"advancing toward done\", `meter` as a\n * static measurement.\n */\nexport interface ProgressNode extends NodeBase {\n type: \"progress\";\n props?: {\n /** The fraction complete, `0..1`. Omit when `indeterminate`. */\n value?: number;\n indeterminate?: boolean;\n tone?: VizTone;\n label?: string;\n /** Render the percentage as text. Default false. */\n showValue?: boolean;\n size?: VizSize;\n };\n}\n\n/**\n * A tiny inline chart — a bare series with no axes or legend, for\n * trend-at-a-glance (cost over time, dispatch throughput, energy shape).\n */\nexport interface SparklineNode extends NodeBase {\n type: \"sparkline\";\n props: {\n values: number[];\n variant?: SparklineVariant;\n tone?: VizTone;\n /** Width in px, or `\"full\"` to fill the container. Default 96. */\n width?: number | \"full\";\n /** Height in px. Default 24. */\n height?: number;\n };\n}\n\n/** One point in a `chart` series. */\nexport interface ChartPoint {\n x: string | number;\n y: number;\n}\n\n/** One series in a `chart` — or, for a `pie`, one ring of slices. */\nexport interface ChartSeries {\n label?: string;\n tone?: VizTone;\n points: ChartPoint[];\n}\n\n/**\n * A labelled chart — a `line` / `area` / `bar` plot, or a `pie` whose\n * slices are `series[0].points`. Richer than `sparkline`: axes, a legend,\n * a title.\n */\nexport interface ChartNode extends NodeBase {\n type: \"chart\";\n props: {\n kind: ChartKind;\n series: ChartSeries[];\n title?: string;\n /** Plot height in px. Default 200. */\n height?: number;\n /** Draw axes + gridlines (ignored for `pie`). Default true. */\n showAxis?: boolean;\n /** Draw a series legend. Default false. */\n showLegend?: boolean;\n };\n}\n\n/** One node in a `tree`. Recursive — `children` nest arbitrarily deep. */\nexport interface TreeItem {\n id: string;\n label: string;\n glyph?: GlyphKind;\n /** A small trailing count / marker. */\n badge?: string | number;\n children?: TreeItem[];\n}\n\n/**\n * A hierarchical, collapsible list — playlist folders, namespace trees,\n * thread forks, file browsers. The host owns `bind.selected` /\n * `bind.expanded`; a click dispatches `onSelect` / `onToggle`. When `bind`\n * is omitted the tree manages expand/collapse internally.\n */\nexport interface TreeNode extends NodeBase {\n type: \"tree\";\n props: {\n items: TreeItem[];\n /** Item ids expanded on first render. */\n defaultExpanded?: string[];\n };\n bind?: { selected?: string; expanded?: string[] };\n actions?: { onSelect?: SRPAction; onToggle?: SRPAction };\n}\n\n/**\n * An editable set of tags — type-and-enter to add, click ✕ to remove,\n * optional autocomplete `suggestions`. The fourth stateful input\n * (alongside `select`, `text-input`, `segmented`); the host owns\n * `bind.tags` and re-renders on `onChange`.\n */\nexport interface TagInputNode extends NodeBase {\n type: \"tag-input\";\n props?: {\n placeholder?: string;\n suggestions?: string[];\n size?: TextSize;\n disabled?: boolean;\n };\n bind: { tags: string[] };\n actions?: { onChange?: SRPAction };\n}\n\n// ---------------------------------------------------------------------------\n// SRP v0.5 — library-workspace nodes (4)\n//\n// `popover` is a container whose children are an anchored panel — it owns\n// its own open/close state, so it needs no `bind`. `slider` + `rating` are\n// the fifth + sixth stateful inputs (alongside select / text-input /\n// segmented / tag-input): the host owns `bind.value`, a change dispatches\n// `onChange`. `thumbnail` is a read-only rectangular image token. These\n// four close the gap between the visualization palette and a full\n// library-management workspace (a configurable grid + filter + column\n// popovers + a record editor). See ADR-105.\n// ---------------------------------------------------------------------------\n\n/** Which edge of the trigger a `popover` panel aligns to. */\nexport type PopoverAlign = \"start\" | \"center\" | \"end\";\n\n/** Corner rounding for a `thumbnail`. */\nexport type ThumbnailRadius = \"none\" | \"sm\" | \"md\" | \"lg\" | \"full\";\n\n/** Aspect ratio for a `thumbnail`. */\nexport type ThumbnailAspect = \"square\" | \"video\" | \"wide\";\n\n/**\n * A trigger button paired with an anchored panel. Clicking the trigger\n * opens `children` in a popover; an outside click or `Escape` closes it.\n * The popover owns its open state — it is presentation, not host state —\n * so there is no `bind`. The toolbar Columns + Filters controls of a\n * library view are `popover` nodes wrapping a `column-config` / `facet`\n * panel.\n */\nexport interface PopoverNode extends NodeBase {\n type: \"popover\";\n props: {\n /** The trigger button's label. */\n label: string;\n /** An optional leading glyph on the trigger. */\n glyph?: GlyphKind;\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** Which trigger edge the panel aligns to. Default `start`. */\n align?: PopoverAlign;\n /** A small count/marker badge on the trigger (e.g. active filters). */\n badge?: string | number;\n };\n /** The popover panel content. */\n children?: SRPNode[];\n}\n\n/**\n * A draggable numeric input — the continuous sibling of `select`. The host\n * owns `bind.value`; a drag (or arrow key) dispatches `onChange` with the\n * new value. Distinct from `meter` (read-only measurement) and `progress`\n * (advancing-toward-done): `slider` is an editable control.\n */\nexport interface SliderNode extends NodeBase {\n type: \"slider\";\n props: {\n min: number;\n max: number;\n /** Snap increment. Default 1. */\n step?: number;\n tone?: VizTone;\n label?: string;\n /** Render the current value as text beside the track. Default false. */\n showValue?: boolean;\n size?: VizSize;\n disabled?: boolean;\n };\n bind: { value: number };\n actions?: { onChange?: SRPAction };\n}\n\n/**\n * A row of stars. With `readOnly` it is a display (a table cell, a card\n * field); otherwise it is an input — clicking a star dispatches `onChange`\n * with the new value. The host owns `bind.value`.\n */\nexport interface RatingNode extends NodeBase {\n type: \"rating\";\n props?: {\n /** Star count. Default 5. */\n max?: number;\n size?: VizSize;\n /** Display only — no interaction, no `onChange`. Default false. */\n readOnly?: boolean;\n tone?: VizTone;\n };\n bind: { value: number };\n actions?: { onChange?: SRPAction };\n}\n\n/**\n * A rectangular image token — album art, a file preview, a cover. An\n * `src` image, or a semantic `glyph` fallback when `src` is absent or\n * fails to load. Distinct from `avatar` (a square identity token that\n * derives initials from a name): `thumbnail` is content imagery with a\n * configurable aspect ratio.\n */\nexport interface ThumbnailNode extends NodeBase {\n type: \"thumbnail\";\n props: {\n /** Accessible description — required even when `src` is set. */\n alt: string;\n src?: string;\n /** Fallback glyph when `src` is absent or fails to load. */\n glyph?: GlyphKind;\n size?: VizSize;\n /** Corner rounding. Default `sm`. */\n radius?: ThumbnailRadius;\n /** Aspect ratio. Default `square`. */\n aspect?: ThumbnailAspect;\n };\n}\n\n// ---------------------------------------------------------------------------\n// SRP v0.6 — configuration-control nodes (2)\n//\n// `facet-grid` + `column-config` are the declarative bodies of the\n// Filters and Columns popovers of a library workspace. Both are stateful\n// inputs in the v0.1 ownership model — the host owns `bind`, an\n// interaction dispatches an intent. They pair with `data-table`:\n// `facet-grid` chooses which rows it shows, `column-config` chooses which\n// columns. See ADR-106.\n// ---------------------------------------------------------------------------\n\n/** One selectable option within a `facet-grid` category. */\nexport interface FacetOption {\n value: string;\n label: string;\n /** A corpus count rendered as a trailing badge on the chip. */\n count?: number;\n}\n\n/** One category (tab) of a `facet-grid` — e.g. genre, mood, vibe. */\nexport interface FacetCategory {\n id: string;\n label: string;\n options: FacetOption[];\n}\n\n/**\n * A faceted filter — a row of category tabs, and beneath the active tab a\n * wrapped grid of selectable, count-bearing chips. The host owns the\n * active category (`bind.active`) and the selected values per category\n * (`bind.selected`); a tab pick dispatches `onFacetChange`, a chip toggle\n * dispatches `onToggle`. The Filters panel's tag section of a library\n * view is a `facet-grid`.\n */\nexport interface FacetGridNode extends NodeBase {\n type: \"facet-grid\";\n props: {\n facets: FacetCategory[];\n };\n bind: {\n /** The active category id. */\n active: string;\n /** Selected values, keyed by category id. */\n selected?: Record<string, string[]>;\n };\n actions?: {\n /** Category tab changed — payload `{ facet }`. */\n onFacetChange?: SRPAction;\n /** A chip toggled — payload `{ facet, value }`. */\n onToggle?: SRPAction;\n };\n}\n\n/** One configurable column in a `column-config`. */\nexport interface ColumnConfigColumn {\n id: string;\n label: string;\n}\n\n/** A named visible-column set a `column-config` can apply in one click. */\nexport interface ColumnConfigPreset {\n id: string;\n label: string;\n /** The visible column ids, in order. */\n columns: string[];\n}\n\n/**\n * A grid column picker — preset buttons plus a drag-to-reorder list of\n * visibility checkboxes. The host owns `bind.visible` (the visible column\n * ids, in display order); any change dispatches `onChange` with the new\n * order. Pairs with `data-table` — `bind.visible` selects + orders the\n * table's columns. The Columns panel of a library view is a\n * `column-config`.\n */\nexport interface ColumnConfigNode extends NodeBase {\n type: \"column-config\";\n props: {\n columns: ColumnConfigColumn[];\n presets?: ColumnConfigPreset[];\n };\n bind: {\n /** The visible column ids, in display order. */\n visible: string[];\n };\n actions?: {\n /** Visibility or order changed — payload `{ visible }`. */\n onChange?: SRPAction;\n };\n}\n"]}
|
package/dist/validators.d.ts
CHANGED
package/dist/validators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOxD,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,MAAM,MAAM,mBAAmB,GAC3B,qBAAqB,GACrB,cAAc,GACd,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,wBAAwB,GACxB,qBAAqB,GACrB,oBAAoB,GACpB,sBAAsB,GACtB,uBAAuB,GACvB,oBAAoB,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GACxB;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GACf;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AAahD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAOxD,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,MAAM,MAAM,mBAAmB,GAC3B,qBAAqB,GACrB,cAAc,GACd,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,wBAAwB,GACxB,qBAAqB,GACrB,oBAAoB,GACpB,sBAAsB,GACtB,uBAAuB,GACvB,oBAAoB,CAAC;AAEzB,MAAM,MAAM,gBAAgB,GACxB;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GACf;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AAahD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAoC1D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAM1E;AAw7CD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,WAAW,CAG9D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,OAAO,CAGxD"}
|
package/dist/validators.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Runtime validators for SRP v0.1
|
|
2
|
+
* Runtime validators for SRP v0.1 – v0.7 documents.
|
|
3
3
|
*
|
|
4
4
|
* Pure functions — no dependencies. Return a ValidationResult with either a
|
|
5
5
|
* `valid: true` flag or a list of errors keyed by path.
|
|
@@ -31,8 +31,11 @@ export function validateSRP(doc) {
|
|
|
31
31
|
if (d.srp !== "0.1" &&
|
|
32
32
|
d.srp !== "0.2" &&
|
|
33
33
|
d.srp !== "0.3" &&
|
|
34
|
-
d.srp !== "0.4"
|
|
35
|
-
|
|
34
|
+
d.srp !== "0.4" &&
|
|
35
|
+
d.srp !== "0.5" &&
|
|
36
|
+
d.srp !== "0.6" &&
|
|
37
|
+
d.srp !== "0.7") {
|
|
38
|
+
c.add("/srp", "SRP_VERSION_INVALID", `srp field must be "0.1"–"0.7", got ${JSON.stringify(d.srp)}`);
|
|
36
39
|
}
|
|
37
40
|
if (!("root" in d)) {
|
|
38
41
|
c.add("/root", "ROOT_MISSING", "SRP document must have a root node");
|
|
@@ -165,6 +168,24 @@ function validateNodeInto(node, path, c) {
|
|
|
165
168
|
case "tag-input":
|
|
166
169
|
validateTagInput(n, path, c);
|
|
167
170
|
break;
|
|
171
|
+
case "popover":
|
|
172
|
+
validatePopover(n, path, c);
|
|
173
|
+
break;
|
|
174
|
+
case "slider":
|
|
175
|
+
validateSlider(n, path, c);
|
|
176
|
+
break;
|
|
177
|
+
case "rating":
|
|
178
|
+
validateRating(n, path, c);
|
|
179
|
+
break;
|
|
180
|
+
case "thumbnail":
|
|
181
|
+
validateThumbnail(n, path, c);
|
|
182
|
+
break;
|
|
183
|
+
case "facet-grid":
|
|
184
|
+
validateFacetGrid(n, path, c);
|
|
185
|
+
break;
|
|
186
|
+
case "column-config":
|
|
187
|
+
validateColumnConfig(n, path, c);
|
|
188
|
+
break;
|
|
168
189
|
}
|
|
169
190
|
}
|
|
170
191
|
// ---------------------------------------------------------------------------
|
|
@@ -381,8 +402,17 @@ function validateDataTable(n, path, c) {
|
|
|
381
402
|
if (o.kind !== undefined &&
|
|
382
403
|
o.kind !== "text" &&
|
|
383
404
|
o.kind !== "chip" &&
|
|
384
|
-
o.kind !== "lines"
|
|
385
|
-
|
|
405
|
+
o.kind !== "lines" &&
|
|
406
|
+
o.kind !== "meter" &&
|
|
407
|
+
o.kind !== "rating" &&
|
|
408
|
+
o.kind !== "thumbnail") {
|
|
409
|
+
c.add(`${path}/props/columns/${i}/kind`, "PROPS_INVALID_VALUE", `data-table column "kind" must be one of text | chip | lines | meter | rating | thumbnail`);
|
|
410
|
+
}
|
|
411
|
+
if (o.thresholds !== undefined && !Array.isArray(o.thresholds)) {
|
|
412
|
+
c.add(`${path}/props/columns/${i}/thresholds`, "PROPS_INVALID_VALUE", `data-table column "thresholds" must be an array of {at, tone}`);
|
|
413
|
+
}
|
|
414
|
+
if (o.max !== undefined && typeof o.max !== "number") {
|
|
415
|
+
c.add(`${path}/props/columns/${i}/max`, "PROPS_INVALID_VALUE", `data-table column "max" must be a number`);
|
|
386
416
|
}
|
|
387
417
|
if (o.subKey !== undefined && typeof o.subKey !== "string") {
|
|
388
418
|
c.add(`${path}/props/columns/${i}/subKey`, "PROPS_INVALID_VALUE", `data-table column "subKey" must be a string`);
|
|
@@ -403,6 +433,11 @@ function validateDataTable(n, path, c) {
|
|
|
403
433
|
}
|
|
404
434
|
// SRP v0.3 — optional data-grid props.
|
|
405
435
|
validateDataTableV3Props(props, path, c);
|
|
436
|
+
// SRP v0.5 — sticky columns.
|
|
437
|
+
if (props.stickyColumns !== undefined &&
|
|
438
|
+
(typeof props.stickyColumns !== "number" || props.stickyColumns < 0)) {
|
|
439
|
+
c.add(`${path}/props/stickyColumns`, "PROPS_INVALID_VALUE", `data-table "stickyColumns" must be a non-negative number`);
|
|
440
|
+
}
|
|
406
441
|
const bind = n.bind;
|
|
407
442
|
if (!bind) {
|
|
408
443
|
c.add(`${path}/bind`, "BIND_MISSING_REQUIRED", `data-table requires "bind.query" or "bind.rows"`);
|
|
@@ -665,6 +700,119 @@ function validateTagInput(n, path, c) {
|
|
|
665
700
|
}
|
|
666
701
|
}
|
|
667
702
|
// ---------------------------------------------------------------------------
|
|
703
|
+
// SRP v0.5 node validators
|
|
704
|
+
// ---------------------------------------------------------------------------
|
|
705
|
+
const POPOVER_ALIGNS = ["start", "center", "end"];
|
|
706
|
+
const THUMBNAIL_RADII = ["none", "sm", "md", "lg", "full"];
|
|
707
|
+
const THUMBNAIL_ASPECTS = ["square", "video", "wide"];
|
|
708
|
+
function validatePopover(n, path, c) {
|
|
709
|
+
const props = (n.props ?? {});
|
|
710
|
+
if (typeof props.label !== "string" || props.label.length === 0) {
|
|
711
|
+
c.add(`${path}/props/label`, "PROPS_MISSING_REQUIRED", `popover requires a non-empty "props.label"`);
|
|
712
|
+
}
|
|
713
|
+
if (props.align !== undefined &&
|
|
714
|
+
(typeof props.align !== "string" ||
|
|
715
|
+
!POPOVER_ALIGNS.includes(props.align))) {
|
|
716
|
+
c.add(`${path}/props/align`, "PROPS_INVALID_VALUE", `popover "props.align" must be one of ${POPOVER_ALIGNS.join(" | ")}`);
|
|
717
|
+
}
|
|
718
|
+
if ("children" in n && n.children !== undefined && !Array.isArray(n.children)) {
|
|
719
|
+
c.add(`${path}/children`, "CHILDREN_NOT_ARRAY", `popover "children" must be an array`);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
function validateSlider(n, path, c) {
|
|
723
|
+
const props = (n.props ?? {});
|
|
724
|
+
if (typeof props.min !== "number" || typeof props.max !== "number") {
|
|
725
|
+
c.add(`${path}/props`, "PROPS_MISSING_REQUIRED", `slider requires numeric "props.min" and "props.max"`);
|
|
726
|
+
}
|
|
727
|
+
if (props.tone !== undefined &&
|
|
728
|
+
(typeof props.tone !== "string" || !VIZ_TONES.includes(props.tone))) {
|
|
729
|
+
c.add(`${path}/props/tone`, "PROPS_INVALID_VALUE", `slider "props.tone" must be one of ${VIZ_TONES.join(" | ")}`);
|
|
730
|
+
}
|
|
731
|
+
const bind = n.bind;
|
|
732
|
+
if (!bind || typeof bind.value !== "number") {
|
|
733
|
+
c.add(`${path}/bind/value`, "BIND_MISSING_REQUIRED", `slider requires "bind.value" (a number)`);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
function validateRating(n, path, c) {
|
|
737
|
+
const props = (n.props ?? {});
|
|
738
|
+
if (props.max !== undefined && typeof props.max !== "number") {
|
|
739
|
+
c.add(`${path}/props/max`, "PROPS_INVALID_VALUE", `rating "props.max" must be a number`);
|
|
740
|
+
}
|
|
741
|
+
const bind = n.bind;
|
|
742
|
+
if (!bind || typeof bind.value !== "number") {
|
|
743
|
+
c.add(`${path}/bind/value`, "BIND_MISSING_REQUIRED", `rating requires "bind.value" (a number)`);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
function validateThumbnail(n, path, c) {
|
|
747
|
+
const props = (n.props ?? {});
|
|
748
|
+
if (typeof props.alt !== "string" || props.alt.length === 0) {
|
|
749
|
+
c.add(`${path}/props/alt`, "PROPS_MISSING_REQUIRED", `thumbnail requires a non-empty "props.alt"`);
|
|
750
|
+
}
|
|
751
|
+
if (props.radius !== undefined &&
|
|
752
|
+
(typeof props.radius !== "string" ||
|
|
753
|
+
!THUMBNAIL_RADII.includes(props.radius))) {
|
|
754
|
+
c.add(`${path}/props/radius`, "PROPS_INVALID_VALUE", `thumbnail "props.radius" must be one of ${THUMBNAIL_RADII.join(" | ")}`);
|
|
755
|
+
}
|
|
756
|
+
if (props.aspect !== undefined &&
|
|
757
|
+
(typeof props.aspect !== "string" ||
|
|
758
|
+
!THUMBNAIL_ASPECTS.includes(props.aspect))) {
|
|
759
|
+
c.add(`${path}/props/aspect`, "PROPS_INVALID_VALUE", `thumbnail "props.aspect" must be one of ${THUMBNAIL_ASPECTS.join(" | ")}`);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
// ---------------------------------------------------------------------------
|
|
763
|
+
// SRP v0.6 node validators
|
|
764
|
+
// ---------------------------------------------------------------------------
|
|
765
|
+
function validateFacetGrid(n, path, c) {
|
|
766
|
+
const props = (n.props ?? {});
|
|
767
|
+
if (!Array.isArray(props.facets) || props.facets.length === 0) {
|
|
768
|
+
c.add(`${path}/props/facets`, "PROPS_MISSING_REQUIRED", `facet-grid requires a non-empty "props.facets" array`);
|
|
769
|
+
}
|
|
770
|
+
else {
|
|
771
|
+
props.facets.forEach((facet, i) => {
|
|
772
|
+
if (typeof facet !== "object" || facet === null) {
|
|
773
|
+
c.add(`${path}/props/facets/${i}`, "PROPS_INVALID_VALUE", `facet-grid facet must be an object`);
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
const f = facet;
|
|
777
|
+
if (typeof f.id !== "string" || typeof f.label !== "string") {
|
|
778
|
+
c.add(`${path}/props/facets/${i}`, "PROPS_INVALID_VALUE", `facet-grid facet must have string "id" and "label"`);
|
|
779
|
+
}
|
|
780
|
+
if (!Array.isArray(f.options)) {
|
|
781
|
+
c.add(`${path}/props/facets/${i}/options`, "PROPS_INVALID_VALUE", `facet-grid facet "options" must be an array`);
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
const bind = n.bind;
|
|
786
|
+
if (!bind || typeof bind.active !== "string") {
|
|
787
|
+
c.add(`${path}/bind/active`, "BIND_MISSING_REQUIRED", `facet-grid requires "bind.active" (the active category id)`);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function validateColumnConfig(n, path, c) {
|
|
791
|
+
const props = (n.props ?? {});
|
|
792
|
+
if (!Array.isArray(props.columns) || props.columns.length === 0) {
|
|
793
|
+
c.add(`${path}/props/columns`, "PROPS_MISSING_REQUIRED", `column-config requires a non-empty "props.columns" array`);
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
props.columns.forEach((col, i) => {
|
|
797
|
+
if (typeof col !== "object" ||
|
|
798
|
+
col === null ||
|
|
799
|
+
typeof col.id !== "string" ||
|
|
800
|
+
typeof col.label !== "string") {
|
|
801
|
+
c.add(`${path}/props/columns/${i}`, "PROPS_INVALID_VALUE", `column-config column must have string "id" and "label"`);
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
if (props.presets !== undefined && !Array.isArray(props.presets)) {
|
|
806
|
+
c.add(`${path}/props/presets`, "PROPS_INVALID_VALUE", `column-config "props.presets" must be an array`);
|
|
807
|
+
}
|
|
808
|
+
const bind = n.bind;
|
|
809
|
+
if (!bind ||
|
|
810
|
+
!Array.isArray(bind.visible) ||
|
|
811
|
+
!bind.visible.every((v) => typeof v === "string")) {
|
|
812
|
+
c.add(`${path}/bind/visible`, "BIND_MISSING_REQUIRED", `column-config requires "bind.visible" (an array of column ids)`);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
// ---------------------------------------------------------------------------
|
|
668
816
|
// Helpers for library consumers
|
|
669
817
|
// ---------------------------------------------------------------------------
|
|
670
818
|
/**
|