pterodactyl-api-client 3.1.0 → 3.2.1
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/class.d.ts +8 -3
- package/dist/class.d.ts.map +1 -1
- package/dist/class.js +17 -3
- package/package.json +1 -1
package/dist/class.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { ApplicationAPI } from "./application/index.js";
|
|
2
2
|
import { ClientAPI } from "./client/index.js";
|
|
3
|
-
export default class PterodactylAPIClient {
|
|
3
|
+
export default class PterodactylAPIClient<T extends "user" | "admin"> {
|
|
4
|
+
private apiKey;
|
|
4
5
|
readonly panelUrl: URL;
|
|
6
|
+
readonly role: T;
|
|
5
7
|
user: ClientAPI;
|
|
6
|
-
admin: ApplicationAPI | undefined;
|
|
7
8
|
constructor(options: {
|
|
8
9
|
apiKey: string;
|
|
9
10
|
panelUrl: string;
|
|
10
|
-
role:
|
|
11
|
+
role: T;
|
|
11
12
|
});
|
|
13
|
+
get admin(): T extends "admin" ? ApplicationAPI : never;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Client is now typed, typescript will no longer throw errors if the role is admin
|
|
16
|
+
*/
|
|
12
17
|
isAdmin(): this is {
|
|
13
18
|
admin: ApplicationAPI;
|
|
14
19
|
};
|
package/dist/class.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../src/class.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../src/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK9C,MAAM,CAAC,OAAO,OAAO,oBAAoB,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO;IAClE,OAAO,CAAC,MAAM,CAAS;IACvB,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACV,IAAI,EAAE,SAAS,CAAC;gBAEX,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE;IAalE,IAAI,KAAK,IAAI,CAAC,SAAS,OAAO,GAAG,cAAc,GAAG,KAAK,CAStD;IAED;;OAEG;IACH,OAAO,IAAI,IAAI,IAAI;QAAE,KAAK,EAAE,cAAc,CAAA;KAAE;CAG7C"}
|
package/dist/class.js
CHANGED
|
@@ -2,16 +2,30 @@ import { ApplicationAPI } from "./application/index.js";
|
|
|
2
2
|
import { ClientAPI } from "./client/index.js";
|
|
3
3
|
import { clientSchema } from "./schemas.js";
|
|
4
4
|
export default class PterodactylAPIClient {
|
|
5
|
+
apiKey;
|
|
5
6
|
panelUrl;
|
|
7
|
+
role;
|
|
6
8
|
user;
|
|
7
|
-
admin;
|
|
8
9
|
constructor(options) {
|
|
9
10
|
const { apiKey, panelUrl, role } = clientSchema.parse(options);
|
|
10
11
|
this.panelUrl = new URL(panelUrl);
|
|
11
12
|
this.user = new ClientAPI({ panelUrl: this.panelUrl, apiKey });
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
this.role = role;
|
|
14
|
+
this.apiKey = apiKey;
|
|
14
15
|
}
|
|
16
|
+
get admin() {
|
|
17
|
+
if (this.role === "admin")
|
|
18
|
+
// @ts-expect-error
|
|
19
|
+
return new ApplicationAPI({
|
|
20
|
+
panelUrl: this.panelUrl,
|
|
21
|
+
apiKey: this.apiKey,
|
|
22
|
+
});
|
|
23
|
+
// @ts-expect-error
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Client is now typed, typescript will no longer throw errors if the role is admin
|
|
28
|
+
*/
|
|
15
29
|
isAdmin() {
|
|
16
30
|
return this.admin !== undefined;
|
|
17
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pterodactyl-api-client",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "SDK TypeScript non officiel et entièrement typé pour l’API Pterodactyl.\nCouvre l’ensemble des endpoints client et application avec une architecture modulaire, orientée classes, conçue pour Node.js et les environnements TypeScript stricts.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|