@mindline/sync 1.0.100 → 1.0.101

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.101",
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,17 @@ 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
+ email: string;
158
+ tenantId: string;
159
+ sel: boolean; // selection state
160
+ constructor();
161
+ }
151
162
  // class to group Users, Tenants, and Configs
152
163
  export class Workspace {
153
164
  id: string;
@@ -320,6 +331,8 @@ declare module "@mindline/sync" {
320
331
  export function userDelegatedScopesRemove(instance: IPublicClientApplication, loggedInUser: User, tenant: Tenant, scope: string): boolean;
321
332
  export function usersGet(instance: IPublicClientApplication, user: User | undefined): { users: string[], error: string };
322
333
  // ======================= Mindline Config API ===============================
334
+ export function auditConfigAdd(instance: IPublicClientApplication, user: User, ac: AuditConfig, debug: boolean): Promise<APIResult>;
335
+ export function auditConfigRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult>;
323
336
  export function auditEventsRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult>;
324
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;
325
338
  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
  };
@@ -279,6 +282,26 @@ export class Config {
279
282
  this.sel = false;
280
283
  }
281
284
  }
285
+ export class AuditConfig {
286
+ id: string;
287
+ workspaceId: string;
288
+ name: string;
289
+ description: string;
290
+ isEnabled: boolean;
291
+ email: string;
292
+ tenantId: string;
293
+ sel: boolean; // selection state
294
+ constructor() {
295
+ this.id = "";
296
+ this.name = "";
297
+ this.workspaceId = "";
298
+ this.description = "";
299
+ this.isEnabled = false;
300
+ this.email = "";
301
+ this.tenantId = "";
302
+ this.sel = false;
303
+ }
304
+ }
282
305
  export class Workspace {
283
306
  id: string;
284
307
  name: string;
@@ -1997,6 +2020,12 @@ export async function usersGet(instance: IPublicClientApplication, user: User |
1997
2020
  }
1998
2021
  }
1999
2022
  // ======================= Mindline Config API ===============================
2023
+ export async function auditConfigAdd(instance: IPublicClientApplication, user: User, ac: AuditConfig, debug: boolean): Promise<APIResult> {
2024
+ return auditConfigPost(instance, user, ac, debug);
2025
+ }
2026
+ export async function auditConfigRetrieve(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult> {
2027
+ return auditConfigGet(instance, user, debug);
2028
+ }
2000
2029
  export async function auditEventsRetrieve(instance: IPublicClientApplication, authorizedUser: User, debug: boolean): Promise<APIResult> {
2001
2030
  return auditEventsGet(instance, authorizedUser, debug);
2002
2031
  }
@@ -2805,6 +2834,77 @@ export async function adminPost(
2805
2834
  }
2806
2835
  return result;
2807
2836
  }
2837
+ //auditConfigPost: write audit config to back end
2838
+ export async function auditConfigPost(
2839
+ instance: IPublicClientApplication,
2840
+ user: User,
2841
+ config: AuditConfig,
2842
+ debug: boolean
2843
+ ): Promise<APIResult> {
2844
+ instance = instance;
2845
+ user = user;
2846
+ debug = debug;
2847
+ let result: APIResult = new APIResult();
2848
+ if (config.id === "") {
2849
+ result.result = false;
2850
+ result.error = "auditConfigPost: invalid config ID";
2851
+ result.status = 500;
2852
+ return result;
2853
+ }
2854
+ // create no parameter audit config post endpoint
2855
+ let endpoint: string = mindlineConfig.auditConfigEndpoint();
2856
+ // create config headers
2857
+ const headers = await mindlineDefineHeaders(instance, user);
2858
+ // create config body
2859
+ let configBody: string = `
2860
+ {
2861
+ "workspaceId": "${config.workspaceId}",
2862
+ "name": "${config.name}",
2863
+ "description": "${config.description}",
2864
+ "isEnabled": ${config.isEnabled},
2865
+ "email": "${config.email}",
2866
+ "tenantId": "${config.tenantId}"
2867
+ }`;
2868
+ let options = { method: "POST", headers: headers, body: configBody };
2869
+ // make config endpoint call
2870
+ try {
2871
+ if (debug) debugger;
2872
+ console.log("Attempting POST to /audit-configuration: " + endpoint);
2873
+ let response = await fetch(endpoint, options);
2874
+ if (response.status === 200 && response.statusText === "OK") {
2875
+ let data = await response.json();
2876
+ config.id = data;
2877
+ console.log(
2878
+ `Successful AuditConfigID: ${data} from POST to /audit-configuration: ${configBody}`
2879
+ );
2880
+ return result;
2881
+ }
2882
+ else {
2883
+ result.error = await processErrors(response);
2884
+ console.log(`Failed POST to /audit-configuration: ${configBody}`);
2885
+ console.log(result.error);
2886
+ result.status = 500;
2887
+ result.result = false;
2888
+ return result;
2889
+ }
2890
+ }
2891
+ catch (error: any) {
2892
+ result.status = 500;
2893
+ result.result = false;
2894
+ result.error = error.message;
2895
+ console.log(result.error);
2896
+ return result;
2897
+ }
2898
+ return result;
2899
+ }
2900
+ //auditConfigPost: get audit config from back end
2901
+ export async function auditConfigGet(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult> {
2902
+ instance = instance;
2903
+ user = user;
2904
+ debug = debug;
2905
+ let result: APIResult = new APIResult();
2906
+ return result;
2907
+ }
2808
2908
  export async function auditEventsGet(instance: IPublicClientApplication, user: User, debug: boolean): Promise<APIResult> {
2809
2909
  let result: APIResult = new APIResult();
2810
2910
  // we need a valid user