@mindline/sync 1.0.102 → 1.0.104

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.102",
3
+ "version": "1.0.104",
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
@@ -137,7 +137,7 @@ declare module "@mindline/sync" {
137
137
  isReadPermissionConsented: boolean;
138
138
  isWritePermissionConsented: boolean;
139
139
  }
140
- export class Config {
140
+ export class SyncConfig {
141
141
  id: string;
142
142
  workspaceId: string;
143
143
  name: string;
@@ -179,7 +179,7 @@ declare module "@mindline/sync" {
179
179
  tab: number;
180
180
  us: User[];
181
181
  ts: Tenant[];
182
- cs: Config[];
182
+ cs: SyncConfig[];
183
183
  acs: AuditConfig[];
184
184
  ws: Workspace[];
185
185
  configlevelconsent_configid: string;
@@ -257,13 +257,13 @@ declare module "@mindline/sync" {
257
257
  pb_total: number;
258
258
  pb_timer: NodeJS.Timer;
259
259
  milestoneArray: MilestoneArray;
260
- constructor(config: Config|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: Config|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(
266
- config: Config | null | undefined,
266
+ config: SyncConfig | null | undefined,
267
267
  syncPortalGlobalState: InitInfo | null,
268
268
  batchIdArray: Array<Object>,
269
269
  setRefreshDeltaTrigger: (workspace: string) => void,
@@ -274,7 +274,7 @@ declare module "@mindline/sync" {
274
274
  setMilestones: (milestones: Milestone[]) => void,
275
275
  setConfigSyncResult: (result: string) => void,
276
276
  bClearLocalStorage: boolean): void;
277
- startSync(instance: IPublicClientApplication, authorizedUser: User | null | undefined, config: Config | null | undefined): APIResult;
277
+ startSync(instance: IPublicClientApplication, authorizedUser: User | null | undefined, config: SyncConfig | null | undefined): APIResult;
278
278
  }
279
279
  export class TenantNode {
280
280
  expanded: boolean;
@@ -335,16 +335,16 @@ declare module "@mindline/sync" {
335
335
  export function userDelegatedScopesGet(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant): { scopes: string, id: string, error: string };
336
336
  export function userDelegatedScopesRemove(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant, scope: string): boolean;
337
337
  export function usersGet(instance: IPublicClientApplication, user: User | undefined): { users: string[], error: string };
338
- // ======================= Mindline Config API ===============================
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, debug: boolean): Promise<APIResult>;
341
341
  export function auditEventsRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult>;
342
- export function configEdit(instance: IPublicClientApplication, authorizedUser: User, config: Config, setConfigId: (id: string) => void, setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void, workspace: Workspace, ii: InitInfo, debug: boolean): APIResult;
342
+ 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;
343
343
  export function configEnable(instance: IPublicClientApplication, authorizedUser: User, configurationId: string, enabled: boolean, debug: boolean): APIResult;
344
344
  export function configConsentForRead(instance: IPublicClientApplication, authorizedUser: User, configId: string, tid: string, consent: boolean): Promise<APIResult>;
345
345
  export function configConsentForWrite(instance: IPublicClientApplication, authorizedUser: User, configId: string, tid: string, consent: boolean): Promise<APIResult>;
346
346
  export function configsRefresh(instance: IPublicClientApplication, authorizedUser: User, workspaceId: string, ii: InitInfo, debug: boolean): APIResult;
347
- export function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): APIResult;
347
+ export function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: SyncConfig, workspaceId: string, debug: boolean): APIResult;
348
348
  export function initGet(instance: IPublicClientApplication, user: User, ii: InitInfo, tasks: TaskArray, debug: boolean): APIResult;
349
349
  export function tenantAdd(instance: IPublicClientApplication, authorizedUser: User, tenant: Tenant, workspaceId: string): APIResult;
350
350
  export function tenantRemove(instance: IPublicClientApplication, authorizedUser: User, tenant: Tenant, workspaceId: string, debug: boolean): APIResult;
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- //index.ts - published interface - AAD implementations, facade to Mindline Config API
1
+ //index.ts - published interface - AAD implementations, facade to Mindline SyncConfig API
2
2
  import * as signalR from "@microsoft/signalr"
3
3
  import { AccountInfo } from "@azure/msal-common";
4
4
  import { IPublicClientApplication, AuthenticationResult } from "@azure/msal-browser"
@@ -263,7 +263,7 @@ export class TenantConfigInfo {
263
263
  this.isWritePermissionConsented = false;
264
264
  }
265
265
  }
266
- export class Config {
266
+ export class SyncConfig {
267
267
  id: string;
268
268
  workspaceId: string;
269
269
  name: string;
@@ -289,6 +289,7 @@ export class AuditConfig {
289
289
  name: string;
290
290
  description: string;
291
291
  isEnabled: boolean;
292
+ isReadPermissionConsented: boolean;
292
293
  email: string;
293
294
  tenantId: string;
294
295
  sel: boolean; // selection state
@@ -298,11 +299,15 @@ export class AuditConfig {
298
299
  this.workspaceId = "";
299
300
  this.description = "";
300
301
  this.isEnabled = false;
302
+ this.isReadPermissionConsented = false;
301
303
  this.email = "";
302
304
  this.tenantId = "";
303
305
  this.sel = false;
304
306
  }
305
307
  }
308
+
309
+ export type ConfigType = 'sync' | 'auditlogs';
310
+
306
311
  export class Workspace {
307
312
  id: string;
308
313
  name: string;
@@ -353,7 +358,8 @@ export class InitInfo {
353
358
  tab: number = 0;
354
359
  us: User[] = [];
355
360
  ts: Tenant[] = [];
356
- cs: Config[] = [];
361
+ cs: SyncConfig[] = [];
362
+ acs: AuditConfig[] = [];
357
363
  ws: Workspace[] = [];
358
364
  configlevelconsent_configid: string = "";
359
365
  configlevelconsent_access: TenantConfigType = TenantConfigType.sourcetarget;
@@ -392,7 +398,7 @@ export class InitInfo {
392
398
  try {
393
399
  this.us = deserializeArray(User, usersString);
394
400
  this.ts = deserializeArray(Tenant, tenantsString);
395
- this.cs = deserializeArray(Config, configsString);
401
+ this.cs = deserializeArray(SyncConfig, configsString);
396
402
  this.ws = deserializeArray(Workspace, workspacesString);
397
403
  this.tagWithWorkspaces();
398
404
  } catch (e) {
@@ -499,11 +505,11 @@ export class InitInfo {
499
505
  });
500
506
  }
501
507
  if (typeof ii.cs === "undefined") {
502
- this.cs = new Array<Config>();
508
+ this.cs = new Array<SyncConfig>();
503
509
  }
504
510
  else {
505
- this.cs = ii.cs.map((config: Config) => {
506
- let newconfig: Config = new Config();
511
+ this.cs = ii.cs.map((config: SyncConfig) => {
512
+ let newconfig: SyncConfig = new SyncConfig();
507
513
  newconfig.id = config.id;
508
514
  newconfig.workspaceId = config.workspaceId;
509
515
  newconfig.name = config.name;
@@ -721,7 +727,7 @@ export class Task {
721
727
  this.startDisplay = `${this.start.getMinutes().toString().padStart(2, "0")}:${this.start.getSeconds().toString().padStart(2, "0")}`;
722
728
  };
723
729
  }
724
- // class corresponding to an execution of a Config - a *TenantNode* for each source tenant, each with a *TenantNode* array of target tenants
730
+ // class corresponding to an execution of a SyncConfig - a *TenantNode* for each source tenant, each with a *TenantNode* array of target tenants
725
731
  export class Milestone {
726
732
  Run: number = 0;
727
733
  Start: Date = new Date();
@@ -913,7 +919,7 @@ export class BatchArray {
913
919
  pb_timer: NodeJS.Timeout | null;
914
920
  milestoneArray: MilestoneArray;
915
921
  constructor(
916
- config: Config | null,
922
+ config: SyncConfig | null,
917
923
  syncPortalGlobalState: InitInfo | null,
918
924
  bClearLocalStorage: boolean
919
925
  ) {
@@ -930,7 +936,7 @@ export class BatchArray {
930
936
  }
931
937
  // populate tenantNodes based on config tenants
932
938
  init(
933
- config: Config | null | undefined,
939
+ config: SyncConfig | null | undefined,
934
940
  syncPortalGlobalState: InitInfo | null,
935
941
  bClearLocalStorage: boolean
936
942
  ): void {
@@ -944,7 +950,7 @@ export class BatchArray {
944
950
  this.milestoneArray.init(bClearLocalStorage);
945
951
  }
946
952
  }
947
- // create BatchArray if passed Config and InitInfo
953
+ // create BatchArray if passed SyncConfig and InitInfo
948
954
  if (config != null &&
949
955
  config.tenants != null &&
950
956
  syncPortalGlobalState != null) {
@@ -1060,7 +1066,7 @@ export class BatchArray {
1060
1066
  this.milestoneArray.unstart(setMilestones);
1061
1067
  }
1062
1068
  initializeSignalR(
1063
- config: Config | null | undefined,
1069
+ config: SyncConfig | null | undefined,
1064
1070
  syncPortalGlobalState: InitInfo | null,
1065
1071
  batchIdArray: Array<Object>,
1066
1072
  setRefreshDeltaTrigger: (workspace: string) => void,
@@ -1275,7 +1281,7 @@ export class BatchArray {
1275
1281
  });
1276
1282
  }
1277
1283
  // start a sync cycle
1278
- async startSync(instance: IPublicClientApplication, authorizedUser: User | null | undefined, config: Config | null | undefined): Promise<APIResult>
1284
+ async startSync(instance: IPublicClientApplication, authorizedUser: User | null | undefined, config: SyncConfig | null | undefined): Promise<APIResult>
1279
1285
  {
1280
1286
  let result: APIResult = new APIResult();
1281
1287
  if (this.tenantNodes == null || this.tenantNodes.length == 0) {
@@ -2020,7 +2026,7 @@ export async function usersGet(instance: IPublicClientApplication, user: User |
2020
2026
  return { users: [], error: `Exception: ${error}` };
2021
2027
  }
2022
2028
  }
2023
- // ======================= Mindline Config API ===============================
2029
+ // ======================= Mindline SyncConfig API ===============================
2024
2030
  export async function auditConfigAdd(instance: IPublicClientApplication, user: User, ac: AuditConfig, debug: boolean): Promise<APIResult> {
2025
2031
  return auditConfigPost(instance, user, ac, debug);
2026
2032
  }
@@ -2033,7 +2039,7 @@ export async function auditEventsRetrieve(instance: IPublicClientApplication, au
2033
2039
  export async function configEdit(
2034
2040
  instance: IPublicClientApplication,
2035
2041
  authorizedUser: User,
2036
- config: Config,
2042
+ config: SyncConfig,
2037
2043
  setConfigId: (id: string) => void,
2038
2044
  setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void,
2039
2045
  workspace: Workspace,
@@ -2089,7 +2095,7 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2089
2095
  try {
2090
2096
  let workspace: Workspace | undefined = ii.ws.find((w) => w.id === workspaceId);
2091
2097
  if (workspace != null) {
2092
- // clear Config associations as we are about to reset
2098
+ // clear SyncConfig associations as we are about to reset
2093
2099
  workspace.associatedConfigs.length = 0;
2094
2100
  // GET configs associated with this workspace
2095
2101
  let result: APIResult = await configsGet(instance, authorizedUser, workspace.id, debug);
@@ -2097,7 +2103,7 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2097
2103
  // process returned workspace components
2098
2104
  let configSelectedId: string = "";
2099
2105
  for (let cid of workspace.associatedConfigs) {
2100
- let config = ii.cs.find((c: Config) => c.id === cid);
2106
+ let config = ii.cs.find((c: SyncConfig) => c.id === cid);
2101
2107
  if (config != null && config.sel) {
2102
2108
  configSelectedId = config.id;
2103
2109
  }
@@ -2116,7 +2122,7 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2116
2122
  result.status = 500;
2117
2123
  return result;
2118
2124
  }
2119
- export async function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): Promise<APIResult> {
2125
+ export async function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: SyncConfig, workspaceId: string, debug: boolean): Promise<APIResult> {
2120
2126
  return configDelete(instance, authorizedUser, config, workspaceId, debug);
2121
2127
  }
2122
2128
  export async function initGet(instance: IPublicClientApplication, user: User, ii: InitInfo, tasks: TaskArray, debug: boolean): Promise<APIResult> {
@@ -2175,7 +2181,7 @@ export async function workspaceEdit(instance: IPublicClientApplication, authoriz
2175
2181
  {
2176
2182
  return await workspacePut(instance, authorizedUser, workspaceId, workspaceName);
2177
2183
  }
2178
- // retrieve Workspace(s), User(s), Tenant(s), Config(s) given newly logged in user
2184
+ // retrieve Workspace(s), User(s), Tenant(s), SyncConfig(s) given newly logged in user
2179
2185
  function processReturnedAdmins(workspace: Workspace, ii: InitInfo, returnedAdmins: Array<Object>, adminSelectedId: string) {
2180
2186
  returnedAdmins.map((item: any) => {
2181
2187
  // are we already tracking this user?
@@ -2213,7 +2219,7 @@ function processReturnedAdmins(workspace: Workspace, ii: InitInfo, returnedAdmin
2213
2219
  // *try* to set authority/companyName/companyDomain from tenant returned in previous call processReturnedTenants (it may not be there)
2214
2220
  // ASSUMPTION: in terms of setting authority, user either comes from
2215
2221
  // 1. .NET session, in which case user has an authority from the token
2216
- // 2. Config API, in which case either
2222
+ // 2. SyncConfig API, in which case either
2217
2223
  // a. associated tenant with authority exists for this user (i.e. workspace owner has called POST init/configuration and created Admin and Tenant at same time)
2218
2224
  // b. user has never logged in (i.e. workspace owner has invited an incomplete admin to the workspace and there is no corresponding tenant)
2219
2225
  // i. this means that we *may* not have an authority stored for this user
@@ -2278,7 +2284,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2278
2284
  // process returned configs
2279
2285
  returnedConfigs.map((item: any) => {
2280
2286
  // are we already tracking this config?
2281
- let config: Config | null | undefined = null;
2287
+ let config: SyncConfig | null | undefined = null;
2282
2288
  let csIndex = ii.cs.findIndex((c) => c.id === item.id);
2283
2289
  if (csIndex === -1) {
2284
2290
  // start tracking
@@ -2286,7 +2292,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2286
2292
  if (dummyIndex !== -1) {
2287
2293
  // clear and overwrite dummy
2288
2294
  config = ii.cs.at(dummyIndex);
2289
- // replace dummy Config id "1" with real id in associatedConfigs of this workspace
2295
+ // replace dummy SyncConfig id "1" with real id in associatedConfigs of this workspace
2290
2296
  let idx: number = workspace.associatedConfigs.findIndex((id: string) => id == "1");
2291
2297
  if (idx !== -1) {
2292
2298
  workspace.associatedConfigs.splice(idx, 1);
@@ -2294,7 +2300,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2294
2300
  }
2295
2301
  } else {
2296
2302
  // create and track new workspace
2297
- config = new Config();
2303
+ config = new SyncConfig();
2298
2304
  ii.cs.push(config);
2299
2305
  }
2300
2306
  } else {
@@ -2375,7 +2381,7 @@ async function workspaceInfoGet(instance: IPublicClientApplication, user: User,
2375
2381
  }
2376
2382
  let configSelectedId: string = "";
2377
2383
  for (let cid of workspace!.associatedConfigs) {
2378
- let config = ii.cs.find((c: Config) => c.id === cid);
2384
+ let config = ii.cs.find((c: SyncConfig) => c.id === cid);
2379
2385
  if (config != null && config.sel) {
2380
2386
  configSelectedId = config.id;
2381
2387
  }
@@ -2592,7 +2598,7 @@ async function readResources(instance: IPublicClientApplication, user: User): Pr
2592
2598
  }
2593
2599
  return resources;
2594
2600
  }
2595
- // ======================= HYBRIDSPA.TS -- Mindline Config API helper functions ===============================
2601
+ // ======================= HYBRIDSPA.TS -- Mindline SyncConfig API helper functions ===============================
2596
2602
  function getAPIScope(user: User): string {
2597
2603
  let apiAppID: string = "8d95d21c-c378-4bb0-9f52-88c30d271e7a";
2598
2604
  let authority: string = user.authority.toLowerCase();
@@ -2663,7 +2669,7 @@ export async function processErrors(response: Response): Promise<string> {
2663
2669
  if (errorString != "") return errorString;
2664
2670
  }
2665
2671
  let data = await response.json();
2666
- // process errors from Mindline Config API
2672
+ // process errors from Mindline SyncConfig API
2667
2673
  if (data.error !== undefined) {
2668
2674
  errorString = `Error: ${data.error} Message: ${data.message}`;
2669
2675
  } else if (data.errors !== undefined) {
@@ -3046,7 +3052,7 @@ export async function configConsentWritePut(instance: IPublicClientApplication,
3046
3052
  export async function configDelete(
3047
3053
  instance: IPublicClientApplication,
3048
3054
  authorizedUser: User,
3049
- config: Config,
3055
+ config: SyncConfig,
3050
3056
  workspaceId: string,
3051
3057
  debug: boolean
3052
3058
  ): Promise<APIResult> {
@@ -3142,7 +3148,7 @@ export async function configPatch(
3142
3148
  export async function configPost(
3143
3149
  instance: IPublicClientApplication,
3144
3150
  authorizedUser: User,
3145
- config: Config,
3151
+ config: SyncConfig,
3146
3152
  workspaceId: string,
3147
3153
  debug: boolean
3148
3154
  ): Promise<APIResult> {
@@ -3219,7 +3225,7 @@ export async function configPost(
3219
3225
  export async function configPut(
3220
3226
  instance: IPublicClientApplication,
3221
3227
  authorizedUser: User,
3222
- config: Config,
3228
+ config: SyncConfig,
3223
3229
  debug: boolean
3224
3230
  ): Promise<APIResult> {
3225
3231
  let result: APIResult = new APIResult();
@@ -3675,7 +3681,7 @@ export async function workspacesGet(
3675
3681
  export async function readerPost(
3676
3682
  instance: IPublicClientApplication,
3677
3683
  authorizedUser: User,
3678
- config: Config
3684
+ config: SyncConfig
3679
3685
  ): Promise<APIResult> {
3680
3686
  let result: APIResult = new APIResult();
3681
3687
  if (instance == null || authorizedUser == null) {