@integry/sdk 4.5.5 → 4.5.6
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.d.ts +1 -1
- package/dist/esm/index.csm.js +13 -12
- package/dist/umd/index.umd.d.ts +1 -1
- package/dist/umd/index.umd.js +13 -12
- package/package.json +1 -1
- package/src/features/common/ActionForm/index.ts +10 -2
- package/src/index.ts +2 -0
package/dist/esm/index.csm.d.ts
CHANGED
|
@@ -710,7 +710,7 @@ declare class IntegryJS {
|
|
|
710
710
|
containerId: string;
|
|
711
711
|
multipurposeFieldProps: MultipurposeFieldType;
|
|
712
712
|
}) => void;
|
|
713
|
-
renderFlowStep: (containerId: string, step: any, connectedAccountId: string) => void;
|
|
713
|
+
renderFlowStep: (containerId: string, step: any, connectedAccountId: string, tagsTree?: {}) => void;
|
|
714
714
|
verifyAuthConfig: () => Promise<{
|
|
715
715
|
config_verified: boolean;
|
|
716
716
|
meta: any;
|
package/dist/esm/index.csm.js
CHANGED
|
@@ -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:{}}}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}=e;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),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}=e;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
|
|
@@ -3455,8 +3455,8 @@ var e,t,n,i,o,s,a,l={},r=[],d=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]
|
|
|
3455
3455
|
<${Jo}
|
|
3456
3456
|
id=${t.activity_field?.id}
|
|
3457
3457
|
title=${t.title||t.activity_field?.title}
|
|
3458
|
-
activityOutputData=${this.arrayToNestedJSONWithFirstValue(this.props.activityOutputData,this.props.dynamicFieldData||this.state.dynamicFieldDataState||{})}
|
|
3459
|
-
activityOutputDataRaw=${this.props.activityOutputData}
|
|
3458
|
+
activityOutputData=${this.arrayToNestedJSONWithFirstValue(this.props.activityOutputData||this.state.tagsTree,this.props.dynamicFieldData||this.state.dynamicFieldDataState||{})}
|
|
3459
|
+
activityOutputDataRaw=${this.props.activityOutputData||this.state.tagsTree}
|
|
3460
3460
|
description=${p}
|
|
3461
3461
|
value=${r&&r[t.id]&&r[t.id].value&&"x-integry-skipped-field"!==r[t.id].value&&r[t.id].value||t.default_value||""}
|
|
3462
3462
|
placeholder=${this.getPlaceholder(t)}
|
|
@@ -7000,7 +7000,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
7000
|
</div>
|
|
7001
7001
|
</div>
|
|
7002
7002
|
`}
|
|
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.
|
|
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.6";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
7004
|
<${nl}
|
|
7005
7005
|
message="SDK failed to load"
|
|
7006
7006
|
debug=${n.debug}
|
|
@@ -7277,21 +7277,22 @@ var e,t,n,i,o,s,a,l={},r=[],d=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]
|
|
|
7277
7277
|
fieldId=${n.fieldId}
|
|
7278
7278
|
enableTagify=${n.enableTagify}
|
|
7279
7279
|
/>`}
|
|
7280
|
-
</div>`,i):console.warn(`Integry SDK render target with id ${t} was not found`)};renderFlowStep=(e
|
|
7280
|
+
</div>`,i):console.warn(`Integry SDK render target with id ${t} was not found`)};renderFlowStep=(()=>{var e=this;return function(t,n,i){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const s=document.getElementById(t);if(s){const t=de();T(R`<div>
|
|
7281
7281
|
<${ne.Provider}
|
|
7282
|
-
value=${{apiHandler:
|
|
7282
|
+
value=${{apiHandler:e.apiHandler,eventEmitter:e.eventEmitter,isPreviewMode:!1}}
|
|
7283
7283
|
>
|
|
7284
|
-
<${B.Provider} store=${
|
|
7284
|
+
<${B.Provider} store=${t} key=${e.getRandomFlowId(10)}>
|
|
7285
7285
|
<${Xs}
|
|
7286
|
-
step=${
|
|
7286
|
+
step=${n}
|
|
7287
7287
|
stepType=${"CONFIGURE"}
|
|
7288
7288
|
showStepValidation=${!1}
|
|
7289
|
-
apiHandler=${
|
|
7290
|
-
eventEmitter=${
|
|
7289
|
+
apiHandler=${e.apiHandler}
|
|
7290
|
+
eventEmitter=${e.eventEmitter}
|
|
7291
7291
|
isReadOnly="${!1}"
|
|
7292
|
-
selectedAuthId="${
|
|
7292
|
+
selectedAuthId="${i}"
|
|
7293
7293
|
accountConnected=${!0}
|
|
7294
|
+
tagsTree=${o}
|
|
7294
7295
|
/>
|
|
7295
7296
|
<//>
|
|
7296
7297
|
<//>
|
|
7297
|
-
</div>`,
|
|
7298
|
+
</div>`,s)}else console.warn(`Integry SDK render target with id ${t} was not found`)}})();verifyAuthConfig=()=>this.apiHandler.verifyAuthConfig({deploymentId:this.config.deploymentId});getUserVariables=async()=>{try{const e=await this.apiHandler.getUserVariables();return e?e.results:[]}catch(e){return console.error(e),[]}};destroy=()=>{try{this.eventEmitter.offAll();const e=document.getElementById(this.authModalId);e&&e.remove()}catch(e){console.error("There was an error unsubscribing from all events")}};static setFieldValue=(e,t)=>{const n=document.getElementById(e)?.querySelector("input");if(n&&n instanceof HTMLInputElement){n.value=t;const e=new KeyboardEvent("keyup",{key:"a",bubbles:!0,cancelable:!0});n.dispatchEvent(e)}const i=document.getElementById(`tagify_${e}`);if(i&&i instanceof HTMLInputElement){i.value=t;const e=new KeyboardEvent("keyup",{key:"a",bubbles:!0,cancelable:!0});i.dispatchEvent(e)}};getMethod=()=>"POST";getBaseAPIUrl=()=>"https://api.integry.io";getHeaders=()=>({"Content-Type":"application/json"})}export{Rd as Helpers,Wd as IntegryJS,R as html};
|
package/dist/umd/index.umd.d.ts
CHANGED
|
@@ -697,7 +697,7 @@ declare class IntegryJS {
|
|
|
697
697
|
containerId: string;
|
|
698
698
|
multipurposeFieldProps: MultipurposeFieldType;
|
|
699
699
|
}) => void;
|
|
700
|
-
renderFlowStep: (containerId: string, step: any, connectedAccountId: string) => void;
|
|
700
|
+
renderFlowStep: (containerId: string, step: any, connectedAccountId: string, tagsTree?: {}) => void;
|
|
701
701
|
verifyAuthConfig: () => Promise<{
|
|
702
702
|
config_verified: boolean;
|
|
703
703
|
meta: any;
|
package/dist/umd/index.umd.js
CHANGED
|
@@ -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:{}}}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}=e;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),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}=e;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
|
|
@@ -3455,8 +3455,8 @@
|
|
|
3455
3455
|
<${Jo}
|
|
3456
3456
|
id=${t.activity_field?.id}
|
|
3457
3457
|
title=${t.title||t.activity_field?.title}
|
|
3458
|
-
activityOutputData=${this.arrayToNestedJSONWithFirstValue(this.props.activityOutputData,this.props.dynamicFieldData||this.state.dynamicFieldDataState||{})}
|
|
3459
|
-
activityOutputDataRaw=${this.props.activityOutputData}
|
|
3458
|
+
activityOutputData=${this.arrayToNestedJSONWithFirstValue(this.props.activityOutputData||this.state.tagsTree,this.props.dynamicFieldData||this.state.dynamicFieldDataState||{})}
|
|
3459
|
+
activityOutputDataRaw=${this.props.activityOutputData||this.state.tagsTree}
|
|
3460
3460
|
description=${p}
|
|
3461
3461
|
value=${r&&r[t.id]&&r[t.id].value&&"x-integry-skipped-field"!==r[t.id].value&&r[t.id].value||t.default_value||""}
|
|
3462
3462
|
placeholder=${this.getPlaceholder(t)}
|
|
@@ -7000,7 +7000,7 @@
|
|
|
7000
7000
|
</div>
|
|
7001
7001
|
</div>
|
|
7002
7002
|
`}
|
|
7003
|
-
`}});class Rd{static SDK_VERSION="4.5.
|
|
7003
|
+
`}});class Rd{static SDK_VERSION="4.5.6";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
7004
|
<${nl}
|
|
7005
7005
|
message="SDK failed to load"
|
|
7006
7006
|
debug=${n.debug}
|
|
@@ -7277,21 +7277,22 @@
|
|
|
7277
7277
|
fieldId=${n.fieldId}
|
|
7278
7278
|
enableTagify=${n.enableTagify}
|
|
7279
7279
|
/>`}
|
|
7280
|
-
</div>`,i):console.warn(`Integry SDK render target with id ${t} was not found`)};renderFlowStep=(e
|
|
7280
|
+
</div>`,i):console.warn(`Integry SDK render target with id ${t} was not found`)};renderFlowStep=(()=>{var e=this;return function(t,n,i){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const s=document.getElementById(t);if(s){const t=de();T(R`<div>
|
|
7281
7281
|
<${ne.Provider}
|
|
7282
|
-
value=${{apiHandler:
|
|
7282
|
+
value=${{apiHandler:e.apiHandler,eventEmitter:e.eventEmitter,isPreviewMode:!1}}
|
|
7283
7283
|
>
|
|
7284
|
-
<${B.Provider} store=${
|
|
7284
|
+
<${B.Provider} store=${t} key=${e.getRandomFlowId(10)}>
|
|
7285
7285
|
<${Xs}
|
|
7286
|
-
step=${
|
|
7286
|
+
step=${n}
|
|
7287
7287
|
stepType=${"CONFIGURE"}
|
|
7288
7288
|
showStepValidation=${!1}
|
|
7289
|
-
apiHandler=${
|
|
7290
|
-
eventEmitter=${
|
|
7289
|
+
apiHandler=${e.apiHandler}
|
|
7290
|
+
eventEmitter=${e.eventEmitter}
|
|
7291
7291
|
isReadOnly="${!1}"
|
|
7292
|
-
selectedAuthId="${
|
|
7292
|
+
selectedAuthId="${i}"
|
|
7293
7293
|
accountConnected=${!0}
|
|
7294
|
+
tagsTree=${o}
|
|
7294
7295
|
/>
|
|
7295
7296
|
<//>
|
|
7296
7297
|
<//>
|
|
7297
|
-
</div>`,
|
|
7298
|
+
</div>`,s)}else console.warn(`Integry SDK render target with id ${t} was not found`)}})();verifyAuthConfig=()=>this.apiHandler.verifyAuthConfig({deploymentId:this.config.deploymentId});getUserVariables=async()=>{try{const e=await this.apiHandler.getUserVariables();return e?e.results:[]}catch(e){return console.error(e),[]}};destroy=()=>{try{this.eventEmitter.offAll();const e=document.getElementById(this.authModalId);e&&e.remove()}catch(e){console.error("There was an error unsubscribing from all events")}};static setFieldValue=(e,t)=>{const n=document.getElementById(e)?.querySelector("input");if(n&&n instanceof HTMLInputElement){n.value=t;const e=new KeyboardEvent("keyup",{key:"a",bubbles:!0,cancelable:!0});n.dispatchEvent(e)}const i=document.getElementById(`tagify_${e}`);if(i&&i instanceof HTMLInputElement){i.value=t;const e=new KeyboardEvent("keyup",{key:"a",bubbles:!0,cancelable:!0});i.dispatchEvent(e)}};getMethod=()=>"POST";getBaseAPIUrl=()=>"https://api.integry.io";getHeaders=()=>({"Content-Type":"application/json"})}return Rd.Helpers={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("")}},Rd.html=R,Rd}));
|
package/package.json
CHANGED
|
@@ -46,11 +46,13 @@ interface ActionFormPropsType extends StoreType {
|
|
|
46
46
|
isReadOnly?: boolean;
|
|
47
47
|
accountConnected: boolean;
|
|
48
48
|
selectedAuthId: string;
|
|
49
|
+
tagsTree: any;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
interface ActionFormStateType {
|
|
52
53
|
loading: boolean;
|
|
53
54
|
dynamicFieldDataState: any;
|
|
55
|
+
tagsTree: any;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
interface StepDataMapping {
|
|
@@ -63,6 +65,10 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
63
65
|
this.state = {
|
|
64
66
|
loading: false,
|
|
65
67
|
dynamicFieldDataState: {},
|
|
68
|
+
tagsTree:
|
|
69
|
+
this.props.tagsTree && Object.keys(this.props.tagsTree).length > 0
|
|
70
|
+
? JSONToActivityOutputData(this.props.tagsTree)
|
|
71
|
+
: {},
|
|
66
72
|
};
|
|
67
73
|
}
|
|
68
74
|
|
|
@@ -1335,13 +1341,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1335
1341
|
el.title || el.activity_field?.title
|
|
1336
1342
|
}
|
|
1337
1343
|
activityOutputData=${this.arrayToNestedJSONWithFirstValue(
|
|
1338
|
-
this.props.activityOutputData
|
|
1344
|
+
this.props.activityOutputData ||
|
|
1345
|
+
this.state.tagsTree,
|
|
1339
1346
|
this.props.dynamicFieldData ||
|
|
1340
1347
|
this.state.dynamicFieldDataState ||
|
|
1341
1348
|
{},
|
|
1342
1349
|
)}
|
|
1343
1350
|
activityOutputDataRaw=${
|
|
1344
|
-
this.props.activityOutputData
|
|
1351
|
+
this.props.activityOutputData ||
|
|
1352
|
+
this.state.tagsTree
|
|
1345
1353
|
}
|
|
1346
1354
|
description=${elDescription}
|
|
1347
1355
|
value=${
|
package/src/index.ts
CHANGED
|
@@ -1985,6 +1985,7 @@ export class IntegryJS {
|
|
|
1985
1985
|
containerId: string,
|
|
1986
1986
|
step: any,
|
|
1987
1987
|
connectedAccountId: string,
|
|
1988
|
+
tagsTree = {},
|
|
1988
1989
|
) => {
|
|
1989
1990
|
const target = document.getElementById(containerId);
|
|
1990
1991
|
|
|
@@ -2009,6 +2010,7 @@ export class IntegryJS {
|
|
|
2009
2010
|
isReadOnly="${false}"
|
|
2010
2011
|
selectedAuthId="${connectedAccountId}"
|
|
2011
2012
|
accountConnected=${true}
|
|
2013
|
+
tagsTree=${tagsTree}
|
|
2012
2014
|
/>
|
|
2013
2015
|
<//>
|
|
2014
2016
|
<//>
|