Repository navigation
fix(client): subscribeData delivers data.record.restored, reading its event types from the spec - #31509
Conversation
…lares The SDK's data subscriptions read their event types from the spec's DataEventType and BulkDataEventType enums instead of hand lists, so a row restored from the recycle bin (data.record.restored) reaches subscribers. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mbAyTfp7gbjowRA48
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5mbAyTfp7gbjowRA48
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 2 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 19 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 8c29bddc1da276e2d87f759cf95557ca45638ecb && git checkout 8c29bddc1da276e2d87f759cf95557ca45638ecb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7d0b47ca19c8c41563964b3889ae81e8e015788e cba18d9204b4d4569f238a2f799cc1c818989b13 && git checkout -B drift-repro 7d0b47ca19c8c41563964b3889ae81e8e015788e && git merge --no-ff cba18d9204b4d4569f238a2f799cc1c818989b13
node scripts/docs-audit/affected-docs.mjs --json 7d0b47ca19c8c41563964b3889ae81e8e015788e
|
|
domain:server#5 · os-project-manager · session_01FEkQ5o8PE7ZtVjcor51wBZ Contract-review-claim: session_01FEkQ5o8PE7ZtVjcor51wBZ · head cba18d9 · 2026-11-08T12:02Z |
|
domain:server#5 · os-project-manager · session_01FEkQ5o8PE7ZtVjcor51wBZ Contract reviewServed-tier: Inputs: card #31473 with its triage 6720603952, the seat claim 6720748415 and os-dev-report 6721223073; the PR body; the net diff ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS Generated by Claude Code |
|
domain:server#5 · os-project-manager · session_01FEkQ5o8PE7ZtVjcor51wBZ 席位意见:接受。SDK 的 席位核对 — ACCEPT ·
|
Requested by Leehom · project thread
domain:server#5 · os-project-manager · session_01FEkQ5mbAyTfp7gbjowRA48
Fixes #31473
Clause-②: yes (widening) —
RealtimeAPI.subscribeDatanow delivers every per-record event type the spec'sDataEventTypedeclares, which addsdata.record.restored(a row restored from the recycle bin) to the created / updated / deleted it delivered before.subscribeBulkDatareadsBulkDataEventTypethe same way; its two types are unchanged.Metadata-protocol: none
维护者速读
@objectstack/client的subscribeData/subscribeBulkData订阅的事件类型改为直接读 spec 的DataEventType/BulkDataEventType枚举,不再手写列表;回收站恢复产生的data.record.restored因此能送达订阅者。DataEventType加了restored,但 SDK 手写的 created/updated/deleted 列表把它过滤掉,订阅者的实时列表看不到被恢复的记录 (client:subscribeDatafiltersdata.record.restoredout, so an SDK data subscriber never sees a recycle-bin restore #31473)。event.type分支的回调会多看到data.record.restored(载荷after带恢复后的行)。客户端本就运行时依赖@objectstack/spec/api,无新依赖。回滚即 revert 本 PR。packages/client/src/realtime-api.ts中subscribeData与subscribeBulkData的eventTypes。cd packages/client && npx vitest run src/realtime-api-data-event-types.test.ts,预期 4 个用例全过 (在 main 上 3 个红)。What changes
subscribeDataasked for['data.record.created', 'data.record.updated', 'data.record.deleted'], written by hand.data.record.restored, which ObjectQL's recycle-bin restore publishes with the restored row inafterand which feat(objectql): restore a recycle-bin entry under its original ids and emit data.record.restored (#30237 PR 3) #31220 added toDataEventType, matched no subscription filter and was dropped. It now asks for[...DataEventType.options].subscribeBulkDatakept the same kind of hand list (['data.records.updated', 'data.records.deleted']). It now asks for[...BulkDataEventType.options]; its two types are unchanged. No other client code lists data event types.(event: DataEvent) => void, whosetypeisDataEventType. Delivering the whole enum makes the subscription mean what its type says, and a list that rebuilds itself from created / deleted needs the restore to stay correct.realtime-api.tsalready imports runtime values (DataEventSchema,BulkDataEventSchema) from@objectstack/spec/api, so the two enums come from a module the client already loads. The published dependency set and the imported module are unchanged.31473-client-subscribe-data-restored.md:@objectstack/clientpatch (Metadata-protocol: none, ruling A).Tests
New
packages/client/src/realtime-api-data-event-types.test.ts:DataEventTypemember reachessubscribeData(read from the enum, so a type added later is covered without editing the test).BulkDataEventTypemember reachessubscribeBulkData(green on main too; it keeps the bulk list honest from here on).realtime-api.tsspells nodata.record(s).*type as a string literal and reads both enums.Red on main (2ae3e30, test file only):
Tests 3 failed | 1 passed (4):Ablation (
scripts/ablation-replace.mjson committedec765f5d,subscribeData'seventTypes: [...DataEventType.options]put back as the old three-item hand list):ok mutation landed: anchor 1 -> 0, blob 444fe4c6de5e -> 5bcbff9269d0, the same three pins red (Tests 3 failed | 1 passed (4)), thenok restored: blob == HEAD (444fe4c6de5e) and git diff HEAD is empty.Acceptance notes
data.field.changedis "declared inDataEventType". The enum no longer lists it. Left as is because it is outside this card's surface. Noted, not filed.Verification
cba18d92; cut from fresh origin/main2ae3e301, with origin/main7d0b47camerged before opening (no file overlap with this diff; the three realtime test files re-ran green after the merge, 26/26).pnpm --filter @objectstack/client testunderos-verify-lock:VERDICT command-exit 0, Test Files 56 passed (56), Tests 716 passed (716).pnpm --filter @objectstack/client typecheck(tsc --noEmitandcheck:test-typecheck): exit 0.eslinton the two touched.tsfiles: exit 0.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack: 61 derived, 61 run, all exit 0 (--ran: 0 NOT-MEASURED). Two first read exit 3 (check:skill-examples,check:dual-build-cjs-loads: a prerequisite, built output missing in a fresh worktree). Afterpnpm --filter './packages/**' run buildunder the lock, both exited 0. Record:/mnt/project-files/pm-orders/server/31473-gates-ran.txt.Human Minimum
packages/specholds no runtime logic. (not touched)pnpm lintpasses. (eslint on the two touched.tsfiles: exit 0)main, one pull request..changeset/31473-client-subscribe-data-restored.md,@objectstack/clientpatch)packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5mbAyTfp7gbjowRA48
Generated by Claude Code