@sanity/media-library-types 1.0.0 → 1.0.2

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.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import {Asset as Asset_3} from '@sanity/media-library-types'
2
+ import {AssetInstanceDocument as AssetInstanceDocument_2} from '@sanity/media-library-types'
1
3
  import {ClientPerspective} from '@sanity/client'
2
4
  import {ComponentType} from 'react'
3
5
  import {ElementType} from 'react'
@@ -115,6 +117,7 @@ export declare interface Asset<
115
117
  _createdAt: string
116
118
  _updatedAt: string
117
119
  _rev: string
120
+ url?: string
118
121
  }
119
122
 
120
123
  /** @public */
@@ -142,6 +145,7 @@ export declare interface AssetAspectDocument extends BaseDocument {
142
145
  */
143
146
  assetType?: Asset['assetType']
144
147
  definition: FieldDefinition
148
+ public?: boolean
145
149
  }
146
150
 
147
151
  /** @public */
@@ -178,14 +182,14 @@ declare interface AssetSource {
178
182
  component: ComponentType<AssetSourceComponentProps>
179
183
  icon?: ComponentType<EmptyProps>
180
184
  /** @beta */
181
- uploader?: AssetSourceUploader
185
+ Uploader?: AssetSourceUploaderClass
182
186
  }
183
187
 
184
188
  /** @public */
185
189
  declare interface AssetSourceComponentProps {
186
190
  action?: 'select' | 'upload'
187
191
  assetSource: AssetSource
188
- assetType?: 'file' | 'image'
192
+ assetType?: 'file' | 'image' | 'sanity.video'
189
193
  accept: string
190
194
  selectionType: 'single'
191
195
  dialogHeaderTitle?: React.ReactNode
@@ -193,6 +197,8 @@ declare interface AssetSourceComponentProps {
193
197
  onClose: () => void
194
198
  onSelect: (assetFromSource: AssetFromSource[]) => void
195
199
  schemaType?: ImageSchemaType | FileSchemaType
200
+ /** @beta */
201
+ uploader?: AssetSourceUploader
196
202
  }
197
203
 
198
204
  /** @public */
@@ -248,6 +254,9 @@ declare interface AssetSourceUploader {
248
254
  reset(): void
249
255
  }
250
256
 
257
+ /** @beta */
258
+ declare type AssetSourceUploaderClass = new (...args: any[]) => AssetSourceUploader
259
+
251
260
  /** @beta */
252
261
  declare type AssetSourceUploadEvent =
253
262
  | AssetSourceUploadEventProgress
@@ -309,7 +318,7 @@ declare interface AssetSourceUploadFile {
309
318
  id: string
310
319
  file: globalThis.File
311
320
  progress: number
312
- status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
321
+ status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted' | 'alreadyExists'
313
322
  error?: Error
314
323
  result?: unknown
315
324
  }
@@ -368,6 +377,9 @@ declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
368
377
  input?: ComponentType<any>
369
378
  item?: ComponentType<any>
370
379
  preview?: ComponentType<any>
380
+ portableText?: {
381
+ plugins?: ComponentType<any>
382
+ }
371
383
  }
372
384
  /**
373
385
  * @deprecated This will be removed.
@@ -405,7 +417,7 @@ declare interface BaseSchemaTypeOptions {
405
417
  * {title: 'Strong', value: 'strong'},
406
418
  * {title: 'Emphasis', value: 'em'},
407
419
  * {title: 'Underline', value: 'underline'},
408
- * {title: 'Strike', value: 'strike'},
420
+ * {title: 'Strike', value: 'strike-through'},
409
421
  * {title: 'Code', value: 'code'},
410
422
  * ]
411
423
  * }
@@ -439,7 +451,7 @@ declare interface BlockDecoratorDefinition {
439
451
  * {title: 'Strong', value: 'strong'},
440
452
  * {title: 'Emphasis', value: 'em'},
441
453
  * {title: 'Underline', value: 'underline'},
442
- * {title: 'Strike', value: 'strike'},
454
+ * {title: 'Strike', value: 'strike-through'},
443
455
  * {title: 'Code', value: 'code'},
444
456
  * ],
445
457
  * annotations: [
@@ -532,6 +544,16 @@ declare interface BlockOptions extends BaseSchemaTypeOptions {
532
544
  */
533
545
  spellCheck?: boolean
