@pelican.ts/sdk 0.3.4-next.4 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +3 -0
- package/README.md +1 -5
- package/biome.json +36 -0
- package/bun.lock +24 -1
- package/dist/api/index.d.mts +1641 -0
- package/dist/api/index.d.ts +1641 -0
- package/dist/api/index.js +2100 -0
- package/dist/api/index.mjs +2062 -0
- package/dist/index.d.mts +607 -1415
- package/dist/index.d.ts +607 -1415
- package/dist/index.js +569 -444
- package/dist/index.mjs +559 -442
- package/dist/types.d.ts +10 -10
- package/package.json +60 -49
- package/src/api/client/types/server.ts +64 -51
- package/src/api/client/types/user.ts +18 -19
- package/src/api/client/types/websocket.ts +76 -76
- package/src/api/index.ts +17 -0
- package/src/humane/Account.ts +73 -0
- package/src/humane/Client.ts +44 -0
- package/src/humane/Server.ts +206 -0
- package/src/humane/ServerAllocation.ts +41 -0
- package/src/humane/ServerBackup.ts +37 -0
- package/src/humane/ServerDatabase.ts +37 -0
- package/src/humane/ServerFile.ts +88 -0
- package/src/humane/ServerSchedule.ts +160 -0
- package/src/humane/ServerUser.ts +44 -0
- package/src/index.ts +18 -14
- package/src/utils/sized.ts +3 -6
|
@@ -0,0 +1,2100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/api/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
PelicanAPIApplication: () => PelicanAPIApplication,
|
|
34
|
+
PelicanAPIClient: () => PelicanAPIClient
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
|
+
|
|
38
|
+
// src/api/client/account.ts
|
|
39
|
+
var import_zod = __toESM(require("zod"));
|
|
40
|
+
var Account = class {
|
|
41
|
+
r;
|
|
42
|
+
constructor(requester) {
|
|
43
|
+
this.r = requester;
|
|
44
|
+
}
|
|
45
|
+
info = async () => {
|
|
46
|
+
const { data } = await this.r.get("/account");
|
|
47
|
+
return data.attributes;
|
|
48
|
+
};
|
|
49
|
+
updateEmail = async (newEmail, password) => {
|
|
50
|
+
newEmail = import_zod.default.email().parse(newEmail);
|
|
51
|
+
await this.r.put("/account/email", { email: newEmail, password });
|
|
52
|
+
};
|
|
53
|
+
updatePassword = async (newPassword) => {
|
|
54
|
+
newPassword = import_zod.default.string().min(8).parse(newPassword);
|
|
55
|
+
await this.r.put("/account/password", {
|
|
56
|
+
password: newPassword,
|
|
57
|
+
password_confirmation: newPassword
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
apiKeys = {
|
|
61
|
+
list: async () => {
|
|
62
|
+
const { data } = await this.r.get("/account/api-keys");
|
|
63
|
+
return data.data.map((k) => k.attributes);
|
|
64
|
+
},
|
|
65
|
+
create: async (description, allowed_ips) => {
|
|
66
|
+
allowed_ips = import_zod.default.array(import_zod.default.ipv4()).optional().parse(allowed_ips);
|
|
67
|
+
const { data } = await this.r.post("/account/api-keys", { description, allowed_ips });
|
|
68
|
+
return { ...data.attributes, secret_token: data.meta.secret_token };
|
|
69
|
+
},
|
|
70
|
+
delete: async (identifier) => {
|
|
71
|
+
await this.r.delete(`/account/api-keys/${identifier}`);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
sshKeys = {
|
|
75
|
+
list: async () => {
|
|
76
|
+
const { data } = await this.r.get("/account/ssh-keys");
|
|
77
|
+
return data.data.map((k) => k.attributes);
|
|
78
|
+
},
|
|
79
|
+
create: async (name, public_key) => {
|
|
80
|
+
const { data } = await this.r.post("/account/ssh-keys", { name, public_key });
|
|
81
|
+
return data.attributes;
|
|
82
|
+
},
|
|
83
|
+
delete: async (fingerprint) => {
|
|
84
|
+
await this.r.post(`/account/ssh-keys/remove`, { fingerprint });
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
twoFactor = {
|
|
88
|
+
info: async () => {
|
|
89
|
+
const { data } = await this.r.get("/account/two-factor");
|
|
90
|
+
return data;
|
|
91
|
+
},
|
|
92
|
+
enable: async (code) => {
|
|
93
|
+
const { data } = await this.r.post("/account/two-factor", { code });
|
|
94
|
+
return data;
|
|
95
|
+
},
|
|
96
|
+
disable: async (password) => {
|
|
97
|
+
await this.r.delete("/account/two-factor", { data: { password } });
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/api/client/client.ts
|
|
103
|
+
var import_zod5 = __toESM(require("zod"));
|
|
104
|
+
|
|
105
|
+
// src/api/client/server_databases.ts
|
|
106
|
+
var import_zod2 = __toESM(require("zod"));
|
|
107
|
+
var ServerDatabases = class {
|
|
108
|
+
r;
|
|
109
|
+
id;
|
|
110
|
+
constructor(requester, id) {
|
|
111
|
+
this.r = requester;
|
|
112
|
+
this.id = id;
|
|
113
|
+
}
|
|
114
|
+
list = async (include, page = 1) => {
|
|
115
|
+
import_zod2.default.number().positive().parse(page);
|
|
116
|
+
const { data } = await this.r.get(`/servers/${this.id}/databases`, {
|
|
117
|
+
params: { include: include?.join(","), page }
|
|
118
|
+
});
|
|
119
|
+
return data.data.map((d) => d.attributes);
|
|
120
|
+
};
|
|
121
|
+
create = async (database, remote) => {
|
|
122
|
+
const { data } = await this.r.post(`/servers/${this.id}/databases`, { database, remote });
|
|
123
|
+
return data.attributes;
|
|
124
|
+
};
|
|
125
|
+
rotatePassword = async (database_id) => {
|
|
126
|
+
const { data } = await this.r.post(`/servers/${this.id}/databases/${database_id}/rotate-password`);
|
|
127
|
+
return data.attributes;
|
|
128
|
+
};
|
|
129
|
+
delete = async (database_id) => {
|
|
130
|
+
await this.r.delete(`/servers/${this.id}/databases/${database_id}`);
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/api/client/server_files.ts
|
|
135
|
+
var import_axios = __toESM(require("axios"));
|
|
136
|
+
var ServerFiles = class {
|
|
137
|
+
r;
|
|
138
|
+
id;
|
|
139
|
+
constructor(requester, id) {
|
|
140
|
+
this.r = requester;
|
|
141
|
+
this.id = id;
|
|
142
|
+
}
|
|
143
|
+
list = async (path) => {
|
|
144
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
|
|
145
|
+
params: { directory: path }
|
|
146
|
+
});
|
|
147
|
+
return data.data.map((r) => r.attributes);
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
151
|
+
*/
|
|
152
|
+
contents = async (path) => {
|
|
153
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/contents`, {
|
|
154
|
+
params: { file: path }
|
|
155
|
+
});
|
|
156
|
+
return data;
|
|
157
|
+
};
|
|
158
|
+
downloadGetUrl = async (path) => {
|
|
159
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
|
|
160
|
+
params: { file: path }
|
|
161
|
+
});
|
|
162
|
+
return data.attributes.url;
|
|
163
|
+
};
|
|
164
|
+
download = async (path) => {
|
|
165
|
+
const url = await this.downloadGetUrl(path);
|
|
166
|
+
const { data } = await import_axios.default.get(url, { responseType: "arraybuffer" });
|
|
167
|
+
return data;
|
|
168
|
+
};
|
|
169
|
+
rename = async (root = "/", files) => {
|
|
170
|
+
await this.r.put(`/servers/${this.id}/files/rename`, { root, files });
|
|
171
|
+
};
|
|
172
|
+
copy = async (location) => {
|
|
173
|
+
await this.r.post(`/servers/${this.id}/files/copy`, { location });
|
|
174
|
+
};
|
|
175
|
+
write = async (path, content) => {
|
|
176
|
+
await this.r.post(`/servers/${this.id}/files/write`, content, {
|
|
177
|
+
params: { file: path }
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
compress = async (root = "/", files, archive_name, extension) => {
|
|
181
|
+
await this.r.post(`/servers/${this.id}/files/compress`, { root, files, archive_name, extension });
|
|
182
|
+
};
|
|
183
|
+
decompress = async (root = "/", file) => {
|
|
184
|
+
await this.r.post(`/servers/${this.id}/files/decompress`, { root, file });
|
|
185
|
+
};
|
|
186
|
+
delete = async (root = "/", files) => {
|
|
187
|
+
await this.r.post(`/servers/${this.id}/files/delete`, { root, files });
|
|
188
|
+
};
|
|
189
|
+
createFolder = async (root = "/", name) => {
|
|
190
|
+
await this.r.post(`/servers/${this.id}/files/create-folder`, { root, name });
|
|
191
|
+
};
|
|
192
|
+
chmod = async (root = "/", files) => {
|
|
193
|
+
await this.r.post(`/servers/${this.id}/files/chmod`, { root, files });
|
|
194
|
+
};
|
|
195
|
+
pullFromRemote = async (url, directory, filename, use_header = false, foreground = false) => {
|
|
196
|
+
await this.r.post(`/servers/${this.id}/files/pull`, { url, directory, filename, use_header, foreground });
|
|
197
|
+
};
|
|
198
|
+
uploadGetUrl = async () => {
|
|
199
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/upload`);
|
|
200
|
+
return data.attributes.url;
|
|
201
|
+
};
|
|
202
|
+
upload = async (file, root = "/") => {
|
|
203
|
+
const url = await this.uploadGetUrl();
|
|
204
|
+
await import_axios.default.post(url, { files: file }, {
|
|
205
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
206
|
+
params: { directory: root }
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/api/client/server_schedules.ts
|
|
212
|
+
var ServerSchedules = class {
|
|
213
|
+
r;
|
|
214
|
+
id;
|
|
215
|
+
constructor(requester, id) {
|
|
216
|
+
this.r = requester;
|
|
217
|
+
this.id = id;
|
|
218
|
+
}
|
|
219
|
+
list = async () => {
|
|
220
|
+
const { data } = await this.r.get(`/servers/${this.id}/schedules`);
|
|
221
|
+
return data.data.map((d) => d.attributes);
|
|
222
|
+
};
|
|
223
|
+
create = async (params) => {
|
|
224
|
+
const { data } = await this.r.post(`/servers/${this.id}/schedules`, params);
|
|
225
|
+
return data.attributes;
|
|
226
|
+
};
|
|
227
|
+
control = (sched_id) => new ScheduleControl(this.r, this.id, sched_id);
|
|
228
|
+
};
|
|
229
|
+
var ScheduleControl = class {
|
|
230
|
+
r;
|
|
231
|
+
id;
|
|
232
|
+
sched_id;
|
|
233
|
+
constructor(requester, id, sched_id) {
|
|
234
|
+
this.r = requester;
|
|
235
|
+
this.id = id;
|
|
236
|
+
this.sched_id = sched_id;
|
|
237
|
+
}
|
|
238
|
+
info = async () => {
|
|
239
|
+
const { data } = await this.r.get(`/servers/${this.id}/schedules/${this.sched_id}`);
|
|
240
|
+
return data.attributes;
|
|
241
|
+
};
|
|
242
|
+
update = async (params) => {
|
|
243
|
+
const { data } = await this.r.post(`/servers/${this.id}/schedules/${this.sched_id}`, params);
|
|
244
|
+
return data.attributes;
|
|
245
|
+
};
|
|
246
|
+
delete = async () => {
|
|
247
|
+
await this.r.delete(`/servers/${this.id}/schedules/${this.sched_id}`);
|
|
248
|
+
};
|
|
249
|
+
execute = async () => {
|
|
250
|
+
await this.r.post(`/servers/${this.id}/schedules/${this.sched_id}/execute`);
|
|
251
|
+
};
|
|
252
|
+
tasks = {
|
|
253
|
+
create: async (opts) => {
|
|
254
|
+
const { data } = await this.r.post(`/servers/${this.id}/schedules/${this.sched_id}/tasks`, opts);
|
|
255
|
+
return data.attributes;
|
|
256
|
+
},
|
|
257
|
+
update: async (task_id, opts) => {
|
|
258
|
+
const { data } = await this.r.post(`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`, opts);
|
|
259
|
+
return data.attributes;
|
|
260
|
+
},
|
|
261
|
+
delete: async (task_id) => {
|
|
262
|
+
await this.r.delete(`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// src/api/client/server_allocations.ts
|
|
268
|
+
var ServerAllocations = class {
|
|
269
|
+
r;
|
|
270
|
+
id;
|
|
271
|
+
constructor(requester, id) {
|
|
272
|
+
this.r = requester;
|
|
273
|
+
this.id = id;
|
|
274
|
+
}
|
|
275
|
+
list = async () => {
|
|
276
|
+
const { data } = await this.r.get(`/servers/${this.id}/network/allocations`);
|
|
277
|
+
return data.data.map((r) => r.attributes);
|
|
278
|
+
};
|
|
279
|
+
autoAssign = async () => {
|
|
280
|
+
const { data } = await this.r.post(`/servers/${this.id}/network/allocations`);
|
|
281
|
+
return data.attributes;
|
|
282
|
+
};
|
|
283
|
+
setNotes = async (alloc_id, notes) => {
|
|
284
|
+
const { data } = await this.r.post(`/servers/${this.id}/network/allocations/${alloc_id}`, { notes });
|
|
285
|
+
return data.attributes;
|
|
286
|
+
};
|
|
287
|
+
setPrimary = async (alloc_id) => {
|
|
288
|
+
const { data } = await this.r.post(`/servers/${this.id}/network/allocations/${alloc_id}/primary`);
|
|
289
|
+
return data.attributes;
|
|
290
|
+
};
|
|
291
|
+
unassign = async (alloc_id) => {
|
|
292
|
+
await this.r.delete(`/servers/${this.id}/network/allocations/${alloc_id}`);
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
// src/api/client/server_users.ts
|
|
297
|
+
var ServerUsers = class {
|
|
298
|
+
r;
|
|
299
|
+
id;
|
|
300
|
+
constructor(requester, id) {
|
|
301
|
+
this.r = requester;
|
|
302
|
+
this.id = id;
|
|
303
|
+
}
|
|
304
|
+
list = async () => {
|
|
305
|
+
const { data } = await this.r.get(`/servers/${this.id}/users`);
|
|
306
|
+
return data.data.map((d) => d.attributes);
|
|
307
|
+
};
|
|
308
|
+
create = async (email, permissions) => {
|
|
309
|
+
const { data } = await this.r.post(`/servers/${this.id}/users`, { email, permissions });
|
|
310
|
+
return data.attributes;
|
|
311
|
+
};
|
|
312
|
+
info = async (user_uuid) => {
|
|
313
|
+
const { data } = await this.r.get(`/servers/${this.id}/users/${user_uuid}`);
|
|
314
|
+
return data.attributes;
|
|
315
|
+
};
|
|
316
|
+
update = async (user_uuid, permissions) => {
|
|
317
|
+
const { data } = await this.r.put(`/servers/${this.id}/users/${user_uuid}`, { permissions });
|
|
318
|
+
return data.attributes;
|
|
319
|
+
};
|
|
320
|
+
delete = async (user_uuid) => {
|
|
321
|
+
await this.r.delete(`/servers/${this.id}/users/${user_uuid}`);
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// src/api/client/server_backups.ts
|
|
326
|
+
var import_axios2 = __toESM(require("axios"));
|
|
327
|
+
var import_zod3 = __toESM(require("zod"));
|
|
328
|
+
var ServerBackups = class {
|
|
329
|
+
r;
|
|
330
|
+
id;
|
|
331
|
+
constructor(requester, id) {
|
|
332
|
+
this.r = requester;
|
|
333
|
+
this.id = id;
|
|
334
|
+
}
|
|
335
|
+
list = async (page = 1) => {
|
|
336
|
+
import_zod3.default.number().positive().parse(page);
|
|
337
|
+
const { data } = await this.r.get(`/servers/${this.id}/backups`, {
|
|
338
|
+
params: { page }
|
|
339
|
+
});
|
|
340
|
+
return data.data.map((d) => d.attributes);
|
|
341
|
+
};
|
|
342
|
+
create = async (args) => {
|
|
343
|
+
args.name = import_zod3.default.string().max(255).optional().parse(args.name);
|
|
344
|
+
const { data } = await this.r.post(`/servers/${this.id}/backups`, {
|
|
345
|
+
name: args.name,
|
|
346
|
+
is_locked: args.is_locked,
|
|
347
|
+
ignored_files: args.ignored_files.join("\n")
|
|
348
|
+
});
|
|
349
|
+
return data.attributes;
|
|
350
|
+
};
|
|
351
|
+
info = async (backup_uuid) => {
|
|
352
|
+
const { data } = await this.r.get(`/servers/${this.id}/backups/${backup_uuid}`);
|
|
353
|
+
return data.attributes;
|
|
354
|
+
};
|
|
355
|
+
downloadGetUrl = async (backup_uuid) => {
|
|
356
|
+
const { data } = await this.r.get(`/servers/${this.id}/backups/${backup_uuid}/download`);
|
|
357
|
+
return data.attributes.url;
|
|
358
|
+
};
|
|
359
|
+
download = async (backup_uuid) => {
|
|
360
|
+
const url = await this.downloadGetUrl(backup_uuid);
|
|
361
|
+
const { data } = await import_axios2.default.get(url, { responseType: "arraybuffer" });
|
|
362
|
+
return data;
|
|
363
|
+
};
|
|
364
|
+
delete = async (backup_uuid) => {
|
|
365
|
+
await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// src/api/client/server_startup.ts
|
|
370
|
+
var ServerStartup = class {
|
|
371
|
+
r;
|
|
372
|
+
id;
|
|
373
|
+
constructor(requester, id) {
|
|
374
|
+
this.r = requester;
|
|
375
|
+
this.id = id;
|
|
376
|
+
}
|
|
377
|
+
list = async () => {
|
|
378
|
+
const { data } = await this.r.get(`/servers/${this.id}/startup`);
|
|
379
|
+
return {
|
|
380
|
+
object: "list",
|
|
381
|
+
meta: data.meta,
|
|
382
|
+
data: data.data.map((d) => d.attributes)
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
set = async (key, value) => {
|
|
386
|
+
const { data } = await this.r.put(`/servers/${this.id}/startup/variable`, { key, value });
|
|
387
|
+
return data.attributes;
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
// src/api/client/server_settings.ts
|
|
392
|
+
var import_zod4 = __toESM(require("zod"));
|
|
393
|
+
var ServerSettings = class {
|
|
394
|
+
r;
|
|
395
|
+
id;
|
|
396
|
+
constructor(requester, id) {
|
|
397
|
+
this.r = requester;
|
|
398
|
+
this.id = id;
|
|
399
|
+
}
|
|
400
|
+
rename = async (name) => {
|
|
401
|
+
name = import_zod4.default.string().max(255).parse(name);
|
|
402
|
+
await this.r.post(`/servers/${this.id}/settings/rename`, { name });
|
|
403
|
+
};
|
|
404
|
+
updateDescription = async (description) => {
|
|
405
|
+
await this.r.post(`/servers/${this.id}/settings/description`, { description });
|
|
406
|
+
};
|
|
407
|
+
reinstall = async () => {
|
|
408
|
+
await this.r.post(`/servers/${this.id}/settings/reinstall`);
|
|
409
|
+
};
|
|
410
|
+
changeDockerImage = async (image) => {
|
|
411
|
+
await this.r.post(`/servers/${this.id}/settings/docker-image`, { image });
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
// src/api/client/server_websocket.ts
|
|
416
|
+
var import_events = require("events");
|
|
417
|
+
var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
|
|
418
|
+
var import_strip_color = __toESM(require("strip-color"));
|
|
419
|
+
var isBrowser = typeof window !== "undefined";
|
|
420
|
+
var RECONNECT_ERRORS = /* @__PURE__ */ new Set([
|
|
421
|
+
"jwt: exp claim is invalid",
|
|
422
|
+
"jwt: created too far in past (denylist)"
|
|
423
|
+
]);
|
|
424
|
+
var FALLBACK_LOG_MESSAGE = "No logs - is the server online?";
|
|
425
|
+
var ServerWebsocket = class {
|
|
426
|
+
r;
|
|
427
|
+
serverId;
|
|
428
|
+
socket;
|
|
429
|
+
currentToken;
|
|
430
|
+
bus = new import_events.EventEmitter();
|
|
431
|
+
debugLogging = false;
|
|
432
|
+
stripColors;
|
|
433
|
+
detachMessageListener;
|
|
434
|
+
constructor(requester, id, stripColors = false) {
|
|
435
|
+
this.r = requester;
|
|
436
|
+
this.serverId = id;
|
|
437
|
+
this.stripColors = stripColors;
|
|
438
|
+
}
|
|
439
|
+
on(event, listener) {
|
|
440
|
+
const handler = listener;
|
|
441
|
+
this.bus.on(event, handler);
|
|
442
|
+
return () => {
|
|
443
|
+
this.bus.removeListener(event, handler);
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
deregister(event, listener) {
|
|
447
|
+
const handler = listener;
|
|
448
|
+
this.bus.removeListener(event, handler);
|
|
449
|
+
}
|
|
450
|
+
emit(event, ...args) {
|
|
451
|
+
if (args.length === 0) {
|
|
452
|
+
this.bus.emit(event);
|
|
453
|
+
} else {
|
|
454
|
+
this.bus.emit(event, args[0]);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
async connect(resumable, debugLogging) {
|
|
458
|
+
this.debugLogging = debugLogging ?? false;
|
|
459
|
+
if (this.socket) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
const socketUrl = await this.refreshCredentials();
|
|
463
|
+
this.socket = isBrowser ? new import_isomorphic_ws.default(socketUrl) : new import_isomorphic_ws.default(socketUrl, void 0, { origin: new URL(socketUrl).origin });
|
|
464
|
+
await new Promise((resolve, reject) => {
|
|
465
|
+
const socket = this.socket;
|
|
466
|
+
if (!socket) {
|
|
467
|
+
reject(new Error("Failed to create socket connection"));
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
socket.onopen = async () => {
|
|
471
|
+
try {
|
|
472
|
+
await this.authenticate();
|
|
473
|
+
this.attachMessageListener();
|
|
474
|
+
socket.onopen = null;
|
|
475
|
+
socket.onerror = null;
|
|
476
|
+
resolve();
|
|
477
|
+
} catch (error) {
|
|
478
|
+
socket.onopen = null;
|
|
479
|
+
socket.onerror = null;
|
|
480
|
+
reject(error instanceof Error ? error : new Error("Websocket authentication failed"));
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
socket.onerror = (event) => {
|
|
484
|
+
socket.onopen = null;
|
|
485
|
+
socket.onerror = null;
|
|
486
|
+
reject(event instanceof Error ? event : new Error("Websocket connection error"));
|
|
487
|
+
};
|
|
488
|
+
});
|
|
489
|
+
if (resumable) {
|
|
490
|
+
this.makeResumable(true);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
onSocketDisconnect(handler) {
|
|
494
|
+
if (!this.socket) {
|
|
495
|
+
console.error(new Error("No socket connection"));
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
this.socket.onclose = handler;
|
|
499
|
+
}
|
|
500
|
+
onSocketError(handler) {
|
|
501
|
+
if (!this.socket) {
|
|
502
|
+
console.error(new Error("No socket connection"));
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
this.socket.onerror = handler;
|
|
506
|
+
}
|
|
507
|
+
makeResumable(disconnectsToo) {
|
|
508
|
+
const scheduleReconnect = () => {
|
|
509
|
+
setTimeout(() => {
|
|
510
|
+
const previous = this.socket;
|
|
511
|
+
this.detachMessageListener?.();
|
|
512
|
+
this.detachMessageListener = void 0;
|
|
513
|
+
this.socket = void 0;
|
|
514
|
+
previous?.close();
|
|
515
|
+
void this.connect(true, this.debugLogging);
|
|
516
|
+
}, 1e3);
|
|
517
|
+
};
|
|
518
|
+
this.onSocketError(() => scheduleReconnect());
|
|
519
|
+
if (disconnectsToo) {
|
|
520
|
+
this.onSocketDisconnect(() => scheduleReconnect());
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
attachMessageListener() {
|
|
524
|
+
if (!this.socket) {
|
|
525
|
+
throw new Error("No socket connection");
|
|
526
|
+
}
|
|
527
|
+
this.detachMessageListener?.();
|
|
528
|
+
const handler = (event) => {
|
|
529
|
+
void this.handleIncomingMessage(event);
|
|
530
|
+
};
|
|
531
|
+
if (typeof this.socket.addEventListener === "function") {
|
|
532
|
+
this.socket.addEventListener("message", handler);
|
|
533
|
+
this.detachMessageListener = () => {
|
|
534
|
+
this.socket?.removeEventListener?.("message", handler);
|
|
535
|
+
};
|
|
536
|
+
} else {
|
|
537
|
+
const fallback = (data) => handler({ data });
|
|
538
|
+
const socket = this.socket;
|
|
539
|
+
socket.on?.("message", fallback);
|
|
540
|
+
this.detachMessageListener = () => {
|
|
541
|
+
const target = this.socket;
|
|
542
|
+
if (!target) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
if (typeof target.off === "function") {
|
|
546
|
+
target.off("message", fallback);
|
|
547
|
+
} else if (typeof target.removeListener === "function") {
|
|
548
|
+
target.removeListener("message", fallback);
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
async handleIncomingMessage(event) {
|
|
554
|
+
const message = this.parseMessage(event);
|
|
555
|
+
if (!message) {
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
try {
|
|
559
|
+
await this.dispatchMessage(message);
|
|
560
|
+
} catch (error) {
|
|
561
|
+
if (this.debugLogging) {
|
|
562
|
+
console.error("Error while handling websocket message", error);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
parseMessage(event) {
|
|
567
|
+
const payload = this.normalisePayload(event);
|
|
568
|
+
if (!payload) {
|
|
569
|
+
return null;
|
|
570
|
+
}
|
|
571
|
+
try {
|
|
572
|
+
return JSON.parse(payload);
|
|
573
|
+
} catch (error) {
|
|
574
|
+
if (this.debugLogging) {
|
|
575
|
+
console.warn("Failed to parse websocket payload", error);
|
|
576
|
+
}
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
normalisePayload(event) {
|
|
581
|
+
if (typeof event === "string") {
|
|
582
|
+
return event;
|
|
583
|
+
}
|
|
584
|
+
if (typeof event === "object" && event !== null && "data" in event) {
|
|
585
|
+
return this.normalisePayload(event.data);
|
|
586
|
+
}
|
|
587
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(event)) {
|
|
588
|
+
return event.toString("utf8");
|
|
589
|
+
}
|
|
590
|
+
if (typeof ArrayBuffer !== "undefined" && event instanceof ArrayBuffer) {
|
|
591
|
+
if (typeof TextDecoder !== "undefined") {
|
|
592
|
+
return new TextDecoder().decode(new Uint8Array(event));
|
|
593
|
+
}
|
|
594
|
+
if (typeof Buffer !== "undefined") {
|
|
595
|
+
return Buffer.from(event).toString("utf8");
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return null;
|
|
599
|
+
}
|
|
600
|
+
async dispatchMessage(message) {
|
|
601
|
+
switch (message.event) {
|
|
602
|
+
case "auth success" /* AUTH_SUCCESS */: {
|
|
603
|
+
if (this.debugLogging) {
|
|
604
|
+
console.debug("Auth success");
|
|
605
|
+
}
|
|
606
|
+
this.emit("auth success" /* AUTH_SUCCESS */);
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
case "status" /* STATUS */: {
|
|
610
|
+
if (this.debugLogging) {
|
|
611
|
+
console.debug("Received status event", message.args[0]);
|
|
612
|
+
}
|
|
613
|
+
this.emit("status" /* STATUS */, message.args[0]);
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
case "console output" /* CONSOLE_OUTPUT */: {
|
|
617
|
+
let output = message.args[0];
|
|
618
|
+
if (this.stripColors) {
|
|
619
|
+
output = (0, import_strip_color.default)(output);
|
|
620
|
+
}
|
|
621
|
+
if (this.debugLogging) {
|
|
622
|
+
console.debug("Received console output", output);
|
|
623
|
+
}
|
|
624
|
+
this.emit("console output" /* CONSOLE_OUTPUT */, output);
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
case "stats" /* STATS */: {
|
|
628
|
+
try {
|
|
629
|
+
const payload = JSON.parse(message.args[0]);
|
|
630
|
+
this.emit("stats" /* STATS */, payload);
|
|
631
|
+
} catch (error) {
|
|
632
|
+
if (this.debugLogging) {
|
|
633
|
+
console.warn("Failed to parse stats payload", error);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
case "daemon error" /* DAEMON_ERROR */: {
|
|
639
|
+
this.emit("daemon error" /* DAEMON_ERROR */);
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
case "backup completed" /* BACKUP_COMPLETED */: {
|
|
643
|
+
try {
|
|
644
|
+
const payload = JSON.parse(message.args[0]);
|
|
645
|
+
this.emit("backup completed" /* BACKUP_COMPLETED */, payload);
|
|
646
|
+
} catch (error) {
|
|
647
|
+
if (this.debugLogging) {
|
|
648
|
+
console.warn("Failed to parse backup payload", error);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
break;
|
|
652
|
+
}
|
|
653
|
+
case "daemon message" /* DAEMON_MESSAGE */: {
|
|
654
|
+
let output = message.args[0];
|
|
655
|
+
if (this.stripColors) {
|
|
656
|
+
output = (0, import_strip_color.default)(output);
|
|
657
|
+
}
|
|
658
|
+
this.emit("daemon message" /* DAEMON_MESSAGE */, output);
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
case "install output" /* INSTALL_OUTPUT */: {
|
|
662
|
+
let output = message.args[0];
|
|
663
|
+
if (this.stripColors) {
|
|
664
|
+
output = (0, import_strip_color.default)(output);
|
|
665
|
+
}
|
|
666
|
+
this.emit("install output" /* INSTALL_OUTPUT */, output);
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
case "backup restore completed" /* BACKUP_RESTORE_COMPLETED */: {
|
|
670
|
+
this.emit("backup restore completed" /* BACKUP_RESTORE_COMPLETED */);
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
case "install completed" /* INSTALL_COMPLETED */: {
|
|
674
|
+
this.emit("install completed" /* INSTALL_COMPLETED */);
|
|
675
|
+
break;
|
|
676
|
+
}
|
|
677
|
+
case "install started" /* INSTALL_STARTED */: {
|
|
678
|
+
this.emit("install started" /* INSTALL_STARTED */);
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
case "transfer logs" /* TRANSFER_LOGS */: {
|
|
682
|
+
this.emit("transfer logs" /* TRANSFER_LOGS */, message.args[0]);
|
|
683
|
+
break;
|
|
684
|
+
}
|
|
685
|
+
case "transfer status" /* TRANSFER_STATUS */: {
|
|
686
|
+
this.emit("transfer status" /* TRANSFER_STATUS */, message.args[0]);
|
|
687
|
+
break;
|
|
688
|
+
}
|
|
689
|
+
case "token expiring" /* TOKEN_EXPIRING */: {
|
|
690
|
+
this.emit("token expiring" /* TOKEN_EXPIRING */);
|
|
691
|
+
if (this.debugLogging) {
|
|
692
|
+
console.warn("Token expiring, renewing...");
|
|
693
|
+
}
|
|
694
|
+
await this.refreshCredentials();
|
|
695
|
+
await this.authenticate();
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
case "token expired" /* TOKEN_EXPIRED */: {
|
|
699
|
+
this.emit("token expired" /* TOKEN_EXPIRED */);
|
|
700
|
+
throw new Error("Token expired");
|
|
701
|
+
}
|
|
702
|
+
case "jwt error" /* JWT_ERROR */: {
|
|
703
|
+
const reason = message.args[0];
|
|
704
|
+
if (RECONNECT_ERRORS.has(reason)) {
|
|
705
|
+
this.emit("token expiring" /* TOKEN_EXPIRING */);
|
|
706
|
+
if (this.debugLogging) {
|
|
707
|
+
console.warn("Token expiring (JWT error), renewing...");
|
|
708
|
+
}
|
|
709
|
+
await this.refreshCredentials();
|
|
710
|
+
await this.authenticate();
|
|
711
|
+
} else {
|
|
712
|
+
this.emit("jwt error" /* JWT_ERROR */, reason);
|
|
713
|
+
throw new Error("Token expired");
|
|
714
|
+
}
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
default: {
|
|
718
|
+
if (this.debugLogging) {
|
|
719
|
+
console.warn("Unknown websocket event", message);
|
|
720
|
+
}
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
async refreshCredentials() {
|
|
726
|
+
const { data } = await this.r.get(`/servers/${this.serverId}/websocket`);
|
|
727
|
+
this.currentToken = data.data.token;
|
|
728
|
+
return data.data.socket;
|
|
729
|
+
}
|
|
730
|
+
async authenticate() {
|
|
731
|
+
if (!this.socket) {
|
|
732
|
+
throw new Error("No socket connection");
|
|
733
|
+
}
|
|
734
|
+
if (!this.currentToken) {
|
|
735
|
+
throw new Error("Missing websocket token");
|
|
736
|
+
}
|
|
737
|
+
this.socket.send(JSON.stringify({ event: "auth", args: [this.currentToken] }));
|
|
738
|
+
}
|
|
739
|
+
disconnect() {
|
|
740
|
+
this.detachMessageListener?.();
|
|
741
|
+
this.detachMessageListener = void 0;
|
|
742
|
+
if (this.socket) {
|
|
743
|
+
this.socket.close();
|
|
744
|
+
this.socket = void 0;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
requestStats() {
|
|
748
|
+
this.send("send stats", [null]);
|
|
749
|
+
}
|
|
750
|
+
requestLogs() {
|
|
751
|
+
this.send("send logs", [null]);
|
|
752
|
+
}
|
|
753
|
+
send(event, args) {
|
|
754
|
+
if (!this.socket) {
|
|
755
|
+
if (this.debugLogging) {
|
|
756
|
+
console.warn(`Attempted to send "${event}" without an active websocket connection`);
|
|
757
|
+
}
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
this.socket.send(JSON.stringify({ event, args }));
|
|
761
|
+
}
|
|
762
|
+
getStats() {
|
|
763
|
+
return new Promise((resolve, reject) => {
|
|
764
|
+
if (!this.socket) {
|
|
765
|
+
reject(new Error("No socket connection"));
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
let off;
|
|
769
|
+
const timeout = setTimeout(() => {
|
|
770
|
+
off?.();
|
|
771
|
+
reject(new Error("Timed out waiting for stats"));
|
|
772
|
+
}, 5e3);
|
|
773
|
+
off = this.on("stats" /* STATS */, (payload) => {
|
|
774
|
+
clearTimeout(timeout);
|
|
775
|
+
off?.();
|
|
776
|
+
resolve(payload);
|
|
777
|
+
});
|
|
778
|
+
this.requestStats();
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
getLogs() {
|
|
782
|
+
return new Promise((resolve, reject) => {
|
|
783
|
+
if (!this.socket) {
|
|
784
|
+
reject(new Error("No socket connection"));
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
const lines = [];
|
|
788
|
+
let off;
|
|
789
|
+
let initialTimeout;
|
|
790
|
+
let idleTimeout;
|
|
791
|
+
const finalize = (payload) => {
|
|
792
|
+
off?.();
|
|
793
|
+
if (initialTimeout) {
|
|
794
|
+
clearTimeout(initialTimeout);
|
|
795
|
+
}
|
|
796
|
+
if (idleTimeout) {
|
|
797
|
+
clearTimeout(idleTimeout);
|
|
798
|
+
}
|
|
799
|
+
resolve(payload);
|
|
800
|
+
};
|
|
801
|
+
initialTimeout = setTimeout(() => {
|
|
802
|
+
finalize(lines.length > 0 ? lines : [FALLBACK_LOG_MESSAGE]);
|
|
803
|
+
}, 5e3);
|
|
804
|
+
off = this.on("console output" /* CONSOLE_OUTPUT */, (line) => {
|
|
805
|
+
lines.push(line);
|
|
806
|
+
if (initialTimeout) {
|
|
807
|
+
clearTimeout(initialTimeout);
|
|
808
|
+
initialTimeout = void 0;
|
|
809
|
+
}
|
|
810
|
+
if (idleTimeout) {
|
|
811
|
+
clearTimeout(idleTimeout);
|
|
812
|
+
}
|
|
813
|
+
idleTimeout = setTimeout(() => {
|
|
814
|
+
finalize(lines);
|
|
815
|
+
}, 1e3);
|
|
816
|
+
});
|
|
817
|
+
this.requestLogs();
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
sendPoweraction(action) {
|
|
821
|
+
this.send("set state", [action]);
|
|
822
|
+
}
|
|
823
|
+
sendCommand(cmd) {
|
|
824
|
+
this.send("send command", [cmd]);
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
// src/api/client/server_activity.ts
|
|
829
|
+
var ServerActivity = class {
|
|
830
|
+
r;
|
|
831
|
+
id;
|
|
832
|
+
constructor(r, id) {
|
|
833
|
+
this.r = r;
|
|
834
|
+
this.id = id;
|
|
835
|
+
}
|
|
836
|
+
list = async (page = 1, per_page = 25) => {
|
|
837
|
+
const { data } = await this.r.get(`/server/${this.id}/activity`, {
|
|
838
|
+
params: {
|
|
839
|
+
page,
|
|
840
|
+
per_page
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
return data.data.map((log) => log.attributes);
|
|
844
|
+
};
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
// src/api/client/server.ts
|
|
848
|
+
var ServerClient = class {
|
|
849
|
+
r;
|
|
850
|
+
id;
|
|
851
|
+
activity;
|
|
852
|
+
databases;
|
|
853
|
+
files;
|
|
854
|
+
schedules;
|
|
855
|
+
allocations;
|
|
856
|
+
users;
|
|
857
|
+
backups;
|
|
858
|
+
startup;
|
|
859
|
+
variables;
|
|
860
|
+
settings;
|
|
861
|
+
constructor(requester, id) {
|
|
862
|
+
this.r = requester;
|
|
863
|
+
this.id = id;
|
|
864
|
+
this.activity = new ServerActivity(requester, id);
|
|
865
|
+
this.databases = new ServerDatabases(requester, id);
|
|
866
|
+
this.files = new ServerFiles(requester, id);
|
|
867
|
+
this.schedules = new ServerSchedules(requester, id);
|
|
868
|
+
this.allocations = new ServerAllocations(requester, id);
|
|
869
|
+
this.users = new ServerUsers(requester, id);
|
|
870
|
+
this.backups = new ServerBackups(requester, id);
|
|
871
|
+
this.startup = new ServerStartup(requester, id);
|
|
872
|
+
this.variables = this.startup;
|
|
873
|
+
this.settings = new ServerSettings(requester, id);
|
|
874
|
+
}
|
|
875
|
+
info = async (include) => {
|
|
876
|
+
const { data } = await this.r.get(`/servers/${this.id}`, {
|
|
877
|
+
params: { include: include?.join(",") }
|
|
878
|
+
});
|
|
879
|
+
return data.attributes;
|
|
880
|
+
};
|
|
881
|
+
websocket = (stripColors = false) => {
|
|
882
|
+
return new ServerWebsocket(this.r, this.id, stripColors);
|
|
883
|
+
};
|
|
884
|
+
resources = async () => {
|
|
885
|
+
const { data } = await this.r.get(`/servers/${this.id}/resources`);
|
|
886
|
+
return data.attributes;
|
|
887
|
+
};
|
|
888
|
+
command = async (command) => {
|
|
889
|
+
await this.r.post(`/servers/${this.id}/command`, { command });
|
|
890
|
+
};
|
|
891
|
+
power = async (signal) => {
|
|
892
|
+
await this.r.post(`/servers/${this.id}/power`, { signal });
|
|
893
|
+
};
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
// src/api/client/client.ts
|
|
897
|
+
var Client = class {
|
|
898
|
+
account;
|
|
899
|
+
r;
|
|
900
|
+
constructor(requester) {
|
|
901
|
+
this.r = requester;
|
|
902
|
+
this.account = new Account(requester);
|
|
903
|
+
}
|
|
904
|
+
get $r() {
|
|
905
|
+
return this.r;
|
|
906
|
+
}
|
|
907
|
+
listPermissions = async () => {
|
|
908
|
+
const { data } = await this.r.get("/permissions");
|
|
909
|
+
return data.attributes.permissions;
|
|
910
|
+
};
|
|
911
|
+
listServers = async (type = "accessible", page = 1, per_page = 50, include) => {
|
|
912
|
+
import_zod5.default.number().positive().parse(page);
|
|
913
|
+
const { data } = await this.r.get("/", {
|
|
914
|
+
params: { type, page, include: include?.join(",") }
|
|
915
|
+
});
|
|
916
|
+
return data.data.map((s) => s.attributes);
|
|
917
|
+
};
|
|
918
|
+
server = (uuid) => new ServerClient(this.r, uuid);
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
// src/api/application/users.ts
|
|
922
|
+
var import_zod7 = __toESM(require("zod"));
|
|
923
|
+
|
|
924
|
+
// src/utils/transform.ts
|
|
925
|
+
var ArrayQueryParams = (p) => {
|
|
926
|
+
const params = new URLSearchParams();
|
|
927
|
+
const o = {};
|
|
928
|
+
for (const [param, value] of Object.entries(p)) {
|
|
929
|
+
for (const [key, val] of Object.entries(value)) {
|
|
930
|
+
o[`${param}[${key}]`] = val;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
return o;
|
|
934
|
+
};
|
|
935
|
+
var SortParam = (key, p) => {
|
|
936
|
+
return `${p === "desc" ? "-" : ""}${key}`;
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
// src/api/common/types/enums.ts
|
|
940
|
+
var import_zod6 = __toESM(require("zod"));
|
|
941
|
+
var languagesSchema = import_zod6.default.enum([
|
|
942
|
+
"af",
|
|
943
|
+
"ak",
|
|
944
|
+
"am",
|
|
945
|
+
"ar",
|
|
946
|
+
"as",
|
|
947
|
+
"az",
|
|
948
|
+
"be",
|
|
949
|
+
"bg",
|
|
950
|
+
"bm",
|
|
951
|
+
"bn",
|
|
952
|
+
"bo",
|
|
953
|
+
"br",
|
|
954
|
+
"bs",
|
|
955
|
+
"ca",
|
|
956
|
+
"ce",
|
|
957
|
+
"cs",
|
|
958
|
+
"cv",
|
|
959
|
+
"cy",
|
|
960
|
+
"da",
|
|
961
|
+
"de",
|
|
962
|
+
"dz",
|
|
963
|
+
"ee",
|
|
964
|
+
"el",
|
|
965
|
+
"en",
|
|
966
|
+
"eo",
|
|
967
|
+
"es",
|
|
968
|
+
"et",
|
|
969
|
+
"eu",
|
|
970
|
+
"fa",
|
|
971
|
+
"ff",
|
|
972
|
+
"fi",
|
|
973
|
+
"fo",
|
|
974
|
+
"fr",
|
|
975
|
+
"fy",
|
|
976
|
+
"ga",
|
|
977
|
+
"gd",
|
|
978
|
+
"gl",
|
|
979
|
+
"gu",
|
|
980
|
+
"gv",
|
|
981
|
+
"ha",
|
|
982
|
+
"he",
|
|
983
|
+
"hi",
|
|
984
|
+
"hr",
|
|
985
|
+
"hu",
|
|
986
|
+
"hy",
|
|
987
|
+
"ia",
|
|
988
|
+
"id",
|
|
989
|
+
"ig",
|
|
990
|
+
"ii",
|
|
991
|
+
"is",
|
|
992
|
+
"it",
|
|
993
|
+
"ja",
|
|
994
|
+
"jv",
|
|
995
|
+
"ka",
|
|
996
|
+
"ki",
|
|
997
|
+
"kk",
|
|
998
|
+
"kl",
|
|
999
|
+
"km",
|
|
1000
|
+
"kn",
|
|
1001
|
+
"ko",
|
|
1002
|
+
"ks",
|
|
1003
|
+
"ku",
|
|
1004
|
+
"kw",
|
|
1005
|
+
"ky",
|
|
1006
|
+
"lb",
|
|
1007
|
+
"lg",
|
|
1008
|
+
"ln",
|
|
1009
|
+
"lo",
|
|
1010
|
+
"lt",
|
|
1011
|
+
"lu",
|
|
1012
|
+
"lv",
|
|
1013
|
+
"mg",
|
|
1014
|
+
"mi",
|
|
1015
|
+
"mk",
|
|
1016
|
+
"ml",
|
|
1017
|
+
"mn",
|
|
1018
|
+
"mr",
|
|
1019
|
+
"ms",
|
|
1020
|
+
"mt",
|
|
1021
|
+
"my",
|
|
1022
|
+
"nb",
|
|
1023
|
+
"nd",
|
|
1024
|
+
"ne",
|
|
1025
|
+
"nl",
|
|
1026
|
+
"nn",
|
|
1027
|
+
"no",
|
|
1028
|
+
"om",
|
|
1029
|
+
"or",
|
|
1030
|
+
"os",
|
|
1031
|
+
"pa",
|
|
1032
|
+
"pl",
|
|
1033
|
+
"ps",
|
|
1034
|
+
"pt",
|
|
1035
|
+
"qu",
|
|
1036
|
+
"rm",
|
|
1037
|
+
"rn",
|
|
1038
|
+
"ro",
|
|
1039
|
+
"ru",
|
|
1040
|
+
"rw",
|
|
1041
|
+
"sa",
|
|
1042
|
+
"sc",
|
|
1043
|
+
"sd",
|
|
1044
|
+
"se",
|
|
1045
|
+
"sg",
|
|
1046
|
+
"si",
|
|
1047
|
+
"sk",
|
|
1048
|
+
"sl",
|
|
1049
|
+
"sn",
|
|
1050
|
+
"so",
|
|
1051
|
+
"sq",
|
|
1052
|
+
"sr",
|
|
1053
|
+
"su",
|
|
1054
|
+
"sv",
|
|
1055
|
+
"sw",
|
|
1056
|
+
"ta",
|
|
1057
|
+
"te",
|
|
1058
|
+
"tg",
|
|
1059
|
+
"th",
|
|
1060
|
+
"ti",
|
|
1061
|
+
"tk",
|
|
1062
|
+
"to",
|
|
1063
|
+
"tr",
|
|
1064
|
+
"tt",
|
|
1065
|
+
"ug",
|
|
1066
|
+
"uk",
|
|
1067
|
+
"ur",
|
|
1068
|
+
"uz",
|
|
1069
|
+
"vi",
|
|
1070
|
+
"wo",
|
|
1071
|
+
"xh",
|
|
1072
|
+
"yi",
|
|
1073
|
+
"yo",
|
|
1074
|
+
"zh",
|
|
1075
|
+
"zu"
|
|
1076
|
+
]);
|
|
1077
|
+
var timezonesSchema = import_zod6.default.enum([
|
|
1078
|
+
"Africa/Abidjan",
|
|
1079
|
+
"Africa/Accra",
|
|
1080
|
+
"Africa/Addis_Ababa",
|
|
1081
|
+
"Africa/Algiers",
|
|
1082
|
+
"Africa/Asmara",
|
|
1083
|
+
"Africa/Bamako",
|
|
1084
|
+
"Africa/Bangui",
|
|
1085
|
+
"Africa/Banjul",
|
|
1086
|
+
"Africa/Bissau",
|
|
1087
|
+
"Africa/Blantyre",
|
|
1088
|
+
"Africa/Brazzaville",
|
|
1089
|
+
"Africa/Bujumbura",
|
|
1090
|
+
"Africa/Cairo",
|
|
1091
|
+
"Africa/Casablanca",
|
|
1092
|
+
"Africa/Ceuta",
|
|
1093
|
+
"Africa/Conakry",
|
|
1094
|
+
"Africa/Dakar",
|
|
1095
|
+
"Africa/Dar_es_Salaam",
|
|
1096
|
+
"Africa/Djibouti",
|
|
1097
|
+
"Africa/Douala",
|
|
1098
|
+
"Africa/El_Aaiun",
|
|
1099
|
+
"Africa/Freetown",
|
|
1100
|
+
"Africa/Gaborone",
|
|
1101
|
+
"Africa/Harare",
|
|
1102
|
+
"Africa/Johannesburg",
|
|
1103
|
+
"Africa/Juba",
|
|
1104
|
+
"Africa/Kampala",
|
|
1105
|
+
"Africa/Khartoum",
|
|
1106
|
+
"Africa/Kigali",
|
|
1107
|
+
"Africa/Kinshasa",
|
|
1108
|
+
"Africa/Lagos",
|
|
1109
|
+
"Africa/Libreville",
|
|
1110
|
+
"Africa/Lome",
|
|
1111
|
+
"Africa/Luanda",
|
|
1112
|
+
"Africa/Lubumbashi",
|
|
1113
|
+
"Africa/Lusaka",
|
|
1114
|
+
"Africa/Malabo",
|
|
1115
|
+
"Africa/Maputo",
|
|
1116
|
+
"Africa/Maseru",
|
|
1117
|
+
"Africa/Mbabane",
|
|
1118
|
+
"Africa/Mogadishu",
|
|
1119
|
+
"Africa/Monrovia",
|
|
1120
|
+
"Africa/Nairobi",
|
|
1121
|
+
"Africa/Ndjamena",
|
|
1122
|
+
"Africa/Niamey",
|
|
1123
|
+
"Africa/Nouakchott",
|
|
1124
|
+
"Africa/Ouagadougou",
|
|
1125
|
+
"Africa/Porto-Novo",
|
|
1126
|
+
"Africa/Sao_Tome",
|
|
1127
|
+
"Africa/Tripoli",
|
|
1128
|
+
"Africa/Tunis",
|
|
1129
|
+
"Africa/Windhoek",
|
|
1130
|
+
"America/Adak",
|
|
1131
|
+
"America/Anchorage",
|
|
1132
|
+
"America/Anguilla",
|
|
1133
|
+
"America/Antigua",
|
|
1134
|
+
"America/Araguaina",
|
|
1135
|
+
"America/Argentina/Buenos_Aires",
|
|
1136
|
+
"America/Argentina/Catamarca",
|
|
1137
|
+
"America/Argentina/Cordoba",
|
|
1138
|
+
"America/Argentina/Jujuy",
|
|
1139
|
+
"America/Argentina/La_Rioja",
|
|
1140
|
+
"America/Argentina/Mendoza",
|
|
1141
|
+
"America/Argentina/Rio_Gallegos",
|
|
1142
|
+
"America/Argentina/Salta",
|
|
1143
|
+
"America/Argentina/San_Juan",
|
|
1144
|
+
"America/Argentina/San_Luis",
|
|
1145
|
+
"America/Argentina/Tucuman",
|
|
1146
|
+
"America/Argentina/Ushuaia",
|
|
1147
|
+
"America/Aruba",
|
|
1148
|
+
"America/Asuncion",
|
|
1149
|
+
"America/Atikokan",
|
|
1150
|
+
"America/Bahia",
|
|
1151
|
+
"America/Bahia_Banderas",
|
|
1152
|
+
"America/Barbados",
|
|
1153
|
+
"America/Belem",
|
|
1154
|
+
"America/Belize",
|
|
1155
|
+
"America/Blanc-Sablon",
|
|
1156
|
+
"America/Boa_Vista",
|
|
1157
|
+
"America/Bogota",
|
|
1158
|
+
"America/Boise",
|
|
1159
|
+
"America/Cambridge_Bay",
|
|
1160
|
+
"America/Campo_Grande",
|
|
1161
|
+
"America/Cancun",
|
|
1162
|
+
"America/Caracas",
|
|
1163
|
+
"America/Cayenne",
|
|
1164
|
+
"America/Cayman",
|
|
1165
|
+
"America/Chicago",
|
|
1166
|
+
"America/Chihuahua",
|
|
1167
|
+
"America/Ciudad_Juarez",
|
|
1168
|
+
"America/Costa_Rica",
|
|
1169
|
+
"America/Coyhaique",
|
|
1170
|
+
"America/Creston",
|
|
1171
|
+
"America/Cuiaba",
|
|
1172
|
+
"America/Curacao",
|
|
1173
|
+
"America/Danmarkshavn",
|
|
1174
|
+
"America/Dawson",
|
|
1175
|
+
"America/Dawson_Creek",
|
|
1176
|
+
"America/Denver",
|
|
1177
|
+
"America/Detroit",
|
|
1178
|
+
"America/Dominica",
|
|
1179
|
+
"America/Edmonton",
|
|
1180
|
+
"America/Eirunepe",
|
|
1181
|
+
"America/El_Salvador",
|
|
1182
|
+
"America/Fort_Nelson",
|
|
1183
|
+
"America/Fortaleza",
|
|
1184
|
+
"America/Glace_Bay",
|
|
1185
|
+
"America/Goose_Bay",
|
|
1186
|
+
"America/Grand_Turk",
|
|
1187
|
+
"America/Grenada",
|
|
1188
|
+
"America/Guadeloupe",
|
|
1189
|
+
"America/Guatemala",
|
|
1190
|
+
"America/Guayaquil",
|
|
1191
|
+
"America/Guyana",
|
|
1192
|
+
"America/Halifax",
|
|
1193
|
+
"America/Havana",
|
|
1194
|
+
"America/Hermosillo",
|
|
1195
|
+
"America/Indiana/Indianapolis",
|
|
1196
|
+
"America/Indiana/Knox",
|
|
1197
|
+
"America/Indiana/Marengo",
|
|
1198
|
+
"America/Indiana/Petersburg",
|
|
1199
|
+
"America/Indiana/Tell_City",
|
|
1200
|
+
"America/Indiana/Vevay",
|
|
1201
|
+
"America/Indiana/Vincennes",
|
|
1202
|
+
"America/Indiana/Winamac",
|
|
1203
|
+
"America/Inuvik",
|
|
1204
|
+
"America/Iqaluit",
|
|
1205
|
+
"America/Jamaica",
|
|
1206
|
+
"America/Juneau",
|
|
1207
|
+
"America/Kentucky/Louisville",
|
|
1208
|
+
"America/Kentucky/Monticello",
|
|
1209
|
+
"America/Kralendijk",
|
|
1210
|
+
"America/La_Paz",
|
|
1211
|
+
"America/Lima",
|
|
1212
|
+
"America/Los_Angeles",
|
|
1213
|
+
"America/Lower_Princes",
|
|
1214
|
+
"America/Maceio",
|
|
1215
|
+
"America/Managua",
|
|
1216
|
+
"America/Manaus",
|
|
1217
|
+
"America/Marigot",
|
|
1218
|
+
"America/Martinique",
|
|
1219
|
+
"America/Matamoros",
|
|
1220
|
+
"America/Mazatlan",
|
|
1221
|
+
"America/Menominee",
|
|
1222
|
+
"America/Merida",
|
|
1223
|
+
"America/Metlakatla",
|
|
1224
|
+
"America/Mexico_City",
|
|
1225
|
+
"America/Miquelon",
|
|
1226
|
+
"America/Moncton",
|
|
1227
|
+
"America/Monterrey",
|
|
1228
|
+
"America/Montevideo",
|
|
1229
|
+
"America/Montserrat",
|
|
1230
|
+
"America/Nassau",
|
|
1231
|
+
"America/New_York",
|
|
1232
|
+
"America/Nome",
|
|
1233
|
+
"America/Noronha",
|
|
1234
|
+
"America/North_Dakota/Beulah",
|
|
1235
|
+
"America/North_Dakota/Center",
|
|
1236
|
+
"America/North_Dakota/New_Salem",
|
|
1237
|
+
"America/Nuuk",
|
|
1238
|
+
"America/Ojinaga",
|
|
1239
|
+
"America/Panama",
|
|
1240
|
+
"America/Paramaribo",
|
|
1241
|
+
"America/Phoenix",
|
|
1242
|
+
"America/Port-au-Prince",
|
|
1243
|
+
"America/Port_of_Spain",
|
|
1244
|
+
"America/Porto_Velho",
|
|
1245
|
+
"America/Puerto_Rico",
|
|
1246
|
+
"America/Punta_Arenas",
|
|
1247
|
+
"America/Rankin_Inlet",
|
|
1248
|
+
"America/Recife",
|
|
1249
|
+
"America/Regina",
|
|
1250
|
+
"America/Resolute",
|
|
1251
|
+
"America/Rio_Branco",
|
|
1252
|
+
"America/Santarem",
|
|
1253
|
+
"America/Santiago",
|
|
1254
|
+
"America/Santo_Domingo",
|
|
1255
|
+
"America/Sao_Paulo",
|
|
1256
|
+
"America/Scoresbysund",
|
|
1257
|
+
"America/Sitka",
|
|
1258
|
+
"America/St_Barthelemy",
|
|
1259
|
+
"America/St_Johns",
|
|
1260
|
+
"America/St_Kitts",
|
|
1261
|
+
"America/St_Lucia",
|
|
1262
|
+
"America/St_Thomas",
|
|
1263
|
+
"America/St_Vincent",
|
|
1264
|
+
"America/Swift_Current",
|
|
1265
|
+
"America/Tegucigalpa",
|
|
1266
|
+
"America/Thule",
|
|
1267
|
+
"America/Tijuana",
|
|
1268
|
+
"America/Toronto",
|
|
1269
|
+
"America/Tortola",
|
|
1270
|
+
"America/Vancouver",
|
|
1271
|
+
"America/Whitehorse",
|
|
1272
|
+
"America/Winnipeg",
|
|
1273
|
+
"America/Yakutat",
|
|
1274
|
+
"Antarctica/Casey",
|
|
1275
|
+
"Antarctica/Davis",
|
|
1276
|
+
"Antarctica/DumontDUrville",
|
|
1277
|
+
"Antarctica/Macquarie",
|
|
1278
|
+
"Antarctica/Mawson",
|
|
1279
|
+
"Antarctica/McMurdo",
|
|
1280
|
+
"Antarctica/Palmer",
|
|
1281
|
+
"Antarctica/Rothera",
|
|
1282
|
+
"Antarctica/Syowa",
|
|
1283
|
+
"Antarctica/Troll",
|
|
1284
|
+
"Antarctica/Vostok",
|
|
1285
|
+
"Arctic/Longyearbyen",
|
|
1286
|
+
"Asia/Aden",
|
|
1287
|
+
"Asia/Almaty",
|
|
1288
|
+
"Asia/Amman",
|
|
1289
|
+
"Asia/Anadyr",
|
|
1290
|
+
"Asia/Aqtau",
|
|
1291
|
+
"Asia/Aqtobe",
|
|
1292
|
+
"Asia/Ashgabat",
|
|
1293
|
+
"Asia/Atyrau",
|
|
1294
|
+
"Asia/Baghdad",
|
|
1295
|
+
"Asia/Bahrain",
|
|
1296
|
+
"Asia/Baku",
|
|
1297
|
+
"Asia/Bangkok",
|
|
1298
|
+
"Asia/Barnaul",
|
|
1299
|
+
"Asia/Beirut",
|
|
1300
|
+
"Asia/Bishkek",
|
|
1301
|
+
"Asia/Brunei",
|
|
1302
|
+
"Asia/Chita",
|
|
1303
|
+
"Asia/Colombo",
|
|
1304
|
+
"Asia/Damascus",
|
|
1305
|
+
"Asia/Dhaka",
|
|
1306
|
+
"Asia/Dili",
|
|
1307
|
+
"Asia/Dubai",
|
|
1308
|
+
"Asia/Dushanbe",
|
|
1309
|
+
"Asia/Famagusta",
|
|
1310
|
+
"Asia/Gaza",
|
|
1311
|
+
"Asia/Hebron",
|
|
1312
|
+
"Asia/Ho_Chi_Minh",
|
|
1313
|
+
"Asia/Hong_Kong",
|
|
1314
|
+
"Asia/Hovd",
|
|
1315
|
+
"Asia/Irkutsk",
|
|
1316
|
+
"Asia/Jakarta",
|
|
1317
|
+
"Asia/Jayapura",
|
|
1318
|
+
"Asia/Jerusalem",
|
|
1319
|
+
"Asia/Kabul",
|
|
1320
|
+
"Asia/Kamchatka",
|
|
1321
|
+
"Asia/Karachi",
|
|
1322
|
+
"Asia/Kathmandu",
|
|
1323
|
+
"Asia/Khandyga",
|
|
1324
|
+
"Asia/Kolkata",
|
|
1325
|
+
"Asia/Krasnoyarsk",
|
|
1326
|
+
"Asia/Kuala_Lumpur",
|
|
1327
|
+
"Asia/Kuching",
|
|
1328
|
+
"Asia/Kuwait",
|
|
1329
|
+
"Asia/Macau",
|
|
1330
|
+
"Asia/Magadan",
|
|
1331
|
+
"Asia/Makassar",
|
|
1332
|
+
"Asia/Manila",
|
|
1333
|
+
"Asia/Muscat",
|
|
1334
|
+
"Asia/Nicosia",
|
|
1335
|
+
"Asia/Novokuznetsk",
|
|
1336
|
+
"Asia/Novosibirsk",
|
|
1337
|
+
"Asia/Omsk",
|
|
1338
|
+
"Asia/Oral",
|
|
1339
|
+
"Asia/Phnom_Penh",
|
|
1340
|
+
"Asia/Pontianak",
|
|
1341
|
+
"Asia/Pyongyang",
|
|
1342
|
+
"Asia/Qatar",
|
|
1343
|
+
"Asia/Qostanay",
|
|
1344
|
+
"Asia/Qyzylorda",
|
|
1345
|
+
"Asia/Riyadh",
|
|
1346
|
+
"Asia/Sakhalin",
|
|
1347
|
+
"Asia/Samarkand",
|
|
1348
|
+
"Asia/Seoul",
|
|
1349
|
+
"Asia/Shanghai",
|
|
1350
|
+
"Asia/Singapore",
|
|
1351
|
+
"Asia/Srednekolymsk",
|
|
1352
|
+
"Asia/Taipei",
|
|
1353
|
+
"Asia/Tashkent",
|
|
1354
|
+
"Asia/Tbilisi",
|
|
1355
|
+
"Asia/Tehran",
|
|
1356
|
+
"Asia/Thimphu",
|
|
1357
|
+
"Asia/Tokyo",
|
|
1358
|
+
"Asia/Tomsk",
|
|
1359
|
+
"Asia/Ulaanbaatar",
|
|
1360
|
+
"Asia/Urumqi",
|
|
1361
|
+
"Asia/Ust-Nera",
|
|
1362
|
+
"Asia/Vientiane",
|
|
1363
|
+
"Asia/Vladivostok",
|
|
1364
|
+
"Asia/Yakutsk",
|
|
1365
|
+
"Asia/Yangon",
|
|
1366
|
+
"Asia/Yekaterinburg",
|
|
1367
|
+
"Asia/Yerevan",
|
|
1368
|
+
"Atlantic/Azores",
|
|
1369
|
+
"Atlantic/Bermuda",
|
|
1370
|
+
"Atlantic/Canary",
|
|
1371
|
+
"Atlantic/Cape_Verde",
|
|
1372
|
+
"Atlantic/Faroe",
|
|
1373
|
+
"Atlantic/Madeira",
|
|
1374
|
+
"Atlantic/Reykjavik",
|
|
1375
|
+
"Atlantic/South_Georgia",
|
|
1376
|
+
"Atlantic/St_Helena",
|
|
1377
|
+
"Atlantic/Stanley",
|
|
1378
|
+
"Australia/Adelaide",
|
|
1379
|
+
"Australia/Brisbane",
|
|
1380
|
+
"Australia/Broken_Hill",
|
|
1381
|
+
"Australia/Darwin",
|
|
1382
|
+
"Australia/Eucla",
|
|
1383
|
+
"Australia/Hobart",
|
|
1384
|
+
"Australia/Lindeman",
|
|
1385
|
+
"Australia/Lord_Howe",
|
|
1386
|
+
"Australia/Melbourne",
|
|
1387
|
+
"Australia/Perth",
|
|
1388
|
+
"Australia/Sydney",
|
|
1389
|
+
"Europe/Amsterdam",
|
|
1390
|
+
"Europe/Andorra",
|
|
1391
|
+
"Europe/Astrakhan",
|
|
1392
|
+
"Europe/Athens",
|
|
1393
|
+
"Europe/Belgrade",
|
|
1394
|
+
"Europe/Berlin",
|
|
1395
|
+
"Europe/Bratislava",
|
|
1396
|
+
"Europe/Brussels",
|
|
1397
|
+
"Europe/Bucharest",
|
|
1398
|
+
"Europe/Budapest",
|
|
1399
|
+
"Europe/Busingen",
|
|
1400
|
+
"Europe/Chisinau",
|
|
1401
|
+
"Europe/Copenhagen",
|
|
1402
|
+
"Europe/Dublin",
|
|
1403
|
+
"Europe/Gibraltar",
|
|
1404
|
+
"Europe/Guernsey",
|
|
1405
|
+
"Europe/Helsinki",
|
|
1406
|
+
"Europe/Isle_of_Man",
|
|
1407
|
+
"Europe/Istanbul",
|
|
1408
|
+
"Europe/Jersey",
|
|
1409
|
+
"Europe/Kaliningrad",
|
|
1410
|
+
"Europe/Kirov",
|
|
1411
|
+
"Europe/Kyiv",
|
|
1412
|
+
"Europe/Lisbon",
|
|
1413
|
+
"Europe/Ljubljana",
|
|
1414
|
+
"Europe/London",
|
|
1415
|
+
"Europe/Luxembourg",
|
|
1416
|
+
"Europe/Madrid",
|
|
1417
|
+
"Europe/Malta",
|
|
1418
|
+
"Europe/Mariehamn",
|
|
1419
|
+
"Europe/Minsk",
|
|
1420
|
+
"Europe/Monaco",
|
|
1421
|
+
"Europe/Moscow",
|
|
1422
|
+
"Europe/Oslo",
|
|
1423
|
+
"Europe/Paris",
|
|
1424
|
+
"Europe/Podgorica",
|
|
1425
|
+
"Europe/Prague",
|
|
1426
|
+
"Europe/Riga",
|
|
1427
|
+
"Europe/Rome",
|
|
1428
|
+
"Europe/Samara",
|
|
1429
|
+
"Europe/San_Marino",
|
|
1430
|
+
"Europe/Sarajevo",
|
|
1431
|
+
"Europe/Saratov",
|
|
1432
|
+
"Europe/Simferopol",
|
|
1433
|
+
"Europe/Skopje",
|
|
1434
|
+
"Europe/Sofia",
|
|
1435
|
+
"Europe/Stockholm",
|
|
1436
|
+
"Europe/Tallinn",
|
|
1437
|
+
"Europe/Tirane",
|
|
1438
|
+
"Europe/Ulyanovsk",
|
|
1439
|
+
"Europe/Vaduz",
|
|
1440
|
+
"Europe/Vatican",
|
|
1441
|
+
"Europe/Vienna",
|
|
1442
|
+
"Europe/Vilnius",
|
|
1443
|
+
"Europe/Volgograd",
|
|
1444
|
+
"Europe/Warsaw",
|
|
1445
|
+
"Europe/Zagreb",
|
|
1446
|
+
"Europe/Zurich",
|
|
1447
|
+
"Indian/Antananarivo",
|
|
1448
|
+
"Indian/Chagos",
|
|
1449
|
+
"Indian/Christmas",
|
|
1450
|
+
"Indian/Cocos",
|
|
1451
|
+
"Indian/Comoro",
|
|
1452
|
+
"Indian/Kerguelen",
|
|
1453
|
+
"Indian/Mahe",
|
|
1454
|
+
"Indian/Maldives",
|
|
1455
|
+
"Indian/Mauritius",
|
|
1456
|
+
"Indian/Mayotte",
|
|
1457
|
+
"Indian/Reunion",
|
|
1458
|
+
"Pacific/Apia",
|
|
1459
|
+
"Pacific/Auckland",
|
|
1460
|
+
"Pacific/Bougainville",
|
|
1461
|
+
"Pacific/Chatham",
|
|
1462
|
+
"Pacific/Chuuk",
|
|
1463
|
+
"Pacific/Easter",
|
|
1464
|
+
"Pacific/Efate",
|
|
1465
|
+
"Pacific/Fakaofo",
|
|
1466
|
+
"Pacific/Fiji",
|
|
1467
|
+
"Pacific/Funafuti",
|
|
1468
|
+
"Pacific/Galapagos",
|
|
1469
|
+
"Pacific/Gambier",
|
|
1470
|
+
"Pacific/Guadalcanal",
|
|
1471
|
+
"Pacific/Guam",
|
|
1472
|
+
"Pacific/Honolulu",
|
|
1473
|
+
"Pacific/Kanton",
|
|
1474
|
+
"Pacific/Kiritimati",
|
|
1475
|
+
"Pacific/Kosrae",
|
|
1476
|
+
"Pacific/Kwajalein",
|
|
1477
|
+
"Pacific/Majuro",
|
|
1478
|
+
"Pacific/Marquesas",
|
|
1479
|
+
"Pacific/Midway",
|
|
1480
|
+
"Pacific/Nauru",
|
|
1481
|
+
"Pacific/Niue",
|
|
1482
|
+
"Pacific/Norfolk",
|
|
1483
|
+
"Pacific/Noumea",
|
|
1484
|
+
"Pacific/Pago_Pago",
|
|
1485
|
+
"Pacific/Palau",
|
|
1486
|
+
"Pacific/Pitcairn",
|
|
1487
|
+
"Pacific/Pohnpei",
|
|
1488
|
+
"Pacific/Port_Moresby",
|
|
1489
|
+
"Pacific/Rarotonga",
|
|
1490
|
+
"Pacific/Saipan",
|
|
1491
|
+
"Pacific/Tahiti",
|
|
1492
|
+
"Pacific/Tarawa",
|
|
1493
|
+
"Pacific/Tongatapu",
|
|
1494
|
+
"Pacific/Wake",
|
|
1495
|
+
"Pacific/Wallis",
|
|
1496
|
+
"UTC"
|
|
1497
|
+
]);
|
|
1498
|
+
|
|
1499
|
+
// src/api/application/users.ts
|
|
1500
|
+
var Users = class {
|
|
1501
|
+
r;
|
|
1502
|
+
constructor(requester) {
|
|
1503
|
+
this.r = requester;
|
|
1504
|
+
}
|
|
1505
|
+
list = async (opts, page = 1) => {
|
|
1506
|
+
import_zod7.default.number().positive().parse(page);
|
|
1507
|
+
const { data } = await this.r.get("/users", {
|
|
1508
|
+
params: {
|
|
1509
|
+
include: opts.include?.join(","),
|
|
1510
|
+
page,
|
|
1511
|
+
...ArrayQueryParams({ filters: opts.filters || {} }),
|
|
1512
|
+
sort: opts.sort?.id ? SortParam("id", opts.sort?.id) : SortParam("uuid", opts.sort?.uuid)
|
|
1513
|
+
}
|
|
1514
|
+
});
|
|
1515
|
+
return data.data.map((d) => d.attributes);
|
|
1516
|
+
};
|
|
1517
|
+
info = async (id, { include }) => {
|
|
1518
|
+
import_zod7.default.number().positive().parse(id);
|
|
1519
|
+
const { data } = await this.r.get(`/users/${id}`, {
|
|
1520
|
+
params: { include: include?.join(",") }
|
|
1521
|
+
});
|
|
1522
|
+
return data.attributes;
|
|
1523
|
+
};
|
|
1524
|
+
infoByExternal = async (external_id, { include }) => {
|
|
1525
|
+
const { data } = await this.r.get(`/users/external/${external_id}`, {
|
|
1526
|
+
params: { include: include?.join(",") }
|
|
1527
|
+
});
|
|
1528
|
+
return data.attributes;
|
|
1529
|
+
};
|
|
1530
|
+
create = async (user) => {
|
|
1531
|
+
user = CreateSchema.parse(user);
|
|
1532
|
+
const { data } = await this.r.post("/users", user);
|
|
1533
|
+
return data.attributes;
|
|
1534
|
+
};
|
|
1535
|
+
update = async (id, user) => {
|
|
1536
|
+
user = CreateSchema.parse(user);
|
|
1537
|
+
const { data } = await this.r.patch(`/users/${id}`, user);
|
|
1538
|
+
return data.attributes;
|
|
1539
|
+
};
|
|
1540
|
+
delete = async (id) => {
|
|
1541
|
+
import_zod7.default.number().positive().parse(id);
|
|
1542
|
+
await this.r.delete(`/users/${id}`);
|
|
1543
|
+
};
|
|
1544
|
+
addRoles = async (id, roles) => {
|
|
1545
|
+
import_zod7.default.number().positive().parse(id);
|
|
1546
|
+
await this.r.patch(`/users/${id}/roles/assign`, { roles });
|
|
1547
|
+
};
|
|
1548
|
+
removeRoles = async (id, roles) => {
|
|
1549
|
+
import_zod7.default.number().positive().parse(id);
|
|
1550
|
+
await this.r.patch(`/users/${id}/roles/remove`, { roles });
|
|
1551
|
+
};
|
|
1552
|
+
apiKeys = {
|
|
1553
|
+
list: async (id) => {
|
|
1554
|
+
const { data } = await this.r.get(`/users/${id}/api-keys`);
|
|
1555
|
+
return data.data.map((k) => k.attributes);
|
|
1556
|
+
},
|
|
1557
|
+
create: async (id, description, allowed_ips) => {
|
|
1558
|
+
allowed_ips = import_zod7.default.array(import_zod7.default.ipv4()).optional().parse(allowed_ips);
|
|
1559
|
+
const { data } = await this.r.post(`/users/${id}/api-keys`, { description, allowed_ips });
|
|
1560
|
+
return { ...data.attributes, secret_token: data.meta.secret_token };
|
|
1561
|
+
},
|
|
1562
|
+
delete: async (id, identifier) => {
|
|
1563
|
+
await this.r.delete(`/users/${id}/api-keys/${identifier}`);
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
};
|
|
1567
|
+
var CreateSchema = import_zod7.default.object({
|
|
1568
|
+
email: import_zod7.default.email(),
|
|
1569
|
+
external_id: import_zod7.default.string().max(255).optional(),
|
|
1570
|
+
username: import_zod7.default.string().min(1).max(255),
|
|
1571
|
+
password: import_zod7.default.string().optional(),
|
|
1572
|
+
language: languagesSchema,
|
|
1573
|
+
timezone: timezonesSchema
|
|
1574
|
+
});
|
|
1575
|
+
|
|
1576
|
+
// src/api/application/nodes_allocations.ts
|
|
1577
|
+
var import_zod8 = __toESM(require("zod"));
|
|
1578
|
+
var NodesAllocations = class {
|
|
1579
|
+
r;
|
|
1580
|
+
id;
|
|
1581
|
+
constructor(requester, id) {
|
|
1582
|
+
this.r = requester;
|
|
1583
|
+
this.id = id;
|
|
1584
|
+
}
|
|
1585
|
+
list = async (include) => {
|
|
1586
|
+
const { data } = await this.r.get(`/nodes/${this.id}/allocations`, {
|
|
1587
|
+
params: { include: include?.join(",") }
|
|
1588
|
+
});
|
|
1589
|
+
return data.data.map((d) => d.attributes);
|
|
1590
|
+
};
|
|
1591
|
+
create = async (ip, ports, alias) => {
|
|
1592
|
+
import_zod8.default.ipv4().parse(ip);
|
|
1593
|
+
import_zod8.default.ipv4().or(import_zod8.default.url().max(255)).optional().parse(alias);
|
|
1594
|
+
import_zod8.default.array(import_zod8.default.number()).or(import_zod8.default.string().regex(/\d+-\d+/)).parse(ports);
|
|
1595
|
+
await this.r.post(`/nodes/${this.id}/allocations`, {
|
|
1596
|
+
ip,
|
|
1597
|
+
ports,
|
|
1598
|
+
alias
|
|
1599
|
+
});
|
|
1600
|
+
};
|
|
1601
|
+
delete = async (alloc_id) => {
|
|
1602
|
+
await this.r.delete(`/nodes/${this.id}/allocations/${alloc_id}`);
|
|
1603
|
+
};
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
// src/api/application/nodes.ts
|
|
1607
|
+
var import_zod9 = __toESM(require("zod"));
|
|
1608
|
+
var Nodes = class {
|
|
1609
|
+
r;
|
|
1610
|
+
constructor(requester) {
|
|
1611
|
+
this.r = requester;
|
|
1612
|
+
}
|
|
1613
|
+
list = async (include, page = 1) => {
|
|
1614
|
+
import_zod9.default.number().positive().parse(page);
|
|
1615
|
+
const { data } = await this.r.get("/nodes", {
|
|
1616
|
+
params: { include: include?.join(","), page }
|
|
1617
|
+
});
|
|
1618
|
+
return data.data.map((s) => s.attributes);
|
|
1619
|
+
};
|
|
1620
|
+
listDeployable = async (filters, include, page = 1) => {
|
|
1621
|
+
import_zod9.default.number().positive().parse(page);
|
|
1622
|
+
const { data } = await this.r.get("/nodes/deployable", {
|
|
1623
|
+
params: {
|
|
1624
|
+
include: include?.join(","),
|
|
1625
|
+
disk: filters.disk,
|
|
1626
|
+
memory: filters.memory,
|
|
1627
|
+
cpu: filters.cpu,
|
|
1628
|
+
location_ids: filters.location_ids,
|
|
1629
|
+
tags: filters.tags,
|
|
1630
|
+
page
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1633
|
+
return data.data.map((s) => s.attributes);
|
|
1634
|
+
};
|
|
1635
|
+
info = async (id, include) => {
|
|
1636
|
+
import_zod9.default.number().positive().parse(id);
|
|
1637
|
+
const { data } = await this.r.get(`/nodes/${id}`, {
|
|
1638
|
+
params: { include: include?.join(",") }
|
|
1639
|
+
});
|
|
1640
|
+
return data.attributes;
|
|
1641
|
+
};
|
|
1642
|
+
create = async (node) => {
|
|
1643
|
+
node = NodeCreateSchema.parse(node);
|
|
1644
|
+
const { data } = await this.r.post("/nodes", node);
|
|
1645
|
+
return data.attributes;
|
|
1646
|
+
};
|
|
1647
|
+
get_configuration = async (id) => {
|
|
1648
|
+
import_zod9.default.number().positive().parse(id);
|
|
1649
|
+
const { data } = await this.r.get(`/nodes/${id}/configuration`);
|
|
1650
|
+
return data;
|
|
1651
|
+
};
|
|
1652
|
+
update = async (id, node) => {
|
|
1653
|
+
import_zod9.default.number().positive().parse(id);
|
|
1654
|
+
node = NodeCreateSchema.parse(node);
|
|
1655
|
+
const { data } = await this.r.patch(`/nodes/${id}`, node);
|
|
1656
|
+
return data.attributes;
|
|
1657
|
+
};
|
|
1658
|
+
delete = async (id) => {
|
|
1659
|
+
import_zod9.default.number().positive().parse(id);
|
|
1660
|
+
await this.r.delete(`/nodes/${id}`);
|
|
1661
|
+
};
|
|
1662
|
+
allocations = (server_id) => new NodesAllocations(this.r, server_id);
|
|
1663
|
+
};
|
|
1664
|
+
var NodeCreateSchema = import_zod9.default.object({
|
|
1665
|
+
name: import_zod9.default.string().min(1).max(100),
|
|
1666
|
+
description: import_zod9.default.string().optional(),
|
|
1667
|
+
public: import_zod9.default.boolean().optional(),
|
|
1668
|
+
fqdn: import_zod9.default.string().nonempty(),
|
|
1669
|
+
scheme: import_zod9.default.enum(["http", "https"]),
|
|
1670
|
+
behind_proxy: import_zod9.default.boolean().optional(),
|
|
1671
|
+
memory: import_zod9.default.number().min(0),
|
|
1672
|
+
memory_overallocate: import_zod9.default.number().min(-1),
|
|
1673
|
+
disk: import_zod9.default.number().min(0),
|
|
1674
|
+
disk_overallocate: import_zod9.default.number().min(-1),
|
|
1675
|
+
cpu: import_zod9.default.number().min(0),
|
|
1676
|
+
cpu_overallocate: import_zod9.default.number().min(-1),
|
|
1677
|
+
daemon_base: import_zod9.default.string().nonempty().optional(),
|
|
1678
|
+
daemon_sftp: import_zod9.default.number().min(1).max(65535),
|
|
1679
|
+
daemon_sftp_alias: import_zod9.default.string().optional(),
|
|
1680
|
+
daemon_listen: import_zod9.default.number().min(1).max(65535),
|
|
1681
|
+
daemon_connect: import_zod9.default.number().min(1).max(65535),
|
|
1682
|
+
maintenance_mode: import_zod9.default.boolean().optional(),
|
|
1683
|
+
upload_size: import_zod9.default.number().min(1).max(1024),
|
|
1684
|
+
tags: import_zod9.default.array(import_zod9.default.string()).optional()
|
|
1685
|
+
});
|
|
1686
|
+
|
|
1687
|
+
// src/api/application/servers.ts
|
|
1688
|
+
var import_zod11 = __toESM(require("zod"));
|
|
1689
|
+
|
|
1690
|
+
// src/api/application/servers_databases.ts
|
|
1691
|
+
var import_zod10 = __toESM(require("zod"));
|
|
1692
|
+
var ServersDatabases = class {
|
|
1693
|
+
r;
|
|
1694
|
+
id;
|
|
1695
|
+
constructor(r, server_id) {
|
|
1696
|
+
this.r = r;
|
|
1697
|
+
this.id = server_id;
|
|
1698
|
+
}
|
|
1699
|
+
list = async () => {
|
|
1700
|
+
const { data } = await this.r.get(`/servers/${this.id}/databases`);
|
|
1701
|
+
return data.data.map((d) => d.attributes);
|
|
1702
|
+
};
|
|
1703
|
+
create = async (database, remote, host) => {
|
|
1704
|
+
database = import_zod10.default.string().min(1).max(48).parse(database);
|
|
1705
|
+
const { data } = await this.r.post(`/servers/${this.id}/databases`, { database, remote, host });
|
|
1706
|
+
return data.attributes;
|
|
1707
|
+
};
|
|
1708
|
+
info = async (database_id) => {
|
|
1709
|
+
const { data } = await this.r.get(`/servers/${this.id}/databases/${database_id}`);
|
|
1710
|
+
return data.attributes;
|
|
1711
|
+
};
|
|
1712
|
+
delete = async (database_id) => {
|
|
1713
|
+
await this.r.delete(`/servers/${this.id}/databases/${database_id}`);
|
|
1714
|
+
};
|
|
1715
|
+
resetPassword = async (database_id) => {
|
|
1716
|
+
await this.r.post(`/servers/${this.id}/databases/${database_id}/reset-password`);
|
|
1717
|
+
};
|
|
1718
|
+
};
|
|
1719
|
+
|
|
1720
|
+
// src/api/application/servers.ts
|
|
1721
|
+
var Servers = class {
|
|
1722
|
+
r;
|
|
1723
|
+
id;
|
|
1724
|
+
databases;
|
|
1725
|
+
constructor(r, server_id) {
|
|
1726
|
+
this.r = r;
|
|
1727
|
+
this.id = server_id;
|
|
1728
|
+
this.databases = new ServersDatabases(this.r, this.id);
|
|
1729
|
+
}
|
|
1730
|
+
info = async (include) => {
|
|
1731
|
+
const { data } = await this.r.get(`/servers/${this.id}`, {
|
|
1732
|
+
params: { include: include?.join(",") }
|
|
1733
|
+
});
|
|
1734
|
+
return data.attributes;
|
|
1735
|
+
};
|
|
1736
|
+
delete = async (force = false) => {
|
|
1737
|
+
await this.r.delete(`/servers/${this.id}${force ? "/force" : ""}`);
|
|
1738
|
+
};
|
|
1739
|
+
updateDetails = async (opts) => {
|
|
1740
|
+
opts = UpdateDetailsSchema.parse(opts);
|
|
1741
|
+
await this.r.patch(`/servers/${this.id}/details`, opts);
|
|
1742
|
+
};
|
|
1743
|
+
updateBuild = async (opts) => {
|
|
1744
|
+
opts = UpdateBuildSchema.parse(opts);
|
|
1745
|
+
await this.r.patch(`/servers/${this.id}/build`, opts);
|
|
1746
|
+
};
|
|
1747
|
+
updateStartup = async (opts) => {
|
|
1748
|
+
opts = UpdateStartupSchema.parse(opts);
|
|
1749
|
+
await this.r.patch(`/servers/${this.id}/startup`, opts);
|
|
1750
|
+
};
|
|
1751
|
+
suspend = async () => {
|
|
1752
|
+
await this.r.post(`/servers/${this.id}/suspend`);
|
|
1753
|
+
};
|
|
1754
|
+
unsuspend = async () => {
|
|
1755
|
+
await this.r.post(`/servers/${this.id}/unsuspend`);
|
|
1756
|
+
};
|
|
1757
|
+
reinstall = async () => {
|
|
1758
|
+
await this.r.post(`/servers/${this.id}/reinstall`);
|
|
1759
|
+
};
|
|
1760
|
+
transferStart = async (node_id, allocation_id, allocation_additional) => {
|
|
1761
|
+
await this.r.post(`/servers/${this.id}/transfer`, {
|
|
1762
|
+
node_id,
|
|
1763
|
+
allocation_id,
|
|
1764
|
+
allocation_additional
|
|
1765
|
+
});
|
|
1766
|
+
};
|
|
1767
|
+
transferCancel = async () => {
|
|
1768
|
+
await this.r.post(`/servers/${this.id}/transfer/cancel`);
|
|
1769
|
+
};
|
|
1770
|
+
};
|
|
1771
|
+
var CreateServerSchema = import_zod11.default.object({
|
|
1772
|
+
external_id: import_zod11.default.string().min(1).max(255).optional(),
|
|
1773
|
+
name: import_zod11.default.string().min(1).max(255),
|
|
1774
|
+
description: import_zod11.default.string().optional(),
|
|
1775
|
+
user: import_zod11.default.number(),
|
|
1776
|
+
egg: import_zod11.default.number(),
|
|
1777
|
+
docker_image: import_zod11.default.string().optional(),
|
|
1778
|
+
startup: import_zod11.default.string().optional(),
|
|
1779
|
+
environment: import_zod11.default.record(import_zod11.default.string(), import_zod11.default.string()),
|
|
1780
|
+
skip_scripts: import_zod11.default.boolean().optional(),
|
|
1781
|
+
oom_killer: import_zod11.default.boolean().optional(),
|
|
1782
|
+
start_on_completion: import_zod11.default.boolean().optional(),
|
|
1783
|
+
docker_labels: import_zod11.default.record(import_zod11.default.string(), import_zod11.default.string()).optional(),
|
|
1784
|
+
limits: import_zod11.default.object({
|
|
1785
|
+
memory: import_zod11.default.number().min(0),
|
|
1786
|
+
swap: import_zod11.default.number().min(-1),
|
|
1787
|
+
disk: import_zod11.default.number().min(0),
|
|
1788
|
+
io: import_zod11.default.number().min(0),
|
|
1789
|
+
threads: import_zod11.default.string().optional(),
|
|
1790
|
+
cpu: import_zod11.default.number().min(0)
|
|
1791
|
+
}),
|
|
1792
|
+
feature_limits: import_zod11.default.object({
|
|
1793
|
+
databases: import_zod11.default.number().min(0),
|
|
1794
|
+
allocations: import_zod11.default.number().min(0),
|
|
1795
|
+
backups: import_zod11.default.number().min(0)
|
|
1796
|
+
}),
|
|
1797
|
+
allocation: import_zod11.default.object({
|
|
1798
|
+
default: import_zod11.default.string(),
|
|
1799
|
+
additional: import_zod11.default.array(import_zod11.default.string()).optional()
|
|
1800
|
+
}).optional(),
|
|
1801
|
+
deploy: import_zod11.default.object({
|
|
1802
|
+
tags: import_zod11.default.array(import_zod11.default.string()).optional(),
|
|
1803
|
+
dedicated_ip: import_zod11.default.boolean().optional(),
|
|
1804
|
+
port_range: import_zod11.default.array(import_zod11.default.string()).optional()
|
|
1805
|
+
}).optional()
|
|
1806
|
+
});
|
|
1807
|
+
var UpdateDetailsSchema = CreateServerSchema.pick({
|
|
1808
|
+
external_id: true,
|
|
1809
|
+
name: true,
|
|
1810
|
+
user: true,
|
|
1811
|
+
description: true,
|
|
1812
|
+
docker_labels: true
|
|
1813
|
+
});
|
|
1814
|
+
var UpdateBuildSchema = CreateServerSchema.pick({
|
|
1815
|
+
oom_killer: true,
|
|
1816
|
+
limits: true,
|
|
1817
|
+
feature_limits: true
|
|
1818
|
+
}).extend({
|
|
1819
|
+
allocation: import_zod11.default.number().optional(),
|
|
1820
|
+
add_allocations: import_zod11.default.array(import_zod11.default.string()).optional(),
|
|
1821
|
+
remove_allocations: import_zod11.default.array(import_zod11.default.string()).optional()
|
|
1822
|
+
});
|
|
1823
|
+
var UpdateStartupSchema = CreateServerSchema.pick({
|
|
1824
|
+
startup: true,
|
|
1825
|
+
environment: true,
|
|
1826
|
+
egg: true,
|
|
1827
|
+
skip_scripts: true
|
|
1828
|
+
}).extend({
|
|
1829
|
+
image: import_zod11.default.string().optional()
|
|
1830
|
+
});
|
|
1831
|
+
|
|
1832
|
+
// src/api/application/database_hosts.ts
|
|
1833
|
+
var import_zod12 = __toESM(require("zod"));
|
|
1834
|
+
var DatabaseHosts = class {
|
|
1835
|
+
r;
|
|
1836
|
+
constructor(r) {
|
|
1837
|
+
this.r = r;
|
|
1838
|
+
}
|
|
1839
|
+
list = async (page = 1) => {
|
|
1840
|
+
const { data } = await this.r.get("/database-hosts", {
|
|
1841
|
+
params: { page }
|
|
1842
|
+
});
|
|
1843
|
+
return data.data.map((d) => d.attributes);
|
|
1844
|
+
};
|
|
1845
|
+
info = async (id) => {
|
|
1846
|
+
const { data } = await this.r.get(`/database-hosts/${id}`);
|
|
1847
|
+
return data.attributes;
|
|
1848
|
+
};
|
|
1849
|
+
// TODO: find out why API returns 500
|
|
1850
|
+
create = async (opts) => {
|
|
1851
|
+
opts = CreateDBHostSchema.parse(opts);
|
|
1852
|
+
await this.r.post("/database-hosts", opts).catch((e) => {
|
|
1853
|
+
});
|
|
1854
|
+
};
|
|
1855
|
+
update = async (id, opts) => {
|
|
1856
|
+
opts = CreateDBHostSchema.parse(opts);
|
|
1857
|
+
const { data } = await this.r.patch(`/database-hosts/${id}`, opts);
|
|
1858
|
+
return data.attributes;
|
|
1859
|
+
};
|
|
1860
|
+
delete = async (id) => {
|
|
1861
|
+
await this.r.delete(`/database-hosts/${id}`);
|
|
1862
|
+
};
|
|
1863
|
+
};
|
|
1864
|
+
var CreateDBHostSchema = import_zod12.default.object({
|
|
1865
|
+
name: import_zod12.default.string().min(1).max(255),
|
|
1866
|
+
host: import_zod12.default.string(),
|
|
1867
|
+
port: import_zod12.default.number().min(1).max(65535),
|
|
1868
|
+
username: import_zod12.default.string().min(1).max(255),
|
|
1869
|
+
password: import_zod12.default.string().optional(),
|
|
1870
|
+
node_ids: import_zod12.default.array(import_zod12.default.string()).optional(),
|
|
1871
|
+
max_databases: import_zod12.default.number().optional()
|
|
1872
|
+
});
|
|
1873
|
+
|
|
1874
|
+
// src/api/application/roles.ts
|
|
1875
|
+
var Roles = class {
|
|
1876
|
+
r;
|
|
1877
|
+
constructor(r) {
|
|
1878
|
+
this.r = r;
|
|
1879
|
+
}
|
|
1880
|
+
list = async (page = 1) => {
|
|
1881
|
+
const { data } = await this.r.get(`/roles`, {
|
|
1882
|
+
params: { page }
|
|
1883
|
+
});
|
|
1884
|
+
return data.data.map((r) => r.attributes);
|
|
1885
|
+
};
|
|
1886
|
+
info = async (id) => {
|
|
1887
|
+
const { data } = await this.r.get(`/roles/${id}`);
|
|
1888
|
+
return data.attributes;
|
|
1889
|
+
};
|
|
1890
|
+
create = async (opts) => {
|
|
1891
|
+
await this.r.post(`/roles`, opts);
|
|
1892
|
+
};
|
|
1893
|
+
update = async (id, opts) => {
|
|
1894
|
+
await this.r.patch(`/roles/${id}`, opts);
|
|
1895
|
+
};
|
|
1896
|
+
delete = async (id) => {
|
|
1897
|
+
await this.r.delete(`/roles/${id}`);
|
|
1898
|
+
};
|
|
1899
|
+
};
|
|
1900
|
+
|
|
1901
|
+
// src/api/application/eggs.ts
|
|
1902
|
+
var Eggs = class {
|
|
1903
|
+
r;
|
|
1904
|
+
constructor(r) {
|
|
1905
|
+
this.r = r;
|
|
1906
|
+
}
|
|
1907
|
+
list = async () => {
|
|
1908
|
+
const { data } = await this.r.get("/eggs");
|
|
1909
|
+
return data.data.map((d) => d.attributes);
|
|
1910
|
+
};
|
|
1911
|
+
info = async (id) => {
|
|
1912
|
+
const { data } = await this.r.get(`/eggs/${id}`);
|
|
1913
|
+
return data.attributes;
|
|
1914
|
+
};
|
|
1915
|
+
export = async (id, format) => {
|
|
1916
|
+
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1917
|
+
params: { format },
|
|
1918
|
+
transformResponse: (r) => r
|
|
1919
|
+
});
|
|
1920
|
+
return data;
|
|
1921
|
+
};
|
|
1922
|
+
infoExportable = async (id) => {
|
|
1923
|
+
const { data } = await this.r.get(`/eggs/${id}/export`, { params: { format: "json" } });
|
|
1924
|
+
return data;
|
|
1925
|
+
};
|
|
1926
|
+
};
|
|
1927
|
+
|
|
1928
|
+
// src/api/application/mounts.ts
|
|
1929
|
+
var import_zod13 = __toESM(require("zod"));
|
|
1930
|
+
var Mounts = class {
|
|
1931
|
+
r;
|
|
1932
|
+
constructor(r) {
|
|
1933
|
+
this.r = r;
|
|
1934
|
+
}
|
|
1935
|
+
list = async () => {
|
|
1936
|
+
const { data } = await this.r.get("/mounts");
|
|
1937
|
+
return data.data.map((d) => d.attributes);
|
|
1938
|
+
};
|
|
1939
|
+
info = async (id) => {
|
|
1940
|
+
const { data } = await this.r.get(`/mounts/${id}`);
|
|
1941
|
+
return data.attributes;
|
|
1942
|
+
};
|
|
1943
|
+
create = async (opts) => {
|
|
1944
|
+
opts = CreateMountSchema.parse(opts);
|
|
1945
|
+
const { data } = await this.r.post("/mounts", opts);
|
|
1946
|
+
return data.attributes;
|
|
1947
|
+
};
|
|
1948
|
+
update = async (id, opts) => {
|
|
1949
|
+
opts = CreateMountSchema.parse(opts);
|
|
1950
|
+
const { data } = await this.r.patch(`/mounts/${id}`, opts);
|
|
1951
|
+
return data.attributes;
|
|
1952
|
+
};
|
|
1953
|
+
delete = async (id) => {
|
|
1954
|
+
await this.r.delete(`/mounts/${id}`);
|
|
1955
|
+
};
|
|
1956
|
+
listAssignedEggs = async (id) => {
|
|
1957
|
+
const { data } = await this.r.get(`/mounts/${id}/eggs`);
|
|
1958
|
+
return data.data.map((d) => d.attributes);
|
|
1959
|
+
};
|
|
1960
|
+
assignEggs = async (id, eggs) => {
|
|
1961
|
+
await this.r.post(`/mounts/${id}/eggs`, { eggs });
|
|
1962
|
+
};
|
|
1963
|
+
unassignEgg = async (id, egg_id) => {
|
|
1964
|
+
await this.r.delete(`/mounts/${id}/eggs/${egg_id}`);
|
|
1965
|
+
};
|
|
1966
|
+
listAssignedNodes = async (id) => {
|
|
1967
|
+
const { data } = await this.r.get(`/mounts/${id}/nodes`);
|
|
1968
|
+
return data.data.map((d) => d.attributes);
|
|
1969
|
+
};
|
|
1970
|
+
assignNodes = async (id, nodes) => {
|
|
1971
|
+
await this.r.post(`/mounts/${id}/nodes`, { nodes });
|
|
1972
|
+
};
|
|
1973
|
+
unassignNode = async (id, node_id) => {
|
|
1974
|
+
await this.r.delete(`/mounts/${id}/nodes/${node_id}`);
|
|
1975
|
+
};
|
|
1976
|
+
listAssignedServers = async (id) => {
|
|
1977
|
+
const { data } = await this.r.get(`/mounts/${id}/servers`);
|
|
1978
|
+
return data.data.map((d) => d.attributes);
|
|
1979
|
+
};
|
|
1980
|
+
assignServers = async (id, servers) => {
|
|
1981
|
+
await this.r.post(`/mounts/${id}/servers`, { servers });
|
|
1982
|
+
};
|
|
1983
|
+
unassignServer = async (id, server_id) => {
|
|
1984
|
+
await this.r.delete(`/mounts/${id}/servers/${server_id}`);
|
|
1985
|
+
};
|
|
1986
|
+
};
|
|
1987
|
+
var CreateMountSchema = import_zod13.default.object({
|
|
1988
|
+
name: import_zod13.default.string().min(1).max(255),
|
|
1989
|
+
description: import_zod13.default.string().optional(),
|
|
1990
|
+
source: import_zod13.default.string(),
|
|
1991
|
+
target: import_zod13.default.string(),
|
|
1992
|
+
read_only: import_zod13.default.boolean().optional()
|
|
1993
|
+
});
|
|
1994
|
+
|
|
1995
|
+
// src/api/application/client.ts
|
|
1996
|
+
var Client2 = class {
|
|
1997
|
+
r;
|
|
1998
|
+
users;
|
|
1999
|
+
nodes;
|
|
2000
|
+
databaseHosts;
|
|
2001
|
+
roles;
|
|
2002
|
+
eggs;
|
|
2003
|
+
mounts;
|
|
2004
|
+
constructor(requester) {
|
|
2005
|
+
this.r = requester;
|
|
2006
|
+
this.users = new Users(requester);
|
|
2007
|
+
this.nodes = new Nodes(requester);
|
|
2008
|
+
this.databaseHosts = new DatabaseHosts(requester);
|
|
2009
|
+
this.roles = new Roles(requester);
|
|
2010
|
+
this.eggs = new Eggs(requester);
|
|
2011
|
+
this.mounts = new Mounts(requester);
|
|
2012
|
+
}
|
|
2013
|
+
get $r() {
|
|
2014
|
+
return this.r;
|
|
2015
|
+
}
|
|
2016
|
+
listServers = async (search, page = 1) => {
|
|
2017
|
+
const { data } = await this.r.get("/servers", {
|
|
2018
|
+
params: { search, page }
|
|
2019
|
+
});
|
|
2020
|
+
return data.data.map((s) => s.attributes);
|
|
2021
|
+
};
|
|
2022
|
+
createServer = async (opts) => {
|
|
2023
|
+
opts = CreateServerSchema.parse(opts);
|
|
2024
|
+
const { data } = await this.r.post("/servers", opts);
|
|
2025
|
+
return data.attributes;
|
|
2026
|
+
};
|
|
2027
|
+
getServerByExternalId = async (external_id, include) => {
|
|
2028
|
+
const { data } = await this.r.get(`/servers/external/${external_id}`, {
|
|
2029
|
+
params: { include: include?.join(",") }
|
|
2030
|
+
});
|
|
2031
|
+
return data.attributes;
|
|
2032
|
+
};
|
|
2033
|
+
servers = (server_id) => new Servers(this.r, server_id);
|
|
2034
|
+
};
|
|
2035
|
+
|
|
2036
|
+
// src/api/base/request.ts
|
|
2037
|
+
var import_zod14 = __toESM(require("zod"));
|
|
2038
|
+
var import_axios3 = __toESM(require("axios"));
|
|
2039
|
+
|
|
2040
|
+
// src/api/base/types.ts
|
|
2041
|
+
var PterodactylException = class extends Error {
|
|
2042
|
+
data;
|
|
2043
|
+
status;
|
|
2044
|
+
constructor(message, data, status) {
|
|
2045
|
+
super(message);
|
|
2046
|
+
this.data = data;
|
|
2047
|
+
this.status = status;
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
|
|
2051
|
+
// src/api/base/request.ts
|
|
2052
|
+
var Agent = class {
|
|
2053
|
+
base_url;
|
|
2054
|
+
token;
|
|
2055
|
+
requester;
|
|
2056
|
+
constructor(url, token, type, suffix = "/api") {
|
|
2057
|
+
this.base_url = import_zod14.default.url("Invalid URL Schema").transform((url2) => new URL(url2).href).parse(url);
|
|
2058
|
+
this.token = import_zod14.default.string().regex(/^(ptl[ac]|pacc|papp)_.+$/, "Invalid token type").parse(token);
|
|
2059
|
+
this.requester = import_axios3.default.create({
|
|
2060
|
+
baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
|
|
2061
|
+
timeout: 3e3,
|
|
2062
|
+
headers: {
|
|
2063
|
+
Authorization: `Bearer ${this.token}`
|
|
2064
|
+
}
|
|
2065
|
+
});
|
|
2066
|
+
this.requester.interceptors.response.use(void 0, (error) => {
|
|
2067
|
+
if (error.response && error.response.status === 400) {
|
|
2068
|
+
return Promise.reject(new PterodactylException(
|
|
2069
|
+
"Invalid request data",
|
|
2070
|
+
error.response.data,
|
|
2071
|
+
error.response.status
|
|
2072
|
+
));
|
|
2073
|
+
}
|
|
2074
|
+
return Promise.reject(error);
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
};
|
|
2078
|
+
|
|
2079
|
+
// src/api/index.ts
|
|
2080
|
+
var PelicanAPIClient = class extends Client {
|
|
2081
|
+
constructor(url, token, suffix = "/api") {
|
|
2082
|
+
const ax = new Agent(url, token, "client", suffix);
|
|
2083
|
+
super(ax.requester);
|
|
2084
|
+
}
|
|
2085
|
+
};
|
|
2086
|
+
var PelicanAPIApplication = class extends Client2 {
|
|
2087
|
+
constructor(url, token, suffix = "/api") {
|
|
2088
|
+
const ax = new Agent(url, token, "application", suffix);
|
|
2089
|
+
super(ax.requester);
|
|
2090
|
+
}
|
|
2091
|
+
};
|
|
2092
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2093
|
+
0 && (module.exports = {
|
|
2094
|
+
PelicanAPIApplication,
|
|
2095
|
+
PelicanAPIClient
|
|
2096
|
+
});
|
|
2097
|
+
/*
|
|
2098
|
+
* @author BothimTV
|
|
2099
|
+
* @license MIT
|
|
2100
|
+
*/
|