@mindline/sync 1.0.12 → 1.0.14

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,6 +8,8 @@ export function helloNpm() {
8
8
  return "hello NPM";
9
9
  }
10
10
 
11
+ const FILTER_FIELD = "WorkspaceIDs";
12
+
11
13
  export class User {
12
14
  constructor(){
13
15
  this.oid = "";
@@ -54,15 +56,96 @@ export class Workspace {
54
56
  }
55
57
 
56
58
  export class PortalConfigInfo {
57
- constructor(){
59
+ constructor() {
58
60
  this.us = {};
59
61
  this.ts = {};
60
62
  this.cs = {};
61
63
  this.ws = {};
62
64
  }
65
+ tagWithWorkspaces() {
66
+ // for each Workspace tag associated User, Target, Config with Workspace.id
67
+ for (let workspace of this.ws) {
68
+ // find matching Users to tag with this workspace
69
+ for (let userID of workspace.associatedUsers) {
70
+ let user = this.us.find((currentUser) => currentUser.oid === userID);
71
+ if (user !== undefined) {
72
+ // 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
+ }
86
+ } else {
87
+ // we should not have PCI that does not have Workspace component objects
88
+ debugger;
89
+ return false;
90
+ }
91
+ }
92
+ // find matching Targets to tag with this workspace
93
+ for (let targetID of workspace.associatedTargets) {
94
+ let target = this.ts.find(
95
+ (currentTarget) => currentTarget.tid === targetID
96
+ );
97
+ if (target !== undefined) {
98
+ // 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
+ }
112
+ } else {
113
+ // we should not have PCI that does not have Workspace component objects
114
+ debugger;
115
+ return false;
116
+ }
117
+ }
118
+ // find matching Configs to tag with this workspace
119
+ for (let configID of workspace.associatedConfigs) {
120
+ let config = this.cs.find(
121
+ (currentConfig) => currentConfig.id === configID
122
+ );
123
+ if (config !== undefined) {
124
+ // 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
+ }
138
+ } else {
139
+ // we should not have PCI that does not have Workspace component objects
140
+ debugger;
141
+ return false;
142
+ }
143
+ }
144
+ }
145
+ return true;
146
+ }
63
147
  }
64
148
 
65
-
66
149
  import { deserializeArray } from 'class-transformer';
67
150
  import users from "./users.json";
68
151
  import targets from "./targets.json";
@@ -83,6 +166,8 @@ export function InitPortal(user, portalConfigInfo)
83
166
  portalConfigInfo.ts = deserializeArray(Target, targetsString);
84
167
  portalConfigInfo.cs = deserializeArray(Config, configsString);
85
168
  portalConfigInfo.ws = deserializeArray(Workspace, workspacesString);
169
+ portalConfigInfo.tagWithWorkspaces();
170
+ debugger;
86
171
  } catch (e) {
87
172
  debugger;
88
173
  return false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
3
  "type": "module",
4
- "version": "1.0.12",
4
+ "version": "1.0.14",
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
@@ -54,6 +54,7 @@ declare module "@mindline/sync" {
54
54
  ts: Target[];
55
55
  cs: Config[];
56
56
  ws: Workspace[];
57
+ tagWithWorkspaces(): boolean;
57
58
  }
58
59
 
59
60
  export function InitPortal(u: User, pci: PortalConfigInfo): 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
@@ -2,8 +2,22 @@
2
2
  {
3
3
  "id": "1",
4
4
  "name": "Default",
5
- "associatedUsers": [ "102bafe7-9e62-4993-b943-2f20c609e5c9", "e5a42d0c-4fa5-4a65-8d9b-90f989ecae9b"],
6
- "associatedConfigs": [ "1" ],
7
- "associatedTargets": [ "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744", "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e" ]
5
+ "associatedUsers": [ "102bafe7-9e62-4993-b943-2f20c609e5c9", "e5a42d0c-4fa5-4a65-8d9b-90f989ecae9b" ],
6
+ "associatedTargets": [ "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744", "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e" ],
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
  ]