@sanity/media-library-types 1.0.2 → 1.1.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,34 @@ 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
+ pluginFilters?: PluginFilter[]
1545
+ scheme: 'light' | 'dark'
1546
+ selectAssetTypes: PluginSelectAssetType[]
1547
+ selectionType: 'single' | 'multiple'
1548
+ }
1549
+
1517
1550
  export declare type PluginPostMessage =
1518
1551
  | PluginPostMessageAbortUploadRequest
1519
1552
  | PluginPostMessageAssetSelection
@@ -1602,6 +1635,11 @@ export declare type PluginPostMessageUploadFilesResponse = {
1602
1635
  assets: AssetSelectionItemWithLegacySupport[]
1603
1636
  }
1604
1637
 
1638
+ /**
1639
+ * Asset types that can be selected by the plugin
1640
+ */
1641
+ export declare type PluginSelectAssetType = 'file' | 'image' | 'video'
1642
+
1605
1643
  /** @public */
1606
1644
  declare interface PrepareViewOptions {
1607
1645
  /** @beta */
@@ -1679,6 +1717,7 @@ declare interface ReferenceFilterResolverContext {
1679
1717
  document: SanityDocument
1680
1718
  parent?: Record<string, unknown> | Record<string, unknown>[]
1681
1719
  parentPath: Path
1720
+ perspective: StackablePerspective[]
1682
1721
  getClient: (options: {apiVersion: string}) => SanityClient
1683
1722
  }
1684
1723
 
@@ -1695,7 +1734,7 @@ declare type ReferenceFilterSearchOptions = {
1695
1734
  tag?: string
1696
1735
  maxFieldDepth?: number
1697
1736
  strategy?: SearchStrategy
1698
- perspective?: ClientPerspective
1737
+ perspective?: Exclude<ClientPerspective, 'raw' | 'previewDrafts'>
1699
1738
  }
1700
1739
 
1701
1740
  /**
@@ -2109,6 +2148,7 @@ declare type SanityFileAsset = {
2109
2148
  path: string
2110
2149
  extension?: string
2111
2150
  url: string
2151
+ previewUrl?: string
2112
2152
  }
2113
2153
 
2114
2154
  declare type SanityImageAsset = {
@@ -2264,6 +2304,11 @@ declare type SanityVideoMetadata = {
2264
2304
  _key: string
2265
2305
  } & SanityVideoMetadataPlayback
2266
2306
  >
2307
+ renditions?: Array<
2308
+ {
2309
+ _key: string
2310
+ } & SanityVideoMetadataRendition
2311
+ >
2267
2312
  }
2268
2313
 
2269
2314
  declare type SanityVideoMetadataPlayback = {
@@ -2273,6 +2318,12 @@ declare type SanityVideoMetadataPlayback = {
2273
2318
  policy: string
2274
2319
  }
2275
2320
 
2321
+ export declare type SanityVideoMetadataRendition = {
2322
+ _type: 'sanity.videoMetadata.rendition'
2323
+ name: string
2324
+ resolution: string
2325
+ }
2326
+
2276
2327
  /** @public */
2277
2328
  declare interface Schema {
2278
2329
  /** @internal */
@@ -2535,9 +2586,7 @@ declare interface StringDefinition extends BaseSchemaDefinition {
2535
2586
 
2536
2587
  /** @public */
2537
2588
  declare interface StringOptions
2538
- extends EnumListProps<string>,
2539
- SearchConfiguration,
2540
- BaseSchemaTypeOptions {}
2589
+ extends EnumListProps<string>, SearchConfiguration, BaseSchemaTypeOptions {}
2541
2590
 
2542
2591
  /** @public */
2543
2592
  declare interface StringRule extends RuleDef<StringRule, string> {
@@ -2739,6 +2788,13 @@ declare interface ValidationError {
2739
2788
  * the document.
2740
2789
  */
2741
2790
  path?: Path
2791
+ /**
2792
+ * Extra metadata for the validation error. Currently used by the Media Library asset source to ignore
2793
+ * certain validation markers when validating asset source media library assets.
2794
+ *
2795
+ * @internal
2796
+ */
2797
+ __internal_metadata?: unknown
2742
2798
  /**
2743
2799
  * Same as `path` but allows more than one value. If provided, the same
2744
2800
  * message will create two markers from each path with the same message
@@ -2780,6 +2836,13 @@ declare interface ValidationMarker {
2780
2836
  * are not compatible with deep getters like lodash/get
2781
2837
  */
2782
2838
  path: Path
2839
+ /**
2840
+ * Extra metadata for the validation marker. Currently used by the Media Library asset source to ignore
2841
+ * certain validation markers when validating asset source media library assets.
2842
+ *
2843
+ * @internal
2844
+ */
2845
+ __internal_metadata?: unknown
2783
2846
  }
2784
2847
 
2785
2848
  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,34 @@ 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
+ pluginFilters?: PluginFilter[]
1545
+ scheme: 'light' | 'dark'
1546
+ selectAssetTypes: PluginSelectAssetType[]
1547
+ selectionType: 'single' | 'multiple'
1548
+ }
1549
+
1517
1550
  export declare type PluginPostMessage =
1518
1551
  | PluginPostMessageAbortUploadRequest
1519
1552
  | PluginPostMessageAssetSelection
@@ -1602,6 +1635,11 @@ export declare type PluginPostMessageUploadFilesResponse = {
1602
1635
  assets: AssetSelectionItemWithLegacySupport[]
1603
1636
  }
1604
1637
 
1638
+ /**
1639
+ * Asset types that can be selected by the plugin
1640
+ */
1641
+ export declare type PluginSelectAssetType = 'file' | 'image' | 'video'
1642
+
1605
1643
  /** @public */
1606
1644
  declare interface PrepareViewOptions {
1607
1645
  /** @beta */
@@ -1679,6 +1717,7 @@ declare interface ReferenceFilterResolverContext {
1679
1717
  document: SanityDocument
1680
1718
  parent?: Record<string, unknown> | Record<string, unknown>[]
1681
1719
  parentPath: Path
1720
+ perspective: StackablePerspective[]
1682
1721
  getClient: (options: {apiVersion: string}) => SanityClient
1683
1722
  }
1684
1723
 
@@ -1695,7 +1734,7 @@ declare type ReferenceFilterSearchOptions = {
1695
1734
  tag?: string
1696
1735
  maxFieldDepth?: number
1697
1736
  strategy?: SearchStrategy
1698
- perspective?: ClientPerspective
1737
+ perspective?: Exclude<ClientPerspective, 'raw' | 'previewDrafts'>
1699
1738
  }
1700
1739
 
1701
1740
  /**
@@ -2109,6 +2148,7 @@ declare type SanityFileAsset = {
2109
2148
  path: string
2110
2149
  extension?: string
2111
2150
  url: string
2151
+ previewUrl?: string
2112
2152
  }
2113
2153
 
2114
2154
  declare type SanityImageAsset = {
@@ -2264,6 +2304,11 @@ declare type SanityVideoMetadata = {
2264
2304
  _key: string
2265
2305
  } & SanityVideoMetadataPlayback
2266
2306
  >
2307
+ renditions?: Array<
2308
+ {
2309
+ _key: string
2310
+ } & SanityVideoMetadataRendition
2311
+ >
2267
2312
  }
2268
2313
 
2269
2314
  declare type SanityVideoMetadataPlayback = {
@@ -2273,6 +2318,12 @@ declare type SanityVideoMetadataPlayback = {
2273
2318
  policy: string
2274
2319
  }
2275
2320
 
2321
+ export declare type SanityVideoMetadataRendition = {
2322
+ _type: 'sanity.videoMetadata.rendition'
2323
+ name: string
2324
+ resolution: string
2325
+ }
2326
+
2276
2327
  /** @public */
2277
2328
  declare interface Schema {
2278
2329
  /** @internal */
@@ -2535,9 +2586,7 @@ declare interface StringDefinition extends BaseSchemaDefinition {
2535
2586
 
2536
2587
  /** @public */
2537
2588
  declare interface StringOptions
2538
- extends EnumListProps<string>,
2539
- SearchConfiguration,
2540
- BaseSchemaTypeOptions {}
2589
+ extends EnumListProps<string>, SearchConfiguration, BaseSchemaTypeOptions {}
2541
2590
 
2542
2591
  /** @public */
2543
2592
  declare interface StringRule extends RuleDef<StringRule, string> {
@@ -2739,6 +2788,13 @@ declare interface ValidationError {
2739
2788
  * the document.
2740
2789
  */
2741
2790
  path?: Path
2791
+ /**
2792
+ * Extra metadata for the validation error. Currently used by the Media Library asset source to ignore
2793
+ * certain validation markers when validating asset source media library assets.
2794
+ *
2795
+ * @internal
2796
+ */
2797
+ __internal_metadata?: unknown
2742
2798
  /**
2743
2799
  * Same as `path` but allows more than one value. If provided, the same
2744
2800
  * message will create two markers from each path with the same message
@@ -2780,6 +2836,13 @@ declare interface ValidationMarker {
2780
2836
  * are not compatible with deep getters like lodash/get
2781
2837
  */
2782
2838
  path: Path
2839
+ /**
2840
+ * Extra metadata for the validation marker. Currently used by the Media Library asset source to ignore
2841
+ * certain validation markers when validating asset source media library assets.
2842
+ *
2843
+ * @internal
2844
+ */
2845
+ __internal_metadata?: unknown
2783
2846
  }
2784
2847
 
2785
2848
  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.1.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,38 @@
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
+ pluginFilters?: PluginFilter[]
32
+ scheme: 'light' | 'dark'
33
+ selectAssetTypes: PluginSelectAssetType[]
34
+ selectionType: 'single' | 'multiple'
35
+ }
3
36
 
4
37
  /**
5
38
  * 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":""}