@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.
Files changed (78) hide show
  1. package/.husky/pre-commit +2 -3
  2. package/biome.json +42 -32
  3. package/bun.lock +3 -0
  4. package/dist/api/index.d.mts +5 -5
  5. package/dist/api/index.d.ts +5 -5
  6. package/dist/api/index.js +168 -102
  7. package/dist/api/index.mjs +168 -102
  8. package/dist/index.d.mts +2 -2
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +124 -70
  11. package/dist/index.mjs +124 -70
  12. package/dist/types.d.ts +1 -1
  13. package/package.json +60 -59
  14. package/scripts/create-types.ts +4 -4
  15. package/src/api/application/client.ts +26 -19
  16. package/src/api/application/database_hosts.ts +15 -20
  17. package/src/api/application/eggs.ts +14 -7
  18. package/src/api/application/mounts.ts +29 -16
  19. package/src/api/application/nodes.ts +34 -32
  20. package/src/api/application/nodes_allocations.ts +15 -11
  21. package/src/api/application/roles.ts +13 -27
  22. package/src/api/application/servers.ts +36 -27
  23. package/src/api/application/servers_databases.ts +11 -7
  24. package/src/api/application/types/container.ts +7 -8
  25. package/src/api/application/types/database_host.ts +8 -8
  26. package/src/api/application/types/egg.ts +47 -54
  27. package/src/api/application/types/location.ts +5 -7
  28. package/src/api/application/types/mount.ts +9 -9
  29. package/src/api/application/types/node.ts +49 -59
  30. package/src/api/application/types/role.ts +4 -6
  31. package/src/api/application/types/server.ts +21 -22
  32. package/src/api/application/types/server_allocation.ts +11 -12
  33. package/src/api/application/types/user.ts +25 -25
  34. package/src/api/application/users.ts +38 -27
  35. package/src/api/base/request.ts +28 -17
  36. package/src/api/base/types.ts +16 -23
  37. package/src/api/client/account.ts +20 -15
  38. package/src/api/client/client.ts +17 -18
  39. package/src/api/client/server.ts +24 -20
  40. package/src/api/client/server_activity.ts +10 -11
  41. package/src/api/client/server_allocations.ts +11 -6
  42. package/src/api/client/server_backups.ts +21 -17
  43. package/src/api/client/server_databases.ts +14 -8
  44. package/src/api/client/server_files.ts +56 -42
  45. package/src/api/client/server_schedules.ts +43 -19
  46. package/src/api/client/server_settings.ts +11 -8
  47. package/src/api/client/server_startup.ts +16 -8
  48. package/src/api/client/server_users.ts +22 -13
  49. package/src/api/client/server_websocket.ts +79 -33
  50. package/src/api/client/types/server.ts +8 -18
  51. package/src/api/client/types/server_allocation.ts +7 -8
  52. package/src/api/client/types/server_subuser.ts +10 -11
  53. package/src/api/client/types/user.ts +2 -5
  54. package/src/api/client/types/websocket.ts +12 -24
  55. package/src/api/common/types/egg.ts +7 -7
  56. package/src/api/common/types/enums.ts +1 -1
  57. package/src/api/common/types/server_backup.ts +4 -5
  58. package/src/api/common/types/server_database.ts +9 -12
  59. package/src/api/common/types/server_files.ts +9 -9
  60. package/src/api/common/types/server_limits.ts +11 -12
  61. package/src/api/common/types/server_power.ts +1 -1
  62. package/src/api/common/types/server_schedule.ts +27 -25
  63. package/src/api/common/types/server_startup.ts +7 -12
  64. package/src/api/index.ts +3 -3
  65. package/src/humane/Account.ts +2 -2
  66. package/src/humane/Client.ts +6 -6
  67. package/src/humane/Server.ts +31 -43
  68. package/src/humane/ServerAllocation.ts +3 -3
  69. package/src/humane/ServerBackup.ts +6 -9
  70. package/src/humane/ServerDatabase.ts +2 -2
  71. package/src/humane/ServerFile.ts +17 -11
  72. package/src/humane/ServerSchedule.ts +6 -6
  73. package/src/humane/ServerUser.ts +2 -2
  74. package/src/index.ts +3 -3
  75. package/src/utils/sized.ts +1 -1
  76. package/src/utils/transform.ts +5 -10
  77. package/src/utils/types.ts +6 -8
  78. package/tsconfig.json +0 -1
