@sanity/schema
Version:
146 lines (124 loc) • 3.36 kB
text/typescript
import {Schema} from '@sanity/types'
import {SchemaType} from '@sanity/types'
import {SchemaType as SchemaType_2} from 'groq-js'
import {SchemaTypeDefinition} from '@sanity/types'
import {SchemaValidationProblem} from '@sanity/types'
import {SchemaValidationProblemGroup} from '@sanity/types'
export declare const builtinTypes: {
name: string
title: string
type: string
fields: {
name: string
type: string
}[]
}[]
export declare const DEFAULT_MAX_FIELD_DEPTH = 5
export declare function extractSchema(
schemaDef: Schema,
extractOptions?: ExtractSchemaOptions,
): SchemaType_2
declare interface ExtractSchemaOptions {
enforceRequiredFields?: boolean
}
/**
* @internal
*/
export declare type FIXME = any
/**
* @internal
*/
export declare function groupProblems(types: SchemaTypeDefinition[]): SchemaValidationProblemGroup[]
export declare const isActionEnabled: (schemaType: SchemaType, action: string) => boolean
declare interface Options {
transformTypeVisitors?: (visitors: typeof typeVisitors) => Partial<typeof typeVisitors>
}
/**
* @internal
*/
export declare type ProblemPath = ProblemPathSegment[]
/**
* @internal
*/
export declare interface ProblemPathPropertySegment {
kind: 'property'
name: string
}
/**
* @internal
*/
export declare type ProblemPathSegment = ProblemPathTypeSegment | ProblemPathPropertySegment
/**
* @internal
*/
export declare interface ProblemPathTypeSegment {
kind: 'type'
type: string
name: string
}
/**
* @internal
*/
export declare function resolveSearchConfig(type: any, maxDepth?: number): any
export declare function resolveSearchConfigForBaseFieldPaths(type: any, maxDepth?: number): any
/**
* @internal
*/
declare interface SchemaValidationResult {
severity: 'warning' | 'error'
message: string
helpId?: string
}
export {SchemaValidationResult as Problem}
export {SchemaValidationResult as ValidationResult}
declare const typeVisitors: {
array: (typeDef: any, visitorContext: any) => any
object: (typeDef: any, visitorContext: any) => any
slug: (typeDef: any, visitorContext: any) => any
file: (typeDef: any, visitorContext: any) => any
image: (typeDef: any, visitorContext: any) => any
block: typeof validateBlockType
document: (typeDefinition: any, visitorContext: any) => any
reference: (typeDef: any, visitorContext: any) => any
crossDatasetReference: (typeDef: any, visitorContext: any) => any
globalDocumentReference: (typeDef: any, visitorContext: any) => any
}
/**
* @internal
*/
export declare interface TypeWithProblems {
path: ProblemPath
problems: SchemaValidationResult[]
}
declare function validateBlockType(
typeDef: any,
visitorContext: any,
): {
marks: any
styles: any
name: any
of: any
_problems: SchemaValidationResult[]
}
/**
* Ensure that the provided value is a valid Media Library asset aspect that can be safely deployed.
*
* @internal
*/
export declare function validateMediaLibraryAssetAspect(
maybeAspect: unknown,
): [isValidMediaLibraryAspect: boolean, validationErrors: SchemaValidationProblem[][]]
/**
* @internal
*/
export declare function validateSchema(
schemaTypes: FIXME,
{transformTypeVisitors}?: Options,
): {
get(typeName: string): any
has(typeName: string): boolean
getTypeNames(): string[]
getTypes(): any[]
toJSON(): any[]
}
export {}