Share one manifest contract between Standard.site writer and reader#189
Merged
Merged
Conversation
Export StandardSiteManifestSchema, the StandardSiteManifest type, and a new serializeStandardSiteManifest from src/lib/standard-site.ts so the sync script serialises through the same schema it validates on read. The script drops its duplicate PUBLICATION_URI constant and inline manifest builder in favour of standardSitePublicationUri and the shared serializer.
✅ Deploy Preview for lukebennett ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Problem
The generated manifest (
src/generated/standard-site.json) had its shape and the publication URI declared independently in two places: the writer (scripts/sync-standard-site.ts, with its ownPUBLICATION_URIconstant and hand-built JSON) and the reader (src/lib/standard-site.ts, with the Zod schema). Nothing proved the writer emitted a shape the reader would accept — skew would only surface at runtime, in production.Solution
src/lib/standard-site.tsbecomes the single contract module. It now exportsStandardSiteManifestSchema, theStandardSiteManifesttype, andserializeStandardSiteManifest(documentsBySlug), which validates through the schema before producing the JSON. The writer importsstandardSitePublicationUriand the serializer, dropping its duplicate constant and inline JSON construction. The publication URI is now declared once.Serializer output is byte-identical to the previous inline writer (same sort order, 2-space indent, trailing newline), so
standard-site.jsonwill not churn. The file-path resolution on each side is left as-is.Verification
pnpm --filter @lukebennett/web test:standard-site— 21 tests pass (added serializer round-trip + formatting tests; existingbuildDocumentRecordsite assertion unchanged).pnpm --filter @lukebennett/web check— clean.Part of an architecture review pass; sibling PRs cover the AT Protocol module, Cloud Image preview, and renderer registry.