snow-flow-test 10.0.1-test.166 → 10.0.1-test.167

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "10.0.1-test.166",
3
+ "version": "10.0.1-test.167",
4
4
  "name": "snow-flow-test",
5
5
  "description": "Snow-Flow Test - ServiceNow Multi-Agent Development Framework",
6
6
  "license": "Elastic-2.0",
@@ -72,6 +72,10 @@ async function executeFlowPatchMutation(
72
72
  return resp.data?.data?.global?.snFlowDesigner?.flow || resp.data;
73
73
  }
74
74
 
75
+ /** Safely extract a string from a ServiceNow Table API value (handles reference objects like {value, link}). */
76
+ const str = (val: any): string =>
77
+ typeof val === 'object' && val !== null ? (val.display_value || val.value || '') : (val || '');
78
+
75
79
  // Type label mapping for parameter definitions
76
80
  const TYPE_LABELS: Record<string, string> = {
77
81
  string: 'String', integer: 'Integer', boolean: 'True/False', choice: 'Choice',
@@ -106,56 +110,59 @@ async function buildActionInputsForInsert(
106
110
  // Fuzzy-match user-provided values to actual field names
107
111
  var resolvedInputs: Record<string, string> = {};
108
112
  if (userValues) {
109
- var paramElements = actionParams.map(function (p: any) { return p.element; });
113
+ var paramElements = actionParams.map(function (p: any) { return str(p.element); });
110
114
  for (var [key, value] of Object.entries(userValues)) {
111
115
  if (paramElements.includes(key)) {
112
116
  resolvedInputs[key] = value;
113
117
  continue;
114
118
  }
115
119
  var match = actionParams.find(function (p: any) {
116
- return p.element.endsWith('_' + key) || p.element === key || (p.label || '').toLowerCase() === key.toLowerCase();
120
+ var el = str(p.element);
121
+ return el.endsWith('_' + key) || el === key || str(p.label).toLowerCase() === key.toLowerCase();
117
122
  });
118
- if (match) resolvedInputs[match.element] = value;
123
+ if (match) resolvedInputs[str(match.element)] = value;
119
124
  else resolvedInputs[key] = value;
120
125
  }
121
126
  }
122
127
 
123
128
  // Build full input objects with parameter definitions (matching UI format)
129
+ // Use str() on all fields — the Table API may return reference fields as objects {value, link}
124
130
  var inputs = actionParams.map(function (rec: any) {
125
- var paramType = rec.internal_type || 'string';
126
- var userVal = resolvedInputs[rec.element] || '';
131
+ var paramType = str(rec.internal_type) || 'string';
132
+ var element = str(rec.element);
133
+ var userVal = resolvedInputs[element] || '';
127
134
  return {
128
- id: rec.sys_id,
129
- name: rec.element,
135
+ id: str(rec.sys_id),
136
+ name: element,
130
137
  children: [],
131
138
  displayValue: { value: '' },
132
139
  value: { schemaless: false, schemalessValue: '', value: userVal },
133
140
  parameter: {
134
- id: rec.sys_id,
135
- label: rec.label || rec.element,
136
- name: rec.element,
141
+ id: str(rec.sys_id),
142
+ label: str(rec.label) || element,
143
+ name: element,
137
144
  type: paramType,
138
145
  type_label: TYPE_LABELS[paramType] || paramType.charAt(0).toUpperCase() + paramType.slice(1),
139
- hint: rec.hint || '',
140
- order: parseInt(rec.order || '0', 10),
141
- extended: rec.extended === 'true',
142
- mandatory: rec.mandatory === 'true',
143
- readonly: rec.read_only === 'true',
144
- maxsize: parseInt(rec.max_length || '8000', 10),
145
- data_structure: rec.data_structure || '',
146
- reference: rec.reference || '',
147
- reference_display: rec.reference_display || '',
148
- ref_qual: rec.ref_qual || '',
149
- choiceOption: rec.choice_option || '',
150
- table: rec.table_name || '',
151
- columnName: rec.column_name || '',
152
- defaultValue: rec.default_value || '',
153
- use_dependent: rec.use_dependent === 'true',
154
- dependent_on: rec.dependent_on || '',
155
- show_ref_finder: rec.show_ref_finder === 'true',
156
- local: rec.local === 'true',
157
- attributes: rec.attributes || '',
158
- sys_class_name: rec.sys_class_name || '',
146
+ hint: str(rec.hint),
147
+ order: parseInt(str(rec.order) || '0', 10),
148
+ extended: str(rec.extended) === 'true',
149
+ mandatory: str(rec.mandatory) === 'true',
150
+ readonly: str(rec.read_only) === 'true',
151
+ maxsize: parseInt(str(rec.max_length) || '8000', 10),
152
+ data_structure: str(rec.data_structure),
153
+ reference: str(rec.reference),
154
+ reference_display: str(rec.reference_display),
155
+ ref_qual: str(rec.ref_qual),
156
+ choiceOption: str(rec.choice_option),
157
+ table: str(rec.table_name),
158
+ columnName: str(rec.column_name),
159
+ defaultValue: str(rec.default_value),
160
+ use_dependent: str(rec.use_dependent) === 'true',
161
+ dependent_on: str(rec.dependent_on),
162
+ show_ref_finder: str(rec.show_ref_finder) === 'true',
163
+ local: str(rec.local) === 'true',
164
+ attributes: str(rec.attributes),
165
+ sys_class_name: str(rec.sys_class_name),
159
166
  children: []
160
167
  }
161
168
  };
@@ -188,8 +195,8 @@ async function findElementsToReorder(
188
195
  }
189
196
  });
190
197
  for (var rec of (resp.data.result || [])) {
191
- var uuid = rec.ui_unique_identifier;
192
- var curOrder = parseInt(rec.order || '0', 10);
198
+ var uuid = str(rec.ui_unique_identifier);
199
+ var curOrder = parseInt(str(rec.order) || '0', 10);
193
200
  if (uuid && curOrder >= targetOrder) {
194
201
  flowLogicUpdates.push({ order: String(curOrder + 1), uiUniqueIdentifier: uuid, type: 'flowlogic' });
195
202
  }
@@ -206,8 +213,8 @@ async function findElementsToReorder(
206
213
  }
207
214
  });
208
215
  for (var rec2 of (resp2.data.result || [])) {
209
- var uuid2 = rec2.ui_unique_identifier;
210
- var curOrder2 = parseInt(rec2.order || '0', 10);
216
+ var uuid2 = str(rec2.ui_unique_identifier);
217
+ var curOrder2 = parseInt(str(rec2.order) || '0', 10);
211
218
  if (uuid2 && curOrder2 >= targetOrder) {
212
219
  actionUpdates.push({ order: String(curOrder2 + 1), uiUniqueIdentifier: uuid2, type: 'action' });
213
220
  }
@@ -224,8 +231,8 @@ async function findElementsToReorder(
224
231
  }
225
232
  });
226
233
  for (var rec3 of (resp3.data.result || [])) {
227
- var uuid3 = rec3.ui_unique_identifier;
228
- var curOrder3 = parseInt(rec3.order || '0', 10);
234
+ var uuid3 = str(rec3.ui_unique_identifier);
235
+ var curOrder3 = parseInt(str(rec3.order) || '0', 10);
229
236
  if (uuid3 && curOrder3 >= targetOrder) {
230
237
  subflowUpdates.push({ order: String(curOrder3 + 1), uiUniqueIdentifier: uuid3, type: 'subflow' });
231
238
  }
@@ -326,9 +333,6 @@ async function addTriggerViaGraphQL(
326
333
  else if (triggerType.endsWith('e')) variations.push(triggerType + 'd');
327
334
  else variations.push(triggerType + 'ed', triggerType + 'd');
328
335
 
329
- // Resolve reference fields that may be objects {display_value, link} or plain strings
330
- const str = (val: any) => typeof val === 'object' && val !== null ? (val.display_value || val.value || '') : (val || '');
331
-
332
336
  const assignFound = (found: any, matched: string) => {
333
337
  trigDefId = found.sys_id;
334
338
  trigName = str(found.name) || triggerType;