@vizzly/api-client 0.0.27 → 0.0.28

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.
@@ -29,4 +29,5 @@ export declare class GlobalLibraryRepository {
29
29
  static mapParentToChildGlobalLibraries(globalLibraries: GlobalLibrary[]): {
30
30
  [parentGlobalLibraryId: string]: GlobalLibrary[];
31
31
  };
32
+ static upcast(globalLibrary: GlobalLibrary): GlobalLibrary;
32
33
  }
@@ -31,6 +31,7 @@ class GlobalLibraryRepository {
31
31
  else {
32
32
  globalLibrary = yield vizzlyApi.createGlobalLibrary(createParams);
33
33
  }
34
+ globalLibrary.global_library = GlobalLibraryRepository.upcast(globalLibrary.global_library);
34
35
  this.repo.addItem(globalLibrary.global_library, globalLibrary.permissions);
35
36
  return globalLibrary;
36
37
  });
@@ -55,7 +56,7 @@ class GlobalLibraryRepository {
55
56
  }
56
57
  if (accessTokens.status === 200) {
57
58
  const formattedPermissions = accessTokens.body.permissions.map(Permission_1.Permission.formatGlobalLibraryPermission);
58
- this.repo.initRepo(accessTokens.body.global_libraries, formattedPermissions);
59
+ this.repo.initRepo(accessTokens.body.global_libraries.map(GlobalLibraryRepository.upcast), formattedPermissions);
59
60
  }
60
61
  else {
61
62
  throw new FailedToFetchGlobalLibraryAccessTokens_1.FailedToFetchGlobalLibraryAccessTokens('Failed to load access tokens for the global library.');
@@ -78,13 +79,12 @@ class GlobalLibraryRepository {
78
79
  else {
79
80
  updateResponse = yield vizzlyApi.updateGlobalLibrary(params);
80
81
  }
81
- if (updateResponse.status === 200) {
82
- this.repo.updateItem(updateResponse.body.global_library);
83
- }
84
- else {
82
+ if (updateResponse.status != 200) {
85
83
  throw new FailedToUpdateGlobalLibrary_1.FailedToUpdateGlobalLibrary(`Failed to update the global library ${updateResponse.status}`);
86
84
  }
87
- return updateResponse.body["global_library"];
85
+ const globalLibrary = GlobalLibraryRepository.upcast(updateResponse.body.global_library);
86
+ this.repo.updateItem(globalLibrary);
87
+ return globalLibrary;
88
88
  });
89
89
  }
90
90
  getChildGlobalLibrariesByParentGlobalLibraryId(parentGlobalLibraryId) {
@@ -127,5 +127,8 @@ class GlobalLibraryRepository {
127
127
  });
128
128
  return mapping;
129
129
  }
130
+ static upcast(globalLibrary) {
131
+ return Object.assign(Object.assign({}, globalLibrary), { library: Object.assign({ views: [], customFields: {} }, (globalLibrary.library || {})) });
132
+ }
130
133
  }
131
134
  exports.GlobalLibraryRepository = GlobalLibraryRepository;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly/api-client",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "private": false,
5
5
  "license": "NONE",
6
6
  "source": "src/index.ts",