@mindline/sync 1.0.100 → 1.0.102

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.100",
3
+ "version": "1.0.102",
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
@@ -148,6 +148,21 @@ declare module "@mindline/sync" {
148
148
  sel: boolean; // selection state
149
149
  constructor();
150
150
  }
151
+ export class AuditConfig {
152
+ id: string;
153
+ workspaceId: string;
154
+ name: string;
155
+ description: string;
156
+ isEnabled: boolean;
157
+ isReadPermissionConsented: boolean;
158
+ email: string;
159
+ tenantId: string;
160
+ sel: boolean; // selection state
161
+ constructor();
162
+ }
163
+
164
+ export type ConfigType = 'sync' | 'auditlogs';
165
+
151
166
  // class to group Users, Tenants, and Configs
152
167
  export class Workspace {
153
168
  id: string;
@@ -165,6 +180,7 @@ declare module "@mindline/sync" {
165
180
  us: User[];
166
181
  ts: Tenant[];
167
182
  cs: Config[];
183
+ acs: AuditConfig[];
168
184
  ws: Workspace[];
169
185
  configlevelconsent_configid: string;
170
186
  configlevelconsent_access: TenantConfigType;
@@ -320,6 +336,8 @@ declare module "@mindline/sync" {
320
336
  export function userDelegatedScopesRemove(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant, scope: string): boolean;
321
337
  export function usersGet(instance: IPublicClientApplication, user: User | undefined): { users: string[], error: string };
322
338
  // ======================= Mindline Config API ===============================
339
+ export function auditConfigAdd(instance: IPublicClientApplication, user: User, ac: AuditConfig, debug: boolean): Promise<APIResult>;
340
+ export function auditConfigRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult>;
323
341
  export function auditEventsRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult>;
324
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;
325
343
  export function configEnable(instance: IPublicClientApplication, authorizedUser: User, configurationId: string, enabled: boolean, debug: boolean): APIResult;
package/src/index.ts CHANGED
@@ -50,6 +50,9 @@ export class mindlineConfig {
50
50
  static adminsEndpoint(): string {
51
51
  return `https://${mindlineConfig.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/admins`;
52
52
  };
53
+ static auditConfigEndpoint(): string {
54
+ return `https://${mindlineConfig.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-configuration`;
55
+ }
53
56
  static auditEventsEndpoint(): string {
54
57
  return `https://${mindlineConfig.environmentTag}-configurationapi-westus.azurewebsites.net/api/v1/audit-events`;
55
58
  };
@@ -164,6 +167,7 @@ export class User {
164
167
  this.loggingIn = false;
165
168
  }
166
169
  }
170
+
167
171
  export enum TenantType {
168
172
  invalid = 0,
169
173
  aad = 1,
@@ -279,6 +283,26 @@ export class Config {
279
283
  this.sel = false;
280
284
  }
281
285
  }
286
+ export class AuditConfig {
287
+ id: string;
288
+ workspaceId: string;
289
+ name: string;
290
+ description: string;
291
+ isEnabled: boolean;
292
+ email: string;
293
+ tenantId: string;
294
+ sel: boolean; // selection state
295
+ constructor() {
296
+ this.id = "";
297
+ this.name = "";
298
+ this.workspaceId = "";
299
+ this.description = "";
300
+ this.isEnabled = false;
301
+ this.email = "";
302
+ this.tenantId = "";
303
+ this.sel = false;
304
+ }
305
+ }
282
306
  export class Workspace {
283
307
  id: string;
284
308
  name: string;
@@ -1997,6 +2021,12 @@ export async function usersGet(instance: IPublicClientApplication, user: User |
1997
2021
  }
1998
2022
  }
1999
2023
  // ======================= Mindline Config API ===============================
2024
+ export async function auditConfigAdd(instance: IPublicClientApplication, user: User, ac: AuditConfig, debug: boolean): Promise<APIResult> {
2025
+ return auditConfigPost(instance, user, ac, debug);
2026
+ }
2027
+ export async function auditConfigRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult> {
2028
+ return auditConfigGet(instance, user, debug);
2029
+ }
2000
2030
  export async function auditEventsRetrieve(instance: IPublicClientApplication, authorizedUser: User, debug: boolean): Promise<APIResult> {
2001
2031
  return auditEventsGet(instance, authorizedUser, debug);
2002
2032
  }
@@ -2805,6 +2835,77 @@ export async function adminPost(
2805
2835
  }
2806
2836
  return result;
2807
2837
  }
2838
+ //auditConfigPost: write audit config to back end
2839
+ export async function auditConfigPost(
2840
+ instance: IPublicClientApplication,
2841
+ user: User,
2842
+ config: AuditConfig,
2843
+ debug: boolean
2844
+ ): Promise<APIResult> {
2845
+ instance = instance;
2846
+ user = user;
2847
+ debug = debug;
2848
+ let result: APIResult = new APIResult();
2849
+ if (config.id === "") {
2850
+ result.result = false;
2851
+ result.error = "auditConfigPost: invalid config ID";
2852
+ result.status = 500;
2853
+ return result;
2854
+ }
2855
+ // create no parameter audit config post endpoint
2856
+ let endpoint: string = mindlineConfig.auditConfigEndpoint();
2857
+ // create config headers
2858
+ const headers = await mindlineDefineHeaders(instance, user);
2859
+ // create config body
2860
+ let configBody: string = `
2861
+ {
2862
+ "workspaceId": "${config.workspaceId}",
2863
+ "name": "${config.name}",
2864
+ "description": "${config.description}",
2865
+ "isEnabled": ${config.isEnabled},
2866
+ "email": "${config.email}",
2867
+ "tenantId": "${config.tenantId}"
2868
+ }`;
2869
+ let options = { method: "POST", headers: headers, body: configBody };
2870
+ // make config endpoint call
2871
+ try {
2872
+ if (debug) debugger;
2873
+ console.log("Attempting POST to /audit-configuration: " + endpoint);
2874
+ let response = await fetch(endpoint, options);
2875
+ if (response.status === 200 && response.statusText === "OK") {
2876
+ let data = await response.json();
2877
+ config.id = data;
2878
+ console.log(
2879
+ `Successful AuditConfigID: ${data} from POST to /audit-configuration: ${configBody}`
2880
+ );
2881
+ return result;
2882
+ }
2883
+ else {
2884
+ result.error = await processErrors(response);
2885
+ console.log(`Failed POST to /audit-configuration: ${configBody}`);
2886
+ console.log(result.error);
2887
+ result.status = 500;
2888
+ result.result = false;
2889
+ return result;
2890
+ }
2891
+ }
2892
+ catch (error: any) {
2893
+ result.status = 500;
2894
+ result.result = false;
2895
+ result.error = error.message;
2896
+ console.log(result.error);
2897
+ return result;
2898
+ }
2899
+ return result;
2900
+ }
2901
+ //auditConfigPost: get audit config from back end
2902
+ export async function auditConfigGet(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult> {
2903
+ instance = instance;
2904
+ user = user;
2905
+ debug = debug;
2906
+ let result: APIResult = new APIResult();
2907
+ return result;
2908
+ }
2808
2909
  export async function auditEventsGet(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult> {
2809
2910
  let result: APIResult = new APIResult();
2810
2911
  // we need a valid user