@pelican.ts/sdk 0.4.7 → 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 -14
- package/dist/api/index.d.ts +5 -14
- package/dist/api/index.js +167 -114
- package/dist/api/index.mjs +167 -114
- package/dist/index.d.mts +2 -18
- package/dist/index.d.ts +2 -18
- package/dist/index.js +123 -92
- package/dist/index.mjs +123 -92
- 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 -35
- 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 -15
- 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
|
@@ -47,19 +47,6 @@ var Account = class {
|
|
|
47
47
|
await this.r.post(`/account/ssh-keys/remove`, { fingerprint });
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
twoFactor = {
|
|
51
|
-
info: async () => {
|
|
52
|
-
const { data } = await this.r.get("/account/two-factor");
|
|
53
|
-
return data;
|
|
54
|
-
},
|
|
55
|
-
enable: async (code) => {
|
|
56
|
-
const { data } = await this.r.post("/account/two-factor", { code });
|
|
57
|
-
return data;
|
|
58
|
-
},
|
|
59
|
-
disable: async (password) => {
|
|
60
|
-
await this.r.delete("/account/two-factor", { data: { password } });
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
50
|
};
|
|
64
51
|
|
|
65
52
|
// src/api/client/client.ts
|
|
@@ -104,29 +91,28 @@ var ServerFiles = class {
|
|
|
104
91
|
this.id = id;
|
|
105
92
|
}
|
|
106
93
|
list = async (path) => {
|
|
107
|
-
const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
|
|
108
|
-
params: { directory: path }
|
|
109
|
-
});
|
|
94
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/list`, { params: { directory: path } });
|
|
110
95
|
return data.data.map((r) => r.attributes);
|
|
111
96
|
};
|
|
112
97
|
/**
|
|
113
98
|
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
114
99
|
*/
|
|
115
100
|
contents = async (path) => {
|
|
116
|
-
const { data } = await this.r.get(
|
|
117
|
-
|
|
118
|
-
|
|
101
|
+
const { data } = await this.r.get(
|
|
102
|
+
`/servers/${this.id}/files/contents`,
|
|
103
|
+
{ params: { file: path } }
|
|
104
|
+
);
|
|
119
105
|
return data;
|
|
120
106
|
};
|
|
121
107
|
downloadGetUrl = async (path) => {
|
|
122
|
-
const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
|
|
123
|
-
params: { file: path }
|
|
124
|
-
});
|
|
108
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/download`, { params: { file: path } });
|
|
125
109
|
return data.attributes.url;
|
|
126
110
|
};
|
|
127
111
|
download = async (path) => {
|
|
128
112
|
const url = await this.downloadGetUrl(path);
|
|
129
|
-
const { data } = await axios.get(url, {
|
|
113
|
+
const { data } = await axios.get(url, {
|
|
114
|
+
responseType: "arraybuffer"
|
|
115
|
+
});
|
|
130
116
|
return data;
|
|
131
117
|
};
|
|
132
118
|
rename = async (root = "/", files) => {
|
|
@@ -141,7 +127,12 @@ var ServerFiles = class {
|
|
|
141
127
|
});
|
|
142
128
|
};
|
|
143
129
|
compress = async (root = "/", files, archive_name, extension) => {
|
|
144
|
-
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
|
+
});
|
|
145
136
|
return data.attributes;
|
|
146
137
|
};
|
|
147
138
|
decompress = async (root = "/", file) => {
|
|
@@ -151,13 +142,22 @@ var ServerFiles = class {
|
|
|
151
142
|
await this.r.post(`/servers/${this.id}/files/delete`, { root, files });
|
|
152
143
|
};
|
|
153
144
|
createFolder = async (root = "/", name) => {
|
|
154
|
-
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
|
+
});
|
|
155
149
|
};
|
|
156
150
|
chmod = async (root = "/", files) => {
|
|
157
151
|
await this.r.post(`/servers/${this.id}/files/chmod`, { root, files });
|
|
158
152
|
};
|
|
159
153
|
pullFromRemote = async (url, directory, filename, use_header = false, foreground = false) => {
|
|
160
|
-
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
|
+
});
|
|
161
161
|
};
|
|
162
162
|
uploadGetUrl = async () => {
|
|
163
163
|
const { data } = await this.r.get(`/servers/${this.id}/files/upload`);
|
|
@@ -165,10 +165,14 @@ var ServerFiles = class {
|
|
|
165
165
|
};
|
|
166
166
|
upload = async (file, root = "/") => {
|
|
167
167
|
const url = await this.uploadGetUrl();
|
|
168
|
-
await axios.post(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
await axios.post(
|
|
169
|
+
url,
|
|
170
|
+
{ files: file },
|
|
171
|
+
{
|
|
172
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
173
|
+
params: { directory: root }
|
|
174
|
+
}
|
|
175
|
+
);
|
|
172
176
|
};
|
|
173
177
|
};
|
|
174
178
|
|
|
@@ -211,7 +215,9 @@ var ScheduleControl = class {
|
|
|
211
215
|
await this.r.delete(`/servers/${this.id}/schedules/${this.sched_id}`);
|
|
212
216
|
};
|
|
213
217
|
execute = async () => {
|
|
214
|
-
await this.r.post(
|
|
218
|
+
await this.r.post(
|
|
219
|
+
`/servers/${this.id}/schedules/${this.sched_id}/execute`
|
|
220
|
+
);
|
|
215
221
|
};
|
|
216
222
|
tasks = {
|
|
217
223
|
create: async (opts) => {
|
|
@@ -219,11 +225,16 @@ var ScheduleControl = class {
|
|
|
219
225
|
return data.attributes;
|
|
220
226
|
},
|
|
221
227
|
update: async (task_id, opts) => {
|
|
222
|
-
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
|
+
);
|
|
223
232
|
return data.attributes;
|
|
224
233
|
},
|
|
225
234
|
delete: async (task_id) => {
|
|
226
|
-
await this.r.delete(
|
|
235
|
+
await this.r.delete(
|
|
236
|
+
`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`
|
|
237
|
+
);
|
|
227
238
|
}
|
|
228
239
|
};
|
|
229
240
|
};
|
|
@@ -253,7 +264,9 @@ var ServerAllocations = class {
|
|
|
253
264
|
return data.attributes;
|
|
254
265
|
};
|
|
255
266
|
unassign = async (alloc_id) => {
|
|
256
|
-
await this.r.delete(
|
|
267
|
+
await this.r.delete(
|
|
268
|
+
`/servers/${this.id}/network/allocations/${alloc_id}`
|
|
269
|
+
);
|
|
257
270
|
};
|
|
258
271
|
};
|
|
259
272
|
|
|
@@ -274,11 +287,16 @@ var ServerUsers = class {
|
|
|
274
287
|
return data.attributes;
|
|
275
288
|
};
|
|
276
289
|
info = async (user_uuid) => {
|
|
277
|
-
const { data } = await this.r.get(
|
|
290
|
+
const { data } = await this.r.get(
|
|
291
|
+
`/servers/${this.id}/users/${user_uuid}`
|
|
292
|
+
);
|
|
278
293
|
return data.attributes;
|
|
279
294
|
};
|
|
280
295
|
update = async (user_uuid, permissions) => {
|
|
281
|
-
const { data } = await this.r.put(
|
|
296
|
+
const { data } = await this.r.put(
|
|
297
|
+
`/servers/${this.id}/users/${user_uuid}`,
|
|
298
|
+
{ permissions }
|
|
299
|
+
);
|
|
282
300
|
return data.attributes;
|
|
283
301
|
};
|
|
284
302
|
delete = async (user_uuid) => {
|
|
@@ -298,9 +316,7 @@ var ServerBackups = class {
|
|
|
298
316
|
}
|
|
299
317
|
list = async (page = 1) => {
|
|
300
318
|
z3.number().positive().parse(page);
|
|
301
|
-
const { data } = await this.r.get(`/servers/${this.id}/backups`, {
|
|
302
|
-
params: { page }
|
|
303
|
-
});
|
|
319
|
+
const { data } = await this.r.get(`/servers/${this.id}/backups`, { params: { page } });
|
|
304
320
|
return data.data.map((d) => d.attributes);
|
|
305
321
|
};
|
|
306
322
|
create = async (args) => {
|
|
@@ -322,20 +338,27 @@ var ServerBackups = class {
|
|
|
322
338
|
};
|
|
323
339
|
download = async (backup_uuid) => {
|
|
324
340
|
const url = await this.downloadGetUrl(backup_uuid);
|
|
325
|
-
const { data } = await axios2.get(url, {
|
|
341
|
+
const { data } = await axios2.get(url, {
|
|
342
|
+
responseType: "arraybuffer"
|
|
343
|
+
});
|
|
326
344
|
return data;
|
|
327
345
|
};
|
|
328
346
|
delete = async (backup_uuid) => {
|
|
329
347
|
await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
|
|
330
348
|
};
|
|
331
349
|
rename = async (backup_uuid, name) => {
|
|
332
|
-
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
|
+
});
|
|
333
353
|
};
|
|
334
354
|
toggleLock = async (backup_uuid) => {
|
|
335
355
|
await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/lock`);
|
|
336
356
|
};
|
|
337
357
|
restore = async (backup_uuid, truncate) => {
|
|
338
|
-
await this.r.post(
|
|
358
|
+
await this.r.post(
|
|
359
|
+
`/servers/${this.id}/backups/${backup_uuid}/restore`,
|
|
360
|
+
{ truncate }
|
|
361
|
+
);
|
|
339
362
|
};
|
|
340
363
|
};
|
|
341
364
|
|
|
@@ -375,7 +398,9 @@ var ServerSettings = class {
|
|
|
375
398
|
await this.r.post(`/servers/${this.id}/settings/rename`, { name });
|
|
376
399
|
};
|
|
377
400
|
updateDescription = async (description) => {
|
|
378
|
-
await this.r.post(`/servers/${this.id}/settings/description`, {
|
|
401
|
+
await this.r.post(`/servers/${this.id}/settings/description`, {
|
|
402
|
+
description
|
|
403
|
+
});
|
|
379
404
|
};
|
|
380
405
|
reinstall = async () => {
|
|
381
406
|
await this.r.post(`/servers/${this.id}/settings/reinstall`);
|
|
@@ -433,7 +458,9 @@ var ServerWebsocket = class {
|
|
|
433
458
|
return;
|
|
434
459
|
}
|
|
435
460
|
const socketUrl = await this.refreshCredentials();
|
|
436
|
-
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
|
+
});
|
|
437
464
|
await new Promise((resolve, reject) => {
|
|
438
465
|
const socket = this.socket;
|
|
439
466
|
if (!socket) {
|
|
@@ -450,13 +477,17 @@ var ServerWebsocket = class {
|
|
|
450
477
|
} catch (error) {
|
|
451
478
|
socket.onopen = null;
|
|
452
479
|
socket.onerror = null;
|
|
453
|
-
reject(
|
|
480
|
+
reject(
|
|
481
|
+
error instanceof Error ? error : new Error("Websocket authentication failed")
|
|
482
|
+
);
|
|
454
483
|
}
|
|
455
484
|
};
|
|
456
485
|
socket.onerror = (event) => {
|
|
457
486
|
socket.onopen = null;
|
|
458
487
|
socket.onerror = null;
|
|
459
|
-
reject(
|
|
488
|
+
reject(
|
|
489
|
+
event instanceof Error ? event : new Error("Websocket connection error")
|
|
490
|
+
);
|
|
460
491
|
};
|
|
461
492
|
});
|
|
462
493
|
if (resumable) {
|
|
@@ -502,9 +533,15 @@ var ServerWebsocket = class {
|
|
|
502
533
|
void this.handleIncomingMessage(event);
|
|
503
534
|
};
|
|
504
535
|
if (typeof this.socket.addEventListener === "function") {
|
|
505
|
-
this.socket.addEventListener(
|
|
536
|
+
this.socket.addEventListener(
|
|
537
|
+
"message",
|
|
538
|
+
handler
|
|
539
|
+
);
|
|
506
540
|
this.detachMessageListener = () => {
|
|
507
|
-
this.socket?.removeEventListener?.(
|
|
541
|
+
this.socket?.removeEventListener?.(
|
|
542
|
+
"message",
|
|
543
|
+
handler
|
|
544
|
+
);
|
|
508
545
|
};
|
|
509
546
|
} else {
|
|
510
547
|
const fallback = (data) => handler({ data });
|
|
@@ -614,7 +651,9 @@ var ServerWebsocket = class {
|
|
|
614
651
|
}
|
|
615
652
|
case "backup completed" /* BACKUP_COMPLETED */: {
|
|
616
653
|
try {
|
|
617
|
-
const payload = JSON.parse(
|
|
654
|
+
const payload = JSON.parse(
|
|
655
|
+
message.args[0]
|
|
656
|
+
);
|
|
618
657
|
this.emit("backup completed" /* BACKUP_COMPLETED */, payload);
|
|
619
658
|
} catch (error) {
|
|
620
659
|
if (this.debugLogging) {
|
|
@@ -696,7 +735,9 @@ var ServerWebsocket = class {
|
|
|
696
735
|
}
|
|
697
736
|
}
|
|
698
737
|
async refreshCredentials() {
|
|
699
|
-
const { data } = await this.r.get(
|
|
738
|
+
const { data } = await this.r.get(
|
|
739
|
+
`/servers/${this.serverId}/websocket`
|
|
740
|
+
);
|
|
700
741
|
this.currentToken = data.data.token;
|
|
701
742
|
return data.data.socket;
|
|
702
743
|
}
|
|
@@ -707,7 +748,9 @@ var ServerWebsocket = class {
|
|
|
707
748
|
if (!this.currentToken) {
|
|
708
749
|
throw new Error("Missing websocket token");
|
|
709
750
|
}
|
|
710
|
-
this.socket.send(
|
|
751
|
+
this.socket.send(
|
|
752
|
+
JSON.stringify({ event: "auth", args: [this.currentToken] })
|
|
753
|
+
);
|
|
711
754
|
}
|
|
712
755
|
disconnect() {
|
|
713
756
|
this.detachMessageListener?.();
|
|
@@ -726,7 +769,9 @@ var ServerWebsocket = class {
|
|
|
726
769
|
send(event, args) {
|
|
727
770
|
if (!this.socket) {
|
|
728
771
|
if (this.debugLogging) {
|
|
729
|
-
console.warn(
|
|
772
|
+
console.warn(
|
|
773
|
+
`Attempted to send "${event}" without an active websocket connection`
|
|
774
|
+
);
|
|
730
775
|
}
|
|
731
776
|
return;
|
|
732
777
|
}
|
|
@@ -807,12 +852,7 @@ var ServerActivity = class {
|
|
|
807
852
|
this.id = id;
|
|
808
853
|
}
|
|
809
854
|
list = async (page = 1, per_page = 25) => {
|
|
810
|
-
const { data } = await this.r.get(`/server/${this.id}/activity`, {
|
|
811
|
-
params: {
|
|
812
|
-
page,
|
|
813
|
-
per_page
|
|
814
|
-
}
|
|
815
|
-
});
|
|
855
|
+
const { data } = await this.r.get(`/server/${this.id}/activity`, { params: { page, per_page } });
|
|
816
856
|
return data.data.map((log) => log.attributes);
|
|
817
857
|
};
|
|
818
858
|
};
|
|
@@ -846,16 +886,19 @@ var ServerClient = class {
|
|
|
846
886
|
this.settings = new ServerSettings(requester, id);
|
|
847
887
|
}
|
|
848
888
|
info = async (include) => {
|
|
849
|
-
const { data } = await this.r.get(
|
|
850
|
-
|
|
851
|
-
|
|
889
|
+
const { data } = await this.r.get(
|
|
890
|
+
`/servers/${this.id}`,
|
|
891
|
+
{ params: { include: include?.join(",") } }
|
|
892
|
+
);
|
|
852
893
|
return data.attributes;
|
|
853
894
|
};
|
|
854
895
|
websocket = (stripColors = false) => {
|
|
855
896
|
return new ServerWebsocket(this.r, this.id, stripColors);
|
|
856
897
|
};
|
|
857
898
|
resources = async () => {
|
|
858
|
-
const { data } = await this.r.get(
|
|
899
|
+
const { data } = await this.r.get(
|
|
900
|
+
`/servers/${this.id}/resources`
|
|
901
|
+
);
|
|
859
902
|
return data.attributes;
|
|
860
903
|
};
|
|
861
904
|
command = async (command) => {
|
|
@@ -883,9 +926,7 @@ var Client = class {
|
|
|
883
926
|
};
|
|
884
927
|
listServers = async (type = "accessible", page = 1, per_page = 50, include) => {
|
|
885
928
|
z5.number().positive().parse(page);
|
|
886
|
-
const { data } = await this.r.get("/", {
|
|
887
|
-
params: { type, page, include: include?.join(",") }
|
|
888
|
-
});
|
|
929
|
+
const { data } = await this.r.get("/", { params: { type, page, include: include?.join(",") } });
|
|
889
930
|
return data.data.map((s) => s.attributes);
|
|
890
931
|
};
|
|
891
932
|
server = (uuid) => new ServerClient(this.r, uuid);
|
|
@@ -1489,9 +1530,7 @@ var Users = class {
|
|
|
1489
1530
|
};
|
|
1490
1531
|
info = async (id, { include }) => {
|
|
1491
1532
|
z7.number().positive().parse(id);
|
|
1492
|
-
const { data } = await this.r.get(`/users/${id}`, {
|
|
1493
|
-
params: { include: include?.join(",") }
|
|
1494
|
-
});
|
|
1533
|
+
const { data } = await this.r.get(`/users/${id}`, { params: { include: include?.join(",") } });
|
|
1495
1534
|
return data.attributes;
|
|
1496
1535
|
};
|
|
1497
1536
|
infoByExternal = async (external_id, { include }) => {
|
|
@@ -1565,11 +1604,7 @@ var NodesAllocations = class {
|
|
|
1565
1604
|
z8.ipv4().parse(ip);
|
|
1566
1605
|
z8.ipv4().or(z8.url().max(255)).optional().parse(alias);
|
|
1567
1606
|
z8.array(z8.number()).or(z8.string().regex(/\d+-\d+/)).parse(ports);
|
|
1568
|
-
await this.r.post(`/nodes/${this.id}/allocations`, {
|
|
1569
|
-
ip,
|
|
1570
|
-
ports,
|
|
1571
|
-
alias
|
|
1572
|
-
});
|
|
1607
|
+
await this.r.post(`/nodes/${this.id}/allocations`, { ip, ports, alias });
|
|
1573
1608
|
};
|
|
1574
1609
|
delete = async (alloc_id) => {
|
|
1575
1610
|
await this.r.delete(`/nodes/${this.id}/allocations/${alloc_id}`);
|
|
@@ -1585,9 +1620,7 @@ var Nodes = class {
|
|
|
1585
1620
|
}
|
|
1586
1621
|
list = async (include, page = 1) => {
|
|
1587
1622
|
z9.number().positive().parse(page);
|
|
1588
|
-
const { data } = await this.r.get("/nodes", {
|
|
1589
|
-
params: { include: include?.join(","), page }
|
|
1590
|
-
});
|
|
1623
|
+
const { data } = await this.r.get("/nodes", { params: { include: include?.join(","), page } });
|
|
1591
1624
|
return data.data.map((s) => s.attributes);
|
|
1592
1625
|
};
|
|
1593
1626
|
listDeployable = async (filters, include, page = 1) => {
|
|
@@ -1607,25 +1640,34 @@ var Nodes = class {
|
|
|
1607
1640
|
};
|
|
1608
1641
|
info = async (id, include) => {
|
|
1609
1642
|
z9.number().positive().parse(id);
|
|
1610
|
-
const { data } = await this.r.get(
|
|
1611
|
-
|
|
1612
|
-
|
|
1643
|
+
const { data } = await this.r.get(
|
|
1644
|
+
`/nodes/${id}`,
|
|
1645
|
+
{ params: { include: include?.join(",") } }
|
|
1646
|
+
);
|
|
1613
1647
|
return data.attributes;
|
|
1614
1648
|
};
|
|
1615
1649
|
create = async (node) => {
|
|
1616
1650
|
node = NodeCreateSchema.parse(node);
|
|
1617
|
-
const { data } = await this.r.post(
|
|
1651
|
+
const { data } = await this.r.post(
|
|
1652
|
+
"/nodes",
|
|
1653
|
+
node
|
|
1654
|
+
);
|
|
1618
1655
|
return data.attributes;
|
|
1619
1656
|
};
|
|
1620
1657
|
get_configuration = async (id) => {
|
|
1621
1658
|
z9.number().positive().parse(id);
|
|
1622
|
-
const { data } = await this.r.get(
|
|
1659
|
+
const { data } = await this.r.get(
|
|
1660
|
+
`/nodes/${id}/configuration`
|
|
1661
|
+
);
|
|
1623
1662
|
return data;
|
|
1624
1663
|
};
|
|
1625
1664
|
update = async (id, node) => {
|
|
1626
1665
|
z9.number().positive().parse(id);
|
|
1627
1666
|
node = NodeCreateSchema.parse(node);
|
|
1628
|
-
const { data } = await this.r.patch(
|
|
1667
|
+
const { data } = await this.r.patch(
|
|
1668
|
+
`/nodes/${id}`,
|
|
1669
|
+
node
|
|
1670
|
+
);
|
|
1629
1671
|
return data.attributes;
|
|
1630
1672
|
};
|
|
1631
1673
|
delete = async (id) => {
|
|
@@ -1686,7 +1728,9 @@ var ServersDatabases = class {
|
|
|
1686
1728
|
await this.r.delete(`/servers/${this.id}/databases/${database_id}`);
|
|
1687
1729
|
};
|
|
1688
1730
|
resetPassword = async (database_id) => {
|
|
1689
|
-
await this.r.post(
|
|
1731
|
+
await this.r.post(
|
|
1732
|
+
`/servers/${this.id}/databases/${database_id}/reset-password`
|
|
1733
|
+
);
|
|
1690
1734
|
};
|
|
1691
1735
|
};
|
|
1692
1736
|
|
|
@@ -1701,9 +1745,7 @@ var Servers = class {
|
|
|
1701
1745
|
this.databases = new ServersDatabases(this.r, this.id);
|
|
1702
1746
|
}
|
|
1703
1747
|
info = async (include) => {
|
|
1704
|
-
const { data } = await this.r.get(`/servers/${this.id}`, {
|
|
1705
|
-
params: { include: include?.join(",") }
|
|
1706
|
-
});
|
|
1748
|
+
const { data } = await this.r.get(`/servers/${this.id}`, { params: { include: include?.join(",") } });
|
|
1707
1749
|
return data.attributes;
|
|
1708
1750
|
};
|
|
1709
1751
|
delete = async (force = false) => {
|
|
@@ -1798,9 +1840,7 @@ var UpdateStartupSchema = CreateServerSchema.pick({
|
|
|
1798
1840
|
environment: true,
|
|
1799
1841
|
egg: true,
|
|
1800
1842
|
skip_scripts: true
|
|
1801
|
-
}).extend({
|
|
1802
|
-
image: z11.string().optional()
|
|
1803
|
-
});
|
|
1843
|
+
}).extend({ image: z11.string().optional() });
|
|
1804
1844
|
|
|
1805
1845
|
// src/api/application/database_hosts.ts
|
|
1806
1846
|
import z12 from "zod";
|
|
@@ -1810,9 +1850,7 @@ var DatabaseHosts = class {
|
|
|
1810
1850
|
this.r = r;
|
|
1811
1851
|
}
|
|
1812
1852
|
list = async (page = 1) => {
|
|
1813
|
-
const { data } = await this.r.get("/database-hosts", {
|
|
1814
|
-
params: { page }
|
|
1815
|
-
});
|
|
1853
|
+
const { data } = await this.r.get("/database-hosts", { params: { page } });
|
|
1816
1854
|
return data.data.map((d) => d.attributes);
|
|
1817
1855
|
};
|
|
1818
1856
|
info = async (id) => {
|
|
@@ -1822,7 +1860,10 @@ var DatabaseHosts = class {
|
|
|
1822
1860
|
// TODO: find out why API returns 500
|
|
1823
1861
|
create = async (opts) => {
|
|
1824
1862
|
opts = CreateDBHostSchema.parse(opts);
|
|
1825
|
-
await this.r.post(
|
|
1863
|
+
await this.r.post(
|
|
1864
|
+
"/database-hosts",
|
|
1865
|
+
opts
|
|
1866
|
+
).catch((e) => {
|
|
1826
1867
|
});
|
|
1827
1868
|
};
|
|
1828
1869
|
update = async (id, opts) => {
|
|
@@ -1851,13 +1892,13 @@ var Roles = class {
|
|
|
1851
1892
|
this.r = r;
|
|
1852
1893
|
}
|
|
1853
1894
|
list = async (page = 1) => {
|
|
1854
|
-
const { data } = await this.r.get(`/roles`, {
|
|
1855
|
-
params: { page }
|
|
1856
|
-
});
|
|
1895
|
+
const { data } = await this.r.get(`/roles`, { params: { page } });
|
|
1857
1896
|
return data.data.map((r) => r.attributes);
|
|
1858
1897
|
};
|
|
1859
1898
|
info = async (id) => {
|
|
1860
|
-
const { data } = await this.r.get(
|
|
1899
|
+
const { data } = await this.r.get(
|
|
1900
|
+
`/roles/${id}`
|
|
1901
|
+
);
|
|
1861
1902
|
return data.attributes;
|
|
1862
1903
|
};
|
|
1863
1904
|
create = async (opts) => {
|
|
@@ -1878,11 +1919,15 @@ var Eggs = class {
|
|
|
1878
1919
|
this.r = r;
|
|
1879
1920
|
}
|
|
1880
1921
|
list = async () => {
|
|
1881
|
-
const { data } = await this.r.get(
|
|
1922
|
+
const { data } = await this.r.get(
|
|
1923
|
+
"/eggs"
|
|
1924
|
+
);
|
|
1882
1925
|
return data.data.map((d) => d.attributes);
|
|
1883
1926
|
};
|
|
1884
1927
|
info = async (id) => {
|
|
1885
|
-
const { data } = await this.r.get(
|
|
1928
|
+
const { data } = await this.r.get(
|
|
1929
|
+
`/eggs/${id}`
|
|
1930
|
+
);
|
|
1886
1931
|
return data.attributes;
|
|
1887
1932
|
};
|
|
1888
1933
|
export = async (id, format) => {
|
|
@@ -1893,7 +1938,9 @@ var Eggs = class {
|
|
|
1893
1938
|
return data;
|
|
1894
1939
|
};
|
|
1895
1940
|
infoExportable = async (id) => {
|
|
1896
|
-
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1941
|
+
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1942
|
+
params: { format: "json" }
|
|
1943
|
+
});
|
|
1897
1944
|
return data;
|
|
1898
1945
|
};
|
|
1899
1946
|
};
|
|
@@ -1910,17 +1957,25 @@ var Mounts = class {
|
|
|
1910
1957
|
return data.data.map((d) => d.attributes);
|
|
1911
1958
|
};
|
|
1912
1959
|
info = async (id) => {
|
|
1913
|
-
const { data } = await this.r.get(
|
|
1960
|
+
const { data } = await this.r.get(
|
|
1961
|
+
`/mounts/${id}`
|
|
1962
|
+
);
|
|
1914
1963
|
return data.attributes;
|
|
1915
1964
|
};
|
|
1916
1965
|
create = async (opts) => {
|
|
1917
1966
|
opts = CreateMountSchema.parse(opts);
|
|
1918
|
-
const { data } = await this.r.post(
|
|
1967
|
+
const { data } = await this.r.post(
|
|
1968
|
+
"/mounts",
|
|
1969
|
+
opts
|
|
1970
|
+
);
|
|
1919
1971
|
return data.attributes;
|
|
1920
1972
|
};
|
|
1921
1973
|
update = async (id, opts) => {
|
|
1922
1974
|
opts = CreateMountSchema.parse(opts);
|
|
1923
|
-
const { data } = await this.r.patch(
|
|
1975
|
+
const { data } = await this.r.patch(
|
|
1976
|
+
`/mounts/${id}`,
|
|
1977
|
+
opts
|
|
1978
|
+
);
|
|
1924
1979
|
return data.attributes;
|
|
1925
1980
|
};
|
|
1926
1981
|
delete = async (id) => {
|
|
@@ -1987,9 +2042,7 @@ var Client2 = class {
|
|
|
1987
2042
|
return this.r;
|
|
1988
2043
|
}
|
|
1989
2044
|
listServers = async (search, page = 1) => {
|
|
1990
|
-
const { data } = await this.r.get("/servers", {
|
|
1991
|
-
params: { search, page }
|
|
1992
|
-
});
|
|
2045
|
+
const { data } = await this.r.get("/servers", { params: { search, page } });
|
|
1993
2046
|
return data.data.map((s) => s.attributes);
|
|
1994
2047
|
};
|
|
1995
2048
|
createServer = async (opts) => {
|
|
@@ -2032,17 +2085,17 @@ var Agent = class {
|
|
|
2032
2085
|
this.requester = axios3.create({
|
|
2033
2086
|
baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
|
|
2034
2087
|
timeout: 3e3,
|
|
2035
|
-
headers: {
|
|
2036
|
-
Authorization: `Bearer ${this.token}`
|
|
2037
|
-
}
|
|
2088
|
+
headers: { Authorization: `Bearer ${this.token}` }
|
|
2038
2089
|
});
|
|
2039
2090
|
this.requester.interceptors.response.use(void 0, (error) => {
|
|
2040
2091
|
if (error.response && error.response.status === 400) {
|
|
2041
|
-
return Promise.reject(
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2092
|
+
return Promise.reject(
|
|
2093
|
+
new PterodactylException(
|
|
2094
|
+
"Invalid request data",
|
|
2095
|
+
error.response.data,
|
|
2096
|
+
error.response.status
|
|
2097
|
+
)
|
|
2098
|
+
);
|
|
2046
2099
|
}
|
|
2047
2100
|
return Promise.reject(error);
|
|
2048
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;
|
|
@@ -370,22 +370,13 @@ declare class Account$1 {
|
|
|
370
370
|
create: (name: string, public_key: string) => Promise<SSHKey>;
|
|
371
371
|
delete: (fingerprint: string) => Promise<void>;
|
|
372
372
|
};
|
|
373
|
-
twoFactor: {
|
|
374
|
-
info: () => Promise<{
|
|
375
|
-
image_url_data: string;
|
|
376
|
-
}>;
|
|
377
|
-
enable: (code: string) => Promise<{
|
|
378
|
-
tokens: string[];
|
|
379
|
-
}>;
|
|
380
|
-
disable: (password: string) => Promise<void>;
|
|
381
|
-
};
|
|
382
373
|
}
|
|
383
374
|
|
|
384
375
|
declare class ServerDatabases {
|
|
385
376
|
private readonly r;
|
|
386
377
|
private readonly id;
|
|
387
378
|
constructor(requester: AxiosInstance, id: string);
|
|
388
|
-
list: (include?:
|
|
379
|
+
list: (include?: "password"[], page?: number) => Promise<ServerDatabase$1[]>;
|
|
389
380
|
create: (database: string, remote: string) => Promise<ServerDatabase$1>;
|
|
390
381
|
rotatePassword: (database_id: string) => Promise<ServerDatabase$1>;
|
|
391
382
|
delete: (database_id: string) => Promise<void>;
|
|
@@ -579,13 +570,6 @@ declare class Account {
|
|
|
579
570
|
listSshKeys: () => Promise<SSHKey[]>;
|
|
580
571
|
createSshKey: (name: string, public_key: string) => Promise<SSHKey>;
|
|
581
572
|
deleteSshKey: (fingerprint: string) => Promise<void>;
|
|
582
|
-
get2faQR: () => Promise<{
|
|
583
|
-
image_url_data: string;
|
|
584
|
-
}>;
|
|
585
|
-
enable2fa: (code: string) => Promise<{
|
|
586
|
-
tokens: string[];
|
|
587
|
-
}>;
|
|
588
|
-
disable2fa: (password: string) => Promise<void>;
|
|
589
573
|
}
|
|
590
574
|
|
|
591
575
|
declare class ServerAllocation {
|