@descope/role-management-widget 0.1.2 → 0.1.3
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 +3 -3
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.3
|
|
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 l,__classPrivateFieldSet as r,__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,F=e=>e.notifications,I=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"})})))),D=P(N,$,((e,t)=>t.filter((t=>e.includes(t.name))))),q=P(N,(e=>!!e.length)),B=P(N,(e=>1===e.length)),T=P(D,(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)})),le=({text:e,sort:t},i)=>a(void 0,void 0,void 0,(function*(){return new Promise((o=>{const s=[];for(let e=1;e<9;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()))))}))})),re=({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:l}={})=>a(void 0,void 0,void 0,(function*(){if(i)return le({page:o,limit:s,text:n,sort:l},t);const a=yield e.post(se.search,{limit:s,page:o,text:n,sort:l},{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 re({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:l})=>a(void 0,void 0,void 0,(function*(){if(i)return de({name:o,newName:s,description:n,permissionNames:l},t);const a=yield e.post(se.update,{name:o,newName:s,description:n,permissionNames:l,tenantId:t},{queryParams:{tenant:t}});yield ae(a);const r=yield a.json();return r.oldName=o,r}))}),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 l(this,o,"f")||l(this,t,"m",s).call(this),l(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"],(()=>{l(this,o,"f")&&l(this,t,"m",s).call(this)}))}))}},o=new WeakMap,t=new WeakSet,s=function(){this.logger.debug("creating an sdk instance"),r(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([l(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 l(this,s,"f").setData(null===(e=I(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),l(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))})))),r(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"),l(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),l(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 l(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=D(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,r;return r=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),l(this,t,"m",o).call(this),this.subscribe(l(this,n,"f").bind(this),q)}))}},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()}))},r})),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 l(this,s,"f").setData(null===(e=I(this.state))||void 0===e?void 0:e.map((({name:e})=>({value:e,label:e}))))})))),g.set(this,(()=>{var e;const t=null===(e=D(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 l(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=D(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"))),l(this,t,"m",n).call(this),l(this,t,"m",c).call(this),r(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 l(this,u,"f").call(this),l(this,g,"f").call(this)}))}))},m})),Ce=t((e=>{var t,o,n,r;return r=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),l(this,t,"m",o).call(this),this.subscribe(l(this,n,"f").bind(this),B)}))}},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()}))},r})),We=t((e=>{var t,o,s,r;return r=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),l(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(l(this,o,"f"))},r}));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="white"/>\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="#FFDFDD"/>\n</g>\n</svg>\n',"image/svg+xml").firstChild},xe=t((e=>{var t,o,n,r,d;return d=class extends(i(h,me,b,m)(e)){constructor(){super(...arguments),t.add(this),r.set(this,s((e=>{e.length&&(e.forEach((({type:e,msg:i})=>{const s=l(this,t,"m",n).call(this,e);s.setContent(l(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(l(this,r,"f").bind(this),F)}))}},r=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="white"/>\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,r,d,c;return c=class extends(i(me,h,Re)(e)){constructor(){super(...arguments),t.add(this),r.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),l(this,t,"m",o).call(this),this.rolesTable.columns.forEach((e=>{e.onSortDirectionChange((e=>{l(this,d,"f").call(this,e.target,e.detail)}))})),l(this,r,"f").call(this,$(this.state)),this.subscribe(l(this,r,"f").bind(this),$)}))}},r=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
|
+
"__#11874@#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
|
+
"__#11867@#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);
|
|
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
|
+
"__#11877@#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
|
+
"__#11874@#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
|
+
"__#11874@#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
|
+
"__#11873@#errorCbsSym": symbol;
|
|
970
|
+
"__#11873@#loadCbsSym": symbol;
|
|
971
|
+
"__#11873@#getComponentsVersion": (() => Promise<any>) & (() => Promise<any>) & (() => Promise<any>) & (() => Promise<any>);
|
|
972
|
+
"__#11873@#exposeAlternateEvents": ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void);
|
|
973
|
+
"__#11873@#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
|
+
"__#11873@#registerEvents": ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void);
|
|
975
|
+
"__#11873@#getDescopeUiLoadingScript": (() => Promise<HTMLElement>) & (() => Promise<HTMLElement>) & (() => Promise<HTMLElement>) & (() => Promise<HTMLElement>);
|
|
976
|
+
"__#11873@#descopeUi": Promise<any>;
|
|
977
977
|
readonly descopeUi: Promise<any>;
|
|
978
|
-
"__#
|
|
978
|
+
"__#11873@#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
|
+
"__#11873@#getDescopeUi": (() => Promise<unknown>) & (() => Promise<unknown>) & (() => Promise<unknown>) & (() => Promise<unknown>);
|
|
981
981
|
readonly config: any;
|
|
982
|
-
"__#
|
|
983
|
-
"__#
|
|
982
|
+
"__#11870@#_configResource": any;
|
|
983
|
+
"__#11870@#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
|
+
"__#11869@#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
|
+
"__#11868@#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);
|
|
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);
|
|
1036
|
-
"__#
|
|
1036
|
+
"__#11866@#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
|
+
"__#11866@#wrapLogger": ((logger: Partial<{
|
|
1043
1043
|
error(...data: any[]): void;
|
|
1044
1044
|
warn(...data: any[]): void;
|
|
1045
1045
|
info(...data: any[]): void;
|
|
@@ -4918,7 +4918,7 @@ declare const RoleManagementWidget: {
|
|
|
4918
4918
|
"__#10@#updatePermissionsMultiSelect": () => Promise<void>;
|
|
4919
4919
|
"__#10@#updateModalData": () => void;
|
|
4920
4920
|
"__#10@#initEditRoleModal"(): Promise<void>;
|
|
4921
|
-
"__#
|
|
4921
|
+
"__#11876@#ModalDriverWrapper": new (refOrRefFn: Element | (() => HTMLElement), config: {
|
|
4922
4922
|
logger: {
|
|
4923
4923
|
error(...data: any[]): void;
|
|
4924
4924
|
warn(...data: any[]): void;
|
|
@@ -4927,7 +4927,7 @@ declare const RoleManagementWidget: {
|
|
|
4927
4927
|
};
|
|
4928
4928
|
}) => {
|
|
4929
4929
|
setContent(template: HTMLTemplateElement): void;
|
|
4930
|
-
"__#
|
|
4930
|
+
"__#11875@#private": any;
|
|
4931
4931
|
beforeOpen: () => void | Promise<void>;
|
|
4932
4932
|
afterClose: () => void;
|
|
4933
4933
|
nodeName: string;
|
|
@@ -4935,7 +4935,7 @@ declare const RoleManagementWidget: {
|
|
|
4935
4935
|
open(): Promise<void>;
|
|
4936
4936
|
reset(): void;
|
|
4937
4937
|
remove(): void;
|
|
4938
|
-
"__#
|
|
4938
|
+
"__#11874@#private": any;
|
|
4939
4939
|
logger: {
|
|
4940
4940
|
error(...data: any[]): void;
|
|
4941
4941
|
warn(...data: any[]): void;
|
|
@@ -4969,14 +4969,14 @@ declare const RoleManagementWidget: {
|
|
|
4969
4969
|
}[]) => void;
|
|
4970
4970
|
"__#14@#onColumnSortChange": (this: any, ...args: any[]) => void;
|
|
4971
4971
|
readonly theme: _descope_sdk_mixins.ThemeOptions;
|
|
4972
|
-
"__#
|
|
4973
|
-
"__#
|
|
4974
|
-
readonly "__#
|
|
4975
|
-
"__#
|
|
4976
|
-
"__#
|
|
4977
|
-
"__#
|
|
4978
|
-
"__#
|
|
4979
|
-
"__#
|
|
4972
|
+
"__#11878@#_themeResource": Promise<void | Record<string, any>>;
|
|
4973
|
+
"__#11878@#fetchTheme"(): Promise<Record<string, any>>;
|
|
4974
|
+
readonly "__#11878@#themeResource": Promise<void | Record<string, any>>;
|
|
4975
|
+
"__#11878@#loadGlobalStyle"(): Promise<void>;
|
|
4976
|
+
"__#11878@#loadComponentsStyle"(): Promise<void>;
|
|
4977
|
+
"__#11878@#loadFonts"(): Promise<void>;
|
|
4978
|
+
"__#11878@#applyTheme"(): Promise<void>;
|
|
4979
|
+
"__#11872@#debuggerEle": HTMLElement & {
|
|
4980
4980
|
updateData: (data: {
|
|
4981
4981
|
title: string;
|
|
4982
4982
|
description?: string;
|
|
@@ -4985,11 +4985,11 @@ declare const RoleManagementWidget: {
|
|
|
4985
4985
|
description?: string;
|
|
4986
4986
|
}[]) => void;
|
|
4987
4987
|
};
|
|
4988
|
-
"__#
|
|
4989
|
-
"__#
|
|
4988
|
+
"__#11872@#disableDebugger"(): void;
|
|
4989
|
+
"__#11872@#enableDebugger"(): Promise<void>;
|
|
4990
4990
|
readonly debug: boolean;
|
|
4991
|
-
"__#
|
|
4992
|
-
"__#
|
|
4991
|
+
"__#11872@#handleDebugMode"(): void;
|
|
4992
|
+
"__#11872@#updateDebuggerMessages"(title: string, description: string): void;
|
|
4993
4993
|
};
|
|
4994
4994
|
};
|
|
4995
4995
|
|