@pelican.ts/sdk 0.2.5 → 0.3.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/README.md +3 -3
- package/bun.lock +442 -0
- package/dist/index.d.mts +89 -7
- package/dist/index.d.ts +89 -7
- package/dist/index.js +97 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -4
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +47 -1
- package/package.json +2 -2
- package/src/api/application/client.ts +6 -0
- package/src/api/application/eggs.ts +31 -0
- package/src/api/application/mounts.ts +96 -0
- package/src/api/application/types/egg.ts +37 -0
- package/src/api/application/types/index.ts +2 -0
- package/src/api/application/types/mount.ts +12 -0
- package/.github/logo.png +0 -0
- package/.idea/Pterodactyl.ts.iml +0 -12
- package/.idea/discord.xml +0 -14
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
package/dist/types.d.ts
CHANGED
|
@@ -812,6 +812,17 @@ type NodeConfiguration = {
|
|
|
812
812
|
remote: string;
|
|
813
813
|
};
|
|
814
814
|
|
|
815
|
+
type Mount = {
|
|
816
|
+
id: number;
|
|
817
|
+
uuid: string;
|
|
818
|
+
name: string;
|
|
819
|
+
description: Nullable<string>;
|
|
820
|
+
source: string;
|
|
821
|
+
target: string;
|
|
822
|
+
read_only: boolean;
|
|
823
|
+
user_mountable: boolean;
|
|
824
|
+
};
|
|
825
|
+
|
|
815
826
|
type DatabaseHost = {
|
|
816
827
|
id: number;
|
|
817
828
|
name: string;
|
|
@@ -829,6 +840,41 @@ type Role = {
|
|
|
829
840
|
updated_at: string;
|
|
830
841
|
};
|
|
831
842
|
|
|
843
|
+
type Egg = {
|
|
844
|
+
id: number;
|
|
845
|
+
uuid: string;
|
|
846
|
+
name: number;
|
|
847
|
+
author: string;
|
|
848
|
+
description: string;
|
|
849
|
+
features: string[];
|
|
850
|
+
tags: string[];
|
|
851
|
+
docker_image: string;
|
|
852
|
+
docker_images: Record<string, string>;
|
|
853
|
+
config: {
|
|
854
|
+
files: Record<string, FileConfig>;
|
|
855
|
+
startup: Record<string, string>;
|
|
856
|
+
stop: string;
|
|
857
|
+
logs: object | [];
|
|
858
|
+
file_denylist: string[];
|
|
859
|
+
extends: Nullable<number>;
|
|
860
|
+
};
|
|
861
|
+
startup: string;
|
|
862
|
+
startup_commands: Record<string, string>;
|
|
863
|
+
script: {
|
|
864
|
+
privileged: boolean;
|
|
865
|
+
install: string;
|
|
866
|
+
entry: string;
|
|
867
|
+
container: string;
|
|
868
|
+
extends: Nullable<number>;
|
|
869
|
+
};
|
|
870
|
+
created_at: string;
|
|
871
|
+
updated_at: Nullable<string>;
|
|
872
|
+
};
|
|
873
|
+
type FileConfig = {
|
|
874
|
+
parser: string;
|
|
875
|
+
find: Record<string, string>;
|
|
876
|
+
};
|
|
877
|
+
|
|
832
878
|
type ApplicationUser = {
|
|
833
879
|
id: number;
|
|
834
880
|
external_id: Nullable<string>;
|
|
@@ -1072,4 +1118,4 @@ type Permission = {
|
|
|
1072
1118
|
keys: Record<string, string>;
|
|
1073
1119
|
};
|
|
1074
1120
|
|
|
1075
|
-
export { type APIKey, type Allocation, type AllocationRel, type ApplicationServer, type ApplicationUser, type AuthSuccessWsEvent, type BackupCompletedEvent, type BackupCompletedJson, type BackupRestoreCompletedEvent, type ConsoleLogWsEvent, type Container, type DaemonErrorEvent, type DaemonMessageEvent, type DatabaseHost, type EggVariable, type FeatureLimits, type FileObject, type InstallCompletedEvent, type InstallOutputEvent, type InstallStartedEvent, type JwtErrorEvent, type LanguagesType, type Location, type Node, type NodeConfiguration, type Permission, type PowerState, type Role, SERVER_SIGNAL, SOCKET_EVENT, type SSHKey, type Schedule, type ScheduleTask, type Server, type ServerActivityLog, type ServerAllocation, type ServerBackup, type ServerDatabase, type ServerLimits, type ServerSignalOption, type ServerStats, type ServerStatus, type ServerSubuser, type StartupMeta, type StartupParams, type StatsWsEvent, type StatsWsJson, type StatusWsEvent, type SubuserPermission, type TimezonesType, type TokenExpiredWsEvent, type TokenExpiringWsEvent, type TransferLogsEvent, type TransferStatusEvent, type User, type WebsocketEvent, languagesSchema, timezonesSchema };
|
|
1121
|
+
export { type APIKey, type Allocation, type AllocationRel, type ApplicationServer, type ApplicationUser, type AuthSuccessWsEvent, type BackupCompletedEvent, type BackupCompletedJson, type BackupRestoreCompletedEvent, type ConsoleLogWsEvent, type Container, type DaemonErrorEvent, type DaemonMessageEvent, type DatabaseHost, type Egg, type EggVariable, type FeatureLimits, type FileObject, type InstallCompletedEvent, type InstallOutputEvent, type InstallStartedEvent, type JwtErrorEvent, type LanguagesType, type Location, type Mount, type Node, type NodeConfiguration, type Permission, type PowerState, type Role, SERVER_SIGNAL, SOCKET_EVENT, type SSHKey, type Schedule, type ScheduleTask, type Server, type ServerActivityLog, type ServerAllocation, type ServerBackup, type ServerDatabase, type ServerLimits, type ServerSignalOption, type ServerStats, type ServerStatus, type ServerSubuser, type StartupMeta, type StartupParams, type StatsWsEvent, type StatsWsJson, type StatusWsEvent, type SubuserPermission, type TimezonesType, type TokenExpiredWsEvent, type TokenExpiringWsEvent, type TransferLogsEvent, type TransferStatusEvent, type User, type WebsocketEvent, languagesSchema, timezonesSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pelican.ts/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Pelican panel SDK for TypeScript",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build:code": "tsup src/index.ts --format esm,cjs --dts --
|
|
14
|
+
"build:code": "tsup src/index.ts --format esm,cjs --dts --target esnext",
|
|
15
15
|
"build:types": "tsup src/types.ts --dts-only --target esnext",
|
|
16
16
|
"build": "npm run build:code && npm run build:types",
|
|
17
17
|
"pub": "npm publish --access=public",
|
|
@@ -7,6 +7,8 @@ import {CreateServerSchema, Servers} from "@/api/application/servers";
|
|
|
7
7
|
import z from "zod";
|
|
8
8
|
import {DatabaseHosts} from "@/api/application/database_hosts";
|
|
9
9
|
import {Roles} from "@/api/application/roles";
|
|
10
|
+
import {Eggs} from "@/api/application/eggs";
|
|
11
|
+
import {Mounts} from "@/api/application/mounts";
|
|
10
12
|
|
|
11
13
|
export class Client {
|
|
12
14
|
private readonly r: AxiosInstance
|
|
@@ -14,6 +16,8 @@ export class Client {
|
|
|
14
16
|
nodes: Nodes
|
|
15
17
|
databaseHosts: DatabaseHosts
|
|
16
18
|
roles: Roles
|
|
19
|
+
eggs: Eggs
|
|
20
|
+
mounts: Mounts
|
|
17
21
|
|
|
18
22
|
constructor(requester: AxiosInstance) {
|
|
19
23
|
this.r = requester
|
|
@@ -22,6 +26,8 @@ export class Client {
|
|
|
22
26
|
this.nodes = new Nodes(requester)
|
|
23
27
|
this.databaseHosts = new DatabaseHosts(requester)
|
|
24
28
|
this.roles = new Roles(requester)
|
|
29
|
+
this.eggs = new Eggs(requester)
|
|
30
|
+
this.mounts = new Mounts(requester)
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
listServers = async (
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {AxiosInstance} from "axios";
|
|
2
|
+
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
3
|
+
import {Egg} from "@/api/application/types/egg";
|
|
4
|
+
|
|
5
|
+
// TODO: API is incomplete
|
|
6
|
+
|
|
7
|
+
export class Eggs {
|
|
8
|
+
private readonly r: AxiosInstance
|
|
9
|
+
|
|
10
|
+
constructor(r: AxiosInstance) {
|
|
11
|
+
this.r = r
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
list = async (): Promise<Egg[]> => {
|
|
15
|
+
const {data} = await this.r.get<GenericListResponse<GenericResponse<Egg, "egg">>>("/eggs")
|
|
16
|
+
return data.data.map(d => d.attributes)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
info = async (id: number): Promise<Egg> => {
|
|
20
|
+
const {data} = await this.r.get<GenericResponse<Egg, "egg">>(`/eggs/${id}`)
|
|
21
|
+
return data.attributes
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export = async (id: number, format: "json" | "yaml"): Promise<string> => {
|
|
25
|
+
const {data} = await this.r.get<string>(`/eggs/${id}/export`, {
|
|
26
|
+
params: {format},
|
|
27
|
+
transformResponse: r => r
|
|
28
|
+
})
|
|
29
|
+
return data
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {AxiosInstance} from "axios";
|
|
2
|
+
import {Mount} from "@/api/application/types/mount";
|
|
3
|
+
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
4
|
+
import z from "zod";
|
|
5
|
+
import {Egg} from "@/api/application/types/egg";
|
|
6
|
+
import {ApplicationServer} from "@/api/application/types";
|
|
7
|
+
|
|
8
|
+
export class Mounts {
|
|
9
|
+
private readonly r: AxiosInstance
|
|
10
|
+
|
|
11
|
+
constructor(r: AxiosInstance) {
|
|
12
|
+
this.r = r
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
list = async (): Promise<Mount[]> => {
|
|
16
|
+
const {data} = await this.r.get<
|
|
17
|
+
GenericListResponse<GenericResponse<Mount, "mount">>
|
|
18
|
+
>("/mounts")
|
|
19
|
+
return data.data.map(d => d.attributes)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
info = async (id: number): Promise<Mount> => {
|
|
23
|
+
const {data} = await this.r.get<GenericResponse<Mount, "mount">>(`/mounts/${id}`)
|
|
24
|
+
return data.attributes
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
create = async (opts: z.infer<typeof CreateMountSchema>): Promise<Mount> => {
|
|
28
|
+
opts = CreateMountSchema.parse(opts)
|
|
29
|
+
const {data} = await this.r.post<GenericResponse<Mount, "mount">>("/mounts", opts)
|
|
30
|
+
return data.attributes
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
update = async (id: number, opts: z.infer<typeof CreateMountSchema>): Promise<Mount> => {
|
|
34
|
+
opts = CreateMountSchema.parse(opts)
|
|
35
|
+
const {data} = await this.r.patch<GenericResponse<Mount, "mount">>(`/mounts/${id}`, opts)
|
|
36
|
+
return data.attributes
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
delete = async (id: number): Promise<void> => {
|
|
40
|
+
await this.r.delete(`/mounts/${id}`)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
listAssignedEggs = async (id: number): Promise<Egg[]> => {
|
|
44
|
+
const {data} = await this.r.get<
|
|
45
|
+
GenericListResponse<GenericResponse<Egg, "egg">>
|
|
46
|
+
>(`/mounts/${id}/eggs`)
|
|
47
|
+
return data.data.map(d => d.attributes)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
assignEggs = async (id: number, eggs: number[]): Promise<void> => {
|
|
51
|
+
await this.r.post(`/mounts/${id}/eggs`, {eggs})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
unassignEgg = async (id: number, egg_id: number): Promise<void> => {
|
|
55
|
+
await this.r.delete(`/mounts/${id}/eggs/${egg_id}`)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
listAssignedNodes = async (id: number): Promise<Node[]> => {
|
|
59
|
+
const {data} = await this.r.get<
|
|
60
|
+
GenericListResponse<GenericResponse<Node, "node">>
|
|
61
|
+
>(`/mounts/${id}/nodes`)
|
|
62
|
+
return data.data.map(d => d.attributes)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
assignNodes = async (id: number, nodes: number[]): Promise<void> => {
|
|
66
|
+
await this.r.post(`/mounts/${id}/nodes`, {nodes})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
unassignNode = async (id: number, node_id: number): Promise<void> => {
|
|
70
|
+
await this.r.delete(`/mounts/${id}/nodes/${node_id}`)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
listAssignedServers = async (id: number): Promise<ApplicationServer[]> => {
|
|
74
|
+
const {data} = await this.r.get<
|
|
75
|
+
GenericListResponse<GenericResponse<ApplicationServer, "server">>
|
|
76
|
+
>(`/mounts/${id}/servers`)
|
|
77
|
+
return data.data.map(d => d.attributes)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
assignServers = async (id: number, servers: number[]): Promise<void> => {
|
|
81
|
+
await this.r.post(`/mounts/${id}/servers`, {servers})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
unassignServer = async (id: number, server_id: number): Promise<void> => {
|
|
85
|
+
await this.r.delete(`/mounts/${id}/servers/${server_id}`)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
const CreateMountSchema = z.object({
|
|
91
|
+
name: z.string().min(1).max(255),
|
|
92
|
+
description: z.string().optional(),
|
|
93
|
+
source: z.string(),
|
|
94
|
+
target: z.string(),
|
|
95
|
+
read_only: z.boolean().optional()
|
|
96
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {Nullable} from "@/utils/types";
|
|
2
|
+
|
|
3
|
+
export type Egg = {
|
|
4
|
+
id: number,
|
|
5
|
+
uuid: string,
|
|
6
|
+
name: number,
|
|
7
|
+
author: string,
|
|
8
|
+
description: string,
|
|
9
|
+
features: string[],
|
|
10
|
+
tags: string[],
|
|
11
|
+
docker_image: string,
|
|
12
|
+
docker_images: Record<string, string>,
|
|
13
|
+
config: {
|
|
14
|
+
files: Record<string, FileConfig>
|
|
15
|
+
startup: Record<string, string>,
|
|
16
|
+
stop: string,
|
|
17
|
+
logs: object | [],
|
|
18
|
+
file_denylist: string[],
|
|
19
|
+
extends: Nullable<number>
|
|
20
|
+
},
|
|
21
|
+
startup: string,
|
|
22
|
+
startup_commands: Record<string, string>,
|
|
23
|
+
script: {
|
|
24
|
+
privileged: boolean,
|
|
25
|
+
install: string,
|
|
26
|
+
entry: string,
|
|
27
|
+
container: string,
|
|
28
|
+
extends: Nullable<number>
|
|
29
|
+
},
|
|
30
|
+
created_at: string,
|
|
31
|
+
updated_at: Nullable<string>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type FileConfig = {
|
|
35
|
+
parser: string,
|
|
36
|
+
find: Record<string, string>
|
|
37
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from "./node"
|
|
2
|
+
export * from "./mount"
|
|
2
3
|
export * from "./location"
|
|
3
4
|
export * from "./database_host"
|
|
4
5
|
export * from "./container"
|
|
5
6
|
export * from "./role"
|
|
7
|
+
export * from "./egg"
|
|
6
8
|
export * from "./server_allocation"
|
|
7
9
|
export * from "./server"
|
|
8
10
|
export * from "./user"
|
package/.github/logo.png
DELETED
|
Binary file
|
package/.idea/Pterodactyl.ts.iml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|
package/.idea/discord.xml
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="DiscordProjectSettings">
|
|
4
|
-
<option name="show" value="ASK" />
|
|
5
|
-
<option name="description" value="" />
|
|
6
|
-
<option name="applicationTheme" value="default" />
|
|
7
|
-
<option name="iconsTheme" value="default" />
|
|
8
|
-
<option name="button1Title" value="" />
|
|
9
|
-
<option name="button1Url" value="" />
|
|
10
|
-
<option name="button2Title" value="" />
|
|
11
|
-
<option name="button2Url" value="" />
|
|
12
|
-
<option name="customApplicationId" value="" />
|
|
13
|
-
</component>
|
|
14
|
-
</project>
|
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/Pterodactyl.ts.iml" filepath="$PROJECT_DIR$/.idea/Pterodactyl.ts.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|