@descope/audit-management-widget
Advanced tools
Comparing version 0.1.87 to 0.1.88
/** | ||
* @descope/audit-management-widget v0.1.87 | ||
* @descope/audit-management-widget v0.1.88 | ||
*/ | ||
import{createSingletonMixin as e,compose as t,createTemplate as s,debounce as i,withMemCache as o}from"@descope/sdk-helpers";import{__rest as r,__awaiter as a,__classPrivateFieldGet as n,__classPrivateFieldSet as d}from"tslib";import{projectIdMixin as c,observeAttributesMixin as l,loggerMixin as u,baseUrlMixin as g,createValidateAttributesMixin as h,createStateManagementMixin as m,initLifecycleMixin as p,staticResourcesMixin as v,descopeUiMixin as f,initElementMixin as w,debuggerMixin as b,themeMixin as y}from"@descope/sdk-mixins";import{TextFieldDriver as _,SingleSelectDriver as j,GridDriver as k}from"@descope/sdk-component-drivers";import{createAsyncThunk as x}from"@reduxjs/toolkit";import{createSelector as C}from"reselect";import I from"@descope/web-js-sdk";const R=(e,t)=>t?{[e]:t}:{},L=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},A=e=>e.selectedAuditId,O=C((e=>e.auditList.data),(e=>e.map((e=>{const t=e||{},{occurred:s,ID:i,type:o}=t,a=t.data,n=void 0===a?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:""}:a,{saml_request:d,saml_response:c,saml_generated_user:l,saml_generated_roles:u,oidc_response:g,oidc_generated_user:h}=n,m=r(n,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user"]),p=r(t,["occurred","ID","type","data"]);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},p),{data:m}),R("type",(v=o)&&v[0].toUpperCase()+v.slice(1))),R("saml_request",d)),R("saml_response",c)),R("saml_generated_user",L(l))),R("saml_generated_roles",L(u))),R("oidc_response",L(g))),R("oidc_generated_user",L(h))),{occurredFormatted:s?new Date(Number(s)||0).toLocaleString():"N/A"});var v}))));C(A,O,((e,t)=>t.find((t=>e===t.id)))),C(A,(e=>!!e));const W=x("audit/search",((e,{extra:{api:t},getState:s})=>{const i=s().searchParams;return t.audit.search(Object.assign(Object.assign({},i),e))})),D=(e=>(...t)=>s=>{s.addCase(e.pending,((e,s)=>{t.forEach((({onPending:t})=>{null==t||t(e,s)}))})),s.addCase(e.fulfilled,((e,s)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,s)}))})),s.addCase(e.rejected,((e,s)=>{t.forEach((({onRejected:t})=>{null==t||t(e,s)}))}))})(W)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(S=e=>e.auditList,{onFulfilled:e=>{S(e).loading=!1},onPending:e=>{S(e).loading=!0,S(e).error=null},onRejected:(e,t)=>{S(e).loading=!1,S(e).error=t.error}}));var S;const $={action:W,reducer:D},P={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""},M={search:"/v1/mgmt/audit/search"},q=e=>a(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((s=>{const i=[];for(let e=1;e<9;e+=1)i.push({id:`Audit ${e}`,action:`Action ${e}`,actorId:`Actor ${e}`,type:"info",method:`Method ${e}`,userId:`User ${e}`,device:`Device ${e}`,geo:`Geo ${e}`,remoteAddress:`127.0.0.${e}`,externalIds:[`Login ID ${e}`],occurred:(new Date).getTime()});t.forEach((e=>{i.sort(((t,s)=>{var i,o;return e.desc?null===(o=s[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(i=t[e.field])||void 0===i?void 0:i.localeCompare(s[e.field])}))})),s(i.filter((t=>t.id.toLowerCase().includes(e.toLowerCase())||t.action.toLowerCase().includes(e.toLowerCase())||t.type.toLowerCase().includes(e.toLowerCase())||t.device.toLowerCase().includes(e.toLowerCase())||t.method.toLowerCase().includes(e.toLowerCase())||t.geo.toLowerCase().includes(e.toLowerCase())||t.remoteAddress.toLowerCase().includes(e.toLowerCase())||t.externalIds.includes(e.toLowerCase())||t.userId.toLowerCase().includes(e.toLowerCase()))))}))})),E=({httpClient:e,tenant:t,mock:s})=>({search:(...i)=>a(void 0,[...i],void 0,(function*({page:i,limit:o=1e4,text:r,sort:n,from:d}={}){if(s)return q({page:i,limit:o,text:r,sort:n},t);const c=yield e.post(M.search,{limit:o,page:i,text:r,sort:n,from:d},{queryParams:{tenant:t}});yield(e=>a(void 0,void 0,void 0,(function*(){const t=yield e.text(),s=JSON.parse(t);if(!e.ok){const t=`${s.errorDescription}${s.errorMessage?`: ${s.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(s),e.text=()=>Promise.resolve(t)})))(c);return(yield c.json()).audits}))}),T=e((e=>{var s,i,o,r;const m=t(c,l,u,g,h({tenant:h.missingAttrValidator}))(e);return r=class extends m{constructor(){super(...arguments),s.add(this),i.set(this,void 0)}get tenant(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return n(this,i,"f")||n(this,s,"m",o).call(this),n(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{n(this,i,"f")&&n(this,s,"m",o).call(this)}))}))}},i=new WeakMap,s=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),d(this,i,((e,t,s,i)=>{const o=I(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.1.87"}}));return{audit:E({httpClient:o.httpClient,tenant:t,mock:s})}})({projectId:this.projectId,baseUrl:this.baseUrl},this.tenant,"true"===this.mock,this.widgetId),"f")},r})),H=e((e=>{const s=t(m({name:"widget",initialState:P,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{$.reducer(e)},asyncActions:{searchAudit:$.action}}),p,u,T)(e);return class extends s{constructor(...e){super(...e),this.state=P,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),N=e((e=>{const s=t(v,h({"widget-id":h.missingAttrValidator}))(e);return class extends s{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return a(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`audit-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),U=e((e=>{var i,o,r;return r=class extends(t(u,p,f,w,N,H)(e)){constructor(){super(...arguments),i.add(this)}onWidgetRootReady(){return a(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),yield Promise.all([n(this,i,"m",o).call(this)]),this.onWidgetRootReady()}))}},i=new WeakSet,o=function(){return a(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},r})),F=e((e=>{var s,o,r,d,c;return c=class extends(t(u,U,H)(e)){constructor(){super(...arguments),s.add(this),o.set(this,i((()=>{const e=this.rangeInput.value,t=new Date;let s;switch(e){case"minuets15":s=t.setMinutes(t.getMinutes()-15);break;case"hour":s=t.setHours(t.getHours()-1);break;case"hour6":s=t.setHours(t.getHours()-6);break;case"day":default:s=t.setDate(t.getDate()-1);break;case"day3":s=t.setDate(t.getDate()-3);break;case"week":s=t.setDate(t.getDate()-7);break;case"week2":s=t.setDate(t.getDate()-14);break;case"month":s=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(s).getTime())})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),n(this,s,"m",r).call(this),n(this,s,"m",d).call(this)}))}},o=new WeakMap,s=new WeakSet,r=function(){var e;this.searchInput=new _(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(n(this,o,"f"))},d=function(){var e;this.rangeInput=new j(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(n(this,o,"f"))},c})),J=e((e=>{var s,i,r,d;return d=class extends(t(H,u,U)(e)){constructor(){super(...arguments),s.add(this),r.set(this,o((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),n(this,s,"m",i).call(this),n(this,r,"f").call(this,O(this.state)),this.subscribe(n(this,r,"f").bind(this),O)}))}},r=new WeakMap,s=new WeakSet,i=function(){var e;this.auditTable=new k(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="audit-table"]'),{logger:this.logger}),this.auditTable.onSelectedItemsChange((e=>{this.actions.setSelectedAuditId(e.detail.value.map((({id:e})=>e)))}))},d})),V=e((e=>class extends(t(b,y,J,F)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),G=t((e=>class extends(V(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",G);export{G as default}; | ||
import{createSingletonMixin as e,compose as t,createTemplate as s,debounce as i,withMemCache as o}from"@descope/sdk-helpers";import{__rest as r,__awaiter as a,__classPrivateFieldGet as n,__classPrivateFieldSet as d}from"tslib";import{projectIdMixin as c,observeAttributesMixin as l,loggerMixin as u,baseUrlMixin as g,createValidateAttributesMixin as h,createStateManagementMixin as m,initLifecycleMixin as p,staticResourcesMixin as v,descopeUiMixin as f,initElementMixin as w,debuggerMixin as b,themeMixin as y}from"@descope/sdk-mixins";import{TextFieldDriver as _,SingleSelectDriver as j,GridDriver as k}from"@descope/sdk-component-drivers";import{createAsyncThunk as x}from"@reduxjs/toolkit";import{createSelector as C}from"reselect";import I from"@descope/web-js-sdk";const R=(e,t)=>t?{[e]:t}:{},L=e=>{if(!e)return;const t=JSON.parse(e);return Array.isArray(t)&&0===t.length?void 0:t},A=e=>e.selectedAuditId,O=C((e=>e.auditList.data),(e=>e.map((e=>{const t=e||{},{occurred:s,ID:i,type:o}=t,a=t.data,n=void 0===a?{saml_request:"",saml_response:"",saml_generated_user:"",saml_generated_roles:"",oidc_response:"",oidc_generated_user:""}:a,{saml_request:d,saml_response:c,saml_generated_user:l,saml_generated_roles:u,oidc_response:g,oidc_generated_user:h}=n,m=r(n,["saml_request","saml_response","saml_generated_user","saml_generated_roles","oidc_response","oidc_generated_user"]),p=r(t,["occurred","ID","type","data"]);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},p),{data:m}),R("type",(v=o)&&v[0].toUpperCase()+v.slice(1))),R("saml_request",d)),R("saml_response",c)),R("saml_generated_user",L(l))),R("saml_generated_roles",L(u))),R("oidc_response",L(g))),R("oidc_generated_user",L(h))),{occurredFormatted:s?new Date(Number(s)||0).toLocaleString():"N/A"});var v}))));C(A,O,((e,t)=>t.find((t=>e===t.id)))),C(A,(e=>!!e));const W=x("audit/search",((e,{extra:{api:t},getState:s})=>{const i=s().searchParams;return t.audit.search(Object.assign(Object.assign({},i),e))})),D=(e=>(...t)=>s=>{s.addCase(e.pending,((e,s)=>{t.forEach((({onPending:t})=>{null==t||t(e,s)}))})),s.addCase(e.fulfilled,((e,s)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,s)}))})),s.addCase(e.rejected,((e,s)=>{t.forEach((({onRejected:t})=>{null==t||t(e,s)}))}))})(W)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(S=e=>e.auditList,{onFulfilled:e=>{S(e).loading=!1},onPending:e=>{S(e).loading=!0,S(e).error=null},onRejected:(e,t)=>{S(e).loading=!1,S(e).error=t.error}}));var S;const $={action:W,reducer:D},P={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""},M={search:"/v1/mgmt/audit/search"},q=e=>a(void 0,[e],void 0,(function*({text:e,sort:t}){return new Promise((s=>{const i=[];for(let e=1;e<9;e+=1)i.push({id:`Audit ${e}`,action:`Action ${e}`,actorId:`Actor ${e}`,type:"info",method:`Method ${e}`,userId:`User ${e}`,device:`Device ${e}`,geo:`Geo ${e}`,remoteAddress:`127.0.0.${e}`,externalIds:[`Login ID ${e}`],occurred:(new Date).getTime()});t.forEach((e=>{i.sort(((t,s)=>{var i,o;return e.desc?null===(o=s[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(i=t[e.field])||void 0===i?void 0:i.localeCompare(s[e.field])}))})),s(i.filter((t=>t.id.toLowerCase().includes(e.toLowerCase())||t.action.toLowerCase().includes(e.toLowerCase())||t.type.toLowerCase().includes(e.toLowerCase())||t.device.toLowerCase().includes(e.toLowerCase())||t.method.toLowerCase().includes(e.toLowerCase())||t.geo.toLowerCase().includes(e.toLowerCase())||t.remoteAddress.toLowerCase().includes(e.toLowerCase())||t.externalIds.includes(e.toLowerCase())||t.userId.toLowerCase().includes(e.toLowerCase()))))}))})),E=({httpClient:e,tenant:t,mock:s})=>({search:(...i)=>a(void 0,[...i],void 0,(function*({page:i,limit:o=1e4,text:r,sort:n,from:d}={}){if(s)return q({page:i,limit:o,text:r,sort:n},t);const c=yield e.post(M.search,{limit:o,page:i,text:r,sort:n,from:d},{queryParams:{tenant:t}});yield(e=>a(void 0,void 0,void 0,(function*(){const t=yield e.text(),s=JSON.parse(t);if(!e.ok){const t=`${s.errorDescription}${s.errorMessage?`: ${s.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(s),e.text=()=>Promise.resolve(t)})))(c);return(yield c.json()).audits}))}),T=e((e=>{var s,i,o,r;const m=t(c,l,u,g,h({tenant:h.missingAttrValidator}))(e);return r=class extends m{constructor(){super(...arguments),s.add(this),i.set(this,void 0)}get tenant(){return this.getAttribute("tenant")}get widgetId(){return this.getAttribute("widget-id")}get mock(){return this.getAttribute("mock")}get api(){return n(this,i,"f")||n(this,s,"m",o).call(this),n(this,i,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{n(this,i,"f")&&n(this,s,"m",o).call(this)}))}))}},i=new WeakMap,s=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),d(this,i,((e,t,s,i)=>{const o=I(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"audit-management-widget","x-descope-widget-id":i,"x-descope-widget-version":"0.1.88"}}));return{audit:E({httpClient:o.httpClient,tenant:t,mock:s})}})({projectId:this.projectId,baseUrl:this.baseUrl},this.tenant,"true"===this.mock,this.widgetId),"f")},r})),H=e((e=>{const s=t(m({name:"widget",initialState:P,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{$.reducer(e)},asyncActions:{searchAudit:$.action}}),p,u,T)(e);return class extends s{constructor(...e){super(...e),this.state=P,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),N=e((e=>{const s=t(v,h({"widget-id":h.missingAttrValidator}))(e);return class extends s{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return a(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`audit-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),U=e((e=>{var i,o,r;return r=class extends(t(u,p,f,w,N,H)(e)){constructor(){super(...arguments),i.add(this)}onWidgetRootReady(){return a(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this),yield Promise.all([n(this,i,"m",o).call(this)]),this.onWidgetRootReady()}))}},i=new WeakSet,o=function(){return a(this,void 0,void 0,(function*(){const e=s(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},r})),F=e((e=>{var s,o,r,d,c;return c=class extends(t(u,U,H)(e)){constructor(){super(...arguments),s.add(this),o.set(this,i((()=>{const e=this.rangeInput.value,t=new Date;let s;switch(e){case"minuets15":s=t.setMinutes(t.getMinutes()-15);break;case"hour":s=t.setHours(t.getHours()-1);break;case"hour6":s=t.setHours(t.getHours()-6);break;case"day":default:s=t.setDate(t.getDate()-1);break;case"day3":s=t.setDate(t.getDate()-3);break;case"week":s=t.setDate(t.getDate()-7);break;case"week2":s=t.setDate(t.getDate()-14);break;case"month":s=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(s).getTime())})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),n(this,s,"m",r).call(this),n(this,s,"m",d).call(this)}))}},o=new WeakMap,s=new WeakSet,r=function(){var e;this.searchInput=new _(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(n(this,o,"f"))},d=function(){var e;this.rangeInput=new j(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(n(this,o,"f"))},c})),J=e((e=>{var s,i,r,d;return d=class extends(t(H,u,U)(e)){constructor(){super(...arguments),s.add(this),r.set(this,o((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),n(this,s,"m",i).call(this),n(this,r,"f").call(this,O(this.state)),this.subscribe(n(this,r,"f").bind(this),O)}))}},r=new WeakMap,s=new WeakSet,i=function(){var e;this.auditTable=new k(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="audit-table"]'),{logger:this.logger}),this.auditTable.onSelectedItemsChange((e=>{this.actions.setSelectedAuditId(e.detail.value.map((({id:e})=>e)))}))},d})),V=e((e=>class extends(t(b,y,J,F)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return a(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),G=t((e=>class extends(V(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",G);export{G as default}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@descope/audit-management-widget", | ||
"version": "0.1.87", | ||
"version": "0.1.88", | ||
"author": "Descope Team <info@descope.com>", | ||
@@ -79,3 +79,3 @@ "homepage": "https://github.com/descope/descope-js", | ||
"immer": "^10.0.3", | ||
"@descope/web-js-sdk": "1.16.6", | ||
"@descope/web-js-sdk": "1.17.0", | ||
"@descope/sdk-helpers": "0.1.60", | ||
@@ -82,0 +82,0 @@ "@descope/sdk-mixins": "0.3.2", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1272078
+ Added@descope/core-js-sdk@2.26.0(transitive)
+ Added@descope/web-js-sdk@1.17.0(transitive)
- Removed@descope/core-js-sdk@2.25.1(transitive)
- Removed@descope/web-js-sdk@1.16.6(transitive)
Updated@descope/web-js-sdk@1.17.0