@sanity/media-library-types 1.3.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
@@ -57,7 +57,7 @@ declare type ArrayOfType<
57
57
  TAlias extends IntrinsicTypeName | undefined = undefined,
58
58
  > =
59
59
  | IntrinsicArrayOfDefinition[TType]
60
- | ArrayOfEntry<TypeAliasDefinition<string, TAlias>>;
60
+ | ArrayOfEntry<TypeAliasDefinition<AutocompleteString, TAlias>>;
61
61
 
62
62
  /** @public */
63
63
  declare interface ArrayOptions<V = unknown>
@@ -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
  /**
@@ -415,6 +412,20 @@ export declare interface AssetVersion<
415
412
  instance: AssetInstance;
416
413
  }
417
414
 
415
+ /**
416
+ * Enhances VSCode autocomplete by using a distinct type for strings.
417
+ *
418
+ * `AllowOtherStrings` is defined as `string & {}`, an intersection that behaves
419
+ * like `string` but is treated differently by TypeScript's type system for
420
+ * internal processing. This helps in improving the specificity and relevance of
421
+ * autocomplete suggestions by potentially prioritizing `IntrinsicTypeName`
422
+ * over general string inputs, addressing issues where `string` type suggestions
423
+ * might overshadow more useful specific literals.
424
+ *
425
+ * @beta
426
+ */
427
+ declare type AutocompleteString = string & {};
428
+
418
429
  export declare type BaseDocument = {
419
430
  _id: string;
420
431
  _type: string;
@@ -575,9 +586,10 @@ declare interface BlockDefinition extends BaseSchemaDefinition {
575
586
  lists?: BlockListDefinition[];
576
587
  marks?: BlockMarksDefinition;
577
588
  of?: ArrayOfType<"object" | "reference">[];
578
- initialValue?: InitialValueProperty<any, any[]>;
589
+ /** Block types do not support initialValue - the runtime schema validation rejects it. */
590
+ initialValue?: never;
579
591
  options?: BlockOptions;
580
- validation?: ValidationBuilder<BlockRule, any[]>;
592
+ validation?: ValidationBuilder<BlockRule, PortableTextBlock>;
581
593
  }
582
594
 
583
595
  /**
@@ -640,7 +652,7 @@ declare interface BlockOptions extends BaseSchemaTypeOptions {
640
652
  }
641
653
 
642
654
  /** @public */
643
- declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
655
+ declare interface BlockRule extends RuleDef<BlockRule, PortableTextBlock> {}
644
656
 
645
657
  /**
646
658
  * Schema definition for a text block style.
@@ -967,7 +979,10 @@ declare interface EnumListProps<V = unknown> {
967
979
  declare type FieldDefinition<
968
980
  TType extends IntrinsicTypeName = IntrinsicTypeName,
969
981
  TAlias extends IntrinsicTypeName | undefined = undefined,
970
- > = (InlineFieldDefinition[TType] | TypeAliasDefinition<string, TAlias>) &
982
+ > = (
983
+ | InlineFieldDefinition[TType]
984
+ | TypeAliasDefinition<AutocompleteString, TAlias>
985
+ ) &
971
986
  FieldDefinitionBase;
972
987
 
973
988
  /** @public */
@@ -1509,6 +1524,13 @@ declare interface MediaValidator<T extends MediaAssetTypes = MediaAssetTypes> {
1509
1524
  ): CustomValidatorResult | Promise<CustomValidatorResult>;
1510
1525
  }
1511
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
+
1512
1534
  /** @public */
