File tree Expand file tree Collapse file tree 4 files changed +4
-26
lines changed
@sanity/schema/src/descriptors Expand file tree Collapse file tree 4 files changed +4
-26
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,8 @@ const MAX_DEPTH_UKNOWN = 5
5151type UnknownRecord < T > = { [ P in keyof T ] : unknown }
5252
5353export class DescriptorConverter {
54- opts : Options
5554 cache : WeakMap < Schema , SetSynchronization < RegistryType > > = new WeakMap ( )
5655
57- constructor ( opts : Options ) {
58- this . opts = opts
59- }
60-
6156 /**
6257 * Returns a synchronization object for a schema.
6358 *
@@ -69,7 +64,7 @@ export class DescriptorConverter {
6964
7065 const builder = new SetBuilder ( )
7166 for ( const name of schema . getLocalTypeNames ( ) ) {
72- const typeDef = convertTypeDef ( schema . get ( name ) ! , this . opts )
67+ const typeDef = convertTypeDef ( schema . get ( name ) ! , { } )
7368 builder . addObject ( 'sanity.schema.namedType' , { name, typeDef} )
7469 }
7570
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ async function main() {
9090 let serializedDebug : ValidateSchemaWorkerResult [ 'serializedDebug' ]
9191
9292 if ( debugSerialize ) {
93- const conv = new DescriptorConverter ( { } )
93+ const conv = new DescriptorConverter ( )
9494 const set = conv . get ( schema )
9595 serializedDebug = getSeralizedSchemaDebug ( set )
9696 }
Original file line number Diff line number Diff line change 11import { DescriptorConverter } from '@sanity/schema/_internal'
2- import { type Rule , type SchemaValidationValue } from '@sanity/types'
32
4- import { Rule as RuleClass } from '../validation'
5-
6- export const DESCRIPTOR_CONVERTER = new DescriptorConverter ( {
7- ruleClass : RuleClass ,
8- validationExtractor : normalizeValidationValue ,
9- } )
10-
11- function normalizeValidationValue ( validation : SchemaValidationValue ) : Rule [ ] {
12- if ( ! validation ) return [ ]
13-
14- if ( Array . isArray ( validation ) ) {
15- return validation . flatMap ( ( inner ) => normalizeValidationValue ( inner ) )
16- } else if ( typeof validation === 'object' ) {
17- return [ validation ]
18- }
19- return normalizeValidationValue ( validation ( new RuleClass ( ) ) )
20- }
3+ export const DESCRIPTOR_CONVERTER = new DescriptorConverter ( )
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import {describe, test} from 'vitest'
55
66import { expectManifestSchemaConversion } from './utils'
77
8- const DESCRIPTOR_CONVERTER = new DescriptorConverter ( { } )
8+ const DESCRIPTOR_CONVERTER = new DescriptorConverter ( )
99
1010function validate ( schema : Schema ) {
1111 expectManifestSchemaConversion ( schema , DESCRIPTOR_CONVERTER . get ( schema ) )
You can’t perform that action at this time.
0 commit comments