@statelyai/sdk 0.6.1 → 0.7.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/dist/studio.mjs CHANGED
@@ -40,6 +40,14 @@ function unwrapResponseData(data) {
40
40
  if (typeof data === "object" && data !== null && "data" in data) return data.data;
41
41
  return data;
42
42
  }
43
+ function normalizeProjectData(project) {
44
+ if (project.projectVersionId) return project;
45
+ if (project.projectId && project.id) return {
46
+ ...project,
47
+ projectVersionId: project.id
48
+ };
49
+ return project;
50
+ }
43
51
  function normalizeRepoUrl(url) {
44
52
  if (!url) return;
45
53
  return url.replace(/\.git$/i, "").replace(/\/+$/, "");
@@ -71,14 +79,14 @@ function createStatelyClient(options = {}) {
71
79
  } },
72
80
  projects: {
73
81
  list() {
74
- return request("/projects", { method: "GET" });
82
+ return request("/projects", { method: "GET" }).then((projects) => projects.map(normalizeProjectData));
75
83
  },
76
84
  create(input) {
77
85
  return request("/projects/create", {
78
86
  method: "POST",
79
87
  headers: { "Content-Type": "application/json" },
80
88
  body: JSON.stringify(input)
81
- });
89
+ }).then(normalizeProjectData);
82
90
  },
83
91
  async ensure(input) {
84
92
  if (input.repo && input.matchConnectedRepo !== false) {
@@ -88,7 +96,7 @@ function createStatelyClient(options = {}) {
88
96
  return this.create(input);
89
97
  },
90
98
  get(projectId) {
91
- return request(`/projects/${encodeURIComponent(projectId)}`, { method: "GET" });
99
+ return request(`/projects/${encodeURIComponent(projectId)}`, { method: "GET" }).then(normalizeProjectData);
92
100
  }
93
101
  },
94
102
  machines: {
@@ -102,6 +110,13 @@ function createStatelyClient(options = {}) {
102
110
  async createMany(input) {
103
111
  return [await this.create(input)];
104
112
  },
113
+ update(input) {
114
+ return request(`/machines/${encodeURIComponent(input.id)}`, {
115
+ method: "PATCH",
116
+ headers: { "Content-Type": "application/json" },
117
+ body: JSON.stringify(input)
118
+ });
119
+ },
105
120
  get(machineId, getOptions = {}) {
106
121
  const search = new URLSearchParams();
107
122
  if (getOptions.version) search.set("version", getOptions.version);