wispjs 2.1.3 → 2.1.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.
- package/README.md +4 -4
- package/{wisp.ts → dist/wisp.d.ts} +11 -28
- package/dist/wisp.js +34 -0
- package/dist/wisp_api/apis/allocations.d.ts +55 -0
- package/dist/wisp_api/apis/allocations.js +32 -0
- package/dist/wisp_api/apis/audit_log.d.ts +68 -0
- package/dist/wisp_api/apis/audit_log.js +21 -0
- package/{wisp_api/apis/backups.ts → dist/wisp_api/apis/backups.d.ts} +13 -51
- package/dist/wisp_api/apis/backups.js +93 -0
- package/dist/wisp_api/apis/databases.d.ts +61 -0
- package/dist/wisp_api/apis/databases.js +43 -0
- package/dist/wisp_api/apis/fastdl.d.ts +19 -0
- package/dist/wisp_api/apis/fastdl.js +21 -0
- package/dist/wisp_api/apis/filesystem.d.ts +200 -0
- package/dist/wisp_api/apis/filesystem.js +182 -0
- package/dist/wisp_api/apis/index.d.ts +52 -0
- package/dist/wisp_api/apis/index.js +100 -0
- package/dist/wisp_api/apis/mods.d.ts +40 -0
- package/dist/wisp_api/apis/mods.js +30 -0
- package/dist/wisp_api/apis/schedules.d.ts +179 -0
- package/dist/wisp_api/apis/schedules.js +167 -0
- package/dist/wisp_api/apis/servers.d.ts +120 -0
- package/dist/wisp_api/apis/servers.js +76 -0
- package/dist/wisp_api/apis/startup.d.ts +52 -0
- package/dist/wisp_api/apis/startup.js +35 -0
- package/dist/wisp_api/apis/subusers.d.ts +106 -0
- package/dist/wisp_api/apis/subusers.js +87 -0
- package/dist/wisp_api/index.d.ts +39 -0
- package/dist/wisp_api/index.js +41 -0
- package/dist/wisp_socket/index.d.ts +161 -0
- package/{wisp_socket/index.ts → dist/wisp_socket/index.js} +130 -236
- package/dist/wisp_socket/pool.d.ts +183 -0
- package/dist/wisp_socket/pool.js +171 -0
- package/package.json +1 -1
- package/.github/workflows/release.yml +0 -72
- package/tsconfig.json +0 -19
- package/wisp_api/apis/allocations.ts +0 -71
- package/wisp_api/apis/audit_log.ts +0 -81
- package/wisp_api/apis/databases.ts +0 -80
- package/wisp_api/apis/fastdl.ts +0 -22
- package/wisp_api/apis/filesystem.ts +0 -291
- package/wisp_api/apis/index.ts +0 -135
- package/wisp_api/apis/mods.ts +0 -53
- package/wisp_api/apis/schedules.ts +0 -270
- package/wisp_api/apis/servers.ts +0 -155
- package/wisp_api/apis/startup.ts +0 -65
- package/wisp_api/apis/subusers.ts +0 -159
- package/wisp_api/index.ts +0 -57
- package/wisp_socket/pool.ts +0 -387
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { WispAPICore } from "./index";
|
|
2
|
-
import type { PaginationData } from "./index";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A Cron-formatted scheduling object
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export interface CronSchedule {
|
|
10
|
-
minute: string;
|
|
11
|
-
hour: string;
|
|
12
|
-
day_of_week: string;
|
|
13
|
-
day_of_month: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface Schedule {
|
|
17
|
-
object: "schedule";
|
|
18
|
-
attributes: {
|
|
19
|
-
id: number;
|
|
20
|
-
name: string;
|
|
21
|
-
cron: CronSchedule;
|
|
22
|
-
is_active: boolean;
|
|
23
|
-
is_processing: boolean;
|
|
24
|
-
last_run_at: string | null;
|
|
25
|
-
next_run_at: string | null;
|
|
26
|
-
created_at: string;
|
|
27
|
-
updated_at: string;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* A response object for the GetSchedule call
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* Used in {@link SchedulesAPI.List}
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
export interface GetSchedulesResponse {
|
|
40
|
-
object: "list";
|
|
41
|
-
data: Schedule[];
|
|
42
|
-
meta: {
|
|
43
|
-
pagination: PaginationData;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface CreateScheduleRequest {
|
|
48
|
-
name: string;
|
|
49
|
-
cron_minute: string;
|
|
50
|
-
cron_hour: string;
|
|
51
|
-
cron_day_of_week: string;
|
|
52
|
-
cron_day_of_month: string;
|
|
53
|
-
is_active: boolean;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface ScheduleTask {
|
|
57
|
-
object: "schedule_task";
|
|
58
|
-
attributes: {
|
|
59
|
-
id: number;
|
|
60
|
-
sequence_id: number;
|
|
61
|
-
action: string;
|
|
62
|
-
payload: string;
|
|
63
|
-
time_offset: string;
|
|
64
|
-
is_processing: boolean;
|
|
65
|
-
created_at: string;
|
|
66
|
-
updated_at: string;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export type ScheduleTaskAction = "command" | "power" | "backup";
|
|
71
|
-
|
|
72
|
-
export interface CreateScheduleTaskRequest {
|
|
73
|
-
action: ScheduleTaskAction;
|
|
74
|
-
time_offset: number;
|
|
75
|
-
payload: string | null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Handles interactions with Server Schedules
|
|
80
|
-
*
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
83
|
-
export class SchedulesAPI {
|
|
84
|
-
constructor(private core: WispAPICore) {}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Retrieves all of the Schedules for the Server
|
|
89
|
-
*
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
92
|
-
async List(): Promise<GetSchedulesResponse> {
|
|
93
|
-
const response = await this.core.makeRequest("GET", "schedules", { include: "tasks" });
|
|
94
|
-
const data: GetSchedulesResponse = await response.json();
|
|
95
|
-
|
|
96
|
-
return data
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Retrieves the Details for the Schedule
|
|
102
|
-
*
|
|
103
|
-
* @param id The ID of the Schedule
|
|
104
|
-
*
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
|
-
async GetDetails(id: string): Promise<Schedule> {
|
|
108
|
-
const response = await this.core.makeRequest("GET", `schedules/${id}`, { include: "tasks" });
|
|
109
|
-
const data: Schedule = await response.json();
|
|
110
|
-
|
|
111
|
-
return data;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Creates a new Schedule
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* Creates a Schedule that runs at 12am every day
|
|
120
|
-
* ```
|
|
121
|
-
* await wisp.api.Schedules.Create("Example", "0", "0", "*", "*", true);
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* @param name The name of the Schedule
|
|
125
|
-
* @param minute The Cron minute string
|
|
126
|
-
* @param hour The Cron hour string
|
|
127
|
-
* @param dow The Cron day of week string
|
|
128
|
-
* @param dom The Cron day of month string
|
|
129
|
-
* @param active Whether to enable the Schedle on creation
|
|
130
|
-
*
|
|
131
|
-
* @public
|
|
132
|
-
*/
|
|
133
|
-
async Create(name: string, minute: string, hour: string, dow: string, dom: string, active: boolean): Promise<Schedule> {
|
|
134
|
-
const requestData: CreateScheduleRequest = {
|
|
135
|
-
name: name,
|
|
136
|
-
cron_minute: minute,
|
|
137
|
-
cron_hour: hour,
|
|
138
|
-
cron_day_of_week: dow,
|
|
139
|
-
cron_day_of_month: dom,
|
|
140
|
-
is_active: active
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const response = await this.core.makeRequest("POST", "schedules", requestData);
|
|
144
|
-
const data: Schedule = await response.json();
|
|
145
|
-
|
|
146
|
-
return data;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Updates the values of the Schedule
|
|
152
|
-
*
|
|
153
|
-
* @param id The ID of the Schedule
|
|
154
|
-
* @param name The name of the Schedule
|
|
155
|
-
* @param minute The Cron minute string
|
|
156
|
-
* @param hour The Cron hour string
|
|
157
|
-
* @param dow The Cron day of week string
|
|
158
|
-
* @param dom The Cron day of month string
|
|
159
|
-
* @param active Whether to enable the Schedle on creation
|
|
160
|
-
*
|
|
161
|
-
* @public
|
|
162
|
-
*/
|
|
163
|
-
async Update(id: string, name: string, minute: string, hour: string, dow: string, dom: string, active: boolean): Promise<Schedule> {
|
|
164
|
-
const requestData: CreateScheduleRequest = {
|
|
165
|
-
name: name,
|
|
166
|
-
cron_minute: minute,
|
|
167
|
-
cron_hour: hour,
|
|
168
|
-
cron_day_of_week: dow,
|
|
169
|
-
cron_day_of_month: dom,
|
|
170
|
-
is_active: active
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const response = await this.core.makeRequest("PATCH", `schedules/${id}`, requestData);
|
|
174
|
-
const data: Schedule = await response.json();
|
|
175
|
-
|
|
176
|
-
return data;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Triggers the Schedule
|
|
182
|
-
*
|
|
183
|
-
* @param id The ID of the Schedule
|
|
184
|
-
*
|
|
185
|
-
* @public
|
|
186
|
-
*/
|
|
187
|
-
async Trigger(id: string): Promise<void> {
|
|
188
|
-
await this.core.makeRequest("POST", `schedules/${id}`);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Deletes the Schedule
|
|
194
|
-
*
|
|
195
|
-
* @param id The ID of the Schedule
|
|
196
|
-
*
|
|
197
|
-
* @public
|
|
198
|
-
*/
|
|
199
|
-
async Delete(id: string): Promise<void> {
|
|
200
|
-
await this.core.makeRequest("DELETE", `schedules/${id}`);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Creates a new Task for a Schedule
|
|
206
|
-
*
|
|
207
|
-
* @remarks
|
|
208
|
-
* ℹ️ Payload is not required for backup action!
|
|
209
|
-
*
|
|
210
|
-
* @param id The ID of the Schedule to create a Task for
|
|
211
|
-
* @param action The Task action. One of: ["command", "power", "backup"]
|
|
212
|
-
* @param timeOffset The time offset of the Task
|
|
213
|
-
* @param payload The payload to provide to the Task
|
|
214
|
-
*
|
|
215
|
-
* @public
|
|
216
|
-
*/
|
|
217
|
-
async CreateTask(id: string, action: ScheduleTaskAction, timeOffset: number, payload: string | null): Promise<ScheduleTask> {
|
|
218
|
-
const requestData: CreateScheduleTaskRequest = {
|
|
219
|
-
action: action,
|
|
220
|
-
time_offset: timeOffset,
|
|
221
|
-
payload: payload
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const response = await this.core.makeRequest("POST", `schedules/${id}/tasks`, requestData);
|
|
225
|
-
const data: ScheduleTask = await response.json();
|
|
226
|
-
|
|
227
|
-
return data;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Update the Task
|
|
233
|
-
*
|
|
234
|
-
* @remarks
|
|
235
|
-
* ℹ️ Payload is not required for backup action!
|
|
236
|
-
*
|
|
237
|
-
* @param scheduleID The ID of the Schedule that contains the Task
|
|
238
|
-
* @param taskID The ID of the Task
|
|
239
|
-
* @param action The Task action. One of: ["command", "power", "backup"]
|
|
240
|
-
* @param timeOffset The time offset of the Task
|
|
241
|
-
* @param payload The payload to provide to the Task
|
|
242
|
-
*
|
|
243
|
-
* @public
|
|
244
|
-
*/
|
|
245
|
-
async UpdateTask(scheduleID: string, taskID: string, action: ScheduleTaskAction, timeOffset: number, payload: string | null): Promise<ScheduleTask> {
|
|
246
|
-
const requestData: CreateScheduleTaskRequest = {
|
|
247
|
-
action: action,
|
|
248
|
-
time_offset: timeOffset,
|
|
249
|
-
payload: payload
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const response = await this.core.makeRequest("PATCH", `schedules/${scheduleID}/tasks/${taskID}`, requestData);
|
|
253
|
-
const data: ScheduleTask = await response.json();
|
|
254
|
-
|
|
255
|
-
return data;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Delete the Task
|
|
261
|
-
*
|
|
262
|
-
* @param scheduleID The ID of the Schedule that contains the Task
|
|
263
|
-
* @param taskID The ID of the Task
|
|
264
|
-
*
|
|
265
|
-
* @public
|
|
266
|
-
*/
|
|
267
|
-
async DeleteTask(scheduleID: string, taskID: string): Promise<void> {
|
|
268
|
-
await this.core.makeRequest("DELETE", `schedules/${scheduleID}/tasks/${taskID}`);
|
|
269
|
-
}
|
|
270
|
-
}
|
package/wisp_api/apis/servers.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { WispAPICore } from "./index";
|
|
2
|
-
|
|
3
|
-
export type PowerRequest = "start" | "stop" | "restart" | "kill";
|
|
4
|
-
export interface GetDetailsResponse {
|
|
5
|
-
object: "server";
|
|
6
|
-
attributes: {
|
|
7
|
-
id: number;
|
|
8
|
-
uuid: string;
|
|
9
|
-
uuid_short: string;
|
|
10
|
-
name: string;
|
|
11
|
-
description: string|null;
|
|
12
|
-
monitor: boolean;
|
|
13
|
-
support_op: boolean;
|
|
14
|
-
installed: number;
|
|
15
|
-
limits: {
|
|
16
|
-
memory: number;
|
|
17
|
-
swap: number;
|
|
18
|
-
disk: number;
|
|
19
|
-
io: number;
|
|
20
|
-
cpu: number;
|
|
21
|
-
}
|
|
22
|
-
feature_limits: {
|
|
23
|
-
databases: number;
|
|
24
|
-
backup_megabytes: number;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
// TODO: Get permissions types from permission api
|
|
28
|
-
// TODO: This isn't present on the SetName response
|
|
29
|
-
// meta: {
|
|
30
|
-
// extra_objects: { object: "permissions", attributes: ["server:support.update"] }
|
|
31
|
-
// }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface GetWebsocketDetailsResponse {
|
|
35
|
-
url: string;
|
|
36
|
-
upload_url: string;
|
|
37
|
-
token: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface GetResourcesResponse {
|
|
41
|
-
status: number;
|
|
42
|
-
proc: {
|
|
43
|
-
memory: {
|
|
44
|
-
total: number;
|
|
45
|
-
limit: number;
|
|
46
|
-
}
|
|
47
|
-
cpu: {
|
|
48
|
-
total: number;
|
|
49
|
-
limit: number;
|
|
50
|
-
}
|
|
51
|
-
disk: {
|
|
52
|
-
used: number;
|
|
53
|
-
limit: number;
|
|
54
|
-
io_limit: number;
|
|
55
|
-
}
|
|
56
|
-
network: {
|
|
57
|
-
[key:string]: {
|
|
58
|
-
rx_bytes: number;
|
|
59
|
-
rx_packets: number;
|
|
60
|
-
rx_errors: number;
|
|
61
|
-
rx_dropped: number;
|
|
62
|
-
tx_bytes: number;
|
|
63
|
-
tx_packets: number;
|
|
64
|
-
tx_errors: number;
|
|
65
|
-
tx_dropped: number;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Handles generic Server interaction, such as Sending Commands, managing Power State, and getting Details
|
|
73
|
-
*
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
export class ServersAPI {
|
|
77
|
-
constructor(private core: WispAPICore) {}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Sends a command to the Server
|
|
82
|
-
*
|
|
83
|
-
* @param command The full command string to send to the Server
|
|
84
|
-
*
|
|
85
|
-
* @public
|
|
86
|
-
*/
|
|
87
|
-
async SendCommand(command: string): Promise<void> {
|
|
88
|
-
await this.core.makeRequest("POST", "command", { command: command });
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Gets the Websocket connection (and upload) details for the Server
|
|
94
|
-
*
|
|
95
|
-
* @public
|
|
96
|
-
*/
|
|
97
|
-
async GetWebsocketDetails(): Promise<GetWebsocketDetailsResponse> {
|
|
98
|
-
const response = await this.core.makeRequest("GET", "websocket");
|
|
99
|
-
return await response.json();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Sets the name of the Server as it appears in the panel
|
|
105
|
-
* (Same thing as setting the name in the "Server Details" menu)
|
|
106
|
-
*
|
|
107
|
-
* @param name The new name of the server
|
|
108
|
-
*
|
|
109
|
-
* @public
|
|
110
|
-
*/
|
|
111
|
-
async SetName(name: string): Promise<GetDetailsResponse> {
|
|
112
|
-
const response = await this.core.makeRequest("PATCH", "details", { name: name });
|
|
113
|
-
return await response.json();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Retrieves the basic, technical details of the Server
|
|
119
|
-
*
|
|
120
|
-
* @public
|
|
121
|
-
*/
|
|
122
|
-
async GetDetails(): Promise<GetDetailsResponse> {
|
|
123
|
-
const response = await this.core.makeRequest("GET", "");
|
|
124
|
-
return await response.json();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Retrieves technical details of the Server's resources
|
|
129
|
-
* (CPU, Memory, Disk, Network)
|
|
130
|
-
*
|
|
131
|
-
* @public
|
|
132
|
-
*/
|
|
133
|
-
async GetResources(): Promise<GetResourcesResponse> {
|
|
134
|
-
const response = await this.core.makeRequest("GET", "resources");
|
|
135
|
-
return await response.json();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Instructs the Server to start up, shut down, restart, or force quit
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* Example of stopping the server
|
|
144
|
-
* ```
|
|
145
|
-
* await wisp.api.PowerRequest("stop");
|
|
146
|
-
* ```
|
|
147
|
-
*
|
|
148
|
-
* @param action The power action to send. One of: ["start", "stop", "restart", "kill"]
|
|
149
|
-
*
|
|
150
|
-
* @public
|
|
151
|
-
*/
|
|
152
|
-
async PowerRequest(action: PowerRequest): Promise<void> {
|
|
153
|
-
await this.core.makeRequest("POST", "power", { signal: action });
|
|
154
|
-
}
|
|
155
|
-
}
|
package/wisp_api/apis/startup.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { WispAPICore } from "./index";
|
|
2
|
-
|
|
3
|
-
export interface UpdateStartup {
|
|
4
|
-
environment: { [key: string]: any };
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface StartupDetail {
|
|
8
|
-
object: "server_variable";
|
|
9
|
-
attributes: {
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
env_variable: string;
|
|
13
|
-
default_value: string;
|
|
14
|
-
tickable: boolean;
|
|
15
|
-
user_editable: boolean;
|
|
16
|
-
rules: string;
|
|
17
|
-
server_value: string;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface StartupDetails {
|
|
22
|
-
object: "list";
|
|
23
|
-
data: StartupDetail[];
|
|
24
|
-
meta: {
|
|
25
|
-
startup_command: string;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Handles interaction with Server Startup information
|
|
31
|
-
*
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export class StartupAPI {
|
|
35
|
-
constructor(private core: WispAPICore) {}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Gets all Startup details for the Server
|
|
39
|
-
*
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
async Get(): Promise<StartupDetails> {
|
|
43
|
-
const response = await this.core.makeRequest("GET", "startup");
|
|
44
|
-
const startupDetails: StartupDetails = await response.json();
|
|
45
|
-
|
|
46
|
-
return startupDetails;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Updates the Startup details for the Server
|
|
51
|
-
*
|
|
52
|
-
* @remarks
|
|
53
|
-
* ℹ️ Pass the variables with their new value to update them. Response will contain the new updated startup
|
|
54
|
-
*
|
|
55
|
-
* @param startup The Startup values to update
|
|
56
|
-
*
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
async Update(startup: UpdateStartup): Promise<StartupDetails> {
|
|
60
|
-
const response = await this.core.makeRequest("PUT", "startup", startup);
|
|
61
|
-
const data: StartupDetails = await response.json();
|
|
62
|
-
|
|
63
|
-
return data;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { WispAPICore } from "./index";
|
|
2
|
-
import type { PaginationData } from "./index";
|
|
3
|
-
|
|
4
|
-
export type SupportPermissionType = "server:support.update";
|
|
5
|
-
export type ControlPermissionType = "server:control.console" | "server:control.command" | "server:control.start" | "server:control.stop" | "server:control.restart";
|
|
6
|
-
export type SubuserPermissionType = "server:subuser.read" | "server:subuser.update" | "server:subuser.create" | "server:subuser.delete";
|
|
7
|
-
export type AllocationPermissionType = "server:allocation.read" | "server:allocation.update";
|
|
8
|
-
export type StartupPermissionType = "server:startup.read" | "server:startup.update";
|
|
9
|
-
export type DatabasePermissionType = "server:database.read" | "server:database.update" | "server:database.create" | "server:database.update";
|
|
10
|
-
export type FilePermissionType = "server:file.sftp" | "server:file.list" | "server:file.read" | "server:file.write" | "server:file.delete" | "server:file.archive" | "server:file.git" | "server:file.steam_workshop";
|
|
11
|
-
export type SchedulePermissionType = "server:schedule.read" | "server:schedule.update" | "server:schedule.create" | "server:schedule.delete";
|
|
12
|
-
export type BackupPermissionType = "server:backup.read" | "server:backup.update" | "server:backup.create" | "server:backup.delete" | "server:backup.deploy" | "server:backup.download";
|
|
13
|
-
export type DetailsPermissionType = "server:details.read" | "server:details.update";
|
|
14
|
-
export type AuditPermissionType = "server:audit.read";
|
|
15
|
-
export type FastDLPermissionType = "server:fastdl.read" | "server:fastdl.update";
|
|
16
|
-
export type ModPermissionType = "server:mod.read" | "server:mod.update";
|
|
17
|
-
export type MonitorPermissionType = "server:monitor.read" | "server:monitor.update";
|
|
18
|
-
export type ReinstallPermissionType = "server:reinstall.update";
|
|
19
|
-
export type Permission = SupportPermissionType | ControlPermissionType | SubuserPermissionType | AllocationPermissionType | StartupPermissionType | DatabasePermissionType | FilePermissionType | SchedulePermissionType | BackupPermissionType | DetailsPermissionType | AuditPermissionType | FastDLPermissionType | ModPermissionType | MonitorPermissionType | ReinstallPermissionType;
|
|
20
|
-
|
|
21
|
-
export interface User {
|
|
22
|
-
object: "user";
|
|
23
|
-
attributes: {
|
|
24
|
-
email: string;
|
|
25
|
-
name_first: string;
|
|
26
|
-
naem_last: string;
|
|
27
|
-
has_2fa: boolean;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface Subuser {
|
|
32
|
-
object: "server_subuser";
|
|
33
|
-
attributes: {
|
|
34
|
-
id: number;
|
|
35
|
-
permissions: Permission[];
|
|
36
|
-
created_at: string;
|
|
37
|
-
updated_at: string;
|
|
38
|
-
relationships: {
|
|
39
|
-
user: User;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface GetSubusersResponse {
|
|
45
|
-
object: "list";
|
|
46
|
-
data: Subuser[];
|
|
47
|
-
meta: {
|
|
48
|
-
pagination: PaginationData;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface GetAllSubuserPermissionsResponse {
|
|
53
|
-
permissions: Permission[];
|
|
54
|
-
assignable: Permission[];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Handles interfacing with the Subusers API
|
|
59
|
-
*
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
export class SubusersAPI {
|
|
63
|
-
constructor(private core: WispAPICore) {}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Lists all Subusers for the Server
|
|
68
|
-
*
|
|
69
|
-
* @public
|
|
70
|
-
*/
|
|
71
|
-
async List(): Promise<GetSubusersResponse> {
|
|
72
|
-
const response = await this.core.makeRequest("GET", "subusers", { include: "user" });
|
|
73
|
-
const data: GetSubusersResponse = await response.json();
|
|
74
|
-
|
|
75
|
-
return data;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Retrieves the details for the Subuser
|
|
81
|
-
*
|
|
82
|
-
* @param id The ID of the Subuser
|
|
83
|
-
*
|
|
84
|
-
* @public
|
|
85
|
-
*/
|
|
86
|
-
async GetDetails(id: string): Promise<Subuser> {
|
|
87
|
-
const response = await this.core.makeRequest("GET", `subusers/${id}`, { include: "user" });
|
|
88
|
-
const data: Subuser = await response.json();
|
|
89
|
-
|
|
90
|
-
return data;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get all permissions available to Subusers
|
|
96
|
-
*
|
|
97
|
-
* @public
|
|
98
|
-
*/
|
|
99
|
-
async GetAllPermissions(): Promise<GetAllSubuserPermissionsResponse> {
|
|
100
|
-
const response = await this.core.makeRequest("GET", "subusers/permissions");
|
|
101
|
-
const data: GetAllSubuserPermissionsResponse = await response.json();
|
|
102
|
-
|
|
103
|
-
return data;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Creates a new Subuser
|
|
109
|
-
*
|
|
110
|
-
* @param email The email for the Subuser
|
|
111
|
-
* @param permissions The Permissions to grant to the Subuser
|
|
112
|
-
*
|
|
113
|
-
* @public
|
|
114
|
-
*/
|
|
115
|
-
async Create(email: string, permissions: Permission[]): Promise<Subuser> {
|
|
116
|
-
const requestData = {
|
|
117
|
-
email: email,
|
|
118
|
-
permissions: permissions
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const response = await this.core.makeRequest("POST", "subusers", requestData);
|
|
122
|
-
const data: Subuser = await response.json();
|
|
123
|
-
|
|
124
|
-
return data;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Updates the Subuser
|
|
130
|
-
*
|
|
131
|
-
* @param id The ID of the Subuser
|
|
132
|
-
* @param email The new email of the Subuser
|
|
133
|
-
* @param permissions The new permissions for the Subuser
|
|
134
|
-
*
|
|
135
|
-
* @public
|
|
136
|
-
*/
|
|
137
|
-
async Update(id: string, email: string, permissions: Permission[]): Promise<Subuser> {
|
|
138
|
-
const data = {
|
|
139
|
-
email: email,
|
|
140
|
-
permissions: permissions
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const response = await this.core.makeRequest("PATCH", `subusers/${id}`, data);
|
|
144
|
-
const responseData: Subuser = await response.json();
|
|
145
|
-
|
|
146
|
-
return responseData;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Deletes the Subuser
|
|
151
|
-
*
|
|
152
|
-
* @param id The ID of the Subuser
|
|
153
|
-
*
|
|
154
|
-
* @public
|
|
155
|
-
*/
|
|
156
|
-
async Delete(id: string): Promise<void> {
|
|
157
|
-
await this.core.makeRequest("DELETE", `subusers/${id}`);
|
|
158
|
-
}
|
|
159
|
-
}
|
package/wisp_api/index.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { WispAPICore } from "./apis/index.js";
|
|
2
|
-
import { AllocationsAPI } from "./apis/allocations.js";
|
|
3
|
-
import { AuditLogsAPI } from "./apis/audit_log.js";
|
|
4
|
-
import { BackupsAPI } from "./apis/backups.js";
|
|
5
|
-
import { DatabasesAPI } from "./apis/databases.js";
|
|
6
|
-
import { FastDLAPI } from "./apis/fastdl.js";
|
|
7
|
-
import { FilesystemAPI } from "./apis/filesystem.js";
|
|
8
|
-
import { ModsAPI } from "./apis/mods.js";
|
|
9
|
-
import { SchedulesAPI } from "./apis/schedules.js";
|
|
10
|
-
import { ServersAPI } from "./apis/servers.js";
|
|
11
|
-
import { StartupAPI } from "./apis/startup.js";
|
|
12
|
-
import { SubusersAPI } from "./apis/subusers.js";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* An Interface for the Wisp HTTP API
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export class WispAPI {
|
|
20
|
-
private core: WispAPICore;
|
|
21
|
-
|
|
22
|
-
public Allocations: AllocationsAPI;
|
|
23
|
-
public AuditLogs: AuditLogsAPI;
|
|
24
|
-
public Backups: BackupsAPI;
|
|
25
|
-
public Databases: DatabasesAPI;
|
|
26
|
-
public FastDL: FastDLAPI;
|
|
27
|
-
public Filesystem: FilesystemAPI;
|
|
28
|
-
public Mods: ModsAPI;
|
|
29
|
-
public Schedules: SchedulesAPI;
|
|
30
|
-
public Servers: ServersAPI;
|
|
31
|
-
public Startup: StartupAPI;
|
|
32
|
-
public Subusers: SubusersAPI;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param domain The domain name for your panel
|
|
36
|
-
* @param uuid The UUID of the Server that all future API calls will reference
|
|
37
|
-
* @param token The panel API token to use for authorization
|
|
38
|
-
* @param logger The logger to use for all API logging
|
|
39
|
-
*
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
constructor(domain: string, uuid: string, token: string, logger: any) {
|
|
43
|
-
this.core = new WispAPICore(domain, uuid, token, logger);
|
|
44
|
-
|
|
45
|
-
this.Allocations = new AllocationsAPI(this.core);
|
|
46
|
-
this.AuditLogs = new AuditLogsAPI(this.core);
|
|
47
|
-
this.Backups = new BackupsAPI(this.core);
|
|
48
|
-
this.Databases = new DatabasesAPI(this.core);
|
|
49
|
-
this.FastDL = new FastDLAPI(this.core);
|
|
50
|
-
this.Filesystem = new FilesystemAPI(this.core);
|
|
51
|
-
this.Mods = new ModsAPI(this.core);
|
|
52
|
-
this.Schedules = new SchedulesAPI(this.core);
|
|
53
|
-
this.Servers = new ServersAPI(this.core);
|
|
54
|
-
this.Startup = new StartupAPI(this.core);
|
|
55
|
-
this.Subusers = new SubusersAPI(this.core);
|
|
56
|
-
}
|
|
57
|
-
}
|