@sanity/media-library-types 1.6.0 → 1.7.0

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