@pelican.ts/sdk 0.4.5 → 0.4.7

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 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
- ## Usage
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 { PelicanClient } from "@pelican.ts/sdk"
15
- const client = new PelicanClient("https://demo.pelican.dev", "token")
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
- What's done:
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
@@ -390,6 +390,9 @@ declare class ServerBackups {
390
390
  downloadGetUrl: (backup_uuid: string) => Promise<string>;
391
391
  download: (backup_uuid: string) => Promise<ArrayBuffer>;
392
392
  delete: (backup_uuid: string) => Promise<void>;
393
+ rename: (backup_uuid: string, name: string) => Promise<void>;
394
+ toggleLock: (backup_uuid: string) => Promise<void>;
395
+ restore: (backup_uuid: string, truncate: boolean) => Promise<void>;
393
396
  }
394
397
 
395
398
  type StartupParams = {
@@ -390,6 +390,9 @@ declare class ServerBackups {
390
390
  downloadGetUrl: (backup_uuid: string) => Promise<string>;
391
391
  download: (backup_uuid: string) => Promise<ArrayBuffer>;
392
392
  delete: (backup_uuid: string) => Promise<void>;
393
+ rename: (backup_uuid: string, name: string) => Promise<void>;
394
+ toggleLock: (backup_uuid: string) => Promise<void>;
395
+ restore: (backup_uuid: string, truncate: boolean) => Promise<void>;
393
396
  }
394
397
 
395
398
  type StartupParams = {
package/dist/api/index.js CHANGED
@@ -365,6 +365,15 @@ var ServerBackups = class {
365
365
  delete = async (backup_uuid) => {
366
366
  await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
367
367
  };
368
+ rename = async (backup_uuid, name) => {
369
+ await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, { name });
370
+ };
371
+ toggleLock = async (backup_uuid) => {
372
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/lock`);
373
+ };
374
+ restore = async (backup_uuid, truncate) => {
375
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/restore`, { truncate });
376
+ };
368
377
  };
369
378
 
370
379
  // src/api/client/server_startup.ts
@@ -328,6 +328,15 @@ var ServerBackups = class {
328
328
  delete = async (backup_uuid) => {
329
329
  await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
330
330
  };
331
+ rename = async (backup_uuid, name) => {
332
+ await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, { name });
333
+ };
334
+ toggleLock = async (backup_uuid) => {
335
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/lock`);
336
+ };
337
+ restore = async (backup_uuid, truncate) => {
338
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/restore`, { truncate });
339
+ };
331
340
  };
332
341
 
333
342
  // src/api/client/server_startup.ts
package/dist/index.d.mts CHANGED
@@ -493,6 +493,9 @@ declare class ServerBackups {
493
493
  downloadGetUrl: (backup_uuid: string) => Promise<string>;
494
494
  download: (backup_uuid: string) => Promise<ArrayBuffer>;
495
495
  delete: (backup_uuid: string) => Promise<void>;
496
+ rename: (backup_uuid: string, name: string) => Promise<void>;
497
+ toggleLock: (backup_uuid: string) => Promise<void>;
498
+ restore: (backup_uuid: string, truncate: boolean) => Promise<void>;
496
499
  }
497
500
 
