@mindline/sync 1.0.44 → 1.0.45
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/.vs/VSWorkspaceState.json +1 -0
- package/.vs/slnx.sqlite +0 -0
- package/.vs/sync/FileContentIndex/f78dd7fa-b64e-44cf-a39a-d442a67f925d.vsidx +0 -0
- package/.vs/sync/v17/.wsuo +0 -0
- package/configs.json +2 -1
- package/index.d.ts +5 -0
- package/index.ts +129 -19
- package/package.json +1 -1
- package/tenants.json +2 -1
- package/users.json +2 -1
- package/workspaces.json +2 -1
- package/.vs/sync/FileContentIndex/6e2eb4de-f03f-41c0-9850-bdcbce22ae29.vsidx +0 -0
package/.vs/slnx.sqlite
CHANGED
|
Binary file
|
package/.vs/sync/v17/.wsuo
CHANGED
|
Binary file
|
package/configs.json
CHANGED
package/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ declare module "@mindline/sync" {
|
|
|
33
33
|
loginHint: string;
|
|
34
34
|
scopes: string[];
|
|
35
35
|
authTS: Date;
|
|
36
|
+
sel: boolean; // selection state
|
|
36
37
|
constructor();
|
|
37
38
|
}
|
|
38
39
|
// tenant (Azure AD tenant, AD domain, Google workspace)
|
|
@@ -58,6 +59,7 @@ declare module "@mindline/sync" {
|
|
|
58
59
|
onboarded: string; // have we onboarded this tenant? "true" or "false"
|
|
59
60
|
authority: string; // from AAD ID auth response
|
|
60
61
|
workspaceIDs: string;
|
|
62
|
+
sel: boolean; // selection state
|
|
61
63
|
constructor();
|
|
62
64
|
}
|
|
63
65
|
// config
|
|
@@ -87,6 +89,7 @@ declare module "@mindline/sync" {
|
|
|
87
89
|
tenants: TenantConfigInfo[];
|
|
88
90
|
isEnabled: boolean;
|
|
89
91
|
workspaceIDs: string;
|
|
92
|
+
sel: boolean; // selection state
|
|
90
93
|
constructor();
|
|
91
94
|
}
|
|
92
95
|
// class to group Users, Tenants, and Configs
|
|
@@ -96,9 +99,11 @@ declare module "@mindline/sync" {
|
|
|
96
99
|
associatedUsers: string[];
|
|
97
100
|
associatedTenants: string[];
|
|
98
101
|
associatedConfigs: string[];
|
|
102
|
+
sel: boolean; // selection state
|
|
99
103
|
constructor();
|
|
100
104
|
}
|
|
101
105
|
export class InitInfo {
|
|
106
|
+
tab: number;
|
|
102
107
|
us: User[];
|
|
103
108
|
ts: Tenant[];
|
|
104
109
|
cs: Config[];
|
package/index.ts
CHANGED
|
@@ -52,6 +52,7 @@ export class User {
|
|
|
52
52
|
loginHint: string; // to help sign out without prompt
|
|
53
53
|
scopes: string[]; // to detect if incremental consent has happened
|
|
54
54
|
authTS: Date; // timestamp user was authenticated
|
|
55
|
+
sel: boolean; // selection state
|
|
55
56
|
constructor() {
|
|
56
57
|
this.oid = "";
|
|
57
58
|
this.name = "";
|
|
@@ -68,6 +69,7 @@ export class User {
|
|
|
68
69
|
this.loginHint = "";
|
|
69
70
|
this.scopes = new Array();
|
|
70
71
|
this.authTS = new Date(0);
|
|
72
|
+
this.sel = false;
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
export enum TenantType {
|
|
@@ -92,6 +94,7 @@ export class Tenant {
|
|
|
92
94
|
onboarded: string;
|
|
93
95
|
authority: string;
|
|
94
96
|
workspaceIDs: string;
|
|
97
|
+
sel: boolean; // selection state
|
|
95
98
|
constructor() {
|
|
96
99
|
this.tid = "";
|
|
97
100
|
this.name = "";
|
|
@@ -101,6 +104,7 @@ export class Tenant {
|
|
|
101
104
|
this.onboarded = "false";
|
|
102
105
|
this.authority = "";
|
|
103
106
|
this.workspaceIDs = "";
|
|
107
|
+
this.sel = false;
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
110
|
function getGraphEndpoint(authority: string): string {
|
|
@@ -149,6 +153,7 @@ export class Config {
|
|
|
149
153
|
tenants: TenantConfigInfo[];
|
|
150
154
|
isEnabled: boolean;
|
|
151
155
|
workspaceIDs: string;
|
|
156
|
+
sel: boolean; // selection state
|
|
152
157
|
constructor() {
|
|
153
158
|
this.id = "";
|
|
154
159
|
this.name = "";
|
|
@@ -156,6 +161,7 @@ export class Config {
|
|
|
156
161
|
this.tenants = new Array();
|
|
157
162
|
this.isEnabled = false;
|
|
158
163
|
this.workspaceIDs = "";
|
|
164
|
+
this.sel = false;
|
|
159
165
|
}
|
|
160
166
|
}
|
|
161
167
|
export class Workspace {
|
|
@@ -164,12 +170,14 @@ export class Workspace {
|
|
|
164
170
|
associatedUsers: string[];
|
|
165
171
|
associatedTenants: string[];
|
|
166
172
|
associatedConfigs: string[];
|
|
173
|
+
sel: boolean; // selection state
|
|
167
174
|
constructor() {
|
|
168
175
|
this.id = "";
|
|
169
176
|
this.name = "";
|
|
170
177
|
this.associatedUsers = new Array();
|
|
171
178
|
this.associatedTenants = new Array();
|
|
172
179
|
this.associatedConfigs = new Array();
|
|
180
|
+
this.sel = false;
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
183
|
// check for localStorage availability
|
|
@@ -200,6 +208,7 @@ function storageAvailable(type) {
|
|
|
200
208
|
}
|
|
201
209
|
}
|
|
202
210
|
export class InitInfo {
|
|
211
|
+
tab: number;
|
|
203
212
|
us: User[];
|
|
204
213
|
ts: Tenant[];
|
|
205
214
|
cs: Config[];
|
|
@@ -217,7 +226,9 @@ export class InitInfo {
|
|
|
217
226
|
let initInfoString: string = result;
|
|
218
227
|
let iiReadFromLocalStorage: InitInfo = JSON.parse(initInfoString);
|
|
219
228
|
if (iiReadFromLocalStorage.us.length !== 0) {
|
|
220
|
-
if (bClearLocalStorage) {
|
|
229
|
+
if (bClearLocalStorage) {
|
|
230
|
+
localStorage.removeItem("InitInfo");
|
|
231
|
+
}
|
|
221
232
|
else {
|
|
222
233
|
this.#initFromObjects(iiReadFromLocalStorage);
|
|
223
234
|
return;
|
|
@@ -225,12 +236,13 @@ export class InitInfo {
|
|
|
225
236
|
}
|
|
226
237
|
}
|
|
227
238
|
}
|
|
228
|
-
// if storage unavailable or we were just asked to clear, read
|
|
239
|
+
// if storage unavailable or we were just asked to clear, read defaults to enable usable UI
|
|
229
240
|
var usersString = JSON.stringify(users);
|
|
230
241
|
var tenantsString = JSON.stringify(tenants);
|
|
231
242
|
var configsString = JSON.stringify(configs);
|
|
232
243
|
var workspacesString = JSON.stringify(workspaces);
|
|
233
244
|
try {
|
|
245
|
+
this.tab = 0;
|
|
234
246
|
this.us = deserializeArray(User, usersString);
|
|
235
247
|
this.ts = deserializeArray(Tenant, tenantsString);
|
|
236
248
|
this.cs = deserializeArray(Config, configsString);
|
|
@@ -298,15 +310,82 @@ export class InitInfo {
|
|
|
298
310
|
return true;
|
|
299
311
|
}
|
|
300
312
|
#initFromObjects(ii: InitInfo): void {
|
|
301
|
-
|
|
302
|
-
if (typeof ii.us === "undefined")
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
else
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
313
|
+
this.tab = ii.tab;
|
|
314
|
+
if (typeof ii.us === "undefined") {
|
|
315
|
+
this.us = new Array<User>();
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
this.us = ii.us.map((user: User) => {
|
|
319
|
+
let newuser: User = new User();
|
|
320
|
+
newuser.oid = user.oid;
|
|
321
|
+
newuser.name = user.name;
|
|
322
|
+
newuser.mail = user.mail;
|
|
323
|
+
newuser.authority = user.authority;
|
|
324
|
+
newuser.tid = user.tid;
|
|
325
|
+
newuser.companyName = user.companyName;
|
|
326
|
+
newuser.companyDomain = user.companyDomain;
|
|
327
|
+
newuser.associatedWorkspaces = user.associatedWorkspaces;
|
|
328
|
+
newuser.workspaceIDs = user.workspaceIDs;
|
|
329
|
+
newuser.session = user.session;
|
|
330
|
+
newuser.spacode = user.spacode;
|
|
331
|
+
newuser.accessToken = user.accessToken;
|
|
332
|
+
newuser.loginHint = user.loginHint;
|
|
333
|
+
newuser.scopes = user.scopes;
|
|
334
|
+
newuser.authTS = new Date(user.authTS);
|
|
335
|
+
newuser.sel = user.sel;
|
|
336
|
+
return newuser
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
if (typeof ii.ts === "undefined") {
|
|
340
|
+
this.ts = new Array<Tenant>();
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
this.ts = ii.ts.map((tenant: Tenant) => {
|
|
344
|
+
let newtenant: Tenant = new Tenant();
|
|
345
|
+
newtenant.tid = tenant.tid;
|
|
346
|
+
newtenant.name = tenant.name;
|
|
347
|
+
newtenant.domain = tenant.domain;
|
|
348
|
+
newtenant.tenantType = tenant.tenantType;
|
|
349
|
+
newtenant.permissionType = tenant.permissionType;
|
|
350
|
+
newtenant.onboarded = tenant.onboarded;
|
|
351
|
+
newtenant.authority = tenant.authority;
|
|
352
|
+
newtenant.workspaceIDs = tenant.workspaceIDs;
|
|
353
|
+
newtenant.sel = tenant.sel;
|
|
354
|
+
return newtenant;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
if (typeof ii.cs === "undefined") {
|
|
358
|
+
this.cs = new Array<Config>();
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
this.cs = ii.cs.map((config: Config) => {
|
|
362
|
+
let newconfig: Config = new Config();
|
|
363
|
+
newconfig.id = config.id;
|
|
364
|
+
newconfig.workspaceId = config.workspaceId;
|
|
365
|
+
newconfig.name = config.name;
|
|
366
|
+
newconfig.description = config.description;
|
|
367
|
+
newconfig.tenants = config.tenants;
|
|
368
|
+
newconfig.isEnabled = config.isEnabled;
|
|
369
|
+
newconfig.workspaceIDs = config.workspaceIDs;
|
|
370
|
+
newconfig.sel = config.sel;
|
|
371
|
+
return newconfig;
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
if (typeof ii.ws === "undefined") {
|
|
375
|
+
this.ws = new Array<Workspace>();
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
this.ws = ii.ws.map((workspace: Workspace) => {
|
|
379
|
+
let newworkspace: Workspace = new Workspace();
|
|
380
|
+
newworkspace.id = workspace.id;
|
|
381
|
+
newworkspace.name = workspace.name;
|
|
382
|
+
newworkspace.associatedUsers = workspace.associatedUsers;
|
|
383
|
+
newworkspace.associatedTenants = workspace.associatedTenants;
|
|
384
|
+
newworkspace.associatedConfigs = workspace.associatedConfigs;
|
|
385
|
+
newworkspace.sel = workspace.sel;
|
|
386
|
+
return newworkspace;
|
|
387
|
+
});
|
|
388
|
+
}
|
|
310
389
|
}
|
|
311
390
|
}
|
|
312
391
|
export type TaskType = "initialization" |
|
|
@@ -1388,7 +1467,7 @@ export async function initGet(instance: IPublicClientApplication, authorizedUser
|
|
|
1388
1467
|
tenant.domain = user.tid;
|
|
1389
1468
|
let bResult: boolean = await tenantUnauthenticatedLookup(tenant, debug);
|
|
1390
1469
|
if (bResult) {
|
|
1391
|
-
// success, we now know instance
|
|
1470
|
+
// success, we now know cloud instance where this tenant is provisioned
|
|
1392
1471
|
user.authority = tenant.authority;
|
|
1393
1472
|
// do we have a logged in user from the same authority as this newly proposed tenant?
|
|
1394
1473
|
let loggedInUser: User | undefined = ii.us.find((u: User) => (u.session === "Sign Out" && u.authority === user.authority));
|
|
@@ -1407,12 +1486,18 @@ export async function initGet(instance: IPublicClientApplication, authorizedUser
|
|
|
1407
1486
|
result = await workspaceInfoGet(instance, authorizedUser, user, ii, debug);
|
|
1408
1487
|
tasks.setTaskEnd("GET workspaces", new Date(), result.result ? "complete" : "failed");
|
|
1409
1488
|
}
|
|
1410
|
-
if
|
|
1411
|
-
|
|
1489
|
+
// if successful, return true result and the version in the result.error field
|
|
1490
|
+
if (result.result) {
|
|
1491
|
+
result.error = version;
|
|
1492
|
+
}
|
|
1493
|
+
// if failed, output version information to the log
|
|
1494
|
+
else {
|
|
1495
|
+
console.log("@mindline/sync package version: " + version);
|
|
1496
|
+
}
|
|
1412
1497
|
return result;
|
|
1413
1498
|
}
|
|
1414
1499
|
else {
|
|
1415
|
-
result.error = `${user.mail}
|
|
1500
|
+
result.error = `${user.mail} has insufficient privileges to lookup under authority: ${user.authority}.`;
|
|
1416
1501
|
result.result = false;
|
|
1417
1502
|
return result;
|
|
1418
1503
|
}
|
|
@@ -1452,7 +1537,14 @@ function processReturnedAdmins(workspace: Workspace, ii: InitInfo, returnedAdmin
|
|
|
1452
1537
|
if (dummyIndex !== -1) {
|
|
1453
1538
|
// clear and overwrite dummy
|
|
1454
1539
|
user = ii.us.at(dummyIndex);
|
|
1455
|
-
|
|
1540
|
+
// replace dummy User oid "1" with real oid in associatedTenants of all workspaces
|
|
1541
|
+
ii.ws.map((w: Workspace) => {
|
|
1542
|
+
let idx: number = w.associatedUsers.findIndex((oid: string) => oid == "1");
|
|
1543
|
+
if (idx !== -1) {
|
|
1544
|
+
w.associatedUsers.splice(idx, 1);
|
|
1545
|
+
w.associatedUsers.push(item.userId);
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1456
1548
|
}
|
|
1457
1549
|
else {
|
|
1458
1550
|
// create and track new user
|
|
@@ -1484,6 +1576,14 @@ function processReturnedTenants(workspace: Workspace, ii: InitInfo, returnedTena
|
|
|
1484
1576
|
if (dummyIndex !== -1) {
|
|
1485
1577
|
// clear and overwrite dummy
|
|
1486
1578
|
tenant = ii.ts.at(dummyIndex);
|
|
1579
|
+
// replace dummy Tenant id "1" with real id in associatedTenants of all workspaces
|
|
1580
|
+
ii.ws.map((w: Workspace) => {
|
|
1581
|
+
let idx: number = w.associatedTenants.findIndex((tid: string) => tid == "1");
|
|
1582
|
+
if (idx !== -1) {
|
|
1583
|
+
w.associatedTenants.splice(idx, 1);
|
|
1584
|
+
w.associatedTenants.push(item.tenantId);
|
|
1585
|
+
}
|
|
1586
|
+
});
|
|
1487
1587
|
} else {
|
|
1488
1588
|
// create and track new tenant
|
|
1489
1589
|
tenant = new Tenant();
|
|
@@ -1522,6 +1622,14 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
|
|
|
1522
1622
|
if (dummyIndex !== -1) {
|
|
1523
1623
|
// clear and overwrite dummy
|
|
1524
1624
|
config = ii.cs.at(dummyIndex);
|
|
1625
|
+
// replace dummy Config id "1" with real id in associatedConfigs of all workspaces
|
|
1626
|
+
ii.ws.map((w: Workspace) => {
|
|
1627
|
+
let idx: number = w.associatedConfigs.findIndex((id: string) => id == "1");
|
|
1628
|
+
if (idx !== -1) {
|
|
1629
|
+
w.associatedConfigs.splice(idx, 1);
|
|
1630
|
+
w.associatedConfigs.push(item.id);
|
|
1631
|
+
}
|
|
1632
|
+
});
|
|
1525
1633
|
} else {
|
|
1526
1634
|
// create and track new workspace
|
|
1527
1635
|
config = new Config();
|
|
@@ -1582,9 +1690,11 @@ async function workspaceInfoGet(instance: IPublicClientApplication, authorizedUs
|
|
|
1582
1690
|
workspace = ii.ws.at(wsIndex);
|
|
1583
1691
|
}
|
|
1584
1692
|
// clear associations as we are about to reset
|
|
1585
|
-
|
|
1586
|
-
workspace.
|
|
1587
|
-
workspace.
|
|
1693
|
+
// IN PROGRESS: do not clear so we can retain selection state
|
|
1694
|
+
//workspace.associatedUsers.length = 0;
|
|
1695
|
+
//workspace.associatedTenants.length = 0;
|
|
1696
|
+
//workspace.associatedConfigs.length = 0;
|
|
1697
|
+
// set id and name based on returned data
|
|
1588
1698
|
workspace.id = o.id;
|
|
1589
1699
|
workspace.name = o.name;
|
|
1590
1700
|
// parallel GET admins, tenants, configs associated with this workspace
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindline/sync",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.45",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"exports": "./index.ts",
|
|
7
7
|
"description": "sync is a node.js package encapsulating javscript classes required for configuring Mindline sync service.",
|
package/tenants.json
CHANGED
package/users.json
CHANGED
package/workspaces.json
CHANGED
|
Binary file
|