package/dist/index.mjs CHANGED
@@ -91,29 +91,28 @@ var ServerFiles = class {
91
91
  this.id = id;
92
92
  }
93
93
  list = async (path2) => {
94
- const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
95
- params: { directory: path2 }
96
- });
94
+ const { data } = await this.r.get(`/servers/${this.id}/files/list`, { params: { directory: path2 } });
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 (path2) => {
103
- const { data } = await this.r.get(`/servers/${this.id}/files/contents`, {
104
- params: { file: path2 }
105
- });
101
+ const { data } = await this.r.get(
102
+ `/servers/${this.id}/files/contents`,
103
+ { params: { file: path2 } }
104
+ );
106
105
  return data;
107
106
  };
108
107
  downloadGetUrl = async (path2) => {
109
- const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
110
- params: { file: path2 }
111
- });
108
+ const { data } = await this.r.get(`/servers/${this.id}/files/download`, { params: { file: path2 } });
112
109
  return data.attributes.url;
113
110
  };
114
111
  download = async (path2) => {
115
112
  const url = await this.downloadGetUrl(path2);
116
- const { data } = await axios.get(url, { responseType: "arraybuffer" });
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`, { root, files, archive_name, extension });
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`, { root, name });
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`, { url, directory, filename, use_header, foreground });
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(url, { files: file }, {
156
- headers: { "Content-Type": "multipart/form-data" },
157
- params: { directory: root }
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(`/servers/${this.id}/schedules/${this.sched_id}/execute`);
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(`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`, opts);
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(`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`);
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(`/servers/${this.id}/network/allocations/${alloc_id}`);
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(`/servers/${this.id}/users/${user_uuid}`);
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(`/servers/${this.id}/users/${user_uuid}`, { permissions });
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, { responseType: "arraybuffer" });
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`, { name });
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(`/servers/${this.id}/backups/${backup_uuid}/restore`, { truncate });
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`, { 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.post(`/servers/${this.id}/settings/docker-image`, { image });
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, { origin: new URL(socketUrl).origin });
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(error instanceof Error ? error : new Error("Websocket authentication failed"));
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(event instanceof Error ? event : new Error("Websocket connection error"));
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("message", handler);
536
+ this.socket.addEventListener(
537
+ "message",
538
+ handler
539
+ );
493
540
  this.detachMessageListener = () => {
494
- this.socket?.removeEventListener?.("message", handler);
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(message.args[0]);
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(`/servers/${this.serverId}/websocket`);
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(JSON.stringify({ event: "auth", args: [this.currentToken] }));
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(`Attempted to send "${event}" without an active websocket connection`);
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(`/servers/${this.id}`, {
837
- params: { include: include?.join(",") }
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(`/servers/${this.id}/resources`);
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);
@@ -1543,9 +1597,7 @@ var UpdateStartupSchema = CreateServerSchema.pick({
1543
1597
  environment: true,
1544
1598
  egg: true,
1545
1599
  skip_scripts: true
1546
- }).extend({
1547
- image: z11.string().optional()
1548
- });
1600
+ }).extend({ image: z11.string().optional() });
1549
1601
 
1550
1602
  // src/api/application/database_hosts.ts
1551
1603
  import z12 from "zod";
@@ -1595,17 +1647,17 @@ var Agent = class {
1595
1647
  this.requester = axios3.create({
1596
1648
  baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
1597
1649
  timeout: 3e3,
1598
- headers: {
1599
- Authorization: `Bearer ${this.token}`
1600
- }
1650
+ headers: { Authorization: `Bearer ${this.token}` }
1601
1651
  });
1602
1652
  this.requester.interceptors.response.use(void 0, (error) => {
1603
1653
  if (error.response && error.response.status === 400) {
1604
- return Promise.reject(new PterodactylException(
1605
- "Invalid request data",
1606
- error.response.data,
1607
- error.response.status
1608
- ));
1654
+ return Promise.reject(
1655
+ new PterodactylException(
1656
+ "Invalid request data",
1657
+ error.response.data,
1658
+ error.response.status
1659
+ )
1660
+ );
1609
1661
  }
1610
1662
  return Promise.reject(error);
1611
1663
  });
@@ -1815,7 +1867,12 @@ var ServerFile = class _ServerFile {
1815
1867
  write = async (content) => this.client.files.write(this.path, content);
1816
1868
  compress = async (archive_name, extension) => new _ServerFile(
1817
1869
  this.client,
1818
- await this.client.files.compress(this.dir, [this.name], archive_name, extension)
1870
+ await this.client.files.compress(
1871
+ this.dir,
1872
+ [this.name],
1873
+ archive_name,
1874
+ extension
1875
+ )
1819
1876
  );
1820
1877
  decompress = async () => this.client.files.decompress(this.dir, this.name);
1821
1878
  delete = async () => this.client.files.delete(this.dir, [this.name]);
@@ -2060,10 +2117,7 @@ var Server = class {
2060
2117
  getServerStats = async () => this.client.resources();
2061
2118
  runCommand = async (command) => this.client.command(command);
2062
2119
  sendPowerSignal = async (signal) => this.client.power(signal);
2063
- getDatabases = async (opts = {
2064
- include: [],
2065
- page: 1
2066
- }) => {
2120
+ getDatabases = async (opts = { include: [], page: 1 }) => {
2067
2121
  const data = await this.client.databases.list(opts.include, opts.page);
2068
2122
  return data.map((d) => new ServerDatabase(this.client, d));
2069
2123
  };
@@ -2097,7 +2151,7 @@ var Server = class {
2097
2151
  };
2098
2152
  getFiles = async (path2) => {
2099
2153
  const data = await this.client.files.list(path2);
2100
- return data.map((d) => new ServerFile(this.client, d));
2154
+ return data.map((d) => new ServerFile(this.client, d, path2));
2101
2155
  };
2102
2156
  createFolder = async (...opts) => this.client.files.createFolder(...opts);
2103
2157
  uploadFile = async (...opts) => this.client.files.upload(...opts);
package/dist/types.d.ts CHANGED
@@ -2,7 +2,7 @@ import z from 'zod';
2
2
  import { AxiosInstance } from 'axios';
3
3
  import WebSocket from 'isomorphic-ws';
4
4
 
5
- type ServerSignalOption = 'start' | 'stop' | 'restart' | 'kill';
5
+ type ServerSignalOption = "start" | "stop" | "restart" | "kill";
6
6
 
7
7
  type GenericResponse<T, N extends string = string, M = undefined> = {
8
8
  object: N;
package/package.json CHANGED
@@ -1,64 +1,65 @@
1
1
  {
2
- "name": "@pelican.ts/sdk",
3
- "version": "0.4.8",
4
- "description": "Pelican panel SDK for TypeScript",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "require": "./dist/index.js",
12
- "import": "./dist/index.mjs"
13
- },
14
- "./api": {
15
- "types": "./dist/api/index.d.ts",
16
- "require": "./dist/api/index.js",
17
- "import": "./dist/api/index.mjs"
18
- },
19
- "./types": {
20
- "types": "./dist/types.d.ts"
21
- }
2
+ "name": "@pelican.ts/sdk",
3
+ "version": "0.4.10",
4
+ "description": "Pelican panel SDK for TypeScript",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
22
13
  },
23
- "scripts": {
24
- "build:api": "tsup src/api/index.ts --format esm,cjs --dts --target esnext -d dist/api",
25
- "build:humane": "tsup src/index.ts --format esm,cjs --dts --target esnext",
26
- "build:types": "tsup src/types.ts --dts-only --target esnext",
27
- "build": "rm -rf ./dist && npm run build:api && npm run build:humane && npm run build:types",
28
- "pub": "npm publish --access=public",
29
- "pub:next": "npm publish --access=public --tag=next",
30
- "generate-types": "bun run scripts/create-types.ts",
31
- "pipeline:next": "bun run generate-types && bun run build && bun run pub:next",
32
- "pipeline": "bun run generate-types && bun run build && bun run pub",
33
- "format": "biome format --no-errors-on-unmatched --files-ignore-unknown=true --write .",
34
- "prepare": "husky"
14
+ "./api": {
15
+ "types": "./dist/api/index.d.ts",
16
+ "require": "./dist/api/index.js",
17
+ "import": "./dist/api/index.mjs"
35
18
  },
36
- "keywords": [
37
- "pterodactyl",
38
- "pterodactyl.ts",
39
- "pterodactyl.js",
40
- "pelican",
41
- "pelican.ts",
42
- "pelican.js"
43
- ],
44
- "author": "M41den",
45
- "license": "MIT",
46
- "repository": {
47
- "url": "git+https://github.com/m41denx/Pelican.ts"
48
- },
49
- "devDependencies": {
50
- "@biomejs/biome": "2.3.6",
51
- "@types/node": "^22.18.12",
52
- "@types/strip-color": "^0.1.2",
53
- "husky": "^9.1.7",
54
- "tsc-alias": "^1.8.16",
55
- "tsup": "^8.5.0",
56
- "typescript": "^5.9.3"
57
- },
58
- "dependencies": {
59
- "axios": "^1.12.2",
60
- "isomorphic-ws": "^5.0.0",
61
- "strip-color": "^0.1.0",
62
- "zod": "^4.1.12"
19
+ "./types": {
20
+ "types": "./dist/types.d.ts"
63
21
  }
22
+ },
23
+ "scripts": {
24
+ "build:api": "tsup src/api/index.ts --format esm,cjs --dts --target esnext -d dist/api",
25
+ "build:humane": "tsup src/index.ts --format esm,cjs --dts --target esnext",
26
+ "build:types": "tsup src/types.ts --dts-only --target esnext",
27
+ "build": "rm -rf ./dist && npm run build:api && npm run build:humane && npm run build:types",
28
+ "pub": "npm publish --access=public",
29
+ "pub:next": "npm publish --access=public --tag=next",
30
+ "generate-types": "bun run scripts/create-types.ts",
31
+ "pipeline:next": "bun run generate-types && bun run build && bun run pub:next",
32
+ "pipeline": "bun run generate-types && bun run build && bun run pub",
33
+ "format": "biome format --no-errors-on-unmatched --files-ignore-unknown=true --write .",
34
+ "prepare": "husky"
35
+ },
36
+ "keywords": [
37
+ "pterodactyl",
38
+ "pterodactyl.ts",
39
+ "pterodactyl.js",
40
+ "pelican",
41
+ "pelican.ts",
42
+ "pelican.js"
43
+ ],
44
+ "author": "M41den",
45
+ "license": "MIT",
46
+ "repository": {
47
+ "url": "git+https://github.com/m41denx/Pelican.ts"
48
+ },
49
+ "devDependencies": {
50
+ "@biomejs/biome": "2.3.6",
51
+ "@types/node": "^22.18.12",
52
+ "@types/strip-color": "^0.1.2",
53
+ "git-format-staged": "^3.1.1",
54
+ "husky": "^9.1.7",
55
+ "tsc-alias": "^1.8.16",
56
+ "tsup": "^8.5.0",
57
+ "typescript": "^5.9.3"
58
+ },
59
+ "dependencies": {
60
+ "axios": "^1.12.2",
61
+ "isomorphic-ws": "^5.0.0",
62
+ "strip-color": "^0.1.0",
63
+ "zod": "^4.1.12"
64
+ }
64
65
  }
@@ -1,4 +1,3 @@
1
-
2
1
  import fs from "fs"
3
2
  import path from "path"
4
3
 
@@ -9,9 +8,10 @@ const typesPaths = [
9
8
  ]
10
9
 
11
10
  typesPaths.forEach(p => {
12
- const prefix = path.join(__dirname, "../src" , p)
13
- const files = fs.readdirSync(prefix)
14
- .filter(f => f!=="index.ts")
11
+ const prefix = path.join(__dirname, "../src", p)
12
+ const files = fs
13
+ .readdirSync(prefix)
14
+ .filter(f => f !== "index.ts")
15
15
  .map(f => f.replace(/\.ts$/, ""))
16
16
  const strings: Array<string> = []
17
17
  files.forEach(f => {
@@ -1,14 +1,14 @@
1
- import {AxiosInstance} from "axios";
2
- import {Users} from "@/api/application/users";
3
- import {Nodes} from "@/api/application/nodes";
4
- import {GenericListResponse, GenericResponse} from "@/api/base/types";
5
- import {ApplicationServer} from "@/api/application/types/server";
6
- import {CreateServerSchema, Servers} from "@/api/application/servers";
7
- import z from "zod";
8
- import {DatabaseHosts} from "@/api/application/database_hosts";
9
- import {Roles} from "@/api/application/roles";
10
- import {Eggs} from "@/api/application/eggs";
11
- import {Mounts} from "@/api/application/mounts";
1
+ import {AxiosInstance} from "axios"
2
+ import {Users} from "@/api/application/users"
3
+ import {Nodes} from "@/api/application/nodes"
4
+ import {GenericListResponse, GenericResponse} from "@/api/base/types"
5
+ import {ApplicationServer} from "@/api/application/types/server"
6
+ import {CreateServerSchema, Servers} from "@/api/application/servers"
7
+ import z from "zod"
8
+ import {DatabaseHosts} from "@/api/application/database_hosts"
9
+ import {Roles} from "@/api/application/roles"
10
+ import {Eggs} from "@/api/application/eggs"
11
+ import {Mounts} from "@/api/application/mounts"
12
12
 
13
13
  export class Client {
14
14
  private readonly r: AxiosInstance
@@ -40,24 +40,31 @@ export class Client {
40
40
  ): Promise<ApplicationServer[]> => {
41
41
  const {data} = await this.r.get<
42
42
  GenericListResponse<GenericResponse<ApplicationServer, "server">>
43
- >("/servers", {
44
- params: {search, page}
45
- })
43
+ >("/servers", {params: {search, page}})
46
44
  return data.data.map(s => s.attributes)
47
45
  }
48
46
 
49
- createServer = async (opts: z.infer<typeof CreateServerSchema>): Promise<ApplicationServer> => {
47
+ createServer = async (
48
+ opts: z.infer<typeof CreateServerSchema>
49
+ ): Promise<ApplicationServer> => {
50
50
  opts = CreateServerSchema.parse(opts)
51
- const {data} = await this.r.post<GenericResponse<ApplicationServer, "server">>("/servers", opts)
51
+ const {data} = await this.r.post<
52
+ GenericResponse<ApplicationServer, "server">
53
+ >("/servers", opts)
52
54
  return data.attributes
53
55
  }
54
56
 
55
- getServerByExternalId = async (external_id: string, include?: ("egg" | "subusers")[]): Promise<ApplicationServer> => {
56
- const {data} = await this.r.get<GenericResponse<ApplicationServer, "server">>(`/servers/external/${external_id}`, {
57
+ getServerByExternalId = async (
58
+ external_id: string,
59
+ include?: ("egg" | "subusers")[]
60
+ ): Promise<ApplicationServer> => {
61
+ const {data} = await this.r.get<
62
+ GenericResponse<ApplicationServer, "server">
63
+ >(`/servers/external/${external_id}`, {
57
64
  params: {include: include?.join(",")}
58
65
  })
59
66
  return data.attributes
60
67
  }
61
68
 
62
69
  servers = (server_id: number) => new Servers(this.r, server_id)
63
- }
70
+ }