@vizzly/api-client 0.0.14 → 0.0.15

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.
@@ -0,0 +1,3 @@
1
+ export declare class ConnectionDoesNotExistOnProject extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConnectionDoesNotExistOnProject = void 0;
4
+ class ConnectionDoesNotExistOnProject extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'ConnectionDoesNotExistOnProject';
8
+ }
9
+ }
10
+ exports.ConnectionDoesNotExistOnProject = ConnectionDoesNotExistOnProject;
@@ -0,0 +1,3 @@
1
+ export declare class FailedToFetchConnection extends Error {
2
+ constructor(message: string);
3
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FailedToFetchConnection = void 0;
4
+ class FailedToFetchConnection extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'FailedToFetchConnection';
8
+ }
9
+ }
10
+ exports.FailedToFetchConnection = FailedToFetchConnection;
@@ -12,3 +12,5 @@ export * from './FailedToCreateGlobalLibrary';
12
12
  export * from './FailedToDecryptDashboardBeforeClient';
13
13
  export * from './FailedToUpdateDashboard';
14
14
  export * from './FailedToFetchVizzlyConfig';
15
+ export * from './ConnectionDoesNotExistOnProject';
16
+ export * from './FailedToFetchConnection';
@@ -28,3 +28,5 @@ __exportStar(require("./FailedToCreateGlobalLibrary"), exports);
28
28
  __exportStar(require("./FailedToDecryptDashboardBeforeClient"), exports);
29
29
  __exportStar(require("./FailedToUpdateDashboard"), exports);
30
30
  __exportStar(require("./FailedToFetchVizzlyConfig"), exports);
31
+ __exportStar(require("./ConnectionDoesNotExistOnProject"), exports);
32
+ __exportStar(require("./FailedToFetchConnection"), exports);
@@ -57,7 +57,9 @@ export declare class VizzlyApi extends Api {
57
57
  buildCreateVizzlyConfigVersionRequest(params: nVizzlyApi.CreateVizzlyConfigVersionParams): Request<{}>;
58
58
  duplicateParentDashboard(params: nVizzlyApi.DuplicateParentDashboardParams): Promise<import("../types").Response<unknown>>;
59
59
  buildDuplicateParentDashboardRequest(params: nVizzlyApi.DuplicateParentDashboardParams): Request<{}>;
60
- getConnection(params: nVizzlyApi.GetConnectionParams): Promise<import("../types").Response<unknown>>;
60
+ getConnection(params: nVizzlyApi.GetConnectionParams): Promise<{
61
+ encryptedCredentials: string | null;
62
+ }>;
61
63
  buildGetConnectionRequest(params: nVizzlyApi.GetConnectionParams): Request<{}>;
62
64
  getManagedQueryEngineKeyPair(params: nVizzlyApi.GetManagedQueryEngineKeyPairParams): Promise<import("../types").Response<unknown>>;
63
65
  buildGetManagedQueryEngineKeyPairRequest(params: nVizzlyApi.GetManagedQueryEngineKeyPairParams): Request<{}>;
@@ -13,6 +13,8 @@ exports.VizzlyApi = void 0;
13
13
  const Api_1 = require("./Api");
14
14
  const errors_1 = require("../errors");
15
15
  const FailedToFetchVizzlyConfig_1 = require("../errors/FailedToFetchVizzlyConfig");
16
+ const ConnectionDoesNotExistOnProject_1 = require("../errors/ConnectionDoesNotExistOnProject");
17
+ const FailedToFetchConnection_1 = require("../errors/FailedToFetchConnection");
16
18
  class VizzlyApi extends Api_1.Api {
17
19
  constructor(auth, host = 'https://api.vizzly.co') {
18
20
  super(auth, host);
@@ -235,7 +237,16 @@ class VizzlyApi extends Api_1.Api {
235
237
  }
236
238
  getConnection(params) {
237
239
  return __awaiter(this, void 0, void 0, function* () {
238
- return yield this.execute(this.buildGetConnectionRequest(params));
240
+ const response = yield this.execute(this.buildGetConnectionRequest(params));
241
+ if (response.status === 200) {
242
+ return {
243
+ encryptedCredentials: response.body.encrypted_credentials,
244
+ };
245
+ }
246
+ if (response.status == 404) {
247
+ throw new ConnectionDoesNotExistOnProject_1.ConnectionDoesNotExistOnProject('An active connection does not exist on the project');
248
+ }
249
+ throw new FailedToFetchConnection_1.FailedToFetchConnection(`Failed to fetch connection for the project. Got status ${response.status}`);
239
250
  });
240
251
  }
241
252
  buildGetConnectionRequest(params) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizzly/api-client",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "private": false,
5
5
  "license": "NONE",
6
6
  "source": "src/index.ts",