1513
1535
  declare interface MultiFieldSet {
1514
1536
  name: string;
@@ -1590,10 +1612,7 @@ declare interface ObjectOptions extends BaseSchemaTypeOptions {
1590
1612
  collapsible?: boolean;
1591
1613
  collapsed?: boolean;
1592
1614
  columns?: number;
1593
- modal?: {
1594
- type?: "dialog" | "popover";
1595
- width?: number | number[] | "auto";
1596
- };
1615
+ modal?: ModalOptions;
1597
1616
  }
1598
1617
 
1599
1618
  /** @public */
@@ -1662,6 +1681,13 @@ export declare type PluginPayload = {
1662
1681
  scheme: "light" | "dark";
1663
1682
  selectAssetTypes: PluginSelectAssetType[];
1664
1683
  selectionType: "single" | "multiple";
1684
+ /**
1685
+ * Opaque string the host generates to **partition persisted picker UI state** (e.g. folder path,
1686
+ * search query, filters) in the Media Library iframe. Huey derives `localStorage` key suffixes
1687
+ * from this value; embedders often derive it from project + dataset + workspace (or any stable
1688
+ * context).
1689
+ */
1690
+ pickerPersistenceKey?: string;
1665
1691
  };
1666
1692
 
1667
1693
  export declare type PluginPostMessage =
@@ -1757,6 +1783,37 @@ export declare type PluginPostMessageUploadFilesResponse = {
1757
1783
  */
1758
1784
  export declare type PluginSelectAssetType = "file" | "image" | "video";
1759
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
+
1760
1817
  /** @public */
1761
1818
  declare interface PrepareViewOptions {
1762
1819
  /** @beta */
@@ -2263,6 +2320,7 @@ declare type SanityAssetCollection = {
2263
2320
  _key: string;
2264
2321
  } & SanityAssetReference
2265
2322
  >;
2323
+ _system?: SanitySystem;
2266
2324
  };
2267
2325
 
2268
2326
  declare type SanityAssetInstanceState = string;
@@ -2635,7 +2693,7 @@ declare type SchemaTypeDefinition<
2635
2693
  TType extends IntrinsicTypeName = IntrinsicTypeName,
2636
2694
  > =
2637
2695
  | IntrinsicDefinitions[IntrinsicTypeName]
2638
- | TypeAliasDefinition<string, TType>;
2696
+ | TypeAliasDefinition<AutocompleteString, TType>;
2639
2697
 
2640
2698
  /** @public */
2641
2699
  declare interface SchemaValidationError {
package/lib/index.d.ts CHANGED
@@ -57,7 +57,7 @@ declare type ArrayOfType<
57
57
  TAlias extends IntrinsicTypeName | undefined = undefined,
58
58
  > =
59
59
  | IntrinsicArrayOfDefinition[TType]
60
- | ArrayOfEntry<TypeAliasDefinition<string, TAlias>>;
60
+ | ArrayOfEntry<TypeAliasDefinition<AutocompleteString, TAlias>>;
61
61
 
62
62
  /** @public */
63
63
  declare interface ArrayOptions<V = unknown>
@@ -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
  /**
@@ -415,6 +412,20 @@ export declare interface AssetVersion<
415
412
  instance: AssetInstance;
416
413
  }
417
414
 
415
+ /**
416
+ * Enhances VSCode autocomplete by using a distinct type for strings.
417
+ *
418
+ * `AllowOtherStrings` is defined as `string & {}`, an intersection that behaves
419
+ * like `string` but is treated differently by TypeScript's type system for
420
+ * internal processing. This helps in improving the specificity and relevance of
421
+ * autocomplete suggestions by potentially prioritizing `IntrinsicTypeName`
422
+ * over general string inputs, addressing issues where `string` type suggestions
423
+ * might overshadow more useful specific literals.
424
+ *
425
+ * @beta
426
+ */
427
+ declare type AutocompleteString = string & {};
428
+
418
429
  export declare type BaseDocument = {
419
430
  _id: string;
420
431
  _type: string;
@@ -575,9 +586,10 @@ declare interface BlockDefinition extends BaseSchemaDefinition {
575
586
  lists?: BlockListDefinition[];
576
587
  marks?: BlockMarksDefinition;
577
588
  of?: ArrayOfType<"object" | "reference">[];
578
- initialValue?: InitialValueProperty<any, any[]>;
589
+ /** Block types do not support initialValue - the runtime schema validation rejects it. */
590
+ initialValue?: never;
579
591
  options?: BlockOptions;
580
- validation?: ValidationBuilder<BlockRule, any[]>;
592
+ validation?: ValidationBuilder<BlockRule, PortableTextBlock>;
581
593
  }
582
594
 
583
595
  /**
@@ -640,7 +652,7 @@ declare interface BlockOptions extends BaseSchemaTypeOptions {
640
652
  }
641
653
 
642
654
  /** @public */
643
- declare interface BlockRule extends RuleDef<BlockRule, any[]> {}
655
+ declare interface BlockRule extends RuleDef<BlockRule, PortableTextBlock> {}
644
656
 
645
657
  /**
646
658
  * Schema definition for a text block style.
@@ -967,7 +979,10 @@ declare interface EnumListProps<V = unknown> {
967
979
  declare type FieldDefinition<
968
980
  TType extends IntrinsicTypeName = IntrinsicTypeName,
969
981
  TAlias extends IntrinsicTypeName | undefined = undefined,
970
- > = (InlineFieldDefinition[TType] | TypeAliasDefinition<string, TAlias>) &
982
+ > = (
983
+ | InlineFieldDefinition[TType]
984
+ | TypeAliasDefinition<AutocompleteString, TAlias>
985
+ ) &
971
986
  FieldDefinitionBase;
972
987
 
973
988
  /** @public */
@@ -1509,6 +1524,13 @@ declare interface MediaValidator<T extends MediaAssetTypes = MediaAssetTypes> {
1509
1524
  ): CustomValidatorResult | Promise<CustomValidatorResult>;
1510
1525
  }
1511
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
+
1512
1534
  /** @public */
1513
1535
  declare interface MultiFieldSet {
1514
1536
  name: string;
@@ -1590,10 +1612,7 @@ declare interface ObjectOptions extends BaseSchemaTypeOptions {
1590
1612
  collapsible?: boolean;
1591
1613
  collapsed?: boolean;
1592
1614
  columns?: number;
1593
- modal?: {
1594
- type?: "dialog" | "popover";
1595
- width?: number | number[] | "auto";
1596
- };
1615
+ modal?: ModalOptions;
1597
1616
  }
1598
1617
 
1599
1618
  /** @public */
@@ -1662,6 +1681,13 @@ export declare type PluginPayload = {
1662
1681
  scheme: "light" | "dark";
1663
1682
  selectAssetTypes: PluginSelectAssetType[];
1664
1683
  selectionType: "single" | "multiple";
1684
+ /**
1685
+ * Opaque string the host generates to **partition persisted picker UI state** (e.g. folder path,
1686
+ * search query, filters) in the Media Library iframe. Huey derives `localStorage` key suffixes
1687
+ * from this value; embedders often derive it from project + dataset + workspace (or any stable
1688
+ * context).
1689
+ */
1690
+ pickerPersistenceKey?: string;
1665
1691
  };
1666
1692
 
1667
1693
  export declare type PluginPostMessage =
@@ -1757,6 +1783,37 @@ export declare type PluginPostMessageUploadFilesResponse = {
1757
1783
  */
1758
1784
  export declare type PluginSelectAssetType = "file" | "image" | "video";
1759
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
+
1760
1817
  /** @public */
1761
1818
  declare interface PrepareViewOptions {
1762
1819
  /** @beta */
@@ -2263,6 +2320,7 @@ declare type SanityAssetCollection = {
2263
2320
  _key: string;
2264
2321
  } & SanityAssetReference
2265
2322
  >;
2323
+ _system?: SanitySystem;
2266
2324
  };
2267
2325
 
2268
2326
  declare type SanityAssetInstanceState = string;
@@ -2635,7 +2693,7 @@ declare type SchemaTypeDefinition<
2635
2693
  TType extends IntrinsicTypeName = IntrinsicTypeName,
2636
2694
  > =
2637
2695
  | IntrinsicDefinitions[IntrinsicTypeName]
2638
- | TypeAliasDefinition<string, TType>;
2696
+ | TypeAliasDefinition<AutocompleteString, TType>;
2639
2697
 
2640
2698
  /** @public */
2641
2699
  declare interface SchemaValidationError {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/media-library-types",
3
- "version": "1.3.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.10",
41
- "@sanity/types": "5.18.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": {
package/src/plugin.ts CHANGED
@@ -33,6 +33,13 @@ export type PluginPayload = {
33
33
  scheme: 'light' | 'dark'
34
34
  selectAssetTypes: PluginSelectAssetType[]
35
35
  selectionType: 'single' | 'multiple'
36
+ /**
37
+ * Opaque string the host generates to **partition persisted picker UI state** (e.g. folder path,
38
+ * search query, filters) in the Media Library iframe. Huey derives `localStorage` key suffixes
39
+ * from this value; embedders often derive it from project + dataset + workspace (or any stable
40
+ * context).
41
+ */
42
+ pickerPersistenceKey?: string
36
43
  }
37
44
 
38
45
  /**
@@ -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 = {
@@ -186,6 +188,10 @@ export type SanityImageMetadata = {
186
188
  isOpaque: boolean
187
189
  }
188
190
 
191
+ export type SanityFileMetadata = {
192
+ _type: 'sanity.fileMetadata'
193
+ }
194
+
189
195
  export type SanityAssetVersionReference = {
190
196
  _ref: string
191
197
  _type: 'reference'
@@ -389,6 +395,7 @@ export type SanityDirectory = {
389
395
  name?: string
390
396
  parent?: SanityDirectoryReference | SanityTreeReference
391
397
  rootDirectory?: SanityDirectoryReference
398
+ _system?: SanitySystem
392
399
  }
393
400
 
394
401
  export type SanityTree = {
@@ -398,6 +405,7 @@ export type SanityTree = {
398
405
  _updatedAt: string
399
406
  _rev: string
400
407
  name?: string
408
+ _system?: SanitySystem
401
409
  }
402
410
 
403
411
  export type AllSanitySchemaTypes =
@@ -418,6 +426,7 @@ export type AllSanitySchemaTypes =
418
426
  | SanityImagePalette
419
427
  | SanityImageDimensions
420
428
  | SanityImageMetadata
429
+ | SanityFileMetadata
421
430
  | SanityAssetVersionReference
422
431
  | SanityAsset
423
432
  | SanityImageAssetReference