@pelican.ts/sdk 0.3.3 → 0.3.4-next.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 CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  # Pelican.ts — Typescript client for Pelican panel
6
6
 
7
+ > [!WARNING]
8
+ > This is a `next` version of Pelican.ts, it is based on [Pelican-contrib](https://github.com/m41denx/pelican-contrib)
9
+ > fork and is not compatible with upstream Pelican panel.
10
+
7
11
  ## Installation
8
12
  ```shell
9
13
  npm install @pelican.ts/sdk
@@ -32,7 +36,7 @@ What's done:
32
36
  - [X] Nodes
33
37
  - [X] Servers
34
38
  - [X] Databases (TODO: Check if server database type is valid)
35
- - [X] Database Hosts (TODO: find out why create API returns 500 No Route)
39
+ - [X] Database Hosts (~~TODO: find out why create API returns 500 No Route~~ Fix was merged to upstream)
36
40
  - [X] Roles
37
41
  - [X] Eggs
38
42
  - [X] Mounts
package/dist/index.d.mts CHANGED
@@ -11,7 +11,6 @@ type ExactlyOneKey<K extends keyof any, V, KK extends keyof any = K> = {
11
11
  [Q in keyof O]: O[Q];
12
12
  } : never;
13
13
  }[K];
14
- type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
15
14
  type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
16
15
  type Nullable<T> = T | null;
17
16
 
@@ -360,9 +359,9 @@ declare class ServerUsers {
360
359
  constructor(requester: AxiosInstance, id: string);
361
360
  list: () => Promise<ServerSubuser[]>;
362
361
  create: (email: string, permissions: SubuserPermission[] | string[]) => Promise<ServerSubuser>;
363
- info: (user_id: number) => Promise<ServerSubuser>;
364
- update: (user_id: number, permissions: SubuserPermission[] | string[]) => Promise<ServerSubuser>;
365
- delete: (user_id: number) => Promise<void>;
362
+ info: (user_uuid: string) => Promise<ServerSubuser>;
363
+ update: (user_uuid: string, permissions: SubuserPermission[] | string[]) => Promise<ServerSubuser>;
364
+ delete: (user_uuid: string) => Promise<void>;
366
365
  }
367
366
 
368
367
  type ServerBackup = {
@@ -556,6 +555,7 @@ declare class Client$1 {
556
555
  account: Account;
557
556
  private readonly r;
558
557
  constructor(requester: AxiosInstance);
558
+ get $r(): AxiosInstance;
559
559
  listPermissions: () => Promise<Record<string, Permission>>;
560
560
  listServers: (type?: "accessible" | "mine" | "admin" | "admin-all", page?: number, per_page?: number, include?: ("egg" | "subusers")[]) => Promise<Server[]>;
561
561
  server: (uuid: string) => ServerClient;
@@ -579,6 +579,7 @@ type ApplicationServer = {
579
579
  name: string;
580
580
  description: string;
581
581
  status: Nullable<unknown>;
582
+ docker_labels: Record<string, string>;
582
583
  suspended: boolean;
583
584
  limits: ServerLimits;
584
585
  feature_limits: FeatureLimits;
@@ -607,6 +608,19 @@ type ApplicationUser = {
607
608
  servers: GenericListResponse<GenericResponse<ApplicationServer>>;
608
609
  };
609
610
  };
611
+ type ApplicationUserApiKey = {
612
+ id: number;
613
+ user_id: number;
614
+ key_type: 1;
615
+ identifier: string;
616
+ memo: string;
617
+ allowed_ips: Array<string>;
618
+ permissions: [];
619
+ last_used_at: Nullable<string>;
620
+ expires_at: Nullable<string>;
621
+ created_at: string;
622
+ updated_at: string;
623
+ };
610
624
 
611
625
  declare class Users {
612
626
  private readonly r;
@@ -623,6 +637,13 @@ declare class Users {
623
637
  delete: (id: number) => Promise<void>;
624
638
  addRoles: (id: number, roles: number[]) => Promise<void>;
625
639
  removeRoles: (id: number, roles: number[]) => Promise<void>;
640
+ apiKeys: {
641
+ list: (id: number) => Promise<ApplicationUserApiKey[]>;
642
+ create: (id: number, description: string, allowed_ips?: string[]) => Promise<ApplicationUserApiKey & {
643
+ secret_token: string;
644
+ }>;
645
+ delete: (id: number, identifier: string) => Promise<void>;
646
+ };
626
647
  }
627
648
  type ListType = {
628
649
  include?: ("servers")[];
@@ -1369,10 +1390,11 @@ declare const CreateServerSchema: z.ZodObject<{
1369
1390
  egg: z.ZodNumber;
1370
1391
  docker_image: z.ZodOptional<z.ZodString>;
1371
1392
  startup: z.ZodOptional<z.ZodString>;
1372
- environment: z.ZodArray<z.ZodString>;
1393
+ environment: z.ZodRecord<z.ZodString, z.ZodString>;
1373
1394
  skip_scripts: z.ZodOptional<z.ZodBoolean>;
1374
1395
  oom_killer: z.ZodOptional<z.ZodBoolean>;
1375
1396
  start_on_completion: z.ZodOptional<z.ZodBoolean>;
1397
+ docker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1376
1398
  limits: z.ZodObject<{
1377
1399
  memory: z.ZodNumber;
1378
1400
  swap: z.ZodNumber;
@@ -1401,6 +1423,7 @@ declare const UpdateDetailsSchema: z.ZodObject<{
1401
1423
  description: z.ZodOptional<z.ZodString>;
1402
1424
  name: z.ZodString;
1403
1425
  external_id: z.ZodOptional<z.ZodString>;
1426
+ docker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1404
1427
  }, z.core.$strip>;
1405
1428
  declare const UpdateBuildSchema: z.ZodObject<{
1406
1429
  oom_killer: z.ZodOptional<z.ZodBoolean>;
@@ -1424,7 +1447,7 @@ declare const UpdateBuildSchema: z.ZodObject<{
1424
1447
  declare const UpdateStartupSchema: z.ZodObject<{
1425
1448
  egg: z.ZodNumber;
1426
1449
  startup: z.ZodOptional<z.ZodString>;
1427
- environment: z.ZodArray<z.ZodString>;
1450
+ environment: z.ZodRecord<z.ZodString, z.ZodString>;
1428
1451
  skip_scripts: z.ZodOptional<z.ZodBoolean>;
1429
1452
  image: z.ZodOptional<z.ZodString>;
1430
1453
  }, z.core.$strip>;
@@ -1487,7 +1510,7 @@ type Egg = {
1487
1510
  description: string;
1488
1511
  features: string[];
1489
1512
  tags: string[];
1490
- docker_image: string;
1513
+ docker_image: Nullable<string>;
1491
1514
  docker_images: Record<string, string>;
1492
1515
  config: {
1493
1516
  files: Record<string, FileConfig>;
@@ -1513,6 +1536,38 @@ type FileConfig = {
1513
1536
  parser: string;
1514
1537
  find: Record<string, string>;
1515
1538
  };
1539
+ type ApplicationEggVariable = Omit<EggVariable, "server_value" | "is_editable" | "rules"> & {
1540
+ rules: string[];
1541
+ sort: number;
1542
+ user_viewable: boolean;
1543
+ user_editable: boolean;
1544
+ };
1545
+ type ExportedEgg = {
1546
+ meta: {
1547
+ version: "PLCN_v3";
1548
+ update_url: Nullable<string>;
1549
+ };
1550
+ exported_at: string;
1551
+ name: number;
1552
+ author: string;
1553
+ description: string;
1554
+ uuid: string;
1555
+ image: Nullable<string>;
1556
+ docker_images: Record<string, string>;
1557
+ features: string[];
1558
+ tags: string[];
1559
+ file_denylist: string[];
1560
+ startup_commands: Record<string, string>;
1561
+ config: Omit<Egg["config"], "extends" | "file_denylist">;
1562
+ scripts: {
1563
+ installation: {
1564
+ script: string;
1565
+ container: string;
1566
+ entrypoint: string;
1567
+ };
1568
+ };
1569
+ variables: ApplicationEggVariable[];
1570
+ };
1516
1571
 
1517
1572
  declare class Eggs {
1518
1573
  private readonly r;
@@ -1520,6 +1575,7 @@ declare class Eggs {
1520
1575
  list: () => Promise<Egg[]>;
1521
1576
  info: (id: number) => Promise<Egg>;
1522
1577
  export: (id: number, format: "json" | "yaml") => Promise<string>;
1578
+ infoExportable: (id: number) => Promise<ExportedEgg>;
1523
1579
  }
1524
1580
 
1525
1581
  type Mount = {
@@ -1568,6 +1624,7 @@ declare class Client {
1568
1624
  eggs: Eggs;
1569
1625
  mounts: Mounts;
1570
1626
  constructor(requester: AxiosInstance);
1627
+ get $r(): AxiosInstance;
1571
1628
  listServers: (search?: string, page?: number) => Promise<ApplicationServer[]>;
1572
1629
  createServer: (opts: z.infer<typeof CreateServerSchema>) => Promise<ApplicationServer>;
1573
1630
  getServerByExternalId: (external_id: string, include?: ("egg" | "subusers")[]) => Promise<ApplicationServer>;
package/dist/index.d.ts CHANGED
@@ -11,7 +11,6 @@ type ExactlyOneKey<K extends keyof any, V, KK extends keyof any = K> = {
11
11
  [Q in keyof O]: O[Q];
12
12
  } : never;
13
13
  }[K];
14
- type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
15
14
  type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
16
15
  type Nullable<T> = T | null;
17
16
 
@@ -360,9 +359,9 @@ declare class ServerUsers {
360
359
  constructor(requester: AxiosInstance, id: string);
361
360
  list: () => Promise<ServerSubuser[]>;
362
361
  create: (email: string, permissions: SubuserPermission[] | string[]) => Promise<ServerSubuser>;
363
- info: (user_id: number) => Promise<ServerSubuser>;
364
- update: (user_id: number, permissions: SubuserPermission[] | string[]) => Promise<ServerSubuser>;
365
- delete: (user_id: number) => Promise<void>;
362
+ info: (user_uuid: string) => Promise<ServerSubuser>;
363
+ update: (user_uuid: string, permissions: SubuserPermission[] | string[]) => Promise<ServerSubuser>;
364
+ delete: (user_uuid: string) => Promise<void>;
366
365
  }
367
366
 
368
367
  type ServerBackup = {
@@ -556,6 +555,7 @@ declare class Client$1 {
556
555
  account: Account;
557
556
  private readonly r;
558
557
  constructor(requester: AxiosInstance);
558
+ get $r(): AxiosInstance;
559
559
  listPermissions: () => Promise<Record<string, Permission>>;
560
560
  listServers: (type?: "accessible" | "mine" | "admin" | "admin-all", page?: number, per_page?: number, include?: ("egg" | "subusers")[]) => Promise<Server[]>;
561
561
  server: (uuid: string) => ServerClient;
@@ -579,6 +579,7 @@ type ApplicationServer = {
579
579
  name: string;
580
580
  description: string;
581
581
  status: Nullable<unknown>;
582
+ docker_labels: Record<string, string>;
582
583
  suspended: boolean;
583
584
  limits: ServerLimits;
584
585
  feature_limits: FeatureLimits;
@@ -607,6 +608,19 @@ type ApplicationUser = {
607
608
  servers: GenericListResponse<GenericResponse<ApplicationServer>>;
608
609
  };
609
610
  };
611
+ type ApplicationUserApiKey = {
612
+ id: number;
613
+ user_id: number;
614
+ key_type: 1;
615
+ identifier: string;
616
+ memo: string;
617
+ allowed_ips: Array<string>;
618
+ permissions: [];
619
+ last_used_at: Nullable<string>;
620
+ expires_at: Nullable<string>;
621
+ created_at: string;
622
+ updated_at: string;
623
+ };
610
624
 
611
625
  declare class Users {
612
626
  private readonly r;
@@ -623,6 +637,13 @@ declare class Users {
623
637
  delete: (id: number) => Promise<void>;
624
638
  addRoles: (id: number, roles: number[]) => Promise<void>;
625
639
  removeRoles: (id: number, roles: number[]) => Promise<void>;
640
+ apiKeys: {
641
+ list: (id: number) => Promise<ApplicationUserApiKey[]>;
642
+ create: (id: number, description: string, allowed_ips?: string[]) => Promise<ApplicationUserApiKey & {
643
+ secret_token: string;
644
+ }>;
645
+ delete: (id: number, identifier: string) => Promise<void>;
646
+ };
626
647
  }
627
648
  type ListType = {
628
649
  include?: ("servers")[];
@@ -1369,10 +1390,11 @@ declare const CreateServerSchema: z.ZodObject<{
1369
1390
  egg: z.ZodNumber;
1370
1391
  docker_image: z.ZodOptional<z.ZodString>;
1371
1392
  startup: z.ZodOptional<z.ZodString>;
1372
- environment: z.ZodArray<z.ZodString>;
1393
+ environment: z.ZodRecord<z.ZodString, z.ZodString>;
1373
1394
  skip_scripts: z.ZodOptional<z.ZodBoolean>;
1374
1395
  oom_killer: z.ZodOptional<z.ZodBoolean>;
1375
1396
  start_on_completion: z.ZodOptional<z.ZodBoolean>;
1397
+ docker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1376
1398
  limits: z.ZodObject<{
1377
1399
  memory: z.ZodNumber;
1378
1400
  swap: z.ZodNumber;
@@ -1401,6 +1423,7 @@ declare const UpdateDetailsSchema: z.ZodObject<{
1401
1423
  description: z.ZodOptional<z.ZodString>;
1402
1424
  name: z.ZodString;
1403
1425
  external_id: z.ZodOptional<z.ZodString>;
1426
+ docker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1404
1427
  }, z.core.$strip>;
1405
1428
  declare const UpdateBuildSchema: z.ZodObject<{
1406
1429
  oom_killer: z.ZodOptional<z.ZodBoolean>;
@@ -1424,7 +1447,7 @@ declare const UpdateBuildSchema: z.ZodObject<{
1424
1447
  declare const UpdateStartupSchema: z.ZodObject<{
1425
1448
  egg: z.ZodNumber;
1426
1449
  startup: z.ZodOptional<z.ZodString>;
1427
- environment: z.ZodArray<z.ZodString>;
1450
+ environment: z.ZodRecord<z.ZodString, z.ZodString>;
1428
1451
  skip_scripts: z.ZodOptional<z.ZodBoolean>;
1429
1452
  image: z.ZodOptional<z.ZodString>;
1430
1453
  }, z.core.$strip>;
@@ -1487,7 +1510,7 @@ type Egg = {
1487
1510
  description: string;
1488
1511
  features: string[];
1489
1512
  tags: string[];
1490
- docker_image: string;
1513
+ docker_image: Nullable<string>;
1491
1514
  docker_images: Record<string, string>;
1492
1515
  config: {
1493
1516
  files: Record<string, FileConfig>;
@@ -1513,6 +1536,38 @@ type FileConfig = {
1513
1536
  parser: string;
1514
1537
  find: Record<string, string>;
1515
1538
  };
1539
+ type ApplicationEggVariable = Omit<EggVariable, "server_value" | "is_editable" | "rules"> & {
1540
+ rules: string[];
1541
+ sort: number;
1542
+ user_viewable: boolean;
1543
+ user_editable: boolean;
1544
+ };
1545
+ type ExportedEgg = {
1546
+ meta: {
1547
+ version: "PLCN_v3";
1548
+ update_url: Nullable<string>;
1549
+ };
1550
+ exported_at: string;
1551
+ name: number;
1552
+ author: string;
1553
+ description: string;
1554
+ uuid: string;
1555
+ image: Nullable<string>;
1556
+ docker_images: Record<string, string>;
1557
+ features: string[];
1558
+ tags: string[];
1559
+ file_denylist: string[];
1560
+ startup_commands: Record<string, string>;
1561
+ config: Omit<Egg["config"], "extends" | "file_denylist">;
1562
+ scripts: {
1563
+ installation: {
1564
+ script: string;
1565
+ container: string;
1566
+ entrypoint: string;
1567
+ };
1568
+ };
1569
+ variables: ApplicationEggVariable[];
1570
+ };
1516
1571
 
1517
1572
  declare class Eggs {
1518
1573
  private readonly r;
@@ -1520,6 +1575,7 @@ declare class Eggs {
1520
1575
  list: () => Promise<Egg[]>;
1521
1576
  info: (id: number) => Promise<Egg>;
1522
1577
  export: (id: number, format: "json" | "yaml") => Promise<string>;
1578
+ infoExportable: (id: number) => Promise<ExportedEgg>;
1523
1579
  }
1524
1580
 
1525
1581
  type Mount = {
@@ -1568,6 +1624,7 @@ declare class Client {
1568
1624
  eggs: Eggs;
1569
1625
  mounts: Mounts;
1570
1626
  constructor(requester: AxiosInstance);
1627
+ get $r(): AxiosInstance;
1571
1628
  listServers: (search?: string, page?: number) => Promise<ApplicationServer[]>;
1572
1629
  createServer: (opts: z.infer<typeof CreateServerSchema>) => Promise<ApplicationServer>;
1573
1630
  getServerByExternalId: (external_id: string, include?: ("egg" | "subusers")[]) => Promise<ApplicationServer>;
package/dist/index.js CHANGED
@@ -309,16 +309,16 @@ var ServerUsers = class {
309
309
  const { data } = await this.r.post(`/servers/${this.id}/users`, { email, permissions });
310
310
  return data.attributes;
311
311
  };
312
- info = async (user_id) => {
313
- const { data } = await this.r.get(`/servers/${this.id}/users/${user_id}`);
312
+ info = async (user_uuid) => {
313
+ const { data } = await this.r.get(`/servers/${this.id}/users/${user_uuid}`);
314
314
  return data.attributes;
315
315
  };
316
- update = async (user_id, permissions) => {
317
- const { data } = await this.r.put(`/servers/${this.id}/users/${user_id}`, { permissions });
316
+ update = async (user_uuid, permissions) => {
317
+ const { data } = await this.r.put(`/servers/${this.id}/users/${user_uuid}`, { permissions });
318
318
  return data.attributes;
319
319
  };
320
- delete = async (user_id) => {
321
- await this.r.delete(`/servers/${this.id}/users/${user_id}`);
320
+ delete = async (user_uuid) => {
321
+ await this.r.delete(`/servers/${this.id}/users/${user_uuid}`);
322
322
  };
323
323
  };
324
324
 
@@ -901,13 +901,16 @@ 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;
907
910
  };
908
911
  listServers = async (type = "accessible", page = 1, per_page = 50, include) => {
909
912
  import_zod5.default.number().positive().parse(page);
910
- const { data } = await this.r.get("/servers", {
913
+ const { data } = await this.r.get("/", {
911
914
  params: { type, page, include: include?.join(",") }
912
915
  });
913
916
  return data.data.map((s) => s.attributes);
@@ -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}/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
+ };
1549
1566
  };
1550
1567
  var CreateSchema = import_zod7.default.object({
1551
1568
  email: import_zod7.default.email(),
@@ -1759,10 +1776,11 @@ var CreateServerSchema = import_zod11.default.object({
1759
1776
  egg: import_zod11.default.number(),
1760
1777
  docker_image: import_zod11.default.string().optional(),
1761
1778
  startup: import_zod11.default.string().optional(),
1762
- environment: import_zod11.default.array(import_zod11.default.string()),
1779
+ environment: import_zod11.default.record(import_zod11.default.string(), import_zod11.default.string()),
1763
1780
  skip_scripts: import_zod11.default.boolean().optional(),
1764
1781
  oom_killer: import_zod11.default.boolean().optional(),
1765
1782
  start_on_completion: import_zod11.default.boolean().optional(),
1783
+ docker_labels: import_zod11.default.record(import_zod11.default.string(), import_zod11.default.string()).optional(),
1766
1784
  limits: import_zod11.default.object({
1767
1785
  memory: import_zod11.default.number().min(0),
1768
1786
  swap: import_zod11.default.number().min(-1),
@@ -1790,7 +1808,8 @@ var UpdateDetailsSchema = CreateServerSchema.pick({
1790
1808
  external_id: true,
1791
1809
  name: true,
1792
1810
  user: true,
1793
- description: true
1811
+ description: true,
1812
+ docker_labels: true
1794
1813
  });
1795
1814
  var UpdateBuildSchema = CreateServerSchema.pick({
1796
1815
  oom_killer: true,
@@ -1900,6 +1919,10 @@ var Eggs = class {
1900
1919
  });
1901
1920
  return data;
1902
1921
  };
1922
+ infoExportable = async (id) => {
1923
+ const { data } = await this.r.get(`/eggs/${id}/export`);
1924
+ return data;
1925
+ };
1903
1926
  };
1904
1927
 
1905
1928
  // src/api/application/mounts.ts
@@ -1987,6 +2010,9 @@ var Client2 = class {
1987
2010
  this.eggs = new Eggs(requester);
1988
2011
  this.mounts = new Mounts(requester);
1989
2012
  }
2013
+ get $r() {
2014
+ return this.r;
2015
+ }
1990
2016
  listServers = async (search, page = 1) => {
1991
2017
  const { data } = await this.r.get("/servers", {
1992
2018
  params: { search, page }
package/dist/index.mjs CHANGED
@@ -272,16 +272,16 @@ var ServerUsers = class {
272
272
  const { data } = await this.r.post(`/servers/${this.id}/users`, { email, permissions });
273
273
  return data.attributes;
274
274
  };
275
- info = async (user_id) => {
276
- const { data } = await this.r.get(`/servers/${this.id}/users/${user_id}`);
275
+ info = async (user_uuid) => {
276
+ const { data } = await this.r.get(`/servers/${this.id}/users/${user_uuid}`);
277
277
  return data.attributes;
278
278
  };
279
- update = async (user_id, permissions) => {
280
- const { data } = await this.r.put(`/servers/${this.id}/users/${user_id}`, { permissions });
279
+ update = async (user_uuid, permissions) => {
280
+ const { data } = await this.r.put(`/servers/${this.id}/users/${user_uuid}`, { permissions });
281
281
  return data.attributes;
282
282
  };
283
- delete = async (user_id) => {
284
- await this.r.delete(`/servers/${this.id}/users/${user_id}`);
283
+ delete = async (user_uuid) => {
284
+ await this.r.delete(`/servers/${this.id}/users/${user_uuid}`);
285
285
  };
286
286
  };
287
287
 
@@ -864,13 +864,16 @@ 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;
870
873
  };
871
874
  listServers = async (type = "accessible", page = 1, per_page = 50, include) => {
872
875
  z5.number().positive().parse(page);
873
- const { data } = await this.r.get("/servers", {
876
+ const { data } = await this.r.get("/", {
874
877
  params: { type, page, include: include?.join(",") }
875
878
  });
876
879
  return data.data.map((s) => s.attributes);
@@ -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}/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
+ };
1512
1529
  };
1513
1530
  var CreateSchema = z7.object({
1514
1531
  email: z7.email(),
@@ -1722,10 +1739,11 @@ var CreateServerSchema = z11.object({
1722
1739
  egg: z11.number(),
1723
1740
  docker_image: z11.string().optional(),
1724
1741
  startup: z11.string().optional(),
1725
- environment: z11.array(z11.string()),
1742
+ environment: z11.record(z11.string(), z11.string()),
1726
1743
  skip_scripts: z11.boolean().optional(),
1727
1744
  oom_killer: z11.boolean().optional(),
1728
1745
  start_on_completion: z11.boolean().optional(),
1746
+ docker_labels: z11.record(z11.string(), z11.string()).optional(),
1729
1747
  limits: z11.object({
1730
1748
  memory: z11.number().min(0),
1731
1749
  swap: z11.number().min(-1),
@@ -1753,7 +1771,8 @@ var UpdateDetailsSchema = CreateServerSchema.pick({
1753
1771
  external_id: true,
1754
1772
  name: true,
1755
1773
  user: true,
1756
- description: true
1774
+ description: true,
1775
+ docker_labels: true
1757
1776
  });
1758
1777
  var UpdateBuildSchema = CreateServerSchema.pick({
1759
1778
  oom_killer: true,
@@ -1863,6 +1882,10 @@ var Eggs = class {
1863
1882
  });
1864
1883
  return data;
1865
1884
  };
1885
+ infoExportable = async (id) => {
1886
+ const { data } = await this.r.get(`/eggs/${id}/export`);
1887
+ return data;
1888
+ };
1866
1889
  };
1867
1890
 
1868
1891
  // src/api/application/mounts.ts
@@ -1950,6 +1973,9 @@ var Client2 = class {
1950
1973
  this.eggs = new Eggs(requester);
1951
1974
  this.mounts = new Mounts(requester);
1952
1975
  }
1976
+ get $r() {
1977
+ return this.r;
1978
+ }
1953
1979
  listServers = async (search, page = 1) => {
1954
1980
  const { data } = await this.r.get("/servers", {
1955
1981
  params: { search, page }
package/dist/types.d.ts CHANGED
@@ -716,6 +716,7 @@ type ApplicationServer = {
716
716
  name: string;
717
717
  description: string;
718
718
  status: Nullable<unknown>;
719
+ docker_labels: Record<string, string>;
719
720
  suspended: boolean;
720
721
  limits: ServerLimits;
721
722
  feature_limits: FeatureLimits;
@@ -848,7 +849,7 @@ type Egg = {
848
849
  description: string;
849
850
  features: string[];
850
851
  tags: string[];
851
- docker_image: string;
852
+ docker_image: Nullable<string>;
852
853
  docker_images: Record<string, string>;
853
854
  config: {
854
855
  files: Record<string, FileConfig>;
@@ -874,6 +875,38 @@ type FileConfig = {
874
875
  parser: string;
875
876
  find: Record<string, string>;
876
877
  };
878
+ type ApplicationEggVariable = Omit<EggVariable, "server_value" | "is_editable" | "rules"> & {
879
+ rules: string[];
880
+ sort: number;
881
+ user_viewable: boolean;
882
+ user_editable: boolean;
883
+ };
884
+ type ExportedEgg = {
885
+ meta: {
886
+ version: "PLCN_v3";
887
+ update_url: Nullable<string>;
888
+ };
889
+ exported_at: string;
890
+ name: number;
891
+ author: string;
892
+ description: string;
893
+ uuid: string;
894
+ image: Nullable<string>;
895
+ docker_images: Record<string, string>;
896
+ features: string[];
897
+ tags: string[];
898
+ file_denylist: string[];
899
+ startup_commands: Record<string, string>;
900
+ config: Omit<Egg["config"], "extends" | "file_denylist">;
901
+ scripts: {
902
+ installation: {
903
+ script: string;
904
+ container: string;
905
+ entrypoint: string;
906
+ };
907
+ };
908
+ variables: ApplicationEggVariable[];
909
+ };
877
910
 
878
911
  type ApplicationUser = {
879
912
  id: number;
@@ -891,6 +924,19 @@ type ApplicationUser = {
891
924
  servers: GenericListResponse<GenericResponse<ApplicationServer>>;
892
925
  };
893
926
  };
927
+ type ApplicationUserApiKey = {
928
+ id: number;
929
+ user_id: number;
930
+ key_type: 1;
931
+ identifier: string;
932
+ memo: string;
933
+ allowed_ips: Array<string>;
934
+ permissions: [];
935
+ last_used_at: Nullable<string>;
936
+ expires_at: Nullable<string>;
937
+ created_at: string;
938
+ updated_at: string;
939
+ };
894
940
 
895
941
  type ServerStatus = 'starting' | 'stopping' | 'online' | 'offline';
896
942
  declare enum SERVER_SIGNAL {
@@ -1118,4 +1164,4 @@ type Permission = {
1118
1164
  keys: Record<string, string>;
1119
1165
  };
1120
1166
 
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 };
1167
+ export { type APIKey, type Allocation, type AllocationRel, type ApplicationEggVariable, 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 ExportedEgg, 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",
3
+ "version": "0.3.4-next.1",
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"
@@ -20,9 +20,18 @@
20
20
  "build:types": "tsup src/types.ts --dts-only --target esnext",
21
21
  "build": "rm -rf ./dist && npm run build:code && npm run build:types",
22
22
  "pub": "npm publish --access=public",
23
- "generate-types": "bun run scripts/create-types.ts"
23
+ "pub:next": "npm publish --access=public --tag=next",
24
+ "generate-types": "bun run scripts/create-types.ts",
25
+ "pipeline": "bun run generate-types && bun run build && bun run pub:next"
24
26
  },
25
- "keywords": ["pterodactyl", "pterodactyl.ts", "pterodactyl.js", "pelican", "pelican.ts", "pelican.js"],
27
+ "keywords": [
28
+ "pterodactyl",
29
+ "pterodactyl.ts",
30
+ "pterodactyl.js",
31
+ "pelican",
32
+ "pelican.ts",
33
+ "pelican.js"
34
+ ],
26
35
  "author": "M41den",
27
36
  "license": "MIT",
28
37
  "repository": {
@@ -30,6 +30,10 @@ export class Client {
30
30
  this.mounts = new Mounts(requester)
31
31
  }
32
32
 
33
+ get $r(): AxiosInstance {
34
+ return this.r
35
+ }
36
+
33
37
  listServers = async (
34
38
  search?: string,
35
39
  page: number = 1
@@ -1,6 +1,6 @@
1
1
  import {AxiosInstance} from "axios";
2
2
  import {GenericListResponse, GenericResponse} from "@/api/base/types";
3
- import {Egg} from "@/api/application/types/egg";
3
+ import {Egg, ExportedEgg} from "@/api/application/types/egg";
4
4
 
5
5
  // TODO: API is incomplete
6
6
 
@@ -28,4 +28,9 @@ export class Eggs {
28
28
  })
29
29
  return data
30
30
  }
31
+
32
+ infoExportable = async (id: number): Promise<ExportedEgg> => {
33
+ const {data} = await this.r.get<ExportedEgg>(`/eggs/${id}/export`)
34
+ return data
35
+ }
31
36
  }
@@ -80,10 +80,11 @@ export const CreateServerSchema = z.object({
80
80
  egg: z.number(),
81
81
  docker_image: z.string().optional(),
82
82
  startup: z.string().optional(),
83
- environment: z.array(z.string()),
83
+ environment: z.record(z.string(), z.string()),
84
84
  skip_scripts: z.boolean().optional(),
85
85
  oom_killer: z.boolean().optional(),
86
86
  start_on_completion: z.boolean().optional(),
87
+ docker_labels: z.record(z.string(), z.string()).optional(),
87
88
  limits: z.object({
88
89
  memory: z.number().min(0),
89
90
  swap: z.number().min(-1),
@@ -112,7 +113,8 @@ const UpdateDetailsSchema = CreateServerSchema.pick({
112
113
  external_id: true,
113
114
  name: true,
114
115
  user: true,
115
- description: true
116
+ description: true,
117
+ docker_labels: true
116
118
  })
117
119
 
118
120
  const UpdateBuildSchema = CreateServerSchema.pick({
@@ -1,4 +1,5 @@
1
1
  import {Nullable} from "@/utils/types";
2
+ import {EggVariable} from "@/api/common/types";
2
3
 
3
4
  export type Egg = {
4
5
  id: number,
@@ -8,7 +9,7 @@ export type Egg = {
8
9
  description: string,
9
10
  features: string[],
10
11
  tags: string[],
11
- docker_image: string,
12
+ docker_image: Nullable<string>,
12
13
  docker_images: Record<string, string>,
13
14
  config: {
14
15
  files: Record<string, FileConfig>
@@ -34,4 +35,38 @@ export type Egg = {
34
35
  type FileConfig = {
35
36
  parser: string,
36
37
  find: Record<string, string>
38
+ }
39
+
40
+ export type ApplicationEggVariable = Omit<EggVariable, "server_value" | "is_editable" | "rules"> & {
41
+ rules: string[],
42
+ sort: number,
43
+ user_viewable: boolean,
44
+ user_editable: boolean,
45
+ }
46
+
47
+ export type ExportedEgg = {
48
+ meta: {
49
+ version: "PLCN_v3",
50
+ update_url: Nullable<string>
51
+ },
52
+ exported_at: string,
53
+ name: number,
54
+ author: string,
55
+ description: string,
56
+ uuid: string,
57
+ image: Nullable<string>
58
+ docker_images: Record<string, string>,
59
+ features: string[],
60
+ tags: string[],
61
+ file_denylist: string[],
62
+ startup_commands: Record<string, string>,
63
+ config: Omit<Egg["config"], "extends" | "file_denylist">
64
+ scripts: {
65
+ installation: {
66
+ script: string,
67
+ container: string,
68
+ entrypoint: string
69
+ }
70
+ },
71
+ variables: ApplicationEggVariable[]
37
72
  }
@@ -11,6 +11,7 @@ export type ApplicationServer = {
11
11
  name: string,
12
12
  description: string,
13
13
  status: Nullable<unknown>,
14
+ docker_labels: Record<string, string>,
14
15
  suspended: boolean,
15
16
  limits: ServerLimits,
16
17
  feature_limits: FeatureLimits,
@@ -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 = {
@@ -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">
@@ -34,7 +38,7 @@ export class Client {
34
38
  z.number().positive().parse(page)
35
39
  const {data} = await this.r.get<
36
40
  GenericListResponse<GenericResponse<Server, "server">>
37
- >("/servers", {
41
+ >("/", {
38
42
  params: {type, page, include: include?.join(",")}
39
43
  })
40
44
  return data.data.map(s => s.attributes)
@@ -25,22 +25,22 @@ export class ServerUsers {
25
25
  return data.attributes
26
26
  }
27
27
 
28
- info = async (user_id: number): Promise<ServerSubuser> => {
28
+ info = async (user_uuid: string): Promise<ServerSubuser> => {
29
29
  const {data} = await this.r.get<
30
30
  GenericResponse<ServerSubuser, "user">
31
- >(`/servers/${this.id}/users/${user_id}`)
31
+ >(`/servers/${this.id}/users/${user_uuid}`)
32
32
  return data.attributes
33
33
  }
34
34
 
35
- update = async (user_id: number, permissions: SubuserPermission[] | string[]): Promise<ServerSubuser> => {
35
+ update = async (user_uuid: string, permissions: SubuserPermission[] | string[]): Promise<ServerSubuser> => {
36
36
  const {data} = await this.r.put<
37
37
  GenericResponse<ServerSubuser, "user">
38
- >(`/servers/${this.id}/users/${user_id}`, {permissions})
38
+ >(`/servers/${this.id}/users/${user_uuid}`, {permissions})
39
39
  return data.attributes
40
40
  }
41
41
 
42
- delete = async (user_id: number): Promise<void> => {
43
- await this.r.delete(`/servers/${this.id}/users/${user_id}`)
42
+ delete = async (user_uuid: string): Promise<void> => {
43
+ await this.r.delete(`/servers/${this.id}/users/${user_uuid}`)
44
44
  }
45
45
 
46
46
  }
@@ -5,7 +5,6 @@ export type ExactlyOneKey<K extends keyof any, V, KK extends keyof any = K> =
5
5
  { [Q in keyof O]: O[Q] } : never
6
6
  }[K];
7
7
 
8
- export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
9
8
  export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
10
9
 
11
10