Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@superset-ui/query

Package Overview
Dependencies
Maintainers
12
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superset-ui/query - npm Package Compare versions

Comparing version 0.12.23 to 0.13.0

2

esm/buildQueryObject.js

@@ -46,3 +46,3 @@ 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); }

orderby: [],
row_limit: row_limit == null || isNaN(numericRowLimit) ? undefined : numericRowLimit,
row_limit: row_limit == null || Number.isNaN(numericRowLimit) ? undefined : numericRowLimit,
since,

@@ -49,0 +49,0 @@ time_range,

@@ -5,6 +5,6 @@ /** List of operators that do not require another operand */

const BINARY_OPERATORS = ['=', '!=', '>', '<', '>=', '<=', 'like', 'regex'];
const BINARY_OPERATORS = ['=', '!=', '>', '<', '>=', '<=', 'LIKE', 'REGEX'];
/** List of operators that require another operand that is a set */
const SET_OPERATORS = ['in', 'not in']; //---------------------------------------------------
const SET_OPERATORS = ['IN', 'NOT IN']; //---------------------------------------------------
// Derived types

@@ -11,0 +11,0 @@ //---------------------------------------------------

@@ -1,19 +0,11 @@

"use strict";
import buildQueryObject from './buildQueryObject';
import DatasourceKey from './DatasourceKey';
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];
function buildQueryContext(formData, buildQuery = WRAP_IN_ARRAY) {
export default function buildQueryContext(formData, buildQuery = WRAP_IN_ARRAY) {
return {
datasource: new _DatasourceKey.default(formData.datasource).toObject(),
queries: buildQuery((0, _buildQueryObject.default)(formData))
datasource: new DatasourceKey(formData.datasource).toObject(),
queries: buildQuery(buildQueryObject(formData))
};
}

@@ -1,26 +0,13 @@

"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); }
const DTTM_ALIAS = '__timestamp';
exports.DTTM_ALIAS = DTTM_ALIAS;
/* 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';
function processGranularity(formData) {
return (0, _QueryFormData.isSqlaFormData)(formData) ? formData.granularity_sqla : formData.granularity;
return isSqlaFormData(formData) ? formData.granularity_sqla : formData.granularity;
}

@@ -36,3 +23,3 @@ /**

function buildQueryObject(formData) {
export default function buildQueryObject(formData) {
const {

@@ -53,18 +40,18 @@ time_range,

const queryObject = _extends({
extras: (0, _processExtras.default)(formData),
extras: processExtras(formData),
granularity: processGranularity(formData),
groupby: Array.from(groupbySet),
is_timeseries: groupbySet.has(DTTM_ALIAS),
metrics: (0, _processMetrics.default)(formData),
metrics: processMetrics(formData),
order_desc: typeof order_desc === 'undefined' ? true : order_desc,
orderby: [],
row_limit: row_limit == null || isNaN(numericRowLimit) ? undefined : numericRowLimit,
row_limit: row_limit == null || Number.isNaN(numericRowLimit) ? undefined : numericRowLimit,
since,
time_range,
timeseries_limit: limit ? Number(limit) : 0,
timeseries_limit_metric: timeseries_limit_metric ? (0, _convertMetric.default)(timeseries_limit_metric) : null,
timeseries_limit_metric: timeseries_limit_metric ? convertMetric(timeseries_limit_metric) : null,
until
}, (0, _processFilters.default)(formData));
}, processFilters(formData));
return queryObject;
}

@@ -1,9 +0,3 @@

"use strict";
exports.__esModule = true;
exports.default = convertFilter;
var _Filter = require("./types/Filter");
function convertFilter(filter) {
import { isBinaryAdhocFilter, isUnaryAdhocFilter } from './types/Filter';
export default function convertFilter(filter) {
const {

@@ -13,3 +7,3 @@ subject

if ((0, _Filter.isUnaryAdhocFilter)(filter)) {
if (isUnaryAdhocFilter(filter)) {
const {

@@ -24,3 +18,3 @@ operator

if ((0, _Filter.isBinaryAdhocFilter)(filter)) {
if (isBinaryAdhocFilter(filter)) {
const {

@@ -27,0 +21,0 @@ operator

@@ -1,11 +0,4 @@

"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); }
const LABEL_MAX_LENGTH = 43;
exports.LABEL_MAX_LENGTH = LABEL_MAX_LENGTH;
export const LABEL_MAX_LENGTH = 43;

@@ -24,3 +17,3 @@ function getDefaultLabel(metric) {

function convertMetric(metric) {
export default function convertMetric(metric) {
let formattedMetric;

@@ -27,0 +20,0 @@

@@ -1,11 +0,5 @@

"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; }
class DatasourceKey {
import { DatasourceType } from './types/Datasource';
export default class DatasourceKey {
constructor(key) {

@@ -18,3 +12,3 @@ _defineProperty(this, "id", void 0);

this.id = parseInt(idStr, 10);
this.type = typeStr === 'table' ? _Datasource.DatasourceType.Table : _Datasource.DatasourceType.Druid;
this.type = typeStr === 'table' ? DatasourceType.Table : DatasourceType.Druid;
}

@@ -33,4 +27,2 @@

}
exports.default = DatasourceKey;
}

@@ -1,73 +0,10 @@

"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 }; }
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';

@@ -1,10 +0,4 @@

"use strict";
exports.__esModule = true;
exports.default = processExtras;
var _QueryFormData = require("./types/QueryFormData");
/* eslint-disable camelcase */
function processExtras(formData) {
import { isDruidFormData } from './types/QueryFormData';
export default function processExtras(formData) {
const {

@@ -14,3 +8,3 @@ where = ''

if ((0, _QueryFormData.isDruidFormData)(formData)) {
if (isDruidFormData(formData)) {
const {

@@ -17,0 +11,0 @@ druid_time_origin,

@@ -1,14 +0,6 @@

"use strict";
import { isSimpleAdhocFilter } from './types/Filter';
import convertFilter from './convertFilter';
/** Logic formerly in viz.py's process_query_filters */
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 */
function processFilters(formData) {
export default function processFilters(formData) {
// TODO: Implement

@@ -38,4 +30,4 @@ // utils.convert_legacy_filters_into_adhoc(self.form_data)

if ((0, _Filter.isSimpleAdhocFilter)(filter)) {
const filterClause = (0, _convertFilter.default)(filter);
if (isSimpleAdhocFilter(filter)) {
const filterClause = convertFilter(filter);

@@ -42,0 +34,0 @@ if (clause === 'WHERE') {

@@ -1,18 +0,9 @@

"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) {
import { MetricKey } from './types/Metric';
import convertMetric from './convertMetric';
export default function processMetrics(formData) {
// Use Array to maintain insertion order
// for metrics that are order sensitive
const metrics = [];
Object.keys(_Metric.MetricKey).forEach(key => {
const metric = formData[_Metric.MetricKey[key]];
Object.keys(MetricKey).forEach(key => {
const metric = formData[MetricKey[key]];

@@ -22,6 +13,6 @@ if (metric) {

metric.forEach(m => {
metrics.push((0, _convertMetric.default)(m));
metrics.push(convertMetric(m));
});
} else {
metrics.push((0, _convertMetric.default)(metric));
metrics.push(convertMetric(metric));
}

@@ -28,0 +19,0 @@ }

@@ -1,9 +0,3 @@

"use strict";
export let ColumnType; // TODO: fill out additional fields of the Column interface
exports.__esModule = true;
exports.ColumnType = void 0;
let ColumnType; // TODO: fill out additional fields of the Column interface
exports.ColumnType = ColumnType;
(function (ColumnType) {

@@ -25,2 +19,2 @@ ColumnType["DOUBLE"] = "DOUBLE";

ColumnType["CHAR"] = "CHAR";
})(ColumnType || (exports.ColumnType = ColumnType = {}));
})(ColumnType || (ColumnType = {}));

@@ -1,13 +0,7 @@

"use strict";
exports.__esModule = true;
exports.DatasourceType = void 0;
let DatasourceType;
export let DatasourceType;
/** @TODO can continue to add fields to this */
exports.DatasourceType = DatasourceType;
(function (DatasourceType) {
DatasourceType["Table"] = "table";
DatasourceType["Druid"] = "druid";
})(DatasourceType || (exports.DatasourceType = DatasourceType = {}));
})(DatasourceType || (DatasourceType = {}));

@@ -1,28 +0,16 @@

"use strict";
exports.__esModule = true;
exports.isSimpleAdhocFilter = isSimpleAdhocFilter;
exports.isUnaryAdhocFilter = isUnaryAdhocFilter;
exports.isBinaryAdhocFilter = isBinaryAdhocFilter;
exports.isSetAdhocFilter = isSetAdhocFilter;
var _Operator = require("./Operator");
import { isUnaryOperator, isBinaryOperator, isSetOperator } from './Operator';
//---------------------------------------------------
// Type guards
//---------------------------------------------------
function isSimpleAdhocFilter(filter) {
export function isSimpleAdhocFilter(filter) {
return filter.expressionType === 'SIMPLE';
}
function isUnaryAdhocFilter(filter) {
return (0, _Operator.isUnaryOperator)(filter.operator);
export function isUnaryAdhocFilter(filter) {
return isUnaryOperator(filter.operator);
}
function isBinaryAdhocFilter(filter) {
return (0, _Operator.isBinaryOperator)(filter.operator);
export function isBinaryAdhocFilter(filter) {
return isBinaryOperator(filter.operator);
}
function isSetAdhocFilter(filter) {
return (0, _Operator.isSetOperator)(filter.operator);
export function isSetAdhocFilter(filter) {
return isSetOperator(filter.operator);
}

@@ -1,9 +0,4 @@

"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.
let MetricKey;
exports.MetricKey = MetricKey;
export let MetricKey;

@@ -19,2 +14,2 @@ (function (MetricKey) {

MetricKey["SIZE"] = "size";
})(MetricKey || (exports.MetricKey = MetricKey = {}));
})(MetricKey || (MetricKey = {}));
/** List of operators that do not require another operand */
declare const UNARY_OPERATORS: readonly ["IS NOT NULL", "IS NULL"];
/** List of operators that require another operand that is a single value */
declare const BINARY_OPERATORS: readonly ["=", "!=", ">", "<", ">=", "<=", "like", "regex"];
declare const BINARY_OPERATORS: readonly ["=", "!=", ">", "<", ">=", "<=", "LIKE", "REGEX"];
/** List of operators that require another operand that is a set */
declare const SET_OPERATORS: readonly ["in", "not in"];
declare const SET_OPERATORS: readonly ["IN", "NOT IN"];
/** An operator that does not require another operand */

@@ -8,0 +8,0 @@ export declare type UnaryOperator = typeof UNARY_OPERATORS[number];

@@ -1,8 +0,1 @@

"use strict";
exports.__esModule = true;
exports.isUnaryOperator = isUnaryOperator;
exports.isBinaryOperator = isBinaryOperator;
exports.isSetOperator = isSetOperator;
/** List of operators that do not require another operand */

@@ -12,6 +5,6 @@ const UNARY_OPERATORS = ['IS NOT NULL', 'IS NULL'];

const BINARY_OPERATORS = ['=', '!=', '>', '<', '>=', '<=', 'like', 'regex'];
const BINARY_OPERATORS = ['=', '!=', '>', '<', '>=', '<=', 'LIKE', 'REGEX'];
/** List of operators that require another operand that is a set */
const SET_OPERATORS = ['in', 'not in']; //---------------------------------------------------
const SET_OPERATORS = ['IN', 'NOT IN']; //---------------------------------------------------
// Derived types

@@ -26,17 +19,12 @@ //---------------------------------------------------

const unaryOperatorSet = new Set(UNARY_OPERATORS);
function isUnaryOperator(operator) {
export function isUnaryOperator(operator) {
return unaryOperatorSet.has(operator);
}
const binaryOperatorSet = new Set(BINARY_OPERATORS);
function isBinaryOperator(operator) {
export function isBinaryOperator(operator) {
return binaryOperatorSet.has(operator);
}
const setOperatorSet = new Set(SET_OPERATORS);
function isSetOperator(operator) {
export function isSetOperator(operator) {
return setOperatorSet.has(operator);
}

@@ -31,3 +31,3 @@ import { MetricKey, AdhocMetric } from './Metric';

/** limit number of row in the results */
row_limit?: number;
row_limit?: string | number | null;
/** The metric used to order timeseries for limiting */

@@ -34,0 +34,0 @@ timeseries_limit_metric?: QueryFormDataMetric;

@@ -1,7 +0,1 @@

"use strict";
exports.__esModule = true;
exports.isDruidFormData = isDruidFormData;
exports.isSqlaFormData = isSqlaFormData;
/* eslint camelcase: 0 */

@@ -19,8 +13,7 @@ // FormData uses snake_cased keys.

//---------------------------------------------------
function isDruidFormData(formData) {
export function isDruidFormData(formData) {
return 'granularity' in formData;
}
function isSqlaFormData(formData) {
export function isSqlaFormData(formData) {
return 'granularity_sqla' in formData;
}
{
"name": "@superset-ui/query",
"version": "0.12.23",
"version": "0.13.0",
"description": "Superset UI query",

@@ -28,3 +28,3 @@ "sideEffects": false,

},
"gitHead": "b1c93dab71a60342f785848c2d6b851264d14a04"
"gitHead": "72b0c99f843add947371c6ee45cc32d57db6b027"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc