@pelican.ts/sdk 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1842,6 +1842,96 @@ var Roles = class {
1842
1842
  };
1843
1843
  };
1844
1844
 
1845
+ // src/api/application/eggs.ts
1846
+ var Eggs = class {
1847
+ r;
1848
+ constructor(r) {
1849
+ this.r = r;
1850
+ }
1851
+ list = async () => {
1852
+ const { data } = await this.r.get("/eggs");
1853
+ return data.data.map((d) => d.attributes);
1854
+ };
1855
+ info = async (id) => {
1856
+ const { data } = await this.r.get(`/eggs/${id}`);
1857
+ return data.attributes;
1858
+ };
1859
+ export = async (id, format) => {
1860
+ const { data } = await this.r.get(`/eggs/${id}/export`, {
1861
+ params: { format },
1862
+ transformResponse: (r) => r
1863
+ });
1864
+ return data;
1865
+ };
1866
+ };
1867
+
1868
+ // src/api/application/mounts.ts
1869
+ import z13 from "zod";
1870
+ var Mounts = class {
1871
+ r;
1872
+ constructor(r) {
1873
+ this.r = r;
1874
+ }
1875
+ list = async () => {
1876
+ const { data } = await this.r.get("/mounts");
1877
+ return data.data.map((d) => d.attributes);
1878
+ };
1879
+ info = async (id) => {
1880
+ const { data } = await this.r.get(`/mounts/${id}`);
1881
+ return data.attributes;
1882
+ };
1883
+ create = async (opts) => {
1884
+ opts = CreateMountSchema.parse(opts);
1885
+ const { data } = await this.r.post("/mounts", opts);
1886
+ return data.attributes;
1887
+ };
1888
+ update = async (id, opts) => {
1889
+ opts = CreateMountSchema.parse(opts);
1890
+ const { data } = await this.r.patch(`/mounts/${id}`, opts);
1891
+ return data.attributes;
1892
+ };
1893
+ delete = async (id) => {
1894
+ await this.r.delete(`/mounts/${id}`);
1895
+ };
1896
+ listAssignedEggs = async (id) => {
1897
+ const { data } = await this.r.get(`/mounts/${id}/eggs`);
1898
+ return data.data.map((d) => d.attributes);
1899
+ };
1900
+ assignEggs = async (id, eggs) => {
1901
+ await this.r.post(`/mounts/${id}/eggs`, { eggs });
1902
+ };
1903
+ unassignEgg = async (id, egg_id) => {
1904
+ await this.r.delete(`/mounts/${id}/eggs/${egg_id}`);
1905
+ };
1906
+ listAssignedNodes = async (id) => {
1907
+ const { data } = await this.r.get(`/mounts/${id}/nodes`);
1908
+ return data.data.map((d) => d.attributes);
1909
+ };
1910
+ assignNodes = async (id, nodes) => {
1911
+ await this.r.post(`/mounts/${id}/nodes`, { nodes });
1912
+ };
1913
+ unassignNode = async (id, node_id) => {
1914
+ await this.r.delete(`/mounts/${id}/nodes/${node_id}`);
1915
+ };
1916
+ listAssignedServers = async (id) => {
1917
+ const { data } = await this.r.get(`/mounts/${id}/servers`);
1918
+ return data.data.map((d) => d.attributes);
1919
+ };
1920
+ assignServers = async (id, servers) => {
1921
+ await this.r.post(`/mounts/${id}/servers`, { servers });
1922
+ };
1923
+ unassignServer = async (id, server_id) => {
1924
+ await this.r.delete(`/mounts/${id}/servers/${server_id}`);
1925
+ };
1926
+ };
1927
+ var CreateMountSchema = z13.object({
1928
+ name: z13.string().min(1).max(255),
1929
+ description: z13.string().optional(),
1930
+ source: z13.string(),
1931
+ target: z13.string(),
1932
+ read_only: z13.boolean().optional()
1933
+ });
1934
+
1845
1935
  // src/api/application/client.ts
1846
1936
  var Client2 = class {
1847
1937
  r;
@@ -1849,12 +1939,16 @@ var Client2 = class {
1849
1939
  nodes;
1850
1940
  databaseHosts;
1851
1941
  roles;
1942
+ eggs;
1943
+ mounts;
1852
1944
  constructor(requester) {
1853
1945
  this.r = requester;
1854
1946
  this.users = new Users(requester);
1855
1947
  this.nodes = new Nodes(requester);
1856
1948
  this.databaseHosts = new DatabaseHosts(requester);
1857
1949
  this.roles = new Roles(requester);
1950
+ this.eggs = new Eggs(requester);
1951
+ this.mounts = new Mounts(requester);
1858
1952
  }
1859
1953
  listServers = async (search, page = 1) => {
1860
1954
  const { data } = await this.r.get("/servers", {
@@ -1877,7 +1971,7 @@ var Client2 = class {
1877
1971
  };
1878
1972
 
1879
1973
  // src/api/base/request.ts
1880
- import z13 from "zod";
1974
+ import z14 from "zod";
1881
1975
  import axios3 from "axios";
1882
1976
 
1883
1977
  // src/api/base/types.ts
@@ -1897,8 +1991,8 @@ var Agent = class {
1897
1991
  token;
1898
1992
  requester;
1899
1993
  constructor(url, token, type, suffix = "/api") {
1900
- this.base_url = z13.url("Invalid URL Schema").transform((url2) => new URL(url2).href).parse(url);
1901
- this.token = z13.string().regex(/^(ptl[ac]|pacc|papp)_.+$/, "Invalid token type").parse(token);
1994
+ this.base_url = z14.url("Invalid URL Schema").transform((url2) => new URL(url2).href).parse(url);
1995
+ this.token = z14.string().regex(/^(ptl[ac]|pacc|papp)_.+$/, "Invalid token type").parse(token);
1902
1996
  this.requester = axios3.create({
1903
1997
  baseURL: this.base_url.replace(/\/+$/, "") + `${suffix}/${type}`,
1904
1998
  timeout: 3e3,