otomato-sdk 2.0.240 → 2.0.242

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.
@@ -195,17 +195,15 @@ export const TRIGGERS = {
195
195
  {
196
196
  "key": "condition",
197
197
  "type": "logic_operator",
198
+ "hideInUI": true,
198
199
  "description": "The condition to check for the token balance",
199
- "mandatory": true,
200
- "hidden": true,
201
200
  "category": 0
202
201
  },
203
202
  {
204
203
  "key": "comparisonValue",
205
204
  "type": "boolean",
205
+ "hideInUI": true,
206
206
  "description": "The value to compare to",
207
- "mandatory": true,
208
- "hidden": true,
209
207
  "category": 0
210
208
  },
211
209
  ],
@@ -642,17 +640,15 @@ export const TRIGGERS = {
642
640
  {
643
641
  "key": "condition",
644
642
  "type": "logic_operator",
643
+ "hideInUI": true,
645
644
  "description": "The condition to check for the token balance",
646
- "mandatory": true,
647
- "hidden": true,
648
645
  "category": 0
649
646
  },
650
647
  {
651
648
  "key": "comparisonValue",
652
649
  "type": "boolean",
650
+ "hideInUI": true,
653
651
  "description": "The value to compare to",
654
- "mandatory": true,
655
- "hidden": true,
656
652
  "category": 0
657
653
  },
658
654
  ],
@@ -6169,13 +6165,15 @@ export const TRIGGERS = {
6169
6165
  "key": "condition",
6170
6166
  "type": "logic_operator",
6171
6167
  "description": "Logic operator for comparing the new apps (e.g. ==, !=)",
6172
- "category": 0
6168
+ "category": 0,
6169
+ "hideInUI": true
6173
6170
  },
6174
6171
  {
6175
6172
  "key": "comparisonValue",
6176
6173
  "type": "boolean",
6177
6174
  "description": "Comparison target: true if should be new",
6178
- "category": 0
6175
+ "category": 0,
6176
+ "hideInUI": true
6179
6177
  },
6180
6178
  ],
6181
6179
  "examples": [
@@ -6222,6 +6220,7 @@ export const TRIGGERS = {
6222
6220
  {
6223
6221
  "key": "condition",
6224
6222
  "type": "logic_operator",
6223
+ "hideInUI": true,
6225
6224
  "description": "Logic operator for comparing the new badges (e.g. ==, !=)",
6226
6225
  "category": 0
6227
6226
  },
@@ -6229,7 +6228,8 @@ export const TRIGGERS = {
6229
6228
  "key": "comparisonValue",
6230
6229
  "type": "boolean",
6231
6230
  "description": "Comparison target: true if should be new",
6232
- "category": 0
6231
+ "category": 0,
6232
+ "hideInUI": true
6233
6233
  },
6234
6234
  ],
6235
6235
  "examples": [
@@ -6256,6 +6256,44 @@ export const TRIGGERS = {
6256
6256
  "blockId": 105,
6257
6257
  "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/abstract.webp"
6258
6258
  }
6259
+ },
6260
+ "DEFILLAMA": {
6261
+ "description": "DefiLlama is a leading analytics platform for DeFi",
6262
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/defillama.webp",
6263
+ "ON_NEW_RAISE": {
6264
+ "name": "New raise",
6265
+ "description": "Gets triggered when a new raise is listed here: https://defillama.com/raises",
6266
+ "type": 3,
6267
+ "prototype": "defillamaNewRaise",
6268
+ "method": "POST",
6269
+ "output": {
6270
+ "newRaises": "string"
6271
+ },
6272
+ "parameters": [
6273
+ {
6274
+ "key": "project",
6275
+ "type": "string",
6276
+ "description": "The project to monitor",
6277
+ "category": 1
6278
+ },
6279
+ {
6280
+ "key": "condition",
6281
+ "type": "logic_operator",
6282
+ "hideInUI": true,
6283
+ "description": "Logic operator for comparing the new apps (e.g. ==, !=)",
6284
+ "category": 0
6285
+ },
6286
+ {
6287
+ "key": "comparisonValue",
6288
+ "type": "boolean",
6289
+ "hideInUI": true,
6290
+ "description": "Comparison target: true if should be new",
6291
+ "category": 0
6292
+ },
6293
+ ],
6294
+ "blockId": 61,
6295
+ "image": "https://otomato-sdk-images.s3.eu-west-1.amazonaws.com/defillama.webp"
6296
+ }
6259
6297
  }
6260
6298
  },
