@sanity/media-library-types 1.0.2 → 1.2.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.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -5,6 +5,7 @@ import {ComponentType} from 'react'
5
5
  import {ElementType} from 'react'
6
6
  import {ReactNode} from 'react'
7
7
  import {SanityClient} from '@sanity/client'
8
+ import {StackablePerspective} from '@sanity/client'
8
9
 
9
10
  /**
10
11
  * Types of array actions that can be performed
@@ -945,8 +946,10 @@ declare interface File_2 {
945
946
  }
946
947
 
947
948
  /** @public */
948
- declare interface FileDefinition
949
- extends Omit<ObjectDefinition, 'type' | 'fields' | 'options' | 'groups' | 'validation'> {
949
+ declare interface FileDefinition extends Omit<
950
+ ObjectDefinition,
951
+ 'type' | 'fields' | 'options' | 'groups' | 'validation'
952
+ > {
950
953
  type: 'file'
951
954
  fields?: ObjectDefinition['fields']
952
955
  options?: FileOptions
@@ -1102,8 +1105,10 @@ declare interface ImageCrop {
1102
1105
  }
1103
1106
 
1104
1107
  /** @public */
1105
- declare interface ImageDefinition
1106
- extends Omit<ObjectDefinition, 'type' | 'fields' | 'options' | 'groups' | 'validation'> {
1108
+ declare interface ImageDefinition extends Omit<
1109
+ ObjectDefinition,
1110
+ 'type' | 'fields' | 'options' | 'groups' | 'validation'
1111
+ > {
1107
1112
  type: 'image'
1108
1113
  fields?: FieldDefinition[]
1109
1114
  options?: ImageOptions
@@ -1514,6 +1519,35 @@ declare type Path = PathSegment[]
1514
1519
  /** @public */
1515
1520
  declare type PathSegment = string | number | KeyedSegment | IndexTuple
1516
1521
 
1522
+ /**
1523
+ * Media Library capabilities that the consumer can declare it supports
1524
+ */
1525
+ export declare type PluginCapabilities = {
1526
+ privateAssets?: boolean
1527
+ }
1528
+
1529
+ /**
1530
+ * Filter that the plugin consumer can use to limit the assets shown
1531
+ */
1532
+ export declare type PluginFilter = {
1533
+ type: 'groq'
1534
+ name: string
1535
+ query: string
1536
+ }
1537
+
1538
+ /**
1539
+ * Payload used to configure the plugin behavior
1540
+ */
1541
+ export declare type PluginPayload = {
1542
+ auth: 'token' | 'cookie'
1543
+ capabilities?: PluginCapabilities
1544
+ disableNavigation?: boolean
1545
+ pluginFilters?: PluginFilter[]
1546
+ scheme: 'light' | 'dark'
1547
+ selectAssetTypes: PluginSelectAssetType[]
1548
+ selectionType: 'single' | 'multiple'
1549
+ }
1550
+
1517
1551
  export declare type PluginPostMessage =
1518
1552
  | PluginPostMessageAbortUploadRequest
1519
1553
  | PluginPostMessageAssetSelection
@@ -1602,6 +1636,11 @@ export declare type PluginPostMessageUploadFilesResponse = {
1602
1636
  assets: AssetSelectionItemWithLegacySupport[]
1603
1637
  }
1604
1638
 
1639
+ /**
1640
+ * Asset types that can be selected by the plugin
1641
+ */
1642
+ export declare type PluginSelectAssetType = 'file' | 'image' | 'video'
1643
+
1605
1644
  /** @public */
1606
1645
  declare interface PrepareViewOptions {
1607
1646
  /** @beta */
@@ -1679,6 +1718,7 @@ declare interface ReferenceFilterResolverContext {
1679
1718
  document: SanityDocument
1680
1719
  parent?: Record<string, unknown> | Record<string, unknown>[]
1681
1720
  parentPath: Path
1721
+ perspective: StackablePerspective[]
1682
1722
  getClient: (options: {apiVersion: string}) => SanityClient
1683
1723
  }
1684
1724
 
@@ -1695,7 +1735,7 @@ declare type ReferenceFilterSearchOptions = {
1695
1735
  tag?: string
1696
1736
  maxFieldDepth?: number
1697
1737
  strategy?: SearchStrategy
1698
- perspective?: ClientPerspective
1738
+ perspective?: Exclude<ClientPerspective, 'raw' | 'previewDrafts'>
1699
1739
  }
1700
1740
 
1701
1741
  /**
@@ -2109,6 +2149,7 @@ declare type SanityFileAsset = {
2109
2149
  path: string
2110
2150
  extension?: string
2111
2151
  url: string
2152
+ previewUrl?: string
2112
2153
  }
2113
2154
 
2114
2155
  declare type SanityImageAsset = {
@@ -2264,6 +2305,11 @@ declare type SanityVideoMetadata = {
2264
2305
  _key: string
2265
2306
  } & SanityVideoMetadataPlayback
2266
2307
  >
2308
+ renditions?: Array<
2309
+ {
2310
+ _key: string
2311
+ } & SanityVideoMetadataRendition
2312
+ >
2267
2313
  }
2268
2314
 
2269
2315
  declare type SanityVideoMetadataPlayback = {
@@ -2273,6 +2319,12 @@ declare type SanityVideoMetadataPlayback = {
2273
2319
  policy: string
2274
2320
  }
2275
2321
 
2322
+ export declare type SanityVideoMetadataRendition = {
2323
+ _type: 'sanity.videoMetadata.rendition'
2324
+ name: string
2325
+ resolution: string
2326
+ }
2327
+
2276
2328
  /** @public */
2277
2329
  declare interface Schema {
2278
2330
  /** @internal */
@@ -2535,9 +2587,7 @@ declare interface StringDefinition extends BaseSchemaDefinition {
2535
2587
 
2536
2588
  /** @public */
2537
2589
  declare interface StringOptions
2538
- extends EnumListProps<string>,
2539
- SearchConfiguration,
2540
- BaseSchemaTypeOptions {}
2590
+ extends EnumListProps<string>, SearchConfiguration, BaseSchemaTypeOptions {}
2541
2591
 
2542
2592
  /** @public */
2543
2593
  declare interface StringRule extends RuleDef<StringRule, string> {
@@ -2739,6 +2789,13 @@ declare interface ValidationError {
2739
2789
  * the document.
2740
2790
  */
2741
2791
  path?: Path
2792
+ /**
2793
+ * Extra metadata for the validation error. Currently used by the Media Library asset source to ignore
2794
+ * certain validation markers when validating asset source media library assets.
2795
+ *
2796
+ * @internal
2797
+ */
2798
+ __internal_metadata?: unknown
2742
2799
  /**
2743
2800
  * Same as `path` but allows more than one value. If provided, the same
2744
2801
  * message will create two markers from each path with the same message
@@ -2780,6 +2837,13 @@ declare interface ValidationMarker {
2780
2837
  * are not compatible with deep getters like lodash/get
2781
2838
  */
2782
2839
  path: Path
2840
+ /**
2841
+ * Extra metadata for the validation marker. Currently used by the Media Library asset source to ignore
2842
+ * certain validation markers when validating asset source media library assets.
2843
+ *
2844
+ * @internal
2845
+ */
2846
+ __internal_metadata?: unknown
2783
2847
  }
2784
2848
 
2785
2849
  export {}
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import {ComponentType} from 'react'
5
5
  import {ElementType} from 'react'
6
6
  import {ReactNode} from 'react'
7
7
  import {SanityClient} from '@sanity/client'
8
+ import {StackablePerspective} from '@sanity/client'
8
9
 
9
10
  /**
10
11
  * Types of array actions that can be performed
@@ -945,8 +946,10 @@ declare interface File_2 {
945
946
  }
946
947
 
947
948
  /** @public */
948
- declare interface FileDefinition
949
- extends Omit<ObjectDefinition, 'type' | 'fields' | 'options' | 'groups' | 'validation'> {
949
+ declare interface FileDefinition extends Omit<
950
+ ObjectDefinition,
951
+ 'type' | 'fields' | 'options' | 'groups' | 'validation'
952
+ > {
950
953
  type: 'file'
951
954
  fields?: ObjectDefinition['fields']
952
955
  options?: FileOptions
@@ -1102,8 +1105,10 @@ declare interface ImageCrop {
1102
1105
  }
1103
1106
 
1104
1107
  /** @public */
1105
- declare interface ImageDefinition
1106
- extends Omit<ObjectDefinition, 'type' | 'fields' | 'options' | 'groups' | 'validation'> {
1108
+ declare interface ImageDefinition extends Omit<
1109
+ ObjectDefinition,
1110
+ 'type' | 'fields' | 'options' | 'groups' | 'validation'
1111
+ > {
1107
1112
  type: 'image'
1108
1113
  fields?: FieldDefinition[]
1109
1114
  options?: ImageOptions
@@ -1514,6 +1519,35 @@ declare type Path = PathSegment[]
1514
1519
  /** @public */
1515
1520
  declare type PathSegment = string | number | KeyedSegment | IndexTuple
1516
1521
 
1522
+ /**
1523
+ * Media Library capabilities that the consumer can declare it supports
1524
+ */
1525
+ export declare type PluginCapabilities = {
1526
+ privateAssets?: boolean
1527
+ }
1528
+
1529
+ /**
1530
+ * Filter that the plugin consumer can use to limit the assets shown
1531
+ */
1532
+ export declare type PluginFilter = {
1533
+ type: 'groq'
1534
+ name: string
1535
+ query: string
1536
+ }
1537
+
1538
+ /**
1539
+ * Payload used to configure the plugin behavior
1540
+ */
1541
+ export declare type PluginPayload = {
1542
+ auth: 'token' | 'cookie'
1543
+ capabilities?: PluginCapabilities
1544
+ disableNavigation?: boolean
1545
+ pluginFilters?: PluginFilter[]
1546
+ scheme: 'light' | 'dark'
1547
+ selectAssetTypes: PluginSelectAssetType[]
1548
+ selectionType: 'single' | 'multiple'
1549
+ }
1550
+
1517
1551
  export declare type PluginPostMessage =
1518
1552
  | PluginPostMessageAbortUploadRequest
1519
1553
  | PluginPostMessageAssetSelection
@@ -1602,6 +1636,11 @@ export declare type PluginPostMessageUploadFilesResponse = {
1602
1636
  assets: AssetSelectionItemWithLegacySupport[]
1603
1637
  }
1604
1638
 
1639
+ /**
1640
+ * Asset types that can be selected by the plugin
1641
+ */
1642
+ export declare type PluginSelectAssetType = 'file' | 'image' | 'video'
1643
+
1605
1644
  /** @public */
1606
1645
  declare interface PrepareViewOptions {
1607
1646
  /** @beta */
@@ -1679,6 +1718,7 @@ declare interface ReferenceFilterResolverContext {
1679
1718
  document: SanityDocument
1680
1719
  parent?: Record<string, unknown> | Record<string, unknown>[]
1681
1720
  parentPath: Path
1721
+ perspective: StackablePerspective[]
1682
1722
  getClient: (options: {apiVersion: string}) => SanityClient
1683
1723
  }
1684
1724
 
@@ -1695,7 +1735,7 @@ declare type ReferenceFilterSearchOptions = {
1695
1735
  tag?: string
1696
1736
  maxFieldDepth?: number
1697
1737
  strategy?: SearchStrategy
1698
- perspective?: ClientPerspective
1738
+ perspective?: Exclude<ClientPerspective, 'raw' | 'previewDrafts'>
1699
1739
  }
1700
1740
 
1701
1741
  /**
@@ -2109,6 +2149,7 @@ declare type SanityFileAsset = {
2109
2149
  path: string
2110
2150
  extension?: string
2111
2151
  url: string
2152
+ previewUrl?: string
2112
2153
  }
2113
2154
 
2114
2155
  declare type SanityImageAsset = {
@@ -2264,6 +2305,11 @@ declare type SanityVideoMetadata = {
2264
2305
  _key: string
2265
2306
  } & SanityVideoMetadataPlayback
2266
2307
  >
2308
+ renditions?: Array<
2309
+ {
2310
+ _key: string
2311
+ } & SanityVideoMetadataRendition
2312
+ >
2267
2313
  }
2268
2314
 
2269
2315
  declare type SanityVideoMetadataPlayback = {
@@ -2273,6 +2319,12 @@ declare type SanityVideoMetadataPlayback = {
2273
2319
  policy: string
2274
2320
  }
2275
2321
 
2322
+ export declare type SanityVideoMetadataRendition = {
2323
+ _type: 'sanity.videoMetadata.rendition'
2324
+ name: string
2325
+ resolution: string
2326
+ }
2327
+
2276
2328
  /** @public */
2277
2329
  declare interface Schema {
2278
2330
  /** @internal */
@@ -2535,9 +2587,7 @@ declare interface StringDefinition extends BaseSchemaDefinition {
2535
2587
 
2536
2588
  /** @public */
2537
2589
  declare interface StringOptions
2538
- extends EnumListProps<string>,
2539
- SearchConfiguration,
2540
- BaseSchemaTypeOptions {}
2590
+ extends EnumListProps<string>, SearchConfiguration, BaseSchemaTypeOptions {}
2541
2591
 
2542
2592
  /** @public */
2543
2593
  declare interface StringRule extends RuleDef<StringRule, string> {
@@ -2739,6 +2789,13 @@ declare interface ValidationError {
2739
2789
  * the document.
2740
2790
  */
2741
2791
  path?: Path
2792
+ /**
2793
+ * Extra metadata for the validation error. Currently used by the Media Library asset source to ignore
2794
+ * certain validation markers when validating asset source media library assets.
2795
+ *
2796
+ * @internal
2797
+ */
2798
+ __internal_metadata?: unknown
2742
2799
  /**
2743
2800
  * Same as `path` but allows more than one value. If provided, the same
2744
2801
  * message will create two markers from each path with the same message
@@ -2780,6 +2837,13 @@ declare interface ValidationMarker {
2780
2837
  * are not compatible with deep getters like lodash/get
2781
2838
  */
2782
2839
  path: Path
2840
+ /**
2841
+ * Extra metadata for the validation marker. Currently used by the Media Library asset source to ignore
2842
+ * certain validation markers when validating asset source media library assets.
2843
+ *
2844
+ * @internal
2845
+ */
2846
+ __internal_metadata?: unknown
2783
2847
  }
2784
2848
 
2785
2849
  export {}
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";
1
+
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/media-library-types",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Type definitions for common Sanity Media Library data structures",
5
5
  "keywords": [
6
6
  "sanity",
@@ -19,26 +19,26 @@
19
19
  "license": "MIT",
20
20
  "author": "Sanity.io <hello@sanity.io>",
21
21
  "sideEffects": false,
22
- "type": "commonjs",
22
+ "type": "module",
23
23
  "exports": {
24
24
  ".": {
25
25
  "source": "./src/index.ts",
26
- "import": "./lib/index.mjs",
27
- "require": "./lib/index.js",
26
+ "import": "./lib/index.js",
27
+ "require": "./lib/index.cjs",
28
28
  "default": "./lib/index.js"
29
29
  },
30
30
  "./package.json": "./package.json"
31
31
  },
32
- "main": "./lib/index.js",
33
- "module": "./lib/index.mjs",
32
+ "main": "./lib/index.cjs",
33
+ "module": "./lib/index.js",
34
34
  "types": "./lib/index.d.ts",
35
35
  "files": [
36
36
  "lib",
37
37
  "src"
38
38
  ],
39
39
  "devDependencies": {
40
- "@sanity/pkg-utils": "^8.1.29",
41
- "@sanity/types": "^4.15.0",
40
+ "@sanity/pkg-utils": "^10.2.5",
41
+ "@sanity/types": "4.20.0",
42
42
  "rimraf": "^5.0.10"
43
43
  },
44
44
  "scripts": {
package/src/assets.ts CHANGED
@@ -8,7 +8,11 @@ import {
8
8
  } from './schema.types'
9
9
  import {type FieldDefinition} from '@sanity/types'
10
10
 
11
- export type {SanityVideoAsset, SanityAssetUploadSession as UploadSession} from './schema.types'
11
+ export type {
12
+ SanityVideoAsset,
13
+ SanityAssetUploadSession as UploadSession,
14
+ SanityVideoMetadataRendition,
15
+ } from './schema.types'
12
16
 
13
17
  export interface AssetVersion<AssetInstance extends AssetInstanceDocument = AssetInstanceDocument> {
14
18
  _key: string
package/src/plugin.ts CHANGED
@@ -1,5 +1,39 @@
1
- import { Asset } from "./assets"
2
- import { FileUpload } from "./files"
1
+ import {Asset} from './assets'
2
+ import {FileUpload} from './files'
3
+
4
+ /**
5
+ * Media Library capabilities that the consumer can declare it supports
6
+ */
7
+ export type PluginCapabilities = {
8
+ privateAssets?: boolean
9
+ }
10
+
11
+ /**
12
+ * Filter that the plugin consumer can use to limit the assets shown
13
+ */
14
+ export type PluginFilter = {
15
+ type: 'groq'
16
+ name: string
17
+ query: string
18
+ }
19
+
20
+ /**
21
+ * Asset types that can be selected by the plugin
22
+ */
23
+ export type PluginSelectAssetType = 'file' | 'image' | 'video'
24
+
25
+ /**
26
+ * Payload used to configure the plugin behavior
27
+ */
28
+ export type PluginPayload = {
29
+ auth: 'token' | 'cookie'
30
+ capabilities?: PluginCapabilities
31
+ disableNavigation?: boolean
32
+ pluginFilters?: PluginFilter[]
33
+ scheme: 'light' | 'dark'
34
+ selectAssetTypes: PluginSelectAssetType[]
35
+ selectionType: 'single' | 'multiple'
36
+ }
3
37
 
4
38
  /**
5
39
  * Message sent from the plugin when files are uploading
@@ -39,6 +39,12 @@ export type SanityAssetCollection = {
39
39
  }>
40
40
  }
41
41
 
42
+ export type SanityVideoMetadataRendition = {
43
+ _type: 'sanity.videoMetadata.rendition'
44
+ name: string
45
+ resolution: string
46
+ }
47
+
42
48
  export type SanityVideoMetadataPlayback = {
43
49
  _type: 'sanity.videoMetadata.playback'
44
50
  _id: string
@@ -56,6 +62,11 @@ export type SanityVideoMetadata = {
56
62
  _key: string
57
63
  } & SanityVideoMetadataPlayback
58
64
  >
65
+ renditions?: Array<
66
+ {
67
+ _key: string
68
+ } & SanityVideoMetadataRendition
69
+ >
59
70
  }
60
71
 
61
72
  export type SanityImageExifTags = {
@@ -261,6 +272,7 @@ export type SanityFileAsset = {
261
272
  path: string
262
273
  extension?: string
263
274
  url: string
275
+ previewUrl?: string
264
276
  }
265
277
 
266
278
  export type SanityImageAsset = {
@@ -293,6 +305,7 @@ export type AllSanitySchemaTypes =
293
305
  | SanitySystem
294
306
  | SanityAssetUploadSession
295
307
  | SanityAssetCollection
308
+ | SanityVideoMetadataRendition
296
309
  | SanityVideoMetadataPlayback
297
310
  | SanityVideoMetadata
298
311
  | SanityImageExifTags
package/lib/index.mjs DELETED
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=index.mjs.map
package/lib/index.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}