@mindline/sync 1.0.13 → 1.0.15

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/configs.json CHANGED
@@ -17,5 +17,100 @@
17
17
  }
18
18
  ],
19
19
  "enabled": "false"
20
+ },
21
+ {
22
+ "id": "2",
23
+ "name": "TestSync",
24
+ "description": "Automated *test* sync of users from Mindline1 to Mindline2",
25
+ "targetConfigs":
26
+ [
27
+ {
28
+ "tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
29
+ "sourceGroups": ["TODO"],
30
+ "targetGroup": ""
31
+ },
32
+ {
33
+ "tid": "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e",
34
+ "sourceGroups": [],
35
+ "targetGroup": "TODO"
36
+ }
37
+ ],
38
+ "enabled": "false"
39
+ },
40
+ {
41
+ "id": "3",
42
+ "name": "ProdSync",
43
+ "description": "Automated sync of users from WhoIAm to Grit Software",
44
+ "targetConfigs":
45
+ [
46
+ {
47
+ "tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
48
+ "sourceGroups": ["TODO"],
49
+ "targetGroup": ""
50
+ },
51
+ {
52
+ "tid": "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e",
53
+ "sourceGroups": [],
54
+ "targetGroup": "TODO"
55
+ }
56
+ ],
57
+ "enabled": "false"
58
+ },
59
+ {
60
+ "id": "4",
61
+ "name": "TestSync",
62
+ "description": "Automated *test* sync of users from WhoIAm to Grit Software",
63
+ "targetConfigs":
64
+ [
65
+ {
66
+ "tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
67
+ "sourceGroups": ["TODO"],
68
+ "targetGroup": ""
69
+ },
70
+ {
71
+ "tid": "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e",
72
+ "sourceGroups": [],
73
+ "targetGroup": "TODO"
74
+ }
75
+ ],
76
+ "enabled": "false"
77
+ },
78
+ {
79
+ "id": "5",
80
+ "name": "ProdSync",
81
+ "description": "Automated sync of users from Google to Trackman",
82
+ "targetConfigs":
83
+ [
84
+ {
85
+ "tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
86
+ "sourceGroups": ["TODO"],
87
+ "targetGroup": ""
88
+ },
89
+ {
90
+ "tid": "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e",
91
+ "sourceGroups": [],
92
+ "targetGroup": "TODO"
93
+ }
94
+ ],
95
+ "enabled": "false"
96
+ },
97
+ {
98
+ "id": "6",
99
+ "name": "TestSync",
100
+ "description": "Automated *test* sync of users from Google to Trackman",
101
+ "targetConfigs":
102
+ [
103
+ {
104
+ "tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
105
+ "sourceGroups": ["TODO"],
106
+ "targetGroup": ""
107
+ },
108
+ {
109
+ "tid": "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e",
110
+ "sourceGroups": [],
111
+ "targetGroup": "TODO"
112
+ }
113
+ ],
114
+ "enabled": "false"
20
115
  }
21
116
  ]
package/index.js CHANGED
@@ -8,7 +8,7 @@ export function helloNpm() {
8
8
  return "hello NPM";
9
9
  }
10
10
 
11
- const FILTER_FIELD = "WorkspaceIDs";
11
+ const FILTER_FIELD = "workspaceIDs";
12
12
 
13
13
  export class User {
14
14
  constructor(){
@@ -20,6 +20,7 @@ export class User {
20
20
  this.companyName = "";
21
21
  this.companyDomain = "";
22
22
  this.associatedWorkspaces = {};
23
+ this.workspaceIDs = "";
23
24
  }
24
25
  }
25
26
 
@@ -32,6 +33,7 @@ export class Target {
32
33
  this.authority = "";
33
34
  this.readServicePrincipal = "";
34
35
  this.writeServicePrincipal = "";
36
+ this.workspaceIDs = "";
35
37
  }
36
38
  }
37
39
 
