@ggts-sh/ spec( 秒)
便携式Spec类型,出版的JSON Schema, normalize()双层
validate() 与代理错误合同
(单位:千美元){ code, path, message, allowed?, fix }, (中文(简体) ), lintSpec()和流畅
gg() 编号 : aes() 建会者. 没有DOM,没有D3. 预1.0.
bun add @ggts-sh/spec # or: npm install @ggts-sh/spec
单独安装以进行校验和编写,不设渲染器.
@ggts-sh/svelte
再导出此软件包.
快速实例
import { gg, aes, validate } from "@ggts-sh/spec";
// constrained decoding / tool schemas
import schema from "@ggts-sh/spec/schema/v0.json";
const spec = gg(
[
{ year: "1835", value: 12 },
{ year: "2026", value: 31 },
],
aes({ x: "year", y: "value" }),
)
.geomLine()
.spec();
const result = validate(spec, {
profile: {
fields: [
{ name: "year", type: "temporal" },
{ name: "value", type: "quantitative" },
],
},
lint: true,
});
if (!result.ok) {
// Apply fix.example at path, then re-validate.
// { code, path, message, allowed?, fix: { description, example } }
}
代理合同
validate(spec)-只有形状.validate(spec, { profile })——数据认识无航运行.validate(spec, { lint: true })关于有效但有疑问的规格的建议.- 每一个错误都带有
fix.example应用到path并重新验证. - 便携式Spec 仅为 JSON : 否
Date、召回或正则表达式. 构建器Date值到 ISO 字符串. - JSON Aes 用途
{ field: "col" }(JSON中的空字符串无效). 这个 建筑师和斯维尔特道具接受光弦短手.
渲染器
- 无头 SVG :
@ggts-sh/core(单位:千美元)renderToSVGString(中文(简体) ) - CLI 环( 验证 + stderr 上的警告) :
@ggts-sh/cli(单位:千美元)ggts render(中文(简体) ) - 斯维尔特5:
@ggts-sh/svelte
司马: 计划/v0.json * 文件: ggts.sh (英语) • 恢复: github.com/ggts-sh/ggts (英语)
麻省理工学院 利亚姆·奥德