@pelican.ts/sdk 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.d.mts +118 -36
- package/dist/index.d.ts +118 -36
- package/dist/index.js +97 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +1121 -0
- package/package.json +11 -3
- package/scripts/create-types.ts +24 -0
- package/src/api/application/client.ts +13 -7
- package/src/api/application/eggs.ts +31 -0
- package/src/api/application/mounts.ts +96 -0
- package/src/api/application/nodes.ts +1 -1
- package/src/api/application/servers.ts +3 -3
- package/src/api/application/types/egg.ts +37 -0
- package/src/api/application/types/index.ts +10 -0
- package/src/api/application/types/mount.ts +12 -0
- package/src/api/application/types/node.ts +2 -2
- package/src/api/application/types/server.ts +1 -1
- package/src/api/application/types/server_allocation.ts +2 -2
- package/src/api/application/types/user.ts +3 -3
- package/src/api/application/users.ts +11 -11
- package/src/api/client/server_allocations.ts +9 -9
- package/src/api/client/server_backups.ts +7 -7
- package/src/api/client/types/index.ts +5 -0
- package/src/api/client/types/server.ts +2 -2
- package/src/api/client/types/server_allocation.ts +1 -1
- package/src/api/common/types/index.ts +9 -0
- package/src/api/common/types/server_backup.ts +1 -1
- package/src/types.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -1879,6 +1879,96 @@ var Roles = class {
|
|
|
1879
1879
|
};
|
|
1880
1880
|
};
|
|
1881
1881
|
|
|
1882
|
+
// src/api/application/eggs.ts
|
|
1883
|
+
var Eggs = class {
|
|
1884
|
+
r;
|
|
1885
|
+
constructor(r) {
|
|
1886
|
+
this.r = r;
|
|
1887
|
+
}
|
|
1888
|
+
list = async () => {
|
|
1889
|
+
const { data } = await this.r.get("/eggs");
|
|
1890
|
+
return data.data.map((d) => d.attributes);
|
|
1891
|
+
};
|
|
1892
|
+
info = async (id) => {
|
|
1893
|
+
const { data } = await this.r.get(`/eggs/${id}`);
|
|
1894
|
+
return data.attributes;
|
|
1895
|
+
};
|
|
1896
|
+
export = async (id, format) => {
|
|
1897
|
+
const { data } = await this.r.get(`/eggs/${id}/export`, {
|
|
1898
|
+
params: { format },
|
|
1899
|
+
transformResponse: (r) => r
|
|
1900
|
+
});
|
|
1901
|
+
return data;
|
|
1902
|
+
};
|
|
1903
|
+
};
|
|
1904
|
+
|
|
1905
|
+
// src/api/application/mounts.ts
|
|
1906
|
+
var import_zod13 = __toESM(require("zod"));
|
|
1907
|
+
var Mounts = class {
|
|
1908
|
+
r;
|
|
1909
|
+
constructor(r) {
|
|
1910
|
+
this.r = r;
|
|
1911
|
+
}
|
|
1912
|
+
list = async () => {
|
|
1913
|
+
const { data } = await this.r.get("/mounts");
|
|
1914
|
+
return data.data.map((d) => d.attributes);
|
|
1915
|
+
};
|
|
1916
|
+
info = async (id) => {
|
|
1917
|
+
const { data } = await this.r.get(`/mounts/${id}`);
|
|
1918
|
+
return data.attributes;
|
|
1919
|
+
};
|
|
1920
|
+
create = async (opts) => {
|
|
1921
|
+
opts = CreateMountSchema.parse(opts);
|
|
1922
|
+
const { data } = await this.r.post("/mounts", opts);
|
|
1923
|
+
return data.attributes;
|
|
1924
|
+
};
|
|
1925
|
+
update = async (id, opts) => {
|
|
1926
|
+
opts = CreateMountSchema.parse(opts);
|
|
1927
|
+
const { data } = await this.r.patch(`/mounts/${id}`, opts);
|
|
1928
|
+
return data.attributes;
|
|
1929
|
+
};
|
|
1930
|
+
delete = async (id) => {
|
|
1931
|
+
await this.r.delete(`/mounts/${id}`);
|
|
1932
|
+
};
|
|
1933
|
+
listAssignedEggs = async (id) => {
|
|
1934
|
+
const { data } = await this.r.get(`/mounts/${id}/eggs`);
|
|
1935
|
+
return data.data.map((d) => d.attributes);
|
|
1936
|
+
};
|
|
1937
|
+
assignEggs = async (id, eggs) => {
|
|
1938
|
+
await this.r.post(`/mounts/${id}/eggs`, { eggs });
|
|
1939
|
+
};
|
|
1940
|
+
unassignEgg = async (id, egg_id) => {
|
|
1941
|
+
await this.r.delete(`/mounts/${id}/eggs/${egg_id}`);
|
|
1942
|
+
};
|
|
1943
|
+
listAssignedNodes = async (id) => {
|
|
1944
|
+
const { data } = await this.r.get(`/mounts/${id}/nodes`);
|
|
1945
|
+
return data.data.map((d) => d.attributes);
|
|
1946
|
+
};
|
|
1947
|
+
assignNodes = async (id, nodes) => {
|
|
1948
|
+
await this.r.post(`/mounts/${id}/nodes`, { nodes });
|
|
1949
|
+
};
|
|
1950
|
+
unassignNode = async (id, node_id) => {
|
|
1951
|
+
await this.r.delete(`/mounts/${id}/nodes/${node_id}`);
|
|
1952
|
+
};
|
|
1953
|
+
listAssignedServers = async (id) => {
|
|
1954
|
+
const { data } = await this.r.get(`/mounts/${id}/servers`);
|
|
1955
|
+
return data.data.map((d) => d.attributes);
|
|
1956
|
+
};
|
|
1957
|
+
assignServers = async (id, servers) => {
|
|
1958
|
+
await this.r.post(`/mounts/${id}/servers`, { servers });
|
|
1959
|
+
};
|
|
1960
|
+
unassignServer = async (id, server_id) => {
|
|
1961
|
+
await this.r.delete(`/mounts/${id}/servers/${server_id}`);
|
|
1962
|
+
};
|
|
1963
|
+
};
|
|
1964
|
+
var CreateMountSchema = import_zod13.default.object({
|
|
1965
|
+
name: import_zod13.default.string().min(1).max(255),
|
|
1966
|
+
description: import_zod13.default.string().optional(),
|
|
1967
|
+
source: import_zod13.default.string(),
|
|
1968
|
+
target: import_zod13.default.string(),
|
|
1969
|
+
read_only: import_zod13.default.boolean().optional()
|
|
1970
|
+
});
|
|
1971
|
+
|
|
1882
1972
|
// src/api/application/client.ts
|
|
1883
1973
|
var Client2 = class {
|
|
1884
1974
|
r;
|
|
@@ -1886,12 +1976,16 @@ var Client2 = class {
|
|
|
1886
1976
|
nodes;
|
|
1887
1977
|
databaseHosts;
|
|
1888
1978
|
roles;
|
|
1979
|
+
eggs;
|
|
1980
|
+
mounts;
|
|
1889
1981
|
constructor(requester) {
|
|
1890
1982
|
this.r = requester;
|
|
1891
1983
|
this.users = new Users(requester);
|
|
1892
1984
|
this.nodes = new Nodes(requester);
|
|
1893
1985
|
this.databaseHosts = new DatabaseHosts(requester);
|
|
1894
1986
|
this.roles = new Roles(requester);
|
|
1987
|
+
this.eggs = new Eggs(requester);
|
|
1988
|
+
this.mounts = new Mounts(requester);
|
|
1895
1989
|
}
|
|
1896
1990
|
listServers = async (search, page = 1) => {
|
|
1897
1991
|
const { data } = await this.r.get("/servers", {
|
|
@@ -1914,7 +2008,7 @@ var Client2 = class {
|
|
|
1914
2008
|
};
|
|
1915
2009
|
|
|
1916
2010
|
// src/api/base/request.ts
|
|
1917
|
-
var
|
|
2011
|
+
var import_zod14 = __toESM(require("zod"));
|
|
1918
2012
|
var import_axios3 = __toESM(require("axios"));
|
|
1919
2013
|
|
|
1920
2014
|
// src/api/base/types.ts
|
|
@@ -1934,8 +2028,8 @@ var Agent = class {
|
|
|
1934
2028
|
token;
|
|
1935
2029
|
requester;
|
|
1936
2030
|
constructor(url, token, type, suffix = "/api") {
|
|
1937
|
-
this.base_url =
|
|
1938
|
-
this.token =
|
|
2031
|
+
this.base_url = import_zod14.default.url("Invalid URL Schema").transform((url2) => new URL(url2).href).parse(url);
|
|
2032
|
+
this.token = import_zod14.default.string().regex(/^(ptl[ac]|pacc|papp)_.+$/, "Invalid token type").parse(token);
|
|
1939
2033
|
this.requester = import_axios3.default.create({
|
|
1940
2034
|
baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
|
|
1941
2035
|
timeout: 3e3,
|