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