@integry/sdk 4.5.4 → 4.5.5

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.
@@ -29,6 +29,7 @@ import NewMappingUI from '@/features/common/NewMappingUI';
29
29
  import { ObjectField } from '@/components/form';
30
30
  import { areParentValuesValid, getFieldLabelTags } from '@/utils/stepUtils';
31
31
  import ConfigureFieldWrapper from '@/components/ConfigureFieldWrapper';
32
+ import { notEmpty } from '@/types/utils';
32
33
  import {
33
34
  JSONToActivityOutputData,
34
35
  JSONToDynamicFieldData,
@@ -44,6 +45,7 @@ interface ActionFormPropsType extends StoreType {
44
45
  eventEmitter: EventEmitter<IntegrySDKEvents>;
45
46
  isReadOnly?: boolean;
46
47
  accountConnected: boolean;
48
+ selectedAuthId: string;
47
49
  }
48
50
 
49
51
  interface ActionFormStateType {
@@ -711,6 +713,9 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
711
713
  };
712
714
 
713
715
  private shouldShowStep = (field: TemplateField) => {
716
+ if (!this.props.showStepValidation) {
717
+ return true;
718
+ }
714
719
  const stepId = this.props.step.id;
715
720
  const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
716
721
 
@@ -756,13 +761,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
756
761
 
757
762
  private stepIsOfType = (fields: string[]) => {
758
763
  const stepId = this.props.step.id;
759
- const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
760
- return fields.indexOf(stepObject.step.activity.type) > -1;
764
+ const stepObject = (this.props.stepMapping &&
765
+ this.props.stepMapping[stepId]) || { step: this.props.step };
766
+ return fields.indexOf(stepObject.step.activity?.type) > -1;
761
767
  };
762
768
 
763
769
  private textFieldParentHasValues = (currentField: any) => {
764
770
  const stepId = this.props.step.id;
765
- const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
771
+ const stepObject = (this.props.stepMapping &&
772
+ this.props.stepMapping[stepId]) || { step: this.props.step };
766
773
 
767
774
  const anyVisibleFields = stepObject.step.template_fields.filter(
768
775
  (el) => el.is_visible,
@@ -1123,8 +1130,10 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1123
1130
  isReadOnly,
1124
1131
  accountConnected,
1125
1132
  } = this.props;
1126
- const selectedStep = stepMapping[step.id] && stepMapping[step.id].step;
1127
- const selectedStepData = stepDataMapping && stepDataMapping[step.id];
1133
+ const selectedStep =
1134
+ (stepMapping[step.id] && stepMapping[step.id].step) || step;
1135
+ const selectedStepData =
1136
+ (stepDataMapping && stepDataMapping[step.id]) || {};
1128
1137
  const actionConfigPayload = {};
1129
1138
  // userConfig?.objects && genericData.directActionPayloadName
1130
1139
  // ? embedConfig?.objects[genericData.directActionPayloadName]
@@ -1134,9 +1143,9 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1134
1143
  const activityOutputData =
1135
1144
  actionConfigPayload || this.props.activityOutputData || {};
1136
1145
  const noStepFields =
1137
- selectedStep.template_fields.length === 0 ||
1146
+ selectedStep.template_fields?.length === 0 ||
1138
1147
  (!(this.props.userConfig && this.props.userConfig.viewAsIU) &&
1139
- selectedStep.template_fields.filter((field) => field.is_visible)
1148
+ selectedStep.template_fields?.filter((field) => field.is_visible)
1140
1149
  .length === 0);
1141
1150
  return html`
1142
1151
  ${this.state.loading
@@ -1144,12 +1153,18 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1144
1153
  : html`
1145
1154
  ${selectedStep
1146
1155
  ? html`
1147
- <div class=${styles.actionFormWrap}>
1156
+ <div
1157
+ class=${`${styles.actionFormWrap} ${
1158
+ this.props.selectedAuthId && this.props.accountConnected
1159
+ ? `${styles.actionFormWrapAutoWidth}`
1160
+ : ``
1161
+ }`}
1162
+ >
1148
1163
  ${noStepFields
1149
1164
  ? html`<span class=${styles.noStepFields}
1150
1165
  >There’s nothing to configure, please proceed.</span
1151
1166
  >`
1152
- : selectedStep.template_fields.map((el) => {
1167
+ : selectedStep.template_fields?.map((el) => {
1153
1168
  if (
1154
1169
  this.shouldShowStep(el) &&
1155
1170
  (el.activity_field || el.type === 'SECTION')
@@ -1239,11 +1254,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1239
1254
  type=${el.activity_field?.type}
1240
1255
  selectedAuthId=${`${
1241
1256
  this.props.stepMapping[this.props.step.id]
1242
- ?.selectedAuthId || ''
1257
+ ?.selectedAuthId ||
1258
+ this.props.selectedAuthId ||
1259
+ ''
1243
1260
  }`}
1244
- disabled=${!this.props.stepMapping[
1245
- this.props.step.id
1246
- ]?.isAuthVerified}
1261
+ disabled=${
1262
+ !this.props.stepMapping[this.props.step.id]
1263
+ ?.isAuthVerified &&
1264
+ !this.props.accountConnected
1265
+ }
1247
1266
  sourceFlowData=${this.sourceFlowData(el)}
1248
1267
  sourceFlowIntegrataionInvocationUrl=${
1249
1268
  el.source_flow_integration_invocation_url
@@ -1337,9 +1356,16 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1337
1356
  }
1338
1357
  placeholder=${this.getPlaceholder(el)}
1339
1358
  showStepValidation=${showStepValidation}
1340
- regex=${selectedStepData[el.id].regex}
1359
+ regex=${
1360
+ selectedStepData[el.id]
1361
+ ? selectedStepData[el.id].regex
1362
+ : ''
1363
+ }
1341
1364
  regexErrorMessage=${
1342
- selectedStepData[el.id].regexErrorMessage
1365
+ selectedStepData[el.id]
1366
+ ? selectedStepData[el.id]
1367
+ .regexErrorMessage
1368
+ : ''
1343
1369
  }
1344
1370
  isRequired=${el.is_required}
1345
1371
  isHidden=${el.is_hidden}
@@ -1449,10 +1475,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1449
1475
  placeholder=${el.placeholder ||
1450
1476
  'Please enter a URL'}
1451
1477
  showStepValidation=${showStepValidation}
1452
- regex=${selectedStepData[el.id].regex}
1478
+ regex=${selectedStepData[el.id]
1479
+ ? selectedStepData[el.id].regex
1480
+ : ''}
1453
1481
  regexErrorMessage=${selectedStepData[
1454
1482
  el.id
1455
- ].regexErrorMessage}
1483
+ ]
1484
+ ? selectedStepData[el.id]
1485
+ .regexErrorMessage
1486
+ : ''}
1456
1487
  isRequired=${el.is_required}
1457
1488
  onChange=${(
1458
1489
  val: string,
@@ -1586,10 +1617,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1586
1617
  placeholder=${el.placeholder ||
1587
1618
  el.activity_field?.placeholder ||
1588
1619
  'Please enter a value'}
1589
- regex=${selectedStepData[el.id].regex}
1620
+ regex=${selectedStepData[el.id]
1621
+ ? selectedStepData[el.id].regex
1622
+ : ''}
1590
1623
  regexErrorMessage=${selectedStepData[
1591
1624
  el.id
1592
- ].regexErrorMessage}
1625
+ ]
1626
+ ? selectedStepData[el.id]
1627
+ .regexErrorMessage
1628
+ : ''}
1593
1629
  showStepValidation=${showStepValidation}
1594
1630
  isRequired=${el.is_required}
1595
1631
  onChange=${(val: string) => {
@@ -1631,9 +1667,16 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1631
1667
  ''
1632
1668
  }
1633
1669
  placeholder=${this.getPlaceholder(el)}
1634
- regex=${selectedStepData[el.id].regex}
1670
+ regex=${
1671
+ selectedStepData[el.id].regex
1672
+ ? selectedStepData[el.id].regex
1673
+ : ''
1674
+ }
1635
1675
  regexErrorMessage=${
1636
- selectedStepData[el.id].regexErrorMessage
1676
+ selectedStepData[el.id]
1677
+ ? selectedStepData[el.id]
1678
+ .regexErrorMessage
1679
+ : ''
1637
1680
  }
1638
1681
  showStepValidation=${showStepValidation}
1639
1682
  isRequired=${el.is_required}
@@ -12,6 +12,11 @@
12
12
  .actionStepFieldWrap {
13
13
  // margin-bottom: 16px;
14
14
  }
15
+ .actionFormWrapAutoWidth {
16
+ margin-left: 24px;
17
+ margin-right: 24px;
18
+ width: auto;
19
+ }
15
20
 
16
21
  .unsupported {
17
22
  font-size: 12px;
package/src/index.ts CHANGED
@@ -41,6 +41,7 @@ import FlowSetupContainer from '@/features/containers/FlowSetupContainer';
41
41
  import MarketplaceContainer from '@/features/containers/MarketplaceContainer';
42
42
  import AppFlowContainer from '@/features/containers/AppFlowContainer';
43
43
  import MarketplaceAppsContainer from '@/features/containers/MarketplaceAppsContainer';
44
+ import ActionForm from '@/features/common/ActionForm';
44
45
 
45
46
  import FunctionForm from '@/features/common/FunctionForm';
46
47
  import { openPopupWindow } from '@/utils/popup';
@@ -1980,6 +1981,47 @@ export class IntegryJS {
1980
1981
  }
1981
1982
  };
1982
1983
 
1984
+ public renderFlowStep = (
1985
+ containerId: string,
1986
+ step: any,
1987
+ connectedAccountId: string,
1988
+ ) => {
1989
+ const target = document.getElementById(containerId);
1990
+
1991
+ if (target) {
1992
+ const store = createSDKStore();
1993
+ render(
1994
+ html`<div>
1995
+ <${AppContext.Provider}
1996
+ value=${{
1997
+ apiHandler: this.apiHandler,
1998
+ eventEmitter: this.eventEmitter,
1999
+ isPreviewMode: false,
2000
+ }}
2001
+ >
2002
+ <${Provider} store=${store} key=${this.getRandomFlowId(10)}>
2003
+ <${ActionForm}
2004
+ step=${step}
2005
+ stepType=${'CONFIGURE'}
2006
+ showStepValidation=${false}
2007
+ apiHandler=${this.apiHandler}
2008
+ eventEmitter=${this.eventEmitter}
2009
+ isReadOnly="${false}"
2010
+ selectedAuthId="${connectedAccountId}"
2011
+ accountConnected=${true}
2012
+ />
2013
+ <//>
2014
+ <//>
2015
+ </div>`,
2016
+ target,
2017
+ );
2018
+ } else {
2019
+ console.warn(
2020
+ `Integry SDK render target with id ${containerId} was not found`,
2021
+ );
2022
+ }
2023
+ };
2024
+
1983
2025
  public verifyAuthConfig = () =>
1984
2026
  this.apiHandler.verifyAuthConfig({
1985
2027
  deploymentId: this.config.deploymentId,
File without changes
@@ -517,10 +517,15 @@ export const actionFunctions = (storeSnapshot: Store<State>) => ({
517
517
  const { stepDataMapping, conditionalFieldMapping } = state;
518
518
  const element = stepDataMapping[stepId];
519
519
 
520
- const fieldsData = Object.keys(element).map((fieldId) => {
521
- const ele = element[Number(fieldId)];
522
- return ele;
523
- });
520
+ let fieldsData: any[] = [];
521
+ if (element) {
522
+ fieldsData = Object.keys(element).map((fieldId) => {
523
+ const ele = element[Number(fieldId)];
524
+ return ele;
525
+ });
526
+ } else {
527
+ fieldsData = [];
528
+ }
524
529
 
525
530
  const visibleFields = fieldsData.filter((el) => {
526
531
  // filter out hidden conditional fields
package/vitest.config.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { defineConfig } from 'vitest/config';
2
+ import path from 'path';
2
3
 
3
4
  export default defineConfig({
5
+ resolve: {
6
+ alias: {
7
+ '@': path.resolve(__dirname, './src'),
8
+ },
9
+ },
4
10
  test: {
5
11
  globals: true,
6
12
  environment: 'jsdom',