534
546
  unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
547
+ /**
548
+ * When enabled, the editor will restrict all line breaks and soft breaks,
549
+ * forcing content to remain on a single line. This will also update
550
+ * the styling of the editor to reflect the single-line constraint.
551
+ *
552
+ * Pasting content that is on multiple lines will be normalized to a single line, if possible.
553
+ *
554
+ * @defaultValue false
555
+ */
556
+ oneLine?: boolean
535
557
  }
536
558
 
537
559
  /** @public */
@@ -754,6 +776,8 @@ declare interface DatetimeOptions extends BaseSchemaTypeOptions {
754
776
  dateFormat?: string
755
777
  timeFormat?: string
756
778
  timeStep?: number
779
+ displayTimeZone?: string
780
+ allowTimeZoneSwitch?: boolean
757
781
  }
758
782
 
759
783
  /** @public */
@@ -935,6 +959,7 @@ declare interface FileOptions extends ObjectOptions {
935
959
  storeOriginalFilename?: boolean
936
960
  accept?: string
937
961
  sources?: AssetSource[]
962
+ mediaLibrary?: MediaLibraryOptions
938
963
  }
939
964
 
940
965
  /** @public */
@@ -960,7 +985,7 @@ declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
960
985
  options?: FileOptions
961
986
  }
962
987
 
963
- export declare type FileStatus = 'pending' | 'uploading' | 'complete' | 'error'
988
+ export declare type FileStatus = 'pending' | 'uploading' | 'complete' | 'error' | 'alreadyExists'
964
989
 
965
990
  /**
966
991
  * Wrapper object for the file upload with progress and status
@@ -1217,24 +1242,28 @@ declare interface InsertMenuOptions {
1217
1242
  * `filter: 'auto'` automatically turns on filtering if there are more than 5
1218
1243
  * schema types added to the menu.
1219
1244
  */
1220
- filter?: 'auto' | boolean
1221
- groups?: Array<{
1222
- name: string
1223
- title?: string
1224
- of?: Array<string>
1225
- }>
1245
+ filter?: 'auto' | boolean | undefined
1246
+ groups?:
1247
+ | Array<{
1248
+ name: string
1249
+ title?: string
1250
+ of?: Array<string>
1251
+ }>
1252
+ | undefined
1226
1253
  /** defaultValue `true` */
1227
- showIcons?: boolean
1254
+ showIcons?: boolean | undefined
1228
1255
  /** @defaultValue `[{name: 'list'}]` */
1229
- views?: Array<
1230
- | {
1231
- name: 'list'
1232
- }
1233
- | {
1234
- name: 'grid'
1235
- previewImageUrl?: (schemaTypeName: string) => string | undefined
1236
- }
1237
- >
1256
+ views?:
1257
+ | Array<
1258
+ | {
1259
+ name: 'list'
1260
+ }
1261
+ | {
1262
+ name: 'grid'
1263
+ previewImageUrl?: (schemaTypeName: string) => string | undefined
1264
+ }
1265
+ >
1266
+ | undefined
1238
1267
  }
1239
1268
 
1240
1269
  declare const internalGroqTypeReferenceTo: unique symbol
@@ -1317,6 +1346,52 @@ declare interface LocalizedValidationMessages {
1317
1346
  [locale: string]: string
1318
1347
  }
1319
1348
 
1349
+ /** @public */
1350
+ declare type MediaAssetTypes = AssetInstanceDocument_2['_type']
1351
+
1352
+ /** @public */
1353
+ declare interface MediaLibraryFilter {
1354
+ name: string
1355
+ query: string
1356
+ }
1357
+
1358
+ /** @public */
1359
+ declare interface MediaLibraryOptions {
1360
+ filters?: MediaLibraryFilter[]
1361
+ }
1362
+
1363
+ /** @public */
1364
+ declare interface MediaValidationValue<T extends MediaAssetTypes = MediaAssetTypes> {
1365
+ /**
1366
+ * Media information
1367
+ */
1368
+ media: {
1369
+ /**
1370
+ * The Media Library Asset.
1371
+ */
1372
+ asset: Asset_3 & {
1373
+ currentVersion: Extract<
1374
+ AssetInstanceDocument_2,
1375
+ {
1376
+ _type: T
1377
+ }
1378
+ >
1379
+ }
1380
+ }
1381
+ /**
1382
+ * The field value which the media is used in.
1383
+ */
1384
+ value: unknown
1385
+ }
1386
+
1387
+ /** @public */
1388
+ declare interface MediaValidator<T extends MediaAssetTypes = MediaAssetTypes> {
1389
+ (
1390
+ value: MediaValidationValue<T>,
1391
+ context: ValidationContext,
1392
+ ): CustomValidatorResult | Promise<CustomValidatorResult>
1393
+ }
1394
+
1320
1395
  /** @public */
