@descope/outbound-applications-widget 0.2.2 → 0.2.4
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.js +2 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/outbound-applications-widget v0.2.
|
|
3
|
+
* @descope/outbound-applications-widget v0.2.4
|
|
4
4
|
*/
|
|
5
|
-
import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as o,createSingletonMixin as n,compose as d,withMemCache as r}from"@descope/sdk-helpers";import{projectIdMixin as a,observeAttributesMixin as l,loggerMixin as c,cookieConfigMixin as u,baseUrlMixin as p,DEFAULT_STYLE_ID as h,createStateManagementMixin as f,initLifecycleMixin as v,modalMixin as g,themeMixin as m,staticResourcesMixin as b,createValidateAttributesMixin as w,descopeUiMixin as y,initElementMixin as A,debuggerMixin as C}from"@descope/sdk-mixins";import{FlowDriver as I,OutboundAppsListDriver as k}from"@descope/sdk-component-drivers";import{createAsyncThunk as O}from"@reduxjs/toolkit";import S from"@descope/web-js-sdk";import{createSelector as j}from"reselect";const x=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(o(t),i)})),e};function U(t){return new URLSearchParams(window.location.search).get(t)}const R=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},W=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),M=O("outboundApps/load",((t,{extra:{api:e}})=>e.outboundApps.getAllOutboundApps())),E=R(M)({onFulfilled:(t,e)=>{var i;t.outboundAppsList.data=null===(i=e.payload)||void 0===i?void 0:i.apps}},W((t=>t.outboundAppsList))),P={action:M,reducer:E},L=O("outboundApps/getConnectedOutboundApps",((t,{extra:{api:e}})=>e.outboundApps.getConnectedOutboundApps(t))),F=R(L)({onFulfilled:(t,e)=>{var i;t.connectedOutboundAppsIds.data=null===(i=e.payload)||void 0===i?void 0:i.appIds}},W((t=>t.connectedOutboundAppsIds))),N={action:L,reducer:F},q={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}},$={allOutboundApps:"/v1/mgmt/outbound/apps",connectedOutboundApps:"/v1/mgmt/outbound/apps-with-user-token"},D={me:"/v1/auth/me"},T=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),H=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))})),B=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({apps:["outboundApp3"]})}))})),J=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({userId:"user-1"})}))})),V=({httpClient:e,mock:i})=>({getAllOutboundApps:()=>t(void 0,void 0,void 0,(function*(){if(i)return H();const t=yield e.get($.allOutboundApps);return yield T(t),t.json()})),getConnectedOutboundApps:s=>t(void 0,[s],void 0,(function*({userId:t}){if(i)return B();const s=yield e.get($.connectedOutboundApps,{queryParams:{userId:t}});return yield T(s),s.json()}))}),z=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return J();const t=yield e.get(D.me);return yield T(t),t.json()}))}),G=n((s=>{var o,n,r,f;const v=d(a,l,c,u,p)(s);return f=class extends v{constructor(){super(...arguments),o.add(this),n.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||h}get api(){return e(this,n,"f")||e(this,o,"m",r).call(this),e(this,n,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url"],(()=>{e(this,n,"f")&&e(this,o,"m",r).call(this)}))}))}},n=new WeakMap,o=new WeakSet,r=function(){this.logger.debug("creating an sdk instance"),i(this,n,((t,e,i)=>{const s=S(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.2.2"}}));return{outboundApps:V({httpClient:s.httpClient,mock:e}),user:Object.assign({},z({httpClient:s.httpClient,mock:e}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},f})),K=O("users/me",((t,{extra:{api:e}})=>e.user.me())),Q={action:K,reducer:R(K)({onFulfilled:(t,e)=>{t.me.data=e.payload}},W((t=>t.me)))},X=n((t=>{const e=d(f({name:"widget",initialState:q,reducers:{setAllowedAppsIds:(t,{payload:e})=>{t.allowedAppsIds.data=e}},extraReducers:t=>{Q.reducer(t),N.reducer(t),P.reducer(t)},asyncActions:{getMe:Q.action,getOutboundApps:P.action,getConnectedOutboundApps:N.action}}),v,c,G)(t);return class extends e{constructor(...t){super(...t),this.state=q,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),Y="widget-flow",Z=n((i=>{var s,o,n;return n=class extends(d(v,g,X,u,c,m)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const n=U(Y);n&&(!function(t){if(window.history.replaceState&&U(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(Y),e(this,s,"m",o).call(this,n))}))}},s=new WeakSet,o=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(x({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));new I((()=>{var t;return null===(t=e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{e.close(),this.actions.getMe()})),e.afterClose=()=>{e.remove()},e.open()},n})),_=j((t=>t.outboundAppsList.data),(t=>t.connectedOutboundAppsIds.data),(t=>t.allowedAppsIds.data),((t,e,i)=>t.filter((t=>void 0===i||i.includes(t.id))).map((t=>{const i=(null==e?void 0:e.includes(t.id))||!1;return Object.assign(Object.assign({},t),{appId:t.id,isConnected:i})})).sort(((t,e)=>t.name.localeCompare(e.name))))),tt=j((t=>t.me.data),(t=>t.userId)),et=n((e=>{const i=d(b,w({"widget-id":w.missingAttrValidator}))(e);return class extends i{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`outbound-applications-widget/${this.widgetId}/${e}`,"text")).body}))}}})),it=n((i=>{var o,n,r,a,l;return l=class extends(d(c,v,y,A,et,X)(i)){constructor(){super(...arguments),o.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(t,i,s){"allowed-outbound-apps-ids"===t&&i!==s&&this.actions.setAllowedAppsIds(e(this,o,"a",a))}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(e(this,o,"a",a)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:tt(this.state)})]);const s=yield e(this,o,"m",n).call(this);e(this,o,"m",r).call(this,s),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},o=new WeakSet,n=function(){return t(this,void 0,void 0,(function*(){const t=s(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(t),t}))},r=function(t){this.contentRootElement.append(t.content.cloneNode(!0))},a=function(){var t;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const e=null===(t=this.getAttribute("allowed-outbound-apps-ids"))||void 0===t?void 0:t.trim();return e?e.split(",").map((t=>t.trim())).filter(Boolean):[]},l})),st=n((t=>class extends(d(m,l)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),ot=n((s=>{var o,n,a,l,u,p,h,f,v,m,b,w,y,A,C,O,S;return S=class extends(d(st,X,c,it,g)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),u.set(this,void 0),p.set(this,void 0),h.set(this,null),f.set(this,null),O.set(this,r((t=>{e(this,n,"f").data=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",C).call(this,_(this.state)),e(this,o,"m",v).call(this),e(this,o,"m",w).call(this),this.subscribe(e(this,O,"f").bind(this),_)}))}},n=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,p=new WeakMap,h=new WeakMap,f=new WeakMap,O=new WeakMap,o=new WeakSet,v=function(){e(this,n,"f").connectFlowId&&(i(this,a,this.createModal({"data-id":"outbound-apps-connect"}),"f"),e(this,a,"f").afterClose=()=>{var t;if(e(this,h,"f")){const s=null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc");null==s||s.removeEventListener("page-updated",e(this,h,"f")),i(this,h,null,"f")}},i(this,u,new I((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,u,"f")))},m=function(t,e,i){t.open(),e.removeEventListener("page-updated",i)},b=function(t,i){var s;const n=null===(s=t.ele)||void 0===s?void 0:s.querySelector("descope-wc"),d=()=>e(this,o,"m",m).call(this,t,n,d);i=d,null==n||n.addEventListener("page-updated",i)},w=function(){i(this,l,this.createModal({"data-id":"outbound-apps-disconnect"}),"f"),i(this,p,new I((()=>{var t;return null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,l,"f").afterClose=()=>{var t;if(e(this,f,"f")){const s=null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc");null==s||s.removeEventListener("page-updated",e(this,f,"f")),i(this,f,null,"f")}},this.syncFlowTheme(e(this,p,"f"))},y=function(t){e(this,a,"f").setContent(x({projectId:this.projectId,flowId:e(this,n,"f").connectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:t})),e(this,o,"m",b).call(this,e(this,a,"f"),e(this,h,"f")),e(this,u,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getConnectedOutboundApps({userId:tt(this.state)})}))},A=function(t){e(this,l,"f").setContent(x({projectId:this.projectId,flowId:e(this,n,"f").disconnectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:t})),e(this,o,"m",b).call(this,e(this,l,"f"),e(this,f,"f")),e(this,p,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getConnectedOutboundApps({userId:tt(this.state)})}))},C=function(t){i(this,n,new k((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),e(this,n,"f").onConnectClick((({id:t})=>{e(this,o,"m",y).call(this,t)})),e(this,n,"f").onDisconnectClick((({id:t})=>{e(this,o,"m",A).call(this,t)})),e(this,n,"f").data=t},S})),nt=n((e=>class extends(d(C,m,Z,ot)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),dt=d((e=>class extends(nt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.2.2"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",dt);export{dt as default};
|
|
5
|
+
import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createTemplate as s,kebabCase as o,createSingletonMixin as n,compose as d,withMemCache as r}from"@descope/sdk-helpers";import{projectIdMixin as a,observeAttributesMixin as l,loggerMixin as c,cookieConfigMixin as u,baseUrlMixin as p,DEFAULT_STYLE_ID as h,createStateManagementMixin as f,initLifecycleMixin as v,modalMixin as g,themeMixin as m,staticResourcesMixin as b,createValidateAttributesMixin as w,descopeUiMixin as y,initElementMixin as A,debuggerMixin as C}from"@descope/sdk-mixins";import{FlowDriver as I,OutboundAppsListDriver as k}from"@descope/sdk-component-drivers";import{createAsyncThunk as O}from"@reduxjs/toolkit";import S from"@descope/web-js-sdk";import{createSelector as j}from"reselect";const x=(t={})=>{const e=s("<descope-wc></descope-wc>");return Object.entries(t).forEach((([t,i])=>{e.content.querySelector("descope-wc").setAttribute(o(t),i)})),e};function U(t){return new URLSearchParams(window.location.search).get(t)}const R=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},W=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),M=O("outboundApps/load",((t,{extra:{api:e}})=>e.outboundApps.getAllOutboundApps())),E=R(M)({onFulfilled:(t,e)=>{var i;t.outboundAppsList.data=null===(i=e.payload)||void 0===i?void 0:i.apps}},W((t=>t.outboundAppsList))),P={action:M,reducer:E},L=O("outboundApps/getConnectedOutboundApps",((t,{extra:{api:e}})=>e.outboundApps.getConnectedOutboundApps(t))),F=R(L)({onFulfilled:(t,e)=>{var i;t.connectedOutboundAppsIds.data=null===(i=e.payload)||void 0===i?void 0:i.appIds}},W((t=>t.connectedOutboundAppsIds))),N={action:L,reducer:F},q={outboundAppsList:{data:[],loading:!1,error:null},connectedOutboundAppsIds:{data:[],loading:!1,error:null},allowedAppsIds:{data:void 0},me:{loading:!1,error:null,data:{}}},$={allOutboundApps:"/v1/mgmt/outbound/apps",connectedOutboundApps:"/v1/mgmt/outbound/apps-with-user-token"},D={me:"/v1/auth/me"},T=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),H=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({apps:[{id:"appId1",name:"Application 1",description:"Description"},{id:"appId2",name:"Application 2",description:"Description"},{id:"appId3",name:"Application 3",description:"Description"}]})}))})),B=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({apps:["outboundApp3"]})}))})),J=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({userId:"user-1"})}))})),V=({httpClient:e,mock:i})=>({getAllOutboundApps:()=>t(void 0,void 0,void 0,(function*(){if(i)return H();const t=yield e.get($.allOutboundApps);return yield T(t),t.json()})),getConnectedOutboundApps:s=>t(void 0,[s],void 0,(function*({userId:t}){if(i)return B();const s=yield e.get($.connectedOutboundApps,{queryParams:{userId:t}});return yield T(s),s.json()}))}),z=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return J();const t=yield e.get(D.me);return yield T(t),t.json()}))}),G=n((s=>{var o,n,r,f;const v=d(a,l,c,u,p)(s);return f=class extends v{constructor(){super(...arguments),o.add(this),n.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||h}get api(){return e(this,n,"f")||e(this,o,"m",r).call(this),e(this,n,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url"],(()=>{e(this,n,"f")&&e(this,o,"m",r).call(this)}))}))}},n=new WeakMap,o=new WeakSet,r=function(){this.logger.debug("creating an sdk instance"),i(this,n,((t,e,i)=>{const s=S(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.2.4"}}));return{outboundApps:V({httpClient:s.httpClient,mock:e}),user:Object.assign({},z({httpClient:s.httpClient,mock:e}))}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},"true"===this.mock,this.widgetId),"f")},f})),K=O("users/me",((t,{extra:{api:e}})=>e.user.me())),Q={action:K,reducer:R(K)({onFulfilled:(t,e)=>{t.me.data=e.payload}},W((t=>t.me)))},X=n((t=>{const e=d(f({name:"widget",initialState:q,reducers:{setAllowedAppsIds:(t,{payload:e})=>{t.allowedAppsIds.data=e}},extraReducers:t=>{Q.reducer(t),N.reducer(t),P.reducer(t)},asyncActions:{getMe:Q.action,getOutboundApps:P.action,getConnectedOutboundApps:N.action}}),v,c,G)(t);return class extends e{constructor(...t){super(...t),this.state=q,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),Y="widget-flow",Z=n((i=>{var s,o,n;return n=class extends(d(v,g,X,u,c,m)(i)){constructor(){super(...arguments),s.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const n=U(Y);n&&(!function(t){if(window.history.replaceState&&U(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(Y),e(this,s,"m",o).call(this,n))}))}},s=new WeakSet,o=function(t){const e=this.createModal({"data-id":"redirect-flow"});e.setContent(x({projectId:this.projectId,flowId:t,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId}));new I((()=>{var t;return null===(t=e.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{e.close(),this.actions.getMe()})),e.afterClose=()=>{e.remove()},e.open()},n})),_=j((t=>t.outboundAppsList.data),(t=>t.connectedOutboundAppsIds.data),(t=>t.allowedAppsIds.data),((t,e,i)=>t.filter((t=>void 0===i||i.includes(t.id))).map((t=>{const i=(null==e?void 0:e.includes(t.id))||!1;return Object.assign(Object.assign({},t),{appId:t.id,isConnected:i})})).sort(((t,e)=>t.name.localeCompare(e.name))))),tt=j((t=>t.me.data),(t=>t.userId)),et=n((e=>{const i=d(b,w({"widget-id":w.missingAttrValidator}))(e);return class extends i{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return t(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`outbound-applications-widget/${this.widgetId}/${e}`,"text")).body}))}}})),it=n((i=>{var o,n,r,a,l;return l=class extends(d(c,v,y,A,et,X)(i)){constructor(){super(...arguments),o.add(this)}static get observedAttributes(){return["allowed-outbound-apps-ids"]}attributeChangedCallback(t,i,s){"allowed-outbound-apps-ids"===t&&i!==s&&this.actions.setAllowedAppsIds(e(this,o,"a",a))}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),yield this.actions.getMe(),yield this.actions.setAllowedAppsIds(e(this,o,"a",a)),yield Promise.all([this.actions.getOutboundApps(),this.actions.getConnectedOutboundApps({userId:tt(this.state)})]);const s=yield e(this,o,"m",n).call(this);e(this,o,"m",r).call(this,s),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},o=new WeakSet,n=function(){return t(this,void 0,void 0,(function*(){const t=s(yield this.fetchWidgetPage("root.html"));return yield this.loadDescopeUiComponents(t),t}))},r=function(t){this.contentRootElement.append(t.content.cloneNode(!0))},a=function(){var t;if(!this.hasAttribute("allowed-outbound-apps-ids"))return;const e=null===(t=this.getAttribute("allowed-outbound-apps-ids"))||void 0===t?void 0:t.trim();return e?e.split(",").map((t=>t.trim())).filter(Boolean):[]},l})),st=n((t=>class extends(d(m,l)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}})),ot=n((s=>{var o,n,a,l,u,p,h,f,v,m,b,w,y,A,C,O,S;return S=class extends(d(st,X,c,it,g)(s)){constructor(){super(...arguments),o.add(this),n.set(this,void 0),a.set(this,void 0),l.set(this,void 0),u.set(this,void 0),p.set(this,void 0),h.set(this,null),f.set(this,null),O.set(this,r((t=>{e(this,n,"f").data=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",C).call(this,_(this.state)),e(this,o,"m",v).call(this),e(this,o,"m",w).call(this),this.subscribe(e(this,O,"f").bind(this),_)}))}},n=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,p=new WeakMap,h=new WeakMap,f=new WeakMap,O=new WeakMap,o=new WeakSet,v=function(){e(this,n,"f").connectFlowId&&(i(this,a,this.createModal({"data-id":"outbound-apps-connect"}),"f"),e(this,a,"f").afterClose=()=>{var t;if(e(this,h,"f")){const s=null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc");null==s||s.removeEventListener("page-updated",e(this,h,"f")),i(this,h,null,"f")}},i(this,u,new I((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,u,"f")))},m=function(t,e,i){t.open(),e.removeEventListener("page-updated",i)},b=function(t,i){var s;const n=null===(s=t.ele)||void 0===s?void 0:s.querySelector("descope-wc"),d=()=>e(this,o,"m",m).call(this,t,n,d);i=d,null==n||n.addEventListener("page-updated",i)},w=function(){i(this,l,this.createModal({"data-id":"outbound-apps-disconnect"}),"f"),i(this,p,new I((()=>{var t;return null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,l,"f").afterClose=()=>{var t;if(e(this,f,"f")){const s=null===(t=e(this,l,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc");null==s||s.removeEventListener("page-updated",e(this,f,"f")),i(this,f,null,"f")}},this.syncFlowTheme(e(this,p,"f"))},y=function(t){e(this,a,"f").setContent(x({projectId:this.projectId,flowId:e(this,n,"f").connectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:t})),e(this,o,"m",b).call(this,e(this,a,"f"),e(this,h,"f")),e(this,u,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getConnectedOutboundApps({userId:tt(this.state)})}))},A=function(t){e(this,l,"f").setContent(x({projectId:this.projectId,flowId:e(this,n,"f").disconnectFlowId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,"style-id":this.styleId,outboundAppId:t})),e(this,o,"m",b).call(this,e(this,l,"f"),e(this,f,"f")),e(this,p,"f").onSuccess((()=>{e(this,l,"f").close(),this.actions.getConnectedOutboundApps({userId:tt(this.state)})}))},C=function(t){i(this,n,new k((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-outbound-apps")}),{logger:this.logger}),"f"),e(this,n,"f").onConnectClick((({id:t})=>{e(this,o,"m",y).call(this,t)})),e(this,n,"f").onDisconnectClick((({id:t})=>{e(this,o,"m",A).call(this,t)})),e(this,n,"f").data=t},S})),nt=n((e=>class extends(d(C,m,Z,ot)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),dt=d((e=>class extends(nt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"outbound-applications-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.2.4"}}}))}}))(HTMLElement);customElements.define("descope-outbound-applications-widget",dt);export{dt as default};
|
|
6
6
|
//# sourceMappingURL=index.js.map
|