@lightdash/common 0.1413.0 → 0.1413.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,3 @@
1
- import { z } from 'zod';
2
1
  import { type MetricWithAssociatedTimeDimension } from './catalog';
3
2
  import type { Dimension, ItemsMap } from './field';
4
3
  import type { ResultValue } from './results';
@@ -22,65 +21,17 @@ export type MetricExplorerQuery = {
22
21
  name: string;
23
22
  };
24
23
  };
25
- export declare const metricExploreDataPointWithDateValueSchema: z.ZodObject<z.objectUtil.extendShape<{
26
- date: z.ZodDate;
27
- segment: z.ZodNullable<z.ZodString>;
28
- metric: z.ZodObject<{
29
- value: z.ZodNullable<z.ZodNumber>;
30
- label: z.ZodNullable<z.ZodString>;
31
- }, "strip", z.ZodTypeAny, {
32
- label: string | null;
33
- value: number | null;
34
- }, {
35
- label: string | null;
36
- value: number | null;
37
- }>;
38
- compareMetric: z.ZodObject<{
39
- value: z.ZodNullable<z.ZodNumber>;
40
- label: z.ZodNullable<z.ZodString>;
41
- }, "strip", z.ZodTypeAny, {
42
- label: string | null;
43
- value: number | null;
44
- }, {
45
- label: string | null;
46
- value: number | null;
47
- }>;
48
- }, {
49
- dateValue: z.ZodNumber;
50
- }>, "strip", z.ZodTypeAny, {
51
- metric: {
52
- label: string | null;
53
- value: number | null;
54
- };
55
- date: Date;
56
- segment: string | null;
57
- compareMetric: {
58
- label: string | null;
59
- value: number | null;
60
- };
61
- dateValue: number;
62
- }, {
63
- metric: {
64
- label: string | null;
65
- value: number | null;
66
- };
67
- date: Date;
68
- segment: string | null;
69
- compareMetric: {
70
- label: string | null;
71
- value: number | null;
72
- };
73
- dateValue: number;
74
- }>;
75
24
  export type MetricExploreDataPoint = {
76
25
  date: Date;
77
26
  segment: string | null;
78
27
  metric: {
79
28
  value: number | null;
29
+ formatted: string | null;
80
30
  label: string | null;
81
31
  };
82
32
  compareMetric: {
83
33
  value: number | null;
34
+ formatted: string | null;
84
35
  label: string | null;
85
36
  };
86
37
  };
@@ -1,28 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MetricTotalComparisonType = exports.metricExploreDataPointWithDateValueSchema = exports.MetricExplorerComparison = void 0;
4
- const zod_1 = require("zod");
3
+ exports.MetricTotalComparisonType = exports.MetricExplorerComparison = void 0;
5
4
  var MetricExplorerComparison;
6
5
  (function (MetricExplorerComparison) {
7
6
  MetricExplorerComparison["NONE"] = "none";
8
7
  MetricExplorerComparison["PREVIOUS_PERIOD"] = "previous_period";
9
8
  MetricExplorerComparison["DIFFERENT_METRIC"] = "different_metric";
10
9
  })(MetricExplorerComparison = exports.MetricExplorerComparison || (exports.MetricExplorerComparison = {}));
11
- const metricExploreDataPointSchema = zod_1.z.object({
12
- date: zod_1.z.date({ coerce: true }),
13
- segment: zod_1.z.string().nullable(),
14
- metric: zod_1.z.object({
15
- value: zod_1.z.number().nullable(),
16
- label: zod_1.z.string().nullable(),
17
- }),
18
- compareMetric: zod_1.z.object({
19
- value: zod_1.z.number().nullable(),
20
- label: zod_1.z.string().nullable(),
21
- }),
22
- });
23
- exports.metricExploreDataPointWithDateValueSchema = metricExploreDataPointSchema.extend({
24
- dateValue: zod_1.z.number(),
25
- });
26
10
  var MetricTotalComparisonType;
27
11
  (function (MetricTotalComparisonType) {
28
12
  MetricTotalComparisonType["NONE"] = "none";
@@ -160,9 +160,11 @@ const getMetricExplorerDataPoints = (dimension, metric, metricRows, segmentDimen
160
160
  segment: segmentValue,
161
161
  metric: {
162
162
  value: parseMetricValue(row[metricId]?.value.raw),
163
+ formatted: row[metricId]?.value.formatted,
163
164
  label: segmentValue ?? metric.label ?? metric.name,
164
165
  },
165
166
  compareMetric: {
167
+ formatted: null,
166
168
  value: null,
167
169
  label: null,
168
170
  },
@@ -209,10 +211,13 @@ const getMetricExplorerDataPointsWithCompare = (dimension, compareDimension, met
209
211
  date: new Date(date),
210
212
  segment: null,
211
213
  metric: {
214
+ formatted: groupByMetricRows[date]?.[0]?.[metricId]?.value.formatted,
212
215
  value: parseMetricValue(groupByMetricRows[date]?.[0]?.[metricId]?.value.raw),
213
216
  label: metric.label ?? metric.name,
214
217
  },
215
218
  compareMetric: {
219
+ formatted: offsetGroupByCompareMetricRows[date]?.[0]?.[compareMetricId]
220
+ ?.value.formatted,
216
221
  value: parseMetricValue(offsetGroupByCompareMetricRows[date]?.[0]?.[compareMetricId]
217
222
  ?.value.raw),
218
223
  label: comparisonMetricLabel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/common",
3
- "version": "0.1413.0",
3
+ "version": "0.1413.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [