@mindline/sync 1.0.106 → 1.0.107

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.
Files changed (32) hide show
  1. package/.vs/VSWorkspaceState.json +0 -1
  2. package/.vs/slnx.sqlite +0 -0
  3. package/.vs/sync/CopilotIndices/17.14.260.54502/CodeChunks.db +0 -0
  4. package/.vs/sync/CopilotIndices/17.14.260.54502/SemanticSymbols.db +0 -0
  5. package/.vs/sync/FileContentIndex/0a490c4d-e4ea-4e8d-8989-720009d15f9d.vsidx +0 -0
  6. package/.vs/sync/FileContentIndex/173d280f-33b3-451d-8054-08fc6c991498.vsidx +0 -0
  7. package/.vs/sync/FileContentIndex/e27fae98-55a0-4376-b1eb-e2efa630b10b.vsidx +0 -0
  8. package/.vs/sync/FileContentIndex/fae8821f-9f13-46f5-91ef-05b837e2f35a.vsidx +0 -0
  9. package/.vs/sync/v17/.wsuo +0 -0
  10. package/.vs/sync/v17/DocumentLayout.backup.json +87 -28
  11. package/.vs/sync/v17/DocumentLayout.json +81 -15
  12. package/.vs/sync.slnx/FileContentIndex/13d6a28d-932f-4eb6-818c-efea35f24838.vsidx +0 -0
  13. package/.vs/sync.slnx/FileContentIndex/46af7fa0-1a65-4634-9faa-600623e92173.vsidx +0 -0
  14. package/.vs/sync.slnx/FileContentIndex/75bd0095-9fc3-4f35-90e9-f4022b8e4b55.vsidx +0 -0
  15. package/.vs/sync.slnx/FileContentIndex/92b75297-fe76-448d-80d4-cbf5ef4fcd60.vsidx +0 -0
  16. package/.vs/sync.slnx/FileContentIndex/eb2f80ef-22e0-4cc0-a8fb-f7837f87af2d.vsidx +0 -0
  17. package/.vs/sync.slnx/config/applicationhost.config +1011 -0
  18. package/.vs/sync.slnx/v18/.wsuo +0 -0
  19. package/.vs/sync.slnx/v18/DocumentLayout.backup.json +104 -0
  20. package/.vs/sync.slnx/v18/DocumentLayout.json +87 -0
  21. package/dist/src/index.d.ts +7 -3
  22. package/dist/sync.es.js +985 -931
  23. package/dist/sync.es.js.map +1 -1
  24. package/dist/sync.umd.js +24 -24
  25. package/dist/sync.umd.js.map +1 -1
  26. package/package.json +1 -1
  27. package/src/index.ts +214 -54
  28. package/.vs/sync/FileContentIndex/0d08f64f-8fd9-4bd4-90fc-8322cb33dd00.vsidx +0 -0
  29. package/.vs/sync/FileContentIndex/5d404a65-c534-43ee-beba-a5efbe6a49b0.vsidx +0 -0
  30. package/.vs/sync/FileContentIndex/63524bf8-437e-4a1c-951f-7a78da75a1bc.vsidx +0 -0
  31. package/.vs/sync/FileContentIndex/f95b6302-8444-443b-9e3b-a41d3483c73a.vsidx +0 -0
  32. /package/.vs/sync/FileContentIndex/{db560492-d007-4291-a6b3-50ccdcbd66b4.vsidx → 72fe2c03-a5ac-417e-b6be-5d2e18aa7d59.vsidx} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
- "version": "1.0.106",
3
+ "version": "1.0.107",
4
4
  "description": "sync is a node.js package encapsulating JavaScript classes required for configuring Mindline sync service.",
5
5
  "main": "dist/sync.es.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -93,6 +93,9 @@ export class mindlineConfig {
93
93
  static signalREndpoint(): string {
94
94
  return `https://${mindlineConfig.environmentTag}-signalrdispatcher-westus.azurewebsites.net/statsHub`;
95
95
  };
96
+ static statsEndpoint(): string {
97
+ return `https://${mindlineConfig.environmentTag}-signalrdispatcher-westus.azurewebsites.net/api/stats`;
98
+ }
96
99
  }
97
100
  export class graphConfig {
98
101
  // graph API predicates
@@ -785,7 +788,7 @@ export class MilestoneArray {
785
788
  let result = localStorage.getItem("syncmilestones");
786
789
  if (result != null && typeof result === "string" && result !== "") {
787
790
  let milestonesString: string = result;
788
- let milestones: Object [] = JSON.parse(milestonesString);
791
+ let milestones: Object[] = JSON.parse(milestonesString);
789
792
  if (milestones.length !== 0) {
790
793
  if (bClearLocalStorage) {
791
794
  localStorage.removeItem("syncmilestones");
@@ -812,7 +815,7 @@ export class MilestoneArray {
812
815
  if (this.milestones == null || this.milestones.length < 1) { debugger; return; }
813
816
  let currentRun: number = Number(this.milestones[0].Run);
814
817
  // create a new milestone and prepend to front of array
815
- let newMilestone: Milestone = new Milestone(currentRun+1);
818
+ let newMilestone: Milestone = new Milestone(currentRun + 1);
816
819
  this.milestones.unshift(newMilestone);
817
820
  // re-define milestone array to trigger render
818
821
  this.milestones = this.milestones.map((ms: Milestone) => {
@@ -1027,7 +1030,9 @@ export class BatchArray {
1027
1030
  this.pb_total = 0;
1028
1031
  this.pb_timer = setInterval(() => {
1029
1032
  // if signalR has finished the sync, stop the timer
1030
- if (this.milestoneArray.milestones[0].Write != null) {
1033
+ console.log("this.tenantNodes", this.tenantNodes)
1034
+ let isCompletedOrNothingToSync = this.tenantNodes.map((tn: TenantNode) => tn.targets.map((ta) => ta.status === "complete" || tn.nothingtosync).reduce((prev, next) => prev && next)).reduce((prev, next) => prev && next);
1035
+ if (isCompletedOrNothingToSync) {
1031
1036
  clearInterval(this.pb_timer!);
1032
1037
  this.pb_timer = null;
1033
1038
  this.pb_progress = 100;
@@ -1074,12 +1079,15 @@ export class BatchArray {
1074
1079
  batchIdArray: Array<Object>,
1075
1080
  setRefreshDeltaTrigger: (workspace: string) => void,
1076
1081
  setReadersTotal: (readersTotal: number) => void,
1082
+ setReadersExcluded: (readersExcluded: number) => void,
1077
1083
  setReadersCurrent: (readersCurrent: number) => void,
1078
1084
  setWritersTotal: (writersTotal: number) => void,
1079
- setWritersCurrent: (writersCurrent: number) => void ,
1085
+ setWritersExcluded: (writersExcluded: number) => void,
1086
+ setWritersCurrent: (writersCurrent: number) => void,
1080
1087
  setMilestones: (milestones: Milestone[]) => void,
1081
1088
  setConfigSyncResult: (result: string) => void,
1082
- bClearLocalStorage: boolean
1089
+ bClearLocalStorage: boolean,
1090
+ message: string
1083
1091
  ): void {
1084
1092
  bClearLocalStorage = bClearLocalStorage;
1085
1093
  // we have just completed a successful POST to startSync
@@ -1088,7 +1096,7 @@ export class BatchArray {
1088
1096
  // re-initialize batch array with Configuration updated by the succcessful POST to startSync
1089
1097
  this.init(config, syncPortalGlobalState, false);
1090
1098
  // define newMessage handler that can access *this*
1091
- let handler = (message: string) => {
1099
+ let handler = (connection: signalR.HubConnection) => (message: string) => {
1092
1100
  console.log(message);
1093
1101
  let item = JSON.parse(message);
1094
1102
  // reset the countdown timer every time we get a message
@@ -1117,12 +1125,29 @@ export class BatchArray {
1117
1125
  for (let j = 0; j < statskeys.length; j++) {
1118
1126
  let bTotalCount = statskeys[j].endsWith("TotalCount");
1119
1127
  let bCurrentCount = statskeys[j].endsWith("CurrentCount");
1128
+ let bExcludedCount = statskeys[j].endsWith("ExtCount");
1120
1129
  let bDeferredCount = statskeys[j].endsWith("DeferredCount");
1121
1130
  let bRescheduledCount = statskeys[j].endsWith("RescheduledCount");
1131
+ if (bExcludedCount) {
1132
+ tenantNode.excluded = Math.max(Number(statsvalues[j]), tenantNode.excluded);
1133
+ tenantNode.targets.map(writerNode => {
1134
+ writerNode.excluded = tenantNode.excluded;
1135
+ writerNode.update(writerNode.total, writerNode.read, writerNode.excluded, writerNode.written, writerNode.deferred);
1136
+ })
1137
+ }
1138
+ if (bTotalCount) {
1139
+ bTotalCountZero = Number(statsvalues[j]) == 0;
1140
+ tenantNode.total = Math.max(Number(statsvalues[j]), tenantNode.total);
1141
+ tenantNode.targets.map(writerNode => {
1142
+ writerNode.total = tenantNode.total;
1143
+ writerNode.update(writerNode.total, writerNode.read, writerNode.excluded, writerNode.written, writerNode.deferred);
1144
+ })
1145
+ }
1122
1146
  if (statskeys[j].startsWith("Reader")) {
1123
1147
  // parse tid from Reader key
1124
1148
  let tidRegexp = /Reader\/TID:(.+)\/TotalCount/;
1125
1149
  if (bCurrentCount) tidRegexp = /Reader\/TID:(.+)\/CurrentCount/;
1150
+ if (bExcludedCount) tidRegexp = /Reader\/TID:(.+)\/ExtCount/;
1126
1151
  if (bDeferredCount) tidRegexp = /Reader\/TID:(.+)\/DeferredCount/;
1127
1152
  if (bRescheduledCount) tidRegexp = /Reader\/TID:(.+)\/RescheduledCount/;
1128
1153
  let matchTID = statskeys[j].match(tidRegexp);
@@ -1139,15 +1164,21 @@ export class BatchArray {
1139
1164
  }
1140
1165
  else {
1141
1166
  bCurrentCountZero = Number(statsvalues[j]) == 0;
1142
- tenantNode.read = Math.max(Number(statsvalues[j]), tenantNode.read);
1143
- console.log(`----- ${tenantNode.name} Currently Read: ${tenantNode.read}`);
1167
+ if (bCurrentCount) {
1168
+ tenantNode.read = Math.max(Number(statsvalues[j]), tenantNode.read);
1169
+ console.log(`----- ${tenantNode.name} Currently Read: ${tenantNode.read}`);
1170
+ } else if (bDeferredCount) {
1171
+ tenantNode.deferred = Math.max(Number(statsvalues[j]), tenantNode.deferred);
1172
+ console.log(`----- ${tenantNode.name} Deferred: ${tenantNode.deferred}`);
1173
+ }
1144
1174
  }
1145
1175
  }
1146
1176
  tenantNode.nothingtosync = bTotalCountZero && bCurrentCountZero;
1147
1177
  if (statskeys[j].startsWith("Writer")) {
1148
1178
  // parse tid from Writer key
1149
- let tidRegexp = /Writer\/TID:(.+)\/TotalCount/;
1179
+ let tidRegexp = /Reader\/TID:(.+)\/TotalCount/;
1150
1180
  if (bCurrentCount) tidRegexp = /Writer\/TID:(.+)\/CurrentCount/;
1181
+ if (bExcludedCount) tidRegexp = /Writer\/TID:(.+)\/ExtCount/;
1151
1182
  if (bDeferredCount) tidRegexp = /Writer\/TID:(.+)\/DeferredCount/;
1152
1183
  if (bRescheduledCount) tidRegexp = /Writer\/TID:(.+)\/RescheduledCount/;
1153
1184
  let matchTID: RegExpMatchArray | null = statskeys[j].match(tidRegexp);
@@ -1163,9 +1194,11 @@ export class BatchArray {
1163
1194
  debugger;
1164
1195
  return;
1165
1196
  }
1197
+ writerNode.total = Math.max(Number(tenantNode.total), writerNode.total);
1198
+ writerNode.total = Math.max(Number(tenantNode.total), writerNode.total);
1166
1199
  writerNode.batchId = matchingPair.BatchId;
1167
1200
  if (bTotalCount) {
1168
- writerNode.total = Math.max(Number(statsvalues[j]), writerNode.total);
1201
+ writerNode.total = Math.max(Number(bTotalCount), writerNode.total);
1169
1202
  console.log(`----- ${writerNode.name} TID: ${writerNode.tid} batchId: ${writerNode.batchId}`);
1170
1203
  console.log(`----- ${writerNode.name} Total To Write: ${writerNode.total}`);
1171
1204
  }
@@ -1182,11 +1215,12 @@ export class BatchArray {
1182
1215
  debugger;
1183
1216
  return;
1184
1217
  }
1185
- writerNode.update(writerNode.total, writerNode.read, writerNode.written, writerNode.deferred);
1218
+ writerNode.update(writerNode.total, writerNode.read, writerNode.excluded, writerNode.written, writerNode.deferred);
1186
1219
  }
1187
1220
  }
1188
1221
  // update status based on all updates in this message
1189
- tenantNode.update(tenantNode.total, tenantNode.read, tenantNode.written, tenantNode.deferred);
1222
+ tenantNode.update(tenantNode.total, tenantNode.read, tenantNode.excluded, tenantNode.written, tenantNode.deferred);
1223
+
1190
1224
  // for each message, enumerate nodes to assess completion state
1191
1225
  let bReadingComplete: boolean = true;
1192
1226
  let bWritingComplete: boolean = true;
@@ -1194,34 +1228,41 @@ export class BatchArray {
1194
1228
  let bNothingToSync: boolean = true;
1195
1229
  let readerTotal: number = 0;
1196
1230
  let readerCurrent: number = 0;
1231
+ let readerExcluded: number = 0;
1197
1232
  let writerTotal: number = 0;
1198
1233
  let writerCurrent: number = 0;
1234
+ let writerExcluded: number = 0;
1199
1235
  this.tenantNodes.map((sourceTenantNode: TenantNode) => {
1200
1236
  sourceTenantNode.targets.map((writerNode: TenantNode) => {
1201
1237
  bWritingComplete &&= (writerNode.status == "complete" || writerNode.status == "failed");
1202
1238
  bWritingStarted ||= (writerNode.total > 0 || writerNode.status != "not started");
1203
1239
  writerTotal += Math.max(writerNode.total, sourceTenantNode.total);
1204
1240
  writerCurrent += writerNode.written;
1241
+ writerExcluded += writerNode.excluded;
1205
1242
  });
1206
1243
  bNothingToSync &&= sourceTenantNode.nothingtosync;
1207
1244
  bReadingComplete &&= (sourceTenantNode.status == "complete" || sourceTenantNode.status == "failed");
1208
1245
  readerTotal += sourceTenantNode.total;
1209
1246
  readerCurrent += sourceTenantNode.read;
1247
+ readerExcluded += sourceTenantNode.excluded;
1210
1248
  });
1211
1249
  // set linear gauge max and current values
1212
1250
  setReadersTotal(readerTotal);
1213
1251
  setReadersCurrent(readerCurrent);
1252
+ setReadersExcluded(readerExcluded);
1214
1253
  setWritersTotal(Math.max(writerTotal, readerTotal));
1215
1254
  setWritersCurrent(writerCurrent);
1255
+ setWritersExcluded(writerExcluded);
1216
1256
  // check to see if there was nothing to sync
1217
1257
  if (bNothingToSync) {
1218
1258
  this.milestoneArray.write(setMilestones);
1259
+ connection.stop();
1219
1260
  setConfigSyncResult("nothing to sync");
1220
1261
  console.log(`Setting config sync result: "nothing to sync"`);
1221
1262
  }
1222
1263
  else {
1223
1264
  // because it is an important milestone, we always check if we have *just* completed reading
1224
- if (bReadingComplete && this.milestoneArray.milestones[0].Read == null) {
1265
+ if (bReadingComplete) {
1225
1266
  this.milestoneArray.read(setMilestones);
1226
1267
  setConfigSyncResult("reading complete");
1227
1268
  console.log(`Setting config sync result: "reading complete"`);
@@ -1238,6 +1279,7 @@ export class BatchArray {
1238
1279
  // with that out of the way, is writing complete?
1239
1280
  if (bWritingComplete) {
1240
1281
  this.milestoneArray.write(setMilestones);
1282
+ connection.stop();
1241
1283
  setConfigSyncResult("sync complete");
1242
1284
  console.log(`Setting config sync result: "complete"`);
1243
1285
  }
@@ -1253,6 +1295,7 @@ export class BatchArray {
1253
1295
  }
1254
1296
  }
1255
1297
  }
1298
+
1256
1299
  // start SignalR connection based on each batchId
1257
1300
  batchIdArray.map((batchPair: any) => {
1258
1301
  const endpoint: string = mindlineConfig.signalREndpoint();
@@ -1265,7 +1308,10 @@ export class BatchArray {
1265
1308
  .configureLogging(signalR.LogLevel.Information)
1266
1309
  .build();
1267
1310
  // when you get a message, process the message
1268
- connection.on("newMessage", handler);
1311
+ if (!!message && JSON.parse(message).TargetID === batchPair.BatchId) {
1312
+ handler(connection)(message)
1313
+ }
1314
+ connection.on("newMessage", handler(connection));
1269
1315
  connection.onreconnecting(error => {
1270
1316
  console.assert(connection.state === signalR.HubConnectionState.Reconnecting);
1271
1317
  console.log(`Connection lost due to error "${error}". Reconnecting.`);
@@ -1284,8 +1330,7 @@ export class BatchArray {
1284
1330
  });
1285
1331
  }
1286
1332
  // start a sync cycle
1287
- async startSync(instance: IPublicClientApplication, authorizedUser: User | null | undefined, config: SyncConfig | null | undefined): Promise<APIResult>
1288
- {
1333
+ async startSync(instance: IPublicClientApplication, authorizedUser: User | null | undefined, config: SyncConfig | null | undefined): Promise<APIResult> {
1289
1334
  let result: APIResult = new APIResult();
1290
1335
  if (this.tenantNodes == null || this.tenantNodes.length == 0) {
1291
1336
  // we should not have an empty batch array for a test
@@ -1308,8 +1353,9 @@ export class TenantNode {
1308
1353
  batchId: string;
1309
1354
  total: number = 0;
1310
1355
  read: number = 0;
1356
+ excluded: number = 0;
1311
1357
  written: number = 0;
1312
- deferred: number =0 ;
1358
+ deferred: number = 0;
1313
1359
  nothingtosync: boolean;
1314
1360
  targets: TenantNode[];
1315
1361
  constructor(tid: string, name: string, batchId: string) {
@@ -1319,22 +1365,23 @@ export class TenantNode {
1319
1365
  this.batchId = batchId;
1320
1366
  this.nothingtosync = false;
1321
1367
  this.targets = new Array<TenantNode>();
1322
- this.update(0, 0, 0, 0);
1368
+ this.update(0, 0, 0, 0, 0);
1323
1369
  }
1324
- update(total: number, read: number, written: number, deferred: number): void {
1370
+ update(total: number, read: number, excluded: number, written: number, deferred: number): void {
1325
1371
  this.total = total;
1326
1372
  this.read = read;
1373
+ this.excluded = excluded;
1327
1374
  this.written = written;
1328
1375
  this.deferred = deferred;
1329
1376
  if (this.read === 0 && this.written === 0) this.status = "not started";
1330
1377
  if (this.read > 0) {
1331
- if (this.read < this.total) this.status = "in progress";
1332
- else if (this.read === this.total) this.status = "complete";
1378
+ if (this.read + this.excluded < this.total) this.status = "in progress";
1379
+ else if (this.read + this.excluded === this.total) this.status = "complete";
1333
1380
  }
1334
1381
  else if (this.written > 0) {
1335
- if (this.written + this.deferred < this.total) this.status = "in progress";
1336
- else if (this.written === this.total) this.status = "complete";
1337
- else if (this.written + this.deferred >= this.total) this.status = "failed";
1382
+ if (this.written + this.deferred + this.excluded < this.total) this.status = "in progress";
1383
+ else if (this.written + this.deferred + this.excluded === this.total) this.status = "complete";
1384
+ else if (this.written + this.deferred + this.excluded >= this.total) this.status = "failed";
1338
1385
  }
1339
1386
  }
1340
1387
  }
@@ -1549,7 +1596,7 @@ export async function groupsGet(instance: IPublicClientApplication, user: User |
1549
1596
  return { groups: [], error: `Exception: ${error}` };
1550
1597
  }
1551
1598
  }
1552
- export async function oauth2PermissionGrantsGet(options: RequestInit, user: User, spid: string, oid: string): Promise<{ grants: string|null, id: string|null, error: string }> {
1599
+ export async function oauth2PermissionGrantsGet(options: RequestInit, user: User, spid: string, oid: string): Promise<{ grants: string | null, id: string | null, error: string }> {
1553
1600
  try {
1554
1601
  // make /oauth2PermissionGrants endpoint call
1555
1602
  let spurl: string = getGraphEndpoint(user.authority) + graphConfig.graphOauth2PermissionGrantsPredicate;
@@ -1730,7 +1777,7 @@ export function signInIncrementally(user: User, scope: string): void {
1730
1777
  url.searchParams.append("loginHint", user.mail);
1731
1778
  window.location.assign(url.href);
1732
1779
  }
1733
- export async function signOut(user: User): Promise<boolean>{
1780
+ export async function signOut(user: User): Promise<boolean> {
1734
1781
  if (user.oid == "1") return false;
1735
1782
  // set logout_hint in the .NET session for streamlined logout
1736
1783
  let userEndpoint: string = window.location.href;
@@ -1941,7 +1988,7 @@ export async function tenantUnauthenticatedLookup(tenant: Tenant, debug: boolean
1941
1988
  }
1942
1989
  return false; // failed, no need for UX to re-render
1943
1990
  }
1944
- export async function userDelegatedScopesGet(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant): Promise<{ scopes: string|null, id: string|null, error: string }> {
1991
+ export async function userDelegatedScopesGet(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant): Promise<{ scopes: string | null, id: string | null, error: string }> {
1945
1992
  // need a logged in user and valid tenant to query graph
1946
1993
  if (loggedInUser == null || loggedInUser.spacode == "" || tenant == null) {
1947
1994
  debugger;
@@ -2053,8 +2100,7 @@ export async function configEdit(
2053
2100
  setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void,
2054
2101
  workspace: Workspace,
2055
2102
  ii: InitInfo,
2056
- debug: boolean): Promise<APIResult>
2057
- {
2103
+ debug: boolean): Promise<APIResult> {
2058
2104
  let result: APIResult = new APIResult();
2059
2105
  if (config.id === "1") {
2060
2106
  result = await configPost(instance, authorizedUser, config, workspace.id, debug);
@@ -2098,7 +2144,7 @@ export async function configConsentForRead(instance: IPublicClientApplication, a
2098
2144
  export async function configConsentForWrite(instance: IPublicClientApplication, authorizedUser: User, configId: string, tid: string, consent: boolean): Promise<APIResult> {
2099
2145
  return configConsentWritePut(instance, authorizedUser, configId, tid, consent);
2100
2146
  }
2101
- export async function configsRefresh(instance: IPublicClientApplication, authorizedUser: User, workspaceId: string, ii: InitInfo, debug: boolean): Promise<APIResult> {
2147
+ export async function configsRefresh(instance: IPublicClientApplication, authorizedUser: User, workspaceId: string, ii: InitInfo, debug: boolean, currentConfig: SyncConfig): Promise<APIResult> {
2102
2148
  let result: APIResult = new APIResult();
2103
2149
  if (debug) debugger;
2104
2150
  try {
@@ -2107,26 +2153,35 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2107
2153
  // clear SyncConfig associations as we are about to reset
2108
2154
  workspace.associatedConfigs.length = 0;
2109
2155
  // GET configs associated with this workspace
2110
- let result: APIResult = await workspaceConfigsGet(instance, authorizedUser, workspace.id, debug);
2156
+ let result: APIResult = await configGet(instance, authorizedUser, currentConfig, workspace.id, debug);
2111
2157
  if (!result.result) return result;
2112
2158
  // process returned workspace components
2113
- let configSelectedId: string = "";
2114
- for (let cid of workspace.associatedConfigs) {
2115
- let config = ii.cs.find((c: SyncConfig) => c.id === cid);
2116
- if (config != null && config.sel) {
2117
- ii.cs.find((c: SyncConfig) => c.id === cid) ??
2118
- ii.acs.find((a: AuditConfig) => a.id === cid);
2159
+ // let configSelectedId: string = "";
2160
+ // for (let cid of workspace.associatedConfigs) {
2161
+ // let config = ii.cs.find((c: SyncConfig) => c.id === cid);
2162
+ // if (config != null && config.sel) {
2163
+ // ii.cs.find((c: SyncConfig) => c.id === cid) ??
2164
+ // ii.acs.find((a: AuditConfig) => a.id === cid);
2119
2165
 
2120
- if (config && config.sel) {
2121
- configSelectedId = config.id;
2122
- }
2123
- }
2166
+ // if (config && config.sel) {
2167
+ // configSelectedId = config.id;
2168
+ // }
2169
+ // }
2124
2170
 
2125
- // Pass combined list to processor
2126
- processReturnedConfigs(workspace, ii, result.array!, configSelectedId);
2127
- // tag components with workspaceIDs
2128
- ii.tagWithWorkspaces();
2129
- }
2171
+ // // Pass combined list to processor
2172
+ // processReturnedConfigs(workspace, ii, result.array!, currentConfig.id);
2173
+ // console.log("Init Info-----------", ii)
2174
+ // console.log("Init Info-----------", configSelectedId)
2175
+ // // tag components with workspaceIDs
2176
+ // ii.tagWithWorkspaces();
2177
+ // localStorage.setItem("BatchIdArray", "{}");
2178
+ // }
2179
+ // processReturnedConfigs(workspace, ii, result.array!, currentConfig.id);
2180
+ // console.log("Init Info-----------", ii)
2181
+ // console.log("Init Info-----------", currentConfig.id)
2182
+ // tag components with workspaceIDs
2183
+ ii.tagWithWorkspaces();
2184
+ localStorage.setItem("BatchIdArray", "{}");
2130
2185
  return result;
2131
2186
  } else {
2132
2187
  // workspace not found
@@ -2200,8 +2255,7 @@ export async function userAdd(instance: IPublicClientApplication, authorizedUser
2200
2255
  export async function userRemove(instance: IPublicClientApplication, authorizedUser: User, user: User, workspaceId: string): Promise<APIResult> {
2201
2256
  return adminDelete(instance, authorizedUser, user, workspaceId);
2202
2257
  }
2203
- export async function workspaceEdit(instance: IPublicClientApplication, authorizedUser: User, workspaceId: string, workspaceName: string): Promise<APIResult>
2204
- {
2258
+ export async function workspaceEdit(instance: IPublicClientApplication, authorizedUser: User, workspaceId: string, workspaceName: string): Promise<APIResult> {
2205
2259
  return await workspacePut(instance, authorizedUser, workspaceId, workspaceName);
2206
2260
  }
2207
2261
  // retrieve Workspace(s), User(s), Tenant(s), SyncConfig(s) given newly logged in user
@@ -2359,6 +2413,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2359
2413
  let idx = workspace.associatedConfigs.findIndex((c) => c === item.id);
2360
2414
  if (idx == -1) workspace.associatedConfigs.push(item.id);
2361
2415
  });
2416
+ console.log("--------------ii-----------", ii)
2362
2417
  ii.save();
2363
2418
  }
2364
2419
  async function workspaceInfoGet(instance: IPublicClientApplication, user: User, ii: InitInfo, debug: boolean): Promise<APIResult> {
@@ -2463,9 +2518,9 @@ export async function getPowerBIAccessToken(
2463
2518
  }
2464
2519
  let response: AuthenticationResult = await instance.acquireTokenSilent({
2465
2520
  scopes: ["https://analysis.windows.net/powerbi/api/App.Read.All",
2466
- "https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All",
2467
- "https://analysis.windows.net/powerbi/api/Report.ReadWrite.All",
2468
- "https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All"
2521
+ "https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All",
2522
+ "https://analysis.windows.net/powerbi/api/Report.ReadWrite.All",
2523
+ "https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All"
2469
2524
  ],
2470
2525
  account: account!
2471
2526
  });
@@ -2586,7 +2641,7 @@ export async function elevateGlobalAdminToUserAccessAdmin(instance: IPublicClien
2586
2641
  console.log(error);
2587
2642
  return false;
2588
2643
  }
2589
- return true;
2644
+ return true;
2590
2645
  }
2591
2646
  async function readResources(instance: IPublicClientApplication, user: User): Promise<ResourceNode[]> {
2592
2647
  // need a logged in user to call Azure REST API
@@ -3256,6 +3311,56 @@ export async function configConsentWritePut(instance: IPublicClientApplication,
3256
3311
  return result;
3257
3312
  }
3258
3313
  //configDelete
3314
+ export async function configGet(
3315
+ instance: IPublicClientApplication,
3316
+ authorizedUser: User,
3317
+ config: SyncConfig,
3318
+ workspaceId: string,
3319
+ debug: boolean
3320
+ ): Promise<APIResult> {
3321
+ debug = debug;
3322
+ let result: APIResult = new APIResult();
3323
+ if (config.id === "" || workspaceId == "") {
3324
+ result.result = false;
3325
+ result.error = "configGet: invalid config ID";
3326
+ result.status = 500;
3327
+ return result;
3328
+ }
3329
+ let url: URL | null = null;
3330
+ url = new URL(mindlineConfig.configEndpoint());
3331
+ // create headers
3332
+ const headers = await mindlineDefineHeaders(instance, authorizedUser);
3333
+ // make endpoint call
3334
+ let options = { method: "GET", headers: headers };
3335
+ try {
3336
+ console.log("Attempting GET from /config: " + url.href);
3337
+ let response = await fetch(`${url.href}/${config.id}`, options);
3338
+ if (response.status === 200 && response.statusText === "OK") {
3339
+ console.log(`Successful GET from /config`);
3340
+ let data = await response.json()
3341
+ return {
3342
+ ...result,
3343
+ array: [data]
3344
+ };
3345
+ }
3346
+ else {
3347
+ result.error = await processErrors(response);
3348
+ console.log(`Failed GET from ${url.href}`);
3349
+ console.log(result.error);
3350
+ result.status = 500;
3351
+ result.result = false;
3352
+ return result;
3353
+ }
3354
+ }
3355
+ catch (error: any) {
3356
+ result.error = error.message;
3357
+ result.status = 500;
3358
+ result.result = false;
3359
+ console.log(error.message);
3360
+ }
3361
+ return result;
3362
+ }
3363
+ //configDelete
3259
3364
  export async function configDelete(
3260
3365
  instance: IPublicClientApplication,
3261
3366
  authorizedUser: User,
@@ -3482,7 +3587,11 @@ export async function configPut(
3482
3587
  let response = await fetch(url.href, options);
3483
3588
  if (response.status === 200 && response.statusText === "OK") {
3484
3589
  console.log(`Successful PUT to ${url.href}: ${configBody}`);
3485
- return result;
3590
+ let data = await response.json();
3591
+ return {
3592
+ ...result,
3593
+ array: [data]
3594
+ };
3486
3595
  }
3487
3596
  else {
3488
3597
  result.error = await processErrors(response);
@@ -3609,7 +3718,7 @@ export async function workspaceConfigsGet(
3609
3718
  }));
3610
3719
 
3611
3720
  console.log(
3612
- `workspaceConfigsGet: found ${result.array.length} configs.`
3721
+ `workspaceConfigsGet: found ${result.array.length} configs.`
3613
3722
  );
3614
3723
  return result;
3615
3724
  } else {
@@ -4005,4 +4114,55 @@ export async function readerPost(
4005
4114
  console.log(error.message);
4006
4115
  }
4007
4116
  return result;
4117
+ }
4118
+ //readStats
4119
+ export async function readerStats(
4120
+ instance: IPublicClientApplication,
4121
+ authorizedUser: User,
4122
+ tenantId: String
4123
+ ): Promise<APIResult> {
4124
+ let result: APIResult = new APIResult();
4125
+ if (instance == null || authorizedUser == null) {
4126
+ result.result = false;
4127
+ result.error = "readerPost: invalid parameters";
4128
+ result.status = 500;
4129
+ return result;
4130
+ }
4131
+ // create reader endpoint
4132
+ let stasEndpoint: string = mindlineConfig.statsEndpoint();
4133
+ let url: URL = new URL(`${stasEndpoint}/${tenantId}`);
4134
+ // create headers
4135
+ const headers = await mindlineDefineHeaders(instance, authorizedUser);
4136
+ // make reader endpoint call
4137
+ let options = { method: "GET", headers: headers };
4138
+ try {
4139
+ console.log("Attempting GET to /stats: " + url.href);
4140
+ let response = await fetch(url.href, options);
4141
+ if (response.status === 200 && response.statusText === "OK") {
4142
+ console.log(`Successful GET to /stats: ${stasEndpoint}`);
4143
+ let jsonResponse = await response.json();
4144
+ result.array = [jsonResponse];
4145
+ return result;
4146
+ } else if (response.status === 204) {
4147
+ result.error = await processErrors(response);
4148
+ console.log(`Failed GET to /stats: ${stasEndpoint}`);
4149
+ console.log(result.error);
4150
+ result.status = 204;
4151
+ result.result = false;
4152
+ return result;
4153
+ } else {
4154
+ result.error = await processErrors(response);
4155
+ console.log(`Failed GET to /stats: ${stasEndpoint}`);
4156
+ console.log(result.error);
4157
+ result.status = 500;
4158
+ result.result = false;
4159
+ return result;
4160
+ }
4161
+ } catch (error: any) {
4162
+ result.error = error.message;
4163
+ result.status = 500;
4164
+ result.result = false;
4165
+ console.log(error.message);
4166
+ }
4167
+ return result;
4008
4168
  }