@sanity/media-library-types 0.0.2 → 1.0.1

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'
@@ -109,7 +111,7 @@ export declare interface Asset<
109
111
  currentVersion: {
110
112
  _ref: string
111
113
  }
112
- aspects?: Record<string, unknown>
114
+ aspects?: unknown
113
115
  versions: AssetVersion<AssetInstance>[]
114
116
  collections: SanityAssetCollection[]
115
117
  _createdAt: string
@@ -178,14 +180,14 @@ declare interface AssetSource {
178
180
  component: ComponentType<AssetSourceComponentProps>
179
181
  icon?: ComponentType<EmptyProps>
180
182
  /** @beta */
181
- uploader?: AssetSourceUploader
183
+ Uploader?: AssetSourceUploaderClass
182
184
  }
183
185
 
184
186
  /** @public */
185
187
  declare interface AssetSourceComponentProps {
186
188
  action?: 'select' | 'upload'
187
189
  assetSource: AssetSource
188
- assetType?: 'file' | 'image'
190
+ assetType?: 'file' | 'image' | 'sanity.video'
189
191
  accept: string
190
192
  selectionType: 'single'
191
193
  dialogHeaderTitle?: React.ReactNode
@@ -193,6 +195,8 @@ declare interface AssetSourceComponentProps {
193
195
  onClose: () => void
194
196
  onSelect: (assetFromSource: AssetFromSource[]) => void
195
197
  schemaType?: ImageSchemaType | FileSchemaType
198
+ /** @beta */
199
+ uploader?: AssetSourceUploader
196
200
  }
197
201
 
198
202
  /** @public */
@@ -248,6 +252,9 @@ declare interface AssetSourceUploader {
248
252
  reset(): void
249
253
  }
250
254
 
255
+ /** @beta */
256
+ declare type AssetSourceUploaderClass = new (...args: any[]) => AssetSourceUploader
257
+
251
258
  /** @beta */
252
259
  declare type AssetSourceUploadEvent =
253
260
  | AssetSourceUploadEventProgress
@@ -309,7 +316,7 @@ declare interface AssetSourceUploadFile {
309
316
  id: string
310
317
  file: globalThis.File
311
318
  progress: number
312
- status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
319
+ status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted' | 'alreadyExists'
313
320
  error?: Error
314
321
  result?: unknown
315
322
  }
@@ -368,6 +375,9 @@ declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
368
375
  input?: ComponentType<any>
369
376
  item?: ComponentType<any>
370
377
  preview?: ComponentType<any>
378
+ portableText?: {
379
+ plugins?: ComponentType<any>
380
+ }
371
381
  }
372
382
  /**
373
383
  * @deprecated This will be removed.
@@ -405,7 +415,7 @@ declare interface BaseSchemaTypeOptions {
405
415
  * {title: 'Strong', value: 'strong'},
406
416
  * {title: 'Emphasis', value: 'em'},
407
417
  * {title: 'Underline', value: 'underline'},
408
- * {title: 'Strike', value: 'strike'},
418
+ * {title: 'Strike', value: 'strike-through'},
409
419
  * {title: 'Code', value: 'code'},
410
420
  * ]
411
421
  * }
@@ -439,7 +449,7 @@ declare interface BlockDecoratorDefinition {
439
449
  * {title: 'Strong', value: 'strong'},
440
450
  * {title: 'Emphasis', value: 'em'},
441
451
  * {title: 'Underline', value: 'underline'},
442
- * {title: 'Strike', value: 'strike'},
452
+ * {title: 'Strike', value: 'strike-through'},
443
453
  * {title: 'Code', value: 'code'},
444
454
  * ],
445
455
  * annotations: [
@@ -532,6 +542,16 @@ declare interface BlockOptions extends BaseSchemaTypeOptions {
532
542
  */
533
543
  spellCheck?: boolean
534
544
  unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
