@pelican.ts/sdk 0.2.5 → 0.3.0
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/dist/index.d.mts +89 -7
- package/dist/index.d.ts +89 -7
- package/dist/index.js +97 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +47 -1
- package/package.json +1 -1
- 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/README.md
CHANGED
|
@@ -27,15 +27,15 @@ main()
|
|
|
27
27
|
|
|
28
28
|
What's done:
|
|
29
29
|
- [X] Client
|
|
30
|
-
- [
|
|
30
|
+
- [X] Application
|
|
31
31
|
- [X] Users
|
|
32
32
|
- [X] Nodes
|
|
33
33
|
- [X] Servers
|
|
34
34
|
- [X] Databases (TODO: Check if server database type is valid)
|
|
35
35
|
- [X] Database Hosts (TODO: find out why create API returns 500 No Route)
|
|
36
36
|
- [X] Roles
|
|
37
|
-
- [
|
|
38
|
-
- [
|
|
37
|
+
- [X] Eggs
|
|
38
|
+
- [X] Mounts
|
|
39
39
|
- [ ] TSDoc
|
|
40
40
|
- [ ] Examples
|
|
41
41
|
- [ ] Tests
|
package/dist/index.d.mts
CHANGED
|
@@ -1205,7 +1205,7 @@ type Location = {
|
|
|
1205
1205
|
updated_at: string | null;
|
|
1206
1206
|
};
|
|
1207
1207
|
|
|
1208
|
-
type Node = {
|
|
1208
|
+
type Node$1 = {
|
|
1209
1209
|
id: number;
|
|
1210
1210
|
uuid: string;
|
|
1211
1211
|
public: boolean;
|
|
@@ -1276,7 +1276,7 @@ type Allocation = {
|
|
|
1276
1276
|
};
|
|
1277
1277
|
type AllocationRel = Allocation & {
|
|
1278
1278
|
relationships?: {
|
|
1279
|
-
node?: GenericResponse<Node, "node">;
|
|
1279
|
+
node?: GenericResponse<Node$1, "node">;
|
|
1280
1280
|
server?: GenericResponse<ApplicationServer, "server">;
|
|
1281
1281
|
};
|
|
1282
1282
|
};
|
|
@@ -1293,18 +1293,18 @@ declare class NodesAllocations {
|
|
|
1293
1293
|
declare class Nodes {
|
|
1294
1294
|
private readonly r;
|
|
1295
1295
|
constructor(requester: AxiosInstance);
|
|
1296
|
-
list: (include?: ("allocations" | "location" | "servers")[], page?: number) => Promise<Node[]>;
|
|
1296
|
+
list: (include?: ("allocations" | "location" | "servers")[], page?: number) => Promise<Node$1[]>;
|
|
1297
1297
|
listDeployable: (filters: {
|
|
1298
1298
|
disk: number;
|
|
1299
1299
|
memory: number;
|
|
1300
1300
|
cpu?: number;
|
|
1301
1301
|
location_ids?: string[];
|
|
1302
1302
|
tags?: string[];
|
|
1303
|
-
}, include?: ("allocations" | "location" | "servers")[], page?: number) => Promise<Node[]>;
|
|
1304
|
-
info: (id: number, include?: ("allocations" | "location" | "servers")[]) => Promise<Node>;
|
|
1305
|
-
create: (node: z.infer<typeof NodeCreateSchema>) => Promise<Node>;
|
|
1303
|
+
}, include?: ("allocations" | "location" | "servers")[], page?: number) => Promise<Node$1[]>;
|
|
1304
|
+
info: (id: number, include?: ("allocations" | "location" | "servers")[]) => Promise<Node$1>;
|
|
1305
|
+
create: (node: z.infer<typeof NodeCreateSchema>) => Promise<Node$1>;
|
|
1306
1306
|
get_configuration: (id: number) => Promise<NodeConfiguration>;
|
|
1307
|
-
update: (id: number, node: z.infer<typeof NodeCreateSchema>) => Promise<Node>;
|
|
1307
|
+
update: (id: number, node: z.infer<typeof NodeCreateSchema>) => Promise<Node$1>;
|
|
1308
1308
|
delete: (id: number) => Promise<void>;
|
|
1309
1309
|
allocations: (server_id: number) => NodesAllocations;
|
|
1310
1310
|
}
|
|
@@ -1479,12 +1479,94 @@ declare class Roles {
|
|
|
1479
1479
|
delete: (id: number) => Promise<void>;
|
|
1480
1480
|
}
|
|
1481
1481
|
|
|
1482
|
+
type Egg = {
|
|
1483
|
+
id: number;
|
|
1484
|
+
uuid: string;
|
|
1485
|
+
name: number;
|
|
1486
|
+
author: string;
|
|
1487
|
+
description: string;
|
|
1488
|
+
features: string[];
|
|
1489
|
+
tags: string[];
|
|
1490
|
+
docker_image: string;
|
|
1491
|
+
docker_images: Record<string, string>;
|
|
1492
|
+
config: {
|
|
1493
|
+
files: Record<string, FileConfig>;
|
|
1494
|
+
startup: Record<string, string>;
|
|
1495
|
+
stop: string;
|
|
1496
|
+
logs: object | [];
|
|
1497
|
+
file_denylist: string[];
|
|
1498
|
+
extends: Nullable<number>;
|
|
1499
|
+
};
|
|
1500
|
+
startup: string;
|
|
1501
|
+
startup_commands: Record<string, string>;
|
|
1502
|
+
script: {
|
|
1503
|
+
privileged: boolean;
|
|
1504
|
+
install: string;
|
|
1505
|
+
entry: string;
|
|
1506
|
+
container: string;
|
|
1507
|
+
extends: Nullable<number>;
|
|
1508
|
+
};
|
|
1509
|
+
created_at: string;
|
|
1510
|
+
updated_at: Nullable<string>;
|
|
1511
|
+
};
|
|
1512
|
+
type FileConfig = {
|
|
1513
|
+
parser: string;
|
|
1514
|
+
find: Record<string, string>;
|
|
1515
|
+
};
|
|
1516
|
+
|
|
1517
|
+
declare class Eggs {
|
|
1518
|
+
private readonly r;
|
|
1519
|
+
constructor(r: AxiosInstance);
|
|
1520
|
+
list: () => Promise<Egg[]>;
|
|
1521
|
+
info: (id: number) => Promise<Egg>;
|
|
1522
|
+
export: (id: number, format: "json" | "yaml") => Promise<string>;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
type Mount = {
|
|
1526
|
+
id: number;
|
|
1527
|
+
uuid: string;
|
|
1528
|
+
name: string;
|
|
1529
|
+
description: Nullable<string>;
|
|
1530
|
+
source: string;
|
|
1531
|
+
target: string;
|
|
1532
|
+
read_only: boolean;
|
|
1533
|
+
user_mountable: boolean;
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1536
|
+
declare class Mounts {
|
|
1537
|
+
private readonly r;
|
|
1538
|
+
constructor(r: AxiosInstance);
|
|
1539
|
+
list: () => Promise<Mount[]>;
|
|
1540
|
+
info: (id: number) => Promise<Mount>;
|
|
1541
|
+
create: (opts: z.infer<typeof CreateMountSchema>) => Promise<Mount>;
|
|
1542
|
+
update: (id: number, opts: z.infer<typeof CreateMountSchema>) => Promise<Mount>;
|
|
1543
|
+
delete: (id: number) => Promise<void>;
|
|
1544
|
+
listAssignedEggs: (id: number) => Promise<Egg[]>;
|
|
1545
|
+
assignEggs: (id: number, eggs: number[]) => Promise<void>;
|
|
1546
|
+
unassignEgg: (id: number, egg_id: number) => Promise<void>;
|
|
1547
|
+
listAssignedNodes: (id: number) => Promise<Node[]>;
|
|
1548
|
+
assignNodes: (id: number, nodes: number[]) => Promise<void>;
|
|
1549
|
+
unassignNode: (id: number, node_id: number) => Promise<void>;
|
|
1550
|
+
listAssignedServers: (id: number) => Promise<ApplicationServer[]>;
|
|
1551
|
+
assignServers: (id: number, servers: number[]) => Promise<void>;
|
|
1552
|
+
unassignServer: (id: number, server_id: number) => Promise<void>;
|
|
1553
|
+
}
|
|
1554
|
+
declare const CreateMountSchema: z.ZodObject<{
|
|
1555
|
+
name: z.ZodString;
|
|
1556
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1557
|
+
source: z.ZodString;
|
|
1558
|
+
target: z.ZodString;
|
|
1559
|
+
read_only: z.ZodOptional<z.ZodBoolean>;
|
|
1560
|
+
}, z.core.$strip>;
|
|
1561
|
+
|
|
1482
1562
|
declare class Client {
|
|
1483
1563
|
private readonly r;
|
|
1484
1564
|
users: Users;
|
|
1485
1565
|
nodes: Nodes;
|
|
1486
1566
|
databaseHosts: DatabaseHosts;
|
|
1487
1567
|
roles: Roles;
|
|
1568
|
+
eggs: Eggs;
|
|
1569
|
+
mounts: Mounts;
|
|
1488
1570
|
constructor(requester: AxiosInstance);
|
|
1489
1571
|
listServers: (search?: string, page?: number) => Promise<ApplicationServer[]>;
|
|
1490
1572
|
createServer: (opts: z.infer<typeof CreateServerSchema>) => Promise<ApplicationServer>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1205,7 +1205,7 @@ type Location = {
|
|
|
1205
1205
|
updated_at: string | null;
|
|
1206
1206
|
};
|
|
1207
1207
|
|
|
1208
|
-
type Node = {
|
|
1208
|
+
type Node$1 = {
|
|
1209
1209
|
id: number;
|
|
1210
1210
|
uuid: string;
|
|
1211
1211
|
public: boolean;
|
|
@@ -1276,7 +1276,7 @@ type Allocation = {
|
|
|
1276
1276
|
};
|
|
1277
1277
|
type AllocationRel = Allocation & {
|
|
1278
1278
|
relationships?: {
|
|
1279
|
-
node?: GenericResponse<Node, "node">;
|
|
1279
|
+
node?: GenericResponse<Node$1, "node">;
|
|
1280
1280
|
server?: GenericResponse<ApplicationServer, "server">;
|
|
1281
1281
|
};
|
|
1282
1282
|
};
|
|
@@ -1293,18 +1293,18 @@ declare class NodesAllocations {
|
|
|
1293
1293
|
declare class Nodes {
|
|
1294
1294
|
private readonly r;
|
|
1295
1295
|
constructor(requester: AxiosInstance);
|
|
1296
|
-
list: (include?: ("allocations" | "location" | "servers")[], page?: number) => Promise<Node[]>;
|
|
1296
|
+
list: (include?: ("allocations" | "location" | "servers")[], page?: number) => Promise<Node$1[]>;
|
|
1297
1297
|
listDeployable: (filters: {
|
|
1298
1298
|
disk: number;
|
|
1299
1299
|
memory: number;
|
|
1300
1300
|
cpu?: number;
|
|
1301
1301
|
location_ids?: string[];
|
|
1302
1302
|
tags?: string[];
|
|
1303
|
-
}, include?: ("allocations" | "location" | "servers")[], page?: number) => Promise<Node[]>;
|
|
1304
|
-
info: (id: number, include?: ("allocations" | "location" | "servers")[]) => Promise<Node>;
|
|
1305
|
-
create: (node: z.infer<typeof NodeCreateSchema>) => Promise<Node>;
|
|
1303
|
+
}, include?: ("allocations" | "location" | "servers")[], page?: number) => Promise<Node$1[]>;
|
|
1304
|
+
info: (id: number, include?: ("allocations" | "location" | "servers")[]) => Promise<Node$1>;
|
|
1305
|
+
create: (node: z.infer<typeof NodeCreateSchema>) => Promise<Node$1>;
|
|
1306
1306
|
get_configuration: (id: number) => Promise<NodeConfiguration>;
|
|
1307
|
-
update: (id: number, node: z.infer<typeof NodeCreateSchema>) => Promise<Node>;
|
|
1307
|
+
update: (id: number, node: z.infer<typeof NodeCreateSchema>) => Promise<Node$1>;
|
|
1308
1308
|
delete: (id: number) => Promise<void>;
|
|
1309
1309
|
allocations: (server_id: number) => NodesAllocations;
|
|
1310
1310
|
}
|
|
@@ -1479,12 +1479,94 @@ declare class Roles {
|
|
|
1479
1479
|
delete: (id: number) => Promise<void>;
|
|
1480
1480
|
}
|
|
1481
1481
|
|
|
1482
|
+
type Egg = {
|
|
1483
|
+
id: number;
|
|
1484
|
+
uuid: string;
|
|
1485
|
+
name: number;
|
|
1486
|
+
author: string;
|
|
1487
|
+
description: string;
|
|
1488
|
+
features: string[];
|
|
1489
|
+
tags: string[];
|
|
1490
|
+
docker_image: string;
|
|
1491
|
+
docker_images: Record<string, string>;
|
|
1492
|
+
config: {
|
|
1493
|
+
files: Record<string, FileConfig>;
|
|
1494
|
+
startup: Record<string, string>;
|
|
1495
|
+
stop: string;
|
|
1496
|
+
logs: object | [];
|
|
1497
|
+
file_denylist: string[];
|
|
1498
|
+
extends: Nullable<number>;
|
|
1499
|
+
};
|
|
1500
|
+
startup: string;
|
|
1501
|
+
startup_commands: Record<string, string>;
|
|
1502
|
+
script: {
|
|
1503
|
+
privileged: boolean;
|
|
1504
|
+
install: string;
|
|
1505
|
+
entry: string;
|
|
1506
|
+
container: string;
|
|
1507
|
+
extends: Nullable<number>;
|
|
1508
|
+
};
|
|
1509
|
+
created_at: string;
|
|
1510
|
+
updated_at: Nullable<string>;
|
|
1511
|
+
};
|
|
1512
|
+
type FileConfig = {
|
|
1513
|
+
parser: string;
|
|
1514
|
+
find: Record<string, string>;
|
|
1515
|
+
};
|
|
1516
|
+
|
|
1517
|
+
declare class Eggs {
|
|
1518
|
+
private readonly r;
|
|
1519
|
+
constructor(r: AxiosInstance);
|
|
1520
|
+
list: () => Promise<Egg[]>;
|
|
1521
|
+
info: (id: number) => Promise<Egg>;
|
|
1522
|
+
export: (id: number, format: "json" | "yaml") => Promise<string>;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
type Mount = {
|
|
1526
|
+
id: number;
|
|
1527
|
+
uuid: string;
|
|
1528
|
+
name: string;
|
|
1529
|
+
description: Nullable<string>;
|
|
1530
|
+
source: string;
|
|
1531
|
+
target: string;
|
|
1532
|
+
read_only: boolean;
|
|
1533
|
+
user_mountable: boolean;
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1536
|
+
declare class Mounts {
|
|
1537
|
+
private readonly r;
|
|
1538
|
+
constructor(r: AxiosInstance);
|
|
1539
|
+
list: () => Promise<Mount[]>;
|
|
1540
|
+
info: (id: number) => Promise<Mount>;
|
|
1541
|
+
create: (opts: z.infer<typeof CreateMountSchema>) => Promise<Mount>;
|
|
1542
|
+
update: (id: number, opts: z.infer<typeof CreateMountSchema>) => Promise<Mount>;
|
|
1543
|
+
delete: (id: number) => Promise<void>;
|
|
1544
|
+
listAssignedEggs: (id: number) => Promise<Egg[]>;
|
|
1545
|
+
assignEggs: (id: number, eggs: number[]) => Promise<void>;
|
|
1546
|
+
unassignEgg: (id: number, egg_id: number) => Promise<void>;
|
|
1547
|
+
listAssignedNodes: (id: number) => Promise<Node[]>;
|
|
1548
|
+
assignNodes: (id: number, nodes: number[]) => Promise<void>;
|
|
1549
|
+
unassignNode: (id: number, node_id: number) => Promise<void>;
|
|
1550
|
+
listAssignedServers: (id: number) => Promise<ApplicationServer[]>;
|
|
1551
|
+
assignServers: (id: number, servers: number[]) => Promise<void>;
|
|
1552
|
+
unassignServer: (id: number, server_id: number) => Promise<void>;
|
|
1553
|
+
}
|
|
1554
|
+
declare const CreateMountSchema: z.ZodObject<{
|
|
1555
|
+
name: z.ZodString;
|
|
1556
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1557
|
+
source: z.ZodString;
|
|
1558
|
+
target: z.ZodString;
|
|
1559
|
+
read_only: z.ZodOptional<z.ZodBoolean>;
|
|
1560
|
+
}, z.core.$strip>;
|
|
1561
|
+
|
|
1482
1562
|
declare class Client {
|
|
1483
1563
|
private readonly r;
|
|
1484
1564
|
users: Users;
|
|
1485
1565
|
nodes: Nodes;
|
|
1486
1566
|
databaseHosts: DatabaseHosts;
|
|
1487
1567
|
roles: Roles;
|
|
1568
|
+
eggs: Eggs;
|
|
1569
|
+
mounts: Mounts;
|
|
1488
1570
|
constructor(requester: AxiosInstance);
|
|
1489
1571
|
listServers: (search?: string, page?: number) => Promise<ApplicationServer[]>;
|
|
1490
1572
|
createServer: (opts: z.infer<typeof CreateServerSchema>) => Promise<ApplicationServer>;
|
package/dist/index.js
CHANGED
|
@@ -1879,6 +1879,96 @@ var Roles = class {
|
|
|
1879
1879
|
};
|
|
1880
1880
|
};
|
|
1881
1881
|
|
|
1882
|
+
// src/api/application/eggs.ts
|
|
1883
|
+
var Eggs = class {
|
|
1884
|
+
r;
|
|
1885
|
+
constructor(r) {
|
|
1886
|
+
this.r = r;
|
|
1887
|
+
}
|
|
1888
|
+
list = async () => {
|
|
1889
|
+
const { data } = await this.r.get("/eggs");
|
|
1890
|
+
return data.data.map((d) => d.attributes);
|
|
1891
|
+
};
|
|
1892
|
+
info = async (id) => {
|
|
1893
|
+
const { data } = await this.r.get(`/eggs/${id}`);
|
|
1894
|
+
return data.attributes;
|
|
1895
|
+
};
|
|
1896
|
+
export = async (id, format) => {
|
|
1897
|
+
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1898
|
+
params: { format },
|
|
1899
|
+
transformResponse: (r) => r
|
|
1900
|
+
});
|
|
1901
|
+
return data;
|
|
1902
|
+
};
|
|
1903
|
+
};
|
|
1904
|
+
|
|
1905
|
+
// src/api/application/mounts.ts
|
|
1906
|
+
var import_zod13 = __toESM(require("zod"));
|
|
1907
|
+
var Mounts = class {
|
|
1908
|
+
r;
|
|
1909
|
+
constructor(r) {
|
|
1910
|
+
this.r = r;
|
|
1911
|
+
}
|
|
1912
|
+
list = async () => {
|
|
1913
|
+
const { data } = await this.r.get("/mounts");
|
|
1914
|
+
return data.data.map((d) => d.attributes);
|
|
1915
|
+
};
|
|
1916
|
+
info = async (id) => {
|
|
1917
|
+
const { data } = await this.r.get(`/mounts/${id}`);
|
|
1918
|
+
return data.attributes;
|
|
1919
|
+
};
|
|
1920
|
+
create = async (opts) => {
|
|
1921
|
+
opts = CreateMountSchema.parse(opts);
|
|
1922
|
+
const { data } = await this.r.post("/mounts", opts);
|
|
1923
|
+
return data.attributes;
|
|
1924
|
+
};
|
|
1925
|
+
update = async (id, opts) => {
|
|
1926
|
+
opts = CreateMountSchema.parse(opts);
|
|
1927
|
+
const { data } = await this.r.patch(`/mounts/${id}`, opts);
|
|
1928
|
+
return data.attributes;
|
|
1929
|
+
};
|
|
1930
|
+
delete = async (id) => {
|
|
1931
|
+
await this.r.delete(`/mounts/${id}`);
|
|
1932
|
+
};
|
|
1933
|
+
listAssignedEggs = async (id) => {
|
|
1934
|
+
const { data } = await this.r.get(`/mounts/${id}/eggs`);
|
|
1935
|
+
return data.data.map((d) => d.attributes);
|
|
1936
|
+
};
|
|
1937
|
+
assignEggs = async (id, eggs) => {
|
|
1938
|
+
await this.r.post(`/mounts/${id}/eggs`, { eggs });
|
|
1939
|
+
};
|
|
1940
|
+
unassignEgg = async (id, egg_id) => {
|
|
1941
|
+
await this.r.delete(`/mounts/${id}/eggs/${egg_id}`);
|
|
1942
|
+
};
|
|
1943
|
+
listAssignedNodes = async (id) => {
|
|
1944
|
+
const { data } = await this.r.get(`/mounts/${id}/nodes`);
|
|
1945
|
+
return data.data.map((d) => d.attributes);
|
|
1946
|
+
};
|
|
1947
|
+
assignNodes = async (id, nodes) => {
|
|
1948
|
+
await this.r.post(`/mounts/${id}/nodes`, { nodes });
|
|
1949
|
+
};
|
|
1950
|
+
unassignNode = async (id, node_id) => {
|
|
1951
|
+
await this.r.delete(`/mounts/${id}/nodes/${node_id}`);
|
|
1952
|
+
};
|
|
1953
|
+
listAssignedServers = async (id) => {
|
|
1954
|
+
const { data } = await this.r.get(`/mounts/${id}/servers`);
|
|
1955
|
+
return data.data.map((d) => d.attributes);
|
|
1956
|
+
};
|
|
1957
|
+
assignServers = async (id, servers) => {
|
|
1958
|
+
await this.r.post(`/mounts/${id}/servers`, { servers });
|
|
1959
|
+
};
|
|
1960
|
+
unassignServer = async (id, server_id) => {
|
|
1961
|
+
await this.r.delete(`/mounts/${id}/servers/${server_id}`);
|
|
1962
|
+
};
|
|
1963
|
+
};
|
|
1964
|
+
var CreateMountSchema = import_zod13.default.object({
|
|
1965
|
+
name: import_zod13.default.string().min(1).max(255),
|
|
1966
|
+
description: import_zod13.default.string().optional(),
|
|
1967
|
+
source: import_zod13.default.string(),
|
|
1968
|
+
target: import_zod13.default.string(),
|
|
1969
|
+
read_only: import_zod13.default.boolean().optional()
|
|
1970
|
+
});
|
|
1971
|
+
|
|
1882
1972
|
// src/api/application/client.ts
|
|
1883
1973
|
var Client2 = class {
|
|
1884
1974
|
r;
|
|
@@ -1886,12 +1976,16 @@ var Client2 = class {
|
|
|
1886
1976
|
nodes;
|
|
1887
1977
|
databaseHosts;
|
|
1888
1978
|
roles;
|
|
1979
|
+
eggs;
|
|
1980
|
+
mounts;
|
|
1889
1981
|
constructor(requester) {
|
|
1890
1982
|
this.r = requester;
|
|
1891
1983
|
this.users = new Users(requester);
|
|
1892
1984
|
this.nodes = new Nodes(requester);
|
|
1893
1985
|
this.databaseHosts = new DatabaseHosts(requester);
|
|
1894
1986
|
this.roles = new Roles(requester);
|
|
1987
|
+
this.eggs = new Eggs(requester);
|
|
1988
|
+
this.mounts = new Mounts(requester);
|
|
1895
1989
|
}
|
|
1896
1990
|
listServers = async (search, page = 1) => {
|
|
1897
1991
|
const { data } = await this.r.get("/servers", {
|
|
@@ -1914,7 +2008,7 @@ var Client2 = class {
|
|
|
1914
2008
|
};
|
|
1915
2009
|
|
|
1916
2010
|
// src/api/base/request.ts
|
|
1917
|
-
var
|
|
2011
|
+
var import_zod14 = __toESM(require("zod"));
|
|
1918
2012
|
var import_axios3 = __toESM(require("axios"));
|
|
1919
2013
|
|
|
1920
2014
|
// src/api/base/types.ts
|
|
@@ -1934,8 +2028,8 @@ var Agent = class {
|
|
|
1934
2028
|
token;
|
|
1935
2029
|
requester;
|
|
1936
2030
|
constructor(url, token, type, suffix = "/api") {
|
|
1937
|
-
this.base_url =
|
|
1938
|
-
this.token =
|
|
2031
|
+
this.base_url = import_zod14.default.url("Invalid URL Schema").transform((url2) => new URL(url2).href).parse(url);
|
|
2032
|
+
this.token = import_zod14.default.string().regex(/^(ptl[ac]|pacc|papp)_.+$/, "Invalid token type").parse(token);
|
|
1939
2033
|
this.requester = import_axios3.default.create({
|
|
1940
2034
|
baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
|
|
1941
2035
|
timeout: 3e3,
|