@vizzly/api-client 0.0.18 → 0.0.19
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/DashboardManager.d.ts +5 -5
- package/dist/models/DashboardManager.js +7 -6
- package/dist/models/DashboardRepository.d.ts +4 -4
- package/dist/models/DashboardRepository.js +5 -31
- package/dist/models/GlobalLibraryRepository.d.ts +3 -3
- package/dist/models/GlobalLibraryRepository.js +5 -5
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Vizzly } from './Vizzly';
|
|
2
|
-
import { CreateDashboardParams, Dashboard, DashboardDefinition, Dashboard as DashboardType, GlobalLibrary, UpdateDashboardParams } from '../types';
|
|
2
|
+
import { CreateDashboardParams, Dashboard, DashboardDefinition, Dashboard as DashboardType, GlobalLibrary, RequestParams, UpdateDashboardParams } from '../types';
|
|
3
3
|
export declare class DashboardManager {
|
|
4
4
|
private vizzly;
|
|
5
5
|
constructor(vizzly: Vizzly);
|
|
6
|
-
create(params: CreateDashboardParams): Promise<{
|
|
6
|
+
create(params: RequestParams<CreateDashboardParams>): Promise<{
|
|
7
7
|
dashboard: Dashboard;
|
|
8
8
|
permissions: import("../types").DashboardPermission[];
|
|
9
9
|
}>;
|
|
10
|
-
update(params: Omit<UpdateDashboardParams, 'dashboardPermission' | 'definition'> & {
|
|
10
|
+
update(params: RequestParams<Omit<UpdateDashboardParams, 'dashboardPermission' | 'definition'> & {
|
|
11
11
|
dashboardId: string;
|
|
12
12
|
definition?: DashboardDefinition;
|
|
13
|
-
}): Promise<Dashboard>;
|
|
14
|
-
getDashboards(): Promise<DashboardType[]>;
|
|
13
|
+
}>): Promise<Dashboard>;
|
|
14
|
+
getDashboards(params?: RequestParams): Promise<DashboardType[]>;
|
|
15
15
|
static mergeDashboardsAndGlobalLibraries(dashboards: DashboardType[], globalLibraries: GlobalLibrary[]): DashboardType[];
|
|
16
16
|
static mergeCustomFields(dashboard: DashboardType, dashboards: DashboardType[], parentGlobalLibrariesForDashboard: GlobalLibrary[], childGlobalLibrariesForDashboard: GlobalLibrary[]): DashboardType['definition']['customFields'];
|
|
17
17
|
static markViewsAsProtected(componentLibrary: DashboardType['definition']['componentLibrary']): DashboardType['definition']['componentLibrary'];
|
|
@@ -27,7 +27,10 @@ class DashboardManager {
|
|
|
27
27
|
var _a, _b, _c;
|
|
28
28
|
const dashboardRepository = this.vizzly.getDashboardRepository();
|
|
29
29
|
const globalLibraryRepository = this.vizzly.getGlobalLibraryRepository();
|
|
30
|
-
const [{ global_libraries: globalLibraries, permissions: globalLibraryPermissions }, { dashboards, permissions: dashboardPermissions },] = yield Promise.all([
|
|
30
|
+
const [{ global_libraries: globalLibraries, permissions: globalLibraryPermissions }, { dashboards, permissions: dashboardPermissions },] = yield Promise.all([
|
|
31
|
+
globalLibraryRepository.fetchGlobalLibraries(params),
|
|
32
|
+
dashboardRepository.fetchDashboards(params),
|
|
33
|
+
]);
|
|
31
34
|
const dashboardToUpdate = dashboards.find((dashboard) => dashboard.id === params.dashboardId);
|
|
32
35
|
if (!dashboardToUpdate)
|
|
33
36
|
throw new Error('Cannot find dashboard to update.');
|
|
@@ -90,13 +93,13 @@ class DashboardManager {
|
|
|
90
93
|
return updatedDashboard;
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
|
-
getDashboards() {
|
|
96
|
+
getDashboards(params) {
|
|
94
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
98
|
const dashboardRepo = this.vizzly.getDashboardRepository();
|
|
96
99
|
const libraryRepo = this.vizzly.getGlobalLibraryRepository();
|
|
97
100
|
const [{ dashboards }, { global_libraries: globalLibraries }] = yield Promise.all([
|
|
98
|
-
dashboardRepo.fetchDashboards(),
|
|
99
|
-
libraryRepo.fetchGlobalLibraries(),
|
|
101
|
+
dashboardRepo.fetchDashboards(params),
|
|
102
|
+
libraryRepo.fetchGlobalLibraries(params),
|
|
100
103
|
]);
|
|
101
104
|
return DashboardManager.mergeDashboardsAndGlobalLibraries(dashboards, globalLibraries);
|
|
102
105
|
});
|
|
@@ -111,8 +114,6 @@ class DashboardManager {
|
|
|
111
114
|
let { parentGlobalLibraries, childGlobalLibraries } = GlobalLibraryRepository_1.GlobalLibraryRepository.splitParentAndChildGlobalLibraries(globalLibraries);
|
|
112
115
|
// Only include the child libraries if the dashboard is not a parent.
|
|
113
116
|
childGlobalLibraries = dashboard.parent_dashboard_id === null ? [] : childGlobalLibraries;
|
|
114
|
-
// If parent dashboard, all libraries are for the parent.
|
|
115
|
-
// parentGlobalLibraries = dashboard.parent_dashboard_id === null ? [...parentGlobalLibraries, ...childGlobalLibraries] : [];
|
|
116
117
|
// Add the views from the various sources together. The order does matter -
|
|
117
118
|
// first elements are kept if a duplicate view is found.
|
|
118
119
|
let newLibrary = (0, lodash_1.uniqBy)([
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateDashboardParams, Dashboard, DashboardFromAPI, DashboardPermission, UpdateDashboardParams } from '../types';
|
|
1
|
+
import { CreateDashboardParams, Dashboard, DashboardFromAPI, DashboardPermission, RequestParams, UpdateDashboardParams } from '../types';
|
|
2
2
|
import { Vizzly } from './Vizzly';
|
|
3
3
|
export declare class DashboardRepository {
|
|
4
4
|
private vizzly;
|
|
@@ -7,15 +7,15 @@ export declare class DashboardRepository {
|
|
|
7
7
|
dashboard: Dashboard;
|
|
8
8
|
permissions: DashboardPermission[];
|
|
9
9
|
}>;
|
|
10
|
-
updateDashboard(params: UpdateDashboardParams): Promise<Dashboard>;
|
|
11
|
-
fetchDashboards(): Promise<{
|
|
10
|
+
updateDashboard(params: RequestParams<UpdateDashboardParams>): Promise<Dashboard>;
|
|
11
|
+
fetchDashboards(params?: RequestParams): Promise<{
|
|
12
12
|
dashboards: Dashboard[];
|
|
13
13
|
permissions: DashboardPermission[];
|
|
14
14
|
}>;
|
|
15
15
|
static embellishDashboardFromAPI(dashboard: DashboardFromAPI, permissions: DashboardPermission[]): Dashboard;
|
|
16
16
|
static takeHighestPermission(dashboardId: string, permissions: DashboardPermission[]): DashboardPermission;
|
|
17
17
|
static takePermissionsOfScope(dashboardId: string, permissions: DashboardPermission[], scope: 'read' | 'read_write'): DashboardPermission[];
|
|
18
|
-
fetchDashboardAccessTokens(): Promise<{
|
|
18
|
+
fetchDashboardAccessTokens(params?: RequestParams): Promise<{
|
|
19
19
|
dashboards: Dashboard[];
|
|
20
20
|
permissions: DashboardPermission[];
|
|
21
21
|
}>;
|
|
@@ -66,35 +66,9 @@ class DashboardRepository {
|
|
|
66
66
|
throw new FailedToUpdateDashboard_1.FailedToUpdateDashboard(`Failed to update dashboard, got status ${updatedDashboard.status}`);
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
fetchDashboards() {
|
|
69
|
+
fetchDashboards(params) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
return yield this.fetchDashboardAccessTokens();
|
|
72
|
-
// let dashboardResponse: Response<FetchDashboardsResponseBody>;
|
|
73
|
-
// if (this.vizzly.implementationStrategy.shouldPersistViaQueryEngine()) {
|
|
74
|
-
// const vizzlyQueryEngineApi = this.vizzly.getVizzlyQueryEngineAPI();
|
|
75
|
-
// dashboardResponse = await vizzlyQueryEngineApi.execute<FetchDashboardsResponseBody>(
|
|
76
|
-
// vizzlyQueryEngineApi.buildFetchDashboardsRequest(permissions.map((p) => p.token))
|
|
77
|
-
// );
|
|
78
|
-
// } else {
|
|
79
|
-
// const vizzlyApi = this.vizzly.getVizzlyAPI();
|
|
80
|
-
// dashboardResponse = await vizzlyApi.execute<{ found: Dashboard[]; not_found: any[] }>(
|
|
81
|
-
// vizzlyApi.buildFetchDashboardsRequest(permissions.map((p) => p.token))
|
|
82
|
-
// );
|
|
83
|
-
// }
|
|
84
|
-
// if (dashboardResponse.status === 200) {
|
|
85
|
-
// dashboardResponse.body.found.forEach((dashboard) => {
|
|
86
|
-
// if (typeof dashboard.definition === 'string') {
|
|
87
|
-
// throw new FailedToDecryptDashboardBeforeClient();
|
|
88
|
-
// }
|
|
89
|
-
// });
|
|
90
|
-
// return {
|
|
91
|
-
// found: dashboardResponse.body.found.map((foundDashboard) =>
|
|
92
|
-
// DashboardRepository.embellishDashboardFromAPI(foundDashboard, permissions)
|
|
93
|
-
// ),
|
|
94
|
-
// not_found: dashboardResponse.body.not_found,
|
|
95
|
-
// };
|
|
96
|
-
// }
|
|
97
|
-
// throw new FailedToFetchDashboards(`Failed to fetch dashboards. Got status code ${dashboardResponse.status}.`);
|
|
71
|
+
return yield this.fetchDashboardAccessTokens(params);
|
|
98
72
|
});
|
|
99
73
|
}
|
|
100
74
|
static embellishDashboardFromAPI(dashboard, permissions) {
|
|
@@ -108,16 +82,16 @@ class DashboardRepository {
|
|
|
108
82
|
static takePermissionsOfScope(dashboardId, permissions, scope) {
|
|
109
83
|
return permissions.filter((p) => p.dashboardId === dashboardId && p.scope === scope);
|
|
110
84
|
}
|
|
111
|
-
fetchDashboardAccessTokens() {
|
|
85
|
+
fetchDashboardAccessTokens(params) {
|
|
112
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
87
|
let accessTokens;
|
|
114
88
|
if (this.vizzly.implementationStrategy.shouldPersistViaQueryEngine()) {
|
|
115
89
|
const vizzlyQueryEngineApi = this.vizzly.getVizzlyQueryEngineAPI();
|
|
116
|
-
accessTokens = yield vizzlyQueryEngineApi.execute(vizzlyQueryEngineApi.buildFetchDashboardAccessTokensRequest());
|
|
90
|
+
accessTokens = yield vizzlyQueryEngineApi.execute(vizzlyQueryEngineApi.buildFetchDashboardAccessTokensRequest(params));
|
|
117
91
|
}
|
|
118
92
|
else {
|
|
119
93
|
const vizzlyApi = this.vizzly.getVizzlyAPI();
|
|
120
|
-
accessTokens = yield vizzlyApi.execute(vizzlyApi.buildFetchDashboardAccessTokensRequest());
|
|
94
|
+
accessTokens = yield vizzlyApi.execute(vizzlyApi.buildFetchDashboardAccessTokensRequest(params));
|
|
121
95
|
}
|
|
122
96
|
if (accessTokens.status === 200) {
|
|
123
97
|
const formattedPermissions = accessTokens.body.permissions.map(Permission_1.Permission.formatDashboardPermission);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateGlobalLibraryParams, GlobalLibrary, GlobalLibraryPermission, Response, UpdateGlobalLibraryParams } from '../types';
|
|
1
|
+
import { CreateGlobalLibraryParams, GlobalLibrary, GlobalLibraryPermission, RequestParams, Response, UpdateGlobalLibraryParams } from '../types';
|
|
2
2
|
import { Vizzly } from './Vizzly';
|
|
3
3
|
export declare class GlobalLibraryRepository {
|
|
4
4
|
private vizzly;
|
|
@@ -8,11 +8,11 @@ export declare class GlobalLibraryRepository {
|
|
|
8
8
|
global_library: GlobalLibrary;
|
|
9
9
|
permissions: GlobalLibraryPermission[];
|
|
10
10
|
}>;
|
|
11
|
-
fetchGlobalLibraries(): Promise<{
|
|
11
|
+
fetchGlobalLibraries(params?: RequestParams): Promise<{
|
|
12
12
|
global_libraries: GlobalLibrary[];
|
|
13
13
|
permissions: GlobalLibraryPermission[];
|
|
14
14
|
}>;
|
|
15
|
-
fetchGlobalLibraryAccessTokens(): Promise<{
|
|
15
|
+
fetchGlobalLibraryAccessTokens(params?: RequestParams): Promise<{
|
|
16
16
|
global_libraries: GlobalLibrary[];
|
|
17
17
|
permissions: GlobalLibraryPermission[];
|
|
18
18
|
}>;
|
|
@@ -30,22 +30,22 @@ class GlobalLibraryRepository {
|
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
fetchGlobalLibraries() {
|
|
33
|
+
fetchGlobalLibraries(params) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
35
|
// Now, we fetch the libraries and the access tokens from the access call.
|
|
36
|
-
return yield this.fetchGlobalLibraryAccessTokens();
|
|
36
|
+
return yield this.fetchGlobalLibraryAccessTokens(params);
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
fetchGlobalLibraryAccessTokens() {
|
|
39
|
+
fetchGlobalLibraryAccessTokens(params) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
const vizzlyApi = this.vizzly.getVizzlyAPI();
|
|
42
42
|
let accessTokens;
|
|
43
43
|
if (this.vizzly.implementationStrategy.shouldPersistViaQueryEngine()) {
|
|
44
44
|
const vizzlyQueryEngineApi = this.vizzly.getVizzlyQueryEngineAPI();
|
|
45
|
-
accessTokens = yield vizzlyQueryEngineApi.fetchGlobalLibraryAccessTokens();
|
|
45
|
+
accessTokens = yield vizzlyQueryEngineApi.fetchGlobalLibraryAccessTokens(params);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
accessTokens = yield vizzlyApi.fetchGlobalLibraryAccessTokens();
|
|
48
|
+
accessTokens = yield vizzlyApi.fetchGlobalLibraryAccessTokens(params);
|
|
49
49
|
}
|
|
50
50
|
if (accessTokens.status === 200) {
|
|
51
51
|
return {
|