1321
1396
  declare interface MultiFieldSet {
1322
1397
  name: string
@@ -1741,6 +1816,7 @@ declare interface Rule {
1741
1816
  bypassConcurrencyLimit?: boolean
1742
1817
  },
1743
1818
  ): Rule
1819
+ media<T extends MediaAssetTypes = MediaAssetTypes>(fn: MediaValidator<T>): Rule
1744
1820
  min(len: number | string | FieldReference): Rule
1745
1821
  max(len: number | string | FieldReference): Rule
1746
1822
  length(len: number | FieldReference): Rule
@@ -1844,15 +1920,15 @@ declare type RuleSpec =
1844
1920
  }
1845
1921
  | {
1846
1922
  flag: 'min'
1847
- constraint: number | string
1923
+ constraint: number | string | FieldReference
1848
1924
  }
1849
1925
  | {
1850
1926
  flag: 'max'
1851
- constraint: number | string
1927
+ constraint: number | string | FieldReference
1852
1928
  }
1853
1929
  | {
1854
1930
  flag: 'length'
1855
- constraint: number
1931
+ constraint: number | FieldReference
1856
1932
  }
1857
1933
  | {
1858
1934
  flag: 'valid'
@@ -1860,15 +1936,15 @@ declare type RuleSpec =
1860
1936
  }
1861
1937
  | {
1862
1938
  flag: 'precision'
1863
- constraint: number
1939
+ constraint: number | FieldReference
1864
1940
  }
1865
1941
  | {
1866
1942
  flag: 'lessThan'
1867
- constraint: number
1943
+ constraint: number | FieldReference
1868
1944
  }
1869
1945
  | {
1870
1946
  flag: 'greaterThan'
1871
- constraint: number
1947
+ constraint: number | FieldReference
1872
1948
  }
1873
1949
  | {
1874
1950
  flag: 'stringCasing'
@@ -1880,6 +1956,10 @@ declare type RuleSpec =
1880
1956
  assetType: 'asset' | 'image' | 'file'
1881
1957
  }
1882
1958
  }
