feat!: rewrite sanity-bridge for direct Sanity-to-Schema conversion#2207
Draft
christianhg wants to merge 3 commits intomainfrom
Draft
feat!: rewrite sanity-bridge for direct Sanity-to-Schema conversion#2207christianhg wants to merge 3 commits intomainfrom
christianhg wants to merge 3 commits intomainfrom
Conversation
Rewrite sanitySchemaToPortableTextSchema to produce a PTE Schema directly from the Sanity schema, removing the intermediate PortableTextMemberSchemaTypes representation. Removed exports: - compileSchemaDefinitionToPortableTextMemberSchemaTypes - portableTextMemberSchemaTypesToSchema Kept exports (Studio still uses these): - createPortableTextMemberSchemaTypes - PortableTextMemberSchemaTypes type - sanitySchemaToPortableTextSchema
🦋 Changeset detectedLatest commit: 69673ea The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
These were only used by the removed compileSchemaDefinitionToPortableTextMemberSchemaTypes function.
c2a3c89 to
13094b1
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.
Summary
Rewrites
sanitySchemaToPortableTextSchemato produce a PTESchemadirectly from the Sanity schema, removing the intermediatePortableTextMemberSchemaTypesrepresentation.This is a follow-up to the v6 work on
editor-remove-sanity-deps. With PTE v6 no longer exportingPortableTextMemberSchemaTypesor using it internally, the bridge no longer needs the two-step conversion (createPortableTextMemberSchemaTypesthenportableTextMemberSchemaTypesToSchema). The rewritten function walks the Sanity schema and maps directly to the PTESchemashape.Changes
Rewritten:
sanitySchemaToPortableTextSchema- walks the compiled SanityArraySchemaTypeand produces a PTESchemadirectly. The extraction logic (finding block type, span type, styles, decorators, lists, annotations, block objects, inline objects) and the mapping logic (converting Sanity types to PTE schema types) are combined into a single pass.Removed:
compileSchemaDefinitionToPortableTextMemberSchemaTypes- no consumers after v6 (editor tests migrated to@portabletext/schema)portableTextMemberSchemaTypesToSchema- only consumer wassanitySchemaToPortableTextSchema(now rewritten)schema-definition-to-portable-text-member-schema-types.test.ts- tests for the removed functionKept (Studio still imports these):
createPortableTextMemberSchemaTypes- Studio uses this in its ownPortableTextMemberSchemaTypesProvidercontextPortableTextMemberSchemaTypestype - used by Studio's type firewall patternTests:
sanity-schema-to-portable-text-schema.test.ts: removed the "compiled back and forth" test (used removed functions), replaced with a "compiled schema with custom block and inline objects" test that verifies the direct path handles block objects and inline objects correctly.Breaking changes
compileSchemaDefinitionToPortableTextMemberSchemaTypesremovedportableTextMemberSchemaTypesToSchemaremoved