@pelican.ts/sdk 0.3.3-next.4 → 0.3.3-next.6

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 CHANGED
@@ -609,6 +609,19 @@ type ApplicationUser = {
609
609
  servers: GenericListResponse<GenericResponse<ApplicationServer>>;
610
610
  };
611
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
+ };
612
625
 
613
626
  declare class Users {
614
627
  private readonly r;
@@ -625,6 +638,13 @@ declare class Users {
625
638
  delete: (id: number) => Promise<void>;
626
639
  addRoles: (id: number, roles: number[]) => Promise<void>;
627
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
+ };
628
648
  }
629
649
  type ListType = {
630
650
  include?: ("servers")[];
package/dist/index.d.ts CHANGED
@@ -609,6 +609,19 @@ type ApplicationUser = {
609
609
  servers: GenericListResponse<GenericResponse<ApplicationServer>>;
610
610
  };
611
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
+ };
612
625
 
613
626
  declare class Users {
614
627
  private readonly r;
@@ -625,6 +638,13 @@ declare class Users {
625
638
  delete: (id: number) => Promise<void>;
626
639
  addRoles: (id: number, roles: number[]) => Promise<void>;
627
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
+ };
628
648
  }
629
649
  type ListType = {
630
650
  include?: ("servers")[];
package/dist/index.js CHANGED
@@ -1549,6 +1549,20 @@ var Users = class {
1549
1549
  import_zod7.default.number().positive().parse(id);
1550
1550
  await this.r.patch(`/users/${id}/roles/remove`, { roles });
1551
1551
  };
1552
+ apiKeys = {
1553
+ list: async (id) => {
1554
+ const { data } = await this.r.get(`/users/${id}/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}/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}/api-keys/${identifier}`);
1564
+ }
1565
+ };
1552
1566
  };
1553
1567
  var CreateSchema = import_zod7.default.object({
1554
1568
  email: import_zod7.default.email(),
package/dist/index.mjs CHANGED
@@ -1512,6 +1512,20 @@ var Users = class {
1512
1512
  z7.number().positive().parse(id);
1513
1513
  await this.r.patch(`/users/${id}/roles/remove`, { roles });
1514
1514
  };
1515
+ apiKeys = {
1516
+ list: async (id) => {
1517
+ const { data } = await this.r.get(`/users/${id}/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}/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}/api-keys/${identifier}`);
1527
+ }
1528
+ };
1515
1529
  };
1516
1530
  var CreateSchema = z7.object({
1517
1531
  email: z7.email(),
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.4",
3
+ "version": "0.3.3-next.6",
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}/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}/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}/api-keys/${identifier}`)
113
+ }
114
+ }
93
115
  }
94
116
 
95
117
  type ListType = {