@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.
- package/.husky/pre-commit +2 -3
- package/biome.json +42 -32
- package/bun.lock +3 -0
- package/dist/api/index.d.mts +5 -5
- package/dist/api/index.d.ts +5 -5
- package/dist/api/index.js +168 -102
- package/dist/api/index.mjs +168 -102
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +124 -70
- package/dist/index.mjs +124 -70
- package/dist/types.d.ts +1 -1
- package/package.json +60 -59
- package/scripts/create-types.ts +4 -4
- package/src/api/application/client.ts +26 -19
- package/src/api/application/database_hosts.ts +15 -20
- package/src/api/application/eggs.ts +14 -7
- package/src/api/application/mounts.ts +29 -16
- package/src/api/application/nodes.ts +34 -32
- package/src/api/application/nodes_allocations.ts +15 -11
- package/src/api/application/roles.ts +13 -27
- package/src/api/application/servers.ts +36 -27
- package/src/api/application/servers_databases.ts +11 -7
- package/src/api/application/types/container.ts +7 -8
- package/src/api/application/types/database_host.ts +8 -8
- package/src/api/application/types/egg.ts +47 -54
- package/src/api/application/types/location.ts +5 -7
- package/src/api/application/types/mount.ts +9 -9
- package/src/api/application/types/node.ts +49 -59
- package/src/api/application/types/role.ts +4 -6
- package/src/api/application/types/server.ts +21 -22
- package/src/api/application/types/server_allocation.ts +11 -12
- package/src/api/application/types/user.ts +25 -25
- package/src/api/application/users.ts +38 -27
- package/src/api/base/request.ts +28 -17
- package/src/api/base/types.ts +16 -23
- package/src/api/client/account.ts +20 -15
- package/src/api/client/client.ts +17 -18
- package/src/api/client/server.ts +24 -20
- package/src/api/client/server_activity.ts +10 -11
- package/src/api/client/server_allocations.ts +11 -6
- package/src/api/client/server_backups.ts +21 -17
- package/src/api/client/server_databases.ts +14 -8
- package/src/api/client/server_files.ts +56 -42
- package/src/api/client/server_schedules.ts +43 -19
- package/src/api/client/server_settings.ts +11 -8
- package/src/api/client/server_startup.ts +16 -8
- package/src/api/client/server_users.ts +22 -13
- package/src/api/client/server_websocket.ts +79 -33
- package/src/api/client/types/server.ts +8 -18
- package/src/api/client/types/server_allocation.ts +7 -8
- package/src/api/client/types/server_subuser.ts +10 -11
- package/src/api/client/types/user.ts +2 -5
- package/src/api/client/types/websocket.ts +12 -24
- package/src/api/common/types/egg.ts +7 -7
- package/src/api/common/types/enums.ts +1 -1
- package/src/api/common/types/server_backup.ts +4 -5
- package/src/api/common/types/server_database.ts +9 -12
- package/src/api/common/types/server_files.ts +9 -9
- package/src/api/common/types/server_limits.ts +11 -12
- package/src/api/common/types/server_power.ts +1 -1
- package/src/api/common/types/server_schedule.ts +27 -25
- package/src/api/common/types/server_startup.ts +7 -12
- package/src/api/index.ts +3 -3
- package/src/humane/Account.ts +2 -2
- package/src/humane/Client.ts +6 -6
- package/src/humane/Server.ts +31 -43
- package/src/humane/ServerAllocation.ts +3 -3
- package/src/humane/ServerBackup.ts +6 -9
- package/src/humane/ServerDatabase.ts +2 -2
- package/src/humane/ServerFile.ts +17 -11
- package/src/humane/ServerSchedule.ts +6 -6
- package/src/humane/ServerUser.ts +2 -2
- package/src/index.ts +3 -3
- package/src/utils/sized.ts +1 -1
- package/src/utils/transform.ts +5 -10
- package/src/utils/types.ts +6 -8
- package/tsconfig.json +0 -1
|
@@ -9,7 +9,7 @@ export enum SERVER_SIGNAL {
|
|
|
9
9
|
START = "start",
|
|
10
10
|
STOP = "stop",
|
|
11
11
|
RESTART = "restart",
|
|
12
|
-
KILL = "kill"
|
|
12
|
+
KILL = "kill"
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export type WebsocketEvent =
|
|
@@ -49,7 +49,7 @@ export enum SOCKET_EVENT {
|
|
|
49
49
|
BACKUP_RESTORE_COMPLETED = "backup restore completed",
|
|
50
50
|
TOKEN_EXPIRING = "token expiring",
|
|
51
51
|
TOKEN_EXPIRED = "token expired",
|
|
52
|
-
JWT_ERROR = "jwt error"
|
|
52
|
+
JWT_ERROR = "jwt error"
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export type InstallOutputEvent = {
|
|
@@ -57,13 +57,9 @@ export type InstallOutputEvent = {
|
|
|
57
57
|
args: [string]
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export type InstallStartedEvent = {
|
|
61
|
-
event: SOCKET_EVENT.INSTALL_STARTED
|
|
62
|
-
}
|
|
60
|
+
export type InstallStartedEvent = {event: SOCKET_EVENT.INSTALL_STARTED}
|
|
63
61
|
|
|
64
|
-
export type InstallCompletedEvent = {
|
|
65
|
-
event: SOCKET_EVENT.INSTALL_COMPLETED
|
|
66
|
-
}
|
|
62
|
+
export type InstallCompletedEvent = {event: SOCKET_EVENT.INSTALL_COMPLETED}
|
|
67
63
|
|
|
68
64
|
export type TransferLogsEvent = {
|
|
69
65
|
event: SOCKET_EVENT.TRANSFER_LOGS
|
|
@@ -92,11 +88,9 @@ export type BackupRestoreCompletedEvent = {
|
|
|
92
88
|
event: SOCKET_EVENT.BACKUP_RESTORE_COMPLETED
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
export type AuthSuccessWsEvent = {
|
|
96
|
-
event: SOCKET_EVENT.AUTH_SUCCESS
|
|
97
|
-
}
|
|
91
|
+
export type AuthSuccessWsEvent = {event: SOCKET_EVENT.AUTH_SUCCESS}
|
|
98
92
|
|
|
99
|
-
export type StatusWsEvent = {
|
|
93
|
+
export type StatusWsEvent = {event: SOCKET_EVENT.STATUS; args: [PowerState]}
|
|
100
94
|
|
|
101
95
|
export type PowerState = "starting" | "stopping" | "running" | "offline"
|
|
102
96
|
|
|
@@ -105,24 +99,21 @@ export type ConsoleLogWsEvent = {
|
|
|
105
99
|
args: [string]
|
|
106
100
|
}
|
|
107
101
|
|
|
108
|
-
export type StatsWsEvent = {
|
|
109
|
-
event: SOCKET_EVENT.STATS
|
|
110
|
-
args: [string]
|
|
111
|
-
}
|
|
102
|
+
export type StatsWsEvent = {event: SOCKET_EVENT.STATS; args: [string]}
|
|
112
103
|
|
|
113
104
|
export type StatsWsJson = {
|
|
114
105
|
memory_bytes: number
|
|
115
106
|
memory_limit_bytes: number
|
|
116
107
|
cpu_absolute: number
|
|
117
|
-
network: {
|
|
108
|
+
network: {rx_bytes: number; tx_bytes: number}
|
|
118
109
|
state: PowerState
|
|
119
110
|
uptime: number
|
|
120
111
|
disk_bytes: number
|
|
121
112
|
}
|
|
122
113
|
|
|
123
|
-
export type TokenExpiringWsEvent = {
|
|
114
|
+
export type TokenExpiringWsEvent = {event: SOCKET_EVENT.TOKEN_EXPIRING}
|
|
124
115
|
|
|
125
|
-
export type TokenExpiredWsEvent = {
|
|
116
|
+
export type TokenExpiredWsEvent = {event: SOCKET_EVENT.TOKEN_EXPIRED}
|
|
126
117
|
|
|
127
118
|
/**
|
|
128
119
|
* Example:
|
|
@@ -142,9 +133,6 @@ export type DaemonErrorEvent = {
|
|
|
142
133
|
args: [string]
|
|
143
134
|
}
|
|
144
135
|
|
|
145
|
-
export type JwtErrorEvent = {
|
|
146
|
-
event: SOCKET_EVENT.JWT_ERROR
|
|
147
|
-
args: [string]
|
|
148
|
-
}
|
|
136
|
+
export type JwtErrorEvent = {event: SOCKET_EVENT.JWT_ERROR; args: [string]}
|
|
149
137
|
|
|
150
|
-
export {
|
|
138
|
+
export {ServerWebsocket} from "@/api/client/server_websocket"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export type EggVariable = {
|
|
2
|
-
name: string
|
|
3
|
-
description: string
|
|
4
|
-
env_variable: string
|
|
5
|
-
default_value: string
|
|
6
|
-
server_value: string
|
|
7
|
-
is_editable: boolean
|
|
2
|
+
name: string
|
|
3
|
+
description: string
|
|
4
|
+
env_variable: string
|
|
5
|
+
default_value: string
|
|
6
|
+
server_value: string
|
|
7
|
+
is_editable: boolean
|
|
8
8
|
rules: string
|
|
9
|
-
}
|
|
9
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {Nullable} from "@/utils/types"
|
|
2
|
-
|
|
1
|
+
import {Nullable} from "@/utils/types"
|
|
3
2
|
|
|
4
3
|
export type ServerBackup = {
|
|
5
4
|
uuid: string
|
|
6
|
-
is_successful: boolean
|
|
7
|
-
is_locked: boolean
|
|
5
|
+
is_successful: boolean
|
|
6
|
+
is_locked: boolean
|
|
8
7
|
name: string
|
|
9
8
|
ignored_files: string[]
|
|
10
9
|
checksum: Nullable<string>
|
|
11
10
|
bytes: number
|
|
12
11
|
created_at: string
|
|
13
12
|
completed_at: Nullable<string>
|
|
14
|
-
}
|
|
13
|
+
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {GenericResponse} from "@/api/base/types"
|
|
1
|
+
import {GenericResponse} from "@/api/base/types"
|
|
2
2
|
|
|
3
3
|
export type ServerDatabase = {
|
|
4
|
-
id: string
|
|
5
|
-
host: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
username: string,
|
|
11
|
-
connections_from: string,
|
|
12
|
-
max_connections: number,
|
|
4
|
+
id: string
|
|
5
|
+
host: {address: string; port: number}
|
|
6
|
+
name: string
|
|
7
|
+
username: string
|
|
8
|
+
connections_from: string
|
|
9
|
+
max_connections: number
|
|
13
10
|
relationships?: {
|
|
14
|
-
password: GenericResponse<{
|
|
11
|
+
password: GenericResponse<{password: string}, "database_password">
|
|
15
12
|
}
|
|
16
|
-
}
|
|
13
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export type FileObject = {
|
|
2
|
-
name: string
|
|
3
|
-
mode: string
|
|
4
|
-
mode_bits: string
|
|
5
|
-
size: number
|
|
6
|
-
is_file: boolean
|
|
7
|
-
is_symlink: boolean
|
|
8
|
-
mimetype: string
|
|
9
|
-
created_at: string
|
|
2
|
+
name: string
|
|
3
|
+
mode: string
|
|
4
|
+
mode_bits: string
|
|
5
|
+
size: number
|
|
6
|
+
is_file: boolean
|
|
7
|
+
is_symlink: boolean
|
|
8
|
+
mimetype: string
|
|
9
|
+
created_at: string
|
|
10
10
|
modified_at: string
|
|
11
|
-
}
|
|
11
|
+
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {Nullable} from "@/utils/types"
|
|
2
|
-
|
|
1
|
+
import {Nullable} from "@/utils/types"
|
|
3
2
|
|
|
4
3
|
export type ServerLimits = {
|
|
5
|
-
memory: number
|
|
6
|
-
swap: number
|
|
7
|
-
disk: number
|
|
8
|
-
io: number
|
|
9
|
-
cpu: number
|
|
10
|
-
threads: Nullable<number|string
|
|
11
|
-
oom_disabled: boolean
|
|
4
|
+
memory: number
|
|
5
|
+
swap: number
|
|
6
|
+
disk: number
|
|
7
|
+
io: number
|
|
8
|
+
cpu: number
|
|
9
|
+
threads: Nullable<number | string>
|
|
10
|
+
oom_disabled: boolean
|
|
12
11
|
oom_killer: boolean
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
export type FeatureLimits = {
|
|
16
|
-
databases: number
|
|
17
|
-
allocations: number
|
|
15
|
+
databases: number
|
|
16
|
+
allocations: number
|
|
18
17
|
backups: number
|
|
19
|
-
}
|
|
18
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type ServerSignalOption =
|
|
1
|
+
export type ServerSignalOption = "start" | "stop" | "restart" | "kill"
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import {GenericListResponse, GenericResponse} from "@/api/base/types"
|
|
2
|
-
import {Nullable} from "@/utils/types"
|
|
1
|
+
import {GenericListResponse, GenericResponse} from "@/api/base/types"
|
|
2
|
+
import {Nullable} from "@/utils/types"
|
|
3
3
|
|
|
4
4
|
export type Schedule = {
|
|
5
|
-
id: number
|
|
6
|
-
name: string
|
|
5
|
+
id: number
|
|
6
|
+
name: string
|
|
7
7
|
cron: {
|
|
8
|
-
day_of_week: string
|
|
9
|
-
day_of_month: string
|
|
10
|
-
hour: string
|
|
8
|
+
day_of_week: string
|
|
9
|
+
day_of_month: string
|
|
10
|
+
hour: string
|
|
11
11
|
minute: string
|
|
12
|
-
}
|
|
13
|
-
is_active: boolean
|
|
14
|
-
is_processing: boolean
|
|
15
|
-
only_when_online: boolean
|
|
16
|
-
last_run_at: Nullable<string
|
|
17
|
-
next_run_at: string
|
|
18
|
-
created_at: string
|
|
19
|
-
updated_at: string
|
|
12
|
+
}
|
|
13
|
+
is_active: boolean
|
|
14
|
+
is_processing: boolean
|
|
15
|
+
only_when_online: boolean
|
|
16
|
+
last_run_at: Nullable<string>
|
|
17
|
+
next_run_at: string
|
|
18
|
+
created_at: string
|
|
19
|
+
updated_at: string
|
|
20
20
|
relationships: {
|
|
21
|
-
tasks: GenericListResponse<
|
|
21
|
+
tasks: GenericListResponse<
|
|
22
|
+
GenericResponse<ScheduleTask, "schedule_task">
|
|
23
|
+
>
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export type ScheduleTask = {
|
|
26
|
-
id: number
|
|
27
|
-
sequence_id: number
|
|
28
|
-
action: "command" | "power" | "backup" | "delete_files"
|
|
29
|
-
payload: string
|
|
30
|
-
time_offset: number
|
|
31
|
-
is_queued: boolean
|
|
32
|
-
continue_on_failure: boolean
|
|
33
|
-
created_at: string
|
|
28
|
+
id: number
|
|
29
|
+
sequence_id: number
|
|
30
|
+
action: "command" | "power" | "backup" | "delete_files"
|
|
31
|
+
payload: string
|
|
32
|
+
time_offset: number
|
|
33
|
+
is_queued: boolean
|
|
34
|
+
continue_on_failure: boolean
|
|
35
|
+
created_at: string
|
|
34
36
|
updated_at: Nullable<string>
|
|
35
|
-
}
|
|
37
|
+
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
export type StartupParams = {
|
|
4
|
-
name: string
|
|
5
|
-
description: string
|
|
6
|
-
env_variables: string
|
|
7
|
-
default_value: string
|
|
8
|
-
server_value: string
|
|
9
|
-
is_editable: boolean
|
|
2
|
+
name: string
|
|
3
|
+
description: string
|
|
4
|
+
env_variables: string
|
|
5
|
+
default_value: string
|
|
6
|
+
server_value: string
|
|
7
|
+
is_editable: boolean
|
|
10
8
|
rules: string
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
export type StartupMeta = {
|
|
14
|
-
startup_command: string
|
|
15
|
-
raw_startup_command: string
|
|
16
|
-
}
|
|
11
|
+
export type StartupMeta = {startup_command: string; raw_startup_command: string}
|
package/src/api/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {Client as UserClient} from "@/api/client/client"
|
|
2
|
+
import {Client as AppClient} from "@/api/application/client"
|
|
3
|
+
import {Agent} from "@/api/base/request"
|
|
4
4
|
|
|
5
5
|
export class PelicanAPIClient extends UserClient {
|
|
6
6
|
constructor(url: string, token: string, suffix: string = "/api") {
|
package/src/humane/Account.ts
CHANGED
package/src/humane/Client.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type {Client as ClientT} from "@/api/client/client"
|
|
2
|
+
import {Account} from "@/humane/Account"
|
|
3
|
+
import {Server} from "@/humane/Server"
|
|
4
4
|
|
|
5
5
|
export class Client {
|
|
6
6
|
private readonly client: ClientT
|
|
@@ -26,15 +26,15 @@ export class Client {
|
|
|
26
26
|
page?: number
|
|
27
27
|
per_page?: number
|
|
28
28
|
include?: ("egg" | "subusers")[]
|
|
29
|
-
} = {
|
|
29
|
+
} = {type: "accessible", page: 1, per_page: 50}
|
|
30
30
|
) => {
|
|
31
31
|
const data = await this.client.listServers(
|
|
32
32
|
opts.type,
|
|
33
33
|
opts.page,
|
|
34
34
|
opts.per_page,
|
|
35
|
-
opts.include
|
|
35
|
+
opts.include
|
|
36
36
|
)
|
|
37
|
-
return data.map(
|
|
37
|
+
return data.map(d => new Server(this.client.server(d.uuid), d))
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
getServer = async (uuid: string, include?: ("egg" | "subusers")[]) => {
|
package/src/humane/Server.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import type {ServerClient} from "@/api/client/server"
|
|
2
|
+
import type {ServerBackups} from "@/api/client/server_backups"
|
|
3
|
+
import type {ServerFiles} from "@/api/client/server_files"
|
|
4
|
+
import type {ServerSchedules} from "@/api/client/server_schedules"
|
|
5
|
+
import type {Server as ServerT} from "@/api/client/types/server"
|
|
6
|
+
import {ServerAllocation} from "@/humane/ServerAllocation"
|
|
7
|
+
import {ServerBackup} from "@/humane/ServerBackup"
|
|
8
|
+
import {ServerDatabase} from "@/humane/ServerDatabase"
|
|
9
|
+
import {ServerFile} from "@/humane/ServerFile"
|
|
10
|
+
import {ServerSchedule} from "@/humane/ServerSchedule"
|
|
11
|
+
import {ServerUser} from "@/humane/ServerUser"
|
|
12
12
|
import type {
|
|
13
13
|
EggVariable,
|
|
14
14
|
FeatureLimits,
|
|
15
15
|
ServerLimits,
|
|
16
|
-
SubuserPermission
|
|
16
|
+
SubuserPermission
|
|
17
17
|
} from "@/types"
|
|
18
|
-
import type {
|
|
18
|
+
import type {Nullable} from "@/utils/types"
|
|
19
19
|
|
|
20
20
|
export class Server {
|
|
21
21
|
private readonly client: ServerClient
|
|
@@ -30,11 +30,7 @@ export class Server {
|
|
|
30
30
|
}
|
|
31
31
|
readonly node: string
|
|
32
32
|
readonly isNodeUnderMaintenance: boolean
|
|
33
|
-
readonly sftp: {
|
|
34
|
-
ip: string
|
|
35
|
-
alias: Nullable<string>
|
|
36
|
-
port: number
|
|
37
|
-
}
|
|
33
|
+
readonly sftp: {ip: string; alias: Nullable<string>; port: number}
|
|
38
34
|
private $description: string
|
|
39
35
|
get description() {
|
|
40
36
|
return this.$description
|
|
@@ -53,10 +49,7 @@ export class Server {
|
|
|
53
49
|
readonly isTransferring: boolean
|
|
54
50
|
readonly allocations: ServerAllocation[]
|
|
55
51
|
readonly variables: EggVariable[]
|
|
56
|
-
readonly egg?: {
|
|
57
|
-
uuid: string
|
|
58
|
-
name: string
|
|
59
|
-
}
|
|
52
|
+
readonly egg?: {uuid: string; name: string}
|
|
60
53
|
readonly subusers?: ServerUser[]
|
|
61
54
|
|
|
62
55
|
constructor(client: ServerClient, server: ServerT) {
|
|
@@ -80,14 +73,14 @@ export class Server {
|
|
|
80
73
|
this.isInstalling = server.is_installing
|
|
81
74
|
this.isTransferring = server.is_transferring
|
|
82
75
|
this.allocations = server.relationships.allocations.data.map(
|
|
83
|
-
|
|
76
|
+
d => new ServerAllocation(this.client, d.attributes)
|
|
84
77
|
)
|
|
85
78
|
this.variables = server.relationships.variables.data.map(
|
|
86
|
-
|
|
79
|
+
d => d.attributes
|
|
87
80
|
)
|
|
88
81
|
this.egg = server.relationships.egg?.attributes
|
|
89
82
|
this.subusers = server.relationships.subusers?.data.map(
|
|
90
|
-
|
|
83
|
+
d => new ServerUser(this.client, d.attributes)
|
|
91
84
|
)
|
|
92
85
|
}
|
|
93
86
|
|
|
@@ -109,7 +102,7 @@ export class Server {
|
|
|
109
102
|
}
|
|
110
103
|
|
|
111
104
|
getActivityLogs = async (
|
|
112
|
-
opts: {
|
|
105
|
+
opts: {page?: number; per_page?: number} = {page: 1, per_page: 50}
|
|
113
106
|
) => this.client.activity.list(opts.page, opts.per_page)
|
|
114
107
|
|
|
115
108
|
websocket = (stripColors: boolean = false) =>
|
|
@@ -123,13 +116,10 @@ export class Server {
|
|
|
123
116
|
this.client.power(signal)
|
|
124
117
|
|
|
125
118
|
getDatabases = async (
|
|
126
|
-
opts: {
|
|
127
|
-
include: [],
|
|
128
|
-
page: 1,
|
|
129
|
-
},
|
|
119
|
+
opts: {include?: "password"[]; page?: number} = {include: [], page: 1}
|
|
130
120
|
) => {
|
|
131
121
|
const data = await this.client.databases.list(opts.include, opts.page)
|
|
132
|
-
return data.map(
|
|
122
|
+
return data.map(d => new ServerDatabase(this.client, d))
|
|
133
123
|
}
|
|
134
124
|
|
|
135
125
|
createDatabase = async (database: string, remote: string) => {
|
|
@@ -139,7 +129,7 @@ export class Server {
|
|
|
139
129
|
|
|
140
130
|
getSchedules = async () => {
|
|
141
131
|
const data = await this.client.schedules.list()
|
|
142
|
-
return data.map(
|
|
132
|
+
return data.map(d => new ServerSchedule(this.client, d))
|
|
143
133
|
}
|
|
144
134
|
|
|
145
135
|
createSchedule = async (...opts: Parameters<ServerSchedules["create"]>) => {
|
|
@@ -149,7 +139,7 @@ export class Server {
|
|
|
149
139
|
|
|
150
140
|
getBackups = async (page: number = 1) => {
|
|
151
141
|
const data = await this.client.backups.list(page)
|
|
152
|
-
return data.map(
|
|
142
|
+
return data.map(d => new ServerBackup(this.client, d))
|
|
153
143
|
}
|
|
154
144
|
|
|
155
145
|
createBackup = async (...args: Parameters<ServerBackups["create"]>) => {
|
|
@@ -159,7 +149,7 @@ export class Server {
|
|
|
159
149
|
|
|
160
150
|
getAllocations = async () => {
|
|
161
151
|
const data = await this.client.allocations.list()
|
|
162
|
-
return data.map(
|
|
152
|
+
return data.map(d => new ServerAllocation(this.client, d))
|
|
163
153
|
}
|
|
164
154
|
|
|
165
155
|
createAllocation = async () => {
|
|
@@ -169,7 +159,7 @@ export class Server {
|
|
|
169
159
|
|
|
170
160
|
getFiles = async (path?: string) => {
|
|
171
161
|
const data = await this.client.files.list(path)
|
|
172
|
-
return data.map(
|
|
162
|
+
return data.map(d => new ServerFile(this.client, d, path))
|
|
173
163
|
}
|
|
174
164
|
|
|
175
165
|
createFolder = async (...opts: Parameters<ServerFiles["createFolder"]>) =>
|
|
@@ -190,22 +180,20 @@ export class Server {
|
|
|
190
180
|
...opts: Parameters<ServerFiles["compress"]>
|
|
191
181
|
) => this.client.files.compress(...opts)
|
|
192
182
|
|
|
193
|
-
renameMultipleFiles = async (
|
|
194
|
-
...opts
|
|
195
|
-
) => this.client.files.rename(...opts)
|
|
183
|
+
renameMultipleFiles = async (...opts: Parameters<ServerFiles["rename"]>) =>
|
|
184
|
+
this.client.files.rename(...opts)
|
|
196
185
|
|
|
197
|
-
deleteMultipleFiles = async (
|
|
198
|
-
...opts
|
|
199
|
-
) => this.client.files.delete(...opts)
|
|
186
|
+
deleteMultipleFiles = async (...opts: Parameters<ServerFiles["delete"]>) =>
|
|
187
|
+
this.client.files.delete(...opts)
|
|
200
188
|
|
|
201
189
|
getUsers = async () => {
|
|
202
190
|
const data = await this.client.users.list()
|
|
203
|
-
return data.map(
|
|
191
|
+
return data.map(d => new ServerUser(this.client, d))
|
|
204
192
|
}
|
|
205
193
|
|
|
206
194
|
createUser = async (
|
|
207
195
|
email: string,
|
|
208
|
-
permissions: SubuserPermission[] | string[]
|
|
196
|
+
permissions: SubuserPermission[] | string[]
|
|
209
197
|
) => {
|
|
210
198
|
const data = await this.client.users.create(email, permissions)
|
|
211
199
|
return new ServerUser(this.client, data)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type {ServerClient} from "@/api/client/server"
|
|
2
|
+
import type {ServerAllocation as ServerAllocationT} from "@/api/client/types/server_allocation"
|
|
3
|
+
import type {Nullable} from "@/utils/types"
|
|
4
4
|
|
|
5
5
|
export class ServerAllocation {
|
|
6
6
|
private readonly client: ServerClient
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type {ServerClient} from "@/api/client/server"
|
|
2
|
+
import type {ServerBackup as ServerBackupT} from "@/api/common/types/server_backup"
|
|
3
|
+
import type {Nullable} from "@/utils/types"
|
|
4
4
|
|
|
5
5
|
export class ServerBackup {
|
|
6
6
|
private readonly client: ServerClient
|
|
@@ -35,13 +35,10 @@ export class ServerBackup {
|
|
|
35
35
|
|
|
36
36
|
delete = async () => this.client.backups.delete(this.uuid)
|
|
37
37
|
|
|
38
|
-
rename = async (
|
|
39
|
-
name: string
|
|
40
|
-
) => this.client.backups.rename(this.uuid, name)
|
|
38
|
+
rename = async (name: string) => this.client.backups.rename(this.uuid, name)
|
|
41
39
|
|
|
42
40
|
toggleLock = async () => this.client.backups.toggleLock(this.uuid)
|
|
43
41
|
|
|
44
|
-
restore = async (
|
|
45
|
-
truncate
|
|
46
|
-
) => this.client.backups.restore(this.uuid, truncate)
|
|
42
|
+
restore = async (truncate: boolean) =>
|
|
43
|
+
this.client.backups.restore(this.uuid, truncate)
|
|
47
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type {ServerClient} from "@/api/client/server"
|
|
2
|
+
import type {ServerDatabase as ServerDatabaseT} from "@/api/common/types/server_database"
|
|
3
3
|
// TODO: Check for validity
|
|
4
4
|
|
|
5
5
|
export class ServerDatabase {
|
package/src/humane/ServerFile.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path"
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type {ServerClient} from "@/api/client/server"
|
|
3
|
+
import type {FileObject} from "@/api/common/types/server_files"
|
|
4
4
|
|
|
5
5
|
export class ServerFile {
|
|
6
6
|
private readonly client: ServerClient
|
|
@@ -40,8 +40,8 @@ export class ServerFile {
|
|
|
40
40
|
"txz",
|
|
41
41
|
"tar.xz",
|
|
42
42
|
"tbz2",
|
|
43
|
-
"tar.bz2"
|
|
44
|
-
].some(
|
|
43
|
+
"tar.bz2"
|
|
44
|
+
].some(ext => this.name.endsWith(`.${ext}`))
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -54,7 +54,7 @@ export class ServerFile {
|
|
|
54
54
|
download = async () => this.client.files.download(this.path)
|
|
55
55
|
|
|
56
56
|
rename = async (newName: string) =>
|
|
57
|
-
this.client.files.rename(this.dir, [{
|
|
57
|
+
this.client.files.rename(this.dir, [{from: this.name, to: newName}])
|
|
58
58
|
|
|
59
59
|
copy = async () => this.client.files.copy(this.path)
|
|
60
60
|
|
|
@@ -70,16 +70,22 @@ export class ServerFile {
|
|
|
70
70
|
| "txz"
|
|
71
71
|
| "tar.xz"
|
|
72
72
|
| "tbz2"
|
|
73
|
-
| "tar.bz2"
|
|
74
|
-
) =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
| "tar.bz2"
|
|
74
|
+
) =>
|
|
75
|
+
new ServerFile(
|
|
76
|
+
this.client,
|
|
77
|
+
await this.client.files.compress(
|
|
78
|
+
this.dir,
|
|
79
|
+
[this.name],
|
|
80
|
+
archive_name,
|
|
81
|
+
extension
|
|
82
|
+
)
|
|
83
|
+
)
|
|
78
84
|
|
|
79
85
|
decompress = async () => this.client.files.decompress(this.dir, this.name)
|
|
80
86
|
|
|
81
87
|
delete = async () => this.client.files.delete(this.dir, [this.name])
|
|
82
88
|
|
|
83
89
|
chmod = async (mode: number) =>
|
|
84
|
-
this.client.files.chmod(this.dir, [{
|
|
90
|
+
this.client.files.chmod(this.dir, [{file: this.name, mode}])
|
|
85
91
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type {ServerClient} from "@/api/client/server"
|
|
2
|
+
import type {Schedule, ScheduleTask} from "@/api/common/types/server_schedule"
|
|
3
|
+
import type {Nullable, PartialBy} from "@/utils/types"
|
|
4
4
|
|
|
5
5
|
export class ServerSchedule {
|
|
6
6
|
private readonly client: ServerClient
|
|
@@ -12,7 +12,7 @@ export class ServerSchedule {
|
|
|
12
12
|
minute: string
|
|
13
13
|
}
|
|
14
14
|
get cron() {
|
|
15
|
-
return {
|
|
15
|
+
return {...this.$cron}
|
|
16
16
|
}
|
|
17
17
|
readonly id: number
|
|
18
18
|
private $isActive: boolean
|
|
@@ -53,7 +53,7 @@ export class ServerSchedule {
|
|
|
53
53
|
this.nextRunAt = new Date(schedule.next_run_at)
|
|
54
54
|
this.$onlyWhenOnline = schedule.only_when_online
|
|
55
55
|
this.tasks = schedule.relationships.tasks.data.map(
|
|
56
|
-
|
|
56
|
+
d => new ServerScheduleTask(this.client, this.id, d.attributes)
|
|
57
57
|
)
|
|
58
58
|
this.$updatedAt = new Date(schedule.updated_at)
|
|
59
59
|
}
|
|
@@ -144,7 +144,7 @@ export class ServerScheduleTask {
|
|
|
144
144
|
| "continue_on_failure"
|
|
145
145
|
>,
|
|
146
146
|
"payload" | "sequence_id" | "continue_on_failure"
|
|
147
|
-
|
|
147
|
+
>
|
|
148
148
|
) => {
|
|
149
149
|
const data = await this.client.schedules
|
|
150
150
|
.control(this.scheduleId)
|