@pelican.ts/sdk 0.3.4-next.4 → 0.4.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/.husky/pre-commit +3 -0
- package/README.md +1 -5
- package/biome.json +36 -0
- package/bun.lock +24 -1
- package/dist/api/index.d.mts +1641 -0
- package/dist/api/index.d.ts +1641 -0
- package/dist/api/index.js +2100 -0
- package/dist/api/index.mjs +2062 -0
- package/dist/index.d.mts +607 -1415
- package/dist/index.d.ts +607 -1415
- package/dist/index.js +569 -444
- package/dist/index.mjs +559 -442
- package/dist/types.d.ts +10 -10
- package/package.json +60 -49
- package/src/api/client/types/server.ts +64 -51
- package/src/api/client/types/user.ts +18 -19
- package/src/api/client/types/websocket.ts +76 -76
- package/src/api/index.ts +17 -0
- package/src/humane/Account.ts +73 -0
- package/src/humane/Client.ts +44 -0
- package/src/humane/Server.ts +206 -0
- package/src/humane/ServerAllocation.ts +41 -0
- package/src/humane/ServerBackup.ts +37 -0
- package/src/humane/ServerDatabase.ts +37 -0
- package/src/humane/ServerFile.ts +88 -0
- package/src/humane/ServerSchedule.ts +160 -0
- package/src/humane/ServerUser.ts +44 -0
- package/src/index.ts +18 -14
- package/src/utils/sized.ts +3 -6
package/dist/index.mjs
CHANGED
|
@@ -103,29 +103,29 @@ var ServerFiles = class {
|
|
|
103
103
|
this.r = requester;
|
|
104
104
|
this.id = id;
|
|
105
105
|
}
|
|
106
|
-
list = async (
|
|
106
|
+
list = async (path2) => {
|
|
107
107
|
const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
|
|
108
|
-
params: { directory:
|
|
108
|
+
params: { directory: path2 }
|
|
109
109
|
});
|
|
110
110
|
return data.data.map((r) => r.attributes);
|
|
111
111
|
};
|
|
112
112
|
/**
|
|
113
113
|
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
114
114
|
*/
|
|
115
|
-
contents = async (
|
|
115
|
+
contents = async (path2) => {
|
|
116
116
|
const { data } = await this.r.get(`/servers/${this.id}/files/contents`, {
|
|
117
|
-
params: { file:
|
|
117
|
+
params: { file: path2 }
|
|
118
118
|
});
|
|
119
119
|
return data;
|
|
120
120
|
};
|
|
121
|
-
downloadGetUrl = async (
|
|
121
|
+
downloadGetUrl = async (path2) => {
|
|
122
122
|
const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
|
|
123
|
-
params: { file:
|
|
123
|
+
params: { file: path2 }
|
|
124
124
|
});
|
|
125
125
|
return data.attributes.url;
|
|
126
126
|
};
|
|
127
|
-
download = async (
|
|
128
|
-
const url = await this.downloadGetUrl(
|
|
127
|
+
download = async (path2) => {
|
|
128
|
+
const url = await this.downloadGetUrl(path2);
|
|
129
129
|
const { data } = await axios.get(url, { responseType: "arraybuffer" });
|
|
130
130
|
return data;
|
|
131
131
|
};
|
|
@@ -135,9 +135,9 @@ var ServerFiles = class {
|
|
|
135
135
|
copy = async (location) => {
|
|
136
136
|
await this.r.post(`/servers/${this.id}/files/copy`, { location });
|
|
137
137
|
};
|
|
138
|
-
write = async (
|
|
138
|
+
write = async (path2, content) => {
|
|
139
139
|
await this.r.post(`/servers/${this.id}/files/write`, content, {
|
|
140
|
-
params: { file:
|
|
140
|
+
params: { file: path2 }
|
|
141
141
|
});
|
|
142
142
|
};
|
|
143
143
|
compress = async (root = "/", files, archive_name, extension) => {
|
|
@@ -884,21 +884,6 @@ var Client = class {
|
|
|
884
884
|
// src/api/application/users.ts
|
|
885
885
|
import z7 from "zod";
|
|
886
886
|
|
|
887
|
-
// src/utils/transform.ts
|
|
888
|
-
var ArrayQueryParams = (p) => {
|
|
889
|
-
const params = new URLSearchParams();
|
|
890
|
-
const o = {};
|
|
891
|
-
for (const [param, value] of Object.entries(p)) {
|
|
892
|
-
for (const [key, val] of Object.entries(value)) {
|
|
893
|
-
o[`${param}[${key}]`] = val;
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
return o;
|
|
897
|
-
};
|
|
898
|
-
var SortParam = (key, p) => {
|
|
899
|
-
return `${p === "desc" ? "-" : ""}${key}`;
|
|
900
|
-
};
|
|
901
|
-
|
|
902
887
|
// src/api/common/types/enums.ts
|
|
903
888
|
import z6 from "zod";
|
|
904
889
|
var languagesSchema = z6.enum([
|
|
@@ -1460,73 +1445,6 @@ var timezonesSchema = z6.enum([
|
|
|
1460
1445
|
]);
|
|
1461
1446
|
|
|
1462
1447
|
// src/api/application/users.ts
|
|
1463
|
-
var Users = class {
|
|
1464
|
-
r;
|
|
1465
|
-
constructor(requester) {
|
|
1466
|
-
this.r = requester;
|
|
1467
|
-
}
|
|
1468
|
-
list = async (opts, page = 1) => {
|
|
1469
|
-
z7.number().positive().parse(page);
|
|
1470
|
-
const { data } = await this.r.get("/users", {
|
|
1471
|
-
params: {
|
|
1472
|
-
include: opts.include?.join(","),
|
|
1473
|
-
page,
|
|
1474
|
-
...ArrayQueryParams({ filters: opts.filters || {} }),
|
|
1475
|
-
sort: opts.sort?.id ? SortParam("id", opts.sort?.id) : SortParam("uuid", opts.sort?.uuid)
|
|
1476
|
-
}
|
|
1477
|
-
});
|
|
1478
|
-
return data.data.map((d) => d.attributes);
|
|
1479
|
-
};
|
|
1480
|
-
info = async (id, { include }) => {
|
|
1481
|
-
z7.number().positive().parse(id);
|
|
1482
|
-
const { data } = await this.r.get(`/users/${id}`, {
|
|
1483
|
-
params: { include: include?.join(",") }
|
|
1484
|
-
});
|
|
1485
|
-
return data.attributes;
|
|
1486
|
-
};
|
|
1487
|
-
infoByExternal = async (external_id, { include }) => {
|
|
1488
|
-
const { data } = await this.r.get(`/users/external/${external_id}`, {
|
|
1489
|
-
params: { include: include?.join(",") }
|
|
1490
|
-
});
|
|
1491
|
-
return data.attributes;
|
|
1492
|
-
};
|
|
1493
|
-
create = async (user) => {
|
|
1494
|
-
user = CreateSchema.parse(user);
|
|
1495
|
-
const { data } = await this.r.post("/users", user);
|
|
1496
|
-
return data.attributes;
|
|
1497
|
-
};
|
|
1498
|
-
update = async (id, user) => {
|
|
1499
|
-
user = CreateSchema.parse(user);
|
|
1500
|
-
const { data } = await this.r.patch(`/users/${id}`, user);
|
|
1501
|
-
return data.attributes;
|
|
1502
|
-
};
|
|
1503
|
-
delete = async (id) => {
|
|
1504
|
-
z7.number().positive().parse(id);
|
|
1505
|
-
await this.r.delete(`/users/${id}`);
|
|
1506
|
-
};
|
|
1507
|
-
addRoles = async (id, roles) => {
|
|
1508
|
-
z7.number().positive().parse(id);
|
|
1509
|
-
await this.r.patch(`/users/${id}/roles/assign`, { roles });
|
|
1510
|
-
};
|
|
1511
|
-
removeRoles = async (id, roles) => {
|
|
1512
|
-
z7.number().positive().parse(id);
|
|
1513
|
-
await this.r.patch(`/users/${id}/roles/remove`, { roles });
|
|
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
|
-
};
|
|
1529
|
-
};
|
|
1530
1448
|
var CreateSchema = z7.object({
|
|
1531
1449
|
email: z7.email(),
|
|
1532
1450
|
external_id: z7.string().max(255).optional(),
|
|
@@ -1538,92 +1456,9 @@ var CreateSchema = z7.object({
|
|
|
1538
1456
|
|
|
1539
1457
|
// src/api/application/nodes_allocations.ts
|
|
1540
1458
|
import z8 from "zod";
|
|
1541
|
-
var NodesAllocations = class {
|
|
1542
|
-
r;
|
|
1543
|
-
id;
|
|
1544
|
-
constructor(requester, id) {
|
|
1545
|
-
this.r = requester;
|
|
1546
|
-
this.id = id;
|
|
1547
|
-
}
|
|
1548
|
-
list = async (include) => {
|
|
1549
|
-
const { data } = await this.r.get(`/nodes/${this.id}/allocations`, {
|
|
1550
|
-
params: { include: include?.join(",") }
|
|
1551
|
-
});
|
|
1552
|
-
return data.data.map((d) => d.attributes);
|
|
1553
|
-
};
|
|
1554
|
-
create = async (ip, ports, alias) => {
|
|
1555
|
-
z8.ipv4().parse(ip);
|
|
1556
|
-
z8.ipv4().or(z8.url().max(255)).optional().parse(alias);
|
|
1557
|
-
z8.array(z8.number()).or(z8.string().regex(/\d+-\d+/)).parse(ports);
|
|
1558
|
-
await this.r.post(`/nodes/${this.id}/allocations`, {
|
|
1559
|
-
ip,
|
|
1560
|
-
ports,
|
|
1561
|
-
alias
|
|
1562
|
-
});
|
|
1563
|
-
};
|
|
1564
|
-
delete = async (alloc_id) => {
|
|
1565
|
-
await this.r.delete(`/nodes/${this.id}/allocations/${alloc_id}`);
|
|
1566
|
-
};
|
|
1567
|
-
};
|
|
1568
1459
|
|
|
1569
1460
|
// src/api/application/nodes.ts
|
|
1570
1461
|
import z9 from "zod";
|
|
1571
|
-
var Nodes = class {
|
|
1572
|
-
r;
|
|
1573
|
-
constructor(requester) {
|
|
1574
|
-
this.r = requester;
|
|
1575
|
-
}
|
|
1576
|
-
list = async (include, page = 1) => {
|
|
1577
|
-
z9.number().positive().parse(page);
|
|
1578
|
-
const { data } = await this.r.get("/nodes", {
|
|
1579
|
-
params: { include: include?.join(","), page }
|
|
1580
|
-
});
|
|
1581
|
-
return data.data.map((s) => s.attributes);
|
|
1582
|
-
};
|
|
1583
|
-
listDeployable = async (filters, include, page = 1) => {
|
|
1584
|
-
z9.number().positive().parse(page);
|
|
1585
|
-
const { data } = await this.r.get("/nodes/deployable", {
|
|
1586
|
-
params: {
|
|
1587
|
-
include: include?.join(","),
|
|
1588
|
-
disk: filters.disk,
|
|
1589
|
-
memory: filters.memory,
|
|
1590
|
-
cpu: filters.cpu,
|
|
1591
|
-
location_ids: filters.location_ids,
|
|
1592
|
-
tags: filters.tags,
|
|
1593
|
-
page
|
|
1594
|
-
}
|
|
1595
|
-
});
|
|
1596
|
-
return data.data.map((s) => s.attributes);
|
|
1597
|
-
};
|
|
1598
|
-
info = async (id, include) => {
|
|
1599
|
-
z9.number().positive().parse(id);
|
|
1600
|
-
const { data } = await this.r.get(`/nodes/${id}`, {
|
|
1601
|
-
params: { include: include?.join(",") }
|
|
1602
|
-
});
|
|
1603
|
-
return data.attributes;
|
|
1604
|
-
};
|
|
1605
|
-
create = async (node) => {
|
|
1606
|
-
node = NodeCreateSchema.parse(node);
|
|
1607
|
-
const { data } = await this.r.post("/nodes", node);
|
|
1608
|
-
return data.attributes;
|
|
1609
|
-
};
|
|
1610
|
-
get_configuration = async (id) => {
|
|
1611
|
-
z9.number().positive().parse(id);
|
|
1612
|
-
const { data } = await this.r.get(`/nodes/${id}/configuration`);
|
|
1613
|
-
return data;
|
|
1614
|
-
};
|
|
1615
|
-
update = async (id, node) => {
|
|
1616
|
-
z9.number().positive().parse(id);
|
|
1617
|
-
node = NodeCreateSchema.parse(node);
|
|
1618
|
-
const { data } = await this.r.patch(`/nodes/${id}`, node);
|
|
1619
|
-
return data.attributes;
|
|
1620
|
-
};
|
|
1621
|
-
delete = async (id) => {
|
|
1622
|
-
z9.number().positive().parse(id);
|
|
1623
|
-
await this.r.delete(`/nodes/${id}`);
|
|
1624
|
-
};
|
|
1625
|
-
allocations = (server_id) => new NodesAllocations(this.r, server_id);
|
|
1626
|
-
};
|
|
1627
1462
|
var NodeCreateSchema = z9.object({
|
|
1628
1463
|
name: z9.string().min(1).max(100),
|
|
1629
1464
|
description: z9.string().optional(),
|
|
@@ -1652,85 +1487,8 @@ import z11 from "zod";
|
|
|
1652
1487
|
|
|
1653
1488
|
// src/api/application/servers_databases.ts
|
|
1654
1489
|
import z10 from "zod";
|
|
1655
|
-
var ServersDatabases = class {
|
|
1656
|
-
r;
|
|
1657
|
-
id;
|
|
1658
|
-
constructor(r, server_id) {
|
|
1659
|
-
this.r = r;
|
|
1660
|
-
this.id = server_id;
|
|
1661
|
-
}
|
|
1662
|
-
list = async () => {
|
|
1663
|
-
const { data } = await this.r.get(`/servers/${this.id}/databases`);
|
|
1664
|
-
return data.data.map((d) => d.attributes);
|
|
1665
|
-
};
|
|
1666
|
-
create = async (database, remote, host) => {
|
|
1667
|
-
database = z10.string().min(1).max(48).parse(database);
|
|
1668
|
-
const { data } = await this.r.post(`/servers/${this.id}/databases`, { database, remote, host });
|
|
1669
|
-
return data.attributes;
|
|
1670
|
-
};
|
|
1671
|
-
info = async (database_id) => {
|
|
1672
|
-
const { data } = await this.r.get(`/servers/${this.id}/databases/${database_id}`);
|
|
1673
|
-
return data.attributes;
|
|
1674
|
-
};
|
|
1675
|
-
delete = async (database_id) => {
|
|
1676
|
-
await this.r.delete(`/servers/${this.id}/databases/${database_id}`);
|
|
1677
|
-
};
|
|
1678
|
-
resetPassword = async (database_id) => {
|
|
1679
|
-
await this.r.post(`/servers/${this.id}/databases/${database_id}/reset-password`);
|
|
1680
|
-
};
|
|
1681
|
-
};
|
|
1682
1490
|
|
|
1683
1491
|
// src/api/application/servers.ts
|
|
1684
|
-
var Servers = class {
|
|
1685
|
-
r;
|
|
1686
|
-
id;
|
|
1687
|
-
databases;
|
|
1688
|
-
constructor(r, server_id) {
|
|
1689
|
-
this.r = r;
|
|
1690
|
-
this.id = server_id;
|
|
1691
|
-
this.databases = new ServersDatabases(this.r, this.id);
|
|
1692
|
-
}
|
|
1693
|
-
info = async (include) => {
|
|
1694
|
-
const { data } = await this.r.get(`/servers/${this.id}`, {
|
|
1695
|
-
params: { include: include?.join(",") }
|
|
1696
|
-
});
|
|
1697
|
-
return data.attributes;
|
|
1698
|
-
};
|
|
1699
|
-
delete = async (force = false) => {
|
|
1700
|
-
await this.r.delete(`/servers/${this.id}${force ? "/force" : ""}`);
|
|
1701
|
-
};
|
|
1702
|
-
updateDetails = async (opts) => {
|
|
1703
|
-
opts = UpdateDetailsSchema.parse(opts);
|
|
1704
|
-
await this.r.patch(`/servers/${this.id}/details`, opts);
|
|
1705
|
-
};
|
|
1706
|
-
updateBuild = async (opts) => {
|
|
1707
|
-
opts = UpdateBuildSchema.parse(opts);
|
|
1708
|
-
await this.r.patch(`/servers/${this.id}/build`, opts);
|
|
1709
|
-
};
|
|
1710
|
-
updateStartup = async (opts) => {
|
|
1711
|
-
opts = UpdateStartupSchema.parse(opts);
|
|
1712
|
-
await this.r.patch(`/servers/${this.id}/startup`, opts);
|
|
1713
|
-
};
|
|
1714
|
-
suspend = async () => {
|
|
1715
|
-
await this.r.post(`/servers/${this.id}/suspend`);
|
|
1716
|
-
};
|
|
1717
|
-
unsuspend = async () => {
|
|
1718
|
-
await this.r.post(`/servers/${this.id}/unsuspend`);
|
|
1719
|
-
};
|
|
1720
|
-
reinstall = async () => {
|
|
1721
|
-
await this.r.post(`/servers/${this.id}/reinstall`);
|
|
1722
|
-
};
|
|
1723
|
-
transferStart = async (node_id, allocation_id, allocation_additional) => {
|
|
1724
|
-
await this.r.post(`/servers/${this.id}/transfer`, {
|
|
1725
|
-
node_id,
|
|
1726
|
-
allocation_id,
|
|
1727
|
-
allocation_additional
|
|
1728
|
-
});
|
|
1729
|
-
};
|
|
1730
|
-
transferCancel = async () => {
|
|
1731
|
-
await this.r.post(`/servers/${this.id}/transfer/cancel`);
|
|
1732
|
-
};
|
|
1733
|
-
};
|
|
1734
1492
|
var CreateServerSchema = z11.object({
|
|
1735
1493
|
external_id: z11.string().min(1).max(255).optional(),
|
|
1736
1494
|
name: z11.string().min(1).max(255),
|
|
@@ -1794,36 +1552,6 @@ var UpdateStartupSchema = CreateServerSchema.pick({
|
|
|
1794
1552
|
|
|
1795
1553
|
// src/api/application/database_hosts.ts
|
|
1796
1554
|
import z12 from "zod";
|
|
1797
|
-
var DatabaseHosts = class {
|
|
1798
|
-
r;
|
|
1799
|
-
constructor(r) {
|
|
1800
|
-
this.r = r;
|
|
1801
|
-
}
|
|
1802
|
-
list = async (page = 1) => {
|
|
1803
|
-
const { data } = await this.r.get("/database-hosts", {
|
|
1804
|
-
params: { page }
|
|
1805
|
-
});
|
|
1806
|
-
return data.data.map((d) => d.attributes);
|
|
1807
|
-
};
|
|
1808
|
-
info = async (id) => {
|
|
1809
|
-
const { data } = await this.r.get(`/database-hosts/${id}`);
|
|
1810
|
-
return data.attributes;
|
|
1811
|
-
};
|
|
1812
|
-
// TODO: find out why API returns 500
|
|
1813
|
-
create = async (opts) => {
|
|
1814
|
-
opts = CreateDBHostSchema.parse(opts);
|
|
1815
|
-
await this.r.post("/database-hosts", opts).catch((e) => {
|
|
1816
|
-
});
|
|
1817
|
-
};
|
|
1818
|
-
update = async (id, opts) => {
|
|
1819
|
-
opts = CreateDBHostSchema.parse(opts);
|
|
1820
|
-
const { data } = await this.r.patch(`/database-hosts/${id}`, opts);
|
|
1821
|
-
return data.attributes;
|
|
1822
|
-
};
|
|
1823
|
-
delete = async (id) => {
|
|
1824
|
-
await this.r.delete(`/database-hosts/${id}`);
|
|
1825
|
-
};
|
|
1826
|
-
};
|
|
1827
1555
|
var CreateDBHostSchema = z12.object({
|
|
1828
1556
|
name: z12.string().min(1).max(255),
|
|
1829
1557
|
host: z12.string(),
|
|
@@ -1834,119 +1562,8 @@ var CreateDBHostSchema = z12.object({
|
|
|
1834
1562
|
max_databases: z12.number().optional()
|
|
1835
1563
|
});
|
|
1836
1564
|
|
|
1837
|
-
// src/api/application/roles.ts
|
|
1838
|
-
var Roles = class {
|
|
1839
|
-
r;
|
|
1840
|
-
constructor(r) {
|
|
1841
|
-
this.r = r;
|
|
1842
|
-
}
|
|
1843
|
-
list = async (page = 1) => {
|
|
1844
|
-
const { data } = await this.r.get(`/roles`, {
|
|
1845
|
-
params: { page }
|
|
1846
|
-
});
|
|
1847
|
-
return data.data.map((r) => r.attributes);
|
|
1848
|
-
};
|
|
1849
|
-
info = async (id) => {
|
|
1850
|
-
const { data } = await this.r.get(`/roles/${id}`);
|
|
1851
|
-
return data.attributes;
|
|
1852
|
-
};
|
|
1853
|
-
create = async (opts) => {
|
|
1854
|
-
await this.r.post(`/roles`, opts);
|
|
1855
|
-
};
|
|
1856
|
-
update = async (id, opts) => {
|
|
1857
|
-
await this.r.patch(`/roles/${id}`, opts);
|
|
1858
|
-
};
|
|
1859
|
-
delete = async (id) => {
|
|
1860
|
-
await this.r.delete(`/roles/${id}`);
|
|
1861
|
-
};
|
|
1862
|
-
};
|
|
1863
|
-
|
|
1864
|
-
// src/api/application/eggs.ts
|
|
1865
|
-
var Eggs = class {
|
|
1866
|
-
r;
|
|
1867
|
-
constructor(r) {
|
|
1868
|
-
this.r = r;
|
|
1869
|
-
}
|
|
1870
|
-
list = async () => {
|
|
1871
|
-
const { data } = await this.r.get("/eggs");
|
|
1872
|
-
return data.data.map((d) => d.attributes);
|
|
1873
|
-
};
|
|
1874
|
-
info = async (id) => {
|
|
1875
|
-
const { data } = await this.r.get(`/eggs/${id}`);
|
|
1876
|
-
return data.attributes;
|
|
1877
|
-
};
|
|
1878
|
-
export = async (id, format) => {
|
|
1879
|
-
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1880
|
-
params: { format },
|
|
1881
|
-
transformResponse: (r) => r
|
|
1882
|
-
});
|
|
1883
|
-
return data;
|
|
1884
|
-
};
|
|
1885
|
-
infoExportable = async (id) => {
|
|
1886
|
-
const { data } = await this.r.get(`/eggs/${id}/export`, { params: { format: "json" } });
|
|
1887
|
-
return data;
|
|
1888
|
-
};
|
|
1889
|
-
};
|
|
1890
|
-
|
|
1891
1565
|
// src/api/application/mounts.ts
|
|
1892
1566
|
import z13 from "zod";
|
|
1893
|
-
var Mounts = class {
|
|
1894
|
-
r;
|
|
1895
|
-
constructor(r) {
|
|
1896
|
-
this.r = r;
|
|
1897
|
-
}
|
|
1898
|
-
list = async () => {
|
|
1899
|
-
const { data } = await this.r.get("/mounts");
|
|
1900
|
-
return data.data.map((d) => d.attributes);
|
|
1901
|
-
};
|
|
1902
|
-
info = async (id) => {
|
|
1903
|
-
const { data } = await this.r.get(`/mounts/${id}`);
|
|
1904
|
-
return data.attributes;
|
|
1905
|
-
};
|
|
1906
|
-
create = async (opts) => {
|
|
1907
|
-
opts = CreateMountSchema.parse(opts);
|
|
1908
|
-
const { data } = await this.r.post("/mounts", opts);
|
|
1909
|
-
return data.attributes;
|
|
1910
|
-
};
|
|
1911
|
-
update = async (id, opts) => {
|
|
1912
|
-
opts = CreateMountSchema.parse(opts);
|
|
1913
|
-
const { data } = await this.r.patch(`/mounts/${id}`, opts);
|
|
1914
|
-
return data.attributes;
|
|
1915
|
-
};
|
|
1916
|
-
delete = async (id) => {
|
|
1917
|
-
await this.r.delete(`/mounts/${id}`);
|
|
1918
|
-
};
|
|
1919
|
-
listAssignedEggs = async (id) => {
|
|
1920
|
-
const { data } = await this.r.get(`/mounts/${id}/eggs`);
|
|
1921
|
-
return data.data.map((d) => d.attributes);
|
|
1922
|
-
};
|
|
1923
|
-
assignEggs = async (id, eggs) => {
|
|
1924
|
-
await this.r.post(`/mounts/${id}/eggs`, { eggs });
|
|
1925
|
-
};
|
|
1926
|
-
unassignEgg = async (id, egg_id) => {
|
|
1927
|
-
await this.r.delete(`/mounts/${id}/eggs/${egg_id}`);
|
|
1928
|
-
};
|
|
1929
|
-
listAssignedNodes = async (id) => {
|
|
1930
|
-
const { data } = await this.r.get(`/mounts/${id}/nodes`);
|
|
1931
|
-
return data.data.map((d) => d.attributes);
|
|
1932
|
-
};
|
|
1933
|
-
assignNodes = async (id, nodes) => {
|
|
1934
|
-
await this.r.post(`/mounts/${id}/nodes`, { nodes });
|
|
1935
|
-
};
|
|
1936
|
-
unassignNode = async (id, node_id) => {
|
|
1937
|
-
await this.r.delete(`/mounts/${id}/nodes/${node_id}`);
|
|
1938
|
-
};
|
|
1939
|
-
listAssignedServers = async (id) => {
|
|
1940
|
-
const { data } = await this.r.get(`/mounts/${id}/servers`);
|
|
1941
|
-
return data.data.map((d) => d.attributes);
|
|
1942
|
-
};
|
|
1943
|
-
assignServers = async (id, servers) => {
|
|
1944
|
-
await this.r.post(`/mounts/${id}/servers`, { servers });
|
|
1945
|
-
};
|
|
1946
|
-
unassignServer = async (id, server_id) => {
|
|
1947
|
-
await this.r.delete(`/mounts/${id}/servers/${server_id}`);
|
|
1948
|
-
};
|
|
1949
|
-
};
|
|
1950
1567
|
var CreateMountSchema = z13.object({
|
|
1951
1568
|
name: z13.string().min(1).max(255),
|
|
1952
1569
|
description: z13.string().optional(),
|
|
@@ -1955,47 +1572,6 @@ var CreateMountSchema = z13.object({
|
|
|
1955
1572
|
read_only: z13.boolean().optional()
|
|
1956
1573
|
});
|
|
1957
1574
|
|
|
1958
|
-
// src/api/application/client.ts
|
|
1959
|
-
var Client2 = class {
|
|
1960
|
-
r;
|
|
1961
|
-
users;
|
|
1962
|
-
nodes;
|
|
1963
|
-
databaseHosts;
|
|
1964
|
-
roles;
|
|
1965
|
-
eggs;
|
|
1966
|
-
mounts;
|
|
1967
|
-
constructor(requester) {
|
|
1968
|
-
this.r = requester;
|
|
1969
|
-
this.users = new Users(requester);
|
|
1970
|
-
this.nodes = new Nodes(requester);
|
|
1971
|
-
this.databaseHosts = new DatabaseHosts(requester);
|
|
1972
|
-
this.roles = new Roles(requester);
|
|
1973
|
-
this.eggs = new Eggs(requester);
|
|
1974
|
-
this.mounts = new Mounts(requester);
|
|
1975
|
-
}
|
|
1976
|
-
get $r() {
|
|
1977
|
-
return this.r;
|
|
1978
|
-
}
|
|
1979
|
-
listServers = async (search, page = 1) => {
|
|
1980
|
-
const { data } = await this.r.get("/servers", {
|
|
1981
|
-
params: { search, page }
|
|
1982
|
-
});
|
|
1983
|
-
return data.data.map((s) => s.attributes);
|
|
1984
|
-
};
|
|
1985
|
-
createServer = async (opts) => {
|
|
1986
|
-
opts = CreateServerSchema.parse(opts);
|
|
1987
|
-
const { data } = await this.r.post("/servers", opts);
|
|
1988
|
-
return data.attributes;
|
|
1989
|
-
};
|
|
1990
|
-
getServerByExternalId = async (external_id, include) => {
|
|
1991
|
-
const { data } = await this.r.get(`/servers/external/${external_id}`, {
|
|
1992
|
-
params: { include: include?.join(",") }
|
|
1993
|
-
});
|
|
1994
|
-
return data.attributes;
|
|
1995
|
-
};
|
|
1996
|
-
servers = (server_id) => new Servers(this.r, server_id);
|
|
1997
|
-
};
|
|
1998
|
-
|
|
1999
1575
|
// src/api/base/request.ts
|
|
2000
1576
|
import z14 from "zod";
|
|
2001
1577
|
import axios3 from "axios";
|
|
@@ -2039,22 +1615,563 @@ var Agent = class {
|
|
|
2039
1615
|
}
|
|
2040
1616
|
};
|
|
2041
1617
|
|
|
2042
|
-
// src/index.ts
|
|
2043
|
-
var
|
|
1618
|
+
// src/api/index.ts
|
|
1619
|
+
var PelicanAPIClient = class extends Client {
|
|
2044
1620
|
constructor(url, token, suffix = "/api") {
|
|
2045
1621
|
const ax = new Agent(url, token, "client", suffix);
|
|
2046
1622
|
super(ax.requester);
|
|
2047
1623
|
}
|
|
2048
1624
|
};
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
1625
|
+
|
|
1626
|
+
// src/humane/Account.ts
|
|
1627
|
+
var Account2 = class {
|
|
1628
|
+
client;
|
|
1629
|
+
uuid;
|
|
1630
|
+
username;
|
|
1631
|
+
$email;
|
|
1632
|
+
get email() {
|
|
1633
|
+
return this.$email;
|
|
1634
|
+
}
|
|
1635
|
+
language;
|
|
1636
|
+
image;
|
|
1637
|
+
admin;
|
|
1638
|
+
root_admin;
|
|
1639
|
+
$has2faEnabled;
|
|
1640
|
+
get has2faEnabled() {
|
|
1641
|
+
return this.$has2faEnabled;
|
|
1642
|
+
}
|
|
1643
|
+
createdAt;
|
|
1644
|
+
updatedAt;
|
|
1645
|
+
constructor(client, user) {
|
|
1646
|
+
this.client = client;
|
|
1647
|
+
this.uuid = user.uuid;
|
|
1648
|
+
this.username = user.username;
|
|
1649
|
+
this.$email = user.email;
|
|
1650
|
+
this.language = user.language;
|
|
1651
|
+
this.image = user.image;
|
|
1652
|
+
this.admin = user.admin;
|
|
1653
|
+
this.root_admin = user.root_admin;
|
|
1654
|
+
this.$has2faEnabled = user["2fa_enabled"];
|
|
1655
|
+
this.createdAt = new Date(user.created_at);
|
|
1656
|
+
this.updatedAt = new Date(user.updated_at);
|
|
1657
|
+
}
|
|
1658
|
+
updateEmail = async (newEmail, password) => {
|
|
1659
|
+
await this.client.account.updateEmail(newEmail, password);
|
|
1660
|
+
this.$email = newEmail;
|
|
1661
|
+
};
|
|
1662
|
+
updatePassword = async (newPassword) => this.client.account.updatePassword(newPassword);
|
|
1663
|
+
listApiKeys = async () => this.client.account.apiKeys.list();
|
|
1664
|
+
createApiKey = async (description, allowed_ips) => this.client.account.apiKeys.create(description, allowed_ips);
|
|
1665
|
+
deleteApiKey = async (identifier) => this.client.account.apiKeys.delete(identifier);
|
|
1666
|
+
listSshKeys = async () => this.client.account.sshKeys.list();
|
|
1667
|
+
createSshKey = async (name, public_key) => this.client.account.sshKeys.create(name, public_key);
|
|
1668
|
+
deleteSshKey = async (fingerprint) => this.client.account.sshKeys.delete(fingerprint);
|
|
1669
|
+
get2faQR = async () => this.client.account.twoFactor.info();
|
|
1670
|
+
enable2fa = async (code) => {
|
|
1671
|
+
const tokens = await this.client.account.twoFactor.enable(code);
|
|
1672
|
+
this.$has2faEnabled = true;
|
|
1673
|
+
return tokens;
|
|
1674
|
+
};
|
|
1675
|
+
disable2fa = async (password) => {
|
|
1676
|
+
await this.client.account.twoFactor.disable(password);
|
|
1677
|
+
this.$has2faEnabled = false;
|
|
1678
|
+
};
|
|
1679
|
+
};
|
|
1680
|
+
|
|
1681
|
+
// src/humane/ServerAllocation.ts
|
|
1682
|
+
var ServerAllocation = class {
|
|
1683
|
+
client;
|
|
1684
|
+
alias;
|
|
1685
|
+
id;
|
|
1686
|
+
ip;
|
|
1687
|
+
$isDefault;
|
|
1688
|
+
get isDefault() {
|
|
1689
|
+
return this.$isDefault;
|
|
1690
|
+
}
|
|
1691
|
+
$notes;
|
|
1692
|
+
get notes() {
|
|
1693
|
+
return this.$notes;
|
|
1694
|
+
}
|
|
1695
|
+
port;
|
|
1696
|
+
constructor(client, alloc) {
|
|
1697
|
+
this.client = client;
|
|
1698
|
+
this.alias = alloc.alias;
|
|
1699
|
+
this.id = alloc.id;
|
|
1700
|
+
this.ip = alloc.ip;
|
|
1701
|
+
this.$isDefault = alloc.is_default;
|
|
1702
|
+
this.$notes = alloc.notes;
|
|
1703
|
+
this.port = alloc.port;
|
|
1704
|
+
}
|
|
1705
|
+
setNotes = async (notes) => {
|
|
1706
|
+
const data = await this.client.allocations.setNotes(this.id, notes);
|
|
1707
|
+
this.$notes = data.notes;
|
|
1708
|
+
};
|
|
1709
|
+
makeDefault = async () => {
|
|
1710
|
+
const data = await this.client.allocations.setPrimary(this.id);
|
|
1711
|
+
this.$isDefault = data.is_default;
|
|
1712
|
+
};
|
|
1713
|
+
unassign = async () => this.client.allocations.unassign(this.id);
|
|
1714
|
+
};
|
|
1715
|
+
|
|
1716
|
+
// src/humane/ServerBackup.ts
|
|
1717
|
+
var ServerBackup = class {
|
|
1718
|
+
client;
|
|
1719
|
+
bytes;
|
|
1720
|
+
checksum;
|
|
1721
|
+
completedAt;
|
|
1722
|
+
createdAt;
|
|
1723
|
+
ignoredFiles;
|
|
1724
|
+
isLocked;
|
|
1725
|
+
isSuccessful;
|
|
1726
|
+
name;
|
|
1727
|
+
uuid;
|
|
1728
|
+
constructor(client, backup) {
|
|
1729
|
+
this.client = client;
|
|
1730
|
+
this.bytes = backup.bytes;
|
|
1731
|
+
this.checksum = backup.checksum;
|
|
1732
|
+
this.completedAt = backup.completed_at ? new Date(backup.completed_at) : null;
|
|
1733
|
+
this.createdAt = new Date(backup.created_at);
|
|
1734
|
+
this.ignoredFiles = backup.ignored_files;
|
|
1735
|
+
this.isLocked = backup.is_locked;
|
|
1736
|
+
this.isSuccessful = backup.is_successful;
|
|
1737
|
+
this.name = backup.name;
|
|
1738
|
+
this.uuid = backup.uuid;
|
|
1739
|
+
}
|
|
1740
|
+
downloadGetUrl = async () => this.client.backups.downloadGetUrl(this.uuid);
|
|
1741
|
+
download = async () => this.client.backups.download(this.uuid);
|
|
1742
|
+
delete = async () => this.client.backups.delete(this.uuid);
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1745
|
+
// src/humane/ServerDatabase.ts
|
|
1746
|
+
var ServerDatabase = class {
|
|
1747
|
+
client;
|
|
1748
|
+
allowConnectionsFrom;
|
|
1749
|
+
host;
|
|
1750
|
+
port;
|
|
1751
|
+
id;
|
|
1752
|
+
maxConnections;
|
|
1753
|
+
name;
|
|
1754
|
+
$password;
|
|
1755
|
+
get password() {
|
|
1756
|
+
return this.$password;
|
|
1757
|
+
}
|
|
1758
|
+
username;
|
|
1759
|
+
constructor(client, database) {
|
|
1760
|
+
this.client = client;
|
|
1761
|
+
this.allowConnectionsFrom = database.connections_from;
|
|
1762
|
+
this.host = database.host.address;
|
|
1763
|
+
this.port = database.host.port;
|
|
1764
|
+
this.id = database.id;
|
|
1765
|
+
this.maxConnections = database.max_connections;
|
|
1766
|
+
this.name = database.name;
|
|
1767
|
+
this.$password = database.relationships?.password.attributes.password;
|
|
1768
|
+
this.username = database.username;
|
|
1769
|
+
}
|
|
1770
|
+
rotatePassword = async () => {
|
|
1771
|
+
const data = await this.client.databases.rotatePassword(this.id);
|
|
1772
|
+
this.$password = data.relationships?.password.attributes.password;
|
|
1773
|
+
};
|
|
1774
|
+
delete = async () => this.client.databases.delete(this.id);
|
|
1775
|
+
};
|
|
1776
|
+
|
|
1777
|
+
// src/humane/ServerFile.ts
|
|
1778
|
+
import path from "path";
|
|
1779
|
+
var ServerFile = class {
|
|
1780
|
+
client;
|
|
1781
|
+
dir;
|
|
1782
|
+
path;
|
|
1783
|
+
createdAt;
|
|
1784
|
+
isFile;
|
|
1785
|
+
isSymlink;
|
|
1786
|
+
mimetype;
|
|
1787
|
+
mode;
|
|
1788
|
+
modeBits;
|
|
1789
|
+
modifiedAt;
|
|
1790
|
+
name;
|
|
1791
|
+
size;
|
|
1792
|
+
constructor(client, file, dir = "/") {
|
|
1793
|
+
this.client = client;
|
|
1794
|
+
this.dir = dir;
|
|
1795
|
+
this.createdAt = new Date(file.created_at);
|
|
1796
|
+
this.isFile = file.is_file;
|
|
1797
|
+
this.isSymlink = file.is_symlink;
|
|
1798
|
+
this.mimetype = file.mimetype;
|
|
1799
|
+
this.mode = file.mode;
|
|
1800
|
+
this.modeBits = file.mode_bits;
|
|
1801
|
+
this.modifiedAt = new Date(file.modified_at);
|
|
1802
|
+
this.name = file.name;
|
|
1803
|
+
this.size = file.size;
|
|
1804
|
+
this.path = path.join(dir, this.name);
|
|
1805
|
+
}
|
|
1806
|
+
get isArchive() {
|
|
1807
|
+
return [
|
|
1808
|
+
"zip",
|
|
1809
|
+
"tgz",
|
|
1810
|
+
"tar.gz",
|
|
1811
|
+
"txz",
|
|
1812
|
+
"tar.xz",
|
|
1813
|
+
"tbz2",
|
|
1814
|
+
"tar.bz2"
|
|
1815
|
+
].some((ext) => this.name.endsWith(`.${ext}`));
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
1819
|
+
*/
|
|
1820
|
+
contents = async () => this.client.files.contents(this.path);
|
|
1821
|
+
downloadGetUrl = async () => this.client.files.downloadGetUrl(this.path);
|
|
1822
|
+
download = async () => this.client.files.download(this.path);
|
|
1823
|
+
rename = async (newName) => this.client.files.rename(this.dir, [{ from: this.name, to: newName }]);
|
|
1824
|
+
copy = async () => this.client.files.copy(this.path);
|
|
1825
|
+
write = async (content) => this.client.files.write(this.path, content);
|
|
1826
|
+
compress = async (archive_name, extension) => this.client.files.compress(
|
|
1827
|
+
this.dir,
|
|
1828
|
+
[this.name],
|
|
1829
|
+
archive_name,
|
|
1830
|
+
extension
|
|
1831
|
+
);
|
|
1832
|
+
decompress = async () => this.client.files.decompress(this.dir, this.name);
|
|
1833
|
+
delete = async () => this.client.files.delete(this.dir, [this.name]);
|
|
1834
|
+
chmod = async (mode) => this.client.files.chmod(this.dir, [{ file: this.name, mode }]);
|
|
1835
|
+
};
|
|
1836
|
+
|
|
1837
|
+
// src/humane/ServerSchedule.ts
|
|
1838
|
+
var ServerSchedule = class {
|
|
1839
|
+
client;
|
|
1840
|
+
createdAt;
|
|
1841
|
+
$cron;
|
|
1842
|
+
get cron() {
|
|
1843
|
+
return { ...this.$cron };
|
|
1844
|
+
}
|
|
1845
|
+
id;
|
|
1846
|
+
$isActive;
|
|
1847
|
+
get isActive() {
|
|
1848
|
+
return this.$isActive;
|
|
1849
|
+
}
|
|
1850
|
+
$isProcessing;
|
|
1851
|
+
get isProcessing() {
|
|
1852
|
+
return this.$isProcessing;
|
|
1853
|
+
}
|
|
1854
|
+
lastRunAt;
|
|
1855
|
+
$name;
|
|
1856
|
+
get name() {
|
|
1857
|
+
return this.$name;
|
|
1858
|
+
}
|
|
1859
|
+
nextRunAt;
|
|
1860
|
+
$onlyWhenOnline;
|
|
1861
|
+
get onlyWhenOnline() {
|
|
1862
|
+
return this.$onlyWhenOnline;
|
|
1863
|
+
}
|
|
1864
|
+
tasks;
|
|
1865
|
+
$updatedAt;
|
|
1866
|
+
get updatedAt() {
|
|
1867
|
+
return this.$updatedAt;
|
|
1868
|
+
}
|
|
1869
|
+
constructor(client, schedule) {
|
|
1870
|
+
this.client = client;
|
|
1871
|
+
this.createdAt = new Date(schedule.created_at);
|
|
1872
|
+
this.$cron = schedule.cron;
|
|
1873
|
+
this.id = schedule.id;
|
|
1874
|
+
this.$isActive = schedule.is_active;
|
|
1875
|
+
this.$isProcessing = schedule.is_processing;
|
|
1876
|
+
this.lastRunAt = schedule.last_run_at ? new Date(schedule.last_run_at) : null;
|
|
1877
|
+
this.$name = schedule.name;
|
|
1878
|
+
this.nextRunAt = new Date(schedule.next_run_at);
|
|
1879
|
+
this.$onlyWhenOnline = schedule.only_when_online;
|
|
1880
|
+
this.tasks = schedule.relationships.tasks.data.map(
|
|
1881
|
+
(d) => new ServerScheduleTask(this.client, this.id, d.attributes)
|
|
1882
|
+
);
|
|
1883
|
+
this.$updatedAt = new Date(schedule.updated_at);
|
|
1884
|
+
}
|
|
1885
|
+
update = async (opts) => {
|
|
1886
|
+
const data = await this.client.schedules.control(this.id).update(opts);
|
|
1887
|
+
this.$name = data.name;
|
|
1888
|
+
this.$isActive = data.is_active;
|
|
1889
|
+
this.$isProcessing = data.is_processing;
|
|
1890
|
+
this.$onlyWhenOnline = data.only_when_online;
|
|
1891
|
+
this.$cron = data.cron;
|
|
1892
|
+
this.$updatedAt = new Date(data.updated_at);
|
|
1893
|
+
};
|
|
1894
|
+
delete = async () => this.client.schedules.control(this.id).delete();
|
|
1895
|
+
execute = async () => this.client.schedules.control(this.id).execute();
|
|
1896
|
+
};
|
|
1897
|
+
var ServerScheduleTask = class {
|
|
1898
|
+
client;
|
|
1899
|
+
scheduleId;
|
|
1900
|
+
$action;
|
|
1901
|
+
get action() {
|
|
1902
|
+
return this.$action;
|
|
2053
1903
|
}
|
|
1904
|
+
$continueOnFailure;
|
|
1905
|
+
get continueOnFailure() {
|
|
1906
|
+
return this.$continueOnFailure;
|
|
1907
|
+
}
|
|
1908
|
+
createdAt;
|
|
1909
|
+
id;
|
|
1910
|
+
$isQueued;
|
|
1911
|
+
get isQueued() {
|
|
1912
|
+
return this.$isQueued;
|
|
1913
|
+
}
|
|
1914
|
+
$payload;
|
|
1915
|
+
get payload() {
|
|
1916
|
+
return this.$payload;
|
|
1917
|
+
}
|
|
1918
|
+
$sequenceId;
|
|
1919
|
+
get sequenceId() {
|
|
1920
|
+
return this.$sequenceId;
|
|
1921
|
+
}
|
|
1922
|
+
$timeOffset;
|
|
1923
|
+
get timeOffset() {
|
|
1924
|
+
return this.$timeOffset;
|
|
1925
|
+
}
|
|
1926
|
+
$updatedAt;
|
|
1927
|
+
get updatedAt() {
|
|
1928
|
+
return this.$updatedAt;
|
|
1929
|
+
}
|
|
1930
|
+
constructor(client, scheduleId, task) {
|
|
1931
|
+
this.client = client;
|
|
1932
|
+
this.scheduleId = scheduleId;
|
|
1933
|
+
this.$action = task.action;
|
|
1934
|
+
this.$continueOnFailure = task.continue_on_failure;
|
|
1935
|
+
this.createdAt = new Date(task.created_at);
|
|
1936
|
+
this.id = task.id;
|
|
1937
|
+
this.$isQueued = task.is_queued;
|
|
1938
|
+
this.$payload = task.payload;
|
|
1939
|
+
this.$sequenceId = task.sequence_id;
|
|
1940
|
+
this.$timeOffset = task.time_offset;
|
|
1941
|
+
this.$updatedAt = task.updated_at ? new Date(task.updated_at) : null;
|
|
1942
|
+
}
|
|
1943
|
+
delete = async () => this.client.schedules.control(this.scheduleId).tasks.delete(this.id);
|
|
1944
|
+
update = async (opts) => {
|
|
1945
|
+
const data = await this.client.schedules.control(this.scheduleId).tasks.update(this.id, opts);
|
|
1946
|
+
this.$action = data.action;
|
|
1947
|
+
this.$continueOnFailure = data.continue_on_failure;
|
|
1948
|
+
this.$isQueued = data.is_queued;
|
|
1949
|
+
this.$payload = data.payload;
|
|
1950
|
+
this.$sequenceId = data.sequence_id;
|
|
1951
|
+
this.$timeOffset = data.time_offset;
|
|
1952
|
+
this.$updatedAt = data.updated_at ? new Date(data.updated_at) : null;
|
|
1953
|
+
};
|
|
1954
|
+
};
|
|
1955
|
+
|
|
1956
|
+
// src/humane/ServerUser.ts
|
|
1957
|
+
var ServerUser = class {
|
|
1958
|
+
client;
|
|
1959
|
+
uuid;
|
|
1960
|
+
username;
|
|
1961
|
+
email;
|
|
1962
|
+
language;
|
|
1963
|
+
image;
|
|
1964
|
+
admin;
|
|
1965
|
+
root_admin;
|
|
1966
|
+
has2faEnabled;
|
|
1967
|
+
createdAt;
|
|
1968
|
+
$permissions;
|
|
1969
|
+
get permissions() {
|
|
1970
|
+
return this.$permissions;
|
|
1971
|
+
}
|
|
1972
|
+
constructor(client, user) {
|
|
1973
|
+
this.client = client;
|
|
1974
|
+
this.uuid = user.uuid;
|
|
1975
|
+
this.username = user.username;
|
|
1976
|
+
this.email = user.email;
|
|
1977
|
+
this.language = user.language;
|
|
1978
|
+
this.image = user.image;
|
|
1979
|
+
this.admin = user.admin;
|
|
1980
|
+
this.root_admin = user.root_admin;
|
|
1981
|
+
this.has2faEnabled = user["2fa_enabled"];
|
|
1982
|
+
this.createdAt = new Date(user.created_at);
|
|
1983
|
+
this.$permissions = user.permissions;
|
|
1984
|
+
}
|
|
1985
|
+
update = async (permissions) => {
|
|
1986
|
+
const data = await this.client.users.update(this.uuid, permissions);
|
|
1987
|
+
this.$permissions = data.permissions;
|
|
1988
|
+
};
|
|
1989
|
+
delete = async () => this.client.users.delete(this.uuid);
|
|
1990
|
+
};
|
|
1991
|
+
|
|
1992
|
+
// src/humane/Server.ts
|
|
1993
|
+
var Server = class {
|
|
1994
|
+
client;
|
|
1995
|
+
ownsServer;
|
|
1996
|
+
identifier;
|
|
1997
|
+
internalId;
|
|
1998
|
+
uuid;
|
|
1999
|
+
$name;
|
|
2000
|
+
get name() {
|
|
2001
|
+
return this.$name;
|
|
2002
|
+
}
|
|
2003
|
+
node;
|
|
2004
|
+
isNodeUnderMaintenance;
|
|
2005
|
+
sftp;
|
|
2006
|
+
$description;
|
|
2007
|
+
get description() {
|
|
2008
|
+
return this.$description;
|
|
2009
|
+
}
|
|
2010
|
+
limits;
|
|
2011
|
+
invocation;
|
|
2012
|
+
$dockerImage;
|
|
2013
|
+
get dockerImage() {
|
|
2014
|
+
return this.$dockerImage;
|
|
2015
|
+
}
|
|
2016
|
+
eggFeatures;
|
|
2017
|
+
featureLimits;
|
|
2018
|
+
status;
|
|
2019
|
+
isSuspended;
|
|
2020
|
+
isInstalling;
|
|
2021
|
+
isTransferring;
|
|
2022
|
+
allocations;
|
|
2023
|
+
variables;
|
|
2024
|
+
egg;
|
|
2025
|
+
subusers;
|
|
2026
|
+
constructor(client, server) {
|
|
2027
|
+
this.client = client;
|
|
2028
|
+
this.ownsServer = server.server_owner;
|
|
2029
|
+
this.identifier = server.identifier;
|
|
2030
|
+
this.internalId = server.internal_id;
|
|
2031
|
+
this.uuid = server.uuid;
|
|
2032
|
+
this.$name = server.name;
|
|
2033
|
+
this.node = server.node;
|
|
2034
|
+
this.isNodeUnderMaintenance = server.is_node_under_maintenance;
|
|
2035
|
+
this.sftp = server.sftp_details;
|
|
2036
|
+
this.$description = server.description;
|
|
2037
|
+
this.limits = server.limits;
|
|
2038
|
+
this.invocation = server.invocation;
|
|
2039
|
+
this.$dockerImage = server.docker_image;
|
|
2040
|
+
this.eggFeatures = server.egg_features;
|
|
2041
|
+
this.featureLimits = server.feature_limits;
|
|
2042
|
+
this.status = server.status;
|
|
2043
|
+
this.isSuspended = server.is_suspended;
|
|
2044
|
+
this.isInstalling = server.is_installing;
|
|
2045
|
+
this.isTransferring = server.is_transferring;
|
|
2046
|
+
this.allocations = server.relationships.allocations.data.map(
|
|
2047
|
+
(d) => new ServerAllocation(this.client, d.attributes)
|
|
2048
|
+
);
|
|
2049
|
+
this.variables = server.relationships.variables.data.map(
|
|
2050
|
+
(d) => d.attributes
|
|
2051
|
+
);
|
|
2052
|
+
this.egg = server.relationships.egg?.attributes;
|
|
2053
|
+
this.subusers = server.relationships.subusers?.data.map(
|
|
2054
|
+
(d) => new ServerUser(this.client, d.attributes)
|
|
2055
|
+
);
|
|
2056
|
+
}
|
|
2057
|
+
rename = async (name) => {
|
|
2058
|
+
await this.client.settings.rename(name);
|
|
2059
|
+
this.$name = name;
|
|
2060
|
+
};
|
|
2061
|
+
updateDescription = async (description) => {
|
|
2062
|
+
await this.client.settings.updateDescription(description);
|
|
2063
|
+
this.$description = description;
|
|
2064
|
+
};
|
|
2065
|
+
reinstall = async () => this.client.settings.reinstall();
|
|
2066
|
+
changeDockerImage = async (image) => {
|
|
2067
|
+
await this.client.settings.changeDockerImage(image);
|
|
2068
|
+
this.$dockerImage = image;
|
|
2069
|
+
};
|
|
2070
|
+
getActivityLogs = async (opts = { page: 1, per_page: 50 }) => this.client.activity.list(opts.page, opts.per_page);
|
|
2071
|
+
websocket = (stripColors = false) => this.client.websocket(stripColors);
|
|
2072
|
+
getServerStats = async () => this.client.resources();
|
|
2073
|
+
runCommand = async (command) => this.client.command(command);
|
|
2074
|
+
sendPowerSignal = async (signal) => this.client.power(signal);
|
|
2075
|
+
getDatabases = async (opts = {
|
|
2076
|
+
include: [],
|
|
2077
|
+
page: 1
|
|
2078
|
+
}) => {
|
|
2079
|
+
const data = await this.client.databases.list(opts.include, opts.page);
|
|
2080
|
+
return data.map((d) => new ServerDatabase(this.client, d));
|
|
2081
|
+
};
|
|
2082
|
+
createDatabase = async (database, remote) => {
|
|
2083
|
+
const data = await this.client.databases.create(database, remote);
|
|
2084
|
+
return new ServerDatabase(this.client, data);
|
|
2085
|
+
};
|
|
2086
|
+
getSchedules = async () => {
|
|
2087
|
+
const data = await this.client.schedules.list();
|
|
2088
|
+
return data.map((d) => new ServerSchedule(this.client, d));
|
|
2089
|
+
};
|
|
2090
|
+
createSchedule = async (...opts) => {
|
|
2091
|
+
const data = await this.client.schedules.create(...opts);
|
|
2092
|
+
return new ServerSchedule(this.client, data);
|
|
2093
|
+
};
|
|
2094
|
+
getBackups = async (page = 1) => {
|
|
2095
|
+
const data = await this.client.backups.list(page);
|
|
2096
|
+
return data.map((d) => new ServerBackup(this.client, d));
|
|
2097
|
+
};
|
|
2098
|
+
createBackup = async (...args) => {
|
|
2099
|
+
const data = await this.client.backups.create(...args);
|
|
2100
|
+
return new ServerBackup(this.client, data);
|
|
2101
|
+
};
|
|
2102
|
+
getAllocations = async () => {
|
|
2103
|
+
const data = await this.client.allocations.list();
|
|
2104
|
+
return data.map((d) => new ServerAllocation(this.client, d));
|
|
2105
|
+
};
|
|
2106
|
+
createAllocation = async () => {
|
|
2107
|
+
const data = await this.client.allocations.autoAssign();
|
|
2108
|
+
return new ServerAllocation(this.client, data);
|
|
2109
|
+
};
|
|
2110
|
+
getFiles = async (path2) => {
|
|
2111
|
+
const data = await this.client.files.list(path2);
|
|
2112
|
+
return data.map((d) => new ServerFile(this.client, d));
|
|
2113
|
+
};
|
|
2114
|
+
createFolder = async (...opts) => this.client.files.createFolder(...opts);
|
|
2115
|
+
uploadFile = async (...opts) => this.client.files.upload(...opts);
|
|
2116
|
+
uploadFileGetUrl = async (...opts) => this.client.files.uploadGetUrl(...opts);
|
|
2117
|
+
pullFileFromRemote = async (...opts) => this.client.files.pullFromRemote(...opts);
|
|
2118
|
+
getUsers = async () => {
|
|
2119
|
+
const data = await this.client.users.list();
|
|
2120
|
+
return data.map((d) => new ServerUser(this.client, d));
|
|
2121
|
+
};
|
|
2122
|
+
createUser = async (email, permissions) => {
|
|
2123
|
+
const data = await this.client.users.create(email, permissions);
|
|
2124
|
+
return new ServerUser(this.client, data);
|
|
2125
|
+
};
|
|
2126
|
+
getStartupInfo = async () => this.client.startup.list();
|
|
2127
|
+
setStartupVariable = async (key, value) => this.client.startup.set(key, value);
|
|
2128
|
+
};
|
|
2129
|
+
|
|
2130
|
+
// src/humane/Client.ts
|
|
2131
|
+
var Client3 = class {
|
|
2132
|
+
client;
|
|
2133
|
+
constructor(client) {
|
|
2134
|
+
this.client = client;
|
|
2135
|
+
}
|
|
2136
|
+
get $client() {
|
|
2137
|
+
return this.client;
|
|
2138
|
+
}
|
|
2139
|
+
getAccount = async () => {
|
|
2140
|
+
const user = await this.client.account.info();
|
|
2141
|
+
return new Account2(this.client, user);
|
|
2142
|
+
};
|
|
2143
|
+
listPermissions = async () => this.client.listPermissions();
|
|
2144
|
+
listServers = async (opts = { type: "accessible", page: 1, per_page: 50 }) => {
|
|
2145
|
+
const data = await this.client.listServers(
|
|
2146
|
+
opts.type,
|
|
2147
|
+
opts.page,
|
|
2148
|
+
opts.per_page,
|
|
2149
|
+
opts.include
|
|
2150
|
+
);
|
|
2151
|
+
return data.map((d) => new Server(this.client.server(d.uuid), d));
|
|
2152
|
+
};
|
|
2153
|
+
getServer = async (uuid, include) => {
|
|
2154
|
+
const server = await this.client.server(uuid).info(include);
|
|
2155
|
+
return new Server(this.client.server(uuid), server);
|
|
2156
|
+
};
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2159
|
+
// src/index.ts
|
|
2160
|
+
var createPelicanClient = (url, token, suffix = "/api") => {
|
|
2161
|
+
const client = new PelicanAPIClient(url, token, suffix);
|
|
2162
|
+
return new Client3(client);
|
|
2054
2163
|
};
|
|
2055
2164
|
export {
|
|
2056
|
-
|
|
2057
|
-
|
|
2165
|
+
Account2 as Account,
|
|
2166
|
+
Client3 as Client,
|
|
2167
|
+
Server,
|
|
2168
|
+
ServerAllocation,
|
|
2169
|
+
ServerBackup,
|
|
2170
|
+
ServerDatabase,
|
|
2171
|
+
ServerFile,
|
|
2172
|
+
ServerSchedule,
|
|
2173
|
+
ServerUser,
|
|
2174
|
+
createPelicanClient
|
|
2058
2175
|
};
|
|
2059
2176
|
/*
|
|
2060
2177
|
* @author BothimTV
|