@pelican.ts/sdk 0.4.8 → 0.4.10
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 +2 -3
- package/biome.json +42 -32
- package/bun.lock +3 -0
- package/dist/api/index.d.mts +5 -5
- package/dist/api/index.d.ts +5 -5
- package/dist/api/index.js +168 -102
- package/dist/api/index.mjs +168 -102
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +124 -70
- package/dist/index.mjs +124 -70
- package/dist/types.d.ts +1 -1
- package/package.json +60 -59
- package/scripts/create-types.ts +4 -4
- package/src/api/application/client.ts +26 -19
- package/src/api/application/database_hosts.ts +15 -20
- package/src/api/application/eggs.ts +14 -7
- package/src/api/application/mounts.ts +29 -16
- package/src/api/application/nodes.ts +34 -32
- package/src/api/application/nodes_allocations.ts +15 -11
- package/src/api/application/roles.ts +13 -27
- package/src/api/application/servers.ts +36 -27
- package/src/api/application/servers_databases.ts +11 -7
- package/src/api/application/types/container.ts +7 -8
- package/src/api/application/types/database_host.ts +8 -8
- package/src/api/application/types/egg.ts +47 -54
- package/src/api/application/types/location.ts +5 -7
- package/src/api/application/types/mount.ts +9 -9
- package/src/api/application/types/node.ts +49 -59
- package/src/api/application/types/role.ts +4 -6
- package/src/api/application/types/server.ts +21 -22
- package/src/api/application/types/server_allocation.ts +11 -12
- package/src/api/application/types/user.ts +25 -25
- package/src/api/application/users.ts +38 -27
- package/src/api/base/request.ts +28 -17
- package/src/api/base/types.ts +16 -23
- package/src/api/client/account.ts +20 -15
- package/src/api/client/client.ts +17 -18
- package/src/api/client/server.ts +24 -20
- package/src/api/client/server_activity.ts +10 -11
- package/src/api/client/server_allocations.ts +11 -6
- package/src/api/client/server_backups.ts +21 -17
- package/src/api/client/server_databases.ts +14 -8
- package/src/api/client/server_files.ts +56 -42
- package/src/api/client/server_schedules.ts +43 -19
- package/src/api/client/server_settings.ts +11 -8
- package/src/api/client/server_startup.ts +16 -8
- package/src/api/client/server_users.ts +22 -13
- package/src/api/client/server_websocket.ts +79 -33
- package/src/api/client/types/server.ts +8 -18
- package/src/api/client/types/server_allocation.ts +7 -8
- package/src/api/client/types/server_subuser.ts +10 -11
- package/src/api/client/types/user.ts +2 -5
- package/src/api/client/types/websocket.ts +12 -24
- package/src/api/common/types/egg.ts +7 -7
- package/src/api/common/types/enums.ts +1 -1
- package/src/api/common/types/server_backup.ts +4 -5
- package/src/api/common/types/server_database.ts +9 -12
- package/src/api/common/types/server_files.ts +9 -9
- package/src/api/common/types/server_limits.ts +11 -12
- package/src/api/common/types/server_power.ts +1 -1
- package/src/api/common/types/server_schedule.ts +27 -25
- package/src/api/common/types/server_startup.ts +7 -12
- package/src/api/index.ts +3 -3
- package/src/humane/Account.ts +2 -2
- package/src/humane/Client.ts +6 -6
- package/src/humane/Server.ts +31 -43
- package/src/humane/ServerAllocation.ts +3 -3
- package/src/humane/ServerBackup.ts +6 -9
- package/src/humane/ServerDatabase.ts +2 -2
- package/src/humane/ServerFile.ts +17 -11
- package/src/humane/ServerSchedule.ts +6 -6
- package/src/humane/ServerUser.ts +2 -2
- package/src/index.ts +3 -3
- package/src/utils/sized.ts +1 -1
- package/src/utils/transform.ts +5 -10
- package/src/utils/types.ts +6 -8
- package/tsconfig.json +0 -1
package/dist/api/index.mjs
CHANGED
|
@@ -91,29 +91,28 @@ var ServerFiles = class {
|
|
|
91
91
|
this.id = id;
|
|
92
92
|
}
|
|
93
93
|
list = async (path) => {
|
|
94
|
-
const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
|
|
95
|
-
params: { directory: path }
|
|
96
|
-
});
|
|
94
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/list`, { params: { directory: path } });
|
|
97
95
|
return data.data.map((r) => r.attributes);
|
|
98
96
|
};
|
|
99
97
|
/**
|
|
100
98
|
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
101
99
|
*/
|
|
102
100
|
contents = async (path) => {
|
|
103
|
-
const { data } = await this.r.get(
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
const { data } = await this.r.get(
|
|
102
|
+
`/servers/${this.id}/files/contents`,
|
|
103
|
+
{ params: { file: path } }
|
|
104
|
+
);
|
|
106
105
|
return data;
|
|
107
106
|
};
|
|
108
107
|
downloadGetUrl = async (path) => {
|
|
109
|
-
const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
|
|
110
|
-
params: { file: path }
|
|
111
|
-
});
|
|
108
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/download`, { params: { file: path } });
|
|
112
109
|
return data.attributes.url;
|
|
113
110
|
};
|
|
114
111
|
download = async (path) => {
|
|
115
112
|
const url = await this.downloadGetUrl(path);
|
|
116
|
-
const { data } = await axios.get(url, {
|
|
113
|
+
const { data } = await axios.get(url, {
|
|
114
|
+
responseType: "arraybuffer"
|
|
115
|
+
});
|
|
117
116
|
return data;
|
|
118
117
|
};
|
|
119
118
|
rename = async (root = "/", files) => {
|
|
@@ -128,7 +127,12 @@ var ServerFiles = class {
|
|
|
128
127
|
});
|
|
129
128
|
};
|
|
130
129
|
compress = async (root = "/", files, archive_name, extension) => {
|
|
131
|
-
const { data } = await this.r.post(`/servers/${this.id}/files/compress`, {
|
|
130
|
+
const { data } = await this.r.post(`/servers/${this.id}/files/compress`, {
|
|
131
|
+
root,
|
|
132
|
+
files,
|
|
133
|
+
archive_name,
|
|
134
|
+
extension
|
|
135
|
+
});
|
|
132
136
|
return data.attributes;
|
|
133
137
|
};
|
|
134
138
|
decompress = async (root = "/", file) => {
|
|
@@ -138,13 +142,22 @@ var ServerFiles = class {
|
|
|
138
142
|
await this.r.post(`/servers/${this.id}/files/delete`, { root, files });
|
|
139
143
|
};
|
|
140
144
|
createFolder = async (root = "/", name) => {
|
|
141
|
-
await this.r.post(`/servers/${this.id}/files/create-folder`, {
|
|
145
|
+
await this.r.post(`/servers/${this.id}/files/create-folder`, {
|
|
146
|
+
root,
|
|
147
|
+
name
|
|
148
|
+
});
|
|
142
149
|
};
|
|
143
150
|
chmod = async (root = "/", files) => {
|
|
144
151
|
await this.r.post(`/servers/${this.id}/files/chmod`, { root, files });
|
|
145
152
|
};
|
|
146
153
|
pullFromRemote = async (url, directory, filename, use_header = false, foreground = false) => {
|
|
147
|
-
await this.r.post(`/servers/${this.id}/files/pull`, {
|
|
154
|
+
await this.r.post(`/servers/${this.id}/files/pull`, {
|
|
155
|
+
url,
|
|
156
|
+
directory,
|
|
157
|
+
filename,
|
|
158
|
+
use_header,
|
|
159
|
+
foreground
|
|
160
|
+
});
|
|
148
161
|
};
|
|
149
162
|
uploadGetUrl = async () => {
|
|
150
163
|
const { data } = await this.r.get(`/servers/${this.id}/files/upload`);
|
|
@@ -152,10 +165,14 @@ var ServerFiles = class {
|
|
|
152
165
|
};
|
|
153
166
|
upload = async (file, root = "/") => {
|
|
154
167
|
const url = await this.uploadGetUrl();
|
|
155
|
-
await axios.post(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
168
|
+
await axios.post(
|
|
169
|
+
url,
|
|
170
|
+
{ files: file },
|
|
171
|
+
{
|
|
172
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
173
|
+
params: { directory: root }
|
|
174
|
+
}
|
|
175
|
+
);
|
|
159
176
|
};
|
|
160
177
|
};
|
|
161
178
|
|
|
@@ -198,7 +215,9 @@ var ScheduleControl = class {
|
|
|
198
215
|
await this.r.delete(`/servers/${this.id}/schedules/${this.sched_id}`);
|
|
199
216
|
};
|
|
200
217
|
execute = async () => {
|
|
201
|
-
await this.r.post(
|
|
218
|
+
await this.r.post(
|
|
219
|
+
`/servers/${this.id}/schedules/${this.sched_id}/execute`
|
|
220
|
+
);
|
|
202
221
|
};
|
|
203
222
|
tasks = {
|
|
204
223
|
create: async (opts) => {
|
|
@@ -206,11 +225,16 @@ var ScheduleControl = class {
|
|
|
206
225
|
return data.attributes;
|
|
207
226
|
},
|
|
208
227
|
update: async (task_id, opts) => {
|
|
209
|
-
const { data } = await this.r.post(
|
|
228
|
+
const { data } = await this.r.post(
|
|
229
|
+
`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`,
|
|
230
|
+
opts
|
|
231
|
+
);
|
|
210
232
|
return data.attributes;
|
|
211
233
|
},
|
|
212
234
|
delete: async (task_id) => {
|
|
213
|
-
await this.r.delete(
|
|
235
|
+
await this.r.delete(
|
|
236
|
+
`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`
|
|
237
|
+
);
|
|
214
238
|
}
|
|
215
239
|
};
|
|
216
240
|
};
|
|
@@ -240,7 +264,9 @@ var ServerAllocations = class {
|
|
|
240
264
|
return data.attributes;
|
|
241
265
|
};
|
|
242
266
|
unassign = async (alloc_id) => {
|
|
243
|
-
await this.r.delete(
|
|
267
|
+
await this.r.delete(
|
|
268
|
+
`/servers/${this.id}/network/allocations/${alloc_id}`
|
|
269
|
+
);
|
|
244
270
|
};
|
|
245
271
|
};
|
|
246
272
|
|
|
@@ -261,11 +287,16 @@ var ServerUsers = class {
|
|
|
261
287
|
return data.attributes;
|
|
262
288
|
};
|
|
263
289
|
info = async (user_uuid) => {
|
|
264
|
-
const { data } = await this.r.get(
|
|
290
|
+
const { data } = await this.r.get(
|
|
291
|
+
`/servers/${this.id}/users/${user_uuid}`
|
|
292
|
+
);
|
|
265
293
|
return data.attributes;
|
|
266
294
|
};
|
|
267
295
|
update = async (user_uuid, permissions) => {
|
|
268
|
-
const { data } = await this.r.put(
|
|
296
|
+
const { data } = await this.r.put(
|
|
297
|
+
`/servers/${this.id}/users/${user_uuid}`,
|
|
298
|
+
{ permissions }
|
|
299
|
+
);
|
|
269
300
|
return data.attributes;
|
|
270
301
|
};
|
|
271
302
|
delete = async (user_uuid) => {
|
|
@@ -285,9 +316,7 @@ var ServerBackups = class {
|
|
|
285
316
|
}
|
|
286
317
|
list = async (page = 1) => {
|
|
287
318
|
z3.number().positive().parse(page);
|
|
288
|
-
const { data } = await this.r.get(`/servers/${this.id}/backups`, {
|
|
289
|
-
params: { page }
|
|
290
|
-
});
|
|
319
|
+
const { data } = await this.r.get(`/servers/${this.id}/backups`, { params: { page } });
|
|
291
320
|
return data.data.map((d) => d.attributes);
|
|
292
321
|
};
|
|
293
322
|
create = async (args) => {
|
|
@@ -309,20 +338,27 @@ var ServerBackups = class {
|
|
|
309
338
|
};
|
|
310
339
|
download = async (backup_uuid) => {
|
|
311
340
|
const url = await this.downloadGetUrl(backup_uuid);
|
|
312
|
-
const { data } = await axios2.get(url, {
|
|
341
|
+
const { data } = await axios2.get(url, {
|
|
342
|
+
responseType: "arraybuffer"
|
|
343
|
+
});
|
|
313
344
|
return data;
|
|
314
345
|
};
|
|
315
346
|
delete = async (backup_uuid) => {
|
|
316
347
|
await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
|
|
317
348
|
};
|
|
318
349
|
rename = async (backup_uuid, name) => {
|
|
319
|
-
await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, {
|
|
350
|
+
await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, {
|
|
351
|
+
name
|
|
352
|
+
});
|
|
320
353
|
};
|
|
321
354
|
toggleLock = async (backup_uuid) => {
|
|
322
355
|
await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/lock`);
|
|
323
356
|
};
|
|
324
357
|
restore = async (backup_uuid, truncate) => {
|
|
325
|
-
await this.r.post(
|
|
358
|
+
await this.r.post(
|
|
359
|
+
`/servers/${this.id}/backups/${backup_uuid}/restore`,
|
|
360
|
+
{ truncate }
|
|
361
|
+
);
|
|
326
362
|
};
|
|
327
363
|
};
|
|
328
364
|
|
|
@@ -362,13 +398,15 @@ var ServerSettings = class {
|
|
|
362
398
|
await this.r.post(`/servers/${this.id}/settings/rename`, { name });
|
|
363
399
|
};
|
|
364
400
|
updateDescription = async (description) => {
|
|
365
|
-
await this.r.post(`/servers/${this.id}/settings/description`, {
|
|
401
|
+
await this.r.post(`/servers/${this.id}/settings/description`, {
|
|
402
|
+
description
|
|
403
|
+
});
|
|
366
404
|
};
|
|
367
405
|
reinstall = async () => {
|
|
368
406
|
await this.r.post(`/servers/${this.id}/settings/reinstall`);
|
|
369
407
|
};
|
|
370
408
|
changeDockerImage = async (image) => {
|
|
371
|
-
await this.r.
|
|
409
|
+
await this.r.put(`/servers/${this.id}/settings/docker-image`, { image });
|
|
372
410
|
};
|
|
373
411
|
};
|
|
374
412
|
|
|
@@ -420,7 +458,9 @@ var ServerWebsocket = class {
|
|
|
420
458
|
return;
|
|
421
459
|
}
|
|
422
460
|
const socketUrl = await this.refreshCredentials();
|
|
423
|
-
this.socket = isBrowser ? new WebSocket(socketUrl) : new WebSocket(socketUrl, void 0, {
|
|
461
|
+
this.socket = isBrowser ? new WebSocket(socketUrl) : new WebSocket(socketUrl, void 0, {
|
|
462
|
+
origin: new URL(socketUrl).origin
|
|
463
|
+
});
|
|
424
464
|
await new Promise((resolve, reject) => {
|
|
425
465
|
const socket = this.socket;
|
|
426
466
|
if (!socket) {
|
|
@@ -437,13 +477,17 @@ var ServerWebsocket = class {
|
|
|
437
477
|
} catch (error) {
|
|
438
478
|
socket.onopen = null;
|
|
439
479
|
socket.onerror = null;
|
|
440
|
-
reject(
|
|
480
|
+
reject(
|
|
481
|
+
error instanceof Error ? error : new Error("Websocket authentication failed")
|
|
482
|
+
);
|
|
441
483
|
}
|
|
442
484
|
};
|
|
443
485
|
socket.onerror = (event) => {
|
|
444
486
|
socket.onopen = null;
|
|
445
487
|
socket.onerror = null;
|
|
446
|
-
reject(
|
|
488
|
+
reject(
|
|
489
|
+
event instanceof Error ? event : new Error("Websocket connection error")
|
|
490
|
+
);
|
|
447
491
|
};
|
|
448
492
|
});
|
|
449
493
|
if (resumable) {
|
|
@@ -489,9 +533,15 @@ var ServerWebsocket = class {
|
|
|
489
533
|
void this.handleIncomingMessage(event);
|
|
490
534
|
};
|
|
491
535
|
if (typeof this.socket.addEventListener === "function") {
|
|
492
|
-
this.socket.addEventListener(
|
|
536
|
+
this.socket.addEventListener(
|
|
537
|
+
"message",
|
|
538
|
+
handler
|
|
539
|
+
);
|
|
493
540
|
this.detachMessageListener = () => {
|
|
494
|
-
this.socket?.removeEventListener?.(
|
|
541
|
+
this.socket?.removeEventListener?.(
|
|
542
|
+
"message",
|
|
543
|
+
handler
|
|
544
|
+
);
|
|
495
545
|
};
|
|
496
546
|
} else {
|
|
497
547
|
const fallback = (data) => handler({ data });
|
|
@@ -601,7 +651,9 @@ var ServerWebsocket = class {
|
|
|
601
651
|
}
|
|
602
652
|
case "backup completed" /* BACKUP_COMPLETED */: {
|
|
603
653
|
try {
|
|
604
|
-
const payload = JSON.parse(
|
|
654
|
+
const payload = JSON.parse(
|
|
655
|
+
message.args[0]
|
|
656
|
+
);
|
|
605
657
|
this.emit("backup completed" /* BACKUP_COMPLETED */, payload);
|
|
606
658
|
} catch (error) {
|
|
607
659
|
if (this.debugLogging) {
|
|
@@ -683,7 +735,9 @@ var ServerWebsocket = class {
|
|
|
683
735
|
}
|
|
684
736
|
}
|
|
685
737
|
async refreshCredentials() {
|
|
686
|
-
const { data } = await this.r.get(
|
|
738
|
+
const { data } = await this.r.get(
|
|
739
|
+
`/servers/${this.serverId}/websocket`
|
|
740
|
+
);
|
|
687
741
|
this.currentToken = data.data.token;
|
|
688
742
|
return data.data.socket;
|
|
689
743
|
}
|
|
@@ -694,7 +748,9 @@ var ServerWebsocket = class {
|
|
|
694
748
|
if (!this.currentToken) {
|
|
695
749
|
throw new Error("Missing websocket token");
|
|
696
750
|
}
|
|
697
|
-
this.socket.send(
|
|
751
|
+
this.socket.send(
|
|
752
|
+
JSON.stringify({ event: "auth", args: [this.currentToken] })
|
|
753
|
+
);
|
|
698
754
|
}
|
|
699
755
|
disconnect() {
|
|
700
756
|
this.detachMessageListener?.();
|
|
@@ -713,7 +769,9 @@ var ServerWebsocket = class {
|
|
|
713
769
|
send(event, args) {
|
|
714
770
|
if (!this.socket) {
|
|
715
771
|
if (this.debugLogging) {
|
|
716
|
-
console.warn(
|
|
772
|
+
console.warn(
|
|
773
|
+
`Attempted to send "${event}" without an active websocket connection`
|
|
774
|
+
);
|
|
717
775
|
}
|
|
718
776
|
return;
|
|
719
777
|
}
|
|
@@ -794,12 +852,7 @@ var ServerActivity = class {
|
|
|
794
852
|
this.id = id;
|
|
795
853
|
}
|
|
796
854
|
list = async (page = 1, per_page = 25) => {
|
|
797
|
-
const { data } = await this.r.get(`/server/${this.id}/activity`, {
|
|
798
|
-
params: {
|
|
799
|
-
page,
|
|
800
|
-
per_page
|
|
801
|
-
}
|
|
802
|
-
});
|
|
855
|
+
const { data } = await this.r.get(`/server/${this.id}/activity`, { params: { page, per_page } });
|
|
803
856
|
return data.data.map((log) => log.attributes);
|
|
804
857
|
};
|
|
805
858
|
};
|
|
@@ -833,16 +886,19 @@ var ServerClient = class {
|
|
|
833
886
|
this.settings = new ServerSettings(requester, id);
|
|
834
887
|
}
|
|
835
888
|
info = async (include) => {
|
|
836
|
-
const { data } = await this.r.get(
|
|
837
|
-
|
|
838
|
-
|
|
889
|
+
const { data } = await this.r.get(
|
|
890
|
+
`/servers/${this.id}`,
|
|
891
|
+
{ params: { include: include?.join(",") } }
|
|
892
|
+
);
|
|
839
893
|
return data.attributes;
|
|
840
894
|
};
|
|
841
895
|
websocket = (stripColors = false) => {
|
|
842
896
|
return new ServerWebsocket(this.r, this.id, stripColors);
|
|
843
897
|
};
|
|
844
898
|
resources = async () => {
|
|
845
|
-
const { data } = await this.r.get(
|
|
899
|
+
const { data } = await this.r.get(
|
|
900
|
+
`/servers/${this.id}/resources`
|
|
901
|
+
);
|
|
846
902
|
return data.attributes;
|
|
847
903
|
};
|
|
848
904
|
command = async (command) => {
|
|
@@ -870,9 +926,7 @@ var Client = class {
|
|
|
870
926
|
};
|
|
871
927
|
listServers = async (type = "accessible", page = 1, per_page = 50, include) => {
|
|
872
928
|
z5.number().positive().parse(page);
|
|
873
|
-
const { data } = await this.r.get("/", {
|
|
874
|
-
params: { type, page, include: include?.join(",") }
|
|
875
|
-
});
|
|
929
|
+
const { data } = await this.r.get("/", { params: { type, page, include: include?.join(",") } });
|
|
876
930
|
return data.data.map((s) => s.attributes);
|
|
877
931
|
};
|
|
878
932
|
server = (uuid) => new ServerClient(this.r, uuid);
|
|
@@ -1476,9 +1530,7 @@ var Users = class {
|
|
|
1476
1530
|
};
|
|
1477
1531
|
info = async (id, { include }) => {
|
|
1478
1532
|
z7.number().positive().parse(id);
|
|
1479
|
-
const { data } = await this.r.get(`/users/${id}`, {
|
|
1480
|
-
params: { include: include?.join(",") }
|
|
1481
|
-
});
|
|
1533
|
+
const { data } = await this.r.get(`/users/${id}`, { params: { include: include?.join(",") } });
|
|
1482
1534
|
return data.attributes;
|
|
1483
1535
|
};
|
|
1484
1536
|
infoByExternal = async (external_id, { include }) => {
|
|
@@ -1552,11 +1604,7 @@ var NodesAllocations = class {
|
|
|
1552
1604
|
z8.ipv4().parse(ip);
|
|
1553
1605
|
z8.ipv4().or(z8.url().max(255)).optional().parse(alias);
|
|
1554
1606
|
z8.array(z8.number()).or(z8.string().regex(/\d+-\d+/)).parse(ports);
|
|
1555
|
-
await this.r.post(`/nodes/${this.id}/allocations`, {
|
|
1556
|
-
ip,
|
|
1557
|
-
ports,
|
|
1558
|
-
alias
|
|
1559
|
-
});
|
|
1607
|
+
await this.r.post(`/nodes/${this.id}/allocations`, { ip, ports, alias });
|
|
1560
1608
|
};
|
|
1561
1609
|
delete = async (alloc_id) => {
|
|
1562
1610
|
await this.r.delete(`/nodes/${this.id}/allocations/${alloc_id}`);
|
|
@@ -1572,9 +1620,7 @@ var Nodes = class {
|
|
|
1572
1620
|
}
|
|
1573
1621
|
list = async (include, page = 1) => {
|
|
1574
1622
|
z9.number().positive().parse(page);
|
|
1575
|
-
const { data } = await this.r.get("/nodes", {
|
|
1576
|
-
params: { include: include?.join(","), page }
|
|
1577
|
-
});
|
|
1623
|
+
const { data } = await this.r.get("/nodes", { params: { include: include?.join(","), page } });
|
|
1578
1624
|
return data.data.map((s) => s.attributes);
|
|
1579
1625
|
};
|
|
1580
1626
|
listDeployable = async (filters, include, page = 1) => {
|
|
@@ -1594,25 +1640,34 @@ var Nodes = class {
|
|
|
1594
1640
|
};
|
|
1595
1641
|
info = async (id, include) => {
|
|
1596
1642
|
z9.number().positive().parse(id);
|
|
1597
|
-
const { data } = await this.r.get(
|
|
1598
|
-
|
|
1599
|
-
|
|
1643
|
+
const { data } = await this.r.get(
|
|
1644
|
+
`/nodes/${id}`,
|
|
1645
|
+
{ params: { include: include?.join(",") } }
|
|
1646
|
+
);
|
|
1600
1647
|
return data.attributes;
|
|
1601
1648
|
};
|
|
1602
1649
|
create = async (node) => {
|
|
1603
1650
|
node = NodeCreateSchema.parse(node);
|
|
1604
|
-
const { data } = await this.r.post(
|
|
1651
|
+
const { data } = await this.r.post(
|
|
1652
|
+
"/nodes",
|
|
1653
|
+
node
|
|
1654
|
+
);
|
|
1605
1655
|
return data.attributes;
|
|
1606
1656
|
};
|
|
1607
1657
|
get_configuration = async (id) => {
|
|
1608
1658
|
z9.number().positive().parse(id);
|
|
1609
|
-
const { data } = await this.r.get(
|
|
1659
|
+
const { data } = await this.r.get(
|
|
1660
|
+
`/nodes/${id}/configuration`
|
|
1661
|
+
);
|
|
1610
1662
|
return data;
|
|
1611
1663
|
};
|
|
1612
1664
|
update = async (id, node) => {
|
|
1613
1665
|
z9.number().positive().parse(id);
|
|
1614
1666
|
node = NodeCreateSchema.parse(node);
|
|
1615
|
-
const { data } = await this.r.patch(
|
|
1667
|
+
const { data } = await this.r.patch(
|
|
1668
|
+
`/nodes/${id}`,
|
|
1669
|
+
node
|
|
1670
|
+
);
|
|
1616
1671
|
return data.attributes;
|
|
1617
1672
|
};
|
|
1618
1673
|
delete = async (id) => {
|
|
@@ -1673,7 +1728,9 @@ var ServersDatabases = class {
|
|
|
1673
1728
|
await this.r.delete(`/servers/${this.id}/databases/${database_id}`);
|
|
1674
1729
|
};
|
|
1675
1730
|
resetPassword = async (database_id) => {
|
|
1676
|
-
await this.r.post(
|
|
1731
|
+
await this.r.post(
|
|
1732
|
+
`/servers/${this.id}/databases/${database_id}/reset-password`
|
|
1733
|
+
);
|
|
1677
1734
|
};
|
|
1678
1735
|
};
|
|
1679
1736
|
|
|
@@ -1688,9 +1745,7 @@ var Servers = class {
|
|
|
1688
1745
|
this.databases = new ServersDatabases(this.r, this.id);
|
|
1689
1746
|
}
|
|
1690
1747
|
info = async (include) => {
|
|
1691
|
-
const { data } = await this.r.get(`/servers/${this.id}`, {
|
|
1692
|
-
params: { include: include?.join(",") }
|
|
1693
|
-
});
|
|
1748
|
+
const { data } = await this.r.get(`/servers/${this.id}`, { params: { include: include?.join(",") } });
|
|
1694
1749
|
return data.attributes;
|
|
1695
1750
|
};
|
|
1696
1751
|
delete = async (force = false) => {
|
|
@@ -1785,9 +1840,7 @@ var UpdateStartupSchema = CreateServerSchema.pick({
|
|
|
1785
1840
|
environment: true,
|
|
1786
1841
|
egg: true,
|
|
1787
1842
|
skip_scripts: true
|
|
1788
|
-
}).extend({
|
|
1789
|
-
image: z11.string().optional()
|
|
1790
|
-
});
|
|
1843
|
+
}).extend({ image: z11.string().optional() });
|
|
1791
1844
|
|
|
1792
1845
|
// src/api/application/database_hosts.ts
|
|
1793
1846
|
import z12 from "zod";
|
|
@@ -1797,9 +1850,7 @@ var DatabaseHosts = class {
|
|
|
1797
1850
|
this.r = r;
|
|
1798
1851
|
}
|
|
1799
1852
|
list = async (page = 1) => {
|
|
1800
|
-
const { data } = await this.r.get("/database-hosts", {
|
|
1801
|
-
params: { page }
|
|
1802
|
-
});
|
|
1853
|
+
const { data } = await this.r.get("/database-hosts", { params: { page } });
|
|
1803
1854
|
return data.data.map((d) => d.attributes);
|
|
1804
1855
|
};
|
|
1805
1856
|
info = async (id) => {
|
|
@@ -1809,7 +1860,10 @@ var DatabaseHosts = class {
|
|
|
1809
1860
|
// TODO: find out why API returns 500
|
|
1810
1861
|
create = async (opts) => {
|
|
1811
1862
|
opts = CreateDBHostSchema.parse(opts);
|
|
1812
|
-
await this.r.post(
|
|
1863
|
+
await this.r.post(
|
|
1864
|
+
"/database-hosts",
|
|
1865
|
+
opts
|
|
1866
|
+
).catch((e) => {
|
|
1813
1867
|
});
|
|
1814
1868
|
};
|
|
1815
1869
|
update = async (id, opts) => {
|
|
@@ -1838,13 +1892,13 @@ var Roles = class {
|
|
|
1838
1892
|
this.r = r;
|
|
1839
1893
|
}
|
|
1840
1894
|
list = async (page = 1) => {
|
|
1841
|
-
const { data } = await this.r.get(`/roles`, {
|
|
1842
|
-
params: { page }
|
|
1843
|
-
});
|
|
1895
|
+
const { data } = await this.r.get(`/roles`, { params: { page } });
|
|
1844
1896
|
return data.data.map((r) => r.attributes);
|
|
1845
1897
|
};
|
|
1846
1898
|
info = async (id) => {
|
|
1847
|
-
const { data } = await this.r.get(
|
|
1899
|
+
const { data } = await this.r.get(
|
|
1900
|
+
`/roles/${id}`
|
|
1901
|
+
);
|
|
1848
1902
|
return data.attributes;
|
|
1849
1903
|
};
|
|
1850
1904
|
create = async (opts) => {
|
|
@@ -1865,11 +1919,15 @@ var Eggs = class {
|
|
|
1865
1919
|
this.r = r;
|
|
1866
1920
|
}
|
|
1867
1921
|
list = async () => {
|
|
1868
|
-
const { data } = await this.r.get(
|
|
1922
|
+
const { data } = await this.r.get(
|
|
1923
|
+
"/eggs"
|
|
1924
|
+
);
|
|
1869
1925
|
return data.data.map((d) => d.attributes);
|
|
1870
1926
|
};
|
|
1871
1927
|
info = async (id) => {
|
|
1872
|
-
const { data } = await this.r.get(
|
|
1928
|
+
const { data } = await this.r.get(
|
|
1929
|
+
`/eggs/${id}`
|
|
1930
|
+
);
|
|
1873
1931
|
return data.attributes;
|
|
1874
1932
|
};
|
|
1875
1933
|
export = async (id, format) => {
|
|
@@ -1880,7 +1938,9 @@ var Eggs = class {
|
|
|
1880
1938
|
return data;
|
|
1881
1939
|
};
|
|
1882
1940
|
infoExportable = async (id) => {
|
|
1883
|
-
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1941
|
+
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1942
|
+
params: { format: "json" }
|
|
1943
|
+
});
|
|
1884
1944
|
return data;
|
|
1885
1945
|
};
|
|
1886
1946
|
};
|
|
@@ -1897,17 +1957,25 @@ var Mounts = class {
|
|
|
1897
1957
|
return data.data.map((d) => d.attributes);
|
|
1898
1958
|
};
|
|
1899
1959
|
info = async (id) => {
|
|
1900
|
-
const { data } = await this.r.get(
|
|
1960
|
+
const { data } = await this.r.get(
|
|
1961
|
+
`/mounts/${id}`
|
|
1962
|
+
);
|
|
1901
1963
|
return data.attributes;
|
|
1902
1964
|
};
|
|
1903
1965
|
create = async (opts) => {
|
|
1904
1966
|
opts = CreateMountSchema.parse(opts);
|
|
1905
|
-
const { data } = await this.r.post(
|
|
1967
|
+
const { data } = await this.r.post(
|
|
1968
|
+
"/mounts",
|
|
1969
|
+
opts
|
|
1970
|
+
);
|
|
1906
1971
|
return data.attributes;
|
|
1907
1972
|
};
|
|
1908
1973
|
update = async (id, opts) => {
|
|
1909
1974
|
opts = CreateMountSchema.parse(opts);
|
|
1910
|
-
const { data } = await this.r.patch(
|
|
1975
|
+
const { data } = await this.r.patch(
|
|
1976
|
+
`/mounts/${id}`,
|
|
1977
|
+
opts
|
|
1978
|
+
);
|
|
1911
1979
|
return data.attributes;
|
|
1912
1980
|
};
|
|
1913
1981
|
delete = async (id) => {
|
|
@@ -1974,9 +2042,7 @@ var Client2 = class {
|
|
|
1974
2042
|
return this.r;
|
|
1975
2043
|
}
|
|
1976
2044
|
listServers = async (search, page = 1) => {
|
|
1977
|
-
const { data } = await this.r.get("/servers", {
|
|
1978
|
-
params: { search, page }
|
|
1979
|
-
});
|
|
2045
|
+
const { data } = await this.r.get("/servers", { params: { search, page } });
|
|
1980
2046
|
return data.data.map((s) => s.attributes);
|
|
1981
2047
|
};
|
|
1982
2048
|
createServer = async (opts) => {
|
|
@@ -2019,17 +2085,17 @@ var Agent = class {
|
|
|
2019
2085
|
this.requester = axios3.create({
|
|
2020
2086
|
baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
|
|
2021
2087
|
timeout: 3e3,
|
|
2022
|
-
headers: {
|
|
2023
|
-
Authorization: `Bearer ${this.token}`
|
|
2024
|
-
}
|
|
2088
|
+
headers: { Authorization: `Bearer ${this.token}` }
|
|
2025
2089
|
});
|
|
2026
2090
|
this.requester.interceptors.response.use(void 0, (error) => {
|
|
2027
2091
|
if (error.response && error.response.status === 400) {
|
|
2028
|
-
return Promise.reject(
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2092
|
+
return Promise.reject(
|
|
2093
|
+
new PterodactylException(
|
|
2094
|
+
"Invalid request data",
|
|
2095
|
+
error.response.data,
|
|
2096
|
+
error.response.status
|
|
2097
|
+
)
|
|
2098
|
+
);
|
|
2033
2099
|
}
|
|
2034
2100
|
return Promise.reject(error);
|
|
2035
2101
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
|
|
4
|
-
type ServerSignalOption =
|
|
4
|
+
type ServerSignalOption = "start" | "stop" | "restart" | "kill";
|
|
5
5
|
|
|
6
6
|
type GenericResponse<T, N extends string = string, M = undefined> = {
|
|
7
7
|
object: N;
|
|
@@ -376,7 +376,7 @@ declare class ServerDatabases {
|
|
|
376
376
|
private readonly r;
|
|
377
377
|
private readonly id;
|
|
378
378
|
constructor(requester: AxiosInstance, id: string);
|
|
379
|
-
list: (include?:
|
|
379
|
+
list: (include?: "password"[], page?: number) => Promise<ServerDatabase$1[]>;
|
|
380
380
|
create: (database: string, remote: string) => Promise<ServerDatabase$1>;
|
|
381
381
|
rotatePassword: (database_id: string) => Promise<ServerDatabase$1>;
|
|
382
382
|
delete: (database_id: string) => Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import WebSocket from 'isomorphic-ws';
|
|
3
3
|
|
|
4
|
-
type ServerSignalOption =
|
|
4
|
+
type ServerSignalOption = "start" | "stop" | "restart" | "kill";
|
|
5
5
|
|
|
6
6
|
type GenericResponse<T, N extends string = string, M = undefined> = {
|
|
7
7
|
object: N;
|
|
@@ -376,7 +376,7 @@ declare class ServerDatabases {
|
|
|
376
376
|
private readonly r;
|
|
377
377
|
private readonly id;
|
|
378
378
|
constructor(requester: AxiosInstance, id: string);
|
|
379
|
-
list: (include?:
|
|
379
|
+
list: (include?: "password"[], page?: number) => Promise<ServerDatabase$1[]>;
|
|
380
380
|
create: (database: string, remote: string) => Promise<ServerDatabase$1>;
|
|
381
381
|
rotatePassword: (database_id: string) => Promise<ServerDatabase$1>;
|
|
382
382
|
delete: (database_id: string) => Promise<void>;
|