Repository navigation
Commit d3f23d2
fix(core): resolve {next_week_end} and {next_year_end} in the client date-macro resolver (#30364)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgNTEGwukC81vXo95pnRQCnF)_
Fixes #30134
domain:ui#3 · os-bill · session_01Utp6CbPN5UYMnBaNJPJWfG
Clause-②: no — the client resolver catches up with tokens the spec
already declares
Metadata-protocol: none
## 维护者速读
- 改了什么:控制台的日期占位符解析器补上 `{next_week_end}`(下周日)与 `{next_year_end}`(明年 12 月
31 日),并加一条测试逐个核对 spec 声明的全部固定占位符都能在客户端解析。
- 为什么改:spec 早已声明这两个占位符,服务端也能解析,但控制台原样显示 `{next_week_end}`
文本,比较区间与趋势标签随之出错。
- 风险与回滚:只新增两个映射,既有占位符不变;回滚即撤销本 PR,无数据迁移。
-
先看:`ui/packages/core/src/utils/date-macros.ts`(两行新映射)、`date-macros.specTokens-30134.test.ts`(防漂移钉)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/core/src/utils/__tests__/date-macros.specTokens-30134.test.ts`,预期
38 条全绿。
- 需要你做的:无,席位落地。
## What changes
- `resolveDateMacros` (`@object-ui/core`) resolves `{next_week_end}` as
the Sunday of next week (Monday-start weeks, the same week
`{next_week_start}` opens, per the spec's `DATE_MACRO_DESCRIPTIONS`
entry "Sunday of next week") and `{next_year_end}` as Dec 31 of next
year ("Dec 31 of next year").
- The resolver's header list now names both, and its "keep in sync" note
points at the new pin instead of promising a future de-duplication.
- New `date-macros.specTokens-30134.test.ts`: iterates the spec's
exported `DATE_MACRO_TOKENS` (imported from `@objectstack/spec/data`,
not copied) and fails on any token the client leaves unresolved; pins
`next_week_end` from a Monday, a Sunday and across the 2026→2027 year
boundary (Wed 2026-12-30 → `2027-01-04`..`2027-01-10`), and
`next_year_end` on Dec 31 and Jan 1.
- No new dependency: `@object-ui/core` already depends on
`@objectstack/spec` at runtime.
- Changeset `@object-ui/core: patch`.
## Tests
<details><summary>Changed tests plus every test file importing the
changed module or its importers (head 8dec3da, re-run after the main
merge)</summary>
- `pnpm --dir ui exec vitest run` over the 5 `date-macros` /
`dashboard-filters` / `filter-tokens` test files: Test Files 5 passed,
Tests 114 passed.
- The 13 test files importing `compare-to` / `dashboard-filters` /
`filter-tokens`: Test Files 13 passed, Tests 250 passed.
- After merging `origin/main`: the two `date-macros` files, Tests 46
passed.
- `pnpm exec turbo run type-check --filter=@object-ui/core
--concurrency=2` (runs `tsconfig.test.json` too): 4 tasks successful.
- Ablation (`scripts/ablation-replace.mjs --delete` of the
`next_week_end` entry, source import, no dist on the path): the new file
went red, 2 failed (`{next_week_end} resolves to a day or an instant`,
`{next_week_end} is the Sunday of next week`); `git diff HEAD` empty
after the restore leg.
</details>
## Acceptance notes
- The card's observation on `ui/packages/types/src/data-protocol.ts`
(`FilterBuilderDateRangePreset`) is not changed here. The union is a
deliberately separate vocabulary (renamed from `DateRangePreset` in
objectui#4167 because it adds future windows the dashboard schema
refuses), so deriving it from `DATE_RANGE_PRESETS` would drop
`tomorrow`, `next_week`, `next_year`, `next_7_days` and `next_90_days`
that its filter-builder surface uses. Its doc comment's counts
("thirteen", "eight") no longer match the spec table, which now holds
sixteen. Reported to the seat; not filed.
## Verification
<details><summary>dispatch-gates on 8dec3da</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 35 derived families, each run with its exit
code recorded before any pipe, all exit 0 (including `node
scripts/check-sdui-manifest.mjs`). `--ran` reconciliation: 35 derived,
35 run, 0 NOT-MEASURED, 0 UNRUN.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CXcHcEtzn8WgUC46Xj)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 7945a3b commit d3f23d2
3 files changed
Lines changed: 65 additions & 5 deletions
File tree
- .changeset
- ui/packages/core/src/utils
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| 133 | + | |
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| 139 | + | |
136 | 140 | | |
137 | 141 | | |
138 | 142 | | |
| |||
0 commit comments