forked from papyrcms/papyrcms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
198 lines (182 loc) · 3.53 KB
/
types.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
export interface Page {
_id: string
className: string
created: string
css: string
navOrder: number
omitDefaultHeader: boolean
omitDefaultFooter: boolean
route: string
sections: string[]
title: string
}
export interface Post {
_id: string
title: string
tags: string[]
slug: string
subImages: string[]
mainMedia?: string
content?: string
created: string
published: boolean
comments?: Comment[]
}
export interface Comment {
_id: string
content: string
created: string
replies: string[]
author: User
}
export interface User {
_id: string
email: string
password: string
firstName: string
lastName: string
isAdmin: boolean
isSubscribed: boolean
isBanned: boolean
created: string
address1?: string
address2?: string
city?: string
state?: string
country?: string
zip?: string
shippingFirstName?: String
shippingLastName?: String
shippingEmail?: String
shippingAddress1?: string
shippingAddress2?: string
shippingCity?: string
shippingState?: string
shippingCountry?: string
shippingZip?: string
cart: Product[]
}
export interface Product extends Post {
price: number
quantity: number
}
export interface Order {
_id: string
created: string
products: Product[]
user?: User
notes: string
shipped: boolean
}
export interface Blog extends Post {
publishDate?: string
comments: Comment[]
}
export interface Event extends Post {
date: string
latitude: number
longitude: number
}
export interface Message {
_id: string
name: string
email: string
message: string
emailSent: boolean
created: string
}
export interface Settings {
enableMenu: boolean
enableStore: boolean
storeMenuLocation: number
enableBlog: boolean
blogMenuLocation: number
enableEvents: boolean
eventsMenuLocation: number
enableCommenting: boolean
enableRegistration: boolean
enableEmailingToAdmin: boolean
enableEmailingToUsers: boolean
}
export interface SectionOptions {
[key: string]: {
component: string
name: string
description: string
inputs: string[]
maxPosts?: number
defaultProps: any
}
}
export interface Keys {
stripePublishableKey: string
stripeSecretKey?: string
gmailClientId?: string
gmailClientSecret?: string
gmailRefreshToken?: string
googleAnalyticsId: string
googleMapsKey: string
siteEmail?: string
adminEmail?: string
cloudinaryApiKey?: string
cloudinaryApiSecret?: string
cloudinaryCloudName?: string
tinyMceKey?: string
databaseDriver?: string
databaseURI?: string
rootURL?: string
jwtSecret?: string
test?: {
oldPass?: string
newPass?: string
token?: string
tokenRpc?: string
}
}
export interface Models {
Blog: Blog
Event: Event
Message: Message
Comment: Comment
Order: Order
Page: Page
Post: Post
Product: Product
Settings: {
_id: string
name: string
options: any
}
User: User
}
type Fields = {
[key: string]: any
}
type Conditions = {
[key: string]: any
}
type Options = {
sort?: { [key: string]: number }
include?: string[]
}
export interface Database extends Models {
findOne: <M>(
model: M,
conditions: Conditions,
options?: Options
) => M
findAll: <M>(
model: M,
conditions?: Conditions,
options?: Options
) => M[]
update: <M>(
model: M,
conditions: Conditions,
fields: Fields
) => void
create: <M>(model: M, fields: Fields) => M
destroy: <M>(model: M, conditions: Conditions) => void
destroyAll: <M>(model: M, conditions?: Conditions) => void
countAll: <M>(model: M) => number
}