wispjs 2.1.3 → 2.2.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/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 +162 -0
- package/{wisp_socket/index.ts → dist/wisp_socket/index.js} +131 -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
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# WispJS
|
|
2
2
|
<p align="left">
|
|
3
3
|
<a href="https://discord.gg/5JUqZjzmYJ" alt="Discord Invite"><img src="https://img.shields.io/discord/981394195812085770?label=Support&logo=discord&logoColor=white" /></a>
|
|
4
|
-
<a href="https://www.npmjs.com/package
|
|
4
|
+
<a href="https://www.npmjs.com/package/wispjs" alt="NPM Package Link"><img src="https://img.shields.io/npm/v/%40cfc-servers%2Fwispjs?label=NPM&logo=npm" /></a>
|
|
5
5
|
<a href="https://docs.wispjs.com" alt="Docs Link"><img src="https://img.shields.io/badge/Docs-docs.wispjs.com-blue?logo=readthedocs" /></a>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
@@ -20,7 +20,7 @@ We're always looking for notes about what this does/doesn't work for! Please lea
|
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
```
|
|
23
|
-
npm i
|
|
23
|
+
npm i wispjs@v2
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## What can I do with this?
|
|
@@ -58,7 +58,7 @@ _(while logged in)_ and generate a new Token.
|
|
|
58
58
|
|
|
59
59
|
In general, your WispJS code will start like this:
|
|
60
60
|
```js
|
|
61
|
-
import { WispInterface } from "
|
|
61
|
+
import { WispInterface } from "wispjs"
|
|
62
62
|
|
|
63
63
|
const domain = "<your.wisp.domain>"
|
|
64
64
|
|
|
@@ -81,7 +81,7 @@ For almost everything else in the Wisp panel, you use the HTTP API. Databases, s
|
|
|
81
81
|
|
|
82
82
|
In WispJS, you access each of these as you might expect:
|
|
83
83
|
```js
|
|
84
|
-
import { WispInterface } from "
|
|
84
|
+
import { WispInterface } from "wispjs"
|
|
85
85
|
|
|
86
86
|
...
|
|
87
87
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { WispAPI } from "./wisp_api/index.js";
|
|
2
2
|
import { WispSocket } from "./wisp_socket/index.js";
|
|
3
|
-
|
|
4
3
|
export interface WispInterface {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
socket: WispSocket;
|
|
5
|
+
api: WispAPI;
|
|
6
|
+
logger: any;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* The primary Wisp Interface, exposing interactions with both the HTTP and Websockets API
|
|
12
10
|
*
|
|
@@ -17,27 +15,12 @@ export interface WispInterface {
|
|
|
17
15
|
*
|
|
18
16
|
* @public
|
|
19
17
|
*/
|
|
20
|
-
export class WispInterface {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
this.api = new WispAPI(domain, uuid, token, this.logger);
|
|
32
|
-
this.socket = new WispSocket(this.logger, this.api, ghPAT);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Manually disconnects from the Websocket connection(s)
|
|
37
|
-
*
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
async disconnect() {
|
|
41
|
-
await this.socket.disconnect();
|
|
42
|
-
}
|
|
18
|
+
export declare class WispInterface {
|
|
19
|
+
constructor(domain: string, uuid: string, token: string, ghPAT?: string);
|
|
20
|
+
/**
|
|
21
|
+
* Manually disconnects from the Websocket connection(s)
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
disconnect(): Promise<void>;
|
|
43
26
|
}
|
package/dist/wisp.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { WispAPI } from "./wisp_api/index.js";
|
|
2
|
+
import { WispSocket } from "./wisp_socket/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* The primary Wisp Interface, exposing interactions with both the HTTP and Websockets API
|
|
5
|
+
*
|
|
6
|
+
* @param domain The Domain of the Pterodactyl/Wisp panel (e.g. `my.gamepanel.gg`)
|
|
7
|
+
* @param uuid The UUID of the server to reference in all API requests
|
|
8
|
+
* @param token The panel API token to use for authorization
|
|
9
|
+
* @param ghPAT The Github Personal Access Token used for Cloning/Pulling of private repositories. This may be omitted if you do not need to interact with private repositories
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export class WispInterface {
|
|
14
|
+
constructor(domain, uuid, token, ghPAT) {
|
|
15
|
+
this.logger = {
|
|
16
|
+
info: (msg) => {
|
|
17
|
+
console.log(msg);
|
|
18
|
+
},
|
|
19
|
+
error: (msg) => {
|
|
20
|
+
console.error(msg);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
this.api = new WispAPI(domain, uuid, token, this.logger);
|
|
24
|
+
this.socket = new WispSocket(this.logger, this.api, ghPAT);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Manually disconnects from the Websocket connection(s)
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
async disconnect() {
|
|
32
|
+
await this.socket.disconnect();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { WispAPICore } from "./index";
|
|
2
|
+
import type { PaginationData } from "./index";
|
|
3
|
+
/**
|
|
4
|
+
* An Allocation object
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface Allocation {
|
|
9
|
+
object: "allocation";
|
|
10
|
+
attributes: {
|
|
11
|
+
id: number;
|
|
12
|
+
/** Whether or not this Allocation is the primary one for the Server */
|
|
13
|
+
primary: boolean;
|
|
14
|
+
ip: string;
|
|
15
|
+
port: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The response object from the GetAllocations call
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Used in {@link AllocationsAPI.List}
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export interface GetAllocationsResponse {
|
|
27
|
+
object: "list";
|
|
28
|
+
data: Allocation[];
|
|
29
|
+
meta: {
|
|
30
|
+
pagination: PaginationData;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Handles the listing and updating of a Server's IP/Port Allocations
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare class AllocationsAPI {
|
|
39
|
+
private core;
|
|
40
|
+
constructor(core: WispAPICore);
|
|
41
|
+
/**
|
|
42
|
+
* Lists all Allocations for the Server
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
List(): Promise<GetAllocationsResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Sets the new primary Allocation for the server
|
|
49
|
+
*
|
|
50
|
+
* @param id Allocation ID of the new primary allocation
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
Update(id: string): Promise<Allocation>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the listing and updating of a Server's IP/Port Allocations
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class AllocationsAPI {
|
|
7
|
+
constructor(core) {
|
|
8
|
+
this.core = core;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Lists all Allocations for the Server
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
async List() {
|
|
16
|
+
const response = await this.core.makeRequest("GET", "allocations");
|
|
17
|
+
const data = await response.json();
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sets the new primary Allocation for the server
|
|
22
|
+
*
|
|
23
|
+
* @param id Allocation ID of the new primary allocation
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
async Update(id) {
|
|
28
|
+
const response = await this.core.makeRequest("PUT", `allocations/${id}`);
|
|
29
|
+
const data = await response.json();
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { WispAPICore } from "./index";
|
|
2
|
+
import type { PaginationData } from "./index";
|
|
3
|
+
/**
|
|
4
|
+
* Device information
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```json
|
|
8
|
+
* {
|
|
9
|
+
* "city_name": "Seattle",
|
|
10
|
+
* "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0",
|
|
11
|
+
* "country_name": "US",
|
|
12
|
+
* "country_iso_code": "US"
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export interface Device {
|
|
19
|
+
city_name: string;
|
|
20
|
+
user_agent: string;
|
|
21
|
+
country_name: string;
|
|
22
|
+
country_iso_code: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* An Audit Log struct
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export interface AuditLog {
|
|
30
|
+
object: "audit_log";
|
|
31
|
+
attributes: {
|
|
32
|
+
action: string;
|
|
33
|
+
subaction: string;
|
|
34
|
+
device: Device | undefined;
|
|
35
|
+
metadata: any;
|
|
36
|
+
created_at: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The respones object from the GetAuditLogs call
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Used in {@link AuditLogsAPI.List}
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export interface GetAuditLogsResponse {
|
|
48
|
+
object: "list";
|
|
49
|
+
data: AuditLog[];
|
|
50
|
+
meta: {
|
|
51
|
+
pagination: PaginationData;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Interface that handles Listing of all Audit Logs
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export declare class AuditLogsAPI {
|
|
60
|
+
private core;
|
|
61
|
+
constructor(core: WispAPICore);
|
|
62
|
+
/**
|
|
63
|
+
* List all Audit Log events for the server
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
List(): Promise<GetAuditLogsResponse>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface that handles Listing of all Audit Logs
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class AuditLogsAPI {
|
|
7
|
+
constructor(core) {
|
|
8
|
+
this.core = core;
|
|
9
|
+
}
|
|
10
|
+
// TODO: Handle pagination
|
|
11
|
+
/**
|
|
12
|
+
* List all Audit Log events for the server
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
async List() {
|
|
17
|
+
const response = await this.core.makeRequest("GET", "audit-logs");
|
|
18
|
+
const data = await response.json();
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { WispAPICore } from "./index";
|
|
2
2
|
import type { PaginationData } from "./index";
|
|
3
|
-
import type { DownloadFileResponse } from "./filesystem";
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* A Backup Object
|
|
7
5
|
* @example
|
|
@@ -35,9 +33,8 @@ export interface Backup {
|
|
|
35
33
|
locked: boolean;
|
|
36
34
|
creating: boolean;
|
|
37
35
|
created_at: string;
|
|
38
|
-
}
|
|
36
|
+
};
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
/**
|
|
42
39
|
* Response object used in the GetBackups call
|
|
43
40
|
*
|
|
@@ -51,37 +48,29 @@ export interface GetBackupsResponse {
|
|
|
51
48
|
data: Backup[];
|
|
52
49
|
meta: {
|
|
53
50
|
pagination: PaginationData;
|
|
54
|
-
}
|
|
51
|
+
};
|
|
55
52
|
}
|
|
56
|
-
|
|
57
53
|
export type BackupErrorCode = "server.backups.creation_would_exceed_limit";
|
|
58
54
|
export interface BackupError {
|
|
59
55
|
code: BackupErrorCode;
|
|
60
56
|
data: any;
|
|
61
57
|
}
|
|
62
58
|
export interface CreateBackupFailure {
|
|
63
|
-
errors: BackupError[] | undefined
|
|
59
|
+
errors: BackupError[] | undefined;
|
|
64
60
|
}
|
|
65
61
|
export type CreateBackupResponse = Backup | CreateBackupFailure;
|
|
66
|
-
|
|
67
62
|
/**
|
|
68
63
|
* Handles basic server backup tasks, such as creating, restoring, and deleting backups
|
|
69
64
|
*/
|
|
70
|
-
export class BackupsAPI {
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
export declare class BackupsAPI {
|
|
66
|
+
private core;
|
|
67
|
+
constructor(core: WispAPICore);
|
|
73
68
|
/**
|
|
74
69
|
* Lists all current backups for the server
|
|
75
70
|
*
|
|
76
71
|
* @public
|
|
77
72
|
*/
|
|
78
|
-
|
|
79
|
-
const response = await this.core.makeRequest("GET", "backups");
|
|
80
|
-
const data: GetBackupsResponse = await response.json();
|
|
81
|
-
|
|
82
|
-
return data;
|
|
83
|
-
}
|
|
84
|
-
|
|
73
|
+
List(): Promise<GetBackupsResponse>;
|
|
85
74
|
/**
|
|
86
75
|
* Creates a new backup for the server
|
|
87
76
|
*
|
|
@@ -95,22 +84,12 @@ export class BackupsAPI {
|
|
|
95
84
|
*
|
|
96
85
|
* @param name The name of the Backup
|
|
97
86
|
*
|
|
98
|
-
* @throws {@link BackupErrorCode}
|
|
87
|
+
* @throws {@link BackupErrorCode}
|
|
99
88
|
* If the server returns an error code, it will be thrown verbatim here
|
|
100
89
|
*
|
|
101
90
|
* @public
|
|
102
91
|
*/
|
|
103
|
-
|
|
104
|
-
const response = await this.core.makeRequest("POST", "backups", { name: name });
|
|
105
|
-
const data: CreateBackupResponse = await response.json()
|
|
106
|
-
|
|
107
|
-
if ("errors" in data && data.errors) {
|
|
108
|
-
throw new Error(data.errors[0].code);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return data
|
|
112
|
-
}
|
|
113
|
-
|
|
92
|
+
Create(name: string): Promise<CreateBackupResponse>;
|
|
114
93
|
/**
|
|
115
94
|
* Toggles the "Locked" status of the Backup
|
|
116
95
|
*
|
|
@@ -118,13 +97,7 @@ export class BackupsAPI {
|
|
|
118
97
|
*
|
|
119
98
|
* @public
|
|
120
99
|
*/
|
|
121
|
-
|
|
122
|
-
const response = await this.core.makeRequest("POST", `backups/${id}/locked`);
|
|
123
|
-
const data: Backup = await response.json();
|
|
124
|
-
|
|
125
|
-
return data;
|
|
126
|
-
}
|
|
127
|
-
|
|
100
|
+
ToggleLock(id: string): Promise<Backup>;
|
|
128
101
|
/**
|
|
129
102
|
* Deploys the Backup to the Server
|
|
130
103
|
*
|
|
@@ -136,10 +109,7 @@ export class BackupsAPI {
|
|
|
136
109
|
*
|
|
137
110
|
* @public
|
|
138
111
|
*/
|
|
139
|
-
|
|
140
|
-
return await this.core.makeRequest("POST", `backups/${id}/deploy`);
|
|
141
|
-
}
|
|
142
|
-
|
|
112
|
+
Deploy(id: string): Promise<Response>;
|
|
143
113
|
/**
|
|
144
114
|
* Retrieves a URL from which the Backup can be downloaded
|
|
145
115
|
*
|
|
@@ -148,13 +118,7 @@ export class BackupsAPI {
|
|
|
148
118
|
*
|
|
149
119
|
* @public
|
|
150
120
|
*/
|
|
151
|
-
|
|
152
|
-
const response = await this.core.makeRequest("GET", `backups/${id}/download`);
|
|
153
|
-
const data: DownloadFileResponse = await response.json();
|
|
154
|
-
|
|
155
|
-
return data.url;
|
|
156
|
-
}
|
|
157
|
-
|
|
121
|
+
GetDownloadURL(id: string): Promise<string>;
|
|
158
122
|
/**
|
|
159
123
|
* Deletes the Backup
|
|
160
124
|
*
|
|
@@ -162,7 +126,5 @@ export class BackupsAPI {
|
|
|
162
126
|
*
|
|
163
127
|
* @public
|
|
164
128
|
*/
|
|
165
|
-
|
|
166
|
-
await this.core.makeRequest("DELETE", `backups/${id}`);
|
|
167
|
-
}
|
|
129
|
+
Delete(id: string): Promise<void>;
|
|
168
130
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles basic server backup tasks, such as creating, restoring, and deleting backups
|
|
3
|
+
*/
|
|
4
|
+
export class BackupsAPI {
|
|
5
|
+
constructor(core) {
|
|
6
|
+
this.core = core;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Lists all current backups for the server
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
async List() {
|
|
14
|
+
const response = await this.core.makeRequest("GET", "backups");
|
|
15
|
+
const data = await response.json();
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new backup for the server
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* ⚠️ This can fail to create a Backup even if the function completes successfully
|
|
23
|
+
* For example, if the backup would exceed the size limit (and the limit is not 0), the system wouldn't know it failed until it hit the limit.
|
|
24
|
+
*
|
|
25
|
+
* ⚠️ "It is recomended to stop your server before starting a backup. Backups created while the server is on can contain corupted data."
|
|
26
|
+
*
|
|
27
|
+
* Multiple Backups can exist with the same name.
|
|
28
|
+
*
|
|
29
|
+
* @param name The name of the Backup
|
|
30
|
+
*
|
|
31
|
+
* @throws {@link BackupErrorCode}
|
|
32
|
+
* If the server returns an error code, it will be thrown verbatim here
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
async Create(name) {
|
|
37
|
+
const response = await this.core.makeRequest("POST", "backups", { name: name });
|
|
38
|
+
const data = await response.json();
|
|
39
|
+
if ("errors" in data && data.errors) {
|
|
40
|
+
throw new Error(data.errors[0].code);
|
|
41
|
+
}
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Toggles the "Locked" status of the Backup
|
|
46
|
+
*
|
|
47
|
+
* @param id The ID of the Backup
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
async ToggleLock(id) {
|
|
52
|
+
const response = await this.core.makeRequest("POST", `backups/${id}/locked`);
|
|
53
|
+
const data = await response.json();
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Deploys the Backup to the Server
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* **⚠️ This can be dangerous!**
|
|
61
|
+
* The Backup will overwrite the entire Server, erasing any new data since the Backup's creation
|
|
62
|
+
*
|
|
63
|
+
* @param id The ID of the Backup
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
async Deploy(id) {
|
|
68
|
+
return await this.core.makeRequest("POST", `backups/${id}/deploy`);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves a URL from which the Backup can be downloaded
|
|
72
|
+
*
|
|
73
|
+
* @param id The ID of the Backup
|
|
74
|
+
* @returns The download URL
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
async GetDownloadURL(id) {
|
|
79
|
+
const response = await this.core.makeRequest("GET", `backups/${id}/download`);
|
|
80
|
+
const data = await response.json();
|
|
81
|
+
return data.url;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Deletes the Backup
|
|
85
|
+
*
|
|
86
|
+
* @param id The ID of the Backup
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
async Delete(id) {
|
|
91
|
+
await this.core.makeRequest("DELETE", `backups/${id}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { WispAPICore } from "./index";
|
|
2
|
+
import type { PaginationData } from "./index";
|
|
3
|
+
export interface DatabaseRelationship {
|
|
4
|
+
object: "database_host";
|
|
5
|
+
attributes: {
|
|
6
|
+
id: number;
|
|
7
|
+
name: string;
|
|
8
|
+
host: string;
|
|
9
|
+
port: number;
|
|
10
|
+
phpmyadmin_url: string | null;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface Database {
|
|
14
|
+
object: "database";
|
|
15
|
+
attributes: {
|
|
16
|
+
id: number;
|
|
17
|
+
name: string;
|
|
18
|
+
remote: string;
|
|
19
|
+
username: string;
|
|
20
|
+
password: string;
|
|
21
|
+
relationships: DatabaseRelationship[];
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface GetDatabasesResponse {
|
|
25
|
+
object: "list";
|
|
26
|
+
data: Database[];
|
|
27
|
+
meta: {
|
|
28
|
+
pagination: PaginationData;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Handles Creating, Listing, Updating, and Deleting of Databases for the Server
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare class DatabasesAPI {
|
|
37
|
+
private core;
|
|
38
|
+
constructor(core: WispAPICore);
|
|
39
|
+
/**
|
|
40
|
+
* Lists all Databases associated with the Server
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
List(): Promise<GetDatabasesResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Deletes the Database from the Server
|
|
47
|
+
*
|
|
48
|
+
* @param id The ID of the Backup
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
Delete(id: string): Promise<Response>;
|
|
53
|
+
/**
|
|
54
|
+
* Rotates the password for the Backup
|
|
55
|
+
*
|
|
56
|
+
* @param id The ID of the Backup
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
RotatePassword(id: string): Promise<Response>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles Creating, Listing, Updating, and Deleting of Databases for the Server
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class DatabasesAPI {
|
|
7
|
+
constructor(core) {
|
|
8
|
+
this.core = core;
|
|
9
|
+
}
|
|
10
|
+
// TODO: Handle Pagination
|
|
11
|
+
/**
|
|
12
|
+
* Lists all Databases associated with the Server
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
async List() {
|
|
17
|
+
const response = await this.core.makeRequest("GET", "databases", { include: "hosts" });
|
|
18
|
+
const data = await response.json();
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
// TODO: verify response
|
|
22
|
+
/**
|
|
23
|
+
* Deletes the Database from the Server
|
|
24
|
+
*
|
|
25
|
+
* @param id The ID of the Backup
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
async Delete(id) {
|
|
30
|
+
return await this.core.makeRequest("DELETE", `databases/${id}`);
|
|
31
|
+
}
|
|
32
|
+
// TODO: Verify response
|
|
33
|
+
/**
|
|
34
|
+
* Rotates the password for the Backup
|
|
35
|
+
*
|
|
36
|
+
* @param id The ID of the Backup
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
async RotatePassword(id) {
|
|
41
|
+
return await this.core.makeRequest("POST", `databases/${id}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WispAPICore } from "./index";
|
|
2
|
+
/**
|
|
3
|
+
* Handles the syncing of the FastDL feature
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare class FastDLAPI {
|
|
8
|
+
private core;
|
|
9
|
+
constructor(core: WispAPICore);
|
|
10
|
+
/**
|
|
11
|
+
* Begins a FastDL Sync for the server
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* ⚠️ If a Sync is already in progress, this function will succeed even though the process will fail.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
Sync(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the syncing of the FastDL feature
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class FastDLAPI {
|
|
7
|
+
constructor(core) {
|
|
8
|
+
this.core = core;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Begins a FastDL Sync for the server
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* ⚠️ If a Sync is already in progress, this function will succeed even though the process will fail.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
async Sync() {
|
|
19
|
+
await this.core.makeRequest("POST", "fastdl");
|
|
20
|
+
}
|
|
21
|
+
}
|