@mindline/sync 1.0.11 → 1.0.12

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 ADDED
@@ -0,0 +1,21 @@
1
+ [
2
+ {
3
+ "id": "1",
4
+ "name": "ProdSync",
5
+ "description": "Automated sync of users from Mindline1 to Mindline2",
6
+ "targetConfigs":
7
+ [
8
+ {
9
+ "tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
10
+ "sourceGroups": ["TODO"],
11
+ "targetGroup": ""
12
+ },
13
+ {
14
+ "tid": "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e",
15
+ "sourceGroups": [],
16
+ "targetGroup": "TODO"
17
+ }
18
+ ],
19
+ "enabled": "false"
20
+ }
21
+ ]
package/index.js CHANGED
@@ -1,107 +1,116 @@
1
1
  //index.js
2
2
 
3
- // called by unit test
3
+ // called by unit tests
4
4
  export function sum(a, b) {
5
5
  return a + b;
6
6
  }
7
-
8
- // called by simpleclass test app
9
7
  export function helloNpm() {
10
8
  return "hello NPM";
11
9
  }
12
10
 
13
11
  export class User {
14
12
  constructor(){
15
- this.authority = "";
16
13
  this.oid = "";
17
- this.tid = "";
18
- this.upn = "";
19
14
  this.name = "";
15
+ this.mail = "";
16
+ this.authority = "";
17
+ this.tid = "";
18
+ this.companyName = "";
19
+ this.companyDomain = "";
20
+ this.associatedWorkspaces = {};
20
21
  }
21
22
  }
22
23
 
