@pelican.ts/sdk 0.3.3-next.3 → 0.3.3-next.5
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/index.d.mts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +20 -0
- package/dist/index.mjs +20 -0
- package/dist/types.d.ts +14 -1
- package/package.json +3 -3
- package/src/api/application/client.ts +4 -0
- package/src/api/application/types/user.ts +14 -0
- package/src/api/application/users.ts +23 -1
- package/src/api/client/client.ts +4 -0
package/dist/index.d.mts
CHANGED
|
@@ -556,6 +556,7 @@ declare class Client$1 {
|
|
|
556
556
|
account: Account;
|
|
557
557
|
private readonly r;
|
|
558
558
|
constructor(requester: AxiosInstance);
|
|
559
|
+
get $r(): AxiosInstance;
|
|
559
560
|
listPermissions: () => Promise<Record<string, Permission>>;
|
|
560
561
|
listServers: (type?: "accessible" | "mine" | "admin" | "admin-all", page?: number, per_page?: number, include?: ("egg" | "subusers")[]) => Promise<Server[]>;
|
|
561
562
|
server: (uuid: string) => ServerClient;
|
|
@@ -608,6 +609,19 @@ type ApplicationUser = {
|
|
|
608
609
|
servers: GenericListResponse<GenericResponse<ApplicationServer>>;
|
|
609
610
|
};
|
|
610
611
|
};
|
|
612
|
+
type ApplicationUserApiKey = {
|
|
613
|
+
id: number;
|
|
614
|
+
user_id: number;
|
|
615
|
+
key_type: 1;
|
|
616
|
+
identifier: string;
|
|
617
|
+
memo: string;
|
|
618
|
+
allowed_ips: Array<string>;
|
|
619
|
+
permissions: [];
|
|
620
|
+
last_used_at: Nullable<string>;
|
|
621
|
+
expires_at: Nullable<string>;
|
|
622
|
+
created_at: string;
|
|
623
|
+
updated_at: string;
|
|
624
|
+
};
|
|
611
625
|
|
|
612
626
|
declare class Users {
|
|
613
627
|
private readonly r;
|
|
@@ -624,6 +638,13 @@ declare class Users {
|
|
|
624
638
|
delete: (id: number) => Promise<void>;
|
|
625
639
|
addRoles: (id: number, roles: number[]) => Promise<void>;
|
|
626
640
|
removeRoles: (id: number, roles: number[]) => Promise<void>;
|
|
641
|
+
apiKeys: {
|
|
642
|
+
list: (id: number) => Promise<ApplicationUserApiKey[]>;
|
|
643
|
+
create: (id: number, description: string, allowed_ips?: string[]) => Promise<ApplicationUserApiKey & {
|
|
644
|
+
secret_token: string;
|
|
645
|
+
}>;
|
|
646
|
+
delete: (id: number, identifier: string) => Promise<void>;
|
|
647
|
+
};
|
|
627
648
|
}
|
|
628
649
|
type ListType = {
|
|
629
650
|
include?: ("servers")[];
|
|
@@ -1571,6 +1592,7 @@ declare class Client {
|
|
|
1571
1592
|
eggs: Eggs;
|
|
1572
1593
|
mounts: Mounts;
|
|
1573
1594
|
constructor(requester: AxiosInstance);
|
|
1595
|
+
get $r(): AxiosInstance;
|
|
1574
1596
|
listServers: (search?: string, page?: number) => Promise<ApplicationServer[]>;
|
|
1575
1597
|
createServer: (opts: z.infer<typeof CreateServerSchema>) => Promise<ApplicationServer>;
|
|
1576
1598
|
getServerByExternalId: (external_id: string, include?: ("egg" | "subusers")[]) => Promise<ApplicationServer>;
|
package/dist/index.d.ts
CHANGED
|
@@ -556,6 +556,7 @@ declare class Client$1 {
|
|
|
556
556
|
account: Account;
|
|
557
557
|
private readonly r;
|
|
558
558
|
constructor(requester: AxiosInstance);
|
|
559
|
+
get $r(): AxiosInstance;
|
|
559
560
|
listPermissions: () => Promise<Record<string, Permission>>;
|
|
560
561
|
listServers: (type?: "accessible" | "mine" | "admin" | "admin-all", page?: number, per_page?: number, include?: ("egg" | "subusers")[]) => Promise<Server[]>;
|
|
561
562
|
server: (uuid: string) => ServerClient;
|
|
@@ -608,6 +609,19 @@ type ApplicationUser = {
|
|
|
608
609
|
servers: GenericListResponse<GenericResponse<ApplicationServer>>;
|
|
609
610
|
};
|
|
610
611
|
};
|
|
612
|
+
type ApplicationUserApiKey = {
|
|
613
|
+
id: number;
|
|
614
|
+
user_id: number;
|
|
615
|
+
key_type: 1;
|
|
616
|
+
identifier: string;
|
|
617
|
+
memo: string;
|
|
618
|
+
allowed_ips: Array<string>;
|
|
619
|
+
permissions: [];
|
|
620
|
+
last_used_at: Nullable<string>;
|
|
621
|
+
expires_at: Nullable<string>;
|
|
622
|
+
created_at: string;
|
|
623
|
+
updated_at: string;
|
|
624
|
+
};
|
|
611
625
|
|
|
612
626
|
declare class Users {
|
|
613
627
|
private readonly r;
|
|
@@ -624,6 +638,13 @@ declare class Users {
|
|
|
624
638
|
delete: (id: number) => Promise<void>;
|
|
625
639
|
addRoles: (id: number, roles: number[]) => Promise<void>;
|
|
626
640
|
removeRoles: (id: number, roles: number[]) => Promise<void>;
|
|
641
|
+
apiKeys: {
|
|
642
|
+
list: (id: number) => Promise<ApplicationUserApiKey[]>;
|
|
643
|
+
create: (id: number, description: string, allowed_ips?: string[]) => Promise<ApplicationUserApiKey & {
|
|
644
|
+
secret_token: string;
|
|
645
|
+
}>;
|
|
646
|
+
delete: (id: number, identifier: string) => Promise<void>;
|
|
647
|
+
};
|
|
627
648
|
}
|
|
628
649
|
type ListType = {
|
|
629
650
|
include?: ("servers")[];
|
|
@@ -1571,6 +1592,7 @@ declare class Client {
|
|
|
1571
1592
|
eggs: Eggs;
|
|
1572
1593
|
mounts: Mounts;
|
|
1573
1594
|
constructor(requester: AxiosInstance);
|
|
1595
|
+
get $r(): AxiosInstance;
|
|
1574
1596
|
listServers: (search?: string, page?: number) => Promise<ApplicationServer[]>;
|
|
1575
1597
|
createServer: (opts: z.infer<typeof CreateServerSchema>) => Promise<ApplicationServer>;
|
|
1576
1598
|
getServerByExternalId: (external_id: string, include?: ("egg" | "subusers")[]) => Promise<ApplicationServer>;
|
package/dist/index.js
CHANGED
|
@@ -901,6 +901,9 @@ var Client = class {
|
|
|
901
901
|
this.r = requester;
|
|
902
902
|
this.account = new Account(requester);
|
|
903
903
|
}
|
|
904
|
+
get $r() {
|
|
905
|
+
return this.r;
|
|
906
|
+
}
|
|
904
907
|
listPermissions = async () => {
|
|
905
908
|
const { data } = await this.r.get("/permissions");
|
|
906
909
|
return data.attributes.permissions;
|
|
@@ -1546,6 +1549,20 @@ var Users = class {
|
|
|
1546
1549
|
import_zod7.default.number().positive().parse(id);
|
|
1547
1550
|
await this.r.patch(`/users/${id}/roles/remove`, { roles });
|
|
1548
1551
|
};
|
|
1552
|
+
apiKeys = {
|
|
1553
|
+
list: async (id) => {
|
|
1554
|
+
const { data } = await this.r.get(`/users/${id}/roles/api-keys`);
|
|
1555
|
+
return data.data.map((k) => k.attributes);
|
|
1556
|
+
},
|
|
1557
|
+
create: async (id, description, allowed_ips) => {
|
|
1558
|
+
allowed_ips = import_zod7.default.array(import_zod7.default.ipv4()).optional().parse(allowed_ips);
|
|
1559
|
+
const { data } = await this.r.post(`/users/${id}/roles/api-keys`, { description, allowed_ips });
|
|
1560
|
+
return { ...data.attributes, secret_token: data.meta.secret_token };
|
|
1561
|
+
},
|
|
1562
|
+
delete: async (id, identifier) => {
|
|
1563
|
+
await this.r.delete(`/users/${id}/roles/api-keys/${identifier}`);
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1549
1566
|
};
|
|
1550
1567
|
var CreateSchema = import_zod7.default.object({
|
|
1551
1568
|
email: import_zod7.default.email(),
|
|
@@ -1989,6 +2006,9 @@ var Client2 = class {
|
|
|
1989
2006
|
this.eggs = new Eggs(requester);
|
|
1990
2007
|
this.mounts = new Mounts(requester);
|
|
1991
2008
|
}
|
|
2009
|
+
get $r() {
|
|
2010
|
+
return this.r;
|
|
2011
|
+
}
|
|
1992
2012
|
listServers = async (search, page = 1) => {
|
|
1993
2013
|
const { data } = await this.r.get("/servers", {
|
|
1994
2014
|
params: { search, page }
|
package/dist/index.mjs
CHANGED
|
@@ -864,6 +864,9 @@ var Client = class {
|
|
|
864
864
|
this.r = requester;
|
|
865
865
|
this.account = new Account(requester);
|
|
866
866
|
}
|
|
867
|
+
get $r() {
|
|
868
|
+
return this.r;
|
|
869
|
+
}
|
|
867
870
|
listPermissions = async () => {
|
|
868
871
|
const { data } = await this.r.get("/permissions");
|
|
869
872
|
return data.attributes.permissions;
|
|
@@ -1509,6 +1512,20 @@ var Users = class {
|
|
|
1509
1512
|
z7.number().positive().parse(id);
|
|
1510
1513
|
await this.r.patch(`/users/${id}/roles/remove`, { roles });
|
|
1511
1514
|
};
|
|
1515
|
+
apiKeys = {
|
|
1516
|
+
list: async (id) => {
|
|
1517
|
+
const { data } = await this.r.get(`/users/${id}/roles/api-keys`);
|
|
1518
|
+
return data.data.map((k) => k.attributes);
|
|
1519
|
+
},
|
|
1520
|
+
create: async (id, description, allowed_ips) => {
|
|
1521
|
+
allowed_ips = z7.array(z7.ipv4()).optional().parse(allowed_ips);
|
|
1522
|
+
const { data } = await this.r.post(`/users/${id}/roles/api-keys`, { description, allowed_ips });
|
|
1523
|
+
return { ...data.attributes, secret_token: data.meta.secret_token };
|
|
1524
|
+
},
|
|
1525
|
+
delete: async (id, identifier) => {
|
|
1526
|
+
await this.r.delete(`/users/${id}/roles/api-keys/${identifier}`);
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1512
1529
|
};
|
|
1513
1530
|
var CreateSchema = z7.object({
|
|
1514
1531
|
email: z7.email(),
|
|
@@ -1952,6 +1969,9 @@ var Client2 = class {
|
|
|
1952
1969
|
this.eggs = new Eggs(requester);
|
|
1953
1970
|
this.mounts = new Mounts(requester);
|
|
1954
1971
|
}
|
|
1972
|
+
get $r() {
|
|
1973
|
+
return this.r;
|
|
1974
|
+
}
|
|
1955
1975
|
listServers = async (search, page = 1) => {
|
|
1956
1976
|
const { data } = await this.r.get("/servers", {
|
|
1957
1977
|
params: { search, page }
|
package/dist/types.d.ts
CHANGED
|
@@ -892,6 +892,19 @@ type ApplicationUser = {
|
|
|
892
892
|
servers: GenericListResponse<GenericResponse<ApplicationServer>>;
|
|
893
893
|
};
|
|
894
894
|
};
|
|
895
|
+
type ApplicationUserApiKey = {
|
|
896
|
+
id: number;
|
|
897
|
+
user_id: number;
|
|
898
|
+
key_type: 1;
|
|
899
|
+
identifier: string;
|
|
900
|
+
memo: string;
|
|
901
|
+
allowed_ips: Array<string>;
|
|
902
|
+
permissions: [];
|
|
903
|
+
last_used_at: Nullable<string>;
|
|
904
|
+
expires_at: Nullable<string>;
|
|
905
|
+
created_at: string;
|
|
906
|
+
updated_at: string;
|
|
907
|
+
};
|
|
895
908
|
|
|
896
909
|
type ServerStatus = 'starting' | 'stopping' | 'online' | 'offline';
|
|
897
910
|
declare enum SERVER_SIGNAL {
|
|
@@ -1119,4 +1132,4 @@ type Permission = {
|
|
|
1119
1132
|
keys: Record<string, string>;
|
|
1120
1133
|
};
|
|
1121
1134
|
|
|
1122
|
-
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 };
|
|
1135
|
+
export { type APIKey, type Allocation, type AllocationRel, type ApplicationServer, type ApplicationUser, type ApplicationUserApiKey, 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,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pelican.ts/sdk",
|
|
3
|
-
"version": "0.3.3-next.
|
|
3
|
+
"version": "0.3.3-next.5",
|
|
4
4
|
"description": "Pelican panel SDK for TypeScript",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
10
11
|
"require": "./dist/index.js",
|
|
11
|
-
"import": "./dist/index.mjs"
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
13
13
|
},
|
|
14
14
|
"./types": {
|
|
15
15
|
"types": "./dist/types.d.ts"
|
|
@@ -17,4 +17,18 @@ export type ApplicationUser = {
|
|
|
17
17
|
relationships?: {
|
|
18
18
|
servers: GenericListResponse<GenericResponse<ApplicationServer>>
|
|
19
19
|
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type ApplicationUserApiKey = {
|
|
23
|
+
id: number,
|
|
24
|
+
user_id: number,
|
|
25
|
+
key_type: 1,
|
|
26
|
+
identifier: string,
|
|
27
|
+
memo: string,
|
|
28
|
+
allowed_ips: Array<string>,
|
|
29
|
+
permissions: [],
|
|
30
|
+
last_used_at: Nullable<string>,
|
|
31
|
+
expires_at: Nullable<string>,
|
|
32
|
+
created_at: string,
|
|
33
|
+
updated_at: string
|
|
20
34
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {AxiosInstance} from "axios";
|
|
2
2
|
import z from "zod";
|
|
3
3
|
import {GenericListResponse, GenericResponse} from "@/api/base/types";
|
|
4
|
-
import {ApplicationUser} from "@/api/application/types/user";
|
|
4
|
+
import {ApplicationUser, ApplicationUserApiKey} from "@/api/application/types/user";
|
|
5
5
|
import {ArrayQueryParams, SortParam} from "@/utils/transform";
|
|
6
6
|
import {ExactlyOneKey} from "@/utils/types";
|
|
7
7
|
import {languagesSchema, timezonesSchema} from "@/api/common/types/enums";
|
|
8
|
+
import {APIKey} from "@/api/client/types";
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
export class Users {
|
|
@@ -90,6 +91,27 @@ export class Users {
|
|
|
90
91
|
z.number().positive().parse(id)
|
|
91
92
|
await this.r.patch(`/users/${id}/roles/remove`, {roles})
|
|
92
93
|
}
|
|
94
|
+
|
|
95
|
+
apiKeys = {
|
|
96
|
+
list: async (id: number): Promise<ApplicationUserApiKey[]> => {
|
|
97
|
+
const {data} = await this.r.get<
|
|
98
|
+
GenericListResponse<GenericResponse<ApplicationUserApiKey, "api_key">>
|
|
99
|
+
>(`/users/${id}/roles/api-keys`)
|
|
100
|
+
return data.data.map(k => k.attributes)
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
create: async (id: number, description: string, allowed_ips?: string[]): Promise<ApplicationUserApiKey & { secret_token: string }> => {
|
|
104
|
+
allowed_ips = z.array(z.ipv4()).optional().parse(allowed_ips)
|
|
105
|
+
const {data} = await this.r.post<
|
|
106
|
+
GenericResponse<ApplicationUserApiKey, "api_key", { secret_token: string }>
|
|
107
|
+
>(`/users/${id}/roles/api-keys`, {description, allowed_ips})
|
|
108
|
+
return {...data.attributes, secret_token: data.meta!.secret_token}
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
delete: async (id: number, identifier: string): Promise<void> => {
|
|
112
|
+
await this.r.delete(`/users/${id}/roles/api-keys/${identifier}`)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
93
115
|
}
|
|
94
116
|
|
|
95
117
|
type ListType = {
|
package/src/api/client/client.ts
CHANGED
|
@@ -17,6 +17,10 @@ export class Client {
|
|
|
17
17
|
this.account = new Account(requester)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
get $r(): AxiosInstance {
|
|
21
|
+
return this.r
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
listPermissions = async (): Promise<Record<string, Permission>> => {
|
|
21
25
|
const {data} = await this.r.get<
|
|
22
26
|
GenericResponse<{ permissions: Record<string, Permission> }, "system_permissions">
|