@descope/role-management-widget 0.1.40 → 0.1.42
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 +1 -1
- package/dist/index.d.ts +36 -36
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/**
|
|
3
|
-
* @descope/role-management-widget v0.1.
|
|
3
|
+
* @descope/role-management-widget v0.1.42
|
|
4
4
|
*/
|
|
5
5
|
import{pluralize as e,createSingletonMixin as t,compose as i,createTemplate as o,withMemCache as s,debounce as n}from"@descope/sdk-helpers";import{__awaiter as a,__classPrivateFieldGet as r,__classPrivateFieldSet as l,__rest as d}from"tslib";import{projectIdMixin as c,observeAttributesMixin as u,loggerMixin as h,createValidateAttributesMixin as g,createStateManagementMixin as v,initLifecycleMixin as m,staticResourcesMixin as p,descopeUiMixin as R,initElementMixin as f,modalMixin as y,formMixin as w,notificationsMixin as b,debuggerMixin as M,themeMixin as C}from"@descope/sdk-mixins";import{ButtonDriver as W,MultiSelectDriver as k,TextDriver as x,TextFieldDriver as S,GridDriver as j}from"@descope/sdk-component-drivers";import{createSelector as P}from"reselect";import{createAsyncThunk as L}from"@reduxjs/toolkit";import O from"@descope/web-js-sdk";const N=e=>e.selectedRolesIds,I=e=>e.notifications,F=e=>e.tenantPermissions.data||[],$=P((e=>e.rolesList.data),(e=>e.map((e=>{var t;return Object.assign(Object.assign({},e),{editable:0===(null===(t=null==e?void 0:e.tenantId)||void 0===t?void 0:t.length)?"no":"yes"})})))),q=P(N,$,((e,t)=>t.filter((t=>e.includes(t.name))))),B=P(N,(e=>!!e.length)),D=P(N,(e=>1===e.length)),T=P(q,(e=>1===e.length?e[0].name:`${e.length} roles`)),E=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},A=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),H=({getErrorMsg:e,getSuccessMsg:t})=>({onFulfilled:(e,i)=>{t&&e.notifications.push({type:"success",msg:t(i)})},onRejected:(t,i)=>{e&&t.notifications.push({type:"error",msg:e(i)})}}),Z=L("roles/create",((e,{extra:{api:t}})=>t.role.create(e))),V=E(Z)({onFulfilled:(e,t)=>{e.rolesList.data.unshift(t.payload)}},A((e=>e.createRole)),H({getSuccessMsg:()=>"Role created successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to create role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),U={action:Z,reducer:V},z=L("roles/delete",((e,{extra:{api:t}})=>t.role.deleteBatch(e))),J=E(z)({onFulfilled:(e,t)=>{e.rolesList.data=e.rolesList.data.filter((e=>{var i;return 0===(null===(i=null==e?void 0:e.tenantId)||void 0===i?void 0:i.length)||!t.meta.arg.includes(e.name)})),e.selectedRolesIds=[]}},A((e=>e.deleteRole)),H({getSuccessMsg:t=>e(t.meta.arg.length)`${["",t.meta.arg.length]} ${["R","r"]}ole${["","s"]} deleted successfully`,getErrorMsg:t=>e(t.meta.arg.length)`Failed to delete role${["","s"]}`})),G={action:z,reducer:J},K=L("roles/search",((e,{extra:{api:t},getState:i})=>{const o=i().searchParams;return t.role.search(Object.assign(Object.assign({},o),e))})),Q=E(K)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.rolesList.data=t.payload}},A((e=>e.rolesList))),X={action:K,reducer:Q},Y=L("roles/update",((e,{extra:{api:t}})=>t.role.update(e))),_=E(Y)({onFulfilled:(e,t)=>{const i=e.rolesList.data.findIndex((e=>e.name===t.payload.oldName));-1!==i&&(e.rolesList.data[i]=t.payload)}},A((e=>e.updateRole)),H({getSuccessMsg:()=>"Role updated successfully",getErrorMsg:e=>{var t;return`\n <div>\n <div>Failed to update role</div>\n ${null===(t=e.error)||void 0===t?void 0:t.message}\n </div>`}})),ee={action:Y,reducer:_},te=L("tenant/getTenantPermissions",((e,{extra:{api:t}})=>t.tenant.getTenantPermissions())),ie={action:te,reducer:E(te)({onFulfilled:(e,t)=>{e.tenantPermissions.data=t.payload.permissions}},A((e=>e.tenantPermissions)))},oe={rolesList:{data:[],loading:!1,error:null},createRole:{loading:!1,error:null},updateRole:{loading:!1,error:null},deleteRole:{loading:!1,error:null},tenantPermissions:{loading:!1,error:null,data:[]},searchParams:{text:"",sort:[]},selectedRolesIds:[],notifications:[]},se={search:"/v1/mgmt/role/search",deleteBatch:"/v1/mgmt/role/delete/batch",create:"/v1/mgmt/role/create",update:"/v1/mgmt/role/update"},ne={permissions:"/v1/mgmt/permission/all"},ae=e=>a(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)})),re=({text:e,sort:t},i)=>a(void 0,void 0,void 0,(function*(){return new Promise((o=>{const s=[];for(let e=1;e<10;e+=1)s.push({name:`Role ${e}`,description:`Role description ${e}`,permissionNames:[`Permission ${e}`],createdTime:new Date,tenantId:i});t.forEach((e=>{s.sort(((t,i)=>{var o,s;return e.desc?null===(s=i[e.field])||void 0===s?void 0:s.localeCompare(t[e.field]):null===(o=t[e.field])||void 0===o?void 0:o.localeCompare(i[e.field])}))})),o(s.filter((t=>t.name.toLowerCase().includes(e.toLowerCase())||t.description.toLowerCase().includes(e.toLowerCase()))))}))})),le=({name:e,description:t,permissionNames:i},o)=>a(void 0,void 0,void 0,(function*(){return new Promise((s=>{s({name:e,description:t,permissionNames:i,createdTime:new Date,tenantId:o})}))})),de=({name:e,newName:t,description:i,permissionNames:o},s)=>a(void 0,void 0,void 0,(function*(){return new Promise((n=>{n({name:t,description:i,permissionNames:o,createdTime:new Date,oldName:e,tenantId:s})}))})),ce=()=>a(void 0,void 0,void 0,(function*(){})),ue=()=>new Promise((e=>{const t=[];for(let e=1;e<5;e+=1)t.push({name:`Permission ${e}`});e({permissions:t})})),he=({httpClient:e,tenant:t,mock:i})=>({search:({page:o,limit:s=1e4,text:n,sort:r}={})=>a(void 0,void 0,void 0,(function*(){if(i)return re({page:o,limit:s,text:n,sort:r},t);const a=yield e.post(se.search,{limit:s,page:o,text:n,sort:r},{queryParams:{tenant:t}});yield ae(a);return(yield a.json()).roles})),deleteBatch:o=>a(void 0,void 0,void 0,(function*(){if(i)return ce();const s=yield e.post(se.deleteBatch,{roleNames:o},{queryParams:{tenant:t}});return yield ae(s),s.json()})),create:({name:o,description:s,permissionNames:n})=>a(void 0,void 0,void 0,(function*(){if(i)return le({name:o,description:s,permissionNames:n},t);const a=yield e.post(se.create,{name:o,description:s,permissionNames:n,tenantId:t},{queryParams:{tenant:t}});yield ae(a);return yield a.json()})),update:({name:o,newName:s,description:n,permissionNames:r})=>a(void 0,void 0,void 0,(function*(){if(i)return de({name:o,newName:s,description:n,permissionNames:r},t);const a=yield e.post(se.update,{name:o,newName:s,description:n,permissionNames:r,tenantId:t},{queryParams:{tenant:t}});yield ae(a);const l=yield a.json();return l.oldName=o,l}))}),ge=({httpClient:e,tenant:t,mock:i})=>({getTenantPermissions:()=>a(void 0,void 0,void 0,(function*(){if(i)return ue();const o=yield e.get(ne.permissions,{queryParams:{tenant:t}});return yield ae(o),o.json()}))}),ve=t((e=>{var t,o,s,n;const d=i(c,u,h,g({tenant:g.missingAttrValidator}))(e);return n=class extends d{constructor(){super(...arguments),t.add(this),o.set(this,void 0)}get baseUrl(){return this.getAttribute("base-url")}get tenant(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get api(){return r(this,o,"f")||r(this,t,"m",s).call(this),r(this,o,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{r(this,o,"f")&&r(this,t,"m",s).call(this)}))}))}},o=new WeakMap,t=new WeakSet,s=function(){this.logger.debug("creating an sdk instance"),l(this,o,((e,t,i)=>{const o=O(Object.assign(Object.assign({},e),{persistTokens:!0}));return{role:he({httpClient:o.httpClient,tenant:t,mock:i}),tenant:ge({httpClient:o.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl},this.tenant,"true"===this.mock),"f")},n})),me=t((e=>{const t=i(v({name:"widget",initialState:oe,reducers:{setSelectedRolesIds:(e,{payload:t})=>{e.selectedRolesIds=t},clearNotifications:e=>{e.notifications=[]}},extraReducers:e=>{U.reducer(e),ee.reducer(e),G.reducer(e),X.reducer(e),ie.reducer(e)},asyncActions:{searchRoles:X.action,createRole:U.action,updateRole:ee.action,deleteRoles:G.action,getTenantPermissions:ie.action}}),m,h,ve)(e);return class extends t{constructor(...e){super(...e),this.state=oe,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),pe=t((e=>{const t=i(p,g({"widget-id":g.missingAttrValidator}))(e);return class extends t{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return a(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`role-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),Re=t((e=>{var t,s,n;return n=class extends(i(h,m,R,f,pe,me)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){return a(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.init)||void 0===i?void 0:i.call(this),yield Promise.all([r(this,t,"m",s).call(this),this.actions.searchRoles(),this.actions.getTenantPermissions()]),this.onWidgetRootReady()}))}},t=new WeakSet,s=function(){return a(this,void 0,void 0,(function*(){const e=o(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),fe=t((e=>{var t,s,n,d,c;return c=class extends(i(me,y,w,h,Re)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),d.set(this,(()=>a(this,void 0,void 0,(function*(){var e;yield r(this,s,"f").setData(null===(e=F(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))}))))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),r(this,t,"m",n).call(this)}))}},s=new WeakMap,d=new WeakMap,t=new WeakSet,n=function(){return a(this,void 0,void 0,(function*(){this.createRoleModal=this.createModal(),this.createRoleModal.setContent(o(yield this.fetchWidgetPage("create-role-modal.html")));const e=new W((()=>{var e;return null===(e=this.createRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});e.onClick((()=>{this.createRoleModal.close(),this.resetFormData(this.createRoleModal.ele)}));const t=new W((()=>{var e;return null===(e=this.createRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});t.onClick((()=>a(this,void 0,void 0,(function*(){this.validateForm(this.createRoleModal.ele)&&(this.actions.createRole(Object.assign({},this.getFormData(this.createRoleModal.ele))),this.createRoleModal.close(),this.resetFormData(this.createRoleModal.ele))})))),l(this,s,new k((()=>{var e;return null===(e=this.createRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),r(this,d,"f").call(this)}))},c})),ye=t((e=>{var t,o,s;return s=class extends(i(h,fe,Re)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),r(this,t,"m",o).call(this)}))}},t=new WeakSet,o=function(){var e;this.createButton=new W(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="create-role"]'),{logger:this.logger}),this.createButton.onClick((()=>this.createRoleModal.open()))},s})),we=t((e=>{var t,s,n;return n=class extends(i(me,y,h,Re)(e)){constructor(){super(...arguments),t.add(this)}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield r(this,t,"m",s).call(this)}))}},t=new WeakSet,s=function(){var e;return a(this,void 0,void 0,(function*(){this.deleteRolesModal=this.createModal(),this.deleteRolesModal.setContent(o(yield this.fetchWidgetPage("delete-roles-modal.html")));const t=new W((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});t.onClick((()=>this.deleteRolesModal.close()));const i=new W((()=>{var e;return null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});i.onClick((()=>{const e=q(this.state);this.actions.deleteRoles(null==e?void 0:e.map((e=>e.name))),this.deleteRolesModal.close()}));const s=new x(null===(e=this.deleteRolesModal.ele)||void 0===e?void 0:e.querySelector('[data-id="body-text"]'),{logger:this.logger});this.deleteRolesModal.beforeOpen=()=>{const e=T(this.state);s.text=`Delete ${e}?`}}))},n})),be=t((e=>{var t,o,n,l;return l=class extends(i(h,Re,me,we)(e)){constructor(){super(...arguments),t.add(this),n.set(this,s((e=>{e?this.deleteButton.enable():this.deleteButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),r(this,t,"m",o).call(this),this.subscribe(r(this,n,"f").bind(this),B)}))}},n=new WeakMap,t=new WeakSet,o=function(){var e;this.deleteButton=new W(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="delete-roles"]'),{logger:this.logger}),this.deleteButton.disable(),this.deleteButton.onClick((()=>{this.deleteRolesModal.open()}))},l})),Me=t((e=>{var t,s,n,c,u,g,v,m;return m=class extends(i(me,y,h,w,Re)(e)){constructor(){super(...arguments),t.add(this),s.set(this,void 0),u.set(this,(()=>a(this,void 0,void 0,(function*(){var e;yield r(this,s,"f").setData(null===(e=F(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),g.set(this,(()=>{var e;const t=null===(e=q(this.state))||void 0===e?void 0:e[0],i={name:null==t?void 0:t.name,description:null==t?void 0:t.description,permissionNames:null==t?void 0:t.permissionNames};this.setFormData(this.editRoleModal.ele,i)}))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),yield r(this,t,"m",v).call(this)}))}},s=new WeakMap,u=new WeakMap,g=new WeakMap,t=new WeakSet,n=function(){const e=new W((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-cancel"]')}),{logger:this.logger});e.onClick((()=>this.editRoleModal.close()))},c=function(){const e=new W((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="modal-submit"]')}),{logger:this.logger});e.onClick((()=>{var e;if(this.validateForm(this.editRoleModal.ele)){const t=this.getFormData(this.editRoleModal.ele),{name:i}=t,o=d(t,["name"]),s=null===(e=q(this.state))||void 0===e?void 0:e[0];this.actions.updateRole(Object.assign({newName:i,name:s.name},o)),this.editRoleModal.close(),this.resetFormData(this.editRoleModal.ele)}}))},v=function(){return a(this,void 0,void 0,(function*(){this.editRoleModal=this.createModal(),this.editRoleModal.setContent(o(yield this.fetchWidgetPage("edit-role-modal.html"))),r(this,t,"m",n).call(this),r(this,t,"m",c).call(this),l(this,s,new k((()=>{var e;return null===(e=this.editRoleModal.ele)||void 0===e?void 0:e.querySelector('[data-id="permissions-multiselect"]')}),{logger:this.logger}),"f"),this.editRoleModal.beforeOpen=()=>a(this,void 0,void 0,(function*(){yield r(this,u,"f").call(this),r(this,g,"f").call(this)}))}))},m})),Ce=t((e=>{var t,o,n,l;return l=class extends(i(h,Re,me,Me,w)(e)){constructor(){super(...arguments),t.add(this),n.set(this,s((e=>{e?this.editButton.enable():this.editButton.disable()})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),r(this,t,"m",o).call(this),this.subscribe(r(this,n,"f").bind(this),D)}))}},n=new WeakMap,t=new WeakSet,o=function(){var e;this.editButton=new W(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="edit-role"]'),{logger:this.logger}),this.editButton.disable(),this.editButton.onClick((()=>{this.editRoleModal.open()}))},l})),We=t((e=>{var t,o,s,l;return l=class extends(i(h,Re,me)(e)){constructor(){super(...arguments),t.add(this),o.set(this,n((()=>{this.actions.searchRoles({text:this.searchInput.value})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),r(this,t,"m",s).call(this)}))}},o=new WeakMap,t=new WeakSet,s=function(){var e;this.searchInput=new S(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(r(this,o,"f"))},l}));const ke={success:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Checkmark">\n<path id="Shape" d="M10.0485 15.6396C9.5799 15.171 8.8201 15.171 8.35147 15.6396C7.88284 16.1082 7.88284 16.868 8.35147 17.3367L12.7072 21.6924C13.1759 22.1611 13.9357 22.1611 14.4043 21.6924L24.7152 11.3815C25.1838 10.9129 25.1838 10.1531 24.7152 9.68448C24.2466 9.21585 23.4868 9.21585 23.0181 9.68448L13.5558 19.1469L10.0485 15.6396Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,error:(new DOMParser).parseFromString('<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Vector" d="M15.9998 26.6558C10.1118 26.6558 5.34375 21.8878 5.34375 15.9998C5.34375 10.1118 10.1118 5.34375 15.9998 5.34375C21.8878 5.34375 26.6558 10.1118 26.6558 15.9998C26.6558 21.8878 21.8878 26.6558 15.9998 26.6558ZM15.9998 24.4798C20.6718 24.4798 24.4798 20.7038 24.4798 15.9998C24.4798 11.3278 20.7038 7.51975 15.9998 7.51975C11.3278 7.51975 7.51975 11.2958 7.51975 15.9998C7.51975 20.6718 11.2958 24.4798 15.9998 24.4798ZM15.3278 9.34375H16.6718C17.0558 9.34375 17.3438 9.63175 17.3118 9.98375L16.9598 16.9278C16.9598 17.1838 16.7678 17.3438 16.5438 17.3438H15.4558C15.2318 17.3438 15.0398 17.1518 15.0398 16.9278L14.6878 9.98375C14.6878 9.63175 14.9758 9.34375 15.3278 9.34375ZM15.4558 19.4558H16.5438C16.9278 19.4558 17.2158 19.7438 17.1838 20.1278V21.1838C17.1838 21.5678 16.8958 21.8558 16.5438 21.8558H15.4558C15.0718 21.8558 14.7838 21.5678 14.7838 21.1838V20.1278C14.7838 19.7438 15.0718 19.4558 15.4558 19.4558Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},xe=t((e=>{var t,o,n,l,d;return d=class extends(i(h,me,b,m)(e)){constructor(){super(...arguments),t.add(this),l.set(this,s((e=>{e.length&&(e.forEach((({type:e,msg:i})=>{const s=r(this,t,"m",n).call(this,e);s.setContent(r(this,t,"m",o).call(this,{type:e,msg:i})),s.show()})),setTimeout((()=>this.actions.clearNotifications())))})))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return a(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.subscribe(r(this,l,"f").bind(this),I)}))}},l=new WeakMap,t=new WeakSet,o=function({type:e,msg:t}){const i=ke[e],o=Object.assign((new DOMParser).parseFromString('<svg width="2em" height="2em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g id="Icon">\n<path id="Shape" d="M10.6712 12L7.27521 8.60406C6.90826 8.23711 6.90826 7.64216 7.27521 7.27521C7.64216 6.90826 8.23711 6.90826 8.60406 7.27521L12 10.6712L15.3959 7.27521C15.7629 6.90826 16.3578 6.90826 16.7248 7.27521C17.0917 7.64216 17.0917 8.23711 16.7248 8.60406L13.3288 12L16.7248 15.3959C17.0917 15.7629 17.0917 16.3578 16.7248 16.7248C16.3578 17.0917 15.7629 17.0917 15.3959 16.7248L12 13.3288L8.60406 16.7248C8.23711 17.0917 7.64216 17.0917 7.27521 16.7248C6.90826 16.3578 6.90826 15.7629 7.27521 15.3959L10.6712 12Z" fill="currentcolor"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild,{slot:"close"});return`${(null==i?void 0:i.outerHTML)||""}${t}${o.outerHTML}`},n=function(e){return this.createNotification({mode:e,duration:"error"===e?0:3e3,position:"bottom-start",size:"sm"})},d})),Se=t((e=>{var t,o,l,d,c;return c=class extends(i(me,h,Re)(e)){constructor(){super(...arguments),t.add(this),l.set(this,s((e=>{this.rolesTable.data=e}))),d.set(this,n(((e,t)=>{const i=[],{value:o}=t;if(o){const t=e.path;i.push({field:t,desc:"desc"===o})}this.actions.searchRoles({sort:i})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var i;return a(this,void 0,void 0,(function*(){yield null===(i=e.onWidgetRootReady)||void 0===i?void 0:i.call(this),r(this,t,"m",o).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{r(this,d,"f").call(this,e.target,e.detail)}))})),r(this,l,"f").call(this,$(this.state)),this.subscribe(r(this,l,"f").bind(this),$)}))}},l=new WeakMap,d=new WeakMap,t=new WeakSet,o=function(){var e;this.rolesTable=new j(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="roles-table"]'),{logger:this.logger}),this.rolesTable.onSelectedItemsChange((e=>{this.actions.setSelectedRolesIds(e.detail.value.map((({name:e})=>e)))}))},c})),je=t((e=>class extends(i(M,C,Se,ye,be,Ce,We,xe)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return a(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Pe=i((e=>class extends(je(e)){}))(HTMLElement);customElements.define("descope-role-management-widget",Pe);export{Pe as default};
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ declare const RoleManagementWidget: {
|
|
|
83
83
|
close(): void;
|
|
84
84
|
show(): void;
|
|
85
85
|
remove(): void;
|
|
86
|
-
"__#
|
|
86
|
+
"__#12028@#private": any;
|
|
87
87
|
logger: {
|
|
88
88
|
error(...data: any[]): void;
|
|
89
89
|
warn(...data: any[]): void;
|
|
@@ -97,7 +97,7 @@ declare const RoleManagementWidget: {
|
|
|
97
97
|
type: "success" | "error";
|
|
98
98
|
msg: string;
|
|
99
99
|
}[]) => void;
|
|
100
|
-
"__#
|
|
100
|
+
"__#12021@#isInit": boolean;
|
|
101
101
|
connectedCallback: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
|
|
102
102
|
accessKey: string;
|
|
103
103
|
readonly accessKeyLabel: string;
|
|
@@ -918,7 +918,7 @@ declare const RoleManagementWidget: {
|
|
|
918
918
|
tabIndex: number;
|
|
919
919
|
blur: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
|
|
920
920
|
focus: ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void) & ((options?: FocusOptions) => void);
|
|
921
|
-
"__#
|
|
921
|
+
"__#12032@#NotificationDriverWrapper": new (refOrRefFn: Element | (() => HTMLElement), config: {
|
|
922
922
|
logger: {
|
|
923
923
|
error(...data: any[]): void;
|
|
924
924
|
warn(...data: any[]): void;
|
|
@@ -931,7 +931,7 @@ declare const RoleManagementWidget: {
|
|
|
931
931
|
close(): void;
|
|
932
932
|
show(): void;
|
|
933
933
|
remove(): void;
|
|
934
|
-
"__#
|
|
934
|
+
"__#12028@#private": any;
|
|
935
935
|
logger: {
|
|
936
936
|
error(...data: any[]): void;
|
|
937
937
|
warn(...data: any[]): void;
|
|
@@ -956,7 +956,7 @@ declare const RoleManagementWidget: {
|
|
|
956
956
|
close(): void;
|
|
957
957
|
show(): void;
|
|
958
958
|
remove(): void;
|
|
959
|
-
"__#
|
|
959
|
+
"__#12028@#private": any;
|
|
960
960
|
logger: {
|
|
961
961
|
error(...data: any[]): void;
|
|
962
962
|
warn(...data: any[]): void;
|
|
@@ -966,21 +966,21 @@ declare const RoleManagementWidget: {
|
|
|
966
966
|
readonly asyncEle: Promise<Element>;
|
|
967
967
|
readonly ele: Element;
|
|
968
968
|
};
|
|
969
|
-
"__#
|
|
970
|
-
"__#
|
|
971
|
-
"__#
|
|
972
|
-
"__#
|
|
973
|
-
"__#
|
|
974
|
-
"__#
|
|
975
|
-
"__#
|
|
976
|
-
"__#
|
|
969
|
+
"__#12027@#errorCbsSym": symbol;
|
|
970
|
+
"__#12027@#loadCbsSym": symbol;
|
|
971
|
+
"__#12027@#getComponentsVersion": (() => Promise<any>) & (() => Promise<any>) & (() => Promise<any>) & (() => Promise<any>);
|
|
972
|
+
"__#12027@#exposeAlternateEvents": ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void);
|
|
973
|
+
"__#12027@#handleFallbackScript": ((errorCbs: ((error: string) => void)[], loadCbs: (() => void)[]) => Promise<void>) & ((errorCbs: ((error: string) => void)[], loadCbs: (() => void)[]) => Promise<void>) & ((errorCbs: ((error: string) => void)[], loadCbs: (() => void)[]) => Promise<void>) & ((errorCbs: ((error: string) => void)[], loadCbs: (() => void)[]) => Promise<void>);
|
|
974
|
+
"__#12027@#registerEvents": ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void);
|
|
975
|
+
"__#12027@#getDescopeUiLoadingScript": (() => Promise<HTMLElement>) & (() => Promise<HTMLElement>) & (() => Promise<HTMLElement>) & (() => Promise<HTMLElement>);
|
|
976
|
+
"__#12027@#descopeUi": Promise<any>;
|
|
977
977
|
readonly descopeUi: Promise<any>;
|
|
978
|
-
"__#
|
|
978
|
+
"__#12027@#loadDescopeUiComponent": ((componentName: string) => Promise<any>) & ((componentName: string) => Promise<any>) & ((componentName: string) => Promise<any>) & ((componentName: string) => Promise<any>);
|
|
979
979
|
loadDescopeUiComponents: ((templateOrComponentNames: string[] | HTMLTemplateElement) => Promise<any[]>) & ((templateOrComponentNames: string[] | HTMLTemplateElement) => Promise<any[]>) & ((templateOrComponentNames: string[] | HTMLTemplateElement) => Promise<any[]>) & ((templateOrComponentNames: string[] | HTMLTemplateElement) => Promise<any[]>);
|
|
980
|
-
"__#
|
|
980
|
+
"__#12027@#getDescopeUi": (() => Promise<unknown>) & (() => Promise<unknown>) & (() => Promise<unknown>) & (() => Promise<unknown>);
|
|
981
981
|
readonly config: any;
|
|
982
|
-
"__#
|
|
983
|
-
"__#
|
|
982
|
+
"__#12024@#_configResource": any;
|
|
983
|
+
"__#12024@#fetchConfig": (() => Promise<{
|
|
984
984
|
projectConfig: _descope_sdk_mixins.ProjectConfiguration;
|
|
985
985
|
executionContext: {
|
|
986
986
|
geo: string;
|
|
@@ -1029,17 +1029,17 @@ declare const RoleManagementWidget: {
|
|
|
1029
1029
|
headers: Record<string, string>;
|
|
1030
1030
|
}>);
|
|
1031
1031
|
readonly projectId: string;
|
|
1032
|
-
"__#
|
|
1033
|
-
"__#
|
|
1032
|
+
"__#12023@#handleError": ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void) & ((attrName: string, newValue: string) => void);
|
|
1033
|
+
"__#12022@#observeMappings": {};
|
|
1034
1034
|
observeAttribute: ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any) & ((attrName: string, onAttrChange: (attrName: string, value: string) => void) => () => any);
|
|
1035
1035
|
observeAttributes: ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void) & ((attrs: string[], cb: (attrName: string, value: string) => void) => () => void);
|
|
1036
|
-
"__#
|
|
1036
|
+
"__#12020@#logger": {
|
|
1037
1037
|
error(...data: any[]): void;
|
|
1038
1038
|
warn(...data: any[]): void;
|
|
1039
1039
|
info(...data: any[]): void;
|
|
1040
1040
|
debug(...data: any[]): void;
|
|
1041
1041
|
};
|
|
1042
|
-
"__#
|
|
1042
|
+
"__#12020@#wrapLogger": ((logger: Partial<{
|
|
1043
1043
|
error(...data: any[]): void;
|
|
1044
1044
|
warn(...data: any[]): void;
|
|
1045
1045
|
info(...data: any[]): void;
|
|
@@ -4928,7 +4928,7 @@ declare const RoleManagementWidget: {
|
|
|
4928
4928
|
"__#11@#updatePermissionsMultiSelect": () => Promise<void>;
|
|
4929
4929
|
"__#11@#updateModalData": () => void;
|
|
4930
4930
|
"__#11@#initEditRoleModal"(): Promise<void>;
|
|
4931
|
-
"__#
|
|
4931
|
+
"__#12031@#ModalDriverWrapper": new (refOrRefFn: Element | (() => HTMLElement), config: {
|
|
4932
4932
|
logger: {
|
|
4933
4933
|
error(...data: any[]): void;
|
|
4934
4934
|
warn(...data: any[]): void;
|
|
@@ -4937,7 +4937,7 @@ declare const RoleManagementWidget: {
|
|
|
4937
4937
|
};
|
|
4938
4938
|
}) => {
|
|
4939
4939
|
setContent(template: HTMLTemplateElement): void;
|
|
4940
|
-
"__#
|
|
4940
|
+
"__#12030@#private": any;
|
|
4941
4941
|
beforeOpen: () => void | Promise<void>;
|
|
4942
4942
|
afterClose: () => void;
|
|
4943
4943
|
nodeName: string;
|
|
@@ -4945,7 +4945,7 @@ declare const RoleManagementWidget: {
|
|
|
4945
4945
|
open(): Promise<void>;
|
|
4946
4946
|
reset(): void;
|
|
4947
4947
|
remove(): void;
|
|
4948
|
-
"__#
|
|
4948
|
+
"__#12028@#private": any;
|
|
4949
4949
|
logger: {
|
|
4950
4950
|
error(...data: any[]): void;
|
|
4951
4951
|
warn(...data: any[]): void;
|
|
@@ -4979,14 +4979,14 @@ declare const RoleManagementWidget: {
|
|
|
4979
4979
|
}[]) => void;
|
|
4980
4980
|
"__#15@#onColumnSortChange": (this: any, ...args: any[]) => void;
|
|
4981
4981
|
readonly theme: _descope_sdk_mixins.ThemeOptions;
|
|
4982
|
-
"__#
|
|
4983
|
-
"__#
|
|
4984
|
-
readonly "__#
|
|
4985
|
-
"__#
|
|
4986
|
-
"__#
|
|
4987
|
-
"__#
|
|
4988
|
-
"__#
|
|
4989
|
-
"__#
|
|
4982
|
+
"__#12033@#_themeResource": Promise<void | Record<string, any>>;
|
|
4983
|
+
"__#12033@#fetchTheme"(): Promise<Record<string, any>>;
|
|
4984
|
+
readonly "__#12033@#themeResource": Promise<void | Record<string, any>>;
|
|
4985
|
+
"__#12033@#loadGlobalStyle"(): Promise<void>;
|
|
4986
|
+
"__#12033@#loadComponentsStyle"(): Promise<void>;
|
|
4987
|
+
"__#12033@#loadFonts"(): Promise<void>;
|
|
4988
|
+
"__#12033@#applyTheme"(): Promise<void>;
|
|
4989
|
+
"__#12026@#debuggerEle": HTMLElement & {
|
|
4990
4990
|
updateData: (data: {
|
|
4991
4991
|
title: string;
|
|
4992
4992
|
description?: string;
|
|
@@ -4995,11 +4995,11 @@ declare const RoleManagementWidget: {
|
|
|
4995
4995
|
description?: string;
|
|
4996
4996
|
}[]) => void;
|
|
4997
4997
|
};
|
|
4998
|
-
"__#
|
|
4999
|
-
"__#
|
|
4998
|
+
"__#12026@#disableDebugger"(): void;
|
|
4999
|
+
"__#12026@#enableDebugger"(): Promise<void>;
|
|
5000
5000
|
readonly debug: boolean;
|
|
5001
|
-
"__#
|
|
5002
|
-
"__#
|
|
5001
|
+
"__#12026@#handleDebugMode"(): void;
|
|
5002
|
+
"__#12026@#updateDebuggerMessages"(title: string, description: string): void;
|
|
5003
5003
|
};
|
|
5004
5004
|
};
|
|
5005
5005
|
|