This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(data-objectstack): queryDataset 返回的 fields 元素改用 spec 的 AnalyticsResult.fields[] 类型 (#3752) - #3817
Merged
Conversation
…alyticsResult element (#3752) The return-value half of the drift #3613/#3753 fixed on the parameter side. The adapter hand-listed five keys for a result column (name/type/label/format/ currency) and, like every restatement, stopped at the contract of the day it was written: it never grew percentScale, which @objectstack/spec@17.0.0-rc.5 carries on AnalyticsResult.fields[] and documents as mandatory reading — "renderers that receive it must scale by it instead of guessing from the value" (#3136). Three in-repo consumers (plugin-dashboard, plugin-report, DatasetPreview) read the key through @object-ui/core's local DatasetResultField, so nothing was red here; but an author reading columns through the adapter's DECLARED return type got "Property 'percentScale' does not exist" — the declaration steering them back to the guess-by-magnitude #3136 banned. fields is now the spec element by reference, additively for existing consumers. The rest of the envelope stays locally declared on purpose: the route adds ADR-0021 D2 drill metadata on top of AnalyticsResult, and this method rebuilds its own object without copying sql (index.ts:3355), so an intersection with AnalyticsResult would advertise a key the adapter structurally cannot return. queryDataset.test.ts pins structural identity with the spec element, pins percentScale as the 'fraction' | 'whole' union rather than a widened string, keeps a negative pin against the five-key shape, pins the envelope as NOT an AnalyticsResult, and reads percentScale off a column through the declared type at runtime.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Contributor
Author
|
✅ 验收通过(objectui 分片 PM,session_01GTRjn8xBqp75dk7kFupVRt)—— undraft + auto-merge。 方向裁定采纳:守 B 不升 A 的论证质量高 —— A 的前提失效点不在服务端(路由确实回全 核验:净 diff 3 文件(PM 前跳已核);sabotage 方向先判后跑(红信号在 tsc 非 vitest,8 条错误含 issue 描述的外部作者现场两处);消费半径三包 type-check 零变化(预期=实测);19 项 CI 全绿含承载类型钉子的 Type Check。changeset patch 同族先例。dev 的 curl 假绿自曝(GH_TOKEN 空 + 无 check_runs 键读成 PENDING 0)为该失败类第五例,结论全部改由鉴权通道 —— 处置正确。衍生:#3813(adapter 丢 Generated by Claude Code |
yinlianghui
marked this pull request as ready for review
August 8, 2026 17:36
This was referenced Aug 8, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #3752
做了什么
ObjectStackAdapter.queryDataset返回类型里fields的元素形状,由手写的五键改成 spec 拥有的那一个类型:JSDoc 一并改写:原来那段逐项列举("a display
label…, and a measure's numeralformat+ declaredcurrency")本身就是第二方言的载体 —— 它和被删的类型犯的是同一个错,停在了写它那天的 spec 上。新注释指向 spec、不再复述键名,只留下"为什么只有这一项派生"的理由。为什么漏项不是纸面问题
实装
@objectstack/spec@17.0.0-rc.5的AnalyticsResult.fields[]除那五项外还有percentScale?: PercentScale,spec 注释写明「renderers that receive it must scale by it instead of guessing from the value (objectui#3136)」。仓内三个消费端(plugin-dashboard/plugin-report/DatasetPreview)靠@object-ui/core的本地DatasetResultField读到它,所以今天不红;而按 adapter 声明的返回类型取值的外部作者会拿到Property 'percentScale' does not exist—— 声明在把作者推回 #3136 明令禁止的"按数值大小猜刻度"。取向:守 B,不升 A(实读 framework 路由后的结论)
派单允许在"实证服务端回全
AnalyticsResult"时升级为 A(整体交叉类型)。实读后结论相反,且证据在本仓自己这边:objectstack@ea1d9165d)packages/rest/src/rest-server.ts的POST /analytics/dataset/query是res.json(result),原样下发svc.queryDataset(...)的结果;packages/services/service-analytics/src/analytics-service.ts:614声明返回Promise< AnalyticsResult >,并在:745起把 ADR-0021 D2 的钻取旁路(object/dimensionFields/drillRawRows/drillRawTotals/drillRanges)通过AnalyticsResultWithDrill加在AnalyticsResult之上。也就是说线上信封确实是「AnalyticsResult+ 增量」。packages/data-objectstack/src/index.ts:3355是return { rows, fields, object, dimensionFields, drillRawRows, totals };—— 逐项挑键,从不拷贝sql。所以哪怕路由回全,声明成AnalyticsResult & { … }也会向调用方广告一个本方法结构上永远不会给出的键(sql?: string虽是可选,但"可能有"本身就是假声明)。因此 A 的前提在本仓一侧就不成立,和路由回不回
sql无关。信封其余字段保持本地声明,并把这个事实钉成测试(_NoSql),下一个读者不必再重查一遍。类型钉子与 sabotage 自证
packages/data-objectstack/src/queryDataset.test.ts追加一段(沿用本包 #3613 那节的Assert/Equal范式;本包 tsconfig 编译自己的测试树,所以这些钉子由tsc --noEmit承载):_IsTheSpecField—— 与 spec 元素结构相等(用Equal而非extends:窄化的手抄件在漂移方向上仍然可赋值)。_HasPercentScale/_PercentScaleIsTheSpecUnion/_PercentScaleIsNotString—— 点名那一个漏键,并钉住它是'fraction' | 'whole'而不是被放宽的string。_NotTheFiveKeyCopy—— 负向钉子:把手写五键放回去就红,sabotage 方向写进测试而不是只写进 commit message。_NoSql/_HasDrillObject/_HasDimensionFields/_HasDrillRawRows—— 钉住"信封不是AnalyticsResult"这个取向。percentScale: 'fraction'的列,经声明类型读出来仍是'fraction'(修前这一行根本不编译)。sabotage(临时把五键手写形状放回
index.ts,未入 commit)。预判方向:vitest 只做类型擦除、不会变红,红信号必须来自tsc --noEmit—— 实测如此::345那两条正是 issue 描述的外部作者现场:读一列的percentScale编译不过。还原后tsc --noEmit无输出(绿)。验证
pnpm vitest run packages/data-objectstack --maxWorkers=2—— 24 files / 359 tests passed(含新增的 3 个断言块)。pnpm --filter @object-ui/data-objectstack type-check—— 绿(钉子在这里生效)。pnpm --filter @object-ui/data-objectstack lint—— 0 errors(330 个既有no-explicit-anywarning,与本改动无关)。plugin-dashboard/plugin-report/app-shell三个读percentScale的包type-check全绿、零改动 —— 与预期一致,它们走@object-ui/core的本地类型,而本改动对它们是加性的(多一个可选键)。node scripts/check-control-bytes.mjs—— OK(3733 个文件);改动文件另做grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f]'自扫,零命中。Changeset
.changeset/dataset-result-fields-spec-type-3752.md,@object-ui/data-objectstack: patch—— 类型面修正、对既有消费者加性,与同族的 #3753(dataset-selection-spec-type-3613.md)同档。顺手核对与越界发现(均已单开,本 PR 不修)
finding,只核对不实施):packages/core/src/utils/dataset-format.ts:29的DatasetResultField仍是同一契约的手写重述。今天没有漂移(六键齐,PercentScale还是从@objectstack/spec/dataimport 的真身),唯一形状差异是type被放宽成可选而 spec 必填。属休眠漂移面,且改它要先决type可选性是否有意、以及公开名字的兼容路线,跨packages/core面 —— 超出本单文件面,故只记录。index.ts:3355的挑键式返回丢掉了服务端的drillRanges,而DatasetWidget.tsx:471/593与DatasetReportRenderer.tsx:316/431/855都在读它 —— 只按日期维度分组的图表因此canDrill === false,chore(deps): bump @sentry/react from 10.56.0 to 10.57.0 #1752 的日期分桶钻取经真实 adapter 永不可用。现有测试看不见,因为两边的测试都用自己 mock 的 data source 直接喂这个键。与本 PR 同一处代码但是运行时行为改动,按 PD [WIP] Enhance every detail of the designer #10 不并入纯类型面的这个 PR。Generated by Claude Code