snow-flow 10.0.1-dev.481 → 10.0.1-dev.482
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
|
@@ -896,8 +896,8 @@ async function addTriggerViaGraphQL(
|
|
|
896
896
|
steps.insert = { success: !!triggerId, triggerId, triggerUiId };
|
|
897
897
|
if (!triggerId) return { success: false, steps, error: 'GraphQL trigger INSERT returned no trigger ID' };
|
|
898
898
|
|
|
899
|
-
// Step 2: UPDATE with actual table and condition values (matching UI behavior
|
|
900
|
-
// The UI sends: table with displayField+displayValue+value, condition with
|
|
899
|
+
// Step 2: UPDATE with actual table and condition values (matching UI behavior)
|
|
900
|
+
// The UI sends: table with displayField+displayValue+value, condition with displayField+displayValue(empty)+value, metadata with predicates
|
|
901
901
|
if (table) {
|
|
902
902
|
try {
|
|
903
903
|
var tableDisplayName = '';
|
|
@@ -911,6 +911,30 @@ async function addTriggerViaGraphQL(
|
|
|
911
911
|
tableDisplayName = table.charAt(0).toUpperCase() + table.slice(1).replace(/_/g, ' ');
|
|
912
912
|
}
|
|
913
913
|
|
|
914
|
+
// Build condition predicates via query_parse API (same as UI)
|
|
915
|
+
var conditionValue = condition || '^EQ';
|
|
916
|
+
var predicatesJson = '[]';
|
|
917
|
+
if (conditionValue && conditionValue !== '^EQ') {
|
|
918
|
+
try {
|
|
919
|
+
var qpResp = await client.get('/api/now/ui/query_parse/' + table + '/map', {
|
|
920
|
+
params: { table: table, sysparm_query: conditionValue }
|
|
921
|
+
});
|
|
922
|
+
var qpResult = qpResp.data?.result;
|
|
923
|
+
if (qpResult) {
|
|
924
|
+
predicatesJson = typeof qpResult === 'string' ? qpResult : JSON.stringify(qpResult);
|
|
925
|
+
}
|
|
926
|
+
} catch (_) {
|
|
927
|
+
// Fallback: build minimal predicates from parsed condition
|
|
928
|
+
var parsedClauses = parseEncodedQuery(conditionValue);
|
|
929
|
+
if (parsedClauses.length > 0) {
|
|
930
|
+
var minPredicates = parsedClauses.map(function (c) {
|
|
931
|
+
return { field: c.field, operator: c.operator, value: c.value };
|
|
932
|
+
});
|
|
933
|
+
predicatesJson = JSON.stringify(minPredicates);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
|
|
914
938
|
var trigUpdateInputs: any[] = [
|
|
915
939
|
{
|
|
916
940
|
name: 'table',
|
|
@@ -920,7 +944,9 @@ async function addTriggerViaGraphQL(
|
|
|
920
944
|
},
|
|
921
945
|
{
|
|
922
946
|
name: 'condition',
|
|
923
|
-
|
|
947
|
+
displayField: '',
|
|
948
|
+
displayValue: { value: '' },
|
|
949
|
+
value: { schemaless: false, schemalessValue: '', value: conditionValue }
|
|
924
950
|
}
|
|
925
951
|
];
|
|
926
952
|
|
|
@@ -929,11 +955,12 @@ async function addTriggerViaGraphQL(
|
|
|
929
955
|
triggerInstances: {
|
|
930
956
|
update: [{
|
|
931
957
|
id: triggerId,
|
|
932
|
-
inputs: trigUpdateInputs
|
|
958
|
+
inputs: trigUpdateInputs,
|
|
959
|
+
metadata: '{"predicates":' + predicatesJson + '}'
|
|
933
960
|
}]
|
|
934
961
|
}
|
|
935
962
|
}, triggerResponseFields);
|
|
936
|
-
steps.trigger_update = { success: true, table: table, tableDisplay: tableDisplayName };
|
|
963
|
+
steps.trigger_update = { success: true, table: table, tableDisplay: tableDisplayName, predicates: predicatesJson };
|
|
937
964
|
} catch (updateErr: any) {
|
|
938
965
|
steps.trigger_update = { success: false, error: updateErr.message };
|
|
939
966
|
// Trigger was created — update failure is non-fatal
|
|
@@ -1259,6 +1286,14 @@ async function getFlowTriggerInfo(
|
|
|
1259
1286
|
var pfData = pfRaw.result || pfRaw;
|
|
1260
1287
|
debug.processflow_keys = pfData && typeof pfData === 'object' ? Object.keys(pfData).slice(0, 20) : null;
|
|
1261
1288
|
|
|
1289
|
+
// ProcessFlow API wraps actual flow data inside a "data" property
|
|
1290
|
+
// e.g. {data: {triggerInstances: [...]}, errorMessage, errorCode, integrationsPluginActive}
|
|
1291
|
+
if (pfData.data && typeof pfData.data === 'object' && !pfData.triggerInstances) {
|
|
1292
|
+
pfData = pfData.data;
|
|
1293
|
+
debug.processflow_unwrapped = true;
|
|
1294
|
+
debug.processflow_data_keys = typeof pfData === 'object' ? Object.keys(pfData).slice(0, 20) : null;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1262
1297
|
var pfTriggers = pfData?.triggerInstances || pfData?.trigger_instances || pfData?.triggers || [];
|
|
1263
1298
|
if (!Array.isArray(pfTriggers) && pfData?.model?.triggerInstances) {
|
|
1264
1299
|
pfTriggers = pfData.model.triggerInstances;
|
|
@@ -1986,6 +2021,13 @@ async function addFlowLogicViaGraphQL(
|
|
|
1986
2021
|
[/(\}\})\s+ends\s+with\s+/gi, '$1ENDSWITH'],
|
|
1987
2022
|
[/(\}\})\s+greater\s+than\s+/gi, '$1>'],
|
|
1988
2023
|
[/(\}\})\s+less\s+than\s+/gi, '$1<'],
|
|
2024
|
+
// Symbol operators: == / === / != / !== / >= / <= / > / < with optional spaces
|
|
2025
|
+
[/(\}\})\s*===?\s*/g, '$1='],
|
|
2026
|
+
[/(\}\})\s*!==?\s*/g, '$1!='],
|
|
2027
|
+
[/(\}\})\s*>=\s*/g, '$1>='],
|
|
2028
|
+
[/(\}\})\s*<=\s*/g, '$1<='],
|
|
2029
|
+
[/(\}\})\s*>\s*/g, '$1>'],
|
|
2030
|
+
[/(\}\})\s*<\s*/g, '$1<'],
|
|
1989
2031
|
];
|
|
1990
2032
|
var pillWordOriginal = rawCondition;
|
|
1991
2033
|
for (var pwi = 0; pwi < PILL_WORD_OPS.length; pwi++) {
|
|
@@ -2119,26 +2161,26 @@ async function addFlowLogicViaGraphQL(
|
|
|
2119
2161
|
steps.label_cache = labelCacheResult.map(function (e: any) { return e.name; });
|
|
2120
2162
|
|
|
2121
2163
|
try {
|
|
2122
|
-
// Match the UI's exact format for condition UPDATE (captured from Flow Designer
|
|
2123
|
-
// when editing a programmatically-created flow):
|
|
2164
|
+
// Match the UI's exact format for condition UPDATE (captured from clean Flow Designer network trace):
|
|
2124
2165
|
// - labelCache.insert: field-level pills with FULL metadata (type, parent_table_name, etc.)
|
|
2125
|
-
// -
|
|
2126
|
-
// - flowLogicDefinition
|
|
2166
|
+
// - Two inputs: condition_name (label) + condition (pill expression)
|
|
2167
|
+
// - No flowLogicDefinition, no displayValue on condition
|
|
2127
2168
|
var updatePatch: any = {
|
|
2128
2169
|
flowId: flowId,
|
|
2129
2170
|
flowLogics: {
|
|
2130
2171
|
update: [{
|
|
2131
2172
|
uiUniqueIdentifier: returnedUuid,
|
|
2132
2173
|
type: 'flowlogic',
|
|
2133
|
-
inputs: [
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2174
|
+
inputs: [
|
|
2175
|
+
{
|
|
2176
|
+
name: 'condition_name',
|
|
2177
|
+
value: { schemaless: false, schemalessValue: '', value: 'label' }
|
|
2178
|
+
},
|
|
2179
|
+
{
|
|
2180
|
+
name: 'condition',
|
|
2181
|
+
value: { schemaless: false, schemalessValue: '', value: transformedCondition }
|
|
2182
|
+
}
|
|
2183
|
+
]
|
|
2142
2184
|
}]
|
|
2143
2185
|
}
|
|
2144
2186
|
};
|