Repository navigation
feat: register cms-framework post + page core-data entities (#399 Phase B) - #423
Conversation
…se B) 2 of 3 PRs closing #399. Phase A shipped the WP-shape REST surface; this phase wires the JS-side entity registration so blocks like core/post-title can resolve postType:post / postType:page through the core-data shim. Phase C will add the editor's EntityProvider wrapping + inspector-sidebar enhancements. The shim already defaults apiBase to /visual-editor/api, so adding the entries to DEFAULT_ENTITIES is sufficient — `useEntityRecord( 'postType', 'post', id )` resolves to /visual-editor/api/posts/{id} (Phase A) automatically. Entities are declared unconditionally so visual-editor doesn't need a runtime detection seam for cms-framework; when the package isn't installed the matching endpoints are unrouted and the resolver returns null, which is the same shape any unseeded entity returns. - Extends DEFAULT_ENTITIES with postType:post (/posts) + postType:page (/pages); same { kind, name, baseURL, key, label, plural } shape as the existing wp_template / wp_navigation entries. - Updates the strict-equality registry test to include the two new entries; new dedicated test asserts each entity's full shape so a future rename to either baseURL or key is caught. Refs #399 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe core-data-shim's default entity registry is expanded to include Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
Description
2 of 3 PRs closing #399 (G3 editor entity adapter). Phase A shipped the backend REST surface (WP-shape
/visual-editor/api/{posts,pages}/{id}); this phase wires the JS-side entity registration socore/post-*blocks can resolvepostType:post/postType:pagethrough the core-data shim. Phase C will add the editor'sEntityProviderwrapping + inspector-sidebar enhancements that surface the integration to the user.Refs: #399 (closes when Phase C also merges)
Type of Change
Related Issue
Issue: #399 (Phase B of 3)
Motivation and Context
G3 from plan 12 §4.4 — "the shim's editor bootstrap registers two new entities:
postType:post→/visual-editor/api/postsandpostType:page→/visual-editor/api/pages". Builds on Phase A's REST surface (merged) and the resource-bridge filter from #397 (merged). With these entities registered, downstream Phase C (editorEntityProviderwrapping + inspector sidebar) plus existingcore/post-*blocks resolve their data automatically.Changes Made
The shim already defaults
apiBaseto/visual-editor/api, so the only seam needed isDEFAULT_ENTITIES:postType:post→/posts(resolves to/visual-editor/api/posts/{id}from Phase A)postType:page→/pages(resolves to/visual-editor/api/pages/{id}from Phase A)Unconditional declaration: the entities are registered regardless of whether cms-framework is installed. When the package isn't present, the matching endpoints are unrouted and the resolver returns
null— the same shape any unseeded entity returns. No runtime detection seam needed in JS.How Has This Been Tested?
Testing Environment:
Tests Performed:
core-data-shim.test.tsxto include the new G3 entriesthe G3 post + page entities resolve to /posts and /pages baseURLs) asserts the full shape of both entriesManual smoke notes: Phase B's user-visible value depends on Phase C wiring an
EntityProvideraround the editor canvas — without that context, blocks likecore/post-titlehave no entity to resolve and render placeholders. Phase B in isolation is verified by the unit tests + the Phase A REST endpoints (proven via tinker on the Phase A PR). End-to-end network-call verification will land naturally during Phase C's manual smoke.Accessibility Tests Run
N/A — no UI surface in this phase.
Details: Pure entity-registry change. UI work lands in Phase C.
Tests Added
Test details:
core-data-shim entity registry > registers the V1 site-editor + G3 cms-framework entities by defaultto expect 7 entries instead of 5exposes default entities via getEntities after resetto include the two new entries in thearrayContainingsetthe G3 post + page entities resolve to /posts and /pages baseURLstest asserts each entity's full shape — will catch any future rename ofbaseURL/key/label/pluralDocumentation
Documentation details:
Pre-Submission Checklist
.php-cs-fixer.dist.php/ pint binary in this package; tests are the gate)Summary by CodeRabbit
Release Notes
New Features
Tests