545
+ /**
546
+ * When enabled, the editor will restrict all line breaks and soft breaks,
547
+ * forcing content to remain on a single line. This will also update
548
+ * the styling of the editor to reflect the single-line constraint.
549
+ *
550
+ * Pasting content that is on multiple lines will be normalized to a single line, if possible.
551
+ *
552
+ * @defaultValue false
553
+ */
554
+ oneLine?: boolean
535
555
  }
536
556
 
537
557
  /** @public */
@@ -754,6 +774,8 @@ declare interface DatetimeOptions extends BaseSchemaTypeOptions {
754
774
  dateFormat?: string
755
775
  timeFormat?: string
756
776
  timeStep?: number
777
+ displayTimeZone?: string
778
+ allowTimeZoneSwitch?: boolean
757
779
  }
758
780
 
759
781
  /** @public */
@@ -935,6 +957,7 @@ declare interface FileOptions extends ObjectOptions {
935
957
  storeOriginalFilename?: boolean
936
958
  accept?: string
937
959
  sources?: AssetSource[]
960
+ mediaLibrary?: MediaLibraryOptions
938
961
  }
939
962
 
940
963
  /** @public */
@@ -960,7 +983,7 @@ declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
960
983
  options?: FileOptions
961
984
  }
962
985
 
963
- export declare type FileStatus = 'pending' | 'uploading' | 'complete' | 'error'
986
+ export declare type FileStatus = 'pending' | 'uploading' | 'complete' | 'error' | 'alreadyExists'
964
987
 
965
988
  /**
966
989
  * Wrapper object for the file upload with progress and status
@@ -1217,24 +1240,28 @@ declare interface InsertMenuOptions {
1217
1240
  * `filter: 'auto'` automatically turns on filtering if there are more than 5
1218
1241
  * schema types added to the menu.
1219
1242
  */
1220
- filter?: 'auto' | boolean
1221
- groups?: Array<{
1222
- name: string
1223
- title?: string
1224
- of?: Array<string>
1225
- }>
1243
+ filter?: 'auto' | boolean | undefined
1244
+ groups?:
1245
+ | Array<{
1246
+ name: string
1247
+ title?: string
1248
+ of?: Array<string>
1249
+ }>
1250
+ | undefined
1226
1251
  /** defaultValue `true` */
1227
- showIcons?: boolean
1252
+ showIcons?: boolean | undefined
1228
1253
  /** @defaultValue `[{name: 'list'}]` */
1229
- views?: Array<
1230
- | {
1231
- name: 'list'
1232
- }
1233
- | {
1234
- name: 'grid'
1235
- previewImageUrl?: (schemaTypeName: string) => string | undefined
1236
- }
1237
- >
1254
+ views?:
1255
+ | Array<
1256
+ | {
1257
+ name: 'list'
1258
+ }
1259
+ | {
1260
+ name: 'grid'
1261
+ previewImageUrl?: (schemaTypeName: string) => string | undefined
1262
+ }
1263
+ >
1264
+ | undefined
1238
1265
  }
1239
1266
 
1240
1267
  declare const internalGroqTypeReferenceTo: unique symbol
@@ -1317,6 +1344,52 @@ declare interface LocalizedValidationMessages {
1317
1344
  [locale: string]: string
1318
1345
  }
1319
1346
 
