@mindline/sync 1.0.110 → 1.0.111
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/src/index.d.ts +0 -2
- package/dist/sync.es.js +585 -596
- package/dist/sync.es.js.map +1 -1
- package/dist/sync.umd.js +21 -21
- package/dist/sync.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +15 -70
package/dist/sync.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(f,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("class-transformer")):typeof define=="function"&&define.amd?define(["exports","class-transformer"],S):(f=typeof globalThis<"u"?globalThis:f||self,S(f.sync={},f.classTransformer))})(this,(function(f,S){"use strict";var Ts=Object.defineProperty;var mt=f=>{throw TypeError(f)};var Ss=(f,S,C)=>S in f?Ts(f,S,{enumerable:!0,configurable:!0,writable:!0,value:C}):f[S]=C;var u=(f,S,C)=>Ss(f,typeof S!="symbol"?S+"":S,C),Is=(f,S,C)=>S.has(f)||mt("Cannot "+C);var re=(f,S,C)=>S.has(f)?mt("Cannot add the same private member more than once"):S instanceof WeakSet?S.add(f):S.set(f,C);var B=(f,S,C)=>(Is(f,S,"access private method"),C);var Y,yt,N,Ie,be,Ae,H,$e;const C=[{oid:"1",name:"",mail:"",authority:"",tid:"",companyName:"",companyDomain:"",session:"Sign In",sel:!0}],wt=[{tid:"1",name:"",domain:"",tenantType:"",authority:"",sel:!0,graphSP:""}],Tt=[],St=[{id:"1",name:"",associatedUsers:["1"],associatedTenants:["1"],associatedConfigs:[],sel:!0}],It=[{Run:"3",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"},{Run:"2",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"},{Run:"1",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"}],bt=[{type:"mg",resource:"Tenant Root Group",cost:0,expanded:!0,resources:[{type:"sub",resource:"Applications",cost:16677.52,expanded:!0,resources:[{type:"rg",resource:"ssfdev",cost:7500.08,expanded:!0,resources:[{type:"resources",resource:"SSFServices",cost:0,expanded:!1,resources:[]}]}]},{type:"sub",resource:"Infrastructure",cost:8737.58,expanded:!0,resources:[{type:"rg",resource:"SFFA_Prod_Mgmt_Shared_Resources_RG",cost:7500.08,expanded:!0,resources:[{type:"resources",resource:"SSFA-Prod-UTIL-01",cost:0,expanded:!1,resources:[]}]}]}]}],At=[{type:"user",actor:"arvind@mindline.site",resource:"kv-syncproject",role:"Key Vault Certificate Officer",updatedby:"arvind@mindline.site",updatedon:"2023-09-06T15:36:45.7760714Z",resources:[]},{type:"app",actor:"mindline1-sync-512169f5-38d1-4b57-be8b-967f2d0ae4c6",resource:"dev-subscription",role:"Contributor",updatedby:"arvind@mindline.site",updatedon:"2023-09-06T15:36:45.7760714Z",resources:[]}],_="workspaceIDs";function $t(n,s){return n+s}function kt(){return"hello NPM"}function U(){return"1.0.110"}class y{constructor(){u(this,"result");u(this,"status");u(this,"error");u(this,"version");u(this,"array");this.result=!0,this.status=200,this.error="",this.version=U(),this.array=null}}class M{}u(M,"azureElevateAccess","https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"),u(M,"azureListRootAssignments","https://management.azure.com/providers/Microsoft.Authorization/roleAssignments?api-version=2022-04-01&$filter=principalId+eq+");const k=class k{static adminEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admin`}static adminIncompleteEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/incomplete-admin`}static adminsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admins`}static auditConfigEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-configuration`}static auditEventsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-events`}static configConsentEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/consent`}static configEnabledEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/status`}static configEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration`}static configsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configurations`}static initEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/init`}static readerStartSyncEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/startSync`}static tenantEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenant`}static tenantsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenants`}static workspaceEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace`}static workspacesEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspaces`}static workspaceConfigsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace-configurations`}static signalREndpoint(){return`https://${k.environmentTag}-signalrdispatcher-westus.azurewebsites.net/statsHub`}static statsEndpoint(){return`https://${k.environmentTag}-signalrdispatcher-westus.azurewebsites.net/api/stats`}};u(k,"environmentTag","dev");let T=k;class g{}u(g,"graphGroupsPredicate","v1.0/groups"),u(g,"graphMailPredicate","v1.0/me/messages"),u(g,"graphMePredicate","v1.0/me"),u(g,"graphOauth2PermissionGrantsPredicate","v1.0/oauth2PermissionGrants"),u(g,"graphServicePrincipalsPredicate","v1.0/servicePrincipals"),u(g,"graphUsersPredicate","v1.0/users"),u(g,"graphTenantByDomainPredicate","beta/tenantRelationships/findTenantInformationByDomainName"),u(g,"graphTenantByIdPredicate","beta/tenantRelationships/findTenantInformationByTenantId"),u(g,"authorityWW","https://login.microsoftonline.com/"),u(g,"authorityWWRegex",/^(https:\/\/login\.microsoftonline\.com\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/),u(g,"authorityUS","https://login.microsoftonline.us/"),u(g,"authorityUSRegex",/^(https:\/\/login\.microsoftonline\.us\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/),u(g,"authorityCN","https://login.partner.microsoftonline.cn/"),u(g,"authorityCNRegex",/^(https:\/\/login\.partner\.microsoftonline\.cn\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/);class Et{constructor(){u(this,"id","");u(this,"displayName","");u(this,"description","")}}class Pt{constructor(){u(this,"group","");u(this,"value","");u(this,"consented",!1);u(this,"removable",!1);u(this,"expanded","")}static compareByValue(s,r){return s.value.localeCompare(r.value)}static compareByGroup(s,r){return s.group.localeCompare(r.group)}}class K{constructor(){u(this,"oid");u(this,"name");u(this,"mail");u(this,"authority");u(this,"tid");u(this,"companyName");u(this,"companyDomain");u(this,"workspaceIDs");u(this,"session");u(this,"spacode");u(this,"graphAccessToken");u(this,"mindlineAccessToken");u(this,"azureAccessToken");u(this,"loginHint");u(this,"scopes");u(this,"authTS");u(this,"sel");u(this,"loggingIn");this.oid="",this.name="",this.mail="",this.authority="",this.tid="",this.companyName="",this.companyDomain="",this.workspaceIDs="",this.session="Sign In",this.spacode="",this.graphAccessToken="",this.mindlineAccessToken="",this.azureAccessToken="",this.loginHint="",this.scopes=new Array,this.authTS=new Date(0),this.sel=!1,this.loggingIn=!1}}var ke=(n=>(n[n.invalid=0]="invalid",n[n.aad=1]="aad",n[n.ad=2]="ad",n[n.googleworkspace=3]="googleworkspace",n))(ke||{}),Ee=(n=>(n[n.read=1]="read",n[n.write=2]="write",n[n.notassigned=3]="notassigned",n))(Ee||{});class j{constructor(){u(this,"tid");u(this,"name");u(this,"domain");u(this,"tenantType");u(this,"authority");u(this,"workspaceIDs");u(this,"sel");u(this,"graphSP");u(this,"lookupfield");this.tid="",this.name="",this.domain="",this.tenantType="aad",this.authority="",this.workspaceIDs="",this.sel=!1,this.graphSP="",this.lookupfield="Domain"}}function vt(n,s){switch(n){case g.authorityWW:return s===1?"85d35da2-4118-4b03-aa05-605cedd7f2f8":"63100afe-506e-4bb2-8ff7-d8d5ab373129";case g.authorityUS:return s===1?"b08630c7-e227-4215-9746-afc9286fb864":"17aa5d5a-f09f-4cec-87a6-28596f9fa513";case g.authorityCN:return s===1?"7db7293b-add9-4a3f-8562-1a20bfe27d5e":"debd015b-1154-4111-a4cb-fc220a537697";default:debugger;return""}}function L(n){switch(n){case g.authorityWW:return"https://graph.microsoft.com/";case g.authorityUS:return"https://graph.microsoft.us/";case g.authorityCN:return"https://microsoftgraph.chinacloudapi.cn/";default:debugger;return""}}function Dt(n){switch(n){case g.authorityWW:return"https://login.microsoftonline.com/";case g.authorityUS:return"https://login.microsoftonline.us/";case g.authorityCN:return"https://login.partner.microsoftonline.cn/";default:debugger;return""}}var Pe=(n=>(n[n.source=1]="source",n[n.target=2]="target",n[n.sourcetarget=3]="sourcetarget",n))(Pe||{});class ve{constructor(){u(this,"tid");u(this,"sourceGroupId");u(this,"sourceGroupName");u(this,"targetGroupId");u(this,"targetGroupName");u(this,"configurationTenantType");u(this,"deltaToken");u(this,"usersWritten");u(this,"configId");u(this,"batchId");u(this,"isReadPermissionConsented");u(this,"isWritePermissionConsented");this.tid="",this.sourceGroupId="",this.sourceGroupName="",this.targetGroupId="",this.targetGroupName="",this.configurationTenantType="source",this.deltaToken="",this.usersWritten=0,this.configId="",this.batchId="",this.isReadPermissionConsented=!1,this.isWritePermissionConsented=!1}}class J{constructor(){u(this,"id");u(this,"workspaceId");u(this,"name");u(this,"description");u(this,"tenants");u(this,"isEnabled");u(this,"workspaceIDs");u(this,"sel");this.id="",this.name="",this.workspaceId="",this.description="",this.tenants=new Array,this.isEnabled=!1,this.workspaceIDs="",this.sel=!1}}class Gt{constructor(){u(this,"id");u(this,"workspaceId");u(this,"name");u(this,"description");u(this,"isEnabled");u(this,"isReadPermissionConsented");u(this,"email");u(this,"tenantId");u(this,"sel");this.id="",this.name="",this.workspaceId="",this.description="",this.isEnabled=!1,this.isReadPermissionConsented=!1,this.email="",this.tenantId="",this.sel=!1}}class V{constructor(){u(this,"id");u(this,"name");u(this,"ownerid");u(this,"associatedUsers");u(this,"associatedTenants");u(this,"associatedConfigs");u(this,"sel");this.id="",this.name="",this.ownerid="",this.associatedUsers=new Array,this.associatedTenants=new Array,this.associatedConfigs=new Array,this.sel=!1}}function O(){let n;try{n=window.localStorage;const s="__storage_test__";return n.setItem(s,s),n.removeItem(s),!0}catch(s){return s instanceof DOMException&&(s.code===22||s.code===1014||s.name==="QuotaExceededError"||s.name==="NS_ERROR_DOM_QUOTA_REACHED")&&n&&n.length!==0}}class Rt{constructor(s=!1){re(this,Y);u(this,"version",U());u(this,"tab",0);u(this,"us",[]);u(this,"ts",[]);u(this,"cs",[]);u(this,"acs",[]);u(this,"ws",[]);u(this,"configlevelconsent_configid","");u(this,"configlevelconsent_access",3);this.init(s)}init(s){if(console.log(`Calling InitInfo::init(bClearLocalStorage: ${s?"true":"false"})`),O()){let o=localStorage.getItem("InitInfo");if(o!=null&&typeof o=="string"&&o!==""){let i=JSON.parse(o);if(i.us.length!==0)if(s)localStorage.removeItem("InitInfo");else{B(this,Y,yt).call(this,i);return}}}this.tab=0,this.version=U(),this.configlevelconsent_configid="",this.configlevelconsent_access=3;var r=JSON.stringify(C),t=JSON.stringify(wt),e=JSON.stringify(Tt),a=JSON.stringify(St);try{this.us=S.deserializeArray(K,r),this.ts=S.deserializeArray(j,t),this.cs=S.deserializeArray(J,e),this.ws=S.deserializeArray(V,a),this.tagWithWorkspaces()}catch{debugger}}save(){let s=JSON.stringify(this);localStorage.setItem("InitInfo",s)}tagWithWorkspaces(){this.us.map(s=>s.workspaceIDs=""),this.ts.map(s=>s.workspaceIDs=""),this.cs.map(s=>s.workspaceIDs="");for(let s of this.ws){for(let r of s.associatedUsers){let t=this.us.find(e=>e.oid===r);if(t!==void 0)t[_]+=s.id,t[_]+=" ";else debugger}for(let r of s.associatedTenants){let t=this.ts.find(e=>e.tid===r);if(t!==void 0)t[_]+=s.id,t[_]+=" ";else debugger}for(let r of s.associatedConfigs){let t=this.cs.find(e=>e.id===r);if(t!==void 0)t[_]+=s.id,t[_]+=" ";else debugger}}return!0}}Y=new WeakSet,yt=function(s){this.tab=s.tab,this.version=U(),this.configlevelconsent_configid=s.configlevelconsent_configid,this.configlevelconsent_access=s.configlevelconsent_access,typeof s.us>"u"?this.us=new Array:this.us=s.us.map(r=>{let t=new K;return t.oid=r.oid,t.name=r.name,t.mail=r.mail,t.authority=r.authority,t.tid=r.tid,t.companyName=r.companyName,t.companyDomain=r.companyDomain,t.workspaceIDs=r.workspaceIDs,t.session=r.session,t.spacode=r.spacode,t.graphAccessToken=r.graphAccessToken,t.mindlineAccessToken=r.mindlineAccessToken,t.azureAccessToken=r.azureAccessToken,t.loginHint=r.loginHint,t.scopes=r.scopes,t.authTS=new Date(r.authTS),t.sel=r.sel,t.loggingIn=r.loggingIn,t}),typeof s.ts>"u"?this.ts=new Array:this.ts=s.ts.map(r=>{let t=new j;return t.tid=r.tid,t.name=r.name,t.domain=r.domain,t.tenantType=r.tenantType,t.authority=r.authority,t.workspaceIDs=r.workspaceIDs,t.sel=r.sel,t.lookupfield=r.lookupfield,t}),typeof s.cs>"u"?this.cs=new Array:this.cs=s.cs.map(r=>{let t=new J;return t.id=r.id,t.workspaceId=r.workspaceId,t.name=r.name,t.description=r.description,t.tenants=r.tenants,t.isEnabled=r.isEnabled,t.workspaceIDs=r.workspaceIDs,t.sel=r.sel,t}),typeof s.ws>"u"?this.ws=new Array:this.ws=s.ws.map(r=>{let t=new V;return t.id=r.id,t.name=r.name,t.ownerid=r.ownerid,t.associatedUsers=r.associatedUsers,t.associatedTenants=r.associatedTenants,t.associatedConfigs=r.associatedConfigs,t.sel=r.sel,t})};const Ct=[{id:1,task:"initialization",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:22",status:"not started",expanded:!0,subtasks:[{id:2,task:"authenticate user",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:01",status:"not started"},{id:3,task:"reload React",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:07",status:"not started"},{id:4,task:"GET tenant details",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:01",status:"not started"},{id:5,task:"POST config init",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:10",status:"not started"},{id:6,task:"GET workspaces",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:04",status:"not started"}]}];class Ot{constructor(s){re(this,N);u(this,"tasks");this.tasks=[new Z],this.init(s)}init(s){if(console.log(`Calling TaskArray::init(bClearLocalStorage: ${s?"true":"false"})`),this.tasks.length=0,s&&O()&&localStorage.removeItem("Tasks"),O()){let r=localStorage.getItem("Tasks");if(r!=null&&typeof r=="string"&&r!==""){let e=JSON.parse(r);if(this.tasks=B(this,N,be).call(this,e.tasks),this.tasks.length!==0)return}}this.tasks=B(this,N,be).call(this,Ct)}setTaskStart(s,r){let t=B(this,N,Ie).call(this,s);if(t!=null&&t!=null)t.setStart(r),t.status="in progress",B(this,N,Ae).call(this);else debugger}setTaskEnd(s,r,t){let e=B(this,N,Ie).call(this,s);if(e!=null&&e!=null)e.setEnd(r),e.status=t,B(this,N,Ae).call(this);else debugger}}N=new WeakSet,Ie=function(s){let r=this.tasks.find(t=>t.task==s);if(r==null||r==null){for(r of this.tasks)if(r.subtasks!=null&&r.subtasks!=null&&(r=r.subtasks.find(t=>t.task==s),r!=null&&r!=null))break}return r},be=function(s){return s.map(r=>{let t=new Z;return t.id=r.id,t.task=r.task,t.setStart(new Date(r.start)),t.setEnd(new Date(r.end)),t.expected=r.expected,t.status=r.status,t.expanded=r.expanded,typeof r.subtasks<"u"&&r.subtasks!=null&&(t.subtasks=r.subtasks.map(e=>{let a=new Z;return a.id=e.id,a.task=e.task,a.setStart(new Date(e.start)),a.setEnd(new Date(e.end)),a.expected=e.expected,a.status=e.status,a.expanded=e.expanded,a})),t})},Ae=function(){let s=JSON.stringify(this);O()&&localStorage.setItem("Tasks",s)};class Z{constructor(){u(this,"id",0);u(this,"task","");u(this,"start",new Date);u(this,"startDisplay","");u(this,"end",new Date);u(this,"endDisplay","");u(this,"elapsedDisplay","");u(this,"expected",0);u(this,"status","");u(this,"expanded",!1);u(this,"subtasks",[])}setEnd(s){this.end=s,this.endDisplay=`${this.end.getMinutes().toString().padStart(2,"0")}:${this.end.getSeconds().toString().padStart(2,"0")}`;let r=0,t=this.end.getSeconds()-this.start.getSeconds();t<0&&(t+=60,r=-1);let e=this.end.getMinutes()-this.start.getMinutes()+r;e<0&&(e+=60),this.elapsedDisplay=`${e.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`}setStart(s){this.start=s,this.startDisplay=`${this.start.getMinutes().toString().padStart(2,"0")}:${this.start.getSeconds().toString().padStart(2,"0")}`}}class q{constructor(s){u(this,"Run",0);u(this,"Start",new Date);u(this,"startDisplay","");u(this,"POST");u(this,"postDisplay");u(this,"Read");u(this,"readDisplay");u(this,"Write");u(this,"writeDisplay");u(this,"Duration");u(this,"durationDisplay");this.Run=s,this.start(""),this.POST=new Date,this.postDisplay="",this.Read=new Date,this.readDisplay="",this.Write=new Date,this.writeDisplay="",this.Duration=new Date,this.durationDisplay=""}start(s){s==""?this.Start=new Date:this.Start=new Date(s),this.startDisplay=`${this.Start.getMinutes().toString().padStart(2,"0")}:${this.Start.getSeconds().toString().padStart(2,"0")}`}post(s){s==""?this.POST=new Date:this.POST=new Date(s),this.postDisplay=`${this.POST.getMinutes().toString().padStart(2,"0")}:${this.POST.getSeconds().toString().padStart(2,"0")}`}read(s){s==""?this.Read=new Date:this.Read=new Date(s),this.readDisplay=`${this.Read.getMinutes().toString().padStart(2,"0")}:${this.Read.getSeconds().toString().padStart(2,"0")}`}write(s){s==""?this.Write=new Date:this.Write=new Date(s),this.writeDisplay=`${this.Write.getMinutes().toString().padStart(2,"0")}:${this.Write.getSeconds().toString().padStart(2,"0")}`,this.Duration=new Date(this.Write.getTime()-this.Start.getTime()),this.durationDisplay=`${this.Duration.getMinutes().toString().padStart(2,"0")}:${this.Duration.getSeconds().toString().padStart(2,"0")}`}}class De{constructor(s){re(this,H);u(this,"milestones",[]);this.init(s)}init(s){if(O()){let r=localStorage.getItem("syncmilestones");if(r!=null&&typeof r=="string"&&r!==""){let e=JSON.parse(r);if(e.length!==0)if(s)localStorage.removeItem("syncmilestones");else{B(this,H,$e).call(this,e);return}}}B(this,H,$e).call(this,It)}save(){let s=JSON.stringify(this.milestones);O()&&localStorage.setItem("syncmilestones",s)}start(s){if(this.milestones==null||this.milestones.length<1){debugger;return}let r=Number(this.milestones[0].Run),t=new q(r+1);this.milestones.unshift(t),this.milestones=this.milestones.map(e=>{let a=new q(e.Run);return a.Start=e.Start,a.startDisplay=e.startDisplay,a.POST=e.POST,a.postDisplay=e.postDisplay,a.Read=e.Read,a.readDisplay=e.readDisplay,a.Write=e.Write,a.writeDisplay=e.writeDisplay,a.Duration=e.Duration,a.durationDisplay=e.durationDisplay,a}),s(this.milestones),console.log(`Start milestone: ${this.milestones[0].Run}:${this.milestones[0].Start}`)}unstart(s){if(this.milestones==null||this.milestones.length<1){debugger;return}let r=this.milestones.shift();this.milestones=this.milestones.map(t=>{let e=new q(t.Run);return e.Start=t.Start,e.startDisplay=t.startDisplay,e.POST=t.POST,e.postDisplay=t.postDisplay,e.Read=t.Read,e.readDisplay=t.readDisplay,e.Write=t.Write,e.writeDisplay=t.writeDisplay,e.Duration=t.Duration,e.durationDisplay=t.durationDisplay,e}),s(this.milestones),console.log(`Unstart removed first milestone: ${r.Run}:${r.Start}`)}post(s){if(this.milestones==null||this.milestones.length<1){debugger;return}this.milestones[0].post(""),s(this.milestones),console.log(`POST milestone: ${this.milestones[0].Run}:${this.milestones[0].POST}`)}read(s){if(this.milestones==null||this.milestones.length<1){debugger;return}this.milestones[0].read(""),s(this.milestones),console.log(`Read milestone: ${this.milestones[0].Run}:${this.milestones[0].Read}`)}write(s){if(this.milestones==null||this.milestones.length<1){debugger;return}for(this.milestones[0].write("");this.milestones.length>10;){let r=this.milestones.pop();console.log(`Removed milestone #${r.Run}: ${r.Start}`)}this.save(),this.milestones=this.milestones.map(r=>{let t=new q(r.Run);return t.Start=r.Start,t.startDisplay=r.startDisplay,t.POST=r.POST,t.postDisplay=r.postDisplay,t.Read=r.Read,t.readDisplay=r.readDisplay,t.Write=r.Write,t.writeDisplay=r.writeDisplay,t.Duration=r.Duration,t.durationDisplay=r.durationDisplay,t}),s(this.milestones)}}H=new WeakSet,$e=function(s){s==null?this.milestones=new Array:this.milestones=s.map(r=>{let t=new q(Number(r.Run));return t.start(r.Start),t.post(r.POST),t.read(r.Read),t.write(r.Write),t})};class Nt{constructor(s,r,t){u(this,"tenantNodes");u(this,"pb_startTS");u(this,"pb_progress");u(this,"pb_idle");u(this,"pb_total");u(this,"pb_timer");u(this,"pollIntervalSeconds",5);u(this,"pollTimer",null);u(this,"pollLastUpdatedByBatchId",{});u(this,"pollInstance",null);u(this,"pollAuthorizedUser",null);u(this,"pollBatchIdArray",[]);u(this,"lastQueues",{main:null,writer:null,deferred:null});u(this,"hasQueueInfo",!1);u(this,"setIdleText",null);u(this,"statsHydrationHandler",null);u(this,"milestoneArray");this.tenantNodes=new Array,this.init(s,r,t),this.pb_startTS=0,this.pb_progress=0,this.pb_timer=null,this.pb_idle=0,this.pb_total=0,this.milestoneArray=new De(!1)}clearStoredBatchIds(){O()&&(localStorage.setItem("BatchIdArray","[]"),localStorage.removeItem("BatchIdArrayProgress"))}init(s,r,t){console.log(`Calling BatchArray::init(config: "${s?s.name:"null"}", bClearLocalStorage: ${t?"true":"false"})`),t&&O()&&(localStorage.removeItem(s.name),this.milestoneArray.init(t)),s!=null&&s.tenants!=null&&r!=null&&(this.tenantNodes.length=0,s.tenants.map(e=>{if(e.configurationTenantType==="source"||e.configurationTenantType==="sourcetarget"){let a=r.ts.find(o=>o.tid===e.tid);if(a!=null){let o=new ae(e.tid,a.name,e.batchId);this.tenantNodes.push(o)}else{console.log(`Error: no tenant found for config source tenant ${s.name}`);debugger;return}}}),this.tenantNodes.map(e=>{s.tenants.map(a=>{if((a.configurationTenantType==="target"||a.configurationTenantType==="sourcetarget")&&a.tid!==e.tid){let o=r.ts.find(d=>d.tid===a.tid);if(o!=null){let d=new ae(a.tid,o.name,a.batchId);e.targets.push(d),e.expanded=!0}else{console.log(`Error: no tenant found for config target tenant ${s.name}`);debugger;return}}})}))}initializeProgressBar(s,r,t,e){this.setIdleText=t,this.hasQueueInfo=!1,this.lastQueues={main:null,writer:null,deferred:null},this.pb_startTS=Date.now(),this.pb_progress=0,this.pb_idle=0,this.pb_total=0,s(this.pb_progress),t("Starting sync..."),this.pb_timer=setInterval(()=>{console.log("this.tenantNodes",this.tenantNodes);let a=this.tenantNodes.every(i=>i.nothingtosync||i.targets.every(l=>l.status==="complete"||l.status==="failed"));this.hasQueueInfo&&this.lastQueues.main===0&&this.lastQueues.writer===0&&this.lastQueues.deferred===0||!this.hasQueueInfo&&a?(clearInterval(this.pb_timer),this.pb_timer=null,this.pb_progress=100,s(this.pb_progress),t("Complete."),this.stopPolling(),this.clearStoredBatchIds()):(this.pb_total=this.pb_total+1,this.pb_idle=this.pb_idle+1,t(`${this.pb_total} seconds elapsed. Last update ${this.pb_idle} seconds ago.`))},1e3),this.milestoneArray.start(e)}stopPolling(){this.pollTimer!=null&&(clearInterval(this.pollTimer),this.pollTimer=null),this.pollInstance=null,this.pollAuthorizedUser=null,this.pollBatchIdArray=[],this.pollLastUpdatedByBatchId={}}async pollStatsOnce(){if(this.pb_timer!=null&&!(this.pollInstance==null||this.pollAuthorizedUser==null)&&this.statsHydrationHandler&&!(!this.pollBatchIdArray||this.pollBatchIdArray.length===0))for(const s of this.pollBatchIdArray){const r=s==null?void 0:s.BatchId;if(!r)continue;const t=await ot(this.pollInstance,this.pollAuthorizedUser,r);if(!t.result||!t.array||!t.array[0])continue;const e=t.array[0],a=e.lastUpdated,o=this.pollLastUpdatedByBatchId[r];this.pollLastUpdatedByBatchId[r]=a??"",!(!a||a===o)&&this.statsHydrationHandler(r,e.stats)}}uninitializeProgressBar(s,r,t,e){this.pb_startTS=0,this.pb_progress=0,s(this.pb_progress),r("sync failed to execute"),clearInterval(this.pb_timer),this.pb_timer=null,this.pb_idle=0,t(`No updates seen for ${this.pb_idle} seconds.`),this.milestoneArray.unstart(e)}calculateProgress(s,r,t,e,a){if(s<=0)return 0;const o=Math.min(s,r+e),d=Math.min(s,t+e+a),i=o+d;return Math.min(99,Math.round(i/(s*2)*100))}updateProgressFromTotals(s,r,t,e,a,o){const d=this.calculateProgress(s,r,t,e,a);this.pb_progress=Math.max(this.pb_progress,d),o(this.pb_progress),O()&&localStorage.setItem("BatchIdArrayProgress",String(this.pb_progress))}initializeSignalR(s,r,t,e,a,o,d,i,l,c,h,$,E,W,z,x,G){this.hasQueueInfo=!1,this.lastQueues={main:null,writer:null,deferred:null},this.milestoneArray.post(h),$("started sync, waiting for updates..."),this.init(s,r,!1);let P=(F,it)=>{var pt,gt;this.pb_idle=0;let Q=t.find(p=>p.BatchId==F);if(Q==null){console.log(`Batch ${F} not found in batchIdArray.`);debugger;return}let m=this.tenantNodes.find(p=>p.tid===Q.SourceId);if(m==null){console.log(`Tenant ${Q.SourceId} not found in BatchArray.`);debugger;return}m.batchId=Q.BatchId;let v=Object.keys(it),R=Object.values(it),le=!1,lt=!1,ue=null,de=null,ce=null;for(let p=0;p<v.length;p++){let D=v[p].endsWith("TotalCount"),te=v[p].endsWith("CurrentCount"),we=v[p].endsWith("ExtCount"),se=v[p].endsWith("DeferredCount"),Te=v[p].endsWith("RescheduledCount");if(we&&(m.excluded=Math.max(Number(R[p]),m.excluded),m.targets.map(I=>{I.excluded=m.excluded,I.update(I.total,I.read,I.excluded,I.written,I.deferred)})),D&&(le=Number(R[p])==0,m.total=Math.max(Number(R[p]),m.total),m.targets.map(I=>{I.total=m.total,I.update(I.total,I.read,I.excluded,I.written,I.deferred)})),v[p].startsWith("Reader")){let I=/Reader\/TID:(.+)\/TotalCount/;if(te&&(I=/Reader\/TID:(.+)\/CurrentCount/),we&&(I=/Reader\/TID:(.+)\/ExtCount/),se&&(I=/Reader\/TID:(.+)\/DeferredCount/),Te&&(I=/Reader\/TID:(.+)\/RescheduledCount/),v[p].match(I)==null){console.log(`tid not found in ${v[p]}.`);debugger;return}D?(le=Number(R[p])==0,m.total=Math.max(Number(R[p]),m.total),console.log(`----- ${m.name} TID: ${m.tid} batchId: ${m.batchId}`),console.log(`----- ${m.name} Total To Read: ${m.total}`)):(lt=Number(R[p])==0,te?(m.read=Math.max(Number(R[p]),m.read),console.log(`----- ${m.name} Currently Read: ${m.read}`)):se&&(m.deferred=Math.max(Number(R[p]),m.deferred),console.log(`----- ${m.name} Deferred: ${m.deferred}`)))}if(m.nothingtosync=le&<,v[p]==="TotalInMainQueue"&&(ue=Number(R[p])),v[p]==="TotalInWriterQueue"&&(de=Number(R[p])),v[p]==="TotalInDeferredQueue"&&(ce=Number(R[p])),v[p].startsWith("Writer")){let I=/Writer\/TID:(.+)\/TotalCount/;te&&(I=/Writer\/TID:(.+)\/CurrentCount/),we&&(I=/Writer\/TID:(.+)\/ExtCount/),se&&(I=/Writer\/TID:(.+)\/DeferredCount/),Te&&(I=/Writer\/TID:(.+)\/RescheduledCount/);let Se=v[p].match(I);if(Se==null){console.log(`tid not found in ${v[p]}.`);debugger;return}let b=m.targets.find(ws=>ws.tid===Se[1]);if(b==null){console.log(`Writer ${m.name} not found under Reader ${m.name}.`);debugger;return}if(b.total=Math.max(Number(m.total),b.total),b.total=Math.max(Number(m.total),b.total),b.batchId=Q.BatchId,D)b.total=Math.max(Number(R[p]),b.total),console.log(`----- ${b.name} TID: ${b.tid} batchId: ${b.batchId}`),console.log(`----- ${b.name} Total To Write: ${b.total}`);else if(te)b.written=Math.max(Number(R[p]),b.written),console.log(`----- ${b.name} Total Written: ${b.written}`);else if(se||Te)b.deferred=Math.max(Number(R[p]),b.deferred),console.log(`----- ${b.name} Total Deferred: ${b.deferred}`);else{console.log("unknown writer type");debugger;return}b.update(b.total,b.read,b.excluded,b.written,b.deferred)}}m.update(m.total,m.read,m.excluded,m.written,m.deferred);let ut=!0,fe=!0,dt=!1,ct=!0,ee=0,he=0,pe=0,ge=0,me=0,ye=0,ft=0;this.tenantNodes.map(p=>{p.targets.map(D=>{fe&&(fe=D.status=="complete"||D.status=="failed"),dt||(dt=D.total>0||D.status!="not started"),ge+=Math.max(D.total,p.total),me+=D.written,ye+=D.excluded,ft+=D.deferred}),ct&&(ct=p.nothingtosync),ut&&(ut=p.total>0&&p.read+p.excluded>=p.total),ee+=p.total,he+=p.read,pe+=p.excluded}),ue!=null&&(this.lastQueues.main=ue),de!=null&&(this.lastQueues.writer=de),ce!=null&&(this.lastQueues.deferred=ce),this.hasQueueInfo=this.lastQueues.main!=null&&this.lastQueues.writer!=null&&this.lastQueues.deferred!=null;const ht=this.hasQueueInfo&&this.lastQueues.main===0&&this.lastQueues.writer===0&&this.lastQueues.deferred===0;ht&&(fe=!0,this.tenantNodes.forEach(p=>{p.targets.forEach(D=>{D.status!=="failed"&&(D.status="complete")}),p.status!=="failed"&&(p.status="complete")})),a(ee),d(he),o(pe),i(Math.max(ge,ee)),c(me),l(ye),this.updateProgressFromTotals(Math.max(ee,ge),he,me,Math.max(pe,ye),ft,E),ct?(this.milestoneArray.write(h),this.stopPolling(),$("nothing to sync"),this.pb_timer&&(clearInterval(this.pb_timer),this.pb_timer=null),this.pb_progress=100,E(this.pb_progress),(pt=this.setIdleText)==null||pt.call(this,"Complete (nothing to sync)."),this.clearStoredBatchIds(),console.log('Setting config sync result: "nothing to sync"')):(ut&&(this.milestoneArray.read(h),$("reading complete"),console.log('Setting config sync result: "reading complete"'),e(s.workspaceId)),fe&&(ht||!this.hasQueueInfo)?(this.milestoneArray.write(h),this.stopPolling(),$("sync complete"),this.pb_timer&&(clearInterval(this.pb_timer),this.pb_timer=null),this.pb_progress=100,E(this.pb_progress),(gt=this.setIdleText)==null||gt.call(this,"Complete."),this.clearStoredBatchIds(),console.log('Setting config sync result: "complete"')):dt?($("writing in progress"),console.log('Setting config sync result: "writing in progress"')):this.milestoneArray.milestones[0].Read==null&&($("reading in progress"),console.log('Setting config sync result: "reading in progress"')))};this.statsHydrationHandler=P,x&&G&&(this.pollInstance=x,this.pollAuthorizedUser=G,this.pollBatchIdArray=t,this.stopPolling(),this.pollInstance=x,this.pollAuthorizedUser=G,this.pollBatchIdArray=t,this.pollStatsOnce(),this.pollTimer=setInterval(()=>{this.pollStatsOnce()},this.pollIntervalSeconds*1e3))}async startSync(s,r,t){let e=new y;if(this.tenantNodes==null||this.tenantNodes.length==0){debugger;return e.result=!1,e.error="startSync: invalid parameters",e.status=500,e}return e=await nt(s,r,t),e}}class ae{constructor(s,r,t){u(this,"expanded");u(this,"status","");u(this,"name");u(this,"tid");u(this,"batchId");u(this,"total",0);u(this,"read",0);u(this,"excluded",0);u(this,"written",0);u(this,"deferred",0);u(this,"nothingtosync");u(this,"targets");this.expanded=!1,this.name=r,this.tid=s,this.batchId=t,this.nothingtosync=!1,this.targets=new Array,this.update(0,0,0,0,0)}update(s,r,t,e,a){if(this.total=s,this.read=r,this.excluded=t,this.written=e,this.deferred=a,this.read===0&&this.written===0&&(this.status="not started"),this.read>0){if(this.read+this.excluded<this.total)this.status="in progress";else if(this.read+this.excluded===this.total)if(this.targets!=null&&this.targets.length>0){const o=this.targets.every(d=>d.status==="complete"||d.status==="failed");this.status=o?"complete":"in progress"}else this.status="complete"}else this.written>0&&(this.written+this.deferred+this.excluded<this.total?this.status="in progress":this.written+this.deferred+this.excluded===this.total?this.status="complete":this.written+this.deferred+this.excluded>=this.total&&(this.status="failed"))}}class ne{constructor(s,r){u(this,"resourceNodes");this.resourceNodes=new Array,s&&this.init(r)}init(s){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${s?"true":"false"})`),O()){let t=localStorage.getItem("ResourceArray");if(t!=null&&typeof t=="string"&&t!=="")if(s)localStorage.removeItem("ResourceArray");else{let a=JSON.parse(t);this.resourceNodes=a.resourceNodes;return}}var r=JSON.stringify(bt);try{this.resourceNodes=S.deserializeArray(Ge,r)}catch{debugger}}async read(s,r){let t=new ne(!1,!1);return t.resourceNodes=await gs(s,r),t}save(){if(O()){let s=JSON.stringify(this);localStorage.setItem("ResourceArray",s)}}}class Ge{constructor(s,r,t){u(this,"type");u(this,"resource");u(this,"cost");u(this,"expanded");u(this,"resources");this.type=s,this.resource=r,this.cost=t,this.expanded=!1,this.resources=new Array}}class Bt{constructor(s){u(this,"actorNodes");this.actorNodes=new Array,this.init(s)}init(s){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${s?"true":"false"})`),O()){let t=localStorage.getItem("RBACActors");if(t!=null&&typeof t=="string"&&t!=="")if(s)localStorage.removeItem("RBACActors");else{let a=JSON.parse(t);this.actorNodes=a.actorNodes;return}}var r=JSON.stringify(At);try{this.actorNodes=S.deserializeArray(Re,r)}catch{debugger}}}class Re{constructor(s,r,t,e,a,o){u(this,"type");u(this,"actor");u(this,"resource");u(this,"role");u(this,"updatedby");u(this,"updatedon");u(this,"actors");this.type=s,this.actor=r,this.resource=t,this.role=e,this.updatedby=a,this.updatedon=o,this.actors=new Array}}function Wt(n){return"Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All"}async function X(n,s){const r=new Headers;r.append("Content-Type","application/json"),r.append("accept","*/*");const t=Wt();if(s.graphAccessToken==null||s.graphAccessToken==="")try{let e=await n.acquireTokenByCode({code:s.spacode});s.graphAccessToken=e.accessToken,console.log("Front end token acquired by code: "+s.graphAccessToken.slice(0,20))}catch(e){console.log("Front end token failure: "+e)}else try{let e=n.getAllAccounts(),a=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==a&&(o=e[i]);let d=await n.acquireTokenSilent({scopes:[t],account:o});s.graphAccessToken=d.accessToken,console.log("Front end token graph acquired silently: "+s.graphAccessToken.slice(0,20))}catch(e){try{console.log("Front end graph token silent acquisition failure: "+e);let a=n.getAllAccounts(),o=s.oid+"."+s.tid,d=null;for(let i=0;i<a.length;i++)a[i].homeAccountId==o&&(d=a[i]);n.acquireTokenRedirect({scopes:[t],account:d})}catch(a){console.log("Front end graph token redirect acquisition failure: "+a)}}return r.append("Authorization",`Bearer ${s.graphAccessToken}`),r}async function Ft(n,s,r){if(s==null||s.spacode=="")return{groups:[],error:"500: invalid user passed to groupsGet"};let e={method:"GET",headers:await X(n,s)};try{let a=L(s.authority)+g.graphGroupsPredicate;a+=`/?$filter=startsWith(displayName, '${r}')`;let d=await(await fetch(a,e)).json();return typeof d.error<"u"?{groups:[],error:`${d.error.code}: ${d.error.message}`}:{groups:d.value,error:""}}catch(a){return console.log(a),{groups:[],error:`Exception: ${a}`}}}async function Ce(n,s,r,t){try{let e=L(s.authority)+g.graphOauth2PermissionGrantsPredicate,a=new URL(e);a.searchParams.append("$filter",`resourceId eq '${r}' and consentType eq 'Principal' and principalId eq '${t}'`);let d=await(await fetch(a.href,n)).json();if(typeof d.error<"u")return{grants:null,id:null,error:`${d.error.code}: ${d.error.message}`};if(d.value.length!=1){debugger;return{grants:null,id:null,error:"oauth2PermissionGrantsGet: more than one matching delegated consent grant."}}return{grants:d.value[0].scope,id:d.value[0].id,error:""}}catch(e){return console.log(e),{grants:null,id:null,error:`Exception: ${e}`}}}async function Oe(n,s,r,t){if(s==null||s.spacode=="")return!1;try{let e=L(s.authority);e+=g.graphOauth2PermissionGrantsPredicate+`/${r}`;let a=`{ "scope": "${t}" }`,d={method:"PATCH",headers:await X(n,s),body:a},i=await fetch(e,d),l=await i.json();if(i.status==204&&i.statusText=="No Content")return!0;debugger;return console.log(`oauth2PermissionGrantsSet: PATCH failed ${l.error.code}: ${l.error.message}`),!1}catch(e){debugger;return console.log(e),!1}}function Ut(n,s){let r=Dt(n.authority);r+=n.tid,r+="/adminconsent";let t=new URL(r),e=vt(n.authority,s);t.searchParams.append("client_id",e),t.searchParams.append("redirect_uri",window.location.origin),t.searchParams.append("domain_hint",n.companyDomain),t.searchParams.append("login_hint",n.mail),window.location.assign(t.href)}async function Ne(n,s,r){try{let t=L(s.authority);t+=g.graphServicePrincipalsPredicate,t+=`(appId='${r}')`;let e=new URL(t);e.searchParams.append("$select","id,appId,displayName");let o=await(await fetch(e.href,n)).json();return typeof o.error<"u"?{spid:"",error:`${o.error.code}: ${o.error.message}`}:{spid:o.id,error:""}}catch(t){return console.log(t),{spid:"",error:`Exception: ${t}`}}}async function Lt(n,s){if(n.authority==""){let e=new j;if(e.domain=n.tid,await oe(e,!1))n.authority=e.authority;else{debugger;return!1}}let r=window.location.href;switch(n.authority){case g.authorityWW:r+="MicrosoftIdentity/Account/SignIn";break;case g.authorityUS:r+="USGov/SignIn";break;case g.authorityCN:r+="China/SignIn";break;default:return!1}let t=new URL(r);if(t.searchParams.append("redirectUri",window.location.origin),n.oid!=="1"){t.searchParams.append("loginHint",n.mail);const e=/@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/,a=n.mail.match(e);let o=a?a[1]:"organizations";t.searchParams.append("domainHint",o)}else t.searchParams.append("domainHint","organizations");return s.setTaskStart("initialization",new Date),s.setTaskStart("authenticate user",new Date),window.location.assign(t.href),!0}function zt(n,s){debugger;if(n.oid=="1")return;let r=window.location.href;switch(n.authority){case g.authorityWW:r+="MicrosoftIdentity/Account/Challenge";break;case g.authorityUS:r+="USGov/Challenge";break;case g.authorityCN:r+="China/Challenge";break;default:return}let t=new URL(r);t.searchParams.append("redirectUri",window.location.origin),t.searchParams.append("scope",s),t.searchParams.append("domainHint","organizations"),t.searchParams.append("loginHint",n.mail),window.location.assign(t.href)}async function xt(n){if(n.oid=="1")return!1;let s=window.location.href;s+="user";let r=new URL(s);r.searchParams.append("oid",n.oid),r.searchParams.append("tid",n.tid),r.searchParams.append("loginHint",n.loginHint),r.searchParams.append("verb","LOGOUT");let t={method:"PATCH"},e=await fetch(r.href,t);if(e.status==200&&e.statusText=="OK")console.log(`Successfully set admin ${n.mail} logout_hint`);else return console.log(`Failed to set admin ${n.mail} logout_hint`),!1;let a=window.location.href;switch(n.authority){case g.authorityWW:a+="MicrosoftIdentity/Account/SignOut";break;case g.authorityUS:a+="USGov/SignOut";break;case g.authorityCN:a+="China/SignOut";break;default:return!1}return r=new URL(a),r.searchParams.append("redirectUri",window.location.origin),window.location.assign(r.href),!0}async function _t(n,s,r,t){if(t)debugger;if(s.name!=null&&s.name!=="")return!1;if(n.graphAccessToken!=null&&n.graphAccessToken===""){console.log(`tenantRelationshipsGetByDomain called with invalid logged in user: ${n.name}`);try{let i=await r.acquireTokenByCode({code:n.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});n.graphAccessToken=i.accessToken,console.log("tenantRelationshipsGetByDomain: Front end token acquired: "+n.graphAccessToken.slice(0,20))}catch(i){return console.log("tenantRelationshipsGetByDomain: Front end token failure: "+i),!1}}const e=new Headers,a=`Bearer ${n.graphAccessToken}`;e.append("Authorization",a);let o={method:"GET",headers:e};try{var d=L(s.authority)+g.graphTenantByDomainPredicate;d+="(domainName='",d+=s.domain,d+="')",console.log("tenantRelationshipsGetByDomain: Attempting GET from /findTenantInformationByDomainName:",d);let i=await fetch(d,o);if(i.status==200){let l=await i.json();if(l){if(l.error!=null){debugger;return console.log("tenantRelationshipsGetByDomain: Failed GET from /findTenantInformationByDomainName: ",l.error.message),!1}else if(l.displayName!=null&&l.displayName!=="")return s.tid=l.tenantId,s.name=l.displayName,console.log("tenantRelationshipsGetByDomain: Successful GET from /findTenantInformationByDomainName: ",l.displayName),!0}else console.log("tenantRelationshipsGetByDomain: Failed to GET from /findTenantInformationByDomainName: ",d)}}catch(i){return console.log("Failed to GET from /findTenantInformationByDomainName: ",i),!1}return!1}async function Be(n,s,r,t,e){if(console.log("**** tenantRelationshipsGetById"),e)debugger;if(n.graphAccessToken==="")try{let l=await t.acquireTokenByCode({code:n.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});n.graphAccessToken=l.accessToken,console.log("tenantRelationshipsGetById: Front end token acquired: "+n.graphAccessToken.slice(0,20))}catch(l){return console.log("tenantRelationshipsGetById: Front end token failure: "+l),!1}const a=new Headers,o=`Bearer ${n.graphAccessToken}`;a.append("Authorization",o);let d={method:"GET",headers:a};try{var i=L(n.authority)+g.graphTenantByIdPredicate;i+="(tenantId='",i+=s.tid,i+="')",console.log("tenantRelationshipsGetById: Attempting GET from /findTenantInformationByTenantId:",i);let c=await(await fetch(i,d)).json();if(c&&typeof c.displayName!==void 0&&c.displayName!==""){if(s!==void 0)s.name=c.displayName,s.domain=c.defaultDomainName;else{console.log("tenantRelationshipsGetById: missing associated tenant for logged in user.");debugger}return console.log("tenantRelationshipsGetById: Successful GET from /findTenantInformationByTenantId: ",c.displayName),!0}else console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ",i)}catch(l){return console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ",l),!1}return!1}async function oe(n,s){if(s)debugger;let r=[g.authorityWW,g.authorityUS,g.authorityCN],t=[g.authorityWWRegex,g.authorityUSRegex,g.authorityCNRegex],e=null;try{for(let i=0;i<3;i++){var a=r[i];if(n.lookupfield=="Domain"?a+=n.domain:n.lookupfield=="Tenant ID"&&(a+=n.tid),a+="/.well-known/openid-configuration",console.log("Attempting GET from openid well-known endpoint: ",a),e=await fetch(a),e.status==200){let l=await e.json();if(l){var o=l.authorization_endpoint;for(let c=0;c<3;c++){var d=o.match(t[c]);if(d!=null)return n.tid=d[2],n.authority=d[1],console.log(`Successful GET from openid well-known endpoint: tid: ${n.tid} authority: ${n.authority}`),!0}}else console.log(`Failed JSON parse of openid well-known endpoint response ${a}.`)}else console.log(`Failed GET from ${a}.`)}}catch(i){console.log("Failed to GET from openid well-known endpoint: ",i)}return(n.tid==""||n.authority=="")&&console.log(`GET from openid well-known endpoint failed to find tenant: ${e?e.statusText:"unknown"}`),!1}async function We(n,s,r){if(s==null||s.spacode==""||r==null){debugger;return{scopes:null,id:null,error:"500: invalid parameter(s) passed to getUserDelegatedScopes"}}let e={method:"GET",headers:await X(n,s)};try{if(r.graphSP==""){let{spid:i,error:l}=await Ne(e,s,"00000003-0000-0000-c000-000000000000");if(l!=""){debugger;return{scopes:null,id:null,error:`${l}`}}r.graphSP=i}let{grants:a,id:o,error:d}=await Ce(e,s,r.graphSP,s.oid);if(d!=""){debugger;return{scopes:null,id:null,error:`${d}`}}return{scopes:a,id:o,error:""}}catch(a){debugger;return console.log(a),{scopes:null,id:null,error:`Exception: ${a}`}}}async function Mt(n,s,r,t){if(s==null||s.spacode==""||r==null){debugger;return!1}let{scopes:e,id:a,error:o}=await We(n,s,r);if(o!=""){debugger;return console.log(`userDelegatedScopesRemove: cannot find userDelegatedScopes for ${s.mail}: ${o}`),!1}e=e.replace(t,"");let d=await Oe(n,s,a,e);if(!d){debugger;return console.log(`userDelegatedScopesRemove: cannot set oauth2PermissionGrants for ${s.mail}: ${o}`),!1}return s.scopes=e.split(" "),d}async function jt(n,s){if(s==null||s.spacode=="")return{users:[],error:"500: invalid user passed to usersGet"};try{let t={method:"GET",headers:await X(n,s)},e=L(s.authority);e+=g.graphUsersPredicate;let o=await(await fetch(e,t)).json();if(typeof o.error<"u")return{users:[],error:`${o.error.code}: ${o.error.message}`};let d=new Array;for(let i of o.value)d.push(i.mail);return{users:d,error:""}}catch(r){return console.log(r),{users:[],error:`Exception: ${r}`}}}async function qt(n,s,r,t){return ze(n,s,r,t)}async function Ht(n,s,r,t){return xe(n,s,r,t)}async function Qt(n,s,r,t,e){return _e(n,s,r,t,e)}async function Kt(n,s,r,t){return Me(n,s,r,t)}async function Jt(n,s,r){return je(n,s,r)}async function Vt(n,s,r,t,e,a,o,d){let i=new y;if(r.id==="1"){if(i=await Ve(n,s,r,a.id,d),i.result){r.tenants.forEach(h=>{(h.configId==="1"||h.configId==="")&&(h.configId=r.id)}),t&&t(r.id);const l={};Object.defineProperty(l,r.id,{value:!0,writable:!0,enumerable:!0}),e(l);let c=a.associatedConfigs.findIndex(h=>h=="1");c!==-1&&(a.associatedConfigs.splice(c,1),a.associatedConfigs.push(r.id))}}else i=await Ze(n,s,r,d);return o.save(),i}async function Zt(n,s,r,t,e){let a=new y;return a=await Je(n,s,r,t,e),a}async function Xt(n,s,r,t,e){return qe(n,s,r,t,e)}async function Yt(n,s,r,t,e){return He(n,s,r,t,e)}async function es(n,s,r,t,e,a){let o=new y;if(e)debugger;try{let d=t.ws.find(i=>i.id===r);if(d!=null){d.associatedConfigs.length=0;let i=await Qe(n,s,a,d.id,e);return i.result&&t.tagWithWorkspaces(),i}else return o.result=!1,o.error="Workspace not found.",o.status=404,o}catch(d){return console.log(d.message),o.error=d.message,o.result=!1,o.status=500,o}}async function ts(n,s,r,t,e){return Ke(n,s,r,t)}async function ss(n,s,r,t,e){console.log(">>>>>> initGet");let a=new y;if(e)debugger;let o=new j;return o.tid=s.tid,o.domain=s.tid,await oe(o,e)?(s.authority=o.authority,t.setTaskStart("GET tenant details",new Date),a.result=await Be(s,o,r,n,e),t.setTaskEnd("GET tenant details",new Date,"complete"),a.result&&(s.companyName=o.name,s.companyDomain=o.domain,t.setTaskStart("POST config init",new Date),a=await Ye(n,s,e),t.setTaskEnd("POST config init",new Date,a.result?"complete":"failed")),a.result&&(t.setTaskStart("GET workspaces",new Date),a=await cs(n,s,r,e),t.setTaskEnd("GET workspaces",new Date,a.result?"complete":"failed")),console.log("initGet complete. Version: "+U()),a):(a.error=`Failed to retrieve authority for user "${s.mail}" TID ${s.tid}.`,a.result=!1,a)}async function rs(n,s,r,t){return st(n,s,r,t)}async function as(n,s,r,t,e){return et(n,s,r,t)}async function ns(n,s,r,t){return Le(n,s,r,t)}async function os(n,s,r,t){return Fe(n,s,r,t)}async function is(n,s,r,t){return await rt(n,s,r,t)}function ls(n,s,r,t){r.map(e=>{let a=null,o=s.us.findIndex(l=>l.oid===e.userId||l.oid===e.email);if(o===-1){let l=s.us.findIndex(c=>c.oid==="1");if(l!==-1){a=s.us.at(l);let c=n.associatedUsers.findIndex(h=>h=="1");c!==-1&&(n.associatedUsers.splice(c,1),n.associatedUsers.push(e.userId))}else a=new K,s.us.push(a)}else a=s.us.at(o);a.sel=t===e.userId,a.oid=e.userId?e.userId:e.email,a.name=e.firstName??a.name,a.mail=e.email,a.tid=e.tenantId;let d=s.ts.find(l=>l.tid===a.tid);d!=null&&(a.authority=d.authority,a.companyName=d.name,a.companyDomain=d.domain),n.associatedUsers.findIndex(l=>l===a.oid)==-1&&n.associatedUsers.push(a.oid)}),s.save()}function us(n,s,r,t){r.map(e=>{let a=null,o=s.ts.findIndex(c=>c.tid===e.tenantId);if(o===-1){let c=s.ts.findIndex(h=>h.tid==="1");if(c!==-1){a=s.ts.at(c);let h=n.associatedTenants.findIndex($=>$=="1");h!==-1&&(n.associatedTenants.splice(h,1),n.associatedTenants.push(e.tenantId))}else a=new j,s.ts.push(a)}else a=s.ts.at(o);a.sel=t===e.tenantId,a.tid=e.tenantId,a.name=e.name,a.domain=e.domain,a.tenantType=e.type.toLowerCase();const d=/^(https:\/\/login.microsoftonline.(?:us|com)\/)organizations\/v2.0$/,i=e.authority.match(d);a.authority=i?i[1]:e.authority,n.associatedTenants.findIndex(c=>c===e.tenantId)==-1&&n.associatedTenants.push(e.tenantId)}),s.save()}function ds(n,s,r,t){r.map(e=>{let a=null,o=s.cs.findIndex(i=>i.id===e.id);if(o===-1){let i=s.cs.findIndex(l=>l.id==="1");if(i!==-1){a=s.cs.at(i);let l=n.associatedConfigs.findIndex(c=>c=="1");l!==-1&&(n.associatedConfigs.splice(l,1),n.associatedConfigs.push(e.id))}else a=new J,s.cs.push(a)}else a=s.cs.at(o);a.sel=t===e.id,a.id=e.id,a.workspaceId=e.workspaceId,a.name=e.name,a.description=e.description,a.isEnabled=e.isEnabled,a.tenants.length=0,e.tenants.map(i=>{let l=new ve;l.tid=i.tenantId,l.sourceGroupId=i.sourceGroupId??"",l.sourceGroupName=i.sourceGroupName??"",l.targetGroupId=i.targetGroupId??"",l.targetGroupName=i.targetGroupName??"",l.configurationTenantType=i.configurationTenantType.toLowerCase(),l.deltaToken=i.deltaToken??"",l.configId=a.id,l.batchId=i.batchId??"",l.isReadPermissionConsented=i.isReadPermissionConsented,l.isWritePermissionConsented=i.isWritePermissionConsented,a.tenants.push(l)}),n.associatedConfigs.findIndex(i=>i===e.id)==-1&&n.associatedConfigs.push(e.id)}),console.log("--------------ii-----------",s),s.save()}async function cs(n,s,r,t){let e=new y;if(t)debugger;try{if(e=await at(n,s,t),e.result){for(let a of e.array){let o=null,d=r.ws.findIndex(G=>G.id===a.id);if(d===-1){let G=r.ws.findIndex(P=>P.id==="1");G!==-1?o=r.ws.at(G):(o=new V,r.ws.push(o))}else o=r.ws.at(d);let i="";for(let G of o.associatedUsers){let P=r.us.find(F=>F.oid===G);P!=null&&P.sel&&(i=P.oid)}let l="";for(let G of o.associatedTenants){let P=r.ts.find(F=>F.tid===G);P!=null&&P.sel&&(l=P.tid)}let c="";for(let G of o.associatedConfigs){let P=r.cs.find(F=>F.id===G);P!=null&&P.sel&&(c=P.id)}o.associatedUsers.length=0,o.associatedTenants.length=0,o.associatedConfigs.length=0,o.id=a.id,o.name=a.name,o.ownerid=a.workspaceOwnerUserId;let h=Ue(n,s,o.id,t),$=tt(n,s,o.id,t),E=Xe(n,s,o.id,t),[W,z,x]=await Promise.all([h,$,E]);if(!W.result)return W;if(!z.result)return z;if(!x.result)return x;us(o,r,z.array,l),ls(o,r,W.array,i),ds(o,r,x.array,c),r.tagWithWorkspaces()}return e}}catch(a){console.log(a.message),e.error=a.message}return e.result=!1,e.status=500,e}async function fs(n,s){let r="",t=U();try{let e=n.getAllAccounts(),a=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==a&&(o=e[i]);r=(await n.acquireTokenSilent({scopes:["https://analysis.windows.net/powerbi/api/App.Read.All","https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All","https://analysis.windows.net/powerbi/api/Report.ReadWrite.All","https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All"],account:o})).accessToken,console.log("PowerBI token acquired silently: "+r.slice(0,20))}catch{console.log("PowerBI token failed to be acquired silently")}return console.log(t),r}async function ie(n,s){const r=new Headers;if(r.append("Content-Type","application/json"),r.append("accept","*/*"),s.azureAccessToken==null||s.azureAccessToken==="")try{let t=n.getAllAccounts(),e=s.oid+"."+s.tid,a=null;for(let d=0;d<t.length;d++)t[d].homeAccountId==e&&(a=t[d]);let o=await n.acquireTokenSilent({scopes:["https://management.azure.com/user_impersonation"],account:a});s.azureAccessToken=o.accessToken,console.log("Front end token acquired silently: "+s.azureAccessToken.slice(0,20))}catch(t){try{console.log("Front end token silent acquisition failure: "+t);let e=n.getAllAccounts(),a=s.oid+"."+s.tid,o=null;for(let d=0;d<e.length;d++)e[d].homeAccountId==a&&(o=e[d]);n.acquireTokenRedirect({scopes:["https://management.azure.com/user_impersonation"],account:o})}catch(e){console.log("Front end token popup acquisition failure: "+e)}}return r.append("Authorization",`Bearer ${s.azureAccessToken}`),r}async function hs(n,s){if(s==null||s.spacode=="")return!1;try{let t={method:"GET",headers:await ie(n,s)},e=M.azureListRootAssignments;e+="'",e+=s.oid,e+="'";let a=await fetch(e,t);if(a.status==200){let o=await a.json();o=o;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await w(a)),!1}catch(r){return console.log(r),!1}return!0}async function ps(n,s){if(s==null||s.spacode=="")return!1;try{let t={method:"POST",headers:await ie(n,s)},e=M.azureElevateAccess,a=await fetch(e,t);if(a.status==200)console.log("Successful call to Azure Resource Graph list root assignments");else return console.log(await w(a)),!1}catch(r){return console.log(r),!1}return!0}async function gs(n,s){let r=new Array;if(s==null||s.spacode=="")return r;try{let e={method:"GET",headers:await ie(n,s)},a=M.azureListRootAssignments;a+="'",a+=s.oid,a+="'";let o=await fetch(a,e);if(o.status==200){let d=await o.json();d=d;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await w(o)),r}catch(t){return console.log(t),r}return r}function ms(n){let s="8d95d21c-c378-4bb0-9f52-88c30d271e7a",r=n.authority.toLowerCase();return r.startsWith("https://login.microsoftonline.com/")?s="8d95d21c-c378-4bb0-9f52-88c30d271e7a":r.startsWith("https://login.microsoftonline.us/")?s="48da942e-ea3d-49e4-a054-81649012f8f2":r.startsWith("https://login.partner.microsoftonline.cn/")&&(s="c91d32e4-dcc5-4d77-826a-16e93ffce666"),`api://${s}/Config.Write`}async function A(n,s){const r=new Headers;r.append("Content-Type","application/json"),r.append("accept","*/*");const t=ms(s);try{let e=n.getAllAccounts(),a=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==a&&(o=e[i]);let d=await n.acquireTokenSilent({scopes:[t],account:o});s.mindlineAccessToken=d.accessToken,console.log("Front end mindline token acquired silently: "+s.mindlineAccessToken.slice(0,20))}catch(e){try{console.log("Front end mindline token silent acquisition failure, triggering redirect: "+e);let a=n.getAllAccounts(),o=s.oid+"."+s.tid,d=null;for(let i=0;i<a.length;i++)a[i].homeAccountId==o&&(d=a[i]);n.acquireTokenRedirect({scopes:[t],account:d})}catch(a){console.log("Front end mindline token redirect acquisition failure: "+a)}}return r.append("Authorization",`Bearer ${s.mindlineAccessToken}`),r}async function w(n){let s="";if(n.status===401&&(s=n.statusText,s!=""))return s;let r=await n.json();if(r.error!==void 0)s=`Error: ${r.error} Message: ${r.message}`;else if(r.errors!==void 0)s=Object.keys(r.errors).reduce((a,o)=>a+o+": "+r.errors[o]+" ","");else if(r.title!==void 0)s=r.title;else debugger;return s}async function Fe(n,s,r,t){let e=new y;if(r.oid==""&&r.mail==""||t=="")return e.result=!1,e.error="adminDelete: invalid parameters",e.status=500,e;let a=null;a=new URL(T.adminEndpoint()),a.searchParams.append("workspaceId",t),a.searchParams.append("email",r.mail);let d={method:"DELETE",headers:await A(n,s)};try{console.log("Attempting DELETE from /admin: "+a.href);let i=await fetch(a.href,d);return i.status===200&&i.statusText==="OK"?(console.log(`Successful DELETE from /admin: ${a.href}`),e):(e.error=await w(i),console.log(`Failed DELETE from /admin: ${a.href}`),console.log(e.error),e.status=500,e.result=!1,e)}catch(i){e.error=i.message,e.status=500,e.result=!1,console.log(i.message)}return e}async function Ue(n,s,r,t){let e=new y;if(r==="")return e.result=!1,e.status=500,e.error="adminsGet: no workspace provided",e;let a=T.adminsEndpoint(),o=new URL(a);o.searchParams.append("workspaceId",r);let i={method:"GET",headers:await A(n,s)};try{if(t)debugger;console.log("Attempting GET from /admins: "+o.href);let l=await fetch(o.href,i);if(l.status===200&&l.statusText==="OK"){let c=await l.json();return c!=null?(e.array=c,console.log(`Successful GET from /admins: ${e.array.reduce(($,E)=>$+E.email+" ","")}`),e):(e.error="Failed GET from /admins: failed to JSON-parse response",console.log(e.error),e.status=500,e.result=!1,e)}else return console.log(`Failed GET from /admins: ${o.href}`),e.error=await w(l),e.status=500,e.result=!1,console.log(e.error),e}catch(l){e.error=l.message,e.status=500,e.result=!1,console.log(l.message)}return e}async function Le(n,s,r,t){let e=new y;if(r.mail==""||r.authority==""||r.tid==="")return e.result=!1,e.error="adminPost: invalid argument",e.status=500,e;let a=T.adminEndpoint();const o=await A(n,s);let d=`
|
|
1
|
+
(function(f,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("class-transformer")):typeof define=="function"&&define.amd?define(["exports","class-transformer"],S):(f=typeof globalThis<"u"?globalThis:f||self,S(f.sync={},f.classTransformer))})(this,(function(f,S){"use strict";var ws=Object.defineProperty;var pt=f=>{throw TypeError(f)};var Ts=(f,S,G)=>S in f?ws(f,S,{enumerable:!0,configurable:!0,writable:!0,value:G}):f[S]=G;var c=(f,S,G)=>Ts(f,typeof S!="symbol"?S+"":S,G),Ss=(f,S,G)=>S.has(f)||pt("Cannot "+G);var ne=(f,S,G)=>S.has(f)?pt("Cannot add the same private member more than once"):S instanceof WeakSet?S.add(f):S.set(f,G);var B=(f,S,G)=>(Ss(f,S,"access private method"),G);var ee,gt,O,Te,Se,Ie,q,Ae;const G=[{oid:"1",name:"",mail:"",authority:"",tid:"",companyName:"",companyDomain:"",session:"Sign In",sel:!0}],mt=[{tid:"1",name:"",domain:"",tenantType:"",authority:"",sel:!0,graphSP:""}],yt=[],wt=[{id:"1",name:"",associatedUsers:["1"],associatedTenants:["1"],associatedConfigs:[],sel:!0}],Tt=[{Run:"3",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"},{Run:"2",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"},{Run:"1",Start:"2023-09-17T12:00:00.000-07:00",POST:"2023-09-17T12:00:09.500-07:00",Read:"2023-09-17T12:00:15.500-07:00",Write:"2023-09-17T12:01:30.000-07:00"}],St=[{type:"mg",resource:"Tenant Root Group",cost:0,expanded:!0,resources:[{type:"sub",resource:"Applications",cost:16677.52,expanded:!0,resources:[{type:"rg",resource:"ssfdev",cost:7500.08,expanded:!0,resources:[{type:"resources",resource:"SSFServices",cost:0,expanded:!1,resources:[]}]}]},{type:"sub",resource:"Infrastructure",cost:8737.58,expanded:!0,resources:[{type:"rg",resource:"SFFA_Prod_Mgmt_Shared_Resources_RG",cost:7500.08,expanded:!0,resources:[{type:"resources",resource:"SSFA-Prod-UTIL-01",cost:0,expanded:!1,resources:[]}]}]}]}],It=[{type:"user",actor:"arvind@mindline.site",resource:"kv-syncproject",role:"Key Vault Certificate Officer",updatedby:"arvind@mindline.site",updatedon:"2023-09-06T15:36:45.7760714Z",resources:[]},{type:"app",actor:"mindline1-sync-512169f5-38d1-4b57-be8b-967f2d0ae4c6",resource:"dev-subscription",role:"Contributor",updatedby:"arvind@mindline.site",updatedon:"2023-09-06T15:36:45.7760714Z",resources:[]}],_="workspaceIDs";function At(n,s){return n+s}function bt(){return"hello NPM"}function U(){return"1.0.111"}class y{constructor(){c(this,"result");c(this,"status");c(this,"error");c(this,"version");c(this,"array");this.result=!0,this.status=200,this.error="",this.version=U(),this.array=null}}class M{}c(M,"azureElevateAccess","https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"),c(M,"azureListRootAssignments","https://management.azure.com/providers/Microsoft.Authorization/roleAssignments?api-version=2022-04-01&$filter=principalId+eq+");const k=class k{static adminEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admin`}static adminIncompleteEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/incomplete-admin`}static adminsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admins`}static auditConfigEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-configuration`}static auditEventsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-events`}static configConsentEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/consent`}static configEnabledEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/status`}static configEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration`}static configsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configurations`}static initEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/init`}static readerStartSyncEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/startSync`}static tenantEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenant`}static tenantsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenants`}static workspaceEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace`}static workspacesEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspaces`}static workspaceConfigsEndpoint(){return`https://${k.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace-configurations`}static signalREndpoint(){return`https://${k.environmentTag}-signalrdispatcher-westus.azurewebsites.net/statsHub`}static statsEndpoint(){return`https://${k.environmentTag}-signalrdispatcher-westus.azurewebsites.net/api/stats`}};c(k,"environmentTag","dev");let T=k;class p{}c(p,"graphGroupsPredicate","v1.0/groups"),c(p,"graphMailPredicate","v1.0/me/messages"),c(p,"graphMePredicate","v1.0/me"),c(p,"graphOauth2PermissionGrantsPredicate","v1.0/oauth2PermissionGrants"),c(p,"graphServicePrincipalsPredicate","v1.0/servicePrincipals"),c(p,"graphUsersPredicate","v1.0/users"),c(p,"graphTenantByDomainPredicate","beta/tenantRelationships/findTenantInformationByDomainName"),c(p,"graphTenantByIdPredicate","beta/tenantRelationships/findTenantInformationByTenantId"),c(p,"authorityWW","https://login.microsoftonline.com/"),c(p,"authorityWWRegex",/^(https:\/\/login\.microsoftonline\.com\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/),c(p,"authorityUS","https://login.microsoftonline.us/"),c(p,"authorityUSRegex",/^(https:\/\/login\.microsoftonline\.us\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/),c(p,"authorityCN","https://login.partner.microsoftonline.cn/"),c(p,"authorityCNRegex",/^(https:\/\/login\.partner\.microsoftonline\.cn\/)([\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{4}-[\dA-Fa-f]{12})\/oauth2\/authorize$/);class $t{constructor(){c(this,"id","");c(this,"displayName","");c(this,"description","")}}class kt{constructor(){c(this,"group","");c(this,"value","");c(this,"consented",!1);c(this,"removable",!1);c(this,"expanded","")}static compareByValue(s,r){return s.value.localeCompare(r.value)}static compareByGroup(s,r){return s.group.localeCompare(r.group)}}class V{constructor(){c(this,"oid");c(this,"name");c(this,"mail");c(this,"authority");c(this,"tid");c(this,"companyName");c(this,"companyDomain");c(this,"workspaceIDs");c(this,"session");c(this,"spacode");c(this,"graphAccessToken");c(this,"mindlineAccessToken");c(this,"azureAccessToken");c(this,"loginHint");c(this,"scopes");c(this,"authTS");c(this,"sel");c(this,"loggingIn");this.oid="",this.name="",this.mail="",this.authority="",this.tid="",this.companyName="",this.companyDomain="",this.workspaceIDs="",this.session="Sign In",this.spacode="",this.graphAccessToken="",this.mindlineAccessToken="",this.azureAccessToken="",this.loginHint="",this.scopes=new Array,this.authTS=new Date(0),this.sel=!1,this.loggingIn=!1}}var be=(n=>(n[n.invalid=0]="invalid",n[n.aad=1]="aad",n[n.ad=2]="ad",n[n.googleworkspace=3]="googleworkspace",n))(be||{}),$e=(n=>(n[n.read=1]="read",n[n.write=2]="write",n[n.notassigned=3]="notassigned",n))($e||{});class j{constructor(){c(this,"tid");c(this,"name");c(this,"domain");c(this,"tenantType");c(this,"authority");c(this,"workspaceIDs");c(this,"sel");c(this,"graphSP");c(this,"lookupfield");this.tid="",this.name="",this.domain="",this.tenantType="aad",this.authority="",this.workspaceIDs="",this.sel=!1,this.graphSP="",this.lookupfield="Domain"}}function Et(n,s){switch(n){case p.authorityWW:return s===1?"85d35da2-4118-4b03-aa05-605cedd7f2f8":"63100afe-506e-4bb2-8ff7-d8d5ab373129";case p.authorityUS:return s===1?"b08630c7-e227-4215-9746-afc9286fb864":"17aa5d5a-f09f-4cec-87a6-28596f9fa513";case p.authorityCN:return s===1?"7db7293b-add9-4a3f-8562-1a20bfe27d5e":"debd015b-1154-4111-a4cb-fc220a537697";default:debugger;return""}}function L(n){switch(n){case p.authorityWW:return"https://graph.microsoft.com/";case p.authorityUS:return"https://graph.microsoft.us/";case p.authorityCN:return"https://microsoftgraph.chinacloudapi.cn/";default:debugger;return""}}function Pt(n){switch(n){case p.authorityWW:return"https://login.microsoftonline.com/";case p.authorityUS:return"https://login.microsoftonline.us/";case p.authorityCN:return"https://login.partner.microsoftonline.cn/";default:debugger;return""}}var ke=(n=>(n[n.source=1]="source",n[n.target=2]="target",n[n.sourcetarget=3]="sourcetarget",n))(ke||{});class Ee{constructor(){c(this,"tid");c(this,"sourceGroupId");c(this,"sourceGroupName");c(this,"targetGroupId");c(this,"targetGroupName");c(this,"configurationTenantType");c(this,"deltaToken");c(this,"usersWritten");c(this,"configId");c(this,"batchId");c(this,"isReadPermissionConsented");c(this,"isWritePermissionConsented");this.tid="",this.sourceGroupId="",this.sourceGroupName="",this.targetGroupId="",this.targetGroupName="",this.configurationTenantType="source",this.deltaToken="",this.usersWritten=0,this.configId="",this.batchId="",this.isReadPermissionConsented=!1,this.isWritePermissionConsented=!1}}class Z{constructor(){c(this,"id");c(this,"workspaceId");c(this,"name");c(this,"description");c(this,"tenants");c(this,"isEnabled");c(this,"workspaceIDs");c(this,"sel");this.id="",this.name="",this.workspaceId="",this.description="",this.tenants=new Array,this.isEnabled=!1,this.workspaceIDs="",this.sel=!1}}class vt{constructor(){c(this,"id");c(this,"workspaceId");c(this,"name");c(this,"description");c(this,"isEnabled");c(this,"isReadPermissionConsented");c(this,"email");c(this,"tenantId");c(this,"sel");this.id="",this.name="",this.workspaceId="",this.description="",this.isEnabled=!1,this.isReadPermissionConsented=!1,this.email="",this.tenantId="",this.sel=!1}}class Q{constructor(){c(this,"id");c(this,"name");c(this,"ownerid");c(this,"associatedUsers");c(this,"associatedTenants");c(this,"associatedConfigs");c(this,"sel");this.id="",this.name="",this.ownerid="",this.associatedUsers=new Array,this.associatedTenants=new Array,this.associatedConfigs=new Array,this.sel=!1}}function R(){let n;try{n=window.localStorage;const s="__storage_test__";return n.setItem(s,s),n.removeItem(s),!0}catch(s){return s instanceof DOMException&&(s.code===22||s.code===1014||s.name==="QuotaExceededError"||s.name==="NS_ERROR_DOM_QUOTA_REACHED")&&n&&n.length!==0}}class Dt{constructor(s=!1){ne(this,ee);c(this,"version",U());c(this,"tab",0);c(this,"us",[]);c(this,"ts",[]);c(this,"cs",[]);c(this,"acs",[]);c(this,"ws",[]);c(this,"configlevelconsent_configid","");c(this,"configlevelconsent_access",3);this.init(s)}init(s){if(console.log(`Calling InitInfo::init(bClearLocalStorage: ${s?"true":"false"})`),R()){let o=localStorage.getItem("InitInfo");if(o!=null&&typeof o=="string"&&o!==""){let i=JSON.parse(o);if(i.us.length!==0)if(s)localStorage.removeItem("InitInfo");else{B(this,ee,gt).call(this,i);return}}}this.tab=0,this.version=U(),this.configlevelconsent_configid="",this.configlevelconsent_access=3;var r=JSON.stringify(G),t=JSON.stringify(mt),e=JSON.stringify(yt),a=JSON.stringify(wt);try{this.us=S.deserializeArray(V,r),this.ts=S.deserializeArray(j,t),this.cs=S.deserializeArray(Z,e),this.ws=S.deserializeArray(Q,a),this.tagWithWorkspaces()}catch{debugger}}save(){let s=JSON.stringify(this);localStorage.setItem("InitInfo",s)}tagWithWorkspaces(){this.us.map(s=>s.workspaceIDs=""),this.ts.map(s=>s.workspaceIDs=""),this.cs.map(s=>s.workspaceIDs="");for(let s of this.ws){for(let r of s.associatedUsers){let t=this.us.find(e=>e.oid===r);if(t!==void 0)t[_]+=s.id,t[_]+=" ";else debugger}for(let r of s.associatedTenants){let t=this.ts.find(e=>e.tid===r);if(t!==void 0)t[_]+=s.id,t[_]+=" ";else debugger}for(let r of s.associatedConfigs){let t=this.cs.find(e=>e.id===r);if(t!==void 0)t[_]+=s.id,t[_]+=" ";else debugger}}return!0}}ee=new WeakSet,gt=function(s){this.tab=s.tab,this.version=U(),this.configlevelconsent_configid=s.configlevelconsent_configid,this.configlevelconsent_access=s.configlevelconsent_access,typeof s.us>"u"?this.us=new Array:this.us=s.us.map(r=>{let t=new V;return t.oid=r.oid,t.name=r.name,t.mail=r.mail,t.authority=r.authority,t.tid=r.tid,t.companyName=r.companyName,t.companyDomain=r.companyDomain,t.workspaceIDs=r.workspaceIDs,t.session=r.session,t.spacode=r.spacode,t.graphAccessToken=r.graphAccessToken,t.mindlineAccessToken=r.mindlineAccessToken,t.azureAccessToken=r.azureAccessToken,t.loginHint=r.loginHint,t.scopes=r.scopes,t.authTS=new Date(r.authTS),t.sel=r.sel,t.loggingIn=r.loggingIn,t}),typeof s.ts>"u"?this.ts=new Array:this.ts=s.ts.map(r=>{let t=new j;return t.tid=r.tid,t.name=r.name,t.domain=r.domain,t.tenantType=r.tenantType,t.authority=r.authority,t.workspaceIDs=r.workspaceIDs,t.sel=r.sel,t.lookupfield=r.lookupfield,t}),typeof s.cs>"u"?this.cs=new Array:this.cs=s.cs.map(r=>{let t=new Z;return t.id=r.id,t.workspaceId=r.workspaceId,t.name=r.name,t.description=r.description,t.tenants=r.tenants,t.isEnabled=r.isEnabled,t.workspaceIDs=r.workspaceIDs,t.sel=r.sel,t}),typeof s.ws>"u"?this.ws=new Array:this.ws=s.ws.map(r=>{let t=new Q;return t.id=r.id,t.name=r.name,t.ownerid=r.ownerid,t.associatedUsers=r.associatedUsers,t.associatedTenants=r.associatedTenants,t.associatedConfigs=r.associatedConfigs,t.sel=r.sel,t})};const Gt=[{id:1,task:"initialization",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:22",status:"not started",expanded:!0,subtasks:[{id:2,task:"authenticate user",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:01",status:"not started"},{id:3,task:"reload React",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:07",status:"not started"},{id:4,task:"GET tenant details",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:01",status:"not started"},{id:5,task:"POST config init",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:10",status:"not started"},{id:6,task:"GET workspaces",start:"1970-01-01T00:00:00",end:"1970-01-01T00:00:00",expected:"0:04",status:"not started"}]}];class Rt{constructor(s){ne(this,O);c(this,"tasks");this.tasks=[new X],this.init(s)}init(s){if(console.log(`Calling TaskArray::init(bClearLocalStorage: ${s?"true":"false"})`),this.tasks.length=0,s&&R()&&localStorage.removeItem("Tasks"),R()){let r=localStorage.getItem("Tasks");if(r!=null&&typeof r=="string"&&r!==""){let e=JSON.parse(r);if(this.tasks=B(this,O,Se).call(this,e.tasks),this.tasks.length!==0)return}}this.tasks=B(this,O,Se).call(this,Gt)}setTaskStart(s,r){let t=B(this,O,Te).call(this,s);if(t!=null&&t!=null)t.setStart(r),t.status="in progress",B(this,O,Ie).call(this);else debugger}setTaskEnd(s,r,t){let e=B(this,O,Te).call(this,s);if(e!=null&&e!=null)e.setEnd(r),e.status=t,B(this,O,Ie).call(this);else debugger}}O=new WeakSet,Te=function(s){let r=this.tasks.find(t=>t.task==s);if(r==null||r==null){for(r of this.tasks)if(r.subtasks!=null&&r.subtasks!=null&&(r=r.subtasks.find(t=>t.task==s),r!=null&&r!=null))break}return r},Se=function(s){return s.map(r=>{let t=new X;return t.id=r.id,t.task=r.task,t.setStart(new Date(r.start)),t.setEnd(new Date(r.end)),t.expected=r.expected,t.status=r.status,t.expanded=r.expanded,typeof r.subtasks<"u"&&r.subtasks!=null&&(t.subtasks=r.subtasks.map(e=>{let a=new X;return a.id=e.id,a.task=e.task,a.setStart(new Date(e.start)),a.setEnd(new Date(e.end)),a.expected=e.expected,a.status=e.status,a.expanded=e.expanded,a})),t})},Ie=function(){let s=JSON.stringify(this);R()&&localStorage.setItem("Tasks",s)};class X{constructor(){c(this,"id",0);c(this,"task","");c(this,"start",new Date);c(this,"startDisplay","");c(this,"end",new Date);c(this,"endDisplay","");c(this,"elapsedDisplay","");c(this,"expected",0);c(this,"status","");c(this,"expanded",!1);c(this,"subtasks",[])}setEnd(s){this.end=s,this.endDisplay=`${this.end.getMinutes().toString().padStart(2,"0")}:${this.end.getSeconds().toString().padStart(2,"0")}`;let r=0,t=this.end.getSeconds()-this.start.getSeconds();t<0&&(t+=60,r=-1);let e=this.end.getMinutes()-this.start.getMinutes()+r;e<0&&(e+=60),this.elapsedDisplay=`${e.toString().padStart(2,"0")}:${t.toString().padStart(2,"0")}`}setStart(s){this.start=s,this.startDisplay=`${this.start.getMinutes().toString().padStart(2,"0")}:${this.start.getSeconds().toString().padStart(2,"0")}`}}class H{constructor(s){c(this,"Run",0);c(this,"Start",new Date);c(this,"startDisplay","");c(this,"POST");c(this,"postDisplay");c(this,"Read");c(this,"readDisplay");c(this,"Write");c(this,"writeDisplay");c(this,"Duration");c(this,"durationDisplay");this.Run=s,this.start(""),this.POST=new Date,this.postDisplay="",this.Read=new Date,this.readDisplay="",this.Write=new Date,this.writeDisplay="",this.Duration=new Date,this.durationDisplay=""}start(s){s==""?this.Start=new Date:this.Start=new Date(s),this.startDisplay=`${this.Start.getMinutes().toString().padStart(2,"0")}:${this.Start.getSeconds().toString().padStart(2,"0")}`}post(s){s==""?this.POST=new Date:this.POST=new Date(s),this.postDisplay=`${this.POST.getMinutes().toString().padStart(2,"0")}:${this.POST.getSeconds().toString().padStart(2,"0")}`}read(s){s==""?this.Read=new Date:this.Read=new Date(s),this.readDisplay=`${this.Read.getMinutes().toString().padStart(2,"0")}:${this.Read.getSeconds().toString().padStart(2,"0")}`}write(s){s==""?this.Write=new Date:this.Write=new Date(s),this.writeDisplay=`${this.Write.getMinutes().toString().padStart(2,"0")}:${this.Write.getSeconds().toString().padStart(2,"0")}`,this.Duration=new Date(this.Write.getTime()-this.Start.getTime()),this.durationDisplay=`${this.Duration.getMinutes().toString().padStart(2,"0")}:${this.Duration.getSeconds().toString().padStart(2,"0")}`}}class Pe{constructor(s){ne(this,q);c(this,"milestones",[]);this.init(s)}init(s){if(R()){let r=localStorage.getItem("syncmilestones");if(r!=null&&typeof r=="string"&&r!==""){let e=JSON.parse(r);if(e.length!==0)if(s)localStorage.removeItem("syncmilestones");else{B(this,q,Ae).call(this,e);return}}}B(this,q,Ae).call(this,Tt)}save(){let s=JSON.stringify(this.milestones);R()&&localStorage.setItem("syncmilestones",s)}start(s){if(this.milestones==null||this.milestones.length<1){debugger;return}let r=Number(this.milestones[0].Run),t=new H(r+1);this.milestones.unshift(t),this.milestones=this.milestones.map(e=>{let a=new H(e.Run);return a.Start=e.Start,a.startDisplay=e.startDisplay,a.POST=e.POST,a.postDisplay=e.postDisplay,a.Read=e.Read,a.readDisplay=e.readDisplay,a.Write=e.Write,a.writeDisplay=e.writeDisplay,a.Duration=e.Duration,a.durationDisplay=e.durationDisplay,a}),s(this.milestones),console.log(`Start milestone: ${this.milestones[0].Run}:${this.milestones[0].Start}`)}unstart(s){if(this.milestones==null||this.milestones.length<1){debugger;return}let r=this.milestones.shift();this.milestones=this.milestones.map(t=>{let e=new H(t.Run);return e.Start=t.Start,e.startDisplay=t.startDisplay,e.POST=t.POST,e.postDisplay=t.postDisplay,e.Read=t.Read,e.readDisplay=t.readDisplay,e.Write=t.Write,e.writeDisplay=t.writeDisplay,e.Duration=t.Duration,e.durationDisplay=t.durationDisplay,e}),s(this.milestones),console.log(`Unstart removed first milestone: ${r.Run}:${r.Start}`)}post(s){if(this.milestones==null||this.milestones.length<1){debugger;return}this.milestones[0].post(""),s(this.milestones),console.log(`POST milestone: ${this.milestones[0].Run}:${this.milestones[0].POST}`)}read(s){if(this.milestones==null||this.milestones.length<1){debugger;return}this.milestones[0].read(""),s(this.milestones),console.log(`Read milestone: ${this.milestones[0].Run}:${this.milestones[0].Read}`)}write(s){if(this.milestones==null||this.milestones.length<1){debugger;return}for(this.milestones[0].write("");this.milestones.length>10;){let r=this.milestones.pop();console.log(`Removed milestone #${r.Run}: ${r.Start}`)}this.save(),this.milestones=this.milestones.map(r=>{let t=new H(r.Run);return t.Start=r.Start,t.startDisplay=r.startDisplay,t.POST=r.POST,t.postDisplay=r.postDisplay,t.Read=r.Read,t.readDisplay=r.readDisplay,t.Write=r.Write,t.writeDisplay=r.writeDisplay,t.Duration=r.Duration,t.durationDisplay=r.durationDisplay,t}),s(this.milestones)}}q=new WeakSet,Ae=function(s){s==null?this.milestones=new Array:this.milestones=s.map(r=>{let t=new H(Number(r.Run));return t.start(r.Start),t.post(r.POST),t.read(r.Read),t.write(r.Write),t})};class Ct{constructor(s,r,t){c(this,"tenantNodes");c(this,"pb_startTS");c(this,"pb_progress");c(this,"pb_idle");c(this,"pb_total");c(this,"pb_timer");c(this,"pollIntervalSeconds",5);c(this,"pollTimer",null);c(this,"pollLastUpdatedByBatchId",{});c(this,"pollInstance",null);c(this,"pollAuthorizedUser",null);c(this,"pollBatchIdArray",[]);c(this,"setIdleText",null);c(this,"statsHydrationHandler",null);c(this,"milestoneArray");this.tenantNodes=new Array,this.init(s,r,t),this.pb_startTS=0,this.pb_progress=0,this.pb_timer=null,this.pb_idle=0,this.pb_total=0,this.milestoneArray=new Pe(!1)}clearStoredBatchIds(){R()&&(localStorage.setItem("BatchIdArray","[]"),localStorage.removeItem("BatchIdArrayProgress"))}init(s,r,t){console.log(`Calling BatchArray::init(config: "${s?s.name:"null"}", bClearLocalStorage: ${t?"true":"false"})`),t&&R()&&(localStorage.removeItem(s.name),this.milestoneArray.init(t)),s!=null&&s.tenants!=null&&r!=null&&(this.tenantNodes.length=0,s.tenants.map(e=>{if(e.configurationTenantType==="source"||e.configurationTenantType==="sourcetarget"){let a=r.ts.find(o=>o.tid===e.tid);if(a!=null){let o=new oe(e.tid,a.name,e.batchId);this.tenantNodes.push(o)}else{console.log(`Error: no tenant found for config source tenant ${s.name}`);debugger;return}}}),this.tenantNodes.map(e=>{s.tenants.map(a=>{if((a.configurationTenantType==="target"||a.configurationTenantType==="sourcetarget")&&a.tid!==e.tid){let o=r.ts.find(d=>d.tid===a.tid);if(o!=null){let d=new oe(a.tid,o.name,a.batchId);e.targets.push(d),e.expanded=!0}else{console.log(`Error: no tenant found for config target tenant ${s.name}`);debugger;return}}})}))}initializeProgressBar(s,r,t,e){this.setIdleText=t,this.pb_startTS=Date.now(),this.pb_progress=0,this.pb_idle=0,this.pb_total=0,s(this.pb_progress),t("Starting sync..."),this.pb_timer=setInterval(()=>{console.log("this.tenantNodes",this.tenantNodes),this.pb_total=this.pb_total+1,this.pb_idle=this.pb_idle+1,t(`${this.pb_total} seconds elapsed. Last update ${this.pb_idle} seconds ago.`)},1e3),this.milestoneArray.start(e)}stopPolling(){this.pollTimer!=null&&(clearInterval(this.pollTimer),this.pollTimer=null),this.pollInstance=null,this.pollAuthorizedUser=null,this.pollBatchIdArray=[],this.pollLastUpdatedByBatchId={}}async pollStatsOnce(){if(this.pb_timer!=null&&!(this.pollInstance==null||this.pollAuthorizedUser==null)&&this.statsHydrationHandler&&!(!this.pollBatchIdArray||this.pollBatchIdArray.length===0))for(const s of this.pollBatchIdArray){const r=s==null?void 0:s.BatchId;if(!r)continue;const t=await at(this.pollInstance,this.pollAuthorizedUser,r);if(!t.result||!t.array||!t.array[0])continue;const e=t.array[0],a=e.lastUpdated,o=this.pollLastUpdatedByBatchId[r];this.pollLastUpdatedByBatchId[r]=a??"",!(!a||a===o)&&this.statsHydrationHandler(r,e.stats)}}uninitializeProgressBar(s,r,t,e){this.pb_startTS=0,this.pb_progress=0,s(this.pb_progress),r("sync failed to execute"),clearInterval(this.pb_timer),this.pb_timer=null,this.pb_idle=0,t(`No updates seen for ${this.pb_idle} seconds.`),this.milestoneArray.unstart(e)}calculateProgress(s,r,t,e,a){if(s<=0)return 0;const o=Math.min(s,r+e),d=Math.min(s,t+e+a),i=o+d;return Math.min(99,Math.round(i/(s*2)*100))}updateProgressFromTotals(s,r,t,e,a,o){const d=this.calculateProgress(s,r,t,e,a);this.pb_progress=Math.max(this.pb_progress,d),o(this.pb_progress),R()&&localStorage.setItem("BatchIdArrayProgress",String(this.pb_progress))}initializeSignalR(s,r,t,e,a,o,d,i,l,u,h,$,E,W,z,x,D){this.milestoneArray.post(h),$("started sync, waiting for updates..."),this.init(s,r,!1);let P=(F,nt)=>{var ft,ht;this.pb_idle=0;let K=t.find(g=>g.BatchId==F);if(K==null){console.log(`Batch ${F} not found in batchIdArray.`);debugger;return}let m=this.tenantNodes.find(g=>g.tid===K.SourceId);if(m==null){console.log(`Tenant ${K.SourceId} not found in BatchArray.`);debugger;return}m.batchId=K.BatchId;let C=Object.keys(nt),N=Object.values(nt),de=!1,ot=!1;for(let g=0;g<C.length;g++){let v=C[g].endsWith("TotalCount"),re=C[g].endsWith("CurrentCount"),me=C[g].endsWith("ExtCount"),ae=C[g].endsWith("DeferredCount"),ye=C[g].endsWith("RescheduledCount");if(me&&(m.excluded=Math.max(Number(N[g]),m.excluded),m.targets.map(I=>{I.excluded=m.excluded,I.update(I.total,I.read,I.excluded,I.written,I.deferred)})),v&&(de=Number(N[g])==0,m.total=Math.max(Number(N[g]),m.total),m.targets.map(I=>{I.total=m.total,I.update(I.total,I.read,I.excluded,I.written,I.deferred)})),C[g].startsWith("Reader")){let I=/Reader\/TID:(.+)\/TotalCount/;if(re&&(I=/Reader\/TID:(.+)\/CurrentCount/),me&&(I=/Reader\/TID:(.+)\/ExtCount/),ae&&(I=/Reader\/TID:(.+)\/DeferredCount/),ye&&(I=/Reader\/TID:(.+)\/RescheduledCount/),C[g].match(I)==null){console.log(`tid not found in ${C[g]}.`);debugger;return}v?(de=Number(N[g])==0,m.total=Math.max(Number(N[g]),m.total),console.log(`----- ${m.name} TID: ${m.tid} batchId: ${m.batchId}`),console.log(`----- ${m.name} Total To Read: ${m.total}`)):(ot=Number(N[g])==0,re?(m.read=Math.max(Number(N[g]),m.read),console.log(`----- ${m.name} Currently Read: ${m.read}`)):ae&&(m.deferred=Math.max(Number(N[g]),m.deferred),console.log(`----- ${m.name} Deferred: ${m.deferred}`)))}if(m.nothingtosync=de&&ot,C[g].startsWith("Writer")){let I=/Writer\/TID:(.+)\/TotalCount/;re&&(I=/Writer\/TID:(.+)\/CurrentCount/),me&&(I=/Writer\/TID:(.+)\/ExtCount/),ae&&(I=/Writer\/TID:(.+)\/DeferredCount/),ye&&(I=/Writer\/TID:(.+)\/RescheduledCount/);let we=C[g].match(I);if(we==null){console.log(`tid not found in ${C[g]}.`);debugger;return}let A=m.targets.find(ys=>ys.tid===we[1]);if(A==null){console.log(`Writer ${m.name} not found under Reader ${m.name}.`);debugger;return}if(A.total=Math.max(Number(m.total),A.total),A.total=Math.max(Number(m.total),A.total),A.batchId=K.BatchId,v)A.total=Math.max(Number(N[g]),A.total),console.log(`----- ${A.name} TID: ${A.tid} batchId: ${A.batchId}`),console.log(`----- ${A.name} Total To Write: ${A.total}`);else if(re)A.written=Math.max(Number(N[g]),A.written),console.log(`----- ${A.name} Total Written: ${A.written}`);else if(ae||ye)A.deferred=Math.max(Number(N[g]),A.deferred),console.log(`----- ${A.name} Total Deferred: ${A.deferred}`);else{console.log("unknown writer type");debugger;return}A.update(A.total,A.read,A.excluded,A.written,A.deferred)}}m.update(m.total,m.read,m.excluded,m.written,m.deferred);let it=!0,ue=!0,lt=!1,ct=!0,J=0,fe=0,te=0,he=0,se=0,pe=0,ge=0;this.tenantNodes.map(g=>{g.targets.map(v=>{ue&&(ue=v.status=="complete"||v.status=="failed"),lt||(lt=v.total>0||v.status!="not started"),he+=Math.max(v.total,g.total),se+=v.written,pe+=v.excluded,ge+=v.deferred}),ct&&(ct=g.nothingtosync),it&&(it=g.total>0&&g.read+g.excluded>=g.total),J+=g.total,fe+=g.read,te+=g.excluded});const dt=J-te,ms=se+ge,ut=dt>0&&dt===ms;ut&&(ue=!0,this.tenantNodes.forEach(g=>{g.targets.forEach(v=>{v.status!=="failed"&&(v.status="complete")}),g.status!=="failed"&&(g.status="complete")})),a(J),d(fe),o(te),i(Math.max(he,J)),u(se),l(pe),this.updateProgressFromTotals(Math.max(J,he),fe,se,Math.max(te,pe),ge,E),ct?(this.milestoneArray.write(h),this.stopPolling(),$("nothing to sync"),this.pb_timer&&(clearInterval(this.pb_timer),this.pb_timer=null),this.pb_progress=100,E(this.pb_progress),(ft=this.setIdleText)==null||ft.call(this,"Complete (nothing to sync)."),this.clearStoredBatchIds(),console.log('Setting config sync result: "nothing to sync"')):(it&&(this.milestoneArray.read(h),$("reading complete"),console.log('Setting config sync result: "reading complete"'),e(s.workspaceId)),ue&&ut?(this.milestoneArray.write(h),this.stopPolling(),$("sync complete"),this.pb_timer&&(clearInterval(this.pb_timer),this.pb_timer=null),this.pb_progress=100,E(this.pb_progress),(ht=this.setIdleText)==null||ht.call(this,"Complete."),this.clearStoredBatchIds(),console.log('Setting config sync result: "complete"')):lt?($("writing in progress"),console.log('Setting config sync result: "writing in progress"')):this.milestoneArray.milestones[0].Read==null&&($("reading in progress"),console.log('Setting config sync result: "reading in progress"')))};this.statsHydrationHandler=P,x&&D&&(this.pollInstance=x,this.pollAuthorizedUser=D,this.pollBatchIdArray=t,this.stopPolling(),this.pollInstance=x,this.pollAuthorizedUser=D,this.pollBatchIdArray=t,this.pollStatsOnce(),this.pollTimer=setInterval(()=>{this.pollStatsOnce()},this.pollIntervalSeconds*1e3))}async startSync(s,r,t){let e=new y;if(this.tenantNodes==null||this.tenantNodes.length==0){debugger;return e.result=!1,e.error="startSync: invalid parameters",e.status=500,e}return e=await rt(s,r,t),e}}class oe{constructor(s,r,t){c(this,"expanded");c(this,"status","");c(this,"name");c(this,"tid");c(this,"batchId");c(this,"total",0);c(this,"read",0);c(this,"excluded",0);c(this,"written",0);c(this,"deferred",0);c(this,"nothingtosync");c(this,"targets");this.expanded=!1,this.name=r,this.tid=s,this.batchId=t,this.nothingtosync=!1,this.targets=new Array,this.update(0,0,0,0,0)}update(s,r,t,e,a){if(this.total=s,this.read=r,this.excluded=t,this.written=e,this.deferred=a,this.read===0&&this.written===0&&(this.status="not started"),this.read>0){if(this.read+this.excluded<this.total)this.status="in progress";else if(this.read+this.excluded===this.total)if(this.targets!=null&&this.targets.length>0){const o=this.targets.every(d=>d.status==="complete"||d.status==="failed");this.status=o?"complete":"in progress"}else this.status="complete"}else this.written>0&&(this.written+this.deferred+this.excluded<this.total?this.status="in progress":this.written+this.deferred+this.excluded===this.total?this.status="complete":this.written+this.deferred+this.excluded>=this.total&&(this.status="failed"))}}class ie{constructor(s,r){c(this,"resourceNodes");this.resourceNodes=new Array,s&&this.init(r)}init(s){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${s?"true":"false"})`),R()){let t=localStorage.getItem("ResourceArray");if(t!=null&&typeof t=="string"&&t!=="")if(s)localStorage.removeItem("ResourceArray");else{let a=JSON.parse(t);this.resourceNodes=a.resourceNodes;return}}var r=JSON.stringify(St);try{this.resourceNodes=S.deserializeArray(ve,r)}catch{debugger}}async read(s,r){let t=new ie(!1,!1);return t.resourceNodes=await hs(s,r),t}save(){if(R()){let s=JSON.stringify(this);localStorage.setItem("ResourceArray",s)}}}class ve{constructor(s,r,t){c(this,"type");c(this,"resource");c(this,"cost");c(this,"expanded");c(this,"resources");this.type=s,this.resource=r,this.cost=t,this.expanded=!1,this.resources=new Array}}class Ot{constructor(s){c(this,"actorNodes");this.actorNodes=new Array,this.init(s)}init(s){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${s?"true":"false"})`),R()){let t=localStorage.getItem("RBACActors");if(t!=null&&typeof t=="string"&&t!=="")if(s)localStorage.removeItem("RBACActors");else{let a=JSON.parse(t);this.actorNodes=a.actorNodes;return}}var r=JSON.stringify(It);try{this.actorNodes=S.deserializeArray(De,r)}catch{debugger}}}class De{constructor(s,r,t,e,a,o){c(this,"type");c(this,"actor");c(this,"resource");c(this,"role");c(this,"updatedby");c(this,"updatedon");c(this,"actors");this.type=s,this.actor=r,this.resource=t,this.role=e,this.updatedby=a,this.updatedon=o,this.actors=new Array}}function Nt(n){return"Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All"}async function Y(n,s){const r=new Headers;r.append("Content-Type","application/json"),r.append("accept","*/*");const t=Nt();if(s.graphAccessToken==null||s.graphAccessToken==="")try{let e=await n.acquireTokenByCode({code:s.spacode});s.graphAccessToken=e.accessToken,console.log("Front end token acquired by code: "+s.graphAccessToken.slice(0,20))}catch(e){console.log("Front end token failure: "+e)}else try{let e=n.getAllAccounts(),a=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==a&&(o=e[i]);let d=await n.acquireTokenSilent({scopes:[t],account:o});s.graphAccessToken=d.accessToken,console.log("Front end token graph acquired silently: "+s.graphAccessToken.slice(0,20))}catch(e){try{console.log("Front end graph token silent acquisition failure: "+e);let a=n.getAllAccounts(),o=s.oid+"."+s.tid,d=null;for(let i=0;i<a.length;i++)a[i].homeAccountId==o&&(d=a[i]);n.acquireTokenRedirect({scopes:[t],account:d})}catch(a){console.log("Front end graph token redirect acquisition failure: "+a)}}return r.append("Authorization",`Bearer ${s.graphAccessToken}`),r}async function Bt(n,s,r){if(s==null||s.spacode=="")return{groups:[],error:"500: invalid user passed to groupsGet"};let e={method:"GET",headers:await Y(n,s)};try{let a=L(s.authority)+p.graphGroupsPredicate;a+=`/?$filter=startsWith(displayName, '${r}')`;let d=await(await fetch(a,e)).json();return typeof d.error<"u"?{groups:[],error:`${d.error.code}: ${d.error.message}`}:{groups:d.value,error:""}}catch(a){return console.log(a),{groups:[],error:`Exception: ${a}`}}}async function Ge(n,s,r,t){try{let e=L(s.authority)+p.graphOauth2PermissionGrantsPredicate,a=new URL(e);a.searchParams.append("$filter",`resourceId eq '${r}' and consentType eq 'Principal' and principalId eq '${t}'`);let d=await(await fetch(a.href,n)).json();if(typeof d.error<"u")return{grants:null,id:null,error:`${d.error.code}: ${d.error.message}`};if(d.value.length!=1){debugger;return{grants:null,id:null,error:"oauth2PermissionGrantsGet: more than one matching delegated consent grant."}}return{grants:d.value[0].scope,id:d.value[0].id,error:""}}catch(e){return console.log(e),{grants:null,id:null,error:`Exception: ${e}`}}}async function Re(n,s,r,t){if(s==null||s.spacode=="")return!1;try{let e=L(s.authority);e+=p.graphOauth2PermissionGrantsPredicate+`/${r}`;let a=`{ "scope": "${t}" }`,d={method:"PATCH",headers:await Y(n,s),body:a},i=await fetch(e,d),l=await i.json();if(i.status==204&&i.statusText=="No Content")return!0;debugger;return console.log(`oauth2PermissionGrantsSet: PATCH failed ${l.error.code}: ${l.error.message}`),!1}catch(e){debugger;return console.log(e),!1}}function Wt(n,s){let r=Pt(n.authority);r+=n.tid,r+="/adminconsent";let t=new URL(r),e=Et(n.authority,s);t.searchParams.append("client_id",e),t.searchParams.append("redirect_uri",window.location.origin),t.searchParams.append("domain_hint",n.companyDomain),t.searchParams.append("login_hint",n.mail),window.location.assign(t.href)}async function Ce(n,s,r){try{let t=L(s.authority);t+=p.graphServicePrincipalsPredicate,t+=`(appId='${r}')`;let e=new URL(t);e.searchParams.append("$select","id,appId,displayName");let o=await(await fetch(e.href,n)).json();return typeof o.error<"u"?{spid:"",error:`${o.error.code}: ${o.error.message}`}:{spid:o.id,error:""}}catch(t){return console.log(t),{spid:"",error:`Exception: ${t}`}}}async function Ft(n,s){if(n.authority==""){let e=new j;if(e.domain=n.tid,await le(e,!1))n.authority=e.authority;else{debugger;return!1}}let r=window.location.href;switch(n.authority){case p.authorityWW:r+="MicrosoftIdentity/Account/SignIn";break;case p.authorityUS:r+="USGov/SignIn";break;case p.authorityCN:r+="China/SignIn";break;default:return!1}let t=new URL(r);if(t.searchParams.append("redirectUri",window.location.origin),n.oid!=="1"){t.searchParams.append("loginHint",n.mail);const e=/@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/,a=n.mail.match(e);let o=a?a[1]:"organizations";t.searchParams.append("domainHint",o)}else t.searchParams.append("domainHint","organizations");return s.setTaskStart("initialization",new Date),s.setTaskStart("authenticate user",new Date),window.location.assign(t.href),!0}function Ut(n,s){debugger;if(n.oid=="1")return;let r=window.location.href;switch(n.authority){case p.authorityWW:r+="MicrosoftIdentity/Account/Challenge";break;case p.authorityUS:r+="USGov/Challenge";break;case p.authorityCN:r+="China/Challenge";break;default:return}let t=new URL(r);t.searchParams.append("redirectUri",window.location.origin),t.searchParams.append("scope",s),t.searchParams.append("domainHint","organizations"),t.searchParams.append("loginHint",n.mail),window.location.assign(t.href)}async function Lt(n){if(n.oid=="1")return!1;let s=window.location.href;s+="user";let r=new URL(s);r.searchParams.append("oid",n.oid),r.searchParams.append("tid",n.tid),r.searchParams.append("loginHint",n.loginHint),r.searchParams.append("verb","LOGOUT");let t={method:"PATCH"},e=await fetch(r.href,t);if(e.status==200&&e.statusText=="OK")console.log(`Successfully set admin ${n.mail} logout_hint`);else return console.log(`Failed to set admin ${n.mail} logout_hint`),!1;let a=window.location.href;switch(n.authority){case p.authorityWW:a+="MicrosoftIdentity/Account/SignOut";break;case p.authorityUS:a+="USGov/SignOut";break;case p.authorityCN:a+="China/SignOut";break;default:return!1}return r=new URL(a),r.searchParams.append("redirectUri",window.location.origin),window.location.assign(r.href),!0}async function zt(n,s,r,t){if(t)debugger;if(s.name!=null&&s.name!=="")return!1;if(n.graphAccessToken!=null&&n.graphAccessToken===""){console.log(`tenantRelationshipsGetByDomain called with invalid logged in user: ${n.name}`);try{let i=await r.acquireTokenByCode({code:n.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});n.graphAccessToken=i.accessToken,console.log("tenantRelationshipsGetByDomain: Front end token acquired: "+n.graphAccessToken.slice(0,20))}catch(i){return console.log("tenantRelationshipsGetByDomain: Front end token failure: "+i),!1}}const e=new Headers,a=`Bearer ${n.graphAccessToken}`;e.append("Authorization",a);let o={method:"GET",headers:e};try{var d=L(s.authority)+p.graphTenantByDomainPredicate;d+="(domainName='",d+=s.domain,d+="')",console.log("tenantRelationshipsGetByDomain: Attempting GET from /findTenantInformationByDomainName:",d);let i=await fetch(d,o);if(i.status==200){let l=await i.json();if(l){if(l.error!=null){debugger;return console.log("tenantRelationshipsGetByDomain: Failed GET from /findTenantInformationByDomainName: ",l.error.message),!1}else if(l.displayName!=null&&l.displayName!=="")return s.tid=l.tenantId,s.name=l.displayName,console.log("tenantRelationshipsGetByDomain: Successful GET from /findTenantInformationByDomainName: ",l.displayName),!0}else console.log("tenantRelationshipsGetByDomain: Failed to GET from /findTenantInformationByDomainName: ",d)}}catch(i){return console.log("Failed to GET from /findTenantInformationByDomainName: ",i),!1}return!1}async function Oe(n,s,r,t,e){if(console.log("**** tenantRelationshipsGetById"),e)debugger;if(n.graphAccessToken==="")try{let l=await t.acquireTokenByCode({code:n.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});n.graphAccessToken=l.accessToken,console.log("tenantRelationshipsGetById: Front end token acquired: "+n.graphAccessToken.slice(0,20))}catch(l){return console.log("tenantRelationshipsGetById: Front end token failure: "+l),!1}const a=new Headers,o=`Bearer ${n.graphAccessToken}`;a.append("Authorization",o);let d={method:"GET",headers:a};try{var i=L(n.authority)+p.graphTenantByIdPredicate;i+="(tenantId='",i+=s.tid,i+="')",console.log("tenantRelationshipsGetById: Attempting GET from /findTenantInformationByTenantId:",i);let u=await(await fetch(i,d)).json();if(u&&typeof u.displayName!==void 0&&u.displayName!==""){if(s!==void 0)s.name=u.displayName,s.domain=u.defaultDomainName;else{console.log("tenantRelationshipsGetById: missing associated tenant for logged in user.");debugger}return console.log("tenantRelationshipsGetById: Successful GET from /findTenantInformationByTenantId: ",u.displayName),!0}else console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ",i)}catch(l){return console.log("tenantRelationshipsGetById: Failed to GET from /findTenantInformationByTenantId: ",l),!1}return!1}async function le(n,s){if(s)debugger;let r=[p.authorityWW,p.authorityUS,p.authorityCN],t=[p.authorityWWRegex,p.authorityUSRegex,p.authorityCNRegex],e=null;try{for(let i=0;i<3;i++){var a=r[i];if(n.lookupfield=="Domain"?a+=n.domain:n.lookupfield=="Tenant ID"&&(a+=n.tid),a+="/.well-known/openid-configuration",console.log("Attempting GET from openid well-known endpoint: ",a),e=await fetch(a),e.status==200){let l=await e.json();if(l){var o=l.authorization_endpoint;for(let u=0;u<3;u++){var d=o.match(t[u]);if(d!=null)return n.tid=d[2],n.authority=d[1],console.log(`Successful GET from openid well-known endpoint: tid: ${n.tid} authority: ${n.authority}`),!0}}else console.log(`Failed JSON parse of openid well-known endpoint response ${a}.`)}else console.log(`Failed GET from ${a}.`)}}catch(i){console.log("Failed to GET from openid well-known endpoint: ",i)}return(n.tid==""||n.authority=="")&&console.log(`GET from openid well-known endpoint failed to find tenant: ${e?e.statusText:"unknown"}`),!1}async function Ne(n,s,r){if(s==null||s.spacode==""||r==null){debugger;return{scopes:null,id:null,error:"500: invalid parameter(s) passed to getUserDelegatedScopes"}}let e={method:"GET",headers:await Y(n,s)};try{if(r.graphSP==""){let{spid:i,error:l}=await Ce(e,s,"00000003-0000-0000-c000-000000000000");if(l!=""){debugger;return{scopes:null,id:null,error:`${l}`}}r.graphSP=i}let{grants:a,id:o,error:d}=await Ge(e,s,r.graphSP,s.oid);if(d!=""){debugger;return{scopes:null,id:null,error:`${d}`}}return{scopes:a,id:o,error:""}}catch(a){debugger;return console.log(a),{scopes:null,id:null,error:`Exception: ${a}`}}}async function xt(n,s,r,t){if(s==null||s.spacode==""||r==null){debugger;return!1}let{scopes:e,id:a,error:o}=await Ne(n,s,r);if(o!=""){debugger;return console.log(`userDelegatedScopesRemove: cannot find userDelegatedScopes for ${s.mail}: ${o}`),!1}e=e.replace(t,"");let d=await Re(n,s,a,e);if(!d){debugger;return console.log(`userDelegatedScopesRemove: cannot set oauth2PermissionGrants for ${s.mail}: ${o}`),!1}return s.scopes=e.split(" "),d}async function _t(n,s){if(s==null||s.spacode=="")return{users:[],error:"500: invalid user passed to usersGet"};try{let t={method:"GET",headers:await Y(n,s)},e=L(s.authority);e+=p.graphUsersPredicate;let o=await(await fetch(e,t)).json();if(typeof o.error<"u")return{users:[],error:`${o.error.code}: ${o.error.message}`};let d=new Array;for(let i of o.value)d.push(i.mail);return{users:d,error:""}}catch(r){return console.log(r),{users:[],error:`Exception: ${r}`}}}async function Mt(n,s,r,t){return Ue(n,s,r,t)}async function jt(n,s,r,t){return Le(n,s,r,t)}async function Ht(n,s,r,t,e){return ze(n,s,r,t,e)}async function qt(n,s,r,t){return xe(n,s,r,t)}async function Kt(n,s,r){return _e(n,s,r)}async function Jt(n,s,r,t,e,a,o,d){let i=new y;if(r.id==="1"){if(i=await Je(n,s,r,a.id,d),i.result){r.tenants.forEach(h=>{(h.configId==="1"||h.configId==="")&&(h.configId=r.id)}),t&&t(r.id);const l={};Object.defineProperty(l,r.id,{value:!0,writable:!0,enumerable:!0}),e(l);let u=a.associatedConfigs.findIndex(h=>h=="1");u!==-1&&(a.associatedConfigs.splice(u,1),a.associatedConfigs.push(r.id))}}else i=await Ve(n,s,r,d);return o.save(),i}async function Vt(n,s,r,t,e){let a=new y;return a=await Ke(n,s,r,t,e),a}async function Zt(n,s,r,t,e){return Me(n,s,r,t,e)}async function Qt(n,s,r,t,e){return je(n,s,r,t,e)}async function Xt(n,s,r,t,e,a){let o=new y;if(e)debugger;try{let d=t.ws.find(i=>i.id===r);if(d!=null){d.associatedConfigs.length=0;let i=await He(n,s,a,d.id,e);return i.result&&t.tagWithWorkspaces(),i}else return o.result=!1,o.error="Workspace not found.",o.status=404,o}catch(d){return console.log(d.message),o.error=d.message,o.result=!1,o.status=500,o}}async function Yt(n,s,r,t,e){return qe(n,s,r,t)}async function es(n,s,r,t,e){console.log(">>>>>> initGet");let a=new y;if(e)debugger;let o=new j;return o.tid=s.tid,o.domain=s.tid,await le(o,e)?(s.authority=o.authority,t.setTaskStart("GET tenant details",new Date),a.result=await Oe(s,o,r,n,e),t.setTaskEnd("GET tenant details",new Date,"complete"),a.result&&(s.companyName=o.name,s.companyDomain=o.domain,t.setTaskStart("POST config init",new Date),a=await Qe(n,s,e),t.setTaskEnd("POST config init",new Date,a.result?"complete":"failed")),a.result&&(t.setTaskStart("GET workspaces",new Date),a=await cs(n,s,r,e),t.setTaskEnd("GET workspaces",new Date,a.result?"complete":"failed")),console.log("initGet complete. Version: "+U()),a):(a.error=`Failed to retrieve authority for user "${s.mail}" TID ${s.tid}.`,a.result=!1,a)}async function ts(n,s,r,t){return et(n,s,r,t)}async function ss(n,s,r,t,e){return Xe(n,s,r,t)}async function rs(n,s,r,t){return Fe(n,s,r,t)}async function as(n,s,r,t){return Be(n,s,r,t)}async function ns(n,s,r,t){return await tt(n,s,r,t)}function os(n,s,r,t){r.map(e=>{let a=null,o=s.us.findIndex(l=>l.oid===e.userId||l.oid===e.email);if(o===-1){let l=s.us.findIndex(u=>u.oid==="1");if(l!==-1){a=s.us.at(l);let u=n.associatedUsers.findIndex(h=>h=="1");u!==-1&&(n.associatedUsers.splice(u,1),n.associatedUsers.push(e.userId))}else a=new V,s.us.push(a)}else a=s.us.at(o);a.sel=t===e.userId,a.oid=e.userId?e.userId:e.email,a.name=e.firstName??a.name,a.mail=e.email,a.tid=e.tenantId;let d=s.ts.find(l=>l.tid===a.tid);d!=null&&(a.authority=d.authority,a.companyName=d.name,a.companyDomain=d.domain),n.associatedUsers.findIndex(l=>l===a.oid)==-1&&n.associatedUsers.push(a.oid)}),s.save()}function is(n,s,r,t){r.map(e=>{let a=null,o=s.ts.findIndex(u=>u.tid===e.tenantId);if(o===-1){let u=s.ts.findIndex(h=>h.tid==="1");if(u!==-1){a=s.ts.at(u);let h=n.associatedTenants.findIndex($=>$=="1");h!==-1&&(n.associatedTenants.splice(h,1),n.associatedTenants.push(e.tenantId))}else a=new j,s.ts.push(a)}else a=s.ts.at(o);a.sel=t===e.tenantId,a.tid=e.tenantId,a.name=e.name,a.domain=e.domain,a.tenantType=e.type.toLowerCase();const d=/^(https:\/\/login.microsoftonline.(?:us|com)\/)organizations\/v2.0$/,i=e.authority.match(d);a.authority=i?i[1]:e.authority,n.associatedTenants.findIndex(u=>u===e.tenantId)==-1&&n.associatedTenants.push(e.tenantId)}),s.save()}function ls(n,s,r,t){r.map(e=>{let a=null,o=s.cs.findIndex(i=>i.id===e.id);if(o===-1){let i=s.cs.findIndex(l=>l.id==="1");if(i!==-1){a=s.cs.at(i);let l=n.associatedConfigs.findIndex(u=>u=="1");l!==-1&&(n.associatedConfigs.splice(l,1),n.associatedConfigs.push(e.id))}else a=new Z,s.cs.push(a)}else a=s.cs.at(o);a.sel=t===e.id,a.id=e.id,a.workspaceId=e.workspaceId,a.name=e.name,a.description=e.description,a.isEnabled=e.isEnabled,a.tenants.length=0,e.tenants.map(i=>{let l=new Ee;l.tid=i.tenantId,l.sourceGroupId=i.sourceGroupId??"",l.sourceGroupName=i.sourceGroupName??"",l.targetGroupId=i.targetGroupId??"",l.targetGroupName=i.targetGroupName??"",l.configurationTenantType=i.configurationTenantType.toLowerCase(),l.deltaToken=i.deltaToken??"",l.configId=a.id,l.batchId=i.batchId??"",l.isReadPermissionConsented=i.isReadPermissionConsented,l.isWritePermissionConsented=i.isWritePermissionConsented,a.tenants.push(l)}),n.associatedConfigs.findIndex(i=>i===e.id)==-1&&n.associatedConfigs.push(e.id)}),console.log("--------------ii-----------",s),s.save()}async function cs(n,s,r,t){let e=new y;if(t)debugger;try{if(e=await st(n,s,t),e.result){for(let a of e.array){let o=null,d=r.ws.findIndex(D=>D.id===a.id);if(d===-1){let D=r.ws.findIndex(P=>P.id==="1");D!==-1?o=r.ws.at(D):(o=new Q,r.ws.push(o))}else o=r.ws.at(d);let i="";for(let D of o.associatedUsers){let P=r.us.find(F=>F.oid===D);P!=null&&P.sel&&(i=P.oid)}let l="";for(let D of o.associatedTenants){let P=r.ts.find(F=>F.tid===D);P!=null&&P.sel&&(l=P.tid)}let u="";for(let D of o.associatedConfigs){let P=r.cs.find(F=>F.id===D);P!=null&&P.sel&&(u=P.id)}o.associatedUsers.length=0,o.associatedTenants.length=0,o.associatedConfigs.length=0,o.id=a.id,o.name=a.name,o.ownerid=a.workspaceOwnerUserId;let h=We(n,s,o.id,t),$=Ye(n,s,o.id,t),E=Ze(n,s,o.id,t),[W,z,x]=await Promise.all([h,$,E]);if(!W.result)return W;if(!z.result)return z;if(!x.result)return x;is(o,r,z.array,l),os(o,r,W.array,i),ls(o,r,x.array,u),r.tagWithWorkspaces()}return e}}catch(a){console.log(a.message),e.error=a.message}return e.result=!1,e.status=500,e}async function ds(n,s){let r="",t=U();try{let e=n.getAllAccounts(),a=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==a&&(o=e[i]);r=(await n.acquireTokenSilent({scopes:["https://analysis.windows.net/powerbi/api/App.Read.All","https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All","https://analysis.windows.net/powerbi/api/Report.ReadWrite.All","https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All"],account:o})).accessToken,console.log("PowerBI token acquired silently: "+r.slice(0,20))}catch{console.log("PowerBI token failed to be acquired silently")}return console.log(t),r}async function ce(n,s){const r=new Headers;if(r.append("Content-Type","application/json"),r.append("accept","*/*"),s.azureAccessToken==null||s.azureAccessToken==="")try{let t=n.getAllAccounts(),e=s.oid+"."+s.tid,a=null;for(let d=0;d<t.length;d++)t[d].homeAccountId==e&&(a=t[d]);let o=await n.acquireTokenSilent({scopes:["https://management.azure.com/user_impersonation"],account:a});s.azureAccessToken=o.accessToken,console.log("Front end token acquired silently: "+s.azureAccessToken.slice(0,20))}catch(t){try{console.log("Front end token silent acquisition failure: "+t);let e=n.getAllAccounts(),a=s.oid+"."+s.tid,o=null;for(let d=0;d<e.length;d++)e[d].homeAccountId==a&&(o=e[d]);n.acquireTokenRedirect({scopes:["https://management.azure.com/user_impersonation"],account:o})}catch(e){console.log("Front end token popup acquisition failure: "+e)}}return r.append("Authorization",`Bearer ${s.azureAccessToken}`),r}async function us(n,s){if(s==null||s.spacode=="")return!1;try{let t={method:"GET",headers:await ce(n,s)},e=M.azureListRootAssignments;e+="'",e+=s.oid,e+="'";let a=await fetch(e,t);if(a.status==200){let o=await a.json();o=o;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await w(a)),!1}catch(r){return console.log(r),!1}return!0}async function fs(n,s){if(s==null||s.spacode=="")return!1;try{let t={method:"POST",headers:await ce(n,s)},e=M.azureElevateAccess,a=await fetch(e,t);if(a.status==200)console.log("Successful call to Azure Resource Graph list root assignments");else return console.log(await w(a)),!1}catch(r){return console.log(r),!1}return!0}async function hs(n,s){let r=new Array;if(s==null||s.spacode=="")return r;try{let e={method:"GET",headers:await ce(n,s)},a=M.azureListRootAssignments;a+="'",a+=s.oid,a+="'";let o=await fetch(a,e);if(o.status==200){let d=await o.json();d=d;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await w(o)),r}catch(t){return console.log(t),r}return r}function ps(n){let s="8d95d21c-c378-4bb0-9f52-88c30d271e7a",r=n.authority.toLowerCase();return r.startsWith("https://login.microsoftonline.com/")?s="8d95d21c-c378-4bb0-9f52-88c30d271e7a":r.startsWith("https://login.microsoftonline.us/")?s="48da942e-ea3d-49e4-a054-81649012f8f2":r.startsWith("https://login.partner.microsoftonline.cn/")&&(s="c91d32e4-dcc5-4d77-826a-16e93ffce666"),`api://${s}/Config.Write`}async function b(n,s){const r=new Headers;r.append("Content-Type","application/json"),r.append("accept","*/*");const t=ps(s);try{let e=n.getAllAccounts(),a=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==a&&(o=e[i]);let d=await n.acquireTokenSilent({scopes:[t],account:o});s.mindlineAccessToken=d.accessToken,console.log("Front end mindline token acquired silently: "+s.mindlineAccessToken.slice(0,20))}catch(e){try{console.log("Front end mindline token silent acquisition failure, triggering redirect: "+e);let a=n.getAllAccounts(),o=s.oid+"."+s.tid,d=null;for(let i=0;i<a.length;i++)a[i].homeAccountId==o&&(d=a[i]);n.acquireTokenRedirect({scopes:[t],account:d})}catch(a){console.log("Front end mindline token redirect acquisition failure: "+a)}}return r.append("Authorization",`Bearer ${s.mindlineAccessToken}`),r}async function w(n){let s="";if(n.status===401&&(s=n.statusText,s!=""))return s;let r=await n.json();if(r.error!==void 0)s=`Error: ${r.error} Message: ${r.message}`;else if(r.errors!==void 0)s=Object.keys(r.errors).reduce((a,o)=>a+o+": "+r.errors[o]+" ","");else if(r.title!==void 0)s=r.title;else debugger;return s}async function Be(n,s,r,t){let e=new y;if(r.oid==""&&r.mail==""||t=="")return e.result=!1,e.error="adminDelete: invalid parameters",e.status=500,e;let a=null;a=new URL(T.adminEndpoint()),a.searchParams.append("workspaceId",t),a.searchParams.append("email",r.mail);let d={method:"DELETE",headers:await b(n,s)};try{console.log("Attempting DELETE from /admin: "+a.href);let i=await fetch(a.href,d);return i.status===200&&i.statusText==="OK"?(console.log(`Successful DELETE from /admin: ${a.href}`),e):(e.error=await w(i),console.log(`Failed DELETE from /admin: ${a.href}`),console.log(e.error),e.status=500,e.result=!1,e)}catch(i){e.error=i.message,e.status=500,e.result=!1,console.log(i.message)}return e}async function We(n,s,r,t){let e=new y;if(r==="")return e.result=!1,e.status=500,e.error="adminsGet: no workspace provided",e;let a=T.adminsEndpoint(),o=new URL(a);o.searchParams.append("workspaceId",r);let i={method:"GET",headers:await b(n,s)};try{if(t)debugger;console.log("Attempting GET from /admins: "+o.href);let l=await fetch(o.href,i);if(l.status===200&&l.statusText==="OK"){let u=await l.json();return u!=null?(e.array=u,console.log(`Successful GET from /admins: ${e.array.reduce(($,E)=>$+E.email+" ","")}`),e):(e.error="Failed GET from /admins: failed to JSON-parse response",console.log(e.error),e.status=500,e.result=!1,e)}else return console.log(`Failed GET from /admins: ${o.href}`),e.error=await w(l),e.status=500,e.result=!1,console.log(e.error),e}catch(l){e.error=l.message,e.status=500,e.result=!1,console.log(l.message)}return e}async function Fe(n,s,r,t){let e=new y;if(r.mail==""||r.authority==""||r.tid==="")return e.result=!1,e.error="adminPost: invalid argument",e.status=500,e;let a=T.adminEndpoint();const o=await b(n,s);let d=`
|
|
2
2
|
{"email": "${r.mail}",
|
|
3
3
|
"tenantId": "${r.tid}",
|
|
4
4
|
"workspaceId": "${t}"
|
|
5
|
-
}`,i={method:"POST",headers:o,body:d};try{console.log("Attempting POST to /admin: "+a);let l=await fetch(a,i);return l.status===200&&l.statusText==="OK"?(console.log(`Successful POST to /admin: ${d}`),e):(e.error=await w(l),console.log(`Failed POST to /admin: ${d}`),console.log(e.error),e.status=500,e.result=!1,e)}catch(l){e.error=l.message,e.status=500,e.result=!1,console.log(l.message)}return e}async function
|
|
5
|
+
}`,i={method:"POST",headers:o,body:d};try{console.log("Attempting POST to /admin: "+a);let l=await fetch(a,i);return l.status===200&&l.statusText==="OK"?(console.log(`Successful POST to /admin: ${d}`),e):(e.error=await w(l),console.log(`Failed POST to /admin: ${d}`),console.log(e.error),e.status=500,e.result=!1,e)}catch(l){e.error=l.message,e.status=500,e.result=!1,console.log(l.message)}return e}async function Ue(n,s,r,t){n=n,s=s,t=t;let e=new y;if(r.id==="")return e.result=!1,e.error="auditConfigPost: invalid config ID",e.status=500,e;let a=T.auditConfigEndpoint();const o=await b(n,s);let d=`
|
|
6
6
|
{
|
|
7
7
|
"workspaceId": "${r.workspaceId}",
|
|
8
8
|
"name": "${r.name}",
|
|
@@ -10,51 +10,51 @@
|
|
|
10
10
|
"isEnabled": ${r.isEnabled},
|
|
11
11
|
"email": "${r.email}",
|
|
12
12
|
"tenantId": "${r.tenantId}"
|
|
13
|
-
}`,i={method:"POST",headers:o,body:d};try{if(t)debugger;console.log("Attempting POST to /audit-configuration: "+a);let l=await fetch(a,i);if(l.status===200&&l.statusText==="OK"){let
|
|
13
|
+
}`,i={method:"POST",headers:o,body:d};try{if(t)debugger;console.log("Attempting POST to /audit-configuration: "+a);let l=await fetch(a,i);if(l.status===200&&l.statusText==="OK"){let u=await l.json();return r.id=u,console.log(`Successful AuditConfigID: ${u} from POST to /audit-configuration: ${d}`),e}else return e.error=await w(l),console.log(`Failed POST to /audit-configuration: ${d}`),console.log(e.error),e.status=500,e.result=!1,e}catch(l){return e.status=500,e.result=!1,e.error=l.message,console.log(e.error),e}return e}async function Le(n,s,r,t){n=n,s=s,t=t;let e=new y;if(s.mail==null||s.mail=="")return e.result=!1,e.status=500,e.error="auditConfigGet: no user provided",e;if(!r||r.trim()==="")return e.result=!1,e.error="auditConfigGet: configurationId is required",e.status=500,e;let a=T.auditConfigEndpoint(),o=new URL(`${a}/${r}`),i={method:"GET",headers:await b(n,s)};try{if(t)debugger;console.log("Attempting GET to /audit-configuration: "+o.href);const l=await fetch(o.href,i);if(l.status===200&&l.statusText==="OK"){let u=await l.json();e.result=!0,e.status=l.status,console.log("Successful GET from /audit-configuration:",u)}else e.error=await w(l),console.log("Failed GET from /audit-configuration: "+o.href),console.log(e.error),e.status=l.status,e.result=!1}catch(l){e.status=500,e.result=!1,e.error=l.message,console.log("Error during auditConfigGet:",l.message)}return e}async function ze(n,s,r,t,e){let a=new y;if(!r||r.trim()==="")return a.result=!1,a.error="auditConfigPut: invalid configuration ID",a.status=500,a;let o=T.auditConfigEndpoint(),d=new URL(o);d.searchParams.append("configurationId",r);const i=await b(n,s);let l=`
|
|
14
14
|
{
|
|
15
15
|
"name": "${t.name}",
|
|
16
16
|
"description": "${t.description}",
|
|
17
17
|
"isEnabled": ${t.isEnabled},
|
|
18
18
|
"isReadPermissionConsented": ${t.isReadPermissionConsented},
|
|
19
19
|
"email": "${t.email}"
|
|
20
|
-
}`,
|
|
20
|
+
}`,u={method:"PUT",headers:i,body:l};try{if(e)debugger;console.log("Attempting PUT to /audit-configuration: "+d.href);const h=await fetch(d.href,u);h.status===200&&h.statusText==="OK"?(a.result=!0,console.log(`Successful PUT to ${d.href}: ${l}`)):(a.error=await w(h),console.error(`Failed PUT to ${d.href}: ${l}`),a.status=h.status,a.result=!1)}catch(h){a.error=h.message,a.status=500,a.result=!1,console.error("Error during auditConfigPut:",h.message)}return a}async function xe(n,s,r,t){let e=new y;if(!s.mail)return e.result=!1,e.status=500,e.error="auditConfigDelete: no user provided",e;if(!r||r.trim()==="")return e.result=!1,e.status=500,e.error="auditConfigDelete: configurationId is required",e;let a=T.auditConfigEndpoint(),o=new URL(a);o.searchParams.append("configurationId",r);const i={method:"DELETE",headers:await b(n,s)};try{if(t)debugger;console.log(`Attempting DELETE to /audit-configuration: ${o.href}`);const l=await fetch(o.href,i);l.ok?(e.result=!0,console.log(`Successful DELETE for configurationId ${r}`)):(e.error=await w(l),e.status=l.status,e.result=!1,console.error(`Failed DELETE for configurationId ${r}`))}catch(l){e.status=500,e.result=!1,e.error=l.message,console.error("Error during auditConfigDelete:",l.message)}return e}async function _e(n,s,r){let t=new y;if(s.mail==null||s.mail=="")return t.result=!1,t.status=500,t.error="auditEventsGet: no user provided",t;let e=T.auditEventsEndpoint(),a=new URL(e),d={method:"GET",headers:await b(n,s)};try{if(r)debugger;console.log("Attempting GET from /audit-events endpoint: "+a.href);let i=await fetch(a.href,d);if(i.status===200&&i.statusText==="OK"){let l=await i.json();if(Array.isArray(l.data)){let u=l.data;if(u!=null)return t.array=u,console.log(`Successful GET from /audit-events: ${t.array.reduce(($,E)=>$+E.initiatedByUser+" ","")}`),t}return t.error="Failed GET from /audit-events: failed to JSON-parse response",console.log(t.error),t.status=500,t.result=!1,t}else return console.log(`Failed GET from /audit-events: ${a.href}`),t.error=await w(i),t.status=500,t.result=!1,console.log(t.error),t}catch(i){t.error=i.message,t.status=500,t.result=!1,console.log(i.message)}return t}async function Me(n,s,r,t,e){let a=new y,o=T.configConsentEndpoint(),d=new URL(o);d.searchParams.append("configurationId",r);const i=await b(n,s);let l=`
|
|
21
21
|
{
|
|
22
22
|
"tenantId": "${t}",
|
|
23
23
|
"isReadPermissionConsented": ${e?"true":"false"}
|
|
24
|
-
}`,
|
|
24
|
+
}`,u={method:"PUT",headers:i,body:l};try{console.log("Attempting PUT read consent to /configuration/consent: "+d.href);let h=await fetch(d.href,u);return h.status===200&&h.statusText==="OK"?(console.log(`Successful PUT to ${d.href}`),a):(a.error=await w(h),console.log(`Failed PUT to ${d.href}`),console.log(a.error),a.status=500,a.result=!1,a)}catch(h){a.error=h.message,a.status=500,a.result=!1,console.log(h.message)}return a}async function je(n,s,r,t,e){let a=new y,o=T.configConsentEndpoint(),d=new URL(o);d.searchParams.append("configurationId",r);const i=await b(n,s);let l=`
|
|
25
25
|
{
|
|
26
26
|
"tenantId": "${t}",
|
|
27
27
|
"isWritePermissionConsented": ${e?"true":"false"}
|
|
28
|
-
}`,
|
|
28
|
+
}`,u={method:"PUT",headers:i,body:l};try{console.log("Attempting PUT read consent to /configuration/consent: "+d.href);let h=await fetch(d.href,u);return h.status===200&&h.statusText==="OK"?(console.log(`Successful PUT to ${d.href}`),a):(a.error=await w(h),console.log(`Failed PUT to ${d.href}`),console.log(a.error),a.status=500,a.result=!1,a)}catch(h){a.error=h.message,a.status=500,a.result=!1,console.log(h.message)}return a}async function He(n,s,r,t,e){let a=new y;if(r.id===""||t=="")return a.result=!1,a.error="configGet: invalid config ID",a.status=500,a;let o=null;o=new URL(T.configEndpoint());let i={method:"GET",headers:await b(n,s)};try{console.log("Attempting GET from /config: "+o.href);let l=await fetch(`${o.href}/${r.id}`,i);if(l.status===200&&l.statusText==="OK"){console.log("Successful GET from /config");let u=await l.json();return{...a,array:[u]}}else return a.error=await w(l),console.log(`Failed GET from ${o.href}`),console.log(a.error),a.status=500,a.result=!1,a}catch(l){a.error=l.message,a.status=500,a.result=!1,console.log(l.message)}return a}async function qe(n,s,r,t,e){let a=new y;if(r.id===""||t=="")return a.result=!1,a.error="configPost: invalid config ID",a.status=500,a;let o=null;o=new URL(T.configEndpoint()),o.searchParams.append("configurationId",r.id);let i={method:"DELETE",headers:await b(n,s)};try{console.log("Attempting DELETE from /config: "+o.href);let l=await fetch(o.href,i);return l.status===200&&l.statusText==="OK"?(console.log("Successful DELETE from /config"),a):(a.error=await w(l),console.log(`Failed DELETE from ${o.href}`),console.log(a.error),a.status=500,a.result=!1,a)}catch(l){a.error=l.message,a.status=500,a.result=!1,console.log(l.message)}return a}async function Ke(n,s,r,t,e){let a=new y;if(r==="")return a.result=!1,a.error="configPatch: invalid config ID",a.status=500,a;let o=T.configEnabledEndpoint(),d=new URL(o);d.searchParams.append("configurationId",r),d.searchParams.append("isEnabled",t.toString());let l={method:"PATCH",headers:await b(n,s)};try{if(e)debugger;console.log("Attempting PATCH to /config: "+d.href);let u=await fetch(d.href,l);return u.status===200&&u.statusText==="OK"?(console.log(`Successful PATCH to ${d.href}: ${t.toString()}`),a):(a.error=await w(u),console.log(`Failed PATCH to ${d.href}: ${t.toString()}`),console.log(a.error),a.status=500,a.result=!1,a)}catch(u){a.error=u.message,a.status=500,a.result=!1,console.log(u.message)}return a}async function Je(n,s,r,t,e){let a=new y;if(r.id==="")return a.result=!1,a.error="configPost: invalid config ID",a.status=500,a;let o=T.configEndpoint();const d=await b(n,s);let i=`
|
|
29
29
|
{
|
|
30
30
|
"workspaceId": "${t}",
|
|
31
31
|
"name": "${r.name}",
|
|
32
32
|
"description": "${r.description}",
|
|
33
33
|
"isEnabled": ${r.isEnabled},
|
|
34
|
-
"tenants": [`;r.tenants.map(
|
|
35
|
-
"tenantId": "${
|
|
34
|
+
"tenants": [`;r.tenants.map(u=>{let h=u.sourceGroupId!=""?`"${u.sourceGroupId}"`:"null",$=u.sourceGroupName!=""?`"${u.sourceGroupName}"`:"null",E=u.targetGroupId!=""?`"${u.targetGroupId}"`:"null",W=u.targetGroupName!=""?`"${u.targetGroupName}"`:"null";i.slice(-1)==="}"&&(i+=","),i+=`{
|
|
35
|
+
"tenantId": "${u.tid}",
|
|
36
36
|
"sourceGroupId": ${h},
|
|
37
37
|
"sourceGroupName": ${$},
|
|
38
38
|
"targetGroupId": ${E},
|
|
39
39
|
"targetGroupName": ${W},
|
|
40
|
-
"configurationTenantType": "${
|
|
41
|
-
"isReadPermissionConsented": ${
|
|
42
|
-
"isWritePermissionConsented": ${
|
|
43
|
-
}`}),i+="]}";let l={method:"POST",headers:d,body:i};try{if(e)debugger;console.log("Attempting POST to /config: "+o);let
|
|
40
|
+
"configurationTenantType": "${u.configurationTenantType}",
|
|
41
|
+
"isReadPermissionConsented": ${u.isReadPermissionConsented},
|
|
42
|
+
"isWritePermissionConsented": ${u.isWritePermissionConsented}
|
|
43
|
+
}`}),i+="]}";let l={method:"POST",headers:d,body:i};try{if(e)debugger;console.log("Attempting POST to /config: "+o);let u=await fetch(o,l);if(u.status===200&&u.statusText==="OK"){let h=await u.json();return r.id=typeof h=="object"&&h!==null&&h.id?h.id:h,console.log(`Successful ConfigID: ${r.id} from POST to /config: ${i}`),a}else return a.error=await w(u),console.log(`Failed PUT to /config: ${i}`),console.log(a.error),a.status=500,a.result=!1,a}catch(u){return a.status=500,a.result=!1,a.error=u.message,console.log(a.error),a}}async function Ve(n,s,r,t){let e=new y;if(r.id==="")return e.result=!1,e.error="configPost: invalid config ID",e.status=500,e;let a=T.configEndpoint(),o=new URL(a);o.searchParams.append("configurationId",r.id);const d=await b(n,s);let i=`
|
|
44
44
|
{
|
|
45
45
|
"name": "${r.name}",
|
|
46
46
|
"description": "${r.description}",
|
|
47
|
-
"tenants": [`;r.tenants.map(
|
|
48
|
-
"tenantId": "${
|
|
47
|
+
"tenants": [`;r.tenants.map(u=>{i.slice(-1)==="}"&&(i+=",");let $=u.sourceGroupId!=""?`"${u.sourceGroupId}"`:"null",E=u.sourceGroupName!=""?`"${u.sourceGroupName}"`:"null",W=u.targetGroupId!=""?`"${u.targetGroupId}"`:"null",z=u.targetGroupName!=""?`"${u.targetGroupName}"`:"null";i+=`{
|
|
48
|
+
"tenantId": "${u.tid}",
|
|
49
49
|
"sourceGroupId": ${$},
|
|
50
50
|
"sourceGroupName": ${E},
|
|
51
51
|
"targetGroupId": ${W},
|
|
52
52
|
"targetGroupName": ${z},
|
|
53
|
-
"configurationTenantType": "${
|
|
54
|
-
"deltaToken": "${
|
|
55
|
-
"isReadPermissionConsented": ${
|
|
56
|
-
"isWritePermissionConsented": ${
|
|
57
|
-
}`}),i+="]}";let l={method:"PUT",headers:d,body:i};try{if(t)debugger;console.log("Attempting PUT to /config: "+o.href);let
|
|
53
|
+
"configurationTenantType": "${u.configurationTenantType}",
|
|
54
|
+
"deltaToken": "${u.deltaToken}",
|
|
55
|
+
"isReadPermissionConsented": ${u.isReadPermissionConsented},
|
|
56
|
+
"isWritePermissionConsented": ${u.isWritePermissionConsented}
|
|
57
|
+
}`}),i+="]}";let l={method:"PUT",headers:d,body:i};try{if(t)debugger;console.log("Attempting PUT to /config: "+o.href);let u=await fetch(o.href,l);if(u.status===200&&u.statusText==="OK"){console.log(`Successful PUT to ${o.href}: ${i}`);let h=await u.json();return{...e,array:[h]}}else return e.error=await w(u),console.log(`Failed PUT to ${o.href}: ${i}`),console.log(e.error),e.status=500,e.result=!1,e}catch(u){e.error=u.message,e.status=500,e.result=!1,console.log(u.message)}return e}async function Ze(n,s,r,t){let e=new y;if(r==="")return e.result=!1,e.status=500,e.error="configsGet: no workspace provided",e;let a=T.configsEndpoint(),o=new URL(a);o.searchParams.append("workspaceId",r);let i={method:"GET",headers:await b(n,s)};try{if(t)debugger;console.log("Attempting GET from /configurations: "+o.href);let l=await fetch(o.href,i);if(l.status===200&&l.statusText==="OK"){let u=await l.json();return u!=null?(e.array=u,console.log(`Successful GET from /configurations: ${e.array.reduce(($,E)=>$+E.name+" ","")}`),e):(e.error="Failed GET from /configurations: failed to JSON-parse response",console.log(e.error),e.status=500,e.result=!1,e)}else return console.log(`Failed GET from /configurations: ${o.href}`),e.error=await w(l),e.status=500,e.result=!1,console.log(e.error),e}catch(l){e.error=l.message,e.status=500,e.result=!1,console.log(l.message)}return e}async function gs(n,s,r,t){let e=new y;if(!r)return e.result=!1,e.status=500,e.error="workspaceConfigsGet: no workspace provided",e;let a=T.workspaceConfigsEndpoint(),o=new URL(a);o.searchParams.append("workspaceId",r);let i={method:"GET",headers:await b(n,s)};try{if(t)debugger;console.log("Attempting GET from /workspaceConfigs: "+o.href);const l=await fetch(o.href,i);if(l.status===200&&l.statusText==="OK"){const u=await l.json();if(u)return e.array=u.map(h=>({id:h.id,name:h.name,description:h.description,configurationType:h.configurationType,isEnabled:h.isEnabled})),console.log(`workspaceConfigsGet: found ${e.array.length} configs.`),e;e.error="workspaceConfigsGet: failed to parse returned configs",e.result=!1,e.status=500}else e.error=await w(l),e.result=!1,e.status=l.status,console.log(e.error)}catch(l){e.error=l.message,e.result=!1,e.status=500}return e}async function Qe(n,s,r){let t=new y;if(s.companyName===""||s.companyDomain==="")return t.result=!1,t.error="initPost: invalid company name or domain",t.status=500,t;let e=T.initEndpoint();const a=await b(n,s);let o=`
|
|
58
58
|
{
|
|
59
59
|
"tenantCreateModel": {
|
|
60
60
|
"tenantId": "${s.tid}",
|
|
@@ -63,11 +63,11 @@
|
|
|
63
63
|
"type": "aad",
|
|
64
64
|
"authority": "${s.authority}"
|
|
65
65
|
}
|
|
66
|
-
}`,d={method:"POST",headers:a,body:o};try{if(r)debugger;console.log("Attempting POST to /configuration/init: "+e);let i=await fetch(e,d);return i.status===200&&i.statusText==="OK"?(console.log(`Successful POST to /configuration/init: ${o}`),t):(t.error=await w(i),t.status=500,t.result=!1,console.log(`Failed POST to /configuration/init: ${o}`),console.log(t.error),t)}catch(i){t.error=i.message,console.log(t.error)}return t.status=500,t.result=!1,t}async function
|
|
66
|
+
}`,d={method:"POST",headers:a,body:o};try{if(r)debugger;console.log("Attempting POST to /configuration/init: "+e);let i=await fetch(e,d);return i.status===200&&i.statusText==="OK"?(console.log(`Successful POST to /configuration/init: ${o}`),t):(t.error=await w(i),t.status=500,t.result=!1,console.log(`Failed POST to /configuration/init: ${o}`),console.log(t.error),t)}catch(i){t.error=i.message,console.log(t.error)}return t.status=500,t.result=!1,t}async function Xe(n,s,r,t,e){let a=new y;if(r.tid===""||t==="")return a.result=!1,a.error="tenantDelete: invalid tid, workspaceId",a.status=500,a;let o=new URL(T.tenantEndpoint());o.searchParams.append("tenantId",r.tid),o.searchParams.append("workspaceId",t);let i={method:"DELETE",headers:await b(n,s)};try{console.log("Attempting DELETE from /tenant: "+o.href);let l=await fetch(o.href,i);return l.status===200&&l.statusText==="OK"?(console.log(`Successful DELETE from /tenant: ${o.href}`),a):(console.log(`Failed DELETE from /tenant: ${o.href}`),a.error=await w(l),console.log(a.error),a.status=500,a.result=!1,a)}catch(l){a.error=l.message,a.status=500,a.result=!1,console.log(a.error)}return a}async function Ye(n,s,r,t){let e=new y;if(r==="")return e.result=!1,e.status=500,e.error="tenantsGet: no workspace provided",e;let a=T.tenantsEndpoint(),o=new URL(a);o.searchParams.append("workspaceId",r);let i={method:"GET",headers:await b(n,s)};try{if(t)debugger;console.log(`Attempting GET from /tenants: ${o.href}`);let l=await fetch(o.href,i);if(l.status===200&&l.statusText==="OK"){let u=await l.json();return u!=null?(e.array=u,console.log(`Successful GET from /tenants: ${e.array.reduce(($,E)=>$+E.domain+" ","")}`),e):(e.error="Failed GET from /tenants: failed to JSON-parse response",console.log(e.error),e.status=500,e.result=!1,e)}else return console.log(`Failed GET from /tenants: ${o.href}`),e.error=await w(l),e.status=500,e.result=!1,console.log(e.error),e}catch(l){e.error=l.message,e.status=500,e.result=!1,console.log(l.message)}return e}async function et(n,s,r,t){let e=new y;if(r.tid===""||r.name===""||r.domain==="")return e.result=!1,e.error="tenantPost: invalid tid, name, domain",e.status=500,e;let a=T.tenantEndpoint(),o=new URL(a);o.searchParams.append("workspaceId",t);const d=await b(n,s);let i=`
|
|
67
67
|
{"tenantId": "${r.tid}",
|
|
68
68
|
"name": "${r.name}",
|
|
69
69
|
"domain": "${r.domain}",
|
|
70
70
|
"type": 1,
|
|
71
71
|
"authority": "${r.authority}"
|
|
72
|
-
}`,l={method:"POST",headers:d,body:i};try{console.log(`Attempting POST to ${o.href}: ${i}`);let
|
|
72
|
+
}`,l={method:"POST",headers:d,body:i};try{console.log(`Attempting POST to ${o.href}: ${i}`);let u=await fetch(o.href,l);return u.status===200&&u.statusText==="OK"?(console.log(`Successful POST to ${o.href}: ${i}`),e):(console.log(`Failed POST to ${o.href}: ${i}`),e.error=await w(u),console.log(e.error),e.status=500,e.result=!1,e)}catch(u){e.error=u.message,e.status=500,e.result=!1,console.log(e.error)}return e}async function tt(n,s,r,t){let e=new y;if(r==""||t=="")return e.result=!1,e.error="workspacePut: invalid workspace ID or name",e.status=500,e;let a=T.workspaceEndpoint(),o=new URL(a);o.searchParams.append("workspaceId",r),o.searchParams.append("workspaceName",t);let i={method:"PUT",headers:await b(n,s)};try{console.log("Attempting PUT to /workspace: "+o.href);let l=await fetch(o.href,i);return l.status===200&&l.statusText==="OK"?(console.log(`Successful PUT to ${o.href}`),e):(e.error=await w(l),console.log(`Failed PUT to ${o.href}`),console.log(e.error),e.status=500,e.result=!1,e)}catch(l){e.error=l.message,e.status=500,e.result=!1,console.log(l.message)}return e}async function st(n,s,r){let t=new y;if(s.mail==null||s.mail=="")return t.result=!1,t.status=500,t.error="adminsGet: no workspace provided",t;let e=T.workspacesEndpoint(),a=new URL(e),d={method:"GET",headers:await b(n,s)};try{if(r)debugger;console.log("Attempting GET from /workspaces endpoint: "+a.href);let i=await fetch(a.href,d);if(i.status===200&&i.statusText==="OK"){let l=await i.json();return l!=null?(t.array=l,console.log(`Successful GET from /workspaces: ${t.array.reduce((h,$)=>h+$.name+" ","")}`),t):(t.error="Failed GET from /workspaces: failed to JSON-parse response",console.log(t.error),t.status=500,t.result=!1,t)}else return console.log(`Failed GET from /workspaces: ${a.href}`),t.error=await w(i),t.status=500,t.result=!1,console.log(t.error),t}catch(i){t.error=i.message,t.status=500,t.result=!1,console.log(i.message)}return t}async function rt(n,s,r){let t=new y;if(n==null||s==null)return t.result=!1,t.error="readerPost: invalid parameters",t.status=500,t;let e=T.readerStartSyncEndpoint(),a=new URL(e);a.searchParams.append("configurationId",r.id);let d={method:"POST",headers:await b(n,s)};try{console.log("Attempting POST to /startSync: "+a.href);let i=await fetch(a.href,d);if(i.status===200&&i.statusText==="OK"){console.log(`Successful POST to /startSync: ${e}`);let l=await i.json();return l.PayloadStr!=""?t.array=JSON.parse(l.PayloadStr):(t.result=!1,t.error="readerPost: blank payload returned, sync may be disabled on back end",t.status=500),t}else return t.error=await w(i),console.log(`Failed POST to /startSync: ${e}`),console.log(t.error),t.status=500,t.result=!1,t}catch(i){t.error=i.message,t.status=500,t.result=!1,console.log(i.message)}return t}async function at(n,s,r){let t=new y;if(n==null||s==null)return t.result=!1,t.error="readerPost: invalid parameters",t.status=500,t;let e=T.statsEndpoint(),a=new URL(`${e}/${r}`),d={method:"GET",headers:await b(n,s)};try{console.log("Attempting GET to /stats: "+a.href);let i=await fetch(a.href,d);if(i.status===200&&i.statusText==="OK"){console.log(`Successful GET to /stats: ${e}`);let l=await i.json();return t.array=[l],t}else return i.status===204?(t.error=await w(i),console.log(`Failed GET to /stats: ${e}`),console.log(t.error),t.status=204,t.result=!1,t):(t.error=await w(i),console.log(`Failed GET to /stats: ${e}`),console.log(t.error),t.status=500,t.result=!1,t)}catch(i){t.error=i.message,t.status=500,t.result=!1,console.log(i.message)}return t}f.APIResult=y,f.ActorArray=Ot,f.ActorNode=De,f.AuditConfig=vt,f.BatchArray=Ct,f.Group=$t,f.InitInfo=Dt,f.Milestone=H,f.MilestoneArray=Pe,f.ResourceArray=ie,f.ResourceNode=ve,f.SyncConfig=Z,f.Task=X,f.TaskArray=Rt,f.Tenant=j,f.TenantConfigInfo=Ee,f.TenantConfigType=ke,f.TenantNode=oe,f.TenantPermissionType=$e,f.TenantType=be,f.User=V,f.UserScope=kt,f.Workspace=Q,f.adminDelete=Be,f.adminPost=Fe,f.adminsGet=We,f.auditConfigAdd=Mt,f.auditConfigDelete=xe,f.auditConfigEdit=Ht,f.auditConfigGet=Le,f.auditConfigPost=Ue,f.auditConfigPut=ze,f.auditConfigRemove=qt,f.auditConfigRetrieve=jt,f.auditEventsGet=_e,f.auditEventsRetrieve=Kt,f.azureConfig=M,f.canListRootAssignments=us,f.configConsentForRead=Zt,f.configConsentForWrite=Qt,f.configConsentReadPut=Me,f.configConsentWritePut=je,f.configDelete=qe,f.configEdit=Jt,f.configEnable=Vt,f.configGet=He,f.configPatch=Ke,f.configPost=Je,f.configPut=Ve,f.configRemove=Yt,f.configsGet=Ze,f.configsRefresh=Xt,f.elevateGlobalAdminToUserAccessAdmin=fs,f.getPowerBIAccessToken=ds,f.getSyncVersion=U,f.graphConfig=p,f.groupsGet=Bt,f.helloNpm=bt,f.initGet=es,f.initPost=Qe,f.mindlineConfig=T,f.oauth2PermissionGrantsGet=Ge,f.oauth2PermissionGrantsSet=Re,f.processErrors=w,f.readerPost=rt,f.readerStats=at,f.requestAdminConsent=Wt,f.servicePrincipalGet=Ce,f.signIn=Ft,f.signInIncrementally=Ut,f.signOut=Lt,f.sum=At,f.tenantAdd=ts,f.tenantDelete=Xe,f.tenantPost=et,f.tenantRelationshipsGetByDomain=zt,f.tenantRelationshipsGetById=Oe,f.tenantRemove=ss,f.tenantUnauthenticatedLookup=le,f.tenantsGet=Ye,f.userAdd=rs,f.userDelegatedScopesGet=Ne,f.userDelegatedScopesRemove=xt,f.userRemove=as,f.usersGet=_t,f.workspaceConfigsGet=gs,f.workspaceEdit=ns,f.workspacePut=tt,f.workspacesGet=st,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
|
73
73
|
//# sourceMappingURL=sync.umd.js.map
|