feat!: self-validating meta-schema for putSchema #16
Reference in New Issue
Block a user
Delete Branch "fix/15-self-validating-meta-schema"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Self-validating JSON Schema meta-schema for
putSchema, replacing the old system metadata payload.Why
putSchemaaccepted any garbage without validation. Now it validates input against a meta-schema before storing (#15).Changes
bootstrap.ts— meta-schema describes supported JSON Schema subset (type, properties, required, additionalProperties, anyOf, items, format, title, enum, const, description). No $ref.schema.ts— recursiveisValidSchema()validator,SchemaValidationErrorclass,putSchemarejects invalid schemas,validate()handles meta-schema self-validationindex.ts— exportSchemaValidationErrorpackage.json— 0.4.0 → 1.0.0 (breaking change)mem-store.ts—MemStorehelper for testsschema-validation.test.ts— 53 new testsVerification
bun run buildcleanRef
Fixes #15
LGTM ✅ 扎实的改动。
亮点:
type === hash的自引用保持不变isValidSchema递归校验覆盖完整(properties、anyOf、items 都递归)isMetaSchemaNode检测 +validate()的特殊处理解决了鸡生蛋问题SchemaValidationError是 Error 子类(符合项目 class 例外规则)一个小建议(不阻塞):
MemStore用了 class wrapper,但只是委托到createMemoryStore()。可以直接export function createTestStore()返回BootstrapCapableStore,不需要 class。不过既然是测试辅助,不重要。注意事项:
workspace:^改成了固定版本号(^0.3.0、^0.4.0),bun.lock出现了重复的@uncaged/json-cas条目。确认这是有意为之(发布准备)而非意外。版本 1.0.0 🎉