-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtypes.ts
More file actions
197 lines (174 loc) · 3.96 KB
/
types.ts
File metadata and controls
197 lines (174 loc) · 3.96 KB
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
export type Fetch = typeof fetch;
/**
* microCMS createClient params
*/
export interface MicroCMSClient {
serviceDomain: string;
apiKey: string;
retry?: boolean;
}
/**
* microCMS createManagementClient params
*/
export interface MicroCMSManagementClient {
serviceDomain: string;
apiKey: string;
}
type depthNumber = 0 | 1 | 2 | 3;
/**
* microCMS queries
* https://document.microcms.io/content-api/get-list-contents#h9ce528688c
* https://document.microcms.io/content-api/get-content#h9ce528688c
*/
export interface MicroCMSQueries {
draftKey?: string;
limit?: number;
offset?: number;
orders?: string;
fields?: string | string[];
q?: string;
depth?: depthNumber;
ids?: string | string[];
filters?: string;
richEditorFormat?: 'html' | 'object';
}
/**
* microCMS contentId
* https://document.microcms.io/manual/content-id-setting
*/
export interface MicroCMSContentId {
id: string;
}
/**
* microCMS content common date
*/
export interface MicroCMSDate {
createdAt: string;
updatedAt: string;
publishedAt?: string;
revisedAt?: string;
}
/**
* microCMS image
*/
export interface MicroCMSImage {
url: string;
width?: number;
height?: number;
alt?: string;
}
/**
* microCMS list api Response
*/
export interface MicroCMSListResponse<T> {
contents: (T & MicroCMSListContent)[];
totalCount: number;
limit: number;
offset: number;
}
/**
* microCMS list content common types
*/
export type MicroCMSListContent = MicroCMSContentId & MicroCMSDate;
/**
* microCMS object content common types
*/
export type MicroCMSObjectContent = MicroCMSDate;
export interface MakeRequest {
endpoint: string;
contentId?: string;
queries?: MicroCMSQueries & Record<string, any>;
requestInit?: RequestInit;
}
export type CustomRequestInit = Omit<
RequestInit,
'method' | 'headers' | 'body'
>;
export interface GetRequest {
endpoint: string;
contentId?: string;
queries?: MicroCMSQueries;
customRequestInit?: CustomRequestInit;
}
export interface GetListDetailRequest {
endpoint: string;
contentId: string;
queries?: MicroCMSQueries;
customRequestInit?: CustomRequestInit;
}
export interface GetListRequest {
endpoint: string;
queries?: MicroCMSQueries;
customRequestInit?: CustomRequestInit;
}
export interface GetObjectRequest {
endpoint: string;
queries?: MicroCMSQueries;
customRequestInit?: CustomRequestInit;
}
export interface GetAllContentIdsRequest {
endpoint: string;
/**
* @type {string} alternateField
* @example 'url'
* If you are using a URL other than the content ID, for example, you can specify that value in the `alternateField` field.
*/
alternateField?: string;
draftKey?: string;
filters?: string;
orders?: string;
customRequestInit?: CustomRequestInit;
}
export interface GetAllContentRequest {
endpoint: string;
queries?: Omit<MicroCMSQueries, 'limit' | 'offset' | 'ids'>;
customRequestInit?: CustomRequestInit;
}
export interface WriteApiRequestResult {
id: string;
}
export interface CreateRequest<T> {
endpoint: string;
contentId?: string;
content: T;
isDraft?: boolean;
isClosed?: boolean;
customRequestInit?: CustomRequestInit;
}
export interface UpdateRequest<T> {
endpoint: string;
contentId?: string;
content: Partial<T>;
isDraft?: boolean;
customRequestInit?: CustomRequestInit;
}
export interface DeleteRequest {
endpoint: string;
contentId: string;
customRequestInit?: CustomRequestInit;
}
export type UploadMediaRequest =
| {
data: File;
name?: undefined;
type?: undefined;
customRequestHeaders?: undefined;
}
| {
data: Blob;
name: string;
type?: undefined;
customRequestHeaders?: undefined;
}
| {
data: ReadableStream;
name: string;
type: `image/${string}`;
customRequestHeaders?: undefined;
}
| {
data: URL | string;
name?: string | null | undefined;
type?: undefined;
customRequestHeaders?: HeadersInit | null | undefined;
};