-
Notifications
You must be signed in to change notification settings - Fork 31
/
utils.ts
117 lines (98 loc) · 2.16 KB
/
utils.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
import { ContentTypeFieldValidation } from './entities'
type Sys = {
id: string
type: string
[key: string]: any
}
type Entity = {
sys: Sys
[key: string]: any
}
type Optional<Type, Keys extends keyof Type> = Partial<Type> & Omit<Type, Keys>
export type WithSysWithAtLeastId = { sys: { id: string; [key: string]: any } }
export type WithId<Type extends Entity> = Omit<Type, 'sys'> & WithSysWithAtLeastId
export type WithOptionalId<Type extends Entity> = Optional<Type, 'sys'> | WithId<Type>
export interface Link<LinkType = string, Type = string> {
sys: {
id: string
type: Type
linkType: LinkType
}
}
export interface CollectionResponse<T> {
items: T[]
total: number
skip: number
limit: number
sys: { type: string }
}
export interface CursorBasedCollectionResponse<T> {
items: T[]
limit: number
pages: {
next?: string
prev?: string
}
sys: { type: string }
}
export type ContentEntityType = 'Entry' | 'Asset'
export type ContentEntitySys = {
space: Link
id: string
type: ContentEntityType
createdAt: string
updatedAt: string
environment: Link
publishedVersion?: number
deletedVersion?: number
archivedVersion?: number
publishedAt?: string
firstPublishedAt?: string
createdBy?: Link
updatedBy?: Link
publishedCounter?: number
version: number
publishedBy?: Link
contentType: Link
}
export interface EntrySys extends ContentEntitySys {
type: 'Entry'
automationTags: Link<'Tag'>[]
}
export type FieldType =
| 'Symbol'
| 'Text'
| 'RichText'
| 'Number'
| 'Integer'
| 'Array'
| 'Link'
| 'Object'
| 'Date'
| 'Location'
| 'Boolean'
export type FieldLinkType = 'Entry' | 'Asset'
interface ItemsBase {
validations?: ContentTypeFieldValidation[]
}
interface LinkItems extends ItemsBase {
type: 'Link'
linkType: FieldLinkType
}
interface SymbolItems extends ItemsBase {
type: 'Symbol'
}
export type Items = SymbolItems | LinkItems
export interface SearchQuery {
order?: string
skip?: number
limit?: number
[key: string]: any
}
export type SerializedJSONValue =
| null
| string
| number
| boolean
| Array<SerializedJSONValue>
| { [key: string]: SerializedJSONValue }