@vizzly/api-client 0.0.2 → 0.0.4
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.
- package/dist/models/{Dashboard.d.ts → DashboardManager.d.ts} +2 -8
- package/dist/models/{Dashboard.js → DashboardManager.js} +8 -8
- package/dist/models/DashboardRepository.d.ts +2 -14
- package/dist/models/GlobalLibraryRepository.d.ts +4 -9
- package/dist/models/GlobalLibraryRepository.js +1 -7
- package/dist/models/Permission.d.ts +1 -12
- package/dist/models/Vizzly.d.ts +5 -2
- package/dist/models/Vizzly.js +8 -6
- package/dist/types.d.ts +9 -4
- package/package.json +1 -1
|
@@ -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
|
|
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.
|
|
12
|
+
exports.DashboardManager = void 0;
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
14
14
|
const GlobalLibraryRepository_1 = require("./GlobalLibraryRepository");
|
|
15
|
-
class
|
|
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
|
|
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
|
-
...
|
|
123
|
+
...DashboardManager.markViewsAsProtected(parentGlobalLibraries.flatMap((gL) => gL.library.views || [])),
|
|
124
124
|
...childGlobalLibraries.flatMap((gL) => gL.library.views || []),
|
|
125
|
-
...
|
|
125
|
+
...DashboardManager.markViewsAsProtected(parentDashboardComponentLibrary),
|
|
126
126
|
...(dashboard.parent_dashboard_id === null
|
|
127
|
-
?
|
|
127
|
+
? DashboardManager.markViewsAsProtected(dashboardComponentLibrary)
|
|
128
128
|
: dashboardComponentLibrary || []),
|
|
129
129
|
], (view) => view.attributes.viewId);
|
|
130
130
|
dashboard.definition.componentLibrary = newLibrary;
|
|
131
|
-
dashboard.definition.customFields =
|
|
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.
|
|
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:
|
|
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
|
-
|
|
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 {};
|
package/dist/models/Vizzly.d.ts
CHANGED
|
@@ -2,10 +2,13 @@ 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 {
|
|
5
|
+
import { DashboardManager } from './DashboardManager';
|
|
6
6
|
export declare class Vizzly {
|
|
7
7
|
private APIs;
|
|
8
8
|
implementationStrategy: ImplementationStrategy;
|
|
9
|
+
private dashboardRepository;
|
|
10
|
+
private globalLibraryRepository;
|
|
11
|
+
private dashboardManager;
|
|
9
12
|
constructor(APIs: PartialBy<APIs, 'vizzlyQueryEngineApi'>, implementationStrategy: PersistDirectToVizzlyApi);
|
|
10
13
|
getAPIs(): APIs | PartialBy<APIs, 'vizzlyQueryEngineApi'>;
|
|
11
14
|
getVizzlyAppApi(): import("./VizzlyAppApi").VizzlyAppApi;
|
|
@@ -13,5 +16,5 @@ export declare class Vizzly {
|
|
|
13
16
|
getVizzlyAPI(): import("./VizzlyApi").VizzlyApi;
|
|
14
17
|
getDashboardRepository(): DashboardRepository;
|
|
15
18
|
getGlobalLibraryRepository(): GlobalLibraryRepository;
|
|
16
|
-
|
|
19
|
+
getDashboardManager(): DashboardManager;
|
|
17
20
|
}
|
package/dist/models/Vizzly.js
CHANGED
|
@@ -4,11 +4,14 @@ 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
|
|
7
|
+
const DashboardManager_1 = require("./DashboardManager");
|
|
8
8
|
class Vizzly {
|
|
9
9
|
constructor(APIs, implementationStrategy) {
|
|
10
10
|
this.APIs = APIs;
|
|
11
11
|
this.implementationStrategy = implementationStrategy;
|
|
12
|
+
this.dashboardManager = new DashboardManager_1.DashboardManager(this);
|
|
13
|
+
this.dashboardRepository = new DashboardRepository_1.DashboardRepository(this);
|
|
14
|
+
this.globalLibraryRepository = new GlobalLibraryRepository_1.GlobalLibraryRepository(this);
|
|
12
15
|
}
|
|
13
16
|
getAPIs() {
|
|
14
17
|
if (this.implementationStrategy.shouldPersistViaQueryEngine() && !this.APIs.vizzlyQueryEngineApi) {
|
|
@@ -26,14 +29,13 @@ class Vizzly {
|
|
|
26
29
|
return this.getAPIs().vizzlyApi;
|
|
27
30
|
}
|
|
28
31
|
getDashboardRepository() {
|
|
29
|
-
return
|
|
32
|
+
return this.dashboardRepository;
|
|
30
33
|
}
|
|
31
34
|
getGlobalLibraryRepository() {
|
|
32
|
-
return
|
|
35
|
+
return this.globalLibraryRepository;
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return new Dashboard_1.Dashboard(this);
|
|
37
|
+
getDashboardManager() {
|
|
38
|
+
return this.dashboardManager;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
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
|
-
|
|
401
|
-
|
|
402
|
-
scope: 'read_write' | 'read';
|
|
400
|
+
type BasePermission = {
|
|
401
|
+
userReference: string;
|
|
403
402
|
token: string;
|
|
404
|
-
|
|
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
|
};
|