@portabletext/editor 1.48.7 → 1.48.8
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/_chunks-cjs/behavior.core.cjs +20 -8
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +5 -5
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +121 -90
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +7 -4
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +63 -47
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -23
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +15 -15
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +258 -38
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +21 -10
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/behavior.markdown.js +5 -6
- package/lib/_chunks-es/behavior.markdown.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +75 -46
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -2
- package/lib/_chunks-es/selector.get-focus-inline-object.js.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +7 -4
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/selector.is-overlapping-selection.js +61 -46
- package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +30 -26
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js +15 -16
- package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +258 -38
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/behaviors/index.d.cts +2552 -251
- package/lib/behaviors/index.d.ts +2552 -251
- package/lib/index.cjs +45 -21
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2350 -51
- package/lib/index.d.ts +2350 -51
- package/lib/index.js +44 -21
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +16 -7
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +2324 -24
- package/lib/plugins/index.d.ts +2324 -24
- package/lib/plugins/index.js +16 -7
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +5 -5
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +2321 -28
- package/lib/selectors/index.d.ts +2321 -28
- package/lib/selectors/index.js +5 -6
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +30 -24
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +2350 -44
- package/lib/utils/index.d.ts +2350 -44
- package/lib/utils/index.js +30 -24
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/behavior-actions/behavior.action.block.unset.ts +1 -1
- package/src/behavior-actions/behavior.action.decorator.add.ts +20 -5
- package/src/behaviors/behavior.abstract.decorator.ts +1 -1
- package/src/behaviors/behavior.abstract.delete.ts +1 -1
- package/src/behaviors/behavior.abstract.insert.ts +2 -2
- package/src/behaviors/behavior.abstract.select.ts +16 -4
- package/src/behaviors/behavior.abstract.split.ts +9 -6
- package/src/behaviors/behavior.core.block-objects.ts +5 -5
- package/src/behaviors/behavior.core.insert-break.ts +16 -4
- package/src/behaviors/behavior.core.lists.ts +4 -6
- package/src/behaviors/behavior.decorator-pair.ts +13 -4
- package/src/behaviors/behavior.default.ts +1 -1
- package/src/behaviors/behavior.markdown.ts +5 -5
- package/src/converters/converter.portable-text.ts +1 -1
- package/src/converters/converter.text-html.ts +1 -1
- package/src/converters/converter.text-plain.ts +4 -4
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +10 -2
- package/src/editor/plugins/createWithSchemaTypes.ts +12 -19
- package/src/internal-utils/__tests__/dmpToOperations.test.ts +13 -12
- package/src/internal-utils/drag-selection.ts +16 -4
- package/src/internal-utils/event-position.ts +20 -8
- package/src/internal-utils/parse-blocks.ts +17 -5
- package/src/internal-utils/validateValue.ts +6 -6
- package/src/plugins/plugin.decorator-shortcut.ts +2 -2
- package/src/selectors/selector.get-active-annotations.ts +5 -2
- package/src/selectors/selector.get-active-list-item.ts +4 -3
- package/src/selectors/selector.get-active-style.ts +4 -3
- package/src/selectors/selector.get-anchor-text-block.ts +3 -6
- package/src/selectors/selector.get-block-offsets.ts +2 -2
- package/src/selectors/selector.get-caret-word-selection.ts +11 -5
- package/src/selectors/selector.get-selected-slice.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +11 -15
- package/src/selectors/selector.get-selected-text-blocks.ts +3 -3
- package/src/selectors/selector.get-selection-text.ts +3 -3
- package/src/selectors/selector.get-text-before.ts +5 -2
- package/src/selectors/selector.get-trimmed-selection.ts +20 -14
- package/src/selectors/selector.is-active-annotation.ts +4 -2
- package/src/selectors/selector.is-active-decorator.test.ts +3 -3
- package/src/selectors/selector.is-at-the-end-of-block.ts +4 -1
- package/src/selectors/selector.is-at-the-start-of-block.ts +4 -1
- package/src/selectors/selector.is-point-after-selection.ts +7 -6
- package/src/selectors/selector.is-point-before-selection.ts +7 -6
- package/src/selectors/selector.is-selecting-entire-blocks.ts +8 -2
- package/src/selectors/selectors.ts +25 -28
- package/src/utils/util.block-offset-to-block-selection-point.ts +4 -4
- package/src/utils/util.block-offset-to-selection-point.ts +5 -5
- package/src/utils/util.block-offset.test.ts +219 -156
- package/src/utils/util.block-offset.ts +14 -17
- package/src/utils/util.block-offsets-to-selection.ts +5 -5
- package/src/utils/util.child-selection-point-to-block-offset.ts +7 -10
- package/src/utils/util.get-block-end-point.ts +15 -15
- package/src/utils/util.get-block-start-point.ts +13 -12
- package/src/utils/util.is-empty-text-block.ts +9 -8
- package/src/utils/util.selection-point-to-block-offset.ts +4 -4
- package/src/utils/util.slice-blocks.test.ts +178 -121
- package/src/utils/util.slice-blocks.ts +25 -24
- package/src/utils/util.split-text-block.ts +18 -12
- package/lib/_chunks-cjs/parse-blocks.cjs +0 -205
- package/lib/_chunks-cjs/parse-blocks.cjs.map +0 -1
- package/lib/_chunks-es/parse-blocks.js +0 -206
- package/lib/_chunks-es/parse-blocks.js.map +0 -1
- package/src/behavior-actions/behavior.guards.ts +0 -24
package/lib/selectors/index.d.ts
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import type {KeyedSegment as KeyedSegment_2, Patch} from '@portabletext/patches'
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
BlockDecoratorDefinition,
|
|
5
|
-
BlockListDefinition,
|
|
6
|
-
BlockStyleDefinition,
|
|
7
|
-
ObjectSchemaType,
|
|
8
|
-
Path,
|
|
9
|
-
PortableTextChild,
|
|
10
|
-
} from '@sanity/types'
|
|
11
|
-
import {
|
|
12
|
-
KeyedSegment,
|
|
13
|
-
PortableTextBlock,
|
|
14
|
-
PortableTextListBlock,
|
|
15
|
-
PortableTextObject,
|
|
16
|
-
PortableTextSpan,
|
|
17
|
-
PortableTextTextBlock,
|
|
18
|
-
} from '@sanity/types'
|
|
2
|
+
import {ClientPerspective, SanityClient} from '@sanity/client'
|
|
3
|
+
import {ComponentType, ElementType, ReactNode} from 'react'
|
|
19
4
|
import type {
|
|
20
5
|
FocusEvent as FocusEvent_2,
|
|
21
6
|
KeyboardEvent as KeyboardEvent_2,
|
|
@@ -216,6 +201,277 @@ declare const abstractBehaviorEventTypes: readonly [
|
|
|
216
201
|
'style.toggle',
|
|
217
202
|
]
|
|
218
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Types of array actions that can be performed
|
|
206
|
+
* @beta
|
|
207
|
+
*/
|
|
208
|
+
declare type ArrayActionName =
|
|
209
|
+
/**
|
|
210
|
+
* Add any item to the array at any position
|
|
211
|
+
*/
|
|
212
|
+
| 'add'
|
|
213
|
+
/**
|
|
214
|
+
* Add item after an existing item
|
|
215
|
+
*/
|
|
216
|
+
| 'addBefore'
|
|
217
|
+
/**
|
|
218
|
+
* Add item after an existing item
|
|
219
|
+
*/
|
|
220
|
+
| 'addAfter'
|
|
221
|
+
/**
|
|
222
|
+
* Remove any item
|
|
223
|
+
*/
|
|
224
|
+
| 'remove'
|
|
225
|
+
/**
|
|
226
|
+
* Duplicate item
|
|
227
|
+
*/
|
|
228
|
+
| 'duplicate'
|
|
229
|
+
/**
|
|
230
|
+
* Copy item
|
|
231
|
+
*/
|
|
232
|
+
| 'copy'
|
|
233
|
+
|
|
234
|
+
/** @public */
|
|
235
|
+
declare interface ArrayDefinition extends BaseSchemaDefinition {
|
|
236
|
+
type: 'array'
|
|
237
|
+
of: ArrayOfType[]
|
|
238
|
+
initialValue?: InitialValueProperty<any, unknown[]>
|
|
239
|
+
validation?: ValidationBuilder<ArrayRule<unknown[]>, unknown[]>
|
|
240
|
+
options?: ArrayOptions
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** @public */
|
|
244
|
+
declare type ArrayOfEntry<T> = Omit<T, 'name' | 'hidden'> & {
|
|
245
|
+
name?: string
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** @public */
|
|
249
|
+
declare type ArrayOfType<
|
|
250
|
+
TType extends IntrinsicTypeName = IntrinsicTypeName,
|
|
251
|
+
TAlias extends IntrinsicTypeName | undefined = undefined,
|
|
252
|
+
> =
|
|
253
|
+
| IntrinsicArrayOfDefinition[TType]
|
|
254
|
+
| ArrayOfEntry<TypeAliasDefinition<string, TAlias>>
|
|
255
|
+
|
|
256
|
+
/** @public */
|
|
257
|
+
declare interface ArrayOptions<V = unknown>
|
|
258
|
+
extends SearchConfiguration,
|
|
259
|
+
BaseSchemaTypeOptions {
|
|
260
|
+
list?: TitledListValue<V>[] | V[]
|
|
261
|
+
layout?: 'list' | 'tags' | 'grid'
|
|
262
|
+
/** @deprecated This option does not have any effect anymore */
|
|
263
|
+
direction?: 'horizontal' | 'vertical'
|
|
264
|
+
sortable?: boolean
|
|
265
|
+
modal?: {
|
|
266
|
+
type?: 'dialog' | 'popover'
|
|
267
|
+
width?: number | 'auto'
|
|
268
|
+
}
|
|
269
|
+
/** @alpha This API may change */
|
|
270
|
+
insertMenu?: InsertMenuOptions
|
|
271
|
+
/**
|
|
272
|
+
* A boolean flag to enable or disable tree editing for the array.
|
|
273
|
+
* If there are any nested arrays, they will inherit this value.
|
|
274
|
+
* @deprecated tree editing beta feature has been disabled
|
|
275
|
+
*/
|
|
276
|
+
treeEditing?: boolean
|
|
277
|
+
/**
|
|
278
|
+
* A list of array actions to disable
|
|
279
|
+
* Possible options are defined by {@link ArrayActionName}
|
|
280
|
+
* @beta
|
|
281
|
+
*/
|
|
282
|
+
disableActions?: ArrayActionName[]
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** @public */
|
|
286
|
+
declare interface ArrayRule<Value> extends RuleDef<ArrayRule<Value>, Value> {
|
|
287
|
+
min: (length: number | FieldReference) => ArrayRule<Value>
|
|
288
|
+
max: (length: number | FieldReference) => ArrayRule<Value>
|
|
289
|
+
length: (length: number | FieldReference) => ArrayRule<Value>
|
|
290
|
+
unique: () => ArrayRule<Value>
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** @public */
|
|
294
|
+
declare interface ArraySchemaType<V = unknown> extends BaseSchemaType {
|
|
295
|
+
jsonType: 'array'
|
|
296
|
+
of: (Exclude<SchemaType, ArraySchemaType> | ReferenceSchemaType)[]
|
|
297
|
+
options?: ArrayOptions<V> & {
|
|
298
|
+
layout?: V extends string ? 'tag' : 'grid'
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** @public */
|
|
303
|
+
declare interface Asset extends SanityDocument {
|
|
304
|
+
url: string
|
|
305
|
+
path: string
|
|
306
|
+
assetId: string
|
|
307
|
+
extension: string
|
|
308
|
+
mimeType: string
|
|
309
|
+
sha1hash: string
|
|
310
|
+
size: number
|
|
311
|
+
originalFilename?: string
|
|
312
|
+
label?: string
|
|
313
|
+
title?: string
|
|
314
|
+
description?: string
|
|
315
|
+
creditLine?: string
|
|
316
|
+
source?: AssetSourceSpec
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** @public */
|
|
320
|
+
declare type AssetFromSource = {
|
|
321
|
+
kind: 'assetDocumentId' | 'file' | 'base64' | 'url'
|
|
322
|
+
value: string | File_2
|
|
323
|
+
assetDocumentProps?: ImageAsset
|
|
324
|
+
mediaLibraryProps?: {
|
|
325
|
+
mediaLibraryId: string
|
|
326
|
+
assetId: string
|
|
327
|
+
assetInstanceId: string
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** @public */
|
|
332
|
+
declare interface AssetSource {
|
|
333
|
+
name: string
|
|
334
|
+
/** @deprecated provide `i18nKey` instead */
|
|
335
|
+
title?: string
|
|
336
|
+
i18nKey?: string
|
|
337
|
+
component: ComponentType<AssetSourceComponentProps>
|
|
338
|
+
icon?: ComponentType<EmptyProps>
|
|
339
|
+
/** @beta */
|
|
340
|
+
uploader?: AssetSourceUploader
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** @public */
|
|
344
|
+
declare interface AssetSourceComponentProps {
|
|
345
|
+
action?: 'select' | 'upload'
|
|
346
|
+
assetSource: AssetSource
|
|
347
|
+
assetType?: 'file' | 'image'
|
|
348
|
+
accept: string
|
|
349
|
+
selectionType: 'single'
|
|
350
|
+
dialogHeaderTitle?: React.ReactNode
|
|
351
|
+
selectedAssets: Asset[]
|
|
352
|
+
onClose: () => void
|
|
353
|
+
onSelect: (assetFromSource: AssetFromSource[]) => void
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** @public */
|
|
357
|
+
declare interface AssetSourceSpec {
|
|
358
|
+
id: string
|
|
359
|
+
name: string
|
|
360
|
+
url?: string
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** @beta */
|
|
364
|
+
declare interface AssetSourceUploader {
|
|
365
|
+
upload(
|
|
366
|
+
files: globalThis.File[],
|
|
367
|
+
options?: {
|
|
368
|
+
/**
|
|
369
|
+
* The schema type of the field the asset is being uploaded to.
|
|
370
|
+
* May be of interest to the uploader to read file and image options.
|
|
371
|
+
*/
|
|
372
|
+
schemaType?: SchemaType
|
|
373
|
+
/**
|
|
374
|
+
* The uploader may send patches directly to the field
|
|
375
|
+
* Typed 'unknown' as we don't have patch definitions in sanity/types yet.
|
|
376
|
+
*/
|
|
377
|
+
onChange?: (patch: unknown) => void
|
|
378
|
+
},
|
|
379
|
+
): AssetSourceUploadFile[]
|
|
380
|
+
/**
|
|
381
|
+
* Abort the upload of a file
|
|
382
|
+
*/
|
|
383
|
+
abort(file?: AssetSourceUploadFile): void
|
|
384
|
+
/**
|
|
385
|
+
* Get the files that are currently being uploaded
|
|
386
|
+
*/
|
|
387
|
+
getFiles(): AssetSourceUploadFile[]
|
|
388
|
+
/**
|
|
389
|
+
* Subscribe to upload events from the uploader
|
|
390
|
+
*/
|
|
391
|
+
subscribe(subscriber: (event: AssetSourceUploadEvent) => void): () => void
|
|
392
|
+
/**
|
|
393
|
+
* Update the status of a file. Will be emitted to subscribers.
|
|
394
|
+
*/
|
|
395
|
+
updateFile(
|
|
396
|
+
fileId: string,
|
|
397
|
+
data: {
|
|
398
|
+
progress?: number
|
|
399
|
+
status?: string
|
|
400
|
+
error?: Error
|
|
401
|
+
},
|
|
402
|
+
): void
|
|
403
|
+
/**
|
|
404
|
+
* Reset the uploader (clear files). Should be called by the uploader when all files are done.
|
|
405
|
+
*/
|
|
406
|
+
reset(): void
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** @beta */
|
|
410
|
+
declare type AssetSourceUploadEvent =
|
|
411
|
+
| AssetSourceUploadEventProgress
|
|
412
|
+
| AssetSourceUploadEventStatus
|
|
413
|
+
| AssetSourceUploadEventAllComplete
|
|
414
|
+
| AssetSourceUploadEventError
|
|
415
|
+
| AssetSourceUploadEventAbort
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Emitted when all files are done, either successfully, aborted or with errors
|
|
419
|
+
* @beta */
|
|
420
|
+
declare type AssetSourceUploadEventAbort = {
|
|
421
|
+
type: 'abort'
|
|
422
|
+
/**
|
|
423
|
+
* Files aborted
|
|
424
|
+
*/
|
|
425
|
+
files: AssetSourceUploadFile[]
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Emitted when all files are done, either successfully, aborted or with errors
|
|
430
|
+
* @beta */
|
|
431
|
+
declare type AssetSourceUploadEventAllComplete = {
|
|
432
|
+
type: 'all-complete'
|
|
433
|
+
files: AssetSourceUploadFile[]
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Emitted when all files are done, either successfully, aborted or with errors
|
|
438
|
+
* @beta */
|
|
439
|
+
declare type AssetSourceUploadEventError = {
|
|
440
|
+
type: 'error'
|
|
441
|
+
/**
|
|
442
|
+
* Files errored
|
|
443
|
+
*/
|
|
444
|
+
files: AssetSourceUploadFile[]
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Emitted when a file upload is progressing
|
|
449
|
+
* @beta */
|
|
450
|
+
declare type AssetSourceUploadEventProgress = {
|
|
451
|
+
type: 'progress'
|
|
452
|
+
file: AssetSourceUploadFile
|
|
453
|
+
progress: number
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Emitted when a file upload is changing status
|
|
458
|
+
* @beta */
|
|
459
|
+
declare type AssetSourceUploadEventStatus = {
|
|
460
|
+
type: 'status'
|
|
461
|
+
file: AssetSourceUploadFile
|
|
462
|
+
status: AssetSourceUploadFile['status']
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** @beta */
|
|
466
|
+
declare interface AssetSourceUploadFile {
|
|
467
|
+
id: string
|
|
468
|
+
file: globalThis.File
|
|
469
|
+
progress: number
|
|
470
|
+
status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
|
|
471
|
+
error?: Error
|
|
472
|
+
result?: unknown
|
|
473
|
+
}
|
|
474
|
+
|
|
219
475
|
/**
|
|
220
476
|
* @public
|
|
221
477
|
*/
|
|
@@ -224,6 +480,60 @@ declare type BaseDefinition = {
|
|
|
224
480
|
title?: string
|
|
225
481
|
}
|
|
226
482
|
|
|
483
|
+
/** @public */
|
|
484
|
+
declare interface BaseSchemaDefinition {
|
|
485
|
+
name: string
|
|
486
|
+
title?: string
|
|
487
|
+
description?: string | React.JSX.Element
|
|
488
|
+
hidden?: ConditionalProperty
|
|
489
|
+
readOnly?: ConditionalProperty
|
|
490
|
+
icon?: ComponentType | ReactNode
|
|
491
|
+
validation?: unknown
|
|
492
|
+
initialValue?: unknown
|
|
493
|
+
deprecated?: DeprecatedProperty
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** @public */
|
|
497
|
+
declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
|
|
498
|
+
name: string
|
|
499
|
+
title?: string
|
|
500
|
+
description?: string
|
|
501
|
+
type?: SchemaType
|
|
502
|
+
liveEdit?: boolean
|
|
503
|
+
readOnly?: ConditionalProperty
|
|
504
|
+
hidden?: ConditionalProperty
|
|
505
|
+
icon?: ComponentType
|
|
506
|
+
initialValue?: InitialValueProperty<any, any>
|
|
507
|
+
validation?: SchemaValidationValue
|
|
508
|
+
preview?: PreviewConfig
|
|
509
|
+
/** @beta */
|
|
510
|
+
components?: {
|
|
511
|
+
block?: ComponentType<any>
|
|
512
|
+
inlineBlock?: ComponentType<any>
|
|
513
|
+
annotation?: ComponentType<any>
|
|
514
|
+
diff?: ComponentType<any>
|
|
515
|
+
field?: ComponentType<any>
|
|
516
|
+
input?: ComponentType<any>
|
|
517
|
+
item?: ComponentType<any>
|
|
518
|
+
preview?: ComponentType<any>
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* @deprecated This will be removed.
|
|
522
|
+
*/
|
|
523
|
+
placeholder?: string
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* `BaseOptions` applies to all type options.
|
|
528
|
+
*
|
|
529
|
+
* It can be extended by interface declaration merging in plugins to provide generic options to all types and fields.
|
|
530
|
+
*
|
|
531
|
+
* @public
|
|
532
|
+
* */
|
|
533
|
+
declare interface BaseSchemaTypeOptions {
|
|
534
|
+
sanityCreate?: SanityCreateOptions
|
|
535
|
+
}
|
|
536
|
+
|
|
227
537
|
/**
|
|
228
538
|
* @beta
|
|
229
539
|
*/
|
|
@@ -309,6 +619,142 @@ declare type BehaviorGuard<TBehaviorEvent, TGuardResponse> = (payload: {
|
|
|
309
619
|
event: TBehaviorEvent
|
|
310
620
|
}) => TGuardResponse | false
|
|
311
621
|
|
|
622
|
+
/**
|
|
623
|
+
* Schema definition for text block decorators.
|
|
624
|
+
*
|
|
625
|
+
* @public
|
|
626
|
+
* @example The default set of decorators
|
|
627
|
+
* ```ts
|
|
628
|
+
* {
|
|
629
|
+
* name: 'blockContent',
|
|
630
|
+
* title: 'Content',
|
|
631
|
+
* type: 'array',
|
|
632
|
+
* of: [
|
|
633
|
+
* {
|
|
634
|
+
* type: 'block',
|
|
635
|
+
* marks: {
|
|
636
|
+
* decorators: [
|
|
637
|
+
* {title: 'Strong', value: 'strong'},
|
|
638
|
+
* {title: 'Emphasis', value: 'em'},
|
|
639
|
+
* {title: 'Underline', value: 'underline'},
|
|
640
|
+
* {title: 'Strike', value: 'strike'},
|
|
641
|
+
* {title: 'Code', value: 'code'},
|
|
642
|
+
* ]
|
|
643
|
+
* }
|
|
644
|
+
* }
|
|
645
|
+
* ]
|
|
646
|
+
* }
|
|
647
|
+
* ```
|
|
648
|
+
*/
|
|
649
|
+
declare interface BlockDecoratorDefinition {
|
|
650
|
+
title: string
|
|
651
|
+
i18nTitleKey?: string
|
|
652
|
+
value: string
|
|
653
|
+
icon?: ReactNode | ComponentType
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Schema definition for text blocks.
|
|
658
|
+
*
|
|
659
|
+
* @public
|
|
660
|
+
* @example the default block definition
|
|
661
|
+
* ```ts
|
|
662
|
+
* {
|
|
663
|
+
* name: 'blockContent',
|
|
664
|
+
* title: 'Content',
|
|
665
|
+
* type: 'array',
|
|
666
|
+
* of: [
|
|
667
|
+
* {
|
|
668
|
+
* type: 'block',
|
|
669
|
+
* marks: {
|
|
670
|
+
* decorators: [
|
|
671
|
+
* {title: 'Strong', value: 'strong'},
|
|
672
|
+
* {title: 'Emphasis', value: 'em'},
|
|
673
|
+
* {title: 'Underline', value: 'underline'},
|
|
674
|
+
* {title: 'Strike', value: 'strike'},
|
|
675
|
+
* {title: 'Code', value: 'code'},
|
|
676
|
+
* ],
|
|
677
|
+
* annotations: [
|
|
678
|
+
* {
|
|
679
|
+
* type: 'object',
|
|
680
|
+
* name: 'link',
|
|
681
|
+
* fields: [
|
|
682
|
+
* {
|
|
683
|
+
* type: 'string',
|
|
684
|
+
* name: 'href',
|
|
685
|
+
* },
|
|
686
|
+
* ],
|
|
687
|
+
* },
|
|
688
|
+
* ]
|
|
689
|
+
* },
|
|
690
|
+
* styles: [
|
|
691
|
+
* {title: 'Normal', value: 'normal'},
|
|
692
|
+
* {title: 'H1', value: 'h1'},
|
|
693
|
+
* {title: 'H2', value: 'h2'},
|
|
694
|
+
* {title: 'H3', value: 'h3'},
|
|
695
|
+
* {title: 'H4', value: 'h4'},
|
|
696
|
+
* {title: 'H5', value: 'h5'},
|
|
697
|
+
* {title: 'H6', value: 'h6'},
|
|
698
|
+
* {title: 'Quote', value: 'blockquote'}
|
|
699
|
+
* ],
|
|
700
|
+
* lists: [
|
|
701
|
+
* {title: 'Bullet', value: 'bullet'},
|
|
702
|
+
* {title: 'Number', value: 'number'},
|
|
703
|
+
* ],
|
|
704
|
+
* },
|
|
705
|
+
* ]
|
|
706
|
+
* }
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
declare interface BlockDefinition extends BaseSchemaDefinition {
|
|
710
|
+
type: 'block'
|
|
711
|
+
styles?: BlockStyleDefinition[]
|
|
712
|
+
lists?: BlockListDefinition[]
|
|
713
|
+
marks?: BlockMarksDefinition
|
|
714
|
+
of?: ArrayOfType<'object' | 'reference'>[]
|
|
715
|
+
initialValue?: InitialValueProperty<any, any[]>
|
|
716
|
+
options?: BlockOptions
|
|
717
|
+
validation?: ValidationBuilder<BlockRule, any[]>
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Schema definition for a text block list style.
|
|
722
|
+
*
|
|
723
|
+
* @public
|
|
724
|
+
* @example The defaults lists
|
|
725
|
+
* ```ts
|
|
726
|
+
* {
|
|
727
|
+
* name: 'blockContent',
|
|
728
|
+
* title: 'Content',
|
|
729
|
+
* type: 'array',
|
|
730
|
+
* of: [
|
|
731
|
+
* {
|
|
732
|
+
* type: 'block',
|
|
733
|
+
* lists: [
|
|
734
|
+
* {title: 'Bullet', value: 'bullet'},
|
|
735
|
+
* {title: 'Number', value: 'number'},
|
|
736
|
+
* ]
|
|
737
|
+
* }
|
|
738
|
+
* ]
|
|
739
|
+
* }
|
|
740
|
+
* ```
|
|
741
|
+
*/
|
|
742
|
+
declare interface BlockListDefinition {
|
|
743
|
+
title: string
|
|
744
|
+
i18nTitleKey?: string
|
|
745
|
+
value: string
|
|
746
|
+
icon?: ReactNode | ComponentType
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Schema definition for text block marks (decorators and annotations).
|
|
751
|
+
*
|
|
752
|
+
* @public */
|
|
753
|
+
declare interface BlockMarksDefinition {
|
|
754
|
+
decorators?: BlockDecoratorDefinition[]
|
|
755
|
+
annotations?: ArrayOfType<'object' | 'reference'>[]
|
|
756
|
+
}
|
|
757
|
+
|
|
312
758
|
/**
|
|
313
759
|
* @beta
|
|
314
760
|
*/
|
|
@@ -317,10 +763,108 @@ declare type BlockOffset = {
|
|
|
317
763
|
offset: number
|
|
318
764
|
}
|
|
319
765
|
|
|
766
|
+
/**
|
|
767
|
+
* Schema options for a Block schema definition
|
|
768
|
+
* @public */
|
|
769
|
+
declare interface BlockOptions extends BaseSchemaTypeOptions {
|
|
770
|
+
/**
|
|
771
|
+
* Turn on or off the builtin browser spellchecking. Default is on.
|
|
772
|
+
*/
|
|
773
|
+
spellCheck?: boolean
|
|
774
|
+
unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/** @public */
|
|
778
|
+
declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Schema definition for a text block style.
|
|
782
|
+
* A text block may have a block style like 'header', 'normal', 'lead'
|
|
783
|
+
* attached to it, which is stored on the `.style` property for that block.
|
|
784
|
+
*
|
|
785
|
+
* @public
|
|
786
|
+
* @remarks The first defined style will become the default style.´´
|
|
787
|
+
* @example The default set of styles
|
|
788
|
+
* ```ts
|
|
789
|
+
* {
|
|
790
|
+
* name: 'blockContent',
|
|
791
|
+
* title: 'Content',
|
|
792
|
+
* type: 'array',
|
|
793
|
+
* of: [
|
|
794
|
+
* {
|
|
795
|
+
* type: 'block',
|
|
796
|
+
* styles: [
|
|
797
|
+
* {title: 'Normal', value: 'normal'},
|
|
798
|
+
* {title: 'H1', value: 'h1'},
|
|
799
|
+
* {title: 'H2', value: 'h2'},
|
|
800
|
+
* {title: 'H3', value: 'h3'},
|
|
801
|
+
* {title: 'H4', value: 'h4'},
|
|
802
|
+
* {title: 'H5', value: 'h5'},
|
|
803
|
+
* {title: 'H6', value: 'h6'},
|
|
804
|
+
* {title: 'Quote', value: 'blockquote'}
|
|
805
|
+
* ]
|
|
806
|
+
* }
|
|
807
|
+
* ]
|
|
808
|
+
* }
|
|
809
|
+
* ```
|
|
810
|
+
* @example Example of defining a block type with custom styles and render components.
|
|
811
|
+
* ```ts
|
|
812
|
+
* defineArrayMember({
|
|
813
|
+
* type: 'block',
|
|
814
|
+
* styles: [
|
|
815
|
+
* {
|
|
816
|
+
* title: 'Paragraph',
|
|
817
|
+
* value: 'paragraph',
|
|
818
|
+
* component: ParagraphStyle,
|
|
819
|
+
* },
|
|
820
|
+
* {
|
|
821
|
+
* title: 'Lead',
|
|
822
|
+
* value: 'lead',
|
|
823
|
+
* component: LeadStyle,
|
|
824
|
+
* },
|
|
825
|
+
* {
|
|
826
|
+
* title: 'Heading',
|
|
827
|
+
* value: 'heading',
|
|
828
|
+
* component: HeadingStyle,
|
|
829
|
+
* },
|
|
830
|
+
* ],
|
|
831
|
+
* })
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
declare interface BlockStyleDefinition {
|
|
835
|
+
title: string
|
|
836
|
+
value: string
|
|
837
|
+
i18nTitleKey?: string
|
|
838
|
+
icon?: ReactNode | ComponentType
|
|
839
|
+
}
|
|
840
|
+
|
|
320
841
|
declare type BlockWithOptionalKey =
|
|
321
842
|
| TextBlockWithOptionalKey
|
|
322
843
|
| ObjectBlockWithOptionalKey
|
|
323
844
|
|
|
845
|
+
/** @public */
|
|
846
|
+
declare interface BooleanDefinition extends BaseSchemaDefinition {
|
|
847
|
+
type: 'boolean'
|
|
848
|
+
options?: BooleanOptions
|
|
849
|
+
initialValue?: InitialValueProperty<any, boolean>
|
|
850
|
+
validation?: ValidationBuilder<BooleanRule, boolean>
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/** @public */
|
|
854
|
+
declare interface BooleanOptions extends BaseSchemaTypeOptions {
|
|
855
|
+
layout?: 'switch' | 'checkbox'
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/** @public */
|
|
859
|
+
declare interface BooleanRule extends RuleDef<BooleanRule, boolean> {}
|
|
860
|
+
|
|
861
|
+
/** @public */
|
|
862
|
+
declare interface BooleanSchemaType extends BaseSchemaType {
|
|
863
|
+
jsonType: 'boolean'
|
|
864
|
+
options?: BooleanOptions
|
|
865
|
+
initialValue?: InitialValueProperty<any, boolean>
|
|
866
|
+
}
|
|
867
|
+
|
|
324
868
|
declare type ClipboardBehaviorEvent =
|
|
325
869
|
| {
|
|
326
870
|
type: StrictExtract<NativeBehaviorEventType, 'clipboard.copy'>
|
|
@@ -344,6 +888,35 @@ declare type ClipboardBehaviorEvent =
|
|
|
344
888
|
position: Pick<EventPosition, 'selection'>
|
|
345
889
|
}
|
|
346
890
|
|
|
891
|
+
/** @public */
|
|
892
|
+
declare interface CollapseOptions {
|
|
893
|
+
collapsed?: boolean
|
|
894
|
+
collapsible?: boolean
|
|
895
|
+
/**
|
|
896
|
+
* @deprecated Use `collapsible` instead
|
|
897
|
+
*/
|
|
898
|
+
collapsable?: boolean
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/** @public */
|
|
902
|
+
declare type ConditionalProperty =
|
|
903
|
+
| boolean
|
|
904
|
+
| ConditionalPropertyCallback
|
|
905
|
+
| undefined
|
|
906
|
+
|
|
907
|
+
/** @public */
|
|
908
|
+
declare type ConditionalPropertyCallback = (
|
|
909
|
+
context: ConditionalPropertyCallbackContext,
|
|
910
|
+
) => boolean
|
|
911
|
+
|
|
912
|
+
/** @public */
|
|
913
|
+
declare interface ConditionalPropertyCallbackContext {
|
|
914
|
+
document: SanityDocument | undefined
|
|
915
|
+
parent: any
|
|
916
|
+
value: any
|
|
917
|
+
currentUser: Omit<CurrentUser, 'role'> | null
|
|
918
|
+
}
|
|
919
|
+
|
|
347
920
|
declare type Converter<TMIMEType extends MIMEType = MIMEType> = {
|
|
348
921
|
mimeType: TMIMEType
|
|
349
922
|
serialize: Serializer<TMIMEType>
|
|
@@ -382,6 +955,46 @@ declare type ConverterEvent<TMIMEType extends MIMEType = MIMEType> =
|
|
|
382
955
|
mimeType: TMIMEType
|
|
383
956
|
}
|
|
384
957
|
|
|
958
|
+
/** @public */
|
|
959
|
+
declare interface CrossDatasetReferenceDefinition extends BaseSchemaDefinition {
|
|
960
|
+
type: 'crossDatasetReference'
|
|
961
|
+
weak?: boolean
|
|
962
|
+
to: {
|
|
963
|
+
type: string
|
|
964
|
+
title?: string
|
|
965
|
+
icon?: ComponentType
|
|
966
|
+
preview?: PreviewConfig
|
|
967
|
+
/**
|
|
968
|
+
* @deprecated Unused. Configuring search is no longer supported.
|
|
969
|
+
*/
|
|
970
|
+
__experimental_search?: {
|
|
971
|
+
path: string | string[]
|
|
972
|
+
weight?: number
|
|
973
|
+
mapWith?: string
|
|
974
|
+
}[]
|
|
975
|
+
}[]
|
|
976
|
+
dataset: string
|
|
977
|
+
studioUrl?: (document: {id: string; type?: string}) => string | null
|
|
978
|
+
tokenId?: string
|
|
979
|
+
options?: ReferenceOptions
|
|
980
|
+
/**
|
|
981
|
+
* @deprecated Cross-project references are no longer supported, only cross-dataset
|
|
982
|
+
*/
|
|
983
|
+
projectId?: string
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/** @public */
|
|
987
|
+
declare interface CurrentUser {
|
|
988
|
+
id: string
|
|
989
|
+
name: string
|
|
990
|
+
email: string
|
|
991
|
+
profileImage?: string
|
|
992
|
+
provider?: string
|
|
993
|
+
/** @deprecated use `roles` instead */
|
|
994
|
+
role: string
|
|
995
|
+
roles: Role[]
|
|
996
|
+
}
|
|
997
|
+
|
|
385
998
|
/**
|
|
386
999
|
* @beta
|
|
387
1000
|
*/
|
|
@@ -406,6 +1019,89 @@ declare type CustomBehaviorEventType<
|
|
|
406
1019
|
TType extends string = '',
|
|
407
1020
|
> = TType extends '' ? `${TNamespace}` : `${TNamespace}.${TType}`
|
|
408
1021
|
|
|
1022
|
+
/** @public */
|
|
1023
|
+
declare interface CustomValidator<T = unknown> {
|
|
1024
|
+
(
|
|
1025
|
+
value: T,
|
|
1026
|
+
context: ValidationContext,
|
|
1027
|
+
): CustomValidatorResult | Promise<CustomValidatorResult>
|
|
1028
|
+
bypassConcurrencyLimit?: boolean
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/** @public */
|
|
1032
|
+
declare type CustomValidatorResult =
|
|
1033
|
+
| true
|
|
1034
|
+
| string
|
|
1035
|
+
| ValidationError
|
|
1036
|
+
| ValidationError[]
|
|
1037
|
+
| LocalizedValidationMessages
|
|
1038
|
+
|
|
1039
|
+
/** @public */
|
|
1040
|
+
declare interface DateDefinition extends BaseSchemaDefinition {
|
|
1041
|
+
type: 'date'
|
|
1042
|
+
options?: DateOptions
|
|
1043
|
+
placeholder?: string
|
|
1044
|
+
validation?: ValidationBuilder<DateRule, string>
|
|
1045
|
+
initialValue?: InitialValueProperty<any, string>
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/** @public */
|
|
1049
|
+
declare interface DateOptions extends BaseSchemaTypeOptions {
|
|
1050
|
+
dateFormat?: string
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/** @public */
|
|
1054
|
+
declare interface DateRule extends RuleDef<DateRule, string> {
|
|
1055
|
+
/**
|
|
1056
|
+
* @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
|
|
1057
|
+
*/
|
|
1058
|
+
min: (minDate: string | FieldReference) => DateRule
|
|
1059
|
+
/**
|
|
1060
|
+
* @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
|
|
1061
|
+
*/
|
|
1062
|
+
max: (maxDate: string | FieldReference) => DateRule
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/** @public */
|
|
1066
|
+
declare interface DatetimeDefinition extends BaseSchemaDefinition {
|
|
1067
|
+
type: 'datetime'
|
|
1068
|
+
options?: DatetimeOptions
|
|
1069
|
+
placeholder?: string
|
|
1070
|
+
validation?: ValidationBuilder<DatetimeRule, string>
|
|
1071
|
+
initialValue?: InitialValueProperty<any, string>
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/** @public */
|
|
1075
|
+
declare interface DatetimeOptions extends BaseSchemaTypeOptions {
|
|
1076
|
+
dateFormat?: string
|
|
1077
|
+
timeFormat?: string
|
|
1078
|
+
timeStep?: number
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/** @public */
|
|
1082
|
+
declare interface DatetimeRule extends RuleDef<DatetimeRule, string> {
|
|
1083
|
+
/**
|
|
1084
|
+
* @param minDate - Minimum date (inclusive). minDate should be in ISO 8601 format.
|
|
1085
|
+
*/
|
|
1086
|
+
min: (minDate: string | FieldReference) => DatetimeRule
|
|
1087
|
+
/**
|
|
1088
|
+
* @param maxDate - Maximum date (inclusive). maxDate should be in ISO 8601 format.
|
|
1089
|
+
*/
|
|
1090
|
+
max: (maxDate: string | FieldReference) => DatetimeRule
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/** @public */
|
|
1094
|
+
declare interface DeprecatedProperty {
|
|
1095
|
+
reason: string
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* @public
|
|
1100
|
+
*/
|
|
1101
|
+
declare interface DeprecationConfiguration {
|
|
1102
|
+
deprecated: DeprecatedProperty
|
|
1103
|
+
}
|
|
1104
|
+
|
|
409
1105
|
declare type Deserializer<TMIMEType extends MIMEType> = ({
|
|
410
1106
|
snapshot,
|
|
411
1107
|
event,
|
|
@@ -418,6 +1114,40 @@ declare type Deserializer<TMIMEType extends MIMEType> = ({
|
|
|
418
1114
|
'deserialization.success' | 'deserialization.failure'
|
|
419
1115
|
>
|
|
420
1116
|
|
|
1117
|
+
/** @public */
|
|
1118
|
+
declare interface DocumentDefinition extends Omit<ObjectDefinition, 'type'> {
|
|
1119
|
+
type: 'document'
|
|
1120
|
+
liveEdit?: boolean
|
|
1121
|
+
/** @beta */
|
|
1122
|
+
orderings?: SortOrdering[]
|
|
1123
|
+
options?: DocumentOptions
|
|
1124
|
+
validation?: ValidationBuilder<DocumentRule, SanityDocument>
|
|
1125
|
+
initialValue?: InitialValueProperty<any, Record<string, unknown>>
|
|
1126
|
+
/** @deprecated Unused. Use the new field-level search config. */
|
|
1127
|
+
__experimental_search?: {
|
|
1128
|
+
path: string
|
|
1129
|
+
weight: number
|
|
1130
|
+
mapWith?: string
|
|
1131
|
+
}[]
|
|
1132
|
+
/** @alpha */
|
|
1133
|
+
__experimental_omnisearch_visibility?: boolean
|
|
1134
|
+
/**
|
|
1135
|
+
* Determines whether the large preview title is displayed in the document pane form
|
|
1136
|
+
* @alpha
|
|
1137
|
+
* */
|
|
1138
|
+
__experimental_formPreviewTitle?: boolean
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* This exists only to allow for extensions using declaration-merging.
|
|
1143
|
+
*
|
|
1144
|
+
* @public
|
|
1145
|
+
*/
|
|
1146
|
+
declare interface DocumentOptions extends BaseSchemaTypeOptions {}
|
|
1147
|
+
|
|
1148
|
+
/** @public */
|
|
1149
|
+
declare interface DocumentRule extends RuleDef<DocumentRule, SanityDocument> {}
|
|
1150
|
+
|
|
421
1151
|
declare type DragBehaviorEvent =
|
|
422
1152
|
| {
|
|
423
1153
|
type: StrictExtract<NativeBehaviorEventType, 'drag.dragstart'>
|
|
@@ -5134,17 +5864,213 @@ declare type EditorSnapshot = {
|
|
|
5134
5864
|
}
|
|
5135
5865
|
}
|
|
5136
5866
|
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5867
|
+
/** @public */
|
|
5868
|
+
declare interface EmailDefinition extends BaseSchemaDefinition {
|
|
5869
|
+
type: 'email'
|
|
5870
|
+
options?: EmailOptions
|
|
5871
|
+
placeholder?: string
|
|
5872
|
+
validation?: ValidationBuilder<EmailRule, string>
|
|
5873
|
+
initialValue?: InitialValueProperty<any, string>
|
|
5144
5874
|
}
|
|
5145
5875
|
|
|
5146
|
-
|
|
5147
|
-
|
|
5876
|
+
/** @public */
|
|
5877
|
+
declare interface EmailOptions extends BaseSchemaTypeOptions {}
|
|
5878
|
+
|
|
5879
|
+
/** @public */
|
|
5880
|
+
declare interface EmailRule extends RuleDef<EmailRule, string> {}
|
|
5881
|
+
|
|
5882
|
+
/** @public */
|
|
5883
|
+
declare interface EmptyProps {}
|
|
5884
|
+
|
|
5885
|
+
/** @public */
|
|
5886
|
+
declare interface EnumListProps<V = unknown> {
|
|
5887
|
+
list?: Array<TitledListValue<V> | V>
|
|
5888
|
+
layout?: 'radio' | 'dropdown'
|
|
5889
|
+
direction?: 'horizontal' | 'vertical'
|
|
5890
|
+
}
|
|
5891
|
+
|
|
5892
|
+
declare type EventPosition = {
|
|
5893
|
+
block: 'start' | 'end'
|
|
5894
|
+
/**
|
|
5895
|
+
* Did the event origin from the editor DOM node itself or from a child node?
|
|
5896
|
+
*/
|
|
5897
|
+
isEditor: boolean
|
|
5898
|
+
selection: NonNullable<EditorSelection>
|
|
5899
|
+
}
|
|
5900
|
+
|
|
5901
|
+
declare type ExtractNamespace<TType extends string> =
|
|
5902
|
+
TType extends `${infer Namespace}.${string}` ? Namespace : TType
|
|
5903
|
+
|
|
5904
|
+
/**
|
|
5905
|
+
* The shape of a field definition. Note, it's recommended to use the
|
|
5906
|
+
* `defineField` function instead of using this type directly.
|
|
5907
|
+
*
|
|
5908
|
+
* Where `defineField` infers the exact field type,
|
|
5909
|
+
* FieldDefinition is a compromise union of all types a field can have.
|
|
5910
|
+
*
|
|
5911
|
+
* A field definition can be a reference to another registered top-level type
|
|
5912
|
+
* or a inline type definition.
|
|
5913
|
+
*
|
|
5914
|
+
* @public
|
|
5915
|
+
*/
|
|
5916
|
+
declare type FieldDefinition<
|
|
5917
|
+
TType extends IntrinsicTypeName = IntrinsicTypeName,
|
|
5918
|
+
TAlias extends IntrinsicTypeName | undefined = undefined,
|
|
5919
|
+
> = (InlineFieldDefinition[TType] | TypeAliasDefinition<string, TAlias>) &
|
|
5920
|
+
FieldDefinitionBase
|
|
5921
|
+
|
|
5922
|
+
/** @public */
|
|
5923
|
+
declare interface FieldDefinitionBase {
|
|
5924
|
+
fieldset?: string
|
|
5925
|
+
group?: string | string[]
|
|
5926
|
+
}
|
|
5927
|
+
|
|
5928
|
+
/** @public */
|
|
5929
|
+
declare interface FieldGroup {
|
|
5930
|
+
name: string
|
|
5931
|
+
icon?: ComponentType
|
|
5932
|
+
title?: string
|
|
5933
|
+
description?: string
|
|
5934
|
+
i18n?: I18nTextRecord<'title'>
|
|
5935
|
+
hidden?: ConditionalProperty
|
|
5936
|
+
default?: boolean
|
|
5937
|
+
fields?: ObjectField[]
|
|
5938
|
+
}
|
|
5939
|
+
|
|
5940
|
+
/** @public */
|
|
5941
|
+
declare type FieldGroupDefinition = {
|
|
5942
|
+
name: string
|
|
5943
|
+
title?: string
|
|
5944
|
+
hidden?: ConditionalProperty
|
|
5945
|
+
icon?: ComponentType
|
|
5946
|
+
default?: boolean
|
|
5947
|
+
i18n?: I18nTextRecord<'title'>
|
|
5948
|
+
}
|
|
5949
|
+
|
|
5950
|
+
/**
|
|
5951
|
+
* Holds a reference to a different field
|
|
5952
|
+
* NOTE: Only use this through {@link Rule.valueOfField}
|
|
5953
|
+
*
|
|
5954
|
+
* @public
|
|
5955
|
+
*/
|
|
5956
|
+
declare interface FieldReference {
|
|
5957
|
+
type: symbol
|
|
5958
|
+
path: string | string[]
|
|
5959
|
+
}
|
|
5960
|
+
|
|
5961
|
+
/** @public */
|
|
5962
|
+
declare type FieldRules = {
|
|
5963
|
+
[fieldKey: string]: SchemaValidationValue
|
|
5964
|
+
}
|
|
5965
|
+
|
|
5966
|
+
/** @public */
|
|
5967
|
+
declare type Fieldset = SingleFieldSet | MultiFieldSet
|
|
5968
|
+
|
|
5969
|
+
/** @public */
|
|
5970
|
+
declare type FieldsetDefinition = {
|
|
5971
|
+
name: string
|
|
5972
|
+
title?: string
|
|
5973
|
+
description?: string
|
|
5974
|
+
group?: string
|
|
5975
|
+
hidden?: ConditionalProperty
|
|
5976
|
+
readOnly?: ConditionalProperty
|
|
5977
|
+
options?: ObjectOptions
|
|
5978
|
+
}
|
|
5979
|
+
|
|
5980
|
+
/** @public */
|
|
5981
|
+
declare interface File_2 {
|
|
5982
|
+
[key: string]: unknown
|
|
5983
|
+
asset?: Reference
|
|
5984
|
+
}
|
|
5985
|
+
|
|
5986
|
+
/** @public */
|
|
5987
|
+
declare interface FileDefinition
|
|
5988
|
+
extends Omit<
|
|
5989
|
+
ObjectDefinition,
|
|
5990
|
+
'type' | 'fields' | 'options' | 'groups' | 'validation'
|
|
5991
|
+
> {
|
|
5992
|
+
type: 'file'
|
|
5993
|
+
fields?: ObjectDefinition['fields']
|
|
5994
|
+
options?: FileOptions
|
|
5995
|
+
validation?: ValidationBuilder<FileRule, FileValue>
|
|
5996
|
+
initialValue?: InitialValueProperty<any, FileValue>
|
|
5997
|
+
}
|
|
5998
|
+
|
|
5999
|
+
/** @public */
|
|
6000
|
+
declare interface FileOptions extends ObjectOptions {
|
|
6001
|
+
storeOriginalFilename?: boolean
|
|
6002
|
+
accept?: string
|
|
6003
|
+
sources?: AssetSource[]
|
|
6004
|
+
}
|
|
6005
|
+
|
|
6006
|
+
/** @public */
|
|
6007
|
+
declare interface FileRule extends RuleDef<FileRule, FileValue> {
|
|
6008
|
+
/**
|
|
6009
|
+
* Require a file field has an asset.
|
|
6010
|
+
*
|
|
6011
|
+
* @example
|
|
6012
|
+
* ```ts
|
|
6013
|
+
* defineField({
|
|
6014
|
+
* name: 'file',
|
|
6015
|
+
* title: 'File',
|
|
6016
|
+
* type: 'file',
|
|
6017
|
+
* validation: (Rule) => Rule.required().assetRequired(),
|
|
6018
|
+
* })
|
|
6019
|
+
* ```
|
|
6020
|
+
*/
|
|
6021
|
+
assetRequired(): FileRule
|
|
6022
|
+
}
|
|
6023
|
+
|
|
6024
|
+
/** @public */
|
|
6025
|
+
declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
|
|
6026
|
+
options?: FileOptions
|
|
6027
|
+
}
|
|
6028
|
+
|
|
6029
|
+
/** @public */
|
|
6030
|
+
declare interface FileValue {
|
|
6031
|
+
asset?: Reference
|
|
6032
|
+
[index: string]: unknown
|
|
6033
|
+
}
|
|
6034
|
+
|
|
6035
|
+
/** @public */
|
|
6036
|
+
declare interface GeopointDefinition extends BaseSchemaDefinition {
|
|
6037
|
+
type: 'geopoint'
|
|
6038
|
+
options?: GeopointOptions
|
|
6039
|
+
validation?: ValidationBuilder<GeopointRule, GeopointValue>
|
|
6040
|
+
initialValue?: InitialValueProperty<any, Omit<GeopointValue, '_type'>>
|
|
6041
|
+
}
|
|
6042
|
+
|
|
6043
|
+
/** @public */
|
|
6044
|
+
declare interface GeopointOptions extends BaseSchemaTypeOptions {}
|
|
6045
|
+
|
|
6046
|
+
/** @public */
|
|
6047
|
+
declare interface GeopointRule extends RuleDef<GeopointRule, GeopointValue> {}
|
|
6048
|
+
|
|
6049
|
+
/**
|
|
6050
|
+
* Geographical point representing a pair of latitude and longitude coordinates,
|
|
6051
|
+
* stored as degrees, in the World Geodetic System 1984 (WGS 84) format. Also
|
|
6052
|
+
* includes an optional `alt` property representing the altitude in meters.
|
|
6053
|
+
*
|
|
6054
|
+
* @public
|
|
6055
|
+
*/
|
|
6056
|
+
declare interface GeopointValue {
|
|
6057
|
+
/**
|
|
6058
|
+
* Type of the object. Must be `geopoint`.
|
|
6059
|
+
*/
|
|
6060
|
+
_type: 'geopoint'
|
|
6061
|
+
/**
|
|
6062
|
+
* Latitude in degrees
|
|
6063
|
+
*/
|
|
6064
|
+
lat: number
|
|
6065
|
+
/**
|
|
6066
|
+
* Longitude in degrees
|
|
6067
|
+
*/
|
|
6068
|
+
lng: number
|
|
6069
|
+
/**
|
|
6070
|
+
* Altitude in meters
|
|
6071
|
+
*/
|
|
6072
|
+
alt?: number
|
|
6073
|
+
}
|
|
5148
6074
|
|
|
5149
6075
|
/**
|
|
5150
6076
|
* @public
|
|
@@ -5469,6 +6395,23 @@ export declare const getTrimmedSelection: EditorSelector<EditorSelection>
|
|
|
5469
6395
|
*/
|
|
5470
6396
|
export declare const getValue: EditorSelector<Array<PortableTextBlock>>
|
|
5471
6397
|
|
|
6398
|
+
/** @public */
|
|
6399
|
+
declare interface GlobalDocumentReferenceDefinition
|
|
6400
|
+
extends BaseSchemaDefinition {
|
|
6401
|
+
type: 'globalDocumentReference'
|
|
6402
|
+
weak?: boolean
|
|
6403
|
+
to: {
|
|
6404
|
+
type: string
|
|
6405
|
+
title?: string
|
|
6406
|
+
icon?: ComponentType
|
|
6407
|
+
preview?: PreviewConfig
|
|
6408
|
+
}[]
|
|
6409
|
+
resourceType: string
|
|
6410
|
+
resourceId: string
|
|
6411
|
+
options?: ReferenceOptions
|
|
6412
|
+
studioUrl?: (document: {id: string; type?: string}) => string | null
|
|
6413
|
+
}
|
|
6414
|
+
|
|
5472
6415
|
declare type HasTag = ReturnType<EditorActor['getSnapshot']>['hasTag']
|
|
5473
6416
|
|
|
5474
6417
|
declare interface History_2 {
|
|
@@ -5481,6 +6424,178 @@ declare type HistoryItem = {
|
|
|
5481
6424
|
timestamp: Date
|
|
5482
6425
|
}
|
|
5483
6426
|
|
|
6427
|
+
/** @public */
|
|
6428
|
+
declare interface HotspotOptions {
|
|
6429
|
+
previews?: HotspotPreview[]
|
|
6430
|
+
}
|
|
6431
|
+
|
|
6432
|
+
/** @public */
|
|
6433
|
+
declare interface HotspotPreview {
|
|
6434
|
+
title: string
|
|
6435
|
+
aspectRatio: number
|
|
6436
|
+
}
|
|
6437
|
+
|
|
6438
|
+
/** @public */
|
|
6439
|
+
declare type I18nTextRecord<K extends string> = {
|
|
6440
|
+
[P in K]?: {
|
|
6441
|
+
key: string
|
|
6442
|
+
ns: string
|
|
6443
|
+
}
|
|
6444
|
+
}
|
|
6445
|
+
|
|
6446
|
+
/** @public */
|
|
6447
|
+
declare interface ImageAsset extends Asset {
|
|
6448
|
+
_type: 'sanity.imageAsset'
|
|
6449
|
+
metadata: ImageMetadata
|
|
6450
|
+
}
|
|
6451
|
+
|
|
6452
|
+
/** @public */
|
|
6453
|
+
declare interface ImageCrop {
|
|
6454
|
+
_type?: 'sanity.imageCrop'
|
|
6455
|
+
left: number
|
|
6456
|
+
bottom: number
|
|
6457
|
+
right: number
|
|
6458
|
+
top: number
|
|
6459
|
+
}
|
|
6460
|
+
|
|
6461
|
+
/** @public */
|
|
6462
|
+
declare interface ImageDefinition
|
|
6463
|
+
extends Omit<
|
|
6464
|
+
ObjectDefinition,
|
|
6465
|
+
'type' | 'fields' | 'options' | 'groups' | 'validation'
|
|
6466
|
+
> {
|
|
6467
|
+
type: 'image'
|
|
6468
|
+
fields?: FieldDefinition[]
|
|
6469
|
+
options?: ImageOptions
|
|
6470
|
+
validation?: ValidationBuilder<ImageRule, ImageValue>
|
|
6471
|
+
initialValue?: InitialValueProperty<any, ImageValue>
|
|
6472
|
+
}
|
|
6473
|
+
|
|
6474
|
+
/** @public */
|
|
6475
|
+
declare interface ImageDimensions {
|
|
6476
|
+
_type: 'sanity.imageDimensions'
|
|
6477
|
+
height: number
|
|
6478
|
+
width: number
|
|
6479
|
+
aspectRatio: number
|
|
6480
|
+
}
|
|
6481
|
+
|
|
6482
|
+
/** @public */
|
|
6483
|
+
declare interface ImageHotspot {
|
|
6484
|
+
_type?: 'sanity.imageHotspot'
|
|
6485
|
+
width: number
|
|
6486
|
+
height: number
|
|
6487
|
+
x: number
|
|
6488
|
+
y: number
|
|
6489
|
+
}
|
|
6490
|
+
|
|
6491
|
+
/** @public */
|
|
6492
|
+
declare interface ImageMetadata {
|
|
6493
|
+
[key: string]: unknown
|
|
6494
|
+
_type: 'sanity.imageMetadata'
|
|
6495
|
+
dimensions: ImageDimensions
|
|
6496
|
+
palette?: ImagePalette
|
|
6497
|
+
lqip?: string
|
|
6498
|
+
blurHash?: string
|
|
6499
|
+
hasAlpha: boolean
|
|
6500
|
+
isOpaque: boolean
|
|
6501
|
+
}
|
|
6502
|
+
|
|
6503
|
+
/** @public */
|
|
6504
|
+
declare type ImageMetadataType =
|
|
6505
|
+
| 'blurhash'
|
|
6506
|
+
| 'lqip'
|
|
6507
|
+
| 'palette'
|
|
6508
|
+
| 'exif'
|
|
6509
|
+
| 'image'
|
|
6510
|
+
| 'location'
|
|
6511
|
+
|
|
6512
|
+
/** @public */
|
|
6513
|
+
declare interface ImageOptions extends FileOptions {
|
|
6514
|
+
metadata?: ImageMetadataType[]
|
|
6515
|
+
hotspot?: boolean | HotspotOptions
|
|
6516
|
+
}
|
|
6517
|
+
|
|
6518
|
+
/** @public */
|
|
6519
|
+
declare interface ImagePalette {
|
|
6520
|
+
_type: 'sanity.imagePalette'
|
|
6521
|
+
darkMuted?: ImageSwatch
|
|
6522
|
+
darkVibrant?: ImageSwatch
|
|
6523
|
+
dominant?: ImageSwatch
|
|
6524
|
+
lightMuted?: ImageSwatch
|
|
6525
|
+
lightVibrant?: ImageSwatch
|
|
6526
|
+
muted?: ImageSwatch
|
|
6527
|
+
vibrant?: ImageSwatch
|
|
6528
|
+
}
|
|
6529
|
+
|
|
6530
|
+
/** @public */
|
|
6531
|
+
declare interface ImageRule extends RuleDef<ImageRule, ImageValue> {
|
|
6532
|
+
/**
|
|
6533
|
+
* Require an image field has an asset.
|
|
6534
|
+
*
|
|
6535
|
+
* @example
|
|
6536
|
+
* ```ts
|
|
6537
|
+
* defineField({
|
|
6538
|
+
* name: 'image',
|
|
6539
|
+
* title: 'Image',
|
|
6540
|
+
* type: 'image',
|
|
6541
|
+
* validation: (Rule) => Rule.required().assetRequired(),
|
|
6542
|
+
* })
|
|
6543
|
+
* ```
|
|
6544
|
+
*/
|
|
6545
|
+
assetRequired(): ImageRule
|
|
6546
|
+
}
|
|
6547
|
+
|
|
6548
|
+
/** @public */
|
|
6549
|
+
declare interface ImageSwatch {
|
|
6550
|
+
_type: 'sanity.imagePaletteSwatch'
|
|
6551
|
+
background: string
|
|
6552
|
+
foreground: string
|
|
6553
|
+
population: number
|
|
6554
|
+
title?: string
|
|
6555
|
+
}
|
|
6556
|
+
|
|
6557
|
+
/** @public */
|
|
6558
|
+
declare interface ImageValue extends FileValue {
|
|
6559
|
+
crop?: ImageCrop
|
|
6560
|
+
hotspot?: ImageHotspot
|
|
6561
|
+
[index: string]: unknown
|
|
6562
|
+
}
|
|
6563
|
+
|
|
6564
|
+
/** @public */
|
|
6565
|
+
declare type IndexTuple = [number | '', number | '']
|
|
6566
|
+
|
|
6567
|
+
/** @public */
|
|
6568
|
+
declare type InitialValueProperty<Params, Value> =
|
|
6569
|
+
| Value
|
|
6570
|
+
| InitialValueResolver<Params, Value>
|
|
6571
|
+
| undefined
|
|
6572
|
+
|
|
6573
|
+
/** @public */
|
|
6574
|
+
declare type InitialValueResolver<Params, Value> = (
|
|
6575
|
+
params: Params | undefined,
|
|
6576
|
+
context: InitialValueResolverContext,
|
|
6577
|
+
) => Promise<Value> | Value
|
|
6578
|
+
|
|
6579
|
+
/** @public */
|
|
6580
|
+
declare interface InitialValueResolverContext {
|
|
6581
|
+
projectId: string
|
|
6582
|
+
dataset: string
|
|
6583
|
+
schema: Schema
|
|
6584
|
+
currentUser: CurrentUser | null
|
|
6585
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
6586
|
+
}
|
|
6587
|
+
|
|
6588
|
+
/** @public */
|
|
6589
|
+
declare type InlineFieldDefinition = {
|
|
6590
|
+
[K in keyof IntrinsicDefinitions]: Omit<
|
|
6591
|
+
IntrinsicDefinitions[K],
|
|
6592
|
+
'initialValue' | 'validation'
|
|
6593
|
+
> & {
|
|
6594
|
+
validation?: SchemaValidationValue
|
|
6595
|
+
initialValue?: InitialValueProperty<any, any>
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6598
|
+
|
|
5484
6599
|
/**
|
|
5485
6600
|
* Used to represent native InputEvents that hold a DataTransfer object.
|
|
5486
6601
|
*
|
|
@@ -5499,6 +6614,33 @@ declare type InputBehaviorEvent = {
|
|
|
5499
6614
|
}
|
|
5500
6615
|
}
|
|
5501
6616
|
|
|
6617
|
+
/** @alpha This API may change */
|
|
6618
|
+
declare interface InsertMenuOptions {
|
|
6619
|
+
/**
|
|
6620
|
+
* @defaultValue `'auto'`
|
|
6621
|
+
* `filter: 'auto'` automatically turns on filtering if there are more than 5
|
|
6622
|
+
* schema types added to the menu.
|
|
6623
|
+
*/
|
|
6624
|
+
filter?: 'auto' | boolean
|
|
6625
|
+
groups?: Array<{
|
|
6626
|
+
name: string
|
|
6627
|
+
title?: string
|
|
6628
|
+
of?: Array<string>
|
|
6629
|
+
}>
|
|
6630
|
+
/** defaultValue `true` */
|
|
6631
|
+
showIcons?: boolean
|
|
6632
|
+
/** @defaultValue `[{name: 'list'}]` */
|
|
6633
|
+
views?: Array<
|
|
6634
|
+
| {
|
|
6635
|
+
name: 'list'
|
|
6636
|
+
}
|
|
6637
|
+
| {
|
|
6638
|
+
name: 'grid'
|
|
6639
|
+
previewImageUrl?: (schemaTypeName: string) => string | undefined
|
|
6640
|
+
}
|
|
6641
|
+
>
|
|
6642
|
+
}
|
|
6643
|
+
|
|
5502
6644
|
declare type InsertPlacement = 'auto' | 'after' | 'before'
|
|
5503
6645
|
|
|
5504
6646
|
declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
|
|
@@ -5506,6 +6648,64 @@ declare type InternalPatchEvent = NamespaceEvent<PatchEvent, 'internal'> & {
|
|
|
5506
6648
|
value: Array<PortableTextBlock>
|
|
5507
6649
|
}
|
|
5508
6650
|
|
|
6651
|
+
/** @public */
|
|
6652
|
+
declare type IntrinsicArrayOfDefinition = {
|
|
6653
|
+
[K in keyof IntrinsicDefinitions]: Omit<
|
|
6654
|
+
ArrayOfEntry<IntrinsicDefinitions[K]>,
|
|
6655
|
+
'validation' | 'initialValue'
|
|
6656
|
+
> & {
|
|
6657
|
+
validation?: SchemaValidationValue
|
|
6658
|
+
initialValue?: InitialValueProperty<any, any>
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6661
|
+
|
|
6662
|
+
/**
|
|
6663
|
+
* `IntrinsicDefinitions` is a lookup map for "predefined" schema definitions.
|
|
6664
|
+
* Schema types in `IntrinsicDefinitions` will have good type-completion and type-safety in {@link defineType},
|
|
6665
|
+
* {@link defineField} and {@link defineArrayMember} once the `type` property is provided.
|
|
6666
|
+
*
|
|
6667
|
+
* By default, `IntrinsicDefinitions` contains all standard Sanity schema types (`array`, `string`, `number` ect),
|
|
6668
|
+
* but it is an interface and as such, open for extension.
|
|
6669
|
+
*
|
|
6670
|
+
* This type can be extended using declaration merging; this way new entries can be added.
|
|
6671
|
+
* See {@link defineType} for examples on how this can be accomplished.
|
|
6672
|
+
*
|
|
6673
|
+
* @see defineType
|
|
6674
|
+
*
|
|
6675
|
+
* @public
|
|
6676
|
+
*/
|
|
6677
|
+
declare interface IntrinsicDefinitions {
|
|
6678
|
+
array: ArrayDefinition
|
|
6679
|
+
block: BlockDefinition
|
|
6680
|
+
boolean: BooleanDefinition
|
|
6681
|
+
date: DateDefinition
|
|
6682
|
+
datetime: DatetimeDefinition
|
|
6683
|
+
document: DocumentDefinition
|
|
6684
|
+
file: FileDefinition
|
|
6685
|
+
geopoint: GeopointDefinition
|
|
6686
|
+
image: ImageDefinition
|
|
6687
|
+
number: NumberDefinition
|
|
6688
|
+
object: ObjectDefinition
|
|
6689
|
+
reference: ReferenceDefinition
|
|
6690
|
+
crossDatasetReference: CrossDatasetReferenceDefinition
|
|
6691
|
+
globalDocumentReference: GlobalDocumentReferenceDefinition
|
|
6692
|
+
slug: SlugDefinition
|
|
6693
|
+
string: StringDefinition
|
|
6694
|
+
text: TextDefinition
|
|
6695
|
+
url: UrlDefinition
|
|
6696
|
+
email: EmailDefinition
|
|
6697
|
+
}
|
|
6698
|
+
|
|
6699
|
+
/**
|
|
6700
|
+
* A union of all intrinsic types allowed natively in the schema.
|
|
6701
|
+
*
|
|
6702
|
+
* @see IntrinsicDefinitions
|
|
6703
|
+
*
|
|
6704
|
+
* @public
|
|
6705
|
+
*/
|
|
6706
|
+
declare type IntrinsicTypeName =
|
|
6707
|
+
IntrinsicDefinitions[keyof IntrinsicDefinitions]['type']
|
|
6708
|
+
|
|
5509
6709
|
/**
|
|
5510
6710
|
* The editor has invalid data in the value that can be resolved by the user
|
|
5511
6711
|
* @beta */
|
|
@@ -5623,6 +6823,27 @@ declare type KeyboardBehaviorEvent =
|
|
|
5623
6823
|
>
|
|
5624
6824
|
}
|
|
5625
6825
|
|
|
6826
|
+
/** @public */
|
|
6827
|
+
declare type KeyedSegment = {
|
|
6828
|
+
_key: string
|
|
6829
|
+
}
|
|
6830
|
+
|
|
6831
|
+
/**
|
|
6832
|
+
* Holds localized validation messages for a given field.
|
|
6833
|
+
*
|
|
6834
|
+
* @example Custom message for English (US) and Norwegian (Bokmål):
|
|
6835
|
+
* ```
|
|
6836
|
+
* {
|
|
6837
|
+
* 'en-US': 'Needs to start with a capital letter',
|
|
6838
|
+
* 'no-NB': 'Må starte med stor bokstav',
|
|
6839
|
+
* }
|
|
6840
|
+
* ```
|
|
6841
|
+
* @public
|
|
6842
|
+
*/
|
|
6843
|
+
declare interface LocalizedValidationMessages {
|
|
6844
|
+
[locale: string]: string
|
|
6845
|
+
}
|
|
6846
|
+
|
|
5626
6847
|
declare type MIMEType = `${string}/${string}`
|
|
5627
6848
|
|
|
5628
6849
|
declare type MouseBehaviorEvent = {
|
|
@@ -5630,6 +6851,21 @@ declare type MouseBehaviorEvent = {
|
|
|
5630
6851
|
position: EventPosition
|
|
5631
6852
|
}
|
|
5632
6853
|
|
|
6854
|
+
/** @public */
|
|
6855
|
+
declare interface MultiFieldSet {
|
|
6856
|
+
name: string
|
|
6857
|
+
title?: string
|
|
6858
|
+
description?: string
|
|
6859
|
+
single?: false
|
|
6860
|
+
group?: string | string[]
|
|
6861
|
+
options?: CollapseOptions & {
|
|
6862
|
+
columns?: number
|
|
6863
|
+
}
|
|
6864
|
+
fields: ObjectField[]
|
|
6865
|
+
hidden?: ConditionalProperty
|
|
6866
|
+
readOnly?: ConditionalProperty
|
|
6867
|
+
}
|
|
6868
|
+
|
|
5633
6869
|
/**
|
|
5634
6870
|
* @public
|
|
5635
6871
|
*/
|
|
@@ -5697,10 +6933,114 @@ declare const nativeBehaviorEventTypes: readonly [
|
|
|
5697
6933
|
'mouse.click',
|
|
5698
6934
|
]
|
|
5699
6935
|
|
|
6936
|
+
/** @public */
|
|
6937
|
+
declare interface NumberDefinition extends BaseSchemaDefinition {
|
|
6938
|
+
type: 'number'
|
|
6939
|
+
options?: NumberOptions
|
|
6940
|
+
placeholder?: string
|
|
6941
|
+
validation?: ValidationBuilder<NumberRule, number>
|
|
6942
|
+
initialValue?: InitialValueProperty<any, number>
|
|
6943
|
+
}
|
|
6944
|
+
|
|
6945
|
+
/** @public */
|
|
6946
|
+
declare interface NumberOptions
|
|
6947
|
+
extends EnumListProps<number>,
|
|
6948
|
+
BaseSchemaTypeOptions {}
|
|
6949
|
+
|
|
6950
|
+
/** @public */
|
|
6951
|
+
declare interface NumberRule extends RuleDef<NumberRule, number> {
|
|
6952
|
+
min: (minNumber: number | FieldReference) => NumberRule
|
|
6953
|
+
max: (maxNumber: number | FieldReference) => NumberRule
|
|
6954
|
+
lessThan: (limit: number | FieldReference) => NumberRule
|
|
6955
|
+
greaterThan: (limit: number | FieldReference) => NumberRule
|
|
6956
|
+
integer: () => NumberRule
|
|
6957
|
+
precision: (limit: number | FieldReference) => NumberRule
|
|
6958
|
+
positive: () => NumberRule
|
|
6959
|
+
negative: () => NumberRule
|
|
6960
|
+
}
|
|
6961
|
+
|
|
6962
|
+
/** @public */
|
|
6963
|
+
declare interface NumberSchemaType extends BaseSchemaType {
|
|
6964
|
+
jsonType: 'number'
|
|
6965
|
+
options?: NumberOptions
|
|
6966
|
+
initialValue?: InitialValueProperty<any, number>
|
|
6967
|
+
}
|
|
6968
|
+
|
|
5700
6969
|
declare type ObjectBlockWithOptionalKey = Omit<PortableTextObject, '_key'> & {
|
|
5701
6970
|
_key?: PortableTextObject['_key']
|
|
5702
6971
|
}
|
|
5703
6972
|
|
|
6973
|
+
/** @public */
|
|
6974
|
+
declare interface ObjectDefinition extends BaseSchemaDefinition {
|
|
6975
|
+
type: 'object'
|
|
6976
|
+
/**
|
|
6977
|
+
* Object must have at least one field. This is validated at Studio startup.
|
|
6978
|
+
*/
|
|
6979
|
+
fields: FieldDefinition[]
|
|
6980
|
+
groups?: FieldGroupDefinition[]
|
|
6981
|
+
fieldsets?: FieldsetDefinition[]
|
|
6982
|
+
preview?: PreviewConfig
|
|
6983
|
+
options?: ObjectOptions
|
|
6984
|
+
validation?: ValidationBuilder<ObjectRule, Record<string, unknown>>
|
|
6985
|
+
initialValue?: InitialValueProperty<any, Record<string, unknown>>
|
|
6986
|
+
}
|
|
6987
|
+
|
|
6988
|
+
/** @public */
|
|
6989
|
+
declare interface ObjectField<T extends SchemaType = SchemaType> {
|
|
6990
|
+
name: string
|
|
6991
|
+
fieldset?: string
|
|
6992
|
+
group?: string | string[]
|
|
6993
|
+
type: ObjectFieldType<T>
|
|
6994
|
+
}
|
|
6995
|
+
|
|
6996
|
+
/** @public */
|
|
6997
|
+
declare type ObjectFieldType<T extends SchemaType = SchemaType> = T & {
|
|
6998
|
+
hidden?: ConditionalProperty
|
|
6999
|
+
readOnly?: ConditionalProperty
|
|
7000
|
+
}
|
|
7001
|
+
|
|
7002
|
+
/** @public */
|
|
7003
|
+
declare interface ObjectOptions extends BaseSchemaTypeOptions {
|
|
7004
|
+
collapsible?: boolean
|
|
7005
|
+
collapsed?: boolean
|
|
7006
|
+
columns?: number
|
|
7007
|
+
modal?: {
|
|
7008
|
+
type?: 'dialog' | 'popover'
|
|
7009
|
+
width?: number | number[] | 'auto'
|
|
7010
|
+
}
|
|
7011
|
+
}
|
|
7012
|
+
|
|
7013
|
+
/** @public */
|
|
7014
|
+
declare interface ObjectRule
|
|
7015
|
+
extends RuleDef<ObjectRule, Record<string, unknown>> {}
|
|
7016
|
+
|
|
7017
|
+
/** @public */
|
|
7018
|
+
declare interface ObjectSchemaType extends BaseSchemaType {
|
|
7019
|
+
jsonType: 'object'
|
|
7020
|
+
fields: ObjectField[]
|
|
7021
|
+
groups?: FieldGroup[]
|
|
7022
|
+
fieldsets?: Fieldset[]
|
|
7023
|
+
initialValue?: InitialValueProperty<any, Record<string, unknown>>
|
|
7024
|
+
weak?: boolean
|
|
7025
|
+
/** @deprecated Unused. Use the new field-level search config. */
|
|
7026
|
+
__experimental_search?: {
|
|
7027
|
+
path: (string | number)[]
|
|
7028
|
+
weight: number
|
|
7029
|
+
mapWith?: string
|
|
7030
|
+
}[]
|
|
7031
|
+
/** @alpha */
|
|
7032
|
+
__experimental_omnisearch_visibility?: boolean
|
|
7033
|
+
/** @alpha */
|
|
7034
|
+
__experimental_actions?: string[]
|
|
7035
|
+
/** @alpha */
|
|
7036
|
+
__experimental_formPreviewTitle?: boolean
|
|
7037
|
+
/**
|
|
7038
|
+
* @beta
|
|
7039
|
+
*/
|
|
7040
|
+
orderings?: SortOrdering[]
|
|
7041
|
+
options?: any
|
|
7042
|
+
}
|
|
7043
|
+
|
|
5704
7044
|
/**
|
|
5705
7045
|
* @public
|
|
5706
7046
|
*/
|
|
@@ -5715,6 +7055,12 @@ declare type PatchEvent = {
|
|
|
5715
7055
|
patch: Patch
|
|
5716
7056
|
}
|
|
5717
7057
|
|
|
7058
|
+
/** @public */
|
|
7059
|
+
declare type Path = PathSegment[]
|
|
7060
|
+
|
|
7061
|
+
/** @public */
|
|
7062
|
+
declare type PathSegment = string | number | KeyedSegment | IndexTuple
|
|
7063
|
+
|
|
5718
7064
|
/**
|
|
5719
7065
|
* @internal
|
|
5720
7066
|
*/
|
|
@@ -5724,6 +7070,18 @@ declare type PickFromUnion<
|
|
|
5724
7070
|
TPickedTags extends TUnion[TTagKey],
|
|
5725
7071
|
> = TUnion extends Record<TTagKey, TPickedTags> ? TUnion : never
|
|
5726
7072
|
|
|
7073
|
+
/** @alpha */
|
|
7074
|
+
declare type PortableTextBlock = PortableTextTextBlock | PortableTextObject
|
|
7075
|
+
|
|
7076
|
+
/** @alpha */
|
|
7077
|
+
declare type PortableTextChild = PortableTextObject | PortableTextSpan
|
|
7078
|
+
|
|
7079
|
+
/** @alpha */
|
|
7080
|
+
declare interface PortableTextListBlock extends PortableTextTextBlock {
|
|
7081
|
+
listItem: string
|
|
7082
|
+
level: number
|
|
7083
|
+
}
|
|
7084
|
+
|
|
5727
7085
|
/** @beta */
|
|
5728
7086
|
declare type PortableTextMemberSchemaTypes = {
|
|
5729
7087
|
annotations: (ObjectSchemaType & {
|
|
@@ -5739,6 +7097,13 @@ declare type PortableTextMemberSchemaTypes = {
|
|
|
5739
7097
|
lists: BlockListDefinition[]
|
|
5740
7098
|
}
|
|
5741
7099
|
|
|
7100
|
+
/** @alpha */
|
|
7101
|
+
declare interface PortableTextObject {
|
|
7102
|
+
_type: string
|
|
7103
|
+
_key: string
|
|
7104
|
+
[other: string]: unknown
|
|
7105
|
+
}
|
|
7106
|
+
|
|
5742
7107
|
declare interface PortableTextSlateEditor extends ReactEditor {
|
|
5743
7108
|
_key: 'editor'
|
|
5744
7109
|
_type: 'editor'
|
|
@@ -5772,8 +7137,164 @@ declare interface PortableTextSlateEditor extends ReactEditor {
|
|
|
5772
7137
|
redo: () => void
|
|
5773
7138
|
}
|
|
5774
7139
|
|
|
5775
|
-
|
|
5776
|
-
|
|
7140
|
+
/** @alpha */
|
|
7141
|
+
declare interface PortableTextSpan {
|
|
7142
|
+
_key: string
|
|
7143
|
+
_type: 'span'
|
|
7144
|
+
text: string
|
|
7145
|
+
marks?: string[]
|
|
7146
|
+
}
|
|
7147
|
+
|
|
7148
|
+
/** @alpha */
|
|
7149
|
+
declare interface PortableTextTextBlock<
|
|
7150
|
+
TChild = PortableTextSpan | PortableTextObject,
|
|
7151
|
+
> {
|
|
7152
|
+
_type: string
|
|
7153
|
+
_key: string
|
|
7154
|
+
children: TChild[]
|
|
7155
|
+
markDefs?: PortableTextObject[]
|
|
7156
|
+
listItem?: string
|
|
7157
|
+
style?: string
|
|
7158
|
+
level?: number
|
|
7159
|
+
}
|
|
7160
|
+
|
|
7161
|
+
/** @public */
|
|
7162
|
+
declare interface PrepareViewOptions {
|
|
7163
|
+
/** @beta */
|
|
7164
|
+
ordering?: SortOrdering
|
|
7165
|
+
}
|
|
7166
|
+
|
|
7167
|
+
/** @public */
|
|
7168
|
+
declare interface PreviewConfig<
|
|
7169
|
+
Select extends Record<string, string> = Record<string, string>,
|
|
7170
|
+
PrepareValue extends Record<keyof Select, any> = Record<keyof Select, any>,
|
|
7171
|
+
> {
|
|
7172
|
+
select?: Select
|
|
7173
|
+
prepare?: (
|
|
7174
|
+
value: PrepareValue,
|
|
7175
|
+
viewOptions?: PrepareViewOptions,
|
|
7176
|
+
) => PreviewValue
|
|
7177
|
+
}
|
|
7178
|
+
|
|
7179
|
+
/** @public */
|
|
7180
|
+
declare interface PreviewValue {
|
|
7181
|
+
_id?: string
|
|
7182
|
+
_createdAt?: string
|
|
7183
|
+
_updatedAt?: string
|
|
7184
|
+
title?: string
|
|
7185
|
+
subtitle?: string
|
|
7186
|
+
description?: string
|
|
7187
|
+
media?: ReactNode | ElementType
|
|
7188
|
+
imageUrl?: string
|
|
7189
|
+
}
|
|
7190
|
+
|
|
7191
|
+
/** @public */
|
|
7192
|
+
declare interface Reference {
|
|
7193
|
+
_type: string
|
|
7194
|
+
_ref: string
|
|
7195
|
+
_key?: string
|
|
7196
|
+
_weak?: boolean
|
|
7197
|
+
_strengthenOnPublish?: {
|
|
7198
|
+
type: string
|
|
7199
|
+
weak?: boolean
|
|
7200
|
+
template?: {
|
|
7201
|
+
id: string
|
|
7202
|
+
params: Record<string, string | number | boolean>
|
|
7203
|
+
}
|
|
7204
|
+
}
|
|
7205
|
+
}
|
|
7206
|
+
|
|
7207
|
+
/** @public */
|
|
7208
|
+
declare interface ReferenceBaseOptions extends BaseSchemaTypeOptions {
|
|
7209
|
+
disableNew?: boolean
|
|
7210
|
+
}
|
|
7211
|
+
|
|
7212
|
+
/** @public */
|
|
7213
|
+
declare interface ReferenceDefinition extends BaseSchemaDefinition {
|
|
7214
|
+
type: 'reference'
|
|
7215
|
+
to: ReferenceTo
|
|
7216
|
+
weak?: boolean
|
|
7217
|
+
options?: ReferenceOptions
|
|
7218
|
+
validation?: ValidationBuilder<ReferenceRule, ReferenceValue>
|
|
7219
|
+
initialValue?: InitialValueProperty<any, Omit<ReferenceValue, '_type'>>
|
|
7220
|
+
}
|
|
7221
|
+
|
|
7222
|
+
/** @public */
|
|
7223
|
+
declare type ReferenceFilterOptions =
|
|
7224
|
+
| ReferenceFilterResolverOptions
|
|
7225
|
+
| ReferenceFilterQueryOptions
|
|
7226
|
+
|
|
7227
|
+
/** @public */
|
|
7228
|
+
declare interface ReferenceFilterQueryOptions {
|
|
7229
|
+
filter: string
|
|
7230
|
+
filterParams?: Record<string, unknown>
|
|
7231
|
+
}
|
|
7232
|
+
|
|
7233
|
+
/** @public */
|
|
7234
|
+
declare type ReferenceFilterResolver = (
|
|
7235
|
+
context: ReferenceFilterResolverContext,
|
|
7236
|
+
) => ReferenceFilterSearchOptions | Promise<ReferenceFilterSearchOptions>
|
|
7237
|
+
|
|
7238
|
+
/** @public */
|
|
7239
|
+
declare interface ReferenceFilterResolverContext {
|
|
7240
|
+
document: SanityDocument
|
|
7241
|
+
parent?: Record<string, unknown> | Record<string, unknown>[]
|
|
7242
|
+
parentPath: Path
|
|
7243
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
7244
|
+
}
|
|
7245
|
+
|
|
7246
|
+
/** @public */
|
|
7247
|
+
declare interface ReferenceFilterResolverOptions {
|
|
7248
|
+
filter?: ReferenceFilterResolver
|
|
7249
|
+
filterParams?: never
|
|
7250
|
+
}
|
|
7251
|
+
|
|
7252
|
+
/** @public */
|
|
7253
|
+
declare type ReferenceFilterSearchOptions = {
|
|
7254
|
+
filter?: string
|
|
7255
|
+
params?: Record<string, unknown>
|
|
7256
|
+
tag?: string
|
|
7257
|
+
maxFieldDepth?: number
|
|
7258
|
+
strategy?: SearchStrategy
|
|
7259
|
+
perspective?: ClientPerspective
|
|
7260
|
+
}
|
|
7261
|
+
|
|
7262
|
+
/**
|
|
7263
|
+
* Types are closed for extension. To add properties via declaration merging to this type,
|
|
7264
|
+
* redeclare and add the properties to the interfaces that make up ReferenceOptions type.
|
|
7265
|
+
*
|
|
7266
|
+
* @see ReferenceFilterOptions
|
|
7267
|
+
* @see ReferenceFilterResolverOptions
|
|
7268
|
+
* @see ReferenceBaseOptions
|
|
7269
|
+
*
|
|
7270
|
+
* @public
|
|
7271
|
+
*/
|
|
7272
|
+
declare type ReferenceOptions = ReferenceBaseOptions & ReferenceFilterOptions
|
|
7273
|
+
|
|
7274
|
+
/** @public */
|
|
7275
|
+
declare interface ReferenceRule
|
|
7276
|
+
extends RuleDef<ReferenceRule, ReferenceValue> {}
|
|
7277
|
+
|
|
7278
|
+
/** @public */
|
|
7279
|
+
declare interface ReferenceSchemaType
|
|
7280
|
+
extends Omit<ObjectSchemaType, 'options'> {
|
|
7281
|
+
jsonType: 'object'
|
|
7282
|
+
to: ObjectSchemaType[]
|
|
7283
|
+
weak?: boolean
|
|
7284
|
+
options?: ReferenceOptions
|
|
7285
|
+
}
|
|
7286
|
+
|
|
7287
|
+
/** @public */
|
|
7288
|
+
declare type ReferenceTo =
|
|
7289
|
+
| SchemaTypeDefinition
|
|
7290
|
+
| TypeReference
|
|
7291
|
+
| Array<SchemaTypeDefinition | TypeReference>
|
|
7292
|
+
|
|
7293
|
+
/** @public */
|
|
7294
|
+
declare type ReferenceValue = Reference
|
|
7295
|
+
|
|
7296
|
+
/**************************************
|
|
7297
|
+
* Resolve behavior event
|
|
5777
7298
|
**************************************/
|
|
5778
7299
|
declare type ResolveBehaviorEvent<
|
|
5779
7300
|
TBehaviorEventType extends
|
|
@@ -5797,6 +7318,437 @@ declare type ResolveBehaviorEvent<
|
|
|
5797
7318
|
? PickFromUnion<BehaviorEvent, 'type', TBehaviorEventType>
|
|
5798
7319
|
: never
|
|
5799
7320
|
|
|
7321
|
+
/** @public */
|
|
7322
|
+
declare interface Role {
|
|
7323
|
+
name: string
|
|
7324
|
+
title: string
|
|
7325
|
+
description?: string
|
|
7326
|
+
}
|
|
7327
|
+
|
|
7328
|
+
/** @public */
|
|
7329
|
+
declare interface Rule {
|
|
7330
|
+
/**
|
|
7331
|
+
* @internal
|
|
7332
|
+
* @deprecated internal use only
|
|
7333
|
+
*/
|
|
7334
|
+
_type: RuleTypeConstraint | undefined
|
|
7335
|
+
/**
|
|
7336
|
+
* @internal
|
|
7337
|
+
* @deprecated internal use only
|
|
7338
|
+
*/
|
|
7339
|
+
_level: 'error' | 'warning' | 'info' | undefined
|
|
7340
|
+
/**
|
|
7341
|
+
* @internal
|
|
7342
|
+
* @deprecated internal use only
|
|
7343
|
+
*/
|
|
7344
|
+
_required: 'required' | 'optional' | undefined
|
|
7345
|
+
/**
|
|
7346
|
+
* @internal
|
|
7347
|
+
* @deprecated internal use only
|
|
7348
|
+
*/
|
|
7349
|
+
_typeDef: SchemaType | undefined
|
|
7350
|
+
/**
|
|
7351
|
+
* @internal
|
|
7352
|
+
* @deprecated internal use only
|
|
7353
|
+
*/
|
|
7354
|
+
_message: string | LocalizedValidationMessages | undefined
|
|
7355
|
+
/**
|
|
7356
|
+
* @internal
|
|
7357
|
+
* @deprecated internal use only
|
|
7358
|
+
*/
|
|
7359
|
+
_rules: RuleSpec[]
|
|
7360
|
+
/**
|
|
7361
|
+
* @internal
|
|
7362
|
+
* @deprecated internal use only
|
|
7363
|
+
*/
|
|
7364
|
+
_fieldRules: FieldRules | undefined
|
|
7365
|
+
/**
|
|
7366
|
+
* Takes in a path and returns an object with a symbol.
|
|
7367
|
+
*
|
|
7368
|
+
* When the validation lib sees this symbol, it will use the provided path to
|
|
7369
|
+
* get a value from the current field's parent and use that value as the input
|
|
7370
|
+
* to the Rule.
|
|
7371
|
+
*
|
|
7372
|
+
* The path that's given is forwarded to `lodash/get`
|
|
7373
|
+
*
|
|
7374
|
+
* ```js
|
|
7375
|
+
* fields: [
|
|
7376
|
+
* // ...
|
|
7377
|
+
* {
|
|
7378
|
+
* // ...
|
|
7379
|
+
* name: 'highestTemperature',
|
|
7380
|
+
* type: 'number',
|
|
7381
|
+
* validation: (Rule) => Rule.positive().min(Rule.valueOfField('lowestTemperature')),
|
|
7382
|
+
* // ...
|
|
7383
|
+
* },
|
|
7384
|
+
* ]
|
|
7385
|
+
* ```
|
|
7386
|
+
*/
|
|
7387
|
+
valueOfField: (path: string | string[]) => FieldReference
|
|
7388
|
+
error(message?: string | LocalizedValidationMessages): Rule
|
|
7389
|
+
warning(message?: string | LocalizedValidationMessages): Rule
|
|
7390
|
+
info(message?: string | LocalizedValidationMessages): Rule
|
|
7391
|
+
reset(): this
|
|
7392
|
+
isRequired(): boolean
|
|
7393
|
+
clone(): Rule
|
|
7394
|
+
cloneWithRules(rules: RuleSpec[]): Rule
|
|
7395
|
+
merge(rule: Rule): Rule
|
|
7396
|
+
type(targetType: RuleTypeConstraint | Lowercase<RuleTypeConstraint>): Rule
|
|
7397
|
+
all(children: Rule[]): Rule
|
|
7398
|
+
either(children: Rule[]): Rule
|
|
7399
|
+
optional(): Rule
|
|
7400
|
+
required(): Rule
|
|
7401
|
+
custom<T = unknown>(
|
|
7402
|
+
fn: CustomValidator<T>,
|
|
7403
|
+
options?: {
|
|
7404
|
+
bypassConcurrencyLimit?: boolean
|
|
7405
|
+
},
|
|
7406
|
+
): Rule
|
|
7407
|
+
min(len: number | string | FieldReference): Rule
|
|
7408
|
+
max(len: number | string | FieldReference): Rule
|
|
7409
|
+
length(len: number | FieldReference): Rule
|
|
7410
|
+
valid(value: unknown | unknown[]): Rule
|
|
7411
|
+
integer(): Rule
|
|
7412
|
+
precision(limit: number | FieldReference): Rule
|
|
7413
|
+
positive(): Rule
|
|
7414
|
+
negative(): Rule
|
|
7415
|
+
greaterThan(num: number | FieldReference): Rule
|
|
7416
|
+
lessThan(num: number | FieldReference): Rule
|
|
7417
|
+
uppercase(): Rule
|
|
7418
|
+
lowercase(): Rule
|
|
7419
|
+
regex(
|
|
7420
|
+
pattern: RegExp,
|
|
7421
|
+
name: string,
|
|
7422
|
+
options: {
|
|
7423
|
+
name?: string
|
|
7424
|
+
invert?: boolean
|
|
7425
|
+
},
|
|
7426
|
+
): Rule
|
|
7427
|
+
regex(
|
|
7428
|
+
pattern: RegExp,
|
|
7429
|
+
options: {
|
|
7430
|
+
name?: string
|
|
7431
|
+
invert?: boolean
|
|
7432
|
+
},
|
|
7433
|
+
): Rule
|
|
7434
|
+
regex(pattern: RegExp, name: string): Rule
|
|
7435
|
+
regex(pattern: RegExp): Rule
|
|
7436
|
+
email(): Rule
|
|
7437
|
+
uri(options?: UriValidationOptions): Rule
|
|
7438
|
+
unique(): Rule
|
|
7439
|
+
reference(): Rule
|
|
7440
|
+
fields(rules: FieldRules): Rule
|
|
7441
|
+
assetRequired(): Rule
|
|
7442
|
+
validate(
|
|
7443
|
+
value: unknown,
|
|
7444
|
+
options: ValidationContext & {
|
|
7445
|
+
/**
|
|
7446
|
+
* @deprecated Internal use only
|
|
7447
|
+
* @internal
|
|
7448
|
+
*/
|
|
7449
|
+
__internal?: {
|
|
7450
|
+
customValidationConcurrencyLimiter?: {
|
|
7451
|
+
ready: () => Promise<void>
|
|
7452
|
+
release: () => void
|
|
7453
|
+
}
|
|
7454
|
+
}
|
|
7455
|
+
},
|
|
7456
|
+
): Promise<ValidationMarker[]>
|
|
7457
|
+
}
|
|
7458
|
+
|
|
7459
|
+
/** @public */
|
|
7460
|
+
declare type RuleBuilder<
|
|
7461
|
+
T extends RuleDef<T, FieldValue>,
|
|
7462
|
+
FieldValue = unknown,
|
|
7463
|
+
> = T | T[]
|
|
7464
|
+
|
|
7465
|
+
/** @public */
|
|
7466
|
+
declare interface RuleDef<T, FieldValue = unknown> {
|
|
7467
|
+
required: () => T
|
|
7468
|
+
custom: <LenientFieldValue extends FieldValue>(
|
|
7469
|
+
fn: CustomValidator<LenientFieldValue | undefined>,
|
|
7470
|
+
) => T
|
|
7471
|
+
info: (message?: string | LocalizedValidationMessages) => T
|
|
7472
|
+
error: (message?: string | LocalizedValidationMessages) => T
|
|
7473
|
+
warning: (message?: string | LocalizedValidationMessages) => T
|
|
7474
|
+
valueOfField: (path: string | string[]) => FieldReference
|
|
7475
|
+
}
|
|
7476
|
+
|
|
7477
|
+
/** @public */
|
|
7478
|
+
declare type RuleSpec =
|
|
7479
|
+
| {
|
|
7480
|
+
flag: 'integer'
|
|
7481
|
+
}
|
|
7482
|
+
| {
|
|
7483
|
+
flag: 'email'
|
|
7484
|
+
}
|
|
7485
|
+
| {
|
|
7486
|
+
flag: 'unique'
|
|
7487
|
+
}
|
|
7488
|
+
| {
|
|
7489
|
+
flag: 'reference'
|
|
7490
|
+
}
|
|
7491
|
+
| {
|
|
7492
|
+
flag: 'type'
|
|
7493
|
+
constraint: RuleTypeConstraint
|
|
7494
|
+
}
|
|
7495
|
+
| {
|
|
7496
|
+
flag: 'all'
|
|
7497
|
+
constraint: Rule[]
|
|
7498
|
+
}
|
|
7499
|
+
| {
|
|
7500
|
+
flag: 'either'
|
|
7501
|
+
constraint: Rule[]
|
|
7502
|
+
}
|
|
7503
|
+
| {
|
|
7504
|
+
flag: 'presence'
|
|
7505
|
+
constraint: 'optional' | 'required'
|
|
7506
|
+
}
|
|
7507
|
+
| {
|
|
7508
|
+
flag: 'custom'
|
|
7509
|
+
constraint: CustomValidator
|
|
7510
|
+
}
|
|
7511
|
+
| {
|
|
7512
|
+
flag: 'min'
|
|
7513
|
+
constraint: number | string
|
|
7514
|
+
}
|
|
7515
|
+
| {
|
|
7516
|
+
flag: 'max'
|
|
7517
|
+
constraint: number | string
|
|
7518
|
+
}
|
|
7519
|
+
| {
|
|
7520
|
+
flag: 'length'
|
|
7521
|
+
constraint: number
|
|
7522
|
+
}
|
|
7523
|
+
| {
|
|
7524
|
+
flag: 'valid'
|
|
7525
|
+
constraint: unknown[]
|
|
7526
|
+
}
|
|
7527
|
+
| {
|
|
7528
|
+
flag: 'precision'
|
|
7529
|
+
constraint: number
|
|
7530
|
+
}
|
|
7531
|
+
| {
|
|
7532
|
+
flag: 'lessThan'
|
|
7533
|
+
constraint: number
|
|
7534
|
+
}
|
|
7535
|
+
| {
|
|
7536
|
+
flag: 'greaterThan'
|
|
7537
|
+
constraint: number
|
|
7538
|
+
}
|
|
7539
|
+
| {
|
|
7540
|
+
flag: 'stringCasing'
|
|
7541
|
+
constraint: 'uppercase' | 'lowercase'
|
|
7542
|
+
}
|
|
7543
|
+
| {
|
|
7544
|
+
flag: 'assetRequired'
|
|
7545
|
+
constraint: {
|
|
7546
|
+
assetType: 'asset' | 'image' | 'file'
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7549
|
+
| {
|
|
7550
|
+
flag: 'regex'
|
|
7551
|
+
constraint: {
|
|
7552
|
+
pattern: RegExp
|
|
7553
|
+
name?: string
|
|
7554
|
+
invert: boolean
|
|
7555
|
+
}
|
|
7556
|
+
}
|
|
7557
|
+
| {
|
|
7558
|
+
flag: 'uri'
|
|
7559
|
+
constraint: {
|
|
7560
|
+
options: {
|
|
7561
|
+
scheme: RegExp[]
|
|
7562
|
+
allowRelative: boolean
|
|
7563
|
+
relativeOnly: boolean
|
|
7564
|
+
allowCredentials: boolean
|
|
7565
|
+
}
|
|
7566
|
+
}
|
|
7567
|
+
}
|
|
7568
|
+
|
|
7569
|
+
/** @public */
|
|
7570
|
+
declare type RuleTypeConstraint =
|
|
7571
|
+
| 'Array'
|
|
7572
|
+
| 'Boolean'
|
|
7573
|
+
| 'Date'
|
|
7574
|
+
| 'Number'
|
|
7575
|
+
| 'Object'
|
|
7576
|
+
| 'String'
|
|
7577
|
+
|
|
7578
|
+
/**
|
|
7579
|
+
* Options for configuring how Sanity Create interfaces with the type or field.
|
|
7580
|
+
*
|
|
7581
|
+
* @public
|
|
7582
|
+
*/
|
|
7583
|
+
declare interface SanityCreateOptions {
|
|
7584
|
+
/** Set to true to exclude a type or field from appearing in Sanity Create */
|
|
7585
|
+
exclude?: boolean
|
|
7586
|
+
/**
|
|
7587
|
+
* A short description of what the type or field is used for.
|
|
7588
|
+
* Purpose can be used to improve how and when content mapping uses the field.
|
|
7589
|
+
* */
|
|
7590
|
+
purpose?: string
|
|
7591
|
+
}
|
|
7592
|
+
|
|
7593
|
+
/** @public */
|
|
7594
|
+
declare interface SanityDocument {
|
|
7595
|
+
_id: string
|
|
7596
|
+
_type: string
|
|
7597
|
+
_createdAt: string
|
|
7598
|
+
_updatedAt: string
|
|
7599
|
+
_rev: string
|
|
7600
|
+
[key: string]: unknown
|
|
7601
|
+
}
|
|
7602
|
+
|
|
7603
|
+
/** @public */
|
|
7604
|
+
declare interface Schema {
|
|
7605
|
+
/** @internal */
|
|
7606
|
+
_original?: {
|
|
7607
|
+
name: string
|
|
7608
|
+
types: SchemaTypeDefinition[]
|
|
7609
|
+
}
|
|
7610
|
+
/** @internal */
|
|
7611
|
+
_registry: {
|
|
7612
|
+
[typeName: string]: any
|
|
7613
|
+
}
|
|
7614
|
+
/** @internal */
|
|
7615
|
+
_validation?: SchemaValidationProblemGroup[]
|
|
7616
|
+
name: string
|
|
7617
|
+
get: (name: string) => SchemaType | undefined
|
|
7618
|
+
has: (name: string) => boolean
|
|
7619
|
+
getTypeNames: () => string[]
|
|
7620
|
+
}
|
|
7621
|
+
|
|
7622
|
+
/**
|
|
7623
|
+
* Note: you probably want `SchemaTypeDefinition` instead
|
|
7624
|
+
* @see SchemaTypeDefinition
|
|
7625
|
+
*
|
|
7626
|
+
* @public
|
|
7627
|
+
*/
|
|
7628
|
+
declare type SchemaType =
|
|
7629
|
+
| ArraySchemaType
|
|
7630
|
+
| BooleanSchemaType
|
|
7631
|
+
| FileSchemaType
|
|
7632
|
+
| NumberSchemaType
|
|
7633
|
+
| ObjectSchemaType
|
|
7634
|
+
| StringSchemaType
|
|
7635
|
+
| ReferenceSchemaType
|
|
7636
|
+
|
|
7637
|
+
/**
|
|
7638
|
+
* Represents a Sanity schema type definition with an optional type parameter.
|
|
7639
|
+
*
|
|
7640
|
+
* It's recommend to use the `defineType` helper instead of this type by
|
|
7641
|
+
* itself.
|
|
7642
|
+
*
|
|
7643
|
+
* @see defineType
|
|
7644
|
+
*
|
|
7645
|
+
* @public
|
|
7646
|
+
*/
|
|
7647
|
+
declare type SchemaTypeDefinition<
|
|
7648
|
+
TType extends IntrinsicTypeName = IntrinsicTypeName,
|
|
7649
|
+
> = IntrinsicDefinitions[IntrinsicTypeName] | TypeAliasDefinition<string, TType>
|
|
7650
|
+
|
|
7651
|
+
/** @public */
|
|
7652
|
+
declare interface SchemaValidationError {
|
|
7653
|
+
helpId?: string
|
|
7654
|
+
message: string
|
|
7655
|
+
severity: 'error'
|
|
7656
|
+
}
|
|
7657
|
+
|
|
7658
|
+
/** @internal */
|
|
7659
|
+
declare type SchemaValidationProblem =
|
|
7660
|
+
| SchemaValidationError
|
|
7661
|
+
| SchemaValidationWarning
|
|
7662
|
+
|
|
7663
|
+
/** @internal */
|
|
7664
|
+
declare interface SchemaValidationProblemGroup {
|
|
7665
|
+
path: SchemaValidationProblemPath
|
|
7666
|
+
problems: SchemaValidationProblem[]
|
|
7667
|
+
}
|
|
7668
|
+
|
|
7669
|
+
/** @internal */
|
|
7670
|
+
declare type SchemaValidationProblemPath = Array<
|
|
7671
|
+
| {
|
|
7672
|
+
kind: 'type'
|
|
7673
|
+
type: string
|
|
7674
|
+
name?: string
|
|
7675
|
+
}
|
|
7676
|
+
| {
|
|
7677
|
+
kind: 'property'
|
|
7678
|
+
name: string
|
|
7679
|
+
}
|
|
7680
|
+
>
|
|
7681
|
+
|
|
7682
|
+
/**
|
|
7683
|
+
* Represents the possible values of a schema type's `validation` field.
|
|
7684
|
+
*
|
|
7685
|
+
* If the schema has not been run through `inferFromSchema` from
|
|
7686
|
+
* `sanity/validation` then value could be a function.
|
|
7687
|
+
*
|
|
7688
|
+
* `inferFromSchema` mutates the schema converts this value to an array of
|
|
7689
|
+
* `Rule` instances.
|
|
7690
|
+
*
|
|
7691
|
+
* @privateRemarks
|
|
7692
|
+
*
|
|
7693
|
+
* Usage of the schema inside the studio will almost always be from the compiled
|
|
7694
|
+
* `createSchema` function. In this case, you can cast the value or throw to
|
|
7695
|
+
* narrow the type. E.g.:
|
|
7696
|
+
*
|
|
7697
|
+
* ```ts
|
|
7698
|
+
* if (typeof type.validation === 'function') {
|
|
7699
|
+
* throw new Error(
|
|
7700
|
+
* `Schema type "${type.name}"'s \`validation\` was not run though \`inferFromSchema\``
|
|
7701
|
+
* )
|
|
7702
|
+
* }
|
|
7703
|
+
* ```
|
|
7704
|
+
*
|
|
7705
|
+
* @public
|
|
7706
|
+
*/
|
|
7707
|
+
declare type SchemaValidationValue =
|
|
7708
|
+
| false
|
|
7709
|
+
| undefined
|
|
7710
|
+
| Rule
|
|
7711
|
+
| SchemaValidationValue[]
|
|
7712
|
+
| ((rule: Rule) => SchemaValidationValue)
|
|
7713
|
+
|
|
7714
|
+
/** @internal */
|
|
7715
|
+
declare interface SchemaValidationWarning {
|
|
7716
|
+
helpId?: string
|
|
7717
|
+
message: string
|
|
7718
|
+
severity: 'warning'
|
|
7719
|
+
}
|
|
7720
|
+
|
|
7721
|
+
/** @public */
|
|
7722
|
+
declare interface SearchConfiguration {
|
|
7723
|
+
search?: {
|
|
7724
|
+
/**
|
|
7725
|
+
* Defines a search weight for this field to prioritize its importance
|
|
7726
|
+
* during search operations in the Studio. This setting allows the specified
|
|
7727
|
+
* field to be ranked higher in search results compared to other fields.
|
|
7728
|
+
*
|
|
7729
|
+
* By default, all fields are assigned a weight of 1. However, if a field is
|
|
7730
|
+
* chosen as the `title` in the preview configuration's `select` option, it
|
|
7731
|
+
* will automatically receive a default weight of 10. Similarly, if selected
|
|
7732
|
+
* as the `subtitle`, the default weight is 5. Fields marked as
|
|
7733
|
+
* `hidden: true` (no function) are assigned a weight of 0 by default.
|
|
7734
|
+
*
|
|
7735
|
+
* Note: Search weight configuration is currently supported only for fields
|
|
7736
|
+
* of type string or portable text arrays.
|
|
7737
|
+
*/
|
|
7738
|
+
weight?: number
|
|
7739
|
+
}
|
|
7740
|
+
}
|
|
7741
|
+
|
|
7742
|
+
/**
|
|
7743
|
+
* @public
|
|
7744
|
+
*/
|
|
7745
|
+
declare const searchStrategies: readonly ['groqLegacy', 'groq2024']
|
|
7746
|
+
|
|
7747
|
+
/**
|
|
7748
|
+
* @public
|
|
7749
|
+
*/
|
|
7750
|
+
declare type SearchStrategy = (typeof searchStrategies)[number]
|
|
7751
|
+
|
|
5800
7752
|
declare type Serializer<TMIMEType extends MIMEType> = ({
|
|
5801
7753
|
snapshot,
|
|
5802
7754
|
event,
|
|
@@ -5809,8 +7761,159 @@ declare type Serializer<TMIMEType extends MIMEType> = ({
|
|
|
5809
7761
|
'serialization.success' | 'serialization.failure'
|
|
5810
7762
|
>
|
|
5811
7763
|
|
|
7764
|
+
/** @public */
|
|
7765
|
+
declare interface SingleFieldSet {
|
|
7766
|
+
single: true
|
|
7767
|
+
field: ObjectField
|
|
7768
|
+
hidden?: ConditionalProperty
|
|
7769
|
+
readOnly?: ConditionalProperty
|
|
7770
|
+
group?: string | string[]
|
|
7771
|
+
}
|
|
7772
|
+
|
|
7773
|
+
/** @public */
|
|
7774
|
+
declare interface SlugDefinition extends BaseSchemaDefinition {
|
|
7775
|
+
type: 'slug'
|
|
7776
|
+
options?: SlugOptions
|
|
7777
|
+
validation?: ValidationBuilder<SlugRule, SlugValue>
|
|
7778
|
+
initialValue?: InitialValueProperty<any, Omit<SlugValue, '_type'>>
|
|
7779
|
+
}
|
|
7780
|
+
|
|
7781
|
+
/** @public */
|
|
7782
|
+
declare type SlugifierFn = (
|
|
7783
|
+
source: string,
|
|
7784
|
+
schemaType: SlugSchemaType,
|
|
7785
|
+
context: SlugSourceContext,
|
|
7786
|
+
) => string | Promise<string>
|
|
7787
|
+
|
|
7788
|
+
/** @public */
|
|
7789
|
+
declare type SlugIsUniqueValidator = (
|
|
7790
|
+
slug: string,
|
|
7791
|
+
context: SlugValidationContext,
|
|
7792
|
+
) => boolean | Promise<boolean>
|
|
7793
|
+
|
|
7794
|
+
/** @public */
|
|
7795
|
+
declare interface SlugOptions
|
|
7796
|
+
extends SearchConfiguration,
|
|
7797
|
+
BaseSchemaTypeOptions {
|
|
7798
|
+
source?: string | Path | SlugSourceFn
|
|
7799
|
+
maxLength?: number
|
|
7800
|
+
slugify?: SlugifierFn
|
|
7801
|
+
isUnique?: SlugIsUniqueValidator
|
|
7802
|
+
disableArrayWarning?: boolean
|
|
7803
|
+
}
|
|
7804
|
+
|
|
7805
|
+
/** @public */
|
|
7806
|
+
declare type SlugParent = Record<string, unknown> | Record<string, unknown>[]
|
|
7807
|
+
|
|
7808
|
+
/** @public */
|
|
7809
|
+
declare interface SlugRule extends RuleDef<SlugRule, SlugValue> {}
|
|
7810
|
+
|
|
7811
|
+
/** @public */
|
|
7812
|
+
declare interface SlugSchemaType extends ObjectSchemaType {
|
|
7813
|
+
jsonType: 'object'
|
|
7814
|
+
options?: SlugOptions
|
|
7815
|
+
}
|
|
7816
|
+
|
|
7817
|
+
/** @public */
|
|
7818
|
+
declare interface SlugSourceContext {
|
|
7819
|
+
parentPath: Path
|
|
7820
|
+
parent: SlugParent
|
|
7821
|
+
projectId: string
|
|
7822
|
+
dataset: string
|
|
7823
|
+
schema: Schema
|
|
7824
|
+
currentUser: CurrentUser | null
|
|
7825
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
7826
|
+
}
|
|
7827
|
+
|
|
7828
|
+
/** @public */
|
|
7829
|
+
declare type SlugSourceFn = (
|
|
7830
|
+
document: SanityDocument,
|
|
7831
|
+
context: SlugSourceContext,
|
|
7832
|
+
) => string | Promise<string>
|
|
7833
|
+
|
|
7834
|
+
/** @public */
|
|
7835
|
+
declare interface SlugValidationContext extends ValidationContext {
|
|
7836
|
+
parent: SlugParent
|
|
7837
|
+
type: SlugSchemaType
|
|
7838
|
+
defaultIsUnique: SlugIsUniqueValidator
|
|
7839
|
+
}
|
|
7840
|
+
|
|
7841
|
+
/** @public */
|
|
7842
|
+
declare interface SlugValue {
|
|
7843
|
+
_type: 'slug'
|
|
7844
|
+
current?: string
|
|
7845
|
+
}
|
|
7846
|
+
|
|
7847
|
+
/** @beta */
|
|
7848
|
+
declare type SortOrdering = {
|
|
7849
|
+
title: string
|
|
7850
|
+
i18n?: I18nTextRecord<'title'>
|
|
7851
|
+
name: string
|
|
7852
|
+
by: SortOrderingItem[]
|
|
7853
|
+
}
|
|
7854
|
+
|
|
7855
|
+
/** @beta */
|
|
7856
|
+
declare interface SortOrderingItem {
|
|
7857
|
+
field: string
|
|
7858
|
+
direction: 'asc' | 'desc'
|
|
7859
|
+
}
|
|
7860
|
+
|
|
5812
7861
|
declare type StrictExtract<T, U extends T> = U
|
|
5813
7862
|
|
|
7863
|
+
/** @public */
|
|
7864
|
+
declare interface StringDefinition extends BaseSchemaDefinition {
|
|
7865
|
+
type: 'string'
|
|
7866
|
+
options?: StringOptions
|
|
7867
|
+
placeholder?: string
|
|
7868
|
+
validation?: ValidationBuilder<StringRule, string>
|
|
7869
|
+
initialValue?: InitialValueProperty<any, string>
|
|
7870
|
+
}
|
|
7871
|
+
|
|
7872
|
+
/** @public */
|
|
7873
|
+
declare interface StringOptions
|
|
7874
|
+
extends EnumListProps<string>,
|
|
7875
|
+
SearchConfiguration,
|
|
7876
|
+
BaseSchemaTypeOptions {}
|
|
7877
|
+
|
|
7878
|
+
/** @public */
|
|
7879
|
+
declare interface StringRule extends RuleDef<StringRule, string> {
|
|
7880
|
+
min: (minNumber: number | FieldReference) => StringRule
|
|
7881
|
+
max: (maxNumber: number | FieldReference) => StringRule
|
|
7882
|
+
length: (exactLength: number | FieldReference) => StringRule
|
|
7883
|
+
uppercase: () => StringRule
|
|
7884
|
+
lowercase: () => StringRule
|
|
7885
|
+
regex(
|
|
7886
|
+
pattern: RegExp,
|
|
7887
|
+
name: string,
|
|
7888
|
+
options: {
|
|
7889
|
+
name?: string
|
|
7890
|
+
invert?: boolean
|
|
7891
|
+
},
|
|
7892
|
+
): StringRule
|
|
7893
|
+
regex(
|
|
7894
|
+
pattern: RegExp,
|
|
7895
|
+
options: {
|
|
7896
|
+
name?: string
|
|
7897
|
+
invert?: boolean
|
|
7898
|
+
},
|
|
7899
|
+
): StringRule
|
|
7900
|
+
regex(pattern: RegExp, name: string): StringRule
|
|
7901
|
+
regex(pattern: RegExp): StringRule
|
|
7902
|
+
email(): StringRule
|
|
7903
|
+
}
|
|
7904
|
+
|
|
7905
|
+
/**
|
|
7906
|
+
* This is used for string, text, date and datetime.
|
|
7907
|
+
* This interface represent the compiled version at runtime, when accessed through Schema.
|
|
7908
|
+
*
|
|
7909
|
+
* @public
|
|
7910
|
+
*/
|
|
7911
|
+
declare interface StringSchemaType extends BaseSchemaType {
|
|
7912
|
+
jsonType: 'string'
|
|
7913
|
+
options?: StringOptions & TextOptions & DateOptions & DatetimeOptions
|
|
7914
|
+
initialValue?: InitialValueProperty<any, string>
|
|
7915
|
+
}
|
|
7916
|
+
|
|
5814
7917
|
/**
|
|
5815
7918
|
* @beta
|
|
5816
7919
|
*/
|
|
@@ -5960,9 +8063,199 @@ declare type TextBlockWithOptionalKey = Omit<PortableTextTextBlock, '_key'> & {
|
|
|
5960
8063
|
_key?: PortableTextTextBlock['_key']
|
|
5961
8064
|
}
|
|
5962
8065
|
|
|
8066
|
+
/** @public */
|
|
8067
|
+
declare interface TextDefinition extends BaseSchemaDefinition {
|
|
8068
|
+
type: 'text'
|
|
8069
|
+
rows?: number
|
|
8070
|
+
options?: TextOptions
|
|
8071
|
+
placeholder?: string
|
|
8072
|
+
validation?: ValidationBuilder<TextRule, string>
|
|
8073
|
+
initialValue?: InitialValueProperty<any, string>
|
|
8074
|
+
}
|
|
8075
|
+
|
|
8076
|
+
/** @public */
|
|
8077
|
+
declare interface TextOptions extends StringOptions {}
|
|
8078
|
+
|
|
8079
|
+
/** @public */
|
|
8080
|
+
declare interface TextRule extends StringRule {}
|
|
8081
|
+
|
|
8082
|
+
/** @public */
|
|
8083
|
+
declare interface TitledListValue<V = unknown> {
|
|
8084
|
+
_key?: string
|
|
8085
|
+
title: string
|
|
8086
|
+
value?: V
|
|
8087
|
+
}
|
|
8088
|
+
|
|
8089
|
+
/**
|
|
8090
|
+
* Represents a type definition that is an alias/extension of an existing type
|
|
8091
|
+
* in your schema. Creating a type alias will re-register that existing type
|
|
8092
|
+
* under a different name. You can also override the default type options with
|
|
8093
|
+
* a type alias definition.
|
|
8094
|
+
*
|
|
8095
|
+
* @public
|
|
8096
|
+
*/
|
|
8097
|
+
declare interface TypeAliasDefinition<
|
|
8098
|
+
TType extends string,
|
|
8099
|
+
TAlias extends IntrinsicTypeName | undefined,
|
|
8100
|
+
> extends BaseSchemaDefinition {
|
|
8101
|
+
type: TType
|
|
8102
|
+
options?: TAlias extends IntrinsicTypeName
|
|
8103
|
+
? IntrinsicDefinitions[TAlias]['options']
|
|
8104
|
+
: unknown
|
|
8105
|
+
validation?: SchemaValidationValue
|
|
8106
|
+
initialValue?: InitialValueProperty<any, any>
|
|
8107
|
+
preview?: PreviewConfig
|
|
8108
|
+
components?: {
|
|
8109
|
+
annotation?: ComponentType<any>
|
|
8110
|
+
block?: ComponentType<any>
|
|
8111
|
+
inlineBlock?: ComponentType<any>
|
|
8112
|
+
diff?: ComponentType<any>
|
|
8113
|
+
field?: ComponentType<any>
|
|
8114
|
+
input?: ComponentType<any>
|
|
8115
|
+
item?: ComponentType<any>
|
|
8116
|
+
preview?: ComponentType<any>
|
|
8117
|
+
}
|
|
8118
|
+
}
|
|
8119
|
+
|
|
8120
|
+
/**
|
|
8121
|
+
* Represents a reference to another type registered top-level in your schema.
|
|
8122
|
+
*
|
|
8123
|
+
* @public
|
|
8124
|
+
*/
|
|
8125
|
+
declare interface TypeReference {
|
|
8126
|
+
type: string
|
|
8127
|
+
name?: string
|
|
8128
|
+
icon?: ComponentType | ReactNode
|
|
8129
|
+
options?: {
|
|
8130
|
+
[key: string]: unknown
|
|
8131
|
+
}
|
|
8132
|
+
}
|
|
8133
|
+
|
|
5963
8134
|
declare type UnsetEvent = {
|
|
5964
8135
|
type: 'unset'
|
|
5965
8136
|
previousValue: Array<PortableTextBlock>
|
|
5966
8137
|
}
|
|
5967
8138
|
|
|
8139
|
+
/** @public */
|
|
8140
|
+
declare interface UriValidationOptions {
|
|
8141
|
+
scheme?: (string | RegExp) | Array<string | RegExp>
|
|
8142
|
+
allowRelative?: boolean
|
|
8143
|
+
relativeOnly?: boolean
|
|
8144
|
+
allowCredentials?: boolean
|
|
8145
|
+
}
|
|
8146
|
+
|
|
8147
|
+
/** @public */
|
|
8148
|
+
declare interface UrlDefinition extends BaseSchemaDefinition {
|
|
8149
|
+
type: 'url'
|
|
8150
|
+
options?: UrlOptions
|
|
8151
|
+
placeholder?: string
|
|
8152
|
+
validation?: ValidationBuilder<UrlRule, string>
|
|
8153
|
+
initialValue?: InitialValueProperty<any, string>
|
|
8154
|
+
}
|
|
8155
|
+
|
|
8156
|
+
/** @public */
|
|
8157
|
+
declare interface UrlOptions extends BaseSchemaTypeOptions {}
|
|
8158
|
+
|
|
8159
|
+
/** @public */
|
|
8160
|
+
declare interface UrlRule extends RuleDef<UrlRule, string> {
|
|
8161
|
+
uri(options: UriValidationOptions): UrlRule
|
|
8162
|
+
}
|
|
8163
|
+
|
|
8164
|
+
/** @public */
|
|
8165
|
+
declare type ValidationBuilder<
|
|
8166
|
+
T extends RuleDef<T, FieldValue>,
|
|
8167
|
+
FieldValue = unknown,
|
|
8168
|
+
> = (rule: T) => RuleBuilder<T, FieldValue>
|
|
8169
|
+
|
|
8170
|
+
/**
|
|
8171
|
+
* A context object passed around during validation. This includes the
|
|
8172
|
+
* `Rule.custom` context.
|
|
8173
|
+
*
|
|
8174
|
+
* e.g.
|
|
8175
|
+
*
|
|
8176
|
+
* ```js
|
|
8177
|
+
* Rule.custom((_, validationContext) => {
|
|
8178
|
+
* // ...
|
|
8179
|
+
* })`
|
|
8180
|
+
* ```
|
|
8181
|
+
*
|
|
8182
|
+
* @public
|
|
8183
|
+
*/
|
|
8184
|
+
declare interface ValidationContext {
|
|
8185
|
+
getClient: (options: {apiVersion: string}) => SanityClient
|
|
8186
|
+
schema: Schema
|
|
8187
|
+
parent?: unknown
|
|
8188
|
+
type?: SchemaType
|
|
8189
|
+
document?: SanityDocument
|
|
8190
|
+
path?: Path
|
|
8191
|
+
getDocumentExists?: (options: {id: string}) => Promise<boolean>
|
|
8192
|
+
environment: 'cli' | 'studio'
|
|
8193
|
+
}
|
|
8194
|
+
|
|
8195
|
+
/**
|
|
8196
|
+
* The shape that can be returned from a custom validator to be converted into
|
|
8197
|
+
* a validation marker by the validation logic. Inside of a custom validator,
|
|
8198
|
+
* you can return an array of these in order to specify multiple paths within
|
|
8199
|
+
* an object or array.
|
|
8200
|
+
*
|
|
8201
|
+
* @public
|
|
8202
|
+
*/
|
|
8203
|
+
declare interface ValidationError {
|
|
8204
|
+
/**
|
|
8205
|
+
* The message describing why the value is not valid. This message will be
|
|
8206
|
+
* included in the validation markers after validation has finished running.
|
|
8207
|
+
*/
|
|
8208
|
+
message: string
|
|
8209
|
+
/**
|
|
8210
|
+
* If writing a custom validator, you can return validation messages to
|
|
8211
|
+
* specific path inside of the current value (object or array) by populating
|
|
8212
|
+
* this `path` prop.
|
|
8213
|
+
*
|
|
8214
|
+
* NOTE: This path is relative to the current value and _not_ relative to
|
|
8215
|
+
* the document.
|
|
8216
|
+
*/
|
|
8217
|
+
path?: Path
|
|
8218
|
+
/**
|
|
8219
|
+
* Same as `path` but allows more than one value. If provided, the same
|
|
8220
|
+
* message will create two markers from each path with the same message
|
|
8221
|
+
* provided.
|
|
8222
|
+
*
|
|
8223
|
+
* @deprecated prefer `path`
|
|
8224
|
+
*/
|
|
8225
|
+
paths?: Path[]
|
|
8226
|
+
/**
|
|
8227
|
+
* @deprecated Unused. Was used to store the results from `.either()` /`.all()`
|
|
8228
|
+
*/
|
|
8229
|
+
children?: ValidationMarker[]
|
|
8230
|
+
/**
|
|
8231
|
+
* @deprecated Unused. Was used to signal if this error came from an `.either()`/`.all()`.
|
|
8232
|
+
*/
|
|
8233
|
+
operation?: 'AND' | 'OR'
|
|
8234
|
+
/**
|
|
8235
|
+
* @deprecated Unused. Was relevant when validation error was used as a class.
|
|
8236
|
+
*/
|
|
8237
|
+
cloneWithMessage?(message: string): ValidationError
|
|
8238
|
+
}
|
|
8239
|
+
|
|
8240
|
+
/** @public */
|
|
8241
|
+
declare interface ValidationMarker {
|
|
8242
|
+
level: 'error' | 'warning' | 'info'
|
|
8243
|
+
/**
|
|
8244
|
+
* The validation message for this marker. E.g. "Must be greater than 0"
|
|
8245
|
+
*/
|
|
8246
|
+
message: string
|
|
8247
|
+
/**
|
|
8248
|
+
* @deprecated use `message` instead
|
|
8249
|
+
*/
|
|
8250
|
+
item?: ValidationError
|
|
8251
|
+
/**
|
|
8252
|
+
* The sanity path _relative to the root of the current document_ to this
|
|
8253
|
+
* marker.
|
|
8254
|
+
*
|
|
8255
|
+
* NOTE: Sanity paths may contain keyed segments (i.e. `{_key: string}`) that
|
|
8256
|
+
* are not compatible with deep getters like lodash/get
|
|
8257
|
+
*/
|
|
8258
|
+
path: Path
|
|
8259
|
+
}
|
|
8260
|
+
|
|
5968
8261
|
export {}
|