snow-flow 10.0.1-dev.431 → 10.0.1-dev.432
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
|
@@ -53,103 +53,6 @@ async function executeFlowPatchMutation(
|
|
|
53
53
|
return resp.data?.data?.global?.snFlowDesigner?.flow || resp.data;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
async function lookupDefinitionParams(client: any, defSysId: string): Promise<any[]> {
|
|
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) {
|
|
65
|
-
try {
|
|
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 }
|
|
68
|
-
});
|
|
69
|
-
const raw = resp.data.result || [];
|
|
70
|
-
if (raw.length === 0) continue;
|
|
71
|
-
const seen = new Set<string>();
|
|
72
|
-
const unique: any[] = [];
|
|
73
|
-
for (const r of raw) {
|
|
74
|
-
const id = r.sys_id || '';
|
|
75
|
-
if (id === defSysId) continue;
|
|
76
|
-
if (id && seen.has(id)) continue;
|
|
77
|
-
const name = r.name || r.element || '';
|
|
78
|
-
if (!name) continue;
|
|
79
|
-
seen.add(id);
|
|
80
|
-
unique.push(r);
|
|
81
|
-
}
|
|
82
|
-
if (unique.length > 0) return unique;
|
|
83
|
-
} catch (_) {}
|
|
84
|
-
}
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function str(v: any): string {
|
|
89
|
-
if (!v) return '';
|
|
90
|
-
if (typeof v === 'string') return v;
|
|
91
|
-
if (typeof v === 'object' && v.value !== undefined) return String(v.value);
|
|
92
|
-
return String(v);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function buildGraphQLInput(p: any, defaultValue?: any, forTrigger?: boolean): any {
|
|
96
|
-
const name = str(p.name) || str(p.element) || '';
|
|
97
|
-
const type = str(p.internal_type) || str(p.type) || 'string';
|
|
98
|
-
const isMandatory = p.mandatory === 'true' || p.mandatory === true;
|
|
99
|
-
const order = parseInt(str(p.order)) || 100;
|
|
100
|
-
const defVal = defaultValue !== undefined ? defaultValue : (str(p.default_value) || '');
|
|
101
|
-
const valueObj = type === 'conditions'
|
|
102
|
-
? { schemaless: false, schemalessValue: '', value: '^EQ' }
|
|
103
|
-
: defVal
|
|
104
|
-
? { schemaless: false, schemalessValue: '', value: String(defVal) }
|
|
105
|
-
: { value: '' };
|
|
106
|
-
const parameter: any = {
|
|
107
|
-
id: str(p.sys_id) || '',
|
|
108
|
-
label: str(p.label) || name,
|
|
109
|
-
name,
|
|
110
|
-
type,
|
|
111
|
-
type_label: str(p.type_label) || '',
|
|
112
|
-
hint: '',
|
|
113
|
-
order,
|
|
114
|
-
extended: false,
|
|
115
|
-
mandatory: isMandatory,
|
|
116
|
-
readonly: p.readonly === 'true' || p.readonly === true,
|
|
117
|
-
maxsize: parseInt(str(p.maxsize)) || 80,
|
|
118
|
-
data_structure: str(p.data_structure) || '',
|
|
119
|
-
reference: str(p.reference) || '',
|
|
120
|
-
reference_display: str(p.reference_display) || '',
|
|
121
|
-
ref_qual: str(p.ref_qual) || '',
|
|
122
|
-
choiceOption: str(p.choice_option) || '',
|
|
123
|
-
table: '',
|
|
124
|
-
columnName: str(p.column_name) || '',
|
|
125
|
-
defaultValue: str(p.default_value) || '',
|
|
126
|
-
use_dependent: p.use_dependent === 'true' || p.use_dependent === true,
|
|
127
|
-
dependent_on: str(p.dependent_on) || '',
|
|
128
|
-
show_ref_finder: false,
|
|
129
|
-
local: false,
|
|
130
|
-
attributes: str(p.attributes) || '',
|
|
131
|
-
sys_class_name: str(p.sys_class_name) || '',
|
|
132
|
-
children: []
|
|
133
|
-
};
|
|
134
|
-
if (!forTrigger) {
|
|
135
|
-
parameter.dynamic = null;
|
|
136
|
-
} else {
|
|
137
|
-
parameter.internal_link = p.internal_link || '';
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (forTrigger) {
|
|
141
|
-
return {
|
|
142
|
-
name, label: str(p.label) || name, internalType: type, mandatory: isMandatory,
|
|
143
|
-
order, valueSysId: '', field_name: name, type,
|
|
144
|
-
children: [], displayValue: { value: '' }, value: valueObj, parameter
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
id: str(p.sys_id) || '', name,
|
|
149
|
-
children: [], displayValue: { value: '' }, value: valueObj, parameter
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
56
|
async function addTriggerViaGraphQL(
|
|
154
57
|
client: any,
|
|
155
58
|
flowId: string,
|
|
@@ -205,18 +108,6 @@ async function addTriggerViaGraphQL(
|
|
|
205
108
|
if (!trigDefId) return { success: false, error: 'Trigger definition not found for: ' + triggerType, steps };
|
|
206
109
|
steps.def_lookup = { id: trigDefId };
|
|
207
110
|
|
|
208
|
-
const params = await lookupDefinitionParams(client, trigDefId);
|
|
209
|
-
steps.params_found = params.length;
|
|
210
|
-
|
|
211
|
-
const gqlInputs = params.map((p: any) => buildGraphQLInput(p, undefined, true));
|
|
212
|
-
|
|
213
|
-
if (gqlInputs.length === 0 && config.triggerType === 'Record') {
|
|
214
|
-
gqlInputs.push(
|
|
215
|
-
buildGraphQLInput({ name: 'table', label: 'Table', internal_type: 'table_name', mandatory: 'true', order: '1' }, undefined, true),
|
|
216
|
-
buildGraphQLInput({ name: 'condition', label: 'Condition', internal_type: 'conditions', mandatory: 'false', order: '100', use_dependent: 'true', dependent_on: 'table' }, undefined, true)
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
111
|
const triggerResponseFields = 'triggerInstances { inserts { sysId uiUniqueIdentifier __typename } updates deletes __typename }';
|
|
221
112
|
try {
|
|
222
113
|
const insertResult = await executeFlowPatchMutation(client, {
|
|
@@ -230,7 +121,7 @@ async function addTriggerViaGraphQL(
|
|
|
230
121
|
type: config.type,
|
|
231
122
|
hasDynamicOutputs: false,
|
|
232
123
|
metadata: '{"predicates":[]}',
|
|
233
|
-
inputs:
|
|
124
|
+
inputs: [],
|
|
234
125
|
outputs: []
|
|
235
126
|
}]
|
|
236
127
|
}
|
|
@@ -317,16 +208,6 @@ async function addActionViaGraphQL(
|
|
|
317
208
|
if (!actionDefId) return { success: false, error: 'Action definition not found for: ' + actionType, steps };
|
|
318
209
|
steps.def_lookup = { id: actionDefId };
|
|
319
210
|
|
|
320
|
-
const params = await lookupDefinitionParams(client, actionDefId);
|
|
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) }));
|
|
323
|
-
|
|
324
|
-
const gqlInputs = params.map((p: any) => {
|
|
325
|
-
const pName = p.name || p.element || '';
|
|
326
|
-
const providedValue = inputs?.[pName];
|
|
327
|
-
return buildGraphQLInput(p, providedValue);
|
|
328
|
-
});
|
|
329
|
-
|
|
330
211
|
const uuid = generateUUID();
|
|
331
212
|
const actionResponseFields = 'actions { inserts { sysId uiUniqueIdentifier __typename } updates deletes __typename }';
|
|
332
213
|
try {
|
|
@@ -343,7 +224,7 @@ async function addActionViaGraphQL(
|
|
|
343
224
|
uiUniqueIdentifier: uuid,
|
|
344
225
|
type: 'action',
|
|
345
226
|
parentUiId: '',
|
|
346
|
-
inputs:
|
|
227
|
+
inputs: []
|
|
347
228
|
}]
|
|
348
229
|
}
|
|
349
230
|
}, actionResponseFields);
|