@mindline/sync 1.0.107 → 1.0.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
- "version": "1.0.107",
3
+ "version": "1.0.109",
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.d.ts CHANGED
@@ -4,12 +4,12 @@ declare module "@mindline/sync" {
4
4
  export function helloNpm(): string;
5
5
  export function getSyncVersion(): string;
6
6
 
7
- export class APIResult {
7
+ export class APIResult<T = any> {
8
8
  result: boolean;
9
9
  status: number;
10
10
  error: string;
11
11
  version: string;
12
- array: Array<Object> | null;
12
+ array: Array<T> | null;
13
13
  constructor();
14
14
  }
15
15
  export class azureConfig {
@@ -189,14 +189,14 @@ declare module "@mindline/sync" {
189
189
  save(): void;
190
190
  tagWithWorkspaces(): boolean;
191
191
  }
192
- export type TaskType = "initialization" |
193
- "authenticate user" |
194
- "reload React" |
195
- "GET tenant details" |
196
- "POST config init" |
197
- "GET workspaces";
192
+ export type TaskType = "initialization" |
193
+ "authenticate user" |
194
+ "reload React" |
195
+ "GET tenant details" |
196
+ "POST config init" |
197
+ "GET workspaces";
198
198
  export class TaskArray {
199
- tasks: Task[];
199
+ tasks: Task[];
200
200
  constructor(bClearLocalStorage: boolean);
201
201
  init(bClearLocalStorage: boolean): void;
202
202
  setTaskStart(taskType: TaskType, startDate: Date): void;
@@ -257,9 +257,9 @@ declare module "@mindline/sync" {
257
257
  pb_total: number;
258
258
  pb_timer: NodeJS.Timer;
259
259
  milestoneArray: MilestoneArray;
260
- constructor(config: SyncConfig|null, syncPortalGlobalState: InitInfo|null, bClearLocalStorage: boolean);
260
+ constructor(config: SyncConfig | null, syncPortalGlobalState: InitInfo | null, bClearLocalStorage: boolean);
261
261
  // populate tenantNodes based on config tenants
262
- init(config: SyncConfig|null|undefined, syncPortalGlobalState: InitInfo|null, bClearLocalStorage: boolean): void;
262
+ init(config: SyncConfig | null | undefined, syncPortalGlobalState: InitInfo | null, bClearLocalStorage: boolean): void;
263
263
  initializeProgressBar(setSyncProgress: (progress: number) => void, setConfigSyncResult: (result: string) => void, setIdleText: (idleText: string) => void, setMilestones: (milestones: Milestone[]) => void): void;
264
264
  uninitializeProgressBar(setSyncProgress: (progress: number) => void, setConfigSyncResult: (result: string) => void, setIdleText: (idleText: string) => void, setMilestones: (milestones: Milestone[]) => void): void;
265
265
  initializeSignalR(
@@ -323,7 +323,7 @@ declare module "@mindline/sync" {
323
323
  }
324
324
  // ======================= Azure AD Graph API ===============================
325
325
  export function groupsGet(instance: IPublicClientApplication, user: User | undefined, groupSearchString: string): Promise<{ groups: Group[], error: string }>;
326
- export function oauth2PermissionGrantsGet(options: RequestInit, user: User, spid: string, oid: string): Promise<{grants: string, error: string}>;
326
+ export function oauth2PermissionGrantsGet(options: RequestInit, user: User, spid: string, oid: string): Promise<{ grants: string, error: string }>;
327
327
  export function requestAdminConsent(admin: User, tct: TenantConfigType): void;
328
328
  export function servicePrincipalGet(options: RequestInit, user: User, appid: string): Promise<{ spid: string, error: string }>;
329
329
  export function signIn(user: User, tasks: TaskArray): boolean;
@@ -338,8 +338,8 @@ declare module "@mindline/sync" {
338
338
  // ======================= Mindline SyncConfig API ===============================
339
339
  export function auditConfigAdd(instance: IPublicClientApplication, user: User, ac: AuditConfig, debug: boolean): Promise<APIResult>;
340
340
  export function auditConfigRetrieve(instance: IPublicClientApplication, user: User, configurationId: string, debug: boolean): Promise<APIResult>;
341
- export function auditConfigEdit(instance: IPublicClientApplication, user: User, configurationId: string, config: AuditConfig, debug: boolean): Promise<APIResult>;
342
- export function auditConfigRemove(instance: IPublicClientApplication, user: User, configurationId: string, debug: boolean): Promise<APIResult>;
341
+ export function auditConfigEdit(instance: IPublicClientApplication, user: User, configurationId: string, config: AuditConfig, debug: boolean): Promise<APIResult>;
342
+ export function auditConfigRemove(instance: IPublicClientApplication, user: User, configurationId: string, debug: boolean): Promise<APIResult>;
343
343
  export function auditEventsRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult>;
344
344
  export function configEdit(instance: IPublicClientApplication, authorizedUser: User, config: SyncConfig, setConfigId: (id: string) => void, setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void, workspace: Workspace, ii: InitInfo, debug: boolean): APIResult;
345
345
  export function configEnable(instance: IPublicClientApplication, authorizedUser: User, configurationId: string, enabled: boolean, debug: boolean): APIResult;
package/src/index.ts CHANGED
@@ -25,12 +25,12 @@ export function getSyncVersion(): string {
25
25
  // injected at build time
26
26
  return __SYNC_VERSION__;
27
27
  }
28
- export class APIResult {
28
+ export class APIResult<T = any> {
29
29
  result: boolean;
30
30
  status: number;
31
31
  error: string;
32
32
  version: string;
33
- array: Array<Object> | null;
33
+ array: Array<T> | null;
34
34
  constructor() { this.result = true; this.status = 200; this.error = ""; this.version = getSyncVersion(); this.array = null; }
35
35
  }
36
36
  export class azureConfig {
@@ -933,13 +933,18 @@ export class BatchArray {
933
933
  this.init(config, syncPortalGlobalState, bClearLocalStorage);
934
934
  this.pb_startTS = 0;
935
935
  this.pb_progress = 0;
936
- this.pb_increment = 0;
936
+ this.pb_increment = .25;
937
937
  this.pb_timer = null;
938
938
  this.pb_idle = 0;
939
939
  this.pb_idleMax = 0;
940
940
  this.pb_total = 0;
941
941
  this.milestoneArray = new MilestoneArray(false);
942
942
  }
943
+ clearStoredBatchIds(): void {
944
+ if (storageAvailable()) {
945
+ localStorage.setItem("BatchIdArray", "[]");
946
+ }
947
+ }
943
948
  // populate tenantNodes based on config tenants
944
949
  init(
945
950
  config: SyncConfig | null | undefined,
@@ -1038,6 +1043,7 @@ export class BatchArray {
1038
1043
  this.pb_progress = 100;
1039
1044
  setSyncProgress(this.pb_progress);
1040
1045
  setIdleText(`Complete. [max idle: ${this.pb_idleMax}]`);
1046
+ this.clearStoredBatchIds();
1041
1047
  }
1042
1048
  else {
1043
1049
  // if we've gone 60 seconds without a signalR message, finish the sync
@@ -1258,6 +1264,7 @@ export class BatchArray {
1258
1264
  this.milestoneArray.write(setMilestones);
1259
1265
  connection.stop();
1260
1266
  setConfigSyncResult("nothing to sync");
1267
+ this.clearStoredBatchIds();
1261
1268
  console.log(`Setting config sync result: "nothing to sync"`);
1262
1269
  }
1263
1270
  else {
@@ -1281,6 +1288,7 @@ export class BatchArray {
1281
1288
  this.milestoneArray.write(setMilestones);
1282
1289
  connection.stop();
1283
1290
  setConfigSyncResult("sync complete");
1291
+ this.clearStoredBatchIds();
1284
1292
  console.log(`Setting config sync result: "complete"`);
1285
1293
  }
1286
1294
  // if not, has writing even started?
@@ -2106,6 +2114,12 @@ export async function configEdit(
2106
2114
  result = await configPost(instance, authorizedUser, config, workspace.id, debug);
2107
2115
  if (result.result) {
2108
2116
  // config id was updated from "1"
2117
+ // Update all TCI configIds to reference the new config ID
2118
+ config.tenants.forEach((tci) => {
2119
+ if (tci.configId === "1" || tci.configId === "") {
2120
+ tci.configId = config.id;
2121
+ }
2122
+ });
2109
2123
  if (setConfigId) {
2110
2124
  setConfigId(config.id);
2111
2125
  }
@@ -2181,7 +2195,9 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2181
2195
  // console.log("Init Info-----------", currentConfig.id)
2182
2196
  // tag components with workspaceIDs
2183
2197
  ii.tagWithWorkspaces();
2184
- localStorage.setItem("BatchIdArray", "{}");
2198
+ // IMPORTANT:
2199
+ // Do not clear BatchIdArray here. It is used by the UI to restore an in-flight sync
2200
+ // after refresh/re-login. BatchIdArray should be cleared when the sync completes.
2185
2201
  return result;
2186
2202
  } else {
2187
2203
  // workspace not found
@@ -3498,7 +3514,9 @@ export async function configPost(
3498
3514
  "sourceGroupName": ${sourceGroupName},
3499
3515
  "targetGroupId": ${targetGroupId},
3500
3516
  "targetGroupName": ${targetGroupName},
3501
- "configurationTenantType": "${tci.configurationTenantType}"
3517
+ "configurationTenantType": "${tci.configurationTenantType}",
3518
+ "isReadPermissionConsented": ${tci.isReadPermissionConsented},
3519
+ "isWritePermissionConsented": ${tci.isWritePermissionConsented}
3502
3520
  }`;
3503
3521
  });
3504
3522
  configBody += `]}`;
@@ -3510,9 +3528,10 @@ export async function configPost(
3510
3528
  let response = await fetch(endpoint, options);
3511
3529
  if (response.status === 200 && response.statusText === "OK") {
3512
3530
  let data = await response.json();
3513
- config.id = data;
3531
+ // API returns an object {id: "..."} or just the ID string directly
3532
+ config.id = (typeof data === 'object' && data !== null && data.id) ? data.id : data;
3514
3533
  console.log(
3515
- `Successful ConfigID: ${data} from POST to /config: ${configBody}`
3534
+ `Successful ConfigID: ${config.id} from POST to /config: ${configBody}`
3516
3535
  );
3517
3536
  return result;
3518
3537
  }
@@ -3575,7 +3594,9 @@ export async function configPut(
3575
3594
  "targetGroupId": ${targetGroupId},
3576
3595
  "targetGroupName": ${targetGroupName},
3577
3596
  "configurationTenantType": "${tci.configurationTenantType}",
3578
- "deltaToken": "${tci.deltaToken}"
3597
+ "deltaToken": "${tci.deltaToken}",
3598
+ "isReadPermissionConsented": ${tci.isReadPermissionConsented},
3599
+ "isWritePermissionConsented": ${tci.isWritePermissionConsented}
3579
3600
  }`;
3580
3601
  });
3581
3602
  configBody += `]}`;
@@ -4165,4 +4186,4 @@ export async function readerStats(
4165
4186
  console.log(error.message);
4166
4187
  }
4167
4188
  return result;
4168
- }
4189
+ }