snow-flow 10.0.1-dev.447 → 10.0.1-dev.449
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
CHANGED
|
@@ -38,14 +38,15 @@ function generateUUID(): string {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
async function getNextOrder(client: any, flowId: string): Promise<number> {
|
|
41
|
+
async function getNextOrder(client: any, flowId: string, parentId?: string): Promise<number> {
|
|
42
42
|
let maxOrder = 0;
|
|
43
|
-
// Query
|
|
43
|
+
// Query elements at the same nesting level (same parent)
|
|
44
|
+
const parentFilter = parentId ? '^parent=' + parentId : '^parentISEMPTY';
|
|
44
45
|
for (const table of ['sys_hub_action_instance', 'sys_hub_flow_logic', 'sys_hub_sub_flow_instance']) {
|
|
45
46
|
try {
|
|
46
47
|
const resp = await client.get('/api/now/table/' + table, {
|
|
47
48
|
params: {
|
|
48
|
-
sysparm_query: 'flow=' + flowId + '^ORDERBYDESCorder',
|
|
49
|
+
sysparm_query: 'flow=' + flowId + parentFilter + '^ORDERBYDESCorder',
|
|
49
50
|
sysparm_fields: 'order',
|
|
50
51
|
sysparm_limit: 1
|
|
51
52
|
}
|
|
@@ -285,7 +286,7 @@ async function addActionViaGraphQL(
|
|
|
285
286
|
}
|
|
286
287
|
|
|
287
288
|
const uuid = generateUUID();
|
|
288
|
-
const resolvedOrder = order || await getNextOrder(client, flowId);
|
|
289
|
+
const resolvedOrder = order || await getNextOrder(client, flowId, parentUiId);
|
|
289
290
|
const actionResponseFields = 'actions { inserts { sysId uiUniqueIdentifier __typename } updates deletes __typename }';
|
|
290
291
|
try {
|
|
291
292
|
const result = await executeFlowPatchMutation(client, {
|
|
@@ -386,7 +387,7 @@ async function addFlowLogicViaGraphQL(
|
|
|
386
387
|
if (!defId) return { success: false, error: 'Flow logic definition not found for: ' + logicType, steps };
|
|
387
388
|
|
|
388
389
|
const uuid = generateUUID();
|
|
389
|
-
const resolvedOrder = order || await getNextOrder(client, flowId);
|
|
390
|
+
const resolvedOrder = order || await getNextOrder(client, flowId, parentUiId);
|
|
390
391
|
const logicResponseFields = 'flowLogics { inserts { sysId uiUniqueIdentifier __typename } updates deletes __typename }';
|
|
391
392
|
try {
|
|
392
393
|
const result = await executeFlowPatchMutation(client, {
|
|
@@ -494,7 +495,7 @@ async function addSubflowCallViaGraphQL(
|
|
|
494
495
|
if (!subflowName) subflowName = subflowId;
|
|
495
496
|
|
|
496
497
|
const uuid = generateUUID();
|
|
497
|
-
const resolvedOrder = order || await getNextOrder(client, flowId);
|
|
498
|
+
const resolvedOrder = order || await getNextOrder(client, flowId, parentUiId);
|
|
498
499
|
const subflowResponseFields = 'subflows { inserts { sysId uiUniqueIdentifier __typename } updates deletes __typename }';
|
|
499
500
|
try {
|
|
500
501
|
const result = await executeFlowPatchMutation(client, {
|
|
@@ -802,7 +803,7 @@ export const toolDefinition: MCPToolDefinition = {
|
|
|
802
803
|
},
|
|
803
804
|
logic_type: {
|
|
804
805
|
type: 'string',
|
|
805
|
-
description: 'Flow logic type for add_flow_logic. Looked up dynamically in sys_hub_flow_logic_definition. Common values: IF, FOR_EACH, DO_UNTIL, SWITCH'
|
|
806
|
+
description: 'Flow logic type for add_flow_logic. Looked up dynamically in sys_hub_flow_logic_definition. Common values: IF, FOR_EACH, DO_UNTIL, SWITCH. Note: IF does NOT require an Else block — if the condition is false the flow simply continues to the next step. Only add Else if explicitly requested.'
|
|
806
807
|
},
|
|
807
808
|
logic_inputs: {
|
|
808
809
|
type: 'object',
|
|
@@ -1002,7 +1003,7 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
|
|
|
1002
1003
|
for (var pfai = 0; pfai < activitiesArg.length; pfai++) {
|
|
1003
1004
|
try {
|
|
1004
1005
|
var pfAct = activitiesArg[pfai];
|
|
1005
|
-
var pfActResult = await addActionViaGraphQL(client, flowSysId, pfAct.type || 'log', pfAct.name || ('Action ' + (pfai + 1)), pfAct.inputs, pfai + 1);
|
|
1006
|
+
var pfActResult = await addActionViaGraphQL(client, flowSysId, pfAct.type || 'log', pfAct.name || ('Action ' + (pfai + 1)), pfAct.inputs, undefined, pfai + 1);
|
|
1006
1007
|
if (pfActResult.success) actionsCreated++;
|
|
1007
1008
|
diagnostics['action_' + pfai] = pfActResult;
|
|
1008
1009
|
} catch (_) { /* best-effort */ }
|
|
@@ -1120,7 +1121,7 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
|
|
|
1120
1121
|
for (var ai = 0; ai < activitiesArg.length; ai++) {
|
|
1121
1122
|
var activity = activitiesArg[ai];
|
|
1122
1123
|
try {
|
|
1123
|
-
var taActResult = await addActionViaGraphQL(client, flowSysId, activity.type || 'log', activity.name || ('Action ' + (ai + 1)), activity.inputs, ai + 1);
|
|
1124
|
+
var taActResult = await addActionViaGraphQL(client, flowSysId, activity.type || 'log', activity.name || ('Action ' + (ai + 1)), activity.inputs, undefined, ai + 1);
|
|
1124
1125
|
if (taActResult.success) actionsCreated++;
|
|
1125
1126
|
diagnostics['action_' + ai] = taActResult;
|
|
1126
1127
|
} catch (actError) {
|