@integry/sdk 4.6.74 → 4.6.76

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.74",
3
+ "version": "4.6.76",
4
4
  "description": "Integry SDK",
5
5
  "main": "dist/umd/index.umd.js",
6
6
  "module": "dist/esm/index.csm.js",
@@ -76,6 +76,7 @@ interface ListBoxProps {
76
76
  serverSideSearchParamName?: string;
77
77
  iconKeyPath?: string;
78
78
  optionDescriptionKeyPath?: string;
79
+ skipInitialLoad?: boolean;
79
80
  }
80
81
 
81
82
  const ListBox = (props: ListBoxProps) => {
@@ -120,6 +121,7 @@ const ListBox = (props: ListBoxProps) => {
120
121
  parentFieldChanged = false,
121
122
  allowWorkspaceConnectedAccounts = false,
122
123
  tagsTree = null,
124
+ skipInitialLoad = false,
123
125
  } = props;
124
126
 
125
127
  const [query, setQuery] = useState<string>('');
@@ -265,6 +267,7 @@ const ListBox = (props: ListBoxProps) => {
265
267
  { id: '1', value: 'Yes' },
266
268
  { id: '0', value: 'No' },
267
269
  ];
270
+
268
271
  // eslint-disable-next-line @typescript-eslint/no-shadow
269
272
  if (skipOptionFetch && isDynamic) {
270
273
  // skip option fetch for dynamic dropdowns only. Static dropdowns should always fetch options
@@ -279,9 +282,14 @@ const ListBox = (props: ListBoxProps) => {
279
282
  }
280
283
  const { apiHandler } = props;
281
284
 
282
- if (isDynamic && sourceFlowIntegrataionInvocationUrl && !disabled) {
285
+ if (
286
+ isDynamic &&
287
+ sourceFlowIntegrataionInvocationUrl &&
288
+ !disabled &&
289
+ !skipInitialLoad
290
+ ) {
283
291
  fetchDynamicDataFromSourceFlow();
284
- } else if (isDynamic && endpointUrl && !disabled) {
292
+ } else if (isDynamic && endpointUrl && !disabled && !skipInitialLoad) {
285
293
  setLoading(true);
286
294
  let data;
287
295
  try {
@@ -900,6 +908,9 @@ const ListBox = (props: ListBoxProps) => {
900
908
  data.connected_account_id = selectedAuthId;
901
909
  data.authorization_id = selectedAuthId;
902
910
  }
911
+ if (allowWorkspaceConnectedAccounts) {
912
+ data.allow_workspace_connected_accounts = true;
913
+ }
903
914
  apiHandler
904
915
  .callDynamicDataEndpoint<
905
916
  {
@@ -24,6 +24,7 @@ import TextContent from '@/components/TextContent';
24
24
  // import { MappedField } from '@/components/MappedField/MappedField';
25
25
  import { MultipurposeField } from '@/components/MultipurposeField';
26
26
  import DynamicField from '@/features/common/DynamicField';
27
+ import DynamicTypedField from '@/features/common/DynamicTypedField';
27
28
  import SectionField from '@/features/common/SectionField';
28
29
  import { TimeInput } from '@/components/TimeInput';
29
30
  import NewMappingUI from '@/features/common/NewMappingUI';
@@ -57,7 +58,8 @@ interface ActionFormStateType {
57
58
  dynamicFieldDataState: any;
58
59
  parentChildMapping: any;
59
60
  dynamicFieldsData: any;
60
- parentFieldChanged: boolean;
61
+ parentFieldChanged: any;
62
+ changedParentMachineName: string;
61
63
  }
62
64
 
63
65
  interface StepDataMapping {
@@ -83,7 +85,8 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
83
85
  dynamicFieldDataState: {},
84
86
  parentChildMapping: this.setParentChildMapping([templateStep]),
85
87
  dynamicFieldsData: {},
86
- parentFieldChanged: false,
88
+ parentFieldChanged: [],
89
+ changedParentMachineName: '',
87
90
  };
88
91
  }
89
92
 
@@ -1087,7 +1090,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1087
1090
  if (
1088
1091
  this.isParentField(this.state.parentChildMapping, machineName || '')
1089
1092
  ) {
1090
- this.setState({ parentFieldChanged: !this.state.parentFieldChanged });
1093
+ this.setState((prevState) => ({
1094
+ parentFieldChanged: {
1095
+ ...prevState.parentFieldChanged,
1096
+ [machineName as string]: !prevState.parentFieldChanged?.[
1097
+ machineName as string
1098
+ ],
1099
+ },
1100
+ }));
1101
+ this.setState({ changedParentMachineName: machineName });
1091
1102
  }
1092
1103
 
1093
1104
  this.props.onFieldChangeCallback(machineName || '', value);
@@ -1138,7 +1149,20 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1138
1149
  this.state.parentChildMapping[stepId],
1139
1150
  )
1140
1151
  ) {
1141
- return this.state.dynamicFieldsData;
1152
+ const selfParentFields =
1153
+ this.state.parentChildMapping[stepId][
1154
+ field.activity_field.machine_name
1155
+ ]?.parentFields || [];
1156
+ const result = selfParentFields.reduce(
1157
+ (acc: Record<string, unknown>, parent: any) => {
1158
+ if (this.state.dynamicFieldsData?.[parent]) {
1159
+ acc[parent] = this.state.dynamicFieldsData[parent];
1160
+ }
1161
+ return acc;
1162
+ },
1163
+ {},
1164
+ );
1165
+ return result;
1142
1166
  }
1143
1167
  }
1144
1168
  return null;
@@ -1285,13 +1309,13 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1285
1309
  const lastPartKey = keyPath.split('.').pop(); // Get the last part of the key path
1286
1310
 
1287
1311
  // Check if dictionary has an exact match for the full path or the last part of the path
1288
- if (dictionary[keyPath] !== undefined) {
1312
+ if (dictionary?.[keyPath] !== undefined) {
1289
1313
  // Replace using the exact match
1290
1314
  updatedObj[key] = value.replace(
1291
1315
  placeholderKey[0],
1292
1316
  dictionary[keyPath],
1293
1317
  );
1294
- } else if (lastPartKey && dictionary[lastPartKey] !== undefined) {
1318
+ } else if (lastPartKey && dictionary?.[lastPartKey] !== undefined) {
1295
1319
  // Replace using the last part match
1296
1320
  updatedObj[key] = value.replace(
1297
1321
  placeholderKey[0],
@@ -1376,12 +1400,26 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1376
1400
  el.data_type === 'OBJECT' &&
1377
1401
  el.type !== 'FUNCTION_FIELD'
1378
1402
  ) {
1379
- fieldType = 'OBJECT';
1403
+ if (
1404
+ el.type === 'DYNAMIC' &&
1405
+ uiField?.type === 'CUSTOM_FIELDS'
1406
+ ) {
1407
+ fieldType = 'CUSTOM_FIELDS';
1408
+ } else {
1409
+ fieldType = 'OBJECT';
1410
+ }
1380
1411
  } else if (
1381
1412
  el.data_type === 'OBJECT[]' &&
1382
1413
  el.type !== 'FUNCTION_FIELD'
1383
1414
  ) {
1384
- fieldType = 'OBJECT[]';
1415
+ if (
1416
+ el.type === 'DYNAMIC' &&
1417
+ uiField?.type === 'CUSTOM_FIELDS'
1418
+ ) {
1419
+ fieldType = 'CUSTOM_FIELDS';
1420
+ } else {
1421
+ fieldType = 'OBJECT[]';
1422
+ }
1385
1423
  }
1386
1424
 
1387
1425
  switch (fieldType) {
@@ -1389,6 +1427,19 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1389
1427
  case 'RADIO':
1390
1428
  case 'SELECT': {
1391
1429
  let fieldVal = null;
1430
+ let elParentFields = [];
1431
+ if (
1432
+ el.activity_field?.parent_fields &&
1433
+ el.activity_field?.parent_fields !== ''
1434
+ ) {
1435
+ try {
1436
+ elParentFields = JSON.parse(
1437
+ el.activity_field?.parent_fields,
1438
+ );
1439
+ } catch (e) {
1440
+ elParentFields = [];
1441
+ }
1442
+ }
1392
1443
  if (this.props.onFieldChangeCallback) {
1393
1444
  if (
1394
1445
  Object.prototype.hasOwnProperty.call(
@@ -1506,9 +1557,9 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1506
1557
  )}
1507
1558
  optionKeyPath=${uiField?.value_key_path || ''}
1508
1559
  valueKeyPath=${uiField?.option_key_path || ''}
1509
- parentFieldChanged=${
1510
- this.state.parentFieldChanged
1511
- }
1560
+ parentFieldChanged=${elParentFields.includes(
1561
+ this.state.changedParentMachineName,
1562
+ )}
1512
1563
  allowWorkspaceConnectedAccounts=${!!this.props
1513
1564
  .onFieldChangeCallback}
1514
1565
  tagsTree=${
@@ -1516,6 +1567,16 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1516
1567
  ? this.props.tagsTree
1517
1568
  : null
1518
1569
  }
1570
+ skipInitialLoad=${
1571
+ (elParentFields.length ?? 0) > 0 &&
1572
+ !elParentFields?.some(
1573
+ (parentField: any) =>
1574
+ parentField &&
1575
+ this.state.dynamicFieldsData?.[
1576
+ parentField
1577
+ ],
1578
+ )
1579
+ }
1519
1580
 
1520
1581
  ><//>
1521
1582
  </${ConfigureFieldWrapper}>
@@ -1882,7 +1943,9 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1882
1943
  refreshRootStepData=${this
1883
1944
  .refreshRootStepData}
1884
1945
  parentFieldChanged=${this.state
1885
- .parentFieldChanged}
1946
+ .parentFieldChanged?.[
1947
+ this.state.changedParentMachineName
1948
+ ]}
1886
1949
  onChangeCallback=${this.props
1887
1950
  .onFieldChangeCallback
1888
1951
  ? (val: any) => {
@@ -1908,6 +1971,125 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1908
1971
  </div>
1909
1972
  `;
1910
1973
  }
1974
+ case 'CUSTOM_FIELDS': {
1975
+ let fieldVal = null;
1976
+ let elParentFields = [];
1977
+ if (
1978
+ el.activity_field?.parent_fields &&
1979
+ el.activity_field?.parent_fields !== ''
1980
+ ) {
1981
+ try {
1982
+ elParentFields = JSON.parse(
1983
+ el.activity_field?.parent_fields,
1984
+ );
1985
+ } catch (e) {
1986
+ elParentFields = [];
1987
+ }
1988
+ }
1989
+ if (this.props.onFieldChangeCallback) {
1990
+ if (
1991
+ Object.prototype.hasOwnProperty.call(
1992
+ this.state.dynamicFieldsData || {},
1993
+ el.activity_field?.machine_name || '',
1994
+ )
1995
+ ) {
1996
+ fieldVal = this.state.dynamicFieldsData[
1997
+ el.activity_field?.machine_name || ''
1998
+ ];
1999
+ } else {
2000
+ fieldVal = el.default_value;
2001
+ }
2002
+ }
2003
+
2004
+ return html`
2005
+ <div
2006
+ key=${el.id}
2007
+ id=${`integry-action-field-wrap-${
2008
+ el?.activity_field?.machine_name || ''
2009
+ }`}
2010
+ class=${`integry-action-field-wrap`}
2011
+ >
2012
+ <${DynamicTypedField}
2013
+ dynamicField=${el}
2014
+ endpointData=${JSON.stringify({
2015
+ authorization_id:
2016
+ (this.props.stepMapping &&
2017
+ this.props.stepMapping[
2018
+ this.props.step.id
2019
+ ]?.selectedAuthId) ||
2020
+ this.props.selectedAuthId,
2021
+ })}
2022
+ placeHolder=${this.getPlaceholder(el)}
2023
+ appName=${this.props.step.activity.app
2024
+ .name}
2025
+ selectedAuthId=${`${
2026
+ this.props.stepMapping[
2027
+ this.props.step.id
2028
+ ]?.selectedAuthId ||
2029
+ this.props.selectedAuthId ||
2030
+ ''
2031
+ }`}
2032
+ sourceFlowIntegrataionInvocationUrl=${uiField
2033
+ ?.data_source?.url}
2034
+ isMappable=${this.props.showMappingMenu}
2035
+ isDisabled=${false}
2036
+ isEditable=${false}
2037
+ allowTagsInText=${true}
2038
+ apiHandler=${this.props.apiHandler}
2039
+ idKeyPath=${uiField?.id_key_path}
2040
+ typeKeyPath=${uiField?.type_key_path}
2041
+ titleKeyPath=${uiField?.title_key_path}
2042
+ onChange=${this.props
2043
+ .onFieldChangeCallback
2044
+ ? (val: any) => {
2045
+ if (
2046
+ this.props.onFieldChangeCallback
2047
+ ) {
2048
+ this.onFieldChange({
2049
+ stepId: step.id,
2050
+ fieldId: el.id,
2051
+ value: val,
2052
+ isRequired: el.is_required,
2053
+ machineName:
2054
+ el.activity_field
2055
+ ?.machine_name,
2056
+ });
2057
+ }
2058
+ }
2059
+ : null}
2060
+ tagsTree=${this.props.showMappingMenu
2061
+ ? this.props.tagsTree
2062
+ : null}
2063
+ dataSourceBody=${this.replacePlaceholders(
2064
+ uiField?.data_source.body || {},
2065
+ this.state.dynamicFieldsData,
2066
+ )}
2067
+ parentFieldsChanged=${this.state
2068
+ .parentFieldChanged?.[
2069
+ this.state.changedParentMachineName
2070
+ ] &&
2071
+ elParentFields.includes(
2072
+ this.state.changedParentMachineName,
2073
+ )}
2074
+ activityOutputData=${this.arrayToNestedJSONWithFirstValue(
2075
+ this.props.activityOutputData ||
2076
+ JSONToActivityOutputData(
2077
+ this.props.tagsTree || {},
2078
+ ),
2079
+ this.props.dynamicFieldData ||
2080
+ this.state.dynamicFieldDataState ||
2081
+ {},
2082
+ )}
2083
+ activityOutputDataRaw=${this.props
2084
+ .activityOutputData ||
2085
+ JSONToActivityOutputData(
2086
+ this.props.tagsTree || {},
2087
+ )}
2088
+ value=${fieldVal}
2089
+ />
2090
+ </div>
2091
+ `;
2092
+ }
1911
2093
  case 'SECTION':
1912
2094
  return html`
1913
2095
  <div
@@ -310,6 +310,9 @@ export interface UiField {
310
310
  type: string;
311
311
  value_key_path: string;
312
312
  data_source: UiFieldDataSource;
313
+ type_key_path?: string;
314
+ title_key_path?: string;
315
+ id_key_path?: string;
313
316
  }
314
317
 
315
318
  export interface TemplateField {