@pelican.ts/sdk 0.4.8 → 0.4.9
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 +167 -101
- package/dist/api/index.mjs +167 -101
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +123 -69
- package/dist/index.mjs +123 -69
- 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 +10 -7
- 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.js
CHANGED
|
@@ -128,29 +128,28 @@ var ServerFiles = class {
|
|
|
128
128
|
this.id = id;
|
|
129
129
|
}
|
|
130
130
|
list = async (path) => {
|
|
131
|
-
const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
|
|
132
|
-
params: { directory: path }
|
|
133
|
-
});
|
|
131
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/list`, { params: { directory: path } });
|
|
134
132
|
return data.data.map((r) => r.attributes);
|
|
135
133
|
};
|
|
136
134
|
/**
|
|
137
135
|
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
138
136
|
*/
|
|
139
137
|
contents = async (path) => {
|
|
140
|
-
const { data } = await this.r.get(
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
const { data } = await this.r.get(
|
|
139
|
+
`/servers/${this.id}/files/contents`,
|
|
140
|
+
{ params: { file: path } }
|
|
141
|
+
);
|
|
143
142
|
return data;
|
|
144
143
|
};
|
|
145
144
|
downloadGetUrl = async (path) => {
|
|
146
|
-
const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
|
|
147
|
-
params: { file: path }
|
|
148
|
-
});
|
|
145
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/download`, { params: { file: path } });
|
|
149
146
|
return data.attributes.url;
|
|
150
147
|
};
|
|
151
148
|
download = async (path) => {
|
|
152
149
|
const url = await this.downloadGetUrl(path);
|
|
153
|
-
const { data } = await import_axios.default.get(url, {
|
|
150
|
+
const { data } = await import_axios.default.get(url, {
|
|
151
|
+
responseType: "arraybuffer"
|
|
152
|
+
});
|
|
154
153
|
return data;
|
|
155
154
|
};
|
|
156
155
|
rename = async (root = "/", files) => {
|
|
@@ -165,7 +164,12 @@ var ServerFiles = class {
|
|
|
165
164
|
});
|
|
166
165
|
};
|
|
167
166
|
compress = async (root = "/", files, archive_name, extension) => {
|
|
168
|
-
const { data } = await this.r.post(`/servers/${this.id}/files/compress`, {
|
|
167
|
+
const { data } = await this.r.post(`/servers/${this.id}/files/compress`, {
|
|
168
|
+
root,
|
|
169
|
+
files,
|
|
170
|
+
archive_name,
|
|
171
|
+
extension
|
|
172
|
+
});
|
|
169
173
|
return data.attributes;
|
|
170
174
|
};
|
|
171
175
|
decompress = async (root = "/", file) => {
|
|
@@ -175,13 +179,22 @@ var ServerFiles = class {
|
|
|
175
179
|
await this.r.post(`/servers/${this.id}/files/delete`, { root, files });
|
|
176
180
|
};
|
|
177
181
|
createFolder = async (root = "/", name) => {
|
|
178
|
-
await this.r.post(`/servers/${this.id}/files/create-folder`, {
|
|
182
|
+
await this.r.post(`/servers/${this.id}/files/create-folder`, {
|
|
183
|
+
root,
|
|
184
|
+
name
|
|
185
|
+
});
|
|
179
186
|
};
|
|
180
187
|
chmod = async (root = "/", files) => {
|
|
181
188
|
await this.r.post(`/servers/${this.id}/files/chmod`, { root, files });
|
|
182
189
|
};
|
|
183
190
|
pullFromRemote = async (url, directory, filename, use_header = false, foreground = false) => {
|
|
184
|
-
await this.r.post(`/servers/${this.id}/files/pull`, {
|
|
191
|
+
await this.r.post(`/servers/${this.id}/files/pull`, {
|
|
192
|
+
url,
|
|
193
|
+
directory,
|
|
194
|
+
filename,
|
|
195
|
+
use_header,
|
|
196
|
+
foreground
|
|
197
|
+
});
|
|
185
198
|
};
|
|
186
199
|
uploadGetUrl = async () => {
|
|
187
200
|
const { data } = await this.r.get(`/servers/${this.id}/files/upload`);
|
|
@@ -189,10 +202,14 @@ var ServerFiles = class {
|
|
|
189
202
|
};
|
|
190
203
|
upload = async (file, root = "/") => {
|
|
191
204
|
const url = await this.uploadGetUrl();
|
|
192
|
-
await import_axios.default.post(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
205
|
+
await import_axios.default.post(
|
|
206
|
+
url,
|
|
207
|
+
{ files: file },
|
|
208
|
+
{
|
|
209
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
210
|
+
params: { directory: root }
|
|
211
|
+
}
|
|
212
|
+
);
|
|
196
213
|
};
|
|
197
214
|
};
|
|
198
215
|
|
|
@@ -235,7 +252,9 @@ var ScheduleControl = class {
|
|
|
235
252
|
await this.r.delete(`/servers/${this.id}/schedules/${this.sched_id}`);
|
|
236
253
|
};
|
|
237
254
|
execute = async () => {
|
|
238
|
-
await this.r.post(
|
|
255
|
+
await this.r.post(
|
|
256
|
+
`/servers/${this.id}/schedules/${this.sched_id}/execute`
|
|
257
|
+
);
|
|
239
258
|
};
|
|
240
259
|
tasks = {
|
|
241
260
|
create: async (opts) => {
|
|
@@ -243,11 +262,16 @@ var ScheduleControl = class {
|
|
|
243
262
|
return data.attributes;
|
|
244
263
|
},
|
|
245
264
|
update: async (task_id, opts) => {
|
|
246
|
-
const { data } = await this.r.post(
|
|
265
|
+
const { data } = await this.r.post(
|
|
266
|
+
`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`,
|
|
267
|
+
opts
|
|
268
|
+
);
|
|
247
269
|
return data.attributes;
|
|
248
270
|
},
|
|
249
271
|
delete: async (task_id) => {
|
|
250
|
-
await this.r.delete(
|
|
272
|
+
await this.r.delete(
|
|
273
|
+
`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`
|
|
274
|
+
);
|
|
251
275
|
}
|
|
252
276
|
};
|
|
253
277
|
};
|
|
@@ -277,7 +301,9 @@ var ServerAllocations = class {
|
|
|
277
301
|
return data.attributes;
|
|
278
302
|
};
|
|
279
303
|
unassign = async (alloc_id) => {
|
|
280
|
-
await this.r.delete(
|
|
304
|
+
await this.r.delete(
|
|
305
|
+
`/servers/${this.id}/network/allocations/${alloc_id}`
|
|
306
|
+
);
|
|
281
307
|
};
|
|
282
308
|
};
|
|
283
309
|
|
|
@@ -298,11 +324,16 @@ var ServerUsers = class {
|
|
|
298
324
|
return data.attributes;
|
|
299
325
|
};
|
|
300
326
|
info = async (user_uuid) => {
|
|
301
|
-
const { data } = await this.r.get(
|
|
327
|
+
const { data } = await this.r.get(
|
|
328
|
+
`/servers/${this.id}/users/${user_uuid}`
|
|
329
|
+
);
|
|
302
330
|
return data.attributes;
|
|
303
331
|
};
|
|
304
332
|
update = async (user_uuid, permissions) => {
|
|
305
|
-
const { data } = await this.r.put(
|
|
333
|
+
const { data } = await this.r.put(
|
|
334
|
+
`/servers/${this.id}/users/${user_uuid}`,
|
|
335
|
+
{ permissions }
|
|
336
|
+
);
|
|
306
337
|
return data.attributes;
|
|
307
338
|
};
|
|
308
339
|
delete = async (user_uuid) => {
|
|
@@ -322,9 +353,7 @@ var ServerBackups = class {
|
|
|
322
353
|
}
|
|
323
354
|
list = async (page = 1) => {
|
|
324
355
|
import_zod3.default.number().positive().parse(page);
|
|
325
|
-
const { data } = await this.r.get(`/servers/${this.id}/backups`, {
|
|
326
|
-
params: { page }
|
|
327
|
-
});
|
|
356
|
+
const { data } = await this.r.get(`/servers/${this.id}/backups`, { params: { page } });
|
|
328
357
|
return data.data.map((d) => d.attributes);
|
|
329
358
|
};
|
|
330
359
|
create = async (args) => {
|
|
@@ -346,20 +375,27 @@ var ServerBackups = class {
|
|
|
346
375
|
};
|
|
347
376
|
download = async (backup_uuid) => {
|
|
348
377
|
const url = await this.downloadGetUrl(backup_uuid);
|
|
349
|
-
const { data } = await import_axios2.default.get(url, {
|
|
378
|
+
const { data } = await import_axios2.default.get(url, {
|
|
379
|
+
responseType: "arraybuffer"
|
|
380
|
+
});
|
|
350
381
|
return data;
|
|
351
382
|
};
|
|
352
383
|
delete = async (backup_uuid) => {
|
|
353
384
|
await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
|
|
354
385
|
};
|
|
355
386
|
rename = async (backup_uuid, name) => {
|
|
356
|
-
await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, {
|
|
387
|
+
await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, {
|
|
388
|
+
name
|
|
389
|
+
});
|
|
357
390
|
};
|
|
358
391
|
toggleLock = async (backup_uuid) => {
|
|
359
392
|
await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/lock`);
|
|
360
393
|
};
|
|
361
394
|
restore = async (backup_uuid, truncate) => {
|
|
362
|
-
await this.r.post(
|
|
395
|
+
await this.r.post(
|
|
396
|
+
`/servers/${this.id}/backups/${backup_uuid}/restore`,
|
|
397
|
+
{ truncate }
|
|
398
|
+
);
|
|
363
399
|
};
|
|
364
400
|
};
|
|
365
401
|
|
|
@@ -399,7 +435,9 @@ var ServerSettings = class {
|
|
|
399
435
|
await this.r.post(`/servers/${this.id}/settings/rename`, { name });
|
|
400
436
|
};
|
|
401
437
|
updateDescription = async (description) => {
|
|
402
|
-
await this.r.post(`/servers/${this.id}/settings/description`, {
|
|
438
|
+
await this.r.post(`/servers/${this.id}/settings/description`, {
|
|
439
|
+
description
|
|
440
|
+
});
|
|
403
441
|
};
|
|
404
442
|
reinstall = async () => {
|
|
405
443
|
await this.r.post(`/servers/${this.id}/settings/reinstall`);
|
|
@@ -457,7 +495,9 @@ var ServerWebsocket = class {
|
|
|
457
495
|
return;
|
|
458
496
|
}
|
|
459
497
|
const socketUrl = await this.refreshCredentials();
|
|
460
|
-
this.socket = isBrowser ? new import_isomorphic_ws.default(socketUrl) : new import_isomorphic_ws.default(socketUrl, void 0, {
|
|
498
|
+
this.socket = isBrowser ? new import_isomorphic_ws.default(socketUrl) : new import_isomorphic_ws.default(socketUrl, void 0, {
|
|
499
|
+
origin: new URL(socketUrl).origin
|
|
500
|
+
});
|
|
461
501
|
await new Promise((resolve, reject) => {
|
|
462
502
|
const socket = this.socket;
|
|
463
503
|
if (!socket) {
|
|
@@ -474,13 +514,17 @@ var ServerWebsocket = class {
|
|
|
474
514
|
} catch (error) {
|
|
475
515
|
socket.onopen = null;
|
|
476
516
|
socket.onerror = null;
|
|
477
|
-
reject(
|
|
517
|
+
reject(
|
|
518
|
+
error instanceof Error ? error : new Error("Websocket authentication failed")
|
|
519
|
+
);
|
|
478
520
|
}
|
|
479
521
|
};
|
|
480
522
|
socket.onerror = (event) => {
|
|
481
523
|
socket.onopen = null;
|
|
482
524
|
socket.onerror = null;
|
|
483
|
-
reject(
|
|
525
|
+
reject(
|
|
526
|
+
event instanceof Error ? event : new Error("Websocket connection error")
|
|
527
|
+
);
|
|
484
528
|
};
|
|
485
529
|
});
|
|
486
530
|
if (resumable) {
|
|
@@ -526,9 +570,15 @@ var ServerWebsocket = class {
|
|
|
526
570
|
void this.handleIncomingMessage(event);
|
|
527
571
|
};
|
|
528
572
|
if (typeof this.socket.addEventListener === "function") {
|
|
529
|
-
this.socket.addEventListener(
|
|
573
|
+
this.socket.addEventListener(
|
|
574
|
+
"message",
|
|
575
|
+
handler
|
|
576
|
+
);
|
|
530
577
|
this.detachMessageListener = () => {
|
|
531
|
-
this.socket?.removeEventListener?.(
|
|
578
|
+
this.socket?.removeEventListener?.(
|
|
579
|
+
"message",
|
|
580
|
+
handler
|
|
581
|
+
);
|
|
532
582
|
};
|
|
533
583
|
} else {
|
|
534
584
|
const fallback = (data) => handler({ data });
|
|
@@ -638,7 +688,9 @@ var ServerWebsocket = class {
|
|
|
638
688
|
}
|
|
639
689
|
case "backup completed" /* BACKUP_COMPLETED */: {
|
|
640
690
|
try {
|
|
641
|
-
const payload = JSON.parse(
|
|
691
|
+
const payload = JSON.parse(
|
|
692
|
+
message.args[0]
|
|
693
|
+
);
|
|
642
694
|
this.emit("backup completed" /* BACKUP_COMPLETED */, payload);
|
|
643
695
|
} catch (error) {
|
|
644
696
|
if (this.debugLogging) {
|
|
@@ -720,7 +772,9 @@ var ServerWebsocket = class {
|
|
|
720
772
|
}
|
|
721
773
|
}
|
|
722
774
|
async refreshCredentials() {
|
|
723
|
-
const { data } = await this.r.get(
|
|
775
|
+
const { data } = await this.r.get(
|
|
776
|
+
`/servers/${this.serverId}/websocket`
|
|
777
|
+
);
|
|
724
778
|
this.currentToken = data.data.token;
|
|
725
779
|
return data.data.socket;
|
|
726
780
|
}
|
|
@@ -731,7 +785,9 @@ var ServerWebsocket = class {
|
|
|
731
785
|
if (!this.currentToken) {
|
|
732
786
|
throw new Error("Missing websocket token");
|
|
733
787
|
}
|
|
734
|
-
this.socket.send(
|
|
788
|
+
this.socket.send(
|
|
789
|
+
JSON.stringify({ event: "auth", args: [this.currentToken] })
|
|
790
|
+
);
|
|
735
791
|
}
|
|
736
792
|
disconnect() {
|
|
737
793
|
this.detachMessageListener?.();
|
|
@@ -750,7 +806,9 @@ var ServerWebsocket = class {
|
|
|
750
806
|
send(event, args) {
|
|
751
807
|
if (!this.socket) {
|
|
752
808
|
if (this.debugLogging) {
|
|
753
|
-
console.warn(
|
|
809
|
+
console.warn(
|
|
810
|
+
`Attempted to send "${event}" without an active websocket connection`
|
|
811
|
+
);
|
|
754
812
|
}
|
|
755
813
|
return;
|
|
756
814
|
}
|
|
@@ -831,12 +889,7 @@ var ServerActivity = class {
|
|
|
831
889
|
this.id = id;
|
|
832
890
|
}
|
|
833
891
|
list = async (page = 1, per_page = 25) => {
|
|
834
|
-
const { data } = await this.r.get(`/server/${this.id}/activity`, {
|
|
835
|
-
params: {
|
|
836
|
-
page,
|
|
837
|
-
per_page
|
|
838
|
-
}
|
|
839
|
-
});
|
|
892
|
+
const { data } = await this.r.get(`/server/${this.id}/activity`, { params: { page, per_page } });
|
|
840
893
|
return data.data.map((log) => log.attributes);
|
|
841
894
|
};
|
|
842
895
|
};
|
|
@@ -870,16 +923,19 @@ var ServerClient = class {
|
|
|
870
923
|
this.settings = new ServerSettings(requester, id);
|
|
871
924
|
}
|
|
872
925
|
info = async (include) => {
|
|
873
|
-
const { data } = await this.r.get(
|
|
874
|
-
|
|
875
|
-
|
|
926
|
+
const { data } = await this.r.get(
|
|
927
|
+
`/servers/${this.id}`,
|
|
928
|
+
{ params: { include: include?.join(",") } }
|
|
929
|
+
);
|
|
876
930
|
return data.attributes;
|
|
877
931
|
};
|
|
878
932
|
websocket = (stripColors = false) => {
|
|
879
933
|
return new ServerWebsocket(this.r, this.id, stripColors);
|
|
880
934
|
};
|
|
881
935
|
resources = async () => {
|
|
882
|
-
const { data } = await this.r.get(
|
|
936
|
+
const { data } = await this.r.get(
|
|
937
|
+
`/servers/${this.id}/resources`
|
|
938
|
+
);
|
|
883
939
|
return data.attributes;
|
|
884
940
|
};
|
|
885
941
|
command = async (command) => {
|
|
@@ -907,9 +963,7 @@ var Client = class {
|
|
|
907
963
|
};
|
|
908
964
|
listServers = async (type = "accessible", page = 1, per_page = 50, include) => {
|
|
909
965
|
import_zod5.default.number().positive().parse(page);
|
|
910
|
-
const { data } = await this.r.get("/", {
|
|
911
|
-
params: { type, page, include: include?.join(",") }
|
|
912
|
-
});
|
|
966
|
+
const { data } = await this.r.get("/", { params: { type, page, include: include?.join(",") } });
|
|
913
967
|
return data.data.map((s) => s.attributes);
|
|
914
968
|
};
|
|
915
969
|
server = (uuid) => new ServerClient(this.r, uuid);
|
|
@@ -1513,9 +1567,7 @@ var Users = class {
|
|
|
1513
1567
|
};
|
|
1514
1568
|
info = async (id, { include }) => {
|
|
1515
1569
|
import_zod7.default.number().positive().parse(id);
|
|
1516
|
-
const { data } = await this.r.get(`/users/${id}`, {
|
|
1517
|
-
params: { include: include?.join(",") }
|
|
1518
|
-
});
|
|
1570
|
+
const { data } = await this.r.get(`/users/${id}`, { params: { include: include?.join(",") } });
|
|
1519
1571
|
return data.attributes;
|
|
1520
1572
|
};
|
|
1521
1573
|
infoByExternal = async (external_id, { include }) => {
|
|
@@ -1589,11 +1641,7 @@ var NodesAllocations = class {
|
|
|
1589
1641
|
import_zod8.default.ipv4().parse(ip);
|
|
1590
1642
|
import_zod8.default.ipv4().or(import_zod8.default.url().max(255)).optional().parse(alias);
|
|
1591
1643
|
import_zod8.default.array(import_zod8.default.number()).or(import_zod8.default.string().regex(/\d+-\d+/)).parse(ports);
|
|
1592
|
-
await this.r.post(`/nodes/${this.id}/allocations`, {
|
|
1593
|
-
ip,
|
|
1594
|
-
ports,
|
|
1595
|
-
alias
|
|
1596
|
-
});
|
|
1644
|
+
await this.r.post(`/nodes/${this.id}/allocations`, { ip, ports, alias });
|
|
1597
1645
|
};
|
|
1598
1646
|
delete = async (alloc_id) => {
|
|
1599
1647
|
await this.r.delete(`/nodes/${this.id}/allocations/${alloc_id}`);
|
|
@@ -1609,9 +1657,7 @@ var Nodes = class {
|
|
|
1609
1657
|
}
|
|
1610
1658
|
list = async (include, page = 1) => {
|
|
1611
1659
|
import_zod9.default.number().positive().parse(page);
|
|
1612
|
-
const { data } = await this.r.get("/nodes", {
|
|
1613
|
-
params: { include: include?.join(","), page }
|
|
1614
|
-
});
|
|
1660
|
+
const { data } = await this.r.get("/nodes", { params: { include: include?.join(","), page } });
|
|
1615
1661
|
return data.data.map((s) => s.attributes);
|
|
1616
1662
|
};
|
|
1617
1663
|
listDeployable = async (filters, include, page = 1) => {
|
|
@@ -1631,25 +1677,34 @@ var Nodes = class {
|
|
|
1631
1677
|
};
|
|
1632
1678
|
info = async (id, include) => {
|
|
1633
1679
|
import_zod9.default.number().positive().parse(id);
|
|
1634
|
-
const { data } = await this.r.get(
|
|
1635
|
-
|
|
1636
|
-
|
|
1680
|
+
const { data } = await this.r.get(
|
|
1681
|
+
`/nodes/${id}`,
|
|
1682
|
+
{ params: { include: include?.join(",") } }
|
|
1683
|
+
);
|
|
1637
1684
|
return data.attributes;
|
|
1638
1685
|
};
|
|
1639
1686
|
create = async (node) => {
|
|
1640
1687
|
node = NodeCreateSchema.parse(node);
|
|
1641
|
-
const { data } = await this.r.post(
|
|
1688
|
+
const { data } = await this.r.post(
|
|
1689
|
+
"/nodes",
|
|
1690
|
+
node
|
|
1691
|
+
);
|
|
1642
1692
|
return data.attributes;
|
|
1643
1693
|
};
|
|
1644
1694
|
get_configuration = async (id) => {
|
|
1645
1695
|
import_zod9.default.number().positive().parse(id);
|
|
1646
|
-
const { data } = await this.r.get(
|
|
1696
|
+
const { data } = await this.r.get(
|
|
1697
|
+
`/nodes/${id}/configuration`
|
|
1698
|
+
);
|
|
1647
1699
|
return data;
|
|
1648
1700
|
};
|
|
1649
1701
|
update = async (id, node) => {
|
|
1650
1702
|
import_zod9.default.number().positive().parse(id);
|
|
1651
1703
|
node = NodeCreateSchema.parse(node);
|
|
1652
|
-
const { data } = await this.r.patch(
|
|
1704
|
+
const { data } = await this.r.patch(
|
|
1705
|
+
`/nodes/${id}`,
|
|
1706
|
+
node
|
|
1707
|
+
);
|
|
1653
1708
|
return data.attributes;
|
|
1654
1709
|
};
|
|
1655
1710
|
delete = async (id) => {
|
|
@@ -1710,7 +1765,9 @@ var ServersDatabases = class {
|
|
|
1710
1765
|
await this.r.delete(`/servers/${this.id}/databases/${database_id}`);
|
|
1711
1766
|
};
|
|
1712
1767
|
resetPassword = async (database_id) => {
|
|
1713
|
-
await this.r.post(
|
|
1768
|
+
await this.r.post(
|
|
1769
|
+
`/servers/${this.id}/databases/${database_id}/reset-password`
|
|
1770
|
+
);
|
|
1714
1771
|
};
|
|
1715
1772
|
};
|
|
1716
1773
|
|
|
@@ -1725,9 +1782,7 @@ var Servers = class {
|
|
|
1725
1782
|
this.databases = new ServersDatabases(this.r, this.id);
|
|
1726
1783
|
}
|
|
1727
1784
|
info = async (include) => {
|
|
1728
|
-
const { data } = await this.r.get(`/servers/${this.id}`, {
|
|
1729
|
-
params: { include: include?.join(",") }
|
|
1730
|
-
});
|
|
1785
|
+
const { data } = await this.r.get(`/servers/${this.id}`, { params: { include: include?.join(",") } });
|
|
1731
1786
|
return data.attributes;
|
|
1732
1787
|
};
|
|
1733
1788
|
delete = async (force = false) => {
|
|
@@ -1822,9 +1877,7 @@ var UpdateStartupSchema = CreateServerSchema.pick({
|
|
|
1822
1877
|
environment: true,
|
|
1823
1878
|
egg: true,
|
|
1824
1879
|
skip_scripts: true
|
|
1825
|
-
}).extend({
|
|
1826
|
-
image: import_zod11.default.string().optional()
|
|
1827
|
-
});
|
|
1880
|
+
}).extend({ image: import_zod11.default.string().optional() });
|
|
1828
1881
|
|
|
1829
1882
|
// src/api/application/database_hosts.ts
|
|
1830
1883
|
var import_zod12 = __toESM(require("zod"));
|
|
@@ -1834,9 +1887,7 @@ var DatabaseHosts = class {
|
|
|
1834
1887
|
this.r = r;
|
|
1835
1888
|
}
|
|
1836
1889
|
list = async (page = 1) => {
|
|
1837
|
-
const { data } = await this.r.get("/database-hosts", {
|
|
1838
|
-
params: { page }
|
|
1839
|
-
});
|
|
1890
|
+
const { data } = await this.r.get("/database-hosts", { params: { page } });
|
|
1840
1891
|
return data.data.map((d) => d.attributes);
|
|
1841
1892
|
};
|
|
1842
1893
|
info = async (id) => {
|
|
@@ -1846,7 +1897,10 @@ var DatabaseHosts = class {
|
|
|
1846
1897
|
// TODO: find out why API returns 500
|
|
1847
1898
|
create = async (opts) => {
|
|
1848
1899
|
opts = CreateDBHostSchema.parse(opts);
|
|
1849
|
-
await this.r.post(
|
|
1900
|
+
await this.r.post(
|
|
1901
|
+
"/database-hosts",
|
|
1902
|
+
opts
|
|
1903
|
+
).catch((e) => {
|
|
1850
1904
|
});
|
|
1851
1905
|
};
|
|
1852
1906
|
update = async (id, opts) => {
|
|
@@ -1875,13 +1929,13 @@ var Roles = class {
|
|
|
1875
1929
|
this.r = r;
|
|
1876
1930
|
}
|
|
1877
1931
|
list = async (page = 1) => {
|
|
1878
|
-
const { data } = await this.r.get(`/roles`, {
|
|
1879
|
-
params: { page }
|
|
1880
|
-
});
|
|
1932
|
+
const { data } = await this.r.get(`/roles`, { params: { page } });
|
|
1881
1933
|
return data.data.map((r) => r.attributes);
|
|
1882
1934
|
};
|
|
1883
1935
|
info = async (id) => {
|
|
1884
|
-
const { data } = await this.r.get(
|
|
1936
|
+
const { data } = await this.r.get(
|
|
1937
|
+
`/roles/${id}`
|
|
1938
|
+
);
|
|
1885
1939
|
return data.attributes;
|
|
1886
1940
|
};
|
|
1887
1941
|
create = async (opts) => {
|
|
@@ -1902,11 +1956,15 @@ var Eggs = class {
|
|
|
1902
1956
|
this.r = r;
|
|
1903
1957
|
}
|
|
1904
1958
|
list = async () => {
|
|
1905
|
-
const { data } = await this.r.get(
|
|
1959
|
+
const { data } = await this.r.get(
|
|
1960
|
+
"/eggs"
|
|
1961
|
+
);
|
|
1906
1962
|
return data.data.map((d) => d.attributes);
|
|
1907
1963
|
};
|
|
1908
1964
|
info = async (id) => {
|
|
1909
|
-
const { data } = await this.r.get(
|
|
1965
|
+
const { data } = await this.r.get(
|
|
1966
|
+
`/eggs/${id}`
|
|
1967
|
+
);
|
|
1910
1968
|
return data.attributes;
|
|
1911
1969
|
};
|
|
1912
1970
|
export = async (id, format) => {
|
|
@@ -1917,7 +1975,9 @@ var Eggs = class {
|
|
|
1917
1975
|
return data;
|
|
1918
1976
|
};
|
|
1919
1977
|
infoExportable = async (id) => {
|
|
1920
|
-
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1978
|
+
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1979
|
+
params: { format: "json" }
|
|
1980
|
+
});
|
|
1921
1981
|
return data;
|
|
1922
1982
|
};
|
|
1923
1983
|
};
|
|
@@ -1934,17 +1994,25 @@ var Mounts = class {
|
|
|
1934
1994
|
return data.data.map((d) => d.attributes);
|
|
1935
1995
|
};
|
|
1936
1996
|
info = async (id) => {
|
|
1937
|
-
const { data } = await this.r.get(
|
|
1997
|
+
const { data } = await this.r.get(
|
|
1998
|
+
`/mounts/${id}`
|
|
1999
|
+
);
|
|
1938
2000
|
return data.attributes;
|
|
1939
2001
|
};
|
|
1940
2002
|
create = async (opts) => {
|
|
1941
2003
|
opts = CreateMountSchema.parse(opts);
|
|
1942
|
-
const { data } = await this.r.post(
|
|
2004
|
+
const { data } = await this.r.post(
|
|
2005
|
+
"/mounts",
|
|
2006
|
+
opts
|
|
2007
|
+
);
|
|
1943
2008
|
return data.attributes;
|
|
1944
2009
|
};
|
|
1945
2010
|
update = async (id, opts) => {
|
|
1946
2011
|
opts = CreateMountSchema.parse(opts);
|
|
1947
|
-
const { data } = await this.r.patch(
|
|
2012
|
+
const { data } = await this.r.patch(
|
|
2013
|
+
`/mounts/${id}`,
|
|
2014
|
+
opts
|
|
2015
|
+
);
|
|
1948
2016
|
return data.attributes;
|
|
1949
2017
|
};
|
|
1950
2018
|
delete = async (id) => {
|
|
@@ -2011,9 +2079,7 @@ var Client2 = class {
|
|
|
2011
2079
|
return this.r;
|
|
2012
2080
|
}
|
|
2013
2081
|
listServers = async (search, page = 1) => {
|
|
2014
|
-
const { data } = await this.r.get("/servers", {
|
|
2015
|
-
params: { search, page }
|
|
2016
|
-
});
|
|
2082
|
+
const { data } = await this.r.get("/servers", { params: { search, page } });
|
|
2017
2083
|
return data.data.map((s) => s.attributes);
|
|
2018
2084
|
};
|
|
2019
2085
|
createServer = async (opts) => {
|
|
@@ -2056,17 +2122,17 @@ var Agent = class {
|
|
|
2056
2122
|
this.requester = import_axios3.default.create({
|
|
2057
2123
|
baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
|
|
2058
2124
|
timeout: 3e3,
|
|
2059
|
-
headers: {
|
|
2060
|
-
Authorization: `Bearer ${this.token}`
|
|
2061
|
-
}
|
|
2125
|
+
headers: { Authorization: `Bearer ${this.token}` }
|
|
2062
2126
|
});
|
|
2063
2127
|
this.requester.interceptors.response.use(void 0, (error) => {
|
|
2064
2128
|
if (error.response && error.response.status === 400) {
|
|
2065
|
-
return Promise.reject(
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2129
|
+
return Promise.reject(
|
|
2130
|
+
new PterodactylException(
|
|
2131
|
+
"Invalid request data",
|
|
2132
|
+
error.response.data,
|
|
2133
|
+
error.response.status
|
|
2134
|
+
)
|
|
2135
|
+
);
|
|
2070
2136
|
}
|
|
2071
2137
|
return Promise.reject(error);
|
|
2072
2138
|
});
|