@pelican.ts/sdk 0.4.6 → 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.
Files changed (2) hide show
  1. package/README.md +65 -15
  2. package/package.json +1 -1
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pelican.ts/sdk",
3
- "version": "0.4.6",
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",