@integry/sdk 4.6.45 → 4.6.46

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
  "name": "@integry/sdk",
3
- "version": "4.6.45",
3
+ "version": "4.6.46",
4
4
  "description": "Integry SDK",
5
5
  "main": "dist/umd/index.umd.js",
6
6
  "module": "dist/esm/index.csm.js",
@@ -56,52 +56,61 @@ const Select = (props: SelectProps) => {
56
56
  const getSortedOptions = (): { label: string; key: string }[] => {
57
57
  if (options.length > 0) {
58
58
  const naturalSort = createNewSortInstance({
59
- comparer: new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare,
59
+ comparer: new Intl.Collator(undefined, {
60
+ numeric: true,
61
+ sensitivity: 'base',
62
+ }).compare,
60
63
  });
61
64
  const sorted = naturalSort(options).asc((option) => option.label);
62
65
  return sorted;
63
66
  }
64
67
  return [];
65
- }
68
+ };
66
69
 
67
70
  return html`
68
71
  <div class=${styles.selectWrapper}>
69
- <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
70
- ${isReadOnly && html `<span class=${styles.readonlyHint} data-hint=${isReadOnly ? `Cannot modify user selection` : ''}></span>`}
71
- <select
72
- aria-label=${ariaLabel}
73
- onchange=${handleInputChange}
74
- class=${`${value && styles.selectedVal} ${isReadOnly ? styles.readonly: ''}`}
75
- disabled=${isReadOnly}
76
- >
77
- ${showUnselectedValue &&
78
- html` <option value="">${unselectedText}</option> `}
79
- ${value === undefined &&
80
- html`
81
- <option value="" disabled selected hidden>${placeholder}</option>
82
- `}
83
- ${getSortedOptions().map(
84
- (el) => html`
85
- <option value=${el.key} selected=${value === el.key}>
86
- ${el.label}
87
- </option>
88
- `,
89
- )}
90
- </select>
91
- <svg
92
- width="12"
93
- height="8"
94
- viewBox="0 0 12 8"
95
- fill="none"
96
- xmlns="http://www.w3.org/2000/svg"
97
- >
98
- <path
99
- d="M11 1.5L6 6.5L1 1.5"
100
- stroke="#999999"
101
- stroke-width="2"
102
- stroke-linecap="round"
103
- />
104
- </svg>
72
+ <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
73
+ ${isReadOnly &&
74
+ html`<span
75
+ class=${styles.readonlyHint}
76
+ data-hint=${isReadOnly ? `` : ''}
77
+ ></span>`}
78
+ <select
79
+ aria-label=${ariaLabel}
80
+ onchange=${handleInputChange}
81
+ class=${`${value && styles.selectedVal} ${
82
+ isReadOnly ? styles.readonly : ''
83
+ }`}
84
+ disabled=${isReadOnly}
85
+ >
86
+ ${showUnselectedValue &&
87
+ html` <option value="">${unselectedText}</option> `}
88
+ ${value === undefined &&
89
+ html`
90
+ <option value="" disabled selected hidden>${placeholder}</option>
91
+ `}
92
+ ${getSortedOptions().map(
93
+ (el) => html`
94
+ <option value=${el.key} selected=${value === el.key}>
95
+ ${el.label}
96
+ </option>
97
+ `,
98
+ )}
99
+ </select>
100
+ <svg
101
+ width="12"
102
+ height="8"
103
+ viewBox="0 0 12 8"
104
+ fill="none"
105
+ xmlns="http://www.w3.org/2000/svg"
106
+ >
107
+ <path
108
+ d="M11 1.5L6 6.5L1 1.5"
109
+ stroke="#999999"
110
+ stroke-width="2"
111
+ stroke-linecap="round"
112
+ />
113
+ </svg>
105
114
  <//>
106
115
  </div>
107
116
  ${isRequired &&
@@ -161,7 +161,7 @@ const Input = forwardRef((props: InputProps, ref) => {
161
161
  ${isReadOnly &&
162
162
  html`<span
163
163
  class=${styles.readonlyHint}
164
- data-hint=${isReadOnly ? `Cannot modify user selection` : ''}
164
+ data-hint=${isReadOnly ? `` : ''}
165
165
  ></span>`}
166
166
  ${values.map((inputValue, index) => {
167
167
  const inputId = isArray ? `${id}-${index}` : id;
@@ -10,5 +10,7 @@
10
10
  height: -webkit-fill-available;
11
11
  z-index: 99;
12
12
  position: absolute;
13
+ background-color: #eee;
14
+ opacity: 0.5;
13
15
  }
14
16
  }
@@ -209,11 +209,16 @@ const ListBox = (props: ListBoxProps) => {
209
209
  }
210
210
  };
211
211
 
212
- const setSortedFilteredItems = (data: { id: string, value: string }[]): void => {
212
+ const setSortedFilteredItems = (
213
+ data: { id: string; value: string }[],
214
+ ): void => {
213
215
  const naturalSort = createNewSortInstance({
214
- comparer: new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare,
216
+ comparer: new Intl.Collator(undefined, {
217
+ numeric: true,
218
+ sensitivity: 'base',
219
+ }).compare,
215
220
  });
216
- const sorted = naturalSort(data).asc(item => item.value);
221
+ const sorted = naturalSort(data).asc((item) => item.value);
217
222
  setFilteredItems(sorted);
218
223
  };
219
224
 
@@ -295,10 +300,12 @@ const ListBox = (props: ListBoxProps) => {
295
300
  return index > -1 ? items[index].value : 'Please Select...';
296
301
  }, [items, value]);
297
302
 
298
- const getItemFromText = (textValue: string): ({
303
+ const getItemFromText = (
304
+ textValue: string,
305
+ ): {
299
306
  id: string;
300
307
  value: string;
301
- }) => {
308
+ } => {
302
309
  let tempItem = {
303
310
  id: textValue,
304
311
  value: textValue,
@@ -319,7 +326,7 @@ const ListBox = (props: ListBoxProps) => {
319
326
  });
320
327
  }
321
328
  return tempItem;
322
- }
329
+ };
323
330
 
324
331
  const updateValue = (e: InputEvent) => {
325
332
  if (e.currentTarget instanceof HTMLInputElement) {
@@ -330,9 +337,9 @@ const ListBox = (props: ListBoxProps) => {
330
337
  onChange(tempItem.id);
331
338
  setEditableTextValue(tempItem.value);
332
339
  setQuery(tempItem.value.trim());
333
- } else if(newValue !== '') {
334
- setQuery(newValue.trim());
335
- }
340
+ } else if (newValue !== '') {
341
+ setQuery(newValue.trim());
342
+ }
336
343
  }
337
344
  };
338
345
 
@@ -344,7 +351,7 @@ const ListBox = (props: ListBoxProps) => {
344
351
  setQuery('');
345
352
  inputRef.current?.blur();
346
353
  }
347
- }
354
+ };
348
355
 
349
356
  return html`
350
357
  <${Hint} dismissOnClick=${false} position="top" deltaY=${0}>
