@mindline/sync 1.0.102 → 1.0.103

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.103",
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;
@@ -303,6 +303,9 @@ export class AuditConfig {
303
303
  this.sel = false;
304
304
  }
305
305
  }
306
+
307
+ export type ConfigType = 'sync' | 'auditlogs';
308
+
306
309
  export class Workspace {
307
310
  id: string;
308
311
  name: string;
@@ -353,7 +356,8 @@ export class InitInfo {
353
356
  tab: number = 0;
354
357
  us: User[] = [];
355
358
  ts: Tenant[] = [];
356
- cs: Config[] = [];
359
+ cs: SyncConfig[] = [];
360
+ acs: AuditConfig[] = [];
357
361
  ws: Workspace[] = [];
358
362
  configlevelconsent_configid: string = "";
359
363
  configlevelconsent_access: TenantConfigType = TenantConfigType.sourcetarget;
@@ -392,7 +396,7 @@ export class InitInfo {
392
396
  try {
393
397
  this.us = deserializeArray(User, usersString);
394
398
  this.ts = deserializeArray(Tenant, tenantsString);
395
- this.cs = deserializeArray(Config, configsString);
399
+ this.cs = deserializeArray(SyncConfig, configsString);
396
400
  this.ws = deserializeArray(Workspace, workspacesString);
397
401
  this.tagWithWorkspaces();
398
402
  } catch (e) {
@@ -499,11 +503,11 @@ export class InitInfo {
499
503
  });
500
504
  }
501
505
  if (typeof ii.cs === "undefined") {
502
- this.cs = new Array<Config>();
506
+ this.cs = new Array<SyncConfig>();
503
507
  }
504
508
  else {
505
- this.cs = ii.cs.map((config: Config) => {
506
- let newconfig: Config = new Config();
509
+ this.cs = ii.cs.map((config: SyncConfig) => {
510
+ let newconfig: SyncConfig = new SyncConfig();
507
511
  newconfig.id = config.id;
508
512
  newconfig.workspaceId = config.workspaceId;
509
513
  newconfig.name = config.name;
@@ -721,7 +725,7 @@ export class Task {
721
725
  this.startDisplay = `${this.start.getMinutes().toString().padStart(2, "0")}:${this.start.getSeconds().toString().padStart(2, "0")}`;
722
726
  };
723
727
  }
724
- // class corresponding to an execution of a Config - a *TenantNode* for each source tenant, each with a *TenantNode* array of target tenants
728
+ // class corresponding to an execution of a SyncConfig - a *TenantNode* for each source tenant, each with a *TenantNode* array of target tenants
725
729
  export class Milestone {
726
730
  Run: number = 0;
727
731
  Start: Date = new Date();
@@ -913,7 +917,7 @@ export class BatchArray {
913
917
  pb_timer: NodeJS.Timeout | null;
914
918
  milestoneArray: MilestoneArray;
915
919
  constructor(
916
- config: Config | null,
920
+ config: SyncConfig | null,
917
921
  syncPortalGlobalState: InitInfo | null,
918
922
  bClearLocalStorage: boolean
919
923
  ) {
@@ -930,7 +934,7 @@ export class BatchArray {
930
934
  }
931
935
  // populate tenantNodes based on config tenants
932
936
  init(
933
- config: Config | null | undefined,
937
+ config: SyncConfig | null | undefined,
934
938
  syncPortalGlobalState: InitInfo | null,
935
939
  bClearLocalStorage: boolean
936
940
  ): void {
@@ -944,7 +948,7 @@ export class BatchArray {
944
948
  this.milestoneArray.init(bClearLocalStorage);
945
949
  }
946
950
  }
947
- // create BatchArray if passed Config and InitInfo
951
+ // create BatchArray if passed SyncConfig and InitInfo
948
952
  if (config != null &&
949
953
  config.tenants != null &&
950
954
  syncPortalGlobalState != null) {
@@ -1060,7 +1064,7 @@ export class BatchArray {
1060
1064
  this.milestoneArray.unstart(setMilestones);
1061
1065
  }
1062
1066
  initializeSignalR(
1063
- config: Config | null | undefined,
1067
+ config: SyncConfig | null | undefined,
1064
1068
  syncPortalGlobalState: InitInfo | null,
1065
1069
  batchIdArray: Array<Object>,
1066
1070
  setRefreshDeltaTrigger: (workspace: string) => void,
@@ -1275,7 +1279,7 @@ export class BatchArray {
1275
1279
  });
1276
1280
  }
1277
1281
  // start a sync cycle
1278
- async startSync(instance: IPublicClientApplication, authorizedUser: User | null | undefined, config: Config | null | undefined): Promise<APIResult>
1282
+ async startSync(instance: IPublicClientApplication, authorizedUser: User | null | undefined, config: SyncConfig | null | undefined): Promise<APIResult>
1279
1283
  {
1280
1284
  let result: APIResult = new APIResult();
1281
1285
  if (this.tenantNodes == null || this.tenantNodes.length == 0) {
@@ -2020,7 +2024,7 @@ export async function usersGet(instance: IPublicClientApplication, user: User |
2020
2024
  return { users: [], error: `Exception: ${error}` };
2021
2025
  }
2022
2026
  }
2023
- // ======================= Mindline Config API ===============================
2027
+ // ======================= Mindline SyncConfig API ===============================
2024
2028
  export async function auditConfigAdd(instance: IPublicClientApplication, user: User, ac: AuditConfig, debug: boolean): Promise<APIResult> {
2025
2029
  return auditConfigPost(instance, user, ac, debug);
2026
2030
  }
@@ -2033,7 +2037,7 @@ export async function auditEventsRetrieve(instance: IPublicClientApplication, au
2033
2037
  export async function configEdit(
2034
2038
  instance: IPublicClientApplication,
2035
2039
  authorizedUser: User,
2036
- config: Config,
2040
+ config: SyncConfig,
2037
2041
  setConfigId: (id: string) => void,
2038
2042
  setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void,
2039
2043
  workspace: Workspace,
@@ -2089,7 +2093,7 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2089
2093
  try {
2090
2094
  let workspace: Workspace | undefined = ii.ws.find((w) => w.id === workspaceId);
2091
2095
  if (workspace != null) {
2092
- // clear Config associations as we are about to reset
2096
+ // clear SyncConfig associations as we are about to reset
2093
2097
  workspace.associatedConfigs.length = 0;
2094
2098
  // GET configs associated with this workspace
2095
2099
  let result: APIResult = await configsGet(instance, authorizedUser, workspace.id, debug);
@@ -2097,7 +2101,7 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2097
2101
  // process returned workspace components
2098
2102
  let configSelectedId: string = "";
2099
2103
  for (let cid of workspace.associatedConfigs) {
2100
- let config = ii.cs.find((c: Config) => c.id === cid);
2104
+ let config = ii.cs.find((c: SyncConfig) => c.id === cid);
2101
2105
  if (config != null && config.sel) {
2102
2106
  configSelectedId = config.id;
2103
2107
  }
@@ -2116,7 +2120,7 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2116
2120
  result.status = 500;
2117
2121
  return result;
2118
2122
  }
2119
- export async function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): Promise<APIResult> {
2123
+ export async function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: SyncConfig, workspaceId: string, debug: boolean): Promise<APIResult> {
2120
2124
  return configDelete(instance, authorizedUser, config, workspaceId, debug);
2121
2125
  }
2122
2126
  export async function initGet(instance: IPublicClientApplication, user: User, ii: InitInfo, tasks: TaskArray, debug: boolean): Promise<APIResult> {
@@ -2175,7 +2179,7 @@ export async function workspaceEdit(instance: IPublicClientApplication, authoriz
2175
2179
  {
2176
2180
  return await workspacePut(instance, authorizedUser, workspaceId, workspaceName);
2177
2181
  }
2178
- // retrieve Workspace(s), User(s), Tenant(s), Config(s) given newly logged in user
2182
+ // retrieve Workspace(s), User(s), Tenant(s), SyncConfig(s) given newly logged in user
2179
2183
  function processReturnedAdmins(workspace: Workspace, ii: InitInfo, returnedAdmins: Array<Object>, adminSelectedId: string) {
2180
2184
  returnedAdmins.map((item: any) => {
2181
2185
  // are we already tracking this user?
@@ -2213,7 +2217,7 @@ function processReturnedAdmins(workspace: Workspace, ii: InitInfo, returnedAdmin
2213
2217
  // *try* to set authority/companyName/companyDomain from tenant returned in previous call processReturnedTenants (it may not be there)
2214
2218
  // ASSUMPTION: in terms of setting authority, user either comes from
2215
2219
  // 1. .NET session, in which case user has an authority from the token
2216
- // 2. Config API, in which case either
2220
+ // 2. SyncConfig API, in which case either
2217
2221
  // 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
2222
  // 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
2223
  // i. this means that we *may* not have an authority stored for this user
@@ -2278,7 +2282,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2278
2282
  // process returned configs
2279
2283
  returnedConfigs.map((item: any) => {
2280
2284
  // are we already tracking this config?
2281
- let config: Config | null | undefined = null;
2285
+ let config: SyncConfig | null | undefined = null;
2282
2286
  let csIndex = ii.cs.findIndex((c) => c.id === item.id);
2283
2287
  if (csIndex === -1) {
2284
2288
  // start tracking
@@ -2286,7 +2290,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2286
2290
  if (dummyIndex !== -1) {
2287
2291
  // clear and overwrite dummy
2288
2292
  config = ii.cs.at(dummyIndex);
2289
- // replace dummy Config id "1" with real id in associatedConfigs of this workspace
2293
+ // replace dummy SyncConfig id "1" with real id in associatedConfigs of this workspace
2290
2294
  let idx: number = workspace.associatedConfigs.findIndex((id: string) => id == "1");
2291
2295
  if (idx !== -1) {
2292
2296
  workspace.associatedConfigs.splice(idx, 1);
@@ -2294,7 +2298,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2294
2298
  }
2295
2299
  } else {
2296
2300
  // create and track new workspace
2297
- config = new Config();
2301
+ config = new SyncConfig();
2298
2302
  ii.cs.push(config);
2299
2303
  }
2300
2304
  } else {
@@ -2375,7 +2379,7 @@ async function workspaceInfoGet(instance: IPublicClientApplication, user: User,
2375
2379
  }
2376
2380
  let configSelectedId: string = "";
2377
2381
  for (let cid of workspace!.associatedConfigs) {
2378
- let config = ii.cs.find((c: Config) => c.id === cid);
2382
+ let config = ii.cs.find((c: SyncConfig) => c.id === cid);
2379
2383
  if (config != null && config.sel) {
2380
2384
  configSelectedId = config.id;
2381
2385
  }
@@ -2592,7 +2596,7 @@ async function readResources(instance: IPublicClientApplication, user: User): Pr
2592
2596
  }
2593
2597
  return resources;
2594
2598
  }
2595
- // ======================= HYBRIDSPA.TS -- Mindline Config API helper functions ===============================
2599
+ // ======================= HYBRIDSPA.TS -- Mindline SyncConfig API helper functions ===============================
2596
2600
  function getAPIScope(user: User): string {
2597
2601
  let apiAppID: string = "8d95d21c-c378-4bb0-9f52-88c30d271e7a";
2598
2602
  let authority: string = user.authority.toLowerCase();
@@ -2663,7 +2667,7 @@ export async function processErrors(response: Response): Promise<string> {
2663
2667
  if (errorString != "") return errorString;
2664
2668
  }
2665
2669
  let data = await response.json();
2666
- // process errors from Mindline Config API
2670
+ // process errors from Mindline SyncConfig API
2667
2671
  if (data.error !== undefined) {
2668
2672
  errorString = `Error: ${data.error} Message: ${data.message}`;
2669
2673
  } else if (data.errors !== undefined) {
@@ -3046,7 +3050,7 @@ export async function configConsentWritePut(instance: IPublicClientApplication,
3046
3050
  export async function configDelete(
3047
3051
  instance: IPublicClientApplication,
3048
3052
  authorizedUser: User,
3049
- config: Config,
3053
+ config: SyncConfig,
3050
3054
  workspaceId: string,
3051
3055
  debug: boolean
3052
3056
  ): Promise<APIResult> {
@@ -3142,7 +3146,7 @@ export async function configPatch(
3142
3146
  export async function configPost(
3143
3147
  instance: IPublicClientApplication,
3144
3148
  authorizedUser: User,
3145
- config: Config,
3149
+ config: SyncConfig,
3146
3150
  workspaceId: string,
3147
3151
  debug: boolean
3148
3152
  ): Promise<APIResult> {
@@ -3219,7 +3223,7 @@ export async function configPost(
3219
3223
  export async function configPut(
3220
3224
  instance: IPublicClientApplication,
3221
3225
  authorizedUser: User,
3222
- config: Config,
3226
+ config: SyncConfig,
3223
3227
  debug: boolean
3224
3228
  ): Promise<APIResult> {
3225
3229
  let result: APIResult = new APIResult();
@@ -3675,7 +3679,7 @@ export async function workspacesGet(
3675
3679
  export async function readerPost(
3676
3680
  instance: IPublicClientApplication,
3677
3681
  authorizedUser: User,
3678
- config: Config
3682
+ config: SyncConfig
3679
3683
  ): Promise<APIResult> {
3680
3684
  let result: APIResult = new APIResult();
3681
3685
  if (instance == null || authorizedUser == null) {