1959
+ | {
1960
+ flag: 'media'
1961
+ constraint: MediaValidator<any>
1962
+ }
1883
1963
  | {
1884
1964
  flag: 'regex'
1885
1965
  constraint: {
@@ -1924,6 +2004,7 @@ declare type SanityAsset = {
1924
2004
  >
1925
2005
  assetType: 'sanity.imageAsset' | 'sanity.videoAsset' | 'sanity.fileAsset'
1926
2006
  cdnAccessPolicy: 'public' | 'private'
2007
+ url?: string
1927
2008
  }
1928
2009
 
1929
2010
  declare type SanityAssetCollection = {
@@ -1943,6 +2024,8 @@ declare type SanityAssetCollection = {
1943
2024
  }>
1944
2025
  }
1945
2026
 
2027
+ declare type SanityAssetInstanceState = string
2028
+
1946
2029
  declare type SanityAssetVersion = {
1947
2030
  _type: 'sanity.asset.version'
1948
2031
  title?: string
@@ -2017,7 +2100,7 @@ declare type SanityFileAsset = {
2017
2100
  _type: 'block'
2018
2101
  _key: string
2019
2102
  }>
2020
- state: string
2103
+ state: SanityAssetInstanceState
2021
2104
  sha1hash?: string
2022
2105
  mimeType?: string
2023
2106
  originalFilename?: string
@@ -2035,7 +2118,7 @@ declare type SanityImageAsset = {
2035
2118
  _updatedAt: string
2036
2119
  _rev: string
2037
2120
  altText?: string
2038
- state: string
2121
+ state: SanityAssetInstanceState
2039
2122
  sha1hash?: string
2040
2123
  mimeType?: string
2041
2124
  originalFilename?: string
@@ -2154,7 +2237,7 @@ export declare type SanityVideoAsset = {
2154
2237
  _type: 'block'
2155
2238
  _key: string
2156
2239
  }>
2157
- state: string
2240
+ state: SanityAssetInstanceState
2158
2241
  sha1hash?: string
2159
2242
  mimeType?: string
2160
2243
  originalFilename?: string
package/lib/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import {Asset as Asset_3} from '@sanity/media-library-types'
2
+ import {AssetInstanceDocument as AssetInstanceDocument_2} from '@sanity/media-library-types'
1
3
  import {ClientPerspective} from '@sanity/client'
2
4
  import {ComponentType} from 'react'
3
5
  import {ElementType} from 'react'
@@ -115,6 +117,7 @@ export declare interface Asset<
115
117
  _createdAt: string
116
118
  _updatedAt: string
117
119
  _rev: string
120
+ url?: string
118
121
  }
119
122
 
120
123
  /** @public */
@@ -142,6 +145,7 @@ export declare interface AssetAspectDocument extends BaseDocument {
142
145
  */
143
146
  assetType?: Asset['assetType']
144
147
  definition: FieldDefinition
148
+ public?: boolean
145
149
  }
146
150
 
147
151
  /** @public */
@@ -178,14 +182,14 @@ declare interface AssetSource {
178
182
  component: ComponentType<AssetSourceComponentProps>
179
183
  icon?: ComponentType<EmptyProps>
180
184
  /** @beta */
181
- uploader?: AssetSourceUploader
185
+ Uploader?: AssetSourceUploaderClass
182
186
  }
183
187
 
184
188
  /** @public */
185
189
  declare interface AssetSourceComponentProps {
186
190
  action?: 'select' | 'upload'
187
191
  assetSource: AssetSource
188
- assetType?: 'file' | 'image'
192
+ assetType?: 'file' | 'image' | 'sanity.video'
189
193
  accept: string
190
194
  selectionType: 'single'
191
195
  dialogHeaderTitle?: React.ReactNode
@@ -193,6 +197,8 @@ declare interface AssetSourceComponentProps {
193
197
  onClose: () => void
194
198
  onSelect: (assetFromSource: AssetFromSource[]) => void
195
199
  schemaType?: ImageSchemaType | FileSchemaType
200
+ /** @beta */
201
+ uploader?: AssetSourceUploader
196
202
  }
197
203
 
198
204
  /** @public */
@@ -248,6 +254,9 @@ declare interface AssetSourceUploader {
248
254
  reset(): void
249
255
  }
250
256
 
257
+ /** @beta */
258
+ declare type AssetSourceUploaderClass = new (...args: any[]) => AssetSourceUploader
259
+
251
260
  /** @beta */
252
261
  declare type AssetSourceUploadEvent =
253
262
  | AssetSourceUploadEventProgress
@@ -309,7 +318,7 @@ declare interface AssetSourceUploadFile {
309
318
  id: string
310
319
  file: globalThis.File
311
320
  progress: number
312
- status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
321
+ status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted' | 'alreadyExists'
313
322
  error?: Error
314
323
  result?: unknown
315
324
  }
@@ -368,6 +377,9 @@ declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
368
377
  input?: ComponentType<any>
369
378
  item?: ComponentType<any>
370
379
  preview?: ComponentType<any>
380
+ portableText?: {
381
+ plugins?: ComponentType<any>
382
+ }
371
383
  }
372
384
  /**
373
385
  * @deprecated This will be removed.
@@ -405,7 +417,7 @@ declare interface BaseSchemaTypeOptions {
405
417
  * {title: 'Strong', value: 'strong'},
406
418
  * {title: 'Emphasis', value: 'em'},
407
419
  * {title: 'Underline', value: 'underline'},
408
- * {title: 'Strike', value: 'strike'},
420
+ * {title: 'Strike', value: 'strike-through'},
409
421
  * {title: 'Code', value: 'code'},
410
422
  * ]
411
423
  * }
@@ -439,7 +451,7 @@ declare interface BlockDecoratorDefinition {
439
451
  * {title: 'Strong', value: 'strong'},
440
452
  * {title: 'Emphasis', value: 'em'},
441
453
  * {title: 'Underline', value: 'underline'},
442
- * {title: 'Strike', value: 'strike'},
454
+ * {title: 'Strike', value: 'strike-through'},
443
455
  * {title: 'Code', value: 'code'},
444
456
  * ],
445
457
  * annotations: [
@@ -532,6 +544,16 @@ declare interface BlockOptions extends BaseSchemaTypeOptions {
532
544
  */
533
545
  spellCheck?: boolean
534
546
  unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
547
+ /**
548
+ * When enabled, the editor will restrict all line breaks and soft breaks,
549
+ * forcing content to remain on a single line. This will also update
550
+ * the styling of the editor to reflect the single-line constraint.
551
+ *
552
+ * Pasting content that is on multiple lines will be normalized to a single line, if possible.
553
+ *
554
+ * @defaultValue false
555
+ */
556
+ oneLine?: boolean
535
557
  }
536
558
 
537
559
  /** @public */
@@ -754,6 +776,8 @@ declare interface DatetimeOptions extends BaseSchemaTypeOptions {
754
776
  dateFormat?: string
755
777
  timeFormat?: string
756
778
  timeStep?: number
779
+ displayTimeZone?: string
780
+ allowTimeZoneSwitch?: boolean
757
781
  }
758
782
 
759
783
  /** @public */
@@ -935,6 +959,7 @@ declare interface FileOptions extends ObjectOptions {
935
959
  storeOriginalFilename?: boolean
936
960
  accept?: string
937
961
  sources?: AssetSource[]
962
+ mediaLibrary?: MediaLibraryOptions
938
963
  }
939
964
 
940
965
  /** @public */
@@ -960,7 +985,7 @@ declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
960
985
  options?: FileOptions
961
986
  }
962
987
 
963
- export declare type FileStatus = 'pending' | 'uploading' | 'complete' | 'error'
988
+ export declare type FileStatus = 'pending' | 'uploading' | 'complete' | 'error' | 'alreadyExists'
964
989
 
965
990
  /**
966
991
  * Wrapper object for the file upload with progress and status
@@ -1217,24 +1242,28 @@ declare interface InsertMenuOptions {
1217
1242
  * `filter: 'auto'` automatically turns on filtering if there are more than 5
1218
1243
  * schema types added to the menu.
1219
1244
  */
1220
- filter?: 'auto' | boolean
1221
- groups?: Array<{
1222
- name: string
1223
- title?: string
1224
- of?: Array<string>
1225
- }>
1245
+ filter?: 'auto' | boolean | undefined
1246
+ groups?:
1247
+ | Array<{
1248
+ name: string
1249
+ title?: string
1250
+ of?: Array<string>
1251
+ }>
1252
+ | undefined
1226
1253
  /** defaultValue `true` */
1227
- showIcons?: boolean
1254
+ showIcons?: boolean | undefined
1228
1255
  /** @defaultValue `[{name: 'list'}]` */
1229
- views?: Array<
1230
- | {
1231
- name: 'list'
1232
- }
1233
- | {
1234
- name: 'grid'
1235
- previewImageUrl?: (schemaTypeName: string) => string | undefined
1236
- }
1237
- >
1256
+ views?:
1257
+ | Array<
1258
+ | {
1259
+ name: 'list'
1260
+ }
1261
+ | {
1262
+ name: 'grid'
1263
+ previewImageUrl?: (schemaTypeName: string) => string | undefined
1264
+ }
1265
+ >
1266
+ | undefined
1238
1267
  }
