@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.js
CHANGED
|
@@ -30,8 +30,16 @@ 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
|
-
|
|
33
|
+
Account: () => Account2,
|
|
34
|
+
Client: () => Client3,
|
|
35
|
+
Server: () => Server,
|
|
36
|
+
ServerAllocation: () => ServerAllocation,
|
|
37
|
+
ServerBackup: () => ServerBackup,
|
|
38
|
+
ServerDatabase: () => ServerDatabase,
|
|
39
|
+
ServerFile: () => ServerFile,
|
|
40
|
+
ServerSchedule: () => ServerSchedule,
|
|
41
|
+
ServerUser: () => ServerUser,
|
|
42
|
+
createPelicanClient: () => createPelicanClient
|
|
35
43
|
});
|
|
36
44
|
module.exports = __toCommonJS(index_exports);
|
|
37
45
|
|
|
@@ -140,29 +148,29 @@ var ServerFiles = class {
|
|
|
140
148
|
this.r = requester;
|
|
141
149
|
this.id = id;
|
|
142
150
|
}
|
|
143
|
-
list = async (
|
|
151
|
+
list = async (path2) => {
|
|
144
152
|
const { data } = await this.r.get(`/servers/${this.id}/files/list`, {
|
|
145
|
-
params: { directory:
|
|
153
|
+
params: { directory: path2 }
|
|
146
154
|
});
|
|
147
155
|
return data.data.map((r) => r.attributes);
|
|
148
156
|
};
|
|
149
157
|
/**
|
|
150
158
|
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
151
159
|
*/
|
|
152
|
-
contents = async (
|
|
160
|
+
contents = async (path2) => {
|
|
153
161
|
const { data } = await this.r.get(`/servers/${this.id}/files/contents`, {
|
|
154
|
-
params: { file:
|
|
162
|
+
params: { file: path2 }
|
|
155
163
|
});
|
|
156
164
|
return data;
|
|
157
165
|
};
|
|
158
|
-
downloadGetUrl = async (
|
|
166
|
+
downloadGetUrl = async (path2) => {
|
|
159
167
|
const { data } = await this.r.get(`/servers/${this.id}/files/download`, {
|
|
160
|
-
params: { file:
|
|
168
|
+
params: { file: path2 }
|
|
161
169
|
});
|
|
162
170
|
return data.attributes.url;
|
|
163
171
|
};
|
|
164
|
-
download = async (
|
|
165
|
-
const url = await this.downloadGetUrl(
|
|
172
|
+
download = async (path2) => {
|
|
173
|
+
const url = await this.downloadGetUrl(path2);
|
|
166
174
|
const { data } = await import_axios.default.get(url, { responseType: "arraybuffer" });
|
|
167
175
|
return data;
|
|
168
176
|
};
|
|
@@ -172,9 +180,9 @@ var ServerFiles = class {
|
|
|
172
180
|
copy = async (location) => {
|
|
173
181
|
await this.r.post(`/servers/${this.id}/files/copy`, { location });
|
|
174
182
|
};
|
|
175
|
-
write = async (
|
|
183
|
+
write = async (path2, content) => {
|
|
176
184
|
await this.r.post(`/servers/${this.id}/files/write`, content, {
|
|
177
|
-
params: { file:
|
|
185
|
+
params: { file: path2 }
|
|
178
186
|
});
|
|
179
187
|
};
|
|
180
188
|
compress = async (root = "/", files, archive_name, extension) => {
|
|
@@ -921,21 +929,6 @@ var Client = class {
|
|
|
921
929
|
// src/api/application/users.ts
|
|
922
930
|
var import_zod7 = __toESM(require("zod"));
|
|
923
931
|
|
|
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
932
|
// src/api/common/types/enums.ts
|
|
940
933
|
var import_zod6 = __toESM(require("zod"));
|
|
941
934
|
var languagesSchema = import_zod6.default.enum([
|
|
@@ -1497,73 +1490,6 @@ var timezonesSchema = import_zod6.default.enum([
|
|
|
1497
1490
|
]);
|
|
1498
1491
|
|
|
1499
1492
|
// 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
1493
|
var CreateSchema = import_zod7.default.object({
|
|
1568
1494
|
email: import_zod7.default.email(),
|
|
1569
1495
|
external_id: import_zod7.default.string().max(255).optional(),
|
|
@@ -1575,92 +1501,9 @@ var CreateSchema = import_zod7.default.object({
|
|
|
1575
1501
|
|
|
1576
1502
|
// src/api/application/nodes_allocations.ts
|
|
1577
1503
|
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
1504
|
|
|
1606
1505
|
// src/api/application/nodes.ts
|
|
1607
1506
|
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
1507
|
var NodeCreateSchema = import_zod9.default.object({
|
|
1665
1508
|
name: import_zod9.default.string().min(1).max(100),
|
|
1666
1509
|
description: import_zod9.default.string().optional(),
|
|
@@ -1689,85 +1532,8 @@ var import_zod11 = __toESM(require("zod"));
|
|
|
1689
1532
|
|
|
1690
1533
|
// src/api/application/servers_databases.ts
|
|
1691
1534
|
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
1535
|
|
|
1720
1536
|
// 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
1537
|
var CreateServerSchema = import_zod11.default.object({
|
|
1772
1538
|
external_id: import_zod11.default.string().min(1).max(255).optional(),
|
|
1773
1539
|
name: import_zod11.default.string().min(1).max(255),
|
|
@@ -1831,36 +1597,6 @@ var UpdateStartupSchema = CreateServerSchema.pick({
|
|
|
1831
1597
|
|
|
1832
1598
|
// src/api/application/database_hosts.ts
|
|
1833
1599
|
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
1600
|
var CreateDBHostSchema = import_zod12.default.object({
|
|
1865
1601
|
name: import_zod12.default.string().min(1).max(255),
|
|
1866
1602
|
host: import_zod12.default.string(),
|
|
@@ -1871,119 +1607,8 @@ var CreateDBHostSchema = import_zod12.default.object({
|
|
|
1871
1607
|
max_databases: import_zod12.default.number().optional()
|
|
1872
1608
|
});
|
|
1873
1609
|
|
|
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
1610
|
// src/api/application/mounts.ts
|
|
1929
1611
|
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
1612
|
var CreateMountSchema = import_zod13.default.object({
|
|
1988
1613
|
name: import_zod13.default.string().min(1).max(255),
|
|
1989
1614
|
description: import_zod13.default.string().optional(),
|
|
@@ -1992,47 +1617,6 @@ var CreateMountSchema = import_zod13.default.object({
|
|
|
1992
1617
|
read_only: import_zod13.default.boolean().optional()
|
|
1993
1618
|
});
|
|
1994
1619
|
|
|
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
1620
|
// src/api/base/request.ts
|
|
2037
1621
|
var import_zod14 = __toESM(require("zod"));
|
|
2038
1622
|
var import_axios3 = __toESM(require("axios"));
|
|
@@ -2076,23 +1660,564 @@ var Agent = class {
|
|
|
2076
1660
|
}
|
|
2077
1661
|
};
|
|
2078
1662
|
|
|
2079
|
-
// src/index.ts
|
|
2080
|
-
var
|
|
1663
|
+
// src/api/index.ts
|
|
1664
|
+
var PelicanAPIClient = class extends Client {
|
|
2081
1665
|
constructor(url, token, suffix = "/api") {
|
|
2082
1666
|
const ax = new Agent(url, token, "client", suffix);
|
|
2083
1667
|
super(ax.requester);
|
|
2084
1668
|
}
|
|
2085
1669
|
};
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
1670
|
+
|
|
1671
|
+
// src/humane/Account.ts
|
|
1672
|
+
var Account2 = class {
|
|
1673
|
+
client;
|
|
1674
|
+
uuid;
|
|
1675
|
+
username;
|
|
1676
|
+
$email;
|
|
1677
|
+
get email() {
|
|
1678
|
+
return this.$email;
|
|
1679
|
+
}
|
|
1680
|
+
language;
|
|
1681
|
+
image;
|
|
1682
|
+
admin;
|
|
1683
|
+
root_admin;
|
|
1684
|
+
$has2faEnabled;
|
|
1685
|
+
get has2faEnabled() {
|
|
1686
|
+
return this.$has2faEnabled;
|
|
1687
|
+
}
|
|
1688
|
+
createdAt;
|
|
1689
|
+
updatedAt;
|
|
1690
|
+
constructor(client, user) {
|
|
1691
|
+
this.client = client;
|
|
1692
|
+
this.uuid = user.uuid;
|
|
1693
|
+
this.username = user.username;
|
|
1694
|
+
this.$email = user.email;
|
|
1695
|
+
this.language = user.language;
|
|
1696
|
+
this.image = user.image;
|
|
1697
|
+
this.admin = user.admin;
|
|
1698
|
+
this.root_admin = user.root_admin;
|
|
1699
|
+
this.$has2faEnabled = user["2fa_enabled"];
|
|
1700
|
+
this.createdAt = new Date(user.created_at);
|
|
1701
|
+
this.updatedAt = new Date(user.updated_at);
|
|
1702
|
+
}
|
|
1703
|
+
updateEmail = async (newEmail, password) => {
|
|
1704
|
+
await this.client.account.updateEmail(newEmail, password);
|
|
1705
|
+
this.$email = newEmail;
|
|
1706
|
+
};
|
|
1707
|
+
updatePassword = async (newPassword) => this.client.account.updatePassword(newPassword);
|
|
1708
|
+
listApiKeys = async () => this.client.account.apiKeys.list();
|
|
1709
|
+
createApiKey = async (description, allowed_ips) => this.client.account.apiKeys.create(description, allowed_ips);
|
|
1710
|
+
deleteApiKey = async (identifier) => this.client.account.apiKeys.delete(identifier);
|
|
1711
|
+
listSshKeys = async () => this.client.account.sshKeys.list();
|
|
1712
|
+
createSshKey = async (name, public_key) => this.client.account.sshKeys.create(name, public_key);
|
|
1713
|
+
deleteSshKey = async (fingerprint) => this.client.account.sshKeys.delete(fingerprint);
|
|
1714
|
+
get2faQR = async () => this.client.account.twoFactor.info();
|
|
1715
|
+
enable2fa = async (code) => {
|
|
1716
|
+
const tokens = await this.client.account.twoFactor.enable(code);
|
|
1717
|
+
this.$has2faEnabled = true;
|
|
1718
|
+
return tokens;
|
|
1719
|
+
};
|
|
1720
|
+
disable2fa = async (password) => {
|
|
1721
|
+
await this.client.account.twoFactor.disable(password);
|
|
1722
|
+
this.$has2faEnabled = false;
|
|
1723
|
+
};
|
|
1724
|
+
};
|
|
1725
|
+
|
|
1726
|
+
// src/humane/ServerAllocation.ts
|
|
1727
|
+
var ServerAllocation = class {
|
|
1728
|
+
client;
|
|
1729
|
+
alias;
|
|
1730
|
+
id;
|
|
1731
|
+
ip;
|
|
1732
|
+
$isDefault;
|
|
1733
|
+
get isDefault() {
|
|
1734
|
+
return this.$isDefault;
|
|
1735
|
+
}
|
|
1736
|
+
$notes;
|
|
1737
|
+
get notes() {
|
|
1738
|
+
return this.$notes;
|
|
1739
|
+
}
|
|
1740
|
+
port;
|
|
1741
|
+
constructor(client, alloc) {
|
|
1742
|
+
this.client = client;
|
|
1743
|
+
this.alias = alloc.alias;
|
|
1744
|
+
this.id = alloc.id;
|
|
1745
|
+
this.ip = alloc.ip;
|
|
1746
|
+
this.$isDefault = alloc.is_default;
|
|
1747
|
+
this.$notes = alloc.notes;
|
|
1748
|
+
this.port = alloc.port;
|
|
1749
|
+
}
|
|
1750
|
+
setNotes = async (notes) => {
|
|
1751
|
+
const data = await this.client.allocations.setNotes(this.id, notes);
|
|
1752
|
+
this.$notes = data.notes;
|
|
1753
|
+
};
|
|
1754
|
+
makeDefault = async () => {
|
|
1755
|
+
const data = await this.client.allocations.setPrimary(this.id);
|
|
1756
|
+
this.$isDefault = data.is_default;
|
|
1757
|
+
};
|
|
1758
|
+
unassign = async () => this.client.allocations.unassign(this.id);
|
|
1759
|
+
};
|
|
1760
|
+
|
|
1761
|
+
// src/humane/ServerBackup.ts
|
|
1762
|
+
var ServerBackup = class {
|
|
1763
|
+
client;
|
|
1764
|
+
bytes;
|
|
1765
|
+
checksum;
|
|
1766
|
+
completedAt;
|
|
1767
|
+
createdAt;
|
|
1768
|
+
ignoredFiles;
|
|
1769
|
+
isLocked;
|
|
1770
|
+
isSuccessful;
|
|
1771
|
+
name;
|
|
1772
|
+
uuid;
|
|
1773
|
+
constructor(client, backup) {
|
|
1774
|
+
this.client = client;
|
|
1775
|
+
this.bytes = backup.bytes;
|
|
1776
|
+
this.checksum = backup.checksum;
|
|
1777
|
+
this.completedAt = backup.completed_at ? new Date(backup.completed_at) : null;
|
|
1778
|
+
this.createdAt = new Date(backup.created_at);
|
|
1779
|
+
this.ignoredFiles = backup.ignored_files;
|
|
1780
|
+
this.isLocked = backup.is_locked;
|
|
1781
|
+
this.isSuccessful = backup.is_successful;
|
|
1782
|
+
this.name = backup.name;
|
|
1783
|
+
this.uuid = backup.uuid;
|
|
1784
|
+
}
|
|
1785
|
+
downloadGetUrl = async () => this.client.backups.downloadGetUrl(this.uuid);
|
|
1786
|
+
download = async () => this.client.backups.download(this.uuid);
|
|
1787
|
+
delete = async () => this.client.backups.delete(this.uuid);
|
|
1788
|
+
};
|
|
1789
|
+
|
|
1790
|
+
// src/humane/ServerDatabase.ts
|
|
1791
|
+
var ServerDatabase = class {
|
|
1792
|
+
client;
|
|
1793
|
+
allowConnectionsFrom;
|
|
1794
|
+
host;
|
|
1795
|
+
port;
|
|
1796
|
+
id;
|
|
1797
|
+
maxConnections;
|
|
1798
|
+
name;
|
|
1799
|
+
$password;
|
|
1800
|
+
get password() {
|
|
1801
|
+
return this.$password;
|
|
1802
|
+
}
|
|
1803
|
+
username;
|
|
1804
|
+
constructor(client, database) {
|
|
1805
|
+
this.client = client;
|
|
1806
|
+
this.allowConnectionsFrom = database.connections_from;
|
|
1807
|
+
this.host = database.host.address;
|
|
1808
|
+
this.port = database.host.port;
|
|
1809
|
+
this.id = database.id;
|
|
1810
|
+
this.maxConnections = database.max_connections;
|
|
1811
|
+
this.name = database.name;
|
|
1812
|
+
this.$password = database.relationships?.password.attributes.password;
|
|
1813
|
+
this.username = database.username;
|
|
1814
|
+
}
|
|
1815
|
+
rotatePassword = async () => {
|
|
1816
|
+
const data = await this.client.databases.rotatePassword(this.id);
|
|
1817
|
+
this.$password = data.relationships?.password.attributes.password;
|
|
1818
|
+
};
|
|
1819
|
+
delete = async () => this.client.databases.delete(this.id);
|
|
1820
|
+
};
|
|
1821
|
+
|
|
1822
|
+
// src/humane/ServerFile.ts
|
|
1823
|
+
var import_node_path = __toESM(require("path"));
|
|
1824
|
+
var ServerFile = class {
|
|
1825
|
+
client;
|
|
1826
|
+
dir;
|
|
1827
|
+
path;
|
|
1828
|
+
createdAt;
|
|
1829
|
+
isFile;
|
|
1830
|
+
isSymlink;
|
|
1831
|
+
mimetype;
|
|
1832
|
+
mode;
|
|
1833
|
+
modeBits;
|
|
1834
|
+
modifiedAt;
|
|
1835
|
+
name;
|
|
1836
|
+
size;
|
|
1837
|
+
constructor(client, file, dir = "/") {
|
|
1838
|
+
this.client = client;
|
|
1839
|
+
this.dir = dir;
|
|
1840
|
+
this.createdAt = new Date(file.created_at);
|
|
1841
|
+
this.isFile = file.is_file;
|
|
1842
|
+
this.isSymlink = file.is_symlink;
|
|
1843
|
+
this.mimetype = file.mimetype;
|
|
1844
|
+
this.mode = file.mode;
|
|
1845
|
+
this.modeBits = file.mode_bits;
|
|
1846
|
+
this.modifiedAt = new Date(file.modified_at);
|
|
1847
|
+
this.name = file.name;
|
|
1848
|
+
this.size = file.size;
|
|
1849
|
+
this.path = import_node_path.default.join(dir, this.name);
|
|
1850
|
+
}
|
|
1851
|
+
get isArchive() {
|
|
1852
|
+
return [
|
|
1853
|
+
"zip",
|
|
1854
|
+
"tgz",
|
|
1855
|
+
"tar.gz",
|
|
1856
|
+
"txz",
|
|
1857
|
+
"tar.xz",
|
|
1858
|
+
"tbz2",
|
|
1859
|
+
"tar.bz2"
|
|
1860
|
+
].some((ext) => this.name.endsWith(`.${ext}`));
|
|
1861
|
+
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Return the contents of a file. To read binary file (non-editable) use {@link download} instead
|
|
1864
|
+
*/
|
|
1865
|
+
contents = async () => this.client.files.contents(this.path);
|
|
1866
|
+
downloadGetUrl = async () => this.client.files.downloadGetUrl(this.path);
|
|
1867
|
+
download = async () => this.client.files.download(this.path);
|
|
1868
|
+
rename = async (newName) => this.client.files.rename(this.dir, [{ from: this.name, to: newName }]);
|
|
1869
|
+
copy = async () => this.client.files.copy(this.path);
|
|
1870
|
+
write = async (content) => this.client.files.write(this.path, content);
|
|
1871
|
+
compress = async (archive_name, extension) => this.client.files.compress(
|
|
1872
|
+
this.dir,
|
|
1873
|
+
[this.name],
|
|
1874
|
+
archive_name,
|
|
1875
|
+
extension
|
|
1876
|
+
);
|
|
1877
|
+
decompress = async () => this.client.files.decompress(this.dir, this.name);
|
|
1878
|
+
delete = async () => this.client.files.delete(this.dir, [this.name]);
|
|
1879
|
+
chmod = async (mode) => this.client.files.chmod(this.dir, [{ file: this.name, mode }]);
|
|
1880
|
+
};
|
|
1881
|
+
|
|
1882
|
+
// src/humane/ServerSchedule.ts
|
|
1883
|
+
var ServerSchedule = class {
|
|
1884
|
+
client;
|
|
1885
|
+
createdAt;
|
|
1886
|
+
$cron;
|
|
1887
|
+
get cron() {
|
|
1888
|
+
return { ...this.$cron };
|
|
1889
|
+
}
|
|
1890
|
+
id;
|
|
1891
|
+
$isActive;
|
|
1892
|
+
get isActive() {
|
|
1893
|
+
return this.$isActive;
|
|
1894
|
+
}
|
|
1895
|
+
$isProcessing;
|
|
1896
|
+
get isProcessing() {
|
|
1897
|
+
return this.$isProcessing;
|
|
1898
|
+
}
|
|
1899
|
+
lastRunAt;
|
|
1900
|
+
$name;
|
|
1901
|
+
get name() {
|
|
1902
|
+
return this.$name;
|
|
1903
|
+
}
|
|
1904
|
+
nextRunAt;
|
|
1905
|
+
$onlyWhenOnline;
|
|
1906
|
+
get onlyWhenOnline() {
|
|
1907
|
+
return this.$onlyWhenOnline;
|
|
1908
|
+
}
|
|
1909
|
+
tasks;
|
|
1910
|
+
$updatedAt;
|
|
1911
|
+
get updatedAt() {
|
|
1912
|
+
return this.$updatedAt;
|
|
1913
|
+
}
|
|
1914
|
+
constructor(client, schedule) {
|
|
1915
|
+
this.client = client;
|
|
1916
|
+
this.createdAt = new Date(schedule.created_at);
|
|
1917
|
+
this.$cron = schedule.cron;
|
|
1918
|
+
this.id = schedule.id;
|
|
1919
|
+
this.$isActive = schedule.is_active;
|
|
1920
|
+
this.$isProcessing = schedule.is_processing;
|
|
1921
|
+
this.lastRunAt = schedule.last_run_at ? new Date(schedule.last_run_at) : null;
|
|
1922
|
+
this.$name = schedule.name;
|
|
1923
|
+
this.nextRunAt = new Date(schedule.next_run_at);
|
|
1924
|
+
this.$onlyWhenOnline = schedule.only_when_online;
|
|
1925
|
+
this.tasks = schedule.relationships.tasks.data.map(
|
|
1926
|
+
(d) => new ServerScheduleTask(this.client, this.id, d.attributes)
|
|
1927
|
+
);
|
|
1928
|
+
this.$updatedAt = new Date(schedule.updated_at);
|
|
1929
|
+
}
|
|
1930
|
+
update = async (opts) => {
|
|
1931
|
+
const data = await this.client.schedules.control(this.id).update(opts);
|
|
1932
|
+
this.$name = data.name;
|
|
1933
|
+
this.$isActive = data.is_active;
|
|
1934
|
+
this.$isProcessing = data.is_processing;
|
|
1935
|
+
this.$onlyWhenOnline = data.only_when_online;
|
|
1936
|
+
this.$cron = data.cron;
|
|
1937
|
+
this.$updatedAt = new Date(data.updated_at);
|
|
1938
|
+
};
|
|
1939
|
+
delete = async () => this.client.schedules.control(this.id).delete();
|
|
1940
|
+
execute = async () => this.client.schedules.control(this.id).execute();
|
|
1941
|
+
};
|
|
1942
|
+
var ServerScheduleTask = class {
|
|
1943
|
+
client;
|
|
1944
|
+
scheduleId;
|
|
1945
|
+
$action;
|
|
1946
|
+
get action() {
|
|
1947
|
+
return this.$action;
|
|
2090
1948
|
}
|
|
1949
|
+
$continueOnFailure;
|
|
1950
|
+
get continueOnFailure() {
|
|
1951
|
+
return this.$continueOnFailure;
|
|
1952
|
+
}
|
|
1953
|
+
createdAt;
|
|
1954
|
+
id;
|
|
1955
|
+
$isQueued;
|
|
1956
|
+
get isQueued() {
|
|
1957
|
+
return this.$isQueued;
|
|
1958
|
+
}
|
|
1959
|
+
$payload;
|
|
1960
|
+
get payload() {
|
|
1961
|
+
return this.$payload;
|
|
1962
|
+
}
|
|
1963
|
+
$sequenceId;
|
|
1964
|
+
get sequenceId() {
|
|
1965
|
+
return this.$sequenceId;
|
|
1966
|
+
}
|
|
1967
|
+
$timeOffset;
|
|
1968
|
+
get timeOffset() {
|
|
1969
|
+
return this.$timeOffset;
|
|
1970
|
+
}
|
|
1971
|
+
$updatedAt;
|
|
1972
|
+
get updatedAt() {
|
|
1973
|
+
return this.$updatedAt;
|
|
1974
|
+
}
|
|
1975
|
+
constructor(client, scheduleId, task) {
|
|
1976
|
+
this.client = client;
|
|
1977
|
+
this.scheduleId = scheduleId;
|
|
1978
|
+
this.$action = task.action;
|
|
1979
|
+
this.$continueOnFailure = task.continue_on_failure;
|
|
1980
|
+
this.createdAt = new Date(task.created_at);
|
|
1981
|
+
this.id = task.id;
|
|
1982
|
+
this.$isQueued = task.is_queued;
|
|
1983
|
+
this.$payload = task.payload;
|
|
1984
|
+
this.$sequenceId = task.sequence_id;
|
|
1985
|
+
this.$timeOffset = task.time_offset;
|
|
1986
|
+
this.$updatedAt = task.updated_at ? new Date(task.updated_at) : null;
|
|
1987
|
+
}
|
|
1988
|
+
delete = async () => this.client.schedules.control(this.scheduleId).tasks.delete(this.id);
|
|
1989
|
+
update = async (opts) => {
|
|
1990
|
+
const data = await this.client.schedules.control(this.scheduleId).tasks.update(this.id, opts);
|
|
1991
|
+
this.$action = data.action;
|
|
1992
|
+
this.$continueOnFailure = data.continue_on_failure;
|
|
1993
|
+
this.$isQueued = data.is_queued;
|
|
1994
|
+
this.$payload = data.payload;
|
|
1995
|
+
this.$sequenceId = data.sequence_id;
|
|
1996
|
+
this.$timeOffset = data.time_offset;
|
|
1997
|
+
this.$updatedAt = data.updated_at ? new Date(data.updated_at) : null;
|
|
1998
|
+
};
|
|
1999
|
+
};
|
|
2000
|
+
|
|
2001
|
+
// src/humane/ServerUser.ts
|
|
2002
|
+
var ServerUser = class {
|
|
2003
|
+
client;
|
|
2004
|
+
uuid;
|
|
2005
|
+
username;
|
|
2006
|
+
email;
|
|
2007
|
+
language;
|
|
2008
|
+
image;
|
|
2009
|
+
admin;
|
|
2010
|
+
root_admin;
|
|
2011
|
+
has2faEnabled;
|
|
2012
|
+
createdAt;
|
|
2013
|
+
$permissions;
|
|
2014
|
+
get permissions() {
|
|
2015
|
+
return this.$permissions;
|
|
2016
|
+
}
|
|
2017
|
+
constructor(client, user) {
|
|
2018
|
+
this.client = client;
|
|
2019
|
+
this.uuid = user.uuid;
|
|
2020
|
+
this.username = user.username;
|
|
2021
|
+
this.email = user.email;
|
|
2022
|
+
this.language = user.language;
|
|
2023
|
+
this.image = user.image;
|
|
2024
|
+
this.admin = user.admin;
|
|
2025
|
+
this.root_admin = user.root_admin;
|
|
2026
|
+
this.has2faEnabled = user["2fa_enabled"];
|
|
2027
|
+
this.createdAt = new Date(user.created_at);
|
|
2028
|
+
this.$permissions = user.permissions;
|
|
2029
|
+
}
|
|
2030
|
+
update = async (permissions) => {
|
|
2031
|
+
const data = await this.client.users.update(this.uuid, permissions);
|
|
2032
|
+
this.$permissions = data.permissions;
|
|
2033
|
+
};
|
|
2034
|
+
delete = async () => this.client.users.delete(this.uuid);
|
|
2035
|
+
};
|
|
2036
|
+
|
|
2037
|
+
// src/humane/Server.ts
|
|
2038
|
+
var Server = class {
|
|
2039
|
+
client;
|
|
2040
|
+
ownsServer;
|
|
2041
|
+
identifier;
|
|
2042
|
+
internalId;
|
|
2043
|
+
uuid;
|
|
2044
|
+
$name;
|
|
2045
|
+
get name() {
|
|
2046
|
+
return this.$name;
|
|
2047
|
+
}
|
|
2048
|
+
node;
|
|
2049
|
+
isNodeUnderMaintenance;
|
|
2050
|
+
sftp;
|
|
2051
|
+
$description;
|
|
2052
|
+
get description() {
|
|
2053
|
+
return this.$description;
|
|
2054
|
+
}
|
|
2055
|
+
limits;
|
|
2056
|
+
invocation;
|
|
2057
|
+
$dockerImage;
|
|
2058
|
+
get dockerImage() {
|
|
2059
|
+
return this.$dockerImage;
|
|
2060
|
+
}
|
|
2061
|
+
eggFeatures;
|
|
2062
|
+
featureLimits;
|
|
2063
|
+
status;
|
|
2064
|
+
isSuspended;
|
|
2065
|
+
isInstalling;
|
|
2066
|
+
isTransferring;
|
|
2067
|
+
allocations;
|
|
2068
|
+
variables;
|
|
2069
|
+
egg;
|
|
2070
|
+
subusers;
|
|
2071
|
+
constructor(client, server) {
|
|
2072
|
+
this.client = client;
|
|
2073
|
+
this.ownsServer = server.server_owner;
|
|
2074
|
+
this.identifier = server.identifier;
|
|
2075
|
+
this.internalId = server.internal_id;
|
|
2076
|
+
this.uuid = server.uuid;
|
|
2077
|
+
this.$name = server.name;
|
|
2078
|
+
this.node = server.node;
|
|
2079
|
+
this.isNodeUnderMaintenance = server.is_node_under_maintenance;
|
|
2080
|
+
this.sftp = server.sftp_details;
|
|
2081
|
+
this.$description = server.description;
|
|
2082
|
+
this.limits = server.limits;
|
|
2083
|
+
this.invocation = server.invocation;
|
|
2084
|
+
this.$dockerImage = server.docker_image;
|
|
2085
|
+
this.eggFeatures = server.egg_features;
|
|
2086
|
+
this.featureLimits = server.feature_limits;
|
|
2087
|
+
this.status = server.status;
|
|
2088
|
+
this.isSuspended = server.is_suspended;
|
|
2089
|
+
this.isInstalling = server.is_installing;
|
|
2090
|
+
this.isTransferring = server.is_transferring;
|
|
2091
|
+
this.allocations = server.relationships.allocations.data.map(
|
|
2092
|
+
(d) => new ServerAllocation(this.client, d.attributes)
|
|
2093
|
+
);
|
|
2094
|
+
this.variables = server.relationships.variables.data.map(
|
|
2095
|
+
(d) => d.attributes
|
|
2096
|
+
);
|
|
2097
|
+
this.egg = server.relationships.egg?.attributes;
|
|
2098
|
+
this.subusers = server.relationships.subusers?.data.map(
|
|
2099
|
+
(d) => new ServerUser(this.client, d.attributes)
|
|
2100
|
+
);
|
|
2101
|
+
}
|
|
2102
|
+
rename = async (name) => {
|
|
2103
|
+
await this.client.settings.rename(name);
|
|
2104
|
+
this.$name = name;
|
|
2105
|
+
};
|
|
2106
|
+
updateDescription = async (description) => {
|
|
2107
|
+
await this.client.settings.updateDescription(description);
|
|
2108
|
+
this.$description = description;
|
|
2109
|
+
};
|
|
2110
|
+
reinstall = async () => this.client.settings.reinstall();
|
|
2111
|
+
changeDockerImage = async (image) => {
|
|
2112
|
+
await this.client.settings.changeDockerImage(image);
|
|
2113
|
+
this.$dockerImage = image;
|
|
2114
|
+
};
|
|
2115
|
+
getActivityLogs = async (opts = { page: 1, per_page: 50 }) => this.client.activity.list(opts.page, opts.per_page);
|
|
2116
|
+
websocket = (stripColors = false) => this.client.websocket(stripColors);
|
|
2117
|
+
getServerStats = async () => this.client.resources();
|
|
2118
|
+
runCommand = async (command) => this.client.command(command);
|
|
2119
|
+
sendPowerSignal = async (signal) => this.client.power(signal);
|
|
2120
|
+
getDatabases = async (opts = {
|
|
2121
|
+
include: [],
|
|
2122
|
+
page: 1
|
|
2123
|
+
}) => {
|
|
2124
|
+
const data = await this.client.databases.list(opts.include, opts.page);
|
|
2125
|
+
return data.map((d) => new ServerDatabase(this.client, d));
|
|
2126
|
+
};
|
|
2127
|
+
createDatabase = async (database, remote) => {
|
|
2128
|
+
const data = await this.client.databases.create(database, remote);
|
|
2129
|
+
return new ServerDatabase(this.client, data);
|
|
2130
|
+
};
|
|
2131
|
+
getSchedules = async () => {
|
|
2132
|
+
const data = await this.client.schedules.list();
|
|
2133
|
+
return data.map((d) => new ServerSchedule(this.client, d));
|
|
2134
|
+
};
|
|
2135
|
+
createSchedule = async (...opts) => {
|
|
2136
|
+
const data = await this.client.schedules.create(...opts);
|
|
2137
|
+
return new ServerSchedule(this.client, data);
|
|
2138
|
+
};
|
|
2139
|
+
getBackups = async (page = 1) => {
|
|
2140
|
+
const data = await this.client.backups.list(page);
|
|
2141
|
+
return data.map((d) => new ServerBackup(this.client, d));
|
|
2142
|
+
};
|
|
2143
|
+
createBackup = async (...args) => {
|
|
2144
|
+
const data = await this.client.backups.create(...args);
|
|
2145
|
+
return new ServerBackup(this.client, data);
|
|
2146
|
+
};
|
|
2147
|
+
getAllocations = async () => {
|
|
2148
|
+
const data = await this.client.allocations.list();
|
|
2149
|
+
return data.map((d) => new ServerAllocation(this.client, d));
|
|
2150
|
+
};
|
|
2151
|
+
createAllocation = async () => {
|
|
2152
|
+
const data = await this.client.allocations.autoAssign();
|
|
2153
|
+
return new ServerAllocation(this.client, data);
|
|
2154
|
+
};
|
|
2155
|
+
getFiles = async (path2) => {
|
|
2156
|
+
const data = await this.client.files.list(path2);
|
|
2157
|
+
return data.map((d) => new ServerFile(this.client, d));
|
|
2158
|
+
};
|
|
2159
|
+
createFolder = async (...opts) => this.client.files.createFolder(...opts);
|
|
2160
|
+
uploadFile = async (...opts) => this.client.files.upload(...opts);
|
|
2161
|
+
uploadFileGetUrl = async (...opts) => this.client.files.uploadGetUrl(...opts);
|
|
2162
|
+
pullFileFromRemote = async (...opts) => this.client.files.pullFromRemote(...opts);
|
|
2163
|
+
getUsers = async () => {
|
|
2164
|
+
const data = await this.client.users.list();
|
|
2165
|
+
return data.map((d) => new ServerUser(this.client, d));
|
|
2166
|
+
};
|
|
2167
|
+
createUser = async (email, permissions) => {
|
|
2168
|
+
const data = await this.client.users.create(email, permissions);
|
|
2169
|
+
return new ServerUser(this.client, data);
|
|
2170
|
+
};
|
|
2171
|
+
getStartupInfo = async () => this.client.startup.list();
|
|
2172
|
+
setStartupVariable = async (key, value) => this.client.startup.set(key, value);
|
|
2173
|
+
};
|
|
2174
|
+
|
|
2175
|
+
// src/humane/Client.ts
|
|
2176
|
+
var Client3 = class {
|
|
2177
|
+
client;
|
|
2178
|
+
constructor(client) {
|
|
2179
|
+
this.client = client;
|
|
2180
|
+
}
|
|
2181
|
+
get $client() {
|
|
2182
|
+
return this.client;
|
|
2183
|
+
}
|
|
2184
|
+
getAccount = async () => {
|
|
2185
|
+
const user = await this.client.account.info();
|
|
2186
|
+
return new Account2(this.client, user);
|
|
2187
|
+
};
|
|
2188
|
+
listPermissions = async () => this.client.listPermissions();
|
|
2189
|
+
listServers = async (opts = { type: "accessible", page: 1, per_page: 50 }) => {
|
|
2190
|
+
const data = await this.client.listServers(
|
|
2191
|
+
opts.type,
|
|
2192
|
+
opts.page,
|
|
2193
|
+
opts.per_page,
|
|
2194
|
+
opts.include
|
|
2195
|
+
);
|
|
2196
|
+
return data.map((d) => new Server(this.client.server(d.uuid), d));
|
|
2197
|
+
};
|
|
2198
|
+
getServer = async (uuid, include) => {
|
|
2199
|
+
const server = await this.client.server(uuid).info(include);
|
|
2200
|
+
return new Server(this.client.server(uuid), server);
|
|
2201
|
+
};
|
|
2202
|
+
};
|
|
2203
|
+
|
|
2204
|
+
// src/index.ts
|
|
2205
|
+
var createPelicanClient = (url, token, suffix = "/api") => {
|
|
2206
|
+
const client = new PelicanAPIClient(url, token, suffix);
|
|
2207
|
+
return new Client3(client);
|
|
2091
2208
|
};
|
|
2092
2209
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2093
2210
|
0 && (module.exports = {
|
|
2094
|
-
|
|
2095
|
-
|
|
2211
|
+
Account,
|
|
2212
|
+
Client,
|
|
2213
|
+
Server,
|
|
2214
|
+
ServerAllocation,
|
|
2215
|
+
ServerBackup,
|
|
2216
|
+
ServerDatabase,
|
|
2217
|
+
ServerFile,
|
|
2218
|
+
ServerSchedule,
|
|
2219
|
+
ServerUser,
|
|
2220
|
+
createPelicanClient
|
|
2096
2221
|
});
|
|
2097
2222
|
/*
|
|
2098
2223
|
* @author BothimTV
|