-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adds support for document types named using _id incompatible cha…
…racters
- Loading branch information
Showing
12 changed files
with
264 additions
and
211 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {createContext} from 'react' | ||
|
||
export interface AssistTypeContextValue { | ||
typePath?: string | ||
documentType?: string | ||
} | ||
export const AssistTypeContext = createContext<AssistTypeContextValue>({}) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {describe, expect, test} from 'vitest' | ||
|
||
import {assistDocumentId} from './ids' | ||
|
||
describe('ids', () => { | ||
test('assistDocumentId should replace illegal id chars with _', () => { | ||
const testCases = [ | ||
{schemaType: 'test', assistId: 'sanity.assist.schemaType.test'}, | ||
{schemaType: 'test-type', assistId: 'sanity.assist.schemaType.test-type'}, | ||
{schemaType: 'test/type', assistId: 'sanity.assist.schemaType.test_type'}, | ||
{schemaType: '%broken©™£€∞', assistId: 'sanity.assist.schemaType._broken_____'}, | ||
] | ||
const outputs = testCases.map((testCase) => assistDocumentId(testCase.schemaType)) | ||
const expected = testCases.map((testCase) => testCase.assistId) | ||
expect(outputs).toEqual(expected) | ||
}) | ||
}) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * as mockArticleTypes from './mockArticle' | ||
export * as languageArticle from './languageArticle' | ||
export * as brokenTypeName from './brokenTypeName' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {defineType} from 'sanity' | ||
|
||
export const brokenTypeName = defineType({ | ||
type: 'document', | ||
name: 'broken/type%broken©™£€∞' /* this document type name will crash standard studio structures*/, | ||
fields: [ | ||
{ | ||
type: 'string', | ||
name: 'title', | ||
}, | ||
], | ||
}) |