@mindline/sync 1.0.85 → 1.0.86

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.
@@ -2,5 +2,6 @@
2
2
  "ExpandedNodes": [
3
3
  ""
4
4
  ],
5
+ "SelectedNode": "\\index.ts",
5
6
  "PreviewInSolutionExplorer": false
6
7
  }
package/.vs/slnx.sqlite CHANGED
Binary file
Binary file
@@ -3,16 +3,8 @@
3
3
  "WorkspaceRootPath": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\",
4
4
  "Documents": [
5
5
  {
6
- "AbsoluteMoniker": "D:1:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
7
- "RelativeMoniker": "D:1:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
8
- },
9
- {
10
- "AbsoluteMoniker": "D:2:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
11
- "RelativeMoniker": "D:2:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
12
- },
13
- {
14
- "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}",
15
- "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.d.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
6
+ "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}",
7
+ "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
16
8
  },
17
9
  {
18
10
  "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}",
@@ -26,7 +18,7 @@
26
18
  "DocumentGroups": [
27
19
  {
28
20
  "DockedWidth": 200,
29
- "SelectedChildIndex": -1,
21
+ "SelectedChildIndex": 9,
30
22
  "Children": [
31
23
  {
32
24
  "$type": "Bookmark",
@@ -59,56 +51,18 @@
59
51
  {
60
52
  "$type": "Bookmark",
61
53
  "Name": "ST:1:0:{d212f56b-c48a-434c-a121-1c5d80b59b9f}"
62
- }
63
- ]
64
- },
65
- {
66
- "DockedWidth": 168,
67
- "SelectedChildIndex": 1,
68
- "Children": [
69
- {
70
- "$type": "Document",
71
- "DocumentIndex": 2,
72
- "Title": "index.d.ts",
73
- "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts",
74
- "RelativeDocumentMoniker": "index.d.ts",
75
- "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts",
76
- "RelativeToolTip": "index.d.ts",
77
- "ViewState": "AQIAABoAAAAAAAAAAAAAABoAAAAoAAAA",
78
- "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
79
- "WhenOpened": "2025-01-29T23:22:53.18Z",
80
- "EditorCaption": ""
81
54
  },
82
55
  {
83
56
  "$type": "Document",
84
57
  "DocumentIndex": 1,
85
- "Title": "index.ts",
86
- "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
87
- "RelativeDocumentMoniker": "index.ts",
88
- "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
89
- "RelativeToolTip": "index.ts",
90
- "ViewState": "AQIAAOIIAAAAAAAAAAAAAOcIAAAAAAAA",
91
- "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
92
- "WhenOpened": "2025-01-29T23:46:37.773Z",
93
- "EditorCaption": ""
94
- }
95
- ]
96
- },
97
- {
98
- "DockedWidth": 232,
99
- "SelectedChildIndex": 1,
100
- "Children": [
101
- {
102
- "$type": "Document",
103
- "DocumentIndex": 3,
104
58
  "Title": "hybridspa.ts",
105
59
  "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
106
60
  "RelativeDocumentMoniker": "hybridspa.ts",
107
61
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
108
62
  "RelativeToolTip": "hybridspa.ts",
109
- "ViewState": "AQIAAAAAAAAAAAAAAAAAABQAAAAXAAAA",
63
+ "ViewState": "AgIAAAAAAAAAAAAAAAAAACsAAAAAAAAAAAAAAA==",
110
64
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
111
- "WhenOpened": "2024-11-04T14:16:26.493Z",
65
+ "WhenOpened": "2025-03-28T16:08:06.165Z",
112
66
  "EditorCaption": ""
113
67
  },
114
68
  {
@@ -119,15 +73,15 @@
119
73
  "RelativeDocumentMoniker": "index.ts",
120
74
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
121
75
  "RelativeToolTip": "index.ts",
122
- "ViewState": "AQIAAL0HAAAAAAAAAADgv9sHAAA1AAAA",
76
+ "ViewState": "AgIAAAAAAAAAAAAAAAAAAGEFAAAAAAAAAAAAAA==",
123
77
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
124
- "WhenOpened": "2025-01-29T14:51:05.763Z",
78
+ "WhenOpened": "2025-03-28T15:55:38.875Z",
125
79
  "EditorCaption": ""
126
80
  }
127
81
  ]
128
82
  },
129
83
  {
130
- "DockedWidth": 294,
84
+ "DockedWidth": 254,
131
85
  "SelectedChildIndex": -1,
132
86
  "Children": [
133
87
  {
@@ -137,7 +91,7 @@
137
91
  ]
138
92
  },
139
93
  {
140
- "DockedWidth": 294,
94
+ "DockedWidth": 200,
141
95
  "SelectedChildIndex": -1,
142
96
  "Children": [
143
97
  {
package/hybridspa.ts CHANGED
@@ -40,6 +40,7 @@ async function mindlineDefineHeaders(
40
40
  // always call acquireTokenSilent, handling expired tokens on exception
41
41
  const apiScope: string = getAPIScope(user);
42
42
  try {
43
+ debugger;
43
44
  let accounts: AccountInfo[] = instance.getAllAccounts();
44
45
  let homeAccountId = user.oid + "." + user.tid;
45
46
  let account: AccountInfo = null;
package/index.d.ts CHANGED
@@ -331,6 +331,7 @@ declare module "@mindline/sync" {
331
331
  export function userAdd(instance: IPublicClientApplication, authorizedUser: User, user: User, workspaceId: string): APIResult;
332
332
  export function userRemove(instance: IPublicClientApplication, authorizedUser: User, user: User, workspaceId: string): APIResult;
333
333
  export function workspaceEdit(instance: IPublicClientApplication, authorizedUser: User, workspaceId: string, workspaceName: string): Promise<APIResult>;
334
+ export function getPowerBIAccessToken(instance: IPublicClientApplication, user: User): Promise<string>;
334
335
  // ======================= Azure REST API ===============================
335
336
  export function canListRootAssignments(instance: IPublicClientApplication, user: User): Promise<boolean>;
336
337
  export function elevateGlobalAdminToUserAccessAdmin(instance: IPublicClientApplication, user: User): Promise<boolean>;
package/index.ts CHANGED
@@ -1363,7 +1363,7 @@ export class ActorNode {
1363
1363
  // ======================= Azure AD Graph API ===============================
1364
1364
  // helper functions
1365
1365
  function getGraphAPIScope(user: User): string {
1366
- return "Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All";
1366
+ return "Group.Read.All User.Read.All openid profile offline_access User.Read Contacts.Read CrossTenantInformation.ReadBasic.All https://analysis.windows.net/powerbi/api/App.Read.All https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All https://analysis.windows.net/powerbi/api/Report.ReadWrite.All https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All";
1367
1367
  }
1368
1368
  // TODO: this is where you want to trigger a re-authentication if token expires
1369
1369
  async function graphDefineHeaders(
@@ -1374,9 +1374,11 @@ async function graphDefineHeaders(
1374
1374
  headers.append("Content-Type", "application/json");
1375
1375
  headers.append("accept", "*/*");
1376
1376
  const graphAPIScope: string = getGraphAPIScope(user);
1377
+ debugger;
1377
1378
  // only call acquireTokenByCode if we have never redeemed the code
1378
1379
  if (user.graphAccessToken == null || user.graphAccessToken === "") {
1379
1380
  try {
1381
+ debugger;
1380
1382
  let response: AuthenticationResult = await instance.acquireTokenByCode({
1381
1383
  code: user.spacode,
1382
1384
  });
@@ -2319,6 +2321,38 @@ async function workspaceInfoGet(instance: IPublicClientApplication, user: User,
2319
2321
  result.status = 500;
2320
2322
  return result;
2321
2323
  }
2324
+ // ======================= PowerBI Access Token Retrieval ===============================
2325
+ export async function getPowerBIAccessToken(
2326
+ instance: IPublicClientApplication,
2327
+ user: User
2328
+ ): Promise<string> {
2329
+ let accesstoken: string = "";
2330
+ // retrieve access token silently
2331
+ try {
2332
+ let accounts: AccountInfo[] = instance.getAllAccounts();
2333
+ let homeAccountId = user.oid + "." + user.tid;
2334
+ let account: AccountInfo = null;
2335
+ for (let i: number = 0; i < accounts.length; i++) {
2336
+ if (accounts[i].homeAccountId == homeAccountId) {
2337
+ account = accounts[i];
2338
+ }
2339
+ }
2340
+ let response: AuthenticationResult = await instance.acquireTokenSilent({
2341
+ scopes: ["https://analysis.windows.net/powerbi/api/App.Read.All",
2342
+ "https://analysis.windows.net/powerbi/api/Dataset.ReadWrite.All",
2343
+ "https://analysis.windows.net/powerbi/api/Report.ReadWrite.All",
2344
+ "https://analysis.windows.net/powerbi/api/Workspace.ReadWrite.All"
2345
+ ],
2346
+ account: account
2347
+ });
2348
+ accesstoken = response.accessToken; // cache access token
2349
+ console.log("PowerBI token acquired silently: " + accesstoken.slice(0, 20));
2350
+ }
2351
+ catch (error: any) {
2352
+ console.log("PowerBI token failed to be acquired silently");
2353
+ }
2354
+ return accesstoken;
2355
+ }
2322
2356
  // ======================= Azure REST API ===============================
2323
2357
  // TODO: this is where you want to trigger a re-authentication if token expires
2324
2358
  async function azureDefineHeaders(
@@ -2339,7 +2373,6 @@ async function azureDefineHeaders(
2339
2373
  account = accounts[i];
2340
2374
  }
2341
2375
  }
2342
- debugger;
2343
2376
  let response: AuthenticationResult = await instance.acquireTokenSilent({
2344
2377
  scopes: ["https://management.azure.com/user_impersonation"],
2345
2378
  account: account
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
3
  "type": "module",
4
- "version": "1.0.85",
4
+ "version": "1.0.86",
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.",