@mindline/sync 1.0.72 → 1.0.74

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.
Binary file
@@ -10,6 +10,14 @@
10
10
  "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
11
11
  "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.d.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
12
12
  },
13
+ {
14
+ "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\package.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
15
+ "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:package.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
16
+ },
17
+ {
18
+ "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\resources.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
19
+ "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:resources.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
20
+ },
13
21
  {
14
22
  "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
15
23
  "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:hybridspa.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
@@ -59,21 +67,47 @@
59
67
  ]
60
68
  },
61
69
  {
62
- "DockedWidth": 200,
63
- "SelectedChildIndex": 1,
70
+ "DockedWidth": 186,
71
+ "SelectedChildIndex": 3,
64
72
  "Children": [
65
73
  {
66
74
  "$type": "Document",
67
75
  "DocumentIndex": 2,
76
+ "Title": "package.json",
77
+ "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\package.json",
78
+ "RelativeDocumentMoniker": "package.json",
79
+ "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\package.json",
80
+ "RelativeToolTip": "package.json",
81
+ "ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
82
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
83
+ "WhenOpened": "2024-03-30T18:10:14.136Z",
84
+ "EditorCaption": ""
85
+ },
86
+ {
87
+ "$type": "Document",
88
+ "DocumentIndex": 4,
68
89
  "Title": "hybridspa.ts",
69
90
  "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
70
91
  "RelativeDocumentMoniker": "hybridspa.ts",
71
92
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
72
93
  "RelativeToolTip": "hybridspa.ts",
73
- "ViewState": "AQIAANwAAAAAAAAAAAAYwOgAAAAjAAAA",
94
+ "ViewState": "AQIAAGQBAAAAAAAAAIAmwAcCAAAEAAAA",
74
95
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
75
96
  "WhenOpened": "2023-11-25T02:18:34.862Z"
76
97
  },
98
+ {
99
+ "$type": "Document",
100
+ "DocumentIndex": 3,
101
+ "Title": "resources.json",
102
+ "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\resources.json",
103
+ "RelativeDocumentMoniker": "resources.json",
104
+ "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\resources.json",
105
+ "RelativeToolTip": "resources.json",
106
+ "ViewState": "AQIAAAgAAAAAAAAAAAAUwDkAAAABAAAA",
107
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
108
+ "WhenOpened": "2024-03-30T16:56:29.032Z",
109
+ "EditorCaption": ""
110
+ },
77
111
  {
78
112
  "$type": "Document",
79
113
  "DocumentIndex": 0,
@@ -82,11 +116,17 @@
82
116
  "RelativeDocumentMoniker": "index.ts",
83
117
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
84
118
  "RelativeToolTip": "index.ts",
85
- "ViewState": "AQIAAPwGAAAAAAAAAAAcwCwHAAAFAAAA",
119
+ "ViewState": "AQIAAOsBAAAAAAAAAAAAANEEAAAuAAAA",
86
120
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
87
121
  "WhenOpened": "2023-12-05T02:10:16.04Z",
88
122
  "EditorCaption": ""
89
- },
123
+ }
124
+ ]
125
+ },
126
+ {
127
+ "DockedWidth": 200,
128
+ "SelectedChildIndex": 0,
129
+ "Children": [
90
130
  {
91
131
  "$type": "Document",
92
132
  "DocumentIndex": 1,
@@ -95,7 +135,7 @@
95
135
  "RelativeDocumentMoniker": "index.d.ts",
96
136
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts",
97
137
  "RelativeToolTip": "index.d.ts",
98
- "ViewState": "AQIAABMBAAAAAAAAAAAEwCsBAAAEAAAA",
138
+ "ViewState": "AQIAAPsAAAAAAAAAAAAAABcBAAAIAAAA",
99
139
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
100
140
  "WhenOpened": "2024-01-01T16:19:43.325Z",
101
141
  "EditorCaption": ""
package/hybridspa.ts CHANGED
@@ -111,7 +111,7 @@ export async function adminDelete(
111
111
  //adminsGet
112
112
  export async function adminsGet(
113
113
  instance: IPublicClientApplication,
114
- authorizedUser: User,
114
+ user: User,
115
115
  workspaceID: string,
116
116
  debug: boolean
117
117
  ): Promise<APIResult> {
@@ -129,7 +129,7 @@ export async function adminsGet(
129
129
  let url: URL = new URL(endpoint);
130
130
  url.searchParams.append("workspaceId", workspaceID);
131
131
  // create headers
132
- const headers = await defineHeaders(instance, authorizedUser);
132
+ const headers = await defineHeaders(instance, user);
133
133
  // make endpoint call
134
134
  let options = { method: "GET", headers: headers };
135
135
  try {
@@ -499,7 +499,7 @@ export async function configPut(
499
499
  //configsGet
500
500
  export async function configsGet(
501
501
  instance: IPublicClientApplication,
502
- authorizedUser: User,
502
+ user: User,
503
503
  workspaceID: string,
504
504
  debug: boolean
505
505
  ): Promise<APIResult> {
@@ -517,7 +517,7 @@ export async function configsGet(
517
517
  let url: URL = new URL(endpoint);
518
518
  url.searchParams.append("workspaceId", workspaceID);
519
519
  // create headers
520
- const headers = await defineHeaders(instance, authorizedUser);
520
+ const headers = await defineHeaders(instance, user);
521
521
  // make endpoint call
522
522
  let options = { method: "GET", headers: headers };
523
523
  try {
@@ -560,7 +560,6 @@ export async function configsGet(
560
560
  //initPost
561
561
  export async function initPost(
562
562
  instance: IPublicClientApplication,
563
- authorizedUser: User,
564
563
  user: User,
565
564
  debug: boolean
566
565
  ): Promise<APIResult> {
@@ -575,7 +574,7 @@ export async function initPost(
575
574
  // create init endpoint
576
575
  let endpoint: string = mindlineConfig.initEndpoint();
577
576
  // create init headers
578
- const headers = await defineHeaders(instance, authorizedUser);
577
+ const headers = await defineHeaders(instance, user);
579
578
  // create init body
580
579
  let initBody: string = `
581
580
  {
@@ -665,7 +664,7 @@ export async function tenantDelete(
665
664
  //tenantsGet
666
665
  export async function tenantsGet(
667
666
  instance: IPublicClientApplication,
668
- authorizedUser: User,
667
+ user: User,
669
668
  workspaceID: string,
670
669
  debug: boolean
671
670
  ): Promise<APIResult> {
@@ -683,7 +682,7 @@ export async function tenantsGet(
683
682
  let url: URL = new URL(endpoint);
684
683
  url.searchParams.append("workspaceId", workspaceID);
685
684
  // create headers
686
- const headers = await defineHeaders(instance, authorizedUser);
685
+ const headers = await defineHeaders(instance, user);
687
686
  // make endpoint call
688
687
  let options = { method: "GET", headers: headers };
689
688
  try {
@@ -823,7 +822,6 @@ export async function workspacePut(instance: IPublicClientApplication, authorize
823
822
  //workspacesGet
824
823
  export async function workspacesGet(
825
824
  instance: IPublicClientApplication,
826
- authorizedUser: User,
827
825
  user: User,
828
826
  debug: boolean
829
827
  ): Promise<APIResult> {
@@ -840,7 +838,7 @@ export async function workspacesGet(
840
838
  // create workspace endpoint
841
839
  let url: URL = new URL(endpoint);
842
840
  // create workspace headers
843
- const headers = await defineHeaders(instance, authorizedUser);
841
+ const headers = await defineHeaders(instance, user);
844
842
  // make workspace endpoint call
845
843
  let options = { method: "GET", headers: headers };
846
844
  try {
package/index.d.ts CHANGED
@@ -265,6 +265,20 @@ declare module "@mindline/sync" {
265
265
  constructor(tid: string, name: string);
266
266
  update(total: number, read: number, written: number, deferred: number): void;
267
267
  }
268
+ export class ResourceArray {
269
+ resourceNodes: ResourceNode[];
270
+ constructor(bClearLocalStorage: boolean);
271
+ // get initial data from localStorage or file
272
+ init(bClearLocalStorage: boolean): void;
273
+ }
274
+ export class ResourceNode {
275
+ type: string;
276
+ resource: string;
277
+ cost: number;
278
+ expanded: boolean;
279
+ resources: ResourceNode[];
280
+ constructor(type: string, resource: string, cost: number);
281
+ }
268
282
  //
269
283
  // Azure AD Graph API
270
284
  //
package/index.ts CHANGED
@@ -10,6 +10,7 @@ import configs from "./configs.json";
10
10
  import workspaces from "./workspaces.json";
11
11
  import tasksData from "./tasks";
12
12
  import syncmilestones from './syncmilestones';
13
+ import resources from './resources';
13
14
  import { log } from "console";
14
15
  const FILTER_FIELD = "workspaceIDs";
15
16
  // called by unit tests
@@ -1228,6 +1229,53 @@ export class TenantNode {
1228
1229
  }
1229
1230
  }
1230
1231
  }
1232
+ export class ResourceArray {
1233
+ resourceNodes: ResourceNode[];
1234
+ constructor(bClearLocalStorage: boolean) {
1235
+ this.resourceNodes = new Array<ResourceNode>();
1236
+ this.init(bClearLocalStorage);
1237
+ }
1238
+ // get initial data from localStorage or file
1239
+ init(bClearLocalStorage: boolean): void {
1240
+ console.log(`Calling ResourceArray::init(bClearLocalStorage: ${bClearLocalStorage ? "true" : "false"})`);
1241
+ // if we have a non-empty string value stored, read it from localStorage
1242
+ if (storageAvailable("localStorage")) {
1243
+ let result = localStorage.getItem("RBAC");
1244
+ if (result != null && typeof result === "string" && result !== "") {
1245
+ if (bClearLocalStorage) {
1246
+ localStorage.removeItem("RBAC");
1247
+ }
1248
+ else {
1249
+ let resourceArrayString: string = result;
1250
+ let raFromLocalStorage: ResourceArray = JSON.parse(resourceArrayString);
1251
+ this.resourceNodes = raFromLocalStorage.resourceNodes;
1252
+ return;
1253
+ }
1254
+ }
1255
+ }
1256
+ // if storage unavailable or we were just asked to clear, read defaults to enable usable UI
1257
+ var resourcesString = JSON.stringify(resources);
1258
+ try {
1259
+ this.resourceNodes = deserializeArray(ResourceNode, resourcesString);
1260
+ } catch (e) {
1261
+ debugger;
1262
+ }
1263
+ }
1264
+ }
1265
+ export class ResourceNode {
1266
+ type: string;
1267
+ resource: string;
1268
+ cost: number;
1269
+ expanded: boolean;
1270
+ resources: ResourceNode[];
1271
+ constructor(type: string, resource: string, cost: number) {
1272
+ this.type = type;
1273
+ this.resource = resource;
1274
+ this.cost = cost;
1275
+ this.expanded = false;
1276
+ this.resources = new Array<ResourceNode>();
1277
+ }
1278
+ }
1231
1279
  // ======================= Azure AD Graph API ===============================
1232
1280
  export async function groupsGet(instance: IPublicClientApplication, user: User | undefined, groupSearchString: string): Promise<{ groups: Group[], error: string }> {
1233
1281
  // need a logged in user to get graph users
@@ -1805,35 +1853,26 @@ export async function initGet(instance: IPublicClientApplication, user: User, ii
1805
1853
  if (bResult) {
1806
1854
  // success, we now know cloud instance where this tenant is provisioned
1807
1855
  user.authority = tenant.authority;
1808
- // do we have a logged in user from the same authority as this newly proposed tenant?
1809
- let loggedInUser: User | undefined = ii.us.find((u: User) => (u.session === "Sign Out" && u.authority === user.authority));
1810
- if (loggedInUser != null) {
1811
- // get tenant name and domain from AAD to pass to Configuration API
1812
- tasks.setTaskStart("GET tenant details", new Date());
1813
- result.result = await tenantRelationshipsGetById(user, tenant, ii, instance, debug);
1814
- tasks.setTaskEnd("GET tenant details", new Date(), "complete");
1815
- // store tenant name and domain on user, POST user and tenant to back end
1816
- if (result.result) {
1817
- user.companyName = tenant.name;
1818
- user.companyDomain = tenant.domain;
1819
- tasks.setTaskStart("POST config init", new Date());
1820
- result = await initPost(instance, loggedInUser, user, debug);
1821
- tasks.setTaskEnd("POST config init", new Date(), result.result ? "complete" : "failed");
1822
- }
1823
- // simlarly, if we just did our first post, then query config backend for workspace(s) associated with this user
1824
- if (result.result) {
1825
- tasks.setTaskStart("GET workspaces", new Date());
1826
- result = await workspaceInfoGet(instance, loggedInUser, user, ii, debug);
1827
- tasks.setTaskEnd("GET workspaces", new Date(), result.result ? "complete" : "failed");
1828
- }
1829
- console.log("initGet complete. Version: " + version);
1830
- return result;
1856
+ // get tenant name and domain from AAD to pass to Configuration API
1857
+ tasks.setTaskStart("GET tenant details", new Date());
1858
+ result.result = await tenantRelationshipsGetById(user, tenant, ii, instance, debug);
1859
+ tasks.setTaskEnd("GET tenant details", new Date(), "complete");
1860
+ // store tenant name and domain on user, POST user and tenant to back end
1861
+ if (result.result) {
1862
+ user.companyName = tenant.name;
1863
+ user.companyDomain = tenant.domain;
1864
+ tasks.setTaskStart("POST config init", new Date());
1865
+ result = await initPost(instance, user, debug);
1866
+ tasks.setTaskEnd("POST config init", new Date(), result.result ? "complete" : "failed");
1831
1867
  }
1832
- else {
1833
- result.error = `${user.mail} has insufficient privileges to lookup under authority: ${user.authority}.`;
1834
- result.result = false;
1835
- return result;
1868
+ // simlarly, if we just did our first post, then query config backend for workspace(s) associated with this user
1869
+ if (result.result) {
1870
+ tasks.setTaskStart("GET workspaces", new Date());
1871
+ result = await workspaceInfoGet(instance, user, ii, debug);
1872
+ tasks.setTaskEnd("GET workspaces", new Date(), result.result ? "complete" : "failed");
1836
1873
  }
1874
+ console.log("initGet complete. Version: " + version);
1875
+ return result;
1837
1876
  }
1838
1877
  else {
1839
1878
  result.error = `Failed to retrieve authority for user "${user.mail}" TID ${user.tid}.`;
@@ -2014,11 +2053,11 @@ function processReturnedConfigs(workspace: Workspace, ii: InitInfo, returnedConf
2014
2053
  });
2015
2054
  ii.save();
2016
2055
  }
2017
- async function workspaceInfoGet(instance: IPublicClientApplication, authorizedUser: User, user: User, ii: InitInfo, debug: boolean): Promise<APIResult> {
2056
+ async function workspaceInfoGet(instance: IPublicClientApplication, user: User, ii: InitInfo, debug: boolean): Promise<APIResult> {
2018
2057
  let result: APIResult = new APIResult();
2019
2058
  if (debug) debugger;
2020
2059
  try {
2021
- result = await workspacesGet(instance, authorizedUser, user, debug);
2060
+ result = await workspacesGet(instance, user, debug);
2022
2061
  if (result.result) {
2023
2062
  for (let o of result.array!) {
2024
2063
  // are we already tracking this workspace?
@@ -2071,9 +2110,9 @@ async function workspaceInfoGet(instance: IPublicClientApplication, authorizedUs
2071
2110
  workspace.name = o.name;
2072
2111
  workspace.ownerid = o.workspaceOwnerUserId;
2073
2112
  // parallel GET admins, tenants, configs associated with this workspace
2074
- let adminsPromise: Promise<APIResult> = adminsGet(instance, authorizedUser, workspace.id, debug);
2075
- let tenantsPromise: Promise<APIResult> = tenantsGet(instance, authorizedUser, workspace.id, debug);
2076
- let configsPromise: Promise<APIResult> = configsGet(instance, authorizedUser, workspace.id, debug);
2113
+ let adminsPromise: Promise<APIResult> = adminsGet(instance, user, workspace.id, debug);
2114
+ let tenantsPromise: Promise<APIResult> = tenantsGet(instance, user, workspace.id, debug);
2115
+ let configsPromise: Promise<APIResult> = configsGet(instance, user, workspace.id, debug);
2077
2116
  // wait for all to finish, return on any failure
2078
2117
  let [adminsResult, tenantsResult, configsResult] = await Promise.all([adminsPromise, tenantsPromise, configsPromise]);
2079
2118
  if (!adminsResult.result) return adminsResult;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
3
  "type": "module",
4
- "version": "1.0.72",
4
+ "version": "1.0.74",
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/resources.json ADDED
@@ -0,0 +1,58 @@
1
+ [
2
+ {
3
+ "type": "mg",
4
+ "resource": "Tenant Root Group",
5
+ "cost": 0,
6
+ "expanded": true,
7
+ "resources": [
8
+ {
9
+ "type": "sub",
10
+ "resource": "Applications",
11
+ "cost": 16677.52,
12
+ "expanded": true,
13
+ "resources": [
14
+ {
15
+ "type": "rg",
16
+ "resource": "ssfdev",
17
+ "cost": 7500.08,
18
+ "expanded": true,
19
+ "resources": [
20
+ {
21
+ "type": "resources",
22
+ "resource": "SSFServices",
23
+ "cost": 0,
24
+ "expanded": false,
25
+ "resources": [
26
+ ]
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ },
32
+ {
33
+ "type": "sub",
34
+ "resource": "Infrastructure",
35
+ "cost": 8737.58,
36
+ "expanded": true,
37
+ "resources": [
38
+ {
39
+ "type": "rg",
40
+ "resource": "SFFA_Prod_Mgmt_Shared_Resources_RG",
41
+ "cost": 7500.08,
42
+ "expanded": true,
43
+ "resources": [
44
+ {
45
+ "type": "resources",
46
+ "resource": "SSFA-Prod-UTIL-01",
47
+ "cost": 0,
48
+ "expanded": false,
49
+ "resources": [
50
+ ]
51
+ }
52
+ ]
53
+ }
54
+ ]
55
+ }
56
+ ]
57
+ }
58
+ ]