@superset-ui/query
Advanced tools
Comparing version 0.13.0 to 0.13.3
@@ -1,11 +0,19 @@ | ||
import buildQueryObject from './buildQueryObject'; | ||
import DatasourceKey from './DatasourceKey'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = buildQueryContext; | ||
var _buildQueryObject = _interopRequireDefault(require("./buildQueryObject")); | ||
var _DatasourceKey = _interopRequireDefault(require("./DatasourceKey")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const WRAP_IN_ARRAY = baseQueryObject => [baseQueryObject]; | ||
export default function buildQueryContext(formData, buildQuery = WRAP_IN_ARRAY) { | ||
function buildQueryContext(formData, buildQuery = WRAP_IN_ARRAY) { | ||
return { | ||
datasource: new DatasourceKey(formData.datasource).toObject(), | ||
queries: buildQuery(buildQueryObject(formData)) | ||
datasource: new _DatasourceKey.default(formData.datasource).toObject(), | ||
queries: buildQuery((0, _buildQueryObject.default)(formData)) | ||
}; | ||
} |
@@ -0,13 +1,26 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = buildQueryObject; | ||
exports.DTTM_ALIAS = void 0; | ||
var _QueryFormData = require("./types/QueryFormData"); | ||
var _convertMetric = _interopRequireDefault(require("./convertMetric")); | ||
var _processFilters = _interopRequireDefault(require("./processFilters")); | ||
var _processMetrics = _interopRequireDefault(require("./processMetrics")); | ||
var _processExtras = _interopRequireDefault(require("./processExtras")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
/* eslint-disable camelcase */ | ||
import { isSqlaFormData } from './types/QueryFormData'; | ||
import convertMetric from './convertMetric'; | ||
import processFilters from './processFilters'; | ||
import processMetrics from './processMetrics'; | ||
import processExtras from './processExtras'; | ||
export const DTTM_ALIAS = '__timestamp'; | ||
const DTTM_ALIAS = '__timestamp'; | ||
exports.DTTM_ALIAS = DTTM_ALIAS; | ||
function processGranularity(formData) { | ||
return isSqlaFormData(formData) ? formData.granularity_sqla : formData.granularity; | ||
return (0, _QueryFormData.isSqlaFormData)(formData) ? formData.granularity_sqla : formData.granularity; | ||
} | ||
@@ -23,3 +36,3 @@ /** | ||
export default function buildQueryObject(formData) { | ||
function buildQueryObject(formData) { | ||
const { | ||
@@ -40,7 +53,7 @@ time_range, | ||
const queryObject = _extends({ | ||
extras: processExtras(formData), | ||
extras: (0, _processExtras.default)(formData), | ||
granularity: processGranularity(formData), | ||
groupby: Array.from(groupbySet), | ||
is_timeseries: groupbySet.has(DTTM_ALIAS), | ||
metrics: processMetrics(formData), | ||
metrics: (0, _processMetrics.default)(formData), | ||
order_desc: typeof order_desc === 'undefined' ? true : order_desc, | ||
@@ -52,7 +65,7 @@ orderby: [], | ||
timeseries_limit: limit ? Number(limit) : 0, | ||
timeseries_limit_metric: timeseries_limit_metric ? convertMetric(timeseries_limit_metric) : null, | ||
timeseries_limit_metric: timeseries_limit_metric ? (0, _convertMetric.default)(timeseries_limit_metric) : null, | ||
until | ||
}, processFilters(formData)); | ||
}, (0, _processFilters.default)(formData)); | ||
return queryObject; | ||
} |
@@ -1,3 +0,9 @@ | ||
import { isBinaryAdhocFilter, isUnaryAdhocFilter } from './types/Filter'; | ||
export default function convertFilter(filter) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = convertFilter; | ||
var _Filter = require("./types/Filter"); | ||
function convertFilter(filter) { | ||
const { | ||
@@ -7,3 +13,3 @@ subject | ||
if (isUnaryAdhocFilter(filter)) { | ||
if ((0, _Filter.isUnaryAdhocFilter)(filter)) { | ||
const { | ||
@@ -18,3 +24,3 @@ operator | ||
if (isBinaryAdhocFilter(filter)) { | ||
if ((0, _Filter.isBinaryAdhocFilter)(filter)) { | ||
const { | ||
@@ -21,0 +27,0 @@ operator |
@@ -0,4 +1,11 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = convertMetric; | ||
exports.LABEL_MAX_LENGTH = void 0; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
export const LABEL_MAX_LENGTH = 43; | ||
const LABEL_MAX_LENGTH = 43; | ||
exports.LABEL_MAX_LENGTH = LABEL_MAX_LENGTH; | ||
@@ -17,3 +24,3 @@ function getDefaultLabel(metric) { | ||
export default function convertMetric(metric) { | ||
function convertMetric(metric) { | ||
let formattedMetric; | ||
@@ -20,0 +27,0 @@ |
@@ -0,5 +1,11 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _Datasource = require("./types/Datasource"); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import { DatasourceType } from './types/Datasource'; | ||
export default class DatasourceKey { | ||
class DatasourceKey { | ||
constructor(key) { | ||
@@ -12,3 +18,3 @@ _defineProperty(this, "id", void 0); | ||
this.id = parseInt(idStr, 10); | ||
this.type = typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid; | ||
this.type = typeStr === 'table' ? _Datasource.DatasourceType.Table : _Datasource.DatasourceType.Druid; | ||
} | ||
@@ -27,2 +33,4 @@ | ||
} | ||
} | ||
exports.default = DatasourceKey; |
@@ -1,10 +0,73 @@ | ||
export { default as buildQueryContext } from './buildQueryContext'; | ||
export { default as buildQueryObject } from './buildQueryObject'; | ||
export { default as convertFilter } from './convertFilter'; | ||
export { default as convertMetric } from './convertMetric'; | ||
export { default as DatasourceKey } from './DatasourceKey'; | ||
export * from './types/QueryFormData'; | ||
export * from './types/Column'; | ||
export * from './types/Datasource'; | ||
export * from './types/Metric'; | ||
export * from './types/Query'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
var _exportNames = { | ||
buildQueryContext: true, | ||
buildQueryObject: true, | ||
convertFilter: true, | ||
convertMetric: true, | ||
DatasourceKey: true | ||
}; | ||
exports.DatasourceKey = exports.convertMetric = exports.convertFilter = exports.buildQueryObject = exports.buildQueryContext = void 0; | ||
var _buildQueryContext = _interopRequireDefault(require("./buildQueryContext")); | ||
exports.buildQueryContext = _buildQueryContext.default; | ||
var _buildQueryObject = _interopRequireDefault(require("./buildQueryObject")); | ||
exports.buildQueryObject = _buildQueryObject.default; | ||
var _convertFilter = _interopRequireDefault(require("./convertFilter")); | ||
exports.convertFilter = _convertFilter.default; | ||
var _convertMetric = _interopRequireDefault(require("./convertMetric")); | ||
exports.convertMetric = _convertMetric.default; | ||
var _DatasourceKey = _interopRequireDefault(require("./DatasourceKey")); | ||
exports.DatasourceKey = _DatasourceKey.default; | ||
var _QueryFormData = require("./types/QueryFormData"); | ||
Object.keys(_QueryFormData).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _QueryFormData[key]; | ||
}); | ||
var _Column = require("./types/Column"); | ||
Object.keys(_Column).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _Column[key]; | ||
}); | ||
var _Datasource = require("./types/Datasource"); | ||
Object.keys(_Datasource).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _Datasource[key]; | ||
}); | ||
var _Metric = require("./types/Metric"); | ||
Object.keys(_Metric).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _Metric[key]; | ||
}); | ||
var _Query = require("./types/Query"); | ||
Object.keys(_Query).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _Query[key]; | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -0,4 +1,10 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = processExtras; | ||
var _QueryFormData = require("./types/QueryFormData"); | ||
/* eslint-disable camelcase */ | ||
import { isDruidFormData } from './types/QueryFormData'; | ||
export default function processExtras(formData) { | ||
function processExtras(formData) { | ||
const { | ||
@@ -8,3 +14,3 @@ where = '' | ||
if (isDruidFormData(formData)) { | ||
if ((0, _QueryFormData.isDruidFormData)(formData)) { | ||
const { | ||
@@ -11,0 +17,0 @@ druid_time_origin, |
@@ -1,6 +0,14 @@ | ||
import { isSimpleAdhocFilter } from './types/Filter'; | ||
import convertFilter from './convertFilter'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = processFilters; | ||
var _Filter = require("./types/Filter"); | ||
var _convertFilter = _interopRequireDefault(require("./convertFilter")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** Logic formerly in viz.py's process_query_filters */ | ||
export default function processFilters(formData) { | ||
function processFilters(formData) { | ||
// TODO: Implement | ||
@@ -30,4 +38,4 @@ // utils.convert_legacy_filters_into_adhoc(self.form_data) | ||
if (isSimpleAdhocFilter(filter)) { | ||
const filterClause = convertFilter(filter); | ||
if ((0, _Filter.isSimpleAdhocFilter)(filter)) { | ||
const filterClause = (0, _convertFilter.default)(filter); | ||
@@ -34,0 +42,0 @@ if (clause === 'WHERE') { |
@@ -1,9 +0,18 @@ | ||
import { MetricKey } from './types/Metric'; | ||
import convertMetric from './convertMetric'; | ||
export default function processMetrics(formData) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = processMetrics; | ||
var _Metric = require("./types/Metric"); | ||
var _convertMetric = _interopRequireDefault(require("./convertMetric")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function processMetrics(formData) { | ||
// Use Array to maintain insertion order | ||
// for metrics that are order sensitive | ||
const metrics = []; | ||
Object.keys(MetricKey).forEach(key => { | ||
const metric = formData[MetricKey[key]]; | ||
Object.keys(_Metric.MetricKey).forEach(key => { | ||
const metric = formData[_Metric.MetricKey[key]]; | ||
@@ -13,6 +22,6 @@ if (metric) { | ||
metric.forEach(m => { | ||
metrics.push(convertMetric(m)); | ||
metrics.push((0, _convertMetric.default)(m)); | ||
}); | ||
} else { | ||
metrics.push(convertMetric(metric)); | ||
metrics.push((0, _convertMetric.default)(metric)); | ||
} | ||
@@ -19,0 +28,0 @@ } |
@@ -1,3 +0,9 @@ | ||
export let ColumnType; // TODO: fill out additional fields of the Column interface | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.ColumnType = void 0; | ||
let ColumnType; // TODO: fill out additional fields of the Column interface | ||
exports.ColumnType = ColumnType; | ||
(function (ColumnType) { | ||
@@ -19,2 +25,2 @@ ColumnType["DOUBLE"] = "DOUBLE"; | ||
ColumnType["CHAR"] = "CHAR"; | ||
})(ColumnType || (ColumnType = {})); | ||
})(ColumnType || (exports.ColumnType = ColumnType = {})); |
@@ -1,7 +0,13 @@ | ||
export let DatasourceType; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.DatasourceType = void 0; | ||
let DatasourceType; | ||
/** @TODO can continue to add fields to this */ | ||
exports.DatasourceType = DatasourceType; | ||
(function (DatasourceType) { | ||
DatasourceType["Table"] = "table"; | ||
DatasourceType["Druid"] = "druid"; | ||
})(DatasourceType || (DatasourceType = {})); | ||
})(DatasourceType || (exports.DatasourceType = DatasourceType = {})); |
@@ -1,16 +0,28 @@ | ||
import { isUnaryOperator, isBinaryOperator, isSetOperator } from './Operator'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.isSimpleAdhocFilter = isSimpleAdhocFilter; | ||
exports.isUnaryAdhocFilter = isUnaryAdhocFilter; | ||
exports.isBinaryAdhocFilter = isBinaryAdhocFilter; | ||
exports.isSetAdhocFilter = isSetAdhocFilter; | ||
var _Operator = require("./Operator"); | ||
//--------------------------------------------------- | ||
// Type guards | ||
//--------------------------------------------------- | ||
export function isSimpleAdhocFilter(filter) { | ||
function isSimpleAdhocFilter(filter) { | ||
return filter.expressionType === 'SIMPLE'; | ||
} | ||
export function isUnaryAdhocFilter(filter) { | ||
return isUnaryOperator(filter.operator); | ||
function isUnaryAdhocFilter(filter) { | ||
return (0, _Operator.isUnaryOperator)(filter.operator); | ||
} | ||
export function isBinaryAdhocFilter(filter) { | ||
return isBinaryOperator(filter.operator); | ||
function isBinaryAdhocFilter(filter) { | ||
return (0, _Operator.isBinaryOperator)(filter.operator); | ||
} | ||
export function isSetAdhocFilter(filter) { | ||
return isSetOperator(filter.operator); | ||
function isSetAdhocFilter(filter) { | ||
return (0, _Operator.isSetOperator)(filter.operator); | ||
} |
@@ -0,4 +1,9 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.MetricKey = void 0; | ||
// Note that the values of MetricKeys are lower_snake_case because they're | ||
// used as keys of form data jsons. | ||
export let MetricKey; | ||
let MetricKey; | ||
exports.MetricKey = MetricKey; | ||
@@ -14,2 +19,2 @@ (function (MetricKey) { | ||
MetricKey["SIZE"] = "size"; | ||
})(MetricKey || (MetricKey = {})); | ||
})(MetricKey || (exports.MetricKey = MetricKey = {})); |
@@ -0,1 +1,8 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.isUnaryOperator = isUnaryOperator; | ||
exports.isBinaryOperator = isBinaryOperator; | ||
exports.isSetOperator = isSetOperator; | ||
/** List of operators that do not require another operand */ | ||
@@ -18,12 +25,17 @@ const UNARY_OPERATORS = ['IS NOT NULL', 'IS NULL']; | ||
const unaryOperatorSet = new Set(UNARY_OPERATORS); | ||
export function isUnaryOperator(operator) { | ||
function isUnaryOperator(operator) { | ||
return unaryOperatorSet.has(operator); | ||
} | ||
const binaryOperatorSet = new Set(BINARY_OPERATORS); | ||
export function isBinaryOperator(operator) { | ||
function isBinaryOperator(operator) { | ||
return binaryOperatorSet.has(operator); | ||
} | ||
const setOperatorSet = new Set(SET_OPERATORS); | ||
export function isSetOperator(operator) { | ||
function isSetOperator(operator) { | ||
return setOperatorSet.has(operator); | ||
} |
@@ -0,1 +1,7 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.isDruidFormData = isDruidFormData; | ||
exports.isSqlaFormData = isSqlaFormData; | ||
/* eslint camelcase: 0 */ | ||
@@ -13,7 +19,8 @@ // FormData uses snake_cased keys. | ||
//--------------------------------------------------- | ||
export function isDruidFormData(formData) { | ||
function isDruidFormData(formData) { | ||
return 'granularity' in formData; | ||
} | ||
export function isSqlaFormData(formData) { | ||
function isSqlaFormData(formData) { | ||
return 'granularity_sqla' in formData; | ||
} |
@@ -1,11 +0,19 @@ | ||
import buildQueryObject from './buildQueryObject'; | ||
import DatasourceKey from './DatasourceKey'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = buildQueryContext; | ||
var _buildQueryObject = _interopRequireDefault(require("./buildQueryObject")); | ||
var _DatasourceKey = _interopRequireDefault(require("./DatasourceKey")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const WRAP_IN_ARRAY = baseQueryObject => [baseQueryObject]; | ||
export default function buildQueryContext(formData, buildQuery = WRAP_IN_ARRAY) { | ||
function buildQueryContext(formData, buildQuery = WRAP_IN_ARRAY) { | ||
return { | ||
datasource: new DatasourceKey(formData.datasource).toObject(), | ||
queries: buildQuery(buildQueryObject(formData)) | ||
datasource: new _DatasourceKey.default(formData.datasource).toObject(), | ||
queries: buildQuery((0, _buildQueryObject.default)(formData)) | ||
}; | ||
} |
@@ -0,13 +1,26 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = buildQueryObject; | ||
exports.DTTM_ALIAS = void 0; | ||
var _QueryFormData = require("./types/QueryFormData"); | ||
var _convertMetric = _interopRequireDefault(require("./convertMetric")); | ||
var _processFilters = _interopRequireDefault(require("./processFilters")); | ||
var _processMetrics = _interopRequireDefault(require("./processMetrics")); | ||
var _processExtras = _interopRequireDefault(require("./processExtras")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
/* eslint-disable camelcase */ | ||
import { isSqlaFormData } from './types/QueryFormData'; | ||
import convertMetric from './convertMetric'; | ||
import processFilters from './processFilters'; | ||
import processMetrics from './processMetrics'; | ||
import processExtras from './processExtras'; | ||
export const DTTM_ALIAS = '__timestamp'; | ||
const DTTM_ALIAS = '__timestamp'; | ||
exports.DTTM_ALIAS = DTTM_ALIAS; | ||
function processGranularity(formData) { | ||
return isSqlaFormData(formData) ? formData.granularity_sqla : formData.granularity; | ||
return (0, _QueryFormData.isSqlaFormData)(formData) ? formData.granularity_sqla : formData.granularity; | ||
} | ||
@@ -23,3 +36,3 @@ /** | ||
export default function buildQueryObject(formData) { | ||
function buildQueryObject(formData) { | ||
const { | ||
@@ -40,7 +53,7 @@ time_range, | ||
const queryObject = _extends({ | ||
extras: processExtras(formData), | ||
extras: (0, _processExtras.default)(formData), | ||
granularity: processGranularity(formData), | ||
groupby: Array.from(groupbySet), | ||
is_timeseries: groupbySet.has(DTTM_ALIAS), | ||
metrics: processMetrics(formData), | ||
metrics: (0, _processMetrics.default)(formData), | ||
order_desc: typeof order_desc === 'undefined' ? true : order_desc, | ||
@@ -52,7 +65,7 @@ orderby: [], | ||
timeseries_limit: limit ? Number(limit) : 0, | ||
timeseries_limit_metric: timeseries_limit_metric ? convertMetric(timeseries_limit_metric) : null, | ||
timeseries_limit_metric: timeseries_limit_metric ? (0, _convertMetric.default)(timeseries_limit_metric) : null, | ||
until | ||
}, processFilters(formData)); | ||
}, (0, _processFilters.default)(formData)); | ||
return queryObject; | ||
} |
@@ -1,3 +0,9 @@ | ||
import { isBinaryAdhocFilter, isUnaryAdhocFilter } from './types/Filter'; | ||
export default function convertFilter(filter) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = convertFilter; | ||
var _Filter = require("./types/Filter"); | ||
function convertFilter(filter) { | ||
const { | ||
@@ -7,3 +13,3 @@ subject | ||
if (isUnaryAdhocFilter(filter)) { | ||
if ((0, _Filter.isUnaryAdhocFilter)(filter)) { | ||
const { | ||
@@ -18,3 +24,3 @@ operator | ||
if (isBinaryAdhocFilter(filter)) { | ||
if ((0, _Filter.isBinaryAdhocFilter)(filter)) { | ||
const { | ||
@@ -21,0 +27,0 @@ operator |
@@ -0,4 +1,11 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = convertMetric; | ||
exports.LABEL_MAX_LENGTH = void 0; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
export const LABEL_MAX_LENGTH = 43; | ||
const LABEL_MAX_LENGTH = 43; | ||
exports.LABEL_MAX_LENGTH = LABEL_MAX_LENGTH; | ||
@@ -17,3 +24,3 @@ function getDefaultLabel(metric) { | ||
export default function convertMetric(metric) { | ||
function convertMetric(metric) { | ||
let formattedMetric; | ||
@@ -20,0 +27,0 @@ |
@@ -0,5 +1,11 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _Datasource = require("./types/Datasource"); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import { DatasourceType } from './types/Datasource'; | ||
export default class DatasourceKey { | ||
class DatasourceKey { | ||
constructor(key) { | ||
@@ -12,3 +18,3 @@ _defineProperty(this, "id", void 0); | ||
this.id = parseInt(idStr, 10); | ||
this.type = typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid; | ||
this.type = typeStr === 'table' ? _Datasource.DatasourceType.Table : _Datasource.DatasourceType.Druid; | ||
} | ||
@@ -27,2 +33,4 @@ | ||
} | ||
} | ||
exports.default = DatasourceKey; |
@@ -1,10 +0,73 @@ | ||
export { default as buildQueryContext } from './buildQueryContext'; | ||
export { default as buildQueryObject } from './buildQueryObject'; | ||
export { default as convertFilter } from './convertFilter'; | ||
export { default as convertMetric } from './convertMetric'; | ||
export { default as DatasourceKey } from './DatasourceKey'; | ||
export * from './types/QueryFormData'; | ||
export * from './types/Column'; | ||
export * from './types/Datasource'; | ||
export * from './types/Metric'; | ||
export * from './types/Query'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
var _exportNames = { | ||
buildQueryContext: true, | ||
buildQueryObject: true, | ||
convertFilter: true, | ||
convertMetric: true, | ||
DatasourceKey: true | ||
}; | ||
exports.DatasourceKey = exports.convertMetric = exports.convertFilter = exports.buildQueryObject = exports.buildQueryContext = void 0; | ||
var _buildQueryContext = _interopRequireDefault(require("./buildQueryContext")); | ||
exports.buildQueryContext = _buildQueryContext.default; | ||
var _buildQueryObject = _interopRequireDefault(require("./buildQueryObject")); | ||
exports.buildQueryObject = _buildQueryObject.default; | ||
var _convertFilter = _interopRequireDefault(require("./convertFilter")); | ||
exports.convertFilter = _convertFilter.default; | ||
var _convertMetric = _interopRequireDefault(require("./convertMetric")); | ||
exports.convertMetric = _convertMetric.default; | ||
var _DatasourceKey = _interopRequireDefault(require("./DatasourceKey")); | ||
exports.DatasourceKey = _DatasourceKey.default; | ||
var _QueryFormData = require("./types/QueryFormData"); | ||
Object.keys(_QueryFormData).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _QueryFormData[key]; | ||
}); | ||
var _Column = require("./types/Column"); | ||
Object.keys(_Column).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _Column[key]; | ||
}); | ||
var _Datasource = require("./types/Datasource"); | ||
Object.keys(_Datasource).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _Datasource[key]; | ||
}); | ||
var _Metric = require("./types/Metric"); | ||
Object.keys(_Metric).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _Metric[key]; | ||
}); | ||
var _Query = require("./types/Query"); | ||
Object.keys(_Query).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _Query[key]; | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -0,4 +1,10 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = processExtras; | ||
var _QueryFormData = require("./types/QueryFormData"); | ||
/* eslint-disable camelcase */ | ||
import { isDruidFormData } from './types/QueryFormData'; | ||
export default function processExtras(formData) { | ||
function processExtras(formData) { | ||
const { | ||
@@ -8,3 +14,3 @@ where = '' | ||
if (isDruidFormData(formData)) { | ||
if ((0, _QueryFormData.isDruidFormData)(formData)) { | ||
const { | ||
@@ -11,0 +17,0 @@ druid_time_origin, |
@@ -1,6 +0,14 @@ | ||
import { isSimpleAdhocFilter } from './types/Filter'; | ||
import convertFilter from './convertFilter'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = processFilters; | ||
var _Filter = require("./types/Filter"); | ||
var _convertFilter = _interopRequireDefault(require("./convertFilter")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** Logic formerly in viz.py's process_query_filters */ | ||
export default function processFilters(formData) { | ||
function processFilters(formData) { | ||
// TODO: Implement | ||
@@ -30,4 +38,4 @@ // utils.convert_legacy_filters_into_adhoc(self.form_data) | ||
if (isSimpleAdhocFilter(filter)) { | ||
const filterClause = convertFilter(filter); | ||
if ((0, _Filter.isSimpleAdhocFilter)(filter)) { | ||
const filterClause = (0, _convertFilter.default)(filter); | ||
@@ -34,0 +42,0 @@ if (clause === 'WHERE') { |
@@ -1,9 +0,18 @@ | ||
import { MetricKey } from './types/Metric'; | ||
import convertMetric from './convertMetric'; | ||
export default function processMetrics(formData) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = processMetrics; | ||
var _Metric = require("./types/Metric"); | ||
var _convertMetric = _interopRequireDefault(require("./convertMetric")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function processMetrics(formData) { | ||
// Use Array to maintain insertion order | ||
// for metrics that are order sensitive | ||
const metrics = []; | ||
Object.keys(MetricKey).forEach(key => { | ||
const metric = formData[MetricKey[key]]; | ||
Object.keys(_Metric.MetricKey).forEach(key => { | ||
const metric = formData[_Metric.MetricKey[key]]; | ||
@@ -13,6 +22,6 @@ if (metric) { | ||
metric.forEach(m => { | ||
metrics.push(convertMetric(m)); | ||
metrics.push((0, _convertMetric.default)(m)); | ||
}); | ||
} else { | ||
metrics.push(convertMetric(metric)); | ||
metrics.push((0, _convertMetric.default)(metric)); | ||
} | ||
@@ -19,0 +28,0 @@ } |
@@ -1,3 +0,9 @@ | ||
export let ColumnType; // TODO: fill out additional fields of the Column interface | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.ColumnType = void 0; | ||
let ColumnType; // TODO: fill out additional fields of the Column interface | ||
exports.ColumnType = ColumnType; | ||
(function (ColumnType) { | ||
@@ -19,2 +25,2 @@ ColumnType["DOUBLE"] = "DOUBLE"; | ||
ColumnType["CHAR"] = "CHAR"; | ||
})(ColumnType || (ColumnType = {})); | ||
})(ColumnType || (exports.ColumnType = ColumnType = {})); |
@@ -1,7 +0,13 @@ | ||
export let DatasourceType; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.DatasourceType = void 0; | ||
let DatasourceType; | ||
/** @TODO can continue to add fields to this */ | ||
exports.DatasourceType = DatasourceType; | ||
(function (DatasourceType) { | ||
DatasourceType["Table"] = "table"; | ||
DatasourceType["Druid"] = "druid"; | ||
})(DatasourceType || (DatasourceType = {})); | ||
})(DatasourceType || (exports.DatasourceType = DatasourceType = {})); |
@@ -1,16 +0,28 @@ | ||
import { isUnaryOperator, isBinaryOperator, isSetOperator } from './Operator'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.isSimpleAdhocFilter = isSimpleAdhocFilter; | ||
exports.isUnaryAdhocFilter = isUnaryAdhocFilter; | ||
exports.isBinaryAdhocFilter = isBinaryAdhocFilter; | ||
exports.isSetAdhocFilter = isSetAdhocFilter; | ||
var _Operator = require("./Operator"); | ||
//--------------------------------------------------- | ||
// Type guards | ||
//--------------------------------------------------- | ||
export function isSimpleAdhocFilter(filter) { | ||
function isSimpleAdhocFilter(filter) { | ||
return filter.expressionType === 'SIMPLE'; | ||
} | ||
export function isUnaryAdhocFilter(filter) { | ||
return isUnaryOperator(filter.operator); | ||
function isUnaryAdhocFilter(filter) { | ||
return (0, _Operator.isUnaryOperator)(filter.operator); | ||
} | ||
export function isBinaryAdhocFilter(filter) { | ||
return isBinaryOperator(filter.operator); | ||
function isBinaryAdhocFilter(filter) { | ||
return (0, _Operator.isBinaryOperator)(filter.operator); | ||
} | ||
export function isSetAdhocFilter(filter) { | ||
return isSetOperator(filter.operator); | ||
function isSetAdhocFilter(filter) { | ||
return (0, _Operator.isSetOperator)(filter.operator); | ||
} |
@@ -0,4 +1,9 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.MetricKey = void 0; | ||
// Note that the values of MetricKeys are lower_snake_case because they're | ||
// used as keys of form data jsons. | ||
export let MetricKey; | ||
let MetricKey; | ||
exports.MetricKey = MetricKey; | ||
@@ -14,2 +19,2 @@ (function (MetricKey) { | ||
MetricKey["SIZE"] = "size"; | ||
})(MetricKey || (MetricKey = {})); | ||
})(MetricKey || (exports.MetricKey = MetricKey = {})); |
@@ -0,1 +1,8 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.isUnaryOperator = isUnaryOperator; | ||
exports.isBinaryOperator = isBinaryOperator; | ||
exports.isSetOperator = isSetOperator; | ||
/** List of operators that do not require another operand */ | ||
@@ -18,12 +25,17 @@ const UNARY_OPERATORS = ['IS NOT NULL', 'IS NULL']; | ||
const unaryOperatorSet = new Set(UNARY_OPERATORS); | ||
export function isUnaryOperator(operator) { | ||
function isUnaryOperator(operator) { | ||
return unaryOperatorSet.has(operator); | ||
} | ||
const binaryOperatorSet = new Set(BINARY_OPERATORS); | ||
export function isBinaryOperator(operator) { | ||
function isBinaryOperator(operator) { | ||
return binaryOperatorSet.has(operator); | ||
} | ||
const setOperatorSet = new Set(SET_OPERATORS); | ||
export function isSetOperator(operator) { | ||
function isSetOperator(operator) { | ||
return setOperatorSet.has(operator); | ||
} |
@@ -0,1 +1,7 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.isDruidFormData = isDruidFormData; | ||
exports.isSqlaFormData = isSqlaFormData; | ||
/* eslint camelcase: 0 */ | ||
@@ -13,7 +19,8 @@ // FormData uses snake_cased keys. | ||
//--------------------------------------------------- | ||
export function isDruidFormData(formData) { | ||
function isDruidFormData(formData) { | ||
return 'granularity' in formData; | ||
} | ||
export function isSqlaFormData(formData) { | ||
function isSqlaFormData(formData) { | ||
return 'granularity_sqla' in formData; | ||
} |
{ | ||
"name": "@superset-ui/query", | ||
"version": "0.13.0", | ||
"version": "0.13.3", | ||
"description": "Superset UI query", | ||
@@ -28,3 +28,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "72b0c99f843add947371c6ee45cc32d57db6b027" | ||
"gitHead": "f72e2d6e13333b55b5d6f1e2d7d5ccaec3868da6" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66245
1158