@sanity/media-library-types 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.cts CHANGED
@@ -67,10 +67,7 @@ declare interface ArrayOptions<V = unknown>
67
67
  /** @deprecated This option does not have any effect anymore */
68
68
  direction?: "horizontal" | "vertical";
69
69
  sortable?: boolean;
70
- modal?: {
71
- type?: "dialog" | "popover";
72
- width?: number | "auto";
73
- };
70
+ modal?: ModalOptions;
74
71
  /** @alpha This API may change */
75
72
  insertMenu?: InsertMenuOptions;
76
73
  /**
@@ -589,9 +586,10 @@ declare interface BlockDefinition extends BaseSchemaDefinition {
589
586
  lists?: BlockListDefinition[];
590
587
  marks?: BlockMarksDefinition;
591
588
  of?: ArrayOfType<"object" | "reference">[];
592
- initialValue?: InitialValueProperty<any, any[]>;
589
+ /** Block types do not support initialValue - the runtime schema validation rejects it. */
590
+ initialValue?: never;
593
591
  options?: BlockOptions;
594
- validation?: ValidationBuilder<BlockRule, any[]>;
592
+ validation?: ValidationBuilder<BlockRule, PortableTextBlock>;
595
593
  }
596
594
 
597
595
  /**
@@ -654,7 +652,7 @@ declare interface BlockOptions extends BaseSchemaTypeOptions {
654
652
  }
655
653
 
656
654
  /** @public */
657
- declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
655
+ declare interface BlockRule extends RuleDef<BlockRule, PortableTextBlock> {}
658
656
 
659
657
  /**
660
658
  * Schema definition for a text block style.
@@ -1526,6 +1524,13 @@ declare interface MediaValidator<T extends MediaAssetTypes = MediaAssetTypes> {
1526
1524
  ): CustomValidatorResult | Promise<CustomValidatorResult>;
1527
1525
  }
1528
1526
 
1527
+ /** @public */
1528
+ /** @public */
1529
+ declare interface ModalOptions {
1530
+ type?: "dialog" | "popover";
1531
+ width?: 1 | 2 | 3 | 4 | 5 | "auto" | (1 | 2 | 3 | 4 | 5 | "auto")[];
1532
+ }
1533
+
1529
1534
  /** @public */