6261
6299
  "ETFS": {
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = '2.0.240';
1
+ export const SDK_VERSION = '2.0.242';
2
2
  export function compareVersions(v1, v2) {
3
3
  // Split the version strings into parts
4
4
  const v1Parts = v1.split('.').map(Number);
@@ -5,6 +5,7 @@ const generatedRefs = new Set();
5
5
  export class Node {
6
6
  constructor(node) {
7
7
  this.id = null;
8
+ this.isOptional = null;
8
9
  this.id = null;
9
10
  this.blockId = node.blockId;
10
11
  this.name = node.name;
@@ -16,6 +17,7 @@ export class Node {
16
17
  this.class = node.class;
17
18
  this.parentInfo = node.parentInfo;
18
19
  this.state = node.state || 'inactive';
20
+ this.isOptional = node.isOptional || null;
19
21
  this.frontendHelpers = node.frontendHelpers || {};
20
22
  if (node.ref) {
21
23
  this.ref = node.ref;
@@ -58,6 +60,9 @@ export class Node {
58
60
  setRef(ref) {
59
61
  this.ref = ref;
60
62
  }
63
+ setIsOptional(isOptional) {
64
+ this.isOptional = isOptional;
65
+ }
61
66
  getParentInfo() {
62
67
  return this.parentInfo;
63
68
  }
@@ -176,6 +181,7 @@ export class Node {
176
181
  blockId: this.blockId,
177
182
  type: this.class,
178
183
  state: this.state,
184
+ isOptional: this.isOptional,
179
185
  parameters: {
180
186
  ...this.getParameters(),
181
187
  },
@@ -232,32 +232,6 @@ export function positionWorkflowNodes(workflow) {
232
232
  }
233
233
  });
234
234
  });
235
- // Additional step: Ensure common children of multiple layer 0 triggers are centered at ROOT_X.
236
- // This runs after initial layer placement and before final overlap resolution specific to children groups might occur,
237
- // and crucially before parent centering which might pull triggers away.
238
- for (const node of workflow.nodes) {
239
- const nodeLayer = node.layer;
240
- if (nodeLayer === 1) { // Check nodes in the layer immediately following triggers
241
- const parents = getParents(node, workflow.edges);
242
- if (parents.length > 1) { // Only if it has multiple parents
243
- const allParentsAreLayer0Triggers = parents.every(p => {
244
- const parentLayer = p.layer;
245
- const parentIsStartingNode = getParents(p, workflow.edges).length === 0;
246
- return parentLayer === 0 && parentIsStartingNode;
247
- });
248
- if (allParentsAreLayer0Triggers) {
249
- if (node.position) { // Ensure node.position exists before trying to read node.position.y
250
- node.setPosition(ROOT_X, node.position.y);
251
- }
252
- else {
253
- // This case should ideally not happen if nodes in layer 1 are already positioned by the main loop.
254
- // If it does, assign a default Y based on its layer.
255
- node.setPosition(ROOT_X, (nodeLayer * ySpacing) + ROOT_Y);
256
- }
257
- }
258
- }
259
- }
260
- }
261
235
  // Step 4: Bottom-up Parent Centering.
262
236
  // Now, we simply set each parent's x to the exact average of its children.
263
237
  centerParentXPositions(workflow);
@@ -271,6 +245,42 @@ export function positionWorkflowNodes(workflow) {
271
245
  return Number(a.getRef()) - Number(b.getRef());
272
246
  });
273
247
  });
248
+ // FINAL STEP: Center nodes in the main action stack only when there are multiple triggers
249
+ const triggers = workflow.nodes.filter(n => n.layer === 0 && getParents(n, workflow.edges).length === 0);
250
+ // Only apply centering if there are multiple triggers
251
+ if (triggers.length > 1) {
252
+ const triggerRefs = new Set(triggers.map(t => t.getRef()));
253
+ const triggerXs = triggers.map(t => t.position.x);
254
+ const triggerCenter = triggerXs.reduce((a, b) => a + b, 0) / triggerXs.length;
255
+ function getAllAncestors(node, edges, visited = new Set()) {
256
+ const parents = getParents(node, edges);
257
+ for (const parent of parents) {
258
+ if (!visited.has(parent.getRef())) {
259
+ visited.add(parent.getRef());
260
+ getAllAncestors(parent, edges, visited);
261
+ }
262
+ }
263
+ return visited;
264
+ }
265
+ // Helper: is a node a descendant of all triggers?
266
+ function isDescendantOfAllTriggers(node) {
267
+ const ancestors = getAllAncestors(node, workflow.edges);
268
+ return Array.from(triggerRefs).every(ref => ancestors.has(ref));
269
+ }
270
+ for (const node of workflow.nodes) {
271
+ if (node.layer === 0)
272
+ continue; // skip triggers
273
+ if (!isDescendantOfAllTriggers(node))
274
+ continue;
275
+ // Check all non-trigger ancestors
276
+ const ancestors = Array.from(getAllAncestors(node, workflow.edges))
277
+ .map(ref => workflow.nodes.find(n => n.getRef() === ref))
278
+ .filter(n => n && n.layer !== 0);
279
+ if (ancestors.every(isDescendantOfAllTriggers)) {
280
+ node.setPosition(triggerCenter, node.position?.y ?? 0);
281
+ }
282
+ }
283
+ }
274
284
  }