23
- export class UserConfigInfo {
24
- constructor(){
25
- this.vts = null;
26
- this.sts = null;
27
- this.scs = null;
28
- }
29
- }
30
-
31
- // shared base class of virtual and sync tenants
32
- export class Tenant {
24
+ export class Target {
33
25
  constructor(){
34
- this.authority = "";
35
26
  this.tid = "";
36
27
  this.name = "";
37
28
  this.domain = "";
29
+ this.type = "";
30
+ this.authority = "";
31
+ this.readServicePrincipal = "";
32
+ this.writeServicePrincipal = "";
38
33
  }
39
34
  }
40
35
 
41
- // class for "hub" tenants
42
- export class VirtualTenant extends Tenant {
36
+ export class Config {
43
37
  constructor(){
44
- super();
38
+ this.id = "";
39
+ this.name = "";
45
40
  this.description = "";
41
+ this.targetConfigs = {};
42
+ this.enabled = false;
46
43
  }
47
44
  }
48
45
 
49
- // class for "spoke" tenants
50
- export class SyncTenant extends Tenant {
46
+ export class Workspace {
51
47
  constructor(){
52
- super();
53
- this.tenantType = "";
54
- this.readServicePrincipal = "";
55
- this.writeServicePrincipal = "";
56
- this.virtualTenantID = "";
48
+ this.id = "";
49
+ this.name = "";
50
+ this.associatedUsers = {};
51
+ this.associatedTargets = {};
52
+ this.associatedConfigs = {};
57
53
  }
58
54
  }
59
55
 
60
- // class for sync configuration
61
- export class SyncConfig {
56
+ export class PortalConfigInfo {
62
57
  constructor(){
63
- this.enabled = "";
64
- this.virtualTenantID = "";
65
- this.deltaLink = "";
58
+ this.us = {};
59
+ this.ts = {};
60
+ this.cs = {};
61
+ this.ws = {};
66
62
  }
67
63
  }
68
64
 
69
- import { deserializeArray } from 'class-transformer';
70
- import virtualTenants from "./virtualTenants.json";
71
- import syncTenants from "./syncTenants.json";
72
- import syncConfigs from "./syncConfigs.json";
73
65
 
74
- // called by unit test
75
- export function readobjects() {
76
- // convert read JSON to VirtualTenant array
77
- debugger;
78
- let virtuals = null;
79
- var virtualTenantsString = JSON.stringify(virtualTenants);
80
- try {
81
- virtuals = deserializeArray(VirtualTenant, virtualTenantsString);
82
- } catch (e) {
83
- debugger;
84
- return 0;
85
- }
86
- // make some assertion about the data we just read
87
- return virtuals.length;
88
- }
66
+ import { deserializeArray } from 'class-transformer';
67
+ import users from "./users.json";
68
+ import targets from "./targets.json";
69
+ import configs from "./configs.json";
70
+ import workspaces from "./workspaces.json";
89
71
 
90
- // retrievesync configurations based on passed user information
91
- export function readConfigs(user, userConfigInfo)
72
+ // retrieve Workspace(s), User(s), Target(s), Config(s) given logged in user
73
+ export function InitPortal(user, portalConfigInfo)
92
74
  {
93
75
  debugger;
94
76
  // for now, just get hardcoded data from JSON
95
- var virtualTenantsString = JSON.stringify(virtualTenants);
96
- var syncTenantsString = JSON.stringify(syncTenants);
97
- var syncConfigsString = JSON.stringify(syncConfigs);
77
+ var usersString = JSON.stringify(users);
78
+ var targetsString = JSON.stringify(targets);
79
+ var configsString = JSON.stringify(configs);
80
+ var workspacesString = JSON.stringify(workspaces);
98
81
  try {
99
- userConfigInfo.vts = deserializeArray(VirtualTenant, virtualTenantsString);
100
- userConfigInfo.sts = deserializeArray(SyncTenant, syncTenantsString);
101
- userConfigInfo.scs = deserializeArray(SyncConfig, syncConfigsString);
82
+ portalConfigInfo.us = deserializeArray(User, usersString);
83
+ portalConfigInfo.ts = deserializeArray(Target, targetsString);
84
+ portalConfigInfo.cs = deserializeArray(Config, configsString);
85
+ portalConfigInfo.ws = deserializeArray(Workspace, workspacesString);
102
86
  } catch (e) {
103
87
  debugger;
104
88
  return false;
105
89
  }
106
90
  return true;
91
+ }
92
+
93
+ export function AddTarget()
94
+ {
95
+ return true;
96
+ }
97
+
98
+ export function CompleteTarget()
99
+ {
100
+ return true;
101
+ }
102
+
103
+ export function AddUser()
104
+ {
105
+ return true;
106
+ }
107
+
108
+ export function CompleteUser()
109
+ {
110
+ return true;
111
+ }
112
+
113
+ export function CreateConfig()
114
+ {
115
+ return true;
107
116
  }
package/index.test.js CHANGED
@@ -1,15 +1,12 @@
1
- import {sum, readobjects, readConfigs, User, UserConfigInfo, VirtualTenant, SyncTenant, SyncConfig} from "./index.js";
1
+ import {sum, User, PortalConfigInfo, InitPortal } from "./index.js";
2
2
  import {test, expect} from "vitest";
3
3
 
4
4
  test("adds 1 + 2 to equal 3", () => {
5
5
  expect(sum(1, 2)).toBe(3);
6
6
  });
7
- test("loads array of VirtualTenants from JSON and expects 2", () => {
8
- expect(readobjects()).toBe(2);
9
- });
10
7
  test("loads config based on a user and expects function to return true", () => {
11
8
  let u = new User();
12
- let uci = new UserConfigInfo();
13
- expect(readConfigs(u, uci)).toBe(true);
14
- expect(uci.vts.length).toBe(2);
9
+ let pci = new PortalConfigInfo();
10
+ expect(InitPortal(u, pci)).toBe(true);
11
+ expect(pci.us.length).toBe(2);
15
12
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
3
  "type": "module",
4
- "version": "1.0.11",
4
+ "version": "1.0.12",
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
@@ -2,50 +2,64 @@ declare module "@mindline/sync" {
2
2
  export function sum(a: number, b: number): number;
3
3
  export function helloNpm(): string;
4
4
 
5
- // user information passed to back end
5
+ // admin
6
6
  export class User {
7
- authority: string; // from AAD
8
- oid: string; // from AAD
9
- tid: string; // from AAD
10
- upn: string; // from AAD
11
- name: string; // from AAD
7
+ oid: string; // from AAD ID token
8
+ name: string; // from AAD ID token
9
+ mail: string; // from AAD ID token TODO: preferred_username *may* differ from UPN, may differ from mail
10
+ authority: string; // from AAD auth response - cloud instance login endpoint
11
+ tid: string; // from AAD ID token
12
+ companyName: string; // findTenantInformationByTenantId TODO: process changes to company name
13
+ companyDomain: string; // findTenantInformationByTenantId TODO: process changes to company name
14
+ associatedWorkspaces: string[];
12
15
  }
13
16
 
14
- // configuration information returned by back end
15
- export class UserConfigInfo {
16
- vts: VirtualTenant[];
17
- sts: SyncTenant[];
18
- scs: SyncConfig[];
17
+ // target (Azure AD tenant, AD domain, Google workspace)
18
+ enum TargetType { AAD = 1, AD, Google }
19
+ export class Target {
20
+ tid: string; // from AAD ID token
21
+ name: string; // findTenantInformationByTenantId
22
+ domain: string; // findTenantInformationByTenantId
23
+ type: TargetType; // always AAD for now
24
+ authority: string; // from AAD ID auth response
25
+ readServicePrincipal: string; // from AAD consent
26
+ writeServicePrincipal: string; // from AAD consent
19
27
  }
20
28
 
21
- // shared base class of virtual and sync tenants
22
- export class Tenant {
23
- authority: string; // from AAD
24
- tid: string; // from AAD
25
- name: string; // from AAD: tenant display name
26
- domain: string; // from AAD: tenant default domain
29
+ // config
30
+ export class TargetConfigInfo {
31
+ tid: string; // target identifier
32
+ sourceGroups: string[]; // source groups - we can confiure multiple source groups for reading (*may* slow things down, but less work for admin)
33
+ targetGroup: string; // target group - we only write users to a single target group (complex to fiugure out which users get written to which groups)
27
34
  }
28
-
29
- // class for "hub" tenants
30
- export class VirtualTenant extends Tenant {
31
- description: string; // from DB
35
+ export class Config {
36
+ id: string;
37
+ name: string;
38
+ description: string;
39
+ targetConfigs: TargetConfigInfo[];
40
+ enabled: boolean;
32
41
  }
33
42
 
34
- // class for "spoke" tenants
35
- export class SyncTenant extends Tenant {
36
- tenantType: string; // from DB: AAD | AD | Google -- always AAD for now
37
- readServicePrincipal: string; // from AAD
38
- writeServicePrincipal: string; // from AAD
39
- virtualTenantID: string;
43
+ // class to group Users, Tenants, and Configs
44
+ export class Workspace {
45
+ id: string;
46
+ name: string;
47
+ associatedUsers: string[];
48
+ associatedTargets: string[];
49
+ associatedConfigs: string[];
40
50
  }
41
51
 
42
- // class for sync configuration
43
- export class SyncConfig {
44
- enabled: boolean; // from DB
45
- virtualTenantID: string;
46
- deltaLink: string;
52
+ export class PortalConfigInfo {
53
+ us: User[];
54
+ ts: Target[];
55
+ cs: Config[];
56
+ ws: Workspace[];
47
57
  }
48
58
 
49
- export function readobjects(): number;
50
- export function readConfigs(u: User, uci: UserConfigInfo): boolean;
59
+ export function InitPortal(u: User, pci: PortalConfigInfo): boolean;
60
+ export function AddTarget(): boolean;
61
+ export function CompleteTarget(): boolean;
62
+ export function AddUser(): boolean;
63
+ export function CompleteUser(): boolean;
64
+ export function CreateConfig(): boolean;
51
65
  }
package/targets.json ADDED
@@ -0,0 +1,20 @@
1
+ [
2
+ {
3
+ "tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
4
+ "name": "Mindline1",
5
+ "domain": "mindline1.onmicrosoft.com",
6
+ "type": "1",
7
+ "authority": "https://login.microsoftonline.com/common/",
8
+ "readServicePrincipal": "TODO",
9
+ "writeServicePrincipal": "TODO"
10
+ },
11
+ {
12
+ "tid": "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e",
13
+ "name": "Mindline2",
14
+ "domain": "mindline2.onmicrosoft.com",
15
+ "type": "1",
16
+ "authority": "https://login.microsoftonline.com/common/",
17
+ "readServicePrincipal": "TODO",
18
+ "writeServicePrincipal": "TODO"
19
+ }
20
+ ]
package/users.json ADDED
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "oid": "102bafe7-9e62-4993-b943-2f20c609e5c9",
4
+ "name": "Arvind Suthar",
5
+ "mail": "arvind@mindline1.onmicrosoft.com",
6
+ "authority": "https://login.microsoftonline.com/common/",
7
+ "tid": "7f4567b8-f9a9-4ad3-9cb5-ef16a80e5744",
8
+ "companyName": "Mindline1",
9
+ "companyDomain": "mindline1.onmicrosoft.com",
10
+ "associatedWorkspaces": [ "1" ]
11
+ },
12
+ {
13
+ "oid": "e5a42d0c-4fa5-4a65-8d9b-90f989ecae9b",
14
+ "name": "Arvind Suthar",
15
+ "mail": "arvind@mindline2.onmicrosoft.com",
16
+ "authority": "https://login.microsoftonline.com/common/",
17
+ "tid": "df9c2e0a-f6fe-43bb-a155-d51f66dffe0e",
18
+ "companyName": "Mindline2",
19
+ "companyDomain": "mindline2.onmicrosoft.com",
20
+ "associatedWorkspaces": [ "1" ]
21
+ }
22
+ ]
@@ -0,0 +1,9 @@
1
+ [
2
+ {
3
+ "id": "1",
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" ]
8
+ }
9
+ ]