@mindline/sync 1.0.60 → 1.0.62

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": "\\configs.json",
5
6
  "PreviewInSolutionExplorer": false
6
7
  }
package/.vs/slnx.sqlite CHANGED
Binary file
Binary file
package/index.d.ts CHANGED
@@ -282,7 +282,15 @@ declare module "@mindline/sync" {
282
282
  //
283
283
  // Mindline Config API
284
284
  //
285
- export function configEdit(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): APIResult;
285
+ export function configEdit(
286
+ instance: IPublicClientApplication,
287
+ authorizedUser: User,
288
+ config: Config,
289
+ setConfigId: (id: string) => void,
290
+ setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void,
291
+ workspace: Workspace,
292
+ ii: InitInfo,
293
+ debug: boolean): APIResult;
286
294
  export function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): APIResult;
287
295
  export function configsRefresh(instance: IPublicClientApplication, authorizedUser: User, workspaceId: string, ii: InitInfo, debug: boolean): APIResult;
288
296
  export function initGet(instance: IPublicClientApplication, authorizedUser: User, user: User, ii: InitInfo, tasks: TaskArray, debug: boolean): APIResult;
package/index.ts CHANGED
@@ -900,7 +900,7 @@ export class BatchArray {
900
900
  setIdleText(`${this.pb_total} seconds elapsed. Last update ${this.pb_idle} seconds ago. [max idle: ${this.pb_idleMax}/60]`);
901
901
  if (this.pb_idle >= 60) {
902
902
  if (this.milestoneArray.milestones[0].Write == null) {
903
- this.milestoneArray.write(setMilestones);
903
+ //this.milestoneArray.write(setMilestones); -- allow sync to cntinue
904
904
  setConfigSyncResult(`sync continuing, but no update for ${this.pb_idle} seconds`);
905
905
  }
906
906
  }
@@ -1674,14 +1674,38 @@ export async function usersGet(instance: IPublicClientApplication, user: User |
1674
1674
  }
1675
1675
  }
1676
1676
  // ======================= Mindline Config API ===============================
1677
- export async function configEdit(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): Promise<APIResult> {
1677
+ export async function configEdit(
1678
+ instance: IPublicClientApplication,
1679
+ authorizedUser: User,
1680
+ config: Config,
1681
+ setConfigId: (id: string) => void,
1682
+ setSelectedConfigs: (selectedConfigs: { [id: string]: boolean | number[] }) => void,
1683
+ workspace: Workspace,
1684
+ ii: InitInfo,
1685
+ debug: boolean): Promise<APIResult>
1686
+ {
1678
1687
  let result: APIResult = new APIResult();
1679
1688
  if (config.id === "1") {
1680
- result = await configPost(instance, authorizedUser, config, workspaceId, debug);
1689
+ result = await configPost(instance, authorizedUser, config, workspace.id, debug);
1690
+ if (result.result) {
1691
+ // config id was updated from "1"
1692
+ setConfigId(config.id);
1693
+ // set this config as the selected config
1694
+ const newSelection = {};
1695
+ Object.defineProperty(newSelection, config.id, { value: true, writable: true, enumerable: true });
1696
+ setSelectedConfigs(newSelection);
1697
+ // update associated configs in this workspace
1698
+ let idx: number = workspace.associatedConfigs.findIndex((id: string) => id == "1");
1699
+ if (idx !== -1) {
1700
+ workspace.associatedConfigs.splice(idx, 1);
1701
+ workspace.associatedConfigs.push(config.id);
1702
+ }
1703
+ }
1681
1704
  }
1682
1705
  else {
1683
1706
  result = await configPut(instance, authorizedUser, config, debug);
1684
1707
  }
1708
+ ii.save();
1685
1709
  return result;
1686
1710
  }
1687
1711
  export async function configRemove(instance: IPublicClientApplication, authorizedUser: User, config: Config, workspaceId: string, debug: boolean): Promise<APIResult> {
@@ -1696,12 +1720,10 @@ export async function configsRefresh(instance: IPublicClientApplication, authori
1696
1720
  // clear Config associations as we are about to reset
1697
1721
  workspace.associatedConfigs.length = 0;
1698
1722
  // GET configs associated with this workspace
1699
- let configsPromise: Promise<APIResult> = configsGet(instance, authorizedUser, workspace.id, debug);
1700
- // wait for query to finish, return on any failure
1701
- let [configsResult] = await Promise.all([configsPromise]);
1702
- if (!configsResult.result) return configsResult;
1723
+ let result: APIResult = await configsGet(instance, authorizedUser, workspace.id, debug);
1724
+ if (!result.result) return result;
1703
1725
  // process returned workspace components
1704
- processReturnedConfigs(workspace, ii, configsResult.array!);
1726
+ processReturnedConfigs(workspace, ii, result.array!);
1705
1727
  // tag components with workspaceIDs
1706
1728
  ii.tagWithWorkspaces();
1707
1729
  }
@@ -1809,8 +1831,8 @@ function processReturnedAdmins(workspace: Workspace, ii: InitInfo, returnedAdmin
1809
1831
  user.name = item.firstName ?? user.name;
1810
1832
  user.mail = item.email;
1811
1833
  user.tid = item.tenantId;
1812
- // *try* to set authority from tenant returned in previous call processReturnedTenants (it may not be there)
1813
- // ASSUMPTION: user either comes from
1834
+ // *try* to set authority/companyName/companyDomain from tenant returned in previous call processReturnedTenants (it may not be there)
1835
+ // ASSUMPTION: in terms of setting authority, user either comes from
1814
1836
  // 1. .NET session, in which case user has an authority from the token
1815
1837
  // 2. Config API, in which case either
1816
1838
  // a. associated tenant with authority exists for this user (i.e. workspace owner has called POST init/configuration and created Admin and Tenant at same time)
@@ -1819,6 +1841,8 @@ function processReturnedAdmins(workspace: Workspace, ii: InitInfo, returnedAdmin
1819
1841
  let tenant: Tenant | undefined = ii.ts.find((t) => (t.tid === user.tid));
1820
1842
  if (tenant != undefined) {
1821
1843
  user.authority = tenant.authority;
1844
+ user.companyName = tenant.name;
1845
+ user.companyDomain = tenant.domain;
1822
1846
  }
1823
1847
  // ensure this workspace tracks this user
1824
1848
  let idx = workspace.associatedUsers.findIndex((u) => u === user.oid);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindline/sync",
3
3
  "type": "module",
4
- "version": "1.0.60",
4
+ "version": "1.0.62",
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.",