@pvt-app/dsl
v0.0.1
Published
Pvt DSL schema — chart types, series fields, formulas, format flags, and isomorphic validators. Placeholder release reserving the scope; production API lands in 0.1.0.
Maintainers
Readme
@pvt-app/dsl
Schema + validators for the Pvt chart DSL.
0.0.1 is a scope-placeholder release. The public API will stabilize at
0.1.0. Pin to a specific 0.x version until 1.0 ships.
Install
npm install @pvt-app/dslWhat's inside
- Chart type catalog — every chart type Pvt renders, with aliases, category, and capability flags.
- Series field registry — valid DSL keys (
x,y,groupby,where,format, …) with their accepted types. - Formula catalog — pre-agg, post-agg, and row-level formulas (
sum,avg,top5,bucketnum, …). - Format flag catalog — every flag declared in
[…]bracket notation, by chart type. - Isomorphic validator — no Node built-ins; runs in browser, Node, CLI, and agent sandboxes.
Usage
Query the schema
const schema = require('@pvt-app/dsl');
schema.isValidChartType('bar'); // → true
schema.resolveAlias('column-chart'); // → 'column'
schema.getChartType('waterfall'); // → { category, aliases, supportsStacking, … }
schema.getChartTypesByCategory('stock'); // → ['candlestick', 'ohlc', 'timeseries', 'hlc']
schema.getAllFormulaNames(); // → ['sum', 'avg', 'median', 'top5', …]Validate a DSL string
const { validateDSL, parseDSL } = require('@pvt-app/dsl/validators');
const result = validateDSL(`series: bar
x: State
y: GDP`);
if (!result.valid) {
console.error(result.errors); // [{ line, field, message, suggestion }]
}Validate a color token
const { isValidColor } = require('@pvt-app/dsl/colors');
isValidColor('red'); // → true (HTML name)
isValidColor('#3498db'); // → true (hex)
isValidColor('c3'); // → true (palette index)
isValidColor('mauve'); // → falseCompatibility
- Pure CommonJS; works in Node 18+.
- Zero runtime dependencies.
- Safe for sandboxed execution environments (Code Interpreter, Claude Code sandboxes, serverless).
Stability
This is a pre-1.0 release. The schema query API (isValidChartType, resolveAlias, etc.)
is stable. The validator's error shape may evolve before 1.0.
License
ISC — see LICENSE.
