@sanity/media-library-types 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.mts +2676 -0
- package/lib/index.d.ts +2676 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +2 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +52 -0
- package/src/assets.ts +159 -0
- package/src/files.ts +12 -0
- package/src/index.ts +3 -0
- package/src/plugin.ts +93 -0
- package/src/schema.types.ts +295 -0
package/lib/index.d.mts
ADDED
|
@@ -0,0 +1,2676 @@
|
|
|
1
|
+
import {ClientPerspective} from '@sanity/client'
|
|
2
|
+
import {ComponentType} from 'react'
|
|
3
|
+
import {ElementType} from 'react'
|
|
4
|
+
import {ReactNode} from 'react'
|
|
5
|
+
import {SanityClient} from '@sanity/client'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Types of array actions that can be performed
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
declare type ArrayActionName =
|
|
12
|
+
/**
|
|
13
|
+
* Add any item to the array at any position
|
|
14
|
+
*/
|
|
15
|
+
| 'add'
|
|
16
|
+
/**
|
|
17
|
+
* Add item after an existing item
|
|
18
|
+
*/
|
|
19
|
+
| 'addBefore'
|
|
20
|
+
/**
|
|
21
|
+
* Add item after an existing item
|
|
22
|
+
*/
|
|
23
|
+
| 'addAfter'
|
|
24
|
+
/**
|
|
25
|
+
* Remove any item
|
|
26
|
+
*/
|
|
27
|
+
| 'remove'
|
|
28
|
+
/**
|
|
29
|
+
* Duplicate item
|
|
30
|
+
*/
|
|
31
|
+
| 'duplicate'
|
|
32
|
+
/**
|
|
33
|
+
* Copy item
|
|
34
|
+
*/
|
|
35
|
+
| 'copy'
|
|
36
|
+
|
|
37
|
+
/** @public */
|
|
38
|
+
declare interface ArrayDefinition extends BaseSchemaDefinition {
|
|
39
|
+
type: 'array'
|
|
40
|
+
of: ArrayOfType[]
|
|
41
|
+
initialValue?: InitialValueProperty<any, unknown[]>
|
|
42
|
+
validation?: ValidationBuilder<ArrayRule<unknown[]>, unknown[]>
|
|
43
|
+
options?: ArrayOptions
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @public */
|
|
47
|
+
declare type ArrayOfEntry<T> = Omit<T, 'name' | 'hidden'> & {
|
|
48
|
+
name?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @public */
|
|
52
|
+
declare type ArrayOfType<
|
|
53
|
+
TType extends IntrinsicTypeName = IntrinsicTypeName,
|
|
54
|
+
TAlias extends IntrinsicTypeName | undefined = undefined,
|
|
55
|
+
> = IntrinsicArrayOfDefinition[TType] | ArrayOfEntry<TypeAliasDefinition<string, TAlias>>
|
|
56
|
+
|
|
57
|
+
/** @public */
|
|
58
|
+
declare interface ArrayOptions<V = unknown> extends SearchConfiguration, BaseSchemaTypeOptions {
|
|
59
|
+
list?: TitledListValue<V>[] | V[]
|
|
60
|
+
layout?: 'list' | 'tags' | 'grid'
|
|
61
|
+
/** @deprecated This option does not have any effect anymore */
|
|
62
|
+
direction?: 'horizontal' | 'vertical'
|
|
63
|
+
sortable?: boolean
|
|
64
|
+
modal?: {
|
|
65
|
+
type?: 'dialog' | 'popover'
|
|
66
|
+
width?: number | 'auto'
|
|
67
|
+
}
|
|
68
|
+
/** @alpha This API may change */
|
|
69
|
+
insertMenu?: InsertMenuOptions
|
|
70
|
+
/**
|
|
71
|
+
* A boolean flag to enable or disable tree editing for the array.
|
|
72
|
+
* If there are any nested arrays, they will inherit this value.
|
|
73
|
+
* @deprecated tree editing beta feature has been disabled
|
|
74
|
+
*/
|
|
75
|
+
treeEditing?: boolean
|
|
76
|
+
/**
|
|
77
|
+
* A list of array actions to disable
|
|
78
|
+
* Possible options are defined by {@link ArrayActionName}
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
disableActions?: ArrayActionName[]
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** @public */
|
|
85
|
+
declare interface ArrayRule<Value> extends RuleDef<ArrayRule<Value>, Value> {
|
|
86
|
+
min: (length: number | FieldReference) => ArrayRule<Value>
|
|
87
|
+
max: (length: number | FieldReference) => ArrayRule<Value>
|
|
88
|
+
length: (length: number | FieldReference) => ArrayRule<Value>
|
|
89
|
+
unique: () => ArrayRule<Value>
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** @public */
|
|
93
|
+
declare interface ArraySchemaType<V = unknown> extends BaseSchemaType {
|
|
94
|
+
jsonType: 'array'
|
|
95
|
+
of: (Exclude<SchemaType, ArraySchemaType> | ReferenceSchemaType)[]
|
|
96
|
+
options?: ArrayOptions<V> & {
|
|
97
|
+
layout?: V extends string ? 'tag' : 'grid'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export declare interface Asset<
|
|
102
|
+
AssetInstance extends AssetInstanceDocument = AssetInstanceDocument,
|
|
103
|
+
> {
|
|
104
|
+
_id: string
|
|
105
|
+
_type: SanityAsset['_type']
|
|
106
|
+
title: string
|
|
107
|
+
assetType: AssetInstance['_type']
|
|
108
|
+
cdnAccessPolicy: SanityAsset['cdnAccessPolicy']
|
|
109
|
+
currentVersion: {
|
|
110
|
+
_ref: string
|
|
111
|
+
}
|
|
112
|
+
aspects?: unknown
|
|
113
|
+
versions: AssetVersion<AssetInstance>[]
|
|
114
|
+
collections: SanityAssetCollection[]
|
|
115
|
+
_createdAt: string
|
|
116
|
+
_updatedAt: string
|
|
117
|
+
_rev: string
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** @public */
|
|
121
|
+
declare interface Asset_2 extends SanityDocument {
|
|
122
|
+
url: string
|
|
123
|
+
path: string
|
|
124
|
+
assetId: string
|
|
125
|
+
extension: string
|
|
126
|
+
mimeType: string
|
|
127
|
+
sha1hash: string
|
|
128
|
+
size: number
|
|
129
|
+
originalFilename?: string
|
|
130
|
+
label?: string
|
|
131
|
+
title?: string
|
|
132
|
+
description?: string
|
|
133
|
+
creditLine?: string
|
|
134
|
+
source?: AssetSourceSpec
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export declare interface AssetAspectDocument extends BaseDocument {
|
|
138
|
+
_type: 'sanity.asset.aspect'
|
|
139
|
+
/**
|
|
140
|
+
* The asset type this aspect definition applies to
|
|
141
|
+
* Undefined means that it applies to all asset types
|
|
142
|
+
*/
|
|
143
|
+
assetType?: Asset['assetType']
|
|
144
|
+
definition: FieldDefinition
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** @public */
|
|
148
|
+
declare type AssetFromSource = {
|
|
149
|
+
kind: 'assetDocumentId' | 'file' | 'base64' | 'url'
|
|
150
|
+
value: string | File_2
|
|
151
|
+
assetDocumentProps?: ImageAsset
|
|
152
|
+
mediaLibraryProps?: {
|
|
153
|
+
mediaLibraryId: string
|
|
154
|
+
assetId: string
|
|
155
|
+
assetInstanceId: string
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export declare type AssetInstanceDocument = SanityImageAsset | SanityVideoAsset | SanityFileAsset
|
|
160
|
+
|
|
161
|
+
export declare interface AssetSelectionItem {
|
|
162
|
+
asset: Asset
|
|
163
|
+
assetInstanceId?: string | null
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare interface AssetSelectionItemWithLegacySupport extends AssetSelectionItem {
|
|
167
|
+
assetId: string
|
|
168
|
+
assetType: string
|
|
169
|
+
assetInstanceId: string
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** @public */
|
|
173
|
+
declare interface AssetSource {
|
|
174
|
+
name: string
|
|
175
|
+
/** @deprecated provide `i18nKey` instead */
|
|
176
|
+
title?: string
|
|
177
|
+
i18nKey?: string
|
|
178
|
+
component: ComponentType<AssetSourceComponentProps>
|
|
179
|
+
icon?: ComponentType<EmptyProps>
|
|
180
|
+
/** @beta */
|
|
181
|
+
uploader?: AssetSourceUploader
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** @public */
|
|
185
|
+
declare interface AssetSourceComponentProps {
|
|
186
|
+
action?: 'select' | 'upload'
|
|
187
|
+
assetSource: AssetSource
|
|
188
|
+
assetType?: 'file' | 'image'
|
|
189
|
+
accept: string
|
|
190
|
+
selectionType: 'single'
|
|
191
|
+
dialogHeaderTitle?: React.ReactNode
|
|
192
|
+
selectedAssets: Asset_2[]
|
|
193
|
+
onClose: () => void
|
|
194
|
+
onSelect: (assetFromSource: AssetFromSource[]) => void
|
|
195
|
+
schemaType?: ImageSchemaType | FileSchemaType
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** @public */
|
|
199
|
+
declare interface AssetSourceSpec {
|
|
200
|
+
id: string
|
|
201
|
+
name: string
|
|
202
|
+
url?: string
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** @beta */
|
|
206
|
+
declare interface AssetSourceUploader {
|
|
207
|
+
upload(
|
|
208
|
+
files: globalThis.File[],
|
|
209
|
+
options?: {
|
|
210
|
+
/**
|
|
211
|
+
* The schema type of the field the asset is being uploaded to.
|
|
212
|
+
* May be of interest to the uploader to read file and image options.
|
|
213
|
+
*/
|
|
214
|
+
schemaType?: SchemaType
|
|
215
|
+
/**
|
|
216
|
+
* The uploader may send patches directly to the field
|
|
217
|
+
* Typed 'unknown' as we don't have patch definitions in sanity/types yet.
|
|
218
|
+
*/
|
|
219
|
+
onChange?: (patch: unknown) => void
|
|
220
|
+
},
|
|
221
|
+
): AssetSourceUploadFile[]
|
|
222
|
+
/**
|
|
223
|
+
* Abort the upload of a file
|
|
224
|
+
*/
|
|
225
|
+
abort(file?: AssetSourceUploadFile): void
|
|
226
|
+
/**
|
|
227
|
+
* Get the files that are currently being uploaded
|
|
228
|
+
*/
|
|
229
|
+
getFiles(): AssetSourceUploadFile[]
|
|
230
|
+
/**
|
|
231
|
+
* Subscribe to upload events from the uploader
|
|
232
|
+
*/
|
|
233
|
+
subscribe(subscriber: (event: AssetSourceUploadEvent) => void): () => void
|
|
234
|
+
/**
|
|
235
|
+
* Update the status of a file. Will be emitted to subscribers.
|
|
236
|
+
*/
|
|
237
|
+
updateFile(
|
|
238
|
+
fileId: string,
|
|
239
|
+
data: {
|
|
240
|
+
progress?: number
|
|
241
|
+
status?: string
|
|
242
|
+
error?: Error
|
|
243
|
+
},
|
|
244
|
+
): void
|
|
245
|
+
/**
|
|
246
|
+
* Reset the uploader (clear files). Should be called by the uploader when all files are done.
|
|
247
|
+
*/
|
|
248
|
+
reset(): void
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** @beta */
|
|
252
|
+
declare type AssetSourceUploadEvent =
|
|
253
|
+
| AssetSourceUploadEventProgress
|
|
254
|
+
| AssetSourceUploadEventStatus
|
|
255
|
+
| AssetSourceUploadEventAllComplete
|
|
256
|
+
| AssetSourceUploadEventError
|
|
257
|
+
| AssetSourceUploadEventAbort
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Emitted when all files are done, either successfully, aborted or with errors
|
|
261
|
+
* @beta */
|
|
262
|
+
declare type AssetSourceUploadEventAbort = {
|
|
263
|
+
type: 'abort'
|
|
264
|
+
/**
|
|
265
|
+
* Files aborted
|
|
266
|
+
*/
|
|
267
|
+
files: AssetSourceUploadFile[]
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Emitted when all files are done, either successfully, aborted or with errors
|
|
272
|
+
* @beta */
|
|
273
|
+
declare type AssetSourceUploadEventAllComplete = {
|
|
274
|
+
type: 'all-complete'
|
|
275
|
+
files: AssetSourceUploadFile[]
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Emitted when all files are done, either successfully, aborted or with errors
|
|
280
|
+
* @beta */
|
|
281
|
+
declare type AssetSourceUploadEventError = {
|
|
282
|
+
type: 'error'
|
|
283
|
+
/**
|
|
284
|
+
* Files errored
|
|
285
|
+
*/
|
|
286
|
+
files: AssetSourceUploadFile[]
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Emitted when a file upload is progressing
|
|
291
|
+
* @beta */
|
|
292
|
+
declare type AssetSourceUploadEventProgress = {
|
|
293
|
+
type: 'progress'
|
|
294
|
+
file: AssetSourceUploadFile
|
|
295
|
+
progress: number
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Emitted when a file upload is changing status
|
|
300
|
+
* @beta */
|
|
301
|
+
declare type AssetSourceUploadEventStatus = {
|
|
302
|
+
type: 'status'
|
|
303
|
+
file: AssetSourceUploadFile
|
|
304
|
+
status: AssetSourceUploadFile['status']
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** @beta */
|
|
308
|
+
declare interface AssetSourceUploadFile {
|
|
309
|
+
id: string
|
|
310
|
+
file: globalThis.File
|
|
311
|
+
progress: number
|
|
312
|
+
status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
|
|
313
|
+
error?: Error
|
|
314
|
+
result?: unknown
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export declare interface AssetVersion<
|
|
318
|
+
AssetInstance extends AssetInstanceDocument = AssetInstanceDocument,
|
|
319
|
+
> {
|
|
320
|
+
_key: string
|
|
321
|
+
_type: SanityAssetVersion['_type']
|
|
322
|
+
title?: string
|
|
323
|
+
instance: AssetInstance
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export declare type BaseDocument = {
|
|
327
|
+
_id: string
|
|
328
|
+
_type: string
|
|
329
|
+
_rev: string
|
|
330
|
+
_createdAt: string
|
|
331
|
+
_updatedAt: string
|
|
332
|
+
[key: string]: any
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** @public */
|
|
336
|
+
declare interface BaseSchemaDefinition {
|
|
337
|
+
name: string
|
|
338
|
+
title?: string
|
|
339
|
+
description?: string | React.JSX.Element
|
|
340
|
+
hidden?: ConditionalProperty
|
|
341
|
+
readOnly?: ConditionalProperty
|
|
342
|
+
icon?: ComponentType | ReactNode
|
|
343
|
+
validation?: unknown
|
|
344
|
+
initialValue?: unknown
|
|
345
|
+
deprecated?: DeprecatedProperty
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** @public */
|
|
349
|
+
declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
|
|
350
|
+
name: string
|
|
351
|
+
title?: string
|
|
352
|
+
description?: string
|
|
353
|
+
type?: SchemaType
|
|
354
|
+
liveEdit?: boolean
|
|
355
|
+
readOnly?: ConditionalProperty
|
|
356
|
+
hidden?: ConditionalProperty
|
|
357
|
+
icon?: ComponentType
|
|
358
|
+
initialValue?: InitialValueProperty<any, any>
|
|
359
|
+
validation?: SchemaValidationValue
|
|
360
|
+
preview?: PreviewConfig
|
|
361
|
+
/** @beta */
|
|
362
|
+
components?: {
|
|
363
|
+
block?: ComponentType<any>
|
|
364
|
+
inlineBlock?: ComponentType<any>
|
|
365
|
+
annotation?: ComponentType<any>
|
|
366
|
+
diff?: ComponentType<any>
|
|
367
|
+
field?: ComponentType<any>
|
|
368
|
+
input?: ComponentType<any>
|
|
369
|
+
item?: ComponentType<any>
|
|
370
|
+
preview?: ComponentType<any>
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* @deprecated This will be removed.
|
|
374
|
+
*/
|
|
375
|
+
placeholder?: string
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* `BaseOptions` applies to all type options.
|
|
380
|
+
*
|
|
381
|
+
* It can be extended by interface declaration merging in plugins to provide generic options to all types and fields.
|
|
382
|
+
*
|
|
383
|
+
* @public
|
|
384
|
+
* */
|
|
385
|
+
declare interface BaseSchemaTypeOptions {
|
|
386
|
+
sanityCreate?: SanityCreateOptions
|
|
387
|
+
canvasApp?: CanvasAppOptions
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Schema definition for text block decorators.
|
|
392
|
+
*
|
|
393
|
+
* @public
|
|
394
|
+
* @example The default set of decorators
|
|
395
|
+
* ```ts
|
|
396
|
+
* {
|
|
397
|
+
* name: 'blockContent',
|
|
398
|
+
* title: 'Content',
|
|
399
|
+
* type: 'array',
|
|
400
|
+
* of: [
|
|
401
|
+
* {
|
|
402
|
+
* type: 'block',
|
|
403
|
+
* marks: {
|
|
404
|
+
* decorators: [
|
|
405
|
+
* {title: 'Strong', value: 'strong'},
|
|
406
|
+
* {title: 'Emphasis', value: 'em'},
|
|
407
|
+
* {title: 'Underline', value: 'underline'},
|
|
408
|
+
* {title: 'Strike', value: 'strike'},
|
|
409
|
+
* {title: 'Code', value: 'code'},
|
|
410
|
+
* ]
|
|
411
|
+
* }
|
|
412
|
+
* }
|
|
413
|
+
* ]
|
|
414
|
+
* }
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
declare interface BlockDecoratorDefinition {
|
|
418
|
+
title: string
|
|
419
|
+
i18nTitleKey?: string
|
|
420
|
+
value: string
|
|
421
|
+
icon?: ReactNode | ComponentType
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Schema definition for text blocks.
|
|
426
|
+
*
|
|
427
|
+
* @public
|
|
428
|
+
* @example the default block definition
|
|
429
|
+
* ```ts
|
|
430
|
+
* {
|
|
431
|
+
* name: 'blockContent',
|
|
432
|
+
* title: 'Content',
|
|
433
|
+
* type: 'array',
|
|
434
|
+
* of: [
|
|
435
|
+
* {
|
|
436
|
+
* type: 'block',
|
|
437
|
+
* marks: {
|
|
438
|
+
* decorators: [
|
|
439
|
+
* {title: 'Strong', value: 'strong'},
|
|
440
|
+
* {title: 'Emphasis', value: 'em'},
|
|
441
|
+
* {title: 'Underline', value: 'underline'},
|
|
442
|
+
* {title: 'Strike', value: 'strike'},
|
|
443
|
+
* {title: 'Code', value: 'code'},
|
|
444
|
+
* ],
|
|
445
|
+
* annotations: [
|
|
446
|
+
* {
|
|
447
|
+
* type: 'object',
|
|
448
|
+
* name: 'link',
|
|
449
|
+
* fields: [
|
|
450
|
+
* {
|
|
451
|
+
* type: 'string',
|
|
452
|
+
* name: 'href',
|
|
453
|
+
* },
|
|
454
|
+
* ],
|
|
455
|
+
* },
|
|
456
|
+
* ]
|
|
457
|
+
* },
|
|
458
|
+
* styles: [
|
|
459
|
+
* {title: 'Normal', value: 'normal'},
|
|
460
|
+
* {title: 'H1', value: 'h1'},
|
|
461
|
+
* {title: 'H2', value: 'h2'},
|
|
462
|
+
* {title: 'H3', value: 'h3'},
|
|
463
|
+
* {title: 'H4', value: 'h4'},
|
|
464
|
+
* {title: 'H5', value: 'h5'},
|
|
465
|
+
* {title: 'H6', value: 'h6'},
|
|
466
|
+
* {title: 'Quote', value: 'blockquote'}
|
|
467
|
+
* ],
|
|
468
|
+
* lists: [
|
|
469
|
+
* {title: 'Bullet', value: 'bullet'},
|
|
470
|
+
* {title: 'Number', value: 'number'},
|
|
471
|
+
* ],
|
|
472
|
+
* },
|
|
473
|
+
* ]
|
|
474
|
+
* }
|
|
475
|
+
* ```
|
|
476
|
+
*/
|
|
477
|
+
declare interface BlockDefinition extends BaseSchemaDefinition {
|
|
478
|
+
type: 'block'
|
|
479
|
+
styles?: BlockStyleDefinition[]
|
|
480
|
+
lists?: BlockListDefinition[]
|
|
481
|
+
marks?: BlockMarksDefinition
|
|
482
|
+
of?: ArrayOfType<'object' | 'reference'>[]
|
|
483
|
+
initialValue?: InitialValueProperty<any, any[]>
|
|
484
|
+
options?: BlockOptions
|
|
485
|
+
validation?: ValidationBuilder<BlockRule, any[]>
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Schema definition for a text block list style.
|
|
490
|
+
*
|
|
491
|
+
* @public
|
|
492
|
+
* @example The defaults lists
|
|
493
|
+
* ```ts
|
|
494
|
+
* {
|
|
495
|
+
* name: 'blockContent',
|
|
496
|
+
* title: 'Content',
|
|
497
|
+
* type: 'array',
|
|
498
|
+
* of: [
|
|
499
|
+
* {
|
|
500
|
+
* type: 'block',
|
|
501
|
+
* lists: [
|
|
502
|
+
* {title: 'Bullet', value: 'bullet'},
|
|
503
|
+
* {title: 'Number', value: 'number'},
|
|
504
|
+
* ]
|
|
505
|
+
* }
|
|
506
|
+
* ]
|
|
507
|
+
* }
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
declare interface BlockListDefinition {
|
|
511
|
+
title: string
|
|
512
|
+
i18nTitleKey?: string
|
|
513
|
+
value: string
|
|
514
|
+
icon?: ReactNode | ComponentType
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Schema definition for text block marks (decorators and annotations).
|
|
519
|
+
*
|
|
520
|
+
* @public */
|
|
521
|
+
declare interface BlockMarksDefinition {
|
|
522
|
+
decorators?: BlockDecoratorDefinition[]
|
|
523
|
+
annotations?: ArrayOfType<'object' | 'reference'>[]
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Schema options for a Block schema definition
|
|
528
|
+
* @public */
|
|
529
|
+
declare interface BlockOptions extends BaseSchemaTypeOptions {
|
|
530
|
+
/**
|
|
531
|
+
* Turn on or off the builtin browser spellchecking. Default is on.
|
|
532
|
+
*/
|
|
533
|
+
spellCheck?: boolean
|
|
534
|
+
unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/** @public */
|
|
538
|
+
declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Schema definition for a text block style.
|
|
542
|
+
* A text block may have a block style like 'header', 'normal', 'lead'
|
|
543
|
+
* attached to it, which is stored on the `.style` property for that block.
|
|
544
|
+
*
|
|
545
|
+
* @public
|
|
546
|
+
* @remarks The first defined style will become the default style.´´
|
|
547
|
+
* @example The default set of styles
|
|
548
|
+
* ```ts
|
|
549
|
+
* {
|
|
550
|
+
* name: 'blockContent',
|
|
551
|
+
* title: 'Content',
|
|
552
|
+
* type: 'array',
|
|
553
|
+
* of: [
|
|
554
|
+
* {
|
|
555
|
+
* type: 'block',
|
|
556
|
+
* styles: [
|
|
557
|
+
* {title: 'Normal', value: 'normal'},
|
|
558
|
+
* {title: 'H1', value: 'h1'},
|
|
559
|
+
* {title: 'H2', value: 'h2'},
|
|
560
|
+
* {title: 'H3', value: 'h3'},
|
|
561
|
+
* {title: 'H4', value: 'h4'},
|
|
562
|
+
* {title: 'H5', value: 'h5'},
|
|
563
|
+
* {title: 'H6', value: 'h6'},
|
|
564
|
+
* {title: 'Quote', value: 'blockquote'}
|
|
565
|
+
* ]
|
|
566
|
+
* }
|
|
567
|
+
* ]
|
|
568
|
+
* }
|
|
569
|
+
* ```
|
|
570
|
+
* @example Example of defining a block type with custom styles and render components.
|
|
571
|
+
* ```ts
|
|
572
|
+
* defineArrayMember({
|
|
573
|
+
* type: 'block',
|
|
574
|
+
* styles: [
|
|
575
|
+
* {
|
|
576
|
+
* title: 'Paragraph',
|
|
577
|
+
* value: 'paragraph',
|
|
578
|
+
* component: ParagraphStyle,
|
|
579
|
+
* },
|
|
580
|
+
* {
|
|
581
|
+
* title: 'Lead',
|
|
582
|
+
* value: 'lead',
|
|
583
|
+
* component: LeadStyle,
|
|
584
|
+
* },
|
|
585
|
+
* {
|
|
586
|
+
* title: 'Heading',
|
|
587
|
+
* value: 'heading',
|
|
588
|
+
* component: HeadingStyle,
|
|
589
|
+
* },
|
|
590
|
+
* ],
|
|
591
|
+
* })
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
declare interface BlockStyleDefinition {
|
|
595
|
+
title: string
|
|
596
|
+
value: string
|
|
597
|
+
i18nTitleKey?: string
|
|
598
|
+
icon?: ReactNode | ComponentType
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/** @public */
|
|
602
|
+
declare interface BooleanDefinition extends BaseSchemaDefinition {
|
|
603
|
+
type: 'boolean'
|
|
604
|
+
options?: BooleanOptions
|
|
605
|
+
initialValue?: InitialValueProperty<any, boolean>
|
|
606
|
+
validation?: ValidationBuilder<BooleanRule, boolean>
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/** @public */
|
|
610
|
+
declare interface BooleanOptions extends BaseSchemaTypeOptions {
|
|
611
|
+
layout?: 'switch' | 'checkbox'
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** @public */
|
|
615
|
+
declare interface BooleanRule extends RuleDef<BooleanRule, boolean> {}
|
|
616
|
+
|
|
617
|
+
/** @public */
|
|
618
|
+
declare interface BooleanSchemaType extends BaseSchemaType {
|
|
619
|
+
jsonType: 'boolean'
|
|
620
|
+
options?: BooleanOptions
|
|
621
|
+
initialValue?: InitialValueProperty<any, boolean>
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Options for configuring how Canvas app interfaces with the type or field.
|
|
626
|
+
*
|
|
627
|
+
* @public
|
|
628
|
+
*/
|
|
629
|
+
declare interface CanvasAppOptions {
|
|
630
|
+
/** Set to true to exclude a type or field from appearing in Canvas */
|
|
631
|
+
exclude?: boolean
|
|
632
|
+
/**
|
|
633
|
+
* A short description of what the type or field is used for.
|
|
634
|
+
* Purpose can be used to improve how and when content mapping uses the field.
|
|
635
|
+
* */
|
|
636
|
+
purpose?: string
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/** @public */
|
|
640
|
+
declare interface CollapseOptions {
|
|
641
|
+
collapsed?: boolean
|
|
642
|
+
collapsible?: boolean
|
|
643
|
+
/**
|
|
644
|
+
* @deprecated Use `collapsible` instead
|
|
645
|
+
*/
|
|
646
|
+
collapsable?: boolean
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/** @public */
|
|
650
|
+
declare type ConditionalProperty = boolean | ConditionalPropertyCallback | undefined
|
|
651
|
+
|
|
652
|
+
/** @public */
|
|
653
|
+
declare type ConditionalPropertyCallback = (context: ConditionalPropertyCallbackContext) => boolean
|
|
654
|
+
|
|
655
|
+
/** @public */
|
|
656
|
+
declare interface ConditionalPropertyCallbackContext {
|
|
657
|
+
document: SanityDocument | undefined
|
|
658
|
+
parent: any
|
|
659
|
+
value: any
|
|
660
|
+
currentUser: Omit<CurrentUser, 'role'> | null
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/** @public */
|
|
664
|
+
declare interface CrossDatasetReferenceDefinition extends BaseSchemaDefinition {
|
|
665
|
+
type: 'crossDatasetReference'
|
|
666
|
+
weak?: boolean
|
|
667
|
+
to: {
|
|
668
|
+
type: string
|
|
669
|
+
title?: string
|
|
670
|
+
icon?: ComponentType
|
|
671
|
+
preview?: PreviewConfig
|
|
672
|
+
/**
|
|
673
|
+
* @deprecated Unused. Configuring search is no longer supported.
|
|
674
|
+
*/
|
|
675
|
+
__experimental_search?: {
|
|
676
|
+
path: string | string[]
|
|
677
|
+
weight?: number
|
|
678
|
+
mapWith?: string
|
|
679
|
+
}[]
|
|
680
|
+
}[]
|
|
681
|
+
dataset: string
|
|
682
|
+
studioUrl?: (document: {id: string; type?: string}) => string | null
|
|
683
|
+
tokenId?: string
|
|
684
|
+
options?: ReferenceOptions
|
|
685
|
+
/**
|
|
686
|
+
* @deprecated Cross-project references are no longer supported, only cross-dataset
|
|
687
|
+
*/
|
|
688
|
+
projectId?: string
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/** @public */
|
|
692
|
+
declare interface CurrentUser {
|
|
693
|
+
id: string
|
|
694
|
+
name: string
|
|
695
|
+
email: string
|
|
696
|
+
profileImage?: string
|
|
697
|
+
provider?: string
|
|
698
|
+
/** @deprecated use `roles` instead */
|
|
699
|
+
role: string
|
|
700
|
+
roles: Role[]
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/** @public */
|
|
704
|
+
declare interface CustomValidator<T = unknown> {
|
|
705
|
+
(value: T, context: ValidationContext): CustomValidatorResult | Promise<CustomValidatorResult>
|
|
706
|
+
bypassConcurrencyLimit?: boolean
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/** @public */
|
|
710
|
+
declare type CustomValidatorResult =
|
|
711
|
+
| true
|
|
712
|
+
| string
|
|
713
|
+
| ValidationError
|
|
714
|
+
| ValidationError[]
|
|
715
|
+
| LocalizedValidationMessages
|
|
716
|
+
|
|
717
|
+
/** @public */
|
|
718
|
+
declare interface DateDefinition extends BaseSchemaDefinition {
|
|
719
|
+
type: 'date'
|
|
720
|
+
options?: DateOptions
|
|
721
|
+
placeholder?: string
|
|
722
|
+
validation?: ValidationBuilder<DateRule, string>
|
|
723
|
+
initialValue?: InitialValueProperty<any, string>
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/** @public */
|
|
727
|
+
declare interface DateOptions extends BaseSchemaTypeOptions {
|
|
728
|
+
dateFormat?: string
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/** @public */
|
|
732
|
+
declare interface DateRule extends RuleDef<DateRule, string> {
|
|
733
|
+
/**
|
|
734
|
+
* @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
|
|
735
|
+
*/
|
|
736
|
+
min: (minDate: string | FieldReference) => DateRule
|
|
737
|
+
/**
|
|
738
|
+
* @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
|
|
739
|
+
*/
|
|
740
|
+
max: (maxDate: string | FieldReference) => DateRule
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/** @public */
|
|
744
|
+
declare interface DatetimeDefinition extends BaseSchemaDefinition {
|
|
745
|
+
type: 'datetime'
|
|
746
|
+
options?: DatetimeOptions
|
|
747
|
+
placeholder?: string
|
|
748
|
+
validation?: ValidationBuilder<DatetimeRule, string>
|
|
749
|
+
initialValue?: InitialValueProperty<any, string>
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/** @public */
|
|
753
|
+
declare interface DatetimeOptions extends BaseSchemaTypeOptions {
|
|
754
|
+
dateFormat?: string
|
|
755
|
+
timeFormat?: string
|
|
756
|
+
timeStep?: number
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/** @public */
|
|
760
|
+
declare interface DatetimeRule extends RuleDef<DatetimeRule, string> {
|
|
761
|
+
/**
|
|
762
|
+
* @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
|
|
763
|
+
*/
|
|
764
|
+
min: (minDate: string | FieldReference) => DatetimeRule
|
|
765
|
+
/**
|
|
766
|
+
* @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
|
|
767
|
+
*/
|
|
768
|
+
max: (maxDate: string | FieldReference) => DatetimeRule
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/** @public */
|
|
772
|
+
declare interface DeprecatedProperty {
|
|
773
|
+
reason: string
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* @public
|
|
778
|
+
*/
|
|
779
|
+
declare interface DeprecationConfiguration {
|
|
780
|
+
deprecated: DeprecatedProperty
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/** @public */
|
|
784
|
+
declare interface DocumentDefinition extends Omit<ObjectDefinition, 'type'> {
|
|
785
|
+
type: 'document'
|
|
786
|
+
liveEdit?: boolean
|
|
787
|
+
/** @beta */
|
|
788
|
+
orderings?: SortOrdering[]
|
|
789
|
+
options?: DocumentOptions
|
|
790
|
+
validation?: ValidationBuilder<DocumentRule, SanityDocument>
|
|
791
|
+
initialValue?: InitialValueProperty<any, Record<string, unknown>>
|
|
792
|
+
/** @deprecated Unused. Use the new field-level search config. */
|
|
793
|
+
__experimental_search?: {
|
|
794
|
+
path: string
|
|
795
|
+
weight: number
|
|
796
|
+
mapWith?: string
|
|
797
|
+
}[]
|
|
798
|
+
/** @alpha */
|
|
799
|
+
__experimental_omnisearch_visibility?: boolean
|
|
800
|
+
/**
|
|
801
|
+
* Determines whether the large preview title is displayed in the document pane form
|
|
802
|
+
* @alpha
|
|
803
|
+
* */
|
|
804
|
+
__experimental_formPreviewTitle?: boolean
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* This exists only to allow for extensions using declaration-merging.
|
|
809
|
+
*
|
|
810
|
+
* @public
|
|
811
|
+
*/
|
|
812
|
+
declare interface DocumentOptions extends BaseSchemaTypeOptions {}
|
|
813
|
+
|
|
814
|
+
/** @public */
|
|
815
|
+
declare interface DocumentRule extends RuleDef<DocumentRule, SanityDocument> {}
|
|
816
|
+
|
|
817
|
+
/** @public */
|
|
818
|
+
declare interface EmailDefinition extends BaseSchemaDefinition {
|
|
819
|
+
type: 'email'
|
|
820
|
+
options?: EmailOptions
|
|
821
|
+
placeholder?: string
|
|
822
|
+
validation?: ValidationBuilder<EmailRule, string>
|
|
823
|
+
initialValue?: InitialValueProperty<any, string>
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/** @public */
|
|
827
|
+
declare interface EmailOptions extends BaseSchemaTypeOptions {}
|
|
828
|
+
|
|
829
|
+
/** @public */
|
|
830
|
+
declare interface EmailRule extends RuleDef<EmailRule, string> {}
|
|
831
|
+
|
|
832
|
+
/** @public */
|
|
833
|
+
declare interface EmptyProps {}
|
|
834
|
+
|
|
835
|
+
/** @public */
|
|
836
|
+
declare interface EnumListProps<V = unknown> {
|
|
837
|
+
list?: Array<TitledListValue<V> | V>
|
|
838
|
+
layout?: 'radio' | 'dropdown'
|
|
839
|
+
direction?: 'horizontal' | 'vertical'
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* The shape of a field definition. Note, it's recommended to use the
|
|
844
|
+
* `defineField` function instead of using this type directly.
|
|
845
|
+
*
|
|
846
|
+
* Where `defineField` infers the exact field type,
|
|
847
|
+
* FieldDefinition is a compromise union of all types a field can have.
|
|
848
|
+
*
|
|
849
|
+
* A field definition can be a reference to another registered top-level type
|
|
850
|
+
* or a inline type definition.
|
|
851
|
+
*
|
|
852
|
+
* @public
|
|
853
|
+
*/
|
|
854
|
+
declare type FieldDefinition<
|
|
855
|
+
TType extends IntrinsicTypeName = IntrinsicTypeName,
|
|
856
|
+
TAlias extends IntrinsicTypeName | undefined = undefined,
|
|
857
|
+
> = (InlineFieldDefinition[TType] | TypeAliasDefinition<string, TAlias>) & FieldDefinitionBase
|
|
858
|
+
|
|
859
|
+
/** @public */
|
|
860
|
+
declare interface FieldDefinitionBase {
|
|
861
|
+
fieldset?: string
|
|
862
|
+
group?: string | string[]
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/** @public */
|
|
866
|
+
declare interface FieldGroup {
|
|
867
|
+
name: string
|
|
868
|
+
icon?: ComponentType
|
|
869
|
+
title?: string
|
|
870
|
+
description?: string
|
|
871
|
+
i18n?: I18nTextRecord<'title'>
|
|
872
|
+
hidden?: ConditionalProperty
|
|
873
|
+
default?: boolean
|
|
874
|
+
fields?: ObjectField[]
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/** @public */
|
|
878
|
+
declare type FieldGroupDefinition = {
|
|
879
|
+
name: string
|
|
880
|
+
title?: string
|
|
881
|
+
hidden?: ConditionalProperty
|
|
882
|
+
icon?: ComponentType
|
|
883
|
+
default?: boolean
|
|
884
|
+
i18n?: I18nTextRecord<'title'>
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Holds a reference to a different field
|
|
889
|
+
* NOTE: Only use this through {@link Rule.valueOfField}
|
|
890
|
+
*
|
|
891
|
+
* @public
|
|
892
|
+
*/
|
|
893
|
+
declare interface FieldReference {
|
|
894
|
+
type: symbol
|
|
895
|
+
path: string | string[]
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/** @public */
|
|
899
|
+
declare type FieldRules = {
|
|
900
|
+
[fieldKey: string]: SchemaValidationValue
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/** @public */
|
|
904
|
+
declare type Fieldset = SingleFieldSet | MultiFieldSet
|
|
905
|
+
|
|
906
|
+
/** @public */
|
|
907
|
+
declare type FieldsetDefinition = {
|
|
908
|
+
name: string
|
|
909
|
+
title?: string
|
|
910
|
+
description?: string
|
|
911
|
+
group?: string
|
|
912
|
+
hidden?: ConditionalProperty
|
|
913
|
+
readOnly?: ConditionalProperty
|
|
914
|
+
options?: ObjectOptions
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/** @public */
|
|
918
|
+
declare interface File_2 {
|
|
919
|
+
[key: string]: unknown
|
|
920
|
+
asset?: Reference
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/** @public */
|
|
924
|
+
declare interface FileDefinition
|
|
925
|
+
extends Omit<ObjectDefinition, 'type' | 'fields' | 'options' | 'groups' | 'validation'> {
|
|
926
|
+
type: 'file'
|
|
927
|
+
fields?: ObjectDefinition['fields']
|
|
928
|
+
options?: FileOptions
|
|
929
|
+
validation?: ValidationBuilder<FileRule, FileValue>
|
|
930
|
+
initialValue?: InitialValueProperty<any, FileValue>
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/** @public */
|
|
934
|
+
declare interface FileOptions extends ObjectOptions {
|
|
935
|
+
storeOriginalFilename?: boolean
|
|
936
|
+
accept?: string
|
|
937
|
+
sources?: AssetSource[]
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
/** @public */
|
|
941
|
+
declare interface FileRule extends RuleDef<FileRule, FileValue> {
|
|
942
|
+
/**
|
|
943
|
+
* Require a file field has an asset.
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```ts
|
|
947
|
+
* defineField({
|
|
948
|
+
* name: 'file',
|
|
949
|
+
* title: 'File',
|
|
950
|
+
* type: 'file',
|
|
951
|
+
* validation: (Rule) => Rule.required().assetRequired(),
|
|
952
|
+
* })
|
|
953
|
+
* ```
|
|
954
|
+
*/
|
|
955
|
+
assetRequired(): FileRule
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/** @public */
|
|
959
|
+
declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
|
|
960
|
+
options?: FileOptions
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
export declare type FileStatus = 'pending' | 'uploading' | 'complete' | 'error'
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Wrapper object for the file upload with progress and status
|
|
967
|
+
*/
|
|
968
|
+
export declare interface FileUpload {
|
|
969
|
+
id: string
|
|
970
|
+
file: File
|
|
971
|
+
status: FileStatus
|
|
972
|
+
progress: number
|
|
973
|
+
error?: Error
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/** @public */
|
|
977
|
+
declare interface FileValue {
|
|
978
|
+
asset?: Reference
|
|
979
|
+
[index: string]: unknown
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
declare type Geopoint = {
|
|
983
|
+
_type: 'geopoint'
|
|
984
|
+
lat?: number
|
|
985
|
+
lng?: number
|
|
986
|
+
alt?: number
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/** @public */
|
|
990
|
+
declare interface GeopointDefinition extends BaseSchemaDefinition {
|
|
991
|
+
type: 'geopoint'
|
|
992
|
+
options?: GeopointOptions
|
|
993
|
+
validation?: ValidationBuilder<GeopointRule, GeopointValue>
|
|
994
|
+
initialValue?: InitialValueProperty<any, Omit<GeopointValue, '_type'>>
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/** @public */
|
|
998
|
+
declare interface GeopointOptions extends BaseSchemaTypeOptions {}
|
|
999
|
+
|
|
1000
|
+
/** @public */
|
|
1001
|
+
declare interface GeopointRule extends RuleDef<GeopointRule, GeopointValue> {}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Geographical point representing a pair of latitude and longitude coordinates,
|
|
1005
|
+
* stored as degrees, in the World Geodetic System 1984 (WGS 84) format. Also
|
|
1006
|
+
* includes an optional `alt` property representing the altitude in meters.
|
|
1007
|
+
*
|
|
1008
|
+
* @public
|
|
1009
|
+
*/
|
|
1010
|
+
declare interface GeopointValue {
|
|
1011
|
+
/**
|
|
1012
|
+
* Type of the object. Must be `geopoint`.
|
|
1013
|
+
*/
|
|
1014
|
+
_type: 'geopoint'
|
|
1015
|
+
/**
|
|
1016
|
+
* Latitude in degrees
|
|
1017
|
+
*/
|
|
1018
|
+
lat: number
|
|
1019
|
+
/**
|
|
1020
|
+
* Longitude in degrees
|
|
1021
|
+
*/
|
|
1022
|
+
lng: number
|
|
1023
|
+
/**
|
|
1024
|
+
* Altitude in meters
|
|
1025
|
+
*/
|
|
1026
|
+
alt?: number
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/** @public */
|
|
1030
|
+
declare interface GlobalDocumentReferenceDefinition extends BaseSchemaDefinition {
|
|
1031
|
+
type: 'globalDocumentReference'
|
|
1032
|
+
weak?: boolean
|
|
1033
|
+
to: {
|
|
1034
|
+
type: string
|
|
1035
|
+
title?: string
|
|
1036
|
+
icon?: ComponentType
|
|
1037
|
+
preview?: PreviewConfig
|
|
1038
|
+
}[]
|
|
1039
|
+
resourceType: string
|
|
1040
|
+
resourceId: string
|
|
1041
|
+
options?: ReferenceOptions
|
|
1042
|
+
studioUrl?: string | ((document: {id: string; type?: string}) => string | null)
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/** @public */
|
|
1046
|
+
declare interface HotspotOptions {
|
|
1047
|
+
previews?: HotspotPreview[]
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/** @public */
|
|
1051
|
+
declare interface HotspotPreview {
|
|
1052
|
+
title: string
|
|
1053
|
+
aspectRatio: number
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/** @public */
|
|
1057
|
+
declare type I18nTextRecord<K extends string> = {
|
|
1058
|
+
[P in K]?: {
|
|
1059
|
+
key: string
|
|
1060
|
+
ns: string
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
/** @public */
|
|
1065
|
+
declare interface ImageAsset extends Asset_2 {
|
|
1066
|
+
_type: 'sanity.imageAsset'
|
|
1067
|
+
metadata: ImageMetadata
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/** @public */
|
|
1071
|
+
declare interface ImageCrop {
|
|
1072
|
+
_type?: 'sanity.imageCrop'
|
|
1073
|
+
left: number
|
|
1074
|
+
bottom: number
|
|
1075
|
+
right: number
|
|
1076
|
+
top: number
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/** @public */
|
|
1080
|
+
declare interface ImageDefinition
|
|
1081
|
+
extends Omit<ObjectDefinition, 'type' | 'fields' | 'options' | 'groups' | 'validation'> {
|
|
1082
|
+
type: 'image'
|
|
1083
|
+
fields?: FieldDefinition[]
|
|
1084
|
+
options?: ImageOptions
|
|
1085
|
+
validation?: ValidationBuilder<ImageRule, ImageValue>
|
|
1086
|
+
initialValue?: InitialValueProperty<any, ImageValue>
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/** @public */
|
|
1090
|
+
declare interface ImageDimensions {
|
|
1091
|
+
_type: 'sanity.imageDimensions'
|
|
1092
|
+
height: number
|
|
1093
|
+
width: number
|
|
1094
|
+
aspectRatio: number
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/** @public */
|
|
1098
|
+
declare interface ImageHotspot {
|
|
1099
|
+
_type?: 'sanity.imageHotspot'
|
|
1100
|
+
width: number
|
|
1101
|
+
height: number
|
|
1102
|
+
x: number
|
|
1103
|
+
y: number
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
/** @public */
|
|
1107
|
+
declare interface ImageMetadata {
|
|
1108
|
+
[key: string]: unknown
|
|
1109
|
+
_type: 'sanity.imageMetadata'
|
|
1110
|
+
dimensions: ImageDimensions
|
|
1111
|
+
palette?: ImagePalette
|
|
1112
|
+
lqip?: string
|
|
1113
|
+
blurHash?: string
|
|
1114
|
+
hasAlpha: boolean
|
|
1115
|
+
isOpaque: boolean
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/** @public */
|
|
1119
|
+
declare type ImageMetadataType = 'blurhash' | 'lqip' | 'palette' | 'exif' | 'image' | 'location'
|
|
1120
|
+
|
|
1121
|
+
/** @public */
|
|
1122
|
+
declare interface ImageOptions extends FileOptions {
|
|
1123
|
+
metadata?: ImageMetadataType[]
|
|
1124
|
+
hotspot?: boolean | HotspotOptions
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/** @public */
|
|
1128
|
+
declare interface ImagePalette {
|
|
1129
|
+
_type: 'sanity.imagePalette'
|
|
1130
|
+
darkMuted?: ImageSwatch
|
|
1131
|
+
darkVibrant?: ImageSwatch
|
|
1132
|
+
dominant?: ImageSwatch
|
|
1133
|
+
lightMuted?: ImageSwatch
|
|
1134
|
+
lightVibrant?: ImageSwatch
|
|
1135
|
+
muted?: ImageSwatch
|
|
1136
|
+
vibrant?: ImageSwatch
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/** @public */
|
|
1140
|
+
declare interface ImageRule extends RuleDef<ImageRule, ImageValue> {
|
|
1141
|
+
/**
|
|
1142
|
+
* Require an image field has an asset.
|
|
1143
|
+
*
|
|
1144
|
+
* @example
|
|
1145
|
+
* ```ts
|
|
1146
|
+
* defineField({
|
|
1147
|
+
* name: 'image',
|
|
1148
|
+
* title: 'Image',
|
|
1149
|
+
* type: 'image',
|
|
1150
|
+
* validation: (Rule) => Rule.required().assetRequired(),
|
|
1151
|
+
* })
|
|
1152
|
+
* ```
|
|
1153
|
+
*/
|
|
1154
|
+
assetRequired(): ImageRule
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
/** @public */
|
|
1158
|
+
declare interface ImageSchemaType extends Omit<ObjectSchemaType, 'options'> {
|
|
1159
|
+
options?: ImageOptions
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
/** @public */
|
|
1163
|
+
declare interface ImageSwatch {
|
|
1164
|
+
_type: 'sanity.imagePaletteSwatch'
|
|
1165
|
+
background: string
|
|
1166
|
+
foreground: string
|
|
1167
|
+
population: number
|
|
1168
|
+
title?: string
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/** @public */
|
|
1172
|
+
declare interface ImageValue extends FileValue {
|
|
1173
|
+
crop?: ImageCrop
|
|
1174
|
+
hotspot?: ImageHotspot
|
|
1175
|
+
[index: string]: unknown
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/** @public */
|
|
1179
|
+
declare type IndexTuple = [number | '', number | '']
|
|
1180
|
+
|
|
1181
|
+
/** @public */
|
|
1182
|
+
declare type InitialValueProperty<Params, Value> =
|
|
1183
|
+
| Value
|
|
1184
|
+
| InitialValueResolver<Params, Value>
|
|
1185
|
+
| undefined
|
|
1186
|
+
|
|
1187
|
+
/** @public */
|
|
1188
|
+
declare type InitialValueResolver<Params, Value> = (
|
|
1189
|
+
params: Params | undefined,
|
|
1190
|
+
context: InitialValueResolverContext,
|
|
1191
|
+
) => Promise<Value> | Value
|
|
1192
|
+
|
|
1193
|
+
/** @public */
|
|
1194
|
+
declare interface InitialValueResolverContext {
|
|
1195
|
+
projectId: string
|
|
1196
|
+
dataset: string
|
|
1197
|
+
schema: Schema
|
|
1198
|
+
currentUser: CurrentUser | null
|
|
1199
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/** @public */
|
|
1203
|
+
declare type InlineFieldDefinition = {
|
|
1204
|
+
[K in keyof IntrinsicDefinitions]: Omit<
|
|
1205
|
+
IntrinsicDefinitions[K],
|
|
1206
|
+
'initialValue' | 'validation'
|
|
1207
|
+
> & {
|
|
1208
|
+
validation?: SchemaValidationValue
|
|
1209
|
+
initialValue?: InitialValueProperty<any, any>
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/** @alpha This API may change */
|
|
1214
|
+
declare interface InsertMenuOptions {
|
|
1215
|
+
/**
|
|
1216
|
+
* @defaultValue `'auto'`
|
|
1217
|
+
* `filter: 'auto'` automatically turns on filtering if there are more than 5
|
|
1218
|
+
* schema types added to the menu.
|
|
1219
|
+
*/
|
|
1220
|
+
filter?: 'auto' | boolean
|
|
1221
|
+
groups?: Array<{
|
|
1222
|
+
name: string
|
|
1223
|
+
title?: string
|
|
1224
|
+
of?: Array<string>
|
|
1225
|
+
}>
|
|
1226
|
+
/** defaultValue `true` */
|
|
1227
|
+
showIcons?: boolean
|
|
1228
|
+
/** @defaultValue `[{name: 'list'}]` */
|
|
1229
|
+
views?: Array<
|
|
1230
|
+
| {
|
|
1231
|
+
name: 'list'
|
|
1232
|
+
}
|
|
1233
|
+
| {
|
|
1234
|
+
name: 'grid'
|
|
1235
|
+
previewImageUrl?: (schemaTypeName: string) => string | undefined
|
|
1236
|
+
}
|
|
1237
|
+
>
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
declare const internalGroqTypeReferenceTo: unique symbol
|
|
1241
|
+
|
|
1242
|
+
/** @public */
|
|
1243
|
+
declare type IntrinsicArrayOfDefinition = {
|
|
1244
|
+
[K in keyof IntrinsicDefinitions]: Omit<
|
|
1245
|
+
ArrayOfEntry<IntrinsicDefinitions[K]>,
|
|
1246
|
+
'validation' | 'initialValue'
|
|
1247
|
+
> & {
|
|
1248
|
+
validation?: SchemaValidationValue
|
|
1249
|
+
initialValue?: InitialValueProperty<any, any>
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* `IntrinsicDefinitions` is a lookup map for "predefined" schema definitions.
|
|
1255
|
+
* Schema types in `IntrinsicDefinitions` will have good type-completion and type-safety in {@link defineType},
|
|
1256
|
+
* {@link defineField} and {@link defineArrayMember} once the `type` property is provided.
|
|
1257
|
+
*
|
|
1258
|
+
* By default, `IntrinsicDefinitions` contains all standard Sanity schema types (`array`, `string`, `number` ect),
|
|
1259
|
+
* but it is an interface and as such, open for extension.
|
|
1260
|
+
*
|
|
1261
|
+
* This type can be extended using declaration merging; this way new entries can be added.
|
|
1262
|
+
* See {@link defineType} for examples on how this can be accomplished.
|
|
1263
|
+
*
|
|
1264
|
+
* @see defineType
|
|
1265
|
+
*
|
|
1266
|
+
* @public
|
|
1267
|
+
*/
|
|
1268
|
+
declare interface IntrinsicDefinitions {
|
|
1269
|
+
array: ArrayDefinition
|
|
1270
|
+
block: BlockDefinition
|
|
1271
|
+
boolean: BooleanDefinition
|
|
1272
|
+
date: DateDefinition
|
|
1273
|
+
datetime: DatetimeDefinition
|
|
1274
|
+
document: DocumentDefinition
|
|
1275
|
+
file: FileDefinition
|
|
1276
|
+
geopoint: GeopointDefinition
|
|
1277
|
+
image: ImageDefinition
|
|
1278
|
+
number: NumberDefinition
|
|
1279
|
+
object: ObjectDefinition
|
|
1280
|
+
reference: ReferenceDefinition
|
|
1281
|
+
crossDatasetReference: CrossDatasetReferenceDefinition
|
|
1282
|
+
globalDocumentReference: GlobalDocumentReferenceDefinition
|
|
1283
|
+
slug: SlugDefinition
|
|
1284
|
+
string: StringDefinition
|
|
1285
|
+
text: TextDefinition
|
|
1286
|
+
url: UrlDefinition
|
|
1287
|
+
email: EmailDefinition
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* A union of all intrinsic types allowed natively in the schema.
|
|
1292
|
+
*
|
|
1293
|
+
* @see IntrinsicDefinitions
|
|
1294
|
+
*
|
|
1295
|
+
* @public
|
|
1296
|
+
*/
|
|
1297
|
+
declare type IntrinsicTypeName = IntrinsicDefinitions[keyof IntrinsicDefinitions]['type']
|
|
1298
|
+
|
|
1299
|
+
/** @public */
|
|
1300
|
+
declare type KeyedSegment = {
|
|
1301
|
+
_key: string
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Holds localized validation messages for a given field.
|
|
1306
|
+
*
|
|
1307
|
+
* @example Custom message for English (US) and Norwegian (Bokmål):
|
|
1308
|
+
* ```
|
|
1309
|
+
* {
|
|
1310
|
+
* 'en-US': 'Needs to start with a capital letter',
|
|
1311
|
+
* 'no-NB': 'Må starte med stor bokstav',
|
|
1312
|
+
* }
|
|
1313
|
+
* ```
|
|
1314
|
+
* @public
|
|
1315
|
+
*/
|
|
1316
|
+
declare interface LocalizedValidationMessages {
|
|
1317
|
+
[locale: string]: string
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
/** @public */
|
|
1321
|
+
declare interface MultiFieldSet {
|
|
1322
|
+
name: string
|
|
1323
|
+
title?: string
|
|
1324
|
+
description?: string
|
|
1325
|
+
single?: false
|
|
1326
|
+
group?: string | string[]
|
|
1327
|
+
options?: CollapseOptions & {
|
|
1328
|
+
columns?: number
|
|
1329
|
+
}
|
|
1330
|
+
fields: ObjectField[]
|
|
1331
|
+
hidden?: ConditionalProperty
|
|
1332
|
+
readOnly?: ConditionalProperty
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
/** @public */
|
|
1336
|
+
declare interface NumberDefinition extends BaseSchemaDefinition {
|
|
1337
|
+
type: 'number'
|
|
1338
|
+
options?: NumberOptions
|
|
1339
|
+
placeholder?: string
|
|
1340
|
+
validation?: ValidationBuilder<NumberRule, number>
|
|
1341
|
+
initialValue?: InitialValueProperty<any, number>
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/** @public */
|
|
1345
|
+
declare interface NumberOptions extends EnumListProps<number>, BaseSchemaTypeOptions {}
|
|
1346
|
+
|
|
1347
|
+
/** @public */
|
|
1348
|
+
declare interface NumberRule extends RuleDef<NumberRule, number> {
|
|
1349
|
+
min: (minNumber: number | FieldReference) => NumberRule
|
|
1350
|
+
max: (maxNumber: number | FieldReference) => NumberRule
|
|
1351
|
+
lessThan: (limit: number | FieldReference) => NumberRule
|
|
1352
|
+
greaterThan: (limit: number | FieldReference) => NumberRule
|
|
1353
|
+
integer: () => NumberRule
|
|
1354
|
+
precision: (limit: number | FieldReference) => NumberRule
|
|
1355
|
+
positive: () => NumberRule
|
|
1356
|
+
negative: () => NumberRule
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/** @public */
|
|
1360
|
+
declare interface NumberSchemaType extends BaseSchemaType {
|
|
1361
|
+
jsonType: 'number'
|
|
1362
|
+
options?: NumberOptions
|
|
1363
|
+
initialValue?: InitialValueProperty<any, number>
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/** @public */
|
|
1367
|
+
declare interface ObjectDefinition extends BaseSchemaDefinition {
|
|
1368
|
+
type: 'object'
|
|
1369
|
+
/**
|
|
1370
|
+
* Object must have at least one field. This is validated at Studio startup.
|
|
1371
|
+
*/
|
|
1372
|
+
fields: FieldDefinition[]
|
|
1373
|
+
groups?: FieldGroupDefinition[]
|
|
1374
|
+
fieldsets?: FieldsetDefinition[]
|
|
1375
|
+
preview?: PreviewConfig
|
|
1376
|
+
options?: ObjectOptions
|
|
1377
|
+
validation?: ValidationBuilder<ObjectRule, Record<string, unknown>>
|
|
1378
|
+
initialValue?: InitialValueProperty<any, Record<string, unknown>>
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
/** @public */
|
|
1382
|
+
declare interface ObjectField<T extends SchemaType = SchemaType> {
|
|
1383
|
+
name: string
|
|
1384
|
+
fieldset?: string
|
|
1385
|
+
group?: string | string[]
|
|
1386
|
+
type: ObjectFieldType<T>
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
/** @public */
|
|
1390
|
+
declare type ObjectFieldType<T extends SchemaType = SchemaType> = T & {
|
|
1391
|
+
hidden?: ConditionalProperty
|
|
1392
|
+
readOnly?: ConditionalProperty
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
/** @public */
|
|
1396
|
+
declare interface ObjectOptions extends BaseSchemaTypeOptions {
|
|
1397
|
+
collapsible?: boolean
|
|
1398
|
+
collapsed?: boolean
|
|
1399
|
+
columns?: number
|
|
1400
|
+
modal?: {
|
|
1401
|
+
type?: 'dialog' | 'popover'
|
|
1402
|
+
width?: number | number[] | 'auto'
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/** @public */
|
|
1407
|
+
declare interface ObjectRule extends RuleDef<ObjectRule, Record<string, unknown>> {}
|
|
1408
|
+
|
|
1409
|
+
/** @public */
|
|
1410
|
+
declare interface ObjectSchemaType extends BaseSchemaType {
|
|
1411
|
+
jsonType: 'object'
|
|
1412
|
+
fields: ObjectField[]
|
|
1413
|
+
groups?: FieldGroup[]
|
|
1414
|
+
fieldsets?: Fieldset[]
|
|
1415
|
+
initialValue?: InitialValueProperty<any, Record<string, unknown>>
|
|
1416
|
+
weak?: boolean
|
|
1417
|
+
/** @deprecated Unused. Use the new field-level search config. */
|
|
1418
|
+
__experimental_search?: {
|
|
1419
|
+
path: (string | number)[]
|
|
1420
|
+
weight: number
|
|
1421
|
+
mapWith?: string
|
|
1422
|
+
}[]
|
|
1423
|
+
/** @alpha */
|
|
1424
|
+
__experimental_omnisearch_visibility?: boolean
|
|
1425
|
+
/** @alpha */
|
|
1426
|
+
__experimental_actions?: string[]
|
|
1427
|
+
/** @alpha */
|
|
1428
|
+
__experimental_formPreviewTitle?: boolean
|
|
1429
|
+
/**
|
|
1430
|
+
* @beta
|
|
1431
|
+
*/
|
|
1432
|
+
orderings?: SortOrdering[]
|
|
1433
|
+
options?: any
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
/** @public */
|
|
1437
|
+
declare type Path = PathSegment[]
|
|
1438
|
+
|
|
1439
|
+
/** @public */
|
|
1440
|
+
declare type PathSegment = string | number | KeyedSegment | IndexTuple
|
|
1441
|
+
|
|
1442
|
+
export declare type PluginPostMessage =
|
|
1443
|
+
| PluginPostMessageAbortUploadRequest
|
|
1444
|
+
| PluginPostMessageAssetSelection
|
|
1445
|
+
| PluginPostMessageDocumentUpdate
|
|
1446
|
+
| PluginPostMessagePageLoaded
|
|
1447
|
+
| PluginPostMessagePageUnloaded
|
|
1448
|
+
| PluginPostMessageTokenRequest
|
|
1449
|
+
| PluginPostMessageTokenResponse
|
|
1450
|
+
| PluginPostMessageUploadFilesProgress
|
|
1451
|
+
| PluginPostMessageUploadFilesRequest
|
|
1452
|
+
| PluginPostMessageUploadFilesResponse
|
|
1453
|
+
|
|
1454
|
+
export declare type PluginPostMessageAbortUploadRequest = {
|
|
1455
|
+
type: 'abortUploadRequest'
|
|
1456
|
+
files?: {
|
|
1457
|
+
id: string
|
|
1458
|
+
}[]
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
export declare type PluginPostMessageAssetSelection = {
|
|
1462
|
+
type: 'assetSelection'
|
|
1463
|
+
selection: AssetSelectionItemWithLegacySupport[]
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* Message sent from the plugin that a document has been updated
|
|
1468
|
+
*/
|
|
1469
|
+
export declare type PluginPostMessageDocumentUpdate = {
|
|
1470
|
+
type: 'documentUpdate'
|
|
1471
|
+
document: {
|
|
1472
|
+
_id: string
|
|
1473
|
+
_type: string
|
|
1474
|
+
_rev: string
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* Message sent from a plugin page to notify the host that the page is loaded and ready to be interacted with
|
|
1480
|
+
*/
|
|
1481
|
+
export declare type PluginPostMessagePageLoaded = {
|
|
1482
|
+
type: 'pageLoaded'
|
|
1483
|
+
page: string
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Message sent from a plugin page that a page is unloaded by the user (for closing the dialog and similar)
|
|
1488
|
+
*/
|
|
1489
|
+
export declare type PluginPostMessagePageUnloaded = {
|
|
1490
|
+
type: 'pageUnloaded'
|
|
1491
|
+
page: string
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
export declare type PluginPostMessageTokenRequest = {
|
|
1495
|
+
type: 'tokenRequest'
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
export declare type PluginPostMessageTokenResponse = {
|
|
1499
|
+
type: 'tokenResponse'
|
|
1500
|
+
token: string | null
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* Message sent from the plugin when files are uploading
|
|
1505
|
+
*/
|
|
1506
|
+
export declare type PluginPostMessageUploadFilesProgress = {
|
|
1507
|
+
type: 'uploadProgress'
|
|
1508
|
+
files: FileUpload[]
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* Message sent from the plugin that the user wants to upload files
|
|
1513
|
+
*/
|
|
1514
|
+
export declare type PluginPostMessageUploadFilesRequest = {
|
|
1515
|
+
type: 'uploadRequest'
|
|
1516
|
+
files: {
|
|
1517
|
+
id: string
|
|
1518
|
+
file: File
|
|
1519
|
+
}[]
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
/**
|
|
1523
|
+
* Message sent from the app that the pending uploads are uploaded
|
|
1524
|
+
*/
|
|
1525
|
+
export declare type PluginPostMessageUploadFilesResponse = {
|
|
1526
|
+
type: 'uploadResponse'
|
|
1527
|
+
assets: AssetSelectionItemWithLegacySupport[]
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
/** @public */
|
|
1531
|
+
declare interface PrepareViewOptions {
|
|
1532
|
+
/** @beta */
|
|
1533
|
+
ordering?: SortOrdering
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
/** @public */
|
|
1537
|
+
declare interface PreviewConfig<
|
|
1538
|
+
Select extends Record<string, string> = Record<string, string>,
|
|
1539
|
+
PrepareValue extends Record<keyof Select, any> = Record<keyof Select, any>,
|
|
1540
|
+
> {
|
|
1541
|
+
select?: Select
|
|
1542
|
+
prepare?: (value: PrepareValue, viewOptions?: PrepareViewOptions) => PreviewValue
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
/** @public */
|
|
1546
|
+
declare interface PreviewValue {
|
|
1547
|
+
_id?: string
|
|
1548
|
+
_createdAt?: string
|
|
1549
|
+
_updatedAt?: string
|
|
1550
|
+
title?: string
|
|
1551
|
+
subtitle?: string
|
|
1552
|
+
description?: string
|
|
1553
|
+
media?: ReactNode | ElementType
|
|
1554
|
+
imageUrl?: string
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
/** @public */
|
|
1558
|
+
declare interface Reference {
|
|
1559
|
+
_type: string
|
|
1560
|
+
_ref: string
|
|
1561
|
+
_key?: string
|
|
1562
|
+
_weak?: boolean
|
|
1563
|
+
_strengthenOnPublish?: {
|
|
1564
|
+
type: string
|
|
1565
|
+
weak?: boolean
|
|
1566
|
+
template?: {
|
|
1567
|
+
id: string
|
|
1568
|
+
params: Record<string, string | number | boolean>
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
/** @public */
|
|
1574
|
+
declare interface ReferenceBaseOptions extends BaseSchemaTypeOptions {
|
|
1575
|
+
disableNew?: boolean
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
/** @public */
|
|
1579
|
+
declare interface ReferenceDefinition extends BaseSchemaDefinition {
|
|
1580
|
+
type: 'reference'
|
|
1581
|
+
to: ReferenceTo
|
|
1582
|
+
weak?: boolean
|
|
1583
|
+
options?: ReferenceOptions
|
|
1584
|
+
validation?: ValidationBuilder<ReferenceRule, ReferenceValue>
|
|
1585
|
+
initialValue?: InitialValueProperty<any, Omit<ReferenceValue, '_type'>>
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
/** @public */
|
|
1589
|
+
declare type ReferenceFilterOptions = ReferenceFilterResolverOptions | ReferenceFilterQueryOptions
|
|
1590
|
+
|
|
1591
|
+
/** @public */
|
|
1592
|
+
declare interface ReferenceFilterQueryOptions {
|
|
1593
|
+
filter: string
|
|
1594
|
+
filterParams?: Record<string, unknown>
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
/** @public */
|
|
1598
|
+
declare type ReferenceFilterResolver = (
|
|
1599
|
+
context: ReferenceFilterResolverContext,
|
|
1600
|
+
) => ReferenceFilterSearchOptions | Promise<ReferenceFilterSearchOptions>
|
|
1601
|
+
|
|
1602
|
+
/** @public */
|
|
1603
|
+
declare interface ReferenceFilterResolverContext {
|
|
1604
|
+
document: SanityDocument
|
|
1605
|
+
parent?: Record<string, unknown> | Record<string, unknown>[]
|
|
1606
|
+
parentPath: Path
|
|
1607
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/** @public */
|
|
1611
|
+
declare interface ReferenceFilterResolverOptions {
|
|
1612
|
+
filter?: ReferenceFilterResolver
|
|
1613
|
+
filterParams?: never
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
/** @public */
|
|
1617
|
+
declare type ReferenceFilterSearchOptions = {
|
|
1618
|
+
filter?: string
|
|
1619
|
+
params?: Record<string, unknown>
|
|
1620
|
+
tag?: string
|
|
1621
|
+
maxFieldDepth?: number
|
|
1622
|
+
strategy?: SearchStrategy
|
|
1623
|
+
perspective?: ClientPerspective
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
/**
|
|
1627
|
+
* Types are closed for extension. To add properties via declaration merging to this type,
|
|
1628
|
+
* redeclare and add the properties to the interfaces that make up ReferenceOptions type.
|
|
1629
|
+
*
|
|
1630
|
+
* @see ReferenceFilterOptions
|
|
1631
|
+
* @see ReferenceFilterResolverOptions
|
|
1632
|
+
* @see ReferenceBaseOptions
|
|
1633
|
+
*
|
|
1634
|
+
* @public
|
|
1635
|
+
*/
|
|
1636
|
+
declare type ReferenceOptions = ReferenceBaseOptions & ReferenceFilterOptions
|
|
1637
|
+
|
|
1638
|
+
/** @public */
|
|
1639
|
+
declare interface ReferenceRule extends RuleDef<ReferenceRule, ReferenceValue> {}
|
|
1640
|
+
|
|
1641
|
+
/** @public */
|
|
1642
|
+
declare interface ReferenceSchemaType extends Omit<ObjectSchemaType, 'options'> {
|
|
1643
|
+
jsonType: 'object'
|
|
1644
|
+
to: ObjectSchemaType[]
|
|
1645
|
+
weak?: boolean
|
|
1646
|
+
options?: ReferenceOptions
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/** @public */
|
|
1650
|
+
declare type ReferenceTo =
|
|
1651
|
+
| SchemaTypeDefinition
|
|
1652
|
+
| TypeReference
|
|
1653
|
+
| Array<SchemaTypeDefinition | TypeReference>
|
|
1654
|
+
|
|
1655
|
+
/** @public */
|
|
1656
|
+
declare type ReferenceValue = Reference
|
|
1657
|
+
|
|
1658
|
+
/** @public */
|
|
1659
|
+
declare interface Role {
|
|
1660
|
+
name: string
|
|
1661
|
+
title: string
|
|
1662
|
+
description?: string
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
/** @public */
|
|
1666
|
+
declare interface Rule {
|
|
1667
|
+
/**
|
|
1668
|
+
* @internal
|
|
1669
|
+
* @deprecated internal use only
|
|
1670
|
+
*/
|
|
1671
|
+
_type: RuleTypeConstraint | undefined
|
|
1672
|
+
/**
|
|
1673
|
+
* @internal
|
|
1674
|
+
* @deprecated internal use only
|
|
1675
|
+
*/
|
|
1676
|
+
_level: 'error' | 'warning' | 'info' | undefined
|
|
1677
|
+
/**
|
|
1678
|
+
* @internal
|
|
1679
|
+
* @deprecated internal use only
|
|
1680
|
+
*/
|
|
1681
|
+
_required: 'required' | 'optional' | undefined
|
|
1682
|
+
/**
|
|
1683
|
+
* @internal
|
|
1684
|
+
* @deprecated internal use only
|
|
1685
|
+
*/
|
|
1686
|
+
_typeDef: SchemaType | undefined
|
|
1687
|
+
/**
|
|
1688
|
+
* @internal
|
|
1689
|
+
* @deprecated internal use only
|
|
1690
|
+
*/
|
|
1691
|
+
_message: string | LocalizedValidationMessages | undefined
|
|
1692
|
+
/**
|
|
1693
|
+
* @internal
|
|
1694
|
+
* @deprecated internal use only
|
|
1695
|
+
*/
|
|
1696
|
+
_rules: RuleSpec[]
|
|
1697
|
+
/**
|
|
1698
|
+
* @internal
|
|
1699
|
+
* @deprecated internal use only
|
|
1700
|
+
*/
|
|
1701
|
+
_fieldRules: FieldRules | undefined
|
|
1702
|
+
/**
|
|
1703
|
+
* Takes in a path and returns an object with a symbol.
|
|
1704
|
+
*
|
|
1705
|
+
* When the validation lib sees this symbol, it will use the provided path to
|
|
1706
|
+
* get a value from the current field's parent and use that value as the input
|
|
1707
|
+
* to the Rule.
|
|
1708
|
+
*
|
|
1709
|
+
* The path that's given is forwarded to `lodash/get`
|
|
1710
|
+
*
|
|
1711
|
+
* ```js
|
|
1712
|
+
* fields: [
|
|
1713
|
+
* // ...
|
|
1714
|
+
* {
|
|
1715
|
+
* // ...
|
|
1716
|
+
* name: 'highestTemperature',
|
|
1717
|
+
* type: 'number',
|
|
1718
|
+
* validation: (Rule) => Rule.positive().min(Rule.valueOfField('lowestTemperature')),
|
|
1719
|
+
* // ...
|
|
1720
|
+
* },
|
|
1721
|
+
* ]
|
|
1722
|
+
* ```
|
|
1723
|
+
*/
|
|
1724
|
+
valueOfField: (path: string | string[]) => FieldReference
|
|
1725
|
+
error(message?: string | LocalizedValidationMessages): Rule
|
|
1726
|
+
warning(message?: string | LocalizedValidationMessages): Rule
|
|
1727
|
+
info(message?: string | LocalizedValidationMessages): Rule
|
|
1728
|
+
reset(): this
|
|
1729
|
+
isRequired(): boolean
|
|
1730
|
+
clone(): Rule
|
|
1731
|
+
cloneWithRules(rules: RuleSpec[]): Rule
|
|
1732
|
+
merge(rule: Rule): Rule
|
|
1733
|
+
type(targetType: RuleTypeConstraint | Lowercase<RuleTypeConstraint>): Rule
|
|
1734
|
+
all(children: Rule[]): Rule
|
|
1735
|
+
either(children: Rule[]): Rule
|
|
1736
|
+
optional(): Rule
|
|
1737
|
+
required(): Rule
|
|
1738
|
+
custom<T = unknown>(
|
|
1739
|
+
fn: CustomValidator<T>,
|
|
1740
|
+
options?: {
|
|
1741
|
+
bypassConcurrencyLimit?: boolean
|
|
1742
|
+
},
|
|
1743
|
+
): Rule
|
|
1744
|
+
min(len: number | string | FieldReference): Rule
|
|
1745
|
+
max(len: number | string | FieldReference): Rule
|
|
1746
|
+
length(len: number | FieldReference): Rule
|
|
1747
|
+
valid(value: unknown | unknown[]): Rule
|
|
1748
|
+
integer(): Rule
|
|
1749
|
+
precision(limit: number | FieldReference): Rule
|
|
1750
|
+
positive(): Rule
|
|
1751
|
+
negative(): Rule
|
|
1752
|
+
greaterThan(num: number | FieldReference): Rule
|
|
1753
|
+
lessThan(num: number | FieldReference): Rule
|
|
1754
|
+
uppercase(): Rule
|
|
1755
|
+
lowercase(): Rule
|
|
1756
|
+
regex(
|
|
1757
|
+
pattern: RegExp,
|
|
1758
|
+
name: string,
|
|
1759
|
+
options: {
|
|
1760
|
+
name?: string
|
|
1761
|
+
invert?: boolean
|
|
1762
|
+
},
|
|
1763
|
+
): Rule
|
|
1764
|
+
regex(
|
|
1765
|
+
pattern: RegExp,
|
|
1766
|
+
options: {
|
|
1767
|
+
name?: string
|
|
1768
|
+
invert?: boolean
|
|
1769
|
+
},
|
|
1770
|
+
): Rule
|
|
1771
|
+
regex(pattern: RegExp, name: string): Rule
|
|
1772
|
+
regex(pattern: RegExp): Rule
|
|
1773
|
+
email(): Rule
|
|
1774
|
+
uri(options?: UriValidationOptions): Rule
|
|
1775
|
+
unique(): Rule
|
|
1776
|
+
reference(): Rule
|
|
1777
|
+
fields(rules: FieldRules): Rule
|
|
1778
|
+
assetRequired(): Rule
|
|
1779
|
+
validate(
|
|
1780
|
+
value: unknown,
|
|
1781
|
+
options: ValidationContext & {
|
|
1782
|
+
/**
|
|
1783
|
+
* @deprecated Internal use only
|
|
1784
|
+
* @internal
|
|
1785
|
+
*/
|
|
1786
|
+
__internal?: {
|
|
1787
|
+
customValidationConcurrencyLimiter?: {
|
|
1788
|
+
ready: () => Promise<void>
|
|
1789
|
+
release: () => void
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
},
|
|
1793
|
+
): Promise<ValidationMarker[]>
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
/** @public */
|
|
1797
|
+
declare type RuleBuilder<T extends RuleDef<T, FieldValue>, FieldValue = unknown> = T | T[]
|
|
1798
|
+
|
|
1799
|
+
/** @public */
|
|
1800
|
+
declare interface RuleDef<T, FieldValue = unknown> {
|
|
1801
|
+
required: () => T
|
|
1802
|
+
custom: <LenientFieldValue extends FieldValue>(
|
|
1803
|
+
fn: CustomValidator<LenientFieldValue | undefined>,
|
|
1804
|
+
) => T
|
|
1805
|
+
info: (message?: string | LocalizedValidationMessages) => T
|
|
1806
|
+
error: (message?: string | LocalizedValidationMessages) => T
|
|
1807
|
+
warning: (message?: string | LocalizedValidationMessages) => T
|
|
1808
|
+
valueOfField: (path: string | string[]) => FieldReference
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
/** @public */
|
|
1812
|
+
declare type RuleSpec =
|
|
1813
|
+
| {
|
|
1814
|
+
flag: 'integer'
|
|
1815
|
+
}
|
|
1816
|
+
| {
|
|
1817
|
+
flag: 'email'
|
|
1818
|
+
}
|
|
1819
|
+
| {
|
|
1820
|
+
flag: 'unique'
|
|
1821
|
+
}
|
|
1822
|
+
| {
|
|
1823
|
+
flag: 'reference'
|
|
1824
|
+
}
|
|
1825
|
+
| {
|
|
1826
|
+
flag: 'type'
|
|
1827
|
+
constraint: RuleTypeConstraint
|
|
1828
|
+
}
|
|
1829
|
+
| {
|
|
1830
|
+
flag: 'all'
|
|
1831
|
+
constraint: Rule[]
|
|
1832
|
+
}
|
|
1833
|
+
| {
|
|
1834
|
+
flag: 'either'
|
|
1835
|
+
constraint: Rule[]
|
|
1836
|
+
}
|
|
1837
|
+
| {
|
|
1838
|
+
flag: 'presence'
|
|
1839
|
+
constraint: 'optional' | 'required'
|
|
1840
|
+
}
|
|
1841
|
+
| {
|
|
1842
|
+
flag: 'custom'
|
|
1843
|
+
constraint: CustomValidator
|
|
1844
|
+
}
|
|
1845
|
+
| {
|
|
1846
|
+
flag: 'min'
|
|
1847
|
+
constraint: number | string
|
|
1848
|
+
}
|
|
1849
|
+
| {
|
|
1850
|
+
flag: 'max'
|
|
1851
|
+
constraint: number | string
|
|
1852
|
+
}
|
|
1853
|
+
| {
|
|
1854
|
+
flag: 'length'
|
|
1855
|
+
constraint: number
|
|
1856
|
+
}
|
|
1857
|
+
| {
|
|
1858
|
+
flag: 'valid'
|
|
1859
|
+
constraint: unknown[]
|
|
1860
|
+
}
|
|
1861
|
+
| {
|
|
1862
|
+
flag: 'precision'
|
|
1863
|
+
constraint: number
|
|
1864
|
+
}
|
|
1865
|
+
| {
|
|
1866
|
+
flag: 'lessThan'
|
|
1867
|
+
constraint: number
|
|
1868
|
+
}
|
|
1869
|
+
| {
|
|
1870
|
+
flag: 'greaterThan'
|
|
1871
|
+
constraint: number
|
|
1872
|
+
}
|
|
1873
|
+
| {
|
|
1874
|
+
flag: 'stringCasing'
|
|
1875
|
+
constraint: 'uppercase' | 'lowercase'
|
|
1876
|
+
}
|
|
1877
|
+
| {
|
|
1878
|
+
flag: 'assetRequired'
|
|
1879
|
+
constraint: {
|
|
1880
|
+
assetType: 'asset' | 'image' | 'file'
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
| {
|
|
1884
|
+
flag: 'regex'
|
|
1885
|
+
constraint: {
|
|
1886
|
+
pattern: RegExp
|
|
1887
|
+
name?: string
|
|
1888
|
+
invert: boolean
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
| {
|
|
1892
|
+
flag: 'uri'
|
|
1893
|
+
constraint: {
|
|
1894
|
+
options: {
|
|
1895
|
+
scheme: RegExp[]
|
|
1896
|
+
allowRelative: boolean
|
|
1897
|
+
relativeOnly: boolean
|
|
1898
|
+
allowCredentials: boolean
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
/** @public */
|
|
1904
|
+
declare type RuleTypeConstraint = 'Array' | 'Boolean' | 'Date' | 'Number' | 'Object' | 'String'
|
|
1905
|
+
|
|
1906
|
+
declare type SanityAsset = {
|
|
1907
|
+
_id: string
|
|
1908
|
+
_type: 'sanity.asset'
|
|
1909
|
+
_createdAt: string
|
|
1910
|
+
_updatedAt: string
|
|
1911
|
+
_rev: string
|
|
1912
|
+
title?: string
|
|
1913
|
+
aspects?: unknown
|
|
1914
|
+
currentVersion: {
|
|
1915
|
+
_ref: string
|
|
1916
|
+
_type: 'reference'
|
|
1917
|
+
_weak?: boolean
|
|
1918
|
+
[internalGroqTypeReferenceTo]?: 'sanity.asset.version'
|
|
1919
|
+
}
|
|
1920
|
+
versions: Array<
|
|
1921
|
+
{
|
|
1922
|
+
_key: string
|
|
1923
|
+
} & SanityAssetVersion
|
|
1924
|
+
>
|
|
1925
|
+
assetType: 'sanity.imageAsset' | 'sanity.videoAsset' | 'sanity.fileAsset'
|
|
1926
|
+
cdnAccessPolicy: 'public' | 'private'
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
declare type SanityAssetCollection = {
|
|
1930
|
+
_id: string
|
|
1931
|
+
_type: 'sanity.asset.collection'
|
|
1932
|
+
_createdAt: string
|
|
1933
|
+
_updatedAt: string
|
|
1934
|
+
_rev: string
|
|
1935
|
+
title: string
|
|
1936
|
+
description?: string
|
|
1937
|
+
assets?: Array<{
|
|
1938
|
+
_ref: string
|
|
1939
|
+
_type: 'reference'
|
|
1940
|
+
_weak?: boolean
|
|
1941
|
+
_key: string
|
|
1942
|
+
[internalGroqTypeReferenceTo]?: 'sanity.asset'
|
|
1943
|
+
}>
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
declare type SanityAssetVersion = {
|
|
1947
|
+
_type: 'sanity.asset.version'
|
|
1948
|
+
title?: string
|
|
1949
|
+
instance:
|
|
1950
|
+
| {
|
|
1951
|
+
_ref: string
|
|
1952
|
+
_type: 'reference'
|
|
1953
|
+
_weak?: boolean
|
|
1954
|
+
[internalGroqTypeReferenceTo]?: 'sanity.imageAsset'
|
|
1955
|
+
}
|
|
1956
|
+
| {
|
|
1957
|
+
_ref: string
|
|
1958
|
+
_type: 'reference'
|
|
1959
|
+
_weak?: boolean
|
|
1960
|
+
[internalGroqTypeReferenceTo]?: 'sanity.fileAsset'
|
|
1961
|
+
}
|
|
1962
|
+
| {
|
|
1963
|
+
_ref: string
|
|
1964
|
+
_type: 'reference'
|
|
1965
|
+
_weak?: boolean
|
|
1966
|
+
[internalGroqTypeReferenceTo]?: 'sanity.videoAsset'
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* Options for configuring how Sanity Create interfaces with the type or field.
|
|
1972
|
+
*
|
|
1973
|
+
* @public
|
|
1974
|
+
*/
|
|
1975
|
+
declare interface SanityCreateOptions {
|
|
1976
|
+
/** Set to true to exclude a type or field from appearing in Sanity Create */
|
|
1977
|
+
exclude?: boolean
|
|
1978
|
+
/**
|
|
1979
|
+
* A short description of what the type or field is used for.
|
|
1980
|
+
* Purpose can be used to improve how and when content mapping uses the field.
|
|
1981
|
+
* */
|
|
1982
|
+
purpose?: string
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
/** @public */
|
|
1986
|
+
declare interface SanityDocument {
|
|
1987
|
+
_id: string
|
|
1988
|
+
_type: string
|
|
1989
|
+
_createdAt: string
|
|
1990
|
+
_updatedAt: string
|
|
1991
|
+
_rev: string
|
|
1992
|
+
[key: string]: unknown
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
export declare type SanityFileAsset = {
|
|
1996
|
+
_id: string
|
|
1997
|
+
_type: 'sanity.fileAsset'
|
|
1998
|
+
_createdAt: string
|
|
1999
|
+
_updatedAt: string
|
|
2000
|
+
_rev: string
|
|
2001
|
+
title?: string
|
|
2002
|
+
description?: Array<{
|
|
2003
|
+
children?: Array<{
|
|
2004
|
+
marks?: Array<string>
|
|
2005
|
+
text?: string
|
|
2006
|
+
_type: 'span'
|
|
2007
|
+
_key: string
|
|
2008
|
+
}>
|
|
2009
|
+
style?: 'normal' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'blockquote'
|
|
2010
|
+
listItem?: 'bullet' | 'number'
|
|
2011
|
+
markDefs?: Array<{
|
|
2012
|
+
href?: string
|
|
2013
|
+
_type: 'link'
|
|
2014
|
+
_key: string
|
|
2015
|
+
}>
|
|
2016
|
+
level?: number
|
|
2017
|
+
_type: 'block'
|
|
2018
|
+
_key: string
|
|
2019
|
+
}>
|
|
2020
|
+
state: string
|
|
2021
|
+
sha1hash?: string
|
|
2022
|
+
mimeType?: string
|
|
2023
|
+
originalFilename?: string
|
|
2024
|
+
size?: number
|
|
2025
|
+
uploadId?: string
|
|
2026
|
+
path: string
|
|
2027
|
+
extension?: string
|
|
2028
|
+
url: string
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
export declare type SanityImageAsset = {
|
|
2032
|
+
_id: string
|
|
2033
|
+
_type: 'sanity.imageAsset'
|
|
2034
|
+
_createdAt: string
|
|
2035
|
+
_updatedAt: string
|
|
2036
|
+
_rev: string
|
|
2037
|
+
altText?: string
|
|
2038
|
+
state: string
|
|
2039
|
+
sha1hash?: string
|
|
2040
|
+
mimeType?: string
|
|
2041
|
+
originalFilename?: string
|
|
2042
|
+
size?: number
|
|
2043
|
+
uploadId?: string
|
|
2044
|
+
path?: string
|
|
2045
|
+
extension?: string
|
|
2046
|
+
url: string
|
|
2047
|
+
metadata: SanityImageMetadata
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
declare type SanityImageDimensions = {
|
|
2051
|
+
_type: 'sanity.imageDimensions'
|
|
2052
|
+
height: number
|
|
2053
|
+
width: number
|
|
2054
|
+
aspectRatio: number
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
declare type SanityImageExifMetadata = {
|
|
2058
|
+
_type: 'sanity.imageExifMetadata'
|
|
2059
|
+
ApertureValue?: number
|
|
2060
|
+
BrightnessValue?: number
|
|
2061
|
+
DateTimeDigitized?: string
|
|
2062
|
+
DateTimeOriginal?: string
|
|
2063
|
+
ExposureBiasValue?: number
|
|
2064
|
+
ExposureMode?: number
|
|
2065
|
+
ExposureProgram?: number
|
|
2066
|
+
ExposureTime?: number
|
|
2067
|
+
FNumber?: number
|
|
2068
|
+
Flash?: number
|
|
2069
|
+
FocalLength?: number
|
|
2070
|
+
FocalLengthIn35mmFormat?: number
|
|
2071
|
+
ISO?: number
|
|
2072
|
+
LensModel?: string
|
|
2073
|
+
WhiteBalance?: number
|
|
2074
|
+
GPSLatitude?: number
|
|
2075
|
+
GPSLongitude?: number
|
|
2076
|
+
GPSAltitude?: number
|
|
2077
|
+
Copyright?: string
|
|
2078
|
+
Artist?: string
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
declare type SanityImageExifTags = {
|
|
2082
|
+
_type: 'sanity.imageExifTags'
|
|
2083
|
+
Make?: string
|
|
2084
|
+
Model?: string
|
|
2085
|
+
Orientation?: number
|
|
2086
|
+
XResolution?: number
|
|
2087
|
+
YResolution?: number
|
|
2088
|
+
ResolutionUnit?: number
|
|
2089
|
+
Software?: string
|
|
2090
|
+
ModifyDate?: string
|
|
2091
|
+
ExifOffset?: number
|
|
2092
|
+
GPSInfo?: number
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
declare type SanityImageMetadata = {
|
|
2096
|
+
_type: 'sanity.imageMetadata'
|
|
2097
|
+
location?: Geopoint
|
|
2098
|
+
dimensions: SanityImageDimensions
|
|
2099
|
+
exif?: SanityImageExifMetadata
|
|
2100
|
+
image?: SanityImageExifTags
|
|
2101
|
+
palette: SanityImagePalette
|
|
2102
|
+
lqip: string
|
|
2103
|
+
blurHash: string
|
|
2104
|
+
hasAlpha: boolean
|
|
2105
|
+
isOpaque: boolean
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
declare type SanityImagePalette = {
|
|
2109
|
+
_type: 'sanity.imagePalette'
|
|
2110
|
+
darkMuted?: SanityImagePaletteSwatch
|
|
2111
|
+
lightVibrant?: SanityImagePaletteSwatch
|
|
2112
|
+
darkVibrant?: SanityImagePaletteSwatch
|
|
2113
|
+
vibrant?: SanityImagePaletteSwatch
|
|
2114
|
+
dominant?: SanityImagePaletteSwatch
|
|
2115
|
+
lightMuted?: SanityImagePaletteSwatch
|
|
2116
|
+
muted?: SanityImagePaletteSwatch
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
declare type SanityImagePaletteSwatch = {
|
|
2120
|
+
_type: 'sanity.imagePaletteSwatch'
|
|
2121
|
+
background?: string
|
|
2122
|
+
foreground?: string
|
|
2123
|
+
population?: number
|
|
2124
|
+
title?: string
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
export declare type SanityVideoAsset = {
|
|
2128
|
+
_id: string
|
|
2129
|
+
_type: 'sanity.videoAsset'
|
|
2130
|
+
_createdAt: string
|
|
2131
|
+
_updatedAt: string
|
|
2132
|
+
_rev: string
|
|
2133
|
+
title?: string
|
|
2134
|
+
description?: Array<{
|
|
2135
|
+
children?: Array<{
|
|
2136
|
+
marks?: Array<string>
|
|
2137
|
+
text?: string
|
|
2138
|
+
_type: 'span'
|
|
2139
|
+
_key: string
|
|
2140
|
+
}>
|
|
2141
|
+
style?: 'normal' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'blockquote'
|
|
2142
|
+
listItem?: 'bullet' | 'number'
|
|
2143
|
+
markDefs?: Array<{
|
|
2144
|
+
href?: string
|
|
2145
|
+
_type: 'link'
|
|
2146
|
+
_key: string
|
|
2147
|
+
}>
|
|
2148
|
+
level?: number
|
|
2149
|
+
_type: 'block'
|
|
2150
|
+
_key: string
|
|
2151
|
+
}>
|
|
2152
|
+
state: string
|
|
2153
|
+
sha1hash?: string
|
|
2154
|
+
mimeType?: string
|
|
2155
|
+
originalFilename?: string
|
|
2156
|
+
size?: number
|
|
2157
|
+
uploadId?: string
|
|
2158
|
+
path?: string
|
|
2159
|
+
url?: string
|
|
2160
|
+
extension?: string
|
|
2161
|
+
metadata: SanityVideoMetadata
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2164
|
+
export declare type SanityVideoMetadata = {
|
|
2165
|
+
_type: 'sanity.videoMetadata'
|
|
2166
|
+
muxAssetId: string
|
|
2167
|
+
muxPlaybackIds: Array<{
|
|
2168
|
+
_id: string
|
|
2169
|
+
_type: string
|
|
2170
|
+
policy: string
|
|
2171
|
+
_key: string
|
|
2172
|
+
}>
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
/** @public */
|
|
2176
|
+
declare interface Schema {
|
|
2177
|
+
/** @internal */
|
|
2178
|
+
_original?: {
|
|
2179
|
+
name: string
|
|
2180
|
+
types: SchemaTypeDefinition[]
|
|
2181
|
+
}
|
|
2182
|
+
/** @internal */
|
|
2183
|
+
_registry: {
|
|
2184
|
+
[typeName: string]: any
|
|
2185
|
+
}
|
|
2186
|
+
/** @internal */
|
|
2187
|
+
_validation?: SchemaValidationProblemGroup[]
|
|
2188
|
+
name: string
|
|
2189
|
+
get: (name: string) => SchemaType | undefined
|
|
2190
|
+
has: (name: string) => boolean
|
|
2191
|
+
getTypeNames: () => string[]
|
|
2192
|
+
/**
|
|
2193
|
+
* Returns the types which were explicitly defined in this schema,
|
|
2194
|
+
* as opposed to the types which were inherited from the parent.
|
|
2195
|
+
*/
|
|
2196
|
+
getLocalTypeNames: () => string[]
|
|
2197
|
+
/**
|
|
2198
|
+
* Returns the parent schema.
|
|
2199
|
+
*/
|
|
2200
|
+
parent?: Schema
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
/**
|
|
2204
|
+
* Note: you probably want `SchemaTypeDefinition` instead
|
|
2205
|
+
* @see SchemaTypeDefinition
|
|
2206
|
+
*
|
|
2207
|
+
* @public
|
|
2208
|
+
*/
|
|
2209
|
+
declare type SchemaType =
|
|
2210
|
+
| ArraySchemaType
|
|
2211
|
+
| BooleanSchemaType
|
|
2212
|
+
| FileSchemaType
|
|
2213
|
+
| NumberSchemaType
|
|
2214
|
+
| ObjectSchemaType
|
|
2215
|
+
| StringSchemaType
|
|
2216
|
+
| ReferenceSchemaType
|
|
2217
|
+
|
|
2218
|
+
/**
|
|
2219
|
+
* Represents a Sanity schema type definition with an optional type parameter.
|
|
2220
|
+
*
|
|
2221
|
+
* It's recommend to use the `defineType` helper instead of this type by
|
|
2222
|
+
* itself.
|
|
2223
|
+
*
|
|
2224
|
+
* @see defineType
|
|
2225
|
+
*
|
|
2226
|
+
* @public
|
|
2227
|
+
*/
|
|
2228
|
+
declare type SchemaTypeDefinition<TType extends IntrinsicTypeName = IntrinsicTypeName> =
|
|
2229
|
+
| IntrinsicDefinitions[IntrinsicTypeName]
|
|
2230
|
+
| TypeAliasDefinition<string, TType>
|
|
2231
|
+
|
|
2232
|
+
/** @public */
|
|
2233
|
+
declare interface SchemaValidationError {
|
|
2234
|
+
helpId?: string
|
|
2235
|
+
message: string
|
|
2236
|
+
severity: 'error'
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
/** @internal */
|
|
2240
|
+
declare type SchemaValidationProblem = SchemaValidationError | SchemaValidationWarning
|
|
2241
|
+
|
|
2242
|
+
/** @internal */
|
|
2243
|
+
declare interface SchemaValidationProblemGroup {
|
|
2244
|
+
path: SchemaValidationProblemPath
|
|
2245
|
+
problems: SchemaValidationProblem[]
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
/** @internal */
|
|
2249
|
+
declare type SchemaValidationProblemPath = Array<
|
|
2250
|
+
| {
|
|
2251
|
+
kind: 'type'
|
|
2252
|
+
type: string
|
|
2253
|
+
name?: string
|
|
2254
|
+
}
|
|
2255
|
+
| {
|
|
2256
|
+
kind: 'property'
|
|
2257
|
+
name: string
|
|
2258
|
+
}
|
|
2259
|
+
>
|
|
2260
|
+
|
|
2261
|
+
/**
|
|
2262
|
+
* Represents the possible values of a schema type's `validation` field.
|
|
2263
|
+
*
|
|
2264
|
+
* If the schema has not been run through `inferFromSchema` from
|
|
2265
|
+
* `sanity/validation` then value could be a function.
|
|
2266
|
+
*
|
|
2267
|
+
* `inferFromSchema` mutates the schema converts this value to an array of
|
|
2268
|
+
* `Rule` instances.
|
|
2269
|
+
*
|
|
2270
|
+
* @privateRemarks
|
|
2271
|
+
*
|
|
2272
|
+
* Usage of the schema inside the studio will almost always be from the compiled
|
|
2273
|
+
* `createSchema` function. In this case, you can cast the value or throw to
|
|
2274
|
+
* narrow the type. E.g.:
|
|
2275
|
+
*
|
|
2276
|
+
* ```ts
|
|
2277
|
+
* if (typeof type.validation === 'function') {
|
|
2278
|
+
* throw new Error(
|
|
2279
|
+
* `Schema type "${type.name}"'s \`validation\` was not run though \`inferFromSchema\``
|
|
2280
|
+
* )
|
|
2281
|
+
* }
|
|
2282
|
+
* ```
|
|
2283
|
+
*
|
|
2284
|
+
* @public
|
|
2285
|
+
*/
|
|
2286
|
+
declare type SchemaValidationValue =
|
|
2287
|
+
| false
|
|
2288
|
+
| undefined
|
|
2289
|
+
| Rule
|
|
2290
|
+
| SchemaValidationValue[]
|
|
2291
|
+
| ((rule: Rule) => SchemaValidationValue)
|
|
2292
|
+
|
|
2293
|
+
/** @internal */
|
|
2294
|
+
declare interface SchemaValidationWarning {
|
|
2295
|
+
helpId?: string
|
|
2296
|
+
message: string
|
|
2297
|
+
severity: 'warning'
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
/** @public */
|
|
2301
|
+
declare interface SearchConfiguration {
|
|
2302
|
+
search?: {
|
|
2303
|
+
/**
|
|
2304
|
+
* Defines a search weight for this field to prioritize its importance
|
|
2305
|
+
* during search operations in the Studio. This setting allows the specified
|
|
2306
|
+
* field to be ranked higher in search results compared to other fields.
|
|
2307
|
+
*
|
|
2308
|
+
* By default, all fields are assigned a weight of 1. However, if a field is
|
|
2309
|
+
* chosen as the `title` in the preview configuration's `select` option, it
|
|
2310
|
+
* will automatically receive a default weight of 10. Similarly, if selected
|
|
2311
|
+
* as the `subtitle`, the default weight is 5. Fields marked as
|
|
2312
|
+
* `hidden: true` (no function) are assigned a weight of 0 by default.
|
|
2313
|
+
*
|
|
2314
|
+
* Note: Search weight configuration is currently supported only for fields
|
|
2315
|
+
* of type string or portable text arrays.
|
|
2316
|
+
*/
|
|
2317
|
+
weight?: number
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
/**
|
|
2322
|
+
* @public
|
|
2323
|
+
*/
|
|
2324
|
+
declare const searchStrategies: readonly ['groqLegacy', 'groq2024']
|
|
2325
|
+
|
|
2326
|
+
/**
|
|
2327
|
+
* @public
|
|
2328
|
+
*/
|
|
2329
|
+
declare type SearchStrategy = (typeof searchStrategies)[number]
|
|
2330
|
+
|
|
2331
|
+
/** @public */
|
|
2332
|
+
declare interface SingleFieldSet {
|
|
2333
|
+
single: true
|
|
2334
|
+
field: ObjectField
|
|
2335
|
+
hidden?: ConditionalProperty
|
|
2336
|
+
readOnly?: ConditionalProperty
|
|
2337
|
+
group?: string | string[]
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
/** @public */
|
|
2341
|
+
declare interface SlugDefinition extends BaseSchemaDefinition {
|
|
2342
|
+
type: 'slug'
|
|
2343
|
+
options?: SlugOptions
|
|
2344
|
+
validation?: ValidationBuilder<SlugRule, SlugValue>
|
|
2345
|
+
initialValue?: InitialValueProperty<any, Omit<SlugValue, '_type'>>
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
/** @public */
|
|
2349
|
+
declare type SlugifierFn = (
|
|
2350
|
+
source: string,
|
|
2351
|
+
schemaType: SlugSchemaType,
|
|
2352
|
+
context: SlugSourceContext,
|
|
2353
|
+
) => string | Promise<string>
|
|
2354
|
+
|
|
2355
|
+
/** @public */
|
|
2356
|
+
declare type SlugIsUniqueValidator = (
|
|
2357
|
+
slug: string,
|
|
2358
|
+
context: SlugValidationContext,
|
|
2359
|
+
) => boolean | Promise<boolean>
|
|
2360
|
+
|
|
2361
|
+
/** @public */
|
|
2362
|
+
declare interface SlugOptions extends SearchConfiguration, BaseSchemaTypeOptions {
|
|
2363
|
+
source?: string | Path | SlugSourceFn
|
|
2364
|
+
maxLength?: number
|
|
2365
|
+
slugify?: SlugifierFn
|
|
2366
|
+
isUnique?: SlugIsUniqueValidator
|
|
2367
|
+
disableArrayWarning?: boolean
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
/** @public */
|
|
2371
|
+
declare type SlugParent = Record<string, unknown> | Record<string, unknown>[]
|
|
2372
|
+
|
|
2373
|
+
/** @public */
|
|
2374
|
+
declare interface SlugRule extends RuleDef<SlugRule, SlugValue> {}
|
|
2375
|
+
|
|
2376
|
+
/** @public */
|
|
2377
|
+
declare interface SlugSchemaType extends ObjectSchemaType {
|
|
2378
|
+
jsonType: 'object'
|
|
2379
|
+
options?: SlugOptions
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
/** @public */
|
|
2383
|
+
declare interface SlugSourceContext {
|
|
2384
|
+
parentPath: Path
|
|
2385
|
+
parent: SlugParent
|
|
2386
|
+
projectId: string
|
|
2387
|
+
dataset: string
|
|
2388
|
+
schema: Schema
|
|
2389
|
+
currentUser: CurrentUser | null
|
|
2390
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
/** @public */
|
|
2394
|
+
declare type SlugSourceFn = (
|
|
2395
|
+
document: SanityDocument,
|
|
2396
|
+
context: SlugSourceContext,
|
|
2397
|
+
) => string | Promise<string>
|
|
2398
|
+
|
|
2399
|
+
/** @public */
|
|
2400
|
+
declare interface SlugValidationContext extends ValidationContext {
|
|
2401
|
+
parent: SlugParent
|
|
2402
|
+
type: SlugSchemaType
|
|
2403
|
+
defaultIsUnique: SlugIsUniqueValidator
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
/** @public */
|
|
2407
|
+
declare interface SlugValue {
|
|
2408
|
+
_type: 'slug'
|
|
2409
|
+
current?: string
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
/** @beta */
|
|
2413
|
+
declare type SortOrdering = {
|
|
2414
|
+
title: string
|
|
2415
|
+
i18n?: I18nTextRecord<'title'>
|
|
2416
|
+
name: string
|
|
2417
|
+
by: SortOrderingItem[]
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
/** @beta */
|
|
2421
|
+
declare interface SortOrderingItem {
|
|
2422
|
+
field: string
|
|
2423
|
+
direction: 'asc' | 'desc'
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
/** @public */
|
|
2427
|
+
declare interface StringDefinition extends BaseSchemaDefinition {
|
|
2428
|
+
type: 'string'
|
|
2429
|
+
options?: StringOptions
|
|
2430
|
+
placeholder?: string
|
|
2431
|
+
validation?: ValidationBuilder<StringRule, string>
|
|
2432
|
+
initialValue?: InitialValueProperty<any, string>
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
/** @public */
|
|
2436
|
+
declare interface StringOptions
|
|
2437
|
+
extends EnumListProps<string>,
|
|
2438
|
+
SearchConfiguration,
|
|
2439
|
+
BaseSchemaTypeOptions {}
|
|
2440
|
+
|
|
2441
|
+
/** @public */
|
|
2442
|
+
declare interface StringRule extends RuleDef<StringRule, string> {
|
|
2443
|
+
min: (minNumber: number | FieldReference) => StringRule
|
|
2444
|
+
max: (maxNumber: number | FieldReference) => StringRule
|
|
2445
|
+
length: (exactLength: number | FieldReference) => StringRule
|
|
2446
|
+
uppercase: () => StringRule
|
|
2447
|
+
lowercase: () => StringRule
|
|
2448
|
+
regex(
|
|
2449
|
+
pattern: RegExp,
|
|
2450
|
+
name: string,
|
|
2451
|
+
options: {
|
|
2452
|
+
name?: string
|
|
2453
|
+
invert?: boolean
|
|
2454
|
+
},
|
|
2455
|
+
): StringRule
|
|
2456
|
+
regex(
|
|
2457
|
+
pattern: RegExp,
|
|
2458
|
+
options: {
|
|
2459
|
+
name?: string
|
|
2460
|
+
invert?: boolean
|
|
2461
|
+
},
|
|
2462
|
+
): StringRule
|
|
2463
|
+
regex(pattern: RegExp, name: string): StringRule
|
|
2464
|
+
regex(pattern: RegExp): StringRule
|
|
2465
|
+
email(): StringRule
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
/**
|
|
2469
|
+
* This is used for string, text, date and datetime.
|
|
2470
|
+
* This interface represent the compiled version at runtime, when accessed through Schema.
|
|
2471
|
+
*
|
|
2472
|
+
* @public
|
|
2473
|
+
*/
|
|
2474
|
+
declare interface StringSchemaType extends BaseSchemaType {
|
|
2475
|
+
jsonType: 'string'
|
|
2476
|
+
options?: StringOptions & TextOptions & DateOptions & DatetimeOptions
|
|
2477
|
+
initialValue?: InitialValueProperty<any, string>
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
/** @public */
|
|
2481
|
+
declare interface TextDefinition extends BaseSchemaDefinition {
|
|
2482
|
+
type: 'text'
|
|
2483
|
+
rows?: number
|
|
2484
|
+
options?: TextOptions
|
|
2485
|
+
placeholder?: string
|
|
2486
|
+
validation?: ValidationBuilder<TextRule, string>
|
|
2487
|
+
initialValue?: InitialValueProperty<any, string>
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
/** @public */
|
|
2491
|
+
declare interface TextOptions extends StringOptions {}
|
|
2492
|
+
|
|
2493
|
+
/** @public */
|
|
2494
|
+
declare interface TextRule extends StringRule {}
|
|
2495
|
+
|
|
2496
|
+
/** @public */
|
|
2497
|
+
declare interface TitledListValue<V = unknown> {
|
|
2498
|
+
_key?: string
|
|
2499
|
+
title: string
|
|
2500
|
+
value?: V
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
/**
|
|
2504
|
+
* Represents a type definition that is an alias/extension of an existing type
|
|
2505
|
+
* in your schema. Creating a type alias will re-register that existing type
|
|
2506
|
+
* under a different name. You can also override the default type options with
|
|
2507
|
+
* a type alias definition.
|
|
2508
|
+
*
|
|
2509
|
+
* @public
|
|
2510
|
+
*/
|
|
2511
|
+
declare interface TypeAliasDefinition<
|
|
2512
|
+
TType extends string,
|
|
2513
|
+
TAlias extends IntrinsicTypeName | undefined,
|
|
2514
|
+
> extends BaseSchemaDefinition {
|
|
2515
|
+
type: TType
|
|
2516
|
+
options?: TAlias extends IntrinsicTypeName ? IntrinsicDefinitions[TAlias]['options'] : unknown
|
|
2517
|
+
validation?: SchemaValidationValue
|
|
2518
|
+
initialValue?: InitialValueProperty<any, any>
|
|
2519
|
+
preview?: PreviewConfig
|
|
2520
|
+
components?: {
|
|
2521
|
+
annotation?: ComponentType<any>
|
|
2522
|
+
block?: ComponentType<any>
|
|
2523
|
+
inlineBlock?: ComponentType<any>
|
|
2524
|
+
diff?: ComponentType<any>
|
|
2525
|
+
field?: ComponentType<any>
|
|
2526
|
+
input?: ComponentType<any>
|
|
2527
|
+
item?: ComponentType<any>
|
|
2528
|
+
preview?: ComponentType<any>
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
/**
|
|
2533
|
+
* Represents a reference to another type registered top-level in your schema.
|
|
2534
|
+
*
|
|
2535
|
+
* @public
|
|
2536
|
+
*/
|
|
2537
|
+
declare interface TypeReference {
|
|
2538
|
+
type: string
|
|
2539
|
+
name?: string
|
|
2540
|
+
icon?: ComponentType | ReactNode
|
|
2541
|
+
options?: {
|
|
2542
|
+
[key: string]: unknown
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
export declare interface UploadSession {
|
|
2547
|
+
_id: string
|
|
2548
|
+
_type: 'sanity.asset.upload-session'
|
|
2549
|
+
title: string
|
|
2550
|
+
assets: Asset[]
|
|
2551
|
+
_createdAt: string
|
|
2552
|
+
_updatedAt: string
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
/** @public */
|
|
2556
|
+
declare interface UriValidationOptions {
|
|
2557
|
+
scheme?: (string | RegExp) | Array<string | RegExp>
|
|
2558
|
+
allowRelative?: boolean
|
|
2559
|
+
relativeOnly?: boolean
|
|
2560
|
+
allowCredentials?: boolean
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
/** @public */
|
|
2564
|
+
declare interface UrlDefinition extends BaseSchemaDefinition {
|
|
2565
|
+
type: 'url'
|
|
2566
|
+
options?: UrlOptions
|
|
2567
|
+
placeholder?: string
|
|
2568
|
+
validation?: ValidationBuilder<UrlRule, string>
|
|
2569
|
+
initialValue?: InitialValueProperty<any, string>
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
/** @public */
|
|
2573
|
+
declare interface UrlOptions extends BaseSchemaTypeOptions {}
|
|
2574
|
+
|
|
2575
|
+
/** @public */
|
|
2576
|
+
declare interface UrlRule extends RuleDef<UrlRule, string> {
|
|
2577
|
+
uri(options: UriValidationOptions): UrlRule
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
/** @public */
|
|
2581
|
+
declare type ValidationBuilder<T extends RuleDef<T, FieldValue>, FieldValue = unknown> = (
|
|
2582
|
+
rule: T,
|
|
2583
|
+
) => RuleBuilder<T, FieldValue>
|
|
2584
|
+
|
|
2585
|
+
/**
|
|
2586
|
+
* A context object passed around during validation. This includes the
|
|
2587
|
+
* `Rule.custom` context.
|
|
2588
|
+
*
|
|
2589
|
+
* e.g.
|
|
2590
|
+
*
|
|
2591
|
+
* ```js
|
|
2592
|
+
* Rule.custom((_, validationContext) => {
|
|
2593
|
+
* // ...
|
|
2594
|
+
* })`
|
|
2595
|
+
* ```
|
|
2596
|
+
*
|
|
2597
|
+
* @public
|
|
2598
|
+
*/
|
|
2599
|
+
declare interface ValidationContext {
|
|
2600
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
2601
|
+
schema: Schema
|
|
2602
|
+
parent?: unknown
|
|
2603
|
+
type?: SchemaType
|
|
2604
|
+
document?: SanityDocument
|
|
2605
|
+
path?: Path
|
|
2606
|
+
getDocumentExists?: (options: {id: string}) => Promise<boolean>
|
|
2607
|
+
environment: 'cli' | 'studio'
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
/**
|
|
2611
|
+
* The shape that can be returned from a custom validator to be converted into
|
|
2612
|
+
* a validation marker by the validation logic. Inside of a custom validator,
|
|
2613
|
+
* you can return an array of these in order to specify multiple paths within
|
|
2614
|
+
* an object or array.
|
|
2615
|
+
*
|
|
2616
|
+
* @public
|
|
2617
|
+
*/
|
|
2618
|
+
declare interface ValidationError {
|
|
2619
|
+
/**
|
|
2620
|
+
* The message describing why the value is not valid. This message will be
|
|
2621
|
+
* included in the validation markers after validation has finished running.
|
|
2622
|
+
*/
|
|
2623
|
+
message: string
|
|
2624
|
+
/**
|
|
2625
|
+
* If writing a custom validator, you can return validation messages to
|
|
2626
|
+
* specific path inside of the current value (object or array) by populating
|
|
2627
|
+
* this `path` prop.
|
|
2628
|
+
*
|
|
2629
|
+
* NOTE: This path is relative to the current value and _not_ relative to
|
|
2630
|
+
* the document.
|
|
2631
|
+
*/
|
|
2632
|
+
path?: Path
|
|
2633
|
+
/**
|
|
2634
|
+
* Same as `path` but allows more than one value. If provided, the same
|
|
2635
|
+
* message will create two markers from each path with the same message
|
|
2636
|
+
* provided.
|
|
2637
|
+
*
|
|
2638
|
+
* @deprecated prefer `path`
|
|
2639
|
+
*/
|
|
2640
|
+
paths?: Path[]
|
|
2641
|
+
/**
|
|
2642
|
+
* @deprecated Unused. Was used to store the results from `.either()` /`.all()`
|
|
2643
|
+
*/
|
|
2644
|
+
children?: ValidationMarker[]
|
|
2645
|
+
/**
|
|
2646
|
+
* @deprecated Unused. Was used to signal if this error came from an `.either()`/`.all()`.
|
|
2647
|
+
*/
|
|
2648
|
+
operation?: 'AND' | 'OR'
|
|
2649
|
+
/**
|
|
2650
|
+
* @deprecated Unused. Was relevant when validation error was used as a class.
|
|
2651
|
+
*/
|
|
2652
|
+
cloneWithMessage?(message: string): ValidationError
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
/** @public */
|
|
2656
|
+
declare interface ValidationMarker {
|
|
2657
|
+
level: 'error' | 'warning' | 'info'
|
|
2658
|
+
/**
|
|
2659
|
+
* The validation message for this marker. E.g. "Must be greater than 0"
|
|
2660
|
+
*/
|
|
2661
|
+
message: string
|
|
2662
|
+
/**
|
|
2663
|
+
* @deprecated use `message` instead
|
|
2664
|
+
*/
|
|
2665
|
+
item?: ValidationError
|
|
2666
|
+
/**
|
|
2667
|
+
* The sanity path _relative to the root of the current document_ to this
|
|
2668
|
+
* marker.
|
|
2669
|
+
*
|
|
2670
|
+
* NOTE: Sanity paths may contain keyed segments (i.e. `{_key: string}`) that
|
|
2671
|
+
* are not compatible with deep getters like lodash/get
|
|
2672
|
+
*/
|
|
2673
|
+
path: Path
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
export {}
|