-
Notifications
You must be signed in to change notification settings - Fork 80
/
interfaces.ts
347 lines (314 loc) · 6.57 KB
/
interfaces.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
import { ResponseFn } from './sbFetch'
export interface ISbStoriesParams
extends Partial<ISbStoryData>,
ISbMultipleStoriesData {
resolve_level?: number
_stopResolving?: boolean
by_slugs?: string
by_uuids?: string
by_uuids_ordered?: string
component?: string
content_type?: string
cv?: number
datasource?: string
dimension?: string
excluding_fields?: string
excluding_ids?: string
excluding_slugs?: string
fallback_lang?: string
filename?: string
filter_query?: any
first_published_at_gt?: string
first_published_at_lt?: string
from_release?: string
is_startpage?: boolean
language?: string
level?: number
page?: number
per_page?: number
published_at_gt?: string
published_at_lt?: string
resolve_assets?: number
resolve_links?: 'link' | 'url' | 'story' | '0' | '1' | 'link'
resolve_relations?: string | string[]
search_term?: string
size?: string
sort_by?: string
starts_with?: string
token?: string
version?: 'draft' | 'published'
with_tag?: string
}
export interface ISbStoryParams {
resolve_level?: number
token?: string
find_by?: 'uuid'
version?: 'draft' | 'published'
resolve_links?: 'link' | 'url' | 'story' | '0' | '1'
resolve_relations?: string | string[]
cv?: number
from_release?: string
language?: string
fallback_lang?: string
}
type Dimension = {
id: number
name: string
entry_value: string
datasource_id: number
created_at: string
updated_at: string
}
/**
* @interface ISbDimensions
* @description Storyblok Dimensions Interface auxiliary interface
* @description One use it to handle the API response
*/
export interface ISbDimensions {
dimensions: Dimension[]
}
export interface ISbComponentType<T extends string> {
_uid?: string
component?: T
_editable?: string
}
export interface ISbStoryData<
Content = ISbComponentType<string> & { [index: string]: any },
> extends ISbMultipleStoriesData {
alternates: ISbAlternateObject[]
breadcrumbs?: ISbLinkURLObject[]
content: Content
created_at: string
default_full_slug?: string
default_root?: string
disble_fe_editor?: boolean
first_published_at?: string
full_slug: string
group_id: string
id: number
imported_at?: string
is_folder?: boolean
is_startpage?: boolean
lang: string
last_author?: {
id: number
userid: string
}
meta_data: any
name: string
parent?: ISbStoryData
parent_id: number
path?: string
pinned?: '1' | boolean
position: number
published?: boolean
published_at: string | null
release_id?: number
slug: string
sort_by_date: string | null
tag_list: string[]
translated_slugs?: {
path: string
name: string | null
lang: ISbStoryData['lang']
}[]
unpublished_changes?: boolean
updated_at?: string
uuid: string
}
export interface ISbMultipleStoriesData {
by_ids?: string
by_uuids?: string
contain_component?: string
excluding_ids?: string
filter_query?: any
folder_only?: boolean
full_slug?: string
in_release?: string
in_trash?: boolean
is_published?: boolean
in_workflow_stages?: string
page?: number
pinned?: '1' | boolean
search?: string
sort_by?: string
starts_with?: string
story_only?: boolean
text_search?: string
with_parent?: number
with_slug?: string
with_tag?: string
}
export interface ISbAlternateObject {
id: number
name: string
slug: string
published: boolean
full_slug: string
is_folder: boolean
parent_id: number
}
export interface ISbLinkURLObject {
id: number
name: string
slug: string
full_slug: string
url: string
uuid: string
}
export interface ISbStories {
data: {
cv: number
links: (ISbStoryData | ISbLinkURLObject)[]
rels: ISbStoryData[]
stories: ISbStoryData[]
}
perPage: number
total: number
headers: any
}
export interface ISbStory {
data: {
cv: number
links: (ISbStoryData | ISbLinkURLObject)[]
rels: ISbStoryData[]
story: ISbStoryData
}
headers: any
}
export interface IMemoryType extends ISbResult {
[key: string]: any
}
export interface ICacheProvider {
get: (key: string) => Promise<IMemoryType | void>
set: (key: string, content: ISbResult) => Promise<void>
getAll: () => Promise<IMemoryType | void>
flush: () => Promise<void>
}
export interface ISbCache {
type?: 'none' | 'memory' | 'custom'
clear?: 'auto' | 'manual'
custom?: ICacheProvider
}
export interface ISbConfig {
accessToken?: string
oauthToken?: string
resolveNestedRelations?: boolean
cache?: ISbCache
responseInterceptor?: ResponseFn
fetch?: typeof fetch
timeout?: number
headers?: any
region?: string
maxRetries?: number
https?: boolean
rateLimit?: number
componentResolver?: (component: string, data: any) => void
richTextSchema?: ISbSchema
endpoint?: string
}
export interface ISbResult {
data: any
perPage: number
total: number
headers: Headers
}
export interface ISbResponse {
data: any
status: number
statusText: string
}
export interface ISbError {
message?: string
status?: number
response?: ISbResponse
}
export interface ISbNode extends Element {
content: object[]
attrs: {
anchor?: string
body?: Array<ISbComponentType<any>>
href?: string
level?: number
linktype?: string
custom?: LinkCustomAttributes
[key: string]: any | undefined
}
}
export type NodeSchema = {
(node: ISbNode): object
}
export type MarkSchema = {
(node: ISbNode): object
}
export interface ISbContentMangmntAPI<
Content = ISbComponentType<string> & { [index: string]: any },
> {
story: {
name: string
slug: string
content?: Content
default_root?: boolean
is_folder?: boolean
parent_id?: string
disble_fe_editor?: boolean
path?: string
is_startpage?: boolean
position?: number
first_published_at?: string
translated_slugs_attributes?: {
path: string
name: string | null
lang: ISbContentMangmntAPI['lang']
}[]
}
force_update?: '1' | unknown
release_id?: number
publish?: '1' | unknown
lang?: string
}
export interface ISbManagmentApiResult {
data: any
headers: any
}
export interface ISbSchema {
nodes: any
marks: any
}
export interface ISbRichtext {
content?: ISbRichtext[]
marks?: ISbRichtext[]
attrs?: any
text?: string
type: string
}
export interface LinkCustomAttributes {
rel?: string
title?: string
[key: string]: any
}
export interface ISbLink {
id?: number
slug?: string
name?: string
is_folder?: boolean
parent_id?: number
published?: boolean
position?: number
uuid?: string
is_startpage?: boolean
}
export interface ISbLinks {
links?: {
[key: string]: ISbLink
}
}
export type ThrottleFn = {
(...args: any): any
}
export type AsyncFn = (...args: any) => [] | Promise<ISbResult>
export type ArrayFn = (...args: any) => void
export type HtmlEscapes = {
[key: string]: string
}
export interface ISbCustomFetch extends Omit<RequestInit, 'method'> {}