snow-flow 10.0.1-dev.430 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "10.0.1-dev.430",
3
+ "version": "10.0.1-dev.432",
4
4
  "name": "snow-flow",
5
5
  "description": "Snow-Flow - ServiceNow Multi-Agent Development Framework powered by AI",
6
6
  "license": "Elastic-2.0",
@@ -53,100 +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 paramTables = ['sys_hub_action_input', 'sys_hub_action_input_param', 'sys_hub_action_type_param'];
58
- for (const table of paramTables) {
59
- 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
- }
67
- });
68
- const raw = resp.data.result || [];
69
- if (raw.length === 0) continue;
70
- const seen = new Set<string>();
71
- const unique: any[] = [];
72
- for (const r of raw) {
73
- const id = r.sys_id || '';
74
- if (id === defSysId) continue;
75
- if (id && seen.has(id)) continue;
76
- seen.add(id);
77
- unique.push(r);
78
- }
79
- if (unique.length > 0) return unique;
80
- } catch (_) {}
81
- }
82
- return [];
83
- }
84
-
85
- function str(v: any): string {
86
- if (!v) return '';
87
- if (typeof v === 'string') return v;
88
- if (typeof v === 'object' && v.value !== undefined) return String(v.value);
89
- return String(v);
90
- }
91
-
92
- function buildGraphQLInput(p: any, defaultValue?: any, forTrigger?: boolean): any {
93
- const name = str(p.name) || str(p.element) || '';
94
- const type = str(p.internal_type) || str(p.type) || 'string';
95
- const isMandatory = p.mandatory === 'true' || p.mandatory === true;
96
- const order = parseInt(str(p.order)) || 100;
97
- const defVal = defaultValue !== undefined ? defaultValue : (str(p.default_value) || '');
98
- const valueObj = type === 'conditions'
99
- ? { schemaless: false, schemalessValue: '', value: '^EQ' }
100
- : defVal
101
- ? { schemaless: false, schemalessValue: '', value: String(defVal) }
102
- : { value: '' };
103
- const parameter: any = {
104
- id: str(p.sys_id) || '',
105
- label: str(p.label) || name,
106
- name,
107
- type,
108
- type_label: str(p.type_label) || '',
109
- hint: '',
110
- order,
111
- extended: false,
112
- mandatory: isMandatory,
113
- readonly: p.readonly === 'true' || p.readonly === true,
114
- maxsize: parseInt(str(p.maxsize)) || 80,
115
- data_structure: str(p.data_structure) || '',
116
- reference: str(p.reference) || '',
117
- reference_display: str(p.reference_display) || '',
118
- ref_qual: str(p.ref_qual) || '',
119
- choiceOption: str(p.choice_option) || '',
120
- table: '',
121
- columnName: str(p.column_name) || '',
122
- defaultValue: str(p.default_value) || '',
123
- use_dependent: p.use_dependent === 'true' || p.use_dependent === true,
124
- dependent_on: str(p.dependent_on) || '',
125
- show_ref_finder: false,
126
- local: false,
127
- attributes: str(p.attributes) || '',
128
- sys_class_name: str(p.sys_class_name) || '',
129
- children: []
130
- };
131
- if (!forTrigger) {
132
- parameter.dynamic = null;
133
- } else {
134
- parameter.internal_link = p.internal_link || '';
135
- }
136
-
137
- if (forTrigger) {
138
- return {
139
- name, label: str(p.label) || name, internalType: type, mandatory: isMandatory,
140
- order, valueSysId: '', field_name: name, type,
141
- children: [], displayValue: { value: '' }, value: valueObj, parameter
142
- };
143
- }
144
- return {
145
- id: str(p.sys_id) || '', name,
146
- children: [], displayValue: { value: '' }, value: valueObj, parameter
147
- };
148
- }
149
-
150
56
  async function addTriggerViaGraphQL(
151
57
  client: any,
152
58
  flowId: string,
@@ -170,43 +76,38 @@ async function addTriggerViaGraphQL(
170
76
  const config = triggerMap[triggerType] || triggerMap['record_create_or_update'];
171
77
 
172
78
  let trigDefId: string | null = null;
173
- for (const defName of config.defNames) {
174
- try {
175
- const resp = await client.get('/api/now/table/sys_hub_action_type_definition', {
176
- params: { sysparm_query: 'internal_name=' + defName, sysparm_fields: 'sys_id', sysparm_limit: 1 }
177
- });
178
- trigDefId = resp.data.result?.[0]?.sys_id || null;
179
- if (trigDefId) break;
180
- } catch (_) {}
79
+ const defTables = ['sys_hub_action_type_definition', 'sys_hub_trigger_definition'];
80
+ for (const defTable of defTables) {
81
+ if (trigDefId) break;
82
+ for (const defName of config.defNames) {
83
+ try {
84
+ const resp = await client.get('/api/now/table/' + defTable, {
85
+ params: { sysparm_query: 'internal_name=' + defName, sysparm_fields: 'sys_id', sysparm_limit: 1 }
86
+ });
87
+ trigDefId = resp.data.result?.[0]?.sys_id || null;
88
+ if (trigDefId) break;
89
+ } catch (_) {}
90
+ }
181
91
  }
182
92
  if (!trigDefId) {
183
- try {
184
- const resp = await client.get('/api/now/table/sys_hub_action_type_definition', {
185
- params: {
186
- sysparm_query: 'internal_nameSTARTSWITHsn_fd.trigger^internal_nameLIKE' + config.type,
187
- sysparm_fields: 'sys_id,internal_name', sysparm_limit: 10
93
+ for (const defTable of defTables) {
94
+ if (trigDefId) break;
95
+ try {
96
+ const resp = await client.get('/api/now/table/' + defTable, {
97
+ params: {
98
+ sysparm_query: 'internal_nameLIKE' + config.type + '^ORnameLIKE' + config.name,
99
+ sysparm_fields: 'sys_id,internal_name', sysparm_limit: 10
100
+ }
101
+ });
102
+ for (const r of (resp.data.result || [])) {
103
+ if ((r.internal_name || '').indexOf(config.type) > -1) { trigDefId = r.sys_id; break; }
188
104
  }
189
- });
190
- for (const r of (resp.data.result || [])) {
191
- if ((r.internal_name || '').indexOf(config.type) > -1) { trigDefId = r.sys_id; break; }
192
- }
193
- } catch (_) {}
105
+ } catch (_) {}
106
+ }
194
107
  }
195
108
  if (!trigDefId) return { success: false, error: 'Trigger definition not found for: ' + triggerType, steps };
196
109
  steps.def_lookup = { id: trigDefId };
197
110
 
198
- const params = await lookupDefinitionParams(client, trigDefId);
199
- steps.params_found = params.length;
200
-
201
- const gqlInputs = params.map((p: any) => buildGraphQLInput(p, undefined, true));
202
-
203
- if (gqlInputs.length === 0 && config.triggerType === 'Record') {
204
- gqlInputs.push(
205
- buildGraphQLInput({ name: 'table', label: 'Table', internal_type: 'table_name', mandatory: 'true', order: '1' }, undefined, true),
206
- buildGraphQLInput({ name: 'condition', label: 'Condition', internal_type: 'conditions', mandatory: 'false', order: '100', use_dependent: 'true', dependent_on: 'table' }, undefined, true)
207
- );
208
- }
209
-
210
111
  const triggerResponseFields = 'triggerInstances { inserts { sysId uiUniqueIdentifier __typename } updates deletes __typename }';
211
112
  try {
212
113
  const insertResult = await executeFlowPatchMutation(client, {
@@ -220,7 +121,7 @@ async function addTriggerViaGraphQL(
220
121
  type: config.type,
221
122
  hasDynamicOutputs: false,
222
123
  metadata: '{"predicates":[]}',
223
- inputs: gqlInputs,
124
+ inputs: [],
224
125
  outputs: []
225
126
  }]
226
127
  }
@@ -307,15 +208,6 @@ async function addActionViaGraphQL(
307
208
  if (!actionDefId) return { success: false, error: 'Action definition not found for: ' + actionType, steps };
308
209
  steps.def_lookup = { id: actionDefId };
309
210
 
310
- const params = await lookupDefinitionParams(client, actionDefId);
311
- steps.params_found = params.length;
312
-
313
- const gqlInputs = params.map((p: any) => {
314
- const pName = p.name || p.element || '';
315
- const providedValue = inputs?.[pName];
316
- return buildGraphQLInput(p, providedValue);
317
- });
318
-
319
211
  const uuid = generateUUID();
320
212
  const actionResponseFields = 'actions { inserts { sysId uiUniqueIdentifier __typename } updates deletes __typename }';
321
213
  try {
@@ -332,7 +224,7 @@ async function addActionViaGraphQL(
332
224
  uiUniqueIdentifier: uuid,
333
225
  type: 'action',
334
226
  parentUiId: '',
335
- inputs: gqlInputs
227
+ inputs: []
336
228
  }]
337
229
  }
338
230
  }, actionResponseFields);