otomato-sdk 2.0.25 → 2.0.27

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.
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = '2.0.25';
1
+ export const SDK_VERSION = '2.0.27';
2
2
  export function compareVersions(v1, v2) {
3
3
  // Split the version strings into parts
4
4
  const v1Parts = v1.split('.').map(Number);
@@ -192,19 +192,6 @@ export class Workflow {
192
192
  return this.notes.map(note => note.toJSON());
193
193
  }
194
194
  toJSON() {
195
- // 1. Create a new Workflow instance, copying only the nodes, edges, and notes
196
- const clonedWorkflow = new Workflow(this.name, // same name
197
- [...this.nodes], // shallow copy of nodes
198
- [...this.edges] // shallow copy of edges
199
- );
200
- clonedWorkflow.notes = [...this.notes]; // shallow copy of notes array
201
- // 2. Identify any empty nodes (blockId === 0), then delete them from the clone
202
- const emptyNodes = clonedWorkflow.nodes.filter(node => node.blockId === 0);
203
- for (const emptyNode of emptyNodes) {
204
- clonedWorkflow.deleteNode(emptyNode);
205
- }
206
- // 3. Return JSON using 'this' for top-level info (id, state, etc.),
207
- // but using the clonedWorkflow's nodes, edges, and notes
208
195
  return {
209
196
  id: this.id,
210
197
  name: this.name,
@@ -212,9 +199,9 @@ export class Workflow {
212
199
  dateCreated: this.dateCreated,
213
200
  dateModified: this.dateModified,
214
201
  executionId: this.executionId,
215
- nodes: clonedWorkflow.nodes.map(node => node.toJSON()),
216
- edges: clonedWorkflow.edges.map(edge => edge.toJSON()),
217
- notes: clonedWorkflow.getNotes(),
202
+ nodes: this.nodes.map(node => node.toJSON()),
203
+ edges: this.edges.map(edge => edge.toJSON()),
204
+ notes: this.getNotes(),
218
205
  };
219
206
  }
220
207
  create() {
@@ -257,7 +244,7 @@ export class Workflow {
257
244
  return __awaiter(this, void 0, void 0, function* () {
258
245
  var _a;
259
246
  try {
260
- const response = yield apiServices.patch(`/workflows/${this.id}`, this.toJSON());
247
+ const response = yield apiServices.put(`/workflows/${this.id}`, this.toJSON());
261
248
  if (response.status === 200) {
262
249
  this.dateModified = response.data.dateModified;
263
250
  // Assign IDs to the nodes based on the response
@@ -40,6 +40,12 @@ class ApiServices {
40
40
  return yield axiosInstance.patch(url, data, { headers });
41
41
  });
42
42
  }
43
+ put(url, data) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const headers = this.auth ? { 'Authorization': this.auth } : {};
46
+ return yield axiosInstance.put(url, data, { headers });
47
+ });
48
+ }
43
49
  get(url) {
44
50
  return __awaiter(this, void 0, void 0, function* () {
45
51
  const headers = this.auth ? { 'Authorization': this.auth } : {};
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "2.0.25";
1
+ export declare const SDK_VERSION = "2.0.27";
2
2
  export declare function compareVersions(v1: string, v2: string): number;
@@ -4,6 +4,7 @@ declare class ApiServices {
4
4
  setUrl(baseUrl: string): void;
5
5
  post(url: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
6
6
  patch(url: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
7
+ put(url: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
7
8
  get(url: string): Promise<any>;
8
9
  delete(url: string): Promise<import("axios").AxiosResponse<any, any>>;
9
10
  generateLoginPayload(address: string, chainId: number, referralCode: string): Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "2.0.25",
3
+ "version": "2.0.27",
4
4
  "description": "An SDK for building and managing automations on Otomato",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/types/src/index.d.ts",