@superset-ui/query
Advanced tools
Comparing version 0.13.16 to 0.13.17
@@ -9,2 +9,4 @@ "use strict"; | ||
var _processGroupby = _interopRequireDefault(require("./processGroupby")); | ||
var _convertMetric = _interopRequireDefault(require("./convertMetric")); | ||
@@ -14,6 +16,6 @@ | ||
var _processMetrics = _interopRequireDefault(require("./processMetrics")); | ||
var _processExtras = _interopRequireDefault(require("./processExtras")); | ||
var _extractQueryFields = _interopRequireDefault(require("./extractQueryFields")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -23,2 +25,4 @@ | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
const DTTM_ALIAS = '__timestamp'; | ||
@@ -44,18 +48,23 @@ exports.DTTM_ALIAS = DTTM_ALIAS; | ||
until, | ||
columns = [], | ||
groupby = [], | ||
order_desc, | ||
row_limit, | ||
limit, | ||
timeseries_limit_metric | ||
} = formData; | ||
timeseries_limit_metric, | ||
queryFields | ||
} = formData, | ||
residualFormData = _objectWithoutPropertiesLoose(formData, ["time_range", "since", "until", "order_desc", "row_limit", "limit", "timeseries_limit_metric", "queryFields"]); | ||
const numericRowLimit = Number(row_limit); | ||
const { | ||
metrics, | ||
groupby, | ||
columns | ||
} = (0, _extractQueryFields.default)(residualFormData, queryFields); | ||
const groupbySet = new Set([...columns, ...groupby]); | ||
const numericRowLimit = Number(row_limit); | ||
const queryObject = _extends({ | ||
return _extends({ | ||
extras: (0, _processExtras.default)(formData), | ||
granularity: processGranularity(formData), | ||
groupby: Array.from(groupbySet), | ||
groupby: (0, _processGroupby.default)(Array.from(groupbySet)), | ||
is_timeseries: groupbySet.has(DTTM_ALIAS), | ||
metrics: (0, _processMetrics.default)(formData), | ||
metrics: metrics.map(_convertMetric.default), | ||
order_desc: typeof order_desc === 'undefined' ? true : order_desc, | ||
@@ -70,4 +79,2 @@ orderby: [], | ||
}, (0, _processFilters.default)(formData)); | ||
return queryObject; | ||
} |
@@ -1,19 +0,1 @@ | ||
"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; | ||
(function (MetricKey) { | ||
MetricKey["METRIC"] = "metric"; | ||
MetricKey["METRICS"] = "metrics"; | ||
MetricKey["PERCENT_METRICS"] = "percent_metrics"; | ||
MetricKey["RIGHT_AXIS_METRIC"] = "metric_2"; | ||
MetricKey["SECONDARY_METRIC"] = "secondary_metric"; | ||
MetricKey["X"] = "x"; | ||
MetricKey["Y"] = "y"; | ||
MetricKey["SIZE"] = "size"; | ||
})(MetricKey || (exports.MetricKey = MetricKey = {})); | ||
"use strict"; |
@@ -9,6 +9,2 @@ "use strict"; | ||
// FormData uses snake_cased keys. | ||
// Define mapped type separately to work around a limitation of TypeScript | ||
// https://github.com/Microsoft/TypeScript/issues/13573 | ||
// The Metrics in formData is either a string or a proper metric. It will be | ||
// unified into a proper Metric type during buildQuery (see `/query/Metrics.ts`). | ||
// Type signature for formData shared by all viz types | ||
@@ -15,0 +11,0 @@ // It will be gradually filled out as we build out the query object |
@@ -9,2 +9,4 @@ "use strict"; | ||
var _processGroupby = _interopRequireDefault(require("./processGroupby")); | ||
var _convertMetric = _interopRequireDefault(require("./convertMetric")); | ||
@@ -14,6 +16,6 @@ | ||
var _processMetrics = _interopRequireDefault(require("./processMetrics")); | ||
var _processExtras = _interopRequireDefault(require("./processExtras")); | ||
var _extractQueryFields = _interopRequireDefault(require("./extractQueryFields")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -23,2 +25,4 @@ | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
const DTTM_ALIAS = '__timestamp'; | ||
@@ -44,18 +48,23 @@ exports.DTTM_ALIAS = DTTM_ALIAS; | ||
until, | ||
columns = [], | ||
groupby = [], | ||
order_desc, | ||
row_limit, | ||
limit, | ||
timeseries_limit_metric | ||
} = formData; | ||
timeseries_limit_metric, | ||
queryFields | ||
} = formData, | ||
residualFormData = _objectWithoutPropertiesLoose(formData, ["time_range", "since", "until", "order_desc", "row_limit", "limit", "timeseries_limit_metric", "queryFields"]); | ||
const numericRowLimit = Number(row_limit); | ||
const { | ||
metrics, | ||
groupby, | ||
columns | ||
} = (0, _extractQueryFields.default)(residualFormData, queryFields); | ||
const groupbySet = new Set([...columns, ...groupby]); | ||
const numericRowLimit = Number(row_limit); | ||
const queryObject = _extends({ | ||
return _extends({ | ||
extras: (0, _processExtras.default)(formData), | ||
granularity: processGranularity(formData), | ||
groupby: Array.from(groupbySet), | ||
groupby: (0, _processGroupby.default)(Array.from(groupbySet)), | ||
is_timeseries: groupbySet.has(DTTM_ALIAS), | ||
metrics: (0, _processMetrics.default)(formData), | ||
metrics: metrics.map(_convertMetric.default), | ||
order_desc: typeof order_desc === 'undefined' ? true : order_desc, | ||
@@ -70,4 +79,2 @@ orderby: [], | ||
}, (0, _processFilters.default)(formData)); | ||
return queryObject; | ||
} |
@@ -1,4 +0,4 @@ | ||
import { QueryFormDataMetric } from './types/QueryFormData'; | ||
import { QueryFormResidualDataValue } from './types/QueryFormData'; | ||
import { QueryObjectMetric } from './types/Query'; | ||
export default function convertMetric(metric: QueryFormDataMetric): QueryObjectMetric; | ||
export default function convertMetric(metric: QueryFormResidualDataValue): QueryObjectMetric; | ||
//# sourceMappingURL=convertMetric.d.ts.map |
import { Column } from './Column'; | ||
export declare enum MetricKey { | ||
METRIC = "metric", | ||
METRICS = "metrics", | ||
PERCENT_METRICS = "percent_metrics", | ||
RIGHT_AXIS_METRIC = "metric_2", | ||
SECONDARY_METRIC = "secondary_metric", | ||
X = "x", | ||
Y = "y", | ||
SIZE = "size" | ||
} | ||
export declare type Aggregate = 'AVG' | 'COUNT' | 'COUNT_DISTINCT' | 'MAX' | 'MIN' | 'SUM'; | ||
@@ -13,0 +3,0 @@ interface AdhocMetricSimple { |
@@ -1,19 +0,1 @@ | ||
"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; | ||
(function (MetricKey) { | ||
MetricKey["METRIC"] = "metric"; | ||
MetricKey["METRICS"] = "metrics"; | ||
MetricKey["PERCENT_METRICS"] = "percent_metrics"; | ||
MetricKey["RIGHT_AXIS_METRIC"] = "metric_2"; | ||
MetricKey["SECONDARY_METRIC"] = "secondary_metric"; | ||
MetricKey["X"] = "x"; | ||
MetricKey["Y"] = "y"; | ||
MetricKey["SIZE"] = "size"; | ||
})(MetricKey || (exports.MetricKey = MetricKey = {})); | ||
"use strict"; |
@@ -5,2 +5,3 @@ import { DatasourceType } from './Datasource'; | ||
import { TimeRange } from './Time'; | ||
import { QueryFormDataMetric, QueryFormResidualDataValue } from './QueryFormData'; | ||
export declare type QueryObjectFilterClause = { | ||
@@ -35,2 +36,5 @@ col: string; | ||
}>; | ||
export declare type ResidualQueryObjectData = { | ||
[key: string]: unknown; | ||
}; | ||
export declare type QueryObject = { | ||
@@ -63,3 +67,3 @@ /** Columns to group by */ | ||
is_timeseries?: boolean; | ||
} & TimeRange; | ||
} & TimeRange & ResidualQueryObjectData; | ||
export interface QueryContext { | ||
@@ -74,2 +78,8 @@ datasource: { | ||
} | ||
export declare type QueryFieldData = { | ||
columns: QueryFormResidualDataValue[]; | ||
groupby: QueryFormResidualDataValue[]; | ||
metrics: QueryFormDataMetric[]; | ||
[key: string]: QueryFormResidualDataValue[]; | ||
}; | ||
//# sourceMappingURL=Query.d.ts.map |
@@ -1,6 +0,12 @@ | ||
import { MetricKey, AdhocMetric } from './Metric'; | ||
import { AdhocMetric } from './Metric'; | ||
import { TimeRange } from './Time'; | ||
import { AdhocFilter } from './Filter'; | ||
export declare type QueryFormDataMetric = string | AdhocMetric; | ||
export declare type QueryFormDataMetrics = Partial<Record<MetricKey, QueryFormDataMetric | QueryFormDataMetric[]>>; | ||
export declare type QueryFormResidualDataValue = string | AdhocMetric; | ||
export declare type QueryFormResidualData = { | ||
[key: string]: any; | ||
}; | ||
export declare type QueryFields = { | ||
[key: string]: string; | ||
}; | ||
export declare type BaseFormData = { | ||
@@ -33,6 +39,7 @@ /** datasource identifier ${id}_${type} */ | ||
/** The metric used to order timeseries for limiting */ | ||
timeseries_limit_metric?: QueryFormDataMetric; | ||
timeseries_limit_metric?: QueryFormResidualDataValue; | ||
/** Force refresh */ | ||
force?: boolean; | ||
} & TimeRange & QueryFormDataMetrics; | ||
queryFields?: QueryFields; | ||
} & TimeRange & QueryFormResidualData; | ||
export declare type SqlaFormData = { | ||
@@ -39,0 +46,0 @@ granularity_sqla: string; |
@@ -9,6 +9,2 @@ "use strict"; | ||
// FormData uses snake_cased keys. | ||
// Define mapped type separately to work around a limitation of TypeScript | ||
// https://github.com/Microsoft/TypeScript/issues/13573 | ||
// The Metrics in formData is either a string or a proper metric. It will be | ||
// unified into a proper Metric type during buildQuery (see `/query/Metrics.ts`). | ||
// Type signature for formData shared by all viz types | ||
@@ -15,0 +11,0 @@ // It will be gradually filled out as we build out the query object |
{ | ||
"name": "@superset-ui/query", | ||
"version": "0.13.16", | ||
"version": "0.13.17", | ||
"description": "Superset UI query", | ||
@@ -28,3 +28,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "13d1565256bf6b1cad9ef1ba2cea78d78da8facb" | ||
"gitHead": "cf83908caca067fb4619e6c54e4db32cb273de25" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
67682
75
1161