@pelican.ts/sdk 0.2.2 → 0.2.4

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 (200) hide show
  1. package/README.md +11 -8
  2. package/dist/index.d.mts +1502 -0
  3. package/dist/index.d.ts +1500 -7
  4. package/dist/index.js +1979 -19
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1943 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +4 -3
  9. package/src/api/application/client.ts +40 -0
  10. package/src/api/application/database_hosts.ts +70 -0
  11. package/src/api/application/nodes.ts +72 -45
  12. package/src/api/application/nodes_allocations.ts +4 -6
  13. package/src/api/application/roles.ts +53 -0
  14. package/src/api/application/servers.ts +135 -0
  15. package/src/api/application/servers_databases.ts +49 -0
  16. package/src/api/application/types/container.ts +1 -3
  17. package/src/api/application/types/database_host.ts +11 -0
  18. package/src/api/application/types/node.ts +39 -4
  19. package/src/api/application/types/role.ts +8 -0
  20. package/src/api/application/types/server.ts +4 -4
  21. package/src/api/{common/types/server_allocations.ts → application/types/server_allocation.ts} +3 -2
  22. package/src/api/application/types/user.ts +4 -4
  23. package/src/api/application/users.ts +28 -18
  24. package/src/api/base/request.ts +3 -3
  25. package/src/api/client/server_allocations.ts +1 -1
  26. package/src/api/client/server_databases.ts +7 -7
  27. package/src/api/client/types/server.ts +1 -1
  28. package/src/api/client/types/server_allocation.ts +11 -0
  29. package/src/api/common/types/enums.ts +21 -0
  30. package/src/api/common/types/server_database.ts +1 -1
  31. package/src/index.ts +4 -4
  32. package/dist/api/application/client.d.ts +0 -8
  33. package/dist/api/application/client.d.ts.map +0 -1
  34. package/dist/api/application/client.js +0 -14
  35. package/dist/api/application/client.js.map +0 -1
  36. package/dist/api/application/nodes.d.ts +0 -36
  37. package/dist/api/application/nodes.d.ts.map +0 -1
  38. package/dist/api/application/nodes.js +0 -47
  39. package/dist/api/application/nodes.js.map +0 -1
  40. package/dist/api/application/nodes_allocations.d.ts +0 -11
  41. package/dist/api/application/nodes_allocations.d.ts.map +0 -1
  42. package/dist/api/application/nodes_allocations.js +0 -36
  43. package/dist/api/application/nodes_allocations.js.map +0 -1
  44. package/dist/api/application/types/container.d.ts +0 -12
  45. package/dist/api/application/types/container.d.ts.map +0 -1
  46. package/dist/api/application/types/container.js +0 -3
  47. package/dist/api/application/types/container.js.map +0 -1
  48. package/dist/api/application/types/location.d.ts +0 -8
  49. package/dist/api/application/types/location.d.ts.map +0 -1
  50. package/dist/api/application/types/location.js +0 -3
  51. package/dist/api/application/types/location.js.map +0 -1
  52. package/dist/api/application/types/node.d.ts +0 -32
  53. package/dist/api/application/types/node.d.ts.map +0 -1
  54. package/dist/api/application/types/node.js +0 -3
  55. package/dist/api/application/types/node.js.map +0 -1
  56. package/dist/api/application/types/server.d.ts +0 -23
  57. package/dist/api/application/types/server.d.ts.map +0 -1
  58. package/dist/api/application/types/server.js +0 -3
  59. package/dist/api/application/types/server.js.map +0 -1
  60. package/dist/api/application/types/user.d.ts +0 -20
  61. package/dist/api/application/types/user.d.ts.map +0 -1
  62. package/dist/api/application/types/user.js +0 -3
  63. package/dist/api/application/types/user.js.map +0 -1
  64. package/dist/api/application/users.d.ts +0 -38
  65. package/dist/api/application/users.d.ts.map +0 -1
  66. package/dist/api/application/users.js +0 -54
  67. package/dist/api/application/users.js.map +0 -1
  68. package/dist/api/base/request.d.ts +0 -8
  69. package/dist/api/base/request.d.ts.map +0 -1
  70. package/dist/api/base/request.js +0 -33
  71. package/dist/api/base/request.js.map +0 -1
  72. package/dist/api/base/types.d.ts +0 -40
  73. package/dist/api/base/types.d.ts.map +0 -1
  74. package/dist/api/base/types.js +0 -14
  75. package/dist/api/base/types.js.map +0 -1
  76. package/dist/api/client/account.d.ts +0 -31
  77. package/dist/api/client/account.d.ts.map +0 -1
  78. package/dist/api/client/account.js +0 -70
  79. package/dist/api/client/account.js.map +0 -1
  80. package/dist/api/client/client.d.ts +0 -14
  81. package/dist/api/client/client.d.ts.map +0 -1
  82. package/dist/api/client/client.js +0 -37
  83. package/dist/api/client/client.js.map +0 -1
  84. package/dist/api/client/server.d.ts +0 -33
  85. package/dist/api/client/server.d.ts.map +0 -1
  86. package/dist/api/client/server.js +0 -62
  87. package/dist/api/client/server.js.map +0 -1
  88. package/dist/api/client/server_activity.d.ts +0 -9
  89. package/dist/api/client/server_activity.d.ts.map +0 -1
  90. package/dist/api/client/server_activity.js +0 -22
  91. package/dist/api/client/server_activity.js.map +0 -1
  92. package/dist/api/client/server_allocations.d.ts +0 -13
  93. package/dist/api/client/server_allocations.d.ts.map +0 -1
  94. package/dist/api/client/server_allocations.js +0 -32
  95. package/dist/api/client/server_allocations.js.map +0 -1
  96. package/dist/api/client/server_backups.d.ts +0 -18
  97. package/dist/api/client/server_backups.d.ts.map +0 -1
  98. package/dist/api/client/server_backups.js +0 -50
  99. package/dist/api/client/server_backups.js.map +0 -1
  100. package/dist/api/client/server_databases.d.ts +0 -12
  101. package/dist/api/client/server_databases.d.ts.map +0 -1
  102. package/dist/api/client/server_databases.js +0 -36
  103. package/dist/api/client/server_databases.js.map +0 -1
  104. package/dist/api/client/server_files.d.ts +0 -34
  105. package/dist/api/client/server_files.d.ts.map +0 -1
  106. package/dist/api/client/server_files.js +0 -86
  107. package/dist/api/client/server_files.js.map +0 -1
  108. package/dist/api/client/server_schedules.d.ts +0 -38
  109. package/dist/api/client/server_schedules.d.ts.map +0 -1
  110. package/dist/api/client/server_schedules.js +0 -59
  111. package/dist/api/client/server_schedules.js.map +0 -1
  112. package/dist/api/client/server_settings.d.ts +0 -12
  113. package/dist/api/client/server_settings.d.ts.map +0 -1
  114. package/dist/api/client/server_settings.js +0 -30
  115. package/dist/api/client/server_settings.js.map +0 -1
  116. package/dist/api/client/server_startup.d.ts +0 -11
  117. package/dist/api/client/server_startup.d.ts.map +0 -1
  118. package/dist/api/client/server_startup.js +0 -25
  119. package/dist/api/client/server_startup.js.map +0 -1
  120. package/dist/api/client/server_users.d.ts +0 -13
  121. package/dist/api/client/server_users.d.ts.map +0 -1
  122. package/dist/api/client/server_users.js +0 -32
  123. package/dist/api/client/server_users.js.map +0 -1
  124. package/dist/api/client/server_websocket.d.ts +0 -60
  125. package/dist/api/client/server_websocket.d.ts.map +0 -1
  126. package/dist/api/client/server_websocket.js +0 -431
  127. package/dist/api/client/server_websocket.js.map +0 -1
  128. package/dist/api/client/types/server.d.ts +0 -64
  129. package/dist/api/client/types/server.d.ts.map +0 -1
  130. package/dist/api/client/types/server.js +0 -3
  131. package/dist/api/client/types/server.js.map +0 -1
  132. package/dist/api/client/types/server_subuser.d.ts +0 -14
  133. package/dist/api/client/types/server_subuser.d.ts.map +0 -1
  134. package/dist/api/client/types/server_subuser.js +0 -3
  135. package/dist/api/client/types/server_subuser.js.map +0 -1
  136. package/dist/api/client/types/user.d.ts +0 -31
  137. package/dist/api/client/types/user.d.ts.map +0 -1
  138. package/dist/api/client/types/user.js +0 -3
  139. package/dist/api/client/types/user.js.map +0 -1
  140. package/dist/api/client/types/websocket.d.ts +0 -116
  141. package/dist/api/client/types/websocket.d.ts.map +0 -1
  142. package/dist/api/client/types/websocket.js +0 -37
  143. package/dist/api/client/types/websocket.js.map +0 -1
  144. package/dist/api/client/websocket_old.d.ts +0 -171
  145. package/dist/api/client/websocket_old.d.ts.map +0 -1
  146. package/dist/api/client/websocket_old.js +0 -319
  147. package/dist/api/client/websocket_old.js.map +0 -1
  148. package/dist/api/common/types/egg.d.ts +0 -10
  149. package/dist/api/common/types/egg.d.ts.map +0 -1
  150. package/dist/api/common/types/egg.js +0 -3
  151. package/dist/api/common/types/egg.js.map +0 -1
  152. package/dist/api/common/types/server_allocations.d.ts +0 -18
  153. package/dist/api/common/types/server_allocations.d.ts.map +0 -1
  154. package/dist/api/common/types/server_allocations.js +0 -3
  155. package/dist/api/common/types/server_allocations.js.map +0 -1
  156. package/dist/api/common/types/server_backup.d.ts +0 -13
  157. package/dist/api/common/types/server_backup.d.ts.map +0 -1
  158. package/dist/api/common/types/server_backup.js +0 -3
  159. package/dist/api/common/types/server_backup.js.map +0 -1
  160. package/dist/api/common/types/server_database.d.ts +0 -18
  161. package/dist/api/common/types/server_database.d.ts.map +0 -1
  162. package/dist/api/common/types/server_database.js +0 -3
  163. package/dist/api/common/types/server_database.js.map +0 -1
  164. package/dist/api/common/types/server_files.d.ts +0 -12
  165. package/dist/api/common/types/server_files.d.ts.map +0 -1
  166. package/dist/api/common/types/server_files.js +0 -3
  167. package/dist/api/common/types/server_files.js.map +0 -1
  168. package/dist/api/common/types/server_limits.d.ts +0 -17
  169. package/dist/api/common/types/server_limits.d.ts.map +0 -1
  170. package/dist/api/common/types/server_limits.js +0 -3
  171. package/dist/api/common/types/server_limits.js.map +0 -1
  172. package/dist/api/common/types/server_power.d.ts +0 -2
  173. package/dist/api/common/types/server_power.d.ts.map +0 -1
  174. package/dist/api/common/types/server_power.js +0 -3
  175. package/dist/api/common/types/server_power.js.map +0 -1
  176. package/dist/api/common/types/server_schedule.d.ts +0 -34
  177. package/dist/api/common/types/server_schedule.d.ts.map +0 -1
  178. package/dist/api/common/types/server_schedule.js +0 -3
  179. package/dist/api/common/types/server_schedule.js.map +0 -1
  180. package/dist/api/common/types/server_startup.d.ts +0 -14
  181. package/dist/api/common/types/server_startup.d.ts.map +0 -1
  182. package/dist/api/common/types/server_startup.js +0 -3
  183. package/dist/api/common/types/server_startup.js.map +0 -1
  184. package/dist/index.d.ts.map +0 -1
  185. package/dist/pterodactyl.d.ts +0 -8
  186. package/dist/pterodactyl.d.ts.map +0 -1
  187. package/dist/pterodactyl.js +0 -20
  188. package/dist/pterodactyl.js.map +0 -1
  189. package/dist/utils/sized.d.ts +0 -10
  190. package/dist/utils/sized.d.ts.map +0 -1
  191. package/dist/utils/sized.js +0 -15
  192. package/dist/utils/sized.js.map +0 -1
  193. package/dist/utils/transform.d.ts +0 -9
  194. package/dist/utils/transform.d.ts.map +0 -1
  195. package/dist/utils/transform.js +0 -19
  196. package/dist/utils/transform.js.map +0 -1
  197. package/dist/utils/types.d.ts +0 -14
  198. package/dist/utils/types.d.ts.map +0 -1
  199. package/dist/utils/types.js +0 -3
  200. package/dist/utils/types.js.map +0 -1