275
285
  catch (e) {
276
286
  console.error(e);
@@ -2359,6 +2359,23 @@ export declare const TRIGGERS: {
2359
2359
  image: string;
2360
2360
  };
2361
2361
  };
2362
+ DEFILLAMA: {
2363
+ description: string;
2364
+ image: string;
2365
+ ON_NEW_RAISE: {
2366
+ name: string;
2367
+ description: string;
2368
+ type: number;
2369
+ prototype: string;
2370
+ method: string;
2371
+ output: {
2372
+ newRaises: string;
2373
+ };
2374
+ parameters: Parameter[];
2375
+ blockId: number;
2376
+ image: string;
2377
+ };
2378
+ };
2362
2379
  };
2363
2380
  ETFS: {
2364
2381
  IBIT: {
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "2.0.240";
1
+ export declare const SDK_VERSION = "2.0.242";
2
2
  export declare function compareVersions(v1: string, v2: string): number;
@@ -30,6 +30,7 @@ export declare abstract class Node {
30
30
  image: string;
31
31
  parentInfo?: ParentInfo;
32
32
  state: NodeState;
33
+ isOptional: boolean | null;
33
34
  frontendHelpers: Record<string, any>;
34
35
  constructor(node: {
35
36
  blockId: number;
@@ -46,6 +47,7 @@ export declare abstract class Node {
46
47
  parentInfo?: ParentInfo;
47
48
  state?: NodeState;
48
49
  frontendHelpers?: Record<string, any>;
50
+ isOptional?: boolean;
49
51
  });
50
52
  setId(id: string): void;
51
53
  setChainId(value: number): void;
@@ -54,6 +56,7 @@ export declare abstract class Node {
54
56
  setPosition(x: number, y: number): void;
55
57
  getRef(): string;
56
58
  setRef(ref: string): void;
59
+ setIsOptional(isOptional: boolean): void;
57
60
  getParentInfo(): ParentInfo | undefined;
58
61
  getState(): NodeState;
59
62
  protected setParameter(key: string, value: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "2.0.240",
3
+ "version": "2.0.242",
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",