1530
1535
  declare interface MultiFieldSet {
1531
1536
  name: string;
@@ -1607,10 +1612,7 @@ declare interface ObjectOptions extends BaseSchemaTypeOptions {
1607
1612
  collapsible?: boolean;
1608
1613
  collapsed?: boolean;
1609
1614
  columns?: number;
1610
- modal?: {
1611
- type?: "dialog" | "popover";
1612
- width?: number | number[] | "auto";
1613
- };
1615
+ modal?: ModalOptions;
1614
1616
  }
1615
1617
 
1616
1618
  /** @public */
@@ -1781,6 +1783,37 @@ export declare type PluginPostMessageUploadFilesResponse = {
1781
1783
  */
1782
1784
  export declare type PluginSelectAssetType = "file" | "image" | "video";
1783
1785
 
1786
+ /** @public */
1787
+ declare type PortableTextBlock = PortableTextTextBlock | PortableTextObject;
1788
+
1789
+ /** @public */
1790
+ declare interface PortableTextObject {
1791
+ _type: string;
1792
+ _key: string;
1793
+ [other: string]: unknown;
1794
+ }
1795
+
1796
+ /** @public */
1797
+ declare interface PortableTextSpan {
1798
+ _key: string;
1799
+ _type: "span";
1800
+ text: string;
1801
+ marks?: string[];
1802
+ }
1803
+
1804
+ /** @public */
1805
+ declare interface PortableTextTextBlock<
1806
+ TChild = PortableTextSpan | PortableTextObject,
1807
+ > {
1808
+ _type: string;
1809
+ _key: string;
1810
+ children: TChild[];
1811
+ markDefs?: PortableTextObject[];
1812
+ listItem?: string;
1813
+ style?: string;
1814
+ level?: number;
1815
+ }
1816
+
1784
1817
  /** @public */
1785
1818
  declare interface PrepareViewOptions {
1786
1819
  /** @beta */
@@ -2287,6 +2320,7 @@ declare type SanityAssetCollection = {
2287
2320
  _key: string;
2288
2321
  } & SanityAssetReference
2289
2322
  >;
2323
+ _system?: SanitySystem;
2290
2324
  };
2291
2325
 
2292
2326
  declare type SanityAssetInstanceState = string;
package/lib/index.d.ts CHANGED
@@ -67,10 +67,7 @@ declare interface ArrayOptions<V = unknown>
67
67
  /** @deprecated This option does not have any effect anymore */
68
68
  direction?: "horizontal" | "vertical";
69
69
  sortable?: boolean;
70
- modal?: {
71
- type?: "dialog" | "popover";
72
- width?: number | "auto";
73
- };
70
+ modal?: ModalOptions;
74
71
  /** @alpha This API may change */
75
72
  insertMenu?: InsertMenuOptions;
76
73
  /**
@@ -589,9 +586,10 @@ declare interface BlockDefinition extends BaseSchemaDefinition {
589
586
  lists?: BlockListDefinition[];
590
587
  marks?: BlockMarksDefinition;
591
588
  of?: ArrayOfType<"object" | "reference">[];
592
- initialValue?: InitialValueProperty<any, any[]>;
589
+ /** Block types do not support initialValue - the runtime schema validation rejects it. */
590
+ initialValue?: never;
593
591
  options?: BlockOptions;
594
- validation?: ValidationBuilder<BlockRule, any[]>;
592
+ validation?: ValidationBuilder<BlockRule, PortableTextBlock>;
595
593
  }
596
594
 
597
595
  /**
@@ -654,7 +652,7 @@ declare interface BlockOptions extends BaseSchemaTypeOptions {
654
652
  }
655
653
 
656
654
  /** @public */
657
- declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
655
+ declare interface BlockRule extends RuleDef<BlockRule, PortableTextBlock> {}
658
656
 
659
657
  /**
660
658
  * Schema definition for a text block style.
@@ -1526,6 +1524,13 @@ declare interface MediaValidator<T extends MediaAssetTypes = MediaAssetTypes> {
1526
1524
  ): CustomValidatorResult | Promise<CustomValidatorResult>;
1527
1525
  }
1528
1526
 
1527
+ /** @public */
1528
+ /** @public */
1529
+ declare interface ModalOptions {
1530
+ type?: "dialog" | "popover";
1531
+ width?: 1 | 2 | 3 | 4 | 5 | "auto" | (1 | 2 | 3 | 4 | 5 | "auto")[];
1532
+ }
1533
+
1529
1534
  /** @public */
1530
1535
  declare interface MultiFieldSet {
1531
1536
  name: string;
@@ -1607,10 +1612,7 @@ declare interface ObjectOptions extends BaseSchemaTypeOptions {
1607
1612
  collapsible?: boolean;
1608
1613
  collapsed?: boolean;
1609
1614
  columns?: number;
1610
- modal?: {
1611
- type?: "dialog" | "popover";
1612
- width?: number | number[] | "auto";
1613
- };
1615
+ modal?: ModalOptions;
1614
1616
  }
1615
1617
 
1616
1618
  /** @public */
@@ -1781,6 +1783,37 @@ export declare type PluginPostMessageUploadFilesResponse = {
1781
1783
  */
1782
1784
  export declare type PluginSelectAssetType = "file" | "image" | "video";
1783
1785
 
1786
+ /** @public */
1787
+ declare type PortableTextBlock = PortableTextTextBlock | PortableTextObject;
1788
+
1789
+ /** @public */
1790
+ declare interface PortableTextObject {
1791
+ _type: string;
1792
+ _key: string;
1793
+ [other: string]: unknown;
1794
+ }
1795
+
1796
+ /** @public */
1797
+ declare interface PortableTextSpan {
1798
+ _key: string;
1799
+ _type: "span";
1800
+ text: string;
1801
+ marks?: string[];
1802
+ }
1803
+
1804
+ /** @public */
1805
+ declare interface PortableTextTextBlock<
1806
+ TChild = PortableTextSpan | PortableTextObject,
1807
+ > {
1808
+ _type: string;
1809
+ _key: string;
1810
+ children: TChild[];
1811
+ markDefs?: PortableTextObject[];
1812
+ listItem?: string;
1813
+ style?: string;
1814
+ level?: number;
1815
+ }
1816
+
1784
1817
  /** @public */
1785
1818
  declare interface PrepareViewOptions {
1786
1819
  /** @beta */
@@ -2287,6 +2320,7 @@ declare type SanityAssetCollection = {
2287
2320
  _key: string;
2288
2321
  } & SanityAssetReference
2289
2322
  >;
2323
+ _system?: SanitySystem;
2290
2324
  };
2291
2325
 
2292
2326
  declare type SanityAssetInstanceState = string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/media-library-types",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Type definitions for common Sanity Media Library data structures",
5
5
  "keywords": [
6
6
  "content",
@@ -37,8 +37,8 @@
37
37
  "./package.json": "./package.json"
38
38
  },
39
39
  "devDependencies": {
40
- "@sanity/pkg-utils": "10.4.15",
41
- "@sanity/types": "5.21.0",
40
+ "@sanity/pkg-utils": "10.5.6",
41
+ "@sanity/types": "5.31.1",
42
42
  "rimraf": "5.0.10"
43
43
  },
44
44
  "scripts": {
@@ -41,6 +41,7 @@ export type SanitySymlink = {
41
41
  parent?: SanityDirectoryReference
42
42
  rootDirectory?: SanityDirectoryReference
43
43
  target?: SanityAssetReference
44
+ _system?: SanitySystem
44
45
  }
45
46
 
46
47
  export type SanityTreeReference = {
@@ -65,6 +66,7 @@ export type SanityAssetCollection = {
65
66
  _key: string
66
67
  } & SanityAssetReference
67
68
  >
69
+ _system?: SanitySystem
68
70
  }
69
71
 
70
72
  export type SanityVideoMetadataRendition = {
@@ -393,6 +395,7 @@ export type SanityDirectory = {
393
395
  name?: string
394
396
  parent?: SanityDirectoryReference | SanityTreeReference
395
397
  rootDirectory?: SanityDirectoryReference
398
+ _system?: SanitySystem
396
399
  }
397
400
 
398
401
  export type SanityTree = {
@@ -402,6 +405,7 @@ export type SanityTree = {
402
405
  _updatedAt: string
403
406
  _rev: string
404
407
  name?: string
408
+ _system?: SanitySystem
405
409
  }
406
410
 
407
411
  export type AllSanitySchemaTypes =