1239
1268
 
1240
1269
  declare const internalGroqTypeReferenceTo: unique symbol
@@ -1317,6 +1346,52 @@ declare interface LocalizedValidationMessages {
1317
1346
  [locale: string]: string
1318
1347
  }
1319
1348
 
1349
+ /** @public */
1350
+ declare type MediaAssetTypes = AssetInstanceDocument_2['_type']
1351
+
1352
+ /** @public */
1353
+ declare interface MediaLibraryFilter {
1354
+ name: string
1355
+ query: string
1356
+ }
1357
+
1358
+ /** @public */
1359
+ declare interface MediaLibraryOptions {
1360
+ filters?: MediaLibraryFilter[]
1361
+ }
1362
+
1363
+ /** @public */
1364
+ declare interface MediaValidationValue<T extends MediaAssetTypes = MediaAssetTypes> {
1365
+ /**
1366
+ * Media information
1367
+ */
1368
+ media: {
1369
+ /**
1370
+ * The Media Library Asset.
1371
+ */
1372
+ asset: Asset_3 & {
1373
+ currentVersion: Extract<
1374
+ AssetInstanceDocument_2,
1375
+ {
1376
+ _type: T
1377
+ }
1378
+ >
1379
+ }
1380
+ }
1381
+ /**
1382
+ * The field value which the media is used in.
1383
+ */
1384
+ value: unknown
1385
+ }
1386
+
1387
+ /** @public */
1388
+ declare interface MediaValidator<T extends MediaAssetTypes = MediaAssetTypes> {
1389
+ (
1390
+ value: MediaValidationValue<T>,
1391
+ context: ValidationContext,
1392
+ ): CustomValidatorResult | Promise<CustomValidatorResult>
1393
+ }
1394
+
1320
1395
  /** @public */
