@vizzly/api-client 0.0.2 → 0.0.3

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.
@@ -1,17 +1,11 @@
1
1
  import { Vizzly } from './Vizzly';
2
2
  import { CreateDashboardParams, DashboardDefinition, Dashboard as DashboardType, GlobalLibrary, UpdateDashboardParams } from '../types';
3
- export declare class Dashboard {
3
+ export declare class DashboardManager {
4
4
  private vizzly;
5
5
  constructor(vizzly: Vizzly);
6
6
  create(params: CreateDashboardParams): Promise<{
7
7
  dashboard: DashboardType;
8
- permissions: ({
9
- userReference: string;
10
- token: string;
11
- scope: "read" | "read_write";
12
- } & {
13
- dashboardId: string;
14
- })[];
8
+ permissions: import("../types").DashboardPermission[];
15
9
  }>;
16
10
  update(params: Omit<UpdateDashboardParams, 'dashboardSessionToken' | 'definition'> & {
17
11
  dashboardId: string;
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Dashboard = void 0;
12
+ exports.DashboardManager = void 0;
13
13
  const lodash_1 = require("lodash");
14
14
  const GlobalLibraryRepository_1 = require("./GlobalLibraryRepository");
15
- class Dashboard {
15
+ class DashboardManager {
16
16
  constructor(vizzly) {
17
17
  this.vizzly = vizzly;
18
18
  }
@@ -102,7 +102,7 @@ class Dashboard {
102
102
  const libraryRepo = this.vizzly.getGlobalLibraryRepository();
103
103
  const { found: dashboards } = yield dashboardRepo.fetchDashboards();
104
104
  const { found: globalLibraries } = yield libraryRepo.fetchGlobalLibraries();
105
- return Dashboard.mergeDashboardsAndGlobalLibraries(dashboards, globalLibraries);
105
+ return DashboardManager.mergeDashboardsAndGlobalLibraries(dashboards, globalLibraries);
106
106
  });
107
107
  }
108
108
  static mergeDashboardsAndGlobalLibraries(dashboards, globalLibraries) {
@@ -120,15 +120,15 @@ class Dashboard {
120
120
  // Add the views from the various sources together. The order does matter -
121
121
  // first elements are kept if a duplicate view is found.
122
122
  let newLibrary = (0, lodash_1.uniqBy)([
123
- ...Dashboard.markViewsAsProtected(parentGlobalLibraries.flatMap((gL) => gL.library.views || [])),
123
+ ...DashboardManager.markViewsAsProtected(parentGlobalLibraries.flatMap((gL) => gL.library.views || [])),
124
124
  ...childGlobalLibraries.flatMap((gL) => gL.library.views || []),
125
- ...Dashboard.markViewsAsProtected(parentDashboardComponentLibrary),
125
+ ...DashboardManager.markViewsAsProtected(parentDashboardComponentLibrary),
126
126
  ...(dashboard.parent_dashboard_id === null
127
- ? Dashboard.markViewsAsProtected(dashboardComponentLibrary)
127
+ ? DashboardManager.markViewsAsProtected(dashboardComponentLibrary)
128
128
  : dashboardComponentLibrary || []),
129
129
  ], (view) => view.attributes.viewId);
130
130
  dashboard.definition.componentLibrary = newLibrary;
131
- dashboard.definition.customFields = Dashboard.mergeCustomFields(dashboard, dashboards, parentGlobalLibraries, childGlobalLibraries);
131
+ dashboard.definition.customFields = DashboardManager.mergeCustomFields(dashboard, dashboards, parentGlobalLibraries, childGlobalLibraries);
132
132
  return dashboard;
133
133
  });
134
134
  }
@@ -153,4 +153,4 @@ class Dashboard {
153
153
  return componentLibrary.map((view) => (Object.assign(Object.assign({}, view), { attributes: Object.assign(Object.assign({}, view.attributes), { protectedByOrganisation: true }) })));
154
154
  }
155
155
  }
156
- exports.Dashboard = Dashboard;
156
+ exports.DashboardManager = DashboardManager;
@@ -18,24 +18,12 @@ export declare class DashboardRepository {
18
18
  constructor(vizzly: Vizzly);
19
19
  createDashboard(createParams: CreateDashboardParams): Promise<{
20
20
  dashboard: Dashboard;
21
- permissions: ({
22
- userReference: string;
23
- token: string;
24
- scope: "read" | "read_write";
25
- } & {
26
- dashboardId: string;
27
- })[];
21
+ permissions: import("../types").DashboardPermission[];
28
22
  }>;
29
23
  updateDashboard(params: UpdateDashboardParams): Promise<Response<CreateDashboardResponseBody>>;
30
24
  fetchDashboards(): Promise<FetchDashboardsResponseBody>;
31
25
  fetchDashboardAccessTokens(): Promise<{
32
- permissions: ({
33
- userReference: string;
34
- token: string;
35
- scope: "read" | "read_write";
36
- } & {
37
- dashboardId: string;
38
- })[];
26
+ permissions: import("../types").DashboardPermission[];
39
27
  }>;
40
28
  }
41
29
  export {};
@@ -1,23 +1,18 @@
1
- import { GlobalLibrary, UpdateGlobalLibraryParams, nVizzlyApi } from '../types';
1
+ import { GlobalLibrary, GlobalLibraryPermission, UpdateGlobalLibraryParams, nVizzlyApi } from '../types';
2
2
  import { Vizzly } from './Vizzly';
3
3
  export declare class GlobalLibraryRepository {
4
4
  private vizzly;
5
+ private cachedPermissions;
5
6
  constructor(vizzly: Vizzly);
6
7
  createGlobalLibrary(createParams: nVizzlyApi.CreateGlobalLibraryParams): Promise<import("../types").Response<{
7
8
  global_library: GlobalLibrary;
8
- permissions: import("../types").GlobalLibraryPermission[];
9
+ permissions: GlobalLibraryPermission[];
9
10
  }>>;
10
11
  fetchGlobalLibraries(): Promise<{
11
12
  found: GlobalLibrary[];
12
13
  }>;
13
14
  fetchGlobalLibraryAccessTokens(): Promise<{
14
- permissions: ({
15
- userReference: string;
16
- token: string;
17
- scope: "read" | "read_write";
18
- } & {
19
- globalLibraryId: string;
20
- })[];
15
+ permissions: GlobalLibraryPermission[];
21
16
  }>;
22
17
  updateGlobalLibrary(params: UpdateGlobalLibraryParams): Promise<import("../types").Response<unknown>>;
23
18
  getChildGlobalLibrariesByParentGlobalLibraryId(parentGlobalLibraryId: string): Promise<GlobalLibrary[]>;
@@ -16,6 +16,7 @@ const FailedToFetchGlobalLibraryAccessTokens_1 = require("../errors/FailedToFetc
16
16
  const FailedToFetchGlobalLibraries_1 = require("../errors/FailedToFetchGlobalLibraries");
17
17
  class GlobalLibraryRepository {
18
18
  constructor(vizzly) {
19
+ this.cachedPermissions = { permissions: [] };
19
20
  this.vizzly = vizzly;
20
21
  }
21
22
  createGlobalLibrary(createParams) {
@@ -37,13 +38,6 @@ class GlobalLibraryRepository {
37
38
  throw new FailedToFetchGlobalLibraries_1.FailedToFetchGlobalLibraries(`Failed to fetch global libraries. Got status ${globalLibraries.status}`);
38
39
  });
39
40
  }
40
- // async updateGlobalLibrary(params: {}) {
41
- // const vizzlyApi = this.vizzly.getVizzlyAPI();
42
- // const accessTokens = await vizzlyApi.execute<{
43
- // permissions: Array<{ global_library_id: string; token: string; user_reference: string, scope: 'read' | 'read_write' }>;
44
- // }>(vizzlyApi.());
45
- // return accessTokens;
46
- // }
47
41
  fetchGlobalLibraryAccessTokens() {
48
42
  return __awaiter(this, void 0, void 0, function* () {
49
43
  const vizzlyApi = this.vizzly.getVizzlyAPI();
@@ -1,14 +1,4 @@
1
- type BasePermission = {
2
- userReference: string;
3
- token: string;
4
- scope: 'read' | 'read_write';
5
- };
6
- type DashboardPermission = BasePermission & {
7
- dashboardId: string;
8
- };
9
- type GlobalLibraryPermission = BasePermission & {
10
- globalLibraryId: string;
11
- };
1
+ import { DashboardPermission, GlobalLibraryPermission } from '../types';
12
2
  export declare class Permission {
13
3
  static formatDashboardPermission(permission: {
14
4
  dashboard_id: string;
@@ -23,4 +13,3 @@ export declare class Permission {
23
13
  scope: 'read' | 'read_write';
24
14
  }): GlobalLibraryPermission;
25
15
  }
26
- export {};
@@ -2,7 +2,7 @@ import { APIs, PartialBy } from '../types';
2
2
  import { ImplementationStrategy, PersistDirectToVizzlyApi } from './ImplementationStrategy';
3
3
  import { DashboardRepository } from './DashboardRepository';
4
4
  import { GlobalLibraryRepository } from './GlobalLibraryRepository';
5
- import { Dashboard } from './Dashboard';
5
+ import { DashboardManager } from './DashboardManager';
6
6
  export declare class Vizzly {
7
7
  private APIs;
8
8
  implementationStrategy: ImplementationStrategy;
@@ -13,5 +13,5 @@ export declare class Vizzly {
13
13
  getVizzlyAPI(): import("./VizzlyApi").VizzlyApi;
14
14
  getDashboardRepository(): DashboardRepository;
15
15
  getGlobalLibraryRepository(): GlobalLibraryRepository;
16
- getDashboard(): Dashboard;
16
+ getDashboardManager(): DashboardManager;
17
17
  }
@@ -4,7 +4,7 @@ exports.Vizzly = void 0;
4
4
  const MissingRequiredVizzlyQueryEngineApi_1 = require("../errors/MissingRequiredVizzlyQueryEngineApi");
5
5
  const DashboardRepository_1 = require("./DashboardRepository");
6
6
  const GlobalLibraryRepository_1 = require("./GlobalLibraryRepository");
7
- const Dashboard_1 = require("./Dashboard");
7
+ const DashboardManager_1 = require("./DashboardManager");
8
8
  class Vizzly {
9
9
  constructor(APIs, implementationStrategy) {
10
10
  this.APIs = APIs;
@@ -31,9 +31,8 @@ class Vizzly {
31
31
  getGlobalLibraryRepository() {
32
32
  return new GlobalLibraryRepository_1.GlobalLibraryRepository(this);
33
33
  }
34
- // TODO; what should this be called!?
35
- getDashboard() {
36
- return new Dashboard_1.Dashboard(this);
34
+ getDashboardManager() {
35
+ return new DashboardManager_1.DashboardManager(this);
37
36
  }
38
37
  }
39
38
  exports.Vizzly = Vizzly;
package/dist/types.d.ts CHANGED
@@ -397,9 +397,14 @@ export type GlobalLibrary = {
397
397
  parent_global_library_id: string | null;
398
398
  updated_at: string;
399
399
  };
400
- export type GlobalLibraryPermission = {
401
- global_library_id: string;
402
- scope: 'read_write' | 'read';
400
+ type BasePermission = {
401
+ userReference: string;
403
402
  token: string;
404
- user_reference: string;
403
+ scope: 'read' | 'read_write';
404
+ };
405
+ export type DashboardPermission = BasePermission & {
406
+ dashboardId: string;
407
+ };
408
+ export type GlobalLibraryPermission = BasePermission & {
409
+ globalLibraryId: string;
405
410
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly/api-client",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "private": false,
5
5
  "license": "NONE",
6
6
  "source": "src/index.ts",