@mindline/sync 1.0.107 → 1.0.109
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/.vs/VSWorkspaceState.json +1 -0
- package/.vs/slnx.sqlite +0 -0
- package/.vs/sync.slnx/FileContentIndex/{13d6a28d-932f-4eb6-818c-efea35f24838.vsidx → 233f16f5-9502-4eee-892d-94508f320b43.vsidx} +0 -0
- package/.vs/sync.slnx/FileContentIndex/88b226f1-9afd-4cf3-bdb6-5db742bb7e8d.vsidx +0 -0
- package/.vs/sync.slnx/FileContentIndex/f109c15d-d422-45e9-a5df-0b391ae0a643.vsidx +0 -0
- package/.vs/sync.slnx/v18/.wsuo +0 -0
- package/.vs/sync.slnx/v18/DocumentLayout.backup.json +20 -3
- package/.vs/sync.slnx/v18/DocumentLayout.json +35 -2
- package/dist/src/index.d.ts +3 -2
- package/dist/sync.es.js +74 -65
- package/dist/sync.es.js.map +1 -1
- package/dist/sync.umd.js +25 -21
- package/dist/sync.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/index.d.ts +14 -14
- package/src/index.ts +30 -9
- package/.vs/sync.slnx/FileContentIndex/75bd0095-9fc3-4f35-90e9-f4022b8e4b55.vsidx +0 -0
- package/.vs/sync.slnx/FileContentIndex/92b75297-fe76-448d-80d4-cbf5ef4fcd60.vsidx +0 -0
package/dist/sync.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(u,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("@microsoft/signalr"),require("class-transformer")):typeof define=="function"&&define.amd?define(["exports","@microsoft/signalr","class-transformer"],A):(u=typeof globalThis<"u"?globalThis:u||self,A(u.sync={},u.signalR,u.classTransformer))})(this,(function(u,A,P){"use strict";var hs=Object.defineProperty;var lt=u=>{throw TypeError(u)};var gs=(u,A,P)=>A in u?hs(u,A,{enumerable:!0,configurable:!0,writable:!0,value:P}):u[A]=P;var c=(u,A,P)=>gs(u,typeof A!="symbol"?A+"":A,P),ms=(u,A,P)=>A.has(u)||lt("Cannot "+P);var ne=(u,A,P)=>A.has(u)?lt("Cannot add the same private member more than once"):A instanceof WeakSet?A.add(u):A.set(u,P);var x=(u,A,P)=>(ms(u,A,"access private method"),P);var te,ct,O,fe,pe,he,H,ge;function dt(a){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(s,n,t.get?t:{enumerable:!0,get:()=>a[n]})}}return s.default=a,Object.freeze(s)}const V=dt(A),ut=[{oid:"1",name:"",mail:"",authority:"",tid:"",companyName:"",companyDomain:"",session:"Sign In",sel:!0}],ft=[{tid:"1",name:"",domain:"",tenantType:"",authority:"",sel:!0,graphSP:""}],pt=[],ht=[{id:"1",name:"",associatedUsers:["1"],associatedTenants:["1"],associatedConfigs:[],sel:!0}],gt=[{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"}],mt=[{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:[]}]}]}]}],yt=[{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:[]}],z="workspaceIDs";function wt(a,s){return a+s}function Tt(){return"hello NPM"}function _(){return"1.0.107"}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=_(),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 D=class D{static adminEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admin`}static adminIncompleteEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/incomplete-admin`}static adminsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admins`}static auditConfigEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-configuration`}static auditEventsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-events`}static configConsentEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/consent`}static configEnabledEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/status`}static configEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration`}static configsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configurations`}static initEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/init`}static readerStartSyncEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/startSync`}static tenantEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenant`}static tenantsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenants`}static workspaceEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace`}static workspacesEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspaces`}static workspaceConfigsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace-configurations`}static signalREndpoint(){return`https://${D.environmentTag}-signalrdispatcher-westus.azurewebsites.net/statsHub`}static statsEndpoint(){return`https://${D.environmentTag}-signalrdispatcher-westus.azurewebsites.net/api/stats`}};c(D,"environmentTag","dev");let T=D;class h{}c(h,"graphGroupsPredicate","v1.0/groups"),c(h,"graphMailPredicate","v1.0/me/messages"),c(h,"graphMePredicate","v1.0/me"),c(h,"graphOauth2PermissionGrantsPredicate","v1.0/oauth2PermissionGrants"),c(h,"graphServicePrincipalsPredicate","v1.0/servicePrincipals"),c(h,"graphUsersPredicate","v1.0/users"),c(h,"graphTenantByDomainPredicate","beta/tenantRelationships/findTenantInformationByDomainName"),c(h,"graphTenantByIdPredicate","beta/tenantRelationships/findTenantInformationByTenantId"),c(h,"authorityWW","https://login.microsoftonline.com/"),c(h,"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(h,"authorityUS","https://login.microsoftonline.us/"),c(h,"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(h,"authorityCN","https://login.partner.microsoftonline.cn/"),c(h,"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 St{constructor(){c(this,"id","");c(this,"displayName","");c(this,"description","")}}class bt{constructor(){c(this,"group","");c(this,"value","");c(this,"consented",!1);c(this,"removable",!1);c(this,"expanded","")}static compareByValue(s,n){return s.value.localeCompare(n.value)}static compareByGroup(s,n){return s.group.localeCompare(n.group)}}class Z{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 me=(a=>(a[a.invalid=0]="invalid",a[a.aad=1]="aad",a[a.ad=2]="ad",a[a.googleworkspace=3]="googleworkspace",a))(me||{}),ye=(a=>(a[a.read=1]="read",a[a.write=2]="write",a[a.notassigned=3]="notassigned",a))(ye||{});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 It(a,s){switch(a){case h.authorityWW:return s===1?"85d35da2-4118-4b03-aa05-605cedd7f2f8":"63100afe-506e-4bb2-8ff7-d8d5ab373129";case h.authorityUS:return s===1?"b08630c7-e227-4215-9746-afc9286fb864":"17aa5d5a-f09f-4cec-87a6-28596f9fa513";case h.authorityCN:return s===1?"7db7293b-add9-4a3f-8562-1a20bfe27d5e":"debd015b-1154-4111-a4cb-fc220a537697";default:debugger;return""}}function L(a){switch(a){case h.authorityWW:return"https://graph.microsoft.com/";case h.authorityUS:return"https://graph.microsoft.us/";case h.authorityCN:return"https://microsoftgraph.chinacloudapi.cn/";default:debugger;return""}}function $t(a){switch(a){case h.authorityWW:return"https://login.microsoftonline.com/";case h.authorityUS:return"https://login.microsoftonline.us/";case h.authorityCN:return"https://login.partner.microsoftonline.cn/";default:debugger;return""}}var we=(a=>(a[a.source=1]="source",a[a.target=2]="target",a[a.sourcetarget=3]="sourcetarget",a))(we||{});class Te{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 Q{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 At{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 X{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 W(){let a;try{a=window.localStorage;const s="__storage_test__";return a.setItem(s,s),a.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")&&a&&a.length!==0}}class kt{constructor(s=!1){ne(this,te);c(this,"version",_());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"})`),W()){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{x(this,te,ct).call(this,i);return}}}this.tab=0,this.version=_(),this.configlevelconsent_configid="",this.configlevelconsent_access=3;var n=JSON.stringify(ut),t=JSON.stringify(ft),e=JSON.stringify(pt),r=JSON.stringify(ht);try{this.us=P.deserializeArray(Z,n),this.ts=P.deserializeArray(j,t),this.cs=P.deserializeArray(Q,e),this.ws=P.deserializeArray(X,r),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 n of s.associatedUsers){let t=this.us.find(e=>e.oid===n);if(t!==void 0)t[z]+=s.id,t[z]+=" ";else debugger}for(let n of s.associatedTenants){let t=this.ts.find(e=>e.tid===n);if(t!==void 0)t[z]+=s.id,t[z]+=" ";else debugger}for(let n of s.associatedConfigs){let t=this.cs.find(e=>e.id===n);if(t!==void 0)t[z]+=s.id,t[z]+=" ";else debugger}}return!0}}te=new WeakSet,ct=function(s){this.tab=s.tab,this.version=_(),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(n=>{let t=new Z;return t.oid=n.oid,t.name=n.name,t.mail=n.mail,t.authority=n.authority,t.tid=n.tid,t.companyName=n.companyName,t.companyDomain=n.companyDomain,t.workspaceIDs=n.workspaceIDs,t.session=n.session,t.spacode=n.spacode,t.graphAccessToken=n.graphAccessToken,t.mindlineAccessToken=n.mindlineAccessToken,t.azureAccessToken=n.azureAccessToken,t.loginHint=n.loginHint,t.scopes=n.scopes,t.authTS=new Date(n.authTS),t.sel=n.sel,t.loggingIn=n.loggingIn,t}),typeof s.ts>"u"?this.ts=new Array:this.ts=s.ts.map(n=>{let t=new j;return t.tid=n.tid,t.name=n.name,t.domain=n.domain,t.tenantType=n.tenantType,t.authority=n.authority,t.workspaceIDs=n.workspaceIDs,t.sel=n.sel,t.lookupfield=n.lookupfield,t}),typeof s.cs>"u"?this.cs=new Array:this.cs=s.cs.map(n=>{let t=new Q;return t.id=n.id,t.workspaceId=n.workspaceId,t.name=n.name,t.description=n.description,t.tenants=n.tenants,t.isEnabled=n.isEnabled,t.workspaceIDs=n.workspaceIDs,t.sel=n.sel,t}),typeof s.ws>"u"?this.ws=new Array:this.ws=s.ws.map(n=>{let t=new X;return t.id=n.id,t.name=n.name,t.ownerid=n.ownerid,t.associatedUsers=n.associatedUsers,t.associatedTenants=n.associatedTenants,t.associatedConfigs=n.associatedConfigs,t.sel=n.sel,t})};const Dt=[{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 Et{constructor(s){ne(this,O);c(this,"tasks");this.tasks=[new Y],this.init(s)}init(s){if(console.log(`Calling TaskArray::init(bClearLocalStorage: ${s?"true":"false"})`),this.tasks.length=0,s&&W()&&localStorage.removeItem("Tasks"),W()){let n=localStorage.getItem("Tasks");if(n!=null&&typeof n=="string"&&n!==""){let e=JSON.parse(n);if(this.tasks=x(this,O,pe).call(this,e.tasks),this.tasks.length!==0)return}}this.tasks=x(this,O,pe).call(this,Dt)}setTaskStart(s,n){let t=x(this,O,fe).call(this,s);if(t!=null&&t!=null)t.setStart(n),t.status="in progress",x(this,O,he).call(this);else debugger}setTaskEnd(s,n,t){let e=x(this,O,fe).call(this,s);if(e!=null&&e!=null)e.setEnd(n),e.status=t,x(this,O,he).call(this);else debugger}}O=new WeakSet,fe=function(s){let n=this.tasks.find(t=>t.task==s);if(n==null||n==null){for(n of this.tasks)if(n.subtasks!=null&&n.subtasks!=null&&(n=n.subtasks.find(t=>t.task==s),n!=null&&n!=null))break}return n},pe=function(s){return s.map(n=>{let t=new Y;return t.id=n.id,t.task=n.task,t.setStart(new Date(n.start)),t.setEnd(new Date(n.end)),t.expected=n.expected,t.status=n.status,t.expanded=n.expanded,typeof n.subtasks<"u"&&n.subtasks!=null&&(t.subtasks=n.subtasks.map(e=>{let r=new Y;return r.id=e.id,r.task=e.task,r.setStart(new Date(e.start)),r.setEnd(new Date(e.end)),r.expected=e.expected,r.status=e.status,r.expanded=e.expanded,r})),t})},he=function(){let s=JSON.stringify(this);W()&&localStorage.setItem("Tasks",s)};class Y{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 n=0,t=this.end.getSeconds()-this.start.getSeconds();t<0&&(t+=60,n=-1);let e=this.end.getMinutes()-this.start.getMinutes()+n;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){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 Se{constructor(s){ne(this,H);c(this,"milestones",[]);this.init(s)}init(s){if(W()){let n=localStorage.getItem("syncmilestones");if(n!=null&&typeof n=="string"&&n!==""){let e=JSON.parse(n);if(e.length!==0)if(s)localStorage.removeItem("syncmilestones");else{x(this,H,ge).call(this,e);return}}}x(this,H,ge).call(this,gt)}save(){let s=JSON.stringify(this.milestones);W()&&localStorage.setItem("syncmilestones",s)}start(s){if(this.milestones==null||this.milestones.length<1){debugger;return}let n=Number(this.milestones[0].Run),t=new q(n+1);this.milestones.unshift(t),this.milestones=this.milestones.map(e=>{let r=new q(e.Run);return r.Start=e.Start,r.startDisplay=e.startDisplay,r.POST=e.POST,r.postDisplay=e.postDisplay,r.Read=e.Read,r.readDisplay=e.readDisplay,r.Write=e.Write,r.writeDisplay=e.writeDisplay,r.Duration=e.Duration,r.durationDisplay=e.durationDisplay,r}),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 n=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: ${n.Run}:${n.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 n=this.milestones.pop();console.log(`Removed milestone #${n.Run}: ${n.Start}`)}this.save(),this.milestones=this.milestones.map(n=>{let t=new q(n.Run);return t.Start=n.Start,t.startDisplay=n.startDisplay,t.POST=n.POST,t.postDisplay=n.postDisplay,t.Read=n.Read,t.readDisplay=n.readDisplay,t.Write=n.Write,t.writeDisplay=n.writeDisplay,t.Duration=n.Duration,t.durationDisplay=n.durationDisplay,t}),s(this.milestones)}}H=new WeakSet,ge=function(s){s==null?this.milestones=new Array:this.milestones=s.map(n=>{let t=new q(Number(n.Run));return t.start(n.Start),t.post(n.POST),t.read(n.Read),t.write(n.Write),t})};class Pt{constructor(s,n,t){c(this,"tenantNodes");c(this,"pb_startTS");c(this,"pb_progress");c(this,"pb_increment");c(this,"pb_idle");c(this,"pb_idleMax");c(this,"pb_total");c(this,"pb_timer");c(this,"milestoneArray");this.tenantNodes=new Array,this.init(s,n,t),this.pb_startTS=0,this.pb_progress=0,this.pb_increment=0,this.pb_timer=null,this.pb_idle=0,this.pb_idleMax=0,this.pb_total=0,this.milestoneArray=new Se(!1)}init(s,n,t){console.log(`Calling BatchArray::init(config: "${s?s.name:"null"}", bClearLocalStorage: ${t?"true":"false"})`),t&&W()&&(localStorage.removeItem(s.name),this.milestoneArray.init(t)),s!=null&&s.tenants!=null&&n!=null&&(this.tenantNodes.length=0,s.tenants.map(e=>{if(e.configurationTenantType==="source"||e.configurationTenantType==="sourcetarget"){let r=n.ts.find(o=>o.tid===e.tid);if(r!=null){let o=new re(e.tid,r.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(r=>{if((r.configurationTenantType==="target"||r.configurationTenantType==="sourcetarget")&&r.tid!==e.tid){let o=n.ts.find(d=>d.tid===r.tid);if(o!=null){let d=new re(r.tid,o.name,r.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,n,t,e){this.pb_startTS=Date.now(),this.pb_progress=0,this.pb_increment=.25,this.pb_idle=0,this.pb_idleMax=0,this.pb_total=0,this.pb_timer=setInterval(()=>{console.log("this.tenantNodes",this.tenantNodes),this.tenantNodes.map(o=>o.targets.map(d=>d.status==="complete"||o.nothingtosync).reduce((d,i)=>d&&i)).reduce((o,d)=>o&&d)?(clearInterval(this.pb_timer),this.pb_timer=null,this.pb_progress=100,s(this.pb_progress),t(`Complete. [max idle: ${this.pb_idleMax}]`)):(this.pb_total=this.pb_total+1,this.pb_idle=this.pb_idle+1,this.pb_idleMax=Math.max(this.pb_idle,this.pb_idleMax),t(`${this.pb_total} seconds elapsed. Last update ${this.pb_idle} seconds ago. [max idle: ${this.pb_idleMax}/60]`),this.pb_idle>=60&&this.milestoneArray.milestones[0].Write==null&&n(`sync continuing, but no update for ${this.pb_idle} seconds`),this.pb_progress<100&&(this.pb_progress=Math.min(100,this.pb_progress+this.pb_increment),s(this.pb_progress)))},1e3),this.milestoneArray.start(e)}uninitializeProgressBar(s,n,t,e){this.pb_startTS=0,this.pb_progress=0,s(this.pb_progress),n("sync failed to execute"),this.pb_increment=0,clearInterval(this.pb_timer),this.pb_timer=null,this.pb_idle=0,this.pb_idleMax=0,t(`No updates seen for ${this.pb_idle} seconds. [max idle: ${this.pb_idleMax}]`),this.milestoneArray.unstart(e)}initializeSignalR(s,n,t,e,r,o,d,i,l,f,p,$,G,N){this.milestoneArray.post(p),$("started sync, waiting for updates..."),this.init(s,n,!1);let U=F=>v=>{console.log(v);let E=JSON.parse(v);this.pb_idle=0;let k=t.find(m=>m.BatchId==E.TargetID);if(k==null){console.log(`Batch ${E.TargetID} not found in batchIdArray.`);debugger;return}let g=this.tenantNodes.find(m=>m.tid===k.SourceId);if(g==null){console.log(`Tenant ${k.SourceId} not found in BatchArray.`);debugger;return}g.batchId=k.BatchId;let Qe=E.Stats,C=Object.keys(Qe),B=Object.values(Qe),le=!1,Xe=!1;for(let m=0;m<C.length;m++){let R=C[m].endsWith("TotalCount"),K=C[m].endsWith("CurrentCount"),J=C[m].endsWith("ExtCount"),se=C[m].endsWith("DeferredCount"),de=C[m].endsWith("RescheduledCount");if(J&&(g.excluded=Math.max(Number(B[m]),g.excluded),g.targets.map(S=>{S.excluded=g.excluded,S.update(S.total,S.read,S.excluded,S.written,S.deferred)})),R&&(le=Number(B[m])==0,g.total=Math.max(Number(B[m]),g.total),g.targets.map(S=>{S.total=g.total,S.update(S.total,S.read,S.excluded,S.written,S.deferred)})),C[m].startsWith("Reader")){let S=/Reader\/TID:(.+)\/TotalCount/;if(K&&(S=/Reader\/TID:(.+)\/CurrentCount/),J&&(S=/Reader\/TID:(.+)\/ExtCount/),se&&(S=/Reader\/TID:(.+)\/DeferredCount/),de&&(S=/Reader\/TID:(.+)\/RescheduledCount/),C[m].match(S)==null){console.log(`tid not found in ${C[m]}.`);debugger;return}R?(le=Number(B[m])==0,g.total=Math.max(Number(B[m]),g.total),console.log(`----- ${g.name} TID: ${g.tid} batchId: ${g.batchId}`),console.log(`----- ${g.name} Total To Read: ${g.total}`)):(Xe=Number(B[m])==0,K?(g.read=Math.max(Number(B[m]),g.read),console.log(`----- ${g.name} Currently Read: ${g.read}`)):se&&(g.deferred=Math.max(Number(B[m]),g.deferred),console.log(`----- ${g.name} Deferred: ${g.deferred}`)))}if(g.nothingtosync=le&&Xe,C[m].startsWith("Writer")){let S=/Reader\/TID:(.+)\/TotalCount/;K&&(S=/Writer\/TID:(.+)\/CurrentCount/),J&&(S=/Writer\/TID:(.+)\/ExtCount/),se&&(S=/Writer\/TID:(.+)\/DeferredCount/),de&&(S=/Writer\/TID:(.+)\/RescheduledCount/);let ue=C[m].match(S);if(ue==null){console.log(`tid not found in ${C[m]}.`);debugger;return}let b=g.targets.find(ps=>ps.tid===ue[1]);if(b==null){console.log(`Writer ${g.name} not found under Reader ${g.name}.`);debugger;return}if(b.total=Math.max(Number(g.total),b.total),b.total=Math.max(Number(g.total),b.total),b.batchId=k.BatchId,R)b.total=Math.max(Number(R),b.total),console.log(`----- ${b.name} TID: ${b.tid} batchId: ${b.batchId}`),console.log(`----- ${b.name} Total To Write: ${b.total}`);else if(K)b.written=Math.max(Number(B[m]),b.written),console.log(`----- ${b.name} Total Written: ${b.written}`);else if(se||de)b.deferred=Math.max(Number(B[m]),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)}}g.update(g.total,g.read,g.excluded,g.written,g.deferred);let Ye=!0,et=!0,tt=!1,st=!0,ce=0,nt=0,rt=0,at=0,ot=0,it=0;if(this.tenantNodes.map(m=>{m.targets.map(R=>{et&&(et=R.status=="complete"||R.status=="failed"),tt||(tt=R.total>0||R.status!="not started"),at+=Math.max(R.total,m.total),ot+=R.written,it+=R.excluded}),st&&(st=m.nothingtosync),Ye&&(Ye=m.status=="complete"||m.status=="failed"),ce+=m.total,nt+=m.read,rt+=m.excluded}),r(ce),d(nt),o(rt),i(Math.max(at,ce)),f(ot),l(it),st)this.milestoneArray.write(p),F.stop(),$("nothing to sync"),console.log('Setting config sync result: "nothing to sync"');else{if(Ye){this.milestoneArray.read(p),$("reading complete"),console.log('Setting config sync result: "reading complete"'),e(s.workspaceId);let J=(Date.now()-this.pb_startTS)/1e3/8.5;this.pb_increment=J,console.log(`Setting increment: ${this.pb_increment}% per second`)}et?(this.milestoneArray.write(p),F.stop(),$("sync complete"),console.log('Setting config sync result: "complete"')):tt?($("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"'))}};t.map(F=>{const v=T.signalREndpoint();let E=new URL(v);E.searchParams.append("statsId",F.BatchId),console.log(`Creating SignalR Hub for TID: ${F.SourceId} ${E.href}`);const k=new V.HubConnectionBuilder().withUrl(E.href).withAutomaticReconnect().configureLogging(V.LogLevel.Information).build();N&&JSON.parse(N).TargetID===F.BatchId&&U(k)(N),k.on("newMessage",U(k)),k.onreconnecting(g=>{console.assert(k.state===V.HubConnectionState.Reconnecting),console.log(`Connection lost due to error "${g}". Reconnecting.`)}),k.onreconnected(g=>{console.assert(k.state===V.HubConnectionState.Connected),console.log(`Connection reestablished. Connected with connectionId "${g}".`)}),k.onclose(async()=>{console.log("Connection closing. Attempting restart."),await k.start()}),k.start().catch(console.error)})}async startSync(s,n,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 Ze(s,n,t),e}}class re{constructor(s,n,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=n,this.tid=s,this.batchId=t,this.nothingtosync=!1,this.targets=new Array,this.update(0,0,0,0,0)}update(s,n,t,e,r){this.total=s,this.read=n,this.excluded=t,this.written=e,this.deferred=r,this.read===0&&this.written===0&&(this.status="not started"),this.read>0?this.read+this.excluded<this.total?this.status="in progress":this.read+this.excluded===this.total&&(this.status="complete"):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 ae{constructor(s,n){c(this,"resourceNodes");this.resourceNodes=new Array,s&&this.init(n)}init(s){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${s?"true":"false"})`),W()){let t=localStorage.getItem("ResourceArray");if(t!=null&&typeof t=="string"&&t!=="")if(s)localStorage.removeItem("ResourceArray");else{let r=JSON.parse(t);this.resourceNodes=r.resourceNodes;return}}var n=JSON.stringify(mt);try{this.resourceNodes=P.deserializeArray(be,n)}catch{debugger}}async read(s,n){let t=new ae(!1,!1);return t.resourceNodes=await cs(s,n),t}save(){if(W()){let s=JSON.stringify(this);localStorage.setItem("ResourceArray",s)}}}class be{constructor(s,n,t){c(this,"type");c(this,"resource");c(this,"cost");c(this,"expanded");c(this,"resources");this.type=s,this.resource=n,this.cost=t,this.expanded=!1,this.resources=new Array}}class vt{constructor(s){c(this,"actorNodes");this.actorNodes=new Array,this.init(s)}init(s){if(console.log(`Calling ResourceArray::init(bClearLocalStorage: ${s?"true":"false"})`),W()){let t=localStorage.getItem("RBACActors");if(t!=null&&typeof t=="string"&&t!=="")if(s)localStorage.removeItem("RBACActors");else{let r=JSON.parse(t);this.actorNodes=r.actorNodes;return}}var n=JSON.stringify(yt);try{this.actorNodes=P.deserializeArray(Ie,n)}catch{debugger}}}class Ie{constructor(s,n,t,e,r,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=n,this.resource=t,this.role=e,this.updatedby=r,this.updatedon=o,this.actors=new Array}}function Gt(a){return"Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All"}async function ee(a,s){const n=new Headers;n.append("Content-Type","application/json"),n.append("accept","*/*");const t=Gt();if(s.graphAccessToken==null||s.graphAccessToken==="")try{let e=await a.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=a.getAllAccounts(),r=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==r&&(o=e[i]);let d=await a.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 r=a.getAllAccounts(),o=s.oid+"."+s.tid,d=null;for(let i=0;i<r.length;i++)r[i].homeAccountId==o&&(d=r[i]);a.acquireTokenRedirect({scopes:[t],account:d})}catch(r){console.log("Front end graph token redirect acquisition failure: "+r)}}return n.append("Authorization",`Bearer ${s.graphAccessToken}`),n}async function Rt(a,s,n){if(s==null||s.spacode=="")return{groups:[],error:"500: invalid user passed to groupsGet"};let e={method:"GET",headers:await ee(a,s)};try{let r=L(s.authority)+h.graphGroupsPredicate;r+=`/?$filter=startsWith(displayName, '${n}')`;let d=await(await fetch(r,e)).json();return typeof d.error<"u"?{groups:[],error:`${d.error.code}: ${d.error.message}`}:{groups:d.value,error:""}}catch(r){return console.log(r),{groups:[],error:`Exception: ${r}`}}}async function $e(a,s,n,t){try{let e=L(s.authority)+h.graphOauth2PermissionGrantsPredicate,r=new URL(e);r.searchParams.append("$filter",`resourceId eq '${n}' and consentType eq 'Principal' and principalId eq '${t}'`);let d=await(await fetch(r.href,a)).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 Ae(a,s,n,t){if(s==null||s.spacode=="")return!1;try{let e=L(s.authority);e+=h.graphOauth2PermissionGrantsPredicate+`/${n}`;let r=`{ "scope": "${t}" }`,d={method:"PATCH",headers:await ee(a,s),body:r},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 Ct(a,s){let n=$t(a.authority);n+=a.tid,n+="/adminconsent";let t=new URL(n),e=It(a.authority,s);t.searchParams.append("client_id",e),t.searchParams.append("redirect_uri",window.location.origin),t.searchParams.append("domain_hint",a.companyDomain),t.searchParams.append("login_hint",a.mail),window.location.assign(t.href)}async function ke(a,s,n){try{let t=L(s.authority);t+=h.graphServicePrincipalsPredicate,t+=`(appId='${n}')`;let e=new URL(t);e.searchParams.append("$select","id,appId,displayName");let o=await(await fetch(e.href,a)).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 Ot(a,s){if(a.authority==""){let e=new j;if(e.domain=a.tid,await oe(e,!1))a.authority=e.authority;else{debugger;return!1}}let n=window.location.href;switch(a.authority){case h.authorityWW:n+="MicrosoftIdentity/Account/SignIn";break;case h.authorityUS:n+="USGov/SignIn";break;case h.authorityCN:n+="China/SignIn";break;default:return!1}let t=new URL(n);if(t.searchParams.append("redirectUri",window.location.origin),a.oid!=="1"){t.searchParams.append("loginHint",a.mail);const e=/@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/,r=a.mail.match(e);let o=r?r[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 Nt(a,s){debugger;if(a.oid=="1")return;let n=window.location.href;switch(a.authority){case h.authorityWW:n+="MicrosoftIdentity/Account/Challenge";break;case h.authorityUS:n+="USGov/Challenge";break;case h.authorityCN:n+="China/Challenge";break;default:return}let t=new URL(n);t.searchParams.append("redirectUri",window.location.origin),t.searchParams.append("scope",s),t.searchParams.append("domainHint","organizations"),t.searchParams.append("loginHint",a.mail),window.location.assign(t.href)}async function Wt(a){if(a.oid=="1")return!1;let s=window.location.href;s+="user";let n=new URL(s);n.searchParams.append("oid",a.oid),n.searchParams.append("tid",a.tid),n.searchParams.append("loginHint",a.loginHint),n.searchParams.append("verb","LOGOUT");let t={method:"PATCH"},e=await fetch(n.href,t);if(e.status==200&&e.statusText=="OK")console.log(`Successfully set admin ${a.mail} logout_hint`);else return console.log(`Failed to set admin ${a.mail} logout_hint`),!1;let r=window.location.href;switch(a.authority){case h.authorityWW:r+="MicrosoftIdentity/Account/SignOut";break;case h.authorityUS:r+="USGov/SignOut";break;case h.authorityCN:r+="China/SignOut";break;default:return!1}return n=new URL(r),n.searchParams.append("redirectUri",window.location.origin),window.location.assign(n.href),!0}async function Ft(a,s,n,t){if(t)debugger;if(s.name!=null&&s.name!=="")return!1;if(a.graphAccessToken!=null&&a.graphAccessToken===""){console.log(`tenantRelationshipsGetByDomain called with invalid logged in user: ${a.name}`);try{let i=await n.acquireTokenByCode({code:a.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});a.graphAccessToken=i.accessToken,console.log("tenantRelationshipsGetByDomain: Front end token acquired: "+a.graphAccessToken.slice(0,20))}catch(i){return console.log("tenantRelationshipsGetByDomain: Front end token failure: "+i),!1}}const e=new Headers,r=`Bearer ${a.graphAccessToken}`;e.append("Authorization",r);let o={method:"GET",headers:e};try{var d=L(s.authority)+h.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 De(a,s,n,t,e){if(console.log("**** tenantRelationshipsGetById"),e)debugger;if(a.graphAccessToken==="")try{let l=await t.acquireTokenByCode({code:a.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});a.graphAccessToken=l.accessToken,console.log("tenantRelationshipsGetById: Front end token acquired: "+a.graphAccessToken.slice(0,20))}catch(l){return console.log("tenantRelationshipsGetById: Front end token failure: "+l),!1}const r=new Headers,o=`Bearer ${a.graphAccessToken}`;r.append("Authorization",o);let d={method:"GET",headers:r};try{var i=L(a.authority)+h.graphTenantByIdPredicate;i+="(tenantId='",i+=s.tid,i+="')",console.log("tenantRelationshipsGetById: Attempting GET from /findTenantInformationByTenantId:",i);let f=await(await fetch(i,d)).json();if(f&&typeof f.displayName!==void 0&&f.displayName!==""){if(s!==void 0)s.name=f.displayName,s.domain=f.defaultDomainName;else{console.log("tenantRelationshipsGetById: missing associated tenant for logged in user.");debugger}return console.log("tenantRelationshipsGetById: Successful GET from /findTenantInformationByTenantId: ",f.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(a,s){if(s)debugger;let n=[h.authorityWW,h.authorityUS,h.authorityCN],t=[h.authorityWWRegex,h.authorityUSRegex,h.authorityCNRegex],e=null;try{for(let i=0;i<3;i++){var r=n[i];if(a.lookupfield=="Domain"?r+=a.domain:a.lookupfield=="Tenant ID"&&(r+=a.tid),r+="/.well-known/openid-configuration",console.log("Attempting GET from openid well-known endpoint: ",r),e=await fetch(r),e.status==200){let l=await e.json();if(l){var o=l.authorization_endpoint;for(let f=0;f<3;f++){var d=o.match(t[f]);if(d!=null)return a.tid=d[2],a.authority=d[1],console.log(`Successful GET from openid well-known endpoint: tid: ${a.tid} authority: ${a.authority}`),!0}}else console.log(`Failed JSON parse of openid well-known endpoint response ${r}.`)}else console.log(`Failed GET from ${r}.`)}}catch(i){console.log("Failed to GET from openid well-known endpoint: ",i)}return(a.tid==""||a.authority=="")&&console.log(`GET from openid well-known endpoint failed to find tenant: ${e?e.statusText:"unknown"}`),!1}async function Ee(a,s,n){if(s==null||s.spacode==""||n==null){debugger;return{scopes:null,id:null,error:"500: invalid parameter(s) passed to getUserDelegatedScopes"}}let e={method:"GET",headers:await ee(a,s)};try{if(n.graphSP==""){let{spid:i,error:l}=await ke(e,s,"00000003-0000-0000-c000-000000000000");if(l!=""){debugger;return{scopes:null,id:null,error:`${l}`}}n.graphSP=i}let{grants:r,id:o,error:d}=await $e(e,s,n.graphSP,s.oid);if(d!=""){debugger;return{scopes:null,id:null,error:`${d}`}}return{scopes:r,id:o,error:""}}catch(r){debugger;return console.log(r),{scopes:null,id:null,error:`Exception: ${r}`}}}async function Bt(a,s,n,t){if(s==null||s.spacode==""||n==null){debugger;return!1}let{scopes:e,id:r,error:o}=await Ee(a,s,n);if(o!=""){debugger;return console.log(`userDelegatedScopesRemove: cannot find userDelegatedScopes for ${s.mail}: ${o}`),!1}e=e.replace(t,"");let d=await Ae(a,s,r,e);if(!d){debugger;return console.log(`userDelegatedScopesRemove: cannot set oauth2PermissionGrants for ${s.mail}: ${o}`),!1}return s.scopes=e.split(" "),d}async function xt(a,s){if(s==null||s.spacode=="")return{users:[],error:"500: invalid user passed to usersGet"};try{let t={method:"GET",headers:await ee(a,s)},e=L(s.authority);e+=h.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(n){return console.log(n),{users:[],error:`Exception: ${n}`}}}async function Ut(a,s,n,t){return Re(a,s,n,t)}async function _t(a,s,n,t){return Ce(a,s,n,t)}async function Lt(a,s,n,t,e){return Oe(a,s,n,t,e)}async function zt(a,s,n,t){return Ne(a,s,n,t)}async function Mt(a,s,n){return We(a,s,n)}async function jt(a,s,n,t,e,r,o,d){let i=new y;if(n.id==="1"){if(i=await Le(a,s,n,r.id,d),i.result){t&&t(n.id);const l={};Object.defineProperty(l,n.id,{value:!0,writable:!0,enumerable:!0}),e(l);let f=r.associatedConfigs.findIndex(p=>p=="1");f!==-1&&(r.associatedConfigs.splice(f,1),r.associatedConfigs.push(n.id))}}else i=await ze(a,s,n,d);return o.save(),i}async function qt(a,s,n,t,e){let r=new y;return r=await _e(a,s,n,t,e),r}async function Ht(a,s,n,t,e){return Fe(a,s,n,t,e)}async function Kt(a,s,n,t,e){return Be(a,s,n,t,e)}async function Jt(a,s,n,t,e,r){let o=new y;if(e)debugger;try{let d=t.ws.find(i=>i.id===n);if(d!=null){d.associatedConfigs.length=0;let i=await xe(a,s,r,d.id,e);return i.result&&(t.tagWithWorkspaces(),localStorage.setItem("BatchIdArray","{}")),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 Vt(a,s,n,t,e){return Ue(a,s,n,t)}async function Zt(a,s,n,t,e){console.log(">>>>>> initGet");let r=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),r.result=await De(s,o,n,a,e),t.setTaskEnd("GET tenant details",new Date,"complete"),r.result&&(s.companyName=o.name,s.companyDomain=o.domain,t.setTaskStart("POST config init",new Date),r=await je(a,s,e),t.setTaskEnd("POST config init",new Date,r.result?"complete":"failed")),r.result&&(t.setTaskStart("GET workspaces",new Date),r=await as(a,s,n,e),t.setTaskEnd("GET workspaces",new Date,r.result?"complete":"failed")),console.log("initGet complete. Version: "+_()),r):(r.error=`Failed to retrieve authority for user "${s.mail}" TID ${s.tid}.`,r.result=!1,r)}async function Qt(a,s,n,t){return Ke(a,s,n,t)}async function Xt(a,s,n,t,e){return qe(a,s,n,t)}async function Yt(a,s,n,t){return Ge(a,s,n,t)}async function es(a,s,n,t){return Pe(a,s,n,t)}async function ts(a,s,n,t){return await Je(a,s,n,t)}function ss(a,s,n,t){n.map(e=>{let r=null,o=s.us.findIndex(l=>l.oid===e.userId||l.oid===e.email);if(o===-1){let l=s.us.findIndex(f=>f.oid==="1");if(l!==-1){r=s.us.at(l);let f=a.associatedUsers.findIndex(p=>p=="1");f!==-1&&(a.associatedUsers.splice(f,1),a.associatedUsers.push(e.userId))}else r=new Z,s.us.push(r)}else r=s.us.at(o);r.sel=t===e.userId,r.oid=e.userId?e.userId:e.email,r.name=e.firstName??r.name,r.mail=e.email,r.tid=e.tenantId;let d=s.ts.find(l=>l.tid===r.tid);d!=null&&(r.authority=d.authority,r.companyName=d.name,r.companyDomain=d.domain),a.associatedUsers.findIndex(l=>l===r.oid)==-1&&a.associatedUsers.push(r.oid)}),s.save()}function ns(a,s,n,t){n.map(e=>{let r=null,o=s.ts.findIndex(f=>f.tid===e.tenantId);if(o===-1){let f=s.ts.findIndex(p=>p.tid==="1");if(f!==-1){r=s.ts.at(f);let p=a.associatedTenants.findIndex($=>$=="1");p!==-1&&(a.associatedTenants.splice(p,1),a.associatedTenants.push(e.tenantId))}else r=new j,s.ts.push(r)}else r=s.ts.at(o);r.sel=t===e.tenantId,r.tid=e.tenantId,r.name=e.name,r.domain=e.domain,r.tenantType=e.type.toLowerCase();const d=/^(https:\/\/login.microsoftonline.(?:us|com)\/)organizations\/v2.0$/,i=e.authority.match(d);r.authority=i?i[1]:e.authority,a.associatedTenants.findIndex(f=>f===e.tenantId)==-1&&a.associatedTenants.push(e.tenantId)}),s.save()}function rs(a,s,n,t){n.map(e=>{let r=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){r=s.cs.at(i);let l=a.associatedConfigs.findIndex(f=>f=="1");l!==-1&&(a.associatedConfigs.splice(l,1),a.associatedConfigs.push(e.id))}else r=new Q,s.cs.push(r)}else r=s.cs.at(o);r.sel=t===e.id,r.id=e.id,r.workspaceId=e.workspaceId,r.name=e.name,r.description=e.description,r.isEnabled=e.isEnabled,r.tenants.length=0,e.tenants.map(i=>{let l=new Te;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=r.id,l.batchId=i.batchId??"",l.isReadPermissionConsented=i.isReadPermissionConsented,l.isWritePermissionConsented=i.isWritePermissionConsented,r.tenants.push(l)}),a.associatedConfigs.findIndex(i=>i===e.id)==-1&&a.associatedConfigs.push(e.id)}),console.log("--------------ii-----------",s),s.save()}async function as(a,s,n,t){let e=new y;if(t)debugger;try{if(e=await Ve(a,s,t),e.result){for(let r of e.array){let o=null,d=n.ws.findIndex(v=>v.id===r.id);if(d===-1){let v=n.ws.findIndex(E=>E.id==="1");v!==-1?o=n.ws.at(v):(o=new X,n.ws.push(o))}else o=n.ws.at(d);let i="";for(let v of o.associatedUsers){let E=n.us.find(k=>k.oid===v);E!=null&&E.sel&&(i=E.oid)}let l="";for(let v of o.associatedTenants){let E=n.ts.find(k=>k.tid===v);E!=null&&E.sel&&(l=E.tid)}let f="";for(let v of o.associatedConfigs){let E=n.cs.find(k=>k.id===v);E!=null&&E.sel&&(f=E.id)}o.associatedUsers.length=0,o.associatedTenants.length=0,o.associatedConfigs.length=0,o.id=r.id,o.name=r.name,o.ownerid=r.workspaceOwnerUserId;let p=ve(a,s,o.id,t),$=He(a,s,o.id,t),G=Me(a,s,o.id,t),[N,U,F]=await Promise.all([p,$,G]);if(!N.result)return N;if(!U.result)return U;if(!F.result)return F;ns(o,n,U.array,l),ss(o,n,N.array,i),rs(o,n,F.array,f),n.tagWithWorkspaces()}return e}}catch(r){console.log(r.message),e.error=r.message}return e.result=!1,e.status=500,e}async function os(a,s){let n="",t=_();try{let e=a.getAllAccounts(),r=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==r&&(o=e[i]);n=(await a.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: "+n.slice(0,20))}catch{console.log("PowerBI token failed to be acquired silently")}return console.log(t),n}async function ie(a,s){const n=new Headers;if(n.append("Content-Type","application/json"),n.append("accept","*/*"),s.azureAccessToken==null||s.azureAccessToken==="")try{let t=a.getAllAccounts(),e=s.oid+"."+s.tid,r=null;for(let d=0;d<t.length;d++)t[d].homeAccountId==e&&(r=t[d]);let o=await a.acquireTokenSilent({scopes:["https://management.azure.com/user_impersonation"],account:r});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=a.getAllAccounts(),r=s.oid+"."+s.tid,o=null;for(let d=0;d<e.length;d++)e[d].homeAccountId==r&&(o=e[d]);a.acquireTokenRedirect({scopes:["https://management.azure.com/user_impersonation"],account:o})}catch(e){console.log("Front end token popup acquisition failure: "+e)}}return n.append("Authorization",`Bearer ${s.azureAccessToken}`),n}async function is(a,s){if(s==null||s.spacode=="")return!1;try{let t={method:"GET",headers:await ie(a,s)},e=M.azureListRootAssignments;e+="'",e+=s.oid,e+="'";let r=await fetch(e,t);if(r.status==200){let o=await r.json();o=o;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await w(r)),!1}catch(n){return console.log(n),!1}return!0}async function ls(a,s){if(s==null||s.spacode=="")return!1;try{let t={method:"POST",headers:await ie(a,s)},e=M.azureElevateAccess,r=await fetch(e,t);if(r.status==200)console.log("Successful call to Azure Resource Graph list root assignments");else return console.log(await w(r)),!1}catch(n){return console.log(n),!1}return!0}async function cs(a,s){let n=new Array;if(s==null||s.spacode=="")return n;try{let e={method:"GET",headers:await ie(a,s)},r=M.azureListRootAssignments;r+="'",r+=s.oid,r+="'";let o=await fetch(r,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)),n}catch(t){return console.log(t),n}return n}function ds(a){let s="8d95d21c-c378-4bb0-9f52-88c30d271e7a",n=a.authority.toLowerCase();return n.startsWith("https://login.microsoftonline.com/")?s="8d95d21c-c378-4bb0-9f52-88c30d271e7a":n.startsWith("https://login.microsoftonline.us/")?s="48da942e-ea3d-49e4-a054-81649012f8f2":n.startsWith("https://login.partner.microsoftonline.cn/")&&(s="c91d32e4-dcc5-4d77-826a-16e93ffce666"),`api://${s}/Config.Write`}async function I(a,s){const n=new Headers;n.append("Content-Type","application/json"),n.append("accept","*/*");const t=ds(s);try{let e=a.getAllAccounts(),r=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==r&&(o=e[i]);let d=await a.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 r=a.getAllAccounts(),o=s.oid+"."+s.tid,d=null;for(let i=0;i<r.length;i++)r[i].homeAccountId==o&&(d=r[i]);a.acquireTokenRedirect({scopes:[t],account:d})}catch(r){console.log("Front end mindline token redirect acquisition failure: "+r)}}return n.append("Authorization",`Bearer ${s.mindlineAccessToken}`),n}async function w(a){let s="";if(a.status===401&&(s=a.statusText,s!=""))return s;let n=await a.json();if(n.error!==void 0)s=`Error: ${n.error} Message: ${n.message}`;else if(n.errors!==void 0)s=Object.keys(n.errors).reduce((r,o)=>r+o+": "+n.errors[o]+" ","");else if(n.title!==void 0)s=n.title;else debugger;return s}async function Pe(a,s,n,t){let e=new y;if(n.oid==""&&n.mail==""||t=="")return e.result=!1,e.error="adminDelete: invalid parameters",e.status=500,e;let r=null;r=new URL(T.adminEndpoint()),r.searchParams.append("workspaceId",t),r.searchParams.append("email",n.mail);let d={method:"DELETE",headers:await I(a,s)};try{console.log("Attempting DELETE from /admin: "+r.href);let i=await fetch(r.href,d);return i.status===200&&i.statusText==="OK"?(console.log(`Successful DELETE from /admin: ${r.href}`),e):(e.error=await w(i),console.log(`Failed DELETE from /admin: ${r.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 ve(a,s,n,t){let e=new y;if(n==="")return e.result=!1,e.status=500,e.error="adminsGet: no workspace provided",e;let r=T.adminsEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n);let i={method:"GET",headers:await I(a,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 f=await l.json();return f!=null?(e.array=f,console.log(`Successful GET from /admins: ${e.array.reduce(($,G)=>$+G.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 Ge(a,s,n,t){let e=new y;if(n.mail==""||n.authority==""||n.tid==="")return e.result=!1,e.error="adminPost: invalid argument",e.status=500,e;let r=T.adminEndpoint();const o=await I(a,s);let d=`
|
|
1
|
+
(function(f,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("@microsoft/signalr"),require("class-transformer")):typeof define=="function"&&define.amd?define(["exports","@microsoft/signalr","class-transformer"],A):(f=typeof globalThis<"u"?globalThis:f||self,A(f.sync={},f.signalR,f.classTransformer))})(this,(function(f,A,P){"use strict";var hs=Object.defineProperty;var lt=f=>{throw TypeError(f)};var gs=(f,A,P)=>A in f?hs(f,A,{enumerable:!0,configurable:!0,writable:!0,value:P}):f[A]=P;var c=(f,A,P)=>gs(f,typeof A!="symbol"?A+"":A,P),ms=(f,A,P)=>A.has(f)||lt("Cannot "+P);var ne=(f,A,P)=>A.has(f)?lt("Cannot add the same private member more than once"):A instanceof WeakSet?A.add(f):A.set(f,P);var x=(f,A,P)=>(ms(f,A,"access private method"),P);var te,ct,N,fe,pe,he,H,ge;function dt(a){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(s,n,t.get?t:{enumerable:!0,get:()=>a[n]})}}return s.default=a,Object.freeze(s)}const V=dt(A),ut=[{oid:"1",name:"",mail:"",authority:"",tid:"",companyName:"",companyDomain:"",session:"Sign In",sel:!0}],ft=[{tid:"1",name:"",domain:"",tenantType:"",authority:"",sel:!0,graphSP:""}],pt=[],ht=[{id:"1",name:"",associatedUsers:["1"],associatedTenants:["1"],associatedConfigs:[],sel:!0}],gt=[{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"}],mt=[{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:[]}]}]}]}],yt=[{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:[]}],z="workspaceIDs";function wt(a,s){return a+s}function Tt(){return"hello NPM"}function _(){return"1.0.109"}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=_(),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 D=class D{static adminEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admin`}static adminIncompleteEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/incomplete-admin`}static adminsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admins`}static auditConfigEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-configuration`}static auditEventsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-events`}static configConsentEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/consent`}static configEnabledEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/status`}static configEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration`}static configsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configurations`}static initEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/configuration/init`}static readerStartSyncEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/startSync`}static tenantEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenant`}static tenantsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/tenants`}static workspaceEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace`}static workspacesEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspaces`}static workspaceConfigsEndpoint(){return`https://${D.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/workspace-configurations`}static signalREndpoint(){return`https://${D.environmentTag}-signalrdispatcher-westus.azurewebsites.net/statsHub`}static statsEndpoint(){return`https://${D.environmentTag}-signalrdispatcher-westus.azurewebsites.net/api/stats`}};c(D,"environmentTag","dev");let T=D;class h{}c(h,"graphGroupsPredicate","v1.0/groups"),c(h,"graphMailPredicate","v1.0/me/messages"),c(h,"graphMePredicate","v1.0/me"),c(h,"graphOauth2PermissionGrantsPredicate","v1.0/oauth2PermissionGrants"),c(h,"graphServicePrincipalsPredicate","v1.0/servicePrincipals"),c(h,"graphUsersPredicate","v1.0/users"),c(h,"graphTenantByDomainPredicate","beta/tenantRelationships/findTenantInformationByDomainName"),c(h,"graphTenantByIdPredicate","beta/tenantRelationships/findTenantInformationByTenantId"),c(h,"authorityWW","https://login.microsoftonline.com/"),c(h,"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(h,"authorityUS","https://login.microsoftonline.us/"),c(h,"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(h,"authorityCN","https://login.partner.microsoftonline.cn/"),c(h,"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 St{constructor(){c(this,"id","");c(this,"displayName","");c(this,"description","")}}class bt{constructor(){c(this,"group","");c(this,"value","");c(this,"consented",!1);c(this,"removable",!1);c(this,"expanded","")}static compareByValue(s,n){return s.value.localeCompare(n.value)}static compareByGroup(s,n){return s.group.localeCompare(n.group)}}class Z{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 me=(a=>(a[a.invalid=0]="invalid",a[a.aad=1]="aad",a[a.ad=2]="ad",a[a.googleworkspace=3]="googleworkspace",a))(me||{}),ye=(a=>(a[a.read=1]="read",a[a.write=2]="write",a[a.notassigned=3]="notassigned",a))(ye||{});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 It(a,s){switch(a){case h.authorityWW:return s===1?"85d35da2-4118-4b03-aa05-605cedd7f2f8":"63100afe-506e-4bb2-8ff7-d8d5ab373129";case h.authorityUS:return s===1?"b08630c7-e227-4215-9746-afc9286fb864":"17aa5d5a-f09f-4cec-87a6-28596f9fa513";case h.authorityCN:return s===1?"7db7293b-add9-4a3f-8562-1a20bfe27d5e":"debd015b-1154-4111-a4cb-fc220a537697";default:debugger;return""}}function L(a){switch(a){case h.authorityWW:return"https://graph.microsoft.com/";case h.authorityUS:return"https://graph.microsoft.us/";case h.authorityCN:return"https://microsoftgraph.chinacloudapi.cn/";default:debugger;return""}}function $t(a){switch(a){case h.authorityWW:return"https://login.microsoftonline.com/";case h.authorityUS:return"https://login.microsoftonline.us/";case h.authorityCN:return"https://login.partner.microsoftonline.cn/";default:debugger;return""}}var we=(a=>(a[a.source=1]="source",a[a.target=2]="target",a[a.sourcetarget=3]="sourcetarget",a))(we||{});class Te{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 Q{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 At{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 X{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 O(){let a;try{a=window.localStorage;const s="__storage_test__";return a.setItem(s,s),a.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")&&a&&a.length!==0}}class kt{constructor(s=!1){ne(this,te);c(this,"version",_());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"})`),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{x(this,te,ct).call(this,i);return}}}this.tab=0,this.version=_(),this.configlevelconsent_configid="",this.configlevelconsent_access=3;var n=JSON.stringify(ut),t=JSON.stringify(ft),e=JSON.stringify(pt),r=JSON.stringify(ht);try{this.us=P.deserializeArray(Z,n),this.ts=P.deserializeArray(j,t),this.cs=P.deserializeArray(Q,e),this.ws=P.deserializeArray(X,r),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 n of s.associatedUsers){let t=this.us.find(e=>e.oid===n);if(t!==void 0)t[z]+=s.id,t[z]+=" ";else debugger}for(let n of s.associatedTenants){let t=this.ts.find(e=>e.tid===n);if(t!==void 0)t[z]+=s.id,t[z]+=" ";else debugger}for(let n of s.associatedConfigs){let t=this.cs.find(e=>e.id===n);if(t!==void 0)t[z]+=s.id,t[z]+=" ";else debugger}}return!0}}te=new WeakSet,ct=function(s){this.tab=s.tab,this.version=_(),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(n=>{let t=new Z;return t.oid=n.oid,t.name=n.name,t.mail=n.mail,t.authority=n.authority,t.tid=n.tid,t.companyName=n.companyName,t.companyDomain=n.companyDomain,t.workspaceIDs=n.workspaceIDs,t.session=n.session,t.spacode=n.spacode,t.graphAccessToken=n.graphAccessToken,t.mindlineAccessToken=n.mindlineAccessToken,t.azureAccessToken=n.azureAccessToken,t.loginHint=n.loginHint,t.scopes=n.scopes,t.authTS=new Date(n.authTS),t.sel=n.sel,t.loggingIn=n.loggingIn,t}),typeof s.ts>"u"?this.ts=new Array:this.ts=s.ts.map(n=>{let t=new j;return t.tid=n.tid,t.name=n.name,t.domain=n.domain,t.tenantType=n.tenantType,t.authority=n.authority,t.workspaceIDs=n.workspaceIDs,t.sel=n.sel,t.lookupfield=n.lookupfield,t}),typeof s.cs>"u"?this.cs=new Array:this.cs=s.cs.map(n=>{let t=new Q;return t.id=n.id,t.workspaceId=n.workspaceId,t.name=n.name,t.description=n.description,t.tenants=n.tenants,t.isEnabled=n.isEnabled,t.workspaceIDs=n.workspaceIDs,t.sel=n.sel,t}),typeof s.ws>"u"?this.ws=new Array:this.ws=s.ws.map(n=>{let t=new X;return t.id=n.id,t.name=n.name,t.ownerid=n.ownerid,t.associatedUsers=n.associatedUsers,t.associatedTenants=n.associatedTenants,t.associatedConfigs=n.associatedConfigs,t.sel=n.sel,t})};const Dt=[{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 Et{constructor(s){ne(this,N);c(this,"tasks");this.tasks=[new Y],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 n=localStorage.getItem("Tasks");if(n!=null&&typeof n=="string"&&n!==""){let e=JSON.parse(n);if(this.tasks=x(this,N,pe).call(this,e.tasks),this.tasks.length!==0)return}}this.tasks=x(this,N,pe).call(this,Dt)}setTaskStart(s,n){let t=x(this,N,fe).call(this,s);if(t!=null&&t!=null)t.setStart(n),t.status="in progress",x(this,N,he).call(this);else debugger}setTaskEnd(s,n,t){let e=x(this,N,fe).call(this,s);if(e!=null&&e!=null)e.setEnd(n),e.status=t,x(this,N,he).call(this);else debugger}}N=new WeakSet,fe=function(s){let n=this.tasks.find(t=>t.task==s);if(n==null||n==null){for(n of this.tasks)if(n.subtasks!=null&&n.subtasks!=null&&(n=n.subtasks.find(t=>t.task==s),n!=null&&n!=null))break}return n},pe=function(s){return s.map(n=>{let t=new Y;return t.id=n.id,t.task=n.task,t.setStart(new Date(n.start)),t.setEnd(new Date(n.end)),t.expected=n.expected,t.status=n.status,t.expanded=n.expanded,typeof n.subtasks<"u"&&n.subtasks!=null&&(t.subtasks=n.subtasks.map(e=>{let r=new Y;return r.id=e.id,r.task=e.task,r.setStart(new Date(e.start)),r.setEnd(new Date(e.end)),r.expected=e.expected,r.status=e.status,r.expanded=e.expanded,r})),t})},he=function(){let s=JSON.stringify(this);O()&&localStorage.setItem("Tasks",s)};class Y{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 n=0,t=this.end.getSeconds()-this.start.getSeconds();t<0&&(t+=60,n=-1);let e=this.end.getMinutes()-this.start.getMinutes()+n;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){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 Se{constructor(s){ne(this,H);c(this,"milestones",[]);this.init(s)}init(s){if(O()){let n=localStorage.getItem("syncmilestones");if(n!=null&&typeof n=="string"&&n!==""){let e=JSON.parse(n);if(e.length!==0)if(s)localStorage.removeItem("syncmilestones");else{x(this,H,ge).call(this,e);return}}}x(this,H,ge).call(this,gt)}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 n=Number(this.milestones[0].Run),t=new q(n+1);this.milestones.unshift(t),this.milestones=this.milestones.map(e=>{let r=new q(e.Run);return r.Start=e.Start,r.startDisplay=e.startDisplay,r.POST=e.POST,r.postDisplay=e.postDisplay,r.Read=e.Read,r.readDisplay=e.readDisplay,r.Write=e.Write,r.writeDisplay=e.writeDisplay,r.Duration=e.Duration,r.durationDisplay=e.durationDisplay,r}),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 n=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: ${n.Run}:${n.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 n=this.milestones.pop();console.log(`Removed milestone #${n.Run}: ${n.Start}`)}this.save(),this.milestones=this.milestones.map(n=>{let t=new q(n.Run);return t.Start=n.Start,t.startDisplay=n.startDisplay,t.POST=n.POST,t.postDisplay=n.postDisplay,t.Read=n.Read,t.readDisplay=n.readDisplay,t.Write=n.Write,t.writeDisplay=n.writeDisplay,t.Duration=n.Duration,t.durationDisplay=n.durationDisplay,t}),s(this.milestones)}}H=new WeakSet,ge=function(s){s==null?this.milestones=new Array:this.milestones=s.map(n=>{let t=new q(Number(n.Run));return t.start(n.Start),t.post(n.POST),t.read(n.Read),t.write(n.Write),t})};class Pt{constructor(s,n,t){c(this,"tenantNodes");c(this,"pb_startTS");c(this,"pb_progress");c(this,"pb_increment");c(this,"pb_idle");c(this,"pb_idleMax");c(this,"pb_total");c(this,"pb_timer");c(this,"milestoneArray");this.tenantNodes=new Array,this.init(s,n,t),this.pb_startTS=0,this.pb_progress=0,this.pb_increment=.25,this.pb_timer=null,this.pb_idle=0,this.pb_idleMax=0,this.pb_total=0,this.milestoneArray=new Se(!1)}clearStoredBatchIds(){O()&&localStorage.setItem("BatchIdArray","[]")}init(s,n,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&&n!=null&&(this.tenantNodes.length=0,s.tenants.map(e=>{if(e.configurationTenantType==="source"||e.configurationTenantType==="sourcetarget"){let r=n.ts.find(o=>o.tid===e.tid);if(r!=null){let o=new re(e.tid,r.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(r=>{if((r.configurationTenantType==="target"||r.configurationTenantType==="sourcetarget")&&r.tid!==e.tid){let o=n.ts.find(d=>d.tid===r.tid);if(o!=null){let d=new re(r.tid,o.name,r.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,n,t,e){this.pb_startTS=Date.now(),this.pb_progress=0,this.pb_increment=.25,this.pb_idle=0,this.pb_idleMax=0,this.pb_total=0,this.pb_timer=setInterval(()=>{console.log("this.tenantNodes",this.tenantNodes),this.tenantNodes.map(o=>o.targets.map(d=>d.status==="complete"||o.nothingtosync).reduce((d,i)=>d&&i)).reduce((o,d)=>o&&d)?(clearInterval(this.pb_timer),this.pb_timer=null,this.pb_progress=100,s(this.pb_progress),t(`Complete. [max idle: ${this.pb_idleMax}]`),this.clearStoredBatchIds()):(this.pb_total=this.pb_total+1,this.pb_idle=this.pb_idle+1,this.pb_idleMax=Math.max(this.pb_idle,this.pb_idleMax),t(`${this.pb_total} seconds elapsed. Last update ${this.pb_idle} seconds ago. [max idle: ${this.pb_idleMax}/60]`),this.pb_idle>=60&&this.milestoneArray.milestones[0].Write==null&&n(`sync continuing, but no update for ${this.pb_idle} seconds`),this.pb_progress<100&&(this.pb_progress=Math.min(100,this.pb_progress+this.pb_increment),s(this.pb_progress)))},1e3),this.milestoneArray.start(e)}uninitializeProgressBar(s,n,t,e){this.pb_startTS=0,this.pb_progress=0,s(this.pb_progress),n("sync failed to execute"),this.pb_increment=0,clearInterval(this.pb_timer),this.pb_timer=null,this.pb_idle=0,this.pb_idleMax=0,t(`No updates seen for ${this.pb_idle} seconds. [max idle: ${this.pb_idleMax}]`),this.milestoneArray.unstart(e)}initializeSignalR(s,n,t,e,r,o,d,i,l,u,p,$,R,W){this.milestoneArray.post(p),$("started sync, waiting for updates..."),this.init(s,n,!1);let U=F=>v=>{console.log(v);let E=JSON.parse(v);this.pb_idle=0;let k=t.find(m=>m.BatchId==E.TargetID);if(k==null){console.log(`Batch ${E.TargetID} not found in batchIdArray.`);debugger;return}let g=this.tenantNodes.find(m=>m.tid===k.SourceId);if(g==null){console.log(`Tenant ${k.SourceId} not found in BatchArray.`);debugger;return}g.batchId=k.BatchId;let Qe=E.Stats,C=Object.keys(Qe),B=Object.values(Qe),le=!1,Xe=!1;for(let m=0;m<C.length;m++){let G=C[m].endsWith("TotalCount"),K=C[m].endsWith("CurrentCount"),J=C[m].endsWith("ExtCount"),se=C[m].endsWith("DeferredCount"),de=C[m].endsWith("RescheduledCount");if(J&&(g.excluded=Math.max(Number(B[m]),g.excluded),g.targets.map(S=>{S.excluded=g.excluded,S.update(S.total,S.read,S.excluded,S.written,S.deferred)})),G&&(le=Number(B[m])==0,g.total=Math.max(Number(B[m]),g.total),g.targets.map(S=>{S.total=g.total,S.update(S.total,S.read,S.excluded,S.written,S.deferred)})),C[m].startsWith("Reader")){let S=/Reader\/TID:(.+)\/TotalCount/;if(K&&(S=/Reader\/TID:(.+)\/CurrentCount/),J&&(S=/Reader\/TID:(.+)\/ExtCount/),se&&(S=/Reader\/TID:(.+)\/DeferredCount/),de&&(S=/Reader\/TID:(.+)\/RescheduledCount/),C[m].match(S)==null){console.log(`tid not found in ${C[m]}.`);debugger;return}G?(le=Number(B[m])==0,g.total=Math.max(Number(B[m]),g.total),console.log(`----- ${g.name} TID: ${g.tid} batchId: ${g.batchId}`),console.log(`----- ${g.name} Total To Read: ${g.total}`)):(Xe=Number(B[m])==0,K?(g.read=Math.max(Number(B[m]),g.read),console.log(`----- ${g.name} Currently Read: ${g.read}`)):se&&(g.deferred=Math.max(Number(B[m]),g.deferred),console.log(`----- ${g.name} Deferred: ${g.deferred}`)))}if(g.nothingtosync=le&&Xe,C[m].startsWith("Writer")){let S=/Reader\/TID:(.+)\/TotalCount/;K&&(S=/Writer\/TID:(.+)\/CurrentCount/),J&&(S=/Writer\/TID:(.+)\/ExtCount/),se&&(S=/Writer\/TID:(.+)\/DeferredCount/),de&&(S=/Writer\/TID:(.+)\/RescheduledCount/);let ue=C[m].match(S);if(ue==null){console.log(`tid not found in ${C[m]}.`);debugger;return}let b=g.targets.find(ps=>ps.tid===ue[1]);if(b==null){console.log(`Writer ${g.name} not found under Reader ${g.name}.`);debugger;return}if(b.total=Math.max(Number(g.total),b.total),b.total=Math.max(Number(g.total),b.total),b.batchId=k.BatchId,G)b.total=Math.max(Number(G),b.total),console.log(`----- ${b.name} TID: ${b.tid} batchId: ${b.batchId}`),console.log(`----- ${b.name} Total To Write: ${b.total}`);else if(K)b.written=Math.max(Number(B[m]),b.written),console.log(`----- ${b.name} Total Written: ${b.written}`);else if(se||de)b.deferred=Math.max(Number(B[m]),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)}}g.update(g.total,g.read,g.excluded,g.written,g.deferred);let Ye=!0,et=!0,tt=!1,st=!0,ce=0,nt=0,rt=0,at=0,ot=0,it=0;if(this.tenantNodes.map(m=>{m.targets.map(G=>{et&&(et=G.status=="complete"||G.status=="failed"),tt||(tt=G.total>0||G.status!="not started"),at+=Math.max(G.total,m.total),ot+=G.written,it+=G.excluded}),st&&(st=m.nothingtosync),Ye&&(Ye=m.status=="complete"||m.status=="failed"),ce+=m.total,nt+=m.read,rt+=m.excluded}),r(ce),d(nt),o(rt),i(Math.max(at,ce)),u(ot),l(it),st)this.milestoneArray.write(p),F.stop(),$("nothing to sync"),this.clearStoredBatchIds(),console.log('Setting config sync result: "nothing to sync"');else{if(Ye){this.milestoneArray.read(p),$("reading complete"),console.log('Setting config sync result: "reading complete"'),e(s.workspaceId);let J=(Date.now()-this.pb_startTS)/1e3/8.5;this.pb_increment=J,console.log(`Setting increment: ${this.pb_increment}% per second`)}et?(this.milestoneArray.write(p),F.stop(),$("sync complete"),this.clearStoredBatchIds(),console.log('Setting config sync result: "complete"')):tt?($("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"'))}};t.map(F=>{const v=T.signalREndpoint();let E=new URL(v);E.searchParams.append("statsId",F.BatchId),console.log(`Creating SignalR Hub for TID: ${F.SourceId} ${E.href}`);const k=new V.HubConnectionBuilder().withUrl(E.href).withAutomaticReconnect().configureLogging(V.LogLevel.Information).build();W&&JSON.parse(W).TargetID===F.BatchId&&U(k)(W),k.on("newMessage",U(k)),k.onreconnecting(g=>{console.assert(k.state===V.HubConnectionState.Reconnecting),console.log(`Connection lost due to error "${g}". Reconnecting.`)}),k.onreconnected(g=>{console.assert(k.state===V.HubConnectionState.Connected),console.log(`Connection reestablished. Connected with connectionId "${g}".`)}),k.onclose(async()=>{console.log("Connection closing. Attempting restart."),await k.start()}),k.start().catch(console.error)})}async startSync(s,n,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 Ze(s,n,t),e}}class re{constructor(s,n,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=n,this.tid=s,this.batchId=t,this.nothingtosync=!1,this.targets=new Array,this.update(0,0,0,0,0)}update(s,n,t,e,r){this.total=s,this.read=n,this.excluded=t,this.written=e,this.deferred=r,this.read===0&&this.written===0&&(this.status="not started"),this.read>0?this.read+this.excluded<this.total?this.status="in progress":this.read+this.excluded===this.total&&(this.status="complete"):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 ae{constructor(s,n){c(this,"resourceNodes");this.resourceNodes=new Array,s&&this.init(n)}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 r=JSON.parse(t);this.resourceNodes=r.resourceNodes;return}}var n=JSON.stringify(mt);try{this.resourceNodes=P.deserializeArray(be,n)}catch{debugger}}async read(s,n){let t=new ae(!1,!1);return t.resourceNodes=await cs(s,n),t}save(){if(O()){let s=JSON.stringify(this);localStorage.setItem("ResourceArray",s)}}}class be{constructor(s,n,t){c(this,"type");c(this,"resource");c(this,"cost");c(this,"expanded");c(this,"resources");this.type=s,this.resource=n,this.cost=t,this.expanded=!1,this.resources=new Array}}class vt{constructor(s){c(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 r=JSON.parse(t);this.actorNodes=r.actorNodes;return}}var n=JSON.stringify(yt);try{this.actorNodes=P.deserializeArray(Ie,n)}catch{debugger}}}class Ie{constructor(s,n,t,e,r,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=n,this.resource=t,this.role=e,this.updatedby=r,this.updatedon=o,this.actors=new Array}}function Rt(a){return"Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All"}async function ee(a,s){const n=new Headers;n.append("Content-Type","application/json"),n.append("accept","*/*");const t=Rt();if(s.graphAccessToken==null||s.graphAccessToken==="")try{let e=await a.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=a.getAllAccounts(),r=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==r&&(o=e[i]);let d=await a.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 r=a.getAllAccounts(),o=s.oid+"."+s.tid,d=null;for(let i=0;i<r.length;i++)r[i].homeAccountId==o&&(d=r[i]);a.acquireTokenRedirect({scopes:[t],account:d})}catch(r){console.log("Front end graph token redirect acquisition failure: "+r)}}return n.append("Authorization",`Bearer ${s.graphAccessToken}`),n}async function Gt(a,s,n){if(s==null||s.spacode=="")return{groups:[],error:"500: invalid user passed to groupsGet"};let e={method:"GET",headers:await ee(a,s)};try{let r=L(s.authority)+h.graphGroupsPredicate;r+=`/?$filter=startsWith(displayName, '${n}')`;let d=await(await fetch(r,e)).json();return typeof d.error<"u"?{groups:[],error:`${d.error.code}: ${d.error.message}`}:{groups:d.value,error:""}}catch(r){return console.log(r),{groups:[],error:`Exception: ${r}`}}}async function $e(a,s,n,t){try{let e=L(s.authority)+h.graphOauth2PermissionGrantsPredicate,r=new URL(e);r.searchParams.append("$filter",`resourceId eq '${n}' and consentType eq 'Principal' and principalId eq '${t}'`);let d=await(await fetch(r.href,a)).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 Ae(a,s,n,t){if(s==null||s.spacode=="")return!1;try{let e=L(s.authority);e+=h.graphOauth2PermissionGrantsPredicate+`/${n}`;let r=`{ "scope": "${t}" }`,d={method:"PATCH",headers:await ee(a,s),body:r},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 Ct(a,s){let n=$t(a.authority);n+=a.tid,n+="/adminconsent";let t=new URL(n),e=It(a.authority,s);t.searchParams.append("client_id",e),t.searchParams.append("redirect_uri",window.location.origin),t.searchParams.append("domain_hint",a.companyDomain),t.searchParams.append("login_hint",a.mail),window.location.assign(t.href)}async function ke(a,s,n){try{let t=L(s.authority);t+=h.graphServicePrincipalsPredicate,t+=`(appId='${n}')`;let e=new URL(t);e.searchParams.append("$select","id,appId,displayName");let o=await(await fetch(e.href,a)).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 Ot(a,s){if(a.authority==""){let e=new j;if(e.domain=a.tid,await oe(e,!1))a.authority=e.authority;else{debugger;return!1}}let n=window.location.href;switch(a.authority){case h.authorityWW:n+="MicrosoftIdentity/Account/SignIn";break;case h.authorityUS:n+="USGov/SignIn";break;case h.authorityCN:n+="China/SignIn";break;default:return!1}let t=new URL(n);if(t.searchParams.append("redirectUri",window.location.origin),a.oid!=="1"){t.searchParams.append("loginHint",a.mail);const e=/@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/,r=a.mail.match(e);let o=r?r[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 Nt(a,s){debugger;if(a.oid=="1")return;let n=window.location.href;switch(a.authority){case h.authorityWW:n+="MicrosoftIdentity/Account/Challenge";break;case h.authorityUS:n+="USGov/Challenge";break;case h.authorityCN:n+="China/Challenge";break;default:return}let t=new URL(n);t.searchParams.append("redirectUri",window.location.origin),t.searchParams.append("scope",s),t.searchParams.append("domainHint","organizations"),t.searchParams.append("loginHint",a.mail),window.location.assign(t.href)}async function Wt(a){if(a.oid=="1")return!1;let s=window.location.href;s+="user";let n=new URL(s);n.searchParams.append("oid",a.oid),n.searchParams.append("tid",a.tid),n.searchParams.append("loginHint",a.loginHint),n.searchParams.append("verb","LOGOUT");let t={method:"PATCH"},e=await fetch(n.href,t);if(e.status==200&&e.statusText=="OK")console.log(`Successfully set admin ${a.mail} logout_hint`);else return console.log(`Failed to set admin ${a.mail} logout_hint`),!1;let r=window.location.href;switch(a.authority){case h.authorityWW:r+="MicrosoftIdentity/Account/SignOut";break;case h.authorityUS:r+="USGov/SignOut";break;case h.authorityCN:r+="China/SignOut";break;default:return!1}return n=new URL(r),n.searchParams.append("redirectUri",window.location.origin),window.location.assign(n.href),!0}async function Ft(a,s,n,t){if(t)debugger;if(s.name!=null&&s.name!=="")return!1;if(a.graphAccessToken!=null&&a.graphAccessToken===""){console.log(`tenantRelationshipsGetByDomain called with invalid logged in user: ${a.name}`);try{let i=await n.acquireTokenByCode({code:a.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});a.graphAccessToken=i.accessToken,console.log("tenantRelationshipsGetByDomain: Front end token acquired: "+a.graphAccessToken.slice(0,20))}catch(i){return console.log("tenantRelationshipsGetByDomain: Front end token failure: "+i),!1}}const e=new Headers,r=`Bearer ${a.graphAccessToken}`;e.append("Authorization",r);let o={method:"GET",headers:e};try{var d=L(s.authority)+h.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 De(a,s,n,t,e){if(console.log("**** tenantRelationshipsGetById"),e)debugger;if(a.graphAccessToken==="")try{let l=await t.acquireTokenByCode({code:a.spacode,scopes:["user.read","contacts.read","CrossTenantInformation.ReadBasic.All"]});a.graphAccessToken=l.accessToken,console.log("tenantRelationshipsGetById: Front end token acquired: "+a.graphAccessToken.slice(0,20))}catch(l){return console.log("tenantRelationshipsGetById: Front end token failure: "+l),!1}const r=new Headers,o=`Bearer ${a.graphAccessToken}`;r.append("Authorization",o);let d={method:"GET",headers:r};try{var i=L(a.authority)+h.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 oe(a,s){if(s)debugger;let n=[h.authorityWW,h.authorityUS,h.authorityCN],t=[h.authorityWWRegex,h.authorityUSRegex,h.authorityCNRegex],e=null;try{for(let i=0;i<3;i++){var r=n[i];if(a.lookupfield=="Domain"?r+=a.domain:a.lookupfield=="Tenant ID"&&(r+=a.tid),r+="/.well-known/openid-configuration",console.log("Attempting GET from openid well-known endpoint: ",r),e=await fetch(r),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 a.tid=d[2],a.authority=d[1],console.log(`Successful GET from openid well-known endpoint: tid: ${a.tid} authority: ${a.authority}`),!0}}else console.log(`Failed JSON parse of openid well-known endpoint response ${r}.`)}else console.log(`Failed GET from ${r}.`)}}catch(i){console.log("Failed to GET from openid well-known endpoint: ",i)}return(a.tid==""||a.authority=="")&&console.log(`GET from openid well-known endpoint failed to find tenant: ${e?e.statusText:"unknown"}`),!1}async function Ee(a,s,n){if(s==null||s.spacode==""||n==null){debugger;return{scopes:null,id:null,error:"500: invalid parameter(s) passed to getUserDelegatedScopes"}}let e={method:"GET",headers:await ee(a,s)};try{if(n.graphSP==""){let{spid:i,error:l}=await ke(e,s,"00000003-0000-0000-c000-000000000000");if(l!=""){debugger;return{scopes:null,id:null,error:`${l}`}}n.graphSP=i}let{grants:r,id:o,error:d}=await $e(e,s,n.graphSP,s.oid);if(d!=""){debugger;return{scopes:null,id:null,error:`${d}`}}return{scopes:r,id:o,error:""}}catch(r){debugger;return console.log(r),{scopes:null,id:null,error:`Exception: ${r}`}}}async function Bt(a,s,n,t){if(s==null||s.spacode==""||n==null){debugger;return!1}let{scopes:e,id:r,error:o}=await Ee(a,s,n);if(o!=""){debugger;return console.log(`userDelegatedScopesRemove: cannot find userDelegatedScopes for ${s.mail}: ${o}`),!1}e=e.replace(t,"");let d=await Ae(a,s,r,e);if(!d){debugger;return console.log(`userDelegatedScopesRemove: cannot set oauth2PermissionGrants for ${s.mail}: ${o}`),!1}return s.scopes=e.split(" "),d}async function xt(a,s){if(s==null||s.spacode=="")return{users:[],error:"500: invalid user passed to usersGet"};try{let t={method:"GET",headers:await ee(a,s)},e=L(s.authority);e+=h.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(n){return console.log(n),{users:[],error:`Exception: ${n}`}}}async function Ut(a,s,n,t){return Ge(a,s,n,t)}async function _t(a,s,n,t){return Ce(a,s,n,t)}async function Lt(a,s,n,t,e){return Oe(a,s,n,t,e)}async function zt(a,s,n,t){return Ne(a,s,n,t)}async function Mt(a,s,n){return We(a,s,n)}async function jt(a,s,n,t,e,r,o,d){let i=new y;if(n.id==="1"){if(i=await Le(a,s,n,r.id,d),i.result){n.tenants.forEach(p=>{(p.configId==="1"||p.configId==="")&&(p.configId=n.id)}),t&&t(n.id);const l={};Object.defineProperty(l,n.id,{value:!0,writable:!0,enumerable:!0}),e(l);let u=r.associatedConfigs.findIndex(p=>p=="1");u!==-1&&(r.associatedConfigs.splice(u,1),r.associatedConfigs.push(n.id))}}else i=await ze(a,s,n,d);return o.save(),i}async function qt(a,s,n,t,e){let r=new y;return r=await _e(a,s,n,t,e),r}async function Ht(a,s,n,t,e){return Fe(a,s,n,t,e)}async function Kt(a,s,n,t,e){return Be(a,s,n,t,e)}async function Jt(a,s,n,t,e,r){let o=new y;if(e)debugger;try{let d=t.ws.find(i=>i.id===n);if(d!=null){d.associatedConfigs.length=0;let i=await xe(a,s,r,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 Vt(a,s,n,t,e){return Ue(a,s,n,t)}async function Zt(a,s,n,t,e){console.log(">>>>>> initGet");let r=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),r.result=await De(s,o,n,a,e),t.setTaskEnd("GET tenant details",new Date,"complete"),r.result&&(s.companyName=o.name,s.companyDomain=o.domain,t.setTaskStart("POST config init",new Date),r=await je(a,s,e),t.setTaskEnd("POST config init",new Date,r.result?"complete":"failed")),r.result&&(t.setTaskStart("GET workspaces",new Date),r=await as(a,s,n,e),t.setTaskEnd("GET workspaces",new Date,r.result?"complete":"failed")),console.log("initGet complete. Version: "+_()),r):(r.error=`Failed to retrieve authority for user "${s.mail}" TID ${s.tid}.`,r.result=!1,r)}async function Qt(a,s,n,t){return Ke(a,s,n,t)}async function Xt(a,s,n,t,e){return qe(a,s,n,t)}async function Yt(a,s,n,t){return Re(a,s,n,t)}async function es(a,s,n,t){return Pe(a,s,n,t)}async function ts(a,s,n,t){return await Je(a,s,n,t)}function ss(a,s,n,t){n.map(e=>{let r=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){r=s.us.at(l);let u=a.associatedUsers.findIndex(p=>p=="1");u!==-1&&(a.associatedUsers.splice(u,1),a.associatedUsers.push(e.userId))}else r=new Z,s.us.push(r)}else r=s.us.at(o);r.sel=t===e.userId,r.oid=e.userId?e.userId:e.email,r.name=e.firstName??r.name,r.mail=e.email,r.tid=e.tenantId;let d=s.ts.find(l=>l.tid===r.tid);d!=null&&(r.authority=d.authority,r.companyName=d.name,r.companyDomain=d.domain),a.associatedUsers.findIndex(l=>l===r.oid)==-1&&a.associatedUsers.push(r.oid)}),s.save()}function ns(a,s,n,t){n.map(e=>{let r=null,o=s.ts.findIndex(u=>u.tid===e.tenantId);if(o===-1){let u=s.ts.findIndex(p=>p.tid==="1");if(u!==-1){r=s.ts.at(u);let p=a.associatedTenants.findIndex($=>$=="1");p!==-1&&(a.associatedTenants.splice(p,1),a.associatedTenants.push(e.tenantId))}else r=new j,s.ts.push(r)}else r=s.ts.at(o);r.sel=t===e.tenantId,r.tid=e.tenantId,r.name=e.name,r.domain=e.domain,r.tenantType=e.type.toLowerCase();const d=/^(https:\/\/login.microsoftonline.(?:us|com)\/)organizations\/v2.0$/,i=e.authority.match(d);r.authority=i?i[1]:e.authority,a.associatedTenants.findIndex(u=>u===e.tenantId)==-1&&a.associatedTenants.push(e.tenantId)}),s.save()}function rs(a,s,n,t){n.map(e=>{let r=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){r=s.cs.at(i);let l=a.associatedConfigs.findIndex(u=>u=="1");l!==-1&&(a.associatedConfigs.splice(l,1),a.associatedConfigs.push(e.id))}else r=new Q,s.cs.push(r)}else r=s.cs.at(o);r.sel=t===e.id,r.id=e.id,r.workspaceId=e.workspaceId,r.name=e.name,r.description=e.description,r.isEnabled=e.isEnabled,r.tenants.length=0,e.tenants.map(i=>{let l=new Te;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=r.id,l.batchId=i.batchId??"",l.isReadPermissionConsented=i.isReadPermissionConsented,l.isWritePermissionConsented=i.isWritePermissionConsented,r.tenants.push(l)}),a.associatedConfigs.findIndex(i=>i===e.id)==-1&&a.associatedConfigs.push(e.id)}),console.log("--------------ii-----------",s),s.save()}async function as(a,s,n,t){let e=new y;if(t)debugger;try{if(e=await Ve(a,s,t),e.result){for(let r of e.array){let o=null,d=n.ws.findIndex(v=>v.id===r.id);if(d===-1){let v=n.ws.findIndex(E=>E.id==="1");v!==-1?o=n.ws.at(v):(o=new X,n.ws.push(o))}else o=n.ws.at(d);let i="";for(let v of o.associatedUsers){let E=n.us.find(k=>k.oid===v);E!=null&&E.sel&&(i=E.oid)}let l="";for(let v of o.associatedTenants){let E=n.ts.find(k=>k.tid===v);E!=null&&E.sel&&(l=E.tid)}let u="";for(let v of o.associatedConfigs){let E=n.cs.find(k=>k.id===v);E!=null&&E.sel&&(u=E.id)}o.associatedUsers.length=0,o.associatedTenants.length=0,o.associatedConfigs.length=0,o.id=r.id,o.name=r.name,o.ownerid=r.workspaceOwnerUserId;let p=ve(a,s,o.id,t),$=He(a,s,o.id,t),R=Me(a,s,o.id,t),[W,U,F]=await Promise.all([p,$,R]);if(!W.result)return W;if(!U.result)return U;if(!F.result)return F;ns(o,n,U.array,l),ss(o,n,W.array,i),rs(o,n,F.array,u),n.tagWithWorkspaces()}return e}}catch(r){console.log(r.message),e.error=r.message}return e.result=!1,e.status=500,e}async function os(a,s){let n="",t=_();try{let e=a.getAllAccounts(),r=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==r&&(o=e[i]);n=(await a.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: "+n.slice(0,20))}catch{console.log("PowerBI token failed to be acquired silently")}return console.log(t),n}async function ie(a,s){const n=new Headers;if(n.append("Content-Type","application/json"),n.append("accept","*/*"),s.azureAccessToken==null||s.azureAccessToken==="")try{let t=a.getAllAccounts(),e=s.oid+"."+s.tid,r=null;for(let d=0;d<t.length;d++)t[d].homeAccountId==e&&(r=t[d]);let o=await a.acquireTokenSilent({scopes:["https://management.azure.com/user_impersonation"],account:r});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=a.getAllAccounts(),r=s.oid+"."+s.tid,o=null;for(let d=0;d<e.length;d++)e[d].homeAccountId==r&&(o=e[d]);a.acquireTokenRedirect({scopes:["https://management.azure.com/user_impersonation"],account:o})}catch(e){console.log("Front end token popup acquisition failure: "+e)}}return n.append("Authorization",`Bearer ${s.azureAccessToken}`),n}async function is(a,s){if(s==null||s.spacode=="")return!1;try{let t={method:"GET",headers:await ie(a,s)},e=M.azureListRootAssignments;e+="'",e+=s.oid,e+="'";let r=await fetch(e,t);if(r.status==200){let o=await r.json();o=o;debugger;console.log("Successful call to Azure Resource Graph list root assignments")}else return console.log(await w(r)),!1}catch(n){return console.log(n),!1}return!0}async function ls(a,s){if(s==null||s.spacode=="")return!1;try{let t={method:"POST",headers:await ie(a,s)},e=M.azureElevateAccess,r=await fetch(e,t);if(r.status==200)console.log("Successful call to Azure Resource Graph list root assignments");else return console.log(await w(r)),!1}catch(n){return console.log(n),!1}return!0}async function cs(a,s){let n=new Array;if(s==null||s.spacode=="")return n;try{let e={method:"GET",headers:await ie(a,s)},r=M.azureListRootAssignments;r+="'",r+=s.oid,r+="'";let o=await fetch(r,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)),n}catch(t){return console.log(t),n}return n}function ds(a){let s="8d95d21c-c378-4bb0-9f52-88c30d271e7a",n=a.authority.toLowerCase();return n.startsWith("https://login.microsoftonline.com/")?s="8d95d21c-c378-4bb0-9f52-88c30d271e7a":n.startsWith("https://login.microsoftonline.us/")?s="48da942e-ea3d-49e4-a054-81649012f8f2":n.startsWith("https://login.partner.microsoftonline.cn/")&&(s="c91d32e4-dcc5-4d77-826a-16e93ffce666"),`api://${s}/Config.Write`}async function I(a,s){const n=new Headers;n.append("Content-Type","application/json"),n.append("accept","*/*");const t=ds(s);try{let e=a.getAllAccounts(),r=s.oid+"."+s.tid,o=null;for(let i=0;i<e.length;i++)e[i].homeAccountId==r&&(o=e[i]);let d=await a.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 r=a.getAllAccounts(),o=s.oid+"."+s.tid,d=null;for(let i=0;i<r.length;i++)r[i].homeAccountId==o&&(d=r[i]);a.acquireTokenRedirect({scopes:[t],account:d})}catch(r){console.log("Front end mindline token redirect acquisition failure: "+r)}}return n.append("Authorization",`Bearer ${s.mindlineAccessToken}`),n}async function w(a){let s="";if(a.status===401&&(s=a.statusText,s!=""))return s;let n=await a.json();if(n.error!==void 0)s=`Error: ${n.error} Message: ${n.message}`;else if(n.errors!==void 0)s=Object.keys(n.errors).reduce((r,o)=>r+o+": "+n.errors[o]+" ","");else if(n.title!==void 0)s=n.title;else debugger;return s}async function Pe(a,s,n,t){let e=new y;if(n.oid==""&&n.mail==""||t=="")return e.result=!1,e.error="adminDelete: invalid parameters",e.status=500,e;let r=null;r=new URL(T.adminEndpoint()),r.searchParams.append("workspaceId",t),r.searchParams.append("email",n.mail);let d={method:"DELETE",headers:await I(a,s)};try{console.log("Attempting DELETE from /admin: "+r.href);let i=await fetch(r.href,d);return i.status===200&&i.statusText==="OK"?(console.log(`Successful DELETE from /admin: ${r.href}`),e):(e.error=await w(i),console.log(`Failed DELETE from /admin: ${r.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 ve(a,s,n,t){let e=new y;if(n==="")return e.result=!1,e.status=500,e.error="adminsGet: no workspace provided",e;let r=T.adminsEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n);let i={method:"GET",headers:await I(a,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(($,R)=>$+R.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 Re(a,s,n,t){let e=new y;if(n.mail==""||n.authority==""||n.tid==="")return e.result=!1,e.error="adminPost: invalid argument",e.status=500,e;let r=T.adminEndpoint();const o=await I(a,s);let d=`
|
|
2
2
|
{"email": "${n.mail}",
|
|
3
3
|
"tenantId": "${n.tid}",
|
|
4
4
|
"workspaceId": "${t}"
|
|
5
|
-
}`,i={method:"POST",headers:o,body:d};try{console.log("Attempting POST to /admin: "+r);let l=await fetch(r,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: "+r);let l=await fetch(r,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 Ge(a,s,n,t){a=a,s=s,t=t;let e=new y;if(n.id==="")return e.result=!1,e.error="auditConfigPost: invalid config ID",e.status=500,e;let r=T.auditConfigEndpoint();const o=await I(a,s);let d=`
|
|
6
6
|
{
|
|
7
7
|
"workspaceId": "${n.workspaceId}",
|
|
8
8
|
"name": "${n.name}",
|
|
@@ -10,47 +10,51 @@
|
|
|
10
10
|
"isEnabled": ${n.isEnabled},
|
|
11
11
|
"email": "${n.email}",
|
|
12
12
|
"tenantId": "${n.tenantId}"
|
|
13
|
-
}`,i={method:"POST",headers:o,body:d};try{if(t)debugger;console.log("Attempting POST to /audit-configuration: "+r);let l=await fetch(r,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: "+r);let l=await fetch(r,i);if(l.status===200&&l.statusText==="OK"){let u=await l.json();return n.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 Ce(a,s,n,t){a=a,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(!n||n.trim()==="")return e.result=!1,e.error="auditConfigGet: configurationId is required",e.status=500,e;let r=T.auditConfigEndpoint(),o=new URL(`${r}/${n}`),i={method:"GET",headers:await I(a,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 Oe(a,s,n,t,e){let r=new y;if(!n||n.trim()==="")return r.result=!1,r.error="auditConfigPut: invalid configuration ID",r.status=500,r;let o=T.auditConfigEndpoint(),d=new URL(o);d.searchParams.append("configurationId",n);const i=await I(a,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 p=await fetch(d.href,u);p.status===200&&p.statusText==="OK"?(r.result=!0,console.log(`Successful PUT to ${d.href}: ${l}`)):(r.error=await w(p),console.error(`Failed PUT to ${d.href}: ${l}`),r.status=p.status,r.result=!1)}catch(p){r.error=p.message,r.status=500,r.result=!1,console.error("Error during auditConfigPut:",p.message)}return r}async function Ne(a,s,n,t){let e=new y;if(!s.mail)return e.result=!1,e.status=500,e.error="auditConfigDelete: no user provided",e;if(!n||n.trim()==="")return e.result=!1,e.status=500,e.error="auditConfigDelete: configurationId is required",e;let r=T.auditConfigEndpoint(),o=new URL(r);o.searchParams.append("configurationId",n);const i={method:"DELETE",headers:await I(a,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 ${n}`)):(e.error=await w(l),e.status=l.status,e.result=!1,console.error(`Failed DELETE for configurationId ${n}`))}catch(l){e.status=500,e.result=!1,e.error=l.message,console.error("Error during auditConfigDelete:",l.message)}return e}async function We(a,s,n){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(),r=new URL(e),d={method:"GET",headers:await I(a,s)};try{if(n)debugger;console.log("Attempting GET from /audit-events endpoint: "+r.href);let i=await fetch(r.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(($,R)=>$+R.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: ${r.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 Fe(a,s,n,t,e){let r=new y,o=T.configConsentEndpoint(),d=new URL(o);d.searchParams.append("configurationId",n);const i=await I(a,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 p=await fetch(d.href,u);return p.status===200&&p.statusText==="OK"?(console.log(`Successful PUT to ${d.href}`),r):(r.error=await w(p),console.log(`Failed PUT to ${d.href}`),console.log(r.error),r.status=500,r.result=!1,r)}catch(p){r.error=p.message,r.status=500,r.result=!1,console.log(p.message)}return r}async function Be(a,s,n,t,e){let r=new y,o=T.configConsentEndpoint(),d=new URL(o);d.searchParams.append("configurationId",n);const i=await I(a,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 p=await fetch(d.href,u);return p.status===200&&p.statusText==="OK"?(console.log(`Successful PUT to ${d.href}`),r):(r.error=await w(p),console.log(`Failed PUT to ${d.href}`),console.log(r.error),r.status=500,r.result=!1,r)}catch(p){r.error=p.message,r.status=500,r.result=!1,console.log(p.message)}return r}async function xe(a,s,n,t,e){let r=new y;if(n.id===""||t=="")return r.result=!1,r.error="configGet: invalid config ID",r.status=500,r;let o=null;o=new URL(T.configEndpoint());let i={method:"GET",headers:await I(a,s)};try{console.log("Attempting GET from /config: "+o.href);let l=await fetch(`${o.href}/${n.id}`,i);if(l.status===200&&l.statusText==="OK"){console.log("Successful GET from /config");let u=await l.json();return{...r,array:[u]}}else return r.error=await w(l),console.log(`Failed GET from ${o.href}`),console.log(r.error),r.status=500,r.result=!1,r}catch(l){r.error=l.message,r.status=500,r.result=!1,console.log(l.message)}return r}async function Ue(a,s,n,t,e){let r=new y;if(n.id===""||t=="")return r.result=!1,r.error="configPost: invalid config ID",r.status=500,r;let o=null;o=new URL(T.configEndpoint()),o.searchParams.append("configurationId",n.id);let i={method:"DELETE",headers:await I(a,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"),r):(r.error=await w(l),console.log(`Failed DELETE from ${o.href}`),console.log(r.error),r.status=500,r.result=!1,r)}catch(l){r.error=l.message,r.status=500,r.result=!1,console.log(l.message)}return r}async function _e(a,s,n,t,e){let r=new y;if(n==="")return r.result=!1,r.error="configPatch: invalid config ID",r.status=500,r;let o=T.configEnabledEndpoint(),d=new URL(o);d.searchParams.append("configurationId",n),d.searchParams.append("isEnabled",t.toString());let l={method:"PATCH",headers:await I(a,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()}`),r):(r.error=await w(u),console.log(`Failed PATCH to ${d.href}: ${t.toString()}`),console.log(r.error),r.status=500,r.result=!1,r)}catch(u){r.error=u.message,r.status=500,r.result=!1,console.log(u.message)}return r}async function Le(a,s,n,t,e){let r=new y;if(n.id==="")return r.result=!1,r.error="configPost: invalid config ID",r.status=500,r;let o=T.configEndpoint();const d=await I(a,s);let i=`
|
|
29
29
|
{
|
|
30
30
|
"workspaceId": "${t}",
|
|
31
31
|
"name": "${n.name}",
|
|
32
32
|
"description": "${n.description}",
|
|
33
33
|
"isEnabled": ${n.isEnabled},
|
|
34
|
-
"tenants": [`;n.tenants.map(
|
|
35
|
-
"tenantId": "${
|
|
34
|
+
"tenants": [`;n.tenants.map(u=>{let p=u.sourceGroupId!=""?`"${u.sourceGroupId}"`:"null",$=u.sourceGroupName!=""?`"${u.sourceGroupName}"`:"null",R=u.targetGroupId!=""?`"${u.targetGroupId}"`:"null",W=u.targetGroupName!=""?`"${u.targetGroupName}"`:"null";i.slice(-1)==="}"&&(i+=","),i+=`{
|
|
35
|
+
"tenantId": "${u.tid}",
|
|
36
36
|
"sourceGroupId": ${p},
|
|
37
37
|
"sourceGroupName": ${$},
|
|
38
|
-
"targetGroupId": ${
|
|
39
|
-
"targetGroupName": ${
|
|
40
|
-
"configurationTenantType": "${
|
|
41
|
-
|
|
38
|
+
"targetGroupId": ${R},
|
|
39
|
+
"targetGroupName": ${W},
|
|
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 p=await u.json();return n.id=typeof p=="object"&&p!==null&&p.id?p.id:p,console.log(`Successful ConfigID: ${n.id} from POST to /config: ${i}`),r}else return r.error=await w(u),console.log(`Failed PUT to /config: ${i}`),console.log(r.error),r.status=500,r.result=!1,r}catch(u){return r.status=500,r.result=!1,r.error=u.message,console.log(r.error),r}}async function ze(a,s,n,t){let e=new y;if(n.id==="")return e.result=!1,e.error="configPost: invalid config ID",e.status=500,e;let r=T.configEndpoint(),o=new URL(r);o.searchParams.append("configurationId",n.id);const d=await I(a,s);let i=`
|
|
42
44
|
{
|
|
43
45
|
"name": "${n.name}",
|
|
44
46
|
"description": "${n.description}",
|
|
45
|
-
"tenants": [`;n.tenants.map(
|
|
46
|
-
"tenantId": "${
|
|
47
|
+
"tenants": [`;n.tenants.map(u=>{i.slice(-1)==="}"&&(i+=",");let $=u.sourceGroupId!=""?`"${u.sourceGroupId}"`:"null",R=u.sourceGroupName!=""?`"${u.sourceGroupName}"`:"null",W=u.targetGroupId!=""?`"${u.targetGroupId}"`:"null",U=u.targetGroupName!=""?`"${u.targetGroupName}"`:"null";i+=`{
|
|
48
|
+
"tenantId": "${u.tid}",
|
|
47
49
|
"sourceGroupId": ${$},
|
|
48
|
-
"sourceGroupName": ${
|
|
49
|
-
"targetGroupId": ${
|
|
50
|
+
"sourceGroupName": ${R},
|
|
51
|
+
"targetGroupId": ${W},
|
|
50
52
|
"targetGroupName": ${U},
|
|
51
|
-
"configurationTenantType": "${
|
|
52
|
-
"deltaToken": "${
|
|
53
|
-
|
|
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 p=await u.json();return{...e,array:[p]}}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 Me(a,s,n,t){let e=new y;if(n==="")return e.result=!1,e.status=500,e.error="configsGet: no workspace provided",e;let r=T.configsEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n);let i={method:"GET",headers:await I(a,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(($,R)=>$+R.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 us(a,s,n,t){let e=new y;if(!n)return e.result=!1,e.status=500,e.error="workspaceConfigsGet: no workspace provided",e;let r=T.workspaceConfigsEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n);let i={method:"GET",headers:await I(a,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(p=>({id:p.id,name:p.name,description:p.description,configurationType:p.configurationType,isEnabled:p.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 je(a,s,n){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 r=await I(a,s);let o=`
|
|
54
58
|
{
|
|
55
59
|
"tenantCreateModel": {
|
|
56
60
|
"tenantId": "${s.tid}",
|
|
@@ -59,11 +63,11 @@
|
|
|
59
63
|
"type": "aad",
|
|
60
64
|
"authority": "${s.authority}"
|
|
61
65
|
}
|
|
62
|
-
}`,d={method:"POST",headers:r,body:o};try{if(n)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 qe(a,s,n,t,e){let r=new y;if(n.tid===""||t==="")return r.result=!1,r.error="tenantDelete: invalid tid, workspaceId",r.status=500,r;let o=new URL(T.tenantEndpoint());o.searchParams.append("tenantId",n.tid),o.searchParams.append("workspaceId",t);let i={method:"DELETE",headers:await I(a,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}`),r):(console.log(`Failed DELETE from /tenant: ${o.href}`),r.error=await w(l),console.log(r.error),r.status=500,r.result=!1,r)}catch(l){r.error=l.message,r.status=500,r.result=!1,console.log(r.error)}return r}async function He(a,s,n,t){let e=new y;if(n==="")return e.result=!1,e.status=500,e.error="tenantsGet: no workspace provided",e;let r=T.tenantsEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n);let i={method:"GET",headers:await I(a,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
|
|
66
|
+
}`,d={method:"POST",headers:r,body:o};try{if(n)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 qe(a,s,n,t,e){let r=new y;if(n.tid===""||t==="")return r.result=!1,r.error="tenantDelete: invalid tid, workspaceId",r.status=500,r;let o=new URL(T.tenantEndpoint());o.searchParams.append("tenantId",n.tid),o.searchParams.append("workspaceId",t);let i={method:"DELETE",headers:await I(a,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}`),r):(console.log(`Failed DELETE from /tenant: ${o.href}`),r.error=await w(l),console.log(r.error),r.status=500,r.result=!1,r)}catch(l){r.error=l.message,r.status=500,r.result=!1,console.log(r.error)}return r}async function He(a,s,n,t){let e=new y;if(n==="")return e.result=!1,e.status=500,e.error="tenantsGet: no workspace provided",e;let r=T.tenantsEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n);let i={method:"GET",headers:await I(a,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(($,R)=>$+R.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 Ke(a,s,n,t){let e=new y;if(n.tid===""||n.name===""||n.domain==="")return e.result=!1,e.error="tenantPost: invalid tid, name, domain",e.status=500,e;let r=T.tenantEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",t);const d=await I(a,s);let i=`
|
|
63
67
|
{"tenantId": "${n.tid}",
|
|
64
68
|
"name": "${n.name}",
|
|
65
69
|
"domain": "${n.domain}",
|
|
66
70
|
"type": 1,
|
|
67
71
|
"authority": "${n.authority}"
|
|
68
|
-
}`,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 Je(a,s,n,t){let e=new y;if(n==""||t=="")return e.result=!1,e.error="workspacePut: invalid workspace ID or name",e.status=500,e;let r=T.workspaceEndpoint(),o=new URL(r);o.searchParams.append("workspaceId",n),o.searchParams.append("workspaceName",t);let i={method:"PUT",headers:await I(a,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 Ve(a,s,n){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(),r=new URL(e),d={method:"GET",headers:await I(a,s)};try{if(n)debugger;console.log("Attempting GET from /workspaces endpoint: "+r.href);let i=await fetch(r.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((p,$)=>p+$.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: ${r.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 Ze(a,s,n){let t=new y;if(a==null||s==null)return t.result=!1,t.error="readerPost: invalid parameters",t.status=500,t;let e=T.readerStartSyncEndpoint(),r=new URL(e);r.searchParams.append("configurationId",n.id);let d={method:"POST",headers:await I(a,s)};try{console.log("Attempting POST to /startSync: "+r.href);let i=await fetch(r.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 fs(a,s,n){let t=new y;if(a==null||s==null)return t.result=!1,t.error="readerPost: invalid parameters",t.status=500,t;let e=T.statsEndpoint(),r=new URL(`${e}/${n}`),d={method:"GET",headers:await I(a,s)};try{console.log("Attempting GET to /stats: "+r.href);let i=await fetch(r.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=vt,f.ActorNode=Ie,f.AuditConfig=At,f.BatchArray=Pt,f.Group=St,f.InitInfo=kt,f.Milestone=q,f.MilestoneArray=Se,f.ResourceArray=ae,f.ResourceNode=be,f.SyncConfig=Q,f.Task=Y,f.TaskArray=Et,f.Tenant=j,f.TenantConfigInfo=Te,f.TenantConfigType=we,f.TenantNode=re,f.TenantPermissionType=ye,f.TenantType=me,f.User=Z,f.UserScope=bt,f.Workspace=X,f.adminDelete=Pe,f.adminPost=Re,f.adminsGet=ve,f.auditConfigAdd=Ut,f.auditConfigDelete=Ne,f.auditConfigEdit=Lt,f.auditConfigGet=Ce,f.auditConfigPost=Ge,f.auditConfigPut=Oe,f.auditConfigRemove=zt,f.auditConfigRetrieve=_t,f.auditEventsGet=We,f.auditEventsRetrieve=Mt,f.azureConfig=M,f.canListRootAssignments=is,f.configConsentForRead=Ht,f.configConsentForWrite=Kt,f.configConsentReadPut=Fe,f.configConsentWritePut=Be,f.configDelete=Ue,f.configEdit=jt,f.configEnable=qt,f.configGet=xe,f.configPatch=_e,f.configPost=Le,f.configPut=ze,f.configRemove=Vt,f.configsGet=Me,f.configsRefresh=Jt,f.elevateGlobalAdminToUserAccessAdmin=ls,f.getPowerBIAccessToken=os,f.getSyncVersion=_,f.graphConfig=h,f.groupsGet=Gt,f.helloNpm=Tt,f.initGet=Zt,f.initPost=je,f.mindlineConfig=T,f.oauth2PermissionGrantsGet=$e,f.oauth2PermissionGrantsSet=Ae,f.processErrors=w,f.readerPost=Ze,f.readerStats=fs,f.requestAdminConsent=Ct,f.servicePrincipalGet=ke,f.signIn=Ot,f.signInIncrementally=Nt,f.signOut=Wt,f.sum=wt,f.tenantAdd=Qt,f.tenantDelete=qe,f.tenantPost=Ke,f.tenantRelationshipsGetByDomain=Ft,f.tenantRelationshipsGetById=De,f.tenantRemove=Xt,f.tenantUnauthenticatedLookup=oe,f.tenantsGet=He,f.userAdd=Yt,f.userDelegatedScopesGet=Ee,f.userDelegatedScopesRemove=Bt,f.userRemove=es,f.usersGet=xt,f.workspaceConfigsGet=us,f.workspaceEdit=ts,f.workspacePut=Je,f.workspacesGet=Ve,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
|
69
73
|
//# sourceMappingURL=sync.umd.js.map
|