@vizzly/api-client 0.0.13 → 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.
- package/dist/errors/ConnectionDoesNotExistOnProject.d.ts +3 -0
- package/dist/errors/ConnectionDoesNotExistOnProject.js +10 -0
- package/dist/errors/FailedToFetchConnection.d.ts +3 -0
- package/dist/errors/FailedToFetchConnection.js +10 -0
- package/dist/errors/FailedToFetchVizzlyConfig.d.ts +3 -0
- package/dist/errors/FailedToFetchVizzlyConfig.js +10 -0
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.js +3 -0
- package/dist/models/Authentication.d.ts +1 -0
- package/dist/models/Authentication.js +3 -24
- package/dist/models/VizzlyApi.d.ts +15 -4
- package/dist/models/VizzlyApi.js +20 -2
- package/package.json +1 -1
|
@@ -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,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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FailedToFetchVizzlyConfig = void 0;
|
|
4
|
+
class FailedToFetchVizzlyConfig extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'FailedToFetchVizzlyConfig';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FailedToFetchVizzlyConfig = FailedToFetchVizzlyConfig;
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -11,3 +11,6 @@ export * from './FailedToResolveDataSets';
|
|
|
11
11
|
export * from './FailedToCreateGlobalLibrary';
|
|
12
12
|
export * from './FailedToDecryptDashboardBeforeClient';
|
|
13
13
|
export * from './FailedToUpdateDashboard';
|
|
14
|
+
export * from './FailedToFetchVizzlyConfig';
|
|
15
|
+
export * from './ConnectionDoesNotExistOnProject';
|
|
16
|
+
export * from './FailedToFetchConnection';
|
package/dist/errors/index.js
CHANGED
|
@@ -27,3 +27,6 @@ __exportStar(require("./FailedToResolveDataSets"), exports);
|
|
|
27
27
|
__exportStar(require("./FailedToCreateGlobalLibrary"), exports);
|
|
28
28
|
__exportStar(require("./FailedToDecryptDashboardBeforeClient"), exports);
|
|
29
29
|
__exportStar(require("./FailedToUpdateDashboard"), exports);
|
|
30
|
+
__exportStar(require("./FailedToFetchVizzlyConfig"), exports);
|
|
31
|
+
__exportStar(require("./ConnectionDoesNotExistOnProject"), exports);
|
|
32
|
+
__exportStar(require("./FailedToFetchConnection"), exports);
|
|
@@ -3,6 +3,7 @@ export declare class Authentication {
|
|
|
3
3
|
private authParams;
|
|
4
4
|
constructor(authParams: AuthParams);
|
|
5
5
|
updateAuthParams(authParams: Partial<AuthParams>): void;
|
|
6
|
+
clearAuthParams(): void;
|
|
6
7
|
getQueryEngineAccessToken(): string;
|
|
7
8
|
getProjectAdminOverrideToken(): string | undefined;
|
|
8
9
|
getDashboardAccessToken(): string;
|
|
@@ -9,6 +9,9 @@ class Authentication {
|
|
|
9
9
|
updateAuthParams(authParams) {
|
|
10
10
|
this.authParams = Object.assign(Object.assign({}, this.authParams), authParams);
|
|
11
11
|
}
|
|
12
|
+
clearAuthParams() {
|
|
13
|
+
this.authParams = {};
|
|
14
|
+
}
|
|
12
15
|
getQueryEngineAccessToken() {
|
|
13
16
|
if (!this.authParams.queryEngineAccessToken)
|
|
14
17
|
throw new MissingAuthParameter_1.MissingAuthParameter('queryEngineAccessToken');
|
|
@@ -64,30 +67,6 @@ class Authentication {
|
|
|
64
67
|
auth: `Bearer ${this.authParams.appSessionToken}`,
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
|
-
// Try without this extra logic to fetch the project tokens...
|
|
68
|
-
// else if (request.preFetchProjectAccessTokens && (config.useCookieAuth || !!config.appSessionAuthToken)) {
|
|
69
|
-
// logDebug(
|
|
70
|
-
// 'Fetching project access token from the Vizzly API',
|
|
71
|
-
// request.preFetchProjectAccessTokens.projectId,
|
|
72
|
-
// 'Filtering by',
|
|
73
|
-
// request.preFetchProjectAccessTokens.resourceFilters
|
|
74
|
-
// );
|
|
75
|
-
// const accessToken = await getProjectAccessToken(httpClient(config))(
|
|
76
|
-
// request.preFetchProjectAccessTokens.projectId,
|
|
77
|
-
// config.appSessionAuthToken,
|
|
78
|
-
// request.preFetchProjectAccessTokens.resourceFilters
|
|
79
|
-
// );
|
|
80
|
-
// if (accessToken) {
|
|
81
|
-
// logDebug('Project access token received.');
|
|
82
|
-
// return {
|
|
83
|
-
// auth: `Bearer ${accessToken}`,
|
|
84
|
-
// };
|
|
85
|
-
// } else {
|
|
86
|
-
// logDebug('Failed to receive project access token.');
|
|
87
|
-
// }
|
|
88
|
-
// } else {
|
|
89
|
-
// logDebug('Not pre-fetching project access token.');
|
|
90
|
-
// }
|
|
91
70
|
return {};
|
|
92
71
|
}
|
|
93
72
|
}
|
|
@@ -42,7 +42,9 @@ export declare class VizzlyApi extends Api {
|
|
|
42
42
|
buildCreateGlobalLibraryRequest(params: CreateGlobalLibraryParams): Request<{}>;
|
|
43
43
|
getProjects(): Promise<import("../types").Response<unknown>>;
|
|
44
44
|
buildGetProjectsRequest(): Request<{}>;
|
|
45
|
-
createProjectApiKey(params: nVizzlyApi.CreateProjectApiKeyParams): Promise<import("../types").Response<
|
|
45
|
+
createProjectApiKey(params: nVizzlyApi.CreateProjectApiKeyParams): Promise<import("../types").Response<{
|
|
46
|
+
api_key: string;
|
|
47
|
+
}>>;
|
|
46
48
|
buildCreateProjectApiKeyRequest(params: nVizzlyApi.CreateProjectApiKeyParams): Request<{}>;
|
|
47
49
|
createQueryEngineUser(params: nVizzlyApi.CreateQueryEngineUserParams): Promise<import("../types").Response<unknown>>;
|
|
48
50
|
buildCreateQueryEngineUserRequest(params: nVizzlyApi.CreateQueryEngineUserParams): Request<{}>;
|
|
@@ -55,19 +57,28 @@ export declare class VizzlyApi extends Api {
|
|
|
55
57
|
buildCreateVizzlyConfigVersionRequest(params: nVizzlyApi.CreateVizzlyConfigVersionParams): Request<{}>;
|
|
56
58
|
duplicateParentDashboard(params: nVizzlyApi.DuplicateParentDashboardParams): Promise<import("../types").Response<unknown>>;
|
|
57
59
|
buildDuplicateParentDashboardRequest(params: nVizzlyApi.DuplicateParentDashboardParams): Request<{}>;
|
|
58
|
-
getConnection(params: nVizzlyApi.GetConnectionParams): Promise<
|
|
60
|
+
getConnection(params: nVizzlyApi.GetConnectionParams): Promise<{
|
|
61
|
+
encryptedCredentials: string | null;
|
|
62
|
+
}>;
|
|
59
63
|
buildGetConnectionRequest(params: nVizzlyApi.GetConnectionParams): Request<{}>;
|
|
60
64
|
getManagedQueryEngineKeyPair(params: nVizzlyApi.GetManagedQueryEngineKeyPairParams): Promise<import("../types").Response<unknown>>;
|
|
61
65
|
buildGetManagedQueryEngineKeyPairRequest(params: nVizzlyApi.GetManagedQueryEngineKeyPairParams): Request<{}>;
|
|
62
66
|
getProject(params: nVizzlyApi.GetProjectParams): Promise<import("../types").Response<unknown>>;
|
|
63
67
|
buildGetProjectRequest(params: nVizzlyApi.GetProjectParams): Request<{}>;
|
|
64
|
-
getProjectAccessToken(params: nVizzlyApi.GetProjectAccessTokenParams): Promise<import("../types").Response<
|
|
68
|
+
getProjectAccessToken(params: nVizzlyApi.GetProjectAccessTokenParams): Promise<import("../types").Response<{
|
|
69
|
+
token: {
|
|
70
|
+
max_age: number;
|
|
71
|
+
token: string;
|
|
72
|
+
};
|
|
73
|
+
}>>;
|
|
65
74
|
buildGetProjectAccessTokenRequest(params: nVizzlyApi.GetProjectAccessTokenParams): Request<{}>;
|
|
66
75
|
getQueryEngineUser(params: nVizzlyApi.GetQueryEngineUserParams): Promise<import("../types").Response<unknown>>;
|
|
67
76
|
buildGetQueryEngineUserRequest(params: nVizzlyApi.GetQueryEngineUserParams): Request<{}>;
|
|
68
77
|
getTeamMembers(params: nVizzlyApi.GetTeamMembers): Promise<import("../types").Response<unknown>>;
|
|
69
78
|
buildGetTeamMembersRequest(params: nVizzlyApi.GetTeamMembers): Request<{}>;
|
|
70
|
-
getVizzlyConfig(params: nVizzlyApi.GetVizzlyConfigParams): Promise<
|
|
79
|
+
getVizzlyConfig(params: nVizzlyApi.GetVizzlyConfigParams): Promise<{
|
|
80
|
+
encryptedConfig: string | null;
|
|
81
|
+
}>;
|
|
71
82
|
buildGetVizzlyConfigRequest(params: nVizzlyApi.GetVizzlyConfigParams): Request<{}>;
|
|
72
83
|
saveConnection(params: nVizzlyApi.SaveConnectionParams): Promise<import("../types").Response<unknown>>;
|
|
73
84
|
buildSaveConnectionRequest(params: nVizzlyApi.SaveConnectionParams): Request<{}>;
|
package/dist/models/VizzlyApi.js
CHANGED
|
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.VizzlyApi = void 0;
|
|
13
13
|
const Api_1 = require("./Api");
|
|
14
14
|
const errors_1 = require("../errors");
|
|
15
|
+
const FailedToFetchVizzlyConfig_1 = require("../errors/FailedToFetchVizzlyConfig");
|
|
16
|
+
const ConnectionDoesNotExistOnProject_1 = require("../errors/ConnectionDoesNotExistOnProject");
|
|
17
|
+
const FailedToFetchConnection_1 = require("../errors/FailedToFetchConnection");
|
|
15
18
|
class VizzlyApi extends Api_1.Api {
|
|
16
19
|
constructor(auth, host = 'https://api.vizzly.co') {
|
|
17
20
|
super(auth, host);
|
|
@@ -234,7 +237,16 @@ class VizzlyApi extends Api_1.Api {
|
|
|
234
237
|
}
|
|
235
238
|
getConnection(params) {
|
|
236
239
|
return __awaiter(this, void 0, void 0, function* () {
|
|
237
|
-
|
|
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}`);
|
|
238
250
|
});
|
|
239
251
|
}
|
|
240
252
|
buildGetConnectionRequest(params) {
|
|
@@ -303,7 +315,13 @@ class VizzlyApi extends Api_1.Api {
|
|
|
303
315
|
}
|
|
304
316
|
getVizzlyConfig(params) {
|
|
305
317
|
return __awaiter(this, void 0, void 0, function* () {
|
|
306
|
-
|
|
318
|
+
const response = yield this.execute(this.buildGetVizzlyConfigRequest(params));
|
|
319
|
+
if (response.status === 200) {
|
|
320
|
+
return {
|
|
321
|
+
encryptedConfig: response.body.encrypted_config,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
throw new FailedToFetchVizzlyConfig_1.FailedToFetchVizzlyConfig(`Failed to fetch the config containing data sets from the Vizzly API. Got status ${response.status}`);
|
|
307
325
|
});
|
|
308
326
|
}
|
|
309
327
|
buildGetVizzlyConfigRequest(params) {
|