reveal-sdk-node
Version:
RevealBI Node.js SDK
123 lines (122 loc) • 5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RVDataSourceItem = void 0;
const RVDashboardDataSource_1 = require("./RVDashboardDataSource");
// @if SERVER_SDK
const types_1 = require("../types");
// @endif
/**
* The basic class for data source items that can be used by visualizations to get data.
* When getting data from a database for example, the data source object contains the information required to connect
* to the database (like server host and database name) and the data source item contains
* the information required to get the dataset itself (like table name or view name).
*/
class RVDataSourceItem {
/** @hidden */
constructor(arg) {
var _a, _b;
this._defaultRefreshRate = null;
this._title = null;
this._subtitle = null;
this._id = null;
this._description = null;
if (arg instanceof RVDashboardDataSource_1.RVDashboardDataSource) {
this._dataSource = arg;
}
else {
this._defaultRefreshRate = (_a = arg.Settings) === null || _a === void 0 ? void 0 : _a['DefaultRefreshRate'];
this._id = arg['Id'];
this._title = arg['Title'];
this._description = arg['Description'];
this._subtitle = arg['Subtitle'];
this._dataSource = (_b = RVDataSourceItem.dataSourceFactory) === null || _b === void 0 ? void 0 : _b.call(RVDataSourceItem, arg['DataSource']);
}
}
/** @hidden */
toJson() {
var json = {
_type: 'DataSourceItemType',
'DataSource': this._dataSource.toJson(),
'Properties': {},
'Parameters': {}
};
if (this._defaultRefreshRate != null) {
var settings = json['Settings'] = {};
settings['DefaultRefreshRate'] = this._defaultRefreshRate;
}
json["Id"] = this._id;
json["Title"] = this._title;
json["Description"] = this._description;
json["Subtitle"] = this._subtitle;
return json;
}
/** The title of the item, as displayed to the user, it might be for example the name of the table in a database. */
get title() {
return this._title;
}
set title(value) {
this._title = value;
}
/** The subtitle of the data source, if not null will be displayed to users instead of connection information like host and database name. */
get subtitle() {
return this._subtitle;
}
set subtitle(value) {
this._subtitle = value;
}
/** The value that identifies this item in the data source, it might be for example the name of the schema concatenated with the table name. */
get id() {
return this._id;
}
set id(value) {
this._id = value;
}
/** Description of this data source item. */
get description() {
return this._description;
}
set description(value) {
this._description = value;
}
/**
* Reference to the data source object this item belongs to.
*/
get dataSource() {
return this._dataSource;
}
set dataSource(value) {
this._dataSource = value;
}
/**
* Default value to use for "Refresh Data" setting for visualizations created using this item, expressed in minutes (e.g. 1440 = 1 day).
* A value of N means that whenever the visualization requests data, the engine will return data found in the cache if it's not older than N minutes -this means, if the engine fetched it from the datasource no more than N minutes before-. If not set it will use the default value set in the data source object.
*/
set defaultRefreshRate(v) {
this._defaultRefreshRate = v;
}
get defaultRefreshRate() {
return this._defaultRefreshRate;
}
// @if SERVER_SDK
/** @hidden */
deserializeCustomQuerySupport(arg, supportsParameters) {
var _a;
const anyThis = this;
anyThis.customQuery = (_a = arg === null || arg === void 0 ? void 0 : arg.Properties) === null || _a === void 0 ? void 0 : _a["RPCustomQuery"];
if (supportsParameters && anyThis.customQuery != null) {
anyThis.customQueryParameters = (0, types_1.createDictionaryFromJsonObject)(arg === null || arg === void 0 ? void 0 : arg["Parameters"]);
}
}
/** @hidden */
serializeCustomQuerySupport(json, supportsParameters) {
const props = json["Properties"];
const anyThis = this;
if (anyThis.customQuery != null) {
props["RPCustomQuery"] = anyThis.customQuery;
if (supportsParameters && anyThis.customQueryParameters != null) {
(0, types_1.copyEntriesToJsonObject)(anyThis.customQueryParameters, json["Parameters"]);
}
}
}
}
exports.RVDataSourceItem = RVDataSourceItem;