fix(spec): anchor the Schema-suffix strip when deriving published schema names (#4592) - #4625
Merged
Merged
Conversation
…ema names (#4592) build-schemas.ts and build-docs.ts derived the published JSON Schema name via key.replace('Schema', '') — a string pattern, which replaces the FIRST occurrence. Consts with 'Schema' in prefix/middle position (SchemaModeSchema, SchemaChangeSchema, SchemaLevelIsolationStrategySchema, DocumentSchemaValidationSchema) lost an inner segment instead of the suffix, publishing $id URLs, manifest keys and docs sections under type names that exist nowhere in the export surface. - extract the mapping into scripts/lib/schema-name.ts (schemaNameFromExportKey, /Schema$/ anchored) shared by both generators, with a pin test covering the four mangled names - swap the 4 stale json-schema.manifest.json keys for the corrected ones (deliberate retirement per #2978 — the old names never named a real type) - rename the 14 affected authorable-surface.json key prefixes (rename, not a key retirement: every authorable key survives under the corrected name) - shrink docs-import-surface.baseline.json 152 -> 144 (the 4 'no schema const export' / 'no type export' pairs are gaps that no longer exist) - regenerate the 4 reference-doc pages: sections renamed, real import examples restored Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 107 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
os-zhuang
marked this pull request as ready for review
August 2, 2026 12:04
os-zhuang
enabled auto-merge
August 2, 2026 12:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4592
问题
packages/spec/scripts/build-schemas.ts:200与build-docs.ts:133用字符串key.replace('Schema', '')把导出常量名转成发布的 JSON Schema 名。String.prototype.replace(string, …)只替换第一处出现,因此名字里前缀/中间也含Schema的 4 个常量被剥掉的不是后缀,而是名字内部的一段:SchemaModeSchemadata/ModeSchemadata/SchemaModeSchemaChangeSchemasystem/ChangeSchemasystem/SchemaChangeSchemaLevelIsolationStrategySchemasystem/LevelIsolationStrategySchemasystem/SchemaLevelIsolationStrategyDocumentSchemaValidationSchemadata/DocumentValidationSchemadata/DocumentSchemaValidation错名同时污染三处对外表面:
$idURL、json-schema.manifest.json棘轮键、参考文档页的小节标题与 import 示例(#4570 之后这 4 个名字在真实导出面查无此名,import 行被剔除,记为 baseline 里 4 对no schema const export/no type export)。修复
scripts/lib/schema-name.ts的schemaNameFromExportKey(锚定后缀的key.replace(/Schema$/, '')),build-schemas.ts与build-docs.ts都改为引用它,避免两个生成器再次各自漂移。scripts/schema-name.test.ts(vitest 已收录scripts/**/*.test.ts):覆盖上表 4 个前缀含Schema的名字、普通后缀、无后缀、双Schema后缀等情形。回退成字符串 replace 时,前缀组 4 个用例即红。$id名从未对应任何真实导出类型,属于 gen:schema silently drops PageTabsProps since #2967 — references regen would delete real docs #2978 所述「必须在同一 PR 中有意删除」的范畴,非静默消失。no schema const export/no type export缺口已消失,build-docs.ts --update-import-baseline按棘轮规则删行(shrink-only)。data/datasource、data/driver-nosql、system/deploy-bundle、system/tenant):小节标题改为真实类型名,import 示例恢复(如import { SchemaModeSchema } from '@objectstack/spec/data'/import type { SchemaMode })。.changeset/schema-name-suffix-strip.md,patch):携带 FROM → TO 映射,便于引用旧$id的一方 grep 到一行修法。TS 导出面本身没有任何变化(api-surface.json零 diff,check:api-surface绿)。验证
pnpm --filter @objectstack/spec check:generated:8 个生成物门禁全绿(含check:authorable-surface、check:api-surface、check:docs)。pnpm --filter @objectstack/spec test:291 个文件 / 7285 个用例全部通过(含新 pin 测试)。pnpm --filter @objectstack/spec typecheck:通过。🤖 Generated with Claude Code
https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
Generated by Claude Code