@pelican.ts/sdk 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/.husky/pre-commit +2 -3
  2. package/biome.json +42 -32
  3. package/bun.lock +3 -0
  4. package/dist/api/index.d.mts +5 -5
  5. package/dist/api/index.d.ts +5 -5
  6. package/dist/api/index.js +168 -102
  7. package/dist/api/index.mjs +168 -102
  8. package/dist/index.d.mts +2 -2
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +124 -70
  11. package/dist/index.mjs +124 -70
  12. package/dist/types.d.ts +1 -1
  13. package/package.json +60 -59
  14. package/scripts/create-types.ts +4 -4
  15. package/src/api/application/client.ts +26 -19
  16. package/src/api/application/database_hosts.ts +15 -20
  17. package/src/api/application/eggs.ts +14 -7
  18. package/src/api/application/mounts.ts +29 -16
  19. package/src/api/application/nodes.ts +34 -32
  20. package/src/api/application/nodes_allocations.ts +15 -11
  21. package/src/api/application/roles.ts +13 -27
  22. package/src/api/application/servers.ts +36 -27
  23. package/src/api/application/servers_databases.ts +11 -7
  24. package/src/api/application/types/container.ts +7 -8
  25. package/src/api/application/types/database_host.ts +8 -8
  26. package/src/api/application/types/egg.ts +47 -54
  27. package/src/api/application/types/location.ts +5 -7
  28. package/src/api/application/types/mount.ts +9 -9
  29. package/src/api/application/types/node.ts +49 -59
  30. package/src/api/application/types/role.ts +4 -6
  31. package/src/api/application/types/server.ts +21 -22
  32. package/src/api/application/types/server_allocation.ts +11 -12
  33. package/src/api/application/types/user.ts +25 -25
  34. package/src/api/application/users.ts +38 -27
  35. package/src/api/base/request.ts +28 -17
  36. package/src/api/base/types.ts +16 -23
  37. package/src/api/client/account.ts +20 -15
  38. package/src/api/client/client.ts +17 -18
  39. package/src/api/client/server.ts +24 -20
  40. package/src/api/client/server_activity.ts +10 -11
  41. package/src/api/client/server_allocations.ts +11 -6
  42. package/src/api/client/server_backups.ts +21 -17
  43. package/src/api/client/server_databases.ts +14 -8
  44. package/src/api/client/server_files.ts +56 -42
  45. package/src/api/client/server_schedules.ts +43 -19
  46. package/src/api/client/server_settings.ts +11 -8
  47. package/src/api/client/server_startup.ts +16 -8
  48. package/src/api/client/server_users.ts +22 -13
  49. package/src/api/client/server_websocket.ts +79 -33
  50. package/src/api/client/types/server.ts +8 -18
  51. package/src/api/client/types/server_allocation.ts +7 -8
  52. package/src/api/client/types/server_subuser.ts +10 -11
  53. package/src/api/client/types/user.ts +2 -5
  54. package/src/api/client/types/websocket.ts +12 -24
  55. package/src/api/common/types/egg.ts +7 -7
  56. package/src/api/common/types/enums.ts +1 -1
  57. package/src/api/common/types/server_backup.ts +4 -5
  58. package/src/api/common/types/server_database.ts +9 -12
  59. package/src/api/common/types/server_files.ts +9 -9
  60. package/src/api/common/types/server_limits.ts +11 -12
  61. package/src/api/common/types/server_power.ts +1 -1
  62. package/src/api/common/types/server_schedule.ts +27 -25
  63. package/src/api/common/types/server_startup.ts +7 -12
  64. package/src/api/index.ts +3 -3
  65. package/src/humane/Account.ts +2 -2
  66. package/src/humane/Client.ts +6 -6
  67. package/src/humane/Server.ts +31 -43
  68. package/src/humane/ServerAllocation.ts +3 -3
  69. package/src/humane/ServerBackup.ts +6 -9
  70. package/src/humane/ServerDatabase.ts +2 -2
  71. package/src/humane/ServerFile.ts +17 -11
  72. package/src/humane/ServerSchedule.ts +6 -6
  73. package/src/humane/ServerUser.ts +2 -2
  74. package/src/index.ts +3 -3
  75. package/src/utils/sized.ts +1 -1
  76. package/src/utils/transform.ts +5 -10
  77. package/src/utils/types.ts +6 -8
  78. package/tsconfig.json +0 -1