1321
1396
  declare interface MultiFieldSet {
1322
1397
  name: string
@@ -1741,6 +1816,7 @@ declare interface Rule {
1741
1816
  bypassConcurrencyLimit?: boolean
1742
1817
  },
1743
1818
  ): Rule
1819
+ media<T extends MediaAssetTypes = MediaAssetTypes>(fn: MediaValidator<T>): Rule
1744
1820
  min(len: number | string | FieldReference): Rule
1745
1821
  max(len: number | string | FieldReference): Rule
1746
1822
  length(len: number | FieldReference): Rule
@@ -1844,15 +1920,15 @@ declare type RuleSpec =
1844
1920
  }
1845
1921
  | {
1846
1922
  flag: 'min'
1847
- constraint: number | string
1923
+ constraint: number | string | FieldReference
1848
1924
  }
1849
1925
  | {
1850
1926
  flag: 'max'
1851
- constraint: number | string
1927
+ constraint: number | string | FieldReference
1852
1928
  }
1853
1929
  | {
1854
1930
  flag: 'length'
1855
- constraint: number
1931
+ constraint: number | FieldReference
1856
1932
  }
1857
1933
  | {
1858
1934
  flag: 'valid'
@@ -1860,15 +1936,15 @@ declare type RuleSpec =
1860
1936
  }
1861
1937
  | {
1862
1938
  flag: 'precision'
1863
- constraint: number
1939
+ constraint: number | FieldReference
1864
1940
  }
1865
1941
  | {
1866
1942
  flag: 'lessThan'
1867
- constraint: number
1943
+ constraint: number | FieldReference
1868
1944
  }
1869
1945
  | {
1870
1946
  flag: 'greaterThan'
1871
- constraint: number
1947
+ constraint: number | FieldReference
1872
1948
  }
1873
1949
  | {
1874
1950
  flag: 'stringCasing'
@@ -1880,6 +1956,10 @@ declare type RuleSpec =
1880
1956
  assetType: 'asset' | 'image' | 'file'
1881
1957
  }
1882
1958
  }
