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