package/dist/index.mjs ADDED
@@ -0,0 +1,1943 @@
1
+ // src/api/client/account.ts
2
+ import z from "zod";
3
+ var Account = class {
4
+ r;
5
+ constructor(requester) {
6
+ this.r = requester;
7
+ }
8
+ info = async () => {
9
+ const { data } = await this.r.get("/account");
10
+ return data.attributes;
11
+ };
12
+ updateEmail = async (newEmail, password) => {
13
+ newEmail = z.email().parse(newEmail);
14
+ await this.r.put("/account/email", { email: newEmail, password });
15
+ };
16
+ updatePassword = async (newPassword) => {
17
+ newPassword = z.string().min(8).parse(newPassword);
18
+ await this.r.put("/account/password", {
19
+ password: newPassword,
20
+ password_confirmation: newPassword
21
+ });
22
+ };
23
+ apiKeys = {
24
+ list: async () => {
25
+ const { data } = await this.r.get("/account/api-keys");
26
+ return data.data.map((k) => k.attributes);
27
+ },
28
+ create: async (description, allowed_ips) => {
29
+ allowed_ips = z.array(z.ipv4()).optional().parse(allowed_ips);
30
+ const { data } = await this.r.post("/account/api-keys", { description, allowed_ips });
31
+ return { ...data.attributes, secret_token: data.meta.secret_token };
32
+ },
33
+ delete: async (identifier) => {
34
+ await this.r.delete(`/account/api-keys/${identifier}`);
35
+ }
36
+ };
37
+ sshKeys = {
38
+ list: async () => {
39
+ const { data } = await this.r.get("/account/ssh-keys");
40
+ return data.data.map((k) => k.attributes);
41
+ },
42
+ create: async (name, public_key) => {
43
+ const { data } = await this.r.post("/account/ssh-keys", { name, public_key });
44
+ return data.attributes;
45
+ },
46
+ delete: async (fingerprint) => {
47
+ await this.r.post(`/account/ssh-keys/remove`, { fingerprint });
48
+ }
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
+ };
64
+
65
+ // src/api/client/client.ts
66
+ import z5 from "zod";
67
+
68
+ // src/api/client/server_databases.ts
69
+ import z2 from "zod";
70
+ var ServerDatabases = class {
71
+ r;
72
+ id;
73
+ constructor(requester, id) {
74
+ this.r = requester;
75
+ this.id = id;
76
+ }
77
+ list = async (include, page = 1) => {
78
+ z2.number().positive().parse(page);
79
+ const { data } = await this.r.get(`/servers/${this.id}/databases`, {
80
+ params: { include: include?.join(","), page }
81
+ });
82
+ return data.data.map((d) => d.attributes);
83
+ };
84
+ create = async (database, remote) => {
85
+ const { data } = await this.r.post(`/servers/${this.id}/databases`, { database, remote });
86
+ return data.attributes;
87
+ };
88
+ rotatePassword = async (database_id) => {
89
+ const { data } = await this.r.post(`/servers/${this.id}/databases/${database_id}/rotate-password`);
90
+ return data.attributes;
91
+ };
92
+ delete = async (database_id) => {
93
+ await this.r.delete(`/servers/${this.id}/databases/${database_id}`);
94
+ };
95
+ };
96
+
97
+ // src/api/client/server_files.ts
98
+ import axios from "axios";
99
+ var ServerFiles = class {
100
+ r;
101
+ id;
102
+ constructor(requester, id) {
103
+ this.r = requester;
104
+ this.id = id;
105
+ }
106
+ list = async (path) => {
107
+ const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
108
+ params: { directory: path }
109
+ });
110
+ return data.data.map((r) => r.attributes);
111
+ };
112
+ /**
113
+ * Return the contents of a file. To read binary file (non-editable) use {@link download} instead
114
+ */
115
+ contents = async (path) => {
116
+ const { data } = await this.r.get(`/servers/${this.id}/files/contents`, {
117
+ params: { file: path }
118
+ });
119
+ return data;
120
+ };
121
+ downloadGetUrl = async (path) => {
122
+ const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
123
+ params: { file: path }
124
+ });
125
+ return data.attributes.url;
126
+ };
127
+ download = async (path) => {
128
+ const url = await this.downloadGetUrl(path);
129
+ const { data } = await axios.get(url, { responseType: "arraybuffer" });
130
+ return data;
131
+ };
132
+ rename = async (root = "/", files) => {
133
+ await this.r.put(`/servers/${this.id}/files/rename`, { root, files });
134
+ };
135
+ copy = async (location) => {
136
+ await this.r.post(`/servers/${this.id}/files/copy`, { location });
137
+ };
138
+ write = async (path, content) => {
139
+ await this.r.post(`/servers/${this.id}/files/write`, content, {
140
+ params: { file: path }
141
+ });
142
+ };
143
+ compress = async (root = "/", files, archive_name, extension) => {
144
+ await this.r.post(`/servers/${this.id}/files/compress`, { root, files, archive_name, extension });
145
+ };
146
+ decompress = async (root = "/", file) => {
147
+ await this.r.post(`/servers/${this.id}/files/decompress`, { root, file });
148
+ };
149
+ delete = async (root = "/", files) => {
150
+ await this.r.post(`/servers/${this.id}/files/delete`, { root, files });
151
+ };
152
+ createFolder = async (root = "/", name) => {
153
+ await this.r.post(`/servers/${this.id}/files/create-folder`, { root, name });
154
+ };
155
+ chmod = async (root = "/", files) => {
156
+ await this.r.post(`/servers/${this.id}/files/chmod`, { root, files });
157
+ };
158
+ pullFromRemote = async (url, directory, filename, use_header = false, foreground = false) => {
159
+ await this.r.post(`/servers/${this.id}/files/pull`, { url, directory, filename, use_header, foreground });
160
+ };
161
+ uploadGetUrl = async () => {
162
+ const { data } = await this.r.get(`/servers/${this.id}/files/upload`);
163
+ return data.attributes.url;
164
+ };
165
+ upload = async (file, root = "/") => {
166
+ const url = await this.uploadGetUrl();
167
+ await axios.post(url, { files: file }, {
168
+ headers: { "Content-Type": "multipart/form-data" },
169
+ params: { directory: root }
170
+ });
171
+ };
172
+ };
173
+
174
+ // src/api/client/server_schedules.ts
175
+ var ServerSchedules = class {
176
+ r;
177
+ id;
178
+ constructor(requester, id) {
179
+ this.r = requester;
180
+ this.id = id;
181
+ }
182
+ list = async () => {
183
+ const { data } = await this.r.get(`/servers/${this.id}/schedules`);
184
+ return data.data.map((d) => d.attributes);
185
+ };
186
+ create = async (params) => {
187
+ const { data } = await this.r.post(`/servers/${this.id}/schedules`, params);
188
+ return data.attributes;
189
+ };
190
+ control = (sched_id) => new ScheduleControl(this.r, this.id, sched_id);
191
+ };
192
+ var ScheduleControl = class {
193
+ r;
194
+ id;
195
+ sched_id;
196
+ constructor(requester, id, sched_id) {
197
+ this.r = requester;
198
+ this.id = id;
199
+ this.sched_id = sched_id;
200
+ }
201
+ info = async () => {
202
+ const { data } = await this.r.get(`/servers/${this.id}/schedules/${this.sched_id}`);
203
+ return data.attributes;
204
+ };
205
+ update = async (params) => {
206
+ const { data } = await this.r.post(`/servers/${this.id}/schedules/${this.sched_id}`, params);
207
+ return data.attributes;
208
+ };
209
+ delete = async () => {
210
+ await this.r.delete(`/servers/${this.id}/schedules/${this.sched_id}`);
211
+ };
212
+ execute = async () => {
213
+ await this.r.post(`/servers/${this.id}/schedules/${this.sched_id}/execute`);
214
+ };
215
+ tasks = {
216
+ create: async (opts) => {
217
+ const { data } = await this.r.post(`/servers/${this.id}/schedules/${this.sched_id}/tasks`, opts);
218
+ return data.attributes;
219
+ },
220
+ update: async (task_id, opts) => {
221
+ const { data } = await this.r.post(`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`, opts);
222
+ return data.attributes;
223
+ },
224
+ delete: async (task_id) => {
225
+ await this.r.delete(`/servers/${this.id}/schedules/${this.sched_id}/tasks/${task_id}`);
226
+ }
227
+ };
228
+ };
229
+
230
+ // src/api/client/server_allocations.ts
231
+ var ServerAllocations = class {
232
+ r;
233
+ id;
234
+ constructor(requester, id) {
235
+ this.r = requester;
236
+ this.id = id;
237
+ }
238
+ list = async () => {
239
+ const { data } = await this.r.get(`/servers/${this.id}/network/allocations`);
240
+ return data.data.map((r) => r.attributes);
241
+ };
242
+ autoAssign = async () => {
243
+ const { data } = await this.r.post(`/servers/${this.id}/network/allocations`);
244
+ return data.attributes;
245
+ };
246
+ setNotes = async (alloc_id, notes) => {
247
+ const { data } = await this.r.post(`/servers/${this.id}/network/allocations/${alloc_id}`, { notes });
248
+ return data.attributes;
249
+ };
250
+ setPrimary = async (alloc_id) => {
251
+ const { data } = await this.r.post(`/servers/${this.id}/network/allocations/${alloc_id}/primary`);
252
+ return data.attributes;
253
+ };
254
+ unassign = async (alloc_id) => {
255
+ await this.r.delete(`/servers/${this.id}/network/allocations/${alloc_id}`);
256
+ };
257
+ };
258
+
259
+ // src/api/client/server_users.ts
260
+ var ServerUsers = class {
261
+ r;
262
+ id;
263
+ constructor(requester, id) {
264
+ this.r = requester;
265
+ this.id = id;
266
+ }
267
+ list = async () => {
268
+ const { data } = await this.r.get(`/servers/${this.id}/users`);
269
+ return data.data.map((d) => d.attributes);
270
+ };
271
+ create = async (email, permissions) => {
272
+ const { data } = await this.r.post(`/servers/${this.id}/users`, { email, permissions });
273
+ return data.attributes;
274
+ };
275
+ info = async (user_id) => {
276
+ const { data } = await this.r.get(`/servers/${this.id}/users/${user_id}`);
277
+ return data.attributes;
278
+ };
279
+ update = async (user_id, permissions) => {
280
+ const { data } = await this.r.put(`/servers/${this.id}/users/${user_id}`, { permissions });
281
+ return data.attributes;
282
+ };
283
+ delete = async (user_id) => {
284
+ await this.r.delete(`/servers/${this.id}/users/${user_id}`);
285
+ };
286
+ };
287
+
288
+ // src/api/client/server_backups.ts
289
+ import axios2 from "axios";
290
+ import z3 from "zod";
291
+ var ServerBackups = class {
292
+ r;
293
+ id;
294
+ constructor(requester, id) {
295
+ this.r = requester;
296
+ this.id = id;
297
+ }
298
+ list = async (page = 1) => {
299
+ z3.number().positive().parse(page);
300
+ const { data } = await this.r.get(`/servers/${this.id}/backups`, {
301
+ params: { page }
302
+ });
303
+ return data.data.map((d) => d.attributes);
304
+ };
305
+ create = async (args) => {
306
+ args.name = z3.string().max(255).optional().parse(args.name);
307
+ const { data } = await this.r.post(`/servers/${this.id}/backups`, {
308
+ name: args.name,
309
+ is_locked: args.is_locked,
310
+ ignored_files: args.ignored_files.join("\n")
311
+ });
312
+ return data.attributes;
313
+ };
314
+ info = async (backup_uuid) => {
315
+ const { data } = await this.r.get(`/servers/${this.id}/backups/${backup_uuid}`);
316
+ return data.attributes;
317
+ };
318
+ downloadGetUrl = async (backup_uuid) => {
319
+ const { data } = await this.r.get(`/servers/${this.id}/backups/${backup_uuid}/download`);
320
+ return data.attributes.url;
321
+ };
322
+ download = async (backup_uuid) => {
323
+ const url = await this.downloadGetUrl(backup_uuid);
324
+ const { data } = await axios2.get(url, { responseType: "arraybuffer" });
325
+ return data;
326
+ };
327
+ delete = async (backup_uuid) => {
328
+ await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
329
+ };
330
+ };
331
+
332
+ // src/api/client/server_startup.ts
333
+ var ServerStartup = class {
334
+ r;
335
+ id;
336
+ constructor(requester, id) {
337
+ this.r = requester;
338
+ this.id = id;
339
+ }
340
+ list = async () => {
341
+ const { data } = await this.r.get(`/servers/${this.id}/startup`);
342
+ return {
343
+ object: "list",
344
+ meta: data.meta,
345
+ data: data.data.map((d) => d.attributes)
346
+ };
347
+ };
348
+ set = async (key, value) => {
349
+ const { data } = await this.r.put(`/servers/${this.id}/startup/variable`, { key, value });
350
+ return data.attributes;
351
+ };
352
+ };
353
+
354
+ // src/api/client/server_settings.ts
355
+ import z4 from "zod";
356
+ var ServerSettings = class {
357
+ r;
358
+ id;
359
+ constructor(requester, id) {
360
+ this.r = requester;
361
+ this.id = id;
362
+ }
363
+ rename = async (name) => {
364
+ name = z4.string().max(255).parse(name);
365
+ await this.r.post(`/servers/${this.id}/settings/rename`, { name });
366
+ };
367
+ updateDescription = async (description) => {
368
+ await this.r.post(`/servers/${this.id}/settings/description`, { description });
369
+ };
370
+ reinstall = async () => {
371
+ await this.r.post(`/servers/${this.id}/settings/reinstall`);
372
+ };
373
+ changeDockerImage = async (image) => {
374
+ await this.r.post(`/servers/${this.id}/settings/docker-image`, { image });
375
+ };
376
+ };
377
+
378
+ // src/api/client/server_websocket.ts
379
+ import { EventEmitter } from "events";
380
+ import WebSocket from "isomorphic-ws";
381
+ import stripColor from "strip-color";
382
+ var isBrowser = typeof window !== "undefined";
383
+ var RECONNECT_ERRORS = /* @__PURE__ */ new Set([
384
+ "jwt: exp claim is invalid",
385
+ "jwt: created too far in past (denylist)"
386
+ ]);
387
+ var FALLBACK_LOG_MESSAGE = "No logs - is the server online?";
388
+ var ServerWebsocket = class {
389
+ r;
390
+ serverId;
391
+ socket;
392
+ currentToken;
393
+ bus = new EventEmitter();
394
+ debugLogging = false;
395
+ stripColors;
396
+ detachMessageListener;
397
+ constructor(requester, id, stripColors = false) {
398
+ this.r = requester;
399
+ this.serverId = id;
400
+ this.stripColors = stripColors;
401
+ }
402
+ on(event, listener) {
403
+ const handler = listener;
404
+ this.bus.on(event, handler);
405
+ return () => {
406
+ this.bus.removeListener(event, handler);
407
+ };
408
+ }
409
+ deregister(event, listener) {
410
+ const handler = listener;
411
+ this.bus.removeListener(event, handler);
412
+ }
413
+ emit(event, ...args) {
414
+ if (args.length === 0) {
415
+ this.bus.emit(event);
416
+ } else {
417
+ this.bus.emit(event, args[0]);
418
+ }
419
+ }
420
+ async connect(resumable, debugLogging) {
421
+ this.debugLogging = debugLogging ?? false;
422
+ if (this.socket) {
423
+ return;
424
+ }
425
+ const socketUrl = await this.refreshCredentials();
426
+ this.socket = isBrowser ? new WebSocket(socketUrl) : new WebSocket(socketUrl, void 0, { origin: new URL(socketUrl).origin });
427
+ await new Promise((resolve, reject) => {
428
+ const socket = this.socket;
429
+ if (!socket) {
430
+ reject(new Error("Failed to create socket connection"));
431
+ return;
432
+ }
433
+ socket.onopen = async () => {
434
+ try {
435
+ await this.authenticate();
436
+ this.attachMessageListener();
437
+ socket.onopen = null;
438
+ socket.onerror = null;
439
+ resolve();
440
+ } catch (error) {
441
+ socket.onopen = null;
442
+ socket.onerror = null;
443
+ reject(error instanceof Error ? error : new Error("Websocket authentication failed"));
444
+ }
445
+ };
446
+ socket.onerror = (event) => {
447
+ socket.onopen = null;
448
+ socket.onerror = null;
449
+ reject(event instanceof Error ? event : new Error("Websocket connection error"));
450
+ };
451
+ });
452
+ if (resumable) {
453
+ this.makeResumable(true);
454
+ }
455
+ }
456
+ onSocketDisconnect(handler) {
457
+ if (!this.socket) {
458
+ console.error(new Error("No socket connection"));
459
+ return;
460
+ }
461
+ this.socket.onclose = handler;
462
+ }
463
+ onSocketError(handler) {
464
+ if (!this.socket) {
465
+ console.error(new Error("No socket connection"));
466
+ return;
467
+ }
468
+ this.socket.onerror = handler;
469
+ }
470
+ makeResumable(disconnectsToo) {
471
+ const scheduleReconnect = () => {
472
+ setTimeout(() => {
473
+ const previous = this.socket;
474
+ this.detachMessageListener?.();
475
+ this.detachMessageListener = void 0;
476
+ this.socket = void 0;
477
+ previous?.close();
478
+ void this.connect(true, this.debugLogging);
479
+ }, 1e3);
480
+ };
481
+ this.onSocketError(() => scheduleReconnect());
482
+ if (disconnectsToo) {
483
+ this.onSocketDisconnect(() => scheduleReconnect());
484
+ }
485
+ }
486
+ attachMessageListener() {
487
+ if (!this.socket) {
488
+ throw new Error("No socket connection");
489
+ }
490
+ this.detachMessageListener?.();
491
+ const handler = (event) => {
492
+ void this.handleIncomingMessage(event);
493
+ };
494
+ if (typeof this.socket.addEventListener === "function") {
495
+ this.socket.addEventListener("message", handler);
496
+ this.detachMessageListener = () => {
497
+ this.socket?.removeEventListener?.("message", handler);
498
+ };
499
+ } else {
500
+ const fallback = (data) => handler({ data });
501
+ const socket = this.socket;
502
+ socket.on?.("message", fallback);
503
+ this.detachMessageListener = () => {
504
+ const target = this.socket;
505
+ if (!target) {
506
+ return;
507
+ }
508
+ if (typeof target.off === "function") {
509
+ target.off("message", fallback);
510
+ } else if (typeof target.removeListener === "function") {
511
+ target.removeListener("message", fallback);
512
+ }
513
+ };
514
+ }
515
+ }
516
+ async handleIncomingMessage(event) {
517
+ const message = this.parseMessage(event);
518
+ if (!message) {
519
+ return;
520
+ }
521
+ try {
522
+ await this.dispatchMessage(message);
523
+ } catch (error) {
524
+ if (this.debugLogging) {
525
+ console.error("Error while handling websocket message", error);
526
+ }
527
+ }
528
+ }
529
+ parseMessage(event) {
530
+ const payload = this.normalisePayload(event);
531
+ if (!payload) {
532
+ return null;
533
+ }
534
+ try {
535
+ return JSON.parse(payload);
536
+ } catch (error) {
537
+ if (this.debugLogging) {
538
+ console.warn("Failed to parse websocket payload", error);
539
+ }
540
+ return null;
541
+ }
542
+ }
543
+ normalisePayload(event) {
544
+ if (typeof event === "string") {
545
+ return event;
546
+ }
547
+ if (typeof event === "object" && event !== null && "data" in event) {
548
+ return this.normalisePayload(event.data);
549
+ }
550
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer(event)) {
551
+ return event.toString("utf8");
552
+ }
553
+ if (typeof ArrayBuffer !== "undefined" && event instanceof ArrayBuffer) {
554
+ if (typeof TextDecoder !== "undefined") {
555
+ return new TextDecoder().decode(new Uint8Array(event));
556
+ }
557
+ if (typeof Buffer !== "undefined") {
558
+ return Buffer.from(event).toString("utf8");
559
+ }
560
+ }
561
+ return null;
562
+ }
563
+ async dispatchMessage(message) {
564
+ switch (message.event) {
565
+ case "auth success" /* AUTH_SUCCESS */: {
566
+ if (this.debugLogging) {
567
+ console.debug("Auth success");
568
+ }
569
+ this.emit("auth success" /* AUTH_SUCCESS */);
570
+ break;
571
+ }
572
+ case "status" /* STATUS */: {
573
+ if (this.debugLogging) {
574
+ console.debug("Received status event", message.args[0]);
575
+ }
576
+ this.emit("status" /* STATUS */, message.args[0]);
577
+ break;
578
+ }
579
+ case "console output" /* CONSOLE_OUTPUT */: {
580
+ let output = message.args[0];
581
+ if (this.stripColors) {
582
+ output = stripColor(output);
583
+ }
584
+ if (this.debugLogging) {
585
+ console.debug("Received console output", output);
586
+ }
587
+ this.emit("console output" /* CONSOLE_OUTPUT */, output);
588
+ break;
589
+ }
590
+ case "stats" /* STATS */: {
591
+ try {
592
+ const payload = JSON.parse(message.args[0]);
593
+ this.emit("stats" /* STATS */, payload);
594
+ } catch (error) {
595
+ if (this.debugLogging) {
596
+ console.warn("Failed to parse stats payload", error);
597
+ }
598
+ }
599
+ break;
600
+ }
601
+ case "daemon error" /* DAEMON_ERROR */: {
602
+ this.emit("daemon error" /* DAEMON_ERROR */);
603
+ break;
604
+ }
605
+ case "backup completed" /* BACKUP_COMPLETED */: {
606
+ try {
607
+ const payload = JSON.parse(message.args[0]);
608
+ this.emit("backup completed" /* BACKUP_COMPLETED */, payload);
609
+ } catch (error) {
610
+ if (this.debugLogging) {
611
+ console.warn("Failed to parse backup payload", error);
612
+ }
613
+ }
614
+ break;
615
+ }
616
+ case "daemon message" /* DAEMON_MESSAGE */: {
617
+ let output = message.args[0];
618
+ if (this.stripColors) {
619
+ output = stripColor(output);
620
+ }
621
+ this.emit("daemon message" /* DAEMON_MESSAGE */, output);
622
+ break;
623
+ }
624
+ case "install output" /* INSTALL_OUTPUT */: {
625
+ let output = message.args[0];
626
+ if (this.stripColors) {
627
+ output = stripColor(output);
628
+ }
629
+ this.emit("install output" /* INSTALL_OUTPUT */, output);
630
+ break;
631
+ }
632
+ case "backup restore completed" /* BACKUP_RESTORE_COMPLETED */: {
633
+ this.emit("backup restore completed" /* BACKUP_RESTORE_COMPLETED */);
634
+ break;
635
+ }
636
+ case "install completed" /* INSTALL_COMPLETED */: {
637
+ this.emit("install completed" /* INSTALL_COMPLETED */);
638
+ break;
639
+ }
640
+ case "install started" /* INSTALL_STARTED */: {
641
+ this.emit("install started" /* INSTALL_STARTED */);
642
+ break;
643
+ }
644
+ case "transfer logs" /* TRANSFER_LOGS */: {
645
+ this.emit("transfer logs" /* TRANSFER_LOGS */, message.args[0]);
646
+ break;
647
+ }
648
+ case "transfer status" /* TRANSFER_STATUS */: {
649
+ this.emit("transfer status" /* TRANSFER_STATUS */, message.args[0]);
650
+ break;
651
+ }
652
+ case "token expiring" /* TOKEN_EXPIRING */: {
653
+ this.emit("token expiring" /* TOKEN_EXPIRING */);
654
+ if (this.debugLogging) {
655
+ console.warn("Token expiring, renewing...");
656
+ }
657
+ await this.refreshCredentials();
658
+ await this.authenticate();
659
+ break;
660
+ }
661
+ case "token expired" /* TOKEN_EXPIRED */: {
662
+ this.emit("token expired" /* TOKEN_EXPIRED */);
663
+ throw new Error("Token expired");
664
+ }
665
+ case "jwt error" /* JWT_ERROR */: {
666
+ const reason = message.args[0];
667
+ if (RECONNECT_ERRORS.has(reason)) {
668
+ this.emit("token expiring" /* TOKEN_EXPIRING */);
669
+ if (this.debugLogging) {
670
+ console.warn("Token expiring (JWT error), renewing...");
671
+ }
672
+ await this.refreshCredentials();
673
+ await this.authenticate();
674
+ } else {
675
+ this.emit("jwt error" /* JWT_ERROR */, reason);
676
+ throw new Error("Token expired");
677
+ }
678
+ break;
679
+ }
680
+ default: {
681
+ if (this.debugLogging) {
682
+ console.warn("Unknown websocket event", message);
683
+ }
684
+ break;
685
+ }
686
+ }
687
+ }
688
+ async refreshCredentials() {
689
+ const { data } = await this.r.get(`/servers/${this.serverId}/websocket`);
690
+ this.currentToken = data.data.token;
691
+ return data.data.socket;
692
+ }
693
+ async authenticate() {
694
+ if (!this.socket) {
695
+ throw new Error("No socket connection");
696
+ }
697
+ if (!this.currentToken) {
698
+ throw new Error("Missing websocket token");
699
+ }
700
+ this.socket.send(JSON.stringify({ event: "auth", args: [this.currentToken] }));
701
+ }
702
+ disconnect() {
703
+ this.detachMessageListener?.();
704
+ this.detachMessageListener = void 0;
705
+ if (this.socket) {
706
+ this.socket.close();
707
+ this.socket = void 0;
708
+ }
709
+ }
710
+ requestStats() {
711
+ this.send("send stats", [null]);
712
+ }
713
+ requestLogs() {
714
+ this.send("send logs", [null]);
715
+ }
716
+ send(event, args) {
717
+ if (!this.socket) {
718
+ if (this.debugLogging) {
719
+ console.warn(`Attempted to send "${event}" without an active websocket connection`);
720
+ }
721
+ return;
722
+ }
723
+ this.socket.send(JSON.stringify({ event, args }));
724
+ }
725
+ getStats() {
726
+ return new Promise((resolve, reject) => {
727
+ if (!this.socket) {
728
+ reject(new Error("No socket connection"));
729
+ return;
730
+ }
731
+ let off;
732
+ const timeout = setTimeout(() => {
733
+ off?.();
734
+ reject(new Error("Timed out waiting for stats"));
735
+ }, 5e3);
736
+ off = this.on("stats" /* STATS */, (payload) => {
737
+ clearTimeout(timeout);
738
+ off?.();
739
+ resolve(payload);
740
+ });
741
+ this.requestStats();
742
+ });
743
+ }
744
+ getLogs() {
745
+ return new Promise((resolve, reject) => {
746
+ if (!this.socket) {
747
+ reject(new Error("No socket connection"));
748
+ return;
749
+ }
750
+ const lines = [];
751
+ let off;
752
+ let initialTimeout;
753
+ let idleTimeout;
754
+ const finalize = (payload) => {
755
+ off?.();
756
+ if (initialTimeout) {
757
+ clearTimeout(initialTimeout);
758
+ }
759
+ if (idleTimeout) {
760
+ clearTimeout(idleTimeout);
761
+ }
762
+ resolve(payload);
763
+ };
764
+ initialTimeout = setTimeout(() => {
765
+ finalize(lines.length > 0 ? lines : [FALLBACK_LOG_MESSAGE]);
766
+ }, 5e3);
767
+ off = this.on("console output" /* CONSOLE_OUTPUT */, (line) => {
768
+ lines.push(line);
769
+ if (initialTimeout) {
770
+ clearTimeout(initialTimeout);
771
+ initialTimeout = void 0;
772
+ }
773
+ if (idleTimeout) {
774
+ clearTimeout(idleTimeout);
775
+ }
776
+ idleTimeout = setTimeout(() => {
777
+ finalize(lines);
778
+ }, 1e3);
779
+ });
780
+ this.requestLogs();
781
+ });
782
+ }
783
+ sendPoweraction(action) {
784
+ this.send("set state", [action]);
785
+ }
786
+ sendCommand(cmd) {
787
+ this.send("send command", [cmd]);
788
+ }
789
+ };
790
+
791
+ // src/api/client/server_activity.ts
792
+ var ServerActivity = class {
793
+ r;
794
+ id;
795
+ constructor(r, id) {
796
+ this.r = r;
797
+ this.id = id;
798
+ }
799
+ list = async (page = 1, per_page = 25) => {
800
+ const { data } = await this.r.get(`/server/${this.id}/activity`, {
801
+ params: {
802
+ page,
803
+ per_page
804
+ }
805
+ });
806
+ return data.data.map((log) => log.attributes);
807
+ };
808
+ };
809
+
810
+ // src/api/client/server.ts
811
+ var ServerClient = class {
812
+ r;
813
+ id;
814
+ activity;
815
+ databases;
816
+ files;
817
+ schedules;
818
+ allocations;
819
+ users;
820
+ backups;
821
+ startup;
822
+ variables;
823
+ settings;
824
+ constructor(requester, id) {
825
+ this.r = requester;
826
+ this.id = id;
827
+ this.activity = new ServerActivity(requester, id);
828
+ this.databases = new ServerDatabases(requester, id);
829
+ this.files = new ServerFiles(requester, id);
830
+ this.schedules = new ServerSchedules(requester, id);
831
+ this.allocations = new ServerAllocations(requester, id);
832
+ this.users = new ServerUsers(requester, id);
833
+ this.backups = new ServerBackups(requester, id);
834
+ this.startup = new ServerStartup(requester, id);
835
+ this.variables = this.startup;
836
+ this.settings = new ServerSettings(requester, id);
837
+ }
838
+ info = async (include) => {
839
+ const { data } = await this.r.get(`/servers/${this.id}`, {
840
+ params: { include: include?.join(",") }
841
+ });
842
+ return data.attributes;
843
+ };
844
+ websocket = (stripColors = false) => {
845
+ return new ServerWebsocket(this.r, this.id, stripColors);
846
+ };
847
+ resources = async () => {
848
+ const { data } = await this.r.get(`/servers/${this.id}/resources`);
849
+ return data.attributes;
850
+ };
851
+ command = async (command) => {
852
+ await this.r.post(`/servers/${this.id}/command`, { command });
853
+ };
854
+ power = async (signal) => {
855
+ await this.r.post(`/servers/${this.id}/power`, { signal });
856
+ };
857
+ };
858
+
859
+ // src/api/client/client.ts
860
+ var Client = class {
861
+ account;
862
+ r;
863
+ constructor(requester) {
864
+ this.r = requester;
865
+ this.account = new Account(requester);
866
+ }
867
+ listPermissions = async () => {
868
+ const { data } = await this.r.get("/permissions");
869
+ return data.attributes.permissions;
870
+ };
871
+ listServers = async (type = "accessible", page = 1, per_page = 50, include) => {
872
+ z5.number().positive().parse(page);
873
+ const { data } = await this.r.get("/servers", {
874
+ params: { type, page, include: include?.join(",") }
875
+ });
876
+ return data.data.map((s) => s.attributes);
877
+ };
878
+ server = (uuid) => new ServerClient(this.r, uuid);
879
+ };
880
+
881
+ // src/api/application/users.ts
882
+ import z7 from "zod";
883
+
884
+ // src/utils/transform.ts
885
+ var ArrayQueryParams = (p) => {
886
+ const params = new URLSearchParams();
887
+ const o = {};
888
+ for (const [param, value] of Object.entries(p)) {
889
+ for (const [key, val] of Object.entries(value)) {
890
+ o[`${param}[${key}]`] = val;
891
+ }
892
+ }
893
+ return o;
894
+ };
895
+ var SortParam = (key, p) => {
896
+ return `${p === "desc" ? "-" : ""}${key}`;
897
+ };
898
+
899
+ // src/api/common/types/enums.ts
900
+ import z6 from "zod";
901
+ var languagesSchema = z6.enum([
902
+ "af",
903
+ "ak",
904
+ "am",
905
+ "ar",
906
+ "as",
907
+ "az",
908
+ "be",
909
+ "bg",
910
+ "bm",
911
+ "bn",
912
+ "bo",
913
+ "br",
914
+ "bs",
915
+ "ca",
916
+ "ce",
917
+ "cs",
918
+ "cv",
919
+ "cy",
920
+ "da",
921
+ "de",
922
+ "dz",
923
+ "ee",
924
+ "el",
925
+ "en",
926
+ "eo",
927
+ "es",
928
+ "et",
929
+ "eu",
930
+ "fa",
931
+ "ff",
932
+ "fi",
933
+ "fo",
934
+ "fr",
935
+ "fy",
936
+ "ga",
937
+ "gd",
938
+ "gl",
939
+ "gu",
940
+ "gv",
941
+ "ha",
942
+ "he",
943
+ "hi",
944
+ "hr",
945
+ "hu",
946
+ "hy",
947
+ "ia",
948
+ "id",
949
+ "ig",
950
+ "ii",
951
+ "is",
952
+ "it",
953
+ "ja",
954
+ "jv",
955
+ "ka",
956
+ "ki",
957
+ "kk",
958
+ "kl",
959
+ "km",
960
+ "kn",
961
+ "ko",
962
+ "ks",
963
+ "ku",
964
+ "kw",
965
+ "ky",
966
+ "lb",
967
+ "lg",
968
+ "ln",
969
+ "lo",
970
+ "lt",
971
+ "lu",
972
+ "lv",
973
+ "mg",
974
+ "mi",
975
+ "mk",
976
+ "ml",
977
+ "mn",
978
+ "mr",
979
+ "ms",
980
+ "mt",
981
+ "my",
982
+ "nb",
983
+ "nd",
984
+ "ne",
985
+ "nl",
986
+ "nn",
987
+ "no",
988
+ "om",
989
+ "or",
990
+ "os",
991
+ "pa",
992
+ "pl",
993
+ "ps",
994
+ "pt",
995
+ "qu",
996
+ "rm",
997
+ "rn",
998
+ "ro",
999
+ "ru",
1000
+ "rw",
1001
+ "sa",
1002
+ "sc",
1003
+ "sd",
1004
+ "se",
1005
+ "sg",
1006
+ "si",
1007
+ "sk",
1008
+ "sl",
1009
+ "sn",
1010
+ "so",
1011
+ "sq",
1012
+ "sr",
1013
+ "su",
1014
+ "sv",
1015
+ "sw",
1016
+ "ta",
1017
+ "te",
1018
+ "tg",
1019
+ "th",
1020
+ "ti",
1021
+ "tk",
1022
+ "to",
1023
+ "tr",
1024
+ "tt",
1025
+ "ug",
1026
+ "uk",
1027
+ "ur",
1028
+ "uz",
1029
+ "vi",
1030
+ "wo",
1031
+ "xh",
1032
+ "yi",
1033
+ "yo",
1034
+ "zh",
1035
+ "zu"
1036
+ ]);
1037
+ var timezonesSchema = z6.enum([
1038
+ "Africa/Abidjan",
1039
+ "Africa/Accra",
1040
+ "Africa/Addis_Ababa",
1041
+ "Africa/Algiers",
1042
+ "Africa/Asmara",
1043
+ "Africa/Bamako",
1044
+ "Africa/Bangui",
1045
+ "Africa/Banjul",
1046
+ "Africa/Bissau",
1047
+ "Africa/Blantyre",
1048
+ "Africa/Brazzaville",
1049
+ "Africa/Bujumbura",
1050
+ "Africa/Cairo",
1051
+ "Africa/Casablanca",
1052
+ "Africa/Ceuta",
1053
+ "Africa/Conakry",
1054
+ "Africa/Dakar",
1055
+ "Africa/Dar_es_Salaam",
1056
+ "Africa/Djibouti",
1057
+ "Africa/Douala",
1058
+ "Africa/El_Aaiun",
1059
+ "Africa/Freetown",
1060
+ "Africa/Gaborone",
1061
+ "Africa/Harare",
1062
+ "Africa/Johannesburg",
1063
+ "Africa/Juba",
1064
+ "Africa/Kampala",
1065
+ "Africa/Khartoum",
1066
+ "Africa/Kigali",
1067
+ "Africa/Kinshasa",
1068
+ "Africa/Lagos",
1069
+ "Africa/Libreville",
1070
+ "Africa/Lome",
1071
+ "Africa/Luanda",
1072
+ "Africa/Lubumbashi",
1073
+ "Africa/Lusaka",
1074
+ "Africa/Malabo",
1075
+ "Africa/Maputo",
1076
+ "Africa/Maseru",
1077
+ "Africa/Mbabane",
1078
+ "Africa/Mogadishu",
1079
+ "Africa/Monrovia",
1080
+ "Africa/Nairobi",
1081
+ "Africa/Ndjamena",
1082
+ "Africa/Niamey",
1083
+ "Africa/Nouakchott",
1084
+ "Africa/Ouagadougou",
1085
+ "Africa/Porto-Novo",
1086
+ "Africa/Sao_Tome",
1087
+ "Africa/Tripoli",
1088
+ "Africa/Tunis",
1089
+ "Africa/Windhoek",
1090
+ "America/Adak",
1091
+ "America/Anchorage",
1092
+ "America/Anguilla",
1093
+ "America/Antigua",
1094
+ "America/Araguaina",
1095
+ "America/Argentina/Buenos_Aires",
1096
+ "America/Argentina/Catamarca",
1097
+ "America/Argentina/Cordoba",
1098
+ "America/Argentina/Jujuy",
1099
+ "America/Argentina/La_Rioja",
1100
+ "America/Argentina/Mendoza",
1101
+ "America/Argentina/Rio_Gallegos",
1102
+ "America/Argentina/Salta",
1103
+ "America/Argentina/San_Juan",
1104
+ "America/Argentina/San_Luis",
1105
+ "America/Argentina/Tucuman",
1106
+ "America/Argentina/Ushuaia",
1107
+ "America/Aruba",
1108
+ "America/Asuncion",
1109
+ "America/Atikokan",
1110
+ "America/Bahia",
1111
+ "America/Bahia_Banderas",
1112
+ "America/Barbados",
1113
+ "America/Belem",
1114
+ "America/Belize",
1115
+ "America/Blanc-Sablon",
1116
+ "America/Boa_Vista",
1117
+ "America/Bogota",
1118
+ "America/Boise",
1119
+ "America/Cambridge_Bay",
1120
+ "America/Campo_Grande",
1121
+ "America/Cancun",
1122
+ "America/Caracas",
1123
+ "America/Cayenne",
1124
+ "America/Cayman",
1125
+ "America/Chicago",
1126
+ "America/Chihuahua",
1127
+ "America/Ciudad_Juarez",
1128
+ "America/Costa_Rica",
1129
+ "America/Coyhaique",
1130
+ "America/Creston",
1131
+ "America/Cuiaba",
1132
+ "America/Curacao",
1133
+ "America/Danmarkshavn",
1134
+ "America/Dawson",
1135
+ "America/Dawson_Creek",
1136
+ "America/Denver",
1137
+ "America/Detroit",
1138
+ "America/Dominica",
1139
+ "America/Edmonton",
1140
+ "America/Eirunepe",
1141
+ "America/El_Salvador",
1142
+ "America/Fort_Nelson",
1143
+ "America/Fortaleza",
1144
+ "America/Glace_Bay",
1145
+ "America/Goose_Bay",
1146
+ "America/Grand_Turk",
1147
+ "America/Grenada",
1148
+ "America/Guadeloupe",
1149
+ "America/Guatemala",
1150
+ "America/Guayaquil",
1151
+ "America/Guyana",
1152
+ "America/Halifax",
1153
+ "America/Havana",
1154
+ "America/Hermosillo",
1155
+ "America/Indiana/Indianapolis",
1156
+ "America/Indiana/Knox",
1157
+ "America/Indiana/Marengo",
1158
+ "America/Indiana/Petersburg",
1159
+ "America/Indiana/Tell_City",
1160
+ "America/Indiana/Vevay",
1161
+ "America/Indiana/Vincennes",
1162
+ "America/Indiana/Winamac",
1163
+ "America/Inuvik",
1164
+ "America/Iqaluit",
1165
+ "America/Jamaica",
1166
+ "America/Juneau",
1167
+ "America/Kentucky/Louisville",
1168
+ "America/Kentucky/Monticello",
1169
+ "America/Kralendijk",
1170
+ "America/La_Paz",
1171
+ "America/Lima",
1172
+ "America/Los_Angeles",
1173
+ "America/Lower_Princes",
1174
+ "America/Maceio",
1175
+ "America/Managua",
1176
+ "America/Manaus",
1177
+ "America/Marigot",
1178
+ "America/Martinique",
1179
+ "America/Matamoros",
1180
+ "America/Mazatlan",
1181
+ "America/Menominee",
1182
+ "America/Merida",
1183
+ "America/Metlakatla",
1184
+ "America/Mexico_City",
1185
+ "America/Miquelon",
1186
+ "America/Moncton",
1187
+ "America/Monterrey",
1188
+ "America/Montevideo",
1189
+ "America/Montserrat",
1190
+ "America/Nassau",
1191
+ "America/New_York",
1192
+ "America/Nome",
1193
+ "America/Noronha",
1194
+ "America/North_Dakota/Beulah",
1195
+ "America/North_Dakota/Center",
1196
+ "America/North_Dakota/New_Salem",
1197
+ "America/Nuuk",
1198
+ "America/Ojinaga",
1199
+ "America/Panama",
1200
+ "America/Paramaribo",
1201
+ "America/Phoenix",
1202
+ "America/Port-au-Prince",
1203
+ "America/Port_of_Spain",
1204
+ "America/Porto_Velho",
1205
+ "America/Puerto_Rico",
1206
+ "America/Punta_Arenas",
1207
+ "America/Rankin_Inlet",
1208
+ "America/Recife",
1209
+ "America/Regina",
1210
+ "America/Resolute",
1211
+ "America/Rio_Branco",
1212
+ "America/Santarem",
1213
+ "America/Santiago",
1214
+ "America/Santo_Domingo",
1215
+ "America/Sao_Paulo",
1216
+ "America/Scoresbysund",
1217
+ "America/Sitka",
1218
+ "America/St_Barthelemy",
1219
+ "America/St_Johns",
1220
+ "America/St_Kitts",
1221
+ "America/St_Lucia",
1222
+ "America/St_Thomas",
1223
+ "America/St_Vincent",
1224
+ "America/Swift_Current",
1225
+ "America/Tegucigalpa",
1226
+ "America/Thule",
1227
+ "America/Tijuana",
1228
+ "America/Toronto",
1229
+ "America/Tortola",
1230
+ "America/Vancouver",
1231
+ "America/Whitehorse",
1232
+ "America/Winnipeg",
1233
+ "America/Yakutat",
1234
+ "Antarctica/Casey",
1235
+ "Antarctica/Davis",
1236
+ "Antarctica/DumontDUrville",
1237
+ "Antarctica/Macquarie",
1238
+ "Antarctica/Mawson",
1239
+ "Antarctica/McMurdo",
1240
+ "Antarctica/Palmer",
1241
+ "Antarctica/Rothera",
1242
+ "Antarctica/Syowa",
1243
+ "Antarctica/Troll",
1244
+ "Antarctica/Vostok",
1245
+ "Arctic/Longyearbyen",
1246
+ "Asia/Aden",
1247
+ "Asia/Almaty",
1248
+ "Asia/Amman",
1249
+ "Asia/Anadyr",
1250
+ "Asia/Aqtau",
1251
+ "Asia/Aqtobe",
1252
+ "Asia/Ashgabat",
1253
+ "Asia/Atyrau",
1254
+ "Asia/Baghdad",
1255
+ "Asia/Bahrain",
1256
+ "Asia/Baku",
1257
+ "Asia/Bangkok",
1258
+ "Asia/Barnaul",
1259
+ "Asia/Beirut",
1260
+ "Asia/Bishkek",
1261
+ "Asia/Brunei",
1262
+ "Asia/Chita",
1263
+ "Asia/Colombo",
1264
+ "Asia/Damascus",
1265
+ "Asia/Dhaka",
1266
+ "Asia/Dili",
1267
+ "Asia/Dubai",
1268
+ "Asia/Dushanbe",
1269
+ "Asia/Famagusta",
1270
+ "Asia/Gaza",
1271
+ "Asia/Hebron",
1272
+ "Asia/Ho_Chi_Minh",
1273
+ "Asia/Hong_Kong",
1274
+ "Asia/Hovd",
1275
+ "Asia/Irkutsk",
1276
+ "Asia/Jakarta",
1277
+ "Asia/Jayapura",
1278
+ "Asia/Jerusalem",
1279
+ "Asia/Kabul",
1280
+ "Asia/Kamchatka",
1281
+ "Asia/Karachi",
1282
+ "Asia/Kathmandu",
1283
+ "Asia/Khandyga",
1284
+ "Asia/Kolkata",
1285
+ "Asia/Krasnoyarsk",
1286
+ "Asia/Kuala_Lumpur",
1287
+ "Asia/Kuching",
1288
+ "Asia/Kuwait",
1289
+ "Asia/Macau",
1290
+ "Asia/Magadan",
1291
+ "Asia/Makassar",
1292
+ "Asia/Manila",
1293
+ "Asia/Muscat",
1294
+ "Asia/Nicosia",
1295
+ "Asia/Novokuznetsk",
1296
+ "Asia/Novosibirsk",
1297
+ "Asia/Omsk",
1298
+ "Asia/Oral",
1299
+ "Asia/Phnom_Penh",
1300
+ "Asia/Pontianak",
1301
+ "Asia/Pyongyang",
1302
+ "Asia/Qatar",
1303
+ "Asia/Qostanay",
1304
+ "Asia/Qyzylorda",
1305
+ "Asia/Riyadh",
1306
+ "Asia/Sakhalin",
1307
+ "Asia/Samarkand",
1308
+ "Asia/Seoul",
1309
+ "Asia/Shanghai",
1310
+ "Asia/Singapore",
1311
+ "Asia/Srednekolymsk",
1312
+ "Asia/Taipei",
1313
+ "Asia/Tashkent",
1314
+ "Asia/Tbilisi",
1315
+ "Asia/Tehran",
1316
+ "Asia/Thimphu",
1317
+ "Asia/Tokyo",
1318
+ "Asia/Tomsk",
1319
+ "Asia/Ulaanbaatar",
1320
+ "Asia/Urumqi",
1321
+ "Asia/Ust-Nera",
1322
+ "Asia/Vientiane",
1323
+ "Asia/Vladivostok",
1324
+ "Asia/Yakutsk",
1325
+ "Asia/Yangon",
1326
+ "Asia/Yekaterinburg",
1327
+ "Asia/Yerevan",
1328
+ "Atlantic/Azores",
1329
+ "Atlantic/Bermuda",
1330
+ "Atlantic/Canary",
1331
+ "Atlantic/Cape_Verde",
1332
+ "Atlantic/Faroe",
1333
+ "Atlantic/Madeira",
1334
+ "Atlantic/Reykjavik",
1335
+ "Atlantic/South_Georgia",
1336
+ "Atlantic/St_Helena",
1337
+ "Atlantic/Stanley",
1338
+ "Australia/Adelaide",
1339
+ "Australia/Brisbane",
1340
+ "Australia/Broken_Hill",
1341
+ "Australia/Darwin",
1342
+ "Australia/Eucla",
1343
+ "Australia/Hobart",
1344
+ "Australia/Lindeman",
1345
+ "Australia/Lord_Howe",
1346
+ "Australia/Melbourne",
1347
+ "Australia/Perth",
1348
+ "Australia/Sydney",
1349
+ "Europe/Amsterdam",
1350
+ "Europe/Andorra",
1351
+ "Europe/Astrakhan",
1352
+ "Europe/Athens",
1353
+ "Europe/Belgrade",
1354
+ "Europe/Berlin",
1355
+ "Europe/Bratislava",
1356
+ "Europe/Brussels",
1357
+ "Europe/Bucharest",
1358
+ "Europe/Budapest",
1359
+ "Europe/Busingen",
1360
+ "Europe/Chisinau",
1361
+ "Europe/Copenhagen",
1362
+ "Europe/Dublin",
1363
+ "Europe/Gibraltar",
1364
+ "Europe/Guernsey",
1365
+ "Europe/Helsinki",
1366
+ "Europe/Isle_of_Man",
1367
+ "Europe/Istanbul",
1368
+ "Europe/Jersey",
1369
+ "Europe/Kaliningrad",
1370
+ "Europe/Kirov",
1371
+ "Europe/Kyiv",
1372
+ "Europe/Lisbon",
1373
+ "Europe/Ljubljana",
1374
+ "Europe/London",
1375
+ "Europe/Luxembourg",
1376
+ "Europe/Madrid",
1377
+ "Europe/Malta",
1378
+ "Europe/Mariehamn",
1379
+ "Europe/Minsk",
1380
+ "Europe/Monaco",
1381
+ "Europe/Moscow",
1382
+ "Europe/Oslo",
1383
+ "Europe/Paris",
1384
+ "Europe/Podgorica",
1385
+ "Europe/Prague",
1386
+ "Europe/Riga",
1387
+ "Europe/Rome",
1388
+ "Europe/Samara",
1389
+ "Europe/San_Marino",
1390
+ "Europe/Sarajevo",
1391
+ "Europe/Saratov",
1392
+ "Europe/Simferopol",
1393
+ "Europe/Skopje",
1394
+ "Europe/Sofia",
1395
+ "Europe/Stockholm",
1396
+ "Europe/Tallinn",
1397
+ "Europe/Tirane",
1398
+ "Europe/Ulyanovsk",
1399
+ "Europe/Vaduz",
1400
+ "Europe/Vatican",
1401
+ "Europe/Vienna",
1402
+ "Europe/Vilnius",
1403
+ "Europe/Volgograd",
1404
+ "Europe/Warsaw",
1405
+ "Europe/Zagreb",
1406
+ "Europe/Zurich",
1407
+ "Indian/Antananarivo",
1408
+ "Indian/Chagos",
1409
+ "Indian/Christmas",
1410
+ "Indian/Cocos",
1411
+ "Indian/Comoro",
1412
+ "Indian/Kerguelen",
1413
+ "Indian/Mahe",
1414
+ "Indian/Maldives",
1415
+ "Indian/Mauritius",
1416
+ "Indian/Mayotte",
1417
+ "Indian/Reunion",
1418
+ "Pacific/Apia",
1419
+ "Pacific/Auckland",
1420
+ "Pacific/Bougainville",
1421
+ "Pacific/Chatham",
1422
+ "Pacific/Chuuk",
1423
+ "Pacific/Easter",
1424
+ "Pacific/Efate",
1425
+ "Pacific/Fakaofo",
1426
+ "Pacific/Fiji",
1427
+ "Pacific/Funafuti",
1428
+ "Pacific/Galapagos",
1429
+ "Pacific/Gambier",
1430
+ "Pacific/Guadalcanal",
1431
+ "Pacific/Guam",
1432
+ "Pacific/Honolulu",
1433
+ "Pacific/Kanton",
1434
+ "Pacific/Kiritimati",
1435
+ "Pacific/Kosrae",
1436
+ "Pacific/Kwajalein",
1437
+ "Pacific/Majuro",
1438
+ "Pacific/Marquesas",
1439
+ "Pacific/Midway",
1440
+ "Pacific/Nauru",
1441
+ "Pacific/Niue",
1442
+ "Pacific/Norfolk",
1443
+ "Pacific/Noumea",
1444
+ "Pacific/Pago_Pago",
1445
+ "Pacific/Palau",
1446
+ "Pacific/Pitcairn",
1447
+ "Pacific/Pohnpei",
1448
+ "Pacific/Port_Moresby",
1449
+ "Pacific/Rarotonga",
1450
+ "Pacific/Saipan",
1451
+ "Pacific/Tahiti",
1452
+ "Pacific/Tarawa",
1453
+ "Pacific/Tongatapu",
1454
+ "Pacific/Wake",
1455
+ "Pacific/Wallis",
1456
+ "UTC"
1457
+ ]);
1458
+
1459
+ // src/api/application/users.ts
1460
+ var Users = class {
1461
+ r;
1462
+ constructor(requester) {
1463
+ this.r = requester;
1464
+ }
1465
+ list = async (opts, page = 1) => {
1466
+ z7.number().positive().parse(page);
1467
+ const { data } = await this.r.get("/users", {
1468
+ params: {
1469
+ include: opts.include?.join(","),
1470
+ page,
1471
+ ...ArrayQueryParams({ filters: opts.filters || {} }),
1472
+ sort: opts.sort?.id ? SortParam("id", opts.sort?.id) : SortParam("uuid", opts.sort?.uuid)
1473
+ }
1474
+ });
1475
+ return data.data.map((d) => d.attributes);
1476
+ };
1477
+ info = async (id, { include }) => {
1478
+ z7.number().positive().parse(id);
1479
+ const { data } = await this.r.get(`/users/${id}`, {
1480
+ params: { include: include?.join(",") }
1481
+ });
1482
+ return data.attributes;
1483
+ };
1484
+ infoByExternal = async (external_id, { include }) => {
1485
+ const { data } = await this.r.get(`/users/external/${external_id}`, {
1486
+ params: { include: include?.join(",") }
1487
+ });
1488
+ return data.attributes;
1489
+ };
1490
+ create = async (user) => {
1491
+ user = CreateSchema.parse(user);
1492
+ const { data } = await this.r.post("/users", user);
1493
+ return data.attributes;
1494
+ };
1495
+ update = async (id, user) => {
1496
+ user = CreateSchema.parse(user);
1497
+ const { data } = await this.r.patch(`/users/${id}`, user);
1498
+ return data.attributes;
1499
+ };
1500
+ delete = async (id) => {
1501
+ z7.number().positive().parse(id);
1502
+ await this.r.delete(`/users/${id}`);
1503
+ };
1504
+ addRoles = async (id, roles) => {
1505
+ z7.number().positive().parse(id);
1506
+ await this.r.patch(`/users/${id}/roles/assign`, { roles });
1507
+ };
1508
+ removeRoles = async (id, roles) => {
1509
+ z7.number().positive().parse(id);
1510
+ await this.r.patch(`/users/${id}/roles/remove`, { roles });
1511
+ };
1512
+ };
1513
+ var CreateSchema = z7.object({
1514
+ email: z7.email(),
1515
+ external_id: z7.string().max(255).optional(),
1516
+ username: z7.string().min(1).max(255),
1517
+ password: z7.string().optional(),
1518
+ language: languagesSchema,
1519
+ timezone: timezonesSchema
1520
+ });
1521
+
1522
+ // src/api/application/nodes_allocations.ts
1523
+ import z8 from "zod";
1524
+ var NodesAllocations = class {
1525
+ r;
1526
+ id;
1527
+ constructor(requester, id) {
1528
+ this.r = requester;
1529
+ this.id = id;
1530
+ }
1531
+ list = async (include) => {
1532
+ const { data } = await this.r.get(`/nodes/${this.id}/allocations`, {
1533
+ params: { include: include?.join(",") }
1534
+ });
1535
+ return data.data.map((d) => d.attributes);
1536
+ };
1537
+ create = async (ip, ports, alias) => {
1538
+ z8.ipv4().parse(ip);
1539
+ z8.ipv4().or(z8.url().max(255)).optional().parse(alias);
1540
+ z8.array(z8.number()).or(z8.string().regex(/\d+-\d+/)).parse(ports);
1541
+ await this.r.post(`/nodes/${this.id}/allocations`, {
1542
+ ip,
1543
+ ports,
1544
+ alias
1545
+ });
1546
+ };
1547
+ delete = async (alloc_id) => {
1548
+ await this.r.delete(`/nodes/${this.id}/allocations/${alloc_id}`);
1549
+ };
1550
+ };
1551
+
1552
+ // src/api/application/nodes.ts
1553
+ import z9 from "zod";
1554
+ var Nodes = class {
1555
+ r;
1556
+ constructor(requester) {
1557
+ this.r = requester;
1558
+ }
1559
+ list = async (include, page = 1) => {
1560
+ z9.number().positive().parse(page);
1561
+ const { data } = await this.r.get("/nodes", {
1562
+ params: { include: include?.join(","), page }
1563
+ });
1564
+ return data.data.map((s) => s.attributes);
1565
+ };
1566
+ listDeployable = async (filters, include, page = 1) => {
1567
+ z9.number().positive().parse(page);
1568
+ const { data } = await this.r.get("/nodes/deployable", {
1569
+ params: {
1570
+ include: include?.join(","),
1571
+ disk: filters.disk,
1572
+ memory: filters.memory,
1573
+ cpu: filters.cpu,
1574
+ location_ids: filters.location_ids,
1575
+ tags: filters.tags,
1576
+ page
1577
+ }
1578
+ });
1579
+ return data.data.map((s) => s.attributes);
1580
+ };
1581
+ info = async (id, include) => {
1582
+ z9.number().positive().parse(id);
1583
+ const { data } = await this.r.get(`/nodes/${id}`, {
1584
+ params: { include: include?.join(",") }
1585
+ });
1586
+ return data.attributes;
1587
+ };
1588
+ create = async (node) => {
1589
+ node = NodeCreateSchema.parse(node);
1590
+ const { data } = await this.r.post("/nodes", node);
1591
+ return data.attributes;
1592
+ };
1593
+ get_configuration = async (id) => {
1594
+ z9.number().positive().parse(id);
1595
+ const { data } = await this.r.get(`/nodes/${id}/configuration`);
1596
+ return data;
1597
+ };
1598
+ update = async (id, node) => {
1599
+ z9.number().positive().parse(id);
1600
+ node = NodeCreateSchema.parse(node);
1601
+ const { data } = await this.r.patch(`/nodes/${id}`, node);
1602
+ return data.attributes;
1603
+ };
1604
+ delete = async (id) => {
1605
+ z9.number().positive().parse(id);
1606
+ await this.r.delete(`/nodes/${id}`);
1607
+ };
1608
+ allocations = (server_id) => new NodesAllocations(this.r, server_id);
1609
+ };
1610
+ var NodeCreateSchema = z9.object({
1611
+ name: z9.string().min(1).max(100),
1612
+ description: z9.string().optional(),
1613
+ public: z9.boolean().optional(),
1614
+ fqdn: z9.string().nonempty(),
1615
+ scheme: z9.enum(["http", "https"]),
1616
+ behind_proxy: z9.boolean().optional(),
1617
+ memory: z9.number().min(0),
1618
+ memory_overallocate: z9.number().min(-1),
1619
+ disk: z9.number().min(0),
1620
+ disk_overallocate: z9.number().min(-1),
1621
+ cpu: z9.number().min(0),
1622
+ cpu_overallocate: z9.number().min(-1),
1623
+ daemon_base: z9.string().nonempty().optional(),
1624
+ daemon_sftp: z9.number().min(1).max(65535),
1625
+ daemon_sftp_alias: z9.string().optional(),
1626
+ daemon_listen: z9.number().min(1).max(65535),
1627
+ daemon_connect: z9.number().min(1).max(65535),
1628
+ maintenance_mode: z9.boolean().optional(),
1629
+ upload_size: z9.number().min(1).max(1024),
1630
+ tags: z9.array(z9.string()).optional()
1631
+ });
1632
+
1633
+ // src/api/application/servers.ts
1634
+ import z11 from "zod";
1635
+
1636
+ // src/api/application/servers_databases.ts
1637
+ import z10 from "zod";
1638
+ var ServersDatabases = class {
1639
+ r;
1640
+ id;
1641
+ constructor(r, server_id) {
1642
+ this.r = r;
1643
+ this.id = server_id;
1644
+ }
1645
+ list = async () => {
1646
+ const { data } = await this.r.get(`/servers/${this.id}/databases`);
1647
+ return data.data.map((d) => d.attributes);
1648
+ };
1649
+ create = async (database, remote, host) => {
1650
+ database = z10.string().min(1).max(48).parse(database);
1651
+ const { data } = await this.r.post(`/servers/${this.id}/databases`, { database, remote, host });
1652
+ return data.attributes;
1653
+ };
1654
+ info = async (database_id) => {
1655
+ const { data } = await this.r.get(`/servers/${this.id}/databases/${database_id}`);
1656
+ return data.attributes;
1657
+ };
1658
+ delete = async (database_id) => {
1659
+ await this.r.delete(`/servers/${this.id}/databases/${database_id}`);
1660
+ };
1661
+ resetPassword = async (database_id) => {
1662
+ await this.r.post(`/servers/${this.id}/databases/${database_id}/reset-password`);
1663
+ };
1664
+ };
1665
+
1666
+ // src/api/application/servers.ts
1667
+ var Servers = class {
1668
+ r;
1669
+ id;
1670
+ databases;
1671
+ constructor(r, server_id) {
1672
+ this.r = r;
1673
+ this.id = server_id;
1674
+ this.databases = new ServersDatabases(this.r, this.id);
1675
+ }
1676
+ info = async (include) => {
1677
+ const { data } = await this.r.get(`/servers/${this.id}`, {
1678
+ params: { include: include?.join(",") }
1679
+ });
1680
+ return data.attributes;
1681
+ };
1682
+ delete = async (force = false) => {
1683
+ await this.r.delete(`/servers/${this.id}${force ? "/force" : ""}`);
1684
+ };
1685
+ updateDetails = async (opts) => {
1686
+ opts = UpdateDetailsSchema.parse(opts);
1687
+ await this.r.patch(`/servers/${this.id}/details`, opts);
1688
+ };
1689
+ updateBuild = async (opts) => {
1690
+ opts = UpdateBuildSchema.parse(opts);
1691
+ await this.r.patch(`/servers/${this.id}/build`, opts);
1692
+ };
1693
+ updateStartup = async (opts) => {
1694
+ opts = UpdateStartupSchema.parse(opts);
1695
+ await this.r.patch(`/servers/${this.id}/startup`, opts);
1696
+ };
1697
+ suspend = async () => {
1698
+ await this.r.post(`/servers/${this.id}/suspend`);
1699
+ };
1700
+ unsuspend = async () => {
1701
+ await this.r.post(`/servers/${this.id}/unsuspend`);
1702
+ };
1703
+ reinstall = async () => {
1704
+ await this.r.post(`/servers/${this.id}/reinstall`);
1705
+ };
1706
+ transferStart = async (node_id, allocation_id, allocation_additional) => {
1707
+ await this.r.post(`/servers/${this.id}/transfer`, {
1708
+ node_id,
1709
+ allocation_id,
1710
+ allocation_additional
1711
+ });
1712
+ };
1713
+ transferCancel = async () => {
1714
+ await this.r.post(`/servers/${this.id}/transfer/cancel`);
1715
+ };
1716
+ };
1717
+ var CreateServerSchema = z11.object({
1718
+ external_id: z11.string().min(1).max(255).optional(),
1719
+ name: z11.string().min(1).max(255),
1720
+ description: z11.string().optional(),
1721
+ user: z11.number(),
1722
+ egg: z11.number(),
1723
+ docker_image: z11.string().optional(),
1724
+ startup: z11.string().optional(),
1725
+ environment: z11.array(z11.string()),
1726
+ skip_scripts: z11.boolean().optional(),
1727
+ oom_killer: z11.boolean().optional(),
1728
+ start_on_completion: z11.boolean().optional(),
1729
+ limits: z11.object({
1730
+ memory: z11.number().min(0),
1731
+ swap: z11.number().min(-1),
1732
+ disk: z11.number().min(0),
1733
+ io: z11.number().min(0),
1734
+ threads: z11.string().optional(),
1735
+ cpu: z11.number().min(0)
1736
+ }),
1737
+ feature_limits: z11.object({
1738
+ databases: z11.number().min(0),
1739
+ allocations: z11.number().min(0),
1740
+ backups: z11.number().min(0)
1741
+ }),
1742
+ allocation: z11.object({
1743
+ default: z11.string(),
1744
+ additional: z11.array(z11.string()).optional()
1745
+ }).optional(),
1746
+ deploy: z11.object({
1747
+ tags: z11.array(z11.string()).optional(),
1748
+ dedicated_ip: z11.boolean().optional(),
1749
+ port_range: z11.array(z11.string()).optional()
1750
+ }).optional()
1751
+ });
1752
+ var UpdateDetailsSchema = CreateServerSchema.pick({
1753
+ external_id: true,
1754
+ name: true,
1755
+ user: true,
1756
+ description: true
1757
+ });
1758
+ var UpdateBuildSchema = CreateServerSchema.pick({
1759
+ oom_killer: true,
1760
+ limits: true,
1761
+ feature_limits: true
1762
+ }).extend({
1763
+ allocation: z11.number().optional(),
1764
+ add_allocations: z11.array(z11.string()).optional(),
1765
+ remove_allocations: z11.array(z11.string()).optional()
1766
+ });
1767
+ var UpdateStartupSchema = CreateServerSchema.pick({
1768
+ startup: true,
1769
+ environment: true,
1770
+ egg: true,
1771
+ skip_scripts: true
1772
+ }).extend({
1773
+ image: z11.string().optional()
1774
+ });
1775
+
1776
+ // src/api/application/database_hosts.ts
1777
+ import z12 from "zod";
1778
+ var DatabaseHosts = class {
1779
+ r;
1780
+ constructor(r) {
1781
+ this.r = r;
1782
+ }
1783
+ list = async (page = 1) => {
1784
+ const { data } = await this.r.get("/database-hosts", {
1785
+ params: { page }
1786
+ });
1787
+ return data.data.map((d) => d.attributes);
1788
+ };
1789
+ info = async (id) => {
1790
+ const { data } = await this.r.get(`/database-hosts/${id}`);
1791
+ return data.attributes;
1792
+ };
1793
+ // TODO: find out why API returns 500
1794
+ create = async (opts) => {
1795
+ opts = CreateDBHostSchema.parse(opts);
1796
+ await this.r.post("/database-hosts", opts).catch((e) => {
1797
+ });
1798
+ };
1799
+ update = async (id, opts) => {
1800
+ opts = CreateDBHostSchema.parse(opts);
1801
+ const { data } = await this.r.patch(`/database-hosts/${id}`, opts);
1802
+ return data.attributes;
1803
+ };
1804
+ delete = async (id) => {
1805
+ await this.r.delete(`/database-hosts/${id}`);
1806
+ };
1807
+ };
1808
+ var CreateDBHostSchema = z12.object({
1809
+ name: z12.string().min(1).max(255),
1810
+ host: z12.string(),
1811
+ port: z12.number().min(1).max(65535),
1812
+ username: z12.string().min(1).max(255),
1813
+ password: z12.string().optional(),
1814
+ node_ids: z12.array(z12.string()).optional(),
1815
+ max_databases: z12.number().optional()
1816
+ });
1817
+
1818
+ // src/api/application/roles.ts
1819
+ var Roles = class {
1820
+ r;
1821
+ constructor(r) {
1822
+ this.r = r;
1823
+ }
1824
+ list = async (page = 1) => {
1825
+ const { data } = await this.r.get(`/roles`, {
1826
+ params: { page }
1827
+ });
1828
+ return data.data.map((r) => r.attributes);
1829
+ };
1830
+ info = async (id) => {
1831
+ const { data } = await this.r.get(`/roles/${id}`);
1832
+ return data.attributes;
1833
+ };
1834
+ create = async (opts) => {
1835
+ await this.r.post(`/roles`, opts);
1836
+ };
1837
+ update = async (id, opts) => {
1838
+ await this.r.patch(`/roles/${id}`, opts);
1839
+ };
1840
+ delete = async (id) => {
1841
+ await this.r.delete(`/roles/${id}`);
1842
+ };
1843
+ };
1844
+
1845
+ // src/api/application/client.ts
1846
+ var Client2 = class {
1847
+ r;
1848
+ users;
1849
+ nodes;
1850
+ databaseHosts;
1851
+ roles;
1852
+ constructor(requester) {
1853
+ this.r = requester;
1854
+ this.users = new Users(requester);
1855
+ this.nodes = new Nodes(requester);
1856
+ this.databaseHosts = new DatabaseHosts(requester);
1857
+ this.roles = new Roles(requester);
1858
+ }
1859
+ listServers = async (search, page = 1) => {
1860
+ const { data } = await this.r.get("/servers", {
1861
+ params: { search, page }
1862
+ });
1863
+ return data.data.map((s) => s.attributes);
1864
+ };
1865
+ createServer = async (opts) => {
1866
+ opts = CreateServerSchema.parse(opts);
1867
+ const { data } = await this.r.post("/servers", opts);
1868
+ return data.attributes;
1869
+ };
1870
+ getServerByExternalId = async (external_id, include) => {
1871
+ const { data } = await this.r.get(`/servers/external/${external_id}`, {
1872
+ params: { include: include?.join(",") }
1873
+ });
1874
+ return data.attributes;
1875
+ };
1876
+ servers = (server_id) => new Servers(this.r, server_id);
1877
+ };
1878
+
1879
+ // src/api/base/request.ts
1880
+ import z13 from "zod";
1881
+ import axios3 from "axios";
1882
+
1883
+ // src/api/base/types.ts
1884
+ var PterodactylException = class extends Error {
1885
+ data;
1886
+ status;
1887
+ constructor(message, data, status) {
1888
+ super(message);
1889
+ this.data = data;
1890
+ this.status = status;
1891
+ }
1892
+ };
1893
+
1894
+ // src/api/base/request.ts
1895
+ var Agent = class {
1896
+ base_url;
1897
+ token;
1898
+ requester;
1899
+ constructor(url, token, type, suffix = "/api") {
1900
+ this.base_url = z13.url("Invalid URL Schema").transform((url2) => new URL(url2).href).parse(url);
1901
+ this.token = z13.string().regex(/^(ptl[ac]|pacc|papp)_.+$/, "Invalid token type").parse(token);
1902
+ this.requester = axios3.create({
1903
+ baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
1904
+ timeout: 3e3,
1905
+ headers: {
1906
+ Authorization: `Bearer ${this.token}`
1907
+ }
1908
+ });
1909
+ this.requester.interceptors.response.use(void 0, (error) => {
1910
+ if (error.response && error.response.status === 400) {
1911
+ return Promise.reject(new PterodactylException(
1912
+ "Invalid request data",
1913
+ error.response.data,
1914
+ error.response.status
1915
+ ));
1916
+ }
1917
+ return Promise.reject(error);
1918
+ });
1919
+ }
1920
+ };
1921
+
1922
+ // src/index.ts
1923
+ var PelicanClient = class extends Client {
1924
+ constructor(url, token, suffix = "/api") {
1925
+ const ax = new Agent(url, token, "client", suffix);
1926
+ super(ax.requester);
1927
+ }
1928
+ };
1929
+ var PelicanApplication = class extends Client2 {
1930
+ constructor(url, token, suffix = "/api") {
1931
+ const ax = new Agent(url, token, "application", suffix);
1932
+ super(ax.requester);
1933
+ }
1934
+ };
1935
+ export {
1936
+ PelicanApplication,
1937
+ PelicanClient
1938
+ };
1939
+ /*
1940
+ * @author BothimTV
1941
+ * @license MIT
1942
+ */
1943
+ //# sourceMappingURL=index.mjs.map