nucleus-core-ts 0.8.131 → 0.8.133
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.
|
@@ -151,12 +151,59 @@ function createNewNode(nodeType, position) {
|
|
|
151
151
|
return base;
|
|
152
152
|
}
|
|
153
153
|
function buildSavePayload(flowId, entityName, flowName, flowDescription, triggerOn, isDraft, viewport, nodes, edges) {
|
|
154
|
+
const flowEdges = edges.map((e)=>({
|
|
155
|
+
edge_id: e.id,
|
|
156
|
+
source_node_id: e.source,
|
|
157
|
+
target_node_id: e.target,
|
|
158
|
+
source_handle: e.sourceHandle || undefined,
|
|
159
|
+
target_handle: e.targetHandle || undefined,
|
|
160
|
+
edge_type: "default",
|
|
161
|
+
label: String(e.label || ""),
|
|
162
|
+
animated: true
|
|
163
|
+
}));
|
|
164
|
+
const stepNodeIds = new Set(nodes.filter((n)=>{
|
|
165
|
+
const d = n.data;
|
|
166
|
+
return (d.nodeType || n.type) === "step";
|
|
167
|
+
}).map((n)=>n.id));
|
|
168
|
+
const adjacency = {};
|
|
169
|
+
for (const e of flowEdges){
|
|
170
|
+
if (!adjacency[e.source_node_id]) adjacency[e.source_node_id] = [];
|
|
171
|
+
adjacency[e.source_node_id].push(e.target_node_id);
|
|
172
|
+
}
|
|
173
|
+
const findNextSteps = (fromId, visited = new Set())=>{
|
|
174
|
+
const result = [];
|
|
175
|
+
for (const t of adjacency[fromId] || []){
|
|
176
|
+
if (visited.has(t)) continue;
|
|
177
|
+
visited.add(t);
|
|
178
|
+
if (stepNodeIds.has(t)) result.push(t);
|
|
179
|
+
else result.push(...findNextSteps(t, visited));
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
};
|
|
183
|
+
const stepGraph = {};
|
|
184
|
+
const incomingSteps = new Set();
|
|
185
|
+
for (const sid of stepNodeIds){
|
|
186
|
+
stepGraph[sid] = findNextSteps(sid);
|
|
187
|
+
for (const next of stepGraph[sid])incomingSteps.add(next);
|
|
188
|
+
}
|
|
189
|
+
const stepOrderMap = {};
|
|
190
|
+
const queue = [
|
|
191
|
+
...stepNodeIds
|
|
192
|
+
].filter((id)=>!incomingSteps.has(id));
|
|
193
|
+
let order = 1;
|
|
194
|
+
while(queue.length > 0){
|
|
195
|
+
const current = queue.shift();
|
|
196
|
+
if (stepOrderMap[current] !== undefined) continue;
|
|
197
|
+
stepOrderMap[current] = order++;
|
|
198
|
+
for (const next of stepGraph[current] || [])queue.push(next);
|
|
199
|
+
}
|
|
154
200
|
const steps = nodes.map((n)=>{
|
|
155
201
|
const d = n.data;
|
|
202
|
+
const nodeType = String(d.nodeType || n.type);
|
|
156
203
|
return {
|
|
157
204
|
node_id: n.id,
|
|
158
|
-
node_type:
|
|
159
|
-
step_order:
|
|
205
|
+
node_type: nodeType,
|
|
206
|
+
step_order: nodeType === "step" ? stepOrderMap[n.id] ?? 0 : 0,
|
|
160
207
|
name: String(d.label || ""),
|
|
161
208
|
description: String(d.description || ""),
|
|
162
209
|
position_x: Math.round(n.position.x),
|
|
@@ -165,16 +212,6 @@ function buildSavePayload(flowId, entityName, flowName, flowDescription, trigger
|
|
|
165
212
|
height: n.height || undefined
|
|
166
213
|
};
|
|
167
214
|
});
|
|
168
|
-
const flowEdges = edges.map((e)=>({
|
|
169
|
-
edge_id: e.id,
|
|
170
|
-
source_node_id: e.source,
|
|
171
|
-
target_node_id: e.target,
|
|
172
|
-
source_handle: e.sourceHandle || undefined,
|
|
173
|
-
target_handle: e.targetHandle || undefined,
|
|
174
|
-
edge_type: "default",
|
|
175
|
-
label: String(e.label || ""),
|
|
176
|
-
animated: true
|
|
177
|
-
}));
|
|
178
215
|
const verifier_configs = nodes.filter((n)=>{
|
|
179
216
|
const d = n.data;
|
|
180
217
|
return d.nodeType === "verifier";
|