@lightdash/common 0.1382.0 → 0.1383.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
@@ -39,6 +39,7 @@ import { type ValidationResponse } from './types/validation';
|
|
39
39
|
import { type ApiCatalogAnalyticsResults, type ApiCatalogMetadataResults, type ApiMetricsCatalog } from './types/catalog';
|
40
40
|
import { type ApiChartContentResponse, type ApiContentResponse } from './types/content';
|
41
41
|
import type { ApiGroupListResponse } from './types/groups';
|
42
|
+
import type { ApiMetricsExplorerQueryResults } from './types/metricsExplorer';
|
42
43
|
import { type ApiPromotionChangesResponse } from './types/promotion';
|
43
44
|
import { type ApiSemanticLayerClientInfo, type ApiSemanticViewerChartCreate, type ApiSemanticViewerChartGet, type ApiSemanticViewerChartUpdate } from './types/semanticLayer';
|
44
45
|
import { type ApiCreateSqlChart, type ApiCreateVirtualView, type ApiGithubDbtWritePreview, type ApiSqlChart, type ApiSqlRunnerJobStatusResponse, type ApiUpdateSqlChart } from './types/sqlRunner';
|
@@ -84,6 +85,7 @@ export * from './types/groups';
|
|
84
85
|
export * from './types/job';
|
85
86
|
export * from './types/knex-paginate';
|
86
87
|
export * from './types/metricQuery';
|
88
|
+
export * from './types/metricsExplorer';
|
87
89
|
export * from './types/notifications';
|
88
90
|
export * from './types/openIdIdentity';
|
89
91
|
export * from './types/organization';
|
@@ -129,6 +131,7 @@ export * from './utils/filters';
|
|
129
131
|
export * from './utils/formatting';
|
130
132
|
export * from './utils/github';
|
131
133
|
export * from './utils/item';
|
134
|
+
export * from './utils/metricsExplorer';
|
132
135
|
export * from './utils/projectMemberRole';
|
133
136
|
export * from './utils/sanitizeHtml';
|
134
137
|
export * from './utils/scheduler';
|
@@ -376,7 +379,7 @@ export type ApiAiGetDashboardSummaryResponse = {
|
|
376
379
|
status: 'ok';
|
377
380
|
results: DashboardSummary;
|
378
381
|
};
|
379
|
-
type ApiResults = ApiQueryResults | ApiSqlQueryResults | ApiCompiledQueryResults | ApiExploresResults | ApiExploreResults | ApiStatusResults | ApiRefreshResults | ApiHealthResults | Organization | LightdashUser | LoginOptions | SavedChart | SavedChart[] | Space[] | InviteLink | OrganizationProject[] | Project | WarehouseCredentials | OrganizationMemberProfile[] | ProjectCatalog | TablesConfiguration | Dashboard | DashboardBasicDetails[] | OnboardingStatus | Dashboard[] | DeleteOpenIdentity | ApiFlashResults | Record<OpenIdIdentitySummary['issuerType'], OpenIdIdentitySummary[]> | FilterableField[] | DashboardAvailableFilters | ProjectSavedChartStatus | null | Array<unknown> | ApiJobStartedResults | ApiCreateUserTokenResults | CreatePersonalAccessToken | PersonalAccessToken | ProjectMemberProfile[] | ProjectGroupAccess | SearchResults | Space | ShareUrl | SlackSettings | ApiSlackChannelsResponse['results'] | UserActivity | SchedulerAndTargets | SchedulerAndTargets[] | FieldValueSearchResult | ApiDownloadCsv | AllowedEmailDomains | UpdateAllowedEmailDomains | UserAllowedOrganization[] | EmailStatusExpiring | ApiScheduledDownloadCsv | PinnedItems | ViewStatistics | SchedulerWithLogs | ValidationResponse[] | ChartHistory | ChartVersion | Array<GitRepo> | PullRequestCreated | GitIntegrationConfiguration | UserWarehouseCredentials | ApiJobStatusResponse['results'] | ApiJobScheduledResponse['results'] | ApiSshKeyPairResponse['results'] | MostPopularAndRecentlyUpdated | ApiCalculateTotalResponse['results'] | Record<string, DbtExposure> | ApiCreateComment['results'] | ApiGetComments['results'] | ApiDeleteComment | ApiSuccessEmpty | ApiCreateProjectResults | ApiAiDashboardSummaryResponse['results'] | ApiAiGetDashboardSummaryResponse['results'] | ApiCatalogMetadataResults | ApiCatalogAnalyticsResults | ApiPromotionChangesResponse['results'] | ApiWarehouseTableFields['results'] | ApiTogglePinnedItem['results'] | ApiOrganizationMemberProfiles['results'] | ApiSqlChart['results'] | ApiCreateSqlChart['results'] | ApiUpdateSqlChart['results'] | ApiContentResponse['results'] | ApiChartContentResponse['results'] | ApiSqlRunnerJobStatusResponse['results'] | ApiSemanticLayerClientInfo['results'] | ApiSemanticViewerChartCreate['results'] | ApiSemanticViewerChartGet['results'] | ApiSemanticViewerChartUpdate['results'] | ApiCreateVirtualView['results'] | ApiGithubDbtWritePreview['results'] | ApiMetricsCatalog['results'] | ApiGroupListResponse['results'] | ApiCreateTagResponse['results'];
|
382
|
+
type ApiResults = ApiQueryResults | ApiSqlQueryResults | ApiCompiledQueryResults | ApiExploresResults | ApiExploreResults | ApiStatusResults | ApiRefreshResults | ApiHealthResults | Organization | LightdashUser | LoginOptions | SavedChart | SavedChart[] | Space[] | InviteLink | OrganizationProject[] | Project | WarehouseCredentials | OrganizationMemberProfile[] | ProjectCatalog | TablesConfiguration | Dashboard | DashboardBasicDetails[] | OnboardingStatus | Dashboard[] | DeleteOpenIdentity | ApiFlashResults | Record<OpenIdIdentitySummary['issuerType'], OpenIdIdentitySummary[]> | FilterableField[] | DashboardAvailableFilters | ProjectSavedChartStatus | null | Array<unknown> | ApiJobStartedResults | ApiCreateUserTokenResults | CreatePersonalAccessToken | PersonalAccessToken | ProjectMemberProfile[] | ProjectGroupAccess | SearchResults | Space | ShareUrl | SlackSettings | ApiSlackChannelsResponse['results'] | UserActivity | SchedulerAndTargets | SchedulerAndTargets[] | FieldValueSearchResult | ApiDownloadCsv | AllowedEmailDomains | UpdateAllowedEmailDomains | UserAllowedOrganization[] | EmailStatusExpiring | ApiScheduledDownloadCsv | PinnedItems | ViewStatistics | SchedulerWithLogs | ValidationResponse[] | ChartHistory | ChartVersion | Array<GitRepo> | PullRequestCreated | GitIntegrationConfiguration | UserWarehouseCredentials | ApiJobStatusResponse['results'] | ApiJobScheduledResponse['results'] | ApiSshKeyPairResponse['results'] | MostPopularAndRecentlyUpdated | ApiCalculateTotalResponse['results'] | Record<string, DbtExposure> | ApiCreateComment['results'] | ApiGetComments['results'] | ApiDeleteComment | ApiSuccessEmpty | ApiCreateProjectResults | ApiAiDashboardSummaryResponse['results'] | ApiAiGetDashboardSummaryResponse['results'] | ApiCatalogMetadataResults | ApiCatalogAnalyticsResults | ApiPromotionChangesResponse['results'] | ApiWarehouseTableFields['results'] | ApiTogglePinnedItem['results'] | ApiOrganizationMemberProfiles['results'] | ApiSqlChart['results'] | ApiCreateSqlChart['results'] | ApiUpdateSqlChart['results'] | ApiContentResponse['results'] | ApiChartContentResponse['results'] | ApiSqlRunnerJobStatusResponse['results'] | ApiSemanticLayerClientInfo['results'] | ApiSemanticViewerChartCreate['results'] | ApiSemanticViewerChartGet['results'] | ApiSemanticViewerChartUpdate['results'] | ApiCreateVirtualView['results'] | ApiGithubDbtWritePreview['results'] | ApiMetricsCatalog['results'] | ApiMetricsExplorerQueryResults['results'] | ApiGroupListResponse['results'] | ApiCreateTagResponse['results'];
|
380
383
|
export type ApiResponse<T extends ApiResults = ApiResults> = {
|
381
384
|
status: 'ok';
|
382
385
|
results: T;
|
package/dist/index.js
CHANGED
@@ -55,6 +55,7 @@ tslib_1.__exportStar(require("./types/groups"), exports);
|
|
55
55
|
tslib_1.__exportStar(require("./types/job"), exports);
|
56
56
|
tslib_1.__exportStar(require("./types/knex-paginate"), exports);
|
57
57
|
tslib_1.__exportStar(require("./types/metricQuery"), exports);
|
58
|
+
tslib_1.__exportStar(require("./types/metricsExplorer"), exports);
|
58
59
|
tslib_1.__exportStar(require("./types/notifications"), exports);
|
59
60
|
tslib_1.__exportStar(require("./types/openIdIdentity"), exports);
|
60
61
|
tslib_1.__exportStar(require("./types/organization"), exports);
|
@@ -101,6 +102,7 @@ tslib_1.__exportStar(require("./utils/filters"), exports);
|
|
101
102
|
tslib_1.__exportStar(require("./utils/formatting"), exports);
|
102
103
|
tslib_1.__exportStar(require("./utils/github"), exports);
|
103
104
|
tslib_1.__exportStar(require("./utils/item"), exports);
|
105
|
+
tslib_1.__exportStar(require("./utils/metricsExplorer"), exports);
|
104
106
|
tslib_1.__exportStar(require("./utils/projectMemberRole"), exports);
|
105
107
|
tslib_1.__exportStar(require("./utils/sanitizeHtml"), exports);
|
106
108
|
tslib_1.__exportStar(require("./utils/scheduler"), exports);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import type { ResultRow } from './results';
|
2
|
+
export declare enum MetricExplorerComparison {
|
3
|
+
PREVIOUS_PERIOD = "previous_period",
|
4
|
+
DIFFERENT_METRIC = "different_metric"
|
5
|
+
}
|
6
|
+
export type MetricExplorerComparisonType = {
|
7
|
+
type: MetricExplorerComparison.PREVIOUS_PERIOD;
|
8
|
+
} | {
|
9
|
+
type: MetricExplorerComparison.DIFFERENT_METRIC;
|
10
|
+
metricName: string;
|
11
|
+
};
|
12
|
+
export type MetricsExplorerQueryResults = {
|
13
|
+
rows: ResultRow[];
|
14
|
+
comparisonRows: ResultRow[] | undefined;
|
15
|
+
};
|
16
|
+
export type ApiMetricsExplorerQueryResults = {
|
17
|
+
status: 'ok';
|
18
|
+
results: MetricsExplorerQueryResults;
|
19
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MetricExplorerComparison = void 0;
|
4
|
+
var MetricExplorerComparison;
|
5
|
+
(function (MetricExplorerComparison) {
|
6
|
+
MetricExplorerComparison["PREVIOUS_PERIOD"] = "previous_period";
|
7
|
+
MetricExplorerComparison["DIFFERENT_METRIC"] = "different_metric";
|
8
|
+
})(MetricExplorerComparison = exports.MetricExplorerComparison || (exports.MetricExplorerComparison = {}));
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { ConditionalOperator } from '../types/conditionalRule';
|
2
|
+
import { type DateFilterSettings, type FieldTarget, type FilterRule } from '../types/filter';
|
3
|
+
import { TimeFrames } from '../types/timeFrames';
|
4
|
+
type DateFilter = FilterRule<ConditionalOperator, FieldTarget, unknown, DateFilterSettings>;
|
5
|
+
export declare const getMetricExplorerDimensionCurrentFilters: (exploreName: string, dimensionName: string, timeInterval: TimeFrames | undefined) => DateFilter[];
|
6
|
+
export declare const getMetricExplorerDimensionPreviousFilters: (exploreName: string, dimensionName: string, timeInterval: TimeFrames | undefined) => DateFilter[];
|
7
|
+
export declare const getFieldIdForDateDimension: (fieldId: string, timeframe: TimeFrames) => string;
|
8
|
+
export {};
|
@@ -0,0 +1,259 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getFieldIdForDateDimension = exports.getMetricExplorerDimensionPreviousFilters = exports.getMetricExplorerDimensionCurrentFilters = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const uuid_1 = require("uuid");
|
6
|
+
const conditionalRule_1 = require("../types/conditionalRule");
|
7
|
+
const filter_1 = require("../types/filter");
|
8
|
+
const timeFrames_1 = require("../types/timeFrames");
|
9
|
+
const assertUnreachable_1 = tslib_1.__importDefault(require("./assertUnreachable"));
|
10
|
+
const item_1 = require("./item");
|
11
|
+
const assertUnimplementedTimeframe = (timeframe) => {
|
12
|
+
switch (timeframe) {
|
13
|
+
case timeFrames_1.TimeFrames.RAW:
|
14
|
+
case timeFrames_1.TimeFrames.QUARTER:
|
15
|
+
case timeFrames_1.TimeFrames.HOUR:
|
16
|
+
case timeFrames_1.TimeFrames.MINUTE:
|
17
|
+
case timeFrames_1.TimeFrames.SECOND:
|
18
|
+
case timeFrames_1.TimeFrames.MILLISECOND:
|
19
|
+
case timeFrames_1.TimeFrames.DAY_OF_WEEK_INDEX:
|
20
|
+
case timeFrames_1.TimeFrames.DAY_OF_MONTH_NUM:
|
21
|
+
case timeFrames_1.TimeFrames.DAY_OF_YEAR_NUM:
|
22
|
+
case timeFrames_1.TimeFrames.WEEK_NUM:
|
23
|
+
case timeFrames_1.TimeFrames.MONTH_NUM:
|
24
|
+
case timeFrames_1.TimeFrames.QUARTER_NUM:
|
25
|
+
case timeFrames_1.TimeFrames.YEAR_NUM:
|
26
|
+
case timeFrames_1.TimeFrames.DAY_OF_WEEK_NAME:
|
27
|
+
case timeFrames_1.TimeFrames.MONTH_NAME:
|
28
|
+
case timeFrames_1.TimeFrames.QUARTER_NAME:
|
29
|
+
case timeFrames_1.TimeFrames.HOUR_OF_DAY_NUM:
|
30
|
+
case timeFrames_1.TimeFrames.MINUTE_OF_HOUR_NUM:
|
31
|
+
throw new Error(`Timeframe "${timeframe}" is not supported for default time interval`);
|
32
|
+
default:
|
33
|
+
return (0, assertUnreachable_1.default)(timeframe, `Unknown time interval: "${timeframe}"`);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
// Time grain Year: -> past 5 years (i.e. 5 completed years + this uncompleted year)
|
37
|
+
// Time grain Month -> past 12 months (i.e. 12 completed months + this uncompleted month)
|
38
|
+
// Time grain Week -> past 12 weeks (i.e. 12 completed weeks + this uncompleted week)
|
39
|
+
// Time grain Day -> past 30 days (i.e. 30 completed days + this uncompleted day)
|
40
|
+
const getMetricExplorerDimensionCurrentFilters = (exploreName, dimensionName, timeInterval) => {
|
41
|
+
const targetFieldId = (0, item_1.getItemId)({
|
42
|
+
table: exploreName,
|
43
|
+
name: dimensionName,
|
44
|
+
});
|
45
|
+
if (!timeInterval) {
|
46
|
+
throw new Error('Time interval is required to get relevant filter');
|
47
|
+
}
|
48
|
+
switch (timeInterval) {
|
49
|
+
case timeFrames_1.TimeFrames.DAY:
|
50
|
+
return [
|
51
|
+
{
|
52
|
+
id: (0, uuid_1.v4)(),
|
53
|
+
target: { fieldId: targetFieldId },
|
54
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_PAST,
|
55
|
+
values: [29],
|
56
|
+
settings: {
|
57
|
+
unitOfTime: filter_1.UnitOfTime.days,
|
58
|
+
completed: true,
|
59
|
+
},
|
60
|
+
},
|
61
|
+
{
|
62
|
+
id: (0, uuid_1.v4)(),
|
63
|
+
target: { fieldId: targetFieldId },
|
64
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_CURRENT,
|
65
|
+
values: [],
|
66
|
+
settings: { unitOfTime: filter_1.UnitOfTime.days },
|
67
|
+
},
|
68
|
+
];
|
69
|
+
case timeFrames_1.TimeFrames.WEEK:
|
70
|
+
return [
|
71
|
+
{
|
72
|
+
id: (0, uuid_1.v4)(),
|
73
|
+
target: { fieldId: targetFieldId },
|
74
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_PAST,
|
75
|
+
values: [11],
|
76
|
+
settings: {
|
77
|
+
unitOfTime: filter_1.UnitOfTime.weeks,
|
78
|
+
completed: true,
|
79
|
+
},
|
80
|
+
},
|
81
|
+
{
|
82
|
+
id: (0, uuid_1.v4)(),
|
83
|
+
target: { fieldId: targetFieldId },
|
84
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_CURRENT,
|
85
|
+
values: [],
|
86
|
+
settings: { unitOfTime: filter_1.UnitOfTime.weeks },
|
87
|
+
},
|
88
|
+
];
|
89
|
+
case timeFrames_1.TimeFrames.MONTH:
|
90
|
+
return [
|
91
|
+
{
|
92
|
+
id: (0, uuid_1.v4)(),
|
93
|
+
target: { fieldId: targetFieldId },
|
94
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_PAST,
|
95
|
+
values: [11],
|
96
|
+
settings: {
|
97
|
+
unitOfTime: filter_1.UnitOfTime.months,
|
98
|
+
completed: true,
|
99
|
+
},
|
100
|
+
},
|
101
|
+
{
|
102
|
+
id: (0, uuid_1.v4)(),
|
103
|
+
target: { fieldId: targetFieldId },
|
104
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_CURRENT,
|
105
|
+
values: [],
|
106
|
+
settings: { unitOfTime: filter_1.UnitOfTime.months },
|
107
|
+
},
|
108
|
+
];
|
109
|
+
case timeFrames_1.TimeFrames.YEAR:
|
110
|
+
return [
|
111
|
+
{
|
112
|
+
id: (0, uuid_1.v4)(),
|
113
|
+
target: { fieldId: targetFieldId },
|
114
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_PAST,
|
115
|
+
values: [4],
|
116
|
+
settings: { unitOfTime: filter_1.UnitOfTime.years, completed: true },
|
117
|
+
},
|
118
|
+
{
|
119
|
+
id: (0, uuid_1.v4)(),
|
120
|
+
target: { fieldId: targetFieldId },
|
121
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_CURRENT,
|
122
|
+
values: [],
|
123
|
+
settings: { unitOfTime: filter_1.UnitOfTime.years },
|
124
|
+
},
|
125
|
+
];
|
126
|
+
default:
|
127
|
+
return assertUnimplementedTimeframe(timeInterval);
|
128
|
+
}
|
129
|
+
};
|
130
|
+
exports.getMetricExplorerDimensionCurrentFilters = getMetricExplorerDimensionCurrentFilters;
|
131
|
+
// Time grain Year: -> 10 years ago - 5 years ago
|
132
|
+
// Time grain Month -> 24 months ago - 12 months ago
|
133
|
+
// Time grain Week -> 24 weeks ago - 12 weeks ago
|
134
|
+
// Time grain Day -> 60 days ago - 30 days ago
|
135
|
+
const getMetricExplorerDimensionPreviousFilters = (exploreName, dimensionName, timeInterval) => {
|
136
|
+
const targetFieldId = (0, item_1.getItemId)({
|
137
|
+
table: exploreName,
|
138
|
+
name: dimensionName,
|
139
|
+
});
|
140
|
+
if (!timeInterval) {
|
141
|
+
throw new Error('Time interval is required to get relevant filter');
|
142
|
+
}
|
143
|
+
switch (timeInterval) {
|
144
|
+
case timeFrames_1.TimeFrames.DAY:
|
145
|
+
// 60 days ago - 30 days ago
|
146
|
+
return [
|
147
|
+
{
|
148
|
+
id: (0, uuid_1.v4)(),
|
149
|
+
target: { fieldId: targetFieldId },
|
150
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_PAST,
|
151
|
+
values: [60],
|
152
|
+
settings: {
|
153
|
+
unitOfTime: filter_1.UnitOfTime.days,
|
154
|
+
completed: true,
|
155
|
+
},
|
156
|
+
},
|
157
|
+
{
|
158
|
+
id: (0, uuid_1.v4)(),
|
159
|
+
target: { fieldId: targetFieldId },
|
160
|
+
operator: conditionalRule_1.ConditionalOperator.NOT_IN_THE_PAST,
|
161
|
+
values: [30],
|
162
|
+
settings: {
|
163
|
+
unitOfTime: filter_1.UnitOfTime.days,
|
164
|
+
completed: true,
|
165
|
+
},
|
166
|
+
},
|
167
|
+
];
|
168
|
+
case timeFrames_1.TimeFrames.WEEK:
|
169
|
+
// 24 weeks ago - 12 weeks ago
|
170
|
+
return [
|
171
|
+
{
|
172
|
+
id: (0, uuid_1.v4)(),
|
173
|
+
target: { fieldId: targetFieldId },
|
174
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_PAST,
|
175
|
+
values: [24],
|
176
|
+
settings: {
|
177
|
+
unitOfTime: filter_1.UnitOfTime.weeks,
|
178
|
+
completed: true,
|
179
|
+
},
|
180
|
+
},
|
181
|
+
{
|
182
|
+
id: (0, uuid_1.v4)(),
|
183
|
+
target: { fieldId: targetFieldId },
|
184
|
+
operator: conditionalRule_1.ConditionalOperator.NOT_IN_THE_PAST,
|
185
|
+
values: [12],
|
186
|
+
settings: {
|
187
|
+
unitOfTime: filter_1.UnitOfTime.weeks,
|
188
|
+
completed: true,
|
189
|
+
},
|
190
|
+
},
|
191
|
+
];
|
192
|
+
case timeFrames_1.TimeFrames.MONTH:
|
193
|
+
// 24 months ago - 12 months ago
|
194
|
+
return [
|
195
|
+
{
|
196
|
+
id: (0, uuid_1.v4)(),
|
197
|
+
target: { fieldId: targetFieldId },
|
198
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_PAST,
|
199
|
+
values: [24],
|
200
|
+
settings: {
|
201
|
+
unitOfTime: filter_1.UnitOfTime.months,
|
202
|
+
completed: true,
|
203
|
+
},
|
204
|
+
},
|
205
|
+
{
|
206
|
+
id: (0, uuid_1.v4)(),
|
207
|
+
target: { fieldId: targetFieldId },
|
208
|
+
operator: conditionalRule_1.ConditionalOperator.NOT_IN_THE_PAST,
|
209
|
+
values: [12],
|
210
|
+
settings: {
|
211
|
+
unitOfTime: filter_1.UnitOfTime.months,
|
212
|
+
completed: true,
|
213
|
+
},
|
214
|
+
},
|
215
|
+
];
|
216
|
+
case timeFrames_1.TimeFrames.YEAR:
|
217
|
+
// 10 years ago - 5 years ago
|
218
|
+
return [
|
219
|
+
{
|
220
|
+
id: (0, uuid_1.v4)(),
|
221
|
+
target: { fieldId: targetFieldId },
|
222
|
+
operator: conditionalRule_1.ConditionalOperator.IN_THE_PAST,
|
223
|
+
values: [10],
|
224
|
+
settings: {
|
225
|
+
unitOfTime: filter_1.UnitOfTime.years,
|
226
|
+
completed: true,
|
227
|
+
},
|
228
|
+
},
|
229
|
+
{
|
230
|
+
id: (0, uuid_1.v4)(),
|
231
|
+
target: { fieldId: targetFieldId },
|
232
|
+
operator: conditionalRule_1.ConditionalOperator.NOT_IN_THE_PAST,
|
233
|
+
values: [5],
|
234
|
+
settings: {
|
235
|
+
unitOfTime: filter_1.UnitOfTime.years,
|
236
|
+
completed: true,
|
237
|
+
},
|
238
|
+
},
|
239
|
+
];
|
240
|
+
default:
|
241
|
+
return assertUnimplementedTimeframe(timeInterval);
|
242
|
+
}
|
243
|
+
};
|
244
|
+
exports.getMetricExplorerDimensionPreviousFilters = getMetricExplorerDimensionPreviousFilters;
|
245
|
+
const getFieldIdForDateDimension = (fieldId, timeframe) => {
|
246
|
+
switch (timeframe) {
|
247
|
+
case timeFrames_1.TimeFrames.DAY:
|
248
|
+
return `${fieldId}_day`;
|
249
|
+
case timeFrames_1.TimeFrames.WEEK:
|
250
|
+
return `${fieldId}_week`;
|
251
|
+
case timeFrames_1.TimeFrames.MONTH:
|
252
|
+
return `${fieldId}_month`;
|
253
|
+
case timeFrames_1.TimeFrames.YEAR:
|
254
|
+
return `${fieldId}_year`;
|
255
|
+
default:
|
256
|
+
return assertUnimplementedTimeframe(timeframe);
|
257
|
+
}
|
258
|
+
};
|
259
|
+
exports.getFieldIdForDateDimension = getFieldIdForDateDimension;
|