-
Notifications
You must be signed in to change notification settings - Fork 395
/
Schema.ts
56 lines (46 loc) · 1.02 KB
/
Schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import getDefaultModule from './getDefaultModule'
interface Schema {
name: string
get(typeName: string): any
getTypeNames(): string[]
}
interface SchemaField {
name: string
type: SchemaType
}
interface PreviewFields {
media?: string
}
interface PreviewPreparer {
(selection: {}): PreviewFields
}
type SortDirection = 'asc' | 'desc'
interface SortItem {
field: string
direction: SortDirection
}
interface Ordering {
title: string
name?: string
by: SortItem[]
}
export interface SchemaType {
name: string
title?: string
icon?: Function
type?: SchemaType
to?: SchemaField[]
fields?: SchemaField[]
orderings?: Ordering[]
initialValues?: Function | {[key: string]: any}
preview?: {
select?: PreviewFields
prepare?: PreviewPreparer
}
}
// We are lazy-loading the part to work around typescript trying to resolve it
const getDefaultSchema = (): Schema => {
const schema: Schema = getDefaultModule(require('part:@sanity/base/schema'))
return schema
}
export {Schema, getDefaultSchema}