@@ -370,7 +377,7 @@ const ListBox = (props: ListBoxProps) => {
370
377
  ${isReadOnly &&
371
378
  html`<span
372
379
  class=${styles.readonlyHint}
373
- data-hint=${isReadOnly ? `Cannot modify user selection` : ''}
380
+ data-hint=${isReadOnly ? `` : ''}
374
381
  ></span>`}
375
382
  <div
376
383
  class=${`${styles.customSelectTrigger} ${
@@ -395,7 +402,9 @@ const ListBox = (props: ListBoxProps) => {
395
402
  ref=${inputRef}
396
403
  class=${styles.searchInput}
397
404
  placeholder=${placeholder ||
398
- (isEditable ? 'Please select or enter value...' : 'Please Select or Search...')}
405
+ (isEditable
406
+ ? 'Please select or enter value...'
407
+ : 'Please Select or Search...')}
399
408
  value=${isEditable ? editableTextValue : query}
400
409
  oninput=${updateValue}
401
410
  onclick=${onInputClicked}
@@ -978,7 +978,7 @@ const ListBox = (props: ListBoxProps) => {
978
978
  ${isReadOnly &&
979
979
  html`<span
980
980
  class=${styles.readonlyHint}
981
- data-hint=${isReadOnly ? `Cannot modify user selection` : ''}
981
+ data-hint=${isReadOnly ? `` : ''}
982
982
  ></span>`}
983
983
  <div
984
984
  class=${`${styles.customSelectTrigger} ${
@@ -30,6 +30,8 @@
30
30
  height: 100%;
31
31
  z-index: 99;
32
32
  position: absolute;
33
+ background-color: #eee;
34
+ opacity: 0.5;
33
35
  }
34
36
  }
35
37
  .disabled {
@@ -55,6 +55,7 @@ interface MultipurposeFieldProps {
55
55
  buttonScriptRequiresAuthToken?: boolean;
56
56
  tagsComponent?: any;
57
57
  tagsTree?: any;
58
+ isDisabled?: boolean;
58
59
  }
59
60
 
60
61
  const MultipurposeField = (props: MultipurposeFieldProps) => {
@@ -89,6 +90,7 @@ const MultipurposeField = (props: MultipurposeFieldProps) => {
89
90
  buttonScriptRequiresAuthToken = false,
90
91
  tagsComponent = null,
91
92
  tagsTree = null,
93
+ isDisabled = false,
92
94
  } = props;
93
95
  const [showTagMenu, setShowTagMenu] = useState(false);
94
96
  const [currentValue, setCurrentValue] = useState(value);
@@ -550,7 +552,7 @@ const MultipurposeField = (props: MultipurposeFieldProps) => {
550
552
  <div class="${styles.multipurposeField}">
551
553
  ${type === 'TEXTAREA'
552
554
  ? html`
553
- ${enableTagify && isMappable
555
+ ${enableTagify && isMappable && !isDisabled
554
556
  ? html`
555
557
  <${TextArea}
556
558
  id="tagify_${fieldId}"
@@ -632,11 +634,12 @@ const MultipurposeField = (props: MultipurposeFieldProps) => {
632
634
  isHidden=${isHidden}
633
635
  fieldId=${fieldId}
634
636
  labelTags=${labelTags}
637
+ isReadOnly=${isDisabled}
635
638
  />
636
639
  `}
637
640
  `
638
641
  : html`
639
- ${enableTagify && isMappable
642
+ ${enableTagify && isMappable && !isDisabled
640
643
  ? html`
641
644
  <${Input}
642
645
  id="tagify_${fieldId}"
@@ -737,6 +740,7 @@ const MultipurposeField = (props: MultipurposeFieldProps) => {
737
740
  onButtonClickScript=${onButtonClickScript}
738
741
  buttonScriptRequiresAuthToken=${buttonScriptRequiresAuthToken}
739
742
  apiHandler=${props.apiHandler}
743
+ isReadOnly=${isDisabled}
740
744
  />
741
745
  `}
742
746
  `}
@@ -105,7 +105,7 @@ const TextArea = forwardRef((props: TextAreaProps, ref) => {
105
105
  ${isReadOnly &&
106
106
  html`<span
107
107
  class=${styles.readonlyHint}
108
- data-hint=${isReadOnly ? `Cannot modify user selection` : ''}
108
+ data-hint=${isReadOnly ? `` : ''}
109
109
  ></span>`}
110
110
  <div
111
111
  class=${`${styles.textareaInputWrapper} ${styles[className || '']}`}
@@ -66,5 +66,7 @@
66
66
  height: -webkit-fill-available;
67
67
  z-index: 99;
68
68
  position: absolute;
69
+ background-color: #eee;
70
+ opacity: 0.5;
69
71
  }
70
72
  }
@@ -41,6 +41,9 @@ const FunctionField = (props: FunctionFieldProps) => {
41
41
  const [connectedAccounts, setConnectedAccounts] = useState<any>([]);
42
42
  const [visibleFields, setVisibleFields] = useState<any>([]);
43
43
 
44
+ // Track AI-assisted fields
45
+ const [aiAssistedFields, setAIAssistedFields] = useState<string[]>([]);
46
+
44
47
  // Modified to support array of values
45
48
  const [functionValues, setFunctionValues] = useState<any[]>(() => {
46
49
  if (isArray && Array.isArray(value)) {
@@ -68,6 +71,7 @@ const FunctionField = (props: FunctionFieldProps) => {
68
71
  setConnectedAccountId(null);
69
72
  setUserFilledData({});
70
73
  setFormHasInvalidFields(false);
74
+ setAIAssistedFields([]); // Reset AI-assisted fields
71
75
  };
72
76
 
73
77
  // Handle clicking outside the modal to close it
@@ -114,7 +118,8 @@ const FunctionField = (props: FunctionFieldProps) => {
114
118
  if (
115
119
  property.meta?.ui?.is_visible &&
116
120
  property.meta?.is_required &&
117
- !userFilledData[key]
121
+ !userFilledData[key] &&
122
+ !aiAssistedFields.includes(key) // Don't mark AI-assisted fields as invalid
118
123
  ) {
119
124
  response.push({ key, ...property });
120
125
  }
@@ -130,6 +135,13 @@ const FunctionField = (props: FunctionFieldProps) => {
130
135
  setSelectedFunction(actionToEdit?.json_schema?.function.name || '');
131
136
  setUserFilledData(actionToEdit?.default_arguments || {});
132
137
 
138
+ // Load AI-assisted fields from meta if available
139
+ if (actionToEdit?.meta?.ai_assisted_fields) {
140
+ setAIAssistedFields(actionToEdit.meta.ai_assisted_fields);
141
+ } else {
142
+ setAIAssistedFields([]);
143
+ }
144
+
133
145
  // Load function details for the selected function
134
146
  setLoadingFunctionDetails(true);
135
147
  props.apiHandler
@@ -193,7 +205,28 @@ const FunctionField = (props: FunctionFieldProps) => {
193
205
  return obj;
194
206
  };
195
207
 
196
- // Modified to handle array of values
208
+ // Handle AI assist toggle changes
209
+ const handleAIAssistToggle = (
210
+ fieldId: string,
211
+ enabled: boolean,
212
+ allAIAssistedFields: string[],
213
+ ) => {
214
+ setAIAssistedFields(allAIAssistedFields);
215
+
216
+ // Update form validation since AI-assisted fields should not be marked as invalid
217
+ if (
218
+ functionDetails &&
219
+ functionDetails.parameters &&
220
+ functionDetails.parameters.properties
221
+ ) {
222
+ const invalidFields = getInvalidFields(
223
+ functionDetails.parameters.properties,
224
+ );
225
+ setFormHasInvalidFields(invalidFields.length > 0);
226
+ }
227
+ };
228
+
229
+ // Modified to handle array of values and include AI-assisted fields in meta
197
230
  const handleSave = () => {
198
231
  if (selectedFunction && functionDetails) {
199
232
  const schema = {
@@ -210,6 +243,7 @@ const FunctionField = (props: FunctionFieldProps) => {
210
243
  title: functionDetails.meta.ui.title,
211
244
  app_name: functionDetails.meta.app.title,
212
245
  app_icon_url: functionDetails.meta.app.icon_url,
246
+ ai_assisted_fields: aiAssistedFields, // Store AI-assisted fields in meta
213
247
  },
214
248
  default_arguments: userFilledData,
215
249
  parameters_visible_to_user: {},
@@ -275,6 +309,19 @@ const FunctionField = (props: FunctionFieldProps) => {
275
309
  setActiveTab('input');
276
310
  };
277
311
 
312
+ // Get default AI-assisted fields based on the current function
313
+ const getDefaultAIAssistedFields = () => {
314
+ // If editing an existing function, use the stored AI-assisted fields
315
+ if (
316
+ editingIndex !== null &&
317
+ functionValues[editingIndex]?.meta?.ai_assisted_fields
318
+ ) {
319
+ return functionValues[editingIndex].meta.ai_assisted_fields;
320
+ }
321
+
322
+ return [];
323
+ };
324
+
278
325
  const loadAuthorizationTabContent = () => {
279
326
  let content;
280
327
 
@@ -396,16 +443,16 @@ const FunctionField = (props: FunctionFieldProps) => {
396
443
  <path
397
444
  d="M3 6H5H21"
398
445
  stroke="currentColor"
399
- stroke-width="2"
400
- stroke-linecap="round"
401
- stroke-linejoin="round"
446
+ strokeWidth="2"
447
+ strokeLinecap="round"
448
+ strokeLinejoin="round"
402
449
  />
403
450
  <path
404
451
  d="M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z"
405
452
  stroke="currentColor"
406
- stroke-width="2"
407
- stroke-linecap="round"
408
- stroke-linejoin="round"
453
+ strokeWidth="2"
454
+ strokeLinecap="round"
455
+ strokeLinejoin="round"
409
456
  />
410
457
  </svg>
411
458
  </button>
@@ -482,16 +529,16 @@ const FunctionField = (props: FunctionFieldProps) => {
482
529
  <path
483
530
  d="M3 6H5H21"
484
531
  stroke="currentColor"
485
- stroke-width="2"
486
- stroke-linecap="round"
487
- stroke-linejoin="round"
532
+ strokeWidth="2"
533
+ strokeLinecap="round"
534
+ strokeLinejoin="round"
488
535
  />
489
536
  <path
490
537
  d="M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z"
491
538
  stroke="currentColor"
492
- stroke-width="2"
493
- stroke-linecap="round"
494
- stroke-linejoin="round"
539
+ strokeWidth="2"
540
+ strokeLinecap="round"
541
+ strokeLinejoin="round"
495
542
  />
496
543
  </svg>
497
544
  </button>
@@ -676,6 +723,9 @@ const FunctionField = (props: FunctionFieldProps) => {
676
723
  variables=${tagsTree}
677
724
  showMappingMenu=${true}
678
725
  forceShowAllFields=${true}
726
+ enableAIAssist=${true}
727
+ defaultAIAssistedFields=${getDefaultAIAssistedFields()}
728
+ onAIAssistToggle=${handleAIAssistToggle}
679
729
  />
680
730
  </div>
681
731
  `