@sanity/types 4.19.1-next.9 → 4.20.0-next.40

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 DELETED
@@ -1,4004 +0,0 @@
1
- import {Asset as Asset_2} from '@sanity/media-library-types'
2
- import {AssetInstanceDocument} from '@sanity/media-library-types'
3
- import {ClientPerspective} from '@sanity/client'
4
- import {ComponentType} from 'react'
5
- import {ElementType} from 'react'
6
- import {ReactNode} from 'react'
7
- import {SanityClient} from '@sanity/client'
8
- import {StackablePerspective} from '@sanity/client'
9
-
10
- /**
11
- * Types of array actions that can be performed
12
- * @beta
13
- */
14
- export declare type ArrayActionName =
15
- /**
16
- * Add any item to the array at any position
17
- */
18
- | 'add'
19
- /**
20
- * Add item after an existing item
21
- */
22
- | 'addBefore'
23
- /**
24
- * Add item after an existing item
25
- */
26
- | 'addAfter'
27
- /**
28
- * Remove any item
29
- */
30
- | 'remove'
31
- /**
32
- * Duplicate item
33
- */
34
- | 'duplicate'
35
- /**
36
- * Copy item
37
- */
38
- | 'copy'
39
-
40
- /** @public */
41
- export declare interface ArrayDefinition extends BaseSchemaDefinition {
42
- type: 'array'
43
- of: ArrayOfType[]
44
- initialValue?: InitialValueProperty<any, unknown[]>
45
- validation?: ValidationBuilder<ArrayRule<unknown[]>, unknown[]>
46
- options?: ArrayOptions
47
- }
48
-
49
- /** @public */
50
- export declare type ArrayOfEntry<T> = Omit<T, 'name' | 'hidden'> & {
51
- name?: string
52
- }
53
-
54
- /** @public */
55
- export declare type ArrayOfType<
56
- TType extends IntrinsicTypeName = IntrinsicTypeName,
57
- TAlias extends IntrinsicTypeName | undefined = undefined,
58
- > = IntrinsicArrayOfDefinition[TType] | ArrayOfEntry<TypeAliasDefinition<string, TAlias>>
59
-
60
- /** @public */
61
- export declare interface ArrayOptions<V = unknown>
62
- extends SearchConfiguration,
63
- BaseSchemaTypeOptions {
64
- list?: TitledListValue<V>[] | V[]
65
- layout?: 'list' | 'tags' | 'grid'
66
- /** @deprecated This option does not have any effect anymore */
67
- direction?: 'horizontal' | 'vertical'
68
- sortable?: boolean
69
- modal?: {
70
- type?: 'dialog' | 'popover'
71
- width?: number | 'auto'
72
- }
73
- /** @alpha This API may change */
74
- insertMenu?: InsertMenuOptions
75
- /**
76
- * A boolean flag to enable or disable tree editing for the array.
77
- * If there are any nested arrays, they will inherit this value.
78
- * @deprecated tree editing beta feature has been disabled
79
- */
80
- treeEditing?: boolean
81
- /**
82
- * A list of array actions to disable
83
- * Possible options are defined by {@link ArrayActionName}
84
- * @beta
85
- */
86
- disableActions?: ArrayActionName[]
87
- }
88
-
89
- /** @public */
90
- export declare interface ArrayRule<Value> extends RuleDef<ArrayRule<Value>, Value> {
91
- min: (length: number | FieldReference) => ArrayRule<Value>
92
- max: (length: number | FieldReference) => ArrayRule<Value>
93
- length: (length: number | FieldReference) => ArrayRule<Value>
94
- unique: () => ArrayRule<Value>
95
- }
96
-
97
- /** @public */
98
- export declare interface ArraySchemaType<V = unknown> extends BaseSchemaType {
99
- jsonType: 'array'
100
- of: (Exclude<SchemaType, ArraySchemaType> | ReferenceSchemaType)[]
101
- options?: ArrayOptions<V> & {
102
- layout?: V extends string ? 'tag' : 'grid'
103
- }
104
- }
105
-
106
- /** @internal */
107
- export declare type ArraySchemaTypeOf<TSchemaType extends ArraySchemaType['of'][number]> = Omit<
108
- ArraySchemaType,
109
- 'of'
110
- > & {
111
- of: TSchemaType[]
112
- }
113
-
114
- /** @public */
115
- export declare interface Asset extends SanityDocument {
116
- url: string
117
- path: string
118
- assetId: string
119
- extension: string
120
- mimeType: string
121
- sha1hash: string
122
- size: number
123
- originalFilename?: string
124
- label?: string
125
- title?: string
126
- description?: string
127
- creditLine?: string
128
- source?: AssetSourceSpec
129
- }
130
-
131
- /** @public */
132
- export declare type AssetFromSource = {
133
- kind: 'assetDocumentId' | 'file' | 'base64' | 'url'
134
- value: string | File_2
135
- assetDocumentProps?: ImageAsset
136
- mediaLibraryProps?: {
137
- mediaLibraryId: string
138
- assetId: string
139
- assetInstanceId: string
140
- }
141
- }
142
-
143
- /** @public */
144
- export declare type AssetMetadataType =
145
- | 'location'
146
- | 'exif'
147
- | 'image'
148
- | 'palette'
149
- | 'lqip'
150
- | 'blurhash'
151
- | 'none'
152
-
153
- /** @public */
154
- export declare interface AssetSchemaTypeOptions {
155
- accept?: string
156
- storeOriginalFilename?: boolean
157
- }
158
-
159
- /** @public */
160
- export declare interface AssetSource {
161
- name: string
162
- /** @deprecated provide `i18nKey` instead */
163
- title?: string
164
- i18nKey?: string
165
- component: ComponentType<AssetSourceComponentProps>
166
- icon?: ComponentType<EmptyProps>
167
- /** @beta */
168
- Uploader?: AssetSourceUploaderClass
169
- }
170
-
171
- /** @public */
172
- export declare interface AssetSourceComponentProps {
173
- action?: 'select' | 'upload'
174
- assetSource: AssetSource
175
- assetType?: 'file' | 'image' | 'sanity.video'
176
- accept: string
177
- selectionType: 'single'
178
- dialogHeaderTitle?: React.ReactNode
179
- selectedAssets: Asset[]
180
- onClose: () => void
181
- onSelect: (assetFromSource: AssetFromSource[]) => void
182
- schemaType?: ImageSchemaType | FileSchemaType
183
- /** @beta */
184
- uploader?: AssetSourceUploader
185
- }
186
-
187
- /** @public */
188
- export declare interface AssetSourceSpec {
189
- id: string
190
- name: string
191
- url?: string
192
- }
193
-
194
- /** @beta */
195
- export declare interface AssetSourceUploader {
196
- upload(
197
- files: globalThis.File[],
198
- options?: {
199
- /**
200
- * The schema type of the field the asset is being uploaded to.
201
- * May be of interest to the uploader to read file and image options.
202
- */
203
- schemaType?: SchemaType
204
- /**
205
- * The uploader may send patches directly to the field
206
- * Typed 'unknown' as we don't have patch definitions in sanity/types yet.
207
- */
208
- onChange?: (patch: unknown) => void
209
- },
210
- ): AssetSourceUploadFile[]
211
- /**
212
- * Abort the upload of a file
213
- */
214
- abort(file?: AssetSourceUploadFile): void
215
- /**
216
- * Get the files that are currently being uploaded
217
- */
218
- getFiles(): AssetSourceUploadFile[]
219
- /**
220
- * Subscribe to upload events from the uploader
221
- */
222
- subscribe(subscriber: (event: AssetSourceUploadEvent) => void): () => void
223
- /**
224
- * Update the status of a file. Will be emitted to subscribers.
225
- */
226
- updateFile(
227
- fileId: string,
228
- data: {
229
- progress?: number
230
- status?: string
231
- error?: Error
232
- },
233
- ): void
234
- /**
235
- * Reset the uploader (clear files). Should be called by the uploader when all files are done.
236
- */
237
- reset(): void
238
- }
239
-
240
- /** @beta */
241
- export declare type AssetSourceUploaderClass = new (...args: any[]) => AssetSourceUploader
242
-
243
- /** @beta */
244
- export declare type AssetSourceUploadEvent =
245
- | AssetSourceUploadEventProgress
246
- | AssetSourceUploadEventStatus
247
- | AssetSourceUploadEventAllComplete
248
- | AssetSourceUploadEventError
249
- | AssetSourceUploadEventAbort
250
-
251
- /**
252
- * Emitted when all files are done, either successfully, aborted or with errors
253
- * @beta */
254
- export declare type AssetSourceUploadEventAbort = {
255
- type: 'abort'
256
- /**
257
- * Files aborted
258
- */
259
- files: AssetSourceUploadFile[]
260
- }
261
-
262
- /**
263
- * Emitted when all files are done, either successfully, aborted or with errors
264
- * @beta */
265
- export declare type AssetSourceUploadEventAllComplete = {
266
- type: 'all-complete'
267
- files: AssetSourceUploadFile[]
268
- }
269
-
270
- /**
271
- * Emitted when all files are done, either successfully, aborted or with errors
272
- * @beta */
273
- export declare type AssetSourceUploadEventError = {
274
- type: 'error'
275
- /**
276
- * Files errored
277
- */
278
- files: AssetSourceUploadFile[]
279
- }
280
-
281
- /**
282
- * Emitted when a file upload is progressing
283
- * @beta */
284
- export declare type AssetSourceUploadEventProgress = {
285
- type: 'progress'
286
- file: AssetSourceUploadFile
287
- progress: number
288
- }
289
-
290
- /**
291
- * Emitted when a file upload is changing status
292
- * @beta */
293
- export declare type AssetSourceUploadEventStatus = {
294
- type: 'status'
295
- file: AssetSourceUploadFile
296
- status: AssetSourceUploadFile['status']
297
- }
298
-
299
- /** @beta */
300
- export declare interface AssetSourceUploadFile {
301
- id: string
302
- file: globalThis.File
303
- progress: number
304
- status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted' | 'alreadyExists'
305
- error?: Error
306
- result?: unknown
307
- }
308
-
309
- /** @beta */
310
- export declare type AssetSourceUploadSubscriber = (event: AssetSourceUploadEvent) => void
311
-
312
- /**
313
- * Enhances VSCode autocomplete by using a distinct type for strings.
314
- *
315
- * `AllowOtherStrings` is defined as `string & {}`, an intersection that behaves
316
- * like `string` but is treated differently by TypeScript's type system for
317
- * internal processing. This helps in improving the specificity and relevance of
318
- * autocomplete suggestions by potentially prioritizing `IntrinsicTypeName`
319
- * over general string inputs, addressing issues where `string` type suggestions
320
- * might overshadow more useful specific literals.
321
- *
322
- * @beta
323
- */
324
- export declare type AutocompleteString = string & {}
325
-
326
- /** @public */
327
- export declare interface BaseSchemaDefinition {
328
- name: string
329
- title?: string
330
- description?: string | React.JSX.Element
331
- hidden?: ConditionalProperty
332
- readOnly?: ConditionalProperty
333
- icon?: ComponentType | ReactNode
334
- validation?: unknown
335
- initialValue?: unknown
336
- deprecated?: DeprecatedProperty
337
- }
338
-
339
- /** @public */
340
- export declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
341
- name: string
342
- title?: string
343
- description?: string
344
- type?: SchemaType
345
- liveEdit?: boolean
346
- readOnly?: ConditionalProperty
347
- hidden?: ConditionalProperty
348
- icon?: ComponentType
349
- initialValue?: InitialValueProperty<any, any>
350
- validation?: SchemaValidationValue
351
- preview?: PreviewConfig
352
- /** @beta */
353
- components?: {
354
- block?: ComponentType<any>
355
- inlineBlock?: ComponentType<any>
356
- annotation?: ComponentType<any>
357
- diff?: ComponentType<any>
358
- field?: ComponentType<any>
359
- input?: ComponentType<any>
360
- item?: ComponentType<any>
361
- preview?: ComponentType<any>
362
- portableText?: {
363
- plugins?: ComponentType<any>
364
- }
365
- }
366
- /**
367
- * @deprecated This will be removed.
368
- */
369
- placeholder?: string
370
- }
371
-
372
- /**
373
- * `BaseOptions` applies to all type options.
374
- *
375
- * It can be extended by interface declaration merging in plugins to provide generic options to all types and fields.
376
- *
377
- * @public
378
- * */
379
- export declare interface BaseSchemaTypeOptions {
380
- sanityCreate?: SanityCreateOptions
381
- canvasApp?: CanvasAppOptions
382
- }
383
-
384
- /**
385
- * Schema definition for a text block annotation object.
386
- *
387
- * @public
388
- * @example The default link annotation
389
- * ```ts
390
- * {
391
- * name: 'blockContent',
392
- * title: 'Content',
393
- * type: 'array',
394
- * of: [
395
- * {
396
- * type: 'block',
397
- * marks: {
398
- * annotations: [
399
- * {
400
- * type: 'object',
401
- * name: 'link',
402
- * fields: [
403
- * {
404
- * type: 'string',
405
- * name: 'href',
406
- * },
407
- * ],
408
- * },
409
- * ]
410
- * },
411
- * }
412
- * ]
413
- * }
414
- * ```
415
- */
416
- export declare interface BlockAnnotationDefinition extends ObjectDefinition {
417
- icon?: ReactNode | ComponentType
418
- }
419
-
420
- /**
421
- * The specific `children` field of a `block` type (`BlockSchemaType`)
422
- * @see BlockSchemaType
423
- *
424
- * @internal
425
- */
426
- export declare type BlockChildrenObjectField = {
427
- name: 'children'
428
- } & ObjectField<ArraySchemaType>
429
-
430
- /**
431
- * Schema definition for text block decorators.
432
- *
433
- * @public
434
- * @example The default set of decorators
435
- * ```ts
436
- * {
437
- * name: 'blockContent',
438
- * title: 'Content',
439
- * type: 'array',
440
- * of: [
441
- * {
442
- * type: 'block',
443
- * marks: {
444
- * decorators: [
445
- * {title: 'Strong', value: 'strong'},
446
- * {title: 'Emphasis', value: 'em'},
447
- * {title: 'Underline', value: 'underline'},
448
- * {title: 'Strike', value: 'strike-through'},
449
- * {title: 'Code', value: 'code'},
450
- * ]
451
- * }
452
- * }
453
- * ]
454
- * }
455
- * ```
456
- */
457
- export declare interface BlockDecoratorDefinition {
458
- title: string
459
- i18nTitleKey?: string
460
- value: string
461
- icon?: ReactNode | ComponentType
462
- }
463
-
464
- /**
465
- * Schema definition for text blocks.
466
- *
467
- * @public
468
- * @example the default block definition
469
- * ```ts
470
- * {
471
- * name: 'blockContent',
472
- * title: 'Content',
473
- * type: 'array',
474
- * of: [
475
- * {
476
- * type: 'block',
477
- * marks: {
478
- * decorators: [
479
- * {title: 'Strong', value: 'strong'},
480
- * {title: 'Emphasis', value: 'em'},
481
- * {title: 'Underline', value: 'underline'},
482
- * {title: 'Strike', value: 'strike-through'},
483
- * {title: 'Code', value: 'code'},
484
- * ],
485
- * annotations: [
486
- * {
487
- * type: 'object',
488
- * name: 'link',
489
- * fields: [
490
- * {
491
- * type: 'string',
492
- * name: 'href',
493
- * },
494
- * ],
495
- * },
496
- * ]
497
- * },
498
- * styles: [
499
- * {title: 'Normal', value: 'normal'},
500
- * {title: 'H1', value: 'h1'},
501
- * {title: 'H2', value: 'h2'},
502
- * {title: 'H3', value: 'h3'},
503
- * {title: 'H4', value: 'h4'},
504
- * {title: 'H5', value: 'h5'},
505
- * {title: 'H6', value: 'h6'},
506
- * {title: 'Quote', value: 'blockquote'}
507
- * ],
508
- * lists: [
509
- * {title: 'Bullet', value: 'bullet'},
510
- * {title: 'Number', value: 'number'},
511
- * ],
512
- * },
513
- * ]
514
- * }
515
- * ```
516
- */
517
- export declare interface BlockDefinition extends BaseSchemaDefinition {
518
- type: 'block'
519
- styles?: BlockStyleDefinition[]
520
- lists?: BlockListDefinition[]
521
- marks?: BlockMarksDefinition
522
- of?: ArrayOfType<'object' | 'reference'>[]
523
- initialValue?: InitialValueProperty<any, any[]>
524
- options?: BlockOptions
525
- validation?: ValidationBuilder<BlockRule, any[]>
526
- }
527
-
528
- /**
529
- * Schema definition for a text block list style.
530
- *
531
- * @public
532
- * @example The defaults lists
533
- * ```ts
534
- * {
535
- * name: 'blockContent',
536
- * title: 'Content',
537
- * type: 'array',
538
- * of: [
539
- * {
540
- * type: 'block',
541
- * lists: [
542
- * {title: 'Bullet', value: 'bullet'},
543
- * {title: 'Number', value: 'number'},
544
- * ]
545
- * }
546
- * ]
547
- * }
548
- * ```
549
- */
550
- export declare interface BlockListDefinition {
551
- title: string
552
- i18nTitleKey?: string
553
- value: string
554
- icon?: ReactNode | ComponentType
555
- }
556
-
557
- /**
558
- * A specific `ObjectField` for `list` in `BlockSchemaType`
559
- * @see BlockSchemaType
560
- *
561
- * @internal
562
- */
563
- export declare type BlockListObjectField = {
564
- name: 'list'
565
- } & ObjectField<StringSchemaType>
566
-
567
- /**
568
- * Schema definition for text block marks (decorators and annotations).
569
- *
570
- * @public */
571
- export declare interface BlockMarksDefinition {
572
- decorators?: BlockDecoratorDefinition[]
573
- annotations?: ArrayOfType<'object' | 'reference'>[]
574
- }
575
-
576
- /**
577
- * Schema options for a Block schema definition
578
- * @public */
579
- export declare interface BlockOptions extends BaseSchemaTypeOptions {
580
- /**
581
- * Turn on or off the builtin browser spellchecking. Default is on.
582
- */
583
- spellCheck?: boolean
584
- unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
585
- /**
586
- * When enabled, the editor will restrict all line breaks and soft breaks,
587
- * forcing content to remain on a single line. This will also update
588
- * the styling of the editor to reflect the single-line constraint.
589
- *
590
- * Pasting content that is on multiple lines will be normalized to a single line, if possible.
591
- *
592
- * @defaultValue false
593
- */
594
- oneLine?: boolean
595
- }
596
-
597
- /** @public */
598
- export declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
599
-
600
- /**
601
- * Represents the compiled schema shape for `block`s for portable text.
602
- *
603
- * Note: this does _not_ represent the schema definition shape.
604
- *
605
- * @internal
606
- */
607
- export declare interface BlockSchemaType extends ObjectSchemaType {
608
- fields: [BlockChildrenObjectField, BlockStyleObjectField, BlockListObjectField, ...ObjectField[]]
609
- options?: BlockOptions
610
- }
611
-
612
- /**
613
- * Schema definition for a text block style.
614
- * A text block may have a block style like 'header', 'normal', 'lead'
615
- * attached to it, which is stored on the `.style` property for that block.
616
- *
617
- * @public
618
- * @remarks The first defined style will become the default style.´´
619
- * @example The default set of styles
620
- * ```ts
621
- * {
622
- * name: 'blockContent',
623
- * title: 'Content',
624
- * type: 'array',
625
- * of: [
626
- * {
627
- * type: 'block',
628
- * styles: [
629
- * {title: 'Normal', value: 'normal'},
630
- * {title: 'H1', value: 'h1'},
631
- * {title: 'H2', value: 'h2'},
632
- * {title: 'H3', value: 'h3'},
633
- * {title: 'H4', value: 'h4'},
634
- * {title: 'H5', value: 'h5'},
635
- * {title: 'H6', value: 'h6'},
636
- * {title: 'Quote', value: 'blockquote'}
637
- * ]
638
- * }
639
- * ]
640
- * }
641
- * ```
642
- * @example Example of defining a block type with custom styles and render components.
643
- * ```ts
644
- * defineArrayMember({
645
- * type: 'block',
646
- * styles: [
647
- * {
648
- * title: 'Paragraph',
649
- * value: 'paragraph',
650
- * component: ParagraphStyle,
651
- * },
652
- * {
653
- * title: 'Lead',
654
- * value: 'lead',
655
- * component: LeadStyle,
656
- * },
657
- * {
658
- * title: 'Heading',
659
- * value: 'heading',
660
- * component: HeadingStyle,
661
- * },
662
- * ],
663
- * })
664
- * ```
665
- */
666
- export declare interface BlockStyleDefinition {
667
- title: string
668
- value: string
669
- i18nTitleKey?: string
670
- icon?: ReactNode | ComponentType
671
- }
672
-
673
- /**
674
- * A specific `ObjectField` for `style` in `BlockSchemaType`
675
- * @see BlockSchemaType
676
- *
677
- * @internal
678
- */
679
- export declare type BlockStyleObjectField = {
680
- name: 'style'
681
- } & ObjectField<StringSchemaType>
682
-
683
- /** @public */
684
- export declare interface BooleanDefinition extends BaseSchemaDefinition {
685
- type: 'boolean'
686
- options?: BooleanOptions
687
- initialValue?: InitialValueProperty<any, boolean>
688
- validation?: ValidationBuilder<BooleanRule, boolean>
689
- }
690
-
691
- /** @public */
692
- export declare interface BooleanOptions extends BaseSchemaTypeOptions {
693
- layout?: 'switch' | 'checkbox'
694
- }
695
-
696
- /** @public */
697
- export declare interface BooleanRule extends RuleDef<BooleanRule, boolean> {}
698
-
699
- /** @public */
700
- export declare interface BooleanSchemaType extends BaseSchemaType {
701
- jsonType: 'boolean'
702
- options?: BooleanOptions
703
- initialValue?: InitialValueProperty<any, boolean>
704
- }
705
-
706
- /**
707
- * Options for configuring how Canvas app interfaces with the type or field.
708
- *
709
- * @public
710
- */
711
- export declare interface CanvasAppOptions {
712
- /** Set to true to exclude a type or field from appearing in Canvas */
713
- exclude?: boolean
714
- /**
715
- * A short description of what the type or field is used for.
716
- * Purpose can be used to improve how and when content mapping uses the field.
717
- * */
718
- purpose?: string
719
- }
720
-
721
- /**
722
- * @internal
723
- * Payload that will be passed by canvas to our notifications system to display the notification in canvas.
724
- * */
725
- export declare interface CanvasNotificationPayload extends DashboardNotificationPayload {
726
- applicationType: 'canvas'
727
- link: {
728
- type: 'dashboard'
729
- path: string
730
- }
731
- }
732
-
733
- /** @public */
734
- export declare interface CollapseOptions {
735
- collapsed?: boolean
736
- collapsible?: boolean
737
- /**
738
- * @deprecated Use `collapsible` instead
739
- */
740
- collapsable?: boolean
741
- }
742
-
743
- /**
744
- * this is used to get allow index access (e.g. `RuleSpec['constraint']`) to
745
- * constraint when a rule spec might not have a `constraint` prop
746
- *
747
- * @internal
748
- */
749
- export declare type ConditionalIndexAccess<T, U> = U extends keyof T ? T[U] : undefined
750
-
751
- /** @public */
752
- export declare type ConditionalProperty = boolean | ConditionalPropertyCallback | undefined
753
-
754
- /** @public */
755
- export declare type ConditionalPropertyCallback = (
756
- context: ConditionalPropertyCallbackContext,
757
- ) => boolean
758
-
759
- /** @public */
760
- export declare interface ConditionalPropertyCallbackContext {
761
- document: SanityDocument | undefined
762
- parent: any
763
- value: any
764
- currentUser: Omit<CurrentUser, 'role'> | null
765
- }
766
-
767
- /** @internal */
768
- export declare interface CreateIfNotExistsMutation {
769
- createIfNotExists: {
770
- _id: string
771
- _type: string
772
- [key: string]: unknown
773
- }
774
- }
775
-
776
- /** @internal */
777
- export declare interface CreateMutation {
778
- create: {
779
- _id?: string
780
- _type: string
781
- [key: string]: unknown
782
- }
783
- }
784
-
785
- /** @internal */
786
- export declare interface CreateOrReplaceMutation {
787
- createOrReplace: {
788
- _id: string
789
- _type: string
790
- [key: string]: unknown
791
- }
792
- }
793
-
794
- /**
795
- * Mutation type used when the document has passed the threshold of the
796
- * "history retention" - any transactions done prior to the threshold gets "squashed"
797
- * into a single "create" transaction.
798
- *
799
- * @internal
800
- */
801
- export declare interface CreateSquashedMutation {
802
- createSquashed: {
803
- /**
804
- * The user IDs of all the users who contributed to the document prior to the squashing
805
- */
806
- authors: string[]
807
- /**
808
- * User ID of the person who initially created the document
809
- */
810
- createdBy: string
811
- /**
812
- * ISO-formatted timestamp (zulu-time) of when the document as initially created
813
- */
814
- createdAt: string
815
- /**
816
- * The document as it exists after squashing has occurred
817
- */
818
- document: {
819
- _id: string
820
- _type: string
821
- [key: string]: unknown
822
- }
823
- }
824
- }
825
-
826
- /** @public */
827
- export declare interface CrossDatasetReferenceDefinition extends BaseSchemaDefinition {
828
- type: 'crossDatasetReference'
829
- weak?: boolean
830
- to: {
831
- type: string
832
- title?: string
833
- icon?: ComponentType
834
- preview?: PreviewConfig
835
- /**
836
- * @deprecated Unused. Configuring search is no longer supported.
837
- */
838
- __experimental_search?: {
839
- path: string | string[]
840
- weight?: number
841
- mapWith?: string
842
- }[]
843
- }[]
844
- dataset: string
845
- studioUrl?: (document: {id: string; type?: string}) => string | null
846
- tokenId?: string
847
- options?: ReferenceOptions
848
- /**
849
- * @deprecated Cross-project references are no longer supported, only cross-dataset
850
- */
851
- projectId?: string
852
- }
853
-
854
- /** @beta */
855
- export declare type CrossDatasetReferenceFilterResolver = (options: {
856
- document: SanityDocument
857
- parent?: Record<string, unknown> | Record<string, unknown>[]
858
- parentPath: Path
859
- }) => CrossDatasetReferenceFilterSearchOptions | Promise<CrossDatasetReferenceFilterSearchOptions>
860
-
861
- /** @beta */
862
- export declare type CrossDatasetReferenceFilterSearchOptions = {
863
- filter?: string
864
- params?: Record<string, unknown>
865
- tag?: string
866
- }
867
-
868
- /** @beta */
869
- export declare interface CrossDatasetReferenceSchemaType extends Omit<ObjectSchemaType, 'options'> {
870
- jsonType: 'object'
871
- to: CrossDatasetType[]
872
- dataset: string
873
- studioUrl?: (document: {id: string; type?: string}) => string | null
874
- weak?: boolean
875
- options?: ReferenceFilterOptions
876
- }
877
-
878
- /** @beta */
879
- export declare interface CrossDatasetReferenceValue {
880
- _type: string
881
- _dataset: string
882
- _projectId: string
883
- _ref: string
884
- _key?: string
885
- _weak?: boolean
886
- }
887
-
888
- /** @beta */
889
- export declare interface CrossDatasetType {
890
- type: string
891
- title?: string
892
- icon: ComponentType
893
- preview: PreviewConfig
894
- /** @deprecated Unused. Configuring search is no longer supported for cross-dataset references. */
895
- __experimental_search: ObjectSchemaType['__experimental_search']
896
- }
897
-
898
- /** @public */
899
- export declare interface CurrentUser {
900
- id: string
901
- name: string
902
- email: string
903
- profileImage?: string
904
- provider?: string
905
- /** @deprecated use `roles` instead */
906
- role: string
907
- roles: Role[]
908
- }
909
-
910
- /** @public */
911
- export declare interface CustomValidator<T = unknown> {
912
- (value: T, context: ValidationContext): CustomValidatorResult | Promise<CustomValidatorResult>
913
- bypassConcurrencyLimit?: boolean
914
- }
915
-
916
- /** @public */
917
- export declare type CustomValidatorResult =
918
- | true
919
- | string
920
- | ValidationError
921
- | ValidationError[]
922
- | LocalizedValidationMessages
923
-
924
- /**
925
- * @internal
926
- * Payload notifications have to provide to the notification system in order to display correctly in dashboard
927
- */
928
- export declare interface DashboardNotificationPayload {
929
- version: '1.0.0'
930
- applicationType: string
931
- createdAt: string
932
- /**
933
- * The user who took the action which triggered the notification.
934
- */
935
- actor: User
936
- title: PortableTextBlock[]
937
- body: PortableTextBlock[] | undefined
938
- organizationId: string
939
- applicationId?: string
940
- workspaceName?: string
941
- link:
942
- | {
943
- type: 'url'
944
- url: string
945
- }
946
- | {
947
- type: 'dashboard'
948
- path: string
949
- }
950
- }
951
-
952
- /** @public */
953
- export declare interface DateDefinition extends BaseSchemaDefinition {
954
- type: 'date'
955
- options?: DateOptions
956
- placeholder?: string
957
- validation?: ValidationBuilder<DateRule, string>
958
- initialValue?: InitialValueProperty<any, string>
959
- }
960
-
961
- /** @public */
962
- export declare interface DateOptions extends BaseSchemaTypeOptions {
963
- dateFormat?: string
964
- }
965
-
966
- /** @public */
967
- export declare interface DateRule extends RuleDef<DateRule, string> {
968
- /**
969
- * @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
970
- */
971
- min: (minDate: string | FieldReference) => DateRule
972
- /**
973
- * @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
974
- */
975
- max: (maxDate: string | FieldReference) => DateRule
976
- }
977
-
978
- /** @public */
979
- export declare interface DatetimeDefinition extends BaseSchemaDefinition {
980
- type: 'datetime'
981
- options?: DatetimeOptions
982
- placeholder?: string
983
- validation?: ValidationBuilder<DatetimeRule, string>
984
- initialValue?: InitialValueProperty<any, string>
985
- }
986
-
987
- /** @public */
988
- export declare interface DatetimeOptions extends BaseSchemaTypeOptions {
989
- dateFormat?: string
990
- timeFormat?: string
991
- timeStep?: number
992
- displayTimeZone?: string
993
- allowTimeZoneSwitch?: boolean
994
- }
995
-
996
- /** @public */
997
- export declare interface DatetimeRule extends RuleDef<DatetimeRule, string> {
998
- /**
999
- * @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
1000
- */
1001
- min: (minDate: string | FieldReference) => DatetimeRule
1002
- /**
1003
- * @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
1004
- */
1005
- max: (maxDate: string | FieldReference) => DatetimeRule
1006
- }
1007
-
1008
- /**
1009
- * Define an array item member type within an array definition `of`-array.
1010
- *
1011
- * This function will narrow the schema type down to fields and options based on the provided
1012
- * `type` string.
1013
- *
1014
- * Using `defineArrayMember` is optional, but should provide improved autocompletion in your IDE, when building your schema.
1015
- * Field properties like `validation` and `initialValue` will also be more specific.
1016
- *
1017
- * See {@link defineType} for example usage.
1018
- *
1019
- * @param arrayOfSchema - should be a valid `array.of` member definition.
1020
- * @param defineOptions - optional param to provide type hints for `arrayOfSchema`.
1021
- *
1022
- * @see defineType
1023
- * @see defineField
1024
- * @see typed
1025
- *
1026
- * @beta
1027
- */
1028
- export declare function defineArrayMember<
1029
- const TType extends IntrinsicTypeName | AutocompleteString,
1030
- const TName extends string,
1031
- TSelect extends Record<string, string> | undefined,
1032
- TPrepareValue extends Record<keyof TSelect, any> | undefined,
1033
- TAlias extends IntrinsicTypeName | undefined,
1034
- TStrict extends StrictDefinition,
1035
- >(
1036
- arrayOfSchema: {
1037
- type: TType
1038
- /**
1039
- * When provided, `name` is used as `_type` for the array item when stored.
1040
- *
1041
- * Necessary when an array contains multiple entries with the same `type`, each with
1042
- * different configuration (title and initialValue for instance).
1043
- */
1044
- name?: TName
1045
- } & DefineArrayMemberBase<TType, TAlias> &
1046
- NarrowPreview<TType, TAlias, TSelect, TPrepareValue> &
1047
- MaybeAllowUnknownProps<TStrict>,
1048
- defineOptions?: DefineSchemaOptions<TStrict, TAlias>,
1049
- ): typeof arrayOfSchema & WidenValidation & WidenInitialValue
1050
-
1051
- /** @beta */
1052
- export declare type DefineArrayMemberBase<
1053
- TType extends string,
1054
- TAlias extends IntrinsicTypeName | undefined,
1055
- > = TType extends IntrinsicTypeName
1056
- ? IntrinsicArrayOfBase[TType]
1057
- : ArrayOfEntry<TypeAliasDefinition<string, TAlias>>
1058
-
1059
- /**
1060
- * Define a Media Library asset aspect.
1061
- *
1062
- * Aspects can be deployed using the `sanity media deploy-aspect` CLI command.
1063
- *
1064
- * @public
1065
- * @beta
1066
- */
1067
- export declare function defineAssetAspect(
1068
- definition: MediaLibraryAssetAspectDefinition,
1069
- ): MediaLibraryAssetAspectDocument
1070
-
1071
- /**
1072
- * Define a field within a document, object, image or file definition `fields` array.
1073
- *
1074
- * This function will narrow the schema type down to fields and options based on the provided
1075
- * type-string.
1076
- *
1077
- * Using `defineField` is optional, but should provide improved autocompletion in your IDE, when building your schema.
1078
- * Field-properties like `validation` and `initialValue`will also be more specific.
1079
- *
1080
- * See {@link defineType} for more examples.
1081
- *
1082
- * @param schemaField - should be a valid field type definition.
1083
- * @param defineOptions - optional param to provide type hints for `schemaField`.
1084
- *
1085
- * @see defineField
1086
- * @see defineArrayMember
1087
- * @see typed
1088
- *
1089
- * @beta
1090
- */
1091
- export declare function defineField<
1092
- const TType extends IntrinsicTypeName | AutocompleteString,
1093
- const TName extends string,
1094
- TSelect extends Record<string, string> | undefined,
1095
- TPrepareValue extends Record<keyof TSelect, any> | undefined,
1096
- TAlias extends IntrinsicTypeName | undefined,
1097
- TStrict extends StrictDefinition,
1098
- >(
1099
- schemaField: {
1100
- type: TType
1101
- name: TName
1102
- } & DefineSchemaBase<TType, TAlias> &
1103
- NarrowPreview<TType, TAlias, TSelect, TPrepareValue> &
1104
- MaybeAllowUnknownProps<TStrict> &
1105
- FieldDefinitionBase,
1106
- defineOptions?: DefineSchemaOptions<TStrict, TAlias>,
1107
- ): typeof schemaField & WidenValidation & WidenInitialValue
1108
-
1109
- /** @beta */
1110
- export declare type DefineSchemaBase<
1111
- TType extends string,
1112
- TAlias extends IntrinsicTypeName | undefined,
1113
- > = TType extends IntrinsicTypeName ? IntrinsicBase[TType] : TypeAliasDefinition<TType, TAlias>
1114
-
1115
- /** @beta */
1116
- export declare interface DefineSchemaOptions<
1117
- TStrict extends StrictDefinition,
1118
- TAlias extends IntrinsicTypeName | undefined,
1119
- > {
1120
- /**
1121
- * `strict: false` allows unknown properties in the schema.
1122
- * Use this when adding customizations to the schema that are not part of sanity core.
1123
- *
1124
- * If you want to extend the Sanity Schema types with your own properties or options to make them typesafe,
1125
- * you can use [TypeScript declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html).
1126
- *
1127
- * See {@link defineType} for more.
1128
- *
1129
- * @see defineType
1130
- */
1131
- strict?: TStrict
1132
- /** Should be provided when type is a non-intrinsic type, ie type is a type alias */
1133
- aliasFor?: TAlias extends IntrinsicTypeName ? TAlias : never
1134
- }
1135
-
1136
- /** @beta */
1137
- export declare type DefineSchemaType<
1138
- TType extends string,
1139
- TAlias extends IntrinsicTypeName | undefined,
1140
- > = TType extends IntrinsicTypeName
1141
- ? IntrinsicDefinitions[TType]
1142
- : TypeAliasDefinition<TType, TAlias>
1143
-
1144
- /**
1145
- * Helper function for defining a Sanity type definition. This function does not do anything on its own;
1146
- * it exists to check that your schema definition is correct, and help autocompletion in your IDE.
1147
- *
1148
- * This function will narrow the schema type down to fields and options based on the provided type-string.
1149
- *
1150
- * Schema types defined using `defineType` should typically be added to the Studio config under `schema.types`.
1151
- * Defined types can be referenced by their `name`. This is referred to as a type-alias.
1152
- *
1153
- * When using type-aliases as `type`, `defineType` cannot know the base-type, so type-safety will be reduced.
1154
- * If you know the base type of the type-alias, provide `defineOptions.aliasFor: <base type name>`.
1155
- * This will enforce that the schema definition conforms with the provided type.
1156
- *
1157
- * By default, `defineType` only allows known properties and options.
1158
- * Use `defineOptions.strict: false` to allow unknown properties and options.
1159
- *
1160
- * ### Basic usage
1161
- *
1162
- * ```ts
1163
- * defineType({
1164
- * type: 'object',
1165
- * name: 'custom-object',
1166
- * fields: [ {type: 'string', name: 'title', title: 'Title'}],
1167
- * })
1168
- * ```
1169
- *
1170
- * ### Usage with aliasFor narrowing
1171
- *
1172
- * ```ts
1173
- * defineType({
1174
- * type: 'custom-object',
1175
- * name: 'redefined-custom-object',
1176
- * options: {
1177
- * columns: 2
1178
- * }
1179
- * }, {aliasFor: 'object' })
1180
- * ```
1181
- *
1182
- * ### Allow unknown properties
1183
- *
1184
- * ```ts
1185
- * defineType({
1186
- * type: 'custom-object',
1187
- * name: 'redefined-custom-object',
1188
- * allowsUnknownProperties: true
1189
- * options: {
1190
- * columns: 2,
1191
- * allowsUnknownOptions: true
1192
- * }
1193
- * }, {strict: false})
1194
- * ```
1195
- * ### Maximum safety and best autocompletion
1196
- *
1197
- * Use {@link defineType}, {@link defineField} and {@link defineArrayMember}:
1198
- *
1199
- * ```ts
1200
- * defineType({
1201
- * type: 'object',
1202
- * name: 'custom-object',
1203
- * fields: [
1204
- * defineField({
1205
- * type: 'array',
1206
- * name: 'arrayField',
1207
- * title: 'Things',
1208
- * of: [
1209
- * defineArrayMember({
1210
- * type: 'object',
1211
- * name: 'type-name-in-array',
1212
- * fields: [defineField({type: 'string', name: 'title', title: 'Title'})],
1213
- * }),
1214
- * ],
1215
- * }),
1216
- * ],
1217
- * })
1218
- * ```
1219
- *
1220
- * ## Note on type-safety in the current implementation
1221
- *
1222
- * Type-safety inside array-like properties (schema properties like `fields` and `of`) can only be guaranteed when
1223
- * {@link defineField} and {@link defineArrayMember} are used to wrap each value in the array.
1224
- *
1225
- * For array-values without a function-wrapper, TypeScript will resolve to a union type of all possible properties across
1226
- * all schema types. This result in less precise typing.
1227
- *
1228
- * ### Extending the Sanity Schema types
1229
- *
1230
- * If you want to extend the Sanity Schema types with your own properties or options to make them typesafe,
1231
- * you can use [TypeScript declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html).
1232
- *
1233
- * With declaration merging, properties and options will be available in a type-safe manner, and
1234
- * `strict: false` will not be necessary.
1235
- *
1236
- * #### Example: Add option to StringOptions
1237
- *
1238
- * ```ts
1239
- * // string.ts
1240
- *
1241
- * //redeclare the sanity module
1242
- * declare module 'sanity' {
1243
- * // redeclare StringOptions; it will be merged with StringOptions in the sanity module
1244
- * export interface StringOptions {
1245
- * myCustomOption?: boolean
1246
- * }
1247
- * }
1248
- *
1249
- * // the option is now part of the StringOptions type, just as if it was declared in the sanity codebase:
1250
- * defineType({
1251
- * type: 'string',
1252
- * name: 'my-string',
1253
- * options: {
1254
- * myCustomOption: true // this does not give an error anymore
1255
- * }
1256
- * })
1257
- *
1258
- * ```
1259
- *
1260
- * #### Example: Add a schema definition to "intrinsic-types"
1261
- *
1262
- * ```ts
1263
- * //my-custom-type-definition.ts
1264
- *
1265
- * // create a new schema definition based on object (we remove the ability to assign field, change the type add some options)
1266
- * export type MagicallyAddedDefinition = Omit<Schema.ObjectDefinition, 'type' | 'fields'> & {
1267
- * type: 'magically-added-type'
1268
- * options?: {
1269
- * sparkles?: boolean
1270
- * }
1271
- * }
1272
- *
1273
- * // redeclares sanity module so we can add interfaces props to it
1274
- * declare module 'sanity' {
1275
- * // redeclares IntrinsicDefinitions and adds a named definition to it
1276
- * // it is important that the key is the same as the type in the definition ('magically-added-type')
1277
- * export interface IntrinsicDefinitions {
1278
- * 'magically-added-type': MagicallyAddedDefinition
1279
- * }
1280
- * }
1281
- *
1282
- * // defineType will now narrow `type: 'magically-added-type'` to `MagicallyAddedDefinition`
1283
- * defineType({
1284
- * type: 'magically-added-type'
1285
- * name: 'magic',
1286
- * options: {
1287
- * sparkles: true // this is allowed,
1288
- * //@ts-expect-error this is not allowed in MagicallyAddedDefinition.options
1289
- * sparks: true
1290
- * }
1291
- * })
1292
- * ```
1293
- *
1294
- * @param schemaDefinition - should be a valid schema type definition.
1295
- * @param defineOptions - optional param to provide type hints for `schemaDefinition`.
1296
- *
1297
- * @see defineField
1298
- * @see defineArrayMember
1299
- * @see typed
1300
- *
1301
- * @beta
1302
- */
1303
- export declare function defineType<
1304
- const TType extends IntrinsicTypeName | AutocompleteString,
1305
- const TName extends string,
1306
- TSelect extends Record<string, string> | undefined,
1307
- TPrepareValue extends Record<keyof TSelect, any> | undefined,
1308
- TAlias extends IntrinsicTypeName | undefined,
1309
- TStrict extends StrictDefinition,
1310
- >(
1311
- schemaDefinition: {
1312
- type: TType
1313
- name: TName
1314
- } & DefineSchemaBase<TType, TAlias> &
1315
- NarrowPreview<TType, TAlias, TSelect, TPrepareValue> &
1316
- MaybeAllowUnknownProps<TStrict>,
1317
- defineOptions?: DefineSchemaOptions<TStrict, TAlias>,
1318
- ): typeof schemaDefinition
1319
-
1320
- /** @internal */
1321
- export declare interface DeleteMutation {
1322
- delete: MutationSelection
1323
- }
1324
-
1325
- /** @public */
1326
- export declare interface DeprecatedProperty {
1327
- reason: string
1328
- }
1329
-
1330
- /** @public */
1331
- export declare type DeprecatedSchemaType<TSchemaType extends BaseSchemaType = BaseSchemaType> =
1332
- TSchemaType & DeprecationConfiguration
1333
-
1334
- /**
1335
- * @public
1336
- */
1337
- export declare interface DeprecationConfiguration {
1338
- deprecated: DeprecatedProperty
1339
- }
1340
-
1341
- /** @public */
1342
- export declare interface DocumentDefinition extends Omit<ObjectDefinition, 'type'> {
1343
- type: 'document'
1344
- liveEdit?: boolean
1345
- /** @beta */
1346
- orderings?: SortOrdering[]
1347
- options?: DocumentOptions
1348
- validation?: ValidationBuilder<DocumentRule, SanityDocument>
1349
- initialValue?: InitialValueProperty<any, Record<string, unknown>>
1350
- /** @deprecated Unused. Use the new field-level search config. */
1351
- __experimental_search?: {
1352
- path: string
1353
- weight: number
1354
- mapWith?: string
1355
- }[]
1356
- /** @alpha */
1357
- __experimental_omnisearch_visibility?: boolean
1358
- /**
1359
- * Determines whether the large preview title is displayed in the document pane form
1360
- * @alpha
1361
- * */
1362
- __experimental_formPreviewTitle?: boolean
1363
- }
1364
-
1365
- /**
1366
- * This exists only to allow for extensions using declaration-merging.
1367
- *
1368
- * @public
1369
- */
1370
- export declare interface DocumentOptions extends BaseSchemaTypeOptions {}
1371
-
1372
- /** @public */
1373
- export declare interface DocumentRule extends RuleDef<DocumentRule, SanityDocument> {}
1374
-
1375
- /** @public */
1376
- export declare interface EmailDefinition extends BaseSchemaDefinition {
1377
- type: 'email'
1378
- options?: EmailOptions
1379
- placeholder?: string
1380
- validation?: ValidationBuilder<EmailRule, string>
1381
- initialValue?: InitialValueProperty<any, string>
1382
- }
1383
-
1384
- /** @public */
1385
- export declare interface EmailOptions extends BaseSchemaTypeOptions {}
1386
-
1387
- /** @public */
1388
- export declare interface EmailRule extends RuleDef<EmailRule, string> {}
1389
-
1390
- /** @public */
1391
- export declare interface EmptyProps {}
1392
-
1393
- /** @public */
1394
- export declare interface EnumListProps<V = unknown> {
1395
- list?: Array<TitledListValue<V> | V>
1396
- layout?: 'radio' | 'dropdown'
1397
- direction?: 'horizontal' | 'vertical'
1398
- }
1399
-
1400
- /**
1401
- * The shape of a field definition. Note, it's recommended to use the
1402
- * `defineField` function instead of using this type directly.
1403
- *
1404
- * Where `defineField` infers the exact field type,
1405
- * FieldDefinition is a compromise union of all types a field can have.
1406
- *
1407
- * A field definition can be a reference to another registered top-level type
1408
- * or a inline type definition.
1409
- *
1410
- * @public
1411
- */
1412
- export declare type FieldDefinition<
1413
- TType extends IntrinsicTypeName = IntrinsicTypeName,
1414
- TAlias extends IntrinsicTypeName | undefined = undefined,
1415
- > = (InlineFieldDefinition[TType] | TypeAliasDefinition<string, TAlias>) & FieldDefinitionBase
1416
-
1417
- /** @public */
1418
- export declare interface FieldDefinitionBase {
1419
- fieldset?: string
1420
- group?: string | string[]
1421
- }
1422
-
1423
- /** @public */
1424
- export declare interface FieldGroup {
1425
- name: string
1426
- icon?: ComponentType
1427
- title?: string
1428
- description?: string
1429
- i18n?: I18nTextRecord<'title'>
1430
- hidden?: ConditionalProperty
1431
- default?: boolean
1432
- fields?: ObjectField[]
1433
- }
1434
-
1435
- /** @public */
1436
- export declare type FieldGroupDefinition = {
1437
- name: string
1438
- title?: string
1439
- hidden?: ConditionalProperty
1440
- icon?: ComponentType
1441
- default?: boolean
1442
- i18n?: I18nTextRecord<'title'>
1443
- }
1444
-
1445
- /**
1446
- * Holds a reference to a different field
1447
- * NOTE: Only use this through {@link Rule.valueOfField}
1448
- *
1449
- * @public
1450
- */
1451
- export declare interface FieldReference {
1452
- type: symbol
1453
- path: string | string[]
1454
- }
1455
-
1456
- /** @public */
1457
- export declare type FieldRules = {
1458
- [fieldKey: string]: SchemaValidationValue
1459
- }
1460
-
1461
- /** @public */
1462
- export declare type Fieldset = SingleFieldSet | MultiFieldSet
1463
-
1464
- /** @public */
1465
- export declare type FieldsetDefinition = {
1466
- name: string
1467
- title?: string
1468
- description?: string
1469
- group?: string
1470
- hidden?: ConditionalProperty
1471
- readOnly?: ConditionalProperty
1472
- options?: ObjectOptions
1473
- }
1474
-
1475
- /** @public */
1476
- declare interface File_2 {
1477
- [key: string]: unknown
1478
- asset?: Reference
1479
- }
1480
- export {File_2 as File}
1481
-
1482
- /** @public */
1483
- export declare interface FileAsset extends Asset {
1484
- _type: 'sanity.fileAsset'
1485
- metadata: Record<string, unknown>
1486
- }
1487
-
1488
- /** @public */
1489
- export declare interface FileDefinition
1490
- extends Omit<ObjectDefinition, 'type' | 'fields' | 'options' | 'groups' | 'validation'> {
1491
- type: 'file'
1492
- fields?: ObjectDefinition['fields']
1493
- options?: FileOptions
1494
- validation?: ValidationBuilder<FileRule, FileValue>
1495
- initialValue?: InitialValueProperty<any, FileValue>
1496
- }
1497
-
1498
- /** @public */
1499
- export declare interface FileOptions extends ObjectOptions {
1500
- storeOriginalFilename?: boolean
1501
- accept?: string
1502
- sources?: AssetSource[]
1503
- mediaLibrary?: MediaLibraryOptions
1504
- }
1505
-
1506
- /** @public */
1507
- export declare interface FileRule extends RuleDef<FileRule, FileValue> {
1508
- /**
1509
- * Require a file field has an asset.
1510
- *
1511
- * @example
1512
- * ```ts
1513
- * defineField({
1514
- * name: 'file',
1515
- * title: 'File',
1516
- * type: 'file',
1517
- * validation: (Rule) => Rule.required().assetRequired(),
1518
- * })
1519
- * ```
1520
- */
1521
- assetRequired(): FileRule
1522
- }
1523
-
1524
- /** @public */
1525
- export declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
1526
- options?: FileOptions
1527
- }
1528
-
1529
- /** @public */
1530
- export declare interface FileValue {
1531
- asset?: Reference
1532
- [index: string]: unknown
1533
- }
1534
-
1535
- /** @public */
1536
- export declare interface FormNodeValidation {
1537
- level: 'error' | 'warning' | 'info'
1538
- message: string
1539
- path: Path
1540
- }
1541
-
1542
- /** @public */
1543
- export declare interface GeopointDefinition extends BaseSchemaDefinition {
1544
- type: 'geopoint'
1545
- options?: GeopointOptions
1546
- validation?: ValidationBuilder<GeopointRule, GeopointValue>
1547
- initialValue?: InitialValueProperty<any, Omit<GeopointValue, '_type'>>
1548
- }
1549
-
1550
- /** @public */
1551
- export declare interface GeopointOptions extends BaseSchemaTypeOptions {}
1552
-
1553
- /** @public */
1554
- export declare interface GeopointRule extends RuleDef<GeopointRule, GeopointValue> {}
1555
-
1556
- /**
1557
- * Geographical point representing a pair of latitude and longitude coordinates,
1558
- * stored as degrees, in the World Geodetic System 1984 (WGS 84) format. Also
1559
- * includes an optional `alt` property representing the altitude in meters.
1560
- *
1561
- * @public
1562
- */
1563
- export declare interface GeopointValue {
1564
- /**
1565
- * Type of the object. Must be `geopoint`.
1566
- */
1567
- _type: 'geopoint'
1568
- /**
1569
- * Latitude in degrees
1570
- */
1571
- lat: number
1572
- /**
1573
- * Longitude in degrees
1574
- */
1575
- lng: number
1576
- /**
1577
- * Altitude in meters
1578
- */
1579
- alt?: number
1580
- }
1581
-
1582
- /** @public */
1583
- export declare interface GlobalDocumentReferenceDefinition extends BaseSchemaDefinition {
1584
- type: 'globalDocumentReference'
1585
- weak?: boolean
1586
- to: {
1587
- type: string
1588
- title?: string
1589
- icon?: ComponentType
1590
- preview?: PreviewConfig
1591
- }[]
1592
- resourceType: string
1593
- resourceId: string
1594
- options?: ReferenceOptions
1595
- studioUrl?: string | ((document: {id: string; type?: string}) => string | null)
1596
- }
1597
-
1598
- /** @beta */
1599
- export declare type GlobalDocumentReferenceFilterResolver = (options: {
1600
- document: SanityDocument
1601
- parent?: Record<string, unknown> | Record<string, unknown>[]
1602
- parentPath: Path
1603
- }) =>
1604
- | GlobalDocumentReferenceFilterSearchOptions
1605
- | Promise<GlobalDocumentReferenceFilterSearchOptions>
1606
-
1607
- /** @beta */
1608
- export declare type GlobalDocumentReferenceFilterSearchOptions = {
1609
- filter?: string
1610
- params?: Record<string, unknown>
1611
- tag?: string
1612
- }
1613
-
1614
- /** @beta */
1615
- export declare interface GlobalDocumentReferenceSchemaType
1616
- extends Omit<ObjectSchemaType, 'options'> {
1617
- jsonType: 'object'
1618
- to: GlobalDocumentReferenceType[]
1619
- resourceType: string
1620
- resourceId: string
1621
- studioUrl?: string | ((document: {id: string; type?: string}) => string | null)
1622
- weak?: boolean
1623
- options?: ReferenceFilterOptions
1624
- }
1625
-
1626
- /** @beta */
1627
- export declare interface GlobalDocumentReferenceType {
1628
- type: string
1629
- title?: string
1630
- icon: ComponentType
1631
- preview: PreviewConfig
1632
- /** @deprecated Unused. It's only here for the type to be compatible with createSearchQuery.ts */
1633
- __experimental_search: never
1634
- }
1635
-
1636
- /** @beta */
1637
- export declare interface GlobalDocumentReferenceValue {
1638
- _type: string
1639
- /** The reference to the document. This is a string of the form `a:b:c`,
1640
- * where:
1641
- * - `a` is the resource type, for example `dataset` or `media-library`
1642
- * - `b` is the resource ID, for example data set name or media library ID
1643
- * - `c` is the document ID */
1644
- _ref: `${string}:${string}:${string}`
1645
- _key?: string
1646
- _weak?: boolean
1647
- }
1648
-
1649
- /** @public */
1650
- export declare interface HotspotOptions {
1651
- previews?: HotspotPreview[]
1652
- }
1653
-
1654
- /** @public */
1655
- export declare interface HotspotPreview {
1656
- title: string
1657
- aspectRatio: number
1658
- }
1659
-
1660
- /** @public */
1661
- export declare type I18nTextRecord<K extends string> = {
1662
- [P in K]?: {
1663
- key: string
1664
- ns: string
1665
- }
1666
- }
1667
-
1668
- /** @public */
1669
- export declare interface I18nTitledListValue<V = unknown> {
1670
- _key?: string
1671
- title: string
1672
- i18nTitleKey?: string
1673
- value?: V
1674
- }
1675
-
1676
- /** @public */
1677
- declare interface Image_2 {
1678
- [key: string]: unknown
1679
- asset?: Reference
1680
- crop?: ImageCrop
1681
- hotspot?: ImageHotspot
1682
- }
1683
- export {Image_2 as Image}
1684
-
1685
- /** @public */
1686
- export declare interface ImageAsset extends Asset {
1687
- _type: 'sanity.imageAsset'
1688
- metadata: ImageMetadata
1689
- }
1690
-
1691
- /** @public */
1692
- export declare interface ImageCrop {
1693
- _type?: 'sanity.imageCrop'
1694
- left: number
1695
- bottom: number
1696
- right: number
1697
- top: number
1698
- }
1699
-
1700
- /** @public */
1701
- export declare interface ImageDefinition
1702
- extends Omit<ObjectDefinition, 'type' | 'fields' | 'options' | 'groups' | 'validation'> {
1703
- type: 'image'
1704
- fields?: FieldDefinition[]
1705
- options?: ImageOptions
1706
- validation?: ValidationBuilder<ImageRule, ImageValue>
1707
- initialValue?: InitialValueProperty<any, ImageValue>
1708
- }
1709
-
1710
- /** @public */
1711
- export declare interface ImageDimensions {
1712
- _type: 'sanity.imageDimensions'
1713
- height: number
1714
- width: number
1715
- aspectRatio: number
1716
- }
1717
-
1718
- /** @public */
1719
- export declare interface ImageHotspot {
1720
- _type?: 'sanity.imageHotspot'
1721
- width: number
1722
- height: number
1723
- x: number
1724
- y: number
1725
- }
1726
-
1727
- /** @public */
1728
- export declare interface ImageMetadata {
1729
- [key: string]: unknown
1730
- _type: 'sanity.imageMetadata'
1731
- dimensions: ImageDimensions
1732
- palette?: ImagePalette
1733
- lqip?: string
1734
- blurHash?: string
1735
- hasAlpha: boolean
1736
- isOpaque: boolean
1737
- }
1738
-
1739
- /** @public */
1740
- export declare type ImageMetadataType =
1741
- | 'blurhash'
1742
- | 'lqip'
1743
- | 'palette'
1744
- | 'exif'
1745
- | 'image'
1746
- | 'location'
1747
-
1748
- /** @public */
1749
- export declare interface ImageOptions extends FileOptions {
1750
- metadata?: ImageMetadataType[]
1751
- hotspot?: boolean | HotspotOptions
1752
- }
1753
-
1754
- /** @public */
1755
- export declare interface ImagePalette {
1756
- _type: 'sanity.imagePalette'
1757
- darkMuted?: ImageSwatch
1758
- darkVibrant?: ImageSwatch
1759
- dominant?: ImageSwatch
1760
- lightMuted?: ImageSwatch
1761
- lightVibrant?: ImageSwatch
1762
- muted?: ImageSwatch
1763
- vibrant?: ImageSwatch
1764
- }
1765
-
1766
- /** @public */
1767
- export declare interface ImageRule extends RuleDef<ImageRule, ImageValue> {
1768
- /**
1769
- * Require an image field has an asset.
1770
- *
1771
- * @example
1772
- * ```ts
1773
- * defineField({
1774
- * name: 'image',
1775
- * title: 'Image',
1776
- * type: 'image',
1777
- * validation: (Rule) => Rule.required().assetRequired(),
1778
- * })
1779
- * ```
1780
- */
1781
- assetRequired(): ImageRule
1782
- }
1783
-
1784
- /** @public */
1785
- export declare interface ImageSchemaType extends Omit<ObjectSchemaType, 'options'> {
1786
- options?: ImageOptions
1787
- }
1788
-
1789
- /** @public */
1790
- export declare interface ImageSwatch {
1791
- _type: 'sanity.imagePaletteSwatch'
1792
- background: string
1793
- foreground: string
1794
- population: number
1795
- title?: string
1796
- }
1797
-
1798
- /** @internal */
1799
- export declare type ImageUrlAutoMode = 'format'
1800
-
1801
- /** @internal */
1802
- export declare type ImageUrlCropMode =
1803
- | 'top'
1804
- | 'bottom'
1805
- | 'left'
1806
- | 'right'
1807
- | 'center'
1808
- | 'focalpoint'
1809
- | 'entropy'
1810
-
1811
- /** @internal */
1812
- export declare type ImageUrlFitMode = 'clip' | 'crop' | 'fill' | 'fillmax' | 'max' | 'scale' | 'min'
1813
-
1814
- /** @internal */
1815
- export declare type ImageUrlFormat = 'jpg' | 'pjpg' | 'png' | 'webp'
1816
-
1817
- /** @internal */
1818
- export declare type ImageUrlOrientation = '0' | '90' | '180' | '270'
1819
-
1820
- /**
1821
- * NOTE: These are query parameters, so they will eventually be encoded as strings.
1822
- * However, since most/all query parameter encoders will accept numbers and encode
1823
- * them as strings, we'll use `string| number` where applicable, as it makes it easier
1824
- * to use in places that do calculations and such.
1825
- *
1826
- * @internal
1827
- */
1828
- export declare interface ImageUrlParams {
1829
- 'bg'?: string
1830
- 'dpr'?: number | string
1831
- 'w'?: number | string
1832
- 'h'?: number | string
1833
- 'q'?: number | string
1834
- 'dl'?: string
1835
- 'dlRaw'?: string
1836
- 'fp-x'?: number | string
1837
- 'fp-y'?: number | string
1838
- 'max-w'?: number | string
1839
- 'max-h'?: number | string
1840
- 'min-w'?: number | string
1841
- 'min-h'?: number | string
1842
- 'blur'?: number | string
1843
- 'sharp'?: number | string
1844
- 'rect'?: string
1845
- 'fm'?: ImageUrlFormat
1846
- 'or'?: ImageUrlOrientation
1847
- 'fit'?: ImageUrlFitMode
1848
- 'crop'?: ImageUrlCropMode
1849
- 'auto'?: ImageUrlAutoMode
1850
- 'invert'?: 'true' | 'false'
1851
- 'quality'?: number | string
1852
- 'flip'?: 'h' | 'v' | 'hv'
1853
- 'sat'?: number | string
1854
- 'pad'?: number | string
1855
- 'colorquant'?: number | string
1856
- 'border'?: string
1857
- }
1858
-
1859
- /** @public */
1860
- export declare interface ImageValue extends FileValue {
1861
- crop?: ImageCrop
1862
- hotspot?: ImageHotspot
1863
- [index: string]: unknown
1864
- }
1865
-
1866
- /** @public */
1867
- export declare type IndexTuple = [number | '', number | '']
1868
-
1869
- /** @public */
1870
- export declare type InitialValueProperty<Params, Value> =
1871
- | Value
1872
- | InitialValueResolver<Params, Value>
1873
- | undefined
1874
-
1875
- /** @public */
1876
- export declare type InitialValueResolver<Params, Value> = (
1877
- params: Params | undefined,
1878
- context: InitialValueResolverContext,
1879
- ) => Promise<Value> | Value
1880
-
1881
- /** @public */
1882
- export declare interface InitialValueResolverContext {
1883
- projectId: string
1884
- dataset: string
1885
- schema: Schema
1886
- currentUser: CurrentUser | null
1887
- getClient: (options: {apiVersion: string}) => SanityClient
1888
- }
1889
-
1890
- /** @public */
1891
- export declare type InlineFieldDefinition = {
1892
- [K in keyof IntrinsicDefinitions]: Omit<
1893
- IntrinsicDefinitions[K],
1894
- 'initialValue' | 'validation'
1895
- > & {
1896
- validation?: SchemaValidationValue
1897
- initialValue?: InitialValueProperty<any, any>
1898
- }
1899
- }
1900
-
1901
- /** @alpha This API may change */
1902
- export declare interface InsertMenuOptions {
1903
- /**
1904
- * @defaultValue `'auto'`
1905
- * `filter: 'auto'` automatically turns on filtering if there are more than 5
1906
- * schema types added to the menu.
1907
- */
1908
- filter?: 'auto' | boolean | undefined
1909
- groups?:
1910
- | Array<{
1911
- name: string
1912
- title?: string
1913
- of?: Array<string>
1914
- }>
1915
- | undefined
1916
- /** defaultValue `true` */
1917
- showIcons?: boolean | undefined
1918
- /** @defaultValue `[{name: 'list'}]` */
1919
- views?:
1920
- | Array<
1921
- | {
1922
- name: 'list'
1923
- }
1924
- | {
1925
- name: 'grid'
1926
- previewImageUrl?: (schemaTypeName: string) => string | undefined
1927
- }
1928
- >
1929
- | undefined
1930
- }
1931
-
1932
- /** @internal */
1933
- export declare type InsertPatch =
1934
- | {
1935
- before: string
1936
- items: unknown[]
1937
- }
1938
- | {
1939
- after: string
1940
- items: unknown[]
1941
- }
1942
- | {
1943
- replace: string
1944
- items: unknown[]
1945
- }
1946
-
1947
- /** @beta */
1948
- export declare type IntrinsicArrayOfBase = {
1949
- [K in keyof IntrinsicDefinitions]: Omit<ArrayOfEntry<IntrinsicDefinitions[K]>, 'preview'>
1950
- }
1951
-
1952
- /** @public */
1953
- export declare type IntrinsicArrayOfDefinition = {
1954
- [K in keyof IntrinsicDefinitions]: Omit<
1955
- ArrayOfEntry<IntrinsicDefinitions[K]>,
1956
- 'validation' | 'initialValue'
1957
- > & {
1958
- validation?: SchemaValidationValue
1959
- initialValue?: InitialValueProperty<any, any>
1960
- }
1961
- }
1962
-
1963
- /** @beta */
1964
- export declare type IntrinsicBase = {
1965
- [K in keyof IntrinsicDefinitions]: Omit<IntrinsicDefinitions[K], 'preview'>
1966
- }
1967
-
1968
- /**
1969
- * `IntrinsicDefinitions` is a lookup map for "predefined" schema definitions.
1970
- * Schema types in `IntrinsicDefinitions` will have good type-completion and type-safety in {@link defineType},
1971
- * {@link defineField} and {@link defineArrayMember} once the `type` property is provided.
1972
- *
1973
- * By default, `IntrinsicDefinitions` contains all standard Sanity schema types (`array`, `string`, `number` ect),
1974
- * but it is an interface and as such, open for extension.
1975
- *
1976
- * This type can be extended using declaration merging; this way new entries can be added.
1977
- * See {@link defineType} for examples on how this can be accomplished.
1978
- *
1979
- * @see defineType
1980
- *
1981
- * @public
1982
- */
1983
- export declare interface IntrinsicDefinitions {
1984
- array: ArrayDefinition
1985
- block: BlockDefinition
1986
- boolean: BooleanDefinition
1987
- date: DateDefinition
1988
- datetime: DatetimeDefinition
1989
- document: DocumentDefinition
1990
- file: FileDefinition
1991
- geopoint: GeopointDefinition
1992
- image: ImageDefinition
1993
- number: NumberDefinition
1994
- object: ObjectDefinition
1995
- reference: ReferenceDefinition
1996
- crossDatasetReference: CrossDatasetReferenceDefinition
1997
- globalDocumentReference: GlobalDocumentReferenceDefinition
1998
- slug: SlugDefinition
1999
- string: StringDefinition
2000
- text: TextDefinition
2001
- url: UrlDefinition
2002
- email: EmailDefinition
2003
- }
2004
-
2005
- /**
2006
- * A union of all intrinsic types allowed natively in the schema.
2007
- *
2008
- * @see IntrinsicDefinitions
2009
- *
2010
- * @public
2011
- */
2012
- export declare type IntrinsicTypeName = IntrinsicDefinitions[keyof IntrinsicDefinitions]['type']
2013
-
2014
- /** @internal */
2015
- export declare function isArrayOfBlocksSchemaType(
2016
- type: unknown,
2017
- ): type is ArraySchemaType<ObjectSchemaType>
2018
-
2019
- /** @internal */
2020
- export declare function isArrayOfObjectsSchemaType(
2021
- type: unknown,
2022
- ): type is ArraySchemaType<ObjectSchemaType>
2023
-
2024
- /** @internal */
2025
- export declare function isArrayOfPrimitivesSchemaType(type: unknown): type is ArraySchemaType
2026
-
2027
- /** @internal */
2028
- export declare function isArraySchemaType(type: unknown): type is ArraySchemaType
2029
-
2030
- /**
2031
- * Check whether the provided value resembles a Media Library asset aspect document.
2032
- *
2033
- * Note: This function does not perform a comprehensive check.
2034
- *
2035
- * @see validateMediaLibraryAssetAspect
2036
- *
2037
- * @internal
2038
- */
2039
- export declare function isAssetAspect(
2040
- maybeAssetAspect: unknown,
2041
- ): maybeAssetAspect is MediaLibraryAssetAspectDocument
2042
-
2043
- /** @internal */
2044
- export declare function isBlockChildrenObjectField(
2045
- field: unknown,
2046
- ): field is BlockChildrenObjectField
2047
-
2048
- /** @internal */
2049
- export declare function isBlockListObjectField(field: unknown): field is BlockListObjectField
2050
-
2051
- /** @internal */
2052
- export declare function isBlockSchemaType(type: unknown): type is BlockSchemaType
2053
-
2054
- /** @internal */
2055
- export declare function isBlockStyleObjectField(field: unknown): field is BlockStyleObjectField
2056
-
2057
- /** @internal */
2058
- export declare function isBooleanSchemaType(type: unknown): type is BooleanSchemaType
2059
-
2060
- /** @internal */
2061
- export declare function isCreateIfNotExistsMutation(
2062
- mutation: Mutation | TransactionLogMutation,
2063
- ): mutation is CreateIfNotExistsMutation
2064
-
2065
- /** @internal */
2066
- export declare function isCreateMutation(
2067
- mutation: Mutation | TransactionLogMutation,
2068
- ): mutation is CreateMutation
2069
-
2070
- /** @internal */
2071
- export declare function isCreateOrReplaceMutation(
2072
- mutation: Mutation | TransactionLogMutation,
2073
- ): mutation is CreateOrReplaceMutation
2074
-
2075
- /** @internal */
2076
- export declare function isCreateSquashedMutation(
2077
- mutation: Mutation | TransactionLogMutation,
2078
- ): mutation is CreateSquashedMutation
2079
-
2080
- /** @beta */
2081
- export declare function isCrossDatasetReference(
2082
- reference: unknown,
2083
- ): reference is CrossDatasetReferenceValue
2084
-
2085
- /** @internal */
2086
- export declare function isCrossDatasetReferenceSchemaType(
2087
- type: unknown,
2088
- ): type is CrossDatasetReferenceSchemaType
2089
-
2090
- /** @internal */
2091
- export declare function isDateTimeSchemaType(type: unknown): type is StringSchemaType
2092
-
2093
- /** @internal */
2094
- export declare function isDeleteMutation(
2095
- mutation: Mutation | TransactionLogMutation,
2096
- ): mutation is DeleteMutation
2097
-
2098
- /** @internal */
2099
- export declare function isDeprecatedSchemaType<TSchemaType extends BaseSchemaType>(
2100
- type: TSchemaType,
2101
- ): type is DeprecatedSchemaType<TSchemaType>
2102
-
2103
- /** @internal */
2104
- export declare function isDeprecationConfiguration(type: unknown): type is DeprecationConfiguration
2105
-
2106
- /**
2107
- * Returns wether or not the given type is a document type
2108
- * (eg that it was defined as `type: 'document'`)
2109
- *
2110
- * @param type - Schema type to test
2111
- * @returns True if type is a document type, false otherwise
2112
- *
2113
- * @public
2114
- */
2115
- export declare function isDocumentSchemaType(type: unknown): type is ObjectSchemaType
2116
-
2117
- /** @internal */
2118
- export declare function isFileSchemaType(type: unknown): type is FileSchemaType
2119
-
2120
- /** @beta */
2121
- export declare function isGlobalDocumentReference(
2122
- reference: unknown,
2123
- ): reference is GlobalDocumentReferenceValue
2124
-
2125
- /** @public */
2126
- export declare function isImage(value: unknown): value is Image_2
2127
-
2128
- /** @internal */
2129
- export declare function isImageSchemaType(type: unknown): type is ImageSchemaType
2130
-
2131
- /** @internal */
2132
- export declare function isIndexSegment(segment: PathSegment): segment is number
2133
-
2134
- /** @internal */
2135
- export declare function isIndexTuple(segment: PathSegment): segment is IndexTuple
2136
-
2137
- /** @public */
2138
- export declare function isKeyedObject(obj: unknown): obj is KeyedObject
2139
-
2140
- /** @internal */
2141
- export declare function isKeySegment(segment: PathSegment): segment is KeyedSegment
2142
-
2143
- /** @internal */
2144
- export declare function isNumberSchemaType(type: unknown): type is NumberSchemaType
2145
-
2146
- /** @internal */
2147
- export declare function isObjectSchemaType(type: unknown): type is ObjectSchemaType
2148
-
2149
- /** @internal */
2150
- export declare function isPatchMutation(
2151
- mutation: Mutation | TransactionLogMutation,
2152
- ): mutation is PatchMutation
2153
-
2154
- /**
2155
- * Assert that a given object is a portable-text list-text-block-type object
2156
- *
2157
- * @remarks
2158
- * Uses `isPortableTextTextBlock` and checks for `listItem` and `level`
2159
- *
2160
- * @see isPortableTextTextBlock
2161
- *
2162
- * @alpha
2163
- */
2164
- export declare function isPortableTextListBlock<T = PortableTextSpan | PortableTextObject>(
2165
- value: unknown,
2166
- ): value is PortableTextTextBlock<T>
2167
-
2168
- /**
2169
- * Assert that a given object is a portable-text span-type object
2170
- *
2171
- * @remarks
2172
- * The `marks` property of a block is optional.
2173
- *
2174
- * @alpha
2175
- */
2176
- export declare function isPortableTextSpan(value: unknown): value is PortableTextSpan
2177
-
2178
- /**
2179
- * Assert that a given object is a portable-text text-block type object
2180
- *
2181
- * @remarks
2182
- * * The `markDefs` and `style` property of a block is optional.
2183
- * * Block types can be named, so expect anything of the _type property.
2184
- *
2185
- * @alpha
2186
- */
2187
- export declare function isPortableTextTextBlock<T = PortableTextSpan | PortableTextObject>(
2188
- value: unknown,
2189
- ): value is PortableTextTextBlock<T>
2190
-
2191
- /** @internal */
2192
- export declare function isPrimitiveSchemaType(
2193
- type: unknown,
2194
- ): type is BooleanSchemaType | StringSchemaType | NumberSchemaType
2195
-
2196
- /** @internal */
2197
- export declare function isReference(reference: unknown): reference is Reference
2198
-
2199
- /** @internal */
2200
- export declare function isReferenceSchemaType(type: unknown): type is ReferenceSchemaType
2201
-
2202
- /** @public */
2203
- export declare function isSanityDocument(document: unknown): document is SanityDocument
2204
-
2205
- /**
2206
- * @internal
2207
- */
2208
- export declare function isSearchStrategy(
2209
- maybeSearchStrategy: unknown,
2210
- ): maybeSearchStrategy is SearchStrategy
2211
-
2212
- /**
2213
- * Checks whether the given `thing` is a slug, eg an object with a `current` string property.
2214
- *
2215
- * @param thing - The thing to check
2216
- * @returns True if slug, false otherwise
2217
- * @public
2218
- */
2219
- export declare function isSlug(thing: unknown): thing is Slug
2220
-
2221
- /** @internal */
2222
- export declare function isSpanSchemaType(type: unknown): type is SpanSchemaType
2223
-
2224
- /** @internal */
2225
- export declare function isStringSchemaType(type: unknown): type is StringSchemaType
2226
-
2227
- /** @internal */
2228
- export declare function isTitledListValue(item: unknown): item is TitledListValue
2229
-
2230
- /** @public */
2231
- export declare function isTypedObject(obj: unknown): obj is TypedObject
2232
-
2233
- /** @internal */
2234
- export declare function isValidationError(node: FormNodeValidation): node is FormNodeValidation & {
2235
- level: 'error'
2236
- }
2237
-
2238
- /** @internal */
2239
- export declare function isValidationErrorMarker(
2240
- marker: ValidationMarker,
2241
- ): marker is ValidationMarker & {
2242
- level: 'error'
2243
- }
2244
-
2245
- /** @internal */
2246
- export declare function isValidationInfo(node: FormNodeValidation): node is FormNodeValidation & {
2247
- level: 'info'
2248
- }
2249
-
2250
- /** @internal */
2251
- export declare function isValidationInfoMarker(
2252
- marker: ValidationMarker,
2253
- ): marker is ValidationMarker & {
2254
- level: 'info'
2255
- }
2256
-
2257
- /** @internal */
2258
- export declare function isValidationWarning(
2259
- node: FormNodeValidation,
2260
- ): node is FormNodeValidation & {
2261
- level: 'warning'
2262
- }
2263
-
2264
- /** @internal */
2265
- export declare function isValidationWarningMarker(
2266
- marker: ValidationMarker,
2267
- ): marker is ValidationMarker & {
2268
- level: 'warning'
2269
- }
2270
-
2271
- /** @public */
2272
- export declare interface KeyedObject {
2273
- [key: string]: unknown
2274
- _key: string
2275
- }
2276
-
2277
- /** @public */
2278
- export declare type KeyedSegment = {
2279
- _key: string
2280
- }
2281
-
2282
- /**
2283
- * Holds localized validation messages for a given field.
2284
- *
2285
- * @example Custom message for English (US) and Norwegian (Bokmål):
2286
- * ```
2287
- * {
2288
- * 'en-US': 'Needs to start with a capital letter',
2289
- * 'no-NB': 'Må starte med stor bokstav',
2290
- * }
2291
- * ```
2292
- * @public
2293
- */
2294
- export declare interface LocalizedValidationMessages {
2295
- [locale: string]: string
2296
- }
2297
-
2298
- /** @beta */
2299
- export declare type MaybeAllowUnknownProps<TStrict extends StrictDefinition> = TStrict extends false
2300
- ? {
2301
- options?: {
2302
- [index: string]: any
2303
- }
2304
- [index: string]: any
2305
- }
2306
- : unknown
2307
-
2308
- /** @beta */
2309
- export declare type MaybePreview<
2310
- Select extends Record<string, string> | undefined,
2311
- PrepareValue extends Record<keyof Select, any> | undefined,
2312
- > =
2313
- Select extends Record<string, string>
2314
- ? PrepareValue extends Record<keyof Select, any>
2315
- ? PreviewConfig<Select, PrepareValue>
2316
- : never
2317
- : never
2318
-
2319
- /**
2320
- * @public
2321
- */
2322
- export declare const MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME = 'sanity.asset.aspect'
2323
-
2324
- /** @public */
2325
- export declare type MediaAssetTypes = AssetInstanceDocument['_type']
2326
-
2327
- /**
2328
- * @public
2329
- */
2330
- export declare type MediaLibraryAssetAspectDefinition =
2331
- MediaLibraryAssetAspectSupportedFieldDefinitions & {
2332
- assetType?: MediaLibraryAssetType | MediaLibraryAssetType[]
2333
- public?: boolean
2334
- }
2335
-
2336
- /**
2337
- * A document representing a Media Library asset aspect.
2338
- *
2339
- * Each aspect provides a schema describing custom data that can be assigned to assets.
2340
- *
2341
- * @public
2342
- */
2343
- export declare interface MediaLibraryAssetAspectDocument extends SanityDocumentLike {
2344
- _type: MediaLibraryAssetAspectTypeName
2345
- /**
2346
- * Asset types the aspect can be assigned to.
2347
- *
2348
- * If no `assetType` is defined, the aspect may be assigned to any asset type.
2349
- */
2350
- assetType?: MediaLibraryAssetType[]
2351
- definition: FieldDefinition
2352
- public?: boolean
2353
- }
2354
-
2355
- /**
2356
- * @public
2357
- */
2358
- export declare type MediaLibraryAssetAspectSupportedFieldDefinitions = FieldDefinition<
2359
- Exclude<IntrinsicTypeName, 'document' | 'image' | 'file' | 'reference' | 'crossDatasetReference'>
2360
- >
2361
-
2362
- /**
2363
- * @public
2364
- */
2365
- export declare type MediaLibraryAssetAspectTypeName = typeof MEDIA_LIBRARY_ASSET_ASPECT_TYPE_NAME
2366
-
2367
- /**
2368
- * @public
2369
- */
2370
- export declare type MediaLibraryAssetType = ImageAsset['_type'] | FileAsset['_type']
2371
-
2372
- /** @public */
2373
- export declare interface MediaLibraryFilter {
2374
- name: string
2375
- query: string
2376
- }
2377
-
2378
- /** @public */
2379
- export declare interface MediaLibraryOptions {
2380
- filters?: MediaLibraryFilter[]
2381
- }
2382
-
2383
- /** @public */
2384
- export declare interface MediaValidationValue<T extends MediaAssetTypes = MediaAssetTypes> {
2385
- /**
2386
- * Media information
2387
- */
2388
- media: {
2389
- /**
2390
- * The Media Library Asset.
2391
- */
2392
- asset: Asset_2 & {
2393
- currentVersion: Extract<
2394
- AssetInstanceDocument,
2395
- {
2396
- _type: T
2397
- }
2398
- >
2399
- }
2400
- }
2401
- /**
2402
- * The field value which the media is used in.
2403
- */
2404
- value: unknown
2405
- }
2406
-
2407
- /** @public */
2408
- export declare interface MediaValidator<T extends MediaAssetTypes = MediaAssetTypes> {
2409
- (
2410
- value: MediaValidationValue<T>,
2411
- context: ValidationContext,
2412
- ): CustomValidatorResult | Promise<CustomValidatorResult>
2413
- }
2414
-
2415
- /**
2416
- * A pair of mendoza patches that can either be _applied_ (to perform the effect),
2417
- * or _reverted_ (to undo the effect). Requires the exact, previous version of the
2418
- * document when applying - any difference might have unexpected consequences.
2419
- *
2420
- * @internal
2421
- */
2422
- export declare interface MendozaEffectPair {
2423
- apply: MendozaPatch
2424
- revert: MendozaPatch
2425
- }
2426
-
2427
- /**
2428
- * A mendoza patch. These are not human-readable patches, but are optimized to
2429
- * take as little space as possible, while still being represented by plain JSON.
2430
- * See {@link https://www.sanity.io/blog/mendoza}
2431
- *
2432
- * @internal
2433
- */
2434
- export declare type MendozaPatch = unknown[]
2435
-
2436
- /** @public */
2437
- export declare interface MultiFieldSet {
2438
- name: string
2439
- title?: string
2440
- description?: string
2441
- single?: false
2442
- group?: string | string[]
2443
- options?: CollapseOptions & {
2444
- columns?: number
2445
- }
2446
- fields: ObjectField[]
2447
- hidden?: ConditionalProperty
2448
- readOnly?: ConditionalProperty
2449
- }
2450
-
2451
- /** @internal */
2452
- export declare interface MultipleMutationResult {
2453
- transactionId: string
2454
- documentIds: string[]
2455
- results: {
2456
- id: string
2457
- }[]
2458
- }
2459
-
2460
- /** @internal */
2461
- export declare type Mutation =
2462
- | CreateMutation
2463
- | CreateOrReplaceMutation
2464
- | CreateIfNotExistsMutation
2465
- | DeleteMutation
2466
- | PatchMutation
2467
-
2468
- /** @internal */
2469
- export declare type MutationOperationName =
2470
- | 'create'
2471
- | 'createOrReplace'
2472
- | 'createIfNotExists'
2473
- | 'delete'
2474
- | 'patch'
2475
-
2476
- /** @internal */
2477
- export declare type MutationSelection =
2478
- | {
2479
- query: string
2480
- params?: Record<string, unknown>
2481
- }
2482
- | {
2483
- id: string
2484
- }
2485
-
2486
- /** @beta */
2487
- export declare type NarrowPreview<
2488
- TType extends string,
2489
- TAlias extends IntrinsicTypeName | undefined,
2490
- TSelect extends Record<string, string> | undefined,
2491
- TPrepareValue extends Record<keyof TSelect, any> | undefined,
2492
- > =
2493
- DefineSchemaType<TType, TAlias> extends {
2494
- preview?: Record<string, any>
2495
- }
2496
- ? {
2497
- preview?: MaybePreview<TSelect, TPrepareValue>
2498
- }
2499
- : unknown
2500
-
2501
- /** @public */
2502
- export declare interface NumberDefinition extends BaseSchemaDefinition {
2503
- type: 'number'
2504
- options?: NumberOptions
2505
- placeholder?: string
2506
- validation?: ValidationBuilder<NumberRule, number>
2507
- initialValue?: InitialValueProperty<any, number>
2508
- }
2509
-
2510
- /** @public */
2511
- export declare interface NumberOptions extends EnumListProps<number>, BaseSchemaTypeOptions {}
2512
-
2513
- /** @public */
2514
- export declare interface NumberRule extends RuleDef<NumberRule, number> {
2515
- min: (minNumber: number | FieldReference) => NumberRule
2516
- max: (maxNumber: number | FieldReference) => NumberRule
2517
- lessThan: (limit: number | FieldReference) => NumberRule
2518
- greaterThan: (limit: number | FieldReference) => NumberRule
2519
- integer: () => NumberRule
2520
- precision: (limit: number | FieldReference) => NumberRule
2521
- positive: () => NumberRule
2522
- negative: () => NumberRule
2523
- }
2524
-
2525
- /** @public */
2526
- export declare interface NumberSchemaType extends BaseSchemaType {
2527
- jsonType: 'number'
2528
- options?: NumberOptions
2529
- initialValue?: InitialValueProperty<any, number>
2530
- }
2531
-
2532
- /** @public */
2533
- export declare interface ObjectDefinition extends BaseSchemaDefinition {
2534
- type: 'object'
2535
- /**
2536
- * Object must have at least one field. This is validated at Studio startup.
2537
- */
2538
- fields: FieldDefinition[]
2539
- groups?: FieldGroupDefinition[]
2540
- fieldsets?: FieldsetDefinition[]
2541
- preview?: PreviewConfig
2542
- options?: ObjectOptions
2543
- validation?: ValidationBuilder<ObjectRule, Record<string, unknown>>
2544
- initialValue?: InitialValueProperty<any, Record<string, unknown>>
2545
- }
2546
-
2547
- /** @public */
2548
- export declare interface ObjectField<T extends SchemaType = SchemaType> {
2549
- name: string
2550
- fieldset?: string
2551
- group?: string | string[]
2552
- type: ObjectFieldType<T>
2553
- }
2554
-
2555
- /** @public */
2556
- export declare type ObjectFieldType<T extends SchemaType = SchemaType> = T & {
2557
- hidden?: ConditionalProperty
2558
- readOnly?: ConditionalProperty
2559
- }
2560
-
2561
- /** @public */
2562
- export declare interface ObjectOptions extends BaseSchemaTypeOptions {
2563
- collapsible?: boolean
2564
- collapsed?: boolean
2565
- columns?: number
2566
- modal?: {
2567
- type?: 'dialog' | 'popover'
2568
- width?: number | number[] | 'auto'
2569
- }
2570
- }
2571
-
2572
- /** @public */
2573
- export declare interface ObjectRule extends RuleDef<ObjectRule, Record<string, unknown>> {}
2574
-
2575
- /** @public */
2576
- export declare interface ObjectSchemaType extends BaseSchemaType {
2577
- jsonType: 'object'
2578
- fields: ObjectField[]
2579
- groups?: FieldGroup[]
2580
- fieldsets?: Fieldset[]
2581
- initialValue?: InitialValueProperty<any, Record<string, unknown>>
2582
- weak?: boolean
2583
- /** @deprecated Unused. Use the new field-level search config. */
2584
- __experimental_search?: {
2585
- path: (string | number)[]
2586
- weight: number
2587
- mapWith?: string
2588
- }[]
2589
- /** @alpha */
2590
- __experimental_omnisearch_visibility?: boolean
2591
- /** @alpha */
2592
- __experimental_actions?: string[]
2593
- /** @alpha */
2594
- __experimental_formPreviewTitle?: boolean
2595
- /**
2596
- * @beta
2597
- */
2598
- orderings?: SortOrdering[]
2599
- options?: any
2600
- }
2601
-
2602
- /** @internal */
2603
- export declare interface ObjectSchemaTypeWithOptions extends Omit<ObjectSchemaType, 'options'> {
2604
- options?: CollapseOptions & {
2605
- columns?: number
2606
- }
2607
- }
2608
-
2609
- /** @internal */
2610
- export declare interface PatchMutation {
2611
- patch: PatchMutationOperation
2612
- }
2613
-
2614
- /** @internal */
2615
- export declare type PatchMutationOperation = PatchOperations & MutationSelection
2616
-
2617
- /**
2618
- * NOTE: this is actually incorrect/invalid, but implemented as-is for backwards compatibility
2619
- *
2620
- * @internal
2621
- */
2622
- export declare interface PatchOperations {
2623
- set?: {
2624
- [key: string]: unknown
2625
- }
2626
- setIfMissing?: {
2627
- [key: string]: unknown
2628
- }
2629
- merge?: {
2630
- [key: string]: unknown
2631
- }
2632
- diffMatchPatch?: {
2633
- [key: string]: string
2634
- }
2635
- unset?: string[]
2636
- inc?: {
2637
- [key: string]: number
2638
- }
2639
- dec?: {
2640
- [key: string]: number
2641
- }
2642
- insert?: InsertPatch
2643
- ifRevisionID?: string
2644
- }
2645
-
2646
- /** @public */
2647
- export declare type Path = PathSegment[]
2648
-
2649
- /** @public */
2650
- export declare type PathSegment = string | number | KeyedSegment | IndexTuple
2651
-
2652
- /** @alpha */
2653
- export declare type PortableTextBlock = PortableTextTextBlock | PortableTextObject
2654
-
2655
- /** @alpha */
2656
- export declare type PortableTextChild = PortableTextObject | PortableTextSpan
2657
-
2658
- /** @alpha */
2659
- export declare interface PortableTextListBlock extends PortableTextTextBlock {
2660
- listItem: string
2661
- level: number
2662
- }
2663
-
2664
- /** @alpha */
2665
- export declare interface PortableTextObject {
2666
- _type: string
2667
- _key: string
2668
- [other: string]: unknown
2669
- }
2670
-
2671
- /** @alpha */
2672
- export declare interface PortableTextSpan {
2673
- _key: string
2674
- _type: 'span'
2675
- text: string
2676
- marks?: string[]
2677
- }
2678
-
2679
- /** @alpha */
2680
- export declare interface PortableTextTextBlock<TChild = PortableTextSpan | PortableTextObject> {
2681
- _type: string
2682
- _key: string
2683
- children: TChild[]
2684
- markDefs?: PortableTextObject[]
2685
- listItem?: string
2686
- style?: string
2687
- level?: number
2688
- }
2689
-
2690
- /** @public */
2691
- export declare interface PrepareViewOptions {
2692
- /** @beta */
2693
- ordering?: SortOrdering
2694
- }
2695
-
2696
- /** @public */
2697
- export declare interface PreviewConfig<
2698
- Select extends Record<string, string> = Record<string, string>,
2699
- PrepareValue extends Record<keyof Select, any> = Record<keyof Select, any>,
2700
- > {
2701
- select?: Select
2702
- prepare?: (value: PrepareValue, viewOptions?: PrepareViewOptions) => PreviewValue
2703
- }
2704
-
2705
- /** @public */
2706
- export declare interface PreviewValue {
2707
- _id?: string
2708
- _createdAt?: string
2709
- _updatedAt?: string
2710
- title?: string
2711
- subtitle?: string
2712
- description?: string
2713
- media?: ReactNode | ElementType
2714
- imageUrl?: string
2715
- }
2716
-
2717
- /** @public */
2718
- export declare interface Reference {
2719
- _type: string
2720
- _ref: string
2721
- _key?: string
2722
- _weak?: boolean
2723
- _strengthenOnPublish?: {
2724
- type: string
2725
- weak?: boolean
2726
- template?: {
2727
- id: string
2728
- params: Record<string, string | number | boolean>
2729
- }
2730
- }
2731
- }
2732
-
2733
- /** @public */
2734
- export declare interface ReferenceBaseOptions extends BaseSchemaTypeOptions {
2735
- disableNew?: boolean
2736
- }
2737
-
2738
- /** @public */
2739
- export declare interface ReferenceDefinition extends BaseSchemaDefinition {
2740
- type: 'reference'
2741
- to: ReferenceTo
2742
- weak?: boolean
2743
- options?: ReferenceOptions
2744
- validation?: ValidationBuilder<ReferenceRule, ReferenceValue>
2745
- initialValue?: InitialValueProperty<any, Omit<ReferenceValue, '_type'>>
2746
- }
2747
-
2748
- /** @public */
2749
- export declare type ReferenceFilterOptions =
2750
- | ReferenceFilterResolverOptions
2751
- | ReferenceFilterQueryOptions
2752
-
2753
- /** @public */
2754
- export declare interface ReferenceFilterQueryOptions {
2755
- filter: string
2756
- filterParams?: Record<string, unknown>
2757
- }
2758
-
2759
- /** @public */
2760
- export declare type ReferenceFilterResolver = (
2761
- context: ReferenceFilterResolverContext,
2762
- ) => ReferenceFilterSearchOptions | Promise<ReferenceFilterSearchOptions>
2763
-
2764
- /** @public */
2765
- export declare interface ReferenceFilterResolverContext {
2766
- document: SanityDocument
2767
- parent?: Record<string, unknown> | Record<string, unknown>[]
2768
- parentPath: Path
2769
- perspective: StackablePerspective[]
2770
- getClient: (options: {apiVersion: string}) => SanityClient
2771
- }
2772
-
2773
- /** @public */
2774
- export declare interface ReferenceFilterResolverOptions {
2775
- filter?: ReferenceFilterResolver
2776
- filterParams?: never
2777
- }
2778
-
2779
- /** @public */
2780
- export declare type ReferenceFilterSearchOptions = {
2781
- filter?: string
2782
- params?: Record<string, unknown>
2783
- tag?: string
2784
- maxFieldDepth?: number
2785
- strategy?: SearchStrategy
2786
- perspective?: Exclude<ClientPerspective, 'raw' | 'previewDrafts'>
2787
- }
2788
-
2789
- /**
2790
- * Types are closed for extension. To add properties via declaration merging to this type,
2791
- * redeclare and add the properties to the interfaces that make up ReferenceOptions type.
2792
- *
2793
- * @see ReferenceFilterOptions
2794
- * @see ReferenceFilterResolverOptions
2795
- * @see ReferenceBaseOptions
2796
- *
2797
- * @public
2798
- */
2799
- export declare type ReferenceOptions = ReferenceBaseOptions & ReferenceFilterOptions
2800
-
2801
- /** @public */
2802
- export declare interface ReferenceRule extends RuleDef<ReferenceRule, ReferenceValue> {}
2803
-
2804
- /** @public */
2805
- export declare interface ReferenceSchemaType extends Omit<ObjectSchemaType, 'options'> {
2806
- jsonType: 'object'
2807
- to: ObjectSchemaType[]
2808
- weak?: boolean
2809
- options?: ReferenceOptions
2810
- }
2811
-
2812
- /** @public */
2813
- export declare type ReferenceTo =
2814
- | SchemaTypeDefinition
2815
- | TypeReference
2816
- | Array<SchemaTypeDefinition | TypeReference>
2817
-
2818
- /** @public */
2819
- export declare type ReferenceValue = Reference
2820
-
2821
- /** @public */
2822
- export declare interface Role {
2823
- name: string
2824
- title: string
2825
- description?: string
2826
- }
2827
-
2828
- /** @public */
2829
- export declare interface Rule {
2830
- /**
2831
- * @internal
2832
- * @deprecated internal use only
2833
- */
2834
- _type: RuleTypeConstraint | undefined
2835
- /**
2836
- * @internal
2837
- * @deprecated internal use only
2838
- */
2839
- _level: 'error' | 'warning' | 'info' | undefined
2840
- /**
2841
- * @internal
2842
- * @deprecated internal use only
2843
- */
2844
- _required: 'required' | 'optional' | undefined
2845
- /**
2846
- * @internal
2847
- * @deprecated internal use only
2848
- */
2849
- _typeDef: SchemaType | undefined
2850
- /**
2851
- * @internal
2852
- * @deprecated internal use only
2853
- */
2854
- _message: string | LocalizedValidationMessages | undefined
2855
- /**
2856
- * @internal
2857
- * @deprecated internal use only
2858
- */
2859
- _rules: RuleSpec[]
2860
- /**
2861
- * @internal
2862
- * @deprecated internal use only
2863
- */
2864
- _fieldRules: FieldRules | undefined
2865
- /**
2866
- * Takes in a path and returns an object with a symbol.
2867
- *
2868
- * When the validation lib sees this symbol, it will use the provided path to
2869
- * get a value from the current field's parent and use that value as the input
2870
- * to the Rule.
2871
- *
2872
- * The path that's given is forwarded to `lodash/get`
2873
- *
2874
- * ```js
2875
- * fields: [
2876
- * // ...
2877
- * {
2878
- * // ...
2879
- * name: 'highestTemperature',
2880
- * type: 'number',
2881
- * validation: (Rule) => Rule.positive().min(Rule.valueOfField('lowestTemperature')),
2882
- * // ...
2883
- * },
2884
- * ]
2885
- * ```
2886
- */
2887
- valueOfField: (path: string | string[]) => FieldReference
2888
- error(message?: string | LocalizedValidationMessages): Rule
2889
- warning(message?: string | LocalizedValidationMessages): Rule
2890
- info(message?: string | LocalizedValidationMessages): Rule
2891
- reset(): this
2892
- isRequired(): boolean
2893
- clone(): Rule
2894
- cloneWithRules(rules: RuleSpec[]): Rule
2895
- merge(rule: Rule): Rule
2896
- type(targetType: RuleTypeConstraint | Lowercase<RuleTypeConstraint>): Rule
2897
- all(children: Rule[]): Rule
2898
- either(children: Rule[]): Rule
2899
- optional(): Rule
2900
- required(): Rule
2901
- custom<T = unknown>(
2902
- fn: CustomValidator<T>,
2903
- options?: {
2904
- bypassConcurrencyLimit?: boolean
2905
- },
2906
- ): Rule
2907
- media<T extends MediaAssetTypes = MediaAssetTypes>(fn: MediaValidator<T>): Rule
2908
- min(len: number | string | FieldReference): Rule
2909
- max(len: number | string | FieldReference): Rule
2910
- length(len: number | FieldReference): Rule
2911
- valid(value: unknown | unknown[]): Rule
2912
- integer(): Rule
2913
- precision(limit: number | FieldReference): Rule
2914
- positive(): Rule
2915
- negative(): Rule
2916
- greaterThan(num: number | FieldReference): Rule
2917
- lessThan(num: number | FieldReference): Rule
2918
- uppercase(): Rule
2919
- lowercase(): Rule
2920
- regex(
2921
- pattern: RegExp,
2922
- name: string,
2923
- options: {
2924
- name?: string
2925
- invert?: boolean
2926
- },
2927
- ): Rule
2928
- regex(
2929
- pattern: RegExp,
2930
- options: {
2931
- name?: string
2932
- invert?: boolean
2933
- },
2934
- ): Rule
2935
- regex(pattern: RegExp, name: string): Rule
2936
- regex(pattern: RegExp): Rule
2937
- email(): Rule
2938
- uri(options?: UriValidationOptions): Rule
2939
- unique(): Rule
2940
- reference(): Rule
2941
- fields(rules: FieldRules): Rule
2942
- assetRequired(): Rule
2943
- validate(
2944
- value: unknown,
2945
- options: ValidationContext & {
2946
- /**
2947
- * @deprecated Internal use only
2948
- * @internal
2949
- */
2950
- __internal?: {
2951
- customValidationConcurrencyLimiter?: {
2952
- ready: () => Promise<void>
2953
- release: () => void
2954
- }
2955
- }
2956
- },
2957
- ): Promise<ValidationMarker[]>
2958
- }
2959
-
2960
- /** @public */
2961
- export declare type RuleBuilder<T extends RuleDef<T, FieldValue>, FieldValue = unknown> = T | T[]
2962
-
2963
- /**
2964
- * Note: `RuleClass` and `Rule` are split to fit the current `@sanity/types`
2965
- * setup. Classes are a bit weird in the `@sanity/types` package because classes
2966
- * create an actual javascript class while simultaneously creating a type
2967
- * definition.
2968
- *
2969
- * This implicitly creates two types:
2970
- * 1. the instance type — `Rule` and
2971
- * 2. the static/class type - `RuleClass`
2972
- *
2973
- * The `RuleClass` type contains the static methods and the `Rule` instance
2974
- * contains the instance methods. Downstream in the validation package, the Rule
2975
- * implementation asserts the class declaration is of this type.
2976
- *
2977
- * @internal
2978
- */
2979
- export declare interface RuleClass {
2980
- FIELD_REF: symbol
2981
- array: (def?: SchemaType) => Rule
2982
- object: (def?: SchemaType) => Rule
2983
- string: (def?: SchemaType) => Rule
2984
- number: (def?: SchemaType) => Rule
2985
- boolean: (def?: SchemaType) => Rule
2986
- dateTime: (def?: SchemaType) => Rule
2987
- valueOfField: Rule['valueOfField']
2988
- new (typeDef?: SchemaType): Rule
2989
- }
2990
-
2991
- /** @public */
2992
- export declare interface RuleDef<T, FieldValue = unknown> {
2993
- required: () => T
2994
- custom: <LenientFieldValue extends FieldValue>(
2995
- fn: CustomValidator<LenientFieldValue | undefined>,
2996
- ) => T
2997
- info: (message?: string | LocalizedValidationMessages) => T
2998
- error: (message?: string | LocalizedValidationMessages) => T
2999
- warning: (message?: string | LocalizedValidationMessages) => T
3000
- valueOfField: (path: string | string[]) => FieldReference
3001
- }
3002
-
3003
- /** @public */
3004
- export declare type RuleSpec =
3005
- | {
3006
- flag: 'integer'
3007
- }
3008
- | {
3009
- flag: 'email'
3010
- }
3011
- | {
3012
- flag: 'unique'
3013
- }
3014
- | {
3015
- flag: 'reference'
3016
- }
3017
- | {
3018
- flag: 'type'
3019
- constraint: RuleTypeConstraint
3020
- }
3021
- | {
3022
- flag: 'all'
3023
- constraint: Rule[]
3024
- }
3025
- | {
3026
- flag: 'either'
3027
- constraint: Rule[]
3028
- }
3029
- | {
3030
- flag: 'presence'
3031
- constraint: 'optional' | 'required'
3032
- }
3033
- | {
3034
- flag: 'custom'
3035
- constraint: CustomValidator
3036
- }
3037
- | {
3038
- flag: 'min'
3039
- constraint: number | string | FieldReference
3040
- }
3041
- | {
3042
- flag: 'max'
3043
- constraint: number | string | FieldReference
3044
- }
3045
- | {
3046
- flag: 'length'
3047
- constraint: number | FieldReference
3048
- }
3049
- | {
3050
- flag: 'valid'
3051
- constraint: unknown[]
3052
- }
3053
- | {
3054
- flag: 'precision'
3055
- constraint: number | FieldReference
3056
- }
3057
- | {
3058
- flag: 'lessThan'
3059
- constraint: number | FieldReference
3060
- }
3061
- | {
3062
- flag: 'greaterThan'
3063
- constraint: number | FieldReference
3064
- }
3065
- | {
3066
- flag: 'stringCasing'
3067
- constraint: 'uppercase' | 'lowercase'
3068
- }
3069
- | {
3070
- flag: 'assetRequired'
3071
- constraint: {
3072
- assetType: 'asset' | 'image' | 'file'
3073
- }
3074
- }
3075
- | {
3076
- flag: 'media'
3077
- constraint: MediaValidator<any>
3078
- }
3079
- | {
3080
- flag: 'regex'
3081
- constraint: {
3082
- pattern: RegExp
3083
- name?: string
3084
- invert: boolean
3085
- }
3086
- }
3087
- | {
3088
- flag: 'uri'
3089
- constraint: {
3090
- options: {
3091
- scheme: RegExp[]
3092
- allowRelative: boolean
3093
- relativeOnly: boolean
3094
- allowCredentials: boolean
3095
- }
3096
- }
3097
- }
3098
-
3099
- /** @internal */
3100
- export declare type RuleSpecConstraint<T extends RuleSpec['flag']> = ConditionalIndexAccess<
3101
- Extract<
3102
- RuleSpec,
3103
- {
3104
- flag: T
3105
- }
3106
- >,
3107
- 'constraint'
3108
- >
3109
-
3110
- /** @public */
3111
- export declare type RuleTypeConstraint =
3112
- | 'Array'
3113
- | 'Boolean'
3114
- | 'Date'
3115
- | 'Number'
3116
- | 'Object'
3117
- | 'String'
3118
-
3119
- /**
3120
- * Options for configuring how Sanity Create interfaces with the type or field.
3121
- *
3122
- * @public
3123
- */
3124
- export declare interface SanityCreateOptions {
3125
- /** Set to true to exclude a type or field from appearing in Sanity Create */
3126
- exclude?: boolean
3127
- /**
3128
- * A short description of what the type or field is used for.
3129
- * Purpose can be used to improve how and when content mapping uses the field.
3130
- * */
3131
- purpose?: string
3132
- }
3133
-
3134
- /** @public */
3135
- export declare interface SanityDocument {
3136
- _id: string
3137
- _type: string
3138
- _createdAt: string
3139
- _updatedAt: string
3140
- _rev: string
3141
- [key: string]: unknown
3142
- }
3143
-
3144
- /**
3145
- * Similar to `SanityDocument` but only requires the `_id` and `_type`
3146
- *
3147
- * @see SanityDocument
3148
- *
3149
- * @public
3150
- */
3151
- export declare interface SanityDocumentLike {
3152
- _id: string
3153
- _type: string
3154
- _createdAt?: string
3155
- _updatedAt?: string
3156
- _rev?: string
3157
- _system?: {
3158
- delete?: boolean
3159
- }
3160
- [key: string]: unknown
3161
- }
3162
-
3163
- /** @public */
3164
- export declare interface Schema {
3165
- /** @internal */
3166
- _original?: {
3167
- name: string
3168
- types: SchemaTypeDefinition[]
3169
- }
3170
- /** @internal */
3171
- _registry: {
3172
- [typeName: string]: any
3173
- }
3174
- /** @internal */
3175
- _validation?: SchemaValidationProblemGroup[]
3176
- name: string
3177
- get: (name: string) => SchemaType | undefined
3178
- has: (name: string) => boolean
3179
- getTypeNames: () => string[]
3180
- /**
3181
- * Returns the types which were explicitly defined in this schema,
3182
- * as opposed to the types which were inherited from the parent.
3183
- */
3184
- getLocalTypeNames: () => string[]
3185
- /**
3186
- * Returns the parent schema.
3187
- */
3188
- parent?: Schema
3189
- }
3190
-
3191
- /**
3192
- * Note: you probably want `SchemaTypeDefinition` instead
3193
- * @see SchemaTypeDefinition
3194
- *
3195
- * @public
3196
- */
3197
- export declare type SchemaType =
3198
- | ArraySchemaType
3199
- | BooleanSchemaType
3200
- | FileSchemaType
3201
- | NumberSchemaType
3202
- | ObjectSchemaType
3203
- | StringSchemaType
3204
- | ReferenceSchemaType
3205
-
3206
- /**
3207
- * Represents a Sanity schema type definition with an optional type parameter.
3208
- *
3209
- * It's recommend to use the `defineType` helper instead of this type by
3210
- * itself.
3211
- *
3212
- * @see defineType
3213
- *
3214
- * @public
3215
- */
3216
- export declare type SchemaTypeDefinition<TType extends IntrinsicTypeName = IntrinsicTypeName> =
3217
- | IntrinsicDefinitions[IntrinsicTypeName]
3218
- | TypeAliasDefinition<string, TType>
3219
-
3220
- /** @public */
3221
- export declare interface SchemaValidationError {
3222
- helpId?: string
3223
- message: string
3224
- severity: 'error'
3225
- }
3226
-
3227
- /** @internal */
3228
- export declare type SchemaValidationProblem = SchemaValidationError | SchemaValidationWarning
3229
-
3230
- /** @internal */
3231
- export declare interface SchemaValidationProblemGroup {
3232
- path: SchemaValidationProblemPath
3233
- problems: SchemaValidationProblem[]
3234
- }
3235
-
3236
- /** @internal */
3237
- export declare type SchemaValidationProblemPath = Array<
3238
- | {
3239
- kind: 'type'
3240
- type: string
3241
- name?: string
3242
- }
3243
- | {
3244
- kind: 'property'
3245
- name: string
3246
- }
3247
- >
3248
-
3249
- /**
3250
- * Represents the possible values of a schema type's `validation` field.
3251
- *
3252
- * If the schema has not been run through `inferFromSchema` from
3253
- * `sanity/validation` then value could be a function.
3254
- *
3255
- * `inferFromSchema` mutates the schema converts this value to an array of
3256
- * `Rule` instances.
3257
- *
3258
- * @privateRemarks
3259
- *
3260
- * Usage of the schema inside the studio will almost always be from the compiled
3261
- * `createSchema` function. In this case, you can cast the value or throw to
3262
- * narrow the type. E.g.:
3263
- *
3264
- * ```ts
3265
- * if (typeof type.validation === 'function') {
3266
- * throw new Error(
3267
- * `Schema type "${type.name}"'s \`validation\` was not run though \`inferFromSchema\``
3268
- * )
3269
- * }
3270
- * ```
3271
- *
3272
- * @public
3273
- */
3274
- export declare type SchemaValidationValue =
3275
- | false
3276
- | undefined
3277
- | Rule
3278
- | SchemaValidationValue[]
3279
- | ((rule: Rule) => SchemaValidationValue)
3280
-
3281
- /** @internal */
3282
- export declare interface SchemaValidationWarning {
3283
- helpId?: string
3284
- message: string
3285
- severity: 'warning'
3286
- }
3287
-
3288
- /** @public */
3289
- export declare interface SearchConfiguration {
3290
- search?: {
3291
- /**
3292
- * Defines a search weight for this field to prioritize its importance
3293
- * during search operations in the Studio. This setting allows the specified
3294
- * field to be ranked higher in search results compared to other fields.
3295
- *
3296
- * By default, all fields are assigned a weight of 1. However, if a field is
3297
- * chosen as the `title` in the preview configuration's `select` option, it
3298
- * will automatically receive a default weight of 10. Similarly, if selected
3299
- * as the `subtitle`, the default weight is 5. Fields marked as
3300
- * `hidden: true` (no function) are assigned a weight of 0 by default.
3301
- *
3302
- * Note: Search weight configuration is currently supported only for fields
3303
- * of type string or portable text arrays.
3304
- */
3305
- weight?: number
3306
- }
3307
- }
3308
-
3309
- /**
3310
- * @public
3311
- */
3312
- export declare const searchStrategies: readonly ['groqLegacy', 'groq2024']
3313
-
3314
- /**
3315
- * @public
3316
- */
3317
- export declare type SearchStrategy = (typeof searchStrategies)[number]
3318
-
3319
- /** @public */
3320
- export declare interface SingleFieldSet {
3321
- single: true
3322
- field: ObjectField
3323
- hidden?: ConditionalProperty
3324
- readOnly?: ConditionalProperty
3325
- group?: string | string[]
3326
- }
3327
-
3328
- /** @internal */
3329
- export declare interface SingleMutationResult {
3330
- transactionId: string
3331
- documentId: string
3332
- results: {
3333
- id: string
3334
- }[]
3335
- }
3336
-
3337
- /**
3338
- * A slug object, currently holding a `current` property
3339
- *
3340
- * In the future, this may be extended with a `history` property
3341
- *
3342
- * @public
3343
- */
3344
- export declare interface Slug {
3345
- _type: 'slug'
3346
- current: string
3347
- }
3348
-
3349
- /** @public */
3350
- export declare interface SlugDefinition extends BaseSchemaDefinition {
3351
- type: 'slug'
3352
- options?: SlugOptions
3353
- validation?: ValidationBuilder<SlugRule, SlugValue>
3354
- initialValue?: InitialValueProperty<any, Omit<SlugValue, '_type'>>
3355
- }
3356
-
3357
- /** @public */
3358
- export declare type SlugifierFn = (
3359
- source: string,
3360
- schemaType: SlugSchemaType,
3361
- context: SlugSourceContext,
3362
- ) => string | Promise<string>
3363
-
3364
- /** @public */
3365
- export declare type SlugIsUniqueValidator = (
3366
- slug: string,
3367
- context: SlugValidationContext,
3368
- ) => boolean | Promise<boolean>
3369
-
3370
- /** @public */
3371
- export declare interface SlugOptions extends SearchConfiguration, BaseSchemaTypeOptions {
3372
- source?: string | Path | SlugSourceFn
3373
- maxLength?: number
3374
- slugify?: SlugifierFn
3375
- isUnique?: SlugIsUniqueValidator
3376
- disableArrayWarning?: boolean
3377
- }
3378
-
3379
- /** @public */
3380
- export declare type SlugParent = Record<string, unknown> | Record<string, unknown>[]
3381
-
3382
- /** @public */
3383
- export declare interface SlugRule extends RuleDef<SlugRule, SlugValue> {}
3384
-
3385
- /** @public */
3386
- export declare interface SlugSchemaType extends ObjectSchemaType {
3387
- jsonType: 'object'
3388
- options?: SlugOptions
3389
- }
3390
-
3391
- /** @public */
3392
- export declare interface SlugSourceContext {
3393
- parentPath: Path
3394
- parent: SlugParent
3395
- projectId: string
3396
- dataset: string
3397
- schema: Schema
3398
- currentUser: CurrentUser | null
3399
- getClient: (options: {apiVersion: string}) => SanityClient
3400
- }
3401
-
3402
- /** @public */
3403
- export declare type SlugSourceFn = (
3404
- document: SanityDocument,
3405
- context: SlugSourceContext,
3406
- ) => string | Promise<string>
3407
-
3408
- /** @public */
3409
- export declare interface SlugValidationContext extends ValidationContext {
3410
- parent: SlugParent
3411
- type: SlugSchemaType
3412
- defaultIsUnique: SlugIsUniqueValidator
3413
- }
3414
-
3415
- /** @public */
3416
- export declare interface SlugValue {
3417
- _type: 'slug'
3418
- current?: string
3419
- }
3420
-
3421
- /** @beta */
3422
- export declare type SortOrdering = {
3423
- title: string
3424
- i18n?: I18nTextRecord<'title'>
3425
- name: string
3426
- by: SortOrderingItem[]
3427
- }
3428
-
3429
- /** @beta */
3430
- export declare interface SortOrderingItem {
3431
- field: string
3432
- direction: 'asc' | 'desc'
3433
- }
3434
-
3435
- /**
3436
- * A specific `ObjectField` for `marks` in `SpanSchemaType`
3437
- * @see SpanSchemaType
3438
- *
3439
- * @internal
3440
- */
3441
- export declare type SpanMarksObjectField = {
3442
- name: 'marks'
3443
- } & ObjectField<ArraySchemaTypeOf<StringSchemaType>>
3444
-
3445
- /**
3446
- * Represents the compiled schema shape for `span`s for portable text.
3447
- *
3448
- * Note: this does _not_ represent the schema definition shape.
3449
- *
3450
- * @internal
3451
- */
3452
- export declare interface SpanSchemaType extends Omit<ObjectSchemaType, 'fields'> {
3453
- annotations: (ObjectSchemaType & {
3454
- icon?: string | ComponentType
3455
- components?: {
3456
- item?: ComponentType
3457
- }
3458
- })[]
3459
- decorators: BlockDecoratorDefinition[]
3460
- fields: [SpanMarksObjectField, SpanTextObjectField]
3461
- }
3462
-
3463
- /**
3464
- * A specific `ObjectField` for `text` in `SpanSchemaType`
3465
- * @see SpanSchemaType
3466
- *
3467
- * @internal
3468
- */
3469
- export declare type SpanTextObjectField = {
3470
- name: 'text'
3471
- } & ObjectField<TextSchemaType>
3472
-
3473
- /** @beta */
3474
- export declare type StrictDefinition = boolean | undefined
3475
-
3476
- /**
3477
- * @internal
3478
- */
3479
- export declare interface StrictVersionLayeringOptions {
3480
- /**
3481
- * By default, version layering includes all document versions, regardless of their expected
3482
- * publication time—or lack thereof. For example, it includes all ASAP and undecided versions,
3483
- * despite ASAP and undecided versions having no fixed chronology. There is no way to determine
3484
- * which ASAP or undecided version is expected to be published before another.
3485
- *
3486
- * It also includes any existing draft, which has no fixed chronology, either.
3487
- *
3488
- * This functionality is useful for listing all document versions in a deterministic order, but
3489
- * doesn't accurately portray the upstream and downstream versions based on expected publication
3490
- * time.
3491
- *
3492
- * In strict mode, version layering instead only includes versions that have a fixed chronology.
3493
- * **Cross-version layering is only effective for scheduled versions, with all other
3494
- * versions being layered directly onto the published version (if it exists).**
3495
- */
3496
- strict?: boolean
3497
- }
3498
-
3499
- /** @public */
3500
- export declare interface StringDefinition extends BaseSchemaDefinition {
3501
- type: 'string'
3502
- options?: StringOptions
3503
- placeholder?: string
3504
- validation?: ValidationBuilder<StringRule, string>
3505
- initialValue?: InitialValueProperty<any, string>
3506
- }
3507
-
3508
- /** @public */
3509
- export declare interface StringOptions
3510
- extends EnumListProps<string>,
3511
- SearchConfiguration,
3512
- BaseSchemaTypeOptions {}
3513
-
3514
- /** @public */
3515
- export declare interface StringRule extends RuleDef<StringRule, string> {
3516
- min: (minNumber: number | FieldReference) => StringRule
3517
- max: (maxNumber: number | FieldReference) => StringRule
3518
- length: (exactLength: number | FieldReference) => StringRule
3519
- uppercase: () => StringRule
3520
- lowercase: () => StringRule
3521
- regex(
3522
- pattern: RegExp,
3523
- name: string,
3524
- options: {
3525
- name?: string
3526
- invert?: boolean
3527
- },
3528
- ): StringRule
3529
- regex(
3530
- pattern: RegExp,
3531
- options: {
3532
- name?: string
3533
- invert?: boolean
3534
- },
3535
- ): StringRule
3536
- regex(pattern: RegExp, name: string): StringRule
3537
- regex(pattern: RegExp): StringRule
3538
- email(): StringRule
3539
- }
3540
-
3541
- /**
3542
- * This is used for string, text, date and datetime.
3543
- * This interface represent the compiled version at runtime, when accessed through Schema.
3544
- *
3545
- * @public
3546
- */
3547
- export declare interface StringSchemaType extends BaseSchemaType {
3548
- jsonType: 'string'
3549
- options?: StringOptions & TextOptions & DateOptions & DatetimeOptions
3550
- initialValue?: InitialValueProperty<any, string>
3551
- }
3552
-
3553
- /**
3554
- * @internal
3555
- * Payload that will be passed by the comments backend to our notifications system to display the notification in dashboard.
3556
- * */
3557
- export declare interface StudioNotificationPayload extends DashboardNotificationPayload {
3558
- applicationType: 'studio'
3559
- applicationId: string | undefined
3560
- workspaceName: string | undefined
3561
- link: {
3562
- type: 'url'
3563
- url: string
3564
- }
3565
- }
3566
-
3567
- /** @public */
3568
- export declare type SwatchName =
3569
- | 'darkMuted'
3570
- | 'darkVibrant'
3571
- | 'dominant'
3572
- | 'lightMuted'
3573
- | 'lightVibrant'
3574
- | 'muted'
3575
- | 'vibrant'
3576
-
3577
- /** @public */
3578
- export declare interface TextDefinition extends BaseSchemaDefinition {
3579
- type: 'text'
3580
- rows?: number
3581
- options?: TextOptions
3582
- placeholder?: string
3583
- validation?: ValidationBuilder<TextRule, string>
3584
- initialValue?: InitialValueProperty<any, string>
3585
- }
3586
-
3587
- /** @public */
3588
- export declare interface TextOptions extends StringOptions {}
3589
-
3590
- /** @public */
3591
- export declare interface TextRule extends StringRule {}
3592
-
3593
- /** @public */
3594
- export declare interface TextSchemaType extends StringSchemaType {
3595
- rows?: number
3596
- }
3597
-
3598
- /** @public */
3599
- export declare interface TitledListValue<V = unknown> {
3600
- _key?: string
3601
- title: string
3602
- value?: V
3603
- }
3604
-
3605
- /**
3606
- * An entry in the transaction log
3607
- *
3608
- * @internal
3609
- */
3610
- export declare interface TransactionLogEvent {
3611
- /**
3612
- * ID of transaction
3613
- */
3614
- id: string
3615
- /**
3616
- * ISO-formatted timestamp (zulu-time) of when the transaction happened
3617
- */
3618
- timestamp: string
3619
- /**
3620
- * User ID of the user who performed the transaction
3621
- */
3622
- author: string
3623
- /**
3624
- * Document IDs involved in this transaction
3625
- */
3626
- documentIDs: string[]
3627
- }
3628
-
3629
- /**
3630
- * An entry in the transaction log that includes the effects of the transaction.
3631
- * Used when asking the transaction log to include effects in mendoza format,
3632
- * eg `?effectFormat=mendoza`
3633
- *
3634
- * @internal
3635
- */
3636
- export declare interface TransactionLogEventWithEffects extends TransactionLogEvent {
3637
- /**
3638
- * Object of effects, where the key is the document ID affected and the value
3639
- * is the effect pair, eg `{apply: MendozaPatch, revert: MendozaPatch}`
3640
- */
3641
- effects: Record<string, MendozaEffectPair | undefined>
3642
- }
3643
-
3644
- /**
3645
- * An entry in the transaction log that includes the mutations that were performed.
3646
- * Used when asking the transaction log not to exclude the mutations,
3647
- * eg `excludeMutations=false`
3648
- *
3649
- * @internal
3650
- */
3651
- export declare interface TransactionLogEventWithMutations extends TransactionLogEvent {
3652
- /**
3653
- * Array of mutations that occurred in this transaction. Note that the transaction
3654
- * log has an additional mutation type not typically seen in other APIs;
3655
- * `createSquashed` ({@link CreateSquashedMutation}).
3656
- */
3657
- mutations: TransactionLogMutation[]
3658
- }
3659
-
3660
- /**
3661
- * A mutation that can occur in the transaction log, which includes the
3662
- * {@link CreateSquashedMutation} mutation type.
3663
- *
3664
- * @internal
3665
- */
3666
- export declare type TransactionLogMutation = Mutation | CreateSquashedMutation
3667
-
3668
- /**
3669
- * Represents a type definition that is an alias/extension of an existing type
3670
- * in your schema. Creating a type alias will re-register that existing type
3671
- * under a different name. You can also override the default type options with
3672
- * a type alias definition.
3673
- *
3674
- * @public
3675
- */
3676
- export declare interface TypeAliasDefinition<
3677
- TType extends string,
3678
- TAlias extends IntrinsicTypeName | undefined,
3679
- > extends BaseSchemaDefinition {
3680
- type: TType
3681
- options?: TAlias extends IntrinsicTypeName ? IntrinsicDefinitions[TAlias]['options'] : unknown
3682
- validation?: SchemaValidationValue
3683
- initialValue?: InitialValueProperty<any, any>
3684
- preview?: PreviewConfig
3685
- components?: {
3686
- annotation?: ComponentType<any>
3687
- block?: ComponentType<any>
3688
- inlineBlock?: ComponentType<any>
3689
- diff?: ComponentType<any>
3690
- field?: ComponentType<any>
3691
- input?: ComponentType<any>
3692
- item?: ComponentType<any>
3693
- preview?: ComponentType<any>
3694
- }
3695
- }
3696
-
3697
- /**
3698
- * `typed` can be used to ensure that an object conforms to an exact interface.
3699
- *
3700
- * It can be useful when working with `defineType` and `defineField` on occasions where a wider type with
3701
- * custom options or properties is required.
3702
- *
3703
- * ## Example usage
3704
- * ```ts
3705
- * defineField({
3706
- * type: 'string',
3707
- * name: 'nestedField',
3708
- * options: typed<StringOptions & {myCustomOption: boolean}>({
3709
- * layout: 'radio',
3710
- * // allowed
3711
- * myCustomOption: true,
3712
- * //@ts-expect-error unknownProp is not part of StringOptions & {myCustomOption: boolean}
3713
- * unknownProp: 'not allowed in typed context',
3714
- * }),
3715
- * }),
3716
- * ```
3717
- *
3718
- * @param input - returned directly
3719
- *
3720
- * @internal
3721
- */
3722
- export declare function typed<T>(input: T): T
3723
-
3724
- /** @public */
3725
- export declare interface TypedObject {
3726
- [key: string]: unknown
3727
- _type: string
3728
- }
3729
-
3730
- /**
3731
- * Represents a reference to another type registered top-level in your schema.
3732
- *
3733
- * @public
3734
- */
3735
- export declare interface TypeReference {
3736
- type: string
3737
- name?: string
3738
- icon?: ComponentType | ReactNode
3739
- options?: {
3740
- [key: string]: unknown
3741
- }
3742
- }
3743
-
3744
- /** @internal */
3745
- export declare interface UploadState {
3746
- progress: number
3747
- /** @deprecated use createdAt instead */
3748
- initiated?: string
3749
- /** @deprecated use updatedAt instead */
3750
- updated?: string
3751
- createdAt: string
3752
- updatedAt: string
3753
- file: {
3754
- name: string
3755
- type: string
3756
- }
3757
- previewImage?: string
3758
- }
3759
-
3760
- /** @public */
3761
- export declare interface UriValidationOptions {
3762
- scheme?: (string | RegExp) | Array<string | RegExp>
3763
- allowRelative?: boolean
3764
- relativeOnly?: boolean
3765
- allowCredentials?: boolean
3766
- }
3767
-
3768
- /** @public */
3769
- export declare interface UrlDefinition extends BaseSchemaDefinition {
3770
- type: 'url'
3771
- options?: UrlOptions
3772
- placeholder?: string
3773
- validation?: ValidationBuilder<UrlRule, string>
3774
- initialValue?: InitialValueProperty<any, string>
3775
- }
3776
-
3777
- /** @public */
3778
- export declare interface UrlOptions extends BaseSchemaTypeOptions {}
3779
-
3780
- /** @public */
3781
- export declare interface UrlRule extends RuleDef<UrlRule, string> {
3782
- uri(options: UriValidationOptions): UrlRule
3783
- }
3784
-
3785
- /** @public */
3786
- export declare interface User {
3787
- id: string
3788
- displayName?: string
3789
- imageUrl?: string
3790
- email?: string
3791
- }
3792
-
3793
- /** @public */
3794
- export declare type ValidationBuilder<T extends RuleDef<T, FieldValue>, FieldValue = unknown> = (
3795
- rule: T,
3796
- ) => RuleBuilder<T, FieldValue>
3797
-
3798
- /**
3799
- * A context object passed around during validation. This includes the
3800
- * `Rule.custom` context.
3801
- *
3802
- * e.g.
3803
- *
3804
- * ```js
3805
- * Rule.custom((_, validationContext) => {
3806
- * // ...
3807
- * })`
3808
- * ```
3809
- *
3810
- * @public
3811
- */
3812
- export declare interface ValidationContext {
3813
- getClient: (options: {apiVersion: string}) => SanityClient
3814
- schema: Schema
3815
- parent?: unknown
3816
- type?: SchemaType
3817
- document?: SanityDocument
3818
- path?: Path
3819
- getDocumentExists?: (options: {id: string}) => Promise<boolean>
3820
- environment: 'cli' | 'studio'
3821
- }
3822
-
3823
- /**
3824
- * The shape that can be returned from a custom validator to be converted into
3825
- * a validation marker by the validation logic. Inside of a custom validator,
3826
- * you can return an array of these in order to specify multiple paths within
3827
- * an object or array.
3828
- *
3829
- * @public
3830
- */
3831
- export declare interface ValidationError {
3832
- /**
3833
- * The message describing why the value is not valid. This message will be
3834
- * included in the validation markers after validation has finished running.
3835
- */
3836
- message: string
3837
- /**
3838
- * If writing a custom validator, you can return validation messages to
3839
- * specific path inside of the current value (object or array) by populating
3840
- * this `path` prop.
3841
- *
3842
- * NOTE: This path is relative to the current value and _not_ relative to
3843
- * the document.
3844
- */
3845
- path?: Path
3846
- /**
3847
- * Extra metadata for the validation error. Currently used by the Media Library asset source to ignore
3848
- * certain validation markers when validating asset source media library assets.
3849
- *
3850
- * @internal
3851
- */
3852
- __internal_metadata?: unknown
3853
- /**
3854
- * Same as `path` but allows more than one value. If provided, the same
3855
- * message will create two markers from each path with the same message
3856
- * provided.
3857
- *
3858
- * @deprecated prefer `path`
3859
- */
3860
- paths?: Path[]
3861
- /**
3862
- * @deprecated Unused. Was used to store the results from `.either()` /`.all()`
3863
- */
3864
- children?: ValidationMarker[]
3865
- /**
3866
- * @deprecated Unused. Was used to signal if this error came from an `.either()`/`.all()`.
3867
- */
3868
- operation?: 'AND' | 'OR'
3869
- /**
3870
- * @deprecated Unused. Was relevant when validation error was used as a class.
3871
- */
3872
- cloneWithMessage?(message: string): ValidationError
3873
- }
3874
-
3875
- /**
3876
- * This follows the same pattern as `RuleClass` and `Rule` above
3877
- * Note: this class does not actually extend `Error` since it's never thrown
3878
- * within the validation library
3879
- *
3880
- * @deprecated It is preferred to a plain object that adheres to `ValidationError`
3881
- * @internal
3882
- */
3883
- export declare interface ValidationErrorClass {
3884
- new (message: string, options?: ValidationErrorOptions): ValidationError
3885
- }
3886
-
3887
- /** @internal */
3888
- export declare interface ValidationErrorOptions {
3889
- paths?: Path[]
3890
- children?: ValidationMarker[]
3891
- operation?: 'AND' | 'OR'
3892
- }
3893
-
3894
- /** @public */
3895
- export declare interface ValidationMarker {
3896
- level: 'error' | 'warning' | 'info'
3897
- /**
3898
- * The validation message for this marker. E.g. "Must be greater than 0"
3899
- */
3900
- message: string
3901
- /**
3902
- * @deprecated use `message` instead
3903
- */
3904
- item?: ValidationError
3905
- /**
3906
- * The sanity path _relative to the root of the current document_ to this
3907
- * marker.
3908
- *
3909
- * NOTE: Sanity paths may contain keyed segments (i.e. `{_key: string}`) that
3910
- * are not compatible with deep getters like lodash/get
3911
- */
3912
- path: Path
3913
- /**
3914
- * Extra metadata for the validation marker. Currently used by the Media Library asset source to ignore
3915
- * certain validation markers when validating asset source media library assets.
3916
- *
3917
- * @internal
3918
- */
3919
- __internal_metadata?: unknown
3920
- }
3921
-
3922
- /**
3923
- * The base type for all validators in the validation library. Takes in a
3924
- * `RuleSpec`'s constraint, the value to check, an optional override message,
3925
- * and the validation context.
3926
- *
3927
- * @see Rule.validate from `sanity/src/core/validation/Rule`
3928
- *
3929
- * @internal
3930
- */
3931
- export declare type Validator<T = any, Value = any> = (
3932
- constraint: T,
3933
- value: Value,
3934
- message: string | undefined,
3935
- context: ValidationContext,
3936
- ) =>
3937
- | ValidationError[]
3938
- | ValidationError
3939
- | string
3940
- | true
3941
- | Promise<ValidationError[] | ValidationError | string | true>
3942
-
3943
- /**
3944
- * A type helper used to define a group of validators. The type of the
3945
- * `RuleSpec` constraint is inferred via the key.
3946
- *
3947
- * E.g.
3948
- *
3949
- * ```ts
3950
- * const booleanValidators: Validators = {
3951
- * ...genericValidator,
3952
- *
3953
- * presence: (v, value, message) => {
3954
- * if (v === 'required' && typeof value !== 'boolean') return message || 'Required'
3955
- * return true
3956
- * },
3957
- * }
3958
- * ```
3959
- *
3960
- * @internal
3961
- */
3962
- export declare type Validators = Partial<{
3963
- [P in RuleSpec['flag']]: Validator<
3964
- Exclude<
3965
- ConditionalIndexAccess<
3966
- Extract<
3967
- RuleSpec,
3968
- {
3969
- flag: P
3970
- }
3971
- >,
3972
- 'constraint'
3973
- >,
3974
- FieldReference
3975
- >
3976
- >
3977
- }>
3978
-
3979
- /** @beta */
3980
- export declare interface WeakCrossDatasetReferenceValue extends CrossDatasetReferenceValue {
3981
- _weak: true
3982
- }
3983
-
3984
- /** @beta */
3985
- export declare interface WeakGlobalDocumentReferenceValue extends GlobalDocumentReferenceValue {
3986
- _weak: true
3987
- }
3988
-
3989
- /** @internal */
3990
- export declare interface WeakReference extends Reference {
3991
- _weak: true
3992
- }
3993
-
3994
- /** @beta */
3995
- export declare interface WidenInitialValue {
3996
- initialValue?: InitialValueProperty<any, any>
3997
- }
3998
-
3999
- /** @beta */
4000
- export declare interface WidenValidation {
4001
- validation?: SchemaValidationValue
4002
- }
4003
-
4004
- export {}