snow-flow 10.0.1-dev.438 → 10.0.1-dev.439
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
|
@@ -67,34 +67,47 @@ async function addTriggerViaGraphQL(
|
|
|
67
67
|
let trigName = '';
|
|
68
68
|
let trigType = triggerType;
|
|
69
69
|
let trigCategory = '';
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
|
|
71
|
+
// Build search variations: record_updated → also try record_update, and vice versa
|
|
72
|
+
const variations = [triggerType];
|
|
73
|
+
if (triggerType.endsWith('ed')) variations.push(triggerType.slice(0, -1), triggerType.slice(0, -2));
|
|
74
|
+
else if (triggerType.endsWith('e')) variations.push(triggerType + 'd');
|
|
75
|
+
else variations.push(triggerType + 'ed', triggerType + 'd');
|
|
76
|
+
|
|
77
|
+
const assignFound = (found: any, matched: string) => {
|
|
78
|
+
trigDefId = found.sys_id;
|
|
79
|
+
trigName = found.name || triggerType;
|
|
80
|
+
trigType = found.type || triggerType;
|
|
81
|
+
trigCategory = found.category || '';
|
|
82
|
+
steps.def_lookup = { id: found.sys_id, type: found.type, name: found.name, category: found.category, matched };
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Try exact match on type and name for each variation
|
|
86
|
+
for (const variant of variations) {
|
|
72
87
|
if (trigDefId) break;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
steps.def_lookup = { id: found.sys_id, type: found.type, name: found.name, category: found.category, matched: field + '=' + triggerType };
|
|
89
|
-
}
|
|
90
|
-
} catch (_) {}
|
|
88
|
+
for (const field of ['type', 'name']) {
|
|
89
|
+
if (trigDefId) break;
|
|
90
|
+
try {
|
|
91
|
+
const resp = await client.get('/api/now/table/sys_hub_trigger_definition', {
|
|
92
|
+
params: {
|
|
93
|
+
sysparm_query: field + '=' + variant,
|
|
94
|
+
sysparm_fields: 'sys_id,type,name,category',
|
|
95
|
+
sysparm_display_value: 'true',
|
|
96
|
+
sysparm_limit: 1
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const found = resp.data.result?.[0];
|
|
100
|
+
if (found?.sys_id) assignFound(found, field + '=' + variant);
|
|
101
|
+
} catch (_) {}
|
|
102
|
+
}
|
|
91
103
|
}
|
|
92
|
-
// Fallback: LIKE search
|
|
104
|
+
// Fallback: LIKE search using shortest variation (most likely to match)
|
|
93
105
|
if (!trigDefId) {
|
|
106
|
+
const shortest = variations.reduce((a, b) => a.length <= b.length ? a : b);
|
|
94
107
|
try {
|
|
95
108
|
const resp = await client.get('/api/now/table/sys_hub_trigger_definition', {
|
|
96
109
|
params: {
|
|
97
|
-
sysparm_query: 'typeLIKE' +
|
|
110
|
+
sysparm_query: 'typeLIKE' + shortest + '^ORnameLIKE' + shortest,
|
|
98
111
|
sysparm_fields: 'sys_id,type,name,category',
|
|
99
112
|
sysparm_display_value: 'true',
|
|
100
113
|
sysparm_limit: 5
|
|
@@ -102,13 +115,7 @@ async function addTriggerViaGraphQL(
|
|
|
102
115
|
});
|
|
103
116
|
const results = resp.data.result || [];
|
|
104
117
|
steps.def_lookup_fallback_candidates = results.map((r: any) => ({ sys_id: r.sys_id, type: r.type, name: r.name, category: r.category }));
|
|
105
|
-
if (results[0]?.sys_id)
|
|
106
|
-
trigDefId = results[0].sys_id;
|
|
107
|
-
trigName = results[0].name || triggerType;
|
|
108
|
-
trigType = results[0].type || triggerType;
|
|
109
|
-
trigCategory = results[0].category || '';
|
|
110
|
-
steps.def_lookup = { id: results[0].sys_id, type: results[0].type, name: results[0].name, category: results[0].category, matched: 'LIKE ' + triggerType };
|
|
111
|
-
}
|
|
118
|
+
if (results[0]?.sys_id) assignFound(results[0], 'LIKE ' + shortest);
|
|
112
119
|
} catch (_) {}
|
|
113
120
|
}
|
|
114
121
|
if (!trigDefId) return { success: false, error: 'Trigger definition not found for: ' + triggerType, steps };
|