@sanity/media-library-types 1.0.1 → 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 +2 -0
- package/lib/index.cjs.map +1 -0
- package/lib/{index.d.mts → index.d.cts} +79 -11
- package/lib/index.d.ts +79 -11
- package/lib/index.js +1 -1
- package/package.json +8 -8
- package/src/assets.ts +7 -1
- package/src/plugin.ts +35 -2
- package/src/schema.types.ts +71 -57
- package/lib/index.mjs +0 -2
- package/lib/index.mjs.map +0 -1
package/lib/index.cjs
ADDED
|
@@ -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
|
|
@@ -117,6 +118,7 @@ export declare interface Asset<
|
|
|
117
118
|
_createdAt: string
|
|
118
119
|
_updatedAt: string
|
|
119
120
|
_rev: string
|
|
121
|
+
url?: string
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
/** @public */
|
|
@@ -144,6 +146,7 @@ export declare interface AssetAspectDocument extends BaseDocument {
|
|
|
144
146
|
*/
|
|
145
147
|
assetType?: Asset['assetType']
|
|
146
148
|
definition: FieldDefinition
|
|
149
|
+
public?: boolean
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
/** @public */
|
|
@@ -943,8 +946,10 @@ declare interface File_2 {
|
|
|
943
946
|
}
|
|
944
947
|
|
|
945
948
|
/** @public */
|
|
946
|
-
declare interface FileDefinition
|
|
947
|
-
|
|
949
|
+
declare interface FileDefinition extends Omit<
|
|
950
|
+
ObjectDefinition,
|
|
951
|
+
'type' | 'fields' | 'options' | 'groups' | 'validation'
|
|
952
|
+
> {
|
|
948
953
|
type: 'file'
|
|
949
954
|
fields?: ObjectDefinition['fields']
|
|
950
955
|
options?: FileOptions
|
|
@@ -1100,8 +1105,10 @@ declare interface ImageCrop {
|
|
|
1100
1105
|
}
|
|
1101
1106
|
|
|
1102
1107
|
/** @public */
|
|
1103
|
-
declare interface ImageDefinition
|
|
1104
|
-
|
|
1108
|
+
declare interface ImageDefinition extends Omit<
|
|
1109
|
+
ObjectDefinition,
|
|
1110
|
+
'type' | 'fields' | 'options' | 'groups' | 'validation'
|
|
1111
|
+
> {
|
|
1105
1112
|
type: 'image'
|
|
1106
1113
|
fields?: FieldDefinition[]
|
|
1107
1114
|
options?: ImageOptions
|
|
@@ -1512,6 +1519,34 @@ declare type Path = PathSegment[]
|
|
|
1512
1519
|
/** @public */
|
|
1513
1520
|
declare type PathSegment = string | number | KeyedSegment | IndexTuple
|
|
1514
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
|
+
|
|
1515
1550
|
export declare type PluginPostMessage =
|
|
1516
1551
|
| PluginPostMessageAbortUploadRequest
|
|
1517
1552
|
| PluginPostMessageAssetSelection
|
|
@@ -1600,6 +1635,11 @@ export declare type PluginPostMessageUploadFilesResponse = {
|
|
|
1600
1635
|
assets: AssetSelectionItemWithLegacySupport[]
|
|
1601
1636
|
}
|
|
1602
1637
|
|
|
1638
|
+
/**
|
|
1639
|
+
* Asset types that can be selected by the plugin
|
|
1640
|
+
*/
|
|
1641
|
+
export declare type PluginSelectAssetType = 'file' | 'image' | 'video'
|
|
1642
|
+
|
|
1603
1643
|
/** @public */
|
|
1604
1644
|
declare interface PrepareViewOptions {
|
|
1605
1645
|
/** @beta */
|
|
@@ -1677,6 +1717,7 @@ declare interface ReferenceFilterResolverContext {
|
|
|
1677
1717
|
document: SanityDocument
|
|
1678
1718
|
parent?: Record<string, unknown> | Record<string, unknown>[]
|
|
1679
1719
|
parentPath: Path
|
|
1720
|
+
perspective: StackablePerspective[]
|
|
1680
1721
|
getClient: (options: {apiVersion: string}) => SanityClient
|
|
1681
1722
|
}
|
|
1682
1723
|
|
|
@@ -1693,7 +1734,7 @@ declare type ReferenceFilterSearchOptions = {
|
|
|
1693
1734
|
tag?: string
|
|
1694
1735
|
maxFieldDepth?: number
|
|
1695
1736
|
strategy?: SearchStrategy
|
|
1696
|
-
perspective?: ClientPerspective
|
|
1737
|
+
perspective?: Exclude<ClientPerspective, 'raw' | 'previewDrafts'>
|
|
1697
1738
|
}
|
|
1698
1739
|
|
|
1699
1740
|
/**
|
|
@@ -2002,6 +2043,7 @@ declare type SanityAsset = {
|
|
|
2002
2043
|
>
|
|
2003
2044
|
assetType: 'sanity.imageAsset' | 'sanity.videoAsset' | 'sanity.fileAsset'
|
|
2004
2045
|
cdnAccessPolicy: 'public' | 'private'
|
|
2046
|
+
url?: string
|
|
2005
2047
|
}
|
|
2006
2048
|
|
|
2007
2049
|
declare type SanityAssetCollection = {
|
|
@@ -2021,6 +2063,8 @@ declare type SanityAssetCollection = {
|
|
|
2021
2063
|
}>
|
|
2022
2064
|
}
|
|
2023
2065
|
|
|
2066
|
+
declare type SanityAssetInstanceState = string
|
|
2067
|
+
|
|
2024
2068
|
declare type SanityAssetVersion = {
|
|
2025
2069
|
_type: 'sanity.asset.version'
|
|
2026
2070
|
title?: string
|
|
@@ -2095,7 +2139,7 @@ declare type SanityFileAsset = {
|
|
|
2095
2139
|
_type: 'block'
|
|
2096
2140
|
_key: string
|
|
2097
2141
|
}>
|
|
2098
|
-
state:
|
|
2142
|
+
state: SanityAssetInstanceState
|
|
2099
2143
|
sha1hash?: string
|
|
2100
2144
|
mimeType?: string
|
|
2101
2145
|
originalFilename?: string
|
|
@@ -2104,6 +2148,7 @@ declare type SanityFileAsset = {
|
|
|
2104
2148
|
path: string
|
|
2105
2149
|
extension?: string
|
|
2106
2150
|
url: string
|
|
2151
|
+
previewUrl?: string
|
|
2107
2152
|
}
|
|
2108
2153
|
|
|
2109
2154
|
declare type SanityImageAsset = {
|
|
@@ -2113,7 +2158,7 @@ declare type SanityImageAsset = {
|
|
|
2113
2158
|
_updatedAt: string
|
|
2114
2159
|
_rev: string
|
|
2115
2160
|
altText?: string
|
|
2116
|
-
state:
|
|
2161
|
+
state: SanityAssetInstanceState
|
|
2117
2162
|
sha1hash?: string
|
|
2118
2163
|
mimeType?: string
|
|
2119
2164
|
originalFilename?: string
|
|
@@ -2232,7 +2277,7 @@ export declare type SanityVideoAsset = {
|
|
|
2232
2277
|
_type: 'block'
|
|
2233
2278
|
_key: string
|
|
2234
2279
|
}>
|
|
2235
|
-
state:
|
|
2280
|
+
state: SanityAssetInstanceState
|
|
2236
2281
|
sha1hash?: string
|
|
2237
2282
|
mimeType?: string
|
|
2238
2283
|
originalFilename?: string
|
|
@@ -2259,6 +2304,11 @@ declare type SanityVideoMetadata = {
|
|
|
2259
2304
|
_key: string
|
|
2260
2305
|
} & SanityVideoMetadataPlayback
|
|
2261
2306
|
>
|
|
2307
|
+
renditions?: Array<
|
|
2308
|
+
{
|
|
2309
|
+
_key: string
|
|
2310
|
+
} & SanityVideoMetadataRendition
|
|
2311
|
+
>
|
|
2262
2312
|
}
|
|
2263
2313
|
|
|
2264
2314
|
declare type SanityVideoMetadataPlayback = {
|
|
@@ -2268,6 +2318,12 @@ declare type SanityVideoMetadataPlayback = {
|
|
|
2268
2318
|
policy: string
|
|
2269
2319
|
}
|
|
2270
2320
|
|
|
2321
|
+
export declare type SanityVideoMetadataRendition = {
|
|
2322
|
+
_type: 'sanity.videoMetadata.rendition'
|
|
2323
|
+
name: string
|
|
2324
|
+
resolution: string
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2271
2327
|
/** @public */
|
|
2272
2328
|
declare interface Schema {
|
|
2273
2329
|
/** @internal */
|
|
@@ -2530,9 +2586,7 @@ declare interface StringDefinition extends BaseSchemaDefinition {
|
|
|
2530
2586
|
|
|
2531
2587
|
/** @public */
|
|
2532
2588
|
declare interface StringOptions
|
|
2533
|
-
extends EnumListProps<string>,
|
|
2534
|
-
SearchConfiguration,
|
|
2535
|
-
BaseSchemaTypeOptions {}
|
|
2589
|
+
extends EnumListProps<string>, SearchConfiguration, BaseSchemaTypeOptions {}
|
|
2536
2590
|
|
|
2537
2591
|
/** @public */
|
|
2538
2592
|
declare interface StringRule extends RuleDef<StringRule, string> {
|
|
@@ -2734,6 +2788,13 @@ declare interface ValidationError {
|
|
|
2734
2788
|
* the document.
|
|
2735
2789
|
*/
|
|
2736
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
|
|
2737
2798
|
/**
|
|
2738
2799
|
* Same as `path` but allows more than one value. If provided, the same
|
|
2739
2800
|
* message will create two markers from each path with the same message
|
|
@@ -2775,6 +2836,13 @@ declare interface ValidationMarker {
|
|
|
2775
2836
|
* are not compatible with deep getters like lodash/get
|
|
2776
2837
|
*/
|
|
2777
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
|
|
2778
2846
|
}
|
|
2779
2847
|
|
|
2780
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
|
|
@@ -117,6 +118,7 @@ export declare interface Asset<
|
|
|
117
118
|
_createdAt: string
|
|
118
119
|
_updatedAt: string
|
|
119
120
|
_rev: string
|
|
121
|
+
url?: string
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
/** @public */
|
|
@@ -144,6 +146,7 @@ export declare interface AssetAspectDocument extends BaseDocument {
|
|
|
144
146
|
*/
|
|
145
147
|
assetType?: Asset['assetType']
|
|
146
148
|
definition: FieldDefinition
|
|
149
|
+
public?: boolean
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
/** @public */
|
|
@@ -943,8 +946,10 @@ declare interface File_2 {
|
|
|
943
946
|
}
|
|
944
947
|
|
|
945
948
|
/** @public */
|
|
946
|
-
declare interface FileDefinition
|
|
947
|
-
|
|
949
|
+
declare interface FileDefinition extends Omit<
|
|
950
|
+
ObjectDefinition,
|
|
951
|
+
'type' | 'fields' | 'options' | 'groups' | 'validation'
|
|
952
|
+
> {
|
|
948
953
|
type: 'file'
|
|
949
954
|
fields?: ObjectDefinition['fields']
|
|
950
955
|
options?: FileOptions
|
|
@@ -1100,8 +1105,10 @@ declare interface ImageCrop {
|
|
|
1100
1105
|
}
|
|
1101
1106
|
|
|
1102
1107
|
/** @public */
|
|
1103
|
-
declare interface ImageDefinition
|
|
1104
|
-
|
|
1108
|
+
declare interface ImageDefinition extends Omit<
|
|
1109
|
+
ObjectDefinition,
|
|
1110
|
+
'type' | 'fields' | 'options' | 'groups' | 'validation'
|
|
1111
|
+
> {
|
|
1105
1112
|
type: 'image'
|
|
1106
1113
|
fields?: FieldDefinition[]
|
|
1107
1114
|
options?: ImageOptions
|
|
@@ -1512,6 +1519,34 @@ declare type Path = PathSegment[]
|
|
|
1512
1519
|
/** @public */
|
|
1513
1520
|
declare type PathSegment = string | number | KeyedSegment | IndexTuple
|
|
1514
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
|
+
|
|
1515
1550
|
export declare type PluginPostMessage =
|
|
1516
1551
|
| PluginPostMessageAbortUploadRequest
|
|
1517
1552
|
| PluginPostMessageAssetSelection
|
|
@@ -1600,6 +1635,11 @@ export declare type PluginPostMessageUploadFilesResponse = {
|
|
|
1600
1635
|
assets: AssetSelectionItemWithLegacySupport[]
|
|
1601
1636
|
}
|
|
1602
1637
|
|
|
1638
|
+
/**
|
|
1639
|
+
* Asset types that can be selected by the plugin
|
|
1640
|
+
*/
|
|
1641
|
+
export declare type PluginSelectAssetType = 'file' | 'image' | 'video'
|
|
1642
|
+
|
|
1603
1643
|
/** @public */
|
|
1604
1644
|
declare interface PrepareViewOptions {
|
|
1605
1645
|
/** @beta */
|
|
@@ -1677,6 +1717,7 @@ declare interface ReferenceFilterResolverContext {
|
|
|
1677
1717
|
document: SanityDocument
|
|
1678
1718
|
parent?: Record<string, unknown> | Record<string, unknown>[]
|
|
1679
1719
|
parentPath: Path
|
|
1720
|
+
perspective: StackablePerspective[]
|
|
1680
1721
|
getClient: (options: {apiVersion: string}) => SanityClient
|
|
1681
1722
|
}
|
|
1682
1723
|
|
|
@@ -1693,7 +1734,7 @@ declare type ReferenceFilterSearchOptions = {
|
|
|
1693
1734
|
tag?: string
|
|
1694
1735
|
maxFieldDepth?: number
|
|
1695
1736
|
strategy?: SearchStrategy
|
|
1696
|
-
perspective?: ClientPerspective
|
|
1737
|
+
perspective?: Exclude<ClientPerspective, 'raw' | 'previewDrafts'>
|
|
1697
1738
|
}
|
|
1698
1739
|
|
|
1699
1740
|
/**
|
|
@@ -2002,6 +2043,7 @@ declare type SanityAsset = {
|
|
|
2002
2043
|
>
|
|
2003
2044
|
assetType: 'sanity.imageAsset' | 'sanity.videoAsset' | 'sanity.fileAsset'
|
|
2004
2045
|
cdnAccessPolicy: 'public' | 'private'
|
|
2046
|
+
url?: string
|
|
2005
2047
|
}
|
|
2006
2048
|
|
|
2007
2049
|
declare type SanityAssetCollection = {
|
|
@@ -2021,6 +2063,8 @@ declare type SanityAssetCollection = {
|
|
|
2021
2063
|
}>
|
|
2022
2064
|
}
|
|
2023
2065
|
|
|
2066
|
+
declare type SanityAssetInstanceState = string
|
|
2067
|
+
|
|
2024
2068
|
declare type SanityAssetVersion = {
|
|
2025
2069
|
_type: 'sanity.asset.version'
|
|
2026
2070
|
title?: string
|
|
@@ -2095,7 +2139,7 @@ declare type SanityFileAsset = {
|
|
|
2095
2139
|
_type: 'block'
|
|
2096
2140
|
_key: string
|
|
2097
2141
|
}>
|
|
2098
|
-
state:
|
|
2142
|
+
state: SanityAssetInstanceState
|
|
2099
2143
|
sha1hash?: string
|
|
2100
2144
|
mimeType?: string
|
|
2101
2145
|
originalFilename?: string
|
|
@@ -2104,6 +2148,7 @@ declare type SanityFileAsset = {
|
|
|
2104
2148
|
path: string
|
|
2105
2149
|
extension?: string
|
|
2106
2150
|
url: string
|
|
2151
|
+
previewUrl?: string
|
|
2107
2152
|
}
|
|
2108
2153
|
|
|
2109
2154
|
declare type SanityImageAsset = {
|
|
@@ -2113,7 +2158,7 @@ declare type SanityImageAsset = {
|
|
|
2113
2158
|
_updatedAt: string
|
|
2114
2159
|
_rev: string
|
|
2115
2160
|
altText?: string
|
|
2116
|
-
state:
|
|
2161
|
+
state: SanityAssetInstanceState
|
|
2117
2162
|
sha1hash?: string
|
|
2118
2163
|
mimeType?: string
|
|
2119
2164
|
originalFilename?: string
|
|
@@ -2232,7 +2277,7 @@ export declare type SanityVideoAsset = {
|
|
|
2232
2277
|
_type: 'block'
|
|
2233
2278
|
_key: string
|
|
2234
2279
|
}>
|
|
2235
|
-
state:
|
|
2280
|
+
state: SanityAssetInstanceState
|
|
2236
2281
|
sha1hash?: string
|
|
2237
2282
|
mimeType?: string
|
|
2238
2283
|
originalFilename?: string
|
|
@@ -2259,6 +2304,11 @@ declare type SanityVideoMetadata = {
|
|
|
2259
2304
|
_key: string
|
|
2260
2305
|
} & SanityVideoMetadataPlayback
|
|
2261
2306
|
>
|
|
2307
|
+
renditions?: Array<
|
|
2308
|
+
{
|
|
2309
|
+
_key: string
|
|
2310
|
+
} & SanityVideoMetadataRendition
|
|
2311
|
+
>
|
|
2262
2312
|
}
|
|
2263
2313
|
|
|
2264
2314
|
declare type SanityVideoMetadataPlayback = {
|
|
@@ -2268,6 +2318,12 @@ declare type SanityVideoMetadataPlayback = {
|
|
|
2268
2318
|
policy: string
|
|
2269
2319
|
}
|
|
2270
2320
|
|
|
2321
|
+
export declare type SanityVideoMetadataRendition = {
|
|
2322
|
+
_type: 'sanity.videoMetadata.rendition'
|
|
2323
|
+
name: string
|
|
2324
|
+
resolution: string
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2271
2327
|
/** @public */
|
|
2272
2328
|
declare interface Schema {
|
|
2273
2329
|
/** @internal */
|
|
@@ -2530,9 +2586,7 @@ declare interface StringDefinition extends BaseSchemaDefinition {
|
|
|
2530
2586
|
|
|
2531
2587
|
/** @public */
|
|
2532
2588
|
declare interface StringOptions
|
|
2533
|
-
extends EnumListProps<string>,
|
|
2534
|
-
SearchConfiguration,
|
|
2535
|
-
BaseSchemaTypeOptions {}
|
|
2589
|
+
extends EnumListProps<string>, SearchConfiguration, BaseSchemaTypeOptions {}
|
|
2536
2590
|
|
|
2537
2591
|
/** @public */
|
|
2538
2592
|
declare interface StringRule extends RuleDef<StringRule, string> {
|
|
@@ -2734,6 +2788,13 @@ declare interface ValidationError {
|
|
|
2734
2788
|
* the document.
|
|
2735
2789
|
*/
|
|
2736
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
|
|
2737
2798
|
/**
|
|
2738
2799
|
* Same as `path` but allows more than one value. If provided, the same
|
|
2739
2800
|
* message will create two markers from each path with the same message
|
|
@@ -2775,6 +2836,13 @@ declare interface ValidationMarker {
|
|
|
2775
2836
|
* are not compatible with deep getters like lodash/get
|
|
2776
2837
|
*/
|
|
2777
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
|
|
2778
2846
|
}
|
|
2779
2847
|
|
|
2780
2848
|
export {}
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
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
|
|
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": "
|
|
22
|
+
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"source": "./src/index.ts",
|
|
26
|
-
"import": "./lib/index.
|
|
27
|
-
"require": "./lib/index.
|
|
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.
|
|
33
|
-
"module": "./lib/index.
|
|
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": "^
|
|
41
|
-
"@sanity/types": "
|
|
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 {
|
|
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
|
|
@@ -34,6 +38,7 @@ export interface Asset<AssetInstance extends AssetInstanceDocument = AssetInstan
|
|
|
34
38
|
_createdAt: string
|
|
35
39
|
_updatedAt: string
|
|
36
40
|
_rev: string
|
|
41
|
+
url?: string
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
export type BaseDocument = {
|
|
@@ -53,4 +58,5 @@ export interface AssetAspectDocument extends BaseDocument {
|
|
|
53
58
|
*/
|
|
54
59
|
assetType?: Asset['assetType']
|
|
55
60
|
definition: FieldDefinition
|
|
61
|
+
public?: boolean
|
|
56
62
|
}
|
package/src/plugin.ts
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
package/src/schema.types.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export declare const internalGroqTypeReferenceTo: unique symbol
|
|
2
2
|
|
|
3
|
+
export type SanitySystem = {
|
|
4
|
+
_type: 'sanity.system'
|
|
5
|
+
createdBy?: string
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
export type SanityAssetUploadSession = {
|
|
4
9
|
_id: string
|
|
5
10
|
_type: 'sanity.asset.upload-session'
|
|
@@ -17,11 +22,6 @@ export type SanityAssetUploadSession = {
|
|
|
17
22
|
_system?: SanitySystem
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
export type SanitySystem = {
|
|
21
|
-
_type: 'sanity.system'
|
|
22
|
-
createdBy?: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
25
|
export type SanityAssetCollection = {
|
|
26
26
|
_id: string
|
|
27
27
|
_type: 'sanity.asset.collection'
|
|
@@ -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
|
|
@@ -46,23 +52,21 @@ export type SanityVideoMetadataPlayback = {
|
|
|
46
52
|
policy: string
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
export type
|
|
50
|
-
_type: 'sanity.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
lightMuted?: SanityImagePaletteSwatch
|
|
65
|
-
muted?: SanityImagePaletteSwatch
|
|
55
|
+
export type SanityVideoMetadata = {
|
|
56
|
+
_type: 'sanity.videoMetadata'
|
|
57
|
+
aspectRatio?: string
|
|
58
|
+
duration?: number
|
|
59
|
+
framerate?: number
|
|
60
|
+
playbacks?: Array<
|
|
61
|
+
{
|
|
62
|
+
_key: string
|
|
63
|
+
} & SanityVideoMetadataPlayback
|
|
64
|
+
>
|
|
65
|
+
renditions?: Array<
|
|
66
|
+
{
|
|
67
|
+
_key: string
|
|
68
|
+
} & SanityVideoMetadataRendition
|
|
69
|
+
>
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
export type SanityImageExifTags = {
|
|
@@ -103,6 +107,25 @@ export type SanityImageExifMetadata = {
|
|
|
103
107
|
Artist?: string
|
|
104
108
|
}
|
|
105
109
|
|
|
110
|
+
export type SanityImagePaletteSwatch = {
|
|
111
|
+
_type: 'sanity.imagePaletteSwatch'
|
|
112
|
+
background?: string
|
|
113
|
+
foreground?: string
|
|
114
|
+
population?: number
|
|
115
|
+
title?: string
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type SanityImagePalette = {
|
|
119
|
+
_type: 'sanity.imagePalette'
|
|
120
|
+
darkMuted?: SanityImagePaletteSwatch
|
|
121
|
+
lightVibrant?: SanityImagePaletteSwatch
|
|
122
|
+
darkVibrant?: SanityImagePaletteSwatch
|
|
123
|
+
vibrant?: SanityImagePaletteSwatch
|
|
124
|
+
dominant?: SanityImagePaletteSwatch
|
|
125
|
+
lightMuted?: SanityImagePaletteSwatch
|
|
126
|
+
muted?: SanityImagePaletteSwatch
|
|
127
|
+
}
|
|
128
|
+
|
|
106
129
|
export type SanityImageDimensions = {
|
|
107
130
|
_type: 'sanity.imageDimensions'
|
|
108
131
|
height: number
|
|
@@ -110,6 +133,19 @@ export type SanityImageDimensions = {
|
|
|
110
133
|
aspectRatio: number
|
|
111
134
|
}
|
|
112
135
|
|
|
136
|
+
export type SanityImageMetadata = {
|
|
137
|
+
_type: 'sanity.imageMetadata'
|
|
138
|
+
location?: Geopoint
|
|
139
|
+
dimensions: SanityImageDimensions
|
|
140
|
+
exif?: SanityImageExifMetadata
|
|
141
|
+
image?: SanityImageExifTags
|
|
142
|
+
palette: SanityImagePalette
|
|
143
|
+
lqip: string
|
|
144
|
+
blurHash: string
|
|
145
|
+
hasAlpha: boolean
|
|
146
|
+
isOpaque: boolean
|
|
147
|
+
}
|
|
148
|
+
|
|
113
149
|
export type SanityAsset = {
|
|
114
150
|
_id: string
|
|
115
151
|
_type: 'sanity.asset'
|
|
@@ -131,6 +167,7 @@ export type SanityAsset = {
|
|
|
131
167
|
>
|
|
132
168
|
assetType: 'sanity.imageAsset' | 'sanity.videoAsset' | 'sanity.fileAsset'
|
|
133
169
|
cdnAccessPolicy: 'public' | 'private'
|
|
170
|
+
url?: string
|
|
134
171
|
}
|
|
135
172
|
|
|
136
173
|
export type SanityAssetVersion = {
|
|
@@ -182,7 +219,7 @@ export type SanityVideoAsset = {
|
|
|
182
219
|
_type: 'block'
|
|
183
220
|
_key: string
|
|
184
221
|
}>
|
|
185
|
-
state:
|
|
222
|
+
state: SanityAssetInstanceState
|
|
186
223
|
sha1hash?: string
|
|
187
224
|
mimeType?: string
|
|
188
225
|
originalFilename?: string
|
|
@@ -199,17 +236,7 @@ export type SanityVideoAsset = {
|
|
|
199
236
|
metadata: SanityVideoMetadata
|
|
200
237
|
}
|
|
201
238
|
|
|
202
|
-
export type
|
|
203
|
-
_type: 'sanity.videoMetadata'
|
|
204
|
-
aspectRatio?: string
|
|
205
|
-
duration?: number
|
|
206
|
-
framerate?: number
|
|
207
|
-
playbacks?: Array<
|
|
208
|
-
{
|
|
209
|
-
_key: string
|
|
210
|
-
} & SanityVideoMetadataPlayback
|
|
211
|
-
>
|
|
212
|
-
}
|
|
239
|
+
export type SanityAssetInstanceState = string
|
|
213
240
|
|
|
214
241
|
export type SanityFileAsset = {
|
|
215
242
|
_id: string
|
|
@@ -236,7 +263,7 @@ export type SanityFileAsset = {
|
|
|
236
263
|
_type: 'block'
|
|
237
264
|
_key: string
|
|
238
265
|
}>
|
|
239
|
-
state:
|
|
266
|
+
state: SanityAssetInstanceState
|
|
240
267
|
sha1hash?: string
|
|
241
268
|
mimeType?: string
|
|
242
269
|
originalFilename?: string
|
|
@@ -245,6 +272,7 @@ export type SanityFileAsset = {
|
|
|
245
272
|
path: string
|
|
246
273
|
extension?: string
|
|
247
274
|
url: string
|
|
275
|
+
previewUrl?: string
|
|
248
276
|
}
|
|
249
277
|
|
|
250
278
|
export type SanityImageAsset = {
|
|
@@ -254,7 +282,7 @@ export type SanityImageAsset = {
|
|
|
254
282
|
_updatedAt: string
|
|
255
283
|
_rev: string
|
|
256
284
|
altText?: string
|
|
257
|
-
state:
|
|
285
|
+
state: SanityAssetInstanceState
|
|
258
286
|
sha1hash?: string
|
|
259
287
|
mimeType?: string
|
|
260
288
|
originalFilename?: string
|
|
@@ -266,19 +294,6 @@ export type SanityImageAsset = {
|
|
|
266
294
|
metadata: SanityImageMetadata
|
|
267
295
|
}
|
|
268
296
|
|
|
269
|
-
export type SanityImageMetadata = {
|
|
270
|
-
_type: 'sanity.imageMetadata'
|
|
271
|
-
location?: Geopoint
|
|
272
|
-
dimensions: SanityImageDimensions
|
|
273
|
-
exif?: SanityImageExifMetadata
|
|
274
|
-
image?: SanityImageExifTags
|
|
275
|
-
palette: SanityImagePalette
|
|
276
|
-
lqip: string
|
|
277
|
-
blurHash: string
|
|
278
|
-
hasAlpha: boolean
|
|
279
|
-
isOpaque: boolean
|
|
280
|
-
}
|
|
281
|
-
|
|
282
297
|
export type Geopoint = {
|
|
283
298
|
_type: 'geopoint'
|
|
284
299
|
lat?: number
|
|
@@ -286,24 +301,23 @@ export type Geopoint = {
|
|
|
286
301
|
alt?: number
|
|
287
302
|
}
|
|
288
303
|
|
|
289
|
-
export type SanityAssetInstanceState = string
|
|
290
|
-
|
|
291
304
|
export type AllSanitySchemaTypes =
|
|
292
|
-
| SanityAssetUploadSession
|
|
293
305
|
| SanitySystem
|
|
306
|
+
| SanityAssetUploadSession
|
|
294
307
|
| SanityAssetCollection
|
|
308
|
+
| SanityVideoMetadataRendition
|
|
295
309
|
| SanityVideoMetadataPlayback
|
|
296
|
-
|
|
|
297
|
-
| SanityImagePalette
|
|
310
|
+
| SanityVideoMetadata
|
|
298
311
|
| SanityImageExifTags
|
|
299
312
|
| SanityImageExifMetadata
|
|
313
|
+
| SanityImagePaletteSwatch
|
|
314
|
+
| SanityImagePalette
|
|
300
315
|
| SanityImageDimensions
|
|
316
|
+
| SanityImageMetadata
|
|
301
317
|
| SanityAsset
|
|
302
318
|
| SanityAssetVersion
|
|
303
319
|
| SanityVideoAsset
|
|
304
|
-
|
|
|
320
|
+
| SanityAssetInstanceState
|
|
305
321
|
| SanityFileAsset
|
|
306
322
|
| SanityImageAsset
|
|
307
|
-
| SanityImageMetadata
|
|
308
323
|
| Geopoint
|
|
309
|
-
| SanityAssetInstanceState
|
package/lib/index.mjs
DELETED
package/lib/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|