@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.
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 -14
  5. package/dist/api/index.d.ts +5 -14
  6. package/dist/api/index.js +167 -114
  7. package/dist/api/index.mjs +167 -114
  8. package/dist/index.d.mts +2 -18
  9. package/dist/index.d.ts +2 -18
  10. package/dist/index.js +123 -92
  11. package/dist/index.mjs +123 -92
  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 -35
  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 +10 -7
  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 -15
  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
@@ -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 (path2) => {
107
- const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
108
- params: { directory: path2 }
109
- });
94
+ const { data } = await this.r.get(`/servers/${this.id}/files/list`, { params: { directory: path2 } });
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 (path2) => {
116
- const { data } = await this.r.get(`/servers/${this.id}/files/contents`, {
117
- params: { file: path2 }
118
- });
101
+ const { data } = await this.r.get(
102
+ `/servers/${this.id}/files/contents`,
103
+ { params: { file: path2 } }
104
+ );
119
105
  return data;
120
106
  };
121
107
  downloadGetUrl = async (path2) => {
122
- const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
123
- params: { file: path2 }
124
- });
108
+ const { data } = await this.r.get(`/servers/${this.id}/files/download`, { params: { file: path2 } });
125
109
  return data.attributes.url;
126
110
  };
127
111
  download = async (path2) => {
128
112
  const url = await this.downloadGetUrl(path2);
129
- const { data } = await axios.get(url, { responseType: "arraybuffer" });
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`, { 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
+ });
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`, { root, name });
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`, { 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
+ });
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(url, { files: file }, {
169
- headers: { "Content-Type": "multipart/form-data" },
170
- params: { directory: root }
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(`/servers/${this.id}/schedules/${this.sched_id}/execute`);
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(`/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
+ );
223
232
  return data.attributes;
224
233
  },
225
234
  delete: async (task_id) => {
226
- 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
+ );
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(`/servers/${this.id}/network/allocations/${alloc_id}`);
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(`/servers/${this.id}/users/${user_uuid}`);
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(`/servers/${this.id}/users/${user_uuid}`, { permissions });
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, { responseType: "arraybuffer" });
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`, { name });
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(`/servers/${this.id}/backups/${backup_uuid}/restore`, { truncate });
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`, { 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, { origin: new URL(socketUrl).origin });
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(error instanceof Error ? error : new Error("Websocket authentication failed"));
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(event instanceof Error ? event : new Error("Websocket connection error"));
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("message", handler);
536
+ this.socket.addEventListener(
537
+ "message",
538
+ handler
539
+ );
506
540
  this.detachMessageListener = () => {
507
- this.socket?.removeEventListener?.("message", handler);
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(message.args[0]);
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(`/servers/${this.serverId}/websocket`);
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(JSON.stringify({ event: "auth", args: [this.currentToken] }));
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(`Attempted to send "${event}" without an active websocket connection`);
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(`/servers/${this.id}`, {
850
- params: { include: include?.join(",") }
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(`/servers/${this.id}/resources`);
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);
@@ -1556,9 +1597,7 @@ var UpdateStartupSchema = CreateServerSchema.pick({
1556
1597
  environment: true,
1557
1598
  egg: true,
1558
1599
  skip_scripts: true
1559
- }).extend({
1560
- image: z11.string().optional()
1561
- });
1600
+ }).extend({ image: z11.string().optional() });
1562
1601
 
1563
1602
  // src/api/application/database_hosts.ts
1564
1603
  import z12 from "zod";
@@ -1608,17 +1647,17 @@ var Agent = class {
1608
1647
  this.requester = axios3.create({
1609
1648
  baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
1610
1649
  timeout: 3e3,
1611
- headers: {
1612
- Authorization: `Bearer ${this.token}`
1613
- }
1650
+ headers: { Authorization: `Bearer ${this.token}` }
1614
1651
  });
1615
1652
  this.requester.interceptors.response.use(void 0, (error) => {
1616
1653
  if (error.response && error.response.status === 400) {
1617
- return Promise.reject(new PterodactylException(
1618
- "Invalid request data",
1619
- error.response.data,
1620
- error.response.status
1621
- ));
1654
+ return Promise.reject(
1655
+ new PterodactylException(
1656
+ "Invalid request data",
1657
+ error.response.data,
1658
+ error.response.status
1659
+ )
1660
+ );
1622
1661
  }
1623
1662
  return Promise.reject(error);
1624
1663
  });
@@ -1676,16 +1715,6 @@ var Account2 = class {
1676
1715
  listSshKeys = async () => this.client.account.sshKeys.list();
1677
1716
  createSshKey = async (name, public_key) => this.client.account.sshKeys.create(name, public_key);
1678
1717
  deleteSshKey = async (fingerprint) => this.client.account.sshKeys.delete(fingerprint);
1679
- get2faQR = async () => this.client.account.twoFactor.info();
1680
- enable2fa = async (code) => {
1681
- const tokens = await this.client.account.twoFactor.enable(code);
1682
- this.$has2faEnabled = true;
1683
- return tokens;
1684
- };
1685
- disable2fa = async (password) => {
1686
- await this.client.account.twoFactor.disable(password);
1687
- this.$has2faEnabled = false;
1688
- };
1689
1718
  };
1690
1719
 
1691
1720
  // src/humane/ServerAllocation.ts
@@ -1838,7 +1867,12 @@ var ServerFile = class _ServerFile {
1838
1867
  write = async (content) => this.client.files.write(this.path, content);
1839
1868
  compress = async (archive_name, extension) => new _ServerFile(
1840
1869
  this.client,
1841
- 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
+ )
1842
1876
  );
1843
1877
  decompress = async () => this.client.files.decompress(this.dir, this.name);
1844
1878
  delete = async () => this.client.files.delete(this.dir, [this.name]);
@@ -2083,10 +2117,7 @@ var Server = class {
2083
2117
  getServerStats = async () => this.client.resources();
2084
2118
  runCommand = async (command) => this.client.command(command);
2085
2119
  sendPowerSignal = async (signal) => this.client.power(signal);
2086
- getDatabases = async (opts = {
2087
- include: [],
2088
- page: 1
2089
- }) => {
2120
+ getDatabases = async (opts = { include: [], page: 1 }) => {
2090
2121
  const data = await this.client.databases.list(opts.include, opts.page);
2091
2122
  return data.map((d) => new ServerDatabase(this.client, d));
2092
2123
  };
@@ -2120,7 +2151,7 @@ var Server = class {
2120
2151
  };
2121
2152
  getFiles = async (path2) => {
2122
2153
  const data = await this.client.files.list(path2);
2123
- return data.map((d) => new ServerFile(this.client, d));
2154
+ return data.map((d) => new ServerFile(this.client, d, path2));
2124
2155
  };
2125
2156
  createFolder = async (...opts) => this.client.files.createFolder(...opts);
2126
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.7",
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.9",
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
+ }