wispjs 2.4.0 → 3.0.0
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/dist/wisp_api/index.d.ts +6 -0
- package/dist/wisp_api/index.js +8 -0
- package/dist/wisp_socket/filesystem.d.ts +60 -0
- package/dist/wisp_socket/filesystem.js +97 -0
- package/dist/wisp_socket/git.d.ts +57 -0
- package/dist/wisp_socket/git.js +76 -0
- package/dist/wisp_socket/index.d.ts +37 -18
- package/dist/wisp_socket/index.js +102 -157
- package/dist/wisp_socket/pool.d.ts +192 -48
- package/dist/wisp_socket/pool.js +132 -33
- package/dist/wisp_socket/ws_adapter.d.ts +72 -0
- package/dist/wisp_socket/ws_adapter.js +130 -0
- package/package.json +5 -4
- package/.github/workflows/release.yml +0 -77
- package/tsconfig.json +0 -19
- package/wisp.ts +0 -43
- package/wisp_api/apis/allocations.ts +0 -71
- package/wisp_api/apis/audit_log.ts +0 -81
- package/wisp_api/apis/backups.ts +0 -168
- 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/index.ts +0 -495
- package/wisp_socket/pool.ts +0 -369
package/wisp_api/apis/index.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
export type RequestTypes = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2
|
-
|
|
3
|
-
export interface PaginationData {
|
|
4
|
-
total: number;
|
|
5
|
-
count: number;
|
|
6
|
-
perPage: number;
|
|
7
|
-
currentPage: number;
|
|
8
|
-
totalPages: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface WispAPICore {
|
|
12
|
-
domain: string;
|
|
13
|
-
uuid: string;
|
|
14
|
-
token: string;
|
|
15
|
-
logger: any;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The Core of the API, handling low-level operations such as making requests and setting the server UUID
|
|
20
|
-
*
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
export class WispAPICore {
|
|
24
|
-
constructor(domain: string, uuid: string, token: string, logger: any) {
|
|
25
|
-
this.domain = domain;
|
|
26
|
-
this.uuid = uuid;
|
|
27
|
-
this.token = token;
|
|
28
|
-
this.logger = logger;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Sets the Server UUID
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* ℹ️ This can be updated at any time, making all future API calls reference the new Server UUID
|
|
36
|
-
*
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
setUUID(uuid: string) {
|
|
40
|
-
this.uuid = uuid;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Generates a URL for the given path
|
|
45
|
-
*
|
|
46
|
-
* @param path The API path
|
|
47
|
-
*
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
makeURL(path: string) {
|
|
51
|
-
return `https://${this.domain}/api/client/servers/${this.uuid}/${path}`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// TODO: Handle standard field-level error messages:
|
|
55
|
-
// {"errors":[{"code":"required","detail":"The path field is required","source":{"field":"path"}}]}
|
|
56
|
-
/**
|
|
57
|
-
* Makes a request with the headers and request data set automatically.
|
|
58
|
-
*
|
|
59
|
-
* @remarks
|
|
60
|
-
* The data field is formatted appropriately for whichever request type is given.
|
|
61
|
-
*
|
|
62
|
-
* @param method A standared request method.
|
|
63
|
-
* @param path The API path to send the request to.
|
|
64
|
-
* @param data The data to include with the request.
|
|
65
|
-
*
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
async makeRequest(method: RequestTypes, path: string, data?: any) {
|
|
69
|
-
let url = this.makeURL(path);
|
|
70
|
-
const headers = new Headers({
|
|
71
|
-
"Content-Type": "application/json",
|
|
72
|
-
"Accept": "application/vnd.wisp.v1+json",
|
|
73
|
-
"Authorization": `Bearer ${this.token}`,
|
|
74
|
-
"User-Agent": "WispJS (https://github.com/CFC-Servers/wispjs, 1.0.0)"
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const request = async () => {
|
|
78
|
-
let response: Response;
|
|
79
|
-
|
|
80
|
-
console.log(`${method} -> ${url}`);
|
|
81
|
-
|
|
82
|
-
switch(method) {
|
|
83
|
-
case "GET":
|
|
84
|
-
if (data !== null) {
|
|
85
|
-
const params = new URLSearchParams(data);
|
|
86
|
-
const uri = new URL(url);
|
|
87
|
-
|
|
88
|
-
uri.search = params.toString();
|
|
89
|
-
url = uri.toString();
|
|
90
|
-
console.log(`Updated GET URL: ${url}`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
response = await fetch(url, { method: "GET", headers: headers });
|
|
94
|
-
break;
|
|
95
|
-
|
|
96
|
-
case "POST":
|
|
97
|
-
data = JSON.stringify(data);
|
|
98
|
-
response = await fetch(url, { method: "POST", headers: headers, body: data });
|
|
99
|
-
break;
|
|
100
|
-
|
|
101
|
-
case "PUT":
|
|
102
|
-
data = data ? JSON.stringify(data) : "";
|
|
103
|
-
response = await fetch(url, { method: "PUT", headers: headers, body: data });
|
|
104
|
-
break;
|
|
105
|
-
|
|
106
|
-
case "PATCH":
|
|
107
|
-
data = JSON.stringify(data);
|
|
108
|
-
response = await fetch(url, { method: "PATCH", headers: headers, body: data });
|
|
109
|
-
break;
|
|
110
|
-
|
|
111
|
-
case "DELETE":
|
|
112
|
-
response = await fetch(url, { method: "DELETE", headers: headers });
|
|
113
|
-
break;
|
|
114
|
-
|
|
115
|
-
default:
|
|
116
|
-
throw new Error(`Invalid method: ${method}`);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (!response.ok) {
|
|
120
|
-
const status = response.status;
|
|
121
|
-
const statusText = response.statusText;
|
|
122
|
-
this.logger.error(`Request failed: ${method} -> ${url}: ${status} - ${statusText}`);
|
|
123
|
-
|
|
124
|
-
const text = await response.text();
|
|
125
|
-
this.logger.error(text);
|
|
126
|
-
|
|
127
|
-
throw new Error(`Request failed! Status: ${status} - ${statusText}`);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return response;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return await request();
|
|
134
|
-
}
|
|
135
|
-
}
|
package/wisp_api/apis/mods.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { WispAPICore } from "./index";
|
|
2
|
-
|
|
3
|
-
export interface Mod {
|
|
4
|
-
object: "mod";
|
|
5
|
-
attributes: {
|
|
6
|
-
id: number;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
version: string;
|
|
10
|
-
category: string;
|
|
11
|
-
install_count: number;
|
|
12
|
-
server_state: number;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface GetModsResponse {
|
|
17
|
-
object: "list";
|
|
18
|
-
data: Mod[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Handles Listing and Installating of Mods
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export class ModsAPI {
|
|
27
|
-
constructor(private core: WispAPICore) {}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Lists all Mods available to the Server
|
|
32
|
-
*
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
|
-
async List(): Promise<GetModsResponse> {
|
|
36
|
-
const response = await this.core.makeRequest("GET", "mods");
|
|
37
|
-
const data: GetModsResponse = await response.json();
|
|
38
|
-
|
|
39
|
-
return data;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Installs or Uninstalls the Mod with the given id
|
|
45
|
-
*
|
|
46
|
-
* @param id The ID of the Mod to Install/Uninstall
|
|
47
|
-
*
|
|
48
|
-
* @public
|
|
49
|
-
*/
|
|
50
|
-
async ToggleInstall(id: string): Promise<void> {
|
|
51
|
-
await this.core.makeRequest("POST", `mods/${id}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -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
|
-
}
|