-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathasset.ts
94 lines (87 loc) · 2.52 KB
/
asset.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { ContentfulCollection } from './collection.js'
import { LocaleCode } from './locale.js'
import { Metadata } from './metadata.js'
import { EntitySys } from './sys.js'
import { ChainModifiers } from './client.js'
/**
* @category Asset
*/
export interface AssetDetails {
size: number
image?: {
width: number
height: number
}
}
/**
* @category Asset
*/
export interface AssetFile {
url: string
details: AssetDetails
fileName: string
contentType: string
}
/**
* @category Asset
*/
export interface AssetFields {
title?: string
description?: string
file?: AssetFile
}
/**
* Assets are binary files in a Contentful space
* @category Asset
* @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
* @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for asset field values.
* @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets | Documentation}
*/
export interface Asset<
Modifiers extends ChainModifiers = ChainModifiers,
Locales extends LocaleCode = LocaleCode,
> {
sys: AssetSys
fields: ChainModifiers extends Modifiers
?
| { [FieldName in keyof AssetFields]: { [LocaleName in Locales]?: AssetFields[FieldName] } }
| AssetFields
: 'WITH_ALL_LOCALES' extends Modifiers
? { [FieldName in keyof AssetFields]: { [LocaleName in Locales]?: AssetFields[FieldName] } }
: AssetFields
metadata: Metadata
}
/**
* @category Asset
*/
export type AssetMimeType =
| 'attachment'
| 'plaintext'
| 'image'
| 'audio'
| 'video'
| 'richtext'
| 'presentation'
| 'spreadsheet'
| 'pdfdocument'
| 'archive'
| 'code'
| 'markup'
/**
* A collection of assets
* @category Asset
* @typeParam Modifiers - The chain modifiers used to configure the client. They’re set automatically when using the client chain modifiers.
* @typeParam Locales - If provided for a client using `allLocales` modifier, response type defines locale keys for asset field values.
* @see {@link https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets | Documentation}
*/
export type AssetCollection<
Modifiers extends ChainModifiers = ChainModifiers,
Locales extends LocaleCode = LocaleCode,
> = ContentfulCollection<Asset<Modifiers, Locales>>
/**
* System managed metadata for assets
* @category Asset
*/
export type AssetSys = EntitySys & {
type: 'Asset'
}