@integry/sdk 4.5.8 → 4.5.9
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/dist/esm/index.csm.js
CHANGED
|
@@ -2668,21 +2668,21 @@ var e,t,n,i,o,s,a,l={},r=[],d=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]
|
|
|
2668
2668
|
</fieldset>
|
|
2669
2669
|
${u&&v.length<1&&c&&R` <${vn}>Please select an option</${vn}>`}
|
|
2670
2670
|
</div>
|
|
2671
|
-
`};var ws={actionFormWrap:"styles-module_actionFormWrap__1l5fH",noStepFields:"styles-module_noStepFields__3OoJ5",actionStepFieldWrap:"styles-module_actionStepFieldWrap__2fC8s",unsupported:"styles-module_unsupported__10T6A",actionFormLoader:"styles-module_actionFormLoader__-bGAV",noOptions:"styles-module_noOptions__3xiOJ",noOptionsRetry:"styles-module_noOptionsRetry___2pkw",loadingText:"styles-module_loadingText__1xzvz",optionsRefreshProminent:"styles-module_optionsRefreshProminent__2hZwe",optionsRefresh:"styles-module_optionsRefresh__1AwL2"};ue('.styles-module_actionFormWrap__1l5fH {\n width: 100%;\n}\n.styles-module_actionFormWrap__1l5fH .styles-module_noStepFields__3OoJ5 {\n font-family: "Inter";\n font-weight: 400;\n font-size: 14px;\n line-height: 24px;\n color: #999999;\n}\n\n.styles-module_actionStepFieldWrap__2fC8s {\n margin-bottom: 16px;\n}\n\n.styles-module_unsupported__10T6A {\n font-size: 12px;\n color: #ca8c1b;\n}\n\n.styles-module_actionFormLoader__-bGAV {\n width: 15px;\n margin: 0 auto;\n}\n\n.styles-module_noOptions__3xiOJ {\n font-weight: 400;\n font-size: 12px;\n line-height: 15px;\n margin-bottom: 12px;\n display: block;\n color: #999;\n}\n.styles-module_noOptions__3xiOJ span.styles-module_noOptionsRetry___2pkw [class^=styles-module_loader_] {\n position: relative;\n top: 5px;\n}\n\n.styles-module_loadingText__1xzvz {\n font-weight: 400;\n font-size: 12px;\n line-height: 15px;\n margin-bottom: 12px;\n color: #999;\n display: flex;\n}\n.styles-module_loadingText__1xzvz .styles-module_actionFormLoader__-bGAV {\n margin: 0 7px 0 0;\n}\n\na.styles-module_optionsRefreshProminent__2hZwe {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 8px;\n font-size: 12px;\n line-height: 15px;\n color: #4250f0;\n cursor: pointer;\n text-decoration: none;\n}\n\na.styles-module_optionsRefresh__1AwL2 {\n font-size: 12px;\n line-height: 15px;\n color: #4250f0;\n cursor: pointer;\n text-decoration: none;\n}');var bs=B.connect(["stepState","genericData","embedConfig","stepMapping","dynamicFieldData","stepDataMapping","parentChildMapping"],re)((e=>{const{stepId:t,dynamicField:n,endpointData:i,genericData:o,activityOutputData:s,activityOutputDataRaw:a,appName:l,sourceFlowData:r={},sourceFlowIntegrataionInvocationUrl:d="",selectedAuthId:p="",isMappable:c=!0,isEditable:u=!0,allowTagsInText:_=!0,placeHolder:m="",refreshRootStepData:h}=e,[
|
|
2671
|
+
`};var ws={actionFormWrap:"styles-module_actionFormWrap__1l5fH",noStepFields:"styles-module_noStepFields__3OoJ5",actionStepFieldWrap:"styles-module_actionStepFieldWrap__2fC8s",unsupported:"styles-module_unsupported__10T6A",actionFormLoader:"styles-module_actionFormLoader__-bGAV",noOptions:"styles-module_noOptions__3xiOJ",noOptionsRetry:"styles-module_noOptionsRetry___2pkw",loadingText:"styles-module_loadingText__1xzvz",optionsRefreshProminent:"styles-module_optionsRefreshProminent__2hZwe",optionsRefresh:"styles-module_optionsRefresh__1AwL2"};ue('.styles-module_actionFormWrap__1l5fH {\n width: 100%;\n}\n.styles-module_actionFormWrap__1l5fH .styles-module_noStepFields__3OoJ5 {\n font-family: "Inter";\n font-weight: 400;\n font-size: 14px;\n line-height: 24px;\n color: #999999;\n}\n\n.styles-module_actionStepFieldWrap__2fC8s {\n margin-bottom: 16px;\n}\n\n.styles-module_unsupported__10T6A {\n font-size: 12px;\n color: #ca8c1b;\n}\n\n.styles-module_actionFormLoader__-bGAV {\n width: 15px;\n margin: 0 auto;\n}\n\n.styles-module_noOptions__3xiOJ {\n font-weight: 400;\n font-size: 12px;\n line-height: 15px;\n margin-bottom: 12px;\n display: block;\n color: #999;\n}\n.styles-module_noOptions__3xiOJ span.styles-module_noOptionsRetry___2pkw [class^=styles-module_loader_] {\n position: relative;\n top: 5px;\n}\n\n.styles-module_loadingText__1xzvz {\n font-weight: 400;\n font-size: 12px;\n line-height: 15px;\n margin-bottom: 12px;\n color: #999;\n display: flex;\n}\n.styles-module_loadingText__1xzvz .styles-module_actionFormLoader__-bGAV {\n margin: 0 7px 0 0;\n}\n\na.styles-module_optionsRefreshProminent__2hZwe {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 8px;\n font-size: 12px;\n line-height: 15px;\n color: #4250f0;\n cursor: pointer;\n text-decoration: none;\n}\n\na.styles-module_optionsRefresh__1AwL2 {\n font-size: 12px;\n line-height: 15px;\n color: #4250f0;\n cursor: pointer;\n text-decoration: none;\n}');var bs=B.connect(["stepState","genericData","embedConfig","stepMapping","dynamicFieldData","stepDataMapping","parentChildMapping"],re)((e=>{const{stepId:t,dynamicField:n,endpointData:i,genericData:o,activityOutputData:s,activityOutputDataRaw:a,appName:l,sourceFlowData:r={},sourceFlowIntegrataionInvocationUrl:d="",selectedAuthId:p="",isMappable:c=!0,isEditable:u=!0,allowTagsInText:_=!0,placeHolder:m="",refreshRootStepData:h,parentFieldChanged:g=!1}=e,[y,f]=Ce([]),[v,x]=Ce(!0),[w,b]=Ce(!1),$=Me(ne),C=$?.isReadOnly,I=async()=>{const{activity_field:e}=n;if(d&&p)$?.apiHandler.callSourceFlowIntegrationInvocationUrl(new URL(d),{authorization_id:p},r).then((e=>{if(e){if(!e)throw b(!0),new Error("Nothing returned from dynamic data endpoint");Array.isArray(e)?f(e):f([])}})).catch((e=>console.error(e))).finally((()=>x(!1)));else if(e&&e.dynamic_field_src){let t;try{t=JSON.parse(i)}catch(e){t=""}$?.apiHandler.callDynamicDataEndpointWithTags(new URL(e.dynamic_field_src),t,s).then((e=>{e?Array.isArray(e)?f(e):f([]):b(!0)})).catch((e=>console.error(e))).finally((()=>{x(!1)}))}};Ie((()=>{I()}),[n,i,p,g]);return R`
|
|
2672
2672
|
<div>
|
|
2673
|
-
${
|
|
2673
|
+
${v?R`<div className=${ws.loadingText}>
|
|
2674
2674
|
<div class=${ws.actionFormLoader}>
|
|
2675
2675
|
<${Ye} />
|
|
2676
2676
|
</div>
|
|
2677
2677
|
Loading custom fields...
|
|
2678
|
-
</div> `:R` ${
|
|
2678
|
+
</div> `:R` ${y.map((i=>{let o="";const r=(e.stepDataMapping[t]?e.stepDataMapping[t][n.id]:{}).objectValue;return r&&r[i.id]&&(o=`${r[i.id]}`),R`
|
|
2679
2679
|
<div class=${ws.dynamicFieldWrapper}>
|
|
2680
2680
|
<${Jo}
|
|
2681
2681
|
title=${i.title}
|
|
2682
2682
|
placeholder=${(()=>{let e="Enter text or map to fields...";return m?e=m:l&&(e=`Enter text or map to ${l} fields...`),e})()}
|
|
2683
2683
|
value=${o}
|
|
2684
2684
|
onChange=${o=>{((i,o)=>{const s=o.match(/{([^}]+)}/g);let l=o;(s||[]).forEach((e=>{const t=e.replace(/{|}/g,"");(a||[]).forEach((n=>{n.text===t&&(l=l.replace(e,`{${n.value}}`))}))})),e.setStepMappingData({stepId:t,fieldId:n.id,id:i,value:l})})(i.id,o)}}
|
|
2685
|
-
isReadOnly=${
|
|
2685
|
+
isReadOnly=${C}
|
|
2686
2686
|
type="TEXTFIELD"
|
|
2687
2687
|
isMappable=${c}
|
|
2688
2688
|
isEditable=${u}
|
|
@@ -2694,12 +2694,12 @@ var e,t,n,i,o,s,a,l={},r=[],d=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]
|
|
|
2694
2694
|
/>
|
|
2695
2695
|
</div>
|
|
2696
2696
|
`}))}`}
|
|
2697
|
-
${
|
|
2697
|
+
${w?R`<span className=${ws.noOptions}
|
|
2698
2698
|
>Could not load custom fields.
|
|
2699
2699
|
${R` <a
|
|
2700
2700
|
className=${ws.optionsRefresh}
|
|
2701
2701
|
href="#"
|
|
2702
|
-
onclick=${()=>{
|
|
2702
|
+
onclick=${()=>{x(!0),b(!1),I()}}
|
|
2703
2703
|
>${" "}Try again?</a
|
|
2704
2704
|
>`}
|
|
2705
2705
|
</span>`:""}
|
|
@@ -3377,7 +3377,7 @@ var e,t,n,i,o,s,a,l={},r=[],d=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]
|
|
|
3377
3377
|
`;var i,o}))}
|
|
3378
3378
|
${l&&R` <a onClick=${()=>{u([...c,{}])}}>+ Add another ${t.title}</a> `}
|
|
3379
3379
|
</div>
|
|
3380
|
-
`};var Js={actionFormWrap:"styles-module_actionFormWrap__1--9G",noStepFields:"styles-module_noStepFields__1NQe1",actionFormWrapAutoWidth:"styles-module_actionFormWrapAutoWidth__2Vs2x",unsupported:"styles-module_unsupported__2swxl",actionFormLoader:"styles-module_actionFormLoader__2AXe4"};ue('.styles-module_actionFormWrap__1--9G {\n width: 100%;\n}\n.styles-module_actionFormWrap__1--9G .styles-module_noStepFields__1NQe1 {\n font-family: "Inter";\n font-weight: 400;\n font-size: 14px;\n line-height: 24px;\n color: #999999;\n}\n\n.styles-module_actionFormWrapAutoWidth__2Vs2x {\n margin-left: 24px;\n margin-right: 24px;\n width: auto;\n}\n\n.styles-module_unsupported__2swxl {\n font-size: 12px;\n color: #ca8c1b;\n}\n\n.styles-module_actionFormLoader__2AXe4 {\n width: 15px;\n margin: 0 auto;\n}');var Xs=B.connect(["stepState","stepMapping","stepDataMapping","parentChildMapping","fieldListMapping","conditionalFieldMapping","embedConfig","activityOutputData","genericData","userConfig","authMapping"],re)(class extends g{constructor(e){super(e),this.state={loading:!1,dynamicFieldDataState:{},tagsTree:this.props.tagsTree&&Object.keys(this.props.tagsTree).length>0?Yo(this.props.tagsTree):{}}}componentDidMount(){const{step:e,verifyStepValidity:t}=this.props;t(e.id);const n=this.props.genericData.stepWithActivityOutput;if(n){const{id:e}=n,t=this.getVisibleFieldsDataOnRootStep(e);this.setRootStepData(t)}else this.setRootStepData({})}componentDidUpdate(e){const{step:t,verifyStepValidity:n}=this.props;if(e.step.id!==t.id){n(t.id);const e=this.props.genericData.stepWithActivityOutput;if(e){const{id:t}=e,n=this.getVisibleFieldsDataOnRootStep(t);this.setRootStepData(n)}else this.setRootStepData({})}}getVisibleFieldsDataOnRootStep=e=>{const t=this.props.stepDataMapping[e];return Object.keys(t).filter((e=>t[Number(e)].value)).reduce(((e,n)=>{const i=t[Number(n)];return{...e,[i.machineName]:i.value}}),{})};refreshRootStepData=async e=>{const t=this.props.genericData.stepWithActivityOutput;if(t){const{id:n}=t,i=this.getVisibleFieldsDataOnRootStep(n);this.setRootStepData(i,!0,e)}else this.setRootStepData({},!0,e)};setActivityOutputFromSourceStep=(e,t,n)=>{const{setDynamicData:i}=this,o=this.setState.bind(this),s=this.props.step.source_steps,{stepMapping:a}=this.props,{props:l}=this;Object.keys(s).forEach((s=>{const r=l.step.source_steps[s];let d=!1;return Object.keys(a).every((p=>{const c=a[p].step.id;if(c&&(a[c].step.machine_name===s||a[c].step.machine_name===r.form_step_machine_name)&&!l.genericData.isTestIntegration){if(d=!0,r.activity_output_url){e||o({loading:!0});const n={},a=Object.keys(l.stepDataMapping[c]);for(let e=0;e<a.length;e+=1){const t=a[e],i=l.stepDataMapping[c][t];i.value&&(n[i.machineName]=i.value)}const d=r.activity_output_url.includes("functions/"),p=d?"POST":"GET";l.apiHandler.callDynamicDataEndpoint(new URL(r.activity_output_url),{authorization_id:`${l.stepMapping[c].selectedAuthId}`,...n},p).then((e=>{o({loading:!1});let n=!1;if(e){const t=e;d&&"output"in t?this.setActivityOutputFromIntegryObjectOrRawActivityOutput(t.output,r,s,!0):l.setActivityOutputData({activityOutputData:r.loop_variable_name?this.replaceContactPrefix(e,s,r):e})}else n=!0;t&&t(n)})),r.sample_data_endpoint_url&&c&&i(r.sample_data_endpoint_url,c,{...n})}else r.activity_output&&(o({loading:!1}),t&&t(),this.setActivityOutputFromIntegryObjectOrRawActivityOutput(n,r,s));return!1}return!((l.genericData.isTestIntegration||!r.app_id&&!this.canOverrideIntegryObject(n))&&r.activity_output)||(o({loading:!1}),t&&t(),d=!0,this.setActivityOutputFromRawActivityOutput(r,s),!1)})),!d&&r.activity_output?(this.setActivityOutputFromIntegryObjectOrRawActivityOutput(n,r,s),o({loading:!1}),t&&t(),d=!0,!1):!d}))};replaceContactPrefix=(e,t,n)=>{const i=`steps.${t}.out.${n.loop_variable_name?`${n.loop_variable_name}`:""}`;return e.map((e=>({...e,value:e.value.replace("contact_v1",i)})))};setActivityOutputFromRawActivityOutput=(()=>{var e=this;return function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";try{let i={};i=t.activity_output;const o=Yo(i,"",`steps.${n}.out.${t.loop_variable_name?`${t.loop_variable_name}.`:""}`),s=Qo(i,"",`steps.${n}.out.${t.loop_variable_name?`${t.loop_variable_name}.`:""}`);e.props.setIncomingWebhookPayload({incomingWebhookPayload:i}),e.props.setActivityOutputData({activityOutputData:o||[]}),e.props.setDynamicFieldData({dynamicFieldData:s||{}}),e.setState({dynamicFieldDataState:s||{}})}catch(e){console.error(e)}}})();setDynamicData=(e,t,n)=>{this.props.apiHandler.callDynamicDataEndpoint(new URL(e),{authorization_id:`${this.props.stepMapping[t].selectedAuthId}`,...n}).then((e=>{e&&(this.props.setDynamicFieldData({dynamicFieldData:e}),this.setState({dynamicFieldDataState:e}))}))};canOverrideIntegryObject=e=>{if(e)try{const t=JSON.parse(e);if(this.props.userConfig?.objects?.[t.name])return!0}catch(e){return!1}return!1};setActivityOutputFromIntegryObjectOrRawActivityOutput=(()=>{var e=this;return function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t)try{let s={};if(o)s=t;else{const n=JSON.parse(t);s=e.props.userConfig?.objects?.[n.name]?e.props.userConfig?.objects?.[n.name]:JSON.parse(n.payload)}const a=Yo(s,"",`steps.${i}.out.${n.loop_variable_name?`${n.loop_variable_name}.`:""}`),l=Qo(s,"",`steps.${i}.out.${n.loop_variable_name?`${n.loop_variable_name}.`:""}`);e.props.setIncomingWebhookPayload({incomingWebhookPayload:s}),e.props.setActivityOutputData({activityOutputData:a||[]}),e.props.setDynamicFieldData({dynamicFieldData:l||{}}),e.setState({dynamicFieldDataState:l||{}})}catch(e){console.error(e)}else e.setActivityOutputFromRawActivityOutput(n,i)}})();setRootStepData=async(e,t,n)=>{const i=this.props.genericData.stepWithActivityOutput;let o=i?.template_fields.find((e=>"integry_webhook_object"===e.activity_field?.machine_name))?.default_value;if(o){let e={};try{e=JSON.parse(o||"{}")}catch(t){e={}}e={payload:o||"{}",name:i?.template_fields.find((e=>"payload_name"===e.activity_field?.machine_name))?.default_value||"payload"},o=JSON.stringify(e)}if(this.props.setActivityOutputData({activityOutputData:[]}),this.props.step.source_steps&&Object.keys(this.props.step.source_steps).length>0)this.setActivityOutputFromSourceStep(t,n,o);else if(i){const{id:s}=i;i.activity.activity_output_url?(t||this.setState({loading:!0}),this.props.apiHandler.callDynamicDataEndpoint(new URL(i.activity.activity_output_url),{authorization_id:`${this.props.stepMapping[s].selectedAuthId}`,...e}).then((e=>{this.setState({loading:!1}),n&&n(),e&&this.props.setActivityOutputData({activityOutputData:e})}))):i.activity.activity_output?(this.setActivityOutputFromIntegryObjectOrRawActivityOutput(o,i.activity),this.setState({loading:!1}),n&&n()):(this.setState({loading:!1}),n&&n()),i.activity.dynamic_field_data_endpoint&&this.setDynamicData(i.activity.dynamic_field_data_endpoint,s,e)}};removeCurlyBraces=e=>e.replace(/^{(.*)}$/,"$1");isNotJSON=e=>{try{return!(Array.isArray(e)&&e.length>0&&"object"==typeof e[0])&&(JSON.parse(e),!!Number(e))}catch(e){return!0}};arrayToNestedJSONWithFirstValue=(e,t)=>{let n={},i=[];e&&Array.isArray(e)&&(i=e),Object.keys(t||{}).forEach((e=>{const i=this.removeCurlyBraces(e);n={...n,[i]:t[e]||""}}));let o={};(i||[]).forEach((e=>{o={...o,[e.text]:t[e.value]||""}}));const s={};return(i||[]).forEach((e=>{if(!e.text||!e.value)return;const t=e.text.split(".");let i=s;t.forEach(((o,s)=>{i[o]||(s===t.length-1?n[e.value]&&n[e.value][0]&&this.isNotJSON(n[e.value][0])?i[o]=n[e.value][0]||"":i[o]="":i[o]={}),i=i[o]}))})),s};getFieldValFromActivityOutputRaw=(e,t)=>{const n=t.match(/{([^}]+)}/g);let i=t;return(n||[]).forEach((t=>{const n=t.replace(/{|}/g,"");(e||[]).forEach((e=>{e.text===n&&(i=i.replace(t,`{${e.value}}`))}))})),i};getStepVisibleFieldsData=e=>{const t=this.props.stepDataMapping[e];return Object.keys(t).filter((e=>t[Number(e)].value)).reduce(((e,n)=>{const i=t[Number(n)];return{...e,[i.machineName]:i.value}}),{})};areParentValuesFilled=(e,t)=>{let n=!0;for(let i=0;i<t.length;i+=1){const o=t[i];let s=null;this.props.parentChildMapping[e][o]&&(s=this.props.parentChildMapping[e][o].fieldId);const a=s&&this.props.stepDataMapping[e]&&this.props.stepDataMapping[e][s];if(!a||!a.value){n=!1;break}}return n};doParentFieldsHaveValues=(e,t)=>{let n=!0;const i=this.props.parentChildMapping[e][t];if(i&&i.parentFields)for(let t=0;t<i.parentFields.length;t+=1){const o=this.props.parentChildMapping[e][i.parentFields[t]],s=o&&this.props.stepDataMapping[e]&&this.props.stepDataMapping[e][o.fieldId];if(!s||!s.value){n=!1;break}}return n};shouldShowStep=e=>{if(!this.props.showStepValidation)return!0;const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t];if("BUTTON"===e.type||"HTML"===e.type||"SECTION"===e.type)return!0;if(n&&e.activity_field){if(this.props.userConfig&&this.props.userConfig.viewAsIU)return!0;const n=!e.is_hidden,i=!0,{parentFields:o}=this.props.parentChildMapping[t][e.activity_field.machine_name],s=this.props.conditionalFieldMapping[t][e.activity_field.machine_name];let a=!0,l=!0;o&&(a=this.areParentValuesFilled(t,o)),s&&(l=ae(t,s,this.props.stepDataMapping));const r=a&&l;return n&&i&&r}return!1};stepIsOfType=e=>{const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t]||{step:this.props.step};return e.indexOf(n.step.activity?.type)>-1};textFieldParentHasValues=e=>{const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t]||{step:this.props.step},i=n.step.template_fields.filter((e=>e.is_visible)),o=!(!this.props?.userConfig||!this.props?.userConfig.viewAsIU)||n.selectedAuthId;if(!i.filter((e=>e.activity_field&&"DYNAMIC"===e.activity_field.type))[0])return!0;let s=!1;return i.forEach((t=>{const{activity_field:n}=t,{activity_field:i}=e;n?.child_fields?.includes(i.machine_name)&&(s=!0)})),!s||!!(i.length>0&&e&&e.activity_field&&o&&this.doParentFieldsHaveValues(t,e.activity_field.machine_name))};shouldShowOldMapping=()=>{const e=this.props.step.id,t=this.props.stepMapping&&this.props.stepMapping[e];if(this.stepIsOfType(["ADAPTER","ACTION"])){const n=t.step.template_fields.filter((e=>e.is_visible)),i=t.step.template_fields.filter((e=>e.is_visible&&"TEXTFIELD"===e.activity_field?.type)),o=t.selectedAuthId,s=n.filter((e=>e.activity_field&&"DYNAMIC"===e.activity_field.type))[0];if(i.length>0&&o&&!s&&!this.shouldShowNewMapping())return!0;if(!s)return!1;if(n.length>0&&o&&s&&s.activity_field&&this.doParentFieldsHaveValues(e,s.activity_field.machine_name)){const t=this.props.conditionalFieldMapping[e][s.activity_field.machine_name];return!t||ae(e,t,this.props.stepDataMapping)}return!1}return!1};shouldShowNewMapping=()=>{const{step:e,stepMapping:t}=this.props,n=t[e.id];if(this.stepIsOfType(["ADAPTER","ACTION"])){const e=n.step.template_fields.filter((e=>e.is_visible));if(e){if(e.filter((e=>e.activity_field&&"FIELD_MAPPING"===e.activity_field.type))[0])return!0}}return!1};getMappingDataInput=()=>{const e=this.props.step.id;return{authId:(this.props.stepMapping&&this.props.stepMapping[e]).selectedAuthId,fieldsData:this.getStepVisibleFieldsData(e)}};onFieldChange=e=>{let{stepId:t,fieldId:n,value:i,isRequired:o,machineName:s}=e;this.props.onFieldChangeCallback?this.props.onFieldChangeCallback(s||"",i):(this.props.setStepFieldData({stepId:`${t}`,fieldId:`${n}`,value:i,isRequired:o}),this.props.clearChildFields({stepId:t,fieldId:n}),this.props.verifyStepValidity(Number(t)))};fieldDynamicData=e=>{const t=this.props.step.id;if(this.props.stepMapping&&this.props.stepMapping[t]&&e.activity_field){const n=this.props.parentChildMapping[t][e.activity_field.machine_name]?.parentFields||null;if(n){return n.reduce(((e,n)=>{const{fieldId:i}=this.props.parentChildMapping[t][n];return i?{...e,[n]:this.props.stepDataMapping[t][i].value}:e}),{})}}return null};sourceFlowData=e=>{if(e.source_flow_integration_invocation_url){const{stepMapping:e,stepDataMapping:t}=this.props;return{steps:{...Object.keys(e).reduce(((n,i)=>{const{machine_name:o,id:s}=e[i].step;return o?{...n,[o]:{in:Object.keys(t[s]).reduce(((e,n)=>{const i=parseInt(n,10);if(t[s][i]){const{value:n,machineName:o}=t[s][i];return{...e,[o]:n}}return e}),{})}}:n}),{})}}}return null};isHTML=e=>!!/<\/?[a-z][\s\S]*>/i.test(e);getPlaceholder=e=>{let t="Incoming Webhook"===this.props.genericData.stepWithActivityOutput?.activity?.app?.name?this.props.genericData.selfAppName:this.props.genericData.stepWithActivityOutput?.activity?.app?.name||"";if(!t||t.includes("Webhook")){const e=this.props.step.source_steps,{stepMapping:n}=this.props,{props:i}=this;let o=null;Object.keys(e).forEach((e=>{const s=i.step.source_steps[e];o=s.app_id,s.app_name?t=s.app_name:Object.keys(n).every((e=>(n[e].step.authorization_type.app.id===s.app_id&&(t=n[e].step.activity.app.name),!0)))})),t?.includes("Incoming Webhook")&&null===o&&(t="Webhook")}return"TEXTAREA"===e.activity_field?.type||"TEXTFIELD"===e.activity_field?.type||"DYNAMIC"===e.activity_field?.type?!e.is_editable||e.is_mappable||e.allow_tags_in_text?!e.is_editable&&e.is_mappable?`Map to a ${t} field...`:e.is_editable&&(e.is_mappable||e.allow_tags_in_text)?`Enter text or map to a ${t} field...`:"Please enter a value":"Enter text...":"CHECKBOX"===e.activity_field?.type||"SELECT"===e.activity_field?.type||"RADIO"===e.activity_field?.type?!e.is_editable||e.is_mappable||e.allow_tags_in_text?!e.is_editable&&e.is_mappable?`Select a value or map to a ${t} field...`:e.is_editable&&e.allow_tags_in_text?`Enter text with ${t} fields or select a value...`:e.is_editable&&e.is_mappable?`Enter text, select a value or map to a ${t} field...`:"Select a value...":"Enter text or select a value...":"TEXTAREA"===e.activity_field?.type||"TEXTFIELD"===e.activity_field?.type?"Enter text...":"CHECKBOX"===e.activity_field?.type||"SELECT"===e.activity_field?.type||"RADIO"===e.activity_field?.type?"Select a value...":""};replacePlaceholders=(e,t)=>{const n={};return Object.entries(e).forEach((e=>{let[i,o]=e;if("string"==typeof o&&o.includes("{")){const e=o.match(/{(.*?)}/);if(e&&e[1]){const s=e[1],a=s.split(".").pop();void 0!==t[s]?n[i]=o.replace(e[0],t[s]):a&&void 0!==t[a]&&(n[i]=o.replace(e[0],t[a]))}}else"string"==typeof o&&o&&(n[i]=o)})),n};render(){const{step:e,stepMapping:t,stepDataMapping:n,setStepFieldData:i,showStepValidation:o,isReadOnly:s,accountConnected:a}=this.props,l=t[e.id]&&t[e.id].step||e,r=n&&n[e.id]||{},d={}||this.props.activityOutputData||{},p=0===l.template_fields?.length||!(this.props.userConfig&&this.props.userConfig.viewAsIU)&&0===l.template_fields?.filter((e=>e.is_visible)).length;return R`
|
|
3380
|
+
`};var Js={actionFormWrap:"styles-module_actionFormWrap__1--9G",noStepFields:"styles-module_noStepFields__1NQe1",actionFormWrapAutoWidth:"styles-module_actionFormWrapAutoWidth__2Vs2x",unsupported:"styles-module_unsupported__2swxl",actionFormLoader:"styles-module_actionFormLoader__2AXe4"};ue('.styles-module_actionFormWrap__1--9G {\n width: 100%;\n}\n.styles-module_actionFormWrap__1--9G .styles-module_noStepFields__1NQe1 {\n font-family: "Inter";\n font-weight: 400;\n font-size: 14px;\n line-height: 24px;\n color: #999999;\n}\n\n.styles-module_actionFormWrapAutoWidth__2Vs2x {\n margin-left: 24px;\n margin-right: 24px;\n width: auto;\n}\n\n.styles-module_unsupported__2swxl {\n font-size: 12px;\n color: #ca8c1b;\n}\n\n.styles-module_actionFormLoader__2AXe4 {\n width: 15px;\n margin: 0 auto;\n}');var Xs=B.connect(["stepState","stepMapping","stepDataMapping","parentChildMapping","fieldListMapping","conditionalFieldMapping","embedConfig","activityOutputData","genericData","userConfig","authMapping"],re)(class extends g{constructor(e){super(e);const t=e.step;this.state={loading:!1,dynamicFieldDataState:{},tagsTree:this.props.tagsTree&&Object.keys(this.props.tagsTree).length>0?Yo(this.props.tagsTree):{},parentChildMapping:this.setParentChildMapping([t]),dynamicFieldsData:{},parentFieldChanged:!1}}componentDidMount(){const{step:e,verifyStepValidity:t}=this.props;t(e.id);const n=this.props.genericData.stepWithActivityOutput;if(n){const{id:e}=n,t=this.getVisibleFieldsDataOnRootStep(e);this.setRootStepData(t)}else this.setRootStepData({})}componentDidUpdate(e){const{step:t,verifyStepValidity:n}=this.props;if(e.step.id!==t.id){n(t.id);const e=this.props.genericData.stepWithActivityOutput;if(e){const{id:t}=e,n=this.getVisibleFieldsDataOnRootStep(t);this.setRootStepData(n)}else this.setRootStepData({})}}setParentChildMapping(e){this.setState((t=>{const n=e.reduce(((e,n)=>{const i=n.template_fields.reduce(((e,t)=>{const n=t.activity_field;if(n){const i={...e};return i[n.machine_name]={fieldId:t.id,childFields:n.child_fields?JSON.parse(n.child_fields):null,parentFields:n.parent_fields?JSON.parse(n.parent_fields):null},i}return e}),{});return{...e,[n.id]:{...t.parentChildMapping?.[n.id]||{},...i}}}),{});return{parentChildMapping:{...t.parentChildMapping,...n}}}))}getVisibleFieldsDataOnRootStep=e=>{const t=this.props.stepDataMapping[e];return Object.keys(t).filter((e=>t[Number(e)].value)).reduce(((e,n)=>{const i=t[Number(n)];return{...e,[i.machineName]:i.value}}),{})};refreshRootStepData=async e=>{const t=this.props.genericData.stepWithActivityOutput;if(t){const{id:n}=t,i=this.getVisibleFieldsDataOnRootStep(n);this.setRootStepData(i,!0,e)}else this.setRootStepData({},!0,e)};setActivityOutputFromSourceStep=(e,t,n)=>{const{setDynamicData:i}=this,o=this.setState.bind(this),s=this.props.step.source_steps,{stepMapping:a}=this.props,{props:l}=this;Object.keys(s).forEach((s=>{const r=l.step.source_steps[s];let d=!1;return Object.keys(a).every((p=>{const c=a[p].step.id;if(c&&(a[c].step.machine_name===s||a[c].step.machine_name===r.form_step_machine_name)&&!l.genericData.isTestIntegration){if(d=!0,r.activity_output_url){e||o({loading:!0});const n={},a=Object.keys(l.stepDataMapping[c]);for(let e=0;e<a.length;e+=1){const t=a[e],i=l.stepDataMapping[c][t];i.value&&(n[i.machineName]=i.value)}const d=r.activity_output_url.includes("functions/"),p=d?"POST":"GET";l.apiHandler.callDynamicDataEndpoint(new URL(r.activity_output_url),{authorization_id:`${l.stepMapping[c].selectedAuthId}`,...n},p).then((e=>{o({loading:!1});let n=!1;if(e){const t=e;d&&"output"in t?this.setActivityOutputFromIntegryObjectOrRawActivityOutput(t.output,r,s,!0):l.setActivityOutputData({activityOutputData:r.loop_variable_name?this.replaceContactPrefix(e,s,r):e})}else n=!0;t&&t(n)})),r.sample_data_endpoint_url&&c&&i(r.sample_data_endpoint_url,c,{...n})}else r.activity_output&&(o({loading:!1}),t&&t(),this.setActivityOutputFromIntegryObjectOrRawActivityOutput(n,r,s));return!1}return!((l.genericData.isTestIntegration||!r.app_id&&!this.canOverrideIntegryObject(n))&&r.activity_output)||(o({loading:!1}),t&&t(),d=!0,this.setActivityOutputFromRawActivityOutput(r,s),!1)})),!d&&r.activity_output?(this.setActivityOutputFromIntegryObjectOrRawActivityOutput(n,r,s),o({loading:!1}),t&&t(),d=!0,!1):!d}))};replaceContactPrefix=(e,t,n)=>{const i=`steps.${t}.out.${n.loop_variable_name?`${n.loop_variable_name}`:""}`;return e.map((e=>({...e,value:e.value.replace("contact_v1",i)})))};setActivityOutputFromRawActivityOutput=(()=>{var e=this;return function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";try{let i={};i=t.activity_output;const o=Yo(i,"",`steps.${n}.out.${t.loop_variable_name?`${t.loop_variable_name}.`:""}`),s=Qo(i,"",`steps.${n}.out.${t.loop_variable_name?`${t.loop_variable_name}.`:""}`);e.props.setIncomingWebhookPayload({incomingWebhookPayload:i}),e.props.setActivityOutputData({activityOutputData:o||[]}),e.props.setDynamicFieldData({dynamicFieldData:s||{}}),e.setState({dynamicFieldDataState:s||{}})}catch(e){console.error(e)}}})();setDynamicData=(e,t,n)=>{this.props.apiHandler.callDynamicDataEndpoint(new URL(e),{authorization_id:`${this.props.stepMapping[t].selectedAuthId}`,...n}).then((e=>{e&&(this.props.setDynamicFieldData({dynamicFieldData:e}),this.setState({dynamicFieldDataState:e}))}))};canOverrideIntegryObject=e=>{if(e)try{const t=JSON.parse(e);if(this.props.userConfig?.objects?.[t.name])return!0}catch(e){return!1}return!1};setActivityOutputFromIntegryObjectOrRawActivityOutput=(()=>{var e=this;return function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t)try{let s={};if(o)s=t;else{const n=JSON.parse(t);s=e.props.userConfig?.objects?.[n.name]?e.props.userConfig?.objects?.[n.name]:JSON.parse(n.payload)}const a=Yo(s,"",`steps.${i}.out.${n.loop_variable_name?`${n.loop_variable_name}.`:""}`),l=Qo(s,"",`steps.${i}.out.${n.loop_variable_name?`${n.loop_variable_name}.`:""}`);e.props.setIncomingWebhookPayload({incomingWebhookPayload:s}),e.props.setActivityOutputData({activityOutputData:a||[]}),e.props.setDynamicFieldData({dynamicFieldData:l||{}}),e.setState({dynamicFieldDataState:l||{}})}catch(e){console.error(e)}else e.setActivityOutputFromRawActivityOutput(n,i)}})();setRootStepData=async(e,t,n)=>{const i=this.props.genericData.stepWithActivityOutput;let o=i?.template_fields.find((e=>"integry_webhook_object"===e.activity_field?.machine_name))?.default_value;if(o){let e={};try{e=JSON.parse(o||"{}")}catch(t){e={}}e={payload:o||"{}",name:i?.template_fields.find((e=>"payload_name"===e.activity_field?.machine_name))?.default_value||"payload"},o=JSON.stringify(e)}if(this.props.setActivityOutputData({activityOutputData:[]}),this.props.step.source_steps&&Object.keys(this.props.step.source_steps).length>0)this.setActivityOutputFromSourceStep(t,n,o);else if(i){const{id:s}=i;i.activity.activity_output_url?(t||this.setState({loading:!0}),this.props.apiHandler.callDynamicDataEndpoint(new URL(i.activity.activity_output_url),{authorization_id:`${this.props.stepMapping[s].selectedAuthId}`,...e}).then((e=>{this.setState({loading:!1}),n&&n(),e&&this.props.setActivityOutputData({activityOutputData:e})}))):i.activity.activity_output?(this.setActivityOutputFromIntegryObjectOrRawActivityOutput(o,i.activity),this.setState({loading:!1}),n&&n()):(this.setState({loading:!1}),n&&n()),i.activity.dynamic_field_data_endpoint&&this.setDynamicData(i.activity.dynamic_field_data_endpoint,s,e)}};removeCurlyBraces=e=>e.replace(/^{(.*)}$/,"$1");isNotJSON=e=>{try{return!(Array.isArray(e)&&e.length>0&&"object"==typeof e[0])&&(JSON.parse(e),!!Number(e))}catch(e){return!0}};arrayToNestedJSONWithFirstValue=(e,t)=>{let n={},i=[];e&&Array.isArray(e)&&(i=e),Object.keys(t||{}).forEach((e=>{const i=this.removeCurlyBraces(e);n={...n,[i]:t[e]||""}}));let o={};(i||[]).forEach((e=>{o={...o,[e.text]:t[e.value]||""}}));const s={};return(i||[]).forEach((e=>{if(!e.text||!e.value)return;const t=e.text.split(".");let i=s;t.forEach(((o,s)=>{i[o]||(s===t.length-1?n[e.value]&&n[e.value][0]&&this.isNotJSON(n[e.value][0])?i[o]=n[e.value][0]||"":i[o]="":i[o]={}),i=i[o]}))})),s};getFieldValFromActivityOutputRaw=(e,t)=>{const n=t.match(/{([^}]+)}/g);let i=t;return(n||[]).forEach((t=>{const n=t.replace(/{|}/g,"");(e||[]).forEach((e=>{e.text===n&&(i=i.replace(t,`{${e.value}}`))}))})),i};getStepVisibleFieldsData=e=>{const t=this.props.stepDataMapping[e];return Object.keys(t).filter((e=>t[Number(e)].value)).reduce(((e,n)=>{const i=t[Number(n)];return{...e,[i.machineName]:i.value}}),{})};areParentValuesFilled=(e,t)=>{let n=!0;for(let i=0;i<t.length;i+=1){const o=t[i];let s=null;this.props.parentChildMapping[e][o]&&(s=this.props.parentChildMapping[e][o].fieldId);const a=s&&this.props.stepDataMapping[e]&&this.props.stepDataMapping[e][s];if(!a||!a.value){n=!1;break}}return n};doParentFieldsHaveValues=(e,t)=>{let n=!0;const i=this.props.parentChildMapping[e][t];if(i&&i.parentFields)for(let t=0;t<i.parentFields.length;t+=1){const o=this.props.parentChildMapping[e][i.parentFields[t]],s=o&&this.props.stepDataMapping[e]&&this.props.stepDataMapping[e][o.fieldId];if(!s||!s.value){n=!1;break}}return n};shouldShowStep=e=>{if(!this.props.showStepValidation)return!0;const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t];if("BUTTON"===e.type||"HTML"===e.type||"SECTION"===e.type)return!0;if(n&&e.activity_field){if(this.props.userConfig&&this.props.userConfig.viewAsIU)return!0;const n=!e.is_hidden,i=!0,{parentFields:o}=this.props.parentChildMapping[t][e.activity_field.machine_name],s=this.props.conditionalFieldMapping[t][e.activity_field.machine_name];let a=!0,l=!0;o&&(a=this.areParentValuesFilled(t,o)),s&&(l=ae(t,s,this.props.stepDataMapping));const r=a&&l;return n&&i&&r}return!1};stepIsOfType=e=>{const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t]||{step:this.props.step};return e.indexOf(n.step.activity?.type)>-1};textFieldParentHasValues=e=>{const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t]||{step:this.props.step},i=n.step.template_fields.filter((e=>e.is_visible)),o=!(!this.props?.userConfig||!this.props?.userConfig.viewAsIU)||n.selectedAuthId;if(!i.filter((e=>e.activity_field&&"DYNAMIC"===e.activity_field.type))[0])return!0;let s=!1;return i.forEach((t=>{const{activity_field:n}=t,{activity_field:i}=e;n?.child_fields?.includes(i.machine_name)&&(s=!0)})),!s||!!(i.length>0&&e&&e.activity_field&&o&&this.doParentFieldsHaveValues(t,e.activity_field.machine_name))};shouldShowOldMapping=()=>{const e=this.props.step.id,t=this.props.stepMapping&&this.props.stepMapping[e]||{step:this.props.step};if(this.stepIsOfType(["ADAPTER","ACTION"])){const n=t.step.template_fields.filter((e=>e.is_visible)),i=t.step.template_fields.filter((e=>e.is_visible&&"TEXTFIELD"===e.activity_field?.type)),o=t.selectedAuthId,s=n.filter((e=>e.activity_field&&"DYNAMIC"===e.activity_field.type))[0];if(i.length>0&&o&&!s&&!this.shouldShowNewMapping())return!0;if(!s)return!1;if(n.length>0&&o&&s&&s.activity_field&&this.doParentFieldsHaveValues(e,s.activity_field.machine_name)){const t=this.props.conditionalFieldMapping[e][s.activity_field.machine_name];return!t||ae(e,t,this.props.stepDataMapping)}return!1}return!1};shouldShowNewMapping=()=>{const{step:e,stepMapping:t}=this.props,n=t[e.id];if(this.stepIsOfType(["ADAPTER","ACTION"])){const e=n.step.template_fields.filter((e=>e.is_visible));if(e){if(e.filter((e=>e.activity_field&&"FIELD_MAPPING"===e.activity_field.type))[0])return!0}}return!1};getMappingDataInput=()=>{const e=this.props.step.id;return{authId:(this.props.stepMapping&&this.props.stepMapping[e]).selectedAuthId,fieldsData:this.getStepVisibleFieldsData(e)}};isParentField=(e,t)=>Object.values(e).some((e=>Object.values(e).some((e=>Array.isArray(e.parentFields)&&e.parentFields.includes(t)))));onFieldChange=e=>{let{stepId:t,fieldId:n,value:i,isRequired:o,machineName:s}=e;this.props.onFieldChangeCallback?(this.setState((e=>({dynamicFieldsData:{...e.dynamicFieldsData,[s||""]:i}}))),this.isParentField(this.state.parentChildMapping,s||"")&&this.setState({parentFieldChanged:!this.state.parentFieldChanged}),this.props.onFieldChangeCallback(s||"",i)):(this.props.setStepFieldData({stepId:`${t}`,fieldId:`${n}`,value:i,isRequired:o}),this.props.clearChildFields({stepId:t,fieldId:n}),this.props.verifyStepValidity(Number(t)))};fieldDynamicData=e=>{const t=this.props.step.id;if(this.props.stepMapping&&this.props.stepMapping[t]&&e.activity_field){const n=this.props.parentChildMapping[t][e.activity_field.machine_name]?.parentFields||null;if(n){return n.reduce(((e,n)=>{const{fieldId:i}=this.props.parentChildMapping[t][n];return i?{...e,[n]:this.props.stepDataMapping[t][i].value}:e}),{})}}return null};sourceFlowData=e=>{if(e.source_flow_integration_invocation_url){const{stepMapping:e,stepDataMapping:t}=this.props;return{steps:{...Object.keys(e).reduce(((n,i)=>{const{machine_name:o,id:s}=e[i].step;return o?{...n,[o]:{in:Object.keys(t[s]).reduce(((e,n)=>{const i=parseInt(n,10);if(t[s][i]){const{value:n,machineName:o}=t[s][i];return{...e,[o]:n}}return e}),{})}}:n}),{})}}}return null};isHTML=e=>!!/<\/?[a-z][\s\S]*>/i.test(e);getPlaceholder=e=>{let t="Incoming Webhook"===this.props.genericData.stepWithActivityOutput?.activity?.app?.name?this.props.genericData.selfAppName:this.props.genericData.stepWithActivityOutput?.activity?.app?.name||"";if(!t||t.includes("Webhook")){const e=this.props.step.source_steps,{stepMapping:n}=this.props,{props:i}=this;let o=null;Object.keys(e).forEach((e=>{const s=i.step.source_steps[e];o=s.app_id,s.app_name?t=s.app_name:Object.keys(n).every((e=>(n[e].step.authorization_type.app.id===s.app_id&&(t=n[e].step.activity.app.name),!0)))})),t?.includes("Incoming Webhook")&&null===o&&(t="Webhook")}return"TEXTAREA"===e.activity_field?.type||"TEXTFIELD"===e.activity_field?.type||"DYNAMIC"===e.activity_field?.type?!e.is_editable||e.is_mappable||e.allow_tags_in_text?!e.is_editable&&e.is_mappable?`Map to a ${t} field...`:e.is_editable&&(e.is_mappable||e.allow_tags_in_text)?`Enter text or map to a ${t} field...`:"Please enter a value":"Enter text...":"CHECKBOX"===e.activity_field?.type||"SELECT"===e.activity_field?.type||"RADIO"===e.activity_field?.type?!e.is_editable||e.is_mappable||e.allow_tags_in_text?!e.is_editable&&e.is_mappable?`Select a value or map to a ${t} field...`:e.is_editable&&e.allow_tags_in_text?`Enter text with ${t} fields or select a value...`:e.is_editable&&e.is_mappable?`Enter text, select a value or map to a ${t} field...`:"Select a value...":"Enter text or select a value...":"TEXTAREA"===e.activity_field?.type||"TEXTFIELD"===e.activity_field?.type?"Enter text...":"CHECKBOX"===e.activity_field?.type||"SELECT"===e.activity_field?.type||"RADIO"===e.activity_field?.type?"Select a value...":""};replacePlaceholders=(e,t)=>{const n={};return Object.entries(e).forEach((e=>{let[i,o]=e;if("string"==typeof o&&o.includes("{")){const e=o.match(/{(.*?)}/);if(e&&e[1]){const s=e[1],a=s.split(".").pop();void 0!==t[s]?n[i]=o.replace(e[0],t[s]):a&&void 0!==t[a]&&(n[i]=o.replace(e[0],t[a]))}}else"string"==typeof o&&o&&(n[i]=o)})),n};render(){const{step:e,stepMapping:t,stepDataMapping:n,setStepFieldData:i,showStepValidation:o,isReadOnly:s,accountConnected:a}=this.props,l=t[e.id]&&t[e.id].step||e,r=n&&n[e.id]||{},d={}||this.props.activityOutputData||{},p=0===l.template_fields?.length||!(this.props.userConfig&&this.props.userConfig.viewAsIU)&&0===l.template_fields?.filter((e=>e.is_visible)).length;return R`
|
|
3381
3381
|
${this.state.loading?R`<div class=${Js.actionFormLoader}><${Ye} /></div>`:R`
|
|
3382
3382
|
${l?R`
|
|
3383
3383
|
<div
|
|
@@ -3528,18 +3528,19 @@ var e,t,n,i,o,s,a,l={},r=[],d=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]
|
|
|
3528
3528
|
<${bs}
|
|
3529
3529
|
stepId=${l.id}
|
|
3530
3530
|
dynamicField=${t}
|
|
3531
|
-
endpointData=${JSON.stringify({authorization_id:this.props.stepMapping&&this.props.stepMapping[this.props.step.id]?.selectedAuthId,...this.fieldDynamicData(t)})}
|
|
3531
|
+
endpointData=${JSON.stringify({authorization_id:this.props.stepMapping&&this.props.stepMapping[this.props.step.id]?.selectedAuthId||this.props.selectedAuthId,...this.fieldDynamicData(t),...this.state.dynamicFieldsData})}
|
|
3532
3532
|
activityOutputData=${this.arrayToNestedJSONWithFirstValue(this.props.activityOutputData,this.props.dynamicFieldData||this.state.dynamicFieldDataState||{})}
|
|
3533
3533
|
activityOutputDataRaw=${this.props.activityOutputData}
|
|
3534
3534
|
placeHolder=${this.getPlaceholder(t)}
|
|
3535
3535
|
appName=${this.props.step.activity.app.name}
|
|
3536
|
-
selectedAuthId=${`${this.props.stepMapping[this.props.step.id]?.selectedAuthId||""}`}
|
|
3536
|
+
selectedAuthId=${`${this.props.stepMapping[this.props.step.id]?.selectedAuthId||this.props.selectedAuthId||""}`}
|
|
3537
3537
|
sourceFlowData=${this.sourceFlowData(t)}
|
|
3538
3538
|
sourceFlowIntegrataionInvocationUrl=${t.source_flow_integration_invocation_url}
|
|
3539
3539
|
isMappable=${t.is_mappable}
|
|
3540
3540
|
isEditable=${t.is_editable}
|
|
3541
3541
|
allowTagsInText=${t.allow_tags_in_text}
|
|
3542
3542
|
refreshRootStepData=${this.refreshRootStepData}
|
|
3543
|
+
parentFieldChanged=${this.state.parentFieldChanged}
|
|
3543
3544
|
/>
|
|
3544
3545
|
</div>
|
|
3545
3546
|
`;case"SECTION":return R`
|
|
@@ -7000,7 +7001,7 @@ var e,t,n,i,o,s,a,l={},r=[],d=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]
|
|
|
7000
7001
|
</div>
|
|
7001
7002
|
</div>
|
|
7002
7003
|
`}
|
|
7003
|
-
`}});const Rd={getAuthHash:async function(e,t){const n=e=>new Uint8Array([...unescape(encodeURIComponent(e))].map((e=>e.charCodeAt(0)))),i=n(t),o=n(e),s=await crypto.subtle.importKey("raw",i,{name:"HMAC",hash:"SHA-256"},!0,["sign"]),a=await crypto.subtle.sign("HMAC",s,o);return[...new Uint8Array(a)].map((e=>e.toString(16).padStart(2,"0"))).join("")}};class Wd{static SDK_VERSION="4.5.
|
|
7004
|
+
`}});const Rd={getAuthHash:async function(e,t){const n=e=>new Uint8Array([...unescape(encodeURIComponent(e))].map((e=>e.charCodeAt(0)))),i=n(t),o=n(e),s=await crypto.subtle.importKey("raw",i,{name:"HMAC",hash:"SHA-256"},!0,["sign"]),a=await crypto.subtle.sign("HMAC",s,o);return[...new Uint8Array(a)].map((e=>e.toString(16).padStart(2,"0"))).join("")}};class Wd{static SDK_VERSION="4.5.9";config;apiHandler;initConfig;eventEmitter=(()=>new G)();static html=(()=>R)();static RenderModes=(()=>ee)();static TemplateFormRenderModes=(()=>Y)();static Layouts=(()=>X)();static ViewStyles=(()=>J)();static MarketplaceRenderModes=(()=>Q)();static Helpers;authModalId="";forceRerender=!1;constructor(e){let t;const n=e.baseUrl||"https://app.integry.io",i=e;if(i.user){const{userId:e,apiKey:t,...n}=i.user;"userId"in i||(i.userId=""),"userId"in i&&(i.userId=e.toString()),i.xIntegryConfig||(i.xIntegryConfig={}),i.xIntegryConfig.appAuth||(i.xIntegryConfig.appAuth={}),i.xIntegryConfig.appAuth.extras||(i.xIntegryConfig.appAuth.extras={}),i.xIntegryConfig.appAuth.apiKey=(t||"").toString(),i.xIntegryConfig.appAuth.extras=n}const o={oauthVerifyPath:"auth/verify",endpointsUrl:"https://integry-app.appspot.com",baseUrl:n,baseUrlv2:`${n}/v2`,baseAPIUrl:"https://api.integry.io",apiKey:i.xIntegryConfig?.appAuth?.apiKey,authId:i.xIntegryConfig?.appAuth?.authId,extras:i.xIntegryConfig?.appAuth?.extras},s=i.options||i.userConfig||{};if(i.options&&i.payloads&&(i.options.objects=e.payloads),"appKey"in i)t={...i,...o,appKey:i.appKey,hash:i.hash,userId:i.userId},this.config={...i,...o,appKey:i.appKey,hash:i.hash,userId:i.userId,deploymentId:i.deploymentId,userConfig:i.deploymentId?{...s,tags:s?.tags?[...s?.tags,`${i.deploymentId}`]:[`${i.deploymentId}`]}:s};else{const e=this.getAuthParamsFromUrl()||{};t={...o,...e},this.config={...o,...e,userConfig:i.userConfig}}this.authModalId=this.getRandomFlowId(6),this.apiHandler=new j(t),this.verifyAuthConfig().then((e=>{e?.config_verified?this.eventEmitter.emit("ready",{isReady:!0}):console.error("IntegrySDK: Auth config verification failed, are your auth parameters correct?")})).catch((e=>console.error(e))),this.initConfig={containerId:"",renderMode:Y.INLINE}}SDKFailedHandler=(e,t)=>{const n=e.options||e.userConfig||{},i=document.getElementById(t);throw i&&T(R`
|
|
7004
7005
|
<${nl}
|
|
7005
7006
|
message="SDK failed to load"
|
|
7006
7007
|
debug=${n.debug}
|
package/dist/umd/index.umd.js
CHANGED
|
@@ -2668,21 +2668,21 @@
|
|
|
2668
2668
|
</fieldset>
|
|
2669
2669
|
${u&&v.length<1&&c&&R` <${vn}>Please select an option</${vn}>`}
|
|
2670
2670
|
</div>
|
|
2671
|
-
`};var ws={actionFormWrap:"styles-module_actionFormWrap__1l5fH",noStepFields:"styles-module_noStepFields__3OoJ5",actionStepFieldWrap:"styles-module_actionStepFieldWrap__2fC8s",unsupported:"styles-module_unsupported__10T6A",actionFormLoader:"styles-module_actionFormLoader__-bGAV",noOptions:"styles-module_noOptions__3xiOJ",noOptionsRetry:"styles-module_noOptionsRetry___2pkw",loadingText:"styles-module_loadingText__1xzvz",optionsRefreshProminent:"styles-module_optionsRefreshProminent__2hZwe",optionsRefresh:"styles-module_optionsRefresh__1AwL2"};ue('.styles-module_actionFormWrap__1l5fH {\n width: 100%;\n}\n.styles-module_actionFormWrap__1l5fH .styles-module_noStepFields__3OoJ5 {\n font-family: "Inter";\n font-weight: 400;\n font-size: 14px;\n line-height: 24px;\n color: #999999;\n}\n\n.styles-module_actionStepFieldWrap__2fC8s {\n margin-bottom: 16px;\n}\n\n.styles-module_unsupported__10T6A {\n font-size: 12px;\n color: #ca8c1b;\n}\n\n.styles-module_actionFormLoader__-bGAV {\n width: 15px;\n margin: 0 auto;\n}\n\n.styles-module_noOptions__3xiOJ {\n font-weight: 400;\n font-size: 12px;\n line-height: 15px;\n margin-bottom: 12px;\n display: block;\n color: #999;\n}\n.styles-module_noOptions__3xiOJ span.styles-module_noOptionsRetry___2pkw [class^=styles-module_loader_] {\n position: relative;\n top: 5px;\n}\n\n.styles-module_loadingText__1xzvz {\n font-weight: 400;\n font-size: 12px;\n line-height: 15px;\n margin-bottom: 12px;\n color: #999;\n display: flex;\n}\n.styles-module_loadingText__1xzvz .styles-module_actionFormLoader__-bGAV {\n margin: 0 7px 0 0;\n}\n\na.styles-module_optionsRefreshProminent__2hZwe {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 8px;\n font-size: 12px;\n line-height: 15px;\n color: #4250f0;\n cursor: pointer;\n text-decoration: none;\n}\n\na.styles-module_optionsRefresh__1AwL2 {\n font-size: 12px;\n line-height: 15px;\n color: #4250f0;\n cursor: pointer;\n text-decoration: none;\n}');var bs=B.connect(["stepState","genericData","embedConfig","stepMapping","dynamicFieldData","stepDataMapping","parentChildMapping"],re)((e=>{const{stepId:t,dynamicField:n,endpointData:i,genericData:o,activityOutputData:s,activityOutputDataRaw:a,appName:l,sourceFlowData:r={},sourceFlowIntegrataionInvocationUrl:d="",selectedAuthId:p="",isMappable:c=!0,isEditable:u=!0,allowTagsInText:_=!0,placeHolder:m="",refreshRootStepData:h}=e,[
|
|
2671
|
+
`};var ws={actionFormWrap:"styles-module_actionFormWrap__1l5fH",noStepFields:"styles-module_noStepFields__3OoJ5",actionStepFieldWrap:"styles-module_actionStepFieldWrap__2fC8s",unsupported:"styles-module_unsupported__10T6A",actionFormLoader:"styles-module_actionFormLoader__-bGAV",noOptions:"styles-module_noOptions__3xiOJ",noOptionsRetry:"styles-module_noOptionsRetry___2pkw",loadingText:"styles-module_loadingText__1xzvz",optionsRefreshProminent:"styles-module_optionsRefreshProminent__2hZwe",optionsRefresh:"styles-module_optionsRefresh__1AwL2"};ue('.styles-module_actionFormWrap__1l5fH {\n width: 100%;\n}\n.styles-module_actionFormWrap__1l5fH .styles-module_noStepFields__3OoJ5 {\n font-family: "Inter";\n font-weight: 400;\n font-size: 14px;\n line-height: 24px;\n color: #999999;\n}\n\n.styles-module_actionStepFieldWrap__2fC8s {\n margin-bottom: 16px;\n}\n\n.styles-module_unsupported__10T6A {\n font-size: 12px;\n color: #ca8c1b;\n}\n\n.styles-module_actionFormLoader__-bGAV {\n width: 15px;\n margin: 0 auto;\n}\n\n.styles-module_noOptions__3xiOJ {\n font-weight: 400;\n font-size: 12px;\n line-height: 15px;\n margin-bottom: 12px;\n display: block;\n color: #999;\n}\n.styles-module_noOptions__3xiOJ span.styles-module_noOptionsRetry___2pkw [class^=styles-module_loader_] {\n position: relative;\n top: 5px;\n}\n\n.styles-module_loadingText__1xzvz {\n font-weight: 400;\n font-size: 12px;\n line-height: 15px;\n margin-bottom: 12px;\n color: #999;\n display: flex;\n}\n.styles-module_loadingText__1xzvz .styles-module_actionFormLoader__-bGAV {\n margin: 0 7px 0 0;\n}\n\na.styles-module_optionsRefreshProminent__2hZwe {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 8px;\n font-size: 12px;\n line-height: 15px;\n color: #4250f0;\n cursor: pointer;\n text-decoration: none;\n}\n\na.styles-module_optionsRefresh__1AwL2 {\n font-size: 12px;\n line-height: 15px;\n color: #4250f0;\n cursor: pointer;\n text-decoration: none;\n}');var bs=B.connect(["stepState","genericData","embedConfig","stepMapping","dynamicFieldData","stepDataMapping","parentChildMapping"],re)((e=>{const{stepId:t,dynamicField:n,endpointData:i,genericData:o,activityOutputData:s,activityOutputDataRaw:a,appName:l,sourceFlowData:r={},sourceFlowIntegrataionInvocationUrl:d="",selectedAuthId:p="",isMappable:c=!0,isEditable:u=!0,allowTagsInText:_=!0,placeHolder:m="",refreshRootStepData:h,parentFieldChanged:g=!1}=e,[y,f]=Ce([]),[v,x]=Ce(!0),[w,b]=Ce(!1),$=Me(ne),C=$?.isReadOnly,I=async()=>{const{activity_field:e}=n;if(d&&p)$?.apiHandler.callSourceFlowIntegrationInvocationUrl(new URL(d),{authorization_id:p},r).then((e=>{if(e){if(!e)throw b(!0),new Error("Nothing returned from dynamic data endpoint");Array.isArray(e)?f(e):f([])}})).catch((e=>console.error(e))).finally((()=>x(!1)));else if(e&&e.dynamic_field_src){let t;try{t=JSON.parse(i)}catch(e){t=""}$?.apiHandler.callDynamicDataEndpointWithTags(new URL(e.dynamic_field_src),t,s).then((e=>{e?Array.isArray(e)?f(e):f([]):b(!0)})).catch((e=>console.error(e))).finally((()=>{x(!1)}))}};Ie((()=>{I()}),[n,i,p,g]);return R`
|
|
2672
2672
|
<div>
|
|
2673
|
-
${
|
|
2673
|
+
${v?R`<div className=${ws.loadingText}>
|
|
2674
2674
|
<div class=${ws.actionFormLoader}>
|
|
2675
2675
|
<${Ye} />
|
|
2676
2676
|
</div>
|
|
2677
2677
|
Loading custom fields...
|
|
2678
|
-
</div> `:R` ${
|
|
2678
|
+
</div> `:R` ${y.map((i=>{let o="";const r=(e.stepDataMapping[t]?e.stepDataMapping[t][n.id]:{}).objectValue;return r&&r[i.id]&&(o=`${r[i.id]}`),R`
|
|
2679
2679
|
<div class=${ws.dynamicFieldWrapper}>
|
|
2680
2680
|
<${Jo}
|
|
2681
2681
|
title=${i.title}
|
|
2682
2682
|
placeholder=${(()=>{let e="Enter text or map to fields...";return m?e=m:l&&(e=`Enter text or map to ${l} fields...`),e})()}
|
|
2683
2683
|
value=${o}
|
|
2684
2684
|
onChange=${o=>{((i,o)=>{const s=o.match(/{([^}]+)}/g);let l=o;(s||[]).forEach((e=>{const t=e.replace(/{|}/g,"");(a||[]).forEach((n=>{n.text===t&&(l=l.replace(e,`{${n.value}}`))}))})),e.setStepMappingData({stepId:t,fieldId:n.id,id:i,value:l})})(i.id,o)}}
|
|
2685
|
-
isReadOnly=${
|
|
2685
|
+
isReadOnly=${C}
|
|
2686
2686
|
type="TEXTFIELD"
|
|
2687
2687
|
isMappable=${c}
|
|
2688
2688
|
isEditable=${u}
|
|
@@ -2694,12 +2694,12 @@
|
|
|
2694
2694
|
/>
|
|
2695
2695
|
</div>
|
|
2696
2696
|
`}))}`}
|
|
2697
|
-
${
|
|
2697
|
+
${w?R`<span className=${ws.noOptions}
|
|
2698
2698
|
>Could not load custom fields.
|
|
2699
2699
|
${R` <a
|
|
2700
2700
|
className=${ws.optionsRefresh}
|
|
2701
2701
|
href="#"
|
|
2702
|
-
onclick=${()=>{
|
|
2702
|
+
onclick=${()=>{x(!0),b(!1),I()}}
|
|
2703
2703
|
>${" "}Try again?</a
|
|
2704
2704
|
>`}
|
|
2705
2705
|
</span>`:""}
|
|
@@ -3377,7 +3377,7 @@
|
|
|
3377
3377
|
`;var i,o}))}
|
|
3378
3378
|
${l&&R` <a onClick=${()=>{u([...c,{}])}}>+ Add another ${t.title}</a> `}
|
|
3379
3379
|
</div>
|
|
3380
|
-
`};var Js={actionFormWrap:"styles-module_actionFormWrap__1--9G",noStepFields:"styles-module_noStepFields__1NQe1",actionFormWrapAutoWidth:"styles-module_actionFormWrapAutoWidth__2Vs2x",unsupported:"styles-module_unsupported__2swxl",actionFormLoader:"styles-module_actionFormLoader__2AXe4"};ue('.styles-module_actionFormWrap__1--9G {\n width: 100%;\n}\n.styles-module_actionFormWrap__1--9G .styles-module_noStepFields__1NQe1 {\n font-family: "Inter";\n font-weight: 400;\n font-size: 14px;\n line-height: 24px;\n color: #999999;\n}\n\n.styles-module_actionFormWrapAutoWidth__2Vs2x {\n margin-left: 24px;\n margin-right: 24px;\n width: auto;\n}\n\n.styles-module_unsupported__2swxl {\n font-size: 12px;\n color: #ca8c1b;\n}\n\n.styles-module_actionFormLoader__2AXe4 {\n width: 15px;\n margin: 0 auto;\n}');var Xs=B.connect(["stepState","stepMapping","stepDataMapping","parentChildMapping","fieldListMapping","conditionalFieldMapping","embedConfig","activityOutputData","genericData","userConfig","authMapping"],re)(class extends g{constructor(e){super(e),this.state={loading:!1,dynamicFieldDataState:{},tagsTree:this.props.tagsTree&&Object.keys(this.props.tagsTree).length>0?Yo(this.props.tagsTree):{}}}componentDidMount(){const{step:e,verifyStepValidity:t}=this.props;t(e.id);const n=this.props.genericData.stepWithActivityOutput;if(n){const{id:e}=n,t=this.getVisibleFieldsDataOnRootStep(e);this.setRootStepData(t)}else this.setRootStepData({})}componentDidUpdate(e){const{step:t,verifyStepValidity:n}=this.props;if(e.step.id!==t.id){n(t.id);const e=this.props.genericData.stepWithActivityOutput;if(e){const{id:t}=e,n=this.getVisibleFieldsDataOnRootStep(t);this.setRootStepData(n)}else this.setRootStepData({})}}getVisibleFieldsDataOnRootStep=e=>{const t=this.props.stepDataMapping[e];return Object.keys(t).filter((e=>t[Number(e)].value)).reduce(((e,n)=>{const i=t[Number(n)];return{...e,[i.machineName]:i.value}}),{})};refreshRootStepData=async e=>{const t=this.props.genericData.stepWithActivityOutput;if(t){const{id:n}=t,i=this.getVisibleFieldsDataOnRootStep(n);this.setRootStepData(i,!0,e)}else this.setRootStepData({},!0,e)};setActivityOutputFromSourceStep=(e,t,n)=>{const{setDynamicData:i}=this,o=this.setState.bind(this),s=this.props.step.source_steps,{stepMapping:a}=this.props,{props:l}=this;Object.keys(s).forEach((s=>{const r=l.step.source_steps[s];let d=!1;return Object.keys(a).every((p=>{const c=a[p].step.id;if(c&&(a[c].step.machine_name===s||a[c].step.machine_name===r.form_step_machine_name)&&!l.genericData.isTestIntegration){if(d=!0,r.activity_output_url){e||o({loading:!0});const n={},a=Object.keys(l.stepDataMapping[c]);for(let e=0;e<a.length;e+=1){const t=a[e],i=l.stepDataMapping[c][t];i.value&&(n[i.machineName]=i.value)}const d=r.activity_output_url.includes("functions/"),p=d?"POST":"GET";l.apiHandler.callDynamicDataEndpoint(new URL(r.activity_output_url),{authorization_id:`${l.stepMapping[c].selectedAuthId}`,...n},p).then((e=>{o({loading:!1});let n=!1;if(e){const t=e;d&&"output"in t?this.setActivityOutputFromIntegryObjectOrRawActivityOutput(t.output,r,s,!0):l.setActivityOutputData({activityOutputData:r.loop_variable_name?this.replaceContactPrefix(e,s,r):e})}else n=!0;t&&t(n)})),r.sample_data_endpoint_url&&c&&i(r.sample_data_endpoint_url,c,{...n})}else r.activity_output&&(o({loading:!1}),t&&t(),this.setActivityOutputFromIntegryObjectOrRawActivityOutput(n,r,s));return!1}return!((l.genericData.isTestIntegration||!r.app_id&&!this.canOverrideIntegryObject(n))&&r.activity_output)||(o({loading:!1}),t&&t(),d=!0,this.setActivityOutputFromRawActivityOutput(r,s),!1)})),!d&&r.activity_output?(this.setActivityOutputFromIntegryObjectOrRawActivityOutput(n,r,s),o({loading:!1}),t&&t(),d=!0,!1):!d}))};replaceContactPrefix=(e,t,n)=>{const i=`steps.${t}.out.${n.loop_variable_name?`${n.loop_variable_name}`:""}`;return e.map((e=>({...e,value:e.value.replace("contact_v1",i)})))};setActivityOutputFromRawActivityOutput=(()=>{var e=this;return function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";try{let i={};i=t.activity_output;const o=Yo(i,"",`steps.${n}.out.${t.loop_variable_name?`${t.loop_variable_name}.`:""}`),s=Qo(i,"",`steps.${n}.out.${t.loop_variable_name?`${t.loop_variable_name}.`:""}`);e.props.setIncomingWebhookPayload({incomingWebhookPayload:i}),e.props.setActivityOutputData({activityOutputData:o||[]}),e.props.setDynamicFieldData({dynamicFieldData:s||{}}),e.setState({dynamicFieldDataState:s||{}})}catch(e){console.error(e)}}})();setDynamicData=(e,t,n)=>{this.props.apiHandler.callDynamicDataEndpoint(new URL(e),{authorization_id:`${this.props.stepMapping[t].selectedAuthId}`,...n}).then((e=>{e&&(this.props.setDynamicFieldData({dynamicFieldData:e}),this.setState({dynamicFieldDataState:e}))}))};canOverrideIntegryObject=e=>{if(e)try{const t=JSON.parse(e);if(this.props.userConfig?.objects?.[t.name])return!0}catch(e){return!1}return!1};setActivityOutputFromIntegryObjectOrRawActivityOutput=(()=>{var e=this;return function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t)try{let s={};if(o)s=t;else{const n=JSON.parse(t);s=e.props.userConfig?.objects?.[n.name]?e.props.userConfig?.objects?.[n.name]:JSON.parse(n.payload)}const a=Yo(s,"",`steps.${i}.out.${n.loop_variable_name?`${n.loop_variable_name}.`:""}`),l=Qo(s,"",`steps.${i}.out.${n.loop_variable_name?`${n.loop_variable_name}.`:""}`);e.props.setIncomingWebhookPayload({incomingWebhookPayload:s}),e.props.setActivityOutputData({activityOutputData:a||[]}),e.props.setDynamicFieldData({dynamicFieldData:l||{}}),e.setState({dynamicFieldDataState:l||{}})}catch(e){console.error(e)}else e.setActivityOutputFromRawActivityOutput(n,i)}})();setRootStepData=async(e,t,n)=>{const i=this.props.genericData.stepWithActivityOutput;let o=i?.template_fields.find((e=>"integry_webhook_object"===e.activity_field?.machine_name))?.default_value;if(o){let e={};try{e=JSON.parse(o||"{}")}catch(t){e={}}e={payload:o||"{}",name:i?.template_fields.find((e=>"payload_name"===e.activity_field?.machine_name))?.default_value||"payload"},o=JSON.stringify(e)}if(this.props.setActivityOutputData({activityOutputData:[]}),this.props.step.source_steps&&Object.keys(this.props.step.source_steps).length>0)this.setActivityOutputFromSourceStep(t,n,o);else if(i){const{id:s}=i;i.activity.activity_output_url?(t||this.setState({loading:!0}),this.props.apiHandler.callDynamicDataEndpoint(new URL(i.activity.activity_output_url),{authorization_id:`${this.props.stepMapping[s].selectedAuthId}`,...e}).then((e=>{this.setState({loading:!1}),n&&n(),e&&this.props.setActivityOutputData({activityOutputData:e})}))):i.activity.activity_output?(this.setActivityOutputFromIntegryObjectOrRawActivityOutput(o,i.activity),this.setState({loading:!1}),n&&n()):(this.setState({loading:!1}),n&&n()),i.activity.dynamic_field_data_endpoint&&this.setDynamicData(i.activity.dynamic_field_data_endpoint,s,e)}};removeCurlyBraces=e=>e.replace(/^{(.*)}$/,"$1");isNotJSON=e=>{try{return!(Array.isArray(e)&&e.length>0&&"object"==typeof e[0])&&(JSON.parse(e),!!Number(e))}catch(e){return!0}};arrayToNestedJSONWithFirstValue=(e,t)=>{let n={},i=[];e&&Array.isArray(e)&&(i=e),Object.keys(t||{}).forEach((e=>{const i=this.removeCurlyBraces(e);n={...n,[i]:t[e]||""}}));let o={};(i||[]).forEach((e=>{o={...o,[e.text]:t[e.value]||""}}));const s={};return(i||[]).forEach((e=>{if(!e.text||!e.value)return;const t=e.text.split(".");let i=s;t.forEach(((o,s)=>{i[o]||(s===t.length-1?n[e.value]&&n[e.value][0]&&this.isNotJSON(n[e.value][0])?i[o]=n[e.value][0]||"":i[o]="":i[o]={}),i=i[o]}))})),s};getFieldValFromActivityOutputRaw=(e,t)=>{const n=t.match(/{([^}]+)}/g);let i=t;return(n||[]).forEach((t=>{const n=t.replace(/{|}/g,"");(e||[]).forEach((e=>{e.text===n&&(i=i.replace(t,`{${e.value}}`))}))})),i};getStepVisibleFieldsData=e=>{const t=this.props.stepDataMapping[e];return Object.keys(t).filter((e=>t[Number(e)].value)).reduce(((e,n)=>{const i=t[Number(n)];return{...e,[i.machineName]:i.value}}),{})};areParentValuesFilled=(e,t)=>{let n=!0;for(let i=0;i<t.length;i+=1){const o=t[i];let s=null;this.props.parentChildMapping[e][o]&&(s=this.props.parentChildMapping[e][o].fieldId);const a=s&&this.props.stepDataMapping[e]&&this.props.stepDataMapping[e][s];if(!a||!a.value){n=!1;break}}return n};doParentFieldsHaveValues=(e,t)=>{let n=!0;const i=this.props.parentChildMapping[e][t];if(i&&i.parentFields)for(let t=0;t<i.parentFields.length;t+=1){const o=this.props.parentChildMapping[e][i.parentFields[t]],s=o&&this.props.stepDataMapping[e]&&this.props.stepDataMapping[e][o.fieldId];if(!s||!s.value){n=!1;break}}return n};shouldShowStep=e=>{if(!this.props.showStepValidation)return!0;const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t];if("BUTTON"===e.type||"HTML"===e.type||"SECTION"===e.type)return!0;if(n&&e.activity_field){if(this.props.userConfig&&this.props.userConfig.viewAsIU)return!0;const n=!e.is_hidden,i=!0,{parentFields:o}=this.props.parentChildMapping[t][e.activity_field.machine_name],s=this.props.conditionalFieldMapping[t][e.activity_field.machine_name];let a=!0,l=!0;o&&(a=this.areParentValuesFilled(t,o)),s&&(l=ae(t,s,this.props.stepDataMapping));const r=a&&l;return n&&i&&r}return!1};stepIsOfType=e=>{const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t]||{step:this.props.step};return e.indexOf(n.step.activity?.type)>-1};textFieldParentHasValues=e=>{const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t]||{step:this.props.step},i=n.step.template_fields.filter((e=>e.is_visible)),o=!(!this.props?.userConfig||!this.props?.userConfig.viewAsIU)||n.selectedAuthId;if(!i.filter((e=>e.activity_field&&"DYNAMIC"===e.activity_field.type))[0])return!0;let s=!1;return i.forEach((t=>{const{activity_field:n}=t,{activity_field:i}=e;n?.child_fields?.includes(i.machine_name)&&(s=!0)})),!s||!!(i.length>0&&e&&e.activity_field&&o&&this.doParentFieldsHaveValues(t,e.activity_field.machine_name))};shouldShowOldMapping=()=>{const e=this.props.step.id,t=this.props.stepMapping&&this.props.stepMapping[e];if(this.stepIsOfType(["ADAPTER","ACTION"])){const n=t.step.template_fields.filter((e=>e.is_visible)),i=t.step.template_fields.filter((e=>e.is_visible&&"TEXTFIELD"===e.activity_field?.type)),o=t.selectedAuthId,s=n.filter((e=>e.activity_field&&"DYNAMIC"===e.activity_field.type))[0];if(i.length>0&&o&&!s&&!this.shouldShowNewMapping())return!0;if(!s)return!1;if(n.length>0&&o&&s&&s.activity_field&&this.doParentFieldsHaveValues(e,s.activity_field.machine_name)){const t=this.props.conditionalFieldMapping[e][s.activity_field.machine_name];return!t||ae(e,t,this.props.stepDataMapping)}return!1}return!1};shouldShowNewMapping=()=>{const{step:e,stepMapping:t}=this.props,n=t[e.id];if(this.stepIsOfType(["ADAPTER","ACTION"])){const e=n.step.template_fields.filter((e=>e.is_visible));if(e){if(e.filter((e=>e.activity_field&&"FIELD_MAPPING"===e.activity_field.type))[0])return!0}}return!1};getMappingDataInput=()=>{const e=this.props.step.id;return{authId:(this.props.stepMapping&&this.props.stepMapping[e]).selectedAuthId,fieldsData:this.getStepVisibleFieldsData(e)}};onFieldChange=e=>{let{stepId:t,fieldId:n,value:i,isRequired:o,machineName:s}=e;this.props.onFieldChangeCallback?this.props.onFieldChangeCallback(s||"",i):(this.props.setStepFieldData({stepId:`${t}`,fieldId:`${n}`,value:i,isRequired:o}),this.props.clearChildFields({stepId:t,fieldId:n}),this.props.verifyStepValidity(Number(t)))};fieldDynamicData=e=>{const t=this.props.step.id;if(this.props.stepMapping&&this.props.stepMapping[t]&&e.activity_field){const n=this.props.parentChildMapping[t][e.activity_field.machine_name]?.parentFields||null;if(n){return n.reduce(((e,n)=>{const{fieldId:i}=this.props.parentChildMapping[t][n];return i?{...e,[n]:this.props.stepDataMapping[t][i].value}:e}),{})}}return null};sourceFlowData=e=>{if(e.source_flow_integration_invocation_url){const{stepMapping:e,stepDataMapping:t}=this.props;return{steps:{...Object.keys(e).reduce(((n,i)=>{const{machine_name:o,id:s}=e[i].step;return o?{...n,[o]:{in:Object.keys(t[s]).reduce(((e,n)=>{const i=parseInt(n,10);if(t[s][i]){const{value:n,machineName:o}=t[s][i];return{...e,[o]:n}}return e}),{})}}:n}),{})}}}return null};isHTML=e=>!!/<\/?[a-z][\s\S]*>/i.test(e);getPlaceholder=e=>{let t="Incoming Webhook"===this.props.genericData.stepWithActivityOutput?.activity?.app?.name?this.props.genericData.selfAppName:this.props.genericData.stepWithActivityOutput?.activity?.app?.name||"";if(!t||t.includes("Webhook")){const e=this.props.step.source_steps,{stepMapping:n}=this.props,{props:i}=this;let o=null;Object.keys(e).forEach((e=>{const s=i.step.source_steps[e];o=s.app_id,s.app_name?t=s.app_name:Object.keys(n).every((e=>(n[e].step.authorization_type.app.id===s.app_id&&(t=n[e].step.activity.app.name),!0)))})),t?.includes("Incoming Webhook")&&null===o&&(t="Webhook")}return"TEXTAREA"===e.activity_field?.type||"TEXTFIELD"===e.activity_field?.type||"DYNAMIC"===e.activity_field?.type?!e.is_editable||e.is_mappable||e.allow_tags_in_text?!e.is_editable&&e.is_mappable?`Map to a ${t} field...`:e.is_editable&&(e.is_mappable||e.allow_tags_in_text)?`Enter text or map to a ${t} field...`:"Please enter a value":"Enter text...":"CHECKBOX"===e.activity_field?.type||"SELECT"===e.activity_field?.type||"RADIO"===e.activity_field?.type?!e.is_editable||e.is_mappable||e.allow_tags_in_text?!e.is_editable&&e.is_mappable?`Select a value or map to a ${t} field...`:e.is_editable&&e.allow_tags_in_text?`Enter text with ${t} fields or select a value...`:e.is_editable&&e.is_mappable?`Enter text, select a value or map to a ${t} field...`:"Select a value...":"Enter text or select a value...":"TEXTAREA"===e.activity_field?.type||"TEXTFIELD"===e.activity_field?.type?"Enter text...":"CHECKBOX"===e.activity_field?.type||"SELECT"===e.activity_field?.type||"RADIO"===e.activity_field?.type?"Select a value...":""};replacePlaceholders=(e,t)=>{const n={};return Object.entries(e).forEach((e=>{let[i,o]=e;if("string"==typeof o&&o.includes("{")){const e=o.match(/{(.*?)}/);if(e&&e[1]){const s=e[1],a=s.split(".").pop();void 0!==t[s]?n[i]=o.replace(e[0],t[s]):a&&void 0!==t[a]&&(n[i]=o.replace(e[0],t[a]))}}else"string"==typeof o&&o&&(n[i]=o)})),n};render(){const{step:e,stepMapping:t,stepDataMapping:n,setStepFieldData:i,showStepValidation:o,isReadOnly:s,accountConnected:a}=this.props,l=t[e.id]&&t[e.id].step||e,r=n&&n[e.id]||{},d={}||this.props.activityOutputData||{},p=0===l.template_fields?.length||!(this.props.userConfig&&this.props.userConfig.viewAsIU)&&0===l.template_fields?.filter((e=>e.is_visible)).length;return R`
|
|
3380
|
+
`};var Js={actionFormWrap:"styles-module_actionFormWrap__1--9G",noStepFields:"styles-module_noStepFields__1NQe1",actionFormWrapAutoWidth:"styles-module_actionFormWrapAutoWidth__2Vs2x",unsupported:"styles-module_unsupported__2swxl",actionFormLoader:"styles-module_actionFormLoader__2AXe4"};ue('.styles-module_actionFormWrap__1--9G {\n width: 100%;\n}\n.styles-module_actionFormWrap__1--9G .styles-module_noStepFields__1NQe1 {\n font-family: "Inter";\n font-weight: 400;\n font-size: 14px;\n line-height: 24px;\n color: #999999;\n}\n\n.styles-module_actionFormWrapAutoWidth__2Vs2x {\n margin-left: 24px;\n margin-right: 24px;\n width: auto;\n}\n\n.styles-module_unsupported__2swxl {\n font-size: 12px;\n color: #ca8c1b;\n}\n\n.styles-module_actionFormLoader__2AXe4 {\n width: 15px;\n margin: 0 auto;\n}');var Xs=B.connect(["stepState","stepMapping","stepDataMapping","parentChildMapping","fieldListMapping","conditionalFieldMapping","embedConfig","activityOutputData","genericData","userConfig","authMapping"],re)(class extends g{constructor(e){super(e);const t=e.step;this.state={loading:!1,dynamicFieldDataState:{},tagsTree:this.props.tagsTree&&Object.keys(this.props.tagsTree).length>0?Yo(this.props.tagsTree):{},parentChildMapping:this.setParentChildMapping([t]),dynamicFieldsData:{},parentFieldChanged:!1}}componentDidMount(){const{step:e,verifyStepValidity:t}=this.props;t(e.id);const n=this.props.genericData.stepWithActivityOutput;if(n){const{id:e}=n,t=this.getVisibleFieldsDataOnRootStep(e);this.setRootStepData(t)}else this.setRootStepData({})}componentDidUpdate(e){const{step:t,verifyStepValidity:n}=this.props;if(e.step.id!==t.id){n(t.id);const e=this.props.genericData.stepWithActivityOutput;if(e){const{id:t}=e,n=this.getVisibleFieldsDataOnRootStep(t);this.setRootStepData(n)}else this.setRootStepData({})}}setParentChildMapping(e){this.setState((t=>{const n=e.reduce(((e,n)=>{const i=n.template_fields.reduce(((e,t)=>{const n=t.activity_field;if(n){const i={...e};return i[n.machine_name]={fieldId:t.id,childFields:n.child_fields?JSON.parse(n.child_fields):null,parentFields:n.parent_fields?JSON.parse(n.parent_fields):null},i}return e}),{});return{...e,[n.id]:{...t.parentChildMapping?.[n.id]||{},...i}}}),{});return{parentChildMapping:{...t.parentChildMapping,...n}}}))}getVisibleFieldsDataOnRootStep=e=>{const t=this.props.stepDataMapping[e];return Object.keys(t).filter((e=>t[Number(e)].value)).reduce(((e,n)=>{const i=t[Number(n)];return{...e,[i.machineName]:i.value}}),{})};refreshRootStepData=async e=>{const t=this.props.genericData.stepWithActivityOutput;if(t){const{id:n}=t,i=this.getVisibleFieldsDataOnRootStep(n);this.setRootStepData(i,!0,e)}else this.setRootStepData({},!0,e)};setActivityOutputFromSourceStep=(e,t,n)=>{const{setDynamicData:i}=this,o=this.setState.bind(this),s=this.props.step.source_steps,{stepMapping:a}=this.props,{props:l}=this;Object.keys(s).forEach((s=>{const r=l.step.source_steps[s];let d=!1;return Object.keys(a).every((p=>{const c=a[p].step.id;if(c&&(a[c].step.machine_name===s||a[c].step.machine_name===r.form_step_machine_name)&&!l.genericData.isTestIntegration){if(d=!0,r.activity_output_url){e||o({loading:!0});const n={},a=Object.keys(l.stepDataMapping[c]);for(let e=0;e<a.length;e+=1){const t=a[e],i=l.stepDataMapping[c][t];i.value&&(n[i.machineName]=i.value)}const d=r.activity_output_url.includes("functions/"),p=d?"POST":"GET";l.apiHandler.callDynamicDataEndpoint(new URL(r.activity_output_url),{authorization_id:`${l.stepMapping[c].selectedAuthId}`,...n},p).then((e=>{o({loading:!1});let n=!1;if(e){const t=e;d&&"output"in t?this.setActivityOutputFromIntegryObjectOrRawActivityOutput(t.output,r,s,!0):l.setActivityOutputData({activityOutputData:r.loop_variable_name?this.replaceContactPrefix(e,s,r):e})}else n=!0;t&&t(n)})),r.sample_data_endpoint_url&&c&&i(r.sample_data_endpoint_url,c,{...n})}else r.activity_output&&(o({loading:!1}),t&&t(),this.setActivityOutputFromIntegryObjectOrRawActivityOutput(n,r,s));return!1}return!((l.genericData.isTestIntegration||!r.app_id&&!this.canOverrideIntegryObject(n))&&r.activity_output)||(o({loading:!1}),t&&t(),d=!0,this.setActivityOutputFromRawActivityOutput(r,s),!1)})),!d&&r.activity_output?(this.setActivityOutputFromIntegryObjectOrRawActivityOutput(n,r,s),o({loading:!1}),t&&t(),d=!0,!1):!d}))};replaceContactPrefix=(e,t,n)=>{const i=`steps.${t}.out.${n.loop_variable_name?`${n.loop_variable_name}`:""}`;return e.map((e=>({...e,value:e.value.replace("contact_v1",i)})))};setActivityOutputFromRawActivityOutput=(()=>{var e=this;return function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";try{let i={};i=t.activity_output;const o=Yo(i,"",`steps.${n}.out.${t.loop_variable_name?`${t.loop_variable_name}.`:""}`),s=Qo(i,"",`steps.${n}.out.${t.loop_variable_name?`${t.loop_variable_name}.`:""}`);e.props.setIncomingWebhookPayload({incomingWebhookPayload:i}),e.props.setActivityOutputData({activityOutputData:o||[]}),e.props.setDynamicFieldData({dynamicFieldData:s||{}}),e.setState({dynamicFieldDataState:s||{}})}catch(e){console.error(e)}}})();setDynamicData=(e,t,n)=>{this.props.apiHandler.callDynamicDataEndpoint(new URL(e),{authorization_id:`${this.props.stepMapping[t].selectedAuthId}`,...n}).then((e=>{e&&(this.props.setDynamicFieldData({dynamicFieldData:e}),this.setState({dynamicFieldDataState:e}))}))};canOverrideIntegryObject=e=>{if(e)try{const t=JSON.parse(e);if(this.props.userConfig?.objects?.[t.name])return!0}catch(e){return!1}return!1};setActivityOutputFromIntegryObjectOrRawActivityOutput=(()=>{var e=this;return function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t)try{let s={};if(o)s=t;else{const n=JSON.parse(t);s=e.props.userConfig?.objects?.[n.name]?e.props.userConfig?.objects?.[n.name]:JSON.parse(n.payload)}const a=Yo(s,"",`steps.${i}.out.${n.loop_variable_name?`${n.loop_variable_name}.`:""}`),l=Qo(s,"",`steps.${i}.out.${n.loop_variable_name?`${n.loop_variable_name}.`:""}`);e.props.setIncomingWebhookPayload({incomingWebhookPayload:s}),e.props.setActivityOutputData({activityOutputData:a||[]}),e.props.setDynamicFieldData({dynamicFieldData:l||{}}),e.setState({dynamicFieldDataState:l||{}})}catch(e){console.error(e)}else e.setActivityOutputFromRawActivityOutput(n,i)}})();setRootStepData=async(e,t,n)=>{const i=this.props.genericData.stepWithActivityOutput;let o=i?.template_fields.find((e=>"integry_webhook_object"===e.activity_field?.machine_name))?.default_value;if(o){let e={};try{e=JSON.parse(o||"{}")}catch(t){e={}}e={payload:o||"{}",name:i?.template_fields.find((e=>"payload_name"===e.activity_field?.machine_name))?.default_value||"payload"},o=JSON.stringify(e)}if(this.props.setActivityOutputData({activityOutputData:[]}),this.props.step.source_steps&&Object.keys(this.props.step.source_steps).length>0)this.setActivityOutputFromSourceStep(t,n,o);else if(i){const{id:s}=i;i.activity.activity_output_url?(t||this.setState({loading:!0}),this.props.apiHandler.callDynamicDataEndpoint(new URL(i.activity.activity_output_url),{authorization_id:`${this.props.stepMapping[s].selectedAuthId}`,...e}).then((e=>{this.setState({loading:!1}),n&&n(),e&&this.props.setActivityOutputData({activityOutputData:e})}))):i.activity.activity_output?(this.setActivityOutputFromIntegryObjectOrRawActivityOutput(o,i.activity),this.setState({loading:!1}),n&&n()):(this.setState({loading:!1}),n&&n()),i.activity.dynamic_field_data_endpoint&&this.setDynamicData(i.activity.dynamic_field_data_endpoint,s,e)}};removeCurlyBraces=e=>e.replace(/^{(.*)}$/,"$1");isNotJSON=e=>{try{return!(Array.isArray(e)&&e.length>0&&"object"==typeof e[0])&&(JSON.parse(e),!!Number(e))}catch(e){return!0}};arrayToNestedJSONWithFirstValue=(e,t)=>{let n={},i=[];e&&Array.isArray(e)&&(i=e),Object.keys(t||{}).forEach((e=>{const i=this.removeCurlyBraces(e);n={...n,[i]:t[e]||""}}));let o={};(i||[]).forEach((e=>{o={...o,[e.text]:t[e.value]||""}}));const s={};return(i||[]).forEach((e=>{if(!e.text||!e.value)return;const t=e.text.split(".");let i=s;t.forEach(((o,s)=>{i[o]||(s===t.length-1?n[e.value]&&n[e.value][0]&&this.isNotJSON(n[e.value][0])?i[o]=n[e.value][0]||"":i[o]="":i[o]={}),i=i[o]}))})),s};getFieldValFromActivityOutputRaw=(e,t)=>{const n=t.match(/{([^}]+)}/g);let i=t;return(n||[]).forEach((t=>{const n=t.replace(/{|}/g,"");(e||[]).forEach((e=>{e.text===n&&(i=i.replace(t,`{${e.value}}`))}))})),i};getStepVisibleFieldsData=e=>{const t=this.props.stepDataMapping[e];return Object.keys(t).filter((e=>t[Number(e)].value)).reduce(((e,n)=>{const i=t[Number(n)];return{...e,[i.machineName]:i.value}}),{})};areParentValuesFilled=(e,t)=>{let n=!0;for(let i=0;i<t.length;i+=1){const o=t[i];let s=null;this.props.parentChildMapping[e][o]&&(s=this.props.parentChildMapping[e][o].fieldId);const a=s&&this.props.stepDataMapping[e]&&this.props.stepDataMapping[e][s];if(!a||!a.value){n=!1;break}}return n};doParentFieldsHaveValues=(e,t)=>{let n=!0;const i=this.props.parentChildMapping[e][t];if(i&&i.parentFields)for(let t=0;t<i.parentFields.length;t+=1){const o=this.props.parentChildMapping[e][i.parentFields[t]],s=o&&this.props.stepDataMapping[e]&&this.props.stepDataMapping[e][o.fieldId];if(!s||!s.value){n=!1;break}}return n};shouldShowStep=e=>{if(!this.props.showStepValidation)return!0;const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t];if("BUTTON"===e.type||"HTML"===e.type||"SECTION"===e.type)return!0;if(n&&e.activity_field){if(this.props.userConfig&&this.props.userConfig.viewAsIU)return!0;const n=!e.is_hidden,i=!0,{parentFields:o}=this.props.parentChildMapping[t][e.activity_field.machine_name],s=this.props.conditionalFieldMapping[t][e.activity_field.machine_name];let a=!0,l=!0;o&&(a=this.areParentValuesFilled(t,o)),s&&(l=ae(t,s,this.props.stepDataMapping));const r=a&&l;return n&&i&&r}return!1};stepIsOfType=e=>{const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t]||{step:this.props.step};return e.indexOf(n.step.activity?.type)>-1};textFieldParentHasValues=e=>{const t=this.props.step.id,n=this.props.stepMapping&&this.props.stepMapping[t]||{step:this.props.step},i=n.step.template_fields.filter((e=>e.is_visible)),o=!(!this.props?.userConfig||!this.props?.userConfig.viewAsIU)||n.selectedAuthId;if(!i.filter((e=>e.activity_field&&"DYNAMIC"===e.activity_field.type))[0])return!0;let s=!1;return i.forEach((t=>{const{activity_field:n}=t,{activity_field:i}=e;n?.child_fields?.includes(i.machine_name)&&(s=!0)})),!s||!!(i.length>0&&e&&e.activity_field&&o&&this.doParentFieldsHaveValues(t,e.activity_field.machine_name))};shouldShowOldMapping=()=>{const e=this.props.step.id,t=this.props.stepMapping&&this.props.stepMapping[e]||{step:this.props.step};if(this.stepIsOfType(["ADAPTER","ACTION"])){const n=t.step.template_fields.filter((e=>e.is_visible)),i=t.step.template_fields.filter((e=>e.is_visible&&"TEXTFIELD"===e.activity_field?.type)),o=t.selectedAuthId,s=n.filter((e=>e.activity_field&&"DYNAMIC"===e.activity_field.type))[0];if(i.length>0&&o&&!s&&!this.shouldShowNewMapping())return!0;if(!s)return!1;if(n.length>0&&o&&s&&s.activity_field&&this.doParentFieldsHaveValues(e,s.activity_field.machine_name)){const t=this.props.conditionalFieldMapping[e][s.activity_field.machine_name];return!t||ae(e,t,this.props.stepDataMapping)}return!1}return!1};shouldShowNewMapping=()=>{const{step:e,stepMapping:t}=this.props,n=t[e.id];if(this.stepIsOfType(["ADAPTER","ACTION"])){const e=n.step.template_fields.filter((e=>e.is_visible));if(e){if(e.filter((e=>e.activity_field&&"FIELD_MAPPING"===e.activity_field.type))[0])return!0}}return!1};getMappingDataInput=()=>{const e=this.props.step.id;return{authId:(this.props.stepMapping&&this.props.stepMapping[e]).selectedAuthId,fieldsData:this.getStepVisibleFieldsData(e)}};isParentField=(e,t)=>Object.values(e).some((e=>Object.values(e).some((e=>Array.isArray(e.parentFields)&&e.parentFields.includes(t)))));onFieldChange=e=>{let{stepId:t,fieldId:n,value:i,isRequired:o,machineName:s}=e;this.props.onFieldChangeCallback?(this.setState((e=>({dynamicFieldsData:{...e.dynamicFieldsData,[s||""]:i}}))),this.isParentField(this.state.parentChildMapping,s||"")&&this.setState({parentFieldChanged:!this.state.parentFieldChanged}),this.props.onFieldChangeCallback(s||"",i)):(this.props.setStepFieldData({stepId:`${t}`,fieldId:`${n}`,value:i,isRequired:o}),this.props.clearChildFields({stepId:t,fieldId:n}),this.props.verifyStepValidity(Number(t)))};fieldDynamicData=e=>{const t=this.props.step.id;if(this.props.stepMapping&&this.props.stepMapping[t]&&e.activity_field){const n=this.props.parentChildMapping[t][e.activity_field.machine_name]?.parentFields||null;if(n){return n.reduce(((e,n)=>{const{fieldId:i}=this.props.parentChildMapping[t][n];return i?{...e,[n]:this.props.stepDataMapping[t][i].value}:e}),{})}}return null};sourceFlowData=e=>{if(e.source_flow_integration_invocation_url){const{stepMapping:e,stepDataMapping:t}=this.props;return{steps:{...Object.keys(e).reduce(((n,i)=>{const{machine_name:o,id:s}=e[i].step;return o?{...n,[o]:{in:Object.keys(t[s]).reduce(((e,n)=>{const i=parseInt(n,10);if(t[s][i]){const{value:n,machineName:o}=t[s][i];return{...e,[o]:n}}return e}),{})}}:n}),{})}}}return null};isHTML=e=>!!/<\/?[a-z][\s\S]*>/i.test(e);getPlaceholder=e=>{let t="Incoming Webhook"===this.props.genericData.stepWithActivityOutput?.activity?.app?.name?this.props.genericData.selfAppName:this.props.genericData.stepWithActivityOutput?.activity?.app?.name||"";if(!t||t.includes("Webhook")){const e=this.props.step.source_steps,{stepMapping:n}=this.props,{props:i}=this;let o=null;Object.keys(e).forEach((e=>{const s=i.step.source_steps[e];o=s.app_id,s.app_name?t=s.app_name:Object.keys(n).every((e=>(n[e].step.authorization_type.app.id===s.app_id&&(t=n[e].step.activity.app.name),!0)))})),t?.includes("Incoming Webhook")&&null===o&&(t="Webhook")}return"TEXTAREA"===e.activity_field?.type||"TEXTFIELD"===e.activity_field?.type||"DYNAMIC"===e.activity_field?.type?!e.is_editable||e.is_mappable||e.allow_tags_in_text?!e.is_editable&&e.is_mappable?`Map to a ${t} field...`:e.is_editable&&(e.is_mappable||e.allow_tags_in_text)?`Enter text or map to a ${t} field...`:"Please enter a value":"Enter text...":"CHECKBOX"===e.activity_field?.type||"SELECT"===e.activity_field?.type||"RADIO"===e.activity_field?.type?!e.is_editable||e.is_mappable||e.allow_tags_in_text?!e.is_editable&&e.is_mappable?`Select a value or map to a ${t} field...`:e.is_editable&&e.allow_tags_in_text?`Enter text with ${t} fields or select a value...`:e.is_editable&&e.is_mappable?`Enter text, select a value or map to a ${t} field...`:"Select a value...":"Enter text or select a value...":"TEXTAREA"===e.activity_field?.type||"TEXTFIELD"===e.activity_field?.type?"Enter text...":"CHECKBOX"===e.activity_field?.type||"SELECT"===e.activity_field?.type||"RADIO"===e.activity_field?.type?"Select a value...":""};replacePlaceholders=(e,t)=>{const n={};return Object.entries(e).forEach((e=>{let[i,o]=e;if("string"==typeof o&&o.includes("{")){const e=o.match(/{(.*?)}/);if(e&&e[1]){const s=e[1],a=s.split(".").pop();void 0!==t[s]?n[i]=o.replace(e[0],t[s]):a&&void 0!==t[a]&&(n[i]=o.replace(e[0],t[a]))}}else"string"==typeof o&&o&&(n[i]=o)})),n};render(){const{step:e,stepMapping:t,stepDataMapping:n,setStepFieldData:i,showStepValidation:o,isReadOnly:s,accountConnected:a}=this.props,l=t[e.id]&&t[e.id].step||e,r=n&&n[e.id]||{},d={}||this.props.activityOutputData||{},p=0===l.template_fields?.length||!(this.props.userConfig&&this.props.userConfig.viewAsIU)&&0===l.template_fields?.filter((e=>e.is_visible)).length;return R`
|
|
3381
3381
|
${this.state.loading?R`<div class=${Js.actionFormLoader}><${Ye} /></div>`:R`
|
|
3382
3382
|
${l?R`
|
|
3383
3383
|
<div
|
|
@@ -3528,18 +3528,19 @@
|
|
|
3528
3528
|
<${bs}
|
|
3529
3529
|
stepId=${l.id}
|
|
3530
3530
|
dynamicField=${t}
|
|
3531
|
-
endpointData=${JSON.stringify({authorization_id:this.props.stepMapping&&this.props.stepMapping[this.props.step.id]?.selectedAuthId,...this.fieldDynamicData(t)})}
|
|
3531
|
+
endpointData=${JSON.stringify({authorization_id:this.props.stepMapping&&this.props.stepMapping[this.props.step.id]?.selectedAuthId||this.props.selectedAuthId,...this.fieldDynamicData(t),...this.state.dynamicFieldsData})}
|
|
3532
3532
|
activityOutputData=${this.arrayToNestedJSONWithFirstValue(this.props.activityOutputData,this.props.dynamicFieldData||this.state.dynamicFieldDataState||{})}
|
|
3533
3533
|
activityOutputDataRaw=${this.props.activityOutputData}
|
|
3534
3534
|
placeHolder=${this.getPlaceholder(t)}
|
|
3535
3535
|
appName=${this.props.step.activity.app.name}
|
|
3536
|
-
selectedAuthId=${`${this.props.stepMapping[this.props.step.id]?.selectedAuthId||""}`}
|
|
3536
|
+
selectedAuthId=${`${this.props.stepMapping[this.props.step.id]?.selectedAuthId||this.props.selectedAuthId||""}`}
|
|
3537
3537
|
sourceFlowData=${this.sourceFlowData(t)}
|
|
3538
3538
|
sourceFlowIntegrataionInvocationUrl=${t.source_flow_integration_invocation_url}
|
|
3539
3539
|
isMappable=${t.is_mappable}
|
|
3540
3540
|
isEditable=${t.is_editable}
|
|
3541
3541
|
allowTagsInText=${t.allow_tags_in_text}
|
|
3542
3542
|
refreshRootStepData=${this.refreshRootStepData}
|
|
3543
|
+
parentFieldChanged=${this.state.parentFieldChanged}
|
|
3543
3544
|
/>
|
|
3544
3545
|
</div>
|
|
3545
3546
|
`;case"SECTION":return R`
|
|
@@ -7000,7 +7001,7 @@
|
|
|
7000
7001
|
</div>
|
|
7001
7002
|
</div>
|
|
7002
7003
|
`}
|
|
7003
|
-
`}});class Rd{static SDK_VERSION="4.5.
|
|
7004
|
+
`}});class Rd{static SDK_VERSION="4.5.9";config;apiHandler;initConfig;eventEmitter=(()=>new G)();static html=(()=>R)();static RenderModes=(()=>ee)();static TemplateFormRenderModes=(()=>Y)();static Layouts=(()=>X)();static ViewStyles=(()=>J)();static MarketplaceRenderModes=(()=>Q)();static Helpers;authModalId="";forceRerender=!1;constructor(e){let t;const n=e.baseUrl||"https://app.integry.io",i=e;if(i.user){const{userId:e,apiKey:t,...n}=i.user;"userId"in i||(i.userId=""),"userId"in i&&(i.userId=e.toString()),i.xIntegryConfig||(i.xIntegryConfig={}),i.xIntegryConfig.appAuth||(i.xIntegryConfig.appAuth={}),i.xIntegryConfig.appAuth.extras||(i.xIntegryConfig.appAuth.extras={}),i.xIntegryConfig.appAuth.apiKey=(t||"").toString(),i.xIntegryConfig.appAuth.extras=n}const o={oauthVerifyPath:"auth/verify",endpointsUrl:"https://integry-app.appspot.com",baseUrl:n,baseUrlv2:`${n}/v2`,baseAPIUrl:"https://api.integry.io",apiKey:i.xIntegryConfig?.appAuth?.apiKey,authId:i.xIntegryConfig?.appAuth?.authId,extras:i.xIntegryConfig?.appAuth?.extras},s=i.options||i.userConfig||{};if(i.options&&i.payloads&&(i.options.objects=e.payloads),"appKey"in i)t={...i,...o,appKey:i.appKey,hash:i.hash,userId:i.userId},this.config={...i,...o,appKey:i.appKey,hash:i.hash,userId:i.userId,deploymentId:i.deploymentId,userConfig:i.deploymentId?{...s,tags:s?.tags?[...s?.tags,`${i.deploymentId}`]:[`${i.deploymentId}`]}:s};else{const e=this.getAuthParamsFromUrl()||{};t={...o,...e},this.config={...o,...e,userConfig:i.userConfig}}this.authModalId=this.getRandomFlowId(6),this.apiHandler=new j(t),this.verifyAuthConfig().then((e=>{e?.config_verified?this.eventEmitter.emit("ready",{isReady:!0}):console.error("IntegrySDK: Auth config verification failed, are your auth parameters correct?")})).catch((e=>console.error(e))),this.initConfig={containerId:"",renderMode:Y.INLINE}}SDKFailedHandler=(e,t)=>{const n=e.options||e.userConfig||{},i=document.getElementById(t);throw i&&T(R`
|
|
7004
7005
|
<${nl}
|
|
7005
7006
|
message="SDK failed to load"
|
|
7006
7007
|
debug=${n.debug}
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import { ListBox } from '@/components/MultipurposeField/Dropdown';
|
|
|
9
9
|
import { Loader } from '@/components/Loader';
|
|
10
10
|
import {
|
|
11
11
|
IntegryStep,
|
|
12
|
+
TemplateStep,
|
|
12
13
|
TemplateField,
|
|
13
14
|
IncomingWebhookObject,
|
|
14
15
|
NestedObject,
|
|
@@ -54,15 +55,29 @@ interface ActionFormStateType {
|
|
|
54
55
|
loading: boolean;
|
|
55
56
|
dynamicFieldDataState: any;
|
|
56
57
|
tagsTree: any;
|
|
58
|
+
parentChildMapping: any;
|
|
59
|
+
dynamicFieldsData: any;
|
|
60
|
+
parentFieldChanged: boolean;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
interface StepDataMapping {
|
|
60
64
|
[key: string]: any;
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
type FieldMapping = {
|
|
68
|
+
[key: string]: {
|
|
69
|
+
fieldId: number;
|
|
70
|
+
childFields: any[] | null;
|
|
71
|
+
parentFields: any[] | null;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
type Mapping = Record<number, any>;
|
|
76
|
+
|
|
63
77
|
class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
64
78
|
constructor(props: ActionFormPropsType) {
|
|
65
79
|
super(props);
|
|
80
|
+
const templateStep: any = props.step;
|
|
66
81
|
this.state = {
|
|
67
82
|
loading: false,
|
|
68
83
|
dynamicFieldDataState: {},
|
|
@@ -70,6 +85,9 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
70
85
|
this.props.tagsTree && Object.keys(this.props.tagsTree).length > 0
|
|
71
86
|
? JSONToActivityOutputData(this.props.tagsTree)
|
|
72
87
|
: {},
|
|
88
|
+
parentChildMapping: this.setParentChildMapping([templateStep]),
|
|
89
|
+
dynamicFieldsData: {},
|
|
90
|
+
parentFieldChanged: false,
|
|
73
91
|
};
|
|
74
92
|
}
|
|
75
93
|
|
|
@@ -105,6 +123,54 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
105
123
|
}
|
|
106
124
|
}
|
|
107
125
|
|
|
126
|
+
setParentChildMapping(steps: TemplateStep[]) {
|
|
127
|
+
this.setState((prevState) => {
|
|
128
|
+
const parentChildMapping = steps.reduce((mapping: Mapping, step) => {
|
|
129
|
+
const stepMapping = step.template_fields.reduce(
|
|
130
|
+
(fields: FieldMapping, field) => {
|
|
131
|
+
const activityField = field.activity_field;
|
|
132
|
+
|
|
133
|
+
if (activityField) {
|
|
134
|
+
// Create a copy of the fields object to avoid mutating it
|
|
135
|
+
const updatedFields = { ...fields };
|
|
136
|
+
|
|
137
|
+
updatedFields[activityField.machine_name] = {
|
|
138
|
+
fieldId: field.id,
|
|
139
|
+
childFields: activityField.child_fields
|
|
140
|
+
? JSON.parse(activityField.child_fields)
|
|
141
|
+
: null,
|
|
142
|
+
parentFields: activityField.parent_fields
|
|
143
|
+
? JSON.parse(activityField.parent_fields)
|
|
144
|
+
: null,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
return updatedFields;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return fields;
|
|
151
|
+
},
|
|
152
|
+
{}, // Initial empty object
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// Create a new object for `mapping` to avoid mutation
|
|
156
|
+
return {
|
|
157
|
+
...mapping, // Spread the existing mapping to preserve the previous entries
|
|
158
|
+
[step.id]: {
|
|
159
|
+
...(prevState.parentChildMapping?.[step.id] || {}), // Ensure it starts with the previous state or empty object
|
|
160
|
+
...stepMapping, // Merge the new step mapping
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}, {});
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
parentChildMapping: {
|
|
167
|
+
...prevState.parentChildMapping, // Spread the previous state to preserve other data
|
|
168
|
+
...parentChildMapping, // Add the newly calculated `parentChildMapping`
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
108
174
|
getVisibleFieldsDataOnRootStep = (
|
|
109
175
|
stepId: number,
|
|
110
176
|
): {
|
|
@@ -829,7 +895,8 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
829
895
|
|
|
830
896
|
private shouldShowOldMapping = () => {
|
|
831
897
|
const stepId = this.props.step.id;
|
|
832
|
-
const stepObject = this.props.stepMapping &&
|
|
898
|
+
const stepObject = (this.props.stepMapping &&
|
|
899
|
+
this.props.stepMapping[stepId]) || { step: this.props.step };
|
|
833
900
|
if (this.stepIsOfType(['ADAPTER', 'ACTION'])) {
|
|
834
901
|
const anyVisibleFields = stepObject.step.template_fields.filter(
|
|
835
902
|
(el) => el.is_visible,
|
|
@@ -918,6 +985,18 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
918
985
|
return payload;
|
|
919
986
|
};
|
|
920
987
|
|
|
988
|
+
private isParentField = (
|
|
989
|
+
mapping: Record<string, Record<string, any>>,
|
|
990
|
+
machineName: string,
|
|
991
|
+
): boolean =>
|
|
992
|
+
Object.values(mapping).some((fields) =>
|
|
993
|
+
Object.values(fields).some(
|
|
994
|
+
(field) =>
|
|
995
|
+
Array.isArray(field.parentFields) &&
|
|
996
|
+
field.parentFields.includes(machineName),
|
|
997
|
+
),
|
|
998
|
+
);
|
|
999
|
+
|
|
921
1000
|
private onFieldChange = ({
|
|
922
1001
|
stepId,
|
|
923
1002
|
fieldId,
|
|
@@ -933,6 +1012,19 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
933
1012
|
}) => {
|
|
934
1013
|
// we want to check if callback function is passed in props, if yes then call it
|
|
935
1014
|
if (this.props.onFieldChangeCallback) {
|
|
1015
|
+
this.setState((prevState) => ({
|
|
1016
|
+
dynamicFieldsData: {
|
|
1017
|
+
...prevState.dynamicFieldsData,
|
|
1018
|
+
[machineName || '']: value,
|
|
1019
|
+
},
|
|
1020
|
+
}));
|
|
1021
|
+
|
|
1022
|
+
if (
|
|
1023
|
+
this.isParentField(this.state.parentChildMapping, machineName || '')
|
|
1024
|
+
) {
|
|
1025
|
+
this.setState({ parentFieldChanged: !this.state.parentFieldChanged });
|
|
1026
|
+
}
|
|
1027
|
+
|
|
936
1028
|
this.props.onFieldChangeCallback(machineName || '', value);
|
|
937
1029
|
} else {
|
|
938
1030
|
this.props.setStepFieldData({
|
|
@@ -1540,11 +1632,13 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1540
1632
|
dynamicField=${el}
|
|
1541
1633
|
endpointData=${JSON.stringify({
|
|
1542
1634
|
authorization_id:
|
|
1543
|
-
this.props.stepMapping &&
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1635
|
+
(this.props.stepMapping &&
|
|
1636
|
+
this.props.stepMapping[
|
|
1637
|
+
this.props.step.id
|
|
1638
|
+
]?.selectedAuthId) ||
|
|
1639
|
+
this.props.selectedAuthId,
|
|
1547
1640
|
...this.fieldDynamicData(el),
|
|
1641
|
+
...this.state.dynamicFieldsData,
|
|
1548
1642
|
})}
|
|
1549
1643
|
activityOutputData=${this.arrayToNestedJSONWithFirstValue(
|
|
1550
1644
|
this.props.activityOutputData,
|
|
@@ -1560,7 +1654,9 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1560
1654
|
selectedAuthId=${`${
|
|
1561
1655
|
this.props.stepMapping[
|
|
1562
1656
|
this.props.step.id
|
|
1563
|
-
]?.selectedAuthId ||
|
|
1657
|
+
]?.selectedAuthId ||
|
|
1658
|
+
this.props.selectedAuthId ||
|
|
1659
|
+
''
|
|
1564
1660
|
}`}
|
|
1565
1661
|
sourceFlowData=${this.sourceFlowData(el)}
|
|
1566
1662
|
sourceFlowIntegrataionInvocationUrl=${el.source_flow_integration_invocation_url}
|
|
@@ -1569,6 +1665,8 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1569
1665
|
allowTagsInText=${el.allow_tags_in_text}
|
|
1570
1666
|
refreshRootStepData=${this
|
|
1571
1667
|
.refreshRootStepData}
|
|
1668
|
+
parentFieldChanged=${this.state
|
|
1669
|
+
.parentFieldChanged}
|
|
1572
1670
|
/>
|
|
1573
1671
|
</div>
|
|
1574
1672
|
`;
|
|
@@ -26,6 +26,7 @@ export type DynamicFieldsProps = {
|
|
|
26
26
|
allowTagsInText?: boolean;
|
|
27
27
|
placeHolder?: string;
|
|
28
28
|
refreshRootStepData?: (callback?: any) => void;
|
|
29
|
+
parentFieldChanged?: boolean;
|
|
29
30
|
} & StoreType;
|
|
30
31
|
|
|
31
32
|
interface DynamicDataItem {
|
|
@@ -50,6 +51,7 @@ const DynamicFields = (props: DynamicFieldsProps) => {
|
|
|
50
51
|
allowTagsInText = true,
|
|
51
52
|
placeHolder = '',
|
|
52
53
|
refreshRootStepData,
|
|
54
|
+
parentFieldChanged = false,
|
|
53
55
|
} = props;
|
|
54
56
|
const [dynamicItems, setDynamicItems] = useState<DynamicDataItem[]>([]);
|
|
55
57
|
const [loading, setLoading] = useState<boolean>(true);
|
|
@@ -121,7 +123,7 @@ const DynamicFields = (props: DynamicFieldsProps) => {
|
|
|
121
123
|
|
|
122
124
|
useEffect(() => {
|
|
123
125
|
fetchDynamicFields();
|
|
124
|
-
}, [dynamicField, endpointData, selectedAuthId]);
|
|
126
|
+
}, [dynamicField, endpointData, selectedAuthId, parentFieldChanged]);
|
|
125
127
|
|
|
126
128
|
const getPlaceholder = () => {
|
|
127
129
|
let placeHolderValue = 'Enter text or map to fields...';
|
|
@@ -163,7 +165,9 @@ const DynamicFields = (props: DynamicFieldsProps) => {
|
|
|
163
165
|
Loading custom fields...
|
|
164
166
|
</div> `
|
|
165
167
|
: html` ${dynamicItems.map((el) => {
|
|
166
|
-
const ele = props.stepDataMapping[stepId]
|
|
168
|
+
const ele = props.stepDataMapping[stepId]
|
|
169
|
+
? props.stepDataMapping[stepId][dynamicField.id]
|
|
170
|
+
: ({} as { objectValue: Record<string, string | number> });
|
|
167
171
|
let fieldVal = '';
|
|
168
172
|
const parsedVal = ele.objectValue as Record<
|
|
169
173
|
string,
|