@mindline/sync 1.0.84 → 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,6 +2,6 @@
2
2
  "ExpandedNodes": [
3
3
  ""
4
4
  ],
5
- "SelectedNode": "\\index.d.ts",
5
+ "SelectedNode": "\\index.ts",
6
6
  "PreviewInSolutionExplorer": false
7
7
  }
package/.vs/slnx.sqlite CHANGED
Binary file
Binary file
@@ -2,17 +2,13 @@
2
2
  "Version": 1,
3
3
  "WorkspaceRootPath": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\",
4
4
  "Documents": [
5
- {
6
- "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}",
7
- "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:hybridspa.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
8
- },
9
5
  {
10
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}",
11
7
  "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:index.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
12
8
  },
13
9
  {
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}"
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}",
11
+ "RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:hybridspa.ts||{0F2454B1-A556-402D-A7D0-1FDE7F99DEE0}"
16
12
  }
17
13
  ],
18
14
  "DocumentGroupContainers": [
@@ -22,7 +18,7 @@
22
18
  "DocumentGroups": [
23
19
  {
24
20
  "DockedWidth": 200,
25
- "SelectedChildIndex": -1,
21
+ "SelectedChildIndex": 9,
26
22
  "Children": [
27
23
  {
28
24
  "$type": "Bookmark",
@@ -55,62 +51,37 @@
55
51
  {
56
52
  "$type": "Bookmark",
57
53
  "Name": "ST:1:0:{d212f56b-c48a-434c-a121-1c5d80b59b9f}"
58
- }
59
- ]
60
- },
61
- {
62
- "DockedWidth": 200,
63
- "SelectedChildIndex": 1,
64
- "Children": [
54
+ },
65
55
  {
66
56
  "$type": "Document",
67
- "DocumentIndex": 2,
68
- "Title": "index.d.ts",
69
- "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts",
70
- "RelativeDocumentMoniker": "index.d.ts",
71
- "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.d.ts",
72
- "RelativeToolTip": "index.d.ts",
73
- "ViewState": "AQIAAAAAAAAAAAAAAAAAABoAAAAoAAAA",
57
+ "DocumentIndex": 1,
58
+ "Title": "hybridspa.ts",
59
+ "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
60
+ "RelativeDocumentMoniker": "hybridspa.ts",
61
+ "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
62
+ "RelativeToolTip": "hybridspa.ts",
63
+ "ViewState": "AgIAAAAAAAAAAAAAAAAAACsAAAAAAAAAAAAAAA==",
74
64
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
75
- "WhenOpened": "2025-01-29T23:22:53.18Z",
65
+ "WhenOpened": "2025-03-28T16:08:06.165Z",
76
66
  "EditorCaption": ""
77
67
  },
78
68
  {
79
69
  "$type": "Document",
80
- "DocumentIndex": 1,
70
+ "DocumentIndex": 0,
81
71
  "Title": "index.ts",
82
72
  "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
83
73
  "RelativeDocumentMoniker": "index.ts",
84
74
  "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\index.ts",
85
75
  "RelativeToolTip": "index.ts",
86
- "ViewState": "AQIAACgAAAAAAAAAAADwvzMAAAAEAAAA",
76
+ "ViewState": "AgIAAAAAAAAAAAAAAAAAAGEFAAAAAAAAAAAAAA==",
87
77
  "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
88
- "WhenOpened": "2025-01-29T14:51:05.763Z",
78
+ "WhenOpened": "2025-03-28T15:55:38.875Z",
89
79
  "EditorCaption": ""
90
80
  }
91
81
  ]
92
82
  },
93
83
  {
94
- "DockedWidth": 200,
95
- "SelectedChildIndex": 0,
96
- "Children": [
97
- {
98
- "$type": "Document",
99
- "DocumentIndex": 0,
100
- "Title": "hybridspa.ts",
101
- "DocumentMoniker": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
102
- "RelativeDocumentMoniker": "hybridspa.ts",
103
- "ToolTip": "C:\\Users\\ArvindSuthar\\source\\repos\\front\\sync\\hybridspa.ts",
104
- "RelativeToolTip": "hybridspa.ts",
105
- "ViewState": "AQIAAH4BAAAAAAAAAADwv5UBAAAiAAAA",
106
- "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003213|",
107
- "WhenOpened": "2024-11-04T14:16:26.493Z",
108
- "EditorCaption": ""
109
- }
110
- ]
111
- },
112
- {
113
- "DockedWidth": 294,
84
+ "DockedWidth": 254,
114
85
  "SelectedChildIndex": -1,
115
86
  "Children": [
116
87
  {
@@ -120,7 +91,7 @@
120
91
  ]
121
92
  },
122
93
  {
123
- "DockedWidth": 294,
94
+ "DockedWidth": 200,
124
95
  "SelectedChildIndex": -1,
125
96
  "Children": [
126
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
  });
@@ -2002,7 +2004,14 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
2002
2004
  let result: APIResult = await configsGet(instance, authorizedUser, workspace.id, debug);
2003
2005
  if (!result.result) return result;
2004
2006
  // process returned workspace components
2005
- processReturnedConfigs(workspace, ii, result.array!);
2007
+ let configSelectedId: string = "";
2008
+ for (let cid of workspace.associatedConfigs) {
2009
+ let config = ii.cs.find((c: Config) => c.id === cid);
2010
+ if (config != null && config.sel) {
2011
+ configSelectedId = config.id;
2012
+ }
2013
+ }
2014
+ processReturnedConfigs(workspace, ii, result.array!, configSelectedId);
2006
2015
  // tag components with workspaceIDs
2007
2016
  ii.tagWithWorkspaces();
2008
2017
  }
@@ -2312,6 +2321,38 @@ async function workspaceInfoGet(instance: IPublicClientApplication, user: User,
2312
2321
  result.status = 500;
2313
2322
  return result;
2314
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
+ }
2315
2356
  // ======================= Azure REST API ===============================
2316
2357
  // TODO: this is where you want to trigger a re-authentication if token expires
2317
2358
  async function azureDefineHeaders(
@@ -2332,7 +2373,6 @@ async function azureDefineHeaders(
2332
2373
  account = accounts[i];
2333
2374
  }
2334
2375
  }
2335
- debugger;
2336
2376
  let response: AuthenticationResult = await instance.acquireTokenSilent({
2337
2377
  scopes: ["https://management.azure.com/user_impersonation"],
2338
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.84",
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.",