Repository navigation
Commit 1de73c0
feat(rest): the record page composite lock carries lockSource, and the record page hides Delete on a master-held line (#38829)
repo:objectstack@os-justin · os-justin ·
session_01QSeKYnrQ7UMtHofKQVjcH2
Fixes #37195
Clause-②: yes (widening: the record page composite's published `lock`
gains `lockSource`, and the published `@object-ui/types`
`RecordPagePayload.approvals.lock` gains the same optional `lockSource`)
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:审批锁住主单时,明细行的记录页不再显示「删除」;明细行被自己的审批锁住、或没有被锁时,「删除」照旧显示。
- 为什么做:把「被谁锁」这一条已定的裁决(表格已经按它隐藏删除)带到记录页,让记录页不再提供服务器必然拒绝的删除。
- 出错会怎样:最坏情况是明细行在主单被锁时仍显示「删除」,点了之后服务器照样拒绝,数据不受影响;改动可以直接撤回。
- 要你做什么:无。
## What changes
- **Spec** (`packages/spec/src/api/record-page.zod.ts`): the `approvals`
part's `lock` gains the optional member `lockSource: 'record' |
'master'` beside `locked`. Before, the object was non-strict, so a parse
silently stripped the kind. Regenerated
`packages/spec/docs/references/api/record-page.md` with `gen:docs`.
- **REST** (`packages/rest/src/record-page-routes.ts`): the composite
now builds its lock through `recordLockPayload`, the projection both
lock doors already serve (now exported from `approvals-routes.ts`; the
package index does not re-export it). So the fifth door answers
`lockSource` by construction, drops any other field a service returns,
and serves `{ locked: true }` alone when the service names no kind.
`null` still means unreadable, missing, or no lock service.
- **Console** (`ui/packages/app-shell`): `useRecordApprovals` keeps the
kind (`recordLock` passes it through; a new `lockSource` result field
keeps it beside a visible pending request too, since the composite
answers the lock either way). `recordLockAnswerOf` reads the lock door's
untyped answer the way the grid's `useRowApprovalLocks` does; the
composite answer is read through its type. A new helper
`views/recordDeleteHeldByMaster.ts` holds the rule, and
`RecordDetailView` only calls it: Delete goes on `lockSource: 'master'`,
as the grid's row menu does.
- **Types** (`ui/packages/types/src/data.ts`): the published
`@object-ui/types` `RecordPagePayload.approvals.lock` gains the same
optional `lockSource?: 'record' | 'master'`, so the client type matches
the wire; the hook's composite path reads the kind through that type,
and only the untyped lock-door fetch keeps a runtime narrowing
(`recordLockAnswerOf`), as the grid does.
Read first, by risk:
1. `ui/packages/app-shell/src/hooks/useRecordApprovals.ts`, the seeded
branch of `startRead`: the kind is kept beside a pending row, while
`recordLock` stays `null` there as before.
2. `packages/rest/src/record-page-routes.ts`, the `answerApprovals` lock
lines.
3. `packages/spec/src/api/record-page.zod.ts`, the widened `lock`
object.
## Tests
- `packages/rest/src/record-page-routes.test.ts`: parity pin. The same
mocked service answers both the composite and `GET
/approvals/records/:object/:recordId/lock` on one server. The
composite's `approvals.lock` equals the single door's `data` in the four
card cases (own approval; line of a held master; self-held line under a
held master; unheld) plus a locked answer naming no kind. A `null`
answer stays a `null` lock.
- `packages/spec/src/api/record-page.test.ts`: the parse keeps
`lockSource` and refuses an unknown kind at `['lock', 'lockSource']`.
-
`ui/packages/app-shell/src/hooks/useRecordApprovals.lockSource-37195.test.tsx`:
the seeded (composite) path in the same four cases, including the kind
beside a visible pending row.
- `ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx`,
block `deleteFollowsLockSource-37195`: the real page's overflow menu has
no Delete on `master`, and keeps Delete on `record`, unheld, and on a
locked answer naming no kind.
Ablations, each restored with `git checkout HEAD`. Reverting the route
to the old `{ locked }` projection turns 3 parity cases red (the 3
locked-with-kind cases; unheld and no-kind stay green, as expected).
Dropping the view's `recordDeleteHeldByMaster` call turns the `master`
case red.
## Acceptance notes
- PM hypothesis falsified: `MetadataLockSourceSchema`
(`packages/spec/src/kernel/metadata-protection.zod.ts`) is the
metadata-protection enum (`artifact | package | env-forced`), not the
approval kind. The approval kind has no Zod schema anywhere in spec; it
is a TypeScript literal union on `IApprovalService.getRecordLock`. The
kind is therefore declared inline, in the one schema that needs it, with
no new export: `check:api-surface` is unchanged.
- `ui/packages/app-shell/src/views/recordPagePayload.ts` needed no
change: it hands `answer.lock` through, now typed with `lockSource`.
- The fallback read (an adapter without `getRecordPage`, or `refresh()`
after a decision) does not ask the lock door when the viewer can see a
pending request, as before. On that path a self-held line under a held
master keeps Delete until the next page read. This fails open: the
server still refuses with `RECORD_LOCKED`. The composite path, which is
the record page's normal read, answers the kind in that case.
- Out of scope, as the claim says: the two loose-id rows on the card
(7152712740, 7153086539) stay open there. This build does not touch the
doors' anchoring.
## Verification
Two-minute check: `pnpm --filter @objectstack/rest exec vitest run
src/record-page-routes.test.ts`. Expected: the five `lockSource` parity
cases and the null case pass.
<details><summary>Local gates (head 6fae497)</summary>
- Local gates (head 6fae497): `dispatch-gates --ran`: 97 derived
families, 96 run with exit 0 (including `pnpm --dir ui exec vitest run
scripts/`: 172 files, 5159 tests passed), 1 NOT MEASURED:
`check:dual-build-cjs-loads` PREREQUISITE NOT MET because there is no
repo-wide dist (exit 3), owed to CI. `@object-ui/types` build (cache
miss; `dist/data.d.ts` carries `lockSource`) and type-check exit 0;
`@object-ui/app-shell` type-check exit 0; `@objectstack/spec
check:generated` exit 0.
- UI consumers of `useRecordApprovals` / `seedRecordApprovals` /
`recordPagePayload`: 37 files, 331 tests passed (round 0).
</details>
L2: a published schema widens, so a contract-tier review is owed.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d7d4605 commit 1de73c0
13 files changed
Lines changed: 411 additions & 21 deletions
File tree
- .changeset
- packages
- rest/src
- spec
- docs/references/api
- src/api
- ui/packages
- app-shell/src
- hooks
- views
- types/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
140 | 142 | | |
141 | | - | |
| 143 | + | |
142 | 144 | | |
143 | 145 | | |
144 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
830 | 830 | | |
831 | 831 | | |
832 | 832 | | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
482 | 483 | | |
483 | 484 | | |
484 | 485 | | |
485 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
486 | 491 | | |
487 | 492 | | |
488 | | - | |
| 493 | + | |
489 | 494 | | |
490 | 495 | | |
491 | 496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
93 | 100 | | |
94 | 101 | | |
95 | 102 | | |
| |||
498 | 505 | | |
499 | 506 | | |
500 | 507 | | |
501 | | - | |
| 508 | + | |
502 | 509 | | |
503 | 510 | | |
504 | 511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
322 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
323 | 330 | | |
324 | 331 | | |
325 | 332 | | |
| |||
| 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 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
0 commit comments