@@ -1,30 +1,25 @@
1
1
  export type GenericResponse<T, N extends string = string, M = undefined> = {
2
- object: N,
3
- attributes: T,
2
+ object: N
3
+ attributes: T
4
4
  meta?: M
5
5
  }
6
6
 
7
7
  type PaginationMeta = {
8
- total: number,
9
- count: number,
10
- per_page: number,
11
- current_page: number,
12
- total_pages: number,
8
+ total: number
9
+ count: number
10
+ per_page: number
11
+ current_page: number
12
+ total_pages: number
13
13
  links: any
14
14
  }
15
15
 
16
16
  export type GenericListResponse<T> = {
17
- object: "list",
18
- data: T[],
19
- meta?: { pagination: PaginationMeta }
20
- }
21
-
22
- export type CustomListResponse<T, M> = {
23
- object: "list",
24
- data: T[],
25
- meta?: M
17
+ object: "list"
18
+ data: T[]
19
+ meta?: {pagination: PaginationMeta}
26
20
  }
27
21
 
22
+ export type CustomListResponse<T, M> = {object: "list"; data: T[]; meta?: M}
28
23
 
29
24
  export class PterodactylException extends Error {
30
25
  data: PterodactylError[]
@@ -38,10 +33,8 @@ export class PterodactylException extends Error {
38
33
  }
39
34
 
40
35
  export type PterodactylError = {
41
- code: string,
42
- status?: number,
43
- detail: string,
44
- source?: {
45
- [key: string]: string
46
- }
47
- }
36
+ code: string
37
+ status?: number
38
+ detail: string
39
+ source?: {[key: string]: string}
40
+ }
@@ -1,8 +1,7 @@
1
- import {AxiosInstance} from "axios";
2
- import {APIKey, SSHKey, User} from "@/api/client/types/user";
3
- import {GenericListResponse, GenericResponse} from "@/api/base/types";
4
- import z from "zod";
5
-
1
+ import {AxiosInstance} from "axios"
2
+ import {APIKey, SSHKey, User} from "@/api/client/types/user"
3
+ import {GenericListResponse, GenericResponse} from "@/api/base/types"
4
+ import z from "zod"
6
5
 