498
501
  declare class ServerStartup {
@@ -616,6 +619,9 @@ declare class ServerBackup {
616
619
  downloadGetUrl: () => Promise<string>;
617
620
  download: () => Promise<ArrayBuffer>;
618
621
  delete: () => Promise<void>;
622
+ rename: (name: string) => Promise<void>;
623
+ toggleLock: () => Promise<void>;
624
+ restore: (truncate: boolean) => Promise<void>;
619
625
  }
620
626
 
621
627
  declare class ServerDatabase {
package/dist/index.d.ts CHANGED
@@ -493,6 +493,9 @@ declare class ServerBackups {
493
493
  downloadGetUrl: (backup_uuid: string) => Promise<string>;
494
494
  download: (backup_uuid: string) => Promise<ArrayBuffer>;
495
495
  delete: (backup_uuid: string) => Promise<void>;
496
+ rename: (backup_uuid: string, name: string) => Promise<void>;
497
+ toggleLock: (backup_uuid: string) => Promise<void>;
498
+ restore: (backup_uuid: string, truncate: boolean) => Promise<void>;
496
499
  }
497
500
 
498
501
  declare class ServerStartup {
@@ -616,6 +619,9 @@ declare class ServerBackup {
616
619
  downloadGetUrl: () => Promise<string>;
617
620
  download: () => Promise<ArrayBuffer>;
618
621
  delete: () => Promise<void>;
622
+ rename: (name: string) => Promise<void>;
623
+ toggleLock: () => Promise<void>;
624
+ restore: (truncate: boolean) => Promise<void>;
619
625
  }
620
626
 
621
627
  declare class ServerDatabase {
package/dist/index.js CHANGED
@@ -373,6 +373,15 @@ var ServerBackups = class {
373
373
  delete = async (backup_uuid) => {
374
374
  await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
375
375
  };
376
+ rename = async (backup_uuid, name) => {
377
+ await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, { name });
378
+ };
379
+ toggleLock = async (backup_uuid) => {
380
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/lock`);
381
+ };
382
+ restore = async (backup_uuid, truncate) => {
383
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/restore`, { truncate });
384
+ };
376
385
  };
377
386
 
378
387
  // src/api/client/server_startup.ts
@@ -1786,6 +1795,9 @@ var ServerBackup = class {
1786
1795
  downloadGetUrl = async () => this.client.backups.downloadGetUrl(this.uuid);
1787
1796
  download = async () => this.client.backups.download(this.uuid);
1788
1797
  delete = async () => this.client.backups.delete(this.uuid);
1798
+ rename = async (name) => this.client.backups.rename(this.uuid, name);
1799
+ toggleLock = async () => this.client.backups.toggleLock(this.uuid);
1800
+ restore = async (truncate) => this.client.backups.restore(this.uuid, truncate);
1789
1801
  };
1790
1802
 
1791
1803
  // src/humane/ServerDatabase.ts
package/dist/index.mjs CHANGED
@@ -328,6 +328,15 @@ var ServerBackups = class {
328
328
  delete = async (backup_uuid) => {
329
329
  await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`);
330
330
  };
331
+ rename = async (backup_uuid, name) => {
332
+ await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, { name });
333
+ };
334
+ toggleLock = async (backup_uuid) => {
335
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/lock`);
336
+ };
337
+ restore = async (backup_uuid, truncate) => {
338
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/restore`, { truncate });
339
+ };
331
340
  };
332
341
 
333
342
  // src/api/client/server_startup.ts
@@ -1741,6 +1750,9 @@ var ServerBackup = class {
1741
1750
  downloadGetUrl = async () => this.client.backups.downloadGetUrl(this.uuid);
1742
1751
  download = async () => this.client.backups.download(this.uuid);
1743
1752
  delete = async () => this.client.backups.delete(this.uuid);
1753
+ rename = async (name) => this.client.backups.rename(this.uuid, name);
1754
+ toggleLock = async () => this.client.backups.toggleLock(this.uuid);
1755
+ restore = async (truncate) => this.client.backups.restore(this.uuid, truncate);
1744
1756
  };
1745
1757
 
1746
1758
  // src/humane/ServerDatabase.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pelican.ts/sdk",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Pelican panel SDK for TypeScript",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -64,4 +64,15 @@ export class ServerBackups {
64
64
  await this.r.delete(`/servers/${this.id}/backups/${backup_uuid}`)
65
65
  }
66
66
 
67
+ rename = async (backup_uuid: string, name: string): Promise<void> => {
68
+ await this.r.put(`/servers/${this.id}/backups/${backup_uuid}/rename`, {name})
69
+ }
70
+
71
+ toggleLock = async (backup_uuid: string): Promise<void> => {
72
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/lock`)
73
+ }
74
+
75
+ restore = async (backup_uuid: string, truncate: boolean): Promise<void> => {
76
+ await this.r.post(`/servers/${this.id}/backups/${backup_uuid}/restore`, {truncate})
77
+ }
67
78
  }
@@ -34,4 +34,14 @@ export class ServerBackup {
34
34
  download = async () => this.client.backups.download(this.uuid)
35
35
 
36
36
  delete = async () => this.client.backups.delete(this.uuid)
37
+
38
+ rename = async (
39
+ name: string
40
+ ) => this.client.backups.rename(this.uuid, name)
41
+
42
+ toggleLock = async () => this.client.backups.toggleLock(this.uuid)
43
+
44
+ restore = async (
45
+ truncate: boolean
46
+ ) => this.client.backups.restore(this.uuid, truncate)
37
47
  }