@jacebenson/jsn 5.5.1-dev.165.1 → 5.5.1-dev.166.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/package.json +1 -1
- package/src/flow-create.js +350 -167
package/package.json
CHANGED
package/src/flow-create.js
CHANGED
|
@@ -28,7 +28,7 @@ const FLOW_RECORD_FIELDS = 'sys_id,name,sys_scope,scope,active,status,type,sys_u
|
|
|
28
28
|
|
|
29
29
|
// Everything this partial-update contract still cannot do, whatever the
|
|
30
30
|
// lifecycle state. Published edits reuse the same component rules.
|
|
31
|
-
const DEFERRED_LIFECYCLE = ['publish/activation', '
|
|
31
|
+
const DEFERRED_LIFECYCLE = ['publish/activation', 'subflows', 'flow variables'];
|
|
32
32
|
|
|
33
33
|
function supportedLifecycle(published) {
|
|
34
34
|
return published
|
|
@@ -155,7 +155,7 @@ export function validateFlowManifest(manifest) {
|
|
|
155
155
|
if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) throw new Error('Flow manifest must be a JSON object');
|
|
156
156
|
if (!String(manifest.name || '').trim()) throw new Error('Flow manifest requires name');
|
|
157
157
|
if (!String(manifest.scope || '').trim()) throw new Error('Flow manifest requires scope');
|
|
158
|
-
|
|
158
|
+
validateLogicManifest(manifest);
|
|
159
159
|
if (manifest.subflows !== undefined || manifest.subFlows !== undefined) throw new Error('Subflows are unsupported in this creation slice');
|
|
160
160
|
if (manifest.variables !== undefined || manifest.flowVariables !== undefined) throw new Error('Flow-variable lifecycle is unsupported in this creation slice');
|
|
161
161
|
if (manifest.errorHandling !== undefined) validateErrorHandling(manifest.errorHandling);
|
|
@@ -175,6 +175,8 @@ export function validateFlowManifest(manifest) {
|
|
|
175
175
|
if (!Array.isArray(manifest.actions)) throw new Error('Flow manifest requires an actions array');
|
|
176
176
|
for (const [index, action] of manifest.actions.entries()) {
|
|
177
177
|
if (!action || typeof action !== 'object' || !String(action.type || '').trim()) throw new Error(`Action ${index + 1} requires type`);
|
|
178
|
+
for (const key of Object.keys(action)) if (!['type', 'inputs', 'order', 'parent', 'parentOrder', 'parentUiId'].includes(key)) throw new Error(`Unsupported action field ${key}`);
|
|
179
|
+
if (action.order !== undefined && (!Number.isInteger(action.order) || action.order < 1)) throw new Error('Action order must be a positive integer');
|
|
178
180
|
if (action.inputs !== undefined && (!action.inputs || typeof action.inputs !== 'object' || Array.isArray(action.inputs))) throw new Error(`Action ${index + 1} inputs must be an object`);
|
|
179
181
|
}
|
|
180
182
|
return manifest;
|
|
@@ -493,6 +495,26 @@ const FLOW_LOGIC_DEFINITIONS = {
|
|
|
493
495
|
connectedTo: '07223332de022010ec58424b73829721,e9060aa2c3013010ace8b740ad40dd51',
|
|
494
496
|
attributes: 'allow_siblings=true,draw_curve=true,line_type=q_curve,visible_in_picker=false,visible_in_ui=false,',
|
|
495
497
|
},
|
|
498
|
+
'try': {
|
|
499
|
+
id: '07223332de022010ec58424b73829721',
|
|
500
|
+
name: 'Try',
|
|
501
|
+
type: 'TRY',
|
|
502
|
+
description: 'Allow a flow to continue running when an error occurs within a flow logic block. Run a sequence of actions in response to errors within the flow logic block',
|
|
503
|
+
compilationClass: 'com.glide.flow.compiler.logic_block.TryCompiler',
|
|
504
|
+
order: 15,
|
|
505
|
+
connectedTo: '',
|
|
506
|
+
attributes: 'allow_siblings=true,disable_opening=true,draw_curve=true,icon_class=try,line_type=cc_curve,visible_in_picker=true,',
|
|
507
|
+
},
|
|
508
|
+
'catch': {
|
|
509
|
+
id: '35d60003e6022010a5e40cdd1254dd21',
|
|
510
|
+
name: 'Catch',
|
|
511
|
+
type: 'CATCH',
|
|
512
|
+
description: 'Catch and handle an error',
|
|
513
|
+
compilationClass: 'com.glide.flow.compiler.logic_block.CatchCompiler',
|
|
514
|
+
order: 16,
|
|
515
|
+
connectedTo: '07223332de022010ec58424b73829721',
|
|
516
|
+
attributes: 'allow_siblings=true,disable_opening=true,draw_curve=true,icon_class=catch,line_type=q_curve,visible_in_picker=false,',
|
|
517
|
+
},
|
|
496
518
|
'if': {
|
|
497
519
|
id: 'af4e1945c3e232002841b63b12d3ae3e',
|
|
498
520
|
name: 'If',
|
|
@@ -923,10 +945,37 @@ async function resolveExistingAction(sdk, actions, requested, index) {
|
|
|
923
945
|
return matches[0];
|
|
924
946
|
}
|
|
925
947
|
|
|
948
|
+
function validateLogicManifest(manifest) {
|
|
949
|
+
if (manifest.logic !== undefined && manifest.flowLogics !== undefined) throw new Error('Specify logic or flowLogics, not both');
|
|
950
|
+
const logics = manifest.logic ?? manifest.flowLogics;
|
|
951
|
+
if (logics === undefined) return;
|
|
952
|
+
if (!Array.isArray(logics)) throw new Error('Flow logic must be an array');
|
|
953
|
+
const orders = new Set();
|
|
954
|
+
for (const l of logics) {
|
|
955
|
+
if (!l || typeof l !== 'object' || Array.isArray(l)) throw new Error('Flow logic must be an object');
|
|
956
|
+
for (const key of Object.keys(l)) if (!['order', 'type', 'name', 'parent', 'parentOrder', 'parentUiId', 'connectedTo', 'connectedToOrder', 'condition', 'condition_name', 'conditionName', 'label', 'values'].includes(key)) throw new Error(`Unsupported logic field ${key}; caller identities are not accepted`);
|
|
957
|
+
if (!Number.isInteger(l.order) || l.order < 1 || orders.has(l.order)) throw new Error('Logic order must be a unique positive integer');
|
|
958
|
+
orders.add(l.order);
|
|
959
|
+
if (l.type !== undefined && l.name !== undefined && String(l.type).toLowerCase().trim() !== String(l.name).toLowerCase().trim()) throw new Error('Conflicting logic type/name aliases');
|
|
960
|
+
if (!FLOW_LOGIC_DEFINITIONS[String(l.type || l.name || '').toLowerCase().trim()]) throw new Error('Unsupported flow logic type');
|
|
961
|
+
const logicType = String(l.type || l.name).toLowerCase().trim();
|
|
962
|
+
const labels = ['condition_name', 'conditionName', 'label'].filter(k => l[k] !== undefined);
|
|
963
|
+
if (labels.some(k => typeof l[k] !== 'string') || new Set(labels.map(k => l[k])).size > 1) throw new Error('Conflicting or malformed condition label aliases');
|
|
964
|
+
if (![ 'if', 'else if' ].includes(logicType) && (l.condition !== undefined || labels.length)) throw new Error('Condition fields are supported only on If and Else If');
|
|
965
|
+
if (l.values !== undefined && logicType !== 'set flow variables') throw new Error('Assignment values are supported only on Set Flow Variables');
|
|
966
|
+
if (l.values && Object.values(l.values).some(v => typeof v !== 'string')) throw new Error('Assignment values must be strings (literal or supported pill reference)');
|
|
967
|
+
if ((manifest.errorHandling !== undefined || manifest.errorHandler !== undefined) && ['top level try', 'top level catch'].includes(logicType)) throw new Error('Explicit top-level error blocks conflict with errorHandling');
|
|
968
|
+
if (l.condition !== undefined && typeof l.condition !== 'string') throw new Error('Logic condition must be a string');
|
|
969
|
+
if (l.values !== undefined && (!l.values || typeof l.values !== 'object' || Array.isArray(l.values))) throw new Error('Logic values must be an object');
|
|
970
|
+
for (const key of ['parent', 'parentOrder', 'parentUiId', 'connectedTo', 'connectedToOrder']) if (l[key] !== undefined && !((typeof l[key] === 'string' && l[key].trim()) || (Number.isInteger(l[key]) && l[key] > 0))) throw new Error(`Malformed logic ${key}`);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
926
974
|
export function validateFlowUpdateManifest(manifest) {
|
|
927
975
|
if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) throw new Error('Flow update manifest must be a JSON object');
|
|
928
976
|
const allowed = new Set(['scope', 'trigger', 'actions', 'stages', 'stageTemplate', 'stageSet', 'flowVariables', 'variables', 'flowLogics', 'logic', 'deleteSteps', 'delete', 'deleteOrders', 'errorHandling', 'errorHandler']);
|
|
929
977
|
for (const key of Object.keys(manifest)) if (!allowed.has(key)) throw new Error(`Flow update field "${key}" is unsupported; editable: trigger, action inputs, action inserts, step deletes, flow variables, flow logic, stage placement`);
|
|
978
|
+
validateLogicManifest(manifest);
|
|
930
979
|
if (manifest.scope !== undefined && !String(manifest.scope).trim()) throw new Error('Flow update scope must not be empty');
|
|
931
980
|
if (manifest.trigger !== undefined) {
|
|
932
981
|
if (!manifest.trigger || typeof manifest.trigger !== 'object' || Array.isArray(manifest.trigger)) throw new Error('Flow update trigger must be an object');
|
|
@@ -941,7 +990,8 @@ export function validateFlowUpdateManifest(manifest) {
|
|
|
941
990
|
if (!Array.isArray(manifest.actions)) throw new Error('Flow update actions must be an array');
|
|
942
991
|
for (const [index, action] of manifest.actions.entries()) {
|
|
943
992
|
if (!action || typeof action !== 'object' || Array.isArray(action)) throw new Error(`Update action ${index + 1} must be an object`);
|
|
944
|
-
for (const key of Object.keys(action)) if (!['order', 'type', 'inputs'].includes(key)) throw new Error(`Update action ${index + 1} field "${key}" is unsupported; caller-supplied identities are not accepted`);
|
|
993
|
+
for (const key of Object.keys(action)) if (!['order', 'type', 'inputs', 'parent', 'parentOrder', 'parentUiId'].includes(key)) throw new Error(`Update action ${index + 1} field "${key}" is unsupported; caller-supplied identities are not accepted`);
|
|
994
|
+
for (const key of ['parent', 'parentOrder', 'parentUiId']) if (action[key] !== undefined && !((typeof action[key] === 'string' && action[key].trim()) || (Number.isInteger(action[key]) && action[key] > 0))) throw new Error(`Malformed action ${key}`);
|
|
945
995
|
if (!Number.isInteger(action.order) || action.order < 1 || !String(action.type || '').trim()) throw new Error(`Update action ${index + 1} requires a positive integer order and type`);
|
|
946
996
|
if (!action.inputs || typeof action.inputs !== 'object' || Array.isArray(action.inputs)) throw new Error(`Update action ${index + 1} inputs must be an object`);
|
|
947
997
|
if (Object.keys(action.inputs).length === 0) throw new Error(`Update action ${index + 1} inputs must contain at least one changed value`);
|
|
@@ -1317,6 +1367,25 @@ function validateFinalStepPlan(before, actionInserts, actionUpdates, actionDelet
|
|
|
1317
1367
|
if (s.order !== undefined) orders.add(order);
|
|
1318
1368
|
if (ui) identities.add(ui);
|
|
1319
1369
|
}
|
|
1370
|
+
const byUi = new Map(steps.map(s => [stringValue(s.uiUniqueIdentifier || s.ui_unique_identifier), s]));
|
|
1371
|
+
const paired = new Set();
|
|
1372
|
+
const parentOf = s => stringValue(s.parentUiId || s.parent);
|
|
1373
|
+
for (const step of steps) {
|
|
1374
|
+
if (step.parent && step.parentUiId && step.parent !== step.parentUiId) throw new Error('Conflicting final parent aliases');
|
|
1375
|
+
const seen = new Set([stringValue(step.uiUniqueIdentifier || step.ui_unique_identifier)]);
|
|
1376
|
+
let parent = parentOf(step);
|
|
1377
|
+
while (parent && byUi.has(parent)) {
|
|
1378
|
+
if (seen.has(parent)) throw new Error('Cyclic final parent links');
|
|
1379
|
+
seen.add(parent); parent = parentOf(byUi.get(parent));
|
|
1380
|
+
}
|
|
1381
|
+
const catchType = { '35d60003e6022010a5e40cdd1254dd21': '07223332de022010ec58424b73829721', '35d60003e6022010a5e40cdd1254dd23': 'e9060aa2c3013010ace8b740ad40dd51' }[step.definitionId];
|
|
1382
|
+
if (!catchType) continue;
|
|
1383
|
+
const target = byUi.get(stringValue(step.connectedTo));
|
|
1384
|
+
if (!target || target.definitionId !== catchType) throw new Error('Catch must connect to a compatible Try');
|
|
1385
|
+
if (paired.has(step.connectedTo)) throw new Error('Ambiguous Catch pair: Try already paired');
|
|
1386
|
+
paired.add(step.connectedTo);
|
|
1387
|
+
if (parentOf(target) !== parentOf(step)) throw new Error('Catch and Try must be siblings with compatible parents');
|
|
1388
|
+
}
|
|
1320
1389
|
}
|
|
1321
1390
|
|
|
1322
1391
|
function assertStepReadback(definition, expectedSteps, kind, flowId) {
|
|
@@ -1331,6 +1400,7 @@ function assertStepReadback(definition, expectedSteps, kind, flowId) {
|
|
|
1331
1400
|
const value = key === 'actionTypeSysId' ? actionTypeIdOf(actual) : actual[key];
|
|
1332
1401
|
if (String(value ?? '') !== String(expected[key])) throw new Error(`Flow ${flowId} ${kind} ${expected.uiUniqueIdentifier} ${key} did not match requested value`);
|
|
1333
1402
|
}
|
|
1403
|
+
if (expected.flowVariables && !requestedContentMatches(actual.flowVariables, expected.flowVariables)) throw new Error(`Flow ${flowId} ${kind} assignments did not match requested content`);
|
|
1334
1404
|
if (expected.inputs) {
|
|
1335
1405
|
for (const input of expected.inputs) {
|
|
1336
1406
|
const found = inputList(actual).filter(i => i.name === input.name);
|
|
@@ -1567,6 +1637,266 @@ async function planErrorHandling({ sdk, instance, scope, flowId, beforeDefinitio
|
|
|
1567
1637
|
}
|
|
1568
1638
|
}
|
|
1569
1639
|
|
|
1640
|
+
async function planManifestSteps({ manifest, beforeDefinition, existingActions, existingOrders, actionUiMap, logicUiMap, pendingSteps, idFactory, sdk, instance, scope, flowId, actionInserts, actionUpdates, flowLogicInserts, actionTargets, changedActionInputs, changes, collectPills }) {
|
|
1641
|
+
const existingLogics = beforeDefinition.flowLogicInstances || beforeDefinition.flowLogics || [];
|
|
1642
|
+
const registry = new Map();
|
|
1643
|
+
const byUi = new Map();
|
|
1644
|
+
const register = (step, kind) => {
|
|
1645
|
+
const ui = stringValue(step.uiUniqueIdentifier || step.ui_unique_identifier);
|
|
1646
|
+
const order = String(step.order);
|
|
1647
|
+
if (registry.has(order) && kind === 'action') throw new Error(`Ambiguous step order ${order}: multiple Action instances`);
|
|
1648
|
+
if (!ui || byUi.has(ui) || registry.has(order)) throw new Error(`Ambiguous step identity or order ${order}`);
|
|
1649
|
+
const entry = { ...step, uiUniqueIdentifier: ui, kind };
|
|
1650
|
+
registry.set(order, entry); byUi.set(ui, entry);
|
|
1651
|
+
(kind === 'action' ? actionUiMap : logicUiMap).set(order, ui);
|
|
1652
|
+
return entry;
|
|
1653
|
+
};
|
|
1654
|
+
const rawDeletes = manifest.deleteSteps || manifest.delete || manifest.deleteOrders || [];
|
|
1655
|
+
const deleteTargets = new Set((Array.isArray(rawDeletes) ? rawDeletes : [rawDeletes]).map(String));
|
|
1656
|
+
const isDeleted = step => {
|
|
1657
|
+
const ui = stringValue(step.uiUniqueIdentifier || step.ui_unique_identifier);
|
|
1658
|
+
const id = stringValue(step.sysId || step.id || step.sys_id || ui);
|
|
1659
|
+
return [String(step.order), ui, id].some(value => deleteTargets.has(value));
|
|
1660
|
+
};
|
|
1661
|
+
const deletedUis = new Set();
|
|
1662
|
+
for (const step of [...existingActions, ...existingLogics]) {
|
|
1663
|
+
if (!isDeleted(step)) continue;
|
|
1664
|
+
deletedUis.add(stringValue(step.uiUniqueIdentifier || step.ui_unique_identifier));
|
|
1665
|
+
actionUiMap.delete(String(step.order));
|
|
1666
|
+
logicUiMap.delete(String(step.order));
|
|
1667
|
+
}
|
|
1668
|
+
existingActions = existingActions.filter(step => !isDeleted(step));
|
|
1669
|
+
existingOrders = new Set(existingActions.map(step => String(step.order)));
|
|
1670
|
+
for (const step of existingActions) register(step, 'action');
|
|
1671
|
+
for (const step of existingLogics.filter(step => !isDeleted(step))) register(step, 'logic');
|
|
1672
|
+
const logicSpecs = manifest.flowLogics || manifest.logic || [];
|
|
1673
|
+
for (const l of logicSpecs) {
|
|
1674
|
+
const type = String(l.type || l.name).toLowerCase().trim();
|
|
1675
|
+
register({ ...l, definitionId: FLOW_LOGIC_DEFINITIONS[type].id, uiUniqueIdentifier: idFactory() }, 'logic');
|
|
1676
|
+
}
|
|
1677
|
+
const actionPlans = new Map();
|
|
1678
|
+
for (const [index, a] of (manifest.actions || []).entries()) {
|
|
1679
|
+
if (actionPlans.has(String(a.order))) throw new Error(`Duplicate action update for order ${a.order}`);
|
|
1680
|
+
if (existingOrders.has(String(a.order))) { actionPlans.set(String(a.order), { existing: true }); continue; }
|
|
1681
|
+
const resolved = await resolveActionType(sdk, a.type);
|
|
1682
|
+
const actionDefinition = await readActionDefinition(sdk, instance, resolved.id, scope);
|
|
1683
|
+
const uiUniqueIdentifier = idFactory();
|
|
1684
|
+
const entry = register({ ...a, uiUniqueIdentifier }, 'action');
|
|
1685
|
+
// Schemas exist before any value is resolved, including forward references.
|
|
1686
|
+
pendingSteps.push({ ...entry, name: a.type, inputs: buildTypedInputs(a, actionDefinition.schema) });
|
|
1687
|
+
actionPlans.set(String(a.order), { resolved, actionDefinition, uiUniqueIdentifier, index });
|
|
1688
|
+
}
|
|
1689
|
+
const resolveLink = (values, label, owner) => {
|
|
1690
|
+
const supplied = values.filter(v => v !== undefined);
|
|
1691
|
+
if (!supplied.length) return '';
|
|
1692
|
+
const targets = supplied.map(v => {
|
|
1693
|
+
const target = registry.get(String(v)) || byUi.get(String(v));
|
|
1694
|
+
if (!target || target.kind !== 'logic' || target.uiUniqueIdentifier === owner) throw new Error(`Absent, wrong-type or self ${label} target ${v}`);
|
|
1695
|
+
return target;
|
|
1696
|
+
});
|
|
1697
|
+
if (new Set(targets.map(t => t.uiUniqueIdentifier)).size !== 1) throw new Error(`Conflicting ${label} aliases`);
|
|
1698
|
+
const target = targets[0];
|
|
1699
|
+
if (label === 'Catch' && !['07223332de022010ec58424b73829721', 'e9060aa2c3013010ace8b740ad40dd51'].includes(target.definitionId)) throw new Error('Catch target must be a Try block');
|
|
1700
|
+
if (label === 'parent' && !Object.values(FLOW_LOGIC_DEFINITIONS).some(d => d.id === target.definitionId && /^(TRY|TOP_LEVEL_TRY|CATCH|TOP_LEVEL_CATCH|IF|ELSE|ELSEIF)$/.test(d.type))) throw new Error('Parent target cannot contain children');
|
|
1701
|
+
return target.uiUniqueIdentifier;
|
|
1702
|
+
};
|
|
1703
|
+
for (const l of logicSpecs) {
|
|
1704
|
+
const entry = registry.get(String(l.order));
|
|
1705
|
+
entry.resolvedParent = resolveLink([l.parent, l.parentOrder, l.parentUiId], 'parent', entry.uiUniqueIdentifier);
|
|
1706
|
+
}
|
|
1707
|
+
for (const entry of registry.values()) {
|
|
1708
|
+
const seen = new Set([entry.uiUniqueIdentifier]);
|
|
1709
|
+
let parent = entry.resolvedParent || entry.parentUiId || entry.parent;
|
|
1710
|
+
while (parent && byUi.has(String(parent))) {
|
|
1711
|
+
if (seen.has(parent)) throw new Error('Cyclic parent links');
|
|
1712
|
+
seen.add(parent); const next = byUi.get(parent); parent = next.resolvedParent || next.parentUiId || next.parent;
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
// Handle flowLogics insertion and update
|
|
1717
|
+
const requestedLogics = manifest.flowLogics || manifest.logic || [];
|
|
1718
|
+
const logicTypeKey = t => String(t || '').toLowerCase().trim();
|
|
1719
|
+
// A manifest names steps by order ({{step_4.__status__.message}} or
|
|
1720
|
+
// {{4.message}}). Resolve that only once the owning map entry exists, but do
|
|
1721
|
+
// it before any value is packaged: a token that survives into the payload
|
|
1722
|
+
// stores an unresolvable reference the canvas renders blank.
|
|
1723
|
+
const resolveStepPill = value => {
|
|
1724
|
+
for (const match of String(value).matchAll(/\{\{([^}]+)\}\}/g)) {
|
|
1725
|
+
if ([...deletedUis].some(ui => match[1].startsWith(`${ui}.`))) throw new Error(`Absent deleted step reference ${match[0]}`);
|
|
1726
|
+
}
|
|
1727
|
+
return String(value).replace(/\{\{(?:step_)?(\d+)\.([^}]+)\}\}/g, (match, order, field) => {
|
|
1728
|
+
const ui = actionUiMap.get(String(order)) || logicUiMap.get(String(order));
|
|
1729
|
+
if (!ui) throw new Error(`Absent step reference ${match}`);
|
|
1730
|
+
return `{{${ui}.${field}}}`;
|
|
1731
|
+
});
|
|
1732
|
+
};
|
|
1733
|
+
const resolveStepValue = value => {
|
|
1734
|
+
if (typeof value === 'string') return resolveStepPill(value);
|
|
1735
|
+
if (Array.isArray(value)) return value.map(resolveStepValue);
|
|
1736
|
+
if (value && typeof value === 'object') return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, resolveStepValue(v)]));
|
|
1737
|
+
return value;
|
|
1738
|
+
};
|
|
1739
|
+
const resolveStepInputs = inputs => resolveStepValue(inputs || {});
|
|
1740
|
+
|
|
1741
|
+
for (const [logicIdx, l] of requestedLogics.entries()) {
|
|
1742
|
+
const lType = logicTypeKey(l.type || l.name);
|
|
1743
|
+
const logicDef = FLOW_LOGIC_DEFINITIONS[lType] || {
|
|
1744
|
+
id: l.definitionId || l.id || '',
|
|
1745
|
+
name: l.name || l.type,
|
|
1746
|
+
type: (l.type || '').toUpperCase(),
|
|
1747
|
+
description: '',
|
|
1748
|
+
compilationClass: '',
|
|
1749
|
+
order: l.order || logicIdx + 1,
|
|
1750
|
+
connectedTo: l.connectedTo || '',
|
|
1751
|
+
attributes: 'allow_children=true,allow_siblings=true,'
|
|
1752
|
+
};
|
|
1753
|
+
|
|
1754
|
+
const uiUniqueIdentifier = logicUiMap.get(String(l.order));
|
|
1755
|
+
const parentUiId = resolveLink([l.parent, l.parentOrder, l.parentUiId], 'parent', uiUniqueIdentifier);
|
|
1756
|
+
const connectedTo = resolveLink([l.connectedTo, l.connectedToOrder], /catch$/.test(lType) ? 'Catch' : 'connection', uiUniqueIdentifier);
|
|
1757
|
+
// A Catch only works when it points at one specific Try instance. Falling
|
|
1758
|
+
// back to the definition id writes a link the instance cannot resolve, so
|
|
1759
|
+
// demand the pairing instead of guessing it.
|
|
1760
|
+
if ((lType === 'catch' || lType === 'top level catch') && l.connectedTo === undefined && l.connectedToOrder === undefined) {
|
|
1761
|
+
throw new Error(`Flow logic at order ${l.order} is a Catch block; set connectedToOrder to the Try block's order so the pair stays linked`);
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
let resolvedCondition = resolveStepPill(l.condition || '');
|
|
1765
|
+
|
|
1766
|
+
const inputs = [];
|
|
1767
|
+
collectPills(resolvedCondition, uiUniqueIdentifier, 'condition');
|
|
1768
|
+
|
|
1769
|
+
if (lType === 'if' || lType === 'else if') {
|
|
1770
|
+
inputs.push({
|
|
1771
|
+
name: 'condition_name',
|
|
1772
|
+
value: { schemaless: false, schemalessValue: '', value: l.condition_name || l.conditionName || l.label || '' }
|
|
1773
|
+
});
|
|
1774
|
+
inputs.push({
|
|
1775
|
+
name: 'condition',
|
|
1776
|
+
value: { schemaless: false, schemalessValue: '', value: resolvedCondition }
|
|
1777
|
+
});
|
|
1778
|
+
} else if (lType === 'catch' || lType === 'top level catch') {
|
|
1779
|
+
inputs.push({
|
|
1780
|
+
name: 'enabled',
|
|
1781
|
+
value: { schemaless: false, schemalessValue: '', value: 'true' }
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
const flowVarsArray = [];
|
|
1786
|
+
if (lType === 'set flow variables' && l.values) {
|
|
1787
|
+
for (const [varName, varVal] of Object.entries(l.values)) {
|
|
1788
|
+
const resolvedValue = resolveStepValue(varVal);
|
|
1789
|
+
collectPills(resolvedValue, uiUniqueIdentifier, varName);
|
|
1790
|
+
flowVarsArray.push({
|
|
1791
|
+
id: '',
|
|
1792
|
+
name: varName,
|
|
1793
|
+
children: [],
|
|
1794
|
+
displayValue: { value: '' },
|
|
1795
|
+
value: { schemaless: false, schemalessValue: '', value: resolvedValue }
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
flowLogicInserts.push({
|
|
1801
|
+
order: String(l.order || logicIdx + 1),
|
|
1802
|
+
uiUniqueIdentifier,
|
|
1803
|
+
parent: parentUiId,
|
|
1804
|
+
parentUiId,
|
|
1805
|
+
connectedTo,
|
|
1806
|
+
metadata: '{"predicates":[]}',
|
|
1807
|
+
flowSysId: flowId,
|
|
1808
|
+
generationSource: '',
|
|
1809
|
+
definitionId: logicDef.id,
|
|
1810
|
+
type: 'flowlogic',
|
|
1811
|
+
inputs,
|
|
1812
|
+
outputsToAssign: [],
|
|
1813
|
+
...(flowVarsArray.length ? { flowVariables: flowVarsArray } : {}),
|
|
1814
|
+
flowLogicDefinition: {
|
|
1815
|
+
id: logicDef.id,
|
|
1816
|
+
name: logicDef.name,
|
|
1817
|
+
description: logicDef.description,
|
|
1818
|
+
connectedTo: logicDef.connectedTo,
|
|
1819
|
+
quiescence: 'never',
|
|
1820
|
+
compilationClass: logicDef.compilationClass,
|
|
1821
|
+
order: logicDef.order,
|
|
1822
|
+
type: logicDef.type,
|
|
1823
|
+
visible: true,
|
|
1824
|
+
attributes: logicDef.attributes,
|
|
1825
|
+
userCanRead: true,
|
|
1826
|
+
category: '',
|
|
1827
|
+
inputs: [],
|
|
1828
|
+
variables: '[]'
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1831
|
+
|
|
1832
|
+
if (lType === 'catch' || lType === 'top level catch') {
|
|
1833
|
+
pendingSteps.push({
|
|
1834
|
+
name: 'Catch',
|
|
1835
|
+
order: String(l.order || logicIdx + 1),
|
|
1836
|
+
uiUniqueIdentifier,
|
|
1837
|
+
inputs: [
|
|
1838
|
+
{ name: '__status__.message', parameter: { label: 'Error Status➛Message', type: 'string' } },
|
|
1839
|
+
{ name: '__status__.code', parameter: { label: 'Error Status➛Code', type: 'integer' } }
|
|
1840
|
+
]
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
changes.push({ component: 'flowLogic', order: l.order, type: logicDef.name, input: 'insert', before: null, after: { parent: parentUiId, connectedTo } });
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
for (const [index, requested] of (manifest.actions || []).entries()) {
|
|
1848
|
+
const isInsert = !existingOrders.has(String(requested.order));
|
|
1849
|
+
if (isInsert) {
|
|
1850
|
+
const { resolved, actionDefinition, uiUniqueIdentifier } = actionPlans.get(String(requested.order));
|
|
1851
|
+
actionUiMap.set(String(requested.order), uiUniqueIdentifier);
|
|
1852
|
+
// Resolve before packaging: the instance must receive the producing step's
|
|
1853
|
+
// own pill name, not the order-based token from the manifest.
|
|
1854
|
+
const insertInputs = buildTypedInputs({ ...requested, inputs: resolveStepInputs(requested.inputs) }, actionDefinition.schema);
|
|
1855
|
+
// A later step in this same manifest may reference this one; its identity
|
|
1856
|
+
// and schema exist now even though the flow does not carry it yet.
|
|
1857
|
+
Object.assign(pendingSteps.find(s => s.uiUniqueIdentifier === uiUniqueIdentifier), { inputs: insertInputs });
|
|
1858
|
+
const actParent = resolveLink([requested.parentUiId, requested.parentOrder, requested.parent], 'parent', uiUniqueIdentifier);
|
|
1859
|
+
actionInserts.push({
|
|
1860
|
+
actionTypeSysId: resolved.id,
|
|
1861
|
+
flowSysId: flowId,
|
|
1862
|
+
generationSource: '',
|
|
1863
|
+
type: 'action',
|
|
1864
|
+
order: String(requested.order),
|
|
1865
|
+
parent: actParent,
|
|
1866
|
+
uiUniqueIdentifier,
|
|
1867
|
+
parentUiId: actParent,
|
|
1868
|
+
metadata: JSON.stringify(parseMaybeJson(actionDefinition.definition.metadata, {})),
|
|
1869
|
+
inputs: insertInputs,
|
|
1870
|
+
});
|
|
1871
|
+
changedActionInputs.set(uiUniqueIdentifier, new Set(Object.keys(requested.inputs || {})));
|
|
1872
|
+
for (const [input, after] of Object.entries(requested.inputs || {})) {
|
|
1873
|
+
const resolvedAfter = typeof after === 'string' ? resolveStepPill(after) : after;
|
|
1874
|
+
changes.push({ component: 'action', order: requested.order, type: requested.type, input, before: null, after: resolvedAfter });
|
|
1875
|
+
collectPills(resolvedAfter, uiUniqueIdentifier, input);
|
|
1876
|
+
}
|
|
1877
|
+
} else {
|
|
1878
|
+
const existing = await resolveExistingAction(sdk, existingActions, requested, index);
|
|
1879
|
+
const resolvedRequest = { ...requested, inputs: resolveStepInputs(requested.inputs) };
|
|
1880
|
+
const update = buildActionUpdate(existing, resolvedRequest, index);
|
|
1881
|
+
if (['parent', 'parentOrder', 'parentUiId'].some(k => requested[k] !== undefined)) {
|
|
1882
|
+
const parent = resolveLink([requested.parentUiId, requested.parentOrder, requested.parent], 'parent', existing.uiUniqueIdentifier);
|
|
1883
|
+
update.parent = parent; update.parentUiId = parent;
|
|
1884
|
+
}
|
|
1885
|
+
actionUpdates.push(update);
|
|
1886
|
+
const uiId = stringValue(existing.uiUniqueIdentifier || existing.ui_unique_identifier);
|
|
1887
|
+
if (actionTargets.has(uiId)) throw new Error(`Duplicate action update for order ${requested.order}; combine input changes in one action entry`);
|
|
1888
|
+
actionTargets.set(uiId, existing);
|
|
1889
|
+
changedActionInputs.set(uiId, new Set(Object.keys(requested.inputs)));
|
|
1890
|
+
for (const [input, after] of Object.entries(requested.inputs)) {
|
|
1891
|
+
const resolvedAfter = typeof after === 'string' ? resolveStepPill(after) : after;
|
|
1892
|
+
changes.push({ component: 'action', order: requested.order, type: requested.type, input, before: inputRawValue(inputList(existing).find(field => field.name === input)), after: resolvedAfter });
|
|
1893
|
+
collectPills(resolvedAfter, uiId, input);
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1570
1900
|
export async function createFlowFromManifest(sdk, instance, inputManifest, options = {}) {
|
|
1571
1901
|
const manifest = validateFlowManifest(inputManifest);
|
|
1572
1902
|
const scope = manifest.scope;
|
|
@@ -1581,39 +1911,22 @@ export async function createFlowFromManifest(sdk, instance, inputManifest, optio
|
|
|
1581
1911
|
}
|
|
1582
1912
|
|
|
1583
1913
|
const actionInstances = [];
|
|
1584
|
-
for (const [index, action] of manifest.actions.entries()) {
|
|
1585
|
-
const resolved = await resolveActionType(sdk, action.type);
|
|
1586
|
-
const actionDefinition = await readActionDefinition(sdk, instance, resolved.id, scope);
|
|
1587
|
-
actionInstances.push({
|
|
1588
|
-
actionTypeSysId: resolved.id,
|
|
1589
|
-
flowSysId: '',
|
|
1590
|
-
generationSource: '',
|
|
1591
|
-
type: 'action',
|
|
1592
|
-
order: String(index + 1),
|
|
1593
|
-
parent: '',
|
|
1594
|
-
uiUniqueIdentifier: idFactory(),
|
|
1595
|
-
parentUiId: '',
|
|
1596
|
-
metadata: JSON.stringify(parseMaybeJson(actionDefinition.definition.metadata, {})),
|
|
1597
|
-
inputs: buildTypedInputs(action, actionDefinition.schema),
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
1914
|
const flowLogicInserts = [];
|
|
1602
1915
|
const labelCacheInserts = [];
|
|
1603
1916
|
const pendingSteps = [];
|
|
1604
1917
|
const pills = [];
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
}
|
|
1918
|
+
const collectPills = (value, uiUniqueIdentifier, inputName) => {
|
|
1919
|
+
for (const match of String(value).matchAll(/\{\{([^}]+)\}\}/g)) pills.push({ name: match[1], uiUniqueIdentifier, inputName });
|
|
1920
|
+
};
|
|
1921
|
+
const orderedManifest = { ...manifest, actions: manifest.actions.map((a, index) => ({ ...a, order: a.order ?? index + 1, inputs: a.inputs || {} })) };
|
|
1922
|
+
await planManifestSteps({ manifest: orderedManifest, beforeDefinition: {}, existingActions: [], existingOrders: new Set(), actionUiMap: new Map(), logicUiMap: new Map(), pendingSteps, idFactory, sdk, instance, scope, flowId: '', actionInserts: actionInstances, actionUpdates: [], flowLogicInserts, actionTargets: new Map(), changedActionInputs: new Map(), changes: [], collectPills });
|
|
1923
|
+
if (manifest.errorHandling !== undefined) await planErrorHandling({ sdk, instance, scope, flowId: '', beforeDefinition: {}, existingActions: [], actionInserts: actionInstances, actionUpdates: [], flowLogicInserts, flowLogicUpdates: [], changes: [], idFactory, actionUiMap: new Map(), pendingSteps, changedActionInputs: new Map(), collectPills, errorHandlingInput: manifest.errorHandling });
|
|
1924
|
+
for (const pill of pills) {
|
|
1925
|
+
const binding = resolvePillBinding({}, pill.name, '', [], pendingSteps);
|
|
1926
|
+
const previous = labelCacheInserts.find(e => e.name === pill.name);
|
|
1927
|
+
if (previous) {
|
|
1928
|
+
if (!previous.usedInstances.some(i => i.uiUniqueIdentifier === pill.uiUniqueIdentifier && i.inputName === pill.inputName)) previous.usedInstances.push({ uiUniqueIdentifier: pill.uiUniqueIdentifier, inputName: pill.inputName });
|
|
1929
|
+
} else labelCacheInserts.push(labelCacheEntry({ name: pill.name, label: binding.label, type: binding.type, baseType: binding.type, usedInstances: { [pill.uiUniqueIdentifier]: [pill.inputName] } }));
|
|
1617
1930
|
}
|
|
1618
1931
|
|
|
1619
1932
|
validateFinalStepPlan({}, actionInstances, [], [], flowLogicInserts, [], []);
|
|
@@ -1695,7 +2008,7 @@ export async function createFlowFromManifest(sdk, instance, inputManifest, optio
|
|
|
1695
2008
|
...(captureContext ? { capture_context: captureContext } : {}),
|
|
1696
2009
|
update_set_capture: updateSetCapture,
|
|
1697
2010
|
update_set_mutations: snapshots,
|
|
1698
|
-
lifecycle: { published: false, supported: ['draft', 'autosave'], deferred: ['publish/activation', '
|
|
2011
|
+
lifecycle: { published: false, supported: ['draft', 'autosave'], deferred: ['publish/activation', 'subflows', 'flow variables'] },
|
|
1699
2012
|
};
|
|
1700
2013
|
} catch (error) {
|
|
1701
2014
|
// Creation is two-stage: the parent POST leaves a real draft behind when the
|
|
@@ -1780,8 +2093,8 @@ export function resolvePillBinding(definition, pillName, flowId, cache, pending
|
|
|
1780
2093
|
...findArray(definition, 'triggerInstances').map(step => ({ ...step, trigger: true })),
|
|
1781
2094
|
...findExistingActions(definition).map(step => ({ ...step, trigger: false })),
|
|
1782
2095
|
...pending.map(step => ({ ...step, trigger: false })),
|
|
1783
|
-
...(findArray(definition, 'flowLogicInstances') || []).filter(fl => String(fl.definitionId) === '35d60003e6022010a5e40cdd1254dd23').map(fl => ({
|
|
1784
|
-
name: 'Error Handler',
|
|
2096
|
+
...(findArray(definition, 'flowLogicInstances') || []).filter(fl => String(fl.definitionId) === '35d60003e6022010a5e40cdd1254dd23' || String(fl.definitionId) === '35d60003e6022010a5e40cdd1254dd21').map(fl => ({
|
|
2097
|
+
name: String(fl.definitionId) === '35d60003e6022010a5e40cdd1254dd23' ? 'Error Handler' : 'Catch',
|
|
1785
2098
|
order: stringValue(fl.order),
|
|
1786
2099
|
uiUniqueIdentifier: stringValue(fl.uiUniqueIdentifier || fl.ui_unique_identifier),
|
|
1787
2100
|
trigger: false,
|
|
@@ -1877,6 +2190,7 @@ export async function updateFlowFromManifest(sdk, instance, identifier, inputMan
|
|
|
1877
2190
|
const pillToInstances = new Map();
|
|
1878
2191
|
const pendingSteps = [];
|
|
1879
2192
|
const actionUiMap = new Map();
|
|
2193
|
+
const logicUiMap = new Map(); // order -> uiUniqueIdentifier
|
|
1880
2194
|
for (const a of existingActions) {
|
|
1881
2195
|
const ui = stringValue(a.uiUniqueIdentifier || a.ui_unique_identifier);
|
|
1882
2196
|
if (a.order && ui) actionUiMap.set(String(a.order), ui);
|
|
@@ -1895,48 +2209,7 @@ export async function updateFlowFromManifest(sdk, instance, identifier, inputMan
|
|
|
1895
2209
|
}
|
|
1896
2210
|
};
|
|
1897
2211
|
|
|
1898
|
-
|
|
1899
|
-
const isInsert = !existingOrders.has(String(requested.order));
|
|
1900
|
-
if (isInsert) {
|
|
1901
|
-
const resolved = await resolveActionType(sdk, requested.type);
|
|
1902
|
-
const actionDefinition = await readActionDefinition(sdk, instance, resolved.id, scope);
|
|
1903
|
-
const uiUniqueIdentifier = requested.uiUniqueIdentifier || idFactory();
|
|
1904
|
-
actionUiMap.set(String(requested.order), uiUniqueIdentifier);
|
|
1905
|
-
const insertInputs = buildTypedInputs(requested, actionDefinition.schema);
|
|
1906
|
-
// A later step in this same manifest may reference this one; its identity
|
|
1907
|
-
// and schema exist now even though the flow does not carry it yet.
|
|
1908
|
-
pendingSteps.push({ name: requested.type, order: String(requested.order), uiUniqueIdentifier, inputs: insertInputs });
|
|
1909
|
-
actionInserts.push({
|
|
1910
|
-
actionTypeSysId: resolved.id,
|
|
1911
|
-
flowSysId: flowId,
|
|
1912
|
-
generationSource: '',
|
|
1913
|
-
type: 'action',
|
|
1914
|
-
order: String(requested.order),
|
|
1915
|
-
parent: '',
|
|
1916
|
-
uiUniqueIdentifier,
|
|
1917
|
-
parentUiId: '',
|
|
1918
|
-
metadata: JSON.stringify(parseMaybeJson(actionDefinition.definition.metadata, {})),
|
|
1919
|
-
inputs: insertInputs,
|
|
1920
|
-
});
|
|
1921
|
-
changedActionInputs.set(uiUniqueIdentifier, new Set(Object.keys(requested.inputs || {})));
|
|
1922
|
-
for (const [input, after] of Object.entries(requested.inputs || {})) {
|
|
1923
|
-
changes.push({ component: 'action', order: requested.order, type: requested.type, input, before: null, after });
|
|
1924
|
-
collectPills(after, uiUniqueIdentifier, input);
|
|
1925
|
-
}
|
|
1926
|
-
} else {
|
|
1927
|
-
const existing = await resolveExistingAction(sdk, existingActions, requested, index);
|
|
1928
|
-
const update = buildActionUpdate(existing, requested, index);
|
|
1929
|
-
actionUpdates.push(update);
|
|
1930
|
-
const uiId = stringValue(existing.uiUniqueIdentifier || existing.ui_unique_identifier);
|
|
1931
|
-
if (actionTargets.has(uiId)) throw new Error(`Duplicate action update for order ${requested.order}; combine input changes in one action entry`);
|
|
1932
|
-
actionTargets.set(uiId, existing);
|
|
1933
|
-
changedActionInputs.set(uiId, new Set(Object.keys(requested.inputs)));
|
|
1934
|
-
for (const [input, after] of Object.entries(requested.inputs)) {
|
|
1935
|
-
changes.push({ component: 'action', order: requested.order, type: requested.type, input, before: inputRawValue(inputList(existing).find(field => field.name === input)), after });
|
|
1936
|
-
collectPills(after, uiId, input);
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
2212
|
+
await planManifestSteps({ manifest, beforeDefinition, existingActions, existingOrders, actionUiMap, logicUiMap, pendingSteps, idFactory, sdk, instance, scope, flowId, actionInserts, actionUpdates, flowLogicInserts, actionTargets, changedActionInputs, changes, collectPills });
|
|
1940
2213
|
|
|
1941
2214
|
const savedStages = stageList(beforeDefinition);
|
|
1942
2215
|
const savedStageById = new Map(savedStages.map(stage => [stringValue(stage.stageId || stage.stage_id), stage]));
|
|
@@ -2011,96 +2284,6 @@ export async function updateFlowFromManifest(sdk, instance, identifier, inputMan
|
|
|
2011
2284
|
changes.push({ component: 'flowVariable', input: name, before: null, after: { label, type, order: varOrder } });
|
|
2012
2285
|
}
|
|
2013
2286
|
|
|
2014
|
-
// Handle flowLogics insertion and update
|
|
2015
|
-
const requestedLogics = manifest.flowLogics || manifest.logic || [];
|
|
2016
|
-
const logicTypeKey = t => String(t || '').toLowerCase().trim();
|
|
2017
|
-
const logicUiMap = new Map(); // order -> uiUniqueIdentifier
|
|
2018
|
-
|
|
2019
|
-
for (const [logicIdx, l] of requestedLogics.entries()) {
|
|
2020
|
-
const lType = logicTypeKey(l.type || l.name);
|
|
2021
|
-
const logicDef = FLOW_LOGIC_DEFINITIONS[lType] || {
|
|
2022
|
-
id: l.definitionId || l.id || '',
|
|
2023
|
-
name: l.name || l.type,
|
|
2024
|
-
type: (l.type || '').toUpperCase(),
|
|
2025
|
-
description: '',
|
|
2026
|
-
compilationClass: '',
|
|
2027
|
-
order: l.order || logicIdx + 1,
|
|
2028
|
-
connectedTo: l.connectedTo || '',
|
|
2029
|
-
attributes: 'allow_children=true,allow_siblings=true,'
|
|
2030
|
-
};
|
|
2031
|
-
|
|
2032
|
-
const uiUniqueIdentifier = l.uiUniqueIdentifier || idFactory();
|
|
2033
|
-
logicUiMap.set(String(l.order), uiUniqueIdentifier);
|
|
2034
|
-
const parentUiId = l.parentUiId || (l.parent ? (logicUiMap.get(String(l.parent)) || l.parent) : '');
|
|
2035
|
-
const connectedTo = l.connectedTo || (l.connectedToOrder ? (logicUiMap.get(String(l.connectedToOrder)) || l.connectedToOrder) : logicDef.connectedTo);
|
|
2036
|
-
|
|
2037
|
-
let resolvedCondition = String(l.condition || '').replace(/\{\{(?:step_)?(\d+)\.([^}]+)\}\}/g, (match, order, field) => {
|
|
2038
|
-
const ui = actionUiMap.get(String(order)) || logicUiMap.get(String(order));
|
|
2039
|
-
return ui ? '{{' + ui + '.' + field + '}}' : match;
|
|
2040
|
-
});
|
|
2041
|
-
|
|
2042
|
-
const inputs = [];
|
|
2043
|
-
collectPills(resolvedCondition, uiUniqueIdentifier, 'condition');
|
|
2044
|
-
|
|
2045
|
-
if (lType === 'if' || lType === 'else if') {
|
|
2046
|
-
inputs.push({
|
|
2047
|
-
name: 'condition_name',
|
|
2048
|
-
value: { schemaless: false, schemalessValue: '', value: l.condition_name || l.conditionName || l.label || '' }
|
|
2049
|
-
});
|
|
2050
|
-
inputs.push({
|
|
2051
|
-
name: 'condition',
|
|
2052
|
-
value: { schemaless: false, schemalessValue: '', value: resolvedCondition }
|
|
2053
|
-
});
|
|
2054
|
-
}
|
|
2055
|
-
|
|
2056
|
-
const flowVarsArray = [];
|
|
2057
|
-
if (lType === 'set flow variables' && l.values) {
|
|
2058
|
-
for (const [varName, varVal] of Object.entries(l.values)) {
|
|
2059
|
-
flowVarsArray.push({
|
|
2060
|
-
id: '',
|
|
2061
|
-
name: varName,
|
|
2062
|
-
children: [],
|
|
2063
|
-
displayValue: { value: '' },
|
|
2064
|
-
value: { schemaless: false, schemalessValue: '', value: String(varVal) }
|
|
2065
|
-
});
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
flowLogicInserts.push({
|
|
2070
|
-
order: String(l.order || logicIdx + 1),
|
|
2071
|
-
uiUniqueIdentifier,
|
|
2072
|
-
parent: parentUiId,
|
|
2073
|
-
parentUiId,
|
|
2074
|
-
connectedTo,
|
|
2075
|
-
metadata: '{"predicates":[]}',
|
|
2076
|
-
flowSysId: flowId,
|
|
2077
|
-
generationSource: '',
|
|
2078
|
-
definitionId: logicDef.id,
|
|
2079
|
-
type: 'flowlogic',
|
|
2080
|
-
inputs,
|
|
2081
|
-
outputsToAssign: [],
|
|
2082
|
-
...(flowVarsArray.length ? { flowVariables: flowVarsArray } : {}),
|
|
2083
|
-
flowLogicDefinition: {
|
|
2084
|
-
id: logicDef.id,
|
|
2085
|
-
name: logicDef.name,
|
|
2086
|
-
description: logicDef.description,
|
|
2087
|
-
connectedTo: logicDef.connectedTo,
|
|
2088
|
-
quiescence: 'never',
|
|
2089
|
-
compilationClass: logicDef.compilationClass,
|
|
2090
|
-
order: logicDef.order,
|
|
2091
|
-
type: logicDef.type,
|
|
2092
|
-
visible: true,
|
|
2093
|
-
attributes: logicDef.attributes,
|
|
2094
|
-
userCanRead: true,
|
|
2095
|
-
category: '',
|
|
2096
|
-
inputs: [],
|
|
2097
|
-
variables: '[]'
|
|
2098
|
-
}
|
|
2099
|
-
});
|
|
2100
|
-
|
|
2101
|
-
changes.push({ component: 'flowLogic', order: l.order, type: logicDef.name, input: 'insert', before: null, after: { parent: parentUiId, connectedTo } });
|
|
2102
|
-
}
|
|
2103
|
-
|
|
2104
2287
|
// Handle deletions by step order or uiUniqueIdentifier
|
|
2105
2288
|
const rawDeletes = manifest.deleteSteps || manifest.delete || manifest.deleteOrders || [];
|
|
2106
2289
|
const deleteTargets = new Set((Array.isArray(rawDeletes) ? rawDeletes : [rawDeletes]).map(String));
|