1959
+ | {
1960
+ flag: 'media'
1961
+ constraint: MediaValidator<any>
1962
+ }
1883
1963
  | {
1884
1964
  flag: 'regex'
1885
1965
  constraint: {
@@ -1924,6 +2004,7 @@ declare type SanityAsset = {
1924
2004
  >
1925
2005
  assetType: 'sanity.imageAsset' | 'sanity.videoAsset' | 'sanity.fileAsset'
1926
2006
  cdnAccessPolicy: 'public' | 'private'
2007
+ url?: string
1927
2008
  }
1928
2009
 
1929
2010
  declare type SanityAssetCollection = {
@@ -1943,6 +2024,8 @@ declare type SanityAssetCollection = {
1943
2024
  }>
1944
2025
  }
1945
2026
 
2027
+ declare type SanityAssetInstanceState = string
2028
+
1946
2029
  declare type SanityAssetVersion = {
1947
2030
  _type: 'sanity.asset.version'
1948
2031
  title?: string
@@ -2017,7 +2100,7 @@ declare type SanityFileAsset = {
2017
2100
  _type: 'block'
2018
2101
  _key: string
2019
2102
  }>
2020
- state: string
2103
+ state: SanityAssetInstanceState
2021
2104
  sha1hash?: string
2022
2105
  mimeType?: string
2023
2106
  originalFilename?: string
@@ -2035,7 +2118,7 @@ declare type SanityImageAsset = {
2035
2118
  _updatedAt: string
2036
2119
  _rev: string
2037
2120
  altText?: string
2038
- state: string
2121
+ state: SanityAssetInstanceState
2039
2122
  sha1hash?: string
2040
2123
  mimeType?: string
2041
2124
  originalFilename?: string
@@ -2154,7 +2237,7 @@ export declare type SanityVideoAsset = {
2154
2237
  _type: 'block'
2155
2238
  _key: string
2156
2239
  }>
2157
- state: string
2240
+ state: SanityAssetInstanceState
2158
2241
  sha1hash?: string
2159
2242
  mimeType?: string
2160
2243
  originalFilename?: string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/media-library-types",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Type definitions for common Sanity Media Library data structures",
5
5
  "keywords": [
6
6
  "sanity",
@@ -36,10 +36,9 @@
36
36
  "lib",
37
37
  "src"
38
38
  ],
39
- "dependencies": {},
40
39
  "devDependencies": {
41
- "@sanity/types": "^3.90.0",
42
- "@sanity/pkg-utils": "^7.2.3",
40
+ "@sanity/pkg-utils": "^8.1.29",
41
+ "@sanity/types": "^4.15.0",
43
42
  "rimraf": "^5.0.10"
44
43
  },
45
44
  "scripts": {
package/src/assets.ts CHANGED
@@ -34,6 +34,7 @@ export interface Asset<AssetInstance extends AssetInstanceDocument = AssetInstan
34
34
  _createdAt: string
35
35
  _updatedAt: string
36
36
  _rev: string
37
+ url?: string
37
38
  }
38
39
 
39
40
  export type BaseDocument = {
@@ -53,4 +54,5 @@ export interface AssetAspectDocument extends BaseDocument {
53
54
  */
54
55
  assetType?: Asset['assetType']
55
56
  definition: FieldDefinition
57
+ public?: boolean
56
58
  }
package/src/files.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type FileStatus = 'pending' | 'uploading' | 'complete' | 'error'
1
+ export type FileStatus = 'pending' | 'uploading' | 'complete' | 'error' | 'alreadyExists'
2
2
 
3
3
  /**
4
4
  * Wrapper object for the file upload with progress and status
@@ -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'
@@ -46,23 +46,16 @@ export type SanityVideoMetadataPlayback = {
46
46
  policy: string
47
47
  }
48
48
 
49
- export type SanityImagePaletteSwatch = {
50
- _type: 'sanity.imagePaletteSwatch'
51
- background?: string
52
- foreground?: string
53
- population?: number
54
- title?: string
55
- }
56
-
57
- export type SanityImagePalette = {
58
- _type: 'sanity.imagePalette'
59
- darkMuted?: SanityImagePaletteSwatch
60
- lightVibrant?: SanityImagePaletteSwatch
61
- darkVibrant?: SanityImagePaletteSwatch
62
- vibrant?: SanityImagePaletteSwatch
63
- dominant?: SanityImagePaletteSwatch
64
- lightMuted?: SanityImagePaletteSwatch
65
- muted?: SanityImagePaletteSwatch
49
+ export type SanityVideoMetadata = {
50
+ _type: 'sanity.videoMetadata'
51
+ aspectRatio?: string
52
+ duration?: number
53
+ framerate?: number
54
+ playbacks?: Array<
55
+ {
56
+ _key: string
57
+ } & SanityVideoMetadataPlayback
58
+ >
66
59
  }
67
60
 
68
61
  export type SanityImageExifTags = {
@@ -103,6 +96,25 @@ export type SanityImageExifMetadata = {
103
96
  Artist?: string
104
97
  }
105
98
 
99
+ export type SanityImagePaletteSwatch = {
100
+ _type: 'sanity.imagePaletteSwatch'
101
+ background?: string
102
+ foreground?: string
103
+ population?: number
104
+ title?: string
105
+ }
106
+
107
+ export type SanityImagePalette = {
108
+ _type: 'sanity.imagePalette'
109
+ darkMuted?: SanityImagePaletteSwatch
110
+ lightVibrant?: SanityImagePaletteSwatch
111
+ darkVibrant?: SanityImagePaletteSwatch
112
+ vibrant?: SanityImagePaletteSwatch
113
+ dominant?: SanityImagePaletteSwatch
114
+ lightMuted?: SanityImagePaletteSwatch
115
+ muted?: SanityImagePaletteSwatch
116
+ }
117
+
106
118
  export type SanityImageDimensions = {
107
119
  _type: 'sanity.imageDimensions'
108
120
  height: number
@@ -110,6 +122,19 @@ export type SanityImageDimensions = {
110
122
  aspectRatio: number
111
123
  }
112
124
 
125
+ export type SanityImageMetadata = {
126
+ _type: 'sanity.imageMetadata'
127
+ location?: Geopoint
128
+ dimensions: SanityImageDimensions
129
+ exif?: SanityImageExifMetadata
130
+ image?: SanityImageExifTags
131
+ palette: SanityImagePalette
132
+ lqip: string
133
+ blurHash: string
134
+ hasAlpha: boolean
135
+ isOpaque: boolean
136
+ }
137
+
113
138
  export type SanityAsset = {
114
139
  _id: string
115
140
  _type: 'sanity.asset'
@@ -131,6 +156,7 @@ export type SanityAsset = {
131
156
  >
132
157
  assetType: 'sanity.imageAsset' | 'sanity.videoAsset' | 'sanity.fileAsset'
133
158
  cdnAccessPolicy: 'public' | 'private'
159
+ url?: string
134
160
  }
135
161
 
136
162
  export type SanityAssetVersion = {
@@ -182,7 +208,7 @@ export type SanityVideoAsset = {
182
208
  _type: 'block'
183
209
  _key: string
184
210
  }>
185
- state: string
211
+ state: SanityAssetInstanceState
186
212
  sha1hash?: string
187
213
  mimeType?: string
188
214
  originalFilename?: string
@@ -199,17 +225,7 @@ export type SanityVideoAsset = {
199
225
  metadata: SanityVideoMetadata
200
226
  }
201
227
 
202
- export type SanityVideoMetadata = {
203
- _type: 'sanity.videoMetadata'
204
- aspectRatio?: string
205
- duration?: number
206
- framerate?: number
207
- playbacks?: Array<
208
- {
209
- _key: string
210
- } & SanityVideoMetadataPlayback
211
- >
212
- }
228
+ export type SanityAssetInstanceState = string
213
229
 
214
230
  export type SanityFileAsset = {
215
231
  _id: string
@@ -236,7 +252,7 @@ export type SanityFileAsset = {
236
252
  _type: 'block'
237
253
  _key: string
238
254
  }>
239
- state: string
255
+ state: SanityAssetInstanceState
240
256
  sha1hash?: string
241
257
  mimeType?: string
242
258
  originalFilename?: string
@@ -254,7 +270,7 @@ export type SanityImageAsset = {
254
270
  _updatedAt: string
255
271
  _rev: string
256
272
  altText?: string
257
- state: string
273
+ state: SanityAssetInstanceState
258
274
  sha1hash?: string
259
275
  mimeType?: string
260
276
  originalFilename?: string
@@ -266,19 +282,6 @@ export type SanityImageAsset = {
266
282
  metadata: SanityImageMetadata
267
283
  }
268
284
 
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
285
  export type Geopoint = {
283
286
  _type: 'geopoint'
284
287
  lat?: number
@@ -286,24 +289,22 @@ export type Geopoint = {
286
289
  alt?: number
287
290
  }
288
291
 
289
- export type SanityAssetInstanceState = string
290
-
291
292
  export type AllSanitySchemaTypes =
292
- | SanityAssetUploadSession
293
293
  | SanitySystem
294
+ | SanityAssetUploadSession
294
295
  | SanityAssetCollection
295
296
  | SanityVideoMetadataPlayback
296
- | SanityImagePaletteSwatch
297
- | SanityImagePalette
297
+ | SanityVideoMetadata
298
298
  | SanityImageExifTags
299
299
  | SanityImageExifMetadata
300
+ | SanityImagePaletteSwatch
301
+ | SanityImagePalette
300
302
  | SanityImageDimensions
303
+ | SanityImageMetadata
301
304
  | SanityAsset
302
305
  | SanityAssetVersion
303
306
  | SanityVideoAsset
304
- | SanityVideoMetadata
307
+ | SanityAssetInstanceState
305
308
  | SanityFileAsset
306
309
  | SanityImageAsset
307
- | SanityImageMetadata
308
310
  | Geopoint
309
- | SanityAssetInstanceState