otomato-sdk 2.0.232 → 2.0.233

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.232';
1
+ export const SDK_VERSION = '2.0.233';
2
2
  export function compareVersions(v1, v2) {
3
3
  // Split the version strings into parts
4
4
  const v1Parts = v1.split('.').map(Number);
@@ -94,6 +94,9 @@ export class Workflow {
94
94
  * - If `nodeAfter` is not specified, we create only one edge:
95
95
  * nodeBefore->nodeToInsert (with `edgeLabelBefore`, `edgeValueBefore`)
96
96
  *
97
+ * SPECIAL CASE: If `nodeBefore` is a trigger and there are other triggers in the workflow,
98
+ * the new node will be connected to ALL triggers in the workflow, not just `nodeBefore`.
99
+ *
97
100
  * @param nodeToInsert The node to insert
98
101
  * @param nodeBefore The existing node that precedes `nodeToInsert`
99
102
  * @param nodeAfter (Optional) The existing node that should follow `nodeToInsert`
@@ -107,6 +110,46 @@ export class Workflow {
107
110
  if (!this.nodes.includes(nodeBefore)) {
108
111
  throw new Error('The nodeBefore must exist in the workflow.');
109
112
  }
113
+ // SPECIAL CASE: If nodeBefore is a trigger, check if there are other triggers
114
+ if (nodeBefore.class === 'trigger') {
115
+ const allTriggers = this.nodes.filter(node => node.class === 'trigger');
116
+ // If there are multiple triggers, connect the new node to all triggers
117
+ if (allTriggers.length > 1) {
118
+ this.addNode(nodeToInsert);
119
+ // Find all targets that triggers currently connect to
120
+ const triggerTargets = new Set();
121
+ allTriggers.forEach(trigger => {
122
+ const outgoingEdges = this.edges.filter(edge => edge.source === trigger);
123
+ outgoingEdges.forEach(edge => {
124
+ triggerTargets.add(edge.target);
125
+ });
126
+ });
127
+ // Remove all existing edges from triggers to their targets
128
+ this.edges = this.edges.filter(edge => !(edge.source.class === 'trigger' && triggerTargets.has(edge.target)));
129
+ // Create edges from all triggers to the new node
130
+ const newEdges = [];
131
+ allTriggers.forEach(trigger => {
132
+ newEdges.push(new Edge({
133
+ source: trigger,
134
+ target: nodeToInsert,
135
+ label: edgeLabelBefore ?? undefined,
136
+ value: edgeValueBefore ?? undefined
137
+ }));
138
+ });
139
+ // Create edges from the new node to all original targets
140
+ triggerTargets.forEach(target => {
141
+ newEdges.push(new Edge({
142
+ source: nodeToInsert,
143
+ target: target,
144
+ label: edgeLabelAfter ?? undefined,
145
+ value: edgeValueAfter ?? undefined
146
+ }));
147
+ });
148
+ this.addEdges(newEdges);
149
+ positionWorkflowNodes(this);
150
+ return;
151
+ }
152
+ }
110
153
  // CASE A: If no nodeAfter => we create a single edge from nodeBefore to nodeToInsert
111
154
  if (!nodeAfter) {
112
155
  this.addNode(nodeToInsert);
@@ -0,0 +1,2 @@
1
+ import { Workflow } from '../../src/index.js';
2
+ export declare function createWorkflowWithMultipleTriggersInsert(): Promise<Workflow | undefined>;
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "2.0.232";
1
+ export declare const SDK_VERSION = "2.0.233";
2
2
  export declare function compareVersions(v1: string, v2: string): number;
@@ -34,6 +34,9 @@ export declare class Workflow {
34
34
  * - If `nodeAfter` is not specified, we create only one edge:
35
35
  * nodeBefore->nodeToInsert (with `edgeLabelBefore`, `edgeValueBefore`)
36
36
  *
37
+ * SPECIAL CASE: If `nodeBefore` is a trigger and there are other triggers in the workflow,
38
+ * the new node will be connected to ALL triggers in the workflow, not just `nodeBefore`.
39
+ *
37
40
  * @param nodeToInsert The node to insert
38
41
  * @param nodeBefore The existing node that precedes `nodeToInsert`
39
42
  * @param nodeAfter (Optional) The existing node that should follow `nodeToInsert`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "2.0.232",
3
+ "version": "2.0.233",
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",