fix: include runtime manual collections in admin manifest so their content routes resolve - #1645
Conversation
…ntent routes resolve
🦋 Changeset detectedLatest commit: 5841a4f The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 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 |
PR template validation failedPlease fix the following issues by editing your PR description:
See CONTRIBUTING.md for the full contribution policy. |
@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/registry-verification
@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: |
There was a problem hiding this comment.
The PR is a sensible refactor at heart: it moves the DB-to-manifest field mapping into api/handlers/manifest.ts so the same code can build a manifest from config collections, runtime/manual DB collections, or both. That consolidation is the right direction.
I checked the changed files, call sites, and the admin/client manifest types. The code is SQL-safe, the runtime still uses this.db (ALS-aware), and the route envelope stays { data: manifest }. I found two concrete issues and one approach concern:
- Missing changeset.
packages/core(the publishedemdashpackage) changed its public API/behavior, so AGENTS.md requires a changeset. - Public return type is now a lie.
generateManifest()returnsManifestResponse, but the objects it now produces carry extra fields (hasSeo,urlPattern,widget,id,validation) that the type does not declare. The admin/client types already know about these fields, so the server-side API type should be updated to match reality. - The new merge path is not wired to the production admin manifest.
EmDashRuntime._buildManifest()callsbuildManifestCollections({}, this.db)with an empty config map, so the runtime manifest still derives only from the database. That already includes manual collections, so it does fix the stated symptom, but the newly-added config+DB merging ingenerateManifest()is only exercised by unit tests. If the intent is for the admin endpoint (or SSR bootstrap) to merge file-defined and manual collections, a production caller still needs to usegenerateManifest().
Nothing here is a security or data-loss regression, so I’m leaving this as a comment rather than request_changes.
Findings
-
[needs fixing]
packages/core/package.json:2This PR changes the published
emdashpackage (manifest generation API/behavior inpackages/core). Per AGENTS.md, a user-facing change to a published package needs a changeset describing the observable effect.Please add a changeset such as
.changeset/fix-manual-collections-manifest.md:--- "emdash": patch --- Fixes missing runtime manual collections in the admin manifest by building manifest descriptors from the live `_emdash_collections` / `_emdash_fields` tables.
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
|
@mvanhorn could you cook at the review feedback. It looks all valid to me |
ManifestResponse.collections now uses ManifestCollectionMap, so the public type declares the fields the handler actually produces (hasSeo, urlPattern, id, widget, validation). Types centralized in api/types.ts and re-exported. Adds a changeset for the emdash package.
|
Addressed the review:
On the third point — I dug into |
|
This PR has been inactive for 14 days. It will be closed automatically in 7 days if there is no further activity. If you're still working on this, please push an update or leave a comment. |
There was a problem hiding this comment.
This re-review covers the fixes pushed since the previous comment review.
The previous review raised three concerns: a missing changeset, generateManifest() returning objects wider than ManifestResponse, and the new config+DB merge helper not being wired to the production admin manifest. All three are now reasonably addressed:
- Changeset added.
.changeset/manifest-field-mapping.mdis present and describes the user-facing effect. - Public types updated.
packages/core/src/api/types.tsnow declaresManifestCollectionMap,ManifestCollectionDescriptor, andManifestFieldDescriptor, andManifestResponse.collectionsuses them. These types match the fields actually produced (hasSeo,urlPattern,id,widget,validation). The new types are also re-exported frompackages/core/src/index.ts. - Merge wiring. The production runtime manifest (
EmDashRuntime._buildManifest()) callsbuildManifestCollections({}, this.db), i.e. it builds from the live database. Because file-defined collections are persisted into_emdash_collectionsalong with manual ones, the database is the runtime source of truth for collections, so both collection sources already appear in the admin manifest. ThegenerateManifest(config, plugins, { db })merge path is exposed for callers that need to merge an in-memory config map with the database, and it is covered by the new unit tests.
What I checked:
- Full diff and the changed files (
manifest.ts,api/types.ts,emdash-runtime.ts,index.ts, the admin manifest route, and the test file). - Call sites of
generateManifestandbuildManifestCollections; only the handler module, public exports, runtime, and tests reference them. - Field mapping parity between the old inline
_buildManifest()code and the new shareddbFieldDescriptor(); behavior is identical. - SQL safety: all DB access goes through
SchemaRegistry/ Kysely; no interpolated SQL. - API envelope shape: the admin manifest route still returns
{ data: manifest }. - Type consistency with the admin SPA’s manifest field types.
The bug described in #1641 is fixed, the refactor consolidates the manifest-field mapping in the right place, and the added tests cover the new manual-collection path plus conflict/fallback/unknown-type edge cases. No new blocking issues were introduced.
…lections-admin-manifest # Conflicts: # packages/core/src/emdash-runtime.ts
Summary
Collections created through the Admin UI (
source: "manual") were absent from the admin manifest, so their content routes failed to resolve at runtime. This builds the manifest from the runtime manual collections via theSchemaRegistry, mapping schema field types to editor field kinds, so manual collections appear alongside file-defined ones.Adds
manifest-build.test.tscovering the manual-collection manifest path.Fixes #1641
AI was used for assistance.