@@ -42,6 +44,7 @@ export class Config {
42
44
  this.description = "";
43
45
  this.targetConfigs = {};
44
46
  this.enabled = false;
47
+ this.workspaceIDs = "";
45
48
  }
46
49
  }
47
50
 
@@ -55,14 +58,14 @@ export class Workspace {
55
58
  }
56
59
  }
57
60
 
58
- export class PortalConfigInfo {
61
+ export class InitInfo {
59
62
  constructor() {
60
63
  this.us = {};
61
64
  this.ts = {};
62
65
  this.cs = {};
63
66
  this.ws = {};
64
67
  }
65
- tagWithWorkspaces() {
68
+ initWorkspaceIDs() {
66
69
  // for each Workspace tag associated User, Target, Config with Workspace.id
67
70
  for (let workspace of this.ws) {
68
71
  // find matching Users to tag with this workspace
@@ -70,21 +73,10 @@ export class PortalConfigInfo {
70
73
  let user = this.us.find((currentUser) => currentUser.oid === userID);
71
74
  if (user !== undefined) {
72
75
  // we found the user
73
- if (user[FILTER_FIELD] === undefined) {
74
- // the user does not have the filter field yet
75
- try {
76
- user[FILTER_FIELD] = workspace.id;
77
- } catch (e) {
78
- debugger;
79
- return false;
80
- }
81
- } else {
82
- // the user does have the filter field
83
- user[FILTER_FIELD] += ", ";
84
- user[FILTER_FIELD] += workspace.id;
85
- }
76
+ user[FILTER_FIELD] += workspace.id;
77
+ user[FILTER_FIELD] += " ";
86
78
  } else {
87
- // we should not have PCI that does not have Workspace component objects
79
+ // we should not have InitInfo missing Workspace components
88
80
  debugger;
89
81
  return false;
90
82
  }
@@ -96,21 +88,10 @@ export class PortalConfigInfo {
96
88
  );
97
89
  if (target !== undefined) {
98
90
  // we found the target
99
- if (target[FILTER_FIELD] === undefined) {
100
- // the target does not have the filter field yet
101
- try {
102
- target[FILTER_FIELD] = workspace.id;
103
- } catch (e) {
104
- debugger;
105
- return false;
106
- }
107
- } else {
108
- // the target does have the filter field
109
- target[FILTER_FIELD] += ", ";
110
- target[FILTER_FIELD] += workspace.id;
111
- }
91
+ target[FILTER_FIELD] += workspace.id;
92
+ target[FILTER_FIELD] += " ";
112
93
  } else {
113
- // we should not have PCI that does not have Workspace component objects
94
+ // we should not have InitInfo missing Workspace components
114
95
  debugger;
115
96
  return false;
116
97
  }
@@ -122,21 +103,10 @@ export class PortalConfigInfo {
122
103
  );
123
104
  if (config !== undefined) {
124
105
  // we found the config
125
- if (config[FILTER_FIELD] === undefined) {
126
- // the config does not have the filter field yet
127
- try {
128
- config[FILTER_FIELD] = workspace.id;
129
- } catch (e) {
130
- debugger;
131
- return false;
132
- }
133
- } else {
134
- // the config does have the filter field
135
- config[FILTER_FIELD] += ", ";
136
- config[FILTER_FIELD] += workspace.id;
137
- }
106
+ config[FILTER_FIELD] += workspace.id;
107
+ config[FILTER_FIELD] += " ";
138
108
  } else {
139
- // we should not have PCI that does not have Workspace component objects
109
+ // we should not have InitInfo missing Workspace components
140
110
  debugger;
141
111
  return false;
142
112
  }
@@ -153,7 +123,7 @@ import configs from "./configs.json";
153
123
  import workspaces from "./workspaces.json";
154
124
 
155
125
  // retrieve Workspace(s), User(s), Target(s), Config(s) given logged in user
156
- export function InitPortal(user, portalConfigInfo)
126
+ export function InitGet(user, ii)
157
127
  {
158
128
  debugger;
159
129
  // for now, just get hardcoded data from JSON
@@ -162,11 +132,11 @@ export function InitPortal(user, portalConfigInfo)
162
132
  var configsString = JSON.stringify(configs);
163
133
  var workspacesString = JSON.stringify(workspaces);
164
134
  try {
165
- portalConfigInfo.us = deserializeArray(User, usersString);
166
- portalConfigInfo.ts = deserializeArray(Target, targetsString);
167
- portalConfigInfo.cs = deserializeArray(Config, configsString);
168
- portalConfigInfo.ws = deserializeArray(Workspace, workspacesString);
169
- portalConfigInfo.tagWithWorkspaces();
135
+ ii.us = deserializeArray(User, usersString);
136
+ ii.ts = deserializeArray(Target, targetsString);
137
+ ii.cs = deserializeArray(Config, configsString);
138
+ ii.ws = deserializeArray(Workspace, workspacesString);
139
+ if(!ii.initWorkspaceIDs()) return false;
170
140
  debugger;
171
141
  } catch (e) {
172
142
  debugger;
package/index.test.js CHANGED
@@ -1,4 +1,4 @@
1
- import {sum, User, PortalConfigInfo, InitPortal } from "./index.js";
1
+ import {sum, User, InitInfo, InitGet } from "./index.js";
2
2
  import {test, expect} from "vitest";
3
3
 
4
4
  test("adds 1 + 2 to equal 3", () => {
@@ -6,7 +6,7 @@ test("adds 1 + 2 to equal 3", () => {
6
6
  });
7
7
  test("loads config based on a user and expects function to return true", () => {
8
8
  let u = new User();
9
- let pci = new PortalConfigInfo();
10
- expect(InitPortal(u, pci)).toBe(true);
11
- expect(pci.us.length).toBe(2);
9
+ let ii = new InitInfo();
10
+ expect(InitGet(u, ii)).toBe(true);
11
+ expect(ii.us.length).toBe(6);
12
12
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
3
  "type": "module",
4
- "version": "1.0.13",
4
+ "version": "1.0.15",
5
5
  "description": "sync is a node.js package encapsulating javscript classes required for configuring Mindline sync service.",
6
6
  "exports": "./index.js",
7
7
  "scripts": {
package/sync.d.ts CHANGED
@@ -12,6 +12,7 @@ declare module "@mindline/sync" {
12
12
  companyName: string; // findTenantInformationByTenantId TODO: process changes to company name
13
13
  companyDomain: string; // findTenantInformationByTenantId TODO: process changes to company name
14
14
  associatedWorkspaces: string[];
15
+ workspaceIDs: string;
15
16
  }
16
17
 
17
18
  // target (Azure AD tenant, AD domain, Google workspace)
@@ -24,6 +25,7 @@ declare module "@mindline/sync" {
24
25
  authority: string; // from AAD ID auth response
25
26
  readServicePrincipal: string; // from AAD consent
26
27
  writeServicePrincipal: string; // from AAD consent
28
+ workspaceIDs: string;
27
29
  }
28
30
 
29
31
  // config
@@ -38,6 +40,7 @@ declare module "@mindline/sync" {
38
40
  description: string;
39
41
  targetConfigs: TargetConfigInfo[];
40
42
  enabled: boolean;
43
+ workspaceIDs: string;
41
44
  }
42
45
 
43
46
  // class to group Users, Tenants, and Configs
@@ -49,7 +52,7 @@ declare module "@mindline/sync" {
49
52
  associatedConfigs: string[];
50
53
  }
51
54
 
52
- export class PortalConfigInfo {
55
+ export class InitInfo {
53
56
  us: User[];
54
57
  ts: Target[];
55
58
  cs: Config[];
@@ -57,7 +60,7 @@ declare module "@mindline/sync" {
57
60
  tagWithWorkspaces(): boolean;
58
61
  }
59
62
 
60
- export function InitPortal(u: User, pci: PortalConfigInfo): boolean;
63
+ export function InitGet(u: User, ii: InitInfo): boolean;
61
64
  export function AddTarget(): boolean;
62
65
  export function CompleteTarget(): boolean;
63
66
  export function AddUser(): boolean;
package/targets.json CHANGED
@@ -16,5 +16,41 @@
16
16
  "authority": "https://login.microsoftonline.com/common/",
17
17
  "readServicePrincipal": "TODO",
18
18
  "writeServicePrincipal": "TODO"
19
+ },
20
+ {
21
+ "tid": "1",
22
+ "name": "WhoIam",
23
+ "domain": "whoiam.onmicrosoft.com",
24
+ "type": "1",
25
+ "authority": "https://login.microsoftonline.com/common/",
26
+ "readServicePrincipal": "TODO",
27
+ "writeServicePrincipal": "TODO"
28
+ },
29
+ {
30
+ "tid": "2",
31
+ "name": "Grit Software",
32
+ "domain": "gritsoftware.onmicrosoft.com",
33
+ "type": "1",
34
+ "authority": "https://login.microsoftonline.com/common/",
35
+ "readServicePrincipal": "TODO",
36
+ "writeServicePrincipal": "TODO"
37
+ },
38
+ {
39
+ "tid": "3",
40
+ "name": "Google",
41
+ "domain": "google.onmicrosoft.com",
42
+ "type": "1",
43
+ "authority": "https://login.microsoftonline.com/common/",
44
+ "readServicePrincipal": "TODO",
45
+ "writeServicePrincipal": "TODO"
46
+ },
47
+ {
48
+ "tid": "4",
49
+ "name": "Trackman Golf",
50
+ "domain": "trackman.onmicrosoft.com",
51
+ "type": "1",
52
+ "authority": "https://login.microsoftonline.com/common/",
53
+ "readServicePrincipal": "TODO",
54
+ "writeServicePrincipal": "TODO"
19
55
  }
20
56
  ]
package/users.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
8
8
  "companyName": "Mindline1",
9
9
  "companyDomain": "mindline1.onmicrosoft.com",
10
- "associatedWorkspaces": [ "1" ]
10
+ "associatedWorkspaces": [ "1", "2", "3" ]
11
11
  },
12
12
  {
13
13
  "oid": "e5a42d0c-4fa5-4a65-8d9b-90f989ecae9b",
@@ -18,5 +18,45 @@
18
18
  "companyName": "Mindline2",
19
19
  "companyDomain": "mindline2.onmicrosoft.com",
20
20
  "associatedWorkspaces": [ "1" ]
21
+ },
22
+ {
23
+ "oid": "1",
24
+ "name": "Ajith Alexander",
25
+ "mail": "ajith.alexander@whoiam.ai",
26
+ "authority": "https://login.microsoftonline.com/common/",
27
+ "tid": "1",
28
+ "companyName": "WhoIAm",
29
+ "companyDomain": "whoiam.onmicrosoft.com",
30
+ "associatedWorkspaces": [ "2" ]
31
+ },
32
+ {
33
+ "oid": "2",
34
+ "name": "Lingeshwaran Palanappian",
35
+ "mail": "lingesh@gritsoftwaresystems.com",
36
+ "authority": "https://login.microsoftonline.com/common/",
37
+ "tid": "2",
38
+ "companyName": "Grit Sofware",
39
+ "companyDomain": "gritsoftware.onmicrosoft.com",
40
+ "associatedWorkspaces": [ "2" ]
41
+ },
42
+ {
43
+ "oid": "3",
44
+ "name": "Gavin Anderson",
45
+ "mail": "gavin@google.com",
46
+ "authority": "https://login.microsoftonline.com/common/",
47
+ "tid": "3",
48
+ "companyName": "Google",
49
+ "companyDomain": "google.onmicrosoft.com",
50
+ "associatedWorkspaces": [ "3" ]
51
+ },
52
+ {
53
+ "oid": "4",
54
+ "name": "Roger Cottam",
55
+ "mail": "roger@trackman.com",
56
+ "authority": "https://login.microsoftonline.com/common/",
57
+ "tid": "4",
58
+ "companyName": "Trackman Golf",
59
+ "companyDomain": "trackman.onmicrosoft.com",
60
+ "associatedWorkspaces": [ "3" ]
21
61
  }
22
62
  ]
package/workspaces.json CHANGED
@@ -4,6 +4,20 @@
4
4
  "name": "Default",
5
5
  "associatedUsers": [ "102bafe7-9e62-4993-b943-2f20c609e5c9", "e5a42d0c-4fa5-4a65-8d9b-90f989ecae9b" ],
6
6
  "associatedTargets": [ "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744", "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e" ],
7
- "associatedConfigs": [ "1" ]
7
+ "associatedConfigs": [ "1", "2" ]
8
+ },
9
+ {
10
+ "id": "2",
11
+ "name": "Joint Venture",
12
+ "associatedUsers": [ "102bafe7-9e62-4993-b943-2f20c609e5c9", "1", "2" ],
13
+ "associatedTargets": [ "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744", "1", "2" ],
14
+ "associatedConfigs": [ "3", "4" ]
15
+ },
16
+ {
17
+ "id": "3",
18
+ "name": "Special Project",
19
+ "associatedUsers": [ "102bafe7-9e62-4993-b943-2f20c609e5c9", "3", "4" ],
20
+ "associatedTargets": [ "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744", "3", "4"],
21
+ "associatedConfigs": [ "5", "6" ]
8
22
  }
9
23
  ]
package/syncConfigs.json DELETED
@@ -1,26 +0,0 @@
1
- [
2
- {
3
- "virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
4
- "name": "ProdSync",
5
- "tenantCount": "2",
6
- "description": "Production Mindline Sync Configuration."
7
- },
8
- {
9
- "virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
10
- "name": "TestSync",
11
- "tenantCount": "2",
12
- "description": "Test Mindline Sync Configuration."
13
- },
14
- {
15
- "virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
16
- "name": "ProdSync",
17
- "tenantCount": "2",
18
- "description": "Automated sync of users from Subsidiary Y to Customer X."
19
- },
20
- {
21
- "virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
22
- "name": "TestSync",
23
- "tenantCount": "2",
24
- "description": "Test automated sync of users from Subsidiary Y to Customer X."
25
- }
26
- ]
package/syncTenants.json DELETED
@@ -1,34 +0,0 @@
1
- [
2
- {
3
- "virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
4
- "name": "Mindline1",
5
- "direction": "Outbound",
6
- "readServicePrincipal": "1234",
7
- "writeServicePrincipal": "N/A",
8
- "session": "Off"
9
- },
10
- {
11
- "virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
12
- "name": "Mindline2",
13
- "direction": "Inbound",
14
- "readServicePrincipal": "9101",
15
- "writeServicePrincipal": "1121",
16
- "session": "Off"
17
- },
18
- {
19
- "virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
20
- "name": "Customer X",
21
- "direction": "Inbound",
22
- "readServicePrincipal": "1234",
23
- "writeServicePrincipal": "5678",
24
- "session": "Off"
25
- },
26
- {
27
- "virtualTenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
28
- "name": "Subisidiary Y",
29
- "direction": "Outbound",
30
- "readServicePrincipal": "9101",
31
- "writeServicePrincipal": "N/A",
32
- "session": "Off"
33
- }
34
- ]
@@ -1,16 +0,0 @@
1
- [
2
- {
3
- "tenantID": "85132631-cac3-4708-86b9-b4019f2132e9",
4
- "name": "Mindline",
5
- "domain": "bellevuearvindhotmail.onmicrosoft.com",
6
- "description": "Mindline virtual tenant.",
7
- "session": "Off"
8
- },
9
- {
10
- "tenantID": "85132631-cac3-4708-86b9-b4019f2132e8",
11
- "name": "virttenant",
12
- "domain": "virttenant.onmicrosoft.com",
13
- "description": "Prod virtual tenant for CustomerX.",
14
- "session": "Off"
15
- }
16
- ]