@vizzly/api-client 0.0.39 → 0.0.42

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.
@@ -15,7 +15,6 @@ const Permission_1 = require("./Permission");
15
15
  const FailedToFetchGlobalLibraryAccessTokens_1 = require("../errors/FailedToFetchGlobalLibraryAccessTokens");
16
16
  const Repository_1 = require("./Repository");
17
17
  const FailedToUpdateGlobalLibrary_1 = require("../errors/FailedToUpdateGlobalLibrary");
18
- const errors_1 = require("../errors");
19
18
  class GlobalLibraryRepository {
20
19
  constructor(vizzly) {
21
20
  this.vizzly = vizzly;
@@ -43,38 +42,7 @@ class GlobalLibraryRepository {
43
42
  }
44
43
  fetchGlobalLibraries(params) {
45
44
  return __awaiter(this, void 0, void 0, function* () {
46
- // Now, we fetch the libraries and the access tokens from the access call.
47
- let libs = yield this.fetchGlobalLibraryAccessTokens(params);
48
- // Find the parent library.
49
- const parentLibrary = libs.global_libraries.find((l) => l.parent_global_library_id === null);
50
- // Find any child library.
51
- const childLibrary = libs.global_libraries.find((l) => l.parent_global_library_id != null);
52
- // If libraries have been returned, but no child library exists
53
- // then create the first and only one.
54
- if (libs.global_libraries.length > 0 && parentLibrary && !childLibrary) {
55
- try {
56
- const created = yield this.createGlobalLibrary({
57
- parentGlobalLibraryId: parentLibrary.id,
58
- library: {
59
- customFields: {},
60
- views: [],
61
- },
62
- permissions: [{ scope: 'read_write' }],
63
- });
64
- libs = {
65
- global_libraries: [...libs.global_libraries, created.global_library],
66
- permissions: [...libs.permissions, ...created.permissions],
67
- };
68
- }
69
- catch (e) {
70
- // Only throw if the error is not a permission denied. A permission denied
71
- // is expected if the user only has `read` access on their identity JWT token.
72
- if (!(e instanceof errors_1.PermissionDenied)) {
73
- throw e;
74
- }
75
- }
76
- }
77
- return libs;
45
+ return yield this.fetchGlobalLibraryAccessTokens(params);
78
46
  });
79
47
  }
80
48
  fetchGlobalLibraryAccessTokens(params) {
@@ -1,6 +1,6 @@
1
1
  import { Api } from './Api';
2
2
  import { Authentication } from './Authentication';
3
- import { CreateDashboardParams, CreateGlobalLibraryParams, GlobalLibrary, GlobalLibraryPermissionFromAPI, QueryEngineUserFromAPI, Request, RequestParams, TeamMemberFromAPI, UpdateDashboardParams, UpdateDashboardResponseBody, UpdateGlobalLibraryParams } from '../types';
3
+ import { CreateDashboardParams, CreateGlobalLibraryParams, GlobalLibrary, GlobalLibraryPermissionFromAPI, PersistedReport, QueryEngineUserFromAPI, Request, RequestParams, TeamMemberFromAPI, UpdateDashboardParams, UpdateDashboardResponseBody, UpdateGlobalLibraryParams } from '../types';
4
4
  import { nVizzlyApi } from '../types';
5
5
  import { ProjectFromAPI } from '../types/project';
6
6
  export declare class VizzlyApi extends Api {
@@ -93,7 +93,13 @@ export declare class VizzlyApi extends Api {
93
93
  buildSaveConnectionRequest(params: RequestParams<nVizzlyApi.SaveConnectionParams>): Request<{}>;
94
94
  saveEncryptedProjectEncryptionSecret(params: RequestParams<nVizzlyApi.SaveEncryptedProjectEncryptionSecretParams>): Promise<boolean>;
95
95
  buildSaveEncryptedProjectEncryptionSecretRequest(params: RequestParams<nVizzlyApi.SaveEncryptedProjectEncryptionSecretParams>): Request<{}>;
96
- saveScheduledReport(params: RequestParams<nVizzlyApi.SaveScheduledReportParams>): Promise<import("../types").Response<unknown>>;
96
+ getScheduledReports(params: RequestParams<nVizzlyApi.GetScheduledReportParams>): Promise<import("../types").Response<{
97
+ reports: Array<PersistedReport>;
98
+ }>>;
99
+ buildGetScheduledReports(params: RequestParams<nVizzlyApi.GetScheduledReportParams>): Request<{}>;
100
+ saveScheduledReport(params: RequestParams<nVizzlyApi.SaveScheduledReportParams>): Promise<import("../types").Response<{
101
+ report: PersistedReport;
102
+ }>>;
97
103
  buildSaveScheduledReportRequest(params: RequestParams<nVizzlyApi.SaveScheduledReportParams>): Request<{}>;
98
104
  updateDashboard(params: RequestParams<UpdateDashboardParams>): Promise<import("../types").Response<UpdateDashboardResponseBody>>;
99
105
  buildUpdateDashboardRequest(params: RequestParams<UpdateDashboardParams>): Request<{}>;
@@ -422,6 +422,21 @@ class VizzlyApi extends Api_1.Api {
422
422
  acceptedAuthParams: ['projectApiKey', 'projectAccessToken'],
423
423
  };
424
424
  }
425
+ getScheduledReports(params) {
426
+ return __awaiter(this, void 0, void 0, function* () {
427
+ return yield this.execute(this.buildGetScheduledReports(params));
428
+ });
429
+ }
430
+ buildGetScheduledReports(params) {
431
+ return {
432
+ path: '/api/scheduled-report/collect',
433
+ method: 'post',
434
+ body: {
435
+ dashboardAccessToken: params.dashboardAccessToken,
436
+ },
437
+ abortSignal: params.abortSignal,
438
+ };
439
+ }
425
440
  saveScheduledReport(params) {
426
441
  return __awaiter(this, void 0, void 0, function* () {
427
442
  return yield this.execute(this.buildSaveScheduledReportRequest(params));
@@ -433,7 +448,7 @@ class VizzlyApi extends Api_1.Api {
433
448
  method: 'post',
434
449
  body: {
435
450
  cronSchedule: params.cronSchedule,
436
- dashboardAccessToken: this.auth.getDashboardAccessToken(),
451
+ dashboardAccessToken: params.dashboardAccessToken,
437
452
  scheduledReportId: params.scheduledReportId,
438
453
  },
439
454
  abortSignal: params.abortSignal,
@@ -41,6 +41,19 @@ export declare class VizzlyAppApi extends Api {
41
41
  buildStartSignInRequest(params: nVizzlyAppApi.StartSignInParams): Request<{}>;
42
42
  completeSignIn(params: nVizzlyAppApi.CompleteSignInParams): Promise<import("../types").Response<unknown>>;
43
43
  buildCompleteSignInRequest(params: nVizzlyAppApi.CompleteSignInParams): Request<{}>;
44
+ searchUserDashboards(params: nVizzlyAppApi.SearchUserDashboardsParams): Promise<import("../types").Response<{
45
+ search_results: Array<{
46
+ id: string;
47
+ parent_dashboard_id: string | null;
48
+ parent_dashboard_name: string | null;
49
+ scope: 'read' | 'read_write';
50
+ user_reference: string;
51
+ permission_created_at: string;
52
+ dashboard_created_at: string;
53
+ dashboard_updated_at: string;
54
+ }>;
55
+ }>>;
56
+ buildSearchUserDashboardsRequest(params: nVizzlyAppApi.SearchUserDashboardsParams): Request<{}>;
44
57
  signUp(params: nVizzlyAppApi.SignUpParams): Promise<import("../types").Response<unknown>>;
45
58
  buildSignUpRequest(params: nVizzlyAppApi.SignUpParams): Request<{}>;
46
59
  switchOrganisation(params: nVizzlyAppApi.SwitchOrganisationParams): Promise<import("../types").Response<unknown>>;
@@ -266,6 +266,17 @@ class VizzlyAppApi extends Api_1.Api {
266
266
  },
267
267
  };
268
268
  }
269
+ searchUserDashboards(params) {
270
+ return __awaiter(this, void 0, void 0, function* () {
271
+ return yield this.execute(this.buildSearchUserDashboardsRequest(params));
272
+ });
273
+ }
274
+ buildSearchUserDashboardsRequest(params) {
275
+ return {
276
+ path: `/api/v2/project/${params.projectId}/search-user-dashboards?user_reference=${params.userReference}`,
277
+ method: 'get',
278
+ };
279
+ }
269
280
  signUp(params) {
270
281
  return __awaiter(this, void 0, void 0, function* () {
271
282
  return yield this.execute(this.buildSignUpRequest(params));
package/dist/types.d.ts CHANGED
@@ -11,6 +11,14 @@ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
11
11
  export type UpdateDashboardResponseBody = {
12
12
  dashboard: DashboardFromAPI;
13
13
  };
14
+ export type PersistedReport = {
15
+ id: string;
16
+ dashboard_id: string;
17
+ organisation_id: string;
18
+ schedule: string;
19
+ type: 'scheduled';
20
+ user_reference: string;
21
+ };
14
22
  export type Response<T> = {
15
23
  status: number;
16
24
  headers: Headers;
@@ -126,6 +134,9 @@ export declare namespace nVizzlyQueryEngine {
126
134
  };
127
135
  }
128
136
  export declare namespace nVizzlyApi {
137
+ type GetScheduledReportParams = {
138
+ dashboardAccessToken: string;
139
+ };
129
140
  type CreateParentDashboardParams = {
130
141
  definition: any;
131
142
  projectId: string;
@@ -155,7 +166,8 @@ export declare namespace nVizzlyApi {
155
166
  name?: string;
156
167
  };
157
168
  type SaveScheduledReportParams = {
158
- cronSchedule: string;
169
+ dashboardAccessToken: string;
170
+ cronSchedule: string | null;
159
171
  scheduledReportId: string;
160
172
  };
161
173
  type SaveEncryptedProjectEncryptionSecretParams = {
@@ -204,6 +216,10 @@ export declare namespace nVizzlyApi {
204
216
  };
205
217
  }
206
218
  export declare namespace nVizzlyAppApi {
219
+ type SearchUserDashboardsParams = {
220
+ projectId: string;
221
+ userReference: string;
222
+ };
207
223
  type CreateInstantDashboardParams = {
208
224
  definition: Object;
209
225
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly/api-client",
3
- "version": "0.0.39",
3
+ "version": "0.0.42",
4
4
  "private": false,
5
5
  "license": "NONE",
6
6
  "source": "src/index.ts",
@@ -25,7 +25,8 @@
25
25
  "uuid": "^9.0.1"
26
26
  },
27
27
  "scripts": {
28
- "test": "jest",
28
+ "test": ". ./secrets.env && jest",
29
+ "test:ci": "jest",
29
30
  "build": "rm -rf ./dist && tsc",
30
31
  "dev": "tsc -w",
31
32
  "format": "prettier --write ./src/** ./__tests__/**",