1347
+ /** @public */
1348
+ declare type MediaAssetTypes = AssetInstanceDocument_2['_type']
1349
+
1350
+ /** @public */
1351
+ declare interface MediaLibraryFilter {
1352
+ name: string
1353
+ query: string
1354
+ }
1355
+
1356
+ /** @public */
1357
+ declare interface MediaLibraryOptions {
1358
+ filters?: MediaLibraryFilter[]
1359
+ }
1360
+
1361
+ /** @public */
1362
+ declare interface MediaValidationValue<T extends MediaAssetTypes = MediaAssetTypes> {
1363
+ /**
1364
+ * Media information
1365
+ */
1366
+ media: {
1367
+ /**
1368
+ * The Media Library Asset.
1369
+ */
1370
+ asset: Asset_3 & {
1371
+ currentVersion: Extract<
1372
+ AssetInstanceDocument_2,
1373
+ {
1374
+ _type: T
1375
+ }
1376
+ >
1377
+ }
1378
+ }
1379
+ /**
1380
+ * The field value which the media is used in.
1381
+ */
1382
+ value: unknown
1383
+ }
1384
+
1385
+ /** @public */
1386
+ declare interface MediaValidator<T extends MediaAssetTypes = MediaAssetTypes> {
1387
+ (
1388
+ value: MediaValidationValue<T>,
1389
+ context: ValidationContext,
1390
+ ): CustomValidatorResult | Promise<CustomValidatorResult>
1391
+ }
1392
+
1320
1393
  /** @public */
1321
1394
  declare interface MultiFieldSet {
1322
1395
  name: string
@@ -1741,6 +1814,7 @@ declare interface Rule {
1741
1814
  bypassConcurrencyLimit?: boolean
1742
1815
  },
1743
1816
  ): Rule
1817
+ media<T extends MediaAssetTypes = MediaAssetTypes>(fn: MediaValidator<T>): Rule
1744
1818
  min(len: number | string | FieldReference): Rule
1745
1819
  max(len: number | string | FieldReference): Rule
1746
1820
  length(len: number | FieldReference): Rule
@@ -1844,15 +1918,15 @@ declare type RuleSpec =
1844
1918
  }
1845
1919
  | {
1846
1920
  flag: 'min'
1847
- constraint: number | string
1921
+ constraint: number | string | FieldReference
1848
1922
  }
1849
1923
  | {
1850
1924
  flag: 'max'
1851
- constraint: number | string
1925
+ constraint: number | string | FieldReference
1852
1926
  }
1853
1927
  | {
1854
1928
  flag: 'length'
1855
- constraint: number
1929
+ constraint: number | FieldReference
1856
1930
  }
1857
1931
  | {
1858
1932
  flag: 'valid'
@@ -1860,15 +1934,15 @@ declare type RuleSpec =
1860
1934
  }
1861
1935
  | {
1862
1936
  flag: 'precision'
1863
- constraint: number
1937
+ constraint: number | FieldReference
1864
1938
  }
1865
1939
  | {
1866
1940
  flag: 'lessThan'
1867
- constraint: number
1941
+ constraint: number | FieldReference
1868
1942
  }
1869
1943
  | {
1870
1944
  flag: 'greaterThan'
1871
- constraint: number
1945
+ constraint: number | FieldReference
1872
1946
  }
1873
1947
  | {
1874
1948
  flag: 'stringCasing'
@@ -1880,6 +1954,10 @@ declare type RuleSpec =
1880
1954
  assetType: 'asset' | 'image' | 'file'
1881
1955
  }
1882
1956
  }
1957
+ | {
1958
+ flag: 'media'
1959
+ constraint: MediaValidator<any>
1960
+ }
1883
1961
  | {
1884
1962
  flag: 'regex'
1885
1963
  constraint: {
@@ -2124,7 +2202,12 @@ declare type SanityImagePaletteSwatch = {
2124
2202
  title?: string
2125
2203
  }
2126
2204
 
2127
- declare type SanityVideoAsset = {
2205
+ declare type SanitySystem = {
2206
+ _type: 'sanity.system'
2207
+ createdBy?: string
2208
+ }
2209
+
2210
+ export declare type SanityVideoAsset = {
2128
2211
  _id: string
2129
2212
  _type: 'sanity.videoAsset'
2130
2213
  _createdAt: string
@@ -2158,18 +2241,31 @@ declare type SanityVideoAsset = {
2158
2241
  path?: string
2159
2242
  url?: string
2160
2243
  extension?: string
2244
+ source?: {
2245
+ id?: string
2246
+ name?: string
2247
+ url?: string
2248
+ }
2161
2249
  metadata: SanityVideoMetadata
2162
2250
  }
2163
2251
 
2164
2252
  declare type SanityVideoMetadata = {
2165
2253
  _type: 'sanity.videoMetadata'
2166
- muxAssetId: string
2167
- muxPlaybackIds: Array<{
2168
- _id: string
2169
- _type: string
2170
- policy: string
2171
- _key: string
2172
- }>
2254
+ aspectRatio?: string
2255
+ duration?: number
2256
+ framerate?: number
2257
+ playbacks?: Array<
2258
+ {
2259
+ _key: string
2260
+ } & SanityVideoMetadataPlayback
2261
+ >
2262
+ }
2263
+
2264
+ declare type SanityVideoMetadataPlayback = {
2265
+ _type: 'sanity.videoMetadata.playback'
2266
+ _id: string
2267
+ name?: string
2268
+ policy: string
2173
2269
  }
2174
2270
 
2175
2271
  /** @public */
@@ -2543,13 +2639,21 @@ declare interface TypeReference {
2543
2639
  }
2544
2640
  }
2545
2641
 
2546
- export declare interface UploadSession {
2642
+ export declare type UploadSession = {
2547
2643
  _id: string
2548
2644
  _type: 'sanity.asset.upload-session'
2549
- title: string
2550
- assets: Asset[]
2551
2645
  _createdAt: string
2552
2646
  _updatedAt: string
2647
+ _rev: string
2648
+ title: string
2649
+ assets?: Array<{
2650
+ _ref: string
2651
+ _type: 'reference'
2652
+ _weak?: boolean
2653
+ _key: string
2654
+ [internalGroqTypeReferenceTo]?: 'sanity.asset'
2655
+ }>
2656
+ _system?: SanitySystem
2553
2657
  }
2554
2658
 
2555
2659
  /** @public */
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'
@@ -109,7 +111,7 @@ export declare interface Asset<
109
111
  currentVersion: {
110
112
  _ref: string
111
113
  }
112
- aspects?: Record<string, unknown>
114
+ aspects?: unknown
113
115
  versions: AssetVersion<AssetInstance>[]
114
116
  collections: SanityAssetCollection[]
115
117
  _createdAt: string
@@ -178,14 +180,14 @@ declare interface AssetSource {
178
180
  component: ComponentType<AssetSourceComponentProps>
179
181
  icon?: ComponentType<EmptyProps>
180
182
  /** @beta */
181
- uploader?: AssetSourceUploader
183
+ Uploader?: AssetSourceUploaderClass
182
184
  }
183
185
 
184
186
  /** @public */
185
187
  declare interface AssetSourceComponentProps {
186
188
  action?: 'select' | 'upload'
187
189
  assetSource: AssetSource
188
- assetType?: 'file' | 'image'
190
+ assetType?: 'file' | 'image' | 'sanity.video'
189
191
  accept: string
190
192
  selectionType: 'single'
191
193
  dialogHeaderTitle?: React.ReactNode
@@ -193,6 +195,8 @@ declare interface AssetSourceComponentProps {
193
195
  onClose: () => void
194
196
  onSelect: (assetFromSource: AssetFromSource[]) => void
195
197
  schemaType?: ImageSchemaType | FileSchemaType
198
+ /** @beta */
199
+ uploader?: AssetSourceUploader
196
200
  }
197
201
 
198
202
  /** @public */
@@ -248,6 +252,9 @@ declare interface AssetSourceUploader {
248
252
  reset(): void
249
253
  }
250
254
 
255
+ /** @beta */
256
+ declare type AssetSourceUploaderClass = new (...args: any[]) => AssetSourceUploader
257
+
251
258
  /** @beta */
252
259
  declare type AssetSourceUploadEvent =
253
260
  | AssetSourceUploadEventProgress
@@ -309,7 +316,7 @@ declare interface AssetSourceUploadFile {
309
316
  id: string
310
317
  file: globalThis.File
311
318
  progress: number
312
- status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted'
319
+ status: 'pending' | 'uploading' | 'complete' | 'error' | 'aborted' | 'alreadyExists'
313
320
  error?: Error
314
321
  result?: unknown
315
322
  }
@@ -368,6 +375,9 @@ declare interface BaseSchemaType extends Partial<DeprecationConfiguration> {
368
375
  input?: ComponentType<any>
369
376
  item?: ComponentType<any>
370
377
  preview?: ComponentType<any>
378
+ portableText?: {
379
+ plugins?: ComponentType<any>
380
+ }
371
381
  }
372
382
  /**
373
383
  * @deprecated This will be removed.
@@ -405,7 +415,7 @@ declare interface BaseSchemaTypeOptions {
405
415
  * {title: 'Strong', value: 'strong'},
406
416
  * {title: 'Emphasis', value: 'em'},
407
417
  * {title: 'Underline', value: 'underline'},
408
- * {title: 'Strike', value: 'strike'},
418
+ * {title: 'Strike', value: 'strike-through'},
409
419
  * {title: 'Code', value: 'code'},
410
420
  * ]
411
421
  * }
@@ -439,7 +449,7 @@ declare interface BlockDecoratorDefinition {
439
449
  * {title: 'Strong', value: 'strong'},
440
450
  * {title: 'Emphasis', value: 'em'},
441
451
  * {title: 'Underline', value: 'underline'},
442
- * {title: 'Strike', value: 'strike'},
452
+ * {title: 'Strike', value: 'strike-through'},
443
453
  * {title: 'Code', value: 'code'},
444
454
  * ],
445
455
  * annotations: [
@@ -532,6 +542,16 @@ declare interface BlockOptions extends BaseSchemaTypeOptions {
532
542
  */
533
543
  spellCheck?: boolean
534
544
  unstable_whitespaceOnPasteMode?: 'preserve' | 'normalize' | 'remove'
545
+ /**
546
+ * When enabled, the editor will restrict all line breaks and soft breaks,
547
+ * forcing content to remain on a single line. This will also update
548
+ * the styling of the editor to reflect the single-line constraint.
549
+ *
550
+ * Pasting content that is on multiple lines will be normalized to a single line, if possible.
551
+ *
552
+ * @defaultValue false
553
+ */
554
+ oneLine?: boolean
535
555
  }
536
556
 
537
557
  /** @public */
@@ -754,6 +774,8 @@ declare interface DatetimeOptions extends BaseSchemaTypeOptions {
754
774
  dateFormat?: string
755
775
  timeFormat?: string
756
776
  timeStep?: number
777
+ displayTimeZone?: string
778
+ allowTimeZoneSwitch?: boolean
757
779
  }
758
780
 
759
781
  /** @public */
@@ -935,6 +957,7 @@ declare interface FileOptions extends ObjectOptions {
935
957
  storeOriginalFilename?: boolean
936
958
  accept?: string
937
959
  sources?: AssetSource[]
960
+ mediaLibrary?: MediaLibraryOptions
938
961
  }
939
962
 
940
963
  /** @public */
@@ -960,7 +983,7 @@ declare interface FileSchemaType extends Omit<ObjectSchemaType, 'options'> {
960
983
  options?: FileOptions
961
984
  }
962
985
 
963
- export declare type FileStatus = 'pending' | 'uploading' | 'complete' | 'error'
986
+ export declare type FileStatus = 'pending' | 'uploading' | 'complete' | 'error' | 'alreadyExists'
964
987
 
965
988
  /**
966
989
  * Wrapper object for the file upload with progress and status
@@ -1217,24 +1240,28 @@ declare interface InsertMenuOptions {
1217
1240
  * `filter: 'auto'` automatically turns on filtering if there are more than 5
1218
1241
  * schema types added to the menu.
1219
1242
  */
1220
- filter?: 'auto' | boolean
1221
- groups?: Array<{
1222
- name: string
1223
- title?: string
1224
- of?: Array<string>
1225
- }>
1243
+ filter?: 'auto' | boolean | undefined
1244
+ groups?:
1245
+ | Array<{
1246
+ name: string
1247
+ title?: string
1248
+ of?: Array<string>
1249
+ }>
1250
+ | undefined
1226
1251
  /** defaultValue `true` */
1227
- showIcons?: boolean
1252
+ showIcons?: boolean | undefined
1228
1253
  /** @defaultValue `[{name: 'list'}]` */
1229
- views?: Array<
1230
- | {
1231
- name: 'list'
1232
- }
1233
- | {
1234
- name: 'grid'
1235
- previewImageUrl?: (schemaTypeName: string) => string | undefined
1236
- }
1237
- >
1254
+ views?:
1255
+ | Array<
1256
+ | {
1257
+ name: 'list'
1258
+ }
1259
+ | {
1260
+ name: 'grid'
1261
+ previewImageUrl?: (schemaTypeName: string) => string | undefined
1262
+ }
1263
+ >
1264
+ | undefined
1238
1265
  }
1239
1266
 
1240
1267
  declare const internalGroqTypeReferenceTo: unique symbol
@@ -1317,6 +1344,52 @@ declare interface LocalizedValidationMessages {
1317
1344
  [locale: string]: string
1318
1345
  }
1319
1346
 
1347
+ /** @public */
1348
+ declare type MediaAssetTypes = AssetInstanceDocument_2['_type']
1349
+
1350
+ /** @public */
1351
+ declare interface MediaLibraryFilter {
1352
+ name: string
1353
+ query: string
1354
+ }
1355
+
1356
+ /** @public */
1357
+ declare interface MediaLibraryOptions {
1358
+ filters?: MediaLibraryFilter[]
1359
+ }
1360
+
1361
+ /** @public */
1362
+ declare interface MediaValidationValue<T extends MediaAssetTypes = MediaAssetTypes> {
1363
+ /**
1364
+ * Media information
1365
+ */
1366
+ media: {
1367
+ /**
1368
+ * The Media Library Asset.
1369
+ */
1370
+ asset: Asset_3 & {
1371
+ currentVersion: Extract<
1372
+ AssetInstanceDocument_2,
1373
+ {
1374
+ _type: T
1375
+ }
1376
+ >
1377
+ }
1378
+ }
1379
+ /**
1380
+ * The field value which the media is used in.
1381
+ */
1382
+ value: unknown
1383
+ }
1384
+
1385
+ /** @public */
1386
+ declare interface MediaValidator<T extends MediaAssetTypes = MediaAssetTypes> {
1387
+ (
1388
+ value: MediaValidationValue<T>,
1389
+ context: ValidationContext,
1390
+ ): CustomValidatorResult | Promise<CustomValidatorResult>
1391
+ }
1392
+
1320
1393
  /** @public */
1321
1394
  declare interface MultiFieldSet {
1322
1395
  name: string
@@ -1741,6 +1814,7 @@ declare interface Rule {
1741
1814
  bypassConcurrencyLimit?: boolean
1742
1815
  },
1743
1816
  ): Rule
1817
+ media<T extends MediaAssetTypes = MediaAssetTypes>(fn: MediaValidator<T>): Rule
1744
1818
  min(len: number | string | FieldReference): Rule
1745
1819
  max(len: number | string | FieldReference): Rule
1746
1820
  length(len: number | FieldReference): Rule
@@ -1844,15 +1918,15 @@ declare type RuleSpec =
1844
1918
  }
1845
1919
  | {
1846
1920
  flag: 'min'
1847
- constraint: number | string
1921
+ constraint: number | string | FieldReference
1848
1922
  }
1849
1923
  | {
1850
1924
  flag: 'max'
1851
- constraint: number | string
1925
+ constraint: number | string | FieldReference
1852
1926
  }
1853
1927
  | {
1854
1928
  flag: 'length'
1855
- constraint: number
1929
+ constraint: number | FieldReference
1856
1930
  }
1857
1931
  | {
1858
1932
  flag: 'valid'
@@ -1860,15 +1934,15 @@ declare type RuleSpec =
1860
1934
  }
1861
1935
  | {
1862
1936
  flag: 'precision'
1863
- constraint: number
1937
+ constraint: number | FieldReference
1864
1938
  }
1865
1939
  | {
1866
1940
  flag: 'lessThan'
1867
- constraint: number
1941
+ constraint: number | FieldReference
1868
1942
  }
1869
1943
  | {
1870
1944
  flag: 'greaterThan'
1871
- constraint: number
1945
+ constraint: number | FieldReference
1872
1946
  }
1873
1947
  | {
1874
1948
  flag: 'stringCasing'
@@ -1880,6 +1954,10 @@ declare type RuleSpec =
1880
1954
  assetType: 'asset' | 'image' | 'file'
1881
1955
  }
1882
1956
  }
1957
+ | {
1958
+ flag: 'media'
1959
+ constraint: MediaValidator<any>
1960
+ }
1883
1961
  | {
1884
1962
  flag: 'regex'
1885
1963
  constraint: {
@@ -2124,7 +2202,12 @@ declare type SanityImagePaletteSwatch = {
2124
2202
  title?: string
2125
2203
  }
2126
2204
 
2127
- declare type SanityVideoAsset = {
2205
+ declare type SanitySystem = {
2206
+ _type: 'sanity.system'
2207
+ createdBy?: string
2208
+ }
2209
+
2210
+ export declare type SanityVideoAsset = {
2128
2211
  _id: string
2129
2212
  _type: 'sanity.videoAsset'
2130
2213
  _createdAt: string
@@ -2158,18 +2241,31 @@ declare type SanityVideoAsset = {
2158
2241
  path?: string
2159
2242
  url?: string
2160
2243
  extension?: string
2244
+ source?: {
2245
+ id?: string
2246
+ name?: string
2247
+ url?: string
2248
+ }
2161
2249
  metadata: SanityVideoMetadata
2162
2250
  }
2163
2251
 
2164
2252
  declare type SanityVideoMetadata = {
2165
2253
  _type: 'sanity.videoMetadata'
2166
- muxAssetId: string
2167
- muxPlaybackIds: Array<{
2168
- _id: string
2169
- _type: string
2170
- policy: string
2171
- _key: string
2172
- }>
2254
+ aspectRatio?: string
2255
+ duration?: number
2256
+ framerate?: number
2257
+ playbacks?: Array<
2258
+ {
2259
+ _key: string
2260
+ } & SanityVideoMetadataPlayback
2261
+ >
2262
+ }
2263
+
2264
+ declare type SanityVideoMetadataPlayback = {
2265
+ _type: 'sanity.videoMetadata.playback'
2266
+ _id: string
2267
+ name?: string
2268
+ policy: string
2173
2269
  }
2174
2270
 
2175
2271
  /** @public */
@@ -2543,13 +2639,21 @@ declare interface TypeReference {
2543
2639
  }
2544
2640
  }
2545
2641
 
2546
- export declare interface UploadSession {
2642
+ export declare type UploadSession = {
2547
2643
  _id: string
2548
2644
  _type: 'sanity.asset.upload-session'
2549
- title: string
2550
- assets: Asset[]
2551
2645
  _createdAt: string
2552
2646
  _updatedAt: string
2647
+ _rev: string
2648
+ title: string
2649
+ assets?: Array<{
2650
+ _ref: string
2651
+ _type: 'reference'
2652
+ _weak?: boolean
2653
+ _key: string
2654
+ [internalGroqTypeReferenceTo]?: 'sanity.asset'
2655
+ }>
2656
+ _system?: SanitySystem
2553
2657
  }
2554
2658
 
2555
2659
  /** @public */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/media-library-types",
3
- "version": "0.0.2",
3
+ "version": "1.0.1",
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.9",
41
+ "@sanity/types": "^4.8.1",
43
42
  "rimraf": "^5.0.10"
44
43
  },
45
44
  "scripts": {
package/src/assets.ts CHANGED
@@ -1,6 +1,15 @@
1
- import { SanityAsset, SanityAssetCollection, SanityAssetVersion, SanityFileAsset, SanityImageAsset, SanityImageMetadata, SanityVideoAsset } from "./schema.types"
1
+ import {
2
+ SanityAsset,
3
+ SanityAssetCollection,
4
+ SanityAssetVersion,
5
+ SanityVideoAsset,
6
+ SanityFileAsset,
7
+ SanityImageAsset,
8
+ } from './schema.types'
2
9
  import {type FieldDefinition} from '@sanity/types'
3
10
 
11
+ export type {SanityVideoAsset, SanityAssetUploadSession as UploadSession} from './schema.types'
12
+
4
13
  export interface AssetVersion<AssetInstance extends AssetInstanceDocument = AssetInstanceDocument> {
5
14
  _key: string
6
15
  _type: SanityAssetVersion['_type']
@@ -19,7 +28,7 @@ export interface Asset<AssetInstance extends AssetInstanceDocument = AssetInstan
19
28
  currentVersion: {
20
29
  _ref: string
21
30
  }
22
- aspects?: Record<string, unknown>
31
+ aspects?: unknown
23
32
  versions: AssetVersion<AssetInstance>[]
24
33
  collections: SanityAssetCollection[]
25
34
  _createdAt: string
@@ -45,12 +54,3 @@ export interface AssetAspectDocument extends BaseDocument {
45
54
  assetType?: Asset['assetType']
46
55
  definition: FieldDefinition
47
56
  }
48
-
49
- export interface UploadSession {
50
- _id: string
51
- _type: 'sanity.asset.upload-session'
52
- title: string
53
- assets: Asset[]
54
- _createdAt: string
55
- _updatedAt: string
56
- }
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
@@ -39,6 +39,13 @@ export type SanityAssetCollection = {
39
39
  }>
40
40
  }
41
41
 
42
+ export type SanityVideoMetadataPlayback = {
43
+ _type: 'sanity.videoMetadata.playback'
44
+ _id: string
45
+ name?: string
46
+ policy: string
47
+ }
48
+
42
49
  export type SanityImagePaletteSwatch = {
43
50
  _type: 'sanity.imagePaletteSwatch'
44
51
  background?: string
@@ -184,18 +191,24 @@ export type SanityVideoAsset = {
184
191
  path?: string
185
192
  url?: string
186
193
  extension?: string
194
+ source?: {
195
+ id?: string
196
+ name?: string
197
+ url?: string
198
+ }
187
199
  metadata: SanityVideoMetadata
188
200
  }
189
201
 
190
202
  export type SanityVideoMetadata = {
191
203
  _type: 'sanity.videoMetadata'
192
- muxAssetId: string
193
- muxPlaybackIds: Array<{
194
- _id: string
195
- _type: string
196
- policy: string
197
- _key: string
198
- }>
204
+ aspectRatio?: string
205
+ duration?: number
206
+ framerate?: number
207
+ playbacks?: Array<
208
+ {
209
+ _key: string
210
+ } & SanityVideoMetadataPlayback
211
+ >
199
212
  }
200
213
 
201
214
  export type SanityFileAsset = {
@@ -279,6 +292,7 @@ export type AllSanitySchemaTypes =
279
292
  | SanityAssetUploadSession
280
293
  | SanitySystem
281
294
  | SanityAssetCollection
295
+ | SanityVideoMetadataPlayback
282
296
  | SanityImagePaletteSwatch
283
297
  | SanityImagePalette
284
298
  | SanityImageExifTags