@ 受影响/ 计划
以 SchemaStore 形状的 Draft-07 JSON Schema 文档发布效果 Schemas 。 核心 effect 已经生成 JSON Schema (Schema.toJsonSchemaDocument)并降低到草案07(JsonSchema.toDocumentDraft07); 此软件包拥有什么 司马斯托尔 编辑们期望这一产出——出版形状、主机身份文件发表在下面、关键词-家庭门、目录条目、插图、版本、Cononic JSON和内容比较文件IO——和 effected schema 命令从一个配置文件中运行全部.
预
1.0.0。 。 。 . 此软件包是@effected/*在稳定基础上建造的工具包 效应v4(effect~4.1.0) 并仍在0.x发展。 稳定效果 制作一个工具箱1.0.0可能,不是自动的。 为了保持你的effect财务报告和审定财务报表@effect/*该工具包在线上构建和测试、安装@effected/pnpm-plugin-effected。 。 。 .稳定:不稳定. 此软件包的 API 表面尚未考虑 完成并可能改变
0.x释放 定一个确切的版本——甚至 标记软件包 稳定 在此之前1.0.0可以引入突破性更改 和精确的针 变成一个类型检查错误 而不是一个 跑步时间惊喜。 完全政策: 释放策略。 。 。 .
安装
两个角色:这个库是发布 schema(它的代码读取 schema 的身份在运行时)的应用程序的常规依赖,以及 @effected/plugin 是提供 effected schema 命令,用于构建和检查文档.
pnpm add @effected/schemastore effect
pnpm add -D @effected/plugin
要求节点.js >=24.11.0. 仅限无害环境管理. effect v4是唯一的对等者; @effected/semver (版本命令)是唯一的运行时间依赖. 这里没有验证引擎—— SchemaValidator 是合同,运出ajv严格型号的发动机是 AjvValidator 内 @effected/engine/schema ——在运行时导入此软件包从不安装或捆绑 ajv.
这两套东西怎么搭配的
模式有三个部分。 申请宣布每个计划 主机身份 一次,在计划旁边,阅读 $schema URL,它从中写入自己的输出. 配置文件将相同的值交到 defineConfig命令产生每一个路径, $id 和目录 URL 从他们, 所以没有拼写两次.
// src/schema/output.ts — the application
import { HostedSchema } from "@effected/schemastore";
import { Schema } from "effect";
export const OUTPUT_SCHEMA_VERSION = "5.2";
export const OutputSchemaIdentity = HostedSchema.github({
repo: "savvy-web/silk-release-action",
path: "schemas",
name: "silk-release-action.output",
versions: [OUTPUT_SCHEMA_VERSION],
});
// Every payload the application emits names the document it was written against.
export const ReleaseOutput = Schema.Struct({
$schema: Schema.Literal(OutputSchemaIdentity.$id),
status: Schema.Literals(["released", "skipped"]),
});
// schemastore.config.ts — the config
import { defineConfig } from "@effected/schemastore";
import { OutputSchemaIdentity, ReleaseOutput } from "./src/schema/output.js";
export default defineConfig({
name: "silk-release-action",
outputDir: "schemas",
schemas: {
[OutputSchemaIdentity.name]: { schema: ReleaseOutput, hosted: OutputSchemaIdentity },
},
});
{
"scripts": {
"schema:build": "effected schema build",
"schema:check": "effected schema check"
}
}
effected schema build 写入 schemas/5.2/silk-release-action.output-5.2.json 与 $id 等于 OutputSchemaIdentity.$id,封闭对象(additionalProperties: false页:1 $schema 说明申请所声称的内容. effected schema check 是 CI 门: 当一个建筑会写出任何东西时, 它失败 。 弹出版本为一常. 命令所做的一切——漂移政策 published 旗帜、被冻结的标签、目录文件、退出代码——记录在 工具的页面。 。 。 .
HostedSchema.github({ repo, branch?, path?, ... }) 从寄存器中服务原始文件( e)branch 默认为 main(三); HostedSchema.schemastore({ name, ... }) 向SchemaStore出版($id 打开 json.schemastore.org,打开目录 URL www.schemastore.org平面布局; HostedSchema.custom({ baseUrl, ... }) 使用任意 https:// 作为字符串或 URL每一个都验证身份—— current 必须是其中之一 versions,两个拼写一个标签被拒绝——并扔出平地 Error 命名原因. $id, (中文(简体) ), url 财务报告和审定财务报表 fileName 答复当前文件; idFor, (中文(简体) ), urlFor 财务报告和审定财务报表 fileNameFor 回答任何广告版本。 版本文件带有 SchemaStore 的 -<version> 默认后缀; 当版本目录只命名文件时(schemas/6.0/output.json,自然当寄存器已经命名工具时),通过 appendVersion: false -它需要的就是... -我需要... - it needs the "versioned" 版式,因为 "flat" 每个版本都会共享一个文件名. 消费者测试针 target.path === \${outputDir}/${身份. file {}to catch a swapped主办方:`国家行动倡议看不到.
直接使用库
命令所编作的一切都是输出的,对于一个需要一块或想自己驱动管道的程序.
StoreDocument.fromSchema 运行一个组件——2020-12代,Draft-07降低 #/definitions → #/$defs 重写和关键词 - 家门—— 所以每个 $ref 在已建文件中 $defs 池内 :
import { StoreDocument } from "@effected/schemastore";
import { Effect, Schema } from "effect";
const Config = Schema.Struct({ name: Schema.String });
const program = Effect.gen(function* () {
const document = yield* StoreDocument.fromSchema(Config, {
$id: "https://example.com/config.schema.json",
});
return yield* Effect.fromResult(document.serializeResult());
});
// { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "…", "type": "object", …, "additionalProperties": false }
对象默认关闭——一个已发布的文档是合同,而这个软件包并不遵循核心的开放默认. jsonSchema: { onExcessProperty: "ignore" } 一个目标(或一个) defineConfig )重新打开文档.
SchemaPipeline.run(targets) 是一个目标显示的发射回路——生成、涂抹、验证、门、写——需要 SchemaFile 财务报告和审定财务报表 SchemaValidator 内 R。在边缘提供文件服务和引擎;引擎是 @effected/engine/schema':
import { SchemaFile, SchemaPipeline, SchemaTarget } from "@effected/schemastore";
import { AjvValidator } from "@effected/engine/schema";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { Effect, Layer, Schema } from "effect";
const targets = [
SchemaTarget.make({
schema: Schema.Struct({ name: Schema.String }),
$id: "https://example.com/config.schema.json",
path: "schemas/config.schema.json",
}),
];
const program = SchemaPipeline.run(targets).pipe(
Effect.provide(Layer.mergeAll(SchemaFile.layer, AjvValidator.layer).pipe(Layer.provide(NodeServices.layer))),
);
run 目标分为两相或全相或全相:每个目标都是生成的、有门的和——为固定版本——在撰写任何文件之前按其前身分类。 阻断查找失败 SchemaGateError; 绑定的、已公布版本的合同更改失败 SchemaContractChangeError 携带 nextVersion 改为:contractChanges: "allow" 仅分类和报告). check 和没有写作的一样 调查结果是数值,从不记录,以及指向上游(blocking)是你的替换.
图书馆拥有的
HostedSchema——一个schema的主机身份(github, (中文(简体) ),schemastore, (中文(简体) ),custom),产生$id,当前版本或任何广告版本的目录 URL和文件名.defineConfig- 那个schemastore.config.ts合同:经一个合同确认Schema.Struct每个关卡(一个打字"d"键被命名,一个条目上的每期一次报告),一个需要的配置name(其目录片的基名),来自条目密钥及其身份的每一个路径和URL,一个可选的catalog.name显示名称( 默认为密钥, 在配置中独有) , 重新命名目录条目, 没有其它名称, 冻结的标签被解析 , 这是 CLI 识别的品牌结果 .StoreDocument- 组装:fromSchema编号 :fromSchemaResult,则draft07手建文件的构造器,平面toJson()出版物形状,serializeResult(), (中文(简体) ),DRAFT_07_META_SCHEMA。 。 。 .KeywordFamilies申报的非标准关键字家族登记册(vscode 5,x-taplo, (中文(简体) ),x-tombi-, (中文(简体) ),x-intellij-还有房子x-ai-机器命名空间)。 外面的任何东西都失败了fromSchema与UndeclaredAnnotationKeyError;没有什么是默默地放弃的.SchemaVersioning编号 :SchemaVersion1至3个组件版本标签,Order, (中文(简体) ),latest, (中文(简体) ),isPinned, (中文(简体) ),next,则fileName编号 :schemaUrl编号 :catalogUrls衍生物.CatalogEntry- 那个catalog.json作为条目Schema.Class, (中文(简体) ),assemble用于目录模式和目录模式fileMatch卫生用品.DocumentLint——总结构线条UnresolvedRef, (中文(简体) ),UnknownKeyword, (中文(简体) ),DepthExceeded, (中文(简体) ),DescriptionWithoutUrl),发现作为价值.SchemaValidator审定合同:noop关掉它,makeTest编号 :layerTest是双倍的;ValidationFinding财务报告和审定财务报表SchemaValidatorError是它的价值观。 发动机是AjvValidator内@effected/engine/schema。 。 。 .DocumentDiff—— 说classify两个文件作为"none"编号 :"annotations"编号 :"contract",表示更改是否需要新版本.DriftPolicy——适用CLI的生命周期规则:published文档为容忍(strict编号 :semantic编号 :allow),未出版的被重新生成.SchemaPipeline——出环:run编号 :check, (中文(简体) ),runOne编号 :checkOne大门和合同警卫.SchemaFile——写出-如果修改了IO于核心FileSystem编号 :Path,通过解析内容进行比较,所以拥有文件文本的前题不会切入;check是非写入的一半.CanonicalJson确定序列器(插入顺序、制表符、一条后继新行、打出故障)和equals一个内容平等规则.
许可证
麻省理工学院