@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/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;
|
|
@@ -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 {
|
package/dist/index.js
CHANGED
|
@@ -92,19 +92,6 @@ var Account = class {
|
|
|
92
92
|
await this.r.post(`/account/ssh-keys/remove`, { fingerprint });
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
twoFactor = {
|
|
96
|
-
info: async () => {
|
|
97
|
-
const { data } = await this.r.get("/account/two-factor");
|
|
98
|
-
return data;
|
|
99
|
-
},
|
|
100
|
-
enable: async (code) => {
|
|
101
|
-
const { data } = await this.r.post("/account/two-factor", { code });
|
|
102
|
-
return data;
|
|
103
|
-
},
|
|
104
|
-
disable: async (password) => {
|
|
105
|
-
await this.r.delete("/account/two-factor", { data: { password } });
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
95
|
};
|
|
109
96
|
|
|
110
97
|
// src/api/client/client.ts
|
|
@@ -149,29 +136,28 @@ var ServerFiles = class {
|
|
|
149
136
|
this.id = id;
|
|
150
137
|
}
|
|
151
138
|
list = async (path2) => {
|
|
152
|
-
const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
|
|
153
|
-
params: { directory: path2 }
|
|
154
|
-
});
|
|
139
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/list`, { params: { directory: path2 } });
|
|
155
140
|
return data.data.map((r) => r.attributes);
|
|
156
141
|
};
|
|
157
142
|
/**
|
|
158
143
|
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
159
144
|
*/
|
|
160
145
|
contents = async (path2) => {
|
|
161
|
-
const { data } = await this.r.get(
|
|
162
|
-
|
|
163
|
-
|
|
146
|
+
const { data } = await this.r.get(
|
|
147
|
+
`/servers/${this.id}/files/contents`,
|
|
148
|
+
{ params: { file: path2 } }
|
|
149
|
+
);
|
|
164
150
|
return data;
|
|
165
151
|
};
|
|
166
152
|
downloadGetUrl = async (path2) => {
|
|
167
|
-
const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
|
|
168
|
-
params: { file: path2 }
|
|
169
|
-
});
|
|
153
|
+
const { data } = await this.r.get(`/servers/${this.id}/files/download`, { params: { file: path2 } });
|
|
170
154
|
return data.attributes.url;
|
|
171
155
|
};
|
|
172
156
|
download = async (path2) => {
|
|
173
157
|
const url = await this.downloadGetUrl(path2);
|
|
174
|
-
const { data } = await import_axios.default.get(url, {
|
|
158
|
+
const { data } = await import_axios.default.get(url, {
|
|
159
|
+
responseType: "arraybuffer"
|
|
160
|
+
});
|
|
175
161
|
return data;
|
|
176
162
|
};
|
|
177
163
|
rename = async (root = "/", files) => {
|
|
@@ -186,7 +172,12 @@ var ServerFiles = class {
|
|
|
186
172
|
});
|
|
187
173
|
};
|
|
188
174
|
compress = async (root = "/", files, archive_name, extension) => {
|
|
189
|
-
const { data } = await this.r.post(`/servers/${this.id}/files/compress`, {
|
|
175
|
+
const { data } = await this.r.post(`/servers/${this.id}/files/compress`, {
|
|
176
|
+
root,
|
|
177
|
+
files,
|
|
178
|
+
archive_name,
|
|
179
|
+
extension
|
|
180
|
+
});
|
|
190
181
|
return data.attributes;
|
|
191
182
|
};
|
|
192
183
|
decompress = async (root = "/", file) => {
|
|
@@ -196,13 +187,22 @@ var ServerFiles = class {
|
|
|
196
187
|
await this.r.post(`/servers/${this.id}/files/delete`, { root, files });
|
|
197
188
|
};
|
|
198
189
|
createFolder = async (root = "/", name) => {
|
|
199
|
-
await this.r.post(`/servers/${this.id}/files/create-folder`, {
|
|
190
|
+
await this.r.post(`/servers/${this.id}/files/create-folder`, {
|
|
191
|
+
root,
|
|
192
|
+
name
|
|
193
|
+
});
|
|
200
194
|
};
|
|
201
195
|
chmod = async (root = "/", files) => {
|
|
202
196
|
await this.r.post(`/servers/${this.id}/files/chmod`, { root, files });
|
|
203
197
|
};
|
|
204
198
|
pullFromRemote = async (url, directory, filename, use_header = false, foreground = false) => {
|
|
205
|
-
await this.r.post(`/servers/${this.id}/files/pull`, {
|
|
199
|
+
await this.r.post(`/servers/${this.id}/files/pull`, {
|
|
200
|
+
url,
|
|
201
|
+
directory,
|
|
202
|
+
filename,
|
|
203
|
+
use_header,
|
|
204
|
+
foreground
|
|
205
|
+
});
|
|
206
206
|
};
|
|
207
207
|
uploadGetUrl = async () => {
|
|
208
208
|
const { data } = await this.r.get(`/servers/${this.id}/files/upload`);
|
|
@@ -210,10 +210,14 @@ var ServerFiles = class {
|
|
|
210
210
|
};
|
|
211
211
|
upload = async (file, root = "/") => {
|
|
212
212
|
const url = await this.uploadGetUrl();
|
|
213
|
-
await import_axios.default.post(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
await import_axios.default.post(
|
|
214
|
+
url,
|
|
215
|
+
{ files: file },
|
|
216
|
+
{
|
|
217
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
218
|
+
params: { directory: root }
|
|
219
|
+
}
|
|
220
|
+
);
|
|
217
221
|
};
|
|
218
222
|
};
|
|
219
223
|
|
|
@@ -256,7 +260,9 @@ var ScheduleControl = class {
|
|
|
256
260
|
await this.r.delete(`/servers/${this.id}/schedules/${this.sched_id}`);
|
|
257
261
|
};
|
|
258
262
|
execute = async () => {
|
|
259
|
-
await this.r.post(
|
|
263
|
+
await this.r.post(
|
|
264
|
+
`/servers/${this.id}/schedules/${this.sched_id}/execute`
|
|
265
|
+
);
|
|
260
266
|
};
|
|
261
267
|
tasks = {
|
|
262
268
|
create: async (opts) => {
|
|
@@ -264,11 +270,16 @@ var ScheduleControl = class {
|
|
|
264
270
|
return data.attributes;
|
|
265
271
|
},
|
|
266
272
|
update: async (task_id, opts) => {
|
|
267
|
-
const { data } = await this.r.post(
|
|
273
|
+
const { data } = await this.r.post(
|
|
274
|
+
`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`,
|
|
275
|
+
opts
|
|
276
|
+
);
|
|
268
277
|
return data.attributes;
|
|
269
278
|
},
|
|
270
279
|
delete: async (task_id) => {
|
|
271
|
-
await this.r.delete(
|
|
280
|
+
await this.r.delete(
|
|
281
|
+
`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`
|
|
282
|
+
);
|
|
272
283
|
}
|
|
273
284
|
};
|
|
274
285
|
};
|
|
@@ -298,7 +309,9 @@ var ServerAllocations = class {
|
|
|
298
309
|
return data.attributes;
|
|
299
310
|
};
|
|
300
311
|
unassign = async (alloc_id) => {
|
|
301
|
-
await this.r.delete(
|
|
312
|
+
await this.r.delete(
|
|
313
|
+
`/servers/${this.id}/network/allocations/${alloc_id}`
|
|
314
|
+
);
|
|
302
315
|
};
|
|
303
316
|
};
|
|
304
317
|
|
|
@@ -319,11 +332,16 @@ var ServerUsers = class {
|
|
|
319
332
|
return data.attributes;
|
|
320
333
|
};
|
|
321
334
|
info = async (user_uuid) => {
|
|
322
|
-
const { data } = await this.r.get(
|
|
335
|
+
const { data } = await this.r.get(
|
|
336
|
+
`/servers/${this.id}/users/${user_uuid}`
|
|
337
|
+
);
|
|
323
338
|
return data.attributes;
|
|
324
339
|
};
|
|
325
340
|
update = async (user_uuid, permissions) => {
|
|
326
|
-
const { data } = await this.r.put(
|
|
341
|
+
const { data } = await this.r.put(
|
|
342
|
+
`/servers/${this.id}/users/${user_uuid}`,
|
|
343
|
+
{ permissions }
|
|
344
|
+
);
|
|
327
345
|
return data.attributes;
|
|
328
346
|
};
|
|
329
347
|
delete = async (user_uuid) => {
|
|
@@ -343,9 +361,7 @@ var ServerBackups = class {
|
|
|
343
361
|
}
|
|
344
362
|
list = async (page = 1) => {
|
|
345
363
|
import_zod3.default.number().positive().parse(page);
|
|
346
|
-
const { data } = await this.r.get(`/servers/${this.id}/backups`, {
|
|
347
|
-
params: { page }
|
|
348
|
-
});
|
|
364
|
+
const { data } = await this.r.get(`/servers/${this.id}/backups`, { params: { page } });
|
|
349
365
|
return data.data.map((d) => d.attributes);
|
|
350
366
|
};
|
|
351
367
|
create = async (args) => {
|
|
@@ -367,20 +383,27 @@ var ServerBackups = class {
|
|
|
367
383
|
};
|
|
368
384
|
download = async (backup_uuid) => {
|
|
369
385
|
const url = await this.downloadGetUrl(backup_uuid);
|
|
370
|
-
const { data } = await import_axios2.default.get(url, {
|
|
386
|
+
const { data } = await import_axios2.default.get(url, {
|
|
387
|
+
responseType: "arraybuffer"
|
|
388
|
+
});
|
|
371
389
|
return data;
|
|
372
390
|
};
|
|
373
391
|
delete = async (backup_uuid) => {
|
|
374
392
|
await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
|
|
375
393
|
};
|
|
376
394
|
rename = async (backup_uuid, name) => {
|
|
377
|
-
await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, {
|
|
395
|
+
await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, {
|
|
396
|
+
name
|
|
397
|
+
});
|
|
378
398
|
};
|
|
379
399
|
toggleLock = async (backup_uuid) => {
|
|
380
400
|
await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/lock`);
|
|
381
401
|
};
|
|
382
402
|
restore = async (backup_uuid, truncate) => {
|
|
383
|
-
await this.r.post(
|
|
403
|
+
await this.r.post(
|
|
404
|
+
`/servers/${this.id}/backups/${backup_uuid}/restore`,
|
|
405
|
+
{ truncate }
|
|
406
|
+
);
|
|
384
407
|
};
|
|
385
408
|
};
|
|
386
409
|
|
|
@@ -420,7 +443,9 @@ var ServerSettings = class {
|
|
|
420
443
|
await this.r.post(`/servers/${this.id}/settings/rename`, { name });
|
|
421
444
|
};
|
|
422
445
|
updateDescription = async (description) => {
|
|
423
|
-
await this.r.post(`/servers/${this.id}/settings/description`, {
|
|
446
|
+
await this.r.post(`/servers/${this.id}/settings/description`, {
|
|
447
|
+
description
|
|
448
|
+
});
|
|
424
449
|
};
|
|
425
450
|
reinstall = async () => {
|
|
426
451
|
await this.r.post(`/servers/${this.id}/settings/reinstall`);
|
|
@@ -478,7 +503,9 @@ var ServerWebsocket = class {
|
|
|
478
503
|
return;
|
|
479
504
|
}
|
|
480
505
|
const socketUrl = await this.refreshCredentials();
|
|
481
|
-
this.socket = isBrowser ? new import_isomorphic_ws.default(socketUrl) : new import_isomorphic_ws.default(socketUrl, void 0, {
|
|
506
|
+
this.socket = isBrowser ? new import_isomorphic_ws.default(socketUrl) : new import_isomorphic_ws.default(socketUrl, void 0, {
|
|
507
|
+
origin: new URL(socketUrl).origin
|
|
508
|
+
});
|
|
482
509
|
await new Promise((resolve, reject) => {
|
|
483
510
|
const socket = this.socket;
|
|
484
511
|
if (!socket) {
|
|
@@ -495,13 +522,17 @@ var ServerWebsocket = class {
|
|
|
495
522
|
} catch (error) {
|
|
496
523
|
socket.onopen = null;
|
|
497
524
|
socket.onerror = null;
|
|
498
|
-
reject(
|
|
525
|
+
reject(
|
|
526
|
+
error instanceof Error ? error : new Error("Websocket authentication failed")
|
|
527
|
+
);
|
|
499
528
|
}
|
|
500
529
|
};
|
|
501
530
|
socket.onerror = (event) => {
|
|
502
531
|
socket.onopen = null;
|
|
503
532
|
socket.onerror = null;
|
|
504
|
-
reject(
|
|
533
|
+
reject(
|
|
534
|
+
event instanceof Error ? event : new Error("Websocket connection error")
|
|
535
|
+
);
|
|
505
536
|
};
|
|
506
537
|
});
|
|
507
538
|
if (resumable) {
|
|
@@ -547,9 +578,15 @@ var ServerWebsocket = class {
|
|
|
547
578
|
void this.handleIncomingMessage(event);
|
|
548
579
|
};
|
|
549
580
|
if (typeof this.socket.addEventListener === "function") {
|
|
550
|
-
this.socket.addEventListener(
|
|
581
|
+
this.socket.addEventListener(
|
|
582
|
+
"message",
|
|
583
|
+
handler
|
|
584
|
+
);
|
|
551
585
|
this.detachMessageListener = () => {
|
|
552
|
-
this.socket?.removeEventListener?.(
|
|
586
|
+
this.socket?.removeEventListener?.(
|
|
587
|
+
"message",
|
|
588
|
+
handler
|
|
589
|
+
);
|
|
553
590
|
};
|
|
554
591
|
} else {
|
|
555
592
|
const fallback = (data) => handler({ data });
|
|
@@ -659,7 +696,9 @@ var ServerWebsocket = class {
|
|
|
659
696
|
}
|
|
660
697
|
case "backup completed" /* BACKUP_COMPLETED */: {
|
|
661
698
|
try {
|
|
662
|
-
const payload = JSON.parse(
|
|
699
|
+
const payload = JSON.parse(
|
|
700
|
+
message.args[0]
|
|
701
|
+
);
|
|
663
702
|
this.emit("backup completed" /* BACKUP_COMPLETED */, payload);
|
|
664
703
|
} catch (error) {
|
|
665
704
|
if (this.debugLogging) {
|
|
@@ -741,7 +780,9 @@ var ServerWebsocket = class {
|
|
|
741
780
|
}
|
|
742
781
|
}
|
|
743
782
|
async refreshCredentials() {
|
|
744
|
-
const { data } = await this.r.get(
|
|
783
|
+
const { data } = await this.r.get(
|
|
784
|
+
`/servers/${this.serverId}/websocket`
|
|
785
|
+
);
|
|
745
786
|
this.currentToken = data.data.token;
|
|
746
787
|
return data.data.socket;
|
|
747
788
|
}
|
|
@@ -752,7 +793,9 @@ var ServerWebsocket = class {
|
|
|
752
793
|
if (!this.currentToken) {
|
|
753
794
|
throw new Error("Missing websocket token");
|
|
754
795
|
}
|
|
755
|
-
this.socket.send(
|
|
796
|
+
this.socket.send(
|
|
797
|
+
JSON.stringify({ event: "auth", args: [this.currentToken] })
|
|
798
|
+
);
|
|
756
799
|
}
|
|
757
800
|
disconnect() {
|
|
758
801
|
this.detachMessageListener?.();
|
|
@@ -771,7 +814,9 @@ var ServerWebsocket = class {
|
|
|
771
814
|
send(event, args) {
|
|
772
815
|
if (!this.socket) {
|
|
773
816
|
if (this.debugLogging) {
|
|
774
|
-
console.warn(
|
|
817
|
+
console.warn(
|
|
818
|
+
`Attempted to send "${event}" without an active websocket connection`
|
|
819
|
+
);
|
|
775
820
|
}
|
|
776
821
|
return;
|
|
777
822
|
}
|
|
@@ -852,12 +897,7 @@ var ServerActivity = class {
|
|
|
852
897
|
this.id = id;
|
|
853
898
|
}
|
|
854
899
|
list = async (page = 1, per_page = 25) => {
|
|
855
|
-
const { data } = await this.r.get(`/server/${this.id}/activity`, {
|
|
856
|
-
params: {
|
|
857
|
-
page,
|
|
858
|
-
per_page
|
|
859
|
-
}
|
|
860
|
-
});
|
|
900
|
+
const { data } = await this.r.get(`/server/${this.id}/activity`, { params: { page, per_page } });
|
|
861
901
|
return data.data.map((log) => log.attributes);
|
|
862
902
|
};
|
|
863
903
|
};
|
|
@@ -891,16 +931,19 @@ var ServerClient = class {
|
|
|
891
931
|
this.settings = new ServerSettings(requester, id);
|
|
892
932
|
}
|
|
893
933
|
info = async (include) => {
|
|
894
|
-
const { data } = await this.r.get(
|
|
895
|
-
|
|
896
|
-
|
|
934
|
+
const { data } = await this.r.get(
|
|
935
|
+
`/servers/${this.id}`,
|
|
936
|
+
{ params: { include: include?.join(",") } }
|
|
937
|
+
);
|
|
897
938
|
return data.attributes;
|
|
898
939
|
};
|
|
899
940
|
websocket = (stripColors = false) => {
|
|
900
941
|
return new ServerWebsocket(this.r, this.id, stripColors);
|
|
901
942
|
};
|
|
902
943
|
resources = async () => {
|
|
903
|
-
const { data } = await this.r.get(
|
|
944
|
+
const { data } = await this.r.get(
|
|
945
|
+
`/servers/${this.id}/resources`
|
|
946
|
+
);
|
|
904
947
|
return data.attributes;
|
|
905
948
|
};
|
|
906
949
|
command = async (command) => {
|
|
@@ -928,9 +971,7 @@ var Client = class {
|
|
|
928
971
|
};
|
|
929
972
|
listServers = async (type = "accessible", page = 1, per_page = 50, include) => {
|
|
930
973
|
import_zod5.default.number().positive().parse(page);
|
|
931
|
-
const { data } = await this.r.get("/", {
|
|
932
|
-
params: { type, page, include: include?.join(",") }
|
|
933
|
-
});
|
|
974
|
+
const { data } = await this.r.get("/", { params: { type, page, include: include?.join(",") } });
|
|
934
975
|
return data.data.map((s) => s.attributes);
|
|
935
976
|
};
|
|
936
977
|
server = (uuid) => new ServerClient(this.r, uuid);
|
|
@@ -1601,9 +1642,7 @@ var UpdateStartupSchema = CreateServerSchema.pick({
|
|
|
1601
1642
|
environment: true,
|
|
1602
1643
|
egg: true,
|
|
1603
1644
|
skip_scripts: true
|
|
1604
|
-
}).extend({
|
|
1605
|
-
image: import_zod11.default.string().optional()
|
|
1606
|
-
});
|
|
1645
|
+
}).extend({ image: import_zod11.default.string().optional() });
|
|
1607
1646
|
|
|
1608
1647
|
// src/api/application/database_hosts.ts
|
|
1609
1648
|
var import_zod12 = __toESM(require("zod"));
|
|
@@ -1653,17 +1692,17 @@ var Agent = class {
|
|
|
1653
1692
|
this.requester = import_axios3.default.create({
|
|
1654
1693
|
baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
|
|
1655
1694
|
timeout: 3e3,
|
|
1656
|
-
headers: {
|
|
1657
|
-
Authorization: `Bearer ${this.token}`
|
|
1658
|
-
}
|
|
1695
|
+
headers: { Authorization: `Bearer ${this.token}` }
|
|
1659
1696
|
});
|
|
1660
1697
|
this.requester.interceptors.response.use(void 0, (error) => {
|
|
1661
1698
|
if (error.response && error.response.status === 400) {
|
|
1662
|
-
return Promise.reject(
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1699
|
+
return Promise.reject(
|
|
1700
|
+
new PterodactylException(
|
|
1701
|
+
"Invalid request data",
|
|
1702
|
+
error.response.data,
|
|
1703
|
+
error.response.status
|
|
1704
|
+
)
|
|
1705
|
+
);
|
|
1667
1706
|
}
|
|
1668
1707
|
return Promise.reject(error);
|
|
1669
1708
|
});
|
|
@@ -1721,16 +1760,6 @@ var Account2 = class {
|
|
|
1721
1760
|
listSshKeys = async () => this.client.account.sshKeys.list();
|
|
1722
1761
|
createSshKey = async (name, public_key) => this.client.account.sshKeys.create(name, public_key);
|
|
1723
1762
|
deleteSshKey = async (fingerprint) => this.client.account.sshKeys.delete(fingerprint);
|
|
1724
|
-
get2faQR = async () => this.client.account.twoFactor.info();
|
|
1725
|
-
enable2fa = async (code) => {
|
|
1726
|
-
const tokens = await this.client.account.twoFactor.enable(code);
|
|
1727
|
-
this.$has2faEnabled = true;
|
|
1728
|
-
return tokens;
|
|
1729
|
-
};
|
|
1730
|
-
disable2fa = async (password) => {
|
|
1731
|
-
await this.client.account.twoFactor.disable(password);
|
|
1732
|
-
this.$has2faEnabled = false;
|
|
1733
|
-
};
|
|
1734
1763
|
};
|
|
1735
1764
|
|
|
1736
1765
|
// src/humane/ServerAllocation.ts
|
|
@@ -1883,7 +1912,12 @@ var ServerFile = class _ServerFile {
|
|
|
1883
1912
|
write = async (content) => this.client.files.write(this.path, content);
|
|
1884
1913
|
compress = async (archive_name, extension) => new _ServerFile(
|
|
1885
1914
|
this.client,
|
|
1886
|
-
await this.client.files.compress(
|
|
1915
|
+
await this.client.files.compress(
|
|
1916
|
+
this.dir,
|
|
1917
|
+
[this.name],
|
|
1918
|
+
archive_name,
|
|
1919
|
+
extension
|
|
1920
|
+
)
|
|
1887
1921
|
);
|
|
1888
1922
|
decompress = async () => this.client.files.decompress(this.dir, this.name);
|
|
1889
1923
|
delete = async () => this.client.files.delete(this.dir, [this.name]);
|
|
@@ -2128,10 +2162,7 @@ var Server = class {
|
|
|
2128
2162
|
getServerStats = async () => this.client.resources();
|
|
2129
2163
|
runCommand = async (command) => this.client.command(command);
|
|
2130
2164
|
sendPowerSignal = async (signal) => this.client.power(signal);
|
|
2131
|
-
getDatabases = async (opts = {
|
|
2132
|
-
include: [],
|
|
2133
|
-
page: 1
|
|
2134
|
-
}) => {
|
|
2165
|
+
getDatabases = async (opts = { include: [], page: 1 }) => {
|
|
2135
2166
|
const data = await this.client.databases.list(opts.include, opts.page);
|
|
2136
2167
|
return data.map((d) => new ServerDatabase(this.client, d));
|
|
2137
2168
|
};
|
|
@@ -2165,7 +2196,7 @@ var Server = class {
|
|
|
2165
2196
|
};
|
|
2166
2197
|
getFiles = async (path2) => {
|
|
2167
2198
|
const data = await this.client.files.list(path2);
|
|
2168
|
-
return data.map((d) => new ServerFile(this.client, d));
|
|
2199
|
+
return data.map((d) => new ServerFile(this.client, d, path2));
|
|
2169
2200
|
};
|
|
2170
2201
|
createFolder = async (...opts) => this.client.files.createFolder(...opts);
|
|
2171
2202
|
uploadFile = async (...opts) => this.client.files.upload(...opts);
|