forked from contentful/contentful.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
154 lines (135 loc) · 3.44 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
// 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;
application?: string;
integration?: string;
resolveLinks?: boolean;
removeUnresolved?: boolean;
retryOnError?: boolean;
logHandler?: (level: ClientLogLevel, data?: any) => void;
timeout?: 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>;
sync(query: any): Promise<SyncCollection>;
}
export interface Asset {
sys: Sys;
fields: {
title: string;
description: string;
file: {
url: string;
details: any;
fileName: string;
contentType: string;
};
};
toPlainObject(): Asset;
}
export interface ContentfulCollection<T> {
total: number;
skip: number;
limit: number;
items: Array<T>;
toPlainObject(): this;
}
export type AssetCollection = ContentfulCollection<Asset>
export interface Entry<T> {
sys: Sys;
fields: T;
toPlainObject(): 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(): ContentType;
}
export type ContentTypeCollection = ContentfulCollection<ContentType>;
export interface Space {
sys: Sys;
name: string;
locales: Array<string>;
toPlainObject(): Space;
}
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 SyncCollection {
entries: Array<Entry<any>>;
assets: Array<Asset>;
deletedEntries: Array<Entry<any>>;
deletedAssets: Array<Asset>;
nextSyncToken: string;
toPlainObject(): SyncCollection;
stringifySafe(replacer: any, space: any): string;
}
export interface Sys {
type: string;
id: string;
createdAt: string;
updatedAt: string;
locale: string;
contentType: {
sys: ContentTypeLink;
};
}
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: string;
}
export function createClient(params: CreateClientParams): ContentfulClientApi;