@descope/audit-management-widget 0.1.5 → 0.1.7
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 +29 -29
- 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/audit-management-widget v0.1.
|
|
3
|
+
* @descope/audit-management-widget v0.1.7
|
|
4
4
|
*/
|
|
5
5
|
import{createSingletonMixin as e,compose as t,createTemplate as i,debounce as s,withMemCache as o}from"@descope/sdk-helpers";import{__awaiter as r,__classPrivateFieldGet as a,__classPrivateFieldSet as n}from"tslib";import{projectIdMixin as d,observeAttributesMixin as c,loggerMixin as l,createValidateAttributesMixin as u,createStateManagementMixin as h,initLifecycleMixin as g,staticResourcesMixin as m,descopeUiMixin as v,initElementMixin as p,debuggerMixin as f,themeMixin as w}from"@descope/sdk-mixins";import{TextFieldDriver as b,SingleSelectDriver as y,GridDriver as k}from"@descope/sdk-component-drivers";import{createAsyncThunk as R}from"@reduxjs/toolkit";import{createSelector as C}from"reselect";import x from"@descope/web-js-sdk";const I=e=>e.selectedAuditId,L=C((e=>e.auditList.data),(e=>e.map((e=>Object.assign(Object.assign({},e),{occurredFormatted:(null==e?void 0:e.occurred)?new Date(Number(null==e?void 0:e.occurred)||0).toLocaleString():"N/A"})))));C(I,L,((e,t)=>t.find((t=>e===t.id)))),C(I,(e=>!!e));const j=R("audit/search",((e,{extra:{api:t},getState:i})=>{const s=i().searchParams;return t.audit.search(Object.assign(Object.assign({},s),e))})),A=(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)}))}))})(j)({onPending:(e,t)=>{e.searchParams=Object.assign(Object.assign({},e.searchParams),t.meta.arg)},onFulfilled:(e,t)=>{e.auditList.data=t.payload}},(W=e=>e.auditList,{onFulfilled:e=>{W(e).loading=!1},onPending:e=>{W(e).loading=!0,W(e).error=null},onRejected:(e,t)=>{W(e).loading=!1,W(e).error=t.error}}));var W;const D={action:j,reducer:A},S={auditList:{data:[],loading:!1,error:null},searchParams:{text:"",sort:[]},selectedAuditId:""},$={search:"/v1/mgmt/audit/search"},O=({text:e,sort:t})=>r(void 0,void 0,void 0,(function*(){return new Promise((i=>{const s=[];for(let e=1;e<9;e+=1)s.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=>{s.sort(((t,i)=>{var s,o;return e.desc?null===(o=i[e.field])||void 0===o?void 0:o.localeCompare(t[e.field]):null===(s=t[e.field])||void 0===s?void 0:s.localeCompare(i[e.field])}))})),i(s.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()))))}))})),P=({httpClient:e,tenant:t,mock:i})=>({search:({page:s,limit:o=1e4,text:a,sort:n,from:d}={})=>r(void 0,void 0,void 0,(function*(){if(i)return O({page:s,limit:o,text:a,sort:n},t);const c=yield e.post($.search,{limit:o,page:s,text:a,sort:n,from:d},{queryParams:{tenant:t}});yield(e=>r(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)})))(c);return(yield c.json()).audits}))}),M=e((e=>{var i,s,o,h;const g=t(d,c,l,u({tenant:u.missingAttrValidator}))(e);return h=class extends g{constructor(){super(...arguments),i.add(this),s.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 a(this,s,"f")||a(this,i,"m",o).call(this),a(this,s,"f")}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant"],(()=>{a(this,s,"f")&&a(this,i,"m",o).call(this)}))}))}},s=new WeakMap,i=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),n(this,s,((e,t,i)=>{const s=x(Object.assign(Object.assign({},e),{persistTokens:!0}));return{audit:P({httpClient:s.httpClient,tenant:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl},this.tenant,"true"===this.mock),"f")},h})),E=e((e=>{const i=t(h({name:"widget",initialState:S,reducers:{setSelectedAuditId:(e,{payload:t})=>{e.selectedAuditId=t}},extraReducers:e=>{D.reducer(e)},asyncActions:{searchAudit:D.action}}),g,l,M)(e);return class extends i{constructor(...e){super(...e),this.state=S,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),T=e((e=>{const i=t(m,u({"widget-id":u.missingAttrValidator}))(e);return class extends i{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(e){return r(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`audit-management-widget/${this.widgetId}/${e}`,"text")).body}))}}})),H=e((e=>{var s,o,n;return n=class extends(t(l,g,v,p,T,E)(e)){constructor(){super(...arguments),s.add(this)}onWidgetRootReady(){return r(this,void 0,void 0,(function*(){}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this),yield Promise.all([a(this,s,"m",o).call(this)]),this.onWidgetRootReady()}))}},s=new WeakSet,o=function(){return r(this,void 0,void 0,(function*(){const e=i(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},n})),U=e((e=>{var i,o,n,d,c;return c=class extends(t(l,H,E)(e)){constructor(){super(...arguments),i.add(this),o.set(this,s((()=>{const e=this.rangeInput.value,t=new Date;let i;switch(e){case"minuets15":i=t.setMinutes(t.getMinutes()-15);break;case"hour":i=t.setHours(t.getHours()-1);break;case"hour6":i=t.setHours(t.getHours()-6);break;case"day":default:i=t.setDate(t.getDate()-1);break;case"day3":i=t.setDate(t.getDate()-3);break;case"week":i=t.setDate(t.getDate()-7);break;case"week2":i=t.setDate(t.getDate()-14);break;case"month":i=t.setMonth(t.getMonth()-1)}this.actions.searchAudit({text:this.searchInput.value,from:Math.floor(new Date(i).getTime())})})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),a(this,i,"m",n).call(this),a(this,i,"m",d).call(this)}))}},o=new WeakMap,i=new WeakSet,n=function(){var e;this.searchInput=new b(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="search-input"]'),{logger:this.logger}),this.searchInput.onInput(a(this,o,"f"))},d=function(){var e;this.rangeInput=new y(null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('[data-id="range-input"]'),{logger:this.logger}),this.rangeInput.onInput(a(this,o,"f"))},c})),q=e((e=>{var i,s,n,d;return d=class extends(t(E,l,H)(e)){constructor(){super(...arguments),i.add(this),n.set(this,o((e=>{this.auditTable.data=e})))}onWidgetRootReady(){const e=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.onWidgetRootReady)||void 0===t?void 0:t.call(this),a(this,i,"m",s).call(this),a(this,n,"f").call(this,L(this.state)),this.subscribe(a(this,n,"f").bind(this),L)}))}},n=new WeakMap,i=new WeakSet,s=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})),F=e((e=>class extends(t(f,w,q,U)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});var t;return r(this,void 0,void 0,(function*(){yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),N=t((e=>class extends(F(e)){}))(HTMLElement);customElements.define("descope-audit-management-widget",N);export{N as default};
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -67,11 +67,11 @@ declare const AuditManagementWidget: {
|
|
|
67
67
|
search: (config: SearchAuditConfig) => Promise<Audit[]>;
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
-
"__#
|
|
71
|
-
"__#
|
|
70
|
+
"__#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);
|
|
71
|
+
"__#12022@#observeMappings": {};
|
|
72
72
|
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);
|
|
73
73
|
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);
|
|
74
|
-
"__#
|
|
74
|
+
"__#12021@#isInit": boolean;
|
|
75
75
|
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);
|
|
76
76
|
accessKey: string;
|
|
77
77
|
readonly accessKeyLabel: string;
|
|
@@ -787,13 +787,13 @@ declare const AuditManagementWidget: {
|
|
|
787
787
|
tabIndex: number;
|
|
788
788
|
blur: (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void) & (() => void);
|
|
789
789
|
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);
|
|
790
|
-
"__#
|
|
790
|
+
"__#12020@#logger": {
|
|
791
791
|
error(...data: any[]): void;
|
|
792
792
|
warn(...data: any[]): void;
|
|
793
793
|
info(...data: any[]): void;
|
|
794
794
|
debug(...data: any[]): void;
|
|
795
795
|
};
|
|
796
|
-
"__#
|
|
796
|
+
"__#12020@#wrapLogger": ((logger: Partial<{
|
|
797
797
|
error(...data: any[]): void;
|
|
798
798
|
warn(...data: any[]): void;
|
|
799
799
|
info(...data: any[]): void;
|
|
@@ -1343,21 +1343,21 @@ declare const AuditManagementWidget: {
|
|
|
1343
1343
|
}>);
|
|
1344
1344
|
contentRootElement: HTMLElement;
|
|
1345
1345
|
rootElement: HTMLElement;
|
|
1346
|
-
"__#
|
|
1347
|
-
"__#
|
|
1348
|
-
"__#
|
|
1349
|
-
"__#
|
|
1350
|
-
"__#
|
|
1351
|
-
"__#
|
|
1352
|
-
"__#
|
|
1353
|
-
"__#
|
|
1346
|
+
"__#12027@#errorCbsSym": symbol;
|
|
1347
|
+
"__#12027@#loadCbsSym": symbol;
|
|
1348
|
+
"__#12027@#getComponentsVersion": (() => Promise<any>) & (() => Promise<any>);
|
|
1349
|
+
"__#12027@#exposeAlternateEvents": ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void);
|
|
1350
|
+
"__#12027@#handleFallbackScript": ((errorCbs: ((error: string) => void)[], loadCbs: (() => void)[]) => Promise<void>) & ((errorCbs: ((error: string) => void)[], loadCbs: (() => void)[]) => Promise<void>);
|
|
1351
|
+
"__#12027@#registerEvents": ((scriptEle: HTMLScriptElement) => void) & ((scriptEle: HTMLScriptElement) => void);
|
|
1352
|
+
"__#12027@#getDescopeUiLoadingScript": (() => Promise<HTMLElement>) & (() => Promise<HTMLElement>);
|
|
1353
|
+
"__#12027@#descopeUi": Promise<any>;
|
|
1354
1354
|
readonly descopeUi: Promise<any>;
|
|
1355
|
-
"__#
|
|
1355
|
+
"__#12027@#loadDescopeUiComponent": ((componentName: string) => Promise<any>) & ((componentName: string) => Promise<any>);
|
|
1356
1356
|
loadDescopeUiComponents: ((templateOrComponentNames: string[] | HTMLTemplateElement) => Promise<any[]>) & ((templateOrComponentNames: string[] | HTMLTemplateElement) => Promise<any[]>);
|
|
1357
|
-
"__#
|
|
1357
|
+
"__#12027@#getDescopeUi": (() => Promise<unknown>) & (() => Promise<unknown>);
|
|
1358
1358
|
readonly config: any;
|
|
1359
|
-
"__#
|
|
1360
|
-
"__#
|
|
1359
|
+
"__#12024@#_configResource": any;
|
|
1360
|
+
"__#12024@#fetchConfig": (() => Promise<{
|
|
1361
1361
|
projectConfig: _descope_sdk_mixins.ProjectConfiguration;
|
|
1362
1362
|
executionContext: {
|
|
1363
1363
|
geo: string;
|
|
@@ -1391,14 +1391,14 @@ declare const AuditManagementWidget: {
|
|
|
1391
1391
|
data?: Record<string, string>;
|
|
1392
1392
|
}[]) => void;
|
|
1393
1393
|
readonly theme: _descope_sdk_mixins.ThemeOptions;
|
|
1394
|
-
"__#
|
|
1395
|
-
"__#
|
|
1396
|
-
readonly "__#
|
|
1397
|
-
"__#
|
|
1398
|
-
"__#
|
|
1399
|
-
"__#
|
|
1400
|
-
"__#
|
|
1401
|
-
"__#
|
|
1394
|
+
"__#12033@#_themeResource": Promise<void | Record<string, any>>;
|
|
1395
|
+
"__#12033@#fetchTheme"(): Promise<Record<string, any>>;
|
|
1396
|
+
readonly "__#12033@#themeResource": Promise<void | Record<string, any>>;
|
|
1397
|
+
"__#12033@#loadGlobalStyle"(): Promise<void>;
|
|
1398
|
+
"__#12033@#loadComponentsStyle"(): Promise<void>;
|
|
1399
|
+
"__#12033@#loadFonts"(): Promise<void>;
|
|
1400
|
+
"__#12033@#applyTheme"(): Promise<void>;
|
|
1401
|
+
"__#12026@#debuggerEle": HTMLElement & {
|
|
1402
1402
|
updateData: (data: {
|
|
1403
1403
|
title: string;
|
|
1404
1404
|
description?: string;
|
|
@@ -1407,11 +1407,11 @@ declare const AuditManagementWidget: {
|
|
|
1407
1407
|
description?: string;
|
|
1408
1408
|
}[]) => void;
|
|
1409
1409
|
};
|
|
1410
|
-
"__#
|
|
1411
|
-
"__#
|
|
1410
|
+
"__#12026@#disableDebugger"(): void;
|
|
1411
|
+
"__#12026@#enableDebugger"(): Promise<void>;
|
|
1412
1412
|
readonly debug: boolean;
|
|
1413
|
-
"__#
|
|
1414
|
-
"__#
|
|
1413
|
+
"__#12026@#handleDebugMode"(): void;
|
|
1414
|
+
"__#12026@#updateDebuggerMessages"(title: string, description: string): void;
|
|
1415
1415
|
};
|
|
1416
1416
|
};
|
|
1417
1417
|
|