@mindline/sync 1.0.14 → 1.0.16
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/index.js +22 -51
- package/index.test.js +4 -4
- package/package.json +1 -1
- package/sync.d.ts +6 -2
- package/users.json +12 -6
- package/syncConfigs.json +0 -26
- package/syncTenants.json +0 -34
- package/virtualTenants.json +0 -16
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export function helloNpm() {
|
|
|
8
8
|
return "hello NPM";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const FILTER_FIELD = "
|
|
11
|
+
const FILTER_FIELD = "workspaceIDs";
|
|
12
12
|
|
|
13
13
|
export class User {
|
|
14
14
|
constructor(){
|
|
@@ -20,6 +20,8 @@ export class User {
|
|
|
20
20
|
this.companyName = "";
|
|
21
21
|
this.companyDomain = "";
|
|
22
22
|
this.associatedWorkspaces = {};
|
|
23
|
+
this.workspaceIDs = "";
|
|
24
|
+
this.session = "";
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -32,6 +34,7 @@ export class Target {
|
|
|
32
34
|
this.authority = "";
|
|
33
35
|
this.readServicePrincipal = "";
|
|
34
36
|
this.writeServicePrincipal = "";
|
|
37
|
+
this.workspaceIDs = "";
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
|
|
@@ -42,6 +45,7 @@ export class Config {
|
|
|
42
45
|
this.description = "";
|
|
43
46
|
this.targetConfigs = {};
|
|
44
47
|
this.enabled = false;
|
|
48
|
+
this.workspaceIDs = "";
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
|
|
@@ -55,14 +59,14 @@ export class Workspace {
|
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
export class
|
|
62
|
+
export class InitInfo {
|
|
59
63
|
constructor() {
|
|
60
64
|
this.us = {};
|
|
61
65
|
this.ts = {};
|
|
62
66
|
this.cs = {};
|
|
63
67
|
this.ws = {};
|
|
64
68
|
}
|
|
65
|
-
|
|
69
|
+
initWorkspaceIDs() {
|
|
66
70
|
// for each Workspace tag associated User, Target, Config with Workspace.id
|
|
67
71
|
for (let workspace of this.ws) {
|
|
68
72
|
// find matching Users to tag with this workspace
|
|
@@ -70,21 +74,10 @@ export class PortalConfigInfo {
|
|
|
70
74
|
let user = this.us.find((currentUser) => currentUser.oid === userID);
|
|
71
75
|
if (user !== undefined) {
|
|
72
76
|
// we found the user
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
}
|
|
77
|
+
user[FILTER_FIELD] += workspace.id;
|
|
78
|
+
user[FILTER_FIELD] += " ";
|
|
86
79
|
} else {
|
|
87
|
-
// we should not have
|
|
80
|
+
// we should not have InitInfo missing Workspace components
|
|
88
81
|
debugger;
|
|
89
82
|
return false;
|
|
90
83
|
}
|
|
@@ -96,21 +89,10 @@ export class PortalConfigInfo {
|
|
|
96
89
|
);
|
|
97
90
|
if (target !== undefined) {
|
|
98
91
|
// we found the target
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
}
|
|
92
|
+
target[FILTER_FIELD] += workspace.id;
|
|
93
|
+
target[FILTER_FIELD] += " ";
|
|
112
94
|
} else {
|
|
113
|
-
// we should not have
|
|
95
|
+
// we should not have InitInfo missing Workspace components
|
|
114
96
|
debugger;
|
|
115
97
|
return false;
|
|
116
98
|
}
|
|
@@ -122,21 +104,10 @@ export class PortalConfigInfo {
|
|
|
122
104
|
);
|
|
123
105
|
if (config !== undefined) {
|
|
124
106
|
// we found the config
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
}
|
|
107
|
+
config[FILTER_FIELD] += workspace.id;
|
|
108
|
+
config[FILTER_FIELD] += " ";
|
|
138
109
|
} else {
|
|
139
|
-
// we should not have
|
|
110
|
+
// we should not have InitInfo missing Workspace components
|
|
140
111
|
debugger;
|
|
141
112
|
return false;
|
|
142
113
|
}
|
|
@@ -153,7 +124,7 @@ import configs from "./configs.json";
|
|
|
153
124
|
import workspaces from "./workspaces.json";
|
|
154
125
|
|
|
155
126
|
// retrieve Workspace(s), User(s), Target(s), Config(s) given logged in user
|
|
156
|
-
export function
|
|
127
|
+
export function InitGet(user, ii)
|
|
157
128
|
{
|
|
158
129
|
debugger;
|
|
159
130
|
// for now, just get hardcoded data from JSON
|
|
@@ -162,11 +133,11 @@ export function InitPortal(user, portalConfigInfo)
|
|
|
162
133
|
var configsString = JSON.stringify(configs);
|
|
163
134
|
var workspacesString = JSON.stringify(workspaces);
|
|
164
135
|
try {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
136
|
+
ii.us = deserializeArray(User, usersString);
|
|
137
|
+
ii.ts = deserializeArray(Target, targetsString);
|
|
138
|
+
ii.cs = deserializeArray(Config, configsString);
|
|
139
|
+
ii.ws = deserializeArray(Workspace, workspacesString);
|
|
140
|
+
if(!ii.initWorkspaceIDs()) return false;
|
|
170
141
|
debugger;
|
|
171
142
|
} catch (e) {
|
|
172
143
|
debugger;
|
package/index.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {sum, User,
|
|
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
|
|
10
|
-
expect(
|
|
11
|
-
expect(
|
|
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
package/sync.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ 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;
|
|
16
|
+
session: string;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
// target (Azure AD tenant, AD domain, Google workspace)
|
|
@@ -24,6 +26,7 @@ declare module "@mindline/sync" {
|
|
|
24
26
|
authority: string; // from AAD ID auth response
|
|
25
27
|
readServicePrincipal: string; // from AAD consent
|
|
26
28
|
writeServicePrincipal: string; // from AAD consent
|
|
29
|
+
workspaceIDs: string;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
// config
|
|
@@ -38,6 +41,7 @@ declare module "@mindline/sync" {
|
|
|
38
41
|
description: string;
|
|
39
42
|
targetConfigs: TargetConfigInfo[];
|
|
40
43
|
enabled: boolean;
|
|
44
|
+
workspaceIDs: string;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
// class to group Users, Tenants, and Configs
|
|
@@ -49,7 +53,7 @@ declare module "@mindline/sync" {
|
|
|
49
53
|
associatedConfigs: string[];
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
export class
|
|
56
|
+
export class InitInfo {
|
|
53
57
|
us: User[];
|
|
54
58
|
ts: Target[];
|
|
55
59
|
cs: Config[];
|
|
@@ -57,7 +61,7 @@ declare module "@mindline/sync" {
|
|
|
57
61
|
tagWithWorkspaces(): boolean;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
export function
|
|
64
|
+
export function InitGet(u: User, ii: InitInfo): boolean;
|
|
61
65
|
export function AddTarget(): boolean;
|
|
62
66
|
export function CompleteTarget(): boolean;
|
|
63
67
|
export function AddUser(): boolean;
|
package/users.json
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
"tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
|
|
8
8
|
"companyName": "Mindline1",
|
|
9
9
|
"companyDomain": "mindline1.onmicrosoft.com",
|
|
10
|
-
"associatedWorkspaces": [ "1", "2", "3" ]
|
|
10
|
+
"associatedWorkspaces": [ "1", "2", "3" ],
|
|
11
|
+
"session": "Sign In"
|
|
11
12
|
},
|
|
12
13
|
{
|
|
13
14
|
"oid": "e5a42d0c-4fa5-4a65-8d9b-90f989ecae9b",
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
"tid": "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e",
|
|
18
19
|
"companyName": "Mindline2",
|
|
19
20
|
"companyDomain": "mindline2.onmicrosoft.com",
|
|
20
|
-
"associatedWorkspaces": [ "1" ]
|
|
21
|
+
"associatedWorkspaces": [ "1" ],
|
|
22
|
+
"session": "Sign In"
|
|
21
23
|
},
|
|
22
24
|
{
|
|
23
25
|
"oid": "1",
|
|
@@ -27,7 +29,8 @@
|
|
|
27
29
|
"tid": "1",
|
|
28
30
|
"companyName": "WhoIAm",
|
|
29
31
|
"companyDomain": "whoiam.onmicrosoft.com",
|
|
30
|
-
"associatedWorkspaces": [ "2" ]
|
|
32
|
+
"associatedWorkspaces": [ "2" ],
|
|
33
|
+
"session": "Sign In"
|
|
31
34
|
},
|
|
32
35
|
{
|
|
33
36
|
"oid": "2",
|
|
@@ -37,7 +40,8 @@
|
|
|
37
40
|
"tid": "2",
|
|
38
41
|
"companyName": "Grit Sofware",
|
|
39
42
|
"companyDomain": "gritsoftware.onmicrosoft.com",
|
|
40
|
-
"associatedWorkspaces": [ "2" ]
|
|
43
|
+
"associatedWorkspaces": [ "2" ],
|
|
44
|
+
"session": "Sign In"
|
|
41
45
|
},
|
|
42
46
|
{
|
|
43
47
|
"oid": "3",
|
|
@@ -47,7 +51,8 @@
|
|
|
47
51
|
"tid": "3",
|
|
48
52
|
"companyName": "Google",
|
|
49
53
|
"companyDomain": "google.onmicrosoft.com",
|
|
50
|
-
"associatedWorkspaces": [ "3" ]
|
|
54
|
+
"associatedWorkspaces": [ "3" ],
|
|
55
|
+
"session": "Sign In"
|
|
51
56
|
},
|
|
52
57
|
{
|
|
53
58
|
"oid": "4",
|
|
@@ -57,6 +62,7 @@
|
|
|
57
62
|
"tid": "4",
|
|
58
63
|
"companyName": "Trackman Golf",
|
|
59
64
|
"companyDomain": "trackman.onmicrosoft.com",
|
|
60
|
-
"associatedWorkspaces": [ "3" ]
|
|
65
|
+
"associatedWorkspaces": [ "3" ],
|
|
66
|
+
"session": "Sign In"
|
|
61
67
|
}
|
|
62
68
|
]
|
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
|
-
]
|
package/virtualTenants.json
DELETED
|
@@ -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
|
-
]
|