7
6
  export class Account {
8
7
  private readonly r: AxiosInstance
@@ -12,7 +11,8 @@ export class Account {
12
11
  }
13
12
 
14
13
  info = async (): Promise<User> => {
15
- const {data} = await this.r.get<GenericResponse<User, "user">>("/account")
14
+ const {data} =
15
+ await this.r.get<GenericResponse<User, "user">>("/account")
16
16
  return data.attributes
17
17
  }
18
18
 
@@ -31,16 +31,20 @@ export class Account {
31
31
 
32
32
  apiKeys = {
33
33
  list: async (): Promise<APIKey[]> => {
34
- const {data} = await this.r.get<
35
- GenericListResponse<GenericResponse<APIKey, "api_key">>
36
- >("/account/api-keys")
34
+ const {data} =
35
+ await this.r.get<
36
+ GenericListResponse<GenericResponse<APIKey, "api_key">>
37
+ >("/account/api-keys")
37
38
  return data.data.map(k => k.attributes)
38
39
  },
39
40
 
40
- create: async (description: string, allowed_ips?: string[]): Promise<APIKey & { secret_token: string }> => {
41
+ create: async (
42
+ description: string,
43
+ allowed_ips?: string[]
44
+ ): Promise<APIKey & {secret_token: string}> => {
41
45
  allowed_ips = z.array(z.ipv4()).optional().parse(allowed_ips)
42
46
  const {data} = await this.r.post<
43
- GenericResponse<APIKey, "api_key", { secret_token: string }>
47
+ GenericResponse<APIKey, "api_key", {secret_token: string}>
44
48
  >("/account/api-keys", {description, allowed_ips})
45
49
  return {...data.attributes, secret_token: data.meta!.secret_token}
46
50
  },
@@ -52,9 +56,10 @@ export class Account {
52
56
 
53
57
  sshKeys = {
54
58
  list: async (): Promise<SSHKey[]> => {
55
- const {data} = await this.r.get<
56
- GenericListResponse<GenericResponse<SSHKey, "ssh_key">>
57
- >("/account/ssh-keys")
59
+ const {data} =
60
+ await this.r.get<
61
+ GenericListResponse<GenericResponse<SSHKey, "ssh_key">>
62
+ >("/account/ssh-keys")
58
63
  return data.data.map(k => k.attributes)
59
64
  },
60
65
 
@@ -69,4 +74,4 @@ export class Account {
69
74
  await this.r.post(`/account/ssh-keys/remove`, {fingerprint})
70
75
  }
71
76
  }
72
- }
77
+ }
@@ -1,11 +1,10 @@
1
- import {Account} from "@/api/client/account";
2
- import {AxiosInstance} from "axios";
3
- import {Permission} from "@/api/client/types/user";
4
- import {GenericListResponse, GenericResponse} from "@/api/base/types";
5
- import {Server} from "@/api/client/types/server";
6
- import z from "zod";
7
- import {ServerClient} from "@/api/client/server";
8
-
1
+ import {Account} from "@/api/client/account"
2
+ import {AxiosInstance} from "axios"
3
+ import {Permission} from "@/api/client/types/user"
4
+ import {GenericListResponse, GenericResponse} from "@/api/base/types"
5
+ import {Server} from "@/api/client/types/server"
6
+ import z from "zod"
7
+ import {ServerClient} from "@/api/client/server"
9
8
 
10
9
  export class Client {
11
10
  account: Account
@@ -22,9 +21,13 @@ export class Client {
22
21
  }
23
22
 
24
23
  listPermissions = async (): Promise<Record<string, Permission>> => {
25
- const {data} = await this.r.get<
26
- GenericResponse<{ permissions: Record<string, Permission> }, "system_permissions">
27
- >("/permissions")
24
+ const {data} =
25
+ await this.r.get<
26
+ GenericResponse<
27
+ {permissions: Record<string, Permission>},
28
+ "system_permissions"
29
+ >
30
+ >("/permissions")
28
31
 
29
32
  return data.attributes.permissions
30
33
  }
@@ -33,25 +36,21 @@ export class Client {
33
36
  type: "accessible" | "mine" | "admin" | "admin-all" = "accessible",
34
37
  page: number = 1,
35
38
  per_page: number = 50,
36
- include?: ("egg" | "subusers")[],
39
+ include?: ("egg" | "subusers")[]
37
40
  ): Promise<Server[]> => {
38
41
  z.number().positive().parse(page)
39
42
  const {data} = await this.r.get<
40
43
  GenericListResponse<GenericResponse<Server, "server">>
41
- >("/", {
42
- params: {type, page, include: include?.join(",")}
43
- })
44
+ >("/", {params: {type, page, include: include?.join(",")}})
44
45
  return data.data.map(s => s.attributes)
45
46
  }
46
47
 
47
48
  server = (uuid: string): ServerClient => new ServerClient(this.r, uuid)
48
-
49
49
  }
50
50
 
51
-
52
51
  /*
53
52
  Include: ?include=param1,param2
54
53
  Avail: ?param1=val1&param2=val2
55
54
  Filters: ?filter[param1]=val1&filter[param2]=val2
56
55
  Sort: ?sort=-param, param=asc, -param=desc
57
- */
56
+ */
@@ -1,17 +1,16 @@
1
- import {AxiosInstance} from "axios";
2
- import {GenericResponse} from "@/api/base/types";
3
- import {Server, ServerStats} from "@/api/client/types/server";
4
- import {ServerDatabases} from "@/api/client/server_databases";
5
- import {ServerFiles} from "@/api/client/server_files";
6
- import {ServerSchedules} from "@/api/client/server_schedules";
7
- import {ServerAllocations} from "@/api/client/server_allocations";
8
- import {ServerUsers} from "@/api/client/server_users";
9
- import {ServerBackups} from "@/api/client/server_backups";
10
- import {ServerStartup} from "@/api/client/server_startup";
11
- import {ServerSettings} from "@/api/client/server_settings";
12
- import {ServerWebsocket} from "@/api/client/server_websocket";
13
- import {ServerActivity} from "@/api/client/server_activity";
14
-
1
+ import {AxiosInstance} from "axios"
2
+ import {GenericResponse} from "@/api/base/types"
3
+ import {Server, ServerStats} from "@/api/client/types/server"
4
+ import {ServerDatabases} from "@/api/client/server_databases"
5
+ import {ServerFiles} from "@/api/client/server_files"
6
+ import {ServerSchedules} from "@/api/client/server_schedules"
7
+ import {ServerAllocations} from "@/api/client/server_allocations"
8
+ import {ServerUsers} from "@/api/client/server_users"
9
+ import {ServerBackups} from "@/api/client/server_backups"
10
+ import {ServerStartup} from "@/api/client/server_startup"
11
+ import {ServerSettings} from "@/api/client/server_settings"
12
+ import {ServerWebsocket} from "@/api/client/server_websocket"
13
+ import {ServerActivity} from "@/api/client/server_activity"
15
14
 
16
15
  export class ServerClient {
17
16
  private readonly r: AxiosInstance
@@ -45,9 +44,10 @@ export class ServerClient {
45
44
  }
46
45
 
47
46
  info = async (include?: ("egg" | "subusers")[]): Promise<Server> => {
48
- const {data} = await this.r.get<GenericResponse<Server, "server">>(`/servers/${this.id}`, {
49
- params: {include: include?.join(",")}
50
- })
47
+ const {data} = await this.r.get<GenericResponse<Server, "server">>(
48
+ `/servers/${this.id}`,
49
+ {params: {include: include?.join(",")}}
50
+ )
51
51
  return data.attributes
52
52
  }
53
53
 
@@ -56,7 +56,9 @@ export class ServerClient {
56
56
  }
57
57
 
58
58
  resources = async (): Promise<ServerStats> => {
59
- const {data} = await this.r.get<GenericResponse<ServerStats, "stats">>(`/servers/${this.id}/resources`)
59
+ const {data} = await this.r.get<GenericResponse<ServerStats, "stats">>(
60
+ `/servers/${this.id}/resources`
61
+ )
60
62
  return data.attributes
61
63
  }
62
64
 
@@ -64,7 +66,9 @@ export class ServerClient {
64
66
  await this.r.post(`/servers/${this.id}/command`, {command})
65
67
  }
66
68
 
67
- power = async (signal: "start" | "stop" | "restart" | "kill"): Promise<void> => {
69
+ power = async (
70
+ signal: "start" | "stop" | "restart" | "kill"
71
+ ): Promise<void> => {
68
72
  await this.r.post(`/servers/${this.id}/power`, {signal})
69
73
  }
70
- }
74
+ }
@@ -1,6 +1,6 @@
1
- import {AxiosInstance} from "axios";
2
- import {ServerActivityLog} from "@/api/client/types/server";
3
- import {GenericListResponse, GenericResponse} from "@/api/base/types";
1
+ import {AxiosInstance} from "axios"
2
+ import {ServerActivityLog} from "@/api/client/types/server"
3
+ import {GenericListResponse, GenericResponse} from "@/api/base/types"
4
4
 
5
5
  export class ServerActivity {
6
6
  private readonly r: AxiosInstance
@@ -13,14 +13,13 @@ export class ServerActivity {
13
13
 
14
14
  list = async (
15
15
  page: number = 1,
16
- per_page: number = 25,
16
+ per_page: number = 25
17
17
  ): Promise<ServerActivityLog[]> => {
18
- const {data} = await this.r.get<GenericListResponse<GenericResponse<ServerActivityLog, "activity_log">>>(`/server/${this.id}/activity`, {
19
- params: {
20
- page,
21
- per_page,
22
- },
23
- })
18
+ const {data} = await this.r.get<
19
+ GenericListResponse<
20
+ GenericResponse<ServerActivityLog, "activity_log">
21
+ >
22
+ >(`/server/${this.id}/activity`, {params: {page, per_page}})
24
23
  return data.data.map(log => log.attributes)
25
24
  }
26
- }
25
+ }
@@ -1,6 +1,6 @@
1
- import {AxiosInstance} from "axios";
2
- import {GenericListResponse, GenericResponse} from "@/api/base/types";
3
- import {ServerAllocation} from "@/api/client/types/server_allocation";
1
+ import {AxiosInstance} from "axios"
2
+ import {GenericListResponse, GenericResponse} from "@/api/base/types"
3
+ import {ServerAllocation} from "@/api/client/types/server_allocation"
4
4
 
5
5
  export class ServerAllocations {
6
6
  private readonly r: AxiosInstance
@@ -25,7 +25,10 @@ export class ServerAllocations {
25
25
  return data.attributes
26
26
  }
27
27
 
28
- setNotes = async (alloc_id: number, notes: string): Promise<ServerAllocation> => {
28
+ setNotes = async (
29
+ alloc_id: number,
30
+ notes: string
31
+ ): Promise<ServerAllocation> => {
29
32
  const {data} = await this.r.post<
30
33
  GenericResponse<ServerAllocation, "allocation">
31
34
  >(`/servers/${this.id}/network/allocations/${alloc_id}`, {notes})
@@ -40,6 +43,8 @@ export class ServerAllocations {
40
43
  }
41
44
 
42
45
  unassign = async (alloc_id: number): Promise<void> => {
43
- await this.r.delete(`/servers/${this.id}/network/allocations/${alloc_id}`)
46
+ await this.r.delete(
47
+ `/servers/${this.id}/network/allocations/${alloc_id}`
48
+ )
44
49
  }
45
- }
50
+ }
@@ -1,8 +1,7 @@
1
- import axios, {AxiosInstance} from "axios";
2
- import {ServerBackup} from "@/api/common/types/server_backup";
3
- import z, {string} from "zod";
4
- import {GenericListResponse, GenericResponse} from "@/api/base/types";
5
-
1
+ import axios, {AxiosInstance} from "axios"
2
+ import {ServerBackup} from "@/api/common/types/server_backup"
3
+ import z, {string} from "zod"
4
+ import {GenericListResponse, GenericResponse} from "@/api/base/types"
6
5
 
7
6
  export class ServerBackups {
8
7
  private readonly r: AxiosInstance
@@ -17,17 +16,15 @@ export class ServerBackups {
17
16
  z.number().positive().parse(page)
18
17
  const {data} = await this.r.get<
19
18
  GenericListResponse<GenericResponse<ServerBackup, "backup">>
20
- >(`/servers/${this.id}/backups`, {
21
- params: {page}
22
- })
19
+ >(`/servers/${this.id}/backups`, {params: {page}})
23
20
 
24
- return data.data.map(d=>d.attributes)
21
+ return data.data.map(d => d.attributes)
25
22
  }
26
23
 
27
24
  create = async (args: {
28
- name?: string,
29
- is_locked: boolean,
30
- ignored_files: string[],
25
+ name?: string
26
+ is_locked: boolean
27
+ ignored_files: string[]
31
28
  }): Promise<ServerBackup> => {
32
29
  args.name = z.string().max(255).optional().parse(args.name)
33
30
  const {data} = await this.r.post<
@@ -49,14 +46,16 @@ export class ServerBackups {
49
46
 
50
47
  downloadGetUrl = async (backup_uuid: string): Promise<string> => {
51
48
  const {data} = await this.r.get<
52
- GenericResponse<{ url: string }, "signed_url">
49
+ GenericResponse<{url: string}, "signed_url">
53
50
  >(`/servers/${this.id}/backups/${backup_uuid}/download`)
54
51
  return data.attributes.url
55
52
  }
56
53
 
57
54
  download = async (backup_uuid: string): Promise<ArrayBuffer> => {
58
55
  const url = await this.downloadGetUrl(backup_uuid)
59
- const {data} = await axios.get<ArrayBuffer>(url, {responseType: "arraybuffer"})
56
+ const {data} = await axios.get<ArrayBuffer>(url, {
57
+ responseType: "arraybuffer"
58
+ })
60
59
  return data
61
60
  }
62
61
 
@@ -65,7 +64,9 @@ export class ServerBackups {
65
64
  }
66
65
 
67
66
  rename = async (backup_uuid: string, name: string): Promise<void> => {
68
- await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, {name})
67
+ await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, {
68
+ name
69
+ })
69
70
  }
70
71
 
71
72
  toggleLock = async (backup_uuid: string): Promise<void> => {
@@ -73,6 +74,9 @@ export class ServerBackups {
73
74
  }
74
75
 
75
76
  restore = async (backup_uuid: string, truncate: boolean): Promise<void> => {
76
- await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/restore`, {truncate})
77
+ await this.r.post(
78
+ `/servers/${this.id}/backups/${backup_uuid}/restore`,
79
+ {truncate}
80
+ )
77
81
  }
78
- }
82
+ }
@@ -1,7 +1,7 @@
1
- import {AxiosInstance} from "axios";
2
- import z from "zod";
3
- import {GenericListResponse, GenericResponse} from "@/api/base/types";
4
- import {ServerDatabase} from "@/api/common/types/server_database";
1
+ import {AxiosInstance} from "axios"
2
+ import z from "zod"
3
+ import {GenericListResponse, GenericResponse} from "@/api/base/types"
4
+ import {ServerDatabase} from "@/api/common/types/server_database"
5
5
  // TODO: Check for validity
6
6
 
7
7
  export class ServerDatabases {
@@ -14,18 +14,24 @@ export class ServerDatabases {
14
14
  }
15
15
 
16
16
  list = async (
17
- include?: ("password")[], page: number = 1
17
+ include?: "password"[],
18
+ page: number = 1
18
19
  ): Promise<ServerDatabase[]> => {
19
20
  z.number().positive().parse(page)
20
21
  const {data} = await this.r.get<
21
- GenericListResponse<GenericResponse<ServerDatabase, "server_database">>
22
+ GenericListResponse<
23
+ GenericResponse<ServerDatabase, "server_database">
24
+ >
22
25
  >(`/servers/${this.id}/databases`, {
23
26
  params: {include: include?.join(","), page}
24
27
  })
25
28
  return data.data.map(d => d.attributes)
26
29
  }
27
30
 
28
- create = async (database: string, remote: string): Promise<ServerDatabase> => {
31
+ create = async (
32
+ database: string,
33
+ remote: string
34
+ ): Promise<ServerDatabase> => {
29
35
  const {data} = await this.r.post<
30
36
  GenericResponse<ServerDatabase, "server_database">
31
37
  >(`/servers/${this.id}/databases`, {database, remote})
@@ -42,4 +48,4 @@ export class ServerDatabases {
42
48
  delete = async (database_id: string): Promise<void> => {
43
49
  await this.r.delete(`/servers/${this.id}/databases/${database_id}`)
44
50
  }
45
- }
51
+ }
@@ -1,8 +1,7 @@
1
- import axios, {AxiosInstance} from "axios";
2
- import {string} from "zod";
3
- import {FileObject} from "@/api/common/types/server_files";
4
- import {GenericListResponse, GenericResponse} from "@/api/base/types";
5
-
1
+ import axios, {AxiosInstance} from "axios"
2
+ import {string} from "zod"
3
+ import {FileObject} from "@/api/common/types/server_files"
4
+ import {GenericListResponse, GenericResponse} from "@/api/base/types"
6
5
 
7
6
  export class ServerFiles {
8
7
  private readonly r: AxiosInstance
@@ -16,9 +15,7 @@ export class ServerFiles {
16
15
  list = async (path?: string): Promise<FileObject[]> => {
17
16
  const {data} = await this.r.get<
18
17
  GenericListResponse<GenericResponse<FileObject, "file_object">>
19
- >(`/servers/${this.id}/files/list`, {
20
- params: {directory: path}
21
- })
18
+ >(`/servers/${this.id}/files/list`, {params: {directory: path}})
22
19
  return data.data.map(r => r.attributes)
23
20
  }
24
21
 
@@ -26,30 +23,31 @@ export class ServerFiles {
26
23
  * Return the contents of a file. To read binary file (non-editable) use {@link download} instead
27
24
  */
28
25
  contents = async (path: string): Promise<string> => {
29
- const {data} = await this.r.get<string>(`/servers/${this.id}/files/contents`, {
30
- params: {file: path}
31
- })
26
+ const {data} = await this.r.get<string>(
27
+ `/servers/${this.id}/files/contents`,
28
+ {params: {file: path}}
29
+ )
32
30
  return data
33
31
  }
34
32
 
35
33
  downloadGetUrl = async (path: string): Promise<string> => {
36
34
  const {data} = await this.r.get<
37
- GenericResponse<{ url: string }, "signed_url">
38
- >(`/servers/${this.id}/files/download`, {
39
- params: {file: path}
40
- })
35
+ GenericResponse<{url: string}, "signed_url">
36
+ >(`/servers/${this.id}/files/download`, {params: {file: path}})
41
37
  return data.attributes.url
42
38
  }
43
39
 
44
40
  download = async (path: string): Promise<ArrayBuffer> => {
45
41
  const url = await this.downloadGetUrl(path)
46
- const {data} = await axios.get<ArrayBuffer>(url, {responseType: "arraybuffer"})
42
+ const {data} = await axios.get<ArrayBuffer>(url, {
43
+ responseType: "arraybuffer"
44
+ })
47
45
  return data
48
46
  }
49
47
 
50
48
  rename = async (
51
49
  root: string = "/",
52
- files: { from: string, to: string }[]
50
+ files: {from: string; to: string}[]
53
51
  ): Promise<void> => {
54
52
  await this.r.put(`/servers/${this.id}/files/rename`, {root, files})
55
53
  }
@@ -60,7 +58,7 @@ export class ServerFiles {
60
58
 
61
59
  write = async (path: string, content: string): Promise<void> => {
62
60
  await this.r.post(`/servers/${this.id}/files/write`, content, {
63
- params: {file: path},
61
+ params: {file: path}
64
62
  })
65
63
  }
66
64
 
@@ -68,38 +66,44 @@ export class ServerFiles {
68
66
  root: string = "/",
69
67
  files: string[],
70
68
  archive_name?: string,
71
- extension?: "zip" | "tgz" | "tar.gz" | "txz" | "tar.xz" | "tbz2" | "tar.bz2"
69
+ extension?:
70
+ | "zip"
71
+ | "tgz"
72
+ | "tar.gz"
73
+ | "txz"
74
+ | "tar.xz"
75
+ | "tbz2"
76
+ | "tar.bz2"
72
77
  ): Promise<FileObject> => {
73
78
  const {data} = await this.r.post<
74
79
  GenericResponse<FileObject, "file_object">
75
- >(`/servers/${this.id}/files/compress`, {root, files, archive_name, extension})
80
+ >(`/servers/${this.id}/files/compress`, {
81
+ root,
82
+ files,
83
+ archive_name,
84
+ extension
85
+ })
76
86
  return data.attributes
77
87
  }
78
88
 
79
- decompress = async (
80
- root: string = "/",
81
- file: string,
82
- ): Promise<void> => {
89
+ decompress = async (root: string = "/", file: string): Promise<void> => {
83
90
  await this.r.post(`/servers/${this.id}/files/decompress`, {root, file})
84
91
  }
85
92
 
86
- delete = async (
87
- root: string = "/",
88
- files: string[],
89
- ): Promise<void> => {
93
+ delete = async (root: string = "/", files: string[]): Promise<void> => {
90
94
  await this.r.post(`/servers/${this.id}/files/delete`, {root, files})
91
95
  }
92
96
 
93
- createFolder = async (
94
- root: string = "/",
95
- name: string,
96
- ): Promise<void> => {
97
- await this.r.post(`/servers/${this.id}/files/create-folder`, {root, name})
97
+ createFolder = async (root: string = "/", name: string): Promise<void> => {
98
+ await this.r.post(`/servers/${this.id}/files/create-folder`, {
99
+ root,
100
+ name
101
+ })
98
102
  }
99
103
 
100
104
  chmod = async (
101
105
  root: string = "/",
102
- files: Array<{ file: string, mode: number }>
106
+ files: Array<{file: string; mode: number}>
103
107
  ): Promise<void> => {
104
108
  await this.r.post(`/servers/${this.id}/files/chmod`, {root, files})
105
109
  }
@@ -111,21 +115,31 @@ export class ServerFiles {
111
115
  use_header: boolean = false, // Unused
112
116
  foreground: boolean = false // Unused
113
117
  ): Promise<void> => {
114
- await this.r.post(`/servers/${this.id}/files/pull`, {url, directory, filename, use_header, foreground})
118
+ await this.r.post(`/servers/${this.id}/files/pull`, {
119
+ url,
120
+ directory,
121
+ filename,
122
+ use_header,
123
+ foreground
124
+ })
115
125
  }
116
126
 
117
127
  uploadGetUrl = async (): Promise<string> => {
118
128
  const {data} = await this.r.get<
119
- GenericResponse<{ url: string }, "signed_url">
129
+ GenericResponse<{url: string}, "signed_url">
120
130
  >(`/servers/${this.id}/files/upload`)
121
131
  return data.attributes.url
122
132
  }
123
133
 
124
134
  upload = async (file: File, root: string = "/"): Promise<void> => {
125
135
  const url = await this.uploadGetUrl()
126
- await axios.post(url, {files: file}, {
127
- headers: {"Content-Type": "multipart/form-data"},
128
- params: {directory: root}
129
- })
130
- }
131
- }
136
+ await axios.post(
137
+ url,
138
+ {files: file},
139
+ {
140
+ headers: {"Content-Type": "multipart/form-data"},
141
+ params: {directory: root}
142
+ }
143
+ )
144
+ }
145
+ }