@mindline/sync 1.0.29 → 1.0.30
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 +3 -14
- package/configs2.json +19 -31
- package/hybridspa.ts +822 -109
- package/index.d.ts +134 -25
- package/index.test.ts +1 -7
- package/index.ts +940 -134
- package/mockconfig.json +18 -0
- package/package.json +1 -2
- package/tasks.ts +103 -0
- package/{targets.json → tenants.json} +3 -1
- package/{targets2.json → tenants2.json} +6 -6
- package/workspaces.json +1 -1
- package/workspaces2.json +3 -3
package/index.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ declare module "@mindline/sync" {
|
|
|
4
4
|
export function sum(a: number, b: number): number;
|
|
5
5
|
export function helloNpm(): string;
|
|
6
6
|
|
|
7
|
+
export class Group {
|
|
8
|
+
id: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
7
12
|
// admin
|
|
8
13
|
export class User {
|
|
9
14
|
oid: string; // from AAD ID token
|
|
@@ -18,56 +23,160 @@ declare module "@mindline/sync" {
|
|
|
18
23
|
session: string;
|
|
19
24
|
spacode: string;
|
|
20
25
|
accessToken: string;
|
|
26
|
+
loginHint: string;
|
|
27
|
+
scopes: string[];
|
|
28
|
+
authTS: Date;
|
|
29
|
+
constructor();
|
|
21
30
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
// tenant (Azure AD tenant, AD domain, Google workspace)
|
|
32
|
+
export enum TenantType {
|
|
33
|
+
invalid = 0,
|
|
34
|
+
aad = 1,
|
|
35
|
+
ad = 2,
|
|
36
|
+
googleworkspace = 3
|
|
37
|
+
}
|
|
38
|
+
type TenantTypeStrings = keyof typeof TenantType;
|
|
39
|
+
export enum TenantPermissionType {
|
|
40
|
+
read = 1,
|
|
41
|
+
write = 2,
|
|
42
|
+
notassigned = 3
|
|
43
|
+
}
|
|
44
|
+
type TenantPermissionTypeStrings = keyof typeof TenantPermissionType;
|
|
45
|
+
export class Tenant {
|
|
46
|
+
tid: string; // from AAD ID token
|
|
47
|
+
name: string; // findTenantInformationByTenantId
|
|
48
|
+
domain: string; // findTenantInformationByTenantId
|
|
49
|
+
tenantType: TenantTypeStrings; // always "aad" for now
|
|
50
|
+
permissionType: TenantPermissionTypeStrings; // read/write/notassigned
|
|
51
|
+
onboarded: string; // have we onboarded this tenant? "true" or "false"
|
|
29
52
|
authority: string; // from AAD ID auth response
|
|
30
53
|
readServicePrincipal: string; // from AAD consent
|
|
31
54
|
writeServicePrincipal: string; // from AAD consent
|
|
32
55
|
workspaceIDs: string;
|
|
56
|
+
constructor();
|
|
33
57
|
}
|
|
34
|
-
|
|
35
58
|
// config
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
export enum TenantConfigType {
|
|
60
|
+
source = 1,
|
|
61
|
+
target = 2,
|
|
62
|
+
sourcetarget = 3
|
|
63
|
+
}
|
|
64
|
+
export type TenantConfigTypeStrings = keyof typeof TenantConfigType;
|
|
65
|
+
export class TenantConfigInfo {
|
|
66
|
+
tid: string; // tenant identifier
|
|
67
|
+
sourceGroupId: string; // source group - we can configure source group for reading
|
|
68
|
+
sourceGroupName: string; // source group - we can configure source group for reading
|
|
69
|
+
configurationTenantType: TenantConfigTypeStrings;
|
|
40
70
|
}
|
|
41
71
|
export class Config {
|
|
42
72
|
id: string;
|
|
73
|
+
workspaceId: string;
|
|
43
74
|
name: string;
|
|
44
75
|
description: string;
|
|
45
|
-
|
|
46
|
-
|
|
76
|
+
tenants: TenantConfigInfo[];
|
|
77
|
+
isEnabled: boolean;
|
|
47
78
|
workspaceIDs: string;
|
|
79
|
+
constructor();
|
|
48
80
|
}
|
|
49
|
-
|
|
50
81
|
// class to group Users, Tenants, and Configs
|
|
51
82
|
export class Workspace {
|
|
52
83
|
id: string;
|
|
53
84
|
name: string;
|
|
54
85
|
associatedUsers: string[];
|
|
55
|
-
|
|
86
|
+
associatedTenants: string[];
|
|
56
87
|
associatedConfigs: string[];
|
|
88
|
+
constructor();
|
|
57
89
|
}
|
|
58
|
-
|
|
59
90
|
export class InitInfo {
|
|
60
91
|
us: User[];
|
|
61
|
-
ts:
|
|
92
|
+
ts: Tenant[];
|
|
62
93
|
cs: Config[];
|
|
63
94
|
ws: Workspace[];
|
|
95
|
+
constructor(bClearLocalStorage: boolean);
|
|
96
|
+
init(bClearLocalStorage: boolean): void;
|
|
97
|
+
save(): void;
|
|
64
98
|
tagWithWorkspaces(): boolean;
|
|
65
99
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
100
|
+
export type TaskType = "initialization" |
|
|
101
|
+
"authenticate user" |
|
|
102
|
+
"reload React" |
|
|
103
|
+
"PUT access token" |
|
|
104
|
+
"GET tenant details" |
|
|
105
|
+
"POST config init" |
|
|
106
|
+
"GET workspaces" |
|
|
107
|
+
"onboard tenant" |
|
|
108
|
+
"create 2nd tenant" |
|
|
109
|
+
"invite 2nd admin" |
|
|
110
|
+
"onboard 2nd tenant" |
|
|
111
|
+
"create config";
|
|
112
|
+
export class TaskArray {
|
|
113
|
+
tasks: Task[];
|
|
114
|
+
constructor(bClearLocalStorage: boolean);
|
|
115
|
+
init(bClearLocalStorage: boolean): void;
|
|
116
|
+
setTaskStart(taskType: TaskType, startDate: Date): void;
|
|
117
|
+
setTaskEnd(taskType: TaskType, startDate: Date, status: string): void;
|
|
118
|
+
}
|
|
119
|
+
export class Task {
|
|
120
|
+
id: number;
|
|
121
|
+
task: string;
|
|
122
|
+
start: Date;
|
|
123
|
+
startDisplay: string;
|
|
124
|
+
end: Date;
|
|
125
|
+
endDisplay: string;
|
|
126
|
+
elapsedDisplay: string;
|
|
127
|
+
expected: number;
|
|
128
|
+
status: string;
|
|
129
|
+
expanded: boolean;
|
|
130
|
+
subtasks: Task[];
|
|
131
|
+
setEnd(endDate: Date): void;
|
|
132
|
+
setStart(startDate: Date): void;
|
|
133
|
+
}
|
|
134
|
+
export class BatchArray {
|
|
135
|
+
tenantNodes: TenantNode[];
|
|
136
|
+
constructor(config: Config|null, syncPortalGlobalState: InitInfo|null, bClearLocalStorage: boolean);
|
|
137
|
+
// populate tenantNodes based on config tenants
|
|
138
|
+
init(config: Config|null, syncPortalGlobalState: InitInfo|null, bClearLocalStorage: boolean): void;
|
|
139
|
+
test(): void;
|
|
140
|
+
}
|
|
141
|
+
export class TenantNode {
|
|
142
|
+
expanded: boolean;
|
|
143
|
+
status: string;
|
|
144
|
+
name: string;
|
|
145
|
+
tid: string;
|
|
146
|
+
total: number;
|
|
147
|
+
read: number;
|
|
148
|
+
written: number;
|
|
149
|
+
deferred: number;
|
|
150
|
+
targets: TenantNode[];
|
|
151
|
+
constructor(tid: string, name: string);
|
|
152
|
+
update(total: number, read: number, written: number, deferred: number): void;
|
|
153
|
+
}
|
|
154
|
+
export class APIResult {
|
|
155
|
+
result: boolean;
|
|
156
|
+
status: number;
|
|
157
|
+
error: string;
|
|
158
|
+
constructor();
|
|
159
|
+
}
|
|
160
|
+
//
|
|
161
|
+
// Azure AD Graph API
|
|
162
|
+
//
|
|
163
|
+
export function groupGet(tenant: Tenant, groupid: string): Promise<{group: string, error: string}>;
|
|
164
|
+
export function groupsGet(tenant: Tenant, groupSearchString: string): Promise<{groups: Group[], error: string}>;
|
|
165
|
+
export function signIn(user: User, tasks: TaskArray): void;
|
|
166
|
+
export function signInIncrementally(user: User, scope: string): void;
|
|
167
|
+
export function signOut(user: User): void;
|
|
168
|
+
export function tenantRelationshipsGetByDomain(loggedInuser: User, tenant: Tenant, instance: IPublicClientApplication, debug: boolean): boolean;
|
|
169
|
+
export function tenantRelationshipsGetById(user: User, ii: InitInfo, instance: IPublicClientApplication, tasks: TaskArray, debug: boolean): boolean;
|
|
170
|
+
export function usersGet(tenant: Tenant): {users: string[], error: string};
|
|
171
|
+
//
|
|
172
|
+
// Mindline Config API
|
|
173
|
+
//
|
|
174
|
+
export function configEdit(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): APIResult;
|
|
175
|
+
export function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): APIResult;
|
|
176
|
+
export function initGet(instance: IPublicClientApplication, authorizedUser: User, user: User, ii: InitInfo, tasks: TaskArray, debug: boolean): APIResult;
|
|
177
|
+
export function tenantAdd(instance: IPublicClientApplication, authorizedUser: User, tenant: Tenant, workspaceId: string): APIResult;
|
|
178
|
+
export function tenantComplete(instance: IPublicClientApplication, authorizedUser: User, tenant: Tenant, debug: boolean): APIResult;
|
|
179
|
+
export function tenantRemove(instance: IPublicClientApplication, authorizedUser: User, tenant: Tenant, workspaceId: string, debug: boolean): APIResult;
|
|
180
|
+
export function userAdd(instance: IPublicClientApplication, authorizedUser: User, user: User, workspaceId: string): APIResult;
|
|
181
|
+
export function userRemove(instance: IPublicClientApplication, authorizedUser: User, user: User, workspaceId: string): APIResult;
|
|
73
182
|
}
|
package/index.test.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {sum
|
|
1
|
+
import {sum} from "./index";
|
|
2
2
|
import {test, expect} from "vitest";
|
|
3
|
-
import {stubbedPublicClientApplication} from "@azure/msal-browser/dist";
|
|
4
3
|
|
|
5
4
|
test("adds 1 + 2 to equal 3", () => {
|
|
6
5
|
expect(sum(1, 2)).toBe(3);
|
|
7
|
-
});
|
|
8
|
-
test("loads config based on a user and expects function to return true", () => {
|
|
9
|
-
let ii = new InitInfo();
|
|
10
|
-
let bResult:boolean = InitGet(ii, stubbedPublicClientApplication, true);
|
|
11
|
-
expect(bResult);
|
|
12
6
|
});
|