@sanity/media-library-types 1.2.0 → 1.4.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/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@sanity/media-library-types",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Type definitions for common Sanity Media Library data structures",
5
5
  "keywords": [
6
- "sanity",
7
- "media",
8
- "library",
6
+ "content",
9
7
  "headless",
8
+ "library",
9
+ "media",
10
10
  "realtime",
11
- "content",
11
+ "sanity",
12
12
  "types",
13
13
  "typescript"
14
14
  ],
@@ -18,8 +18,15 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "author": "Sanity.io <hello@sanity.io>",
21
- "sideEffects": false,
21
+ "files": [
22
+ "lib",
23
+ "src"
24
+ ],
22
25
  "type": "module",
26
+ "sideEffects": false,
27
+ "main": "./lib/index.cjs",
28
+ "module": "./lib/index.js",
29
+ "types": "./lib/index.d.ts",
23
30
  "exports": {
24
31
  ".": {
25
32
  "source": "./src/index.ts",
@@ -29,17 +36,10 @@
29
36
  },
30
37
  "./package.json": "./package.json"
31
38
  },
32
- "main": "./lib/index.cjs",
33
- "module": "./lib/index.js",
34
- "types": "./lib/index.d.ts",
35
- "files": [
36
- "lib",
37
- "src"
38
- ],
39
39
  "devDependencies": {
40
- "@sanity/pkg-utils": "^10.2.5",
41
- "@sanity/types": "4.20.0",
42
- "rimraf": "^5.0.10"
40
+ "@sanity/pkg-utils": "10.4.15",
41
+ "@sanity/types": "5.21.0",
42
+ "rimraf": "5.0.10"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "cp ../../../apps/huey/src/lib/schema.types.ts ./src/ && pkg-utils build --strict --check --clean",
package/src/assets.ts CHANGED
@@ -25,6 +25,7 @@ export type AssetInstanceDocument = SanityImageAsset | SanityVideoAsset | Sanity
25
25
 
26
26
  export interface Asset<AssetInstance extends AssetInstanceDocument = AssetInstanceDocument> {
27
27
  _id: string
28
+ _originalId?: string
28
29
  _type: SanityAsset['_type']
29
30
  title: string
30
31
  assetType: AssetInstance['_type']
package/src/plugin.ts CHANGED
@@ -33,6 +33,13 @@ export type PluginPayload = {
33
33
  scheme: 'light' | 'dark'
34
34
  selectAssetTypes: PluginSelectAssetType[]
35
35
  selectionType: 'single' | 'multiple'
36
+ /**
37
+ * Opaque string the host generates to **partition persisted picker UI state** (e.g. folder path,
38
+ * search query, filters) in the Media Library iframe. Huey derives `localStorage` key suffixes
39
+ * from this value; embedders often derive it from project + dataset + workspace (or any stable
40
+ * context).
41
+ */
42
+ pickerPersistenceKey?: string
36
43
  }
37
44
 
38
45
  /**
@@ -1,10 +1,15 @@
1
- export declare const internalGroqTypeReferenceTo: unique symbol
2
-
3
1
  export type SanitySystem = {
4
2
  _type: 'sanity.system'
5
3
  createdBy?: string
6
4
  }
7
5
 
6
+ export type SanityAssetReference = {
7
+ _ref: string
8
+ _type: 'reference'
9
+ _weak?: boolean
10
+ [internalGroqTypeReferenceTo]?: 'sanity.asset'
11
+ }
12
+
8
13
  export type SanityAssetUploadSession = {
9
14
  _id: string
10
15
  _type: 'sanity.asset.upload-session'
@@ -12,16 +17,39 @@ export type SanityAssetUploadSession = {
12
17
  _updatedAt: string
13
18
  _rev: string
14
19
  title: string
15
- assets?: Array<{
16
- _ref: string
17
- _type: 'reference'
18
- _weak?: boolean
19
- _key: string
20
- [internalGroqTypeReferenceTo]?: 'sanity.asset'
21
- }>
20
+ assets?: Array<
21
+ {
22
+ _key: string
23
+ } & SanityAssetReference
24
+ >
22
25
  _system?: SanitySystem
23
26
  }
24
27
 
28
+ export type SanityDirectoryReference = {
29
+ _ref: string
30
+ _type: 'reference'
31
+ _weak?: boolean
32
+ [internalGroqTypeReferenceTo]?: 'sanity.directory'
33
+ }
34
+
35
+ export type SanitySymlink = {
36
+ _id: string
37
+ _type: 'sanity.symlink'
38
+ _createdAt: string
39
+ _updatedAt: string
40
+ _rev: string
41
+ parent?: SanityDirectoryReference
42
+ rootDirectory?: SanityDirectoryReference
43
+ target?: SanityAssetReference
44
+ }
45
+
46
+ export type SanityTreeReference = {
47
+ _ref: string
48
+ _type: 'reference'
49
+ _weak?: boolean
50
+ [internalGroqTypeReferenceTo]?: 'sanity.tree'
51
+ }
52
+
25
53
  export type SanityAssetCollection = {
26
54
  _id: string
27
55
  _type: 'sanity.asset.collection'
@@ -30,13 +58,13 @@ export type SanityAssetCollection = {
30
58
  _rev: string
31
59
  title: string
32
60
  description?: string
33
- assets?: Array<{
34
- _ref: string
35
- _type: 'reference'
36
- _weak?: boolean
37
- _key: string
38
- [internalGroqTypeReferenceTo]?: 'sanity.asset'
39
- }>
61
+ parent?: SanityDirectoryReference | SanityTreeReference
62
+ rootDirectory?: SanityDirectoryReference
63
+ assets?: Array<
64
+ {
65
+ _key: string
66
+ } & SanityAssetReference
67
+ >
40
68
  }
41
69
 
42
70
  export type SanityVideoMetadataRendition = {
@@ -52,6 +80,13 @@ export type SanityVideoMetadataPlayback = {
52
80
  policy: string
53
81
  }
54
82
 
83
+ export type SanityAssetSubtitleReference = {
84
+ _ref: string
85
+ _type: 'reference'
86
+ _weak?: boolean
87
+ [internalGroqTypeReferenceTo]?: 'sanity.asset.subtitle'
88
+ }
89
+
55
90
  export type SanityVideoMetadata = {
56
91
  _type: 'sanity.videoMetadata'
57
92
  aspectRatio?: string
@@ -67,6 +102,11 @@ export type SanityVideoMetadata = {
67
102
  _key: string
68
103
  } & SanityVideoMetadataRendition
69
104
  >
105
+ subtitles?: Array<
106
+ {
107
+ _key: string
108
+ } & SanityAssetSubtitleReference
109
+ >
70
110
  }
71
111
 
72
112
  export type SanityImageExifTags = {
@@ -146,6 +186,17 @@ export type SanityImageMetadata = {
146
186
  isOpaque: boolean
147
187
  }
148
188
 
189
+ export type SanityFileMetadata = {
190
+ _type: 'sanity.fileMetadata'
191
+ }
192
+
193
+ export type SanityAssetVersionReference = {
194
+ _ref: string
195
+ _type: 'reference'
196
+ _weak?: boolean
197
+ [internalGroqTypeReferenceTo]?: 'sanity.asset.version'
198
+ }
199
+
149
200
  export type SanityAsset = {
150
201
  _id: string
151
202
  _type: 'sanity.asset'
@@ -154,12 +205,7 @@ export type SanityAsset = {
154
205
  _rev: string
155
206
  title?: string
156
207
  aspects?: Record<string, unknown>
157
- currentVersion: {
158
- _ref: string
159
- _type: 'reference'
160
- _weak?: boolean
161
- [internalGroqTypeReferenceTo]?: 'sanity.asset.version'
162
- }
208
+ currentVersion: SanityAssetVersionReference
163
209
  versions: Array<
164
210
  {
165
211
  _key: string
@@ -167,31 +213,37 @@ export type SanityAsset = {
167
213
  >
168
214
  assetType: 'sanity.imageAsset' | 'sanity.videoAsset' | 'sanity.fileAsset'
169
215
  cdnAccessPolicy: 'public' | 'private'
216
+ parent?: SanityDirectoryReference | SanityTreeReference
217
+ rootDirectory?: SanityDirectoryReference
170
218
  url?: string
219
+ _system?: SanitySystem
220
+ }
221
+
222
+ export type SanityImageAssetReference = {
223
+ _ref: string
224
+ _type: 'reference'
225
+ _weak?: boolean
226
+ [internalGroqTypeReferenceTo]?: 'sanity.imageAsset'
227
+ }
228
+
229
+ export type SanityFileAssetReference = {
230
+ _ref: string
231
+ _type: 'reference'
232
+ _weak?: boolean
233
+ [internalGroqTypeReferenceTo]?: 'sanity.fileAsset'
234
+ }
235
+
236
+ export type SanityVideoAssetReference = {
237
+ _ref: string
238
+ _type: 'reference'
239
+ _weak?: boolean
240
+ [internalGroqTypeReferenceTo]?: 'sanity.videoAsset'
171
241
  }
172
242
 
173
243
  export type SanityAssetVersion = {
174
244
  _type: 'sanity.asset.version'
175
245
  title?: string
176
- instance:
177
- | {
178
- _ref: string
179
- _type: 'reference'
180
- _weak?: boolean
181
- [internalGroqTypeReferenceTo]?: 'sanity.imageAsset'
182
- }
183
- | {
184
- _ref: string
185
- _type: 'reference'
186
- _weak?: boolean
187
- [internalGroqTypeReferenceTo]?: 'sanity.fileAsset'
188
- }
189
- | {
190
- _ref: string
191
- _type: 'reference'
192
- _weak?: boolean
193
- [internalGroqTypeReferenceTo]?: 'sanity.videoAsset'
194
- }
246
+ instance: SanityImageAssetReference | SanityFileAssetReference | SanityVideoAssetReference
195
247
  }
196
248
 
197
249
  export type SanityVideoAsset = {
@@ -234,6 +286,8 @@ export type SanityVideoAsset = {
234
286
  url?: string
235
287
  }
236
288
  metadata: SanityVideoMetadata
289
+ rootDirectory?: SanityDirectoryReference
290
+ _system?: SanitySystem
237
291
  }
238
292
 
239
293
  export type SanityAssetInstanceState = string
@@ -273,6 +327,8 @@ export type SanityFileAsset = {
273
327
  extension?: string
274
328
  url: string
275
329
  previewUrl?: string
330
+ rootDirectory?: SanityDirectoryReference
331
+ _system?: SanitySystem
276
332
  }
277
333
 
278
334
  export type SanityImageAsset = {
@@ -292,6 +348,8 @@ export type SanityImageAsset = {
292
348
  extension?: string
293
349
  url: string
294
350
  metadata: SanityImageMetadata
351
+ rootDirectory?: SanityDirectoryReference
352
+ _system?: SanitySystem
295
353
  }
296
354
 
297
355
  export type Geopoint = {
@@ -301,12 +359,62 @@ export type Geopoint = {
301
359
  alt?: number
302
360
  }
303
361
 
362
+ export type SanityAssetSubtitle = {
363
+ _id: string
364
+ _type: 'sanity.asset.subtitle'
365
+ _createdAt: string
366
+ _updatedAt: string
367
+ _rev: string
368
+ languageCode?: string
369
+ closedCaptions?: boolean
370
+ status?: string
371
+ origin?: string
372
+ source?: {
373
+ id?: string
374
+ name?: string
375
+ url?: string
376
+ }
377
+ segments?: Array<{
378
+ startTime?: number
379
+ endTime?: number
380
+ text?: string
381
+ _key: string
382
+ }>
383
+ error?: string
384
+ rootDirectory?: SanityDirectoryReference
385
+ }
386
+
387
+ export type SanityDirectory = {
388
+ _id: string
389
+ _type: 'sanity.directory'
390
+ _createdAt: string
391
+ _updatedAt: string
392
+ _rev: string
393
+ name?: string
394
+ parent?: SanityDirectoryReference | SanityTreeReference
395
+ rootDirectory?: SanityDirectoryReference
396
+ }
397
+
398
+ export type SanityTree = {
399
+ _id: string
400
+ _type: 'sanity.tree'
401
+ _createdAt: string
402
+ _updatedAt: string
403
+ _rev: string
404
+ name?: string
405
+ }
406
+
304
407
  export type AllSanitySchemaTypes =
305
408
  | SanitySystem
409
+ | SanityAssetReference
306
410
  | SanityAssetUploadSession
411
+ | SanityDirectoryReference
412
+ | SanitySymlink
413
+ | SanityTreeReference
307
414
  | SanityAssetCollection
308
415
  | SanityVideoMetadataRendition
309
416
  | SanityVideoMetadataPlayback
417
+ | SanityAssetSubtitleReference
310
418
  | SanityVideoMetadata
311
419
  | SanityImageExifTags
312
420
  | SanityImageExifMetadata
@@ -314,10 +422,20 @@ export type AllSanitySchemaTypes =
314
422
  | SanityImagePalette
315
423
  | SanityImageDimensions
316
424
  | SanityImageMetadata
425
+ | SanityFileMetadata
426
+ | SanityAssetVersionReference
317
427
  | SanityAsset
428
+ | SanityImageAssetReference
429
+ | SanityFileAssetReference
430
+ | SanityVideoAssetReference
318
431
  | SanityAssetVersion
319
432
  | SanityVideoAsset
320
433
  | SanityAssetInstanceState
321
434
  | SanityFileAsset
322
435
  | SanityImageAsset
323
436
  | Geopoint
437
+ | SanityAssetSubtitle
438
+ | SanityDirectory
439
+ | SanityTree
440
+
441
+ export declare const internalGroqTypeReferenceTo: unique symbol