snow-flow-test 10.0.1-test.142 → 10.0.1-test.144

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.142",
3
+ "version": "10.0.1-test.144",
4
4
  "name": "snow-flow-test",
5
5
  "description": "Snow-Flow Test - ServiceNow Multi-Agent Development Framework",
6
6
  "license": "Elastic-2.0",
@@ -61,6 +61,7 @@ async function lookupDefinitionParams(client: any, defSysId: string): Promise<an
61
61
  params: {
62
62
  sysparm_query: 'model=' + defSysId + '^ORaction_type=' + defSysId,
63
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',
64
65
  sysparm_limit: 50
65
66
  }
66
67
  });
@@ -71,57 +72,68 @@ async function lookupDefinitionParams(client: any, defSysId: string): Promise<an
71
72
  return [];
72
73
  }
73
74
 
74
- function buildGraphQLInput(p: any, defaultValue?: any): any {
75
- const name = p.name || p.element || '';
76
- const type = p.internal_type || p.type || 'string';
75
+ function str(v: any): string {
76
+ if (!v) return '';
77
+ if (typeof v === 'string') return v;
78
+ if (typeof v === 'object' && v.value !== undefined) return String(v.value);
79
+ return String(v);
80
+ }
81
+
82
+ function buildGraphQLInput(p: any, defaultValue?: any, forTrigger?: boolean): any {
83
+ const name = str(p.name) || str(p.element) || '';
84
+ const type = str(p.internal_type) || str(p.type) || 'string';
77
85
  const isMandatory = p.mandatory === 'true' || p.mandatory === true;
78
- const order = parseInt(p.order) || 100;
79
- const defVal = defaultValue !== undefined ? defaultValue : (p.default_value || '');
80
- return {
81
- id: p.sys_id || '',
86
+ const order = parseInt(str(p.order)) || 100;
87
+ const defVal = defaultValue !== undefined ? defaultValue : (str(p.default_value) || '');
88
+ const valueObj = type === 'conditions'
89
+ ? { schemaless: false, schemalessValue: '', value: '^EQ' }
90
+ : defVal
91
+ ? { schemaless: false, schemalessValue: '', value: String(defVal) }
92
+ : { value: '' };
93
+ const parameter: any = {
94
+ id: str(p.sys_id) || '',
95
+ label: str(p.label) || name,
82
96
  name,
83
- label: p.label || name,
84
- internalType: type,
85
- mandatory: isMandatory,
86
- order,
87
- valueSysId: '',
88
- field_name: name,
89
97
  type,
90
- children: [],
91
- displayValue: { value: '' },
92
- value: type === 'conditions'
93
- ? { schemaless: false, schemalessValue: '', value: '^EQ' }
94
- : defVal
95
- ? { schemaless: false, schemalessValue: '', value: String(defVal) }
96
- : { value: '' },
97
- parameter: {
98
- id: p.sys_id || '',
99
- label: p.label || name,
100
- name,
101
- type,
102
- type_label: p.type_label || '',
103
- order,
104
- extended: false,
105
- mandatory: isMandatory,
106
- readonly: p.readonly === 'true' || p.readonly === true,
107
- maxsize: parseInt(p.maxsize) || 80,
108
- data_structure: p.data_structure || '',
109
- reference: p.reference || '',
110
- reference_display: p.reference_display || '',
111
- ref_qual: p.ref_qual || '',
112
- choiceOption: p.choice_option || '',
113
- table: '',
114
- columnName: p.column_name || '',
115
- defaultValue: p.default_value || '',
116
- use_dependent: p.use_dependent === 'true' || p.use_dependent === true,
117
- dependent_on: p.dependent_on || '',
118
- internal_link: p.internal_link || '',
119
- show_ref_finder: false,
120
- local: false,
121
- attributes: p.attributes || '',
122
- sys_class_name: p.sys_class_name || '',
123
- children: []
124
- }
98
+ type_label: str(p.type_label) || '',
99
+ hint: '',
100
+ order,
101
+ extended: false,
102
+ mandatory: isMandatory,
103
+ readonly: p.readonly === 'true' || p.readonly === true,
104
+ maxsize: parseInt(str(p.maxsize)) || 80,
105
+ data_structure: str(p.data_structure) || '',
106
+ reference: str(p.reference) || '',
107
+ reference_display: str(p.reference_display) || '',
108
+ ref_qual: str(p.ref_qual) || '',
109
+ choiceOption: str(p.choice_option) || '',
110
+ table: '',
111
+ columnName: str(p.column_name) || '',
112
+ defaultValue: str(p.default_value) || '',
113
+ use_dependent: p.use_dependent === 'true' || p.use_dependent === true,
114
+ dependent_on: str(p.dependent_on) || '',
115
+ show_ref_finder: false,
116
+ local: false,
117
+ attributes: str(p.attributes) || '',
118
+ sys_class_name: str(p.sys_class_name) || '',
119
+ children: []
120
+ };
121
+ if (!forTrigger) {
122
+ parameter.dynamic = null;
123
+ } else {
124
+ parameter.internal_link = p.internal_link || '';
125
+ }
126
+
127
+ if (forTrigger) {
128
+ return {
129
+ name, label: str(p.label) || name, internalType: type, mandatory: isMandatory,
130
+ order, valueSysId: '', field_name: name, type,
131
+ children: [], displayValue: { value: '' }, value: valueObj, parameter
132
+ };
133
+ }
134
+ return {
135
+ id: str(p.sys_id) || '', name,
136
+ children: [], displayValue: { value: '' }, value: valueObj, parameter
125
137
  };
126
138
  }
127
139
 
@@ -176,12 +188,12 @@ async function addTriggerViaGraphQL(
176
188
  const params = await lookupDefinitionParams(client, trigDefId);
177
189
  steps.params_found = params.length;
178
190
 
179
- const gqlInputs = params.map((p: any) => buildGraphQLInput(p));
191
+ const gqlInputs = params.map((p: any) => buildGraphQLInput(p, undefined, true));
180
192
 
181
193
  if (gqlInputs.length === 0 && config.triggerType === 'Record') {
182
194
  gqlInputs.push(
183
- buildGraphQLInput({ name: 'table', label: 'Table', internal_type: 'table_name', mandatory: 'true', order: '1' }),
184
- buildGraphQLInput({ name: 'condition', label: 'Condition', internal_type: 'conditions', mandatory: 'false', order: '100', use_dependent: 'true', dependent_on: 'table' })
195
+ buildGraphQLInput({ name: 'table', label: 'Table', internal_type: 'table_name', mandatory: 'true', order: '1' }, undefined, true),
196
+ buildGraphQLInput({ name: 'condition', label: 'Condition', internal_type: 'conditions', mandatory: 'false', order: '100', use_dependent: 'true', dependent_on: 'table' }, undefined, true)
185
197
  );
186
198
  }
187
199