@lightdash/common 0.1369.1 → 0.1369.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  import { type MetricQuery } from './metricQuery';
2
+ import { type PivotConfig } from './pivot';
2
3
  export type DownloadMetricCsv = {
3
4
  userUuid: string;
4
5
  projectUuid: string;
@@ -12,4 +13,5 @@ export type DownloadMetricCsv = {
12
13
  hiddenFields: string[] | undefined;
13
14
  chartName: string | undefined;
14
15
  fromSavedChart: boolean;
16
+ pivotConfig?: PivotConfig;
15
17
  };
@@ -247,4 +247,5 @@ export declare const isFilterableItem: (item: ItemsMap[string] | TableCalculatio
247
247
  export declare const defaultSql: (columnName: string) => string;
248
248
  export declare const capitalize: (word: string) => string;
249
249
  export declare const friendlyName: (text: string) => string;
250
+ export declare const isSummable: (item: Item | undefined) => boolean;
250
251
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.friendlyName = exports.capitalize = exports.defaultSql = exports.isFilterableItem = exports.isFilterableField = exports.isFilterableDimension = exports.isNonAggregateMetric = exports.isMetric = exports.parseMetricType = exports.isFormat = exports.Format = exports.MetricType = exports.getFieldLabel = exports.getFieldRef = exports.isDimension = exports.DimensionType = exports.convertFieldRefToFieldId = exports.isField = exports.isTableCalculation = exports.FieldType = exports.TableCalculationType = exports.CustomFormatType = exports.isCompiledCustomSqlDimension = exports.isCustomSqlDimension = exports.isCustomBinDimension = exports.isCustomDimension = exports.CustomDimensionType = exports.BinType = exports.findCompactConfig = exports.CompactConfigMap = exports.NumberSeparator = exports.Compact = void 0;
3
+ exports.isSummable = exports.friendlyName = exports.capitalize = exports.defaultSql = exports.isFilterableItem = exports.isFilterableField = exports.isFilterableDimension = exports.isNonAggregateMetric = exports.isMetric = exports.parseMetricType = exports.isFormat = exports.Format = exports.MetricType = exports.getFieldLabel = exports.getFieldRef = exports.isDimension = exports.DimensionType = exports.convertFieldRefToFieldId = exports.isField = exports.isTableCalculation = exports.FieldType = exports.TableCalculationType = exports.CustomFormatType = exports.isCompiledCustomSqlDimension = exports.isCustomSqlDimension = exports.isCustomBinDimension = exports.isCustomDimension = exports.CustomDimensionType = exports.BinType = exports.findCompactConfig = exports.CompactConfigMap = exports.NumberSeparator = exports.Compact = void 0;
4
4
  const errors_1 = require("./errors");
5
5
  var Compact;
6
6
  (function (Compact) {
@@ -269,3 +269,21 @@ const friendlyName = (text) => {
269
269
  return (0, exports.capitalize)(result);
270
270
  };
271
271
  exports.friendlyName = friendlyName;
272
+ const isSummable = (item) => {
273
+ if (!item) {
274
+ return false;
275
+ }
276
+ if ((0, exports.isTableCalculation)(item)) {
277
+ return false;
278
+ }
279
+ if ((0, exports.isCustomDimension)(item)) {
280
+ return false;
281
+ }
282
+ const numericTypes = [MetricType.COUNT, MetricType.SUM];
283
+ const isNumberDimension = (0, exports.isDimension)(item) && item.type === DimensionType.NUMBER;
284
+ const isNumbericType = numericTypes.includes(item.type) || isNumberDimension;
285
+ const isPercent = item.format === 'percent';
286
+ const isDatePart = (0, exports.isDimension)(item) && item.timeInterval;
287
+ return isNumbericType && !isPercent && !isDatePart;
288
+ };
289
+ exports.isSummable = isSummable;
@@ -1,6 +1,7 @@
1
1
  import { type Explore, type ExploreError } from './explore';
2
2
  import { type DashboardFilterRule } from './filter';
3
3
  import { type MetricQuery } from './metricQuery';
4
+ import { type PivotConfig } from './pivot';
4
5
  import { type ValidationTarget } from './validation';
5
6
  export type SchedulerCsvOptions = {
6
7
  formatted: boolean;
@@ -233,6 +234,7 @@ export type DownloadCsvPayload = {
233
234
  hiddenFields: string[] | undefined;
234
235
  chartName: string | undefined;
235
236
  fromSavedChart: boolean;
237
+ pivotConfig?: PivotConfig;
236
238
  };
237
239
  export type ApiCsvUrlResponse = {
238
240
  status: 'ok';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/common",
3
- "version": "0.1369.1",
3
+ "version": "0.1369.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -20,6 +20,7 @@
20
20
  "cronstrue": "^2.23.0",
21
21
  "dayjs": "^1.11.9",
22
22
  "dependency-graph": "^0.11.0",
23
+ "type-fest": "^3.10.0",
23
24
  "liquidjs": "^10.0.0",
24
25
  "lodash": "^4.17.21",
25
26
  "moment": "^2.29.4",