@mindline/sync 1.0.101 → 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.101",
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;
@@ -154,11 +154,15 @@ declare module "@mindline/sync" {
154
154
  name: string;
155
155
  description: string;
156
156
  isEnabled: boolean;
157
+ isReadPermissionConsented: boolean;
157
158
  email: string;
158
159
  tenantId: string;
159
160
  sel: boolean; // selection state
160
161
  constructor();
161
162
  }
163
+
164
+ export type ConfigType = 'sync' | 'auditlogs';
165
+
162
166
  // class to group Users, Tenants, and Configs
163
167
  export class Workspace {
164
168
  id: string;
@@ -175,7 +179,8 @@ declare module "@mindline/sync" {
175
179
  tab: number;
176
180
  us: User[];
177
181
  ts: Tenant[];
178
- cs: Config[];
182
+ cs: SyncConfig[];
183
+ acs: AuditConfig[];
179
184
  ws: Workspace[];
180
185
  configlevelconsent_configid: string;
181
186
  configlevelconsent_access: TenantConfigType;
@@ -252,13 +257,13 @@ declare module "@mindline/sync" {
252
257
  pb_total: number;
253
258
  pb_timer: NodeJS.Timer;
254
259
  milestoneArray: MilestoneArray;
255
- constructor(config: Config|null, syncPortalGlobalState: InitInfo|null, bClearLocalStorage: boolean);
260
+ constructor(config: SyncConfig|null, syncPortalGlobalState: InitInfo|null, bClearLocalStorage: boolean);
256
261
  // populate tenantNodes based on config tenants
257
- init(config: Config|null|undefined, syncPortalGlobalState: InitInfo|null, bClearLocalStorage: boolean): void;
262
+ init(config: SyncConfig|null|undefined, syncPortalGlobalState: InitInfo|null, bClearLocalStorage: boolean): void;
258
263
  initializeProgressBar(setSyncProgress: (progress: number) => void, setConfigSyncResult: (result: string) => void, setIdleText: (idleText: string) => void, setMilestones: (milestones: Milestone[]) => void): void;
259
264
  uninitializeProgressBar(setSyncProgress: (progress: number) => void, setConfigSyncResult: (result: string) => void, setIdleText: (idleText: string) => void, setMilestones: (milestones: Milestone[]) => void): void;
260
265
  initializeSignalR(
261
- config: Config | null | undefined,
266
+ config: SyncConfig | null | undefined,
262
267
  syncPortalGlobalState: InitInfo | null,
263
268
  batchIdArray: Array<Object>,
264
269
  setRefreshDeltaTrigger: (workspace: string) => void,
@@ -269,7 +274,7 @@ declare module "@mindline/sync" {
269
274
  setMilestones: (milestones: Milestone[]) => void,
270
275
  setConfigSyncResult: (result: string) => void,
271
276
  bClearLocalStorage: boolean): void;
272
- 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;
273
278
  }
274
279
  export class TenantNode {
275
280
  expanded: boolean;
@@ -330,16 +335,16 @@ declare module "@mindline/sync" {
330
335
  export function userDelegatedScopesGet(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant): { scopes: string, id: string, error: string };
331
336
  export function userDelegatedScopesRemove(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant, scope: string): boolean;
332
337
  export function usersGet(instance: IPublicClientApplication, user: User | undefined): { users: string[], error: string };
333
- // ======================= Mindline Config API ===============================
338
+ // ======================= Mindline SyncConfig API ===============================
334
339
  export function auditConfigAdd(instance: IPublicClientApplication, user: User, ac: AuditConfig, debug: boolean): Promise<APIResult>;
335
340
  export function auditConfigRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult>;
336
341
  export function auditEventsRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult>;
337
- 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;
338
343
  export function configEnable(instance: IPublicClientApplication, authorizedUser: User, configurationId: string, enabled: boolean, debug: boolean): APIResult;
339
344
  export function configConsentForRead(instance: IPublicClientApplication, authorizedUser: User, configId: string, tid: string, consent: boolean): Promise<APIResult>;
340
345
  export function configConsentForWrite(instance: IPublicClientApplication, authorizedUser: User, configId: string, tid: string, consent: boolean): Promise<APIResult>;
341
346
  export function configsRefresh(instance: IPublicClientApplication, authorizedUser: User, workspaceId: string, ii: InitInfo, debug: boolean): APIResult;
342
- 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;
343
348
  export function initGet(instance: IPublicClientApplication, user: User, ii: InitInfo, tasks: TaskArray, debug: boolean): APIResult;
344
349
  export function tenantAdd(instance: IPublicClientApplication, authorizedUser: User, tenant: Tenant, workspaceId: string): APIResult;
345
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"
@@ -167,6 +167,7 @@ export class User {
167
167
  this.loggingIn = false;
168
168
  }
169
169
  }
170
+
170
171
  export enum TenantType {
171
172
  invalid = 0,
172
173
  aad = 1,
@@ -262,7 +263,7 @@ export class TenantConfigInfo {
262
263
  this.isWritePermissionConsented = false;
263
264
  }
264
265
  }
265
- export class Config {
266
+ export class SyncConfig {
266
267
  id: string;
267
268
  workspaceId: string;
268
269
  name: string;
@@ -302,6 +303,9 @@ export class AuditConfig {
302
303
  this.sel = false;
303
304
  }
304
305
  }
306
+
307
+ export type ConfigType = 'sync' | 'auditlogs';
308
+
305
309
  export class Workspace {
306
310
  id: string;
307
311
  name: string;
@@ -352,7 +356,8 @@ export class InitInfo {
352
356
  tab: number = 0;
353
357
  us: User[] = [];
354
358
  ts: Tenant[] = [];
355
- cs: Config[] = [];
359
+ cs: SyncConfig[] = [];
360
+ acs: AuditConfig[] = [];
356
361
  ws: Workspace[] = [];
357
362
  configlevelconsent_configid: string = "";
358
363
  configlevelconsent_access: TenantConfigType = TenantConfigType.sourcetarget;
@@ -391,7 +396,7 @@ export class InitInfo {
391
396
  try {
392
397
  this.us = deserializeArray(User, usersString);
393
398
  this.ts = deserializeArray(Tenant, tenantsString);
394
- this.cs = deserializeArray(Config, configsString);
399
+ this.cs = deserializeArray(SyncConfig, configsString);
395
400
  this.ws = deserializeArray(Workspace, workspacesString);
396
401
  this.tagWithWorkspaces();
397
402
  } catch (e) {
@@ -498,11 +503,11 @@ export class InitInfo {
498
503
  });
499
504
  }
500
505
  if (typeof ii.cs === "undefined") {
501
- this.cs = new Array<Config>();
506
+ this.cs = new Array<SyncConfig>();
502
507
  }
503
508
  else {
504
- this.cs = ii.cs.map((config: Config) => {
505
- let newconfig: Config = new Config();
509
+ this.cs = ii.cs.map((config: SyncConfig) => {
510
+ let newconfig: SyncConfig = new SyncConfig();
506
511
  newconfig.id = config.id;
507
512
  newconfig.workspaceId = config.workspaceId;
508
513
  newconfig.name = config.name;
@@ -720,7 +725,7 @@ export class Task {
720
725
  this.startDisplay = `${this.start.getMinutes().toString().padStart(2, "0")}:${this.start.getSeconds().toString().padStart(2, "0")}`;
721
726
  };
722
727
  }
723
- // 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
724
729
  export class Milestone {
725
730
  Run: number = 0;
726
731
  Start: Date = new Date();
@@ -912,7 +917,7 @@ export class BatchArray {
912
917
  pb_timer: NodeJS.Timeout | null;
913
918
  milestoneArray: MilestoneArray;
914
919
  constructor(
915
- config: Config | null,
920
+ config: SyncConfig | null,
916
921
  syncPortalGlobalState: InitInfo | null,
917
922
  bClearLocalStorage: boolean
918
923
  ) {
@@ -929,7 +934,7 @@ export class BatchArray {
929
934
  }
930
935
  // populate tenantNodes based on config tenants
931
936
  init(
932
- config: Config | null | undefined,
937
+ config: SyncConfig | null | undefined,
933
938
  syncPortalGlobalState: InitInfo | null,
934
939
  bClearLocalStorage: boolean
935
940
  ): void {
@@ -943,7 +948,7 @@ export class BatchArray {
943
948
  this.milestoneArray.init(bClearLocalStorage);
944
949
  }
945
950
  }
946
- // create BatchArray if passed Config and InitInfo
951
+ // create BatchArray if passed SyncConfig and InitInfo
947
952
  if (config != null &&
948
953
  config.tenants != null &&
949
954
  syncPortalGlobalState != null) {
@@ -1059,7 +1064,7 @@ export class BatchArray {
1059
1064
  this.milestoneArray.unstart(setMilestones);
1060
1065
  }
1061
1066
  initializeSignalR(
1062
- config: Config | null | undefined,
1067
+ config: SyncConfig | null | undefined,
1063
1068
  syncPortalGlobalState: InitInfo | null,
1064
1069
  batchIdArray: Array<Object>,
1065
1070
  setRefreshDeltaTrigger: (workspace: string) => void,
@@ -1274,7 +1279,7 @@ export class BatchArray {
1274
1279
  });
1275
1280
  }
1276
1281
  // start a sync cycle
1277
- 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>
1278
1283
  {
1279
1284
  let result: APIResult = new APIResult();
1280
1285
  if (this.tenantNodes == null || this.tenantNodes.length == 0) {
@@ -2019,7 +2024,7 @@ export async function usersGet(instance: IPublicClientApplication, user: User |
2019
2024
  return { users: [], error: `Exception: ${error}` };
2020
2025
  }
2021
2026
  }
2022
- // ======================= Mindline Config API ===============================
2027
+ // ======================= Mindline SyncConfig API ===============================
2023
2028
  export async function auditConfigAdd(instance: IPublicClientApplication, user: User, ac: AuditConfig, debug: boolean): Promise<APIResult> {
2024
2029
  return auditConfigPost(instance, user, ac, debug);
2025
2030
  }
@@ -2032,7 +2037,7 @@ export async function auditEventsRetrieve(instance: IPublicClientApplication, au
2032
2037
  export async function configEdit(
2033
2038
  instance: IPublicClientApplication,
2034
2039
  authorizedUser: User,
2035
- config: Config,
2040
+ config: SyncConfig,
2036
2041
  setConfigId: (id: string) => void,
2037
2042
  setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void,
2038
2043
  workspace: Workspace,
@@ -2088,7 +2093,7 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2088
2093
  try {
2089
2094
  let workspace: Workspace | undefined = ii.ws.find((w) => w.id === workspaceId);
2090
2095
  if (workspace != null) {
2091
- // clear Config associations as we are about to reset
2096
+ // clear SyncConfig associations as we are about to reset
2092
2097
  workspace.associatedConfigs.length = 0;
2093
2098
  // GET configs associated with this workspace
2094
2099
  let result: APIResult = await configsGet(instance, authorizedUser, workspace.id, debug);
@@ -2096,7 +2101,7 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2096
2101
  // process returned workspace components
2097
2102
  let configSelectedId: string = "";
2098
2103
  for (let cid of workspace.associatedConfigs) {
2099
- let config = ii.cs.find((c: Config) => c.id === cid);
2104
+ let config = ii.cs.find((c: SyncConfig) => c.id === cid);
2100
2105
  if (config != null && config.sel) {
2101
2106
  configSelectedId = config.id;
2102
2107
  }
@@ -2115,7 +2120,7 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2115
2120
  result.status = 500;
2116
2121
  return result;
2117
2122
  }
2118
- 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> {
2119
2124
  return configDelete(instance, authorizedUser, config, workspaceId, debug);
2120
2125
  }
2121
2126
  export async function initGet(instance: IPublicClientApplication, user: User, ii: InitInfo, tasks: TaskArray, debug: boolean): Promise<APIResult> {
@@ -2174,7 +2179,7 @@ export async function workspaceEdit(instance: IPublicClientApplication, authoriz
2174
2179
  {
2175
2180
  return await workspacePut(instance, authorizedUser, workspaceId, workspaceName);
2176
2181
  }
2177
- // 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
2178
2183
  function processReturnedAdmins(workspace: Workspace, ii: InitInfo, returnedAdmins: Array<Object>, adminSelectedId: string) {
2179
2184
  returnedAdmins.map((item: any) => {
2180
2185
  // are we already tracking this user?
@@ -2212,7 +2217,7 @@ function processReturnedAdmins(workspace: Workspace, ii: InitInfo, returnedAdmin
2212
2217
  // *try* to set authority/companyName/companyDomain from tenant returned in previous call processReturnedTenants (it may not be there)
2213
2218
  // ASSUMPTION: in terms of setting authority, user either comes from
2214
2219
  // 1. .NET session, in which case user has an authority from the token
2215
- // 2. Config API, in which case either
2220
+ // 2. SyncConfig API, in which case either
2216
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)
2217
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)
2218
2223
  // i. this means that we *may* not have an authority stored for this user
@@ -2277,7 +2282,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2277
2282
  // process returned configs
2278
2283
  returnedConfigs.map((item: any) => {
2279
2284
  // are we already tracking this config?
2280
- let config: Config | null | undefined = null;
2285
+ let config: SyncConfig | null | undefined = null;
2281
2286
  let csIndex = ii.cs.findIndex((c) => c.id === item.id);
2282
2287
  if (csIndex === -1) {
2283
2288
  // start tracking
@@ -2285,7 +2290,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2285
2290
  if (dummyIndex !== -1) {
2286
2291
  // clear and overwrite dummy
2287
2292
  config = ii.cs.at(dummyIndex);
2288
- // 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
2289
2294
  let idx: number = workspace.associatedConfigs.findIndex((id: string) => id == "1");
2290
2295
  if (idx !== -1) {
2291
2296
  workspace.associatedConfigs.splice(idx, 1);
@@ -2293,7 +2298,7 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2293
2298
  }
2294
2299
  } else {
2295
2300
  // create and track new workspace
2296
- config = new Config();
2301
+ config = new SyncConfig();
2297
2302
  ii.cs.push(config);
2298
2303
  }
2299
2304
  } else {
@@ -2374,7 +2379,7 @@ async function workspaceInfoGet(instance: IPublicClientApplication, user: User,
2374
2379
  }
2375
2380
  let configSelectedId: string = "";
2376
2381
  for (let cid of workspace!.associatedConfigs) {
2377
- let config = ii.cs.find((c: Config) => c.id === cid);
2382
+ let config = ii.cs.find((c: SyncConfig) => c.id === cid);
2378
2383
  if (config != null && config.sel) {
2379
2384
  configSelectedId = config.id;
2380
2385
  }
@@ -2591,7 +2596,7 @@ async function readResources(instance: IPublicClientApplication, user: User): Pr
2591
2596
  }
2592
2597
  return resources;
2593
2598
  }
2594
- // ======================= HYBRIDSPA.TS -- Mindline Config API helper functions ===============================
2599
+ // ======================= HYBRIDSPA.TS -- Mindline SyncConfig API helper functions ===============================
2595
2600
  function getAPIScope(user: User): string {
2596
2601
  let apiAppID: string = "8d95d21c-c378-4bb0-9f52-88c30d271e7a";
2597
2602
  let authority: string = user.authority.toLowerCase();
@@ -2662,7 +2667,7 @@ export async function processErrors(response: Response): Promise<string> {
2662
2667
  if (errorString != "") return errorString;
2663
2668
  }
2664
2669
  let data = await response.json();
2665
- // process errors from Mindline Config API
2670
+ // process errors from Mindline SyncConfig API
2666
2671
  if (data.error !== undefined) {
2667
2672
  errorString = `Error: ${data.error} Message: ${data.message}`;
2668
2673
  } else if (data.errors !== undefined) {
@@ -3045,7 +3050,7 @@ export async function configConsentWritePut(instance: IPublicClientApplication,
3045
3050
  export async function configDelete(
3046
3051
  instance: IPublicClientApplication,
3047
3052
  authorizedUser: User,
3048
- config: Config,
3053
+ config: SyncConfig,
3049
3054
  workspaceId: string,
3050
3055
  debug: boolean
3051
3056
  ): Promise<APIResult> {
@@ -3141,7 +3146,7 @@ export async function configPatch(
3141
3146
  export async function configPost(
3142
3147
  instance: IPublicClientApplication,
3143
3148
  authorizedUser: User,
3144
- config: Config,
3149
+ config: SyncConfig,
3145
3150
  workspaceId: string,
3146
3151
  debug: boolean
3147
3152
  ): Promise<APIResult> {
@@ -3218,7 +3223,7 @@ export async function configPost(
3218
3223
  export async function configPut(
3219
3224
  instance: IPublicClientApplication,
3220
3225
  authorizedUser: User,
3221
- config: Config,
3226
+ config: SyncConfig,
3222
3227
  debug: boolean
3223
3228
  ): Promise<APIResult> {
3224
3229
  let result: APIResult = new APIResult();
@@ -3674,7 +3679,7 @@ export async function workspacesGet(
3674
3679
  export async function readerPost(
3675
3680
  instance: IPublicClientApplication,
3676
3681
  authorizedUser: User,
3677
- config: Config
3682
+ config: SyncConfig
3678
3683
  ): Promise<APIResult> {
3679
3684
  let result: APIResult = new APIResult();
3680
3685
  if (instance == null || authorizedUser == null) {