snow-flow 10.0.1-dev.430 → 10.0.1-dev.431
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
|
@@ -54,16 +54,17 @@ async function executeFlowPatchMutation(
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
async function lookupDefinitionParams(client: any, defSysId: string): Promise<any[]> {
|
|
57
|
-
const
|
|
58
|
-
|
|
57
|
+
const queries = [
|
|
58
|
+
{ table: 'sys_hub_action_type_param', query: 'action_type=' + defSysId },
|
|
59
|
+
{ table: 'sys_hub_action_type_param', query: 'model=' + defSysId },
|
|
60
|
+
{ table: 'sys_hub_action_input_param', query: 'action_type=' + defSysId },
|
|
61
|
+
{ table: 'sys_hub_action_input_param', query: 'model=' + defSysId },
|
|
62
|
+
];
|
|
63
|
+
const fields = 'sys_id,name,element,label,internal_type,type,type_label,order,mandatory,readonly,maxsize,data_structure,reference,reference_display,ref_qual,choice_option,column_name,default_value,use_dependent,dependent_on,internal_link,attributes,sys_class_name';
|
|
64
|
+
for (const q of queries) {
|
|
59
65
|
try {
|
|
60
|
-
const resp = await client.get('/api/now/table/' + table, {
|
|
61
|
-
params: {
|
|
62
|
-
sysparm_query: 'model=' + defSysId + '^ORaction_type=' + defSysId,
|
|
63
|
-
sysparm_fields: 'sys_id,name,element,label,internal_type,type,type_label,order,mandatory,readonly,maxsize,data_structure,reference,reference_display,ref_qual,choice_option,column_name,default_value,use_dependent,dependent_on,internal_link,attributes,sys_class_name',
|
|
64
|
-
sysparm_display_value: 'false',
|
|
65
|
-
sysparm_limit: 50
|
|
66
|
-
}
|
|
66
|
+
const resp = await client.get('/api/now/table/' + q.table, {
|
|
67
|
+
params: { sysparm_query: q.query, sysparm_fields: fields, sysparm_display_value: 'false', sysparm_limit: 50 }
|
|
67
68
|
});
|
|
68
69
|
const raw = resp.data.result || [];
|
|
69
70
|
if (raw.length === 0) continue;
|
|
@@ -73,6 +74,8 @@ async function lookupDefinitionParams(client: any, defSysId: string): Promise<an
|
|
|
73
74
|
const id = r.sys_id || '';
|
|
74
75
|
if (id === defSysId) continue;
|
|
75
76
|
if (id && seen.has(id)) continue;
|
|
77
|
+
const name = r.name || r.element || '';
|
|
78
|
+
if (!name) continue;
|
|
76
79
|
seen.add(id);
|
|
77
80
|
unique.push(r);
|
|
78
81
|
}
|
|
@@ -170,27 +173,34 @@ async function addTriggerViaGraphQL(
|
|
|
170
173
|
const config = triggerMap[triggerType] || triggerMap['record_create_or_update'];
|
|
171
174
|
|
|
172
175
|
let trigDefId: string | null = null;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
const defTables = ['sys_hub_action_type_definition', 'sys_hub_trigger_definition'];
|
|
177
|
+
for (const defTable of defTables) {
|
|
178
|
+
if (trigDefId) break;
|
|
179
|
+
for (const defName of config.defNames) {
|
|
180
|
+
try {
|
|
181
|
+
const resp = await client.get('/api/now/table/' + defTable, {
|
|
182
|
+
params: { sysparm_query: 'internal_name=' + defName, sysparm_fields: 'sys_id', sysparm_limit: 1 }
|
|
183
|
+
});
|
|
184
|
+
trigDefId = resp.data.result?.[0]?.sys_id || null;
|
|
185
|
+
if (trigDefId) break;
|
|
186
|
+
} catch (_) {}
|
|
187
|
+
}
|
|
181
188
|
}
|
|
182
189
|
if (!trigDefId) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
for (const defTable of defTables) {
|
|
191
|
+
if (trigDefId) break;
|
|
192
|
+
try {
|
|
193
|
+
const resp = await client.get('/api/now/table/' + defTable, {
|
|
194
|
+
params: {
|
|
195
|
+
sysparm_query: 'internal_nameLIKE' + config.type + '^ORnameLIKE' + config.name,
|
|
196
|
+
sysparm_fields: 'sys_id,internal_name', sysparm_limit: 10
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
for (const r of (resp.data.result || [])) {
|
|
200
|
+
if ((r.internal_name || '').indexOf(config.type) > -1) { trigDefId = r.sys_id; break; }
|
|
188
201
|
}
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
if ((r.internal_name || '').indexOf(config.type) > -1) { trigDefId = r.sys_id; break; }
|
|
192
|
-
}
|
|
193
|
-
} catch (_) {}
|
|
202
|
+
} catch (_) {}
|
|
203
|
+
}
|
|
194
204
|
}
|
|
195
205
|
if (!trigDefId) return { success: false, error: 'Trigger definition not found for: ' + triggerType, steps };
|
|
196
206
|
steps.def_lookup = { id: trigDefId };
|
|
@@ -309,6 +319,7 @@ async function addActionViaGraphQL(
|
|
|
309
319
|
|
|
310
320
|
const params = await lookupDefinitionParams(client, actionDefId);
|
|
311
321
|
steps.params_found = params.length;
|
|
322
|
+
steps.params_detail = params.map((p: any) => ({ sys_id: p.sys_id, name: p.name || p.element, type: str(p.internal_type) || str(p.type) }));
|
|
312
323
|
|
|
313
324
|
const gqlInputs = params.map((p: any) => {
|
|
314
325
|
const pName = p.name || p.element || '';
|