forked from contentful/contentful.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
283 lines (251 loc) · 6.46 KB
/
index.d.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// Type definitions for contentful
// Definitions by: Miika Hänninen <https://github.com/googol>
export interface AxiosProxyConfig {
host: string;
port?: number;
auth?: {
username: string;
password: string;
};
}
export type ClientLogLevel = 'error' | 'warning' | 'info';
export interface CreateClientParams {
space: string;
accessToken: string;
environment?: string;
insecure?: boolean;
host?: string;
basePath?: string;
httpAgent?: any;
httpsAgent?: any;
proxy?: AxiosProxyConfig;
headers?: any;
adapter?: any;
application?: string;
integration?: string;
resolveLinks?: boolean;
removeUnresolved?: boolean;
retryOnError?: boolean;
logHandler?: (level: ClientLogLevel, data?: any) => void;
timeout?: number;
retryLimit?: number;
}
export interface ContentfulClientApi {
getAsset(id: string, query?: any): Promise<Asset>;
getAssets(query?: any): Promise<AssetCollection>;
getContentType(id: string): Promise<ContentType>;
getContentTypes(query?: any): Promise<ContentTypeCollection>;
getEntries<T>(query?: any): Promise<EntryCollection<T>>;
getEntry<T>(id: string, query?: any): Promise<Entry<T>>;
getSpace(): Promise<Space>;
getLocales(): Promise<LocaleCollection>;
getTag(id: string): Promise<Tag>;
getTags(query?: any): Promise<TagCollection>;
parseEntries<T>(raw: any): Promise<EntryCollection<T>>;
sync(query: any): Promise<SyncCollection>;
}
export interface Asset {
sys: Sys;
fields: {
title: string;
description: string;
file: {
url: string;
details: {
size: number;
image?: {
width: number;
height: number;
};
};
fileName: string;
contentType: string;
};
};
metadata: Metadata;
toPlainObject(): object;
}
export interface ContentfulCollection<T> {
total: number;
skip: number;
limit: number;
items: Array<T>;
toPlainObject(): object;
}
export type AssetCollection = ContentfulCollection<Asset>
export interface Entry<T> {
sys: Sys;
fields: T;
metadata: Metadata;
toPlainObject(): object;
update(): Promise<Entry<T>>;
}
export interface EntryCollection<T> extends ContentfulCollection<Entry<T>> {
errors?: Array<any>;
includes?: any;
stringifySafe(replacer?: any, space?: any): string;
}
export interface ContentType {
sys: Sys;
name: string;
description: string;
displayField: string;
fields: Array<Field>;
toPlainObject(): object;
}
export type ContentTypeCollection = ContentfulCollection<ContentType>;
export interface Space {
sys: Sys;
name: string;
locales: Array<string>;
toPlainObject(): object;
}
export interface Locale {
code: string
name: string
default: boolean
fallbackCode: string | null
sys: {
id: string
type: 'Locale'
version: number
}
}
export type LocaleCollection = ContentfulCollection<Locale>;
export interface Tag {
name: string
sys: {
id: string
type: 'Tag'
version: number
visibility: 'public'
}
}
export type TagCollection = ContentfulCollection<Tag>;
export interface SyncCollection {
entries: Array<Entry<any>>;
assets: Array<Asset>;
deletedEntries: Array<Entry<any>>;
deletedAssets: Array<Asset>;
nextSyncToken: string;
toPlainObject(): object;
stringifySafe(replacer?: any, space?: any): string;
}
export interface Sys {
type: string;
id: string;
createdAt: string;
updatedAt: string;
locale: string;
revision?: number;
space?: {
sys: SpaceLink;
};
contentType: {
sys: ContentTypeLink;
};
}
export interface SpaceLink {
type: 'Link';
linkType: 'Space';
id: string;
}
export interface ContentTypeLink {
type: 'Link';
linkType: 'ContentType';
id: string;
}
export interface Field {
disabled: boolean;
id: string;
linkType?: string;
localized: boolean;
name: string;
omitted: boolean;
required: boolean;
type: FieldType;
validations: FieldValidation[];
items?: FieldItem;
}
export type FieldType = 'Symbol' | 'Text' | 'Integer' | 'Number' | 'Date' | 'Boolean' | 'Location' | 'Link' | 'Array' | 'Object' | 'RichText';
export interface FieldValidation {
unique?: boolean;
size?: {
min?: number;
max?: number;
};
regexp?: {
pattern: string;
};
linkMimetypeGroup?: string[];
in?: string[];
linkContentType?: string[];
message?: string;
nodes?: {
'entry-hyperlink'?: FieldValidation[];
'embedded-entry-block'?: FieldValidation[];
'embedded-entry-inline'?: FieldValidation[];
};
enabledNodeTypes?: string[];
}
export interface FieldItem {
type: 'Link' | 'Symbol';
validations: FieldValidation[];
linkType?: 'Entry' | 'Asset';
}
export function createClient(params: CreateClientParams): ContentfulClientApi;
/**
* Types of fields found in an Entry
*/
export namespace EntryFields {
export type Symbol = string;
export type Text = string;
export type Integer = number;
export type Number = number;
export type Date = string;
export type Boolean = boolean;
export interface Location {
lat: string;
lon: string;
}
export type Link<T> = Asset | Entry<T>;
export type Array<T = any> = Symbol[] | Entry<T>[] | Asset[];
export type Object<T = any> = T;
export interface RichText {
data:{};
content: RichTextContent[];
nodeType: 'document';
}
}
interface RichTextDataTarget {
sys: {
id: string;
type: "Link";
"linkType": 'Entry' | 'Asset';
};
}
interface RichTextData {
uri?: string;
target?: RichTextDataTarget;
}
type RichTextNodeType = 'text' | 'heading-1' | 'heading-2' | 'heading-3' | 'heading-4' | 'heading-5'
| 'heading-6' | 'paragraph' | 'hyperlink' | 'entry-hyperlink' | 'asset-hyperlink'
| 'unordered-list' | 'ordered-list' | 'list-item' | 'blockquote' | 'hr' | 'embedded-entry-block'
| 'embedded-entry-inline';
interface RichTextContent {
data: RichTextData;
content?: RichTextContent[]
marks: {type: ('bold' | 'underline' | 'code' | 'italic')}[];
value?: string;
nodeType: RichTextNodeType;
}
interface TagLink {
sys: {
type: 'Link';
linkType: 'Tag';
id: string;
}
}
interface Metadata {
tags: TagLink[];
}