feat(core): content-references HTTP API (relation defs + entry edges)#1535
Open
MA2153 wants to merge 2 commits into
Open
feat(core): content-references HTTP API (relation defs + entry edges)#1535MA2153 wants to merge 2 commits into
MA2153 wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: ee22100 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Scope checkThis PR changes 1,516 lines across 13 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
Adds relation-definition routes and handlers (list/create/get/update/delete/translations) and content-entry reference edge routes for children and parents, with edge-read hardening and error handling.
96936ca to
b17ee59
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Adds the HTTP API layer over the content-references repository — the third bottom-up slice after the schema (migration
043) andRelationRepository. Two surfaces:/_emdash/api/relations— manage relationship types (editor-readable viaschema:read, admin-writable viaschema:manage), treated as schema-like structural config./_emdash/api/content/:collection/:id/references/:relation/{children,parents}— attach/read directed references on a specific entry, ownership-aware like the taxonomy edge endpoint.This is the trust boundary: Zod at the route, and the write-path invariants (relation-exists, collection-agreement, directed storage) the repository deliberately skipped. References are stored only in
_emdash_content_references, keyed bytranslation_group— noec_*column.The final commit hardens the slice against a code review:
translationOf→NOT_FOUND, name/locale collisions →CONFLICT, missing collections →COLLECTION_NOT_FOUND.INquery (chunked) instead of N+1 per edge.?cursor/?limit, default 50, max 100) returningnextCursor; the backlink (parents) side is genuinely unbounded, so this matters. Bad cursors →INVALID_CURSOR.localeof the variant returned, so the variant fallback is explicit rather than a silent wrong-locale substitution.content:edit_ownis gated before the existence lookup onPOST childrento close an existence-oracle.PATCHrelation bodies are rejected withVALIDATION_ERROR.Closes #
Type of change
Approved feature Discussion: #386
Part of the planned content-references effort tracked under the schema (#1367) and repository (#1444) slices.
Checklist
pnpm typecheckpasses — repo-wide typecheck has 5 pre-existing failures inpackages/plugin-cli/src/plugins/*from an unbuilt@emdash-cms/plugin-types(build-order, unrelated to this PR); 0 new errors introduced by these changes.pnpm lintpasses —pnpm lint:jsonis clean for all files in this PR; the only remaining diagnostics are pre-existing in unrelated demo/templateastro.config.mjsfiles.pnpm testpasses (targeted): relation/reference handler, route, and repository suites — 60 tests green.pnpm formathas been runemdash, minor)AI-generated code disclosure
Screenshots / test output