UNPKG

reveal-sdk-node

Version:

RevealBI Node.js SDK

53 lines (52 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RVJsonSchemaConfigBuilder = void 0; /** * A helper object that can be used to create a configuration for a JSON data source item. */ class RVJsonSchemaConfigBuilder { constructor() { this._columnsConfig = []; this._iterationDepth = 0; } setIterationDepth(v) { this._iterationDepth = v; return this; } addStringField(key) { this._columnsConfig.push(RVJsonSchemaConfigBuilder._createColumnConfig(0, key)); return this; } addNumericField(key) { this._columnsConfig.push(RVJsonSchemaConfigBuilder._createColumnConfig(1, key)); return this; } addDateField(key, dateFormat) { this._columnsConfig.push(RVJsonSchemaConfigBuilder._createDateBasedColumnConfig(3, key, dateFormat)); return this; } addDateTimeField(key, dateFormat) { this._columnsConfig.push(RVJsonSchemaConfigBuilder._createDateBasedColumnConfig(3, key, dateFormat)); return this; } build() { return JSON.stringify({ "columnsConfig": this._columnsConfig, "iterationDepth": this._iterationDepth }); } /** @hidden */ static _createColumnConfig(type, key) { return { "type": type, "key": key }; } /** @hidden */ static _createDateBasedColumnConfig(type, key, dateFormat) { var column = RVJsonSchemaConfigBuilder._createColumnConfig(type, key); column["dateFormat"] = dateFormat; return column; } } exports.RVJsonSchemaConfigBuilder = RVJsonSchemaConfigBuilder;