-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
308 lines (290 loc) · 6.66 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
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
// servers
enum ServerStatus {
Provisioning = "provisioning",
Provisioned = "provisioned",
Failed = "failed",
}
export interface ServerResponse {
id: number;
name: string;
provider_name: string;
ubuntu_version: string;
ip_address: string;
ssh_port: number;
timezone: string;
region: string;
size: string;
disk_space: {
total: number;
available: number;
used: number;
updated_at: string;
};
database: {
server: string;
host: string;
port: number;
};
ssh_publickey: string;
git_publickey: string;
connection_status: "connected" | "disconnected";
reboot_required: boolean;
upgrade_required: boolean;
install_notes: string | null;
created_at: string;
status: ServerStatus;
}
export interface Server {
serverId: number;
name: string;
providerName: string;
ubuntuVersion: string;
ipAddress: string;
sshPort: number;
timezone: string;
region: string;
size: string;
diskSpace: {
total: number;
available: number;
used: number;
updatedAt: string;
};
database: {
server: string;
host: string;
port: number;
};
sshPublicKey: string;
gitPublicKey: string;
connectionStatus: string;
rebootRequired: boolean;
upgradeRequired: boolean;
installNotes: string | null;
createdAt: string;
status: ServerStatus;
spinupUrl: string;
}
interface ServerReference {
serverId: number;
name: "Not found";
}
// sites
enum SiteStatus {
Deployed = "deployed",
Deploying = "deploying",
Failed = "failed",
}
export interface SiteResponse {
id: number;
server_id: number;
domain: string;
additional_domains: {
domain: string;
redirect: {
enabled: boolean;
};
created_at: string;
}[];
site_user: string;
user_auth: string;
php_version: string;
public_folder: string;
is_wordpress: boolean;
page_cache: {
enabled: boolean;
};
https: {
enabled: boolean;
certificate_path?: string;
private_key_path?: string;
certificate_expires?: string;
certificate_renews?: string;
};
nginx: {
uploads_directory_protected: boolean;
xmlrpc_protected: boolean;
subdirectory_rewrite_in_place: boolean;
};
database: {
id: number;
user_id: number;
table_prefix: string;
};
backups: {
files: boolean;
database: boolean;
paths_to_exclude: string;
is_backups_retention_period_enabled: boolean;
retention_period: number;
next_run_time: string | null;
storage_provider: {
id: number | null;
region: string | null;
bucket: string | null;
};
};
wp_core_update: boolean;
wp_theme_updates: number;
wp_plugin_updates: number;
git: {
enabled: boolean;
repo?: string;
branch?: string;
deploy_script?: string;
push_enabled?: boolean;
deployment_url?: string;
};
basic_auth: {
enabled: boolean;
username?: string;
};
created_at: string;
status: SiteStatus;
};
export interface Site {
siteId: number;
server: ServerReference;
domain: string;
additionalDomains: {
domain: string;
redirect: {
enabled: boolean;
};
createdAt: string;
}[];
siteUser: string;
userAuth: string;
phpVersion: string;
publicFolder: string;
isWordpress: boolean;
pageCacheEnabled: boolean;
https: {
name: "https"
enabled: boolean;
certificatePath?: string;
privateKeyPath?: string;
certificateExpires?: string;
certificateRenews?: string;
};
nginx: {
name: "nginx";
uploadsDirectoryProtected: boolean;
xmlrpcProtected: boolean;
subdirectoryRewriteInPlace: boolean;
};
database: {
databaseId: number;
userId: number;
tablePrefix: string;
};
backups: {
files: boolean;
database: boolean;
pathsToExclude: string;
isBackupsRetentionPeriodEnabled: boolean;
retentionPeriod: number;
nextRunTime: string | null;
storageProvider: {
id: number;
region: string;
bucket: string;
};
} | null;
wpCoreUpdate: boolean;
wpThemeUpdates: number;
wpPluginUpdates: number;
git: {
name: "Git";
enabled: boolean;
repo: string;
branch: string;
deployScript: string;
pushEnabled: boolean;
deploymentUrl: string;
};
basicAuth: {
name: "Basic Auth";
enabled: boolean;
username?: string;
};
createdAt: string;
status: SiteStatus;
spinupUrl: string;
siteUrl: string;
siteAdminUrl: string | null;
}
interface SiteReference {
siteId: number;
domain: "Not found";
}
enum EventStatus {
Queued = "queued",
Creating = "creating",
Updating = "updating",
Deleting = "deleting",
Deployed = "deployed",
Failed = "failed"
}
// events
export interface EventResponse {
id: number;
initiated_by: string;
server_id?: number;
site_id?: number;
name: string;
status: EventStatus;
output: string | null;
created_at: string;
started_at: string;
finished_at: string;
}
export interface Event {
eventId: number;
initiatedBy: string;
server: ServerReference;
site: SiteReference;
name: string;
status: EventStatus;
output: string | null;
createdAt: string;
startedAt: string;
finishedAt: string;
}
// Generic api response types
// Error response
enum ErrorCode {
BadRequest = 400,
Unauthorized = 401,
PaymentRequired = 402,
Forbidden = 403,
NotFound = 404,
MethodNotAllowed = 405,
ValidationError = 422,
TooManyAttempts = 429,
InternalServerError = 500,
ServiceUnavailable = 503
}
const errorCodeMeaning: { [key in ErrorCode]: string } = {
[ErrorCode.BadRequest]: 'Bad Request — Your request is invalid.',
[ErrorCode.Unauthorized]: 'Unauthorized — Your API token is wrong or no longer valid.',
[ErrorCode.PaymentRequired]: 'Payment Required — The team does not have a valid subscription.',
[ErrorCode.Forbidden]: 'Forbidden — You do not have permission to access the endpoint.',
[ErrorCode.NotFound]: 'Not Found — The specified resource could not be found.',
[ErrorCode.MethodNotAllowed]: 'Method Not Allowed — You tried to access an endpoint with an invalid method.',
[ErrorCode.ValidationError]: 'Validation Error — Invalid or missing parameters.',
[ErrorCode.TooManyAttempts]: 'Too Many Attempts — You\'ve hit the rate limit on API requests.',
[ErrorCode.InternalServerError]: 'Internal Server Error — We had a problem with our server. Try again later.',
[ErrorCode.ServiceUnavailable]: 'Service Unavailable — We\'re temporarily offline for maintenance. Please try again later.'
};
export interface ApiResponse {
body: {
data: ServerResponse[] | SiteResponse[] | EventResponse[] | undefined
pagination: {
previous: string | null;
next: string | null;
per_page: number;
count: number;
};
};
}