@vizzly/api-client 0.0.6 → 0.0.8

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.
@@ -6,4 +6,5 @@ export declare class Api {
6
6
  protected auth: Authentication;
7
7
  constructor(auth: Authentication, host: string, extraHeaders?: () => {});
8
8
  execute<ResponseBody>(request: Request<any>): Promise<Response<ResponseBody>>;
9
+ getAuth(): Authentication;
9
10
  }
@@ -43,5 +43,8 @@ class Api {
43
43
  return { body: body, status: res.status, headers: res.headers };
44
44
  });
45
45
  }
46
+ getAuth() {
47
+ return this.auth;
48
+ }
46
49
  }
47
50
  exports.Api = Api;
@@ -1,4 +1,4 @@
1
- import { CreateGlobalLibraryParams, GlobalLibrary, GlobalLibraryPermission, UpdateGlobalLibraryParams } from '../types';
1
+ import { CreateGlobalLibraryParams, GlobalLibrary, GlobalLibraryPermission, Response, UpdateGlobalLibraryParams } from '../types';
2
2
  import { Vizzly } from './Vizzly';
3
3
  export declare class GlobalLibraryRepository {
4
4
  private vizzly;
@@ -10,11 +10,12 @@ export declare class GlobalLibraryRepository {
10
10
  }>;
11
11
  fetchGlobalLibraries(): Promise<{
12
12
  found: GlobalLibrary[];
13
+ not_found: string[];
13
14
  }>;
14
15
  fetchGlobalLibraryAccessTokens(): Promise<{
15
16
  permissions: GlobalLibraryPermission[];
16
17
  }>;
17
- updateGlobalLibrary(params: UpdateGlobalLibraryParams): Promise<import("../types").Response<{
18
+ updateGlobalLibrary(params: UpdateGlobalLibraryParams): Promise<Response<{
18
19
  global_library: GlobalLibrary;
19
20
  }>>;
20
21
  getChildGlobalLibrariesByParentGlobalLibraryId(parentGlobalLibraryId: string): Promise<GlobalLibrary[]>;
@@ -33,11 +33,20 @@ class GlobalLibraryRepository {
33
33
  }
34
34
  fetchGlobalLibraries() {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
+ let globalLibraries;
36
37
  const vizzlyApi = this.vizzly.getVizzlyAPI();
37
38
  const accessTokens = yield this.fetchGlobalLibraryAccessTokens();
38
- const globalLibraries = yield vizzlyApi.execute(vizzlyApi.buildFetchGlobalLibrariesRequest({
39
- globalLibraryAccessTokens: accessTokens.permissions.map((p) => p.token),
40
- }));
39
+ if (this.vizzly.implementationStrategy.shouldPersistViaQueryEngine()) {
40
+ const vizzlyQueryEngineApi = this.vizzly.getVizzlyQueryEngineAPI();
41
+ globalLibraries = yield vizzlyQueryEngineApi.fetchGlobalLibraries({
42
+ globalLibraryAccessTokens: accessTokens.permissions.map((p) => p.token),
43
+ });
44
+ }
45
+ else {
46
+ globalLibraries = yield vizzlyApi.fetchGlobalLibraries({
47
+ globalLibraryAccessTokens: accessTokens.permissions.map((p) => p.token),
48
+ });
49
+ }
41
50
  if (globalLibraries.status === 200)
42
51
  return globalLibraries.body;
43
52
  throw new FailedToFetchGlobalLibraries_1.FailedToFetchGlobalLibraries(`Failed to fetch global libraries. Got status ${globalLibraries.status}`);
@@ -46,6 +46,17 @@ export declare class VizzlyQueryEngineApi extends Api {
46
46
  permissions: Array<GlobalLibraryPermission>;
47
47
  }>;
48
48
  buildCreateGlobalLibraryRequest(params: CreateGlobalLibraryParams): Request<{}>;
49
+ fetchGlobalLibraries(params: {
50
+ globalLibraryAccessTokens: string[];
51
+ }): Promise<import("../types").Response<{
52
+ found: GlobalLibrary[];
53
+ not_found: string[];
54
+ }>>;
55
+ buildFetchGlobalLibrariesRequest(params: {
56
+ globalLibraryAccessTokens: string[];
57
+ }): Request<{
58
+ globalLibraryAccessTokens: string[];
59
+ }>;
49
60
  updateGlobalLibrary(params: UpdateGlobalLibraryParams): Promise<import("../types").Response<{
50
61
  global_library: GlobalLibrary;
51
62
  }>>;
@@ -281,6 +281,20 @@ class VizzlyQueryEngineApi extends Api_1.Api {
281
281
  },
282
282
  };
283
283
  }
284
+ fetchGlobalLibraries(params) {
285
+ return __awaiter(this, void 0, void 0, function* () {
286
+ return yield this.execute(this.buildFetchGlobalLibrariesRequest(params));
287
+ });
288
+ }
289
+ buildFetchGlobalLibrariesRequest(params) {
290
+ return {
291
+ path: '/api/v1/get-global-libraries',
292
+ method: 'post',
293
+ body: {
294
+ globalLibraryAccessTokens: params.globalLibraryAccessTokens,
295
+ },
296
+ };
297
+ }
284
298
  updateGlobalLibrary(params) {
285
299
  return __awaiter(this, void 0, void 0, function* () {
286
300
  return yield this.execute(this.buildUpdateGlobalLibraryRequest(params));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly/api-client",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "private": false,
5
5
  "license": "NONE",
6
6
  "source": "src/index.ts",