@vizzly/api-client 0.0.1
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/README.md +1 -0
- package/dist/errors/DashboardQuotaReached.d.ts +3 -0
- package/dist/errors/DashboardQuotaReached.js +10 -0
- package/dist/errors/FailedToCreateDashboard.d.ts +3 -0
- package/dist/errors/FailedToCreateDashboard.js +10 -0
- package/dist/errors/FailedToFetchDashboardAccessTokens.d.ts +3 -0
- package/dist/errors/FailedToFetchDashboardAccessTokens.js +10 -0
- package/dist/errors/FailedToFetchDashboards.d.ts +3 -0
- package/dist/errors/FailedToFetchDashboards.js +10 -0
- package/dist/errors/FailedToFetchGlobalLibraries.d.ts +3 -0
- package/dist/errors/FailedToFetchGlobalLibraries.js +10 -0
- package/dist/errors/FailedToFetchGlobalLibraryAccessTokens.d.ts +3 -0
- package/dist/errors/FailedToFetchGlobalLibraryAccessTokens.js +10 -0
- package/dist/errors/FailedToResolveDataSets.d.ts +3 -0
- package/dist/errors/FailedToResolveDataSets.js +10 -0
- package/dist/errors/FailedToSetupProject.d.ts +3 -0
- package/dist/errors/FailedToSetupProject.js +10 -0
- package/dist/errors/MissingAuthParameter.d.ts +4 -0
- package/dist/errors/MissingAuthParameter.js +9 -0
- package/dist/errors/MissingRequiredVizzlyQueryEngineApi.d.ts +2 -0
- package/dist/errors/MissingRequiredVizzlyQueryEngineApi.js +6 -0
- package/dist/errors/SQLPreviewError.d.ts +4 -0
- package/dist/errors/SQLPreviewError.js +11 -0
- package/dist/errors/ValidationError.d.ts +3 -0
- package/dist/errors/ValidationError.js +10 -0
- package/dist/errors/index.d.ts +10 -0
- package/dist/errors/index.js +26 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +37 -0
- package/dist/interfaces/iSerialize.d.ts +10 -0
- package/dist/interfaces/iSerialize.js +1 -0
- package/dist/models/Api.d.ts +9 -0
- package/dist/models/Api.js +47 -0
- package/dist/models/Authentication.d.ts +16 -0
- package/dist/models/Authentication.js +98 -0
- package/dist/models/Dashboard.d.ts +24 -0
- package/dist/models/Dashboard.js +156 -0
- package/dist/models/DashboardRepository.d.ts +41 -0
- package/dist/models/DashboardRepository.js +92 -0
- package/dist/models/GlobalLibraryRepository.d.ts +35 -0
- package/dist/models/GlobalLibraryRepository.js +106 -0
- package/dist/models/ImplementationStrategy.d.ts +9 -0
- package/dist/models/ImplementationStrategy.js +18 -0
- package/dist/models/Permission.d.ts +26 -0
- package/dist/models/Permission.js +22 -0
- package/dist/models/Vizzly.d.ts +17 -0
- package/dist/models/Vizzly.js +39 -0
- package/dist/models/VizzlyApi.d.ts +77 -0
- package/dist/models/VizzlyApi.js +423 -0
- package/dist/models/VizzlyAppApi.d.ts +54 -0
- package/dist/models/VizzlyAppApi.js +348 -0
- package/dist/models/VizzlyQueryEngineApi.d.ts +50 -0
- package/dist/models/VizzlyQueryEngineApi.js +311 -0
- package/dist/types/dashboard.d.ts +23 -0
- package/dist/types/dashboard.js +2 -0
- package/dist/types.d.ts +405 -0
- package/dist/types.js +17 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Vizzly API client
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DashboardQuotaReached = void 0;
|
|
4
|
+
class DashboardQuotaReached extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'DashboardQuotaReached';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.DashboardQuotaReached = DashboardQuotaReached;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FailedToCreateDashboard = void 0;
|
|
4
|
+
class FailedToCreateDashboard extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'FailedToCreateDashboard';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FailedToCreateDashboard = FailedToCreateDashboard;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FailedToFetchDashboardAccessTokens = void 0;
|
|
4
|
+
class FailedToFetchDashboardAccessTokens extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'FailedToFetchDashboardAccessTokens';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FailedToFetchDashboardAccessTokens = FailedToFetchDashboardAccessTokens;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FailedToFetchDashboards = void 0;
|
|
4
|
+
class FailedToFetchDashboards extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'FailedToFetchDashboards';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FailedToFetchDashboards = FailedToFetchDashboards;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FailedToFetchGlobalLibraries = void 0;
|
|
4
|
+
class FailedToFetchGlobalLibraries extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'FailedToFetchGlobalLibraries';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FailedToFetchGlobalLibraries = FailedToFetchGlobalLibraries;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FailedToFetchGlobalLibraryAccessTokens = void 0;
|
|
4
|
+
class FailedToFetchGlobalLibraryAccessTokens extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'FailedToFetchGlobalLibraryAccessTokens';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FailedToFetchGlobalLibraryAccessTokens = FailedToFetchGlobalLibraryAccessTokens;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FailedToResolveDataSets = void 0;
|
|
4
|
+
class FailedToResolveDataSets extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'FailedToResolveDataSets';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FailedToResolveDataSets = FailedToResolveDataSets;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FailedToSetupProject = void 0;
|
|
4
|
+
class FailedToSetupProject extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'FailedToSetupProject';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.FailedToSetupProject = FailedToSetupProject;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissingAuthParameter = void 0;
|
|
4
|
+
class MissingAuthParameter extends Error {
|
|
5
|
+
constructor(missingParameter) {
|
|
6
|
+
super(`Missing required auth parameter ${missingParameter}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.MissingAuthParameter = MissingAuthParameter;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissingRequiredVizzlyQueryEngineApi = void 0;
|
|
4
|
+
class MissingRequiredVizzlyQueryEngineApi extends Error {
|
|
5
|
+
}
|
|
6
|
+
exports.MissingRequiredVizzlyQueryEngineApi = MissingRequiredVizzlyQueryEngineApi;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SQLPreviewError = void 0;
|
|
4
|
+
const ValidationError_1 = require("./ValidationError");
|
|
5
|
+
class SQLPreviewError extends ValidationError_1.ValidationError {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'SQLPreviewError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.SQLPreviewError = SQLPreviewError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidationError = void 0;
|
|
4
|
+
class ValidationError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message); // (1)
|
|
7
|
+
this.name = 'ValidationError'; // (2)
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ValidationError = ValidationError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './DashboardQuotaReached';
|
|
2
|
+
export * from './FailedToCreateDashboard';
|
|
3
|
+
export * from './FailedToFetchDashboardAccessTokens';
|
|
4
|
+
export * from './FailedToFetchDashboards';
|
|
5
|
+
export * from './MissingAuthParameter';
|
|
6
|
+
export * from './MissingRequiredVizzlyQueryEngineApi';
|
|
7
|
+
export * from './ValidationError';
|
|
8
|
+
export * from './SQLPreviewError';
|
|
9
|
+
export * from './FailedToSetupProject';
|
|
10
|
+
export * from './FailedToResolveDataSets';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./DashboardQuotaReached"), exports);
|
|
18
|
+
__exportStar(require("./FailedToCreateDashboard"), exports);
|
|
19
|
+
__exportStar(require("./FailedToFetchDashboardAccessTokens"), exports);
|
|
20
|
+
__exportStar(require("./FailedToFetchDashboards"), exports);
|
|
21
|
+
__exportStar(require("./MissingAuthParameter"), exports);
|
|
22
|
+
__exportStar(require("./MissingRequiredVizzlyQueryEngineApi"), exports);
|
|
23
|
+
__exportStar(require("./ValidationError"), exports);
|
|
24
|
+
__exportStar(require("./SQLPreviewError"), exports);
|
|
25
|
+
__exportStar(require("./FailedToSetupProject"), exports);
|
|
26
|
+
__exportStar(require("./FailedToResolveDataSets"), exports);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './models/Vizzly';
|
|
2
|
+
export * from './models/VizzlyApi';
|
|
3
|
+
export * from './models/VizzlyAppApi';
|
|
4
|
+
export * from './models/VizzlyQueryEngineApi';
|
|
5
|
+
export * from './models/Authentication';
|
|
6
|
+
export * from './models/ImplementationStrategy';
|
|
7
|
+
export * from './types';
|
|
8
|
+
export * as Errors from './errors';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Errors = void 0;
|
|
30
|
+
__exportStar(require("./models/Vizzly"), exports);
|
|
31
|
+
__exportStar(require("./models/VizzlyApi"), exports);
|
|
32
|
+
__exportStar(require("./models/VizzlyAppApi"), exports);
|
|
33
|
+
__exportStar(require("./models/VizzlyQueryEngineApi"), exports);
|
|
34
|
+
__exportStar(require("./models/Authentication"), exports);
|
|
35
|
+
__exportStar(require("./models/ImplementationStrategy"), exports);
|
|
36
|
+
__exportStar(require("./types"), exports);
|
|
37
|
+
exports.Errors = __importStar(require("./errors"));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface iSerialize<DumpedType, LoadedType> {
|
|
2
|
+
/** Converts attributes from a previously saved version to the latest version. */
|
|
3
|
+
upcast(dumped: unknown): LoadedType;
|
|
4
|
+
/** Load JSON into the instance */
|
|
5
|
+
deserialize(dumped: DumpedType): LoadedType;
|
|
6
|
+
/** Output JSON that can be saved */
|
|
7
|
+
serialize(loaded: LoadedType): DumpedType;
|
|
8
|
+
/** Throws if the loaded type is not valid */
|
|
9
|
+
validate(loaded: LoadedType): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Authentication } from './Authentication';
|
|
2
|
+
import { Request, Response } from '../types';
|
|
3
|
+
export declare class Api {
|
|
4
|
+
private host;
|
|
5
|
+
private extraHeaders;
|
|
6
|
+
protected auth: Authentication;
|
|
7
|
+
constructor(auth: Authentication, host: string, extraHeaders?: () => {});
|
|
8
|
+
execute<ResponseBody>(request: Request<any>): Promise<Response<ResponseBody>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Api = void 0;
|
|
16
|
+
const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch"));
|
|
17
|
+
class Api {
|
|
18
|
+
constructor(auth, host, extraHeaders = () => ({})) {
|
|
19
|
+
this.host = host;
|
|
20
|
+
this.extraHeaders = extraHeaders;
|
|
21
|
+
this.auth = auth;
|
|
22
|
+
}
|
|
23
|
+
execute(request) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
var _a;
|
|
26
|
+
const authHeaders = this.auth.buildAuthHeaders();
|
|
27
|
+
const customHeaders = Object.assign(Object.assign({}, (request.headers || {})), (this.extraHeaders() || {}));
|
|
28
|
+
const path = `${this.host}${request.path}`;
|
|
29
|
+
console.debug(`[REQUEST] ${path}`);
|
|
30
|
+
const res = yield (0, isomorphic_fetch_1.default)(path, {
|
|
31
|
+
method: request.method,
|
|
32
|
+
headers: Object.assign(Object.assign({ 'Content-Type': 'application/json', Accept: 'application/json' }, authHeaders), customHeaders),
|
|
33
|
+
redirect: 'follow',
|
|
34
|
+
referrerPolicy: 'no-referrer',
|
|
35
|
+
body: request.body ? JSON.stringify(request.body) : null,
|
|
36
|
+
signal: request.abortSignal,
|
|
37
|
+
});
|
|
38
|
+
let body = ((_a = res.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('json')) ? yield res.json() : res.text();
|
|
39
|
+
const debugRequestId = res.headers.get('vizzly-query-engine-request-id') || res.headers.get('x-request-id');
|
|
40
|
+
if (debugRequestId && res.status != 200) {
|
|
41
|
+
console.debug(`[Vizzly Query Engine Request Id] ${debugRequestId}`);
|
|
42
|
+
}
|
|
43
|
+
return { body: body, status: res.status, headers: res.headers };
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.Api = Api;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AuthParams } from '../types';
|
|
2
|
+
export declare class Authentication {
|
|
3
|
+
private authParams;
|
|
4
|
+
constructor(authParams: AuthParams);
|
|
5
|
+
updateAuthParams(authParams: Partial<AuthParams>): void;
|
|
6
|
+
getQueryEngineAccessToken(): string;
|
|
7
|
+
getProjectAdminOverrideToken(): string | undefined;
|
|
8
|
+
getDashboardAccessToken(): string;
|
|
9
|
+
getAppSessionToken(): string | undefined;
|
|
10
|
+
getDataAccessToken(): string;
|
|
11
|
+
getProjectApiKey(): string;
|
|
12
|
+
getProjectAccessToken(): string;
|
|
13
|
+
buildAuthHeaders(): {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Authentication = void 0;
|
|
4
|
+
const MissingAuthParameter_1 = require("../errors/MissingAuthParameter");
|
|
5
|
+
class Authentication {
|
|
6
|
+
constructor(authParams) {
|
|
7
|
+
this.authParams = authParams;
|
|
8
|
+
}
|
|
9
|
+
updateAuthParams(authParams) {
|
|
10
|
+
this.authParams = Object.assign(Object.assign({}, this.authParams), authParams);
|
|
11
|
+
}
|
|
12
|
+
getQueryEngineAccessToken() {
|
|
13
|
+
if (!this.authParams.queryEngineAccessToken)
|
|
14
|
+
throw new MissingAuthParameter_1.MissingAuthParameter('queryEngineAccessToken');
|
|
15
|
+
return this.authParams.queryEngineAccessToken;
|
|
16
|
+
}
|
|
17
|
+
getProjectAdminOverrideToken() {
|
|
18
|
+
return this.authParams.projectAdminOverrideToken;
|
|
19
|
+
}
|
|
20
|
+
getDashboardAccessToken() {
|
|
21
|
+
if (!this.authParams.dashboardAccessToken)
|
|
22
|
+
throw new MissingAuthParameter_1.MissingAuthParameter('dashboardAccessToken');
|
|
23
|
+
return this.authParams.dashboardAccessToken;
|
|
24
|
+
}
|
|
25
|
+
getAppSessionToken() {
|
|
26
|
+
return this.authParams.appSessionToken;
|
|
27
|
+
}
|
|
28
|
+
getDataAccessToken() {
|
|
29
|
+
if (!this.authParams.dataAccessToken)
|
|
30
|
+
throw new MissingAuthParameter_1.MissingAuthParameter('dataAccessToken');
|
|
31
|
+
return this.authParams.dataAccessToken;
|
|
32
|
+
}
|
|
33
|
+
getProjectApiKey() {
|
|
34
|
+
if (!this.authParams.projectApiKey)
|
|
35
|
+
throw new MissingAuthParameter_1.MissingAuthParameter('projectApiKey');
|
|
36
|
+
return this.authParams.projectApiKey;
|
|
37
|
+
}
|
|
38
|
+
getProjectAccessToken() {
|
|
39
|
+
if (!this.authParams.projectAccessToken)
|
|
40
|
+
throw new MissingAuthParameter_1.MissingAuthParameter('projectAccessToken');
|
|
41
|
+
return this.authParams.projectAccessToken;
|
|
42
|
+
}
|
|
43
|
+
buildAuthHeaders() {
|
|
44
|
+
if (this.authParams.dashboardAccessToken) {
|
|
45
|
+
console.debug('Using dashboard access token');
|
|
46
|
+
return {
|
|
47
|
+
auth: `Bearer ${this.authParams.dashboardAccessToken}`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// If a project access token has been set on the config, use that instead
|
|
51
|
+
// of fetching one. This is most likely used on the managed query-engine where we
|
|
52
|
+
// pass the project access token through in a request header.
|
|
53
|
+
if (this.authParams.projectAccessToken) {
|
|
54
|
+
console.debug('Using project access token for auth header');
|
|
55
|
+
return {
|
|
56
|
+
auth: `Bearer ${this.authParams.projectAccessToken}`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (this.authParams.projectApiKey) {
|
|
60
|
+
console.debug('Using API Key for auth header');
|
|
61
|
+
return {
|
|
62
|
+
auth: `Api-Key ${this.authParams.projectApiKey}`,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (this.authParams.appSessionToken) {
|
|
66
|
+
console.debug('Using app session access token');
|
|
67
|
+
return {
|
|
68
|
+
auth: `Bearer ${this.authParams.appSessionToken}`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// Try without this extra logic to fetch the project tokens...
|
|
72
|
+
// else if (request.preFetchProjectAccessTokens && (config.useCookieAuth || !!config.appSessionAuthToken)) {
|
|
73
|
+
// logDebug(
|
|
74
|
+
// 'Fetching project access token from the Vizzly API',
|
|
75
|
+
// request.preFetchProjectAccessTokens.projectId,
|
|
76
|
+
// 'Filtering by',
|
|
77
|
+
// request.preFetchProjectAccessTokens.resourceFilters
|
|
78
|
+
// );
|
|
79
|
+
// const accessToken = await getProjectAccessToken(httpClient(config))(
|
|
80
|
+
// request.preFetchProjectAccessTokens.projectId,
|
|
81
|
+
// config.appSessionAuthToken,
|
|
82
|
+
// request.preFetchProjectAccessTokens.resourceFilters
|
|
83
|
+
// );
|
|
84
|
+
// if (accessToken) {
|
|
85
|
+
// logDebug('Project access token received.');
|
|
86
|
+
// return {
|
|
87
|
+
// auth: `Bearer ${accessToken}`,
|
|
88
|
+
// };
|
|
89
|
+
// } else {
|
|
90
|
+
// logDebug('Failed to receive project access token.');
|
|
91
|
+
// }
|
|
92
|
+
// } else {
|
|
93
|
+
// logDebug('Not pre-fetching project access token.');
|
|
94
|
+
// }
|
|
95
|
+
return {};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.Authentication = Authentication;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Vizzly } from './Vizzly';
|
|
2
|
+
import { CreateDashboardParams, DashboardDefinition, Dashboard as DashboardType, GlobalLibrary, UpdateDashboardParams } from '../types';
|
|
3
|
+
export declare class Dashboard {
|
|
4
|
+
private vizzly;
|
|
5
|
+
constructor(vizzly: Vizzly);
|
|
6
|
+
create(params: CreateDashboardParams): Promise<{
|
|
7
|
+
dashboard: DashboardType;
|
|
8
|
+
permissions: ({
|
|
9
|
+
userReference: string;
|
|
10
|
+
token: string;
|
|
11
|
+
scope: "read" | "read_write";
|
|
12
|
+
} & {
|
|
13
|
+
dashboardId: string;
|
|
14
|
+
})[];
|
|
15
|
+
}>;
|
|
16
|
+
update(params: Omit<UpdateDashboardParams, 'dashboardSessionToken' | 'definition'> & {
|
|
17
|
+
dashboardId: string;
|
|
18
|
+
definition?: DashboardDefinition;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
getDashboards(): Promise<DashboardType[]>;
|
|
21
|
+
static mergeDashboardsAndGlobalLibraries(dashboards: DashboardType[], globalLibraries: GlobalLibrary[]): DashboardType[];
|
|
22
|
+
static mergeCustomFields(dashboard: DashboardType, dashboards: DashboardType[], parentGlobalLibrariesForDashboard: GlobalLibrary[], childGlobalLibrariesForDashboard: GlobalLibrary[]): DashboardType['definition']['customFields'];
|
|
23
|
+
static markViewsAsProtected(componentLibrary: DashboardType['definition']['componentLibrary']): DashboardType['definition']['componentLibrary'];
|
|
24
|
+
}
|