Skip to content

Commit 0bf3afd

Browse files
committed
refactor(schema): remove unused options to DescriptorConverter
These are no longer required due to some refactorings we did with validations.
1 parent 8efdc2b commit 0bf3afd

File tree

4 files changed

+4
-26
lines changed

4 files changed

+4
-26
lines changed

packages/@sanity/schema/src/descriptors/convert.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,8 @@ const MAX_DEPTH_UKNOWN = 5
5151
type UnknownRecord<T> = {[P in keyof T]: unknown}
5252

5353
export 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

packages/sanity/src/_internal/cli/threads/validateSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}
Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
11
import {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()

packages/sanity/test/descriptors/extractManifestToSchema.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {describe, test} from 'vitest'
55

66
import {expectManifestSchemaConversion} from './utils'
77

8-
const DESCRIPTOR_CONVERTER = new DescriptorConverter({})
8+
const DESCRIPTOR_CONVERTER = new DescriptorConverter()
99

1010
function validate(schema: Schema) {
1111
expectManifestSchemaConversion(schema, DESCRIPTOR_CONVERTER.get(schema))

0 commit comments

Comments
 (0)