@pelican.ts/sdk 0.4.6 → 0.4.8
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 +65 -15
- package/dist/api/index.d.mts +0 -9
- package/dist/api/index.d.ts +0 -9
- package/dist/api/index.js +0 -13
- package/dist/api/index.mjs +0 -13
- package/dist/index.d.mts +0 -16
- package/dist/index.d.ts +0 -16
- package/dist/index.js +0 -23
- package/dist/index.mjs +0 -23
- package/package.json +1 -1
- package/src/api/client/account.ts +0 -20
- package/src/humane/Account.ts +0 -13
package/README.md
CHANGED
|
@@ -4,16 +4,63 @@
|
|
|
4
4
|
|
|
5
5
|
# Pelican.ts — Typescript client for Pelican panel
|
|
6
6
|
|
|
7
|
-
## Installation
|
|
7
|
+
## 🧭 Installation
|
|
8
8
|
```shell
|
|
9
9
|
npm install @pelican.ts/sdk
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## 📦 What's inside?
|
|
13
|
+
### 🤗 Humane Client `@pelican.ts/sdk`
|
|
14
|
+
**Humane Client** is an object-oriented client that provides a more comfortable experience. Each method corresponds to
|
|
15
|
+
an API endpoint, so each update causes only one request. Objects are updated automatically after each API call.
|
|
16
|
+
|
|
17
|
+
I found the most use of it for file management, as each ServerFile knows exactly where is it located and what is its
|
|
18
|
+
parent folder, so you don't have to use `PelicanAPIClient`, `currentDir` and `FileObject` to achieve simple file operations.
|
|
19
|
+
|
|
20
|
+
Also, each Humane object can be created from API client and corresponding API data object:
|
|
21
|
+
```ts
|
|
22
|
+
import { ServerBackup } from "@pelican.ts/sdk"
|
|
23
|
+
const backup = new ServerBackup(serverClient, backupObject)
|
|
24
|
+
````
|
|
25
|
+
|
|
26
|
+
**Usage:**
|
|
13
27
|
```ts
|
|
14
|
-
import {
|
|
15
|
-
const client =
|
|
28
|
+
import { createPelicanClient } from "@pelican.ts/sdk"
|
|
29
|
+
const client = createPelicanClient("https://demo.pelican.dev", "token")
|
|
16
30
|
|
|
31
|
+
// Create server backup and restore it
|
|
32
|
+
const main = async () => {
|
|
33
|
+
const servers = await client.listServers()
|
|
34
|
+
const myServer = servers[0]
|
|
35
|
+
if (myServer.isInstalling || myServer.isSuspended)
|
|
36
|
+
return
|
|
37
|
+
const backup = await myServer.createBackup({
|
|
38
|
+
name: "first backup",
|
|
39
|
+
is_locked: false,
|
|
40
|
+
ignored_files: ["/dynmap/*"]
|
|
41
|
+
})
|
|
42
|
+
setTimeout(
|
|
43
|
+
async () => {
|
|
44
|
+
await backup.restore()
|
|
45
|
+
}, 60000
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
main()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### 🤖 API Client `@pelican.ts/sdk/api`
|
|
54
|
+
**API Client** takes a more functional approach, consider it a direct API wrapper. It's stateless and doesn't save objects
|
|
55
|
+
for you. Uses zod for input validation.
|
|
56
|
+
|
|
57
|
+
**Usage:**
|
|
58
|
+
```ts
|
|
59
|
+
import { PelicanAPIClient } from "@pelican.ts/sdk/api"
|
|
60
|
+
const client = new PelicanAPIClient("https://demo.pelican.dev", "token")
|
|
61
|
+
// API client is also obtainable from Humane Client via createPelicanClient(...).$client
|
|
62
|
+
|
|
63
|
+
// Create server backup and restore it
|
|
17
64
|
const main = async () => {
|
|
18
65
|
const servers = await client.listServers()
|
|
19
66
|
const serverID = servers[0].identifier // babcaed0 for example
|
|
@@ -25,24 +72,27 @@ const main = async () => {
|
|
|
25
72
|
main()
|
|
26
73
|
```
|
|
27
74
|
|
|
28
|
-
|
|
75
|
+
### 📚 Types `@pelican.ts/sdk/types`
|
|
76
|
+
Contains every API response type
|
|
77
|
+
```ts
|
|
78
|
+
import type {ApplicationServer, ServerBackup} from "@pelican.ts/sdk/types"
|
|
79
|
+
|
|
80
|
+
const backup: ServerBackup = {
|
|
81
|
+
...
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
**What's done:**
|
|
29
87
|
- [X] Client
|
|
30
88
|
- [X] Application
|
|
31
|
-
- [X] Users
|
|
32
|
-
- [X] Nodes
|
|
33
|
-
- [X] Servers
|
|
34
|
-
- [X] Databases (TODO: Check if server database type is valid)
|
|
35
|
-
- [X] Database Hosts (~~TODO: find out why create API returns 500 No Route~~ Fix was merged to upstream)
|
|
36
|
-
- [X] Roles
|
|
37
|
-
- [X] Eggs
|
|
38
|
-
- [X] Mounts
|
|
39
89
|
- [ ] TSDoc
|
|
40
90
|
- [ ] Examples
|
|
41
91
|
- [ ] Tests
|
|
42
92
|
- [ ] Documentation
|
|
43
93
|
- [X] Humane wrapper
|
|
44
94
|
|
|
45
|
-
## Copyright Notice
|
|
95
|
+
## 🧐 Copyright Notice
|
|
46
96
|
[Pterodactyl®](https://github.com/pterodactyl) is a registered trademark of Dane Everitt and contributors.
|
|
47
97
|
|
|
48
98
|
[Pelican®](https://github.com/pelican-dev) is a registered trademark of Pelican contributors.
|
|
@@ -51,5 +101,5 @@ Pelican.ts is Open Source under the [MIT License](LICENSE) and is the copyright
|
|
|
51
101
|
of its contributors stated below. Pelican.ts is not endorsed by or affiliated with Pterodactyl® nor Pelican® team.
|
|
52
102
|
|
|
53
103
|
|
|
54
|
-
## Contributors
|
|
104
|
+
## 🧑💻 Contributors
|
|
55
105
|
[M41den](https://github.com/m41denx) © 2024-2025
|
package/dist/api/index.d.mts
CHANGED
|
@@ -62,15 +62,6 @@ declare class Account {
|
|
|
62
62
|
create: (name: string, public_key: string) => Promise<SSHKey>;
|
|
63
63
|
delete: (fingerprint: string) => Promise<void>;
|
|
64
64
|
};
|
|
65
|
-
twoFactor: {
|
|
66
|
-
info: () => Promise<{
|
|
67
|
-
image_url_data: string;
|
|
68
|
-
}>;
|
|
69
|
-
enable: (code: string) => Promise<{
|
|
70
|
-
tokens: string[];
|
|
71
|
-
}>;
|
|
72
|
-
disable: (password: string) => Promise<void>;
|
|
73
|
-
};
|
|
74
65
|
}
|
|
75
66
|
|
|
76
67
|
type GenericResponse<T, N extends string = string, M = undefined> = {
|
package/dist/api/index.d.ts
CHANGED
|
@@ -62,15 +62,6 @@ declare class Account {
|
|
|
62
62
|
create: (name: string, public_key: string) => Promise<SSHKey>;
|
|
63
63
|
delete: (fingerprint: string) => Promise<void>;
|
|
64
64
|
};
|
|
65
|
-
twoFactor: {
|
|
66
|
-
info: () => Promise<{
|
|
67
|
-
image_url_data: string;
|
|
68
|
-
}>;
|
|
69
|
-
enable: (code: string) => Promise<{
|
|
70
|
-
tokens: string[];
|
|
71
|
-
}>;
|
|
72
|
-
disable: (password: string) => Promise<void>;
|
|
73
|
-
};
|
|
74
65
|
}
|
|
75
66
|
|
|
76
67
|
type GenericResponse<T, N extends string = string, M = undefined> = {
|
package/dist/api/index.js
CHANGED
|
@@ -84,19 +84,6 @@ var Account = class {
|
|
|
84
84
|
await this.r.post(`/account/ssh-keys/remove`, { fingerprint });
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
twoFactor = {
|
|
88
|
-
info: async () => {
|
|
89
|
-
const { data } = await this.r.get("/account/two-factor");
|
|
90
|
-
return data;
|
|
91
|
-
},
|
|
92
|
-
enable: async (code) => {
|
|
93
|
-
const { data } = await this.r.post("/account/two-factor", { code });
|
|
94
|
-
return data;
|
|
95
|
-
},
|
|
96
|
-
disable: async (password) => {
|
|
97
|
-
await this.r.delete("/account/two-factor", { data: { password } });
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
87
|
};
|
|
101
88
|
|
|
102
89
|
// src/api/client/client.ts
|
package/dist/api/index.mjs
CHANGED
|
@@ -47,19 +47,6 @@ var Account = class {
|
|
|
47
47
|
await this.r.post(`/account/ssh-keys/remove`, { fingerprint });
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
twoFactor = {
|
|
51
|
-
info: async () => {
|
|
52
|
-
const { data } = await this.r.get("/account/two-factor");
|
|
53
|
-
return data;
|
|
54
|
-
},
|
|
55
|
-
enable: async (code) => {
|
|
56
|
-
const { data } = await this.r.post("/account/two-factor", { code });
|
|
57
|
-
return data;
|
|
58
|
-
},
|
|
59
|
-
disable: async (password) => {
|
|
60
|
-
await this.r.delete("/account/two-factor", { data: { password } });
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
50
|
};
|
|
64
51
|
|
|
65
52
|
// src/api/client/client.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -370,15 +370,6 @@ declare class Account$1 {
|
|
|
370
370
|
create: (name: string, public_key: string) => Promise<SSHKey>;
|
|
371
371
|
delete: (fingerprint: string) => Promise<void>;
|
|
372
372
|
};
|
|
373
|
-
twoFactor: {
|
|
374
|
-
info: () => Promise<{
|
|
375
|
-
image_url_data: string;
|
|
376
|
-
}>;
|
|
377
|
-
enable: (code: string) => Promise<{
|
|
378
|
-
tokens: string[];
|
|
379
|
-
}>;
|
|
380
|
-
disable: (password: string) => Promise<void>;
|
|
381
|
-
};
|
|
382
373
|
}
|
|
383
374
|
|
|
384
375
|
declare class ServerDatabases {
|
|
@@ -579,13 +570,6 @@ declare class Account {
|
|
|
579
570
|
listSshKeys: () => Promise<SSHKey[]>;
|
|
580
571
|
createSshKey: (name: string, public_key: string) => Promise<SSHKey>;
|
|
581
572
|
deleteSshKey: (fingerprint: string) => Promise<void>;
|
|
582
|
-
get2faQR: () => Promise<{
|
|
583
|
-
image_url_data: string;
|
|
584
|
-
}>;
|
|
585
|
-
enable2fa: (code: string) => Promise<{
|
|
586
|
-
tokens: string[];
|
|
587
|
-
}>;
|
|
588
|
-
disable2fa: (password: string) => Promise<void>;
|
|
589
573
|
}
|
|
590
574
|
|
|
591
575
|
declare class ServerAllocation {
|
package/dist/index.d.ts
CHANGED
|
@@ -370,15 +370,6 @@ declare class Account$1 {
|
|
|
370
370
|
create: (name: string, public_key: string) => Promise<SSHKey>;
|
|
371
371
|
delete: (fingerprint: string) => Promise<void>;
|
|
372
372
|
};
|
|
373
|
-
twoFactor: {
|
|
374
|
-
info: () => Promise<{
|
|
375
|
-
image_url_data: string;
|
|
376
|
-
}>;
|
|
377
|
-
enable: (code: string) => Promise<{
|
|
378
|
-
tokens: string[];
|
|
379
|
-
}>;
|
|
380
|
-
disable: (password: string) => Promise<void>;
|
|
381
|
-
};
|
|
382
373
|
}
|
|
383
374
|
|
|
384
375
|
declare class ServerDatabases {
|
|
@@ -579,13 +570,6 @@ declare class Account {
|
|
|
579
570
|
listSshKeys: () => Promise<SSHKey[]>;
|
|
580
571
|
createSshKey: (name: string, public_key: string) => Promise<SSHKey>;
|
|
581
572
|
deleteSshKey: (fingerprint: string) => Promise<void>;
|
|
582
|
-
get2faQR: () => Promise<{
|
|
583
|
-
image_url_data: string;
|
|
584
|
-
}>;
|
|
585
|
-
enable2fa: (code: string) => Promise<{
|
|
586
|
-
tokens: string[];
|
|
587
|
-
}>;
|
|
588
|
-
disable2fa: (password: string) => Promise<void>;
|
|
589
573
|
}
|
|
590
574
|
|
|
591
575
|
declare class ServerAllocation {
|
package/dist/index.js
CHANGED
|
@@ -92,19 +92,6 @@ var Account = class {
|
|
|
92
92
|
await this.r.post(`/account/ssh-keys/remove`, { fingerprint });
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
twoFactor = {
|
|
96
|
-
info: async () => {
|
|
97
|
-
const { data } = await this.r.get("/account/two-factor");
|
|
98
|
-
return data;
|
|
99
|
-
},
|
|
100
|
-
enable: async (code) => {
|
|
101
|
-
const { data } = await this.r.post("/account/two-factor", { code });
|
|
102
|
-
return data;
|
|
103
|
-
},
|
|
104
|
-
disable: async (password) => {
|
|
105
|
-
await this.r.delete("/account/two-factor", { data: { password } });
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
95
|
};
|
|
109
96
|
|
|
110
97
|
// src/api/client/client.ts
|
|
@@ -1721,16 +1708,6 @@ var Account2 = class {
|
|
|
1721
1708
|
listSshKeys = async () => this.client.account.sshKeys.list();
|
|
1722
1709
|
createSshKey = async (name, public_key) => this.client.account.sshKeys.create(name, public_key);
|
|
1723
1710
|
deleteSshKey = async (fingerprint) => this.client.account.sshKeys.delete(fingerprint);
|
|
1724
|
-
get2faQR = async () => this.client.account.twoFactor.info();
|
|
1725
|
-
enable2fa = async (code) => {
|
|
1726
|
-
const tokens = await this.client.account.twoFactor.enable(code);
|
|
1727
|
-
this.$has2faEnabled = true;
|
|
1728
|
-
return tokens;
|
|
1729
|
-
};
|
|
1730
|
-
disable2fa = async (password) => {
|
|
1731
|
-
await this.client.account.twoFactor.disable(password);
|
|
1732
|
-
this.$has2faEnabled = false;
|
|
1733
|
-
};
|
|
1734
1711
|
};
|
|
1735
1712
|
|
|
1736
1713
|
// src/humane/ServerAllocation.ts
|
package/dist/index.mjs
CHANGED
|
@@ -47,19 +47,6 @@ var Account = class {
|
|
|
47
47
|
await this.r.post(`/account/ssh-keys/remove`, { fingerprint });
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
twoFactor = {
|
|
51
|
-
info: async () => {
|
|
52
|
-
const { data } = await this.r.get("/account/two-factor");
|
|
53
|
-
return data;
|
|
54
|
-
},
|
|
55
|
-
enable: async (code) => {
|
|
56
|
-
const { data } = await this.r.post("/account/two-factor", { code });
|
|
57
|
-
return data;
|
|
58
|
-
},
|
|
59
|
-
disable: async (password) => {
|
|
60
|
-
await this.r.delete("/account/two-factor", { data: { password } });
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
50
|
};
|
|
64
51
|
|
|
65
52
|
// src/api/client/client.ts
|
|
@@ -1676,16 +1663,6 @@ var Account2 = class {
|
|
|
1676
1663
|
listSshKeys = async () => this.client.account.sshKeys.list();
|
|
1677
1664
|
createSshKey = async (name, public_key) => this.client.account.sshKeys.create(name, public_key);
|
|
1678
1665
|
deleteSshKey = async (fingerprint) => this.client.account.sshKeys.delete(fingerprint);
|
|
1679
|
-
get2faQR = async () => this.client.account.twoFactor.info();
|
|
1680
|
-
enable2fa = async (code) => {
|
|
1681
|
-
const tokens = await this.client.account.twoFactor.enable(code);
|
|
1682
|
-
this.$has2faEnabled = true;
|
|
1683
|
-
return tokens;
|
|
1684
|
-
};
|
|
1685
|
-
disable2fa = async (password) => {
|
|
1686
|
-
await this.client.account.twoFactor.disable(password);
|
|
1687
|
-
this.$has2faEnabled = false;
|
|
1688
|
-
};
|
|
1689
1666
|
};
|
|
1690
1667
|
|
|
1691
1668
|
// src/humane/ServerAllocation.ts
|
package/package.json
CHANGED
|
@@ -69,24 +69,4 @@ export class Account {
|
|
|
69
69
|
await this.r.post(`/account/ssh-keys/remove`, {fingerprint})
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
twoFactor = {
|
|
74
|
-
info: async (): Promise<{ image_url_data: string }> => {
|
|
75
|
-
const {data} = await this.r.get<
|
|
76
|
-
Awaited<ReturnType<typeof this.twoFactor.info>>
|
|
77
|
-
>("/account/two-factor")
|
|
78
|
-
return data
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
enable: async (code: string): Promise<{ tokens: string[] }> => {
|
|
82
|
-
const {data} = await this.r.post<
|
|
83
|
-
Awaited<ReturnType<typeof this.twoFactor.enable>>
|
|
84
|
-
>("/account/two-factor", {code})
|
|
85
|
-
return data
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
disable: async (password: string): Promise<void> => {
|
|
89
|
-
await this.r.delete("/account/two-factor", {data: {password}})
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
72
|
}
|
package/src/humane/Account.ts
CHANGED
|
@@ -57,17 +57,4 @@ export class Account {
|
|
|
57
57
|
|
|
58
58
|
deleteSshKey = async (fingerprint: string) =>
|
|
59
59
|
this.client.account.sshKeys.delete(fingerprint)
|
|
60
|
-
|
|
61
|
-
get2faQR = async () => this.client.account.twoFactor.info()
|
|
62
|
-
|
|
63
|
-
enable2fa = async (code: string) => {
|
|
64
|
-
const tokens = await this.client.account.twoFactor.enable(code)
|
|
65
|
-
this.$has2faEnabled = true
|
|
66
|
-
return tokens
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
disable2fa = async (password: string) => {
|
|
70
|
-
await this.client.account.twoFactor.disable(password)
|
|
71
|
-
this.$has2faEnabled = false
|
|
72
|
-
}
|
|
73
60
|
}
|