@vizzly/dashboard 0.14.4-dev-d0e2dcb72115609967eac641863436c4976d6900 → 0.14.4-dev-ed852f0025b4384a82981186f7a42ccbad0c2691

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.
Files changed (32) hide show
  1. package/dist/dashboard.cjs.development.js +592 -792
  2. package/dist/dashboard.cjs.production.min.js +1 -1
  3. package/dist/dashboard.esm.js +592 -792
  4. package/dist/shared-logic/src/ComponentInterface/types.d.ts +0 -1
  5. package/dist/shared-logic/src/CustomField/CustomField.d.ts +2 -3
  6. package/dist/shared-logic/src/CustomField/CustomMetric/__mocks__/mockDataSet.d.ts +2 -0
  7. package/dist/shared-logic/src/CustomField/CustomMetric/build.d.ts +3 -7
  8. package/dist/shared-logic/src/CustomField/CustomMetric/index.d.ts +3 -10
  9. package/dist/shared-logic/src/CustomField/CustomMetric/init.d.ts +4 -0
  10. package/dist/shared-logic/src/CustomField/CustomMetric/types.d.ts +16 -16
  11. package/dist/shared-logic/src/CustomField/CustomMetric/validate.d.ts +2 -0
  12. package/dist/shared-logic/src/CustomField/index.d.ts +1 -1
  13. package/dist/shared-logic/src/CustomField/types.d.ts +28 -29
  14. package/dist/shared-logic/src/FeatureToggle/types.d.ts +0 -1
  15. package/dist/shared-ui/src/components/CustomMetric/buildCustomMetric.d.ts +9 -9
  16. package/dist/shared-ui/src/components/CustomMetric/buildFieldsAndAggregates.d.ts +1 -1
  17. package/dist/shared-ui/src/components/CustomMetric/buildLogicItems.d.ts +2 -0
  18. package/dist/shared-ui/src/components/CustomMetric/buildOperatorItems.d.ts +2 -0
  19. package/dist/shared-ui/src/components/CustomMetric/init.d.ts +7 -5
  20. package/dist/shared-ui/src/components/CustomMetric/items.d.ts +6 -45
  21. package/dist/shared-ui/src/components/ItemPicker/ItemPicker.d.ts +4 -1
  22. package/dist/shared-ui/src/contexts/DashboardContext/types.d.ts +0 -3
  23. package/dist/shared-ui/src/library/DataPanel/CustomFieldInput/CustomMetric/useCustomMetric.d.ts +1 -1
  24. package/dist/shared-ui/src/library/DataPanel/CustomMetricsInput.d.ts +1 -1
  25. package/dist/shared-ui/src/library/DataPanel/metricValuesHaveAggregates.d.ts +2 -0
  26. package/package.json +1 -1
  27. package/dist/shared-logic/src/CustomField/CustomBuild/index.d.ts +0 -7
  28. package/dist/shared-logic/src/CustomField/CustomBuild/schema.d.ts +0 -5
  29. package/dist/shared-logic/src/CustomField/CustomBuild/validate.d.ts +0 -5
  30. package/dist/shared-logic/src/CustomField/CustomMetric/mockDataSet.d.ts +0 -2
  31. package/dist/shared-ui/src/library/DataPanel/CustomFieldInput/CustomMetricBuilder/CustomMetricBuilderModal.d.ts +0 -5
  32. package/dist/shared-ui/src/library/DataPanel/CustomFieldInput/CustomMetricBuilder/useCustomMetricBuilderModal.d.ts +0 -15
@@ -2178,6 +2178,20 @@ var build$7 = function build(measureAttribute, customField) {
2178
2178
  }
2179
2179
  };
2180
2180
 
2181
+ var init$7 = function init(publicName, metric, queryEngineConfig) {
2182
+ return {
2183
+ id: generateId(),
2184
+ publicName: publicName,
2185
+ metric: metric,
2186
+ dataType: 'number',
2187
+ canBeDimension: false,
2188
+ canBeMeasure: true,
2189
+ allowedOperators: validOperatorsForField({
2190
+ dataType: 'number'
2191
+ }, queryEngineConfig)
2192
+ };
2193
+ };
2194
+
2181
2195
  var PropertyType = /*#__PURE__*/function (PropertyType) {
2182
2196
  PropertyType["Operator"] = "operator";
2183
2197
  PropertyType["IfLogic"] = "ifLogic";
@@ -2195,41 +2209,20 @@ var OperatorType = /*#__PURE__*/function (OperatorType) {
2195
2209
  return OperatorType;
2196
2210
  }({});
2197
2211
 
2198
- var buildOperator = function buildOperator(operator, dataSet, params, measureAttribute) {
2199
- var _operator$values = operator.values,
2200
- firstMetric = _operator$values[0],
2201
- secondMetric = _operator$values[1],
2202
- restMetrics = _operator$values.slice(2);
2203
- var left = buildMetric(firstMetric, dataSet, params);
2204
- var right = buildMetric(secondMetric, dataSet, params);
2205
- if (restMetrics.length > 0) {
2206
- right = restMetrics.reduce(function (acc, currMetric) {
2207
- return {
2208
- type: 'maths',
2209
- op: operator.op,
2210
- left: acc,
2211
- right: buildMetric(currMetric, dataSet, params)
2212
- };
2213
- }, right);
2212
+ var build$8 = function build(measureAttribute, customField, dataSet, queryEngineConfig, params) {
2213
+ if (customField.metric.type === PropertyType.IfLogic) {
2214
+ return buildIfLogic(customField.metric, dataSet, fromFilterConfig(params.filterConfig, dataSet, params.timeRangeOptions), queryEngineConfig, params, measureAttribute);
2214
2215
  }
2215
- if (measureAttribute && measureAttribute["function"] != 'none') {
2216
- return {
2217
- type: 'function',
2218
- "function": measureAttribute["function"],
2219
- value: {
2220
- type: 'maths',
2221
- op: operator.op,
2222
- left: left,
2223
- right: right
2224
- }
2225
- };
2216
+ if (customField.metric.type === PropertyType.Aggregate) {
2217
+ return buildAggregate(customField.metric);
2226
2218
  }
2227
- return {
2228
- type: 'maths',
2229
- op: operator.op,
2230
- left: left,
2231
- right: right
2232
- };
2219
+ if (customField.metric.type === PropertyType.Field) {
2220
+ return buildField(customField.metric, measureAttribute);
2221
+ }
2222
+ if (customField.metric.type === PropertyType.NumberInput) {
2223
+ return buildNumber(customField.metric);
2224
+ }
2225
+ return buildOperator(customField.metric, dataSet, params, measureAttribute, false);
2233
2226
  };
2234
2227
  var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilters, queryEngineConfig, params, measureAttribute) {
2235
2228
  var alwaysTrueFilter = [[{
@@ -2245,7 +2238,7 @@ var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilt
2245
2238
  var _params$filterConfig$, _params$filterConfig;
2246
2239
  var customMetricFilter = combineForCustomMetricFilters(addAndFilters((_params$filterConfig$ = params == null || (_params$filterConfig = params.filterConfig) == null ? void 0 : _params$filterConfig.advancedFilter) != null ? _params$filterConfig$ : [], localAndDashboardFilters), c.filter);
2247
2240
  return {
2248
- returns: buildMetric(c.returns, dataSet, params),
2241
+ returns: buildMetric(c.returns, dataSet, params, measureAttribute),
2249
2242
  filter: filterAttributeToQueryFilter(customMetricFilter, queryEngineConfig, dataSet, params)
2250
2243
  };
2251
2244
  });
@@ -2253,11 +2246,11 @@ var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilt
2253
2246
  returns: {
2254
2247
  type: 'null'
2255
2248
  },
2256
- filter: alwaysTrueFilter
2249
+ filter: alwaysTrueFilter // Do not remove
2257
2250
  }]);
2258
2251
  var elseCase = {
2259
- returns: buildMetric(ifLogic["else"], dataSet, params),
2260
- filter: alwaysTrueFilter
2252
+ returns: buildMetric(ifLogic["else"], dataSet, params, measureAttribute),
2253
+ filter: alwaysTrueFilter // Do not remove
2261
2254
  };
2262
2255
  return [].concat(thenCases, [elseCase]);
2263
2256
  }();
@@ -2266,7 +2259,7 @@ var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilt
2266
2259
  }
2267
2260
  return {
2268
2261
  type: 'function',
2269
- "function": measureAttribute == null ? void 0 : measureAttribute["function"],
2262
+ "function": measureAttribute["function"],
2270
2263
  value: {
2271
2264
  type: 'switchField',
2272
2265
  value: {
@@ -2275,7 +2268,56 @@ var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilt
2275
2268
  }
2276
2269
  };
2277
2270
  };
2278
- var buildMetric = function buildMetric(metric, dataSet, params) {
2271
+ var buildAggregate = function buildAggregate(aggregate) {
2272
+ var _aggregate$function;
2273
+ return {
2274
+ type: 'field',
2275
+ value: aggregate.fieldId,
2276
+ "function": (_aggregate$function = aggregate["function"]) != null ? _aggregate$function : ''
2277
+ };
2278
+ };
2279
+ var buildOperator = function buildOperator(operator, dataSet, params, measureAttribute, internal) {
2280
+ var _operator$values = operator.values,
2281
+ firstMetric = _operator$values[0],
2282
+ secondMetric = _operator$values[1],
2283
+ restMetrics = _operator$values.slice(2);
2284
+ var left = buildMetric(firstMetric, dataSet, params, measureAttribute);
2285
+ var right = buildMetric(secondMetric, dataSet, params, measureAttribute);
2286
+ if (restMetrics.length > 0) {
2287
+ right = restMetrics.reduce(function (acc, currMetric) {
2288
+ return {
2289
+ type: 'maths',
2290
+ op: operator.op,
2291
+ left: acc,
2292
+ right: buildMetric(currMetric, dataSet, params, measureAttribute)
2293
+ };
2294
+ }, right);
2295
+ }
2296
+ if (!internal) {
2297
+ var hasFieldValue = operator.values.some(function (value) {
2298
+ return value.type === PropertyType.Field;
2299
+ });
2300
+ if (hasFieldValue) {
2301
+ return {
2302
+ type: 'function',
2303
+ "function": measureAttribute["function"],
2304
+ value: {
2305
+ type: 'maths',
2306
+ op: operator.op,
2307
+ left: left,
2308
+ right: right
2309
+ }
2310
+ };
2311
+ }
2312
+ }
2313
+ return {
2314
+ type: 'maths',
2315
+ op: operator.op,
2316
+ left: left,
2317
+ right: right
2318
+ };
2319
+ };
2320
+ var buildMetric = function buildMetric(metric, dataSet, params, measureAttribute) {
2279
2321
  if (!metric) {
2280
2322
  throw new Error('Invalid metric: undefined metric received');
2281
2323
  }
@@ -2285,9 +2327,11 @@ var buildMetric = function buildMetric(metric, dataSet, params) {
2285
2327
  case PropertyType.Variable:
2286
2328
  return buildVariable(metric, params.variables);
2287
2329
  case PropertyType.Operator:
2288
- return buildOperator(metric, dataSet, params);
2330
+ return buildOperator(metric, dataSet, params, measureAttribute, true);
2289
2331
  case PropertyType.Field:
2290
2332
  return buildField(metric);
2333
+ case PropertyType.Aggregate:
2334
+ return buildAggregate(metric);
2291
2335
  default:
2292
2336
  throw new Error("Unsupported metric type: " + metric.type);
2293
2337
  }
@@ -2317,350 +2361,39 @@ var buildNumber = function buildNumber(numberInput) {
2317
2361
  value: valueAsNumber
2318
2362
  };
2319
2363
  };
2320
- var buildField = function buildField(field) {
2364
+ var buildField = function buildField(field, measureAttribute) {
2321
2365
  return {
2322
2366
  type: 'field',
2323
2367
  value: field.fieldId,
2324
- "function": 'none'
2368
+ "function": measureAttribute ? measureAttribute["function"] : 'none'
2325
2369
  };
2326
2370
  };
2327
2371
 
2328
- var init$7 = function init(publicName, metric, queryEngineConfig) {
2329
- return {
2330
- id: generateId(),
2331
- publicName: publicName,
2332
- metric: metric,
2333
- dataType: 'number',
2334
- canBeDimension: false,
2335
- canBeMeasure: true,
2336
- allowedOperators: validOperatorsForField({
2337
- dataType: 'number'
2338
- }, queryEngineConfig)
2339
- };
2340
- };
2341
- var build$8 = function build(measureAttribute, customField, dataSet, queryEngineConfig, params) {
2342
- if (customField.metric.type === PropertyType.IfLogic) {
2343
- return buildIfLogic(customField.metric, dataSet, fromFilterConfig(params.filterConfig, dataSet, params.timeRangeOptions), queryEngineConfig, params, measureAttribute);
2344
- }
2345
- return buildOperator(customField.metric, dataSet, params, measureAttribute);
2346
- };
2347
2372
  var validate$1 = function validate(field) {
2348
2373
  if (field.publicName.length === 0) return false;
2349
- if (field.publicName === undefined) return false;
2350
- if (field.metric === undefined) return false;
2351
- if (field.metric.type === undefined) return false;
2374
+ if (!field.metric) return false;
2352
2375
  if (field.metric.type === PropertyType.Operator && 'values' in field.metric && field.metric.values.length === 0) return false;
2353
2376
  if (field.metric.type === PropertyType.IfLogic && 'cases' in field.metric && field.metric.cases.length === 0) return false;
2354
- return true;
2355
- };
2356
-
2357
- var tagSchema = function tagSchema() {
2358
- return Joi.object({
2359
- key: Joi.string().required()
2360
- });
2361
- };
2362
- var tagsSchema = function tagsSchema() {
2363
- return Joi.array().items(tagSchema()).min(0);
2364
- };
2365
-
2366
- var measureSchema = function measureSchema(supportedAggregates, attributeSchemaOptions) {
2367
- var buildMeasureJoi = function buildMeasureJoi(fieldJoi, functionJoi) {
2368
- return Joi.object({
2369
- field: fieldJoi.required(),
2370
- "function": functionJoi.required().description('Which if any, aggregate function should be applied to the field?')
2371
- });
2372
- };
2373
-
2374
- // Return an enum using the restriction fields
2375
- if (attributeSchemaOptions != null && attributeSchemaOptions.restrictFields) {
2376
- return Joi.alternatives.apply(Joi, attributeSchemaOptions.restrictFields.filter(function (f) {
2377
- return f.canBeMeasure;
2378
- }).map(function (restrictedField) {
2379
- var _Joi$string;
2380
- var supportedFunctionsForField = listValidFunctionsForDataType(restrictedField, supportedAggregates);
2381
- return buildMeasureJoi(Joi.string().valid(restrictedField.id).description(restrictedField.publicName + ", " + (restrictedField.description || '') + "."), (_Joi$string = Joi.string()).valid.apply(_Joi$string, supportedFunctionsForField.concat(['none'])));
2382
- }));
2377
+ if (field.metric.type === PropertyType.Aggregate && (!field.metric["function"] || field.metric["function"] === 'none')) return false;
2378
+ if (field.metric.type === PropertyType.NumberInput && field.metric.value === undefined) return false;
2379
+ if ('values' in field.metric) {
2380
+ return !_hasAggregatesWithEmptyFunctions(field.metric.values);
2383
2381
  }
2384
- return buildMeasureJoi(Joi.string().description('The ID of the field from the data set to reference.'), Joi.valid.apply(Joi, Object.keys(supportedAggregates).concat(['none'])));
2385
- };
2386
- var orderSchema = function orderSchema(queryEngineConfig) {
2387
- var _Joi$string2;
2388
- return Joi.object({
2389
- field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2390
- direction: Joi.string().valid('asc', 'desc').required().description('In which direction should the results be ordered?'),
2391
- "function": (_Joi$string2 = Joi.string()).valid.apply(_Joi$string2, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])).description('Which if any, function should be applied to the field?')
2392
- });
2393
- };
2394
- var timeDimensionSchema = function timeDimensionSchema(supportedTimeTruncFunctions) {
2395
- return Joi.object({
2396
- field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2397
- truncate: Joi.valid.apply(Joi, Object.keys(supportedTimeTruncFunctions).concat(['none'])),
2398
- bucketFill: Joi["boolean"]()
2399
- });
2400
- };
2401
- var dimensionSchema = function dimensionSchema(supportedTimeTruncFunctions, attributeSchemaOptions) {
2402
- var buildDimensionJoi = function buildDimensionJoi(fieldJoi, isDate) {
2403
- return Joi.object({
2404
- field: fieldJoi.required(),
2405
- pivot: Joi.string().valid('x', 'y').optional(),
2406
- "function": isDate ? Joi.valid.apply(Joi, Object.keys(supportedTimeTruncFunctions).concat(['none'])).required() : Joi.valid('none').required()
2407
- });
2408
- };
2409
-
2410
- // Return an enum using the restriction fields
2411
- if (attributeSchemaOptions != null && attributeSchemaOptions.restrictFields) {
2412
- return Joi.array().items(Joi.alternatives.apply(Joi, attributeSchemaOptions.restrictFields.filter(function (f) {
2413
- return f.canBeDimension;
2414
- }).map(function (restrictedField) {
2415
- return buildDimensionJoi(Joi.string().valid(restrictedField.id).description(restrictedField.publicName + ", " + (restrictedField.description || '') + "."), restrictedField.dataType === 'date_time');
2416
- }))).description('Fields to group the data by');
2417
- }
2418
- return Joi.array().items(buildDimensionJoi(Joi.string().description('The ID of the field from the data set to reference.'), true)).description('Fields to group the data by');
2419
- };
2420
- var filterSchema = function filterSchema(queryEngineConfig) {
2421
- var _Joi$string3, _Joi$string4;
2422
- return Joi.object({
2423
- field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2424
- op: (_Joi$string3 = Joi.string()).valid.apply(_Joi$string3, Object.keys(queryEngineConfig.supportedOperators)).required(),
2425
- value: Joi.alternatives()["try"](joiDate, Joi.string().allow(null), Joi.number(), Joi["boolean"](), Joi.array().items(Joi.string(), Joi.number(), Joi.allow(null)), relativeSchema).required(),
2426
- "function": (_Joi$string4 = Joi.string()).valid.apply(_Joi$string4, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])).description('Which function should be applied to the field?')
2427
- });
2428
- };
2429
- var queryAttributesFilter = function queryAttributesFilter(queryEngineConfig) {
2430
- return Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig)));
2431
- };
2432
- var queryAttributesLimit = function queryAttributesLimit() {
2433
- return Joi.number().description('Limit the number of results returned after the query has been ran.');
2434
- };
2435
- var baseAttributesSchema = function baseAttributesSchema(attributeSchemaOptions) {
2436
- var _Joi$string5;
2437
- var dataSetIdSchema = attributeSchemaOptions != null && attributeSchemaOptions.restrictDataSetIds ? (_Joi$string5 = Joi.string()).valid.apply(_Joi$string5, attributeSchemaOptions.restrictDataSetIds) : Joi.string();
2438
- return {
2439
- viewId: Joi.string().allow('').optional().description('__vizzly_hide_from_docs'),
2440
- displayTitle: Joi.string().allow('').description('A title that explains what is being displayed.'),
2441
- displaySubject: Joi.string().allow('').description('A chance to add a more detailed description of what is being shown.'),
2442
- dataSetId: dataSetIdSchema.description('The ID of the data set that is being used by the view.'),
2443
- protectedByOrganisation: Joi["boolean"]().optional().description('Has the view been created by your organisation, and therefore cannot be modified by your users?')
2444
- };
2445
- };
2446
- var approxAxisLabelCountSchema = /*#__PURE__*/Joi.valid('auto', 2, 0).description('Determine how many axis labels should be shown on the axis');
2447
- var querySchema = function querySchema(queryEngineConfig, attributeSchemaOptions) {
2448
- return {
2449
- measure: Joi.array().items(measureSchema(queryEngineConfig.supportedAggregates, attributeSchemaOptions)).required().description('A list of metrics that are to be shown. For example the `count` of a specific field in your data set.'),
2450
- dimension: dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions).required(),
2451
- order: Joi.array().items(orderSchema(queryEngineConfig)),
2452
- limit: queryAttributesLimit(),
2453
- offset: Joi.number().min(0).description('Paginate results by using this property with limit.')
2454
- };
2455
- };
2456
- var timeDimensionQuerySchema = function timeDimensionQuerySchema(queryEngineConfig, attributeSchemaOptions) {
2457
- return _extends({}, querySchema(queryEngineConfig, attributeSchemaOptions), {
2458
- filter: Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig))),
2459
- timeDimension: Joi.alternatives(timeDimensionSchema(queryEngineConfig.supportedTimeTruncFunctions), Joi.valid(null)).required(),
2460
- drilldown: Joi.alternatives(dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions).required(), Joi.string()),
2461
- xAxisPrefix: Joi.string().allow('').description('Add a prefix to the X Axis'),
2462
- yAxisPrefix: Joi.string().allow('').description('Add a prefix to the Y Axis'),
2463
- xAxisPostfix: Joi.string().allow('').description('Add a postfix to the X Axis'),
2464
- yAxisPostfix: Joi.string().allow('').description('Add a postfix to the Y Axis'),
2465
- yAxisFormat: Joi.alternatives(Joi.string(), Joi.valid(null)).description('ID of the formatting function to apply to the Y Axis values'),
2466
- xAxisFormat: Joi.alternatives(Joi.string(), Joi.valid(null)).description('ID of the formatting function to apply to the X Axis values'),
2467
- approxYAxisLabelCount: approxAxisLabelCountSchema,
2468
- approxXAxisLabelCount: approxAxisLabelCountSchema
2469
- });
2470
- };
2471
- var lineCurveSchema = /*#__PURE__*/Joi.string().valid('natural', 'straight', 'step', 'stepBefore', 'stepAfter', 'dotted');
2472
- var areaCurveSchema = /*#__PURE__*/Joi.string().valid('natural', 'straight', 'step');
2473
- var protectedFieldsMeasure = function protectedFieldsMeasure(queryEngineConfig) {
2474
- var _Joi$string6;
2475
- return Joi.array().items(Joi.object({
2476
- "function": (_Joi$string6 = Joi.string()).valid.apply(_Joi$string6, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])),
2477
- field: Joi.string().required().description('The ID of the field from the data set to reference.')
2478
- }));
2479
- };
2480
- var protectedFieldsDimension = function protectedFieldsDimension(queryEngineConfig) {
2481
- var _Joi$string7;
2482
- return Joi.array().items(Joi.object({
2483
- "function": (_Joi$string7 = Joi.string()).valid.apply(_Joi$string7, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])),
2484
- truncate: Joi.string(),
2485
- field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2486
- bucketFill: Joi["boolean"]().optional(),
2487
- pivot: Joi.string().valid('x', 'y').optional()
2488
- }));
2489
- };
2490
- var parameterGroupSchema = function parameterGroupSchema(queryEngineConfig, attributeSchemaOptions) {
2491
- return Joi.object().pattern(Joi.string(), Joi.alternatives()["try"](Joi.array().items(timeDimensionSchema(queryEngineConfig.supportedTimeTruncFunctions)).min(1), dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions))).unknown(true);
2492
- };
2493
- var parameterMeasureSchema = function parameterMeasureSchema(queryEngineConfig, attributeSchemaOptions) {
2494
- return Joi.object().pattern(Joi.string(), Joi.array().items(measureSchema(queryEngineConfig.supportedAggregates, attributeSchemaOptions)).min(1)).unknown(true);
2495
- };
2496
- var parametersSchema = function parametersSchema(queryEngineConfig, attributeSchemaOptions) {
2497
- return Joi.object({
2498
- measure: parameterMeasureSchema(queryEngineConfig, attributeSchemaOptions),
2499
- group: parameterGroupSchema(queryEngineConfig, attributeSchemaOptions)
2500
- });
2501
- };
2502
- var goalLineValueSchema = /*#__PURE__*/Joi.alternatives()["try"]( /*#__PURE__*/Joi.number().required(), /*#__PURE__*/Joi.string().pattern(/^\{\{.*\}\}$/).required());
2503
- var goalLineSchema = function goalLineSchema() {
2504
- return Joi.object({
2505
- color: Joi.string().required(),
2506
- value: goalLineValueSchema,
2507
- strokeWidth: Joi.number().required(),
2508
- strokeStyle: Joi.string().valid('dashed', 'solid').required(),
2509
- label: Joi["boolean"]().optional()
2510
- });
2511
- };
2512
- var goalLinesSchema = function goalLinesSchema() {
2513
- return Joi.array().items(goalLineSchema());
2514
- };
2515
- var headlineSchema = function headlineSchema() {
2516
- return Joi.object({
2517
- func: Joi.string().valid('mean', 'sum', 'current').allow(null).optional()
2518
- });
2519
- };
2520
- var axisTitleSchema = function axisTitleSchema() {
2521
- return Joi.object({
2522
- x: Joi.string().allow(''),
2523
- y: Joi.string().allow('')
2524
- });
2382
+ return true;
2525
2383
  };
2526
- var sizingSchema = /*#__PURE__*/Joi.object().pattern( /*#__PURE__*/Joi.string(), /*#__PURE__*/Joi.object({
2527
- width: /*#__PURE__*/Joi.number().min(0),
2528
- height: /*#__PURE__*/Joi.number().min(0)
2529
- }));
2530
- var joiDate = /*#__PURE__*/Joi.custom(function (value, helpers) {
2531
- if (Object.prototype.toString.call(value) === '[object Date]') {
2532
- return value;
2533
- }
2534
- return helpers.error('any.invalid');
2535
- }, 'Date object validation');
2536
-
2537
- // Aggregate schema
2538
- var aggregateSchema = /*#__PURE__*/Joi.object({
2539
- type: /*#__PURE__*/Joi.string().valid('aggregate').required(),
2540
- fieldId: /*#__PURE__*/Joi.string().required(),
2541
- "function": /*#__PURE__*/Joi.string().required()
2542
- });
2543
-
2544
- // Field schema
2545
- var fieldSchema = /*#__PURE__*/Joi.object({
2546
- type: /*#__PURE__*/Joi.string().valid('field').required(),
2547
- fieldId: /*#__PURE__*/Joi.string().required(),
2548
- "function": /*#__PURE__*/Joi.string().valid('none').required()
2549
- });
2550
-
2551
- // Variable schema
2552
- var variableSchema = /*#__PURE__*/Joi.object({
2553
- type: /*#__PURE__*/Joi.string().valid('variable').required(),
2554
- value: /*#__PURE__*/Joi.string().required()
2555
- });
2556
-
2557
- // Number schema
2558
- var numberSchema = /*#__PURE__*/Joi.object({
2559
- type: /*#__PURE__*/Joi.string().valid('number').required(),
2560
- value: /*#__PURE__*/Joi.number().required()
2561
- });
2562
-
2563
- // Recursive operator schema (prevents empty values)
2564
- var operatorSchema = /*#__PURE__*/Joi.object({
2565
- type: Joi.string().valid('operator').required(),
2566
- op: Joi.string().valid('+', '-', '*', '/').required(),
2567
- values: Joi.array().items(Joi.when('type', {
2568
- is: 'operator',
2569
- then: Joi.link('#operatorSchema'),
2570
- otherwise: Joi.alternatives()["try"](aggregateSchema, fieldSchema, variableSchema, numberSchema)
2571
- })).min(2).custom(function (values, helpers) {
2572
- var hasAggregate = values.some(function (v) {
2573
- return v.type === 'aggregate';
2574
- });
2575
- var hasField = values.some(function (v) {
2576
- return v.type === 'field';
2577
- });
2578
- var hasEmptyOperator = values.some(function (v) {
2579
- return v.type === 'operator' && (!v.values || v.values.length === 0);
2580
- });
2581
- if (hasAggregate && hasField) {
2582
- return helpers.error('any.invalid', {
2583
- message: 'Field type cannot be mixed with Aggregate type in the same array'
2584
- });
2384
+ var _hasAggregatesWithEmptyFunctions = function hasAggregatesWithEmptyFunctions(values) {
2385
+ return values.some(function (value) {
2386
+ if (value.type === PropertyType.Aggregate) {
2387
+ return !value["function"] || value["function"] === 'none';
2585
2388
  }
2586
- if (hasEmptyOperator) {
2587
- return helpers.error('any.invalid', {
2588
- message: 'Nested operators must have at least two values'
2589
- });
2389
+ if ('values' in value) {
2390
+ return _hasAggregatesWithEmptyFunctions(value.values);
2590
2391
  }
2591
- return values;
2592
- })
2593
- }).meta({
2594
- id: 'operatorSchema'
2595
- });
2596
- var ifLogicSchema = function ifLogicSchema(queryEngineConfig) {
2597
- return Joi.object({
2598
- type: Joi.string().valid('ifLogic').required(),
2599
- cases: Joi.array().items(Joi.object({
2600
- filter: Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig)).min(1)).min(1).required(),
2601
- returns: Joi.alternatives()["try"](fieldSchema, variableSchema, numberSchema, aggregateSchema, operatorSchema).required()
2602
- })).min(1).required(),
2603
- "else": Joi.alternatives()["try"](fieldSchema, variableSchema, numberSchema, aggregateSchema, operatorSchema).optional()
2392
+ return false;
2604
2393
  });
2605
2394
  };
2606
2395
 
2607
- var validate$2 = function validate(queryEngineConfig, metric) {
2608
- if (!metric) return {
2609
- isValid: false
2610
- };
2611
- var schema = null;
2612
-
2613
- // Determine which schema to use based on the metric type
2614
- if (metric.type === 'operator') {
2615
- schema = operatorSchema;
2616
- } else if (metric.type === 'ifLogic') {
2617
- schema = ifLogicSchema(queryEngineConfig);
2618
- } else {
2619
- return {
2620
- isValid: false,
2621
- errors: ['Unsupported metric type']
2622
- };
2623
- }
2624
-
2625
- // Perform validation
2626
- var _schema$validate = schema.validate(metric, {
2627
- abortEarly: false
2628
- }),
2629
- error = _schema$validate.error;
2630
- if (error) {
2631
- return {
2632
- isValid: false,
2633
- errors: error.details.map(function (detail) {
2634
- return detail.message;
2635
- })
2636
- };
2637
- }
2638
- return {
2639
- isValid: true
2640
- };
2641
- };
2642
-
2643
- var init$8 = function init(publicName, metric, queryEngineConfig) {
2644
- return {
2645
- id: generateId(),
2646
- publicName: publicName,
2647
- metricAtrributes: metric,
2648
- canBeDimension: false,
2649
- canBeMeasure: true,
2650
- allowedOperators: validOperatorsForField({
2651
- dataType: 'number'
2652
- }, queryEngineConfig),
2653
- dataType: 'number'
2654
- };
2655
- };
2656
- var build$9 = function build() {
2657
- return {
2658
- type: 'number',
2659
- value: 0
2660
- };
2661
- };
2662
-
2663
- var init$9 = function init(publicName, fieldId, roundToDecimalPlaces, queryEngineConfig) {
2396
+ var init$8 = function init(publicName, fieldId, roundToDecimalPlaces, queryEngineConfig) {
2664
2397
  return {
2665
2398
  id: generateId(),
2666
2399
  publicName: publicName,
@@ -2674,7 +2407,7 @@ var init$9 = function init(publicName, fieldId, roundToDecimalPlaces, queryEngin
2674
2407
  }, queryEngineConfig)
2675
2408
  };
2676
2409
  };
2677
- var build$a = function build(measureAttribute, customField) {
2410
+ var build$9 = function build(measureAttribute, customField) {
2678
2411
  var builtRoundedNumber = {
2679
2412
  type: 'field',
2680
2413
  "function": "round_to_" + customField.roundToDecimalPlaces + "_dp",
@@ -2706,11 +2439,8 @@ var isRules = function isRules(field) {
2706
2439
  var isConditional = function isConditional(field) {
2707
2440
  return 'rule' in field;
2708
2441
  };
2709
- var isMetric = function isMetric(field) {
2710
- return 'metric' in field;
2711
- };
2712
2442
  var isCustomBuildMetric = function isCustomBuildMetric(field) {
2713
- return 'metricAtrributes' in field;
2443
+ return 'metric' in field;
2714
2444
  };
2715
2445
  var isDateCalculation = function isDateCalculation(field) {
2716
2446
  return 'dateCalculationFunction' in field;
@@ -2723,12 +2453,11 @@ var getCustomFieldCategory = function getCustomFieldCategory(field) {
2723
2453
  if (isRoundedNumberField(field)) return 'roundedNumber';
2724
2454
  if (isDateCalculation(field)) return 'dateCalculation';
2725
2455
  if (isConditional(field)) return 'conditional';
2726
- if (isMetric(field)) return 'calculatedField';
2727
2456
  if (isCustomBuildMetric(field)) return 'customBuildMetric';
2728
2457
  throw "Unrecognised custom field type for custom field; " + JSON.stringify(field);
2729
2458
  };
2730
2459
  var isCustomField = function isCustomField(field) {
2731
- return isPercentageField(field) || isSimpleMathField(field) || isAggregateMathField(field) || isRules(field) || isRoundedNumberField(field) || isDateCalculation(field) || isConditional(field) || isMetric(field) || isCustomBuildMetric(field);
2460
+ return isPercentageField(field) || isSimpleMathField(field) || isAggregateMathField(field) || isRules(field) || isRoundedNumberField(field) || isDateCalculation(field) || isConditional(field) || isCustomBuildMetric(field);
2732
2461
  };
2733
2462
 
2734
2463
  /**
@@ -2749,7 +2478,7 @@ var toQueryMeasure = function toQueryMeasure(measureAttribute, customField, quer
2749
2478
  return build$3(measureAttribute, customField, dataSet, params);
2750
2479
  }
2751
2480
  if (isRoundedNumberField(customField)) {
2752
- return build$a(measureAttribute, customField);
2481
+ return build$9(measureAttribute, customField);
2753
2482
  }
2754
2483
  if (isConditional(customField)) {
2755
2484
  return build$5(customField, queryEngineConfig, dataSet, params);
@@ -2757,11 +2486,8 @@ var toQueryMeasure = function toQueryMeasure(measureAttribute, customField, quer
2757
2486
  if (isDateCalculation(customField)) {
2758
2487
  return build$7(measureAttribute, customField);
2759
2488
  }
2760
- if (isMetric(customField)) {
2761
- return build$8(measureAttribute, customField, dataSet, queryEngineConfig, params);
2762
- }
2763
2489
  if (isCustomBuildMetric(customField)) {
2764
- return build$9();
2490
+ return build$8(measureAttribute, customField, dataSet, queryEngineConfig, params);
2765
2491
  }
2766
2492
  throw "Unsupported custom field type; " + JSON.stringify(customField);
2767
2493
  };
@@ -2927,7 +2653,187 @@ var fromDashboardRequiredFilterGroups = function fromDashboardRequiredFilterGrou
2927
2653
  });
2928
2654
  };
2929
2655
 
2930
- var fieldSchema$1 = /*#__PURE__*/Joi.object({
2656
+ var tagSchema = function tagSchema() {
2657
+ return Joi.object({
2658
+ key: Joi.string().required()
2659
+ });
2660
+ };
2661
+ var tagsSchema = function tagsSchema() {
2662
+ return Joi.array().items(tagSchema()).min(0);
2663
+ };
2664
+
2665
+ var measureSchema = function measureSchema(supportedAggregates, attributeSchemaOptions) {
2666
+ var buildMeasureJoi = function buildMeasureJoi(fieldJoi, functionJoi) {
2667
+ return Joi.object({
2668
+ field: fieldJoi.required(),
2669
+ "function": functionJoi.required().description('Which if any, aggregate function should be applied to the field?')
2670
+ });
2671
+ };
2672
+
2673
+ // Return an enum using the restriction fields
2674
+ if (attributeSchemaOptions != null && attributeSchemaOptions.restrictFields) {
2675
+ return Joi.alternatives.apply(Joi, attributeSchemaOptions.restrictFields.filter(function (f) {
2676
+ return f.canBeMeasure;
2677
+ }).map(function (restrictedField) {
2678
+ var _Joi$string;
2679
+ var supportedFunctionsForField = listValidFunctionsForDataType(restrictedField, supportedAggregates);
2680
+ return buildMeasureJoi(Joi.string().valid(restrictedField.id).description(restrictedField.publicName + ", " + (restrictedField.description || '') + "."), (_Joi$string = Joi.string()).valid.apply(_Joi$string, supportedFunctionsForField.concat(['none'])));
2681
+ }));
2682
+ }
2683
+ return buildMeasureJoi(Joi.string().description('The ID of the field from the data set to reference.'), Joi.valid.apply(Joi, Object.keys(supportedAggregates).concat(['none'])));
2684
+ };
2685
+ var orderSchema = function orderSchema(queryEngineConfig) {
2686
+ var _Joi$string2;
2687
+ return Joi.object({
2688
+ field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2689
+ direction: Joi.string().valid('asc', 'desc').required().description('In which direction should the results be ordered?'),
2690
+ "function": (_Joi$string2 = Joi.string()).valid.apply(_Joi$string2, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])).description('Which if any, function should be applied to the field?')
2691
+ });
2692
+ };
2693
+ var timeDimensionSchema = function timeDimensionSchema(supportedTimeTruncFunctions) {
2694
+ return Joi.object({
2695
+ field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2696
+ truncate: Joi.valid.apply(Joi, Object.keys(supportedTimeTruncFunctions).concat(['none'])),
2697
+ bucketFill: Joi["boolean"]()
2698
+ });
2699
+ };
2700
+ var dimensionSchema = function dimensionSchema(supportedTimeTruncFunctions, attributeSchemaOptions) {
2701
+ var buildDimensionJoi = function buildDimensionJoi(fieldJoi, isDate) {
2702
+ return Joi.object({
2703
+ field: fieldJoi.required(),
2704
+ pivot: Joi.string().valid('x', 'y').optional(),
2705
+ "function": isDate ? Joi.valid.apply(Joi, Object.keys(supportedTimeTruncFunctions).concat(['none'])).required() : Joi.valid('none').required()
2706
+ });
2707
+ };
2708
+
2709
+ // Return an enum using the restriction fields
2710
+ if (attributeSchemaOptions != null && attributeSchemaOptions.restrictFields) {
2711
+ return Joi.array().items(Joi.alternatives.apply(Joi, attributeSchemaOptions.restrictFields.filter(function (f) {
2712
+ return f.canBeDimension;
2713
+ }).map(function (restrictedField) {
2714
+ return buildDimensionJoi(Joi.string().valid(restrictedField.id).description(restrictedField.publicName + ", " + (restrictedField.description || '') + "."), restrictedField.dataType === 'date_time');
2715
+ }))).description('Fields to group the data by');
2716
+ }
2717
+ return Joi.array().items(buildDimensionJoi(Joi.string().description('The ID of the field from the data set to reference.'), true)).description('Fields to group the data by');
2718
+ };
2719
+ var filterSchema = function filterSchema(queryEngineConfig) {
2720
+ var _Joi$string3, _Joi$string4;
2721
+ return Joi.object({
2722
+ field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2723
+ op: (_Joi$string3 = Joi.string()).valid.apply(_Joi$string3, Object.keys(queryEngineConfig.supportedOperators)).required(),
2724
+ value: Joi.alternatives()["try"](joiDate, Joi.string().allow(null), Joi.number(), Joi["boolean"](), Joi.array().items(Joi.string(), Joi.number(), Joi.allow(null)), relativeSchema).required(),
2725
+ "function": (_Joi$string4 = Joi.string()).valid.apply(_Joi$string4, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])).description('Which function should be applied to the field?')
2726
+ });
2727
+ };
2728
+ var queryAttributesFilter = function queryAttributesFilter(queryEngineConfig) {
2729
+ return Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig)));
2730
+ };
2731
+ var queryAttributesLimit = function queryAttributesLimit() {
2732
+ return Joi.number().description('Limit the number of results returned after the query has been ran.');
2733
+ };
2734
+ var baseAttributesSchema = function baseAttributesSchema(attributeSchemaOptions) {
2735
+ var _Joi$string5;
2736
+ var dataSetIdSchema = attributeSchemaOptions != null && attributeSchemaOptions.restrictDataSetIds ? (_Joi$string5 = Joi.string()).valid.apply(_Joi$string5, attributeSchemaOptions.restrictDataSetIds) : Joi.string();
2737
+ return {
2738
+ viewId: Joi.string().allow('').optional().description('__vizzly_hide_from_docs'),
2739
+ displayTitle: Joi.string().allow('').description('A title that explains what is being displayed.'),
2740
+ displaySubject: Joi.string().allow('').description('A chance to add a more detailed description of what is being shown.'),
2741
+ dataSetId: dataSetIdSchema.description('The ID of the data set that is being used by the view.'),
2742
+ protectedByOrganisation: Joi["boolean"]().optional().description('Has the view been created by your organisation, and therefore cannot be modified by your users?')
2743
+ };
2744
+ };
2745
+ var approxAxisLabelCountSchema = /*#__PURE__*/Joi.valid('auto', 2, 0).description('Determine how many axis labels should be shown on the axis');
2746
+ var querySchema = function querySchema(queryEngineConfig, attributeSchemaOptions) {
2747
+ return {
2748
+ measure: Joi.array().items(measureSchema(queryEngineConfig.supportedAggregates, attributeSchemaOptions)).required().description('A list of metrics that are to be shown. For example the `count` of a specific field in your data set.'),
2749
+ dimension: dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions).required(),
2750
+ order: Joi.array().items(orderSchema(queryEngineConfig)),
2751
+ limit: queryAttributesLimit(),
2752
+ offset: Joi.number().min(0).description('Paginate results by using this property with limit.')
2753
+ };
2754
+ };
2755
+ var timeDimensionQuerySchema = function timeDimensionQuerySchema(queryEngineConfig, attributeSchemaOptions) {
2756
+ return _extends({}, querySchema(queryEngineConfig, attributeSchemaOptions), {
2757
+ filter: Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig))),
2758
+ timeDimension: Joi.alternatives(timeDimensionSchema(queryEngineConfig.supportedTimeTruncFunctions), Joi.valid(null)).required(),
2759
+ drilldown: Joi.alternatives(dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions).required(), Joi.string()),
2760
+ xAxisPrefix: Joi.string().allow('').description('Add a prefix to the X Axis'),
2761
+ yAxisPrefix: Joi.string().allow('').description('Add a prefix to the Y Axis'),
2762
+ xAxisPostfix: Joi.string().allow('').description('Add a postfix to the X Axis'),
2763
+ yAxisPostfix: Joi.string().allow('').description('Add a postfix to the Y Axis'),
2764
+ yAxisFormat: Joi.alternatives(Joi.string(), Joi.valid(null)).description('ID of the formatting function to apply to the Y Axis values'),
2765
+ xAxisFormat: Joi.alternatives(Joi.string(), Joi.valid(null)).description('ID of the formatting function to apply to the X Axis values'),
2766
+ approxYAxisLabelCount: approxAxisLabelCountSchema,
2767
+ approxXAxisLabelCount: approxAxisLabelCountSchema
2768
+ });
2769
+ };
2770
+ var lineCurveSchema = /*#__PURE__*/Joi.string().valid('natural', 'straight', 'step', 'stepBefore', 'stepAfter', 'dotted');
2771
+ var areaCurveSchema = /*#__PURE__*/Joi.string().valid('natural', 'straight', 'step');
2772
+ var protectedFieldsMeasure = function protectedFieldsMeasure(queryEngineConfig) {
2773
+ var _Joi$string6;
2774
+ return Joi.array().items(Joi.object({
2775
+ "function": (_Joi$string6 = Joi.string()).valid.apply(_Joi$string6, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])),
2776
+ field: Joi.string().required().description('The ID of the field from the data set to reference.')
2777
+ }));
2778
+ };
2779
+ var protectedFieldsDimension = function protectedFieldsDimension(queryEngineConfig) {
2780
+ var _Joi$string7;
2781
+ return Joi.array().items(Joi.object({
2782
+ "function": (_Joi$string7 = Joi.string()).valid.apply(_Joi$string7, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])),
2783
+ truncate: Joi.string(),
2784
+ field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2785
+ bucketFill: Joi["boolean"]().optional(),
2786
+ pivot: Joi.string().valid('x', 'y').optional()
2787
+ }));
2788
+ };
2789
+ var parameterGroupSchema = function parameterGroupSchema(queryEngineConfig, attributeSchemaOptions) {
2790
+ return Joi.object().pattern(Joi.string(), Joi.alternatives()["try"](Joi.array().items(timeDimensionSchema(queryEngineConfig.supportedTimeTruncFunctions)).min(1), dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions))).unknown(true);
2791
+ };
2792
+ var parameterMeasureSchema = function parameterMeasureSchema(queryEngineConfig, attributeSchemaOptions) {
2793
+ return Joi.object().pattern(Joi.string(), Joi.array().items(measureSchema(queryEngineConfig.supportedAggregates, attributeSchemaOptions)).min(1)).unknown(true);
2794
+ };
2795
+ var parametersSchema = function parametersSchema(queryEngineConfig, attributeSchemaOptions) {
2796
+ return Joi.object({
2797
+ measure: parameterMeasureSchema(queryEngineConfig, attributeSchemaOptions),
2798
+ group: parameterGroupSchema(queryEngineConfig, attributeSchemaOptions)
2799
+ });
2800
+ };
2801
+ var goalLineValueSchema = /*#__PURE__*/Joi.alternatives()["try"]( /*#__PURE__*/Joi.number().required(), /*#__PURE__*/Joi.string().pattern(/^\{\{.*\}\}$/).required());
2802
+ var goalLineSchema = function goalLineSchema() {
2803
+ return Joi.object({
2804
+ color: Joi.string().required(),
2805
+ value: goalLineValueSchema,
2806
+ strokeWidth: Joi.number().required(),
2807
+ strokeStyle: Joi.string().valid('dashed', 'solid').required(),
2808
+ label: Joi["boolean"]().optional()
2809
+ });
2810
+ };
2811
+ var goalLinesSchema = function goalLinesSchema() {
2812
+ return Joi.array().items(goalLineSchema());
2813
+ };
2814
+ var headlineSchema = function headlineSchema() {
2815
+ return Joi.object({
2816
+ func: Joi.string().valid('mean', 'sum', 'current').allow(null).optional()
2817
+ });
2818
+ };
2819
+ var axisTitleSchema = function axisTitleSchema() {
2820
+ return Joi.object({
2821
+ x: Joi.string().allow(''),
2822
+ y: Joi.string().allow('')
2823
+ });
2824
+ };
2825
+ var sizingSchema = /*#__PURE__*/Joi.object().pattern( /*#__PURE__*/Joi.string(), /*#__PURE__*/Joi.object({
2826
+ width: /*#__PURE__*/Joi.number().min(0),
2827
+ height: /*#__PURE__*/Joi.number().min(0)
2828
+ }));
2829
+ var joiDate = /*#__PURE__*/Joi.custom(function (value, helpers) {
2830
+ if (Object.prototype.toString.call(value) === '[object Date]') {
2831
+ return value;
2832
+ }
2833
+ return helpers.error('any.invalid');
2834
+ }, 'Date object validation');
2835
+
2836
+ var fieldSchema = /*#__PURE__*/Joi.object({
2931
2837
  fieldId: /*#__PURE__*/Joi.string().required(),
2932
2838
  dataSetId: /*#__PURE__*/Joi.string().required()
2933
2839
  });
@@ -2942,8 +2848,8 @@ var sharedAdditionalFilterSchema = function sharedAdditionalFilterSchema(queryEn
2942
2848
  managedByConfiguration: Joi["boolean"]().optional(),
2943
2849
  requiresValue: Joi["boolean"]().optional(),
2944
2850
  optionsFilters: optionsFiltersSchema(queryEngineConfig).optional(),
2945
- appliesToFields: Joi.array().items(fieldSchema$1).required(),
2946
- optionsPulledFrom: Joi.array().items(fieldSchema$1).optional(),
2851
+ appliesToFields: Joi.array().items(fieldSchema).required(),
2852
+ optionsPulledFrom: Joi.array().items(fieldSchema).optional(),
2947
2853
  hidden: Joi["boolean"](),
2948
2854
  options: Joi.array().items(Joi.object({
2949
2855
  value: Joi.allow(Joi.number(), Joi.string()),
@@ -3302,7 +3208,7 @@ var buildFilters = function buildFilters(dataSet, queryEngineConfig, params, pre
3302
3208
  return [];
3303
3209
  };
3304
3210
 
3305
- var build$b = buildFromQueryAttributes;
3211
+ var build$a = buildFromQueryAttributes;
3306
3212
  var hasDimensions = function hasDimensions(query) {
3307
3213
  return query.group.length > 0;
3308
3214
  };
@@ -4190,10 +4096,6 @@ var upcastHeadline = function upcastHeadline(headline, timeDimension) {
4190
4096
  return undefined;
4191
4097
  };
4192
4098
 
4193
- /** @deprecated */
4194
-
4195
- /** @deprecated */
4196
-
4197
4099
  var AcceptedTypes = /*#__PURE__*/function (AcceptedTypes) {
4198
4100
  AcceptedTypes["Maths"] = "maths";
4199
4101
  AcceptedTypes["IfStatement"] = "ifStatement";
@@ -4331,8 +4233,7 @@ var BarChart = function BarChart(config) {
4331
4233
  aggregateMaths: true,
4332
4234
  roundedNumbers: true,
4333
4235
  conditional: true,
4334
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
4335
- customBuild: false
4236
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
4336
4237
  },
4337
4238
  supportedFeatures: {
4338
4239
  parameters: true,
@@ -4727,8 +4628,7 @@ var LineChart = function LineChart(config) {
4727
4628
  aggregateMaths: true,
4728
4629
  roundedNumbers: true,
4729
4630
  conditional: true,
4730
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
4731
- customBuild: false
4631
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
4732
4632
  },
4733
4633
  supportedFeatures: {
4734
4634
  parameters: true,
@@ -5089,7 +4989,6 @@ var LineChart$1 = function LineChart(config) {
5089
4989
  ];
5090
4990
  },
5091
4991
  supportedCustomFields: {
5092
- calculatedField: false,
5093
4992
  percentages: true,
5094
4993
  dateCalculations: true,
5095
4994
  simpleMaths: true,
@@ -5097,7 +4996,7 @@ var LineChart$1 = function LineChart(config) {
5097
4996
  aggregateMaths: true,
5098
4997
  roundedNumbers: true,
5099
4998
  conditional: true,
5100
- customBuild: false
4999
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
5101
5000
  },
5102
5001
  supportedFeatures: {
5103
5002
  parameters: true,
@@ -5371,8 +5270,7 @@ var PieChart = function PieChart(config) {
5371
5270
  aggregateMaths: true,
5372
5271
  roundedNumbers: true,
5373
5272
  conditional: true,
5374
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
5375
- customBuild: false
5273
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
5376
5274
  },
5377
5275
  supportedFeatures: {
5378
5276
  parameters: true,
@@ -5643,8 +5541,7 @@ var SunburstChart = function SunburstChart(config) {
5643
5541
  aggregateMaths: true,
5644
5542
  roundedNumbers: true,
5645
5543
  conditional: true,
5646
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
5647
- customBuild: false
5544
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
5648
5545
  },
5649
5546
  supportedFeatures: {
5650
5547
  parameters: true,
@@ -5998,8 +5895,7 @@ var ScatterChart = function ScatterChart(config) {
5998
5895
  aggregateMaths: true,
5999
5896
  roundedNumbers: true,
6000
5897
  conditional: true,
6001
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
6002
- customBuild: false
5898
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
6003
5899
  },
6004
5900
  supportedFeatures: {
6005
5901
  parameters: false,
@@ -6371,8 +6267,7 @@ var ComboChart = function ComboChart(config) {
6371
6267
  aggregateMaths: true,
6372
6268
  roundedNumbers: true,
6373
6269
  conditional: true,
6374
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
6375
- customBuild: false
6270
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
6376
6271
  },
6377
6272
  supportedFeatures: {
6378
6273
  parameters: false,
@@ -6707,8 +6602,7 @@ var DataTable = function DataTable(config) {
6707
6602
  aggregateMaths: true,
6708
6603
  roundedNumbers: true,
6709
6604
  conditional: true,
6710
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
6711
- customBuild: false
6605
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
6712
6606
  },
6713
6607
  supportedFeatures: {
6714
6608
  parameters: false,
@@ -6953,8 +6847,7 @@ var BasicTable = function BasicTable(config) {
6953
6847
  roundedNumbers: true,
6954
6848
  dateCalculations: true,
6955
6849
  conditional: true,
6956
- calculatedField: [AcceptedTypes.Maths],
6957
- customBuild: [AcceptedTypes.Maths]
6850
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement]
6958
6851
  },
6959
6852
  supportedFeatures: {
6960
6853
  parameters: false,
@@ -7266,8 +7159,7 @@ var HorizontalBarChart = function HorizontalBarChart(config) {
7266
7159
  aggregateMaths: true,
7267
7160
  roundedNumbers: true,
7268
7161
  conditional: true,
7269
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
7270
- customBuild: false
7162
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
7271
7163
  },
7272
7164
  supportedFeatures: {
7273
7165
  parameters: true,
@@ -7628,8 +7520,7 @@ var AreaChart = function AreaChart(config) {
7628
7520
  aggregateMaths: true,
7629
7521
  roundedNumbers: true,
7630
7522
  conditional: true,
7631
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
7632
- customBuild: false
7523
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
7633
7524
  },
7634
7525
  supportedFeatures: {
7635
7526
  parameters: true,
@@ -7919,7 +7810,6 @@ var SingleStat = function SingleStat(config) {
7919
7810
  rules: true,
7920
7811
  roundedNumbers: true,
7921
7812
  conditional: true,
7922
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
7923
7813
  customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
7924
7814
  },
7925
7815
  supportedFeatures: {
@@ -8055,8 +7945,7 @@ var CustomChart = function CustomChart(config) {
8055
7945
  roundedNumbers: false,
8056
7946
  dateCalculations: false,
8057
7947
  conditional: false,
8058
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
8059
- customBuild: false
7948
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
8060
7949
  },
8061
7950
  supportedFeatures: {
8062
7951
  colorGradient: false,
@@ -8292,8 +8181,7 @@ var MercatorMap = function MercatorMap(config) {
8292
8181
  aggregateMaths: true,
8293
8182
  roundedNumbers: true,
8294
8183
  conditional: true,
8295
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
8296
- customBuild: false
8184
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
8297
8185
  },
8298
8186
  supportedFeatures: {
8299
8187
  parameters: false,
@@ -8604,8 +8492,7 @@ var RichText = function RichText(config) {
8604
8492
  aggregateMaths: true,
8605
8493
  roundedNumbers: true,
8606
8494
  conditional: true,
8607
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
8608
- customBuild: false
8495
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
8609
8496
  },
8610
8497
  supportedFeatures: {
8611
8498
  parameters: false,
@@ -8906,7 +8793,6 @@ var RadarChart = function RadarChart(config) {
8906
8793
  return [headingConstant(CONSTANTS$f), chartStylesConstant(CONSTANTS$f, false, false), axisLabelsConstants(CONSTANTS$f)];
8907
8794
  },
8908
8795
  supportedCustomFields: {
8909
- calculatedField: false,
8910
8796
  percentages: true,
8911
8797
  dateCalculations: true,
8912
8798
  simpleMaths: true,
@@ -8914,7 +8800,7 @@ var RadarChart = function RadarChart(config) {
8914
8800
  aggregateMaths: true,
8915
8801
  roundedNumbers: true,
8916
8802
  conditional: true,
8917
- customBuild: false
8803
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
8918
8804
  },
8919
8805
  supportedFeatures: {
8920
8806
  parameters: true,
@@ -9132,7 +9018,6 @@ var Progress = function Progress(config) {
9132
9018
  rules: true,
9133
9019
  roundedNumbers: true,
9134
9020
  conditional: true,
9135
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
9136
9021
  customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
9137
9022
  },
9138
9023
  supportedFeatures: {
@@ -9436,8 +9321,7 @@ var FunnelChart = function FunnelChart(config) {
9436
9321
  aggregateMaths: true,
9437
9322
  roundedNumbers: true,
9438
9323
  conditional: true,
9439
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
9440
- customBuild: false
9324
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
9441
9325
  },
9442
9326
  supportedFeatures: {
9443
9327
  parameters: true,
@@ -10084,8 +9968,7 @@ var BubbleChart = function BubbleChart(config) {
10084
9968
  aggregateMaths: true,
10085
9969
  roundedNumbers: true,
10086
9970
  conditional: true,
10087
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
10088
- customBuild: false
9971
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
10089
9972
  },
10090
9973
  supportedFeatures: {
10091
9974
  parameters: false,
@@ -10500,7 +10383,6 @@ var BubbleChartV2 = function BubbleChartV2(config) {
10500
10383
  ];
10501
10384
  },
10502
10385
  supportedCustomFields: {
10503
- calculatedField: false,
10504
10386
  percentages: true,
10505
10387
  dateCalculations: true,
10506
10388
  simpleMaths: true,
@@ -10508,7 +10390,7 @@ var BubbleChartV2 = function BubbleChartV2(config) {
10508
10390
  aggregateMaths: true,
10509
10391
  roundedNumbers: true,
10510
10392
  conditional: true,
10511
- customBuild: false
10393
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
10512
10394
  },
10513
10395
  supportedFeatures: {
10514
10396
  parameters: true,
@@ -10863,7 +10745,6 @@ var BarChart$1 = function BarChart(config) {
10863
10745
  }), namespace(CONSTANTS$k, 'goal_line')];
10864
10746
  },
10865
10747
  supportedCustomFields: {
10866
- calculatedField: false,
10867
10748
  percentages: true,
10868
10749
  dateCalculations: true,
10869
10750
  simpleMaths: true,
@@ -10871,7 +10752,7 @@ var BarChart$1 = function BarChart(config) {
10871
10752
  aggregateMaths: true,
10872
10753
  roundedNumbers: true,
10873
10754
  conditional: true,
10874
- customBuild: false
10755
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
10875
10756
  },
10876
10757
  supportedFeatures: {
10877
10758
  parameters: true,
@@ -11202,8 +11083,7 @@ var WaterfallChart = function WaterfallChart(config) {
11202
11083
  aggregateMaths: true,
11203
11084
  roundedNumbers: true,
11204
11085
  conditional: true,
11205
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
11206
- customBuild: false
11086
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
11207
11087
  },
11208
11088
  supportedFeatures: {
11209
11089
  parameters: true,
@@ -11569,7 +11449,6 @@ var AreaChart$1 = function AreaChart(config) {
11569
11449
  }), namespace(CONSTANTS$m, 'goal_line')];
11570
11450
  },
11571
11451
  supportedCustomFields: {
11572
- calculatedField: false,
11573
11452
  percentages: true,
11574
11453
  dateCalculations: true,
11575
11454
  simpleMaths: true,
@@ -11577,7 +11456,7 @@ var AreaChart$1 = function AreaChart(config) {
11577
11456
  aggregateMaths: true,
11578
11457
  roundedNumbers: true,
11579
11458
  conditional: true,
11580
- customBuild: false
11459
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
11581
11460
  },
11582
11461
  supportedFeatures: {
11583
11462
  parameters: true,
@@ -11932,8 +11811,7 @@ var ComboChartV2 = function ComboChartV2(config) {
11932
11811
  aggregateMaths: true,
11933
11812
  roundedNumbers: true,
11934
11813
  conditional: true,
11935
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
11936
- customBuild: false
11814
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
11937
11815
  },
11938
11816
  supportedFeatures: {
11939
11817
  parameters: false,
@@ -13268,7 +13146,7 @@ function linearForecast(data, forecastUnits, key, timeUnit, includeForecast // N
13268
13146
  return trendlineWithForecast;
13269
13147
  }
13270
13148
 
13271
- var init$a = function init(_ref) {
13149
+ var init$9 = function init(_ref) {
13272
13150
  var pivotConfig = _ref.pivotConfig,
13273
13151
  measures = _ref.measures,
13274
13152
  resultSet = _ref.resultSet,
@@ -15018,13 +14896,12 @@ var ADMIN_FEATURE_TOGGLES = {
15018
14896
  canEditCustomMetrics: true,
15019
14897
  allowPercentagesCustomField: true,
15020
14898
  allowDateCalculationsCustomField: true,
15021
- allowCalculatedField: false,
15022
14899
  allowConditionalCustomField: true,
15023
14900
  allowSimpleMathsCustomField: true,
15024
14901
  allowAggregateMathsCustomField: true,
15025
14902
  allowRoundedNumberCustomField: true,
15026
14903
  allowRulesCustomField: true,
15027
- allowCustomBuildField: false,
14904
+ allowCustomBuildField: true,
15028
14905
  showDateAndTimeFilter: true,
15029
14906
  showDateFilter: true,
15030
14907
  canSeeEmptyState: false,
@@ -15060,9 +14937,8 @@ var END_USER_DEFAULT_FEATURE_TOGGLES = {
15060
14937
  allowSimpleMathsCustomField: true,
15061
14938
  allowAggregateMathsCustomField: true,
15062
14939
  allowRoundedNumberCustomField: true,
15063
- allowCalculatedField: false,
15064
14940
  allowRulesCustomField: true,
15065
- allowCustomBuildField: false,
14941
+ allowCustomBuildField: true,
15066
14942
  showDateAndTimeFilter: true,
15067
14943
  showDateFilter: true,
15068
14944
  canSeeEmptyState: false,
@@ -15075,7 +14951,7 @@ var END_USER_DEFAULT_FEATURE_TOGGLES = {
15075
14951
  showSavingIndicator: true,
15076
14952
  disablePersistingGlobalFiltersLocally: false
15077
14953
  };
15078
- var build$c = function build(partialFeatureToggles, queryEngineConfig, mode, scope) {
14954
+ var build$b = function build(partialFeatureToggles, queryEngineConfig, mode, scope) {
15079
14955
  var featureToggles = {};
15080
14956
  featureToggles = _extends({}, featureToggles, END_USER_DEFAULT_FEATURE_TOGGLES, partialFeatureToggles);
15081
14957
  if (mode == 'admin') {
@@ -15141,7 +15017,7 @@ var buildDefaults = function buildDefaults(partialFeatureToggles) {
15141
15017
  canDownloadViewAsPNG: partialFeatureToggles.canDownloadViewAsPNG !== undefined ? partialFeatureToggles.canDownloadViewAsPNG : true,
15142
15018
  forceMobile: partialFeatureToggles.forceMobile !== undefined ? partialFeatureToggles.forceMobile : false,
15143
15019
  unloadOffScreenViews: partialFeatureToggles.unloadOffScreenViews !== undefined ? partialFeatureToggles.unloadOffScreenViews : false,
15144
- allowCalculatedField: (_partialFeatureToggle2 = partialFeatureToggles.allowCalculatedField) != null ? _partialFeatureToggle2 : false
15020
+ allowCustomBuildField: (_partialFeatureToggle2 = partialFeatureToggles.allowCustomBuildField) != null ? _partialFeatureToggle2 : true
15145
15021
  };
15146
15022
  };
15147
15023
 
@@ -15169,7 +15045,7 @@ var removeField$3 = function removeField(component, fieldId) {
15169
15045
  return newComponent;
15170
15046
  };
15171
15047
 
15172
- var init$b = function init(displayTitle) {
15048
+ var init$a = function init(displayTitle) {
15173
15049
  return {
15174
15050
  displayTitle: displayTitle,
15175
15051
  colSpan: 12
@@ -15181,7 +15057,7 @@ var isComponent = function isComponent(component) {
15181
15057
  var HEADER_ROW_HEIGHT$1 = 52;
15182
15058
  var add = function add(display, rowIndex, initialTitle) {
15183
15059
  var updatedDisplay = [].concat(display);
15184
- var newHeader = init$b(initialTitle);
15060
+ var newHeader = init$a(initialTitle);
15185
15061
  var newRow = initRow([newHeader], HEADER_ROW_HEIGHT$1);
15186
15062
  updatedDisplay.splice(rowIndex, 0, newRow);
15187
15063
  return updatedDisplay;
@@ -15656,7 +15532,7 @@ var defaultDateFilterOptions = function defaultDateFilterOptions() {
15656
15532
  }
15657
15533
  return defaultDateFilterOptions;
15658
15534
  };
15659
- var build$d = function build(textOverride, overrides) {
15535
+ var build$c = function build(textOverride, overrides) {
15660
15536
  var timeRangeMapping = defaultTimeRangeMapping(textOverride);
15661
15537
  var orderedKeys = Object.keys(DEFAULT_DATETIME_FILTER_OPTIONS).map(function (key) {
15662
15538
  return key in timeRangeMapping ? "_vizzly_" + key : key;
@@ -15950,7 +15826,7 @@ var base = {
15950
15826
  return undefined;
15951
15827
  }
15952
15828
  };
15953
- var init$c = function init(overrides, includeComponentTypes, excludeComponentTypes, textOverride, featureToggles) {
15829
+ var init$b = function init(overrides, includeComponentTypes, excludeComponentTypes, textOverride, featureToggles) {
15954
15830
  var _overrides$developerT;
15955
15831
  var onlyViewTypes = function onlyViewTypes(dataSet) {
15956
15832
  var allowedView = filterIncludedAndExcludedViews(ALL_VIZZLY_COMPONENT_TYPES, includeComponentTypes,
@@ -15988,7 +15864,7 @@ var init$c = function init(overrides, includeComponentTypes, excludeComponentTyp
15988
15864
  return _extends({}, defaultFormatMapping, overrides.defaultFormats ? overrides.defaultFormats() : {});
15989
15865
  },
15990
15866
  onEditorUpdate: overrides.onEditorUpdate ? overrides.onEditorUpdate : base.onEditorUpdate,
15991
- dateFilterOptions: build$d(textOverride, overrides.dateFilterOptions),
15867
+ dateFilterOptions: build$c(textOverride, overrides.dateFilterOptions),
15992
15868
  onSave: overrides.onSave ? overrides.onSave : base.onSave,
15993
15869
  onScheduledReportChange: overrides.onScheduledReportChange || base.onScheduledReportChange,
15994
15870
  dashboardFilters: overrides.dashboardFilters ? overrides.dashboardFilters : base.dashboardFilters,
@@ -16042,7 +15918,7 @@ function useSubscription(callback, idOverride) {
16042
15918
  var useFeatureTogglesSetup = function useFeatureTogglesSetup(mode, overrideFeatureToggles, queryEngineConfig, scope, id) {
16043
15919
  var base$1 = base;
16044
15920
  var buildInitialFeatureToggles = function () {
16045
- var updatedFeatureToggles = build$c(_.merge({}, base$1.featureToggles, overrideFeatureToggles), queryEngineConfig != null ? queryEngineConfig : base$1.queryEngineConfig, mode || base$1.mode, scope || base$1.scope);
15921
+ var updatedFeatureToggles = build$b(_.merge({}, base$1.featureToggles, overrideFeatureToggles), queryEngineConfig != null ? queryEngineConfig : base$1.queryEngineConfig, mode || base$1.mode, scope || base$1.scope);
16046
15922
  return updatedFeatureToggles;
16047
15923
  }();
16048
15924
  var _useState = useState(buildInitialFeatureToggles),
@@ -16072,7 +15948,7 @@ var DashboardBehaviourContextProvider = function DashboardBehaviourContextProvid
16072
15948
  var _useState = useState(null),
16073
15949
  overrideDeveloperInfo = _useState[0],
16074
15950
  setOverrideDeveloperInfo = _useState[1];
16075
- var dashboardBehaviour = init$c(_extends({}, props.dashboardBehaviour || {}, {
15951
+ var dashboardBehaviour = init$b(_extends({}, props.dashboardBehaviour || {}, {
16076
15952
  mode: props.mode
16077
15953
  }), props.includeComponentTypes, props.excludeComponentTypes, textOverride, featureToggles);
16078
15954
  return jsx(DashboardBehaviourContext.Provider, {
@@ -34839,7 +34715,7 @@ var AreaChart$3 = /*#__PURE__*/forwardRef(function (props, ref) {
34839
34715
  });
34840
34716
  });
34841
34717
 
34842
- var init$d = function init(attributes) {
34718
+ var init$c = function init(attributes) {
34843
34719
  var dimension = [];
34844
34720
  if ('dimension' in attributes) {
34845
34721
  dimension = [].concat(dimension, attributes.dimension || []);
@@ -35731,7 +35607,7 @@ var AreaChartView = function AreaChartView(props) {
35731
35607
  if (isLoading(props.result)) return jsx(LoadingComponent, {});
35732
35608
  if (hasFailed(props.result)) return jsx(FailedToLoadDataNotice, {});
35733
35609
  if (isEmpty(props.result)) return jsx(NoResultContentToShowNotice, _extends({}, headerProps));
35734
- var pivotConfig = init$d(props);
35610
+ var pivotConfig = init$c(props);
35735
35611
  var series$1 = series(pivotConfig, props.measure, props.result);
35736
35612
  var resultSet$1 = resultSet(props.result, props.measure, pivotConfig, props.stacked == '100%', checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
35737
35613
  var showHeadline = headlineAvailable(props.order, props.headline, props.timeDimension);
@@ -37018,7 +36894,7 @@ var BarChartView = function BarChartView(props) {
37018
36894
  if (isLoading(props.result)) return jsx(LoadingComponent, {});
37019
36895
  if (hasFailed(props.result)) return jsx(FailedToLoadDataNotice, {});
37020
36896
  if (isEmpty(props.result)) return jsx(NoResultContentToShowNotice, _extends({}, headerProps));
37021
- var pivotConfig = init$d(props);
36897
+ var pivotConfig = init$c(props);
37022
36898
  var series$1 = series(pivotConfig, props.measure, props.result);
37023
36899
  var resultSet$1 = resultSet(props.result, props.measure, pivotConfig, props.stacked == '100%', checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
37024
36900
  var showHeadline = headlineAvailable(props.order, props.headline, props.timeDimension);
@@ -37423,12 +37299,12 @@ var LineChartView = function LineChartView(props) {
37423
37299
  if (isLoading(props.result)) return jsx(LoadingComponent, {});
37424
37300
  if (hasFailed(props.result)) return jsx(FailedToLoadDataNotice, {});
37425
37301
  if (isEmpty(props.result)) return jsx(NoResultContentToShowNotice, _extends({}, headerProps));
37426
- var pivotConfig = init$d(props);
37302
+ var pivotConfig = init$c(props);
37427
37303
  var series$1 = series(pivotConfig, props.measure, props.result);
37428
37304
  var resultSet$1 = resultSet(props.result, props.measure, pivotConfig, props.stacked == '100%', checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
37429
37305
  var buildTrends = function buildTrends() {
37430
37306
  if (props.order.length > 0 && props.trends && props.trends.length > 0 && acceptedTimeDimensions(props.timeDimension)) {
37431
- var trends = init$a({
37307
+ var trends = init$9({
37432
37308
  pivotConfig: pivotConfig,
37433
37309
  measures: props.measure,
37434
37310
  resultSet: resultSet$1,
@@ -37668,7 +37544,7 @@ var ScatterChartView = function ScatterChartView(props) {
37668
37544
  var measure = [];
37669
37545
  if (props.xMeasure) measure.push(props.xMeasure);
37670
37546
  if (props.yMeasure) measure.push(props.yMeasure);
37671
- var pivotConfig = init$d(props);
37547
+ var pivotConfig = init$c(props);
37672
37548
  var scatterData = props.result ? resultSet(props.result, measure, pivotConfig) : [];
37673
37549
  var xField = key([], [], props.xMeasure.field, props.xMeasure["function"]);
37674
37550
  scatterData.map(function (d) {
@@ -39034,7 +38910,7 @@ var PieChartView = function PieChartView(props) {
39034
38910
  }
39035
38911
  if (hasFailed(props.result)) return jsx(FailedToLoadDataNotice, {});
39036
38912
  if (isEmpty(props.result)) return jsx(NoResultContentToShowNotice, _extends({}, headerProps));
39037
- var pivotConfig = init$d({
38913
+ var pivotConfig = init$c({
39038
38914
  dimension: props.dimension
39039
38915
  });
39040
38916
  var rS = resultSet$1(props.result, pivotConfig, fakeQuery, false, checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
@@ -43192,7 +43068,7 @@ var BubbleChartView = function BubbleChartView(props) {
43192
43068
  var measure = [];
43193
43069
  measure.push(props.xMeasure);
43194
43070
  measure.push(props.yMeasure);
43195
- var pivotConfig = init$d(props);
43071
+ var pivotConfig = init$c(props);
43196
43072
  var bubbleData = props.result ? resultSet(props.result, measure, pivotConfig) : [];
43197
43073
  var xField = key([], [], props.xMeasure.field, props.xMeasure["function"]);
43198
43074
  var zField = props.zMeasure ? key([], [], props.zMeasure.field, props.zMeasure["function"]) : '';
@@ -47033,7 +46909,7 @@ var BubbleChartV2View = function BubbleChartV2View(props) {
47033
46909
  var showHeadline = headlineAvailable(props.attributes.order, props.attributes.headline, null);
47034
46910
  var theme = useTheme();
47035
46911
  var BubbleChartV2Component = getComponentInterface(props.attributes.type);
47036
- var pivotConfig = init$d(props.attributes);
46912
+ var pivotConfig = init$c(props.attributes);
47037
46913
  var chartRepresentation = null;
47038
46914
  if (!isLoading(props.result) && !hasFailed(props.result) && !isEmpty(props.result) && BubbleChartV2Component.isRunnable(props.attributes)) {
47039
46915
  var _theme$charts$colors, _theme$charts, _props$attributes$goa;
@@ -47993,7 +47869,7 @@ var LineChartV2View = function LineChartV2View(props) {
47993
47869
  var showHeadline = headlineAvailable(props.attributes.order, props.attributes.headline, null);
47994
47870
  var theme = useTheme();
47995
47871
  var LineChartV2Component = getComponentInterface(props.attributes.type);
47996
- var pivotConfig = init$d(props.attributes);
47872
+ var pivotConfig = init$c(props.attributes);
47997
47873
  var chartRepresentation = null;
47998
47874
  if (!isLoading(props.result) && !hasFailed(props.result) && !isEmpty(props.result) && LineChartV2Component.isRunnable(props.attributes)) {
47999
47875
  var _theme$charts$colors, _theme$charts, _props$attributes$goa;
@@ -48510,13 +48386,13 @@ var ComboChartView = function ComboChartView(props) {
48510
48386
  }
48511
48387
  if (isLoading(props.lineResult) || isLoading(props.barResult)) return jsx(LoadingComponent, {});
48512
48388
  if (hasFailed(props.lineResult) && hasFailed(props.barResult)) return jsx(FailedToLoadDataNotice, {});
48513
- var barPivotConfig = init$d({
48389
+ var barPivotConfig = init$c({
48514
48390
  dimension: props.barDimension,
48515
48391
  timeDimension: props.timeDimension
48516
48392
  });
48517
48393
  var barSeries = props.barResult ? series(barPivotConfig, props.barMeasure, props.barResult) : [];
48518
48394
  var barTimeseriesResultSet = props.barResult ? resultSet(props.barResult, props.barMeasure, barPivotConfig, props.stacked == '100%', checkForNullValue(props.dataSetId, props.barDimension, props.timeDimension, textOverride, valueAlias)) : [];
48519
- var linePivotConfig = init$d({
48395
+ var linePivotConfig = init$c({
48520
48396
  dimension: props.lineDimension,
48521
48397
  timeDimension: props.timeDimension
48522
48398
  });
@@ -48807,7 +48683,7 @@ var FunnelChartView = function FunnelChartView(props) {
48807
48683
  if (isLoading(props.result)) return jsx(LoadingComponent, {});
48808
48684
  if (hasFailed(props.result)) return jsx(FailedToLoadDataNotice, {});
48809
48685
  if (isEmpty(props.result)) return jsx(NoResultContentToShowNotice, _extends({}, headerProps));
48810
- var pivotConfig = init$d(props);
48686
+ var pivotConfig = init$c(props);
48811
48687
  var series$1 = series(pivotConfig, props.measure, props.result);
48812
48688
  var resultSet$1 = resultSet(props.result, props.measure, pivotConfig, false, checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
48813
48689
  var showHeadline = headlineAvailable(props.order, props.headline, props.timeDimension);
@@ -51460,7 +51336,7 @@ var DataTable$2 = function DataTable(props) {
51460
51336
  }));
51461
51337
  };
51462
51338
 
51463
- var validate$3 = function validate(component, dataSets, dashboardBehaviour) {
51339
+ var validate$2 = function validate(component, dataSets, dashboardBehaviour) {
51464
51340
  try {
51465
51341
  var dataSet = find(dataSets, component.attributes.dataSetId);
51466
51342
  if (!dataSet) throw new DataSetNotFound(dataSets, component.attributes.dataSetId);
@@ -51986,7 +51862,7 @@ var BarChartV2View = function BarChartV2View(props) {
51986
51862
  var showHeadline = headlineAvailable(props.attributes.order, props.attributes.headline, null);
51987
51863
  var theme = useTheme();
51988
51864
  var BarChartV2Component = getComponentInterface(props.attributes.type);
51989
- var pivotConfig = init$d(props.attributes);
51865
+ var pivotConfig = init$c(props.attributes);
51990
51866
  var numberOfDimensions = props.attributes.dimension.length;
51991
51867
  var chartRepresentation = useMemo(function () {
51992
51868
  if (!isLoading(props.result) && !hasFailed(props.result) && !isEmpty(props.result) && BarChartV2Component.isRunnable(props.attributes)) {
@@ -53042,7 +52918,7 @@ var WaterfallChartView = function WaterfallChartView(props) {
53042
52918
  if (hasFailed(result)) return jsx(FailedToLoadDataNotice, {});
53043
52919
  if (isEmpty(result)) return jsx(NoResultContentToShowNotice, _extends({}, headerProps));
53044
52920
  var showHeadline = headlineAvailable(order, headline, timeDimension);
53045
- var pivotConfig = init$d(props);
52921
+ var pivotConfig = init$c(props);
53046
52922
  var _buildWaterfallChartR = buildWaterfallChartRepresentation({
53047
52923
  approxYAxisLabelCount: approxYAxisLabelCount === 'auto' ? 10 : approxYAxisLabelCount,
53048
52924
  axisTitles: axisTitles,
@@ -53370,7 +53246,7 @@ var AreaChartV2View = function AreaChartV2View(props) {
53370
53246
  var showHeadline = headlineAvailable(props.attributes.order, props.attributes.headline, null);
53371
53247
  var theme = useTheme();
53372
53248
  var AreaChartV2Component = getComponentInterface(props.attributes.type);
53373
- var pivotConfig = init$d(props.attributes);
53249
+ var pivotConfig = init$c(props.attributes);
53374
53250
  console.log(props.attributes, pivotConfig);
53375
53251
  var chartRepresentation = null;
53376
53252
  if (!isLoading(props.result) && !hasFailed(props.result) && !isEmpty(props.result) && AreaChartV2Component.isRunnable(props.attributes)) {
@@ -53868,7 +53744,7 @@ var RadarChartView = function RadarChartView(props) {
53868
53744
  if (hasFailed(result)) return jsx(FailedToLoadDataNotice, {});
53869
53745
  if (isEmpty(result)) return jsx(NoResultContentToShowNotice, _extends({}, headerProps));
53870
53746
  var showHeadline = headlineAvailable(order, headline, timeDimension);
53871
- var pivotConfig = init$d(props);
53747
+ var pivotConfig = init$c(props);
53872
53748
  var chartRepresentation = buildRadarChartRepresentation({
53873
53749
  result: result,
53874
53750
  xAxisFormat: xAxisFormat,
@@ -54305,7 +54181,7 @@ var ComboChartViewV2 = function ComboChartViewV2(props) {
54305
54181
  queryEngineConfig = _useDashboardBehaviou.queryEngineConfig;
54306
54182
  var theme = useTheme();
54307
54183
  var ComboChartComponent = getComponentInterface(props.attributes.type);
54308
- var barPivotConfig = init$d({
54184
+ var barPivotConfig = init$c({
54309
54185
  dimension: props.attributes.barDimension,
54310
54186
  timeDimension: props.attributes.timeDimension
54311
54187
  });
@@ -54369,7 +54245,7 @@ var ComboChartViewV2 = function ComboChartViewV2(props) {
54369
54245
  }
54370
54246
  return null;
54371
54247
  }, [props.barResult, props.attributes, theme == null || (_theme$charts2 = theme.charts) == null ? void 0 : _theme$charts2.colors, valueAlias, textOverride, barPivotConfig, props.numberFormatOptions, props.dateTimeFormatOptions, props.defaultFormats, labelFormat, queryEngineConfig]);
54372
- var linePivotConfig = init$d({
54248
+ var linePivotConfig = init$c({
54373
54249
  dimension: props.attributes.lineDimension,
54374
54250
  timeDimension: props.attributes.timeDimension
54375
54251
  });
@@ -54536,7 +54412,7 @@ var Component = function Component(props) {
54536
54412
  var setPartialAttributes = function setPartialAttributes(changes) {
54537
54413
  return props.updateComponentAttributes(componentInterface.setAttributes(props.component.attributes, changes));
54538
54414
  };
54539
- var validationError = validate$3(props.component, dashboard.dataSets, dashboardBehaviour);
54415
+ var validationError = validate$2(props.component, dashboard.dataSets, dashboardBehaviour);
54540
54416
  if (validationError) {
54541
54417
  if (validationError instanceof DataSetNotFound) {
54542
54418
  return jsx(Empty, {
@@ -55377,7 +55253,7 @@ var PopulatedComponentOptions = function PopulatedComponentOptions(props) {
55377
55253
  var theme = useTheme();
55378
55254
  var dashboardBehaviour = useDashboardBehaviourContext();
55379
55255
  var componentInterface = getComponentInterface(props.component.attributes.type);
55380
- var validationError = validate$3(props.component, dashboard.dataSets, dashboardBehaviour);
55256
+ var validationError = validate$2(props.component, dashboard.dataSets, dashboardBehaviour);
55381
55257
  var dataSet = find(dashboard.dataSets, props.component.attributes.dataSetId);
55382
55258
  var populatedCellOptions = [];
55383
55259
  var isCustomComponent = props.component.attributes.type === 'custom';
@@ -57777,10 +57653,6 @@ function customMetricText(key, textOverride) {
57777
57653
  title: textOverride('custom_metric_title.conditional', 'Conditional'),
57778
57654
  subtext: textOverride('custom_metric_description.conditional', 'Create a conditional field')
57779
57655
  },
57780
- calculatedField: {
57781
- title: textOverride('custom_metric_title.caclulated_field', 'Calculated Field'),
57782
- subtext: textOverride('custom_metric_description.caclulated_field', 'Create a calculated field')
57783
- },
57784
57656
  customBuildMetric: {
57785
57657
  title: textOverride('custom_metric_title.caclulated_field', 'Custom Metric Builder'),
57786
57658
  subtext: textOverride('custom_metric_description.caclulated_field', 'Create a custom build field')
@@ -57810,11 +57682,6 @@ var buildInitOptions = function buildInitOptions(featureToggles, componentType,
57810
57682
  logDebug("Simple math custom field not made available, because it is not supported for the view " + componentInterface.title + ".");
57811
57683
  }
57812
57684
  }
57813
- if (featureToggles.allowCustomBuildField && componentInterface.supportedCustomFields.customBuild) {
57814
- initValues.push(_extends({}, customMetricText('customBuildMetric', textOverride), {
57815
- value: 'customBuildMetric'
57816
- }));
57817
- }
57818
57685
  if (featureToggles.allowRoundedNumberCustomField && componentInterface.supportedCustomFields.roundedNumbers) {
57819
57686
  initValues.push(_extends({}, customMetricText('roundedNumber', textOverride), {
57820
57687
  value: 'roundedNumber'
@@ -57878,16 +57745,16 @@ var buildInitOptions = function buildInitOptions(featureToggles, componentType,
57878
57745
  logDebug("Conditional custom field not made available, because it is not supported for the view " + componentInterface.title + ".");
57879
57746
  }
57880
57747
  }
57881
- if (featureToggles.allowCalculatedField && componentInterface.supportedCustomFields.calculatedField) {
57882
- initValues.push(_extends({}, customMetricText('calculatedField', textOverride), {
57883
- value: 'calculatedField'
57748
+ if (featureToggles.allowCustomBuildField && componentInterface.supportedCustomFields.customBuild) {
57749
+ initValues.push(_extends({}, customMetricText('customBuildMetric', textOverride), {
57750
+ value: 'customBuildMetric'
57884
57751
  }));
57885
57752
  } else {
57886
- if (!featureToggles.allowCalculatedField) {
57887
- logDebug('Calculated custom field not made available, because of a feature toggle.');
57753
+ if (!featureToggles.allowCustomBuildField) {
57754
+ logDebug('Custom metric build field not made available, because of a feature toggle.');
57888
57755
  }
57889
- if (!componentInterface.supportedCustomFields.calculatedField) {
57890
- logDebug("Calculated custom field not made available, because it is not supported for the view " + componentInterface.title + ".");
57756
+ if (!componentInterface.supportedCustomFields.customBuild) {
57757
+ logDebug("Custom metric build field not made available, because it is not supported for the view " + componentInterface.title + ".");
57891
57758
  }
57892
57759
  }
57893
57760
  return initValues;
@@ -57909,7 +57776,6 @@ var ModalType = /*#__PURE__*/function (ModalType) {
57909
57776
  ModalType["ConditionalFormatting"] = "conditionalFormatting";
57910
57777
  ModalType["TrendLines"] = "trendLines";
57911
57778
  ModalType["GoalLines"] = "goalLines";
57912
- ModalType["CalculatedField"] = "calculatedField";
57913
57779
  ModalType["ItemPicker"] = "itemPicker";
57914
57780
  ModalType["CustomMetricBuilder"] = "customMetricBuilder";
57915
57781
  return ModalType;
@@ -58185,9 +58051,6 @@ function getSubtext(customField, textOverride) {
58185
58051
  if (isRoundedNumberField(customField)) {
58186
58052
  return customMetricText('roundedNumber', textOverride).title;
58187
58053
  }
58188
- if (isMetric(customField)) {
58189
- return customMetricText('calculatedField', textOverride).title;
58190
- }
58191
58054
  if (isCustomBuildMetric(customField)) {
58192
58055
  return customMetricText('customBuildMetric', textOverride).title;
58193
58056
  }
@@ -58207,8 +58070,6 @@ var mapCategoryToModalType = function mapCategoryToModalType(category) {
58207
58070
  return ModalType.RoundedNumberCustomMetric;
58208
58071
  case 'dateCalculation':
58209
58072
  return ModalType.DateCalculationCustomMetric;
58210
- case 'calculatedField':
58211
- return ModalType.CalculatedField;
58212
58073
  case 'customBuildMetric':
58213
58074
  return ModalType.CustomMetricBuilder;
58214
58075
  default:
@@ -58241,18 +58102,33 @@ var removeHiddenFieldsFromAttributes = function removeHiddenFieldsFromAttributes
58241
58102
  return [];
58242
58103
  };
58243
58104
 
58244
- /*
58105
+ function metricValuesHaveAggregates(values) {
58106
+ if (!values) {
58107
+ return false;
58108
+ }
58109
+ return values.some(function (value) {
58110
+ if (value.type === PropertyType.Aggregate) {
58111
+ return true;
58112
+ }
58113
+ if ('values' in value) {
58114
+ return metricValuesHaveAggregates(value.values);
58115
+ }
58116
+ return false;
58117
+ });
58118
+ }
58119
+
58120
+ /*
58245
58121
  NOTES
58246
58122
  -----
58247
58123
  - Most important thing is to find out how to remove the limit of 1 timeDimension
58248
58124
  - This is introduced by the timeDimension being an object in attributes, so, we need to move the timeDimension object into the dimension array
58249
58125
  - We also need to prevent timeDimension being replaced onClick
58250
58126
 
58251
- ----
58127
+ ----
58252
58128
  - Both the above issues stem from preSetPartialAttributes and the value of attributes being passed to it
58253
58129
  1. What is actually passed to preSetPartialAttributes?
58254
58130
  - [Answer] the output of getValues, why is this necessary?
58255
- -
58131
+ -
58256
58132
  2. How can we amend the function call to put timeDimension into the dimension array?
58257
58133
  */
58258
58134
 
@@ -58270,7 +58146,6 @@ var FieldCollectorInput = function FieldCollectorInput(inputProps) {
58270
58146
  preventDuplicates = inputProps.preventDuplicates;
58271
58147
  var purpose = fieldFilterOptions != null && fieldFilterOptions.onlyDimensions ? 'grouping' : 'metric';
58272
58148
  var values = getValues(attributes);
58273
- console.log('inputProps', JSON.parse(JSON.stringify(inputProps)), values);
58274
58149
 
58275
58150
  // Allow the list of new values to be formatted before calling setPartialAttributes...
58276
58151
  var onChange = function onChange(values) {
@@ -58381,6 +58256,11 @@ function buildDimensionFromField(purpose, field, queryEngineConfig) {
58381
58256
  field: field.id,
58382
58257
  "function": 'none'
58383
58258
  };
58259
+ } else if (isCustomBuildMetric(field) && (field.metric.type === PropertyType.Aggregate || metricValuesHaveAggregates(field.metric.values))) {
58260
+ newValue = {
58261
+ field: field.id,
58262
+ "function": 'none'
58263
+ };
58384
58264
  } else {
58385
58265
  newValue = {
58386
58266
  field: field.id,
@@ -58405,7 +58285,6 @@ function buildFieldsToPickFrom(dataSet, fieldFilterOptions, preventDuplicates, v
58405
58285
  return initValues;
58406
58286
  }
58407
58287
  function buildFieldCollectorItems(values, dataSet, purpose, queryEngineConfig, _onChange) {
58408
- console.log('buildFieldCollectorItems', values, purpose);
58409
58288
  return [].concat(values).map(function (value, valueIndex) {
58410
58289
  var field = findField(dataSet, value.field);
58411
58290
  var selectOptions = [];
@@ -66151,7 +66030,7 @@ var useSimpleMathModal = function useSimpleMathModal(queryEngineConfig, initialM
66151
66030
  }
66152
66031
  if (state.mathType === 'aggregate') {
66153
66032
  if (state.left && state.right && state.operator) {
66154
- var _buildAggregate = buildAggregate(state),
66033
+ var _buildAggregate = buildAggregate$1(state),
66155
66034
  nestedLeft = _buildAggregate.nestedLeft,
66156
66035
  nestedRight = _buildAggregate.nestedRight,
66157
66036
  leftField = _buildAggregate.leftField,
@@ -66222,7 +66101,7 @@ var extractFields = function extractFields(field) {
66222
66101
  nested: nested
66223
66102
  };
66224
66103
  };
66225
- var buildAggregate = function buildAggregate(args) {
66104
+ var buildAggregate$1 = function buildAggregate(args) {
66226
66105
  var left = args.left,
66227
66106
  right = args.right;
66228
66107
  var _extractFields = extractFields(left),
@@ -67496,7 +67375,7 @@ var useRoundedNumberBuilder = function useRoundedNumberBuilder(initialValue, que
67496
67375
  var onCreateNewRoundedNumber = function onCreateNewRoundedNumber() {
67497
67376
  if (selected && selected.dataSetField) {
67498
67377
  var _selected$dataSetFiel;
67499
- var newCustomField = init$9(metricName, (_selected$dataSetFiel = selected.dataSetField) == null ? void 0 : _selected$dataSetFiel.id, selected.transformationFunctionKey == 'round_to_0_dp' ? 0 : 2, queryEngineConfig);
67378
+ var newCustomField = init$8(metricName, (_selected$dataSetFiel = selected.dataSetField) == null ? void 0 : _selected$dataSetFiel.id, selected.transformationFunctionKey == 'round_to_0_dp' ? 0 : 2, queryEngineConfig);
67500
67379
  onNewCustomField(_extends({}, newCustomField, {
67501
67380
  id: isEditing ? initialValue.id : newCustomField.id
67502
67381
  }));
@@ -68549,13 +68428,23 @@ var CustomMetricVariable = function CustomMetricVariable(_ref) {
68549
68428
  };
68550
68429
 
68551
68430
  var initMetric = function initMetric(selected) {
68552
- if ((selected == null ? void 0 : selected.id) === OperatorType.Add || (selected == null ? void 0 : selected.id) === OperatorType.Divide || (selected == null ? void 0 : selected.id) === OperatorType.Subtract || (selected == null ? void 0 : selected.id) === OperatorType.Multiply) {
68431
+ if (!selected) return;
68432
+ if (selected.id === OperatorType.Add || selected.id === OperatorType.Divide || selected.id === OperatorType.Subtract || selected.id === OperatorType.Multiply) {
68553
68433
  return initOperator(selected.id);
68554
68434
  }
68555
- if ((selected == null ? void 0 : selected.id) === PropertyType.IfLogic) {
68435
+ if (selected.id === PropertyType.IfLogic) {
68556
68436
  return initIfLogic();
68557
68437
  }
68558
- return undefined;
68438
+ if (selected.type === PropertyType.Aggregate) {
68439
+ return initAggregate(selected.id);
68440
+ }
68441
+ if (selected.type === PropertyType.Field) {
68442
+ return initField(selected.id);
68443
+ }
68444
+ if (selected.type === PropertyType.NumberInput) {
68445
+ return initNumberInput();
68446
+ }
68447
+ return;
68559
68448
  };
68560
68449
  var initIfLogic = function initIfLogic() {
68561
68450
  return {
@@ -68574,6 +68463,26 @@ var initOperator = function initOperator(op) {
68574
68463
  values: []
68575
68464
  };
68576
68465
  };
68466
+ var initAggregate = function initAggregate(fieldId) {
68467
+ return {
68468
+ type: PropertyType.Aggregate,
68469
+ fieldId: fieldId,
68470
+ "function": undefined
68471
+ };
68472
+ };
68473
+ var initField = function initField(fieldId) {
68474
+ return {
68475
+ type: PropertyType.Field,
68476
+ fieldId: fieldId,
68477
+ "function": 'none'
68478
+ };
68479
+ };
68480
+ var initNumberInput = function initNumberInput() {
68481
+ return {
68482
+ type: PropertyType.NumberInput,
68483
+ value: undefined
68484
+ };
68485
+ };
68577
68486
 
68578
68487
  function updateOperatorValue(value, index, item) {
68579
68488
  var newValue = _extends({}, value);
@@ -68624,11 +68533,7 @@ function createNewValueFromSelected(selected) {
68624
68533
  "function": 'none'
68625
68534
  };
68626
68535
  case PropertyType.Aggregate:
68627
- return {
68628
- type: PropertyType.Aggregate,
68629
- fieldId: selected.id,
68630
- "function": undefined
68631
- };
68536
+ return initAggregate(selected.id);
68632
68537
  case PropertyType.Operator:
68633
68538
  return initOperator(selected.id);
68634
68539
  case PropertyType.IfLogic:
@@ -68727,7 +68632,7 @@ var _formatFormula = function formatFormula(obj, isNested, textOverride, dataSet
68727
68632
  case PropertyType.Aggregate:
68728
68633
  return findField(dataSet, obj.fieldId).publicName + " " + (obj["function"] ? "(" + obj["function"] + ")" : '');
68729
68634
  case PropertyType.Field:
68730
- return obj.fieldId;
68635
+ return findField(dataSet, obj.fieldId).publicName;
68731
68636
  case PropertyType.Operator:
68732
68637
  {
68733
68638
  var op = obj.op,
@@ -68755,7 +68660,7 @@ var _formatFormula = function formatFormula(obj, isNested, textOverride, dataSet
68755
68660
  var then = c.returns ? "then " + _formatFormula(c.returns, true, textOverride, dataSet) : '';
68756
68661
  if (c.filter.length === 0) return toBeDefined;
68757
68662
  return "if (" + c.filter.map(function (f) {
68758
- return filterCondition(f, c.filter.length > 1, textOverride);
68663
+ return filterCondition(f, c.filter.length > 1, textOverride, dataSet);
68759
68664
  }).join(' || ') + ") " + then;
68760
68665
  }).join(' else ');
68761
68666
  var elsePart = obj["else"] ? " else " + _formatFormula(obj["else"], true, textOverride, dataSet) : '';
@@ -68765,7 +68670,7 @@ var _formatFormula = function formatFormula(obj, isNested, textOverride, dataSet
68765
68670
  return '';
68766
68671
  }
68767
68672
  };
68768
- var filterCondition = function filterCondition(filter, nested, textOverride) {
68673
+ var filterCondition = function filterCondition(filter, nested, textOverride, dataSet) {
68769
68674
  var filterString = filter.map(function (f) {
68770
68675
  var op = f.op,
68771
68676
  value = f.value,
@@ -68777,7 +68682,7 @@ var filterCondition = function filterCondition(filter, nested, textOverride) {
68777
68682
  var duration = defaultDurationOptions(textOverride)[relativeValue.unit].description.toLowerCase();
68778
68683
  var timeframe = defaultTimeframeOptions(textOverride)[relativeValue.timeFrame].description.toLowerCase();
68779
68684
  return textOverride('metric_overview.relative_date', '[[field]] [[op]] [[value]] [[duration]] in [[timeframe]]', {
68780
- field: field,
68685
+ field: findField(dataSet, field).publicName,
68781
68686
  op: op,
68782
68687
  value: (_value$value = value.value) != null ? _value$value : '',
68783
68688
  duration: duration,
@@ -68785,7 +68690,7 @@ var filterCondition = function filterCondition(filter, nested, textOverride) {
68785
68690
  });
68786
68691
  }
68787
68692
  }
68788
- return field + " " + op + " \u201C" + value + "\u201C";
68693
+ return findField(dataSet, field).publicName + " " + op + " \u201C" + value + "\u201C";
68789
68694
  }).join(', ');
68790
68695
  return nested ? "(" + filterString + ")" : filterString;
68791
68696
  };
@@ -68821,34 +68726,8 @@ var code$1 = /*#__PURE__*/styles({
68821
68726
  fontSize: 11
68822
68727
  });
68823
68728
 
68824
- var getUsableItems = function getUsableItems(supportedTypes) {
68825
- var possibleItems = {};
68826
- if (supportedTypes.includes(AcceptedTypes.Maths)) {
68827
- possibleItems = _extends({}, possibleItems, {
68828
- operator: [OperatorType.Add, OperatorType.Divide, OperatorType.Subtract, OperatorType.Multiply]
68829
- });
68830
- }
68831
- if (supportedTypes.includes(AcceptedTypes.IfStatement)) {
68832
- possibleItems = _extends({}, possibleItems, {
68833
- logic: [PropertyType.IfLogic]
68834
- });
68835
- }
68836
- return pickAvailableItems(possibleItems);
68837
- };
68838
- var pickAvailableItems = function pickAvailableItems(selection) {
68839
- return availableItems().map(function (group) {
68840
- return _extends({}, group, {
68841
- things: group.things.filter(function (thing) {
68842
- var _selection$group$id$i, _selection$group$id;
68843
- return (_selection$group$id$i = (_selection$group$id = selection[group.id]) == null ? void 0 : _selection$group$id.includes(thing.id)) != null ? _selection$group$id$i : false;
68844
- })
68845
- });
68846
- }).filter(function (group) {
68847
- return group.things.length > 0;
68848
- });
68849
- };
68850
- var availableItems = function availableItems() {
68851
- return [{
68729
+ var buildOperatorItems = function buildOperatorItems() {
68730
+ return {
68852
68731
  title: 'Operators',
68853
68732
  id: 'operator',
68854
68733
  things: [{
@@ -68884,79 +68763,7 @@ var availableItems = function availableItems() {
68884
68763
  }),
68885
68764
  subtext: 'Returns the product of two or more numbers.'
68886
68765
  }]
68887
- }, {
68888
- title: 'Logic',
68889
- id: 'logic',
68890
- things: [{
68891
- id: PropertyType.IfLogic,
68892
- type: PropertyType.IfLogic,
68893
- title: 'If Statement',
68894
- icon: jsx("svg", {
68895
- version: "1.1",
68896
- id: "Layer_1",
68897
- xmlns: "http://www.w3.org/2000/svg",
68898
- viewBox: "0 0 121.83 122.88",
68899
- children: jsx("g", {
68900
- children: jsx("path", {
68901
- d: "M27.61,34.37l-4.07,4.6l0.4,1.74h10.48c-2.14,12.38-3.74,23.54-6.81,40.74c-3.67,21.94-5.78,27.33-7.03,29.3 c-1.1,1.95-2.68,2.96-4.82,2.96c-2.35,0-6.6-1.86-8.88-3.97c-0.82-0.56-1.79-0.42-2.82,0.26C2,111.74,0,114.42,0,116.82 c-0.12,3.24,4.21,6.06,8.34,6.06c3.64,0,9-2.28,14.64-7.64c7.71-7.31,13.48-17.34,18.3-39.02c3.1-13.84,4.56-22.84,6.74-35.5 l13.02-1.18l2.82-5.17H49.2C52.99,10.53,55.95,7,59.59,7c2.42,0,5.24,1.86,8.48,5.52c0.96,1.32,2.4,1.18,3.5,0.28 c1.85-1.1,4.13-3.92,4.28-6.48C75.96,3.5,72.6,0,66.82,0C61.58,0,53.55,3.5,46.8,10.38c-5.92,6.27-9.02,14.1-11.16,23.99H27.61 L27.61,34.37z M69.27,50.33c4.04-5.38,6.46-7.17,7.71-7.17c1.29,0,2.32,1.27,4.53,8.41l3.78,12.19 c-7.31,11.18-12.66,17.41-15.91,17.41c-1.08,0-2.17-0.34-2.94-1.1c-0.76-0.76-1.6-1.39-2.42-1.39c-2.68,0-6,3.25-6.06,7.28 c-0.06,4.11,2.82,7.05,6.6,7.05c6.49,0,11.98-6.37,22.58-23.26l3.1,10.45c2.66,8.98,5.78,12.81,9.68,12.81 c4.82,0,11.3-4.11,18.37-15.22l-2.96-3.38c-4.25,5.12-7.07,7.52-8.74,7.52c-1.86,0-3.49-2.84-5.64-9.82l-4.53-14.73 c2.68-3.95,5.32-7.27,7.64-9.92c2.76-3.15,4.89-4.49,6.34-4.49c1.22,0,2.28,0.52,2.94,1.25c0.87,0.96,1.39,1.41,2.42,1.41 c2.33,0,5.93-2.96,6.06-6.88c0.12-3.64-2.14-6.74-6.06-6.74c-5.92,0-11.14,5.1-21.19,20.04l-2.07-6.41 c-2.9-9-4.82-13.63-8.86-13.63c-4.7,0-11.16,5.78-17.48,14.94L69.27,50.33L69.27,50.33z"
68902
- })
68903
- })
68904
- }),
68905
- subtext: 'Returns the first value if the condition is true; otherwise, returns the second value.'
68906
- }, {
68907
- id: PropertyType.NumberInput,
68908
- type: PropertyType.NumberInput,
68909
- title: 'Number',
68910
- icon: jsx("svg", {
68911
- version: "1.1",
68912
- id: "Layer_1",
68913
- viewBox: "0 0 122.88 102.06",
68914
- children: jsx("g", {
68915
- children: jsx("path", {
68916
- d: "M8.18,23.12h67.09v5.39H8.18c-0.77,0-1.47,0.31-1.98,0.82c-0.5,0.51-0.82,1.21-0.82,1.98v39.46c0,0.77,0.31,1.47,0.82,1.98 c0.51,0.5,1.21,0.82,1.98,0.82h67.09v5.39H8.18c-2.24,0-4.29-0.92-5.77-2.4L2.4,76.53C0.92,75.05,0,73.01,0,70.76V31.3 c0-2.24,0.92-4.29,2.4-5.77l0.01-0.01C3.89,24.04,5.94,23.12,8.18,23.12L8.18,23.12z M71.77,53.85c-1.52,0-2.75-1.23-2.75-2.75 c0-1.52,1.23-2.75,2.75-2.75h12.78V18.04c-0.39-3.8-1.56-6.62-3.34-8.6c-1.93-2.16-4.67-3.43-7.99-3.98 c-1.49-0.24-2.51-1.65-2.26-3.15c0.24-1.49,1.65-2.51,3.15-2.26c4.54,0.75,8.37,2.57,11.19,5.74c0.72,0.8,1.37,1.69,1.94,2.66 c0.72-1.25,1.58-2.35,2.56-3.32c2.94-2.92,6.88-4.51,11.59-5.1c1.51-0.18,2.88,0.89,3.06,2.4c0.18,1.51-0.89,2.88-2.4,3.06 c-3.52,0.44-6.38,1.54-8.39,3.53c-1.99,1.97-3.25,4.91-3.61,9.04v5.07h24.65c2.24,0,4.29,0.92,5.77,2.4l0.01,0.01 c1.48,1.48,2.4,3.53,2.4,5.77v39.46c0,2.24-0.92,4.29-2.4,5.77l-0.01,0.01c-1.48,1.48-3.53,2.4-5.77,2.4H90.05v5.07 c0.36,4.13,1.62,7.08,3.61,9.04c2,1.98,4.86,3.09,8.39,3.53c1.51,0.18,2.58,1.56,2.4,3.06c-0.18,1.51-1.55,2.58-3.06,2.4 c-4.7-0.59-8.65-2.18-11.59-5.1c-0.98-0.97-1.84-2.07-2.56-3.32c-0.57,0.97-1.22,1.85-1.94,2.66c-2.83,3.16-6.66,4.99-11.19,5.74 c-1.49,0.24-2.9-0.77-3.15-2.26c-0.24-1.49,0.77-2.9,2.26-3.15c3.32-0.55,6.06-1.81,7.99-3.98c1.78-1.99,2.94-4.81,3.34-8.6 l0-30.17H71.77L71.77,53.85L71.77,53.85z M90.05,28.5v19.84h12.98c1.52,0,2.75,1.23,2.75,2.75c0,1.52-1.23,2.75-2.75,2.75H90.05 v19.71h24.65c0.77,0,1.47-0.31,1.98-0.82c0.5-0.51,0.82-1.21,0.82-1.98V31.3c0-0.77-0.31-1.47-0.82-1.98 c-0.51-0.5-1.21-0.82-1.98-0.82H90.05L90.05,28.5z"
68917
- })
68918
- })
68919
- }),
68920
- subtext: 'Assign a static number'
68921
- }]
68922
- }];
68923
- };
68924
-
68925
- var CustomMetricAggregate = function CustomMetricAggregate(props) {
68926
- var dashboardBehaviour = useDashboardBehaviourContext();
68927
- var numberFieldsOptions = {
68928
- onlyFieldTypes: ['number'],
68929
- removePercentage: true,
68930
- removeSimpleMaths: true,
68931
- removeAggregateMaths: true,
68932
- removeDateCalculations: true,
68933
- removeConditional: true,
68934
- removeCustomBuildMetric: true
68935
68766
  };
68936
- return jsx(MeasuresInput, {
68937
- id: props.id,
68938
- testId: props.id,
68939
- componentType: props.componentType,
68940
- maxAllowed: 1,
68941
- allowsMultiple: false,
68942
- setPartialAttributes: function setPartialAttributes(_ref) {
68943
- var measure = _ref.measure;
68944
- return props.onChange(_extends({}, props.measure, {
68945
- fieldId: measure.field,
68946
- "function": measure["function"]
68947
- }));
68948
- },
68949
- supportedAggregates: dashboardBehaviour.queryEngineConfig.supportedAggregates,
68950
- attributes: {
68951
- measure: {
68952
- field: props.measure.fieldId,
68953
- "function": props.measure["function"] || undefined
68954
- }
68955
- },
68956
- dataSet: props.dataSet,
68957
- fieldFilterOptions: numberFieldsOptions,
68958
- onDeleteItem: props.onDeleteItem
68959
- });
68960
68767
  };
68961
68768
 
68962
68769
  var buildAggregateItems = function buildAggregateItems(dataSet) {
@@ -68988,6 +68795,51 @@ var buildAggregateItems = function buildAggregateItems(dataSet) {
68988
68795
  };
68989
68796
  };
68990
68797
 
68798
+ var buildLogicItems = function buildLogicItems(onlyNumber) {
68799
+ if (onlyNumber === void 0) {
68800
+ onlyNumber = false;
68801
+ }
68802
+ var ifLogicThings = {
68803
+ id: PropertyType.IfLogic,
68804
+ type: PropertyType.IfLogic,
68805
+ title: 'If Statement',
68806
+ icon: jsx("svg", {
68807
+ version: "1.1",
68808
+ id: "Layer_1",
68809
+ xmlns: "http://www.w3.org/2000/svg",
68810
+ viewBox: "0 0 121.83 122.88",
68811
+ children: jsx("g", {
68812
+ children: jsx("path", {
68813
+ d: "M27.61,34.37l-4.07,4.6l0.4,1.74h10.48c-2.14,12.38-3.74,23.54-6.81,40.74c-3.67,21.94-5.78,27.33-7.03,29.3 c-1.1,1.95-2.68,2.96-4.82,2.96c-2.35,0-6.6-1.86-8.88-3.97c-0.82-0.56-1.79-0.42-2.82,0.26C2,111.74,0,114.42,0,116.82 c-0.12,3.24,4.21,6.06,8.34,6.06c3.64,0,9-2.28,14.64-7.64c7.71-7.31,13.48-17.34,18.3-39.02c3.1-13.84,4.56-22.84,6.74-35.5 l13.02-1.18l2.82-5.17H49.2C52.99,10.53,55.95,7,59.59,7c2.42,0,5.24,1.86,8.48,5.52c0.96,1.32,2.4,1.18,3.5,0.28 c1.85-1.1,4.13-3.92,4.28-6.48C75.96,3.5,72.6,0,66.82,0C61.58,0,53.55,3.5,46.8,10.38c-5.92,6.27-9.02,14.1-11.16,23.99H27.61 L27.61,34.37z M69.27,50.33c4.04-5.38,6.46-7.17,7.71-7.17c1.29,0,2.32,1.27,4.53,8.41l3.78,12.19 c-7.31,11.18-12.66,17.41-15.91,17.41c-1.08,0-2.17-0.34-2.94-1.1c-0.76-0.76-1.6-1.39-2.42-1.39c-2.68,0-6,3.25-6.06,7.28 c-0.06,4.11,2.82,7.05,6.6,7.05c6.49,0,11.98-6.37,22.58-23.26l3.1,10.45c2.66,8.98,5.78,12.81,9.68,12.81 c4.82,0,11.3-4.11,18.37-15.22l-2.96-3.38c-4.25,5.12-7.07,7.52-8.74,7.52c-1.86,0-3.49-2.84-5.64-9.82l-4.53-14.73 c2.68-3.95,5.32-7.27,7.64-9.92c2.76-3.15,4.89-4.49,6.34-4.49c1.22,0,2.28,0.52,2.94,1.25c0.87,0.96,1.39,1.41,2.42,1.41 c2.33,0,5.93-2.96,6.06-6.88c0.12-3.64-2.14-6.74-6.06-6.74c-5.92,0-11.14,5.1-21.19,20.04l-2.07-6.41 c-2.9-9-4.82-13.63-8.86-13.63c-4.7,0-11.16,5.78-17.48,14.94L69.27,50.33L69.27,50.33z"
68814
+ })
68815
+ })
68816
+ }),
68817
+ subtext: 'Returns the first value if the condition is true; otherwise, returns the second value.'
68818
+ };
68819
+ var numberInputThings = {
68820
+ id: PropertyType.NumberInput,
68821
+ type: PropertyType.NumberInput,
68822
+ title: 'Number',
68823
+ icon: jsx("svg", {
68824
+ version: "1.1",
68825
+ id: "Layer_1",
68826
+ viewBox: "0 0 122.88 102.06",
68827
+ children: jsx("g", {
68828
+ children: jsx("path", {
68829
+ d: "M8.18,23.12h67.09v5.39H8.18c-0.77,0-1.47,0.31-1.98,0.82c-0.5,0.51-0.82,1.21-0.82,1.98v39.46c0,0.77,0.31,1.47,0.82,1.98 c0.51,0.5,1.21,0.82,1.98,0.82h67.09v5.39H8.18c-2.24,0-4.29-0.92-5.77-2.4L2.4,76.53C0.92,75.05,0,73.01,0,70.76V31.3 c0-2.24,0.92-4.29,2.4-5.77l0.01-0.01C3.89,24.04,5.94,23.12,8.18,23.12L8.18,23.12z M71.77,53.85c-1.52,0-2.75-1.23-2.75-2.75 c0-1.52,1.23-2.75,2.75-2.75h12.78V18.04c-0.39-3.8-1.56-6.62-3.34-8.6c-1.93-2.16-4.67-3.43-7.99-3.98 c-1.49-0.24-2.51-1.65-2.26-3.15c0.24-1.49,1.65-2.51,3.15-2.26c4.54,0.75,8.37,2.57,11.19,5.74c0.72,0.8,1.37,1.69,1.94,2.66 c0.72-1.25,1.58-2.35,2.56-3.32c2.94-2.92,6.88-4.51,11.59-5.1c1.51-0.18,2.88,0.89,3.06,2.4c0.18,1.51-0.89,2.88-2.4,3.06 c-3.52,0.44-6.38,1.54-8.39,3.53c-1.99,1.97-3.25,4.91-3.61,9.04v5.07h24.65c2.24,0,4.29,0.92,5.77,2.4l0.01,0.01 c1.48,1.48,2.4,3.53,2.4,5.77v39.46c0,2.24-0.92,4.29-2.4,5.77l-0.01,0.01c-1.48,1.48-3.53,2.4-5.77,2.4H90.05v5.07 c0.36,4.13,1.62,7.08,3.61,9.04c2,1.98,4.86,3.09,8.39,3.53c1.51,0.18,2.58,1.56,2.4,3.06c-0.18,1.51-1.55,2.58-3.06,2.4 c-4.7-0.59-8.65-2.18-11.59-5.1c-0.98-0.97-1.84-2.07-2.56-3.32c-0.57,0.97-1.22,1.85-1.94,2.66c-2.83,3.16-6.66,4.99-11.19,5.74 c-1.49,0.24-2.9-0.77-3.15-2.26c-0.24-1.49,0.77-2.9,2.26-3.15c3.32-0.55,6.06-1.81,7.99-3.98c1.78-1.99,2.94-4.81,3.34-8.6 l0-30.17H71.77L71.77,53.85L71.77,53.85z M90.05,28.5v19.84h12.98c1.52,0,2.75,1.23,2.75,2.75c0,1.52-1.23,2.75-2.75,2.75H90.05 v19.71h24.65c0.77,0,1.47-0.31,1.98-0.82c0.5-0.51,0.82-1.21,0.82-1.98V31.3c0-0.77-0.31-1.47-0.82-1.98 c-0.51-0.5-1.21-0.82-1.98-0.82H90.05L90.05,28.5z"
68830
+ })
68831
+ })
68832
+ }),
68833
+ subtext: 'Assign a static number'
68834
+ };
68835
+ var things = onlyNumber ? [numberInputThings] : [ifLogicThings, numberInputThings];
68836
+ return {
68837
+ title: 'Logic',
68838
+ id: 'logic',
68839
+ things: things
68840
+ };
68841
+ };
68842
+
68991
68843
  var buildFieldItems = function buildFieldItems(dataSet) {
68992
68844
  var numberFieldsOptions = {
68993
68845
  onlyFieldTypes: ['number'],
@@ -69016,55 +68868,93 @@ var buildFieldItems = function buildFieldItems(dataSet) {
69016
68868
  };
69017
68869
  };
69018
68870
 
68871
+ var getInitialUsableItems = function getInitialUsableItems(supportedTypes, dataSet) {
68872
+ var possibleItems = [];
68873
+ possibleItems.push(getUsableMathItems(supportedTypes));
68874
+ possibleItems.push(getUsableAggregateItems(supportedTypes, dataSet));
68875
+ possibleItems.push(getUsableFieldItems(dataSet));
68876
+ possibleItems.push(getUsableLogicItems(supportedTypes));
68877
+ return possibleItems.filter(function (item) {
68878
+ return item !== undefined;
68879
+ });
68880
+ };
68881
+ var getUsableMathItems = function getUsableMathItems(supportedTypes) {
68882
+ if (supportedTypes.includes(AcceptedTypes.Maths)) {
68883
+ return buildOperatorItems();
68884
+ }
68885
+ return undefined;
68886
+ };
68887
+ var getUsableAggregateItems = function getUsableAggregateItems(supportedTypes, dataSet) {
68888
+ if (supportedTypes.includes(AcceptedTypes.Aggregates)) {
68889
+ return buildAggregateItems(dataSet);
68890
+ }
68891
+ return undefined;
68892
+ };
68893
+ var getUsableFieldItems = function getUsableFieldItems(dataSet) {
68894
+ return buildFieldItems(dataSet);
68895
+ };
68896
+ var getUsableLogicItems = function getUsableLogicItems(supportedTypes) {
68897
+ if (supportedTypes.includes(AcceptedTypes.IfStatement)) {
68898
+ return buildLogicItems();
68899
+ }
68900
+ return undefined;
68901
+ };
68902
+
68903
+ var CustomMetricAggregate = function CustomMetricAggregate(props) {
68904
+ var dashboardBehaviour = useDashboardBehaviourContext();
68905
+ var numberFieldsOptions = {
68906
+ onlyFieldTypes: ['number'],
68907
+ removePercentage: true,
68908
+ removeSimpleMaths: true,
68909
+ removeAggregateMaths: true,
68910
+ removeDateCalculations: true,
68911
+ removeConditional: true,
68912
+ removeCustomBuildMetric: true
68913
+ };
68914
+ return jsx(MeasuresInput, {
68915
+ id: props.id,
68916
+ testId: props.id,
68917
+ componentType: props.componentType,
68918
+ maxAllowed: 1,
68919
+ allowsMultiple: false,
68920
+ setPartialAttributes: function setPartialAttributes(_ref) {
68921
+ var measure = _ref.measure;
68922
+ return props.onChange(_extends({}, props.measure, {
68923
+ fieldId: measure.field,
68924
+ "function": measure["function"]
68925
+ }));
68926
+ },
68927
+ supportedAggregates: dashboardBehaviour.queryEngineConfig.supportedAggregates,
68928
+ attributes: {
68929
+ measure: {
68930
+ field: props.measure.fieldId,
68931
+ "function": props.measure["function"] || undefined
68932
+ }
68933
+ },
68934
+ dataSet: props.dataSet,
68935
+ fieldFilterOptions: numberFieldsOptions,
68936
+ onDeleteItem: props.onDeleteItem
68937
+ });
68938
+ };
68939
+
69019
68940
  function buildFieldsAndAggregates(value, dataSet, supportedTypes, parentHasAggregate, parentHasField) {
69020
68941
  var isOperator = value.type === PropertyType.Operator;
69021
- var isIfLogic = value.type === PropertyType.IfLogic;
69022
68942
  var hasAggregate = isOperator && value.values.some(function (v) {
69023
68943
  return v.type === PropertyType.Aggregate;
69024
68944
  });
69025
68945
  var hasField = isOperator && value.values.some(function (v) {
69026
68946
  return v.type === PropertyType.Field;
69027
68947
  });
69028
- var hasAggregateCase = isIfLogic && value.cases.some(function (c) {
69029
- var _c$returns;
69030
- return ((_c$returns = c.returns) == null ? void 0 : _c$returns.type) === 'aggregate';
69031
- });
69032
- var hasFieldCase = isIfLogic && value.cases.some(function (c) {
69033
- var _c$returns2;
69034
- return ((_c$returns2 = c.returns) == null ? void 0 : _c$returns2.type) === 'field';
69035
- });
69036
- var hasNoReturns = isIfLogic && value.cases.every(function (c) {
69037
- return !c.returns;
69038
- });
69039
68948
  var updatedItems = [];
69040
- var updatedParentHasAggregate = parentHasAggregate != null ? parentHasAggregate : false;
69041
- var updatedParentHasField = parentHasField != null ? parentHasField : false;
69042
- if (hasAggregate && supportedTypes.includes(AcceptedTypes.Aggregates)) {
69043
- updatedParentHasAggregate = true;
69044
- }
69045
- if (hasField) {
69046
- updatedParentHasField = true;
69047
- }
69048
- if (isOperator) {
69049
- if (!updatedParentHasField && supportedTypes.includes(AcceptedTypes.Aggregates)) {
69050
- updatedItems.push(buildAggregateItems(dataSet));
69051
- }
69052
- if (!updatedParentHasAggregate) updatedItems.push(buildFieldItems(dataSet));
68949
+ var updatedParentHasAggregate = parentHasAggregate != null ? parentHasAggregate : hasAggregate && supportedTypes.includes(AcceptedTypes.Aggregates);
68950
+ var updatedParentHasField = parentHasField != null ? parentHasField : hasField;
68951
+ if (isOperator && !updatedParentHasField && supportedTypes.includes(AcceptedTypes.Aggregates)) {
68952
+ updatedItems.push(buildAggregateItems(dataSet));
69053
68953
  }
69054
- if (isIfLogic) {
69055
- if (!updatedParentHasField && hasAggregateCase && supportedTypes.includes(AcceptedTypes.Aggregates)) {
69056
- updatedItems.push(buildAggregateItems(dataSet));
69057
- }
69058
- if (!updatedParentHasAggregate && hasFieldCase) {
69059
- updatedItems.push(buildFieldItems(dataSet));
69060
- }
69061
- if (hasNoReturns) {
69062
- if (supportedTypes.includes(AcceptedTypes.Aggregates)) {
69063
- updatedItems.push(buildAggregateItems(dataSet));
69064
- }
69065
- updatedItems.push(buildFieldItems(dataSet));
69066
- }
68954
+ if (!updatedParentHasAggregate) {
68955
+ updatedItems.push(buildFieldItems(dataSet));
69067
68956
  }
68957
+ updatedItems.push(buildLogicItems(true));
69068
68958
  return {
69069
68959
  updatedItems: updatedItems,
69070
68960
  updatedParentHasAggregate: updatedParentHasAggregate,
@@ -69159,7 +69049,6 @@ var _RecursiveMetric = function RecursiveMetric(_ref) {
69159
69049
  index = _ref.index,
69160
69050
  onDeleteItem = _ref.onDeleteItem,
69161
69051
  parentIsIfLogic = _ref.parentIsIfLogic,
69162
- isEditing = _ref.isEditing,
69163
69052
  parentHasAggregate = _ref.parentHasAggregate,
69164
69053
  parentHasField = _ref.parentHasField,
69165
69054
  supportedTypes = _ref.supportedTypes;
@@ -69207,10 +69096,8 @@ var _RecursiveMetric = function RecursiveMetric(_ref) {
69207
69096
  id: level + "-" + index + "-field"
69208
69097
  });
69209
69098
  }
69210
- var items = [].concat(pickAvailableItems({
69211
- operator: [OperatorType.Add, OperatorType.Divide, OperatorType.Subtract, OperatorType.Multiply],
69212
- logic: [PropertyType.NumberInput]
69213
- }));
69099
+ var usableMathItems = getUsableMathItems(supportedTypes);
69100
+ var items = usableMathItems ? [usableMathItems] : [];
69214
69101
  if (!parentIsIfLogic) {
69215
69102
  var _buildFieldsAndAggreg = buildFieldsAndAggregates(value, dataSet, supportedTypes, parentHasAggregate, parentHasField),
69216
69103
  updatedItems = _buildFieldsAndAggreg.updatedItems,
@@ -69219,6 +69106,9 @@ var _RecursiveMetric = function RecursiveMetric(_ref) {
69219
69106
  items.push.apply(items, updatedItems);
69220
69107
  parentHasAggregate = updatedParentHasAggregate;
69221
69108
  parentHasField = updatedParentHasField;
69109
+ } else {
69110
+ items.push(buildFieldItems(dataSet));
69111
+ items.push(buildLogicItems(true));
69222
69112
  }
69223
69113
  if (variables != null && variables.variables) {
69224
69114
  var builtVariables = buildVariableItems(variables.variables, 'numbers');
@@ -69229,12 +69119,11 @@ var _RecursiveMetric = function RecursiveMetric(_ref) {
69229
69119
  if (value.type === PropertyType.IfLogic) {
69230
69120
  parentIsIfLogic = true;
69231
69121
  }
69232
- var enableRemove = isEditing ? false : true;
69233
69122
  return jsxs("div", {
69234
69123
  className: styles({
69235
69124
  position: 'relative'
69236
69125
  }),
69237
- children: [enableRemove && jsx(DeleteAction, {
69126
+ children: [jsx(DeleteAction, {
69238
69127
  id: level + "-block-" + index,
69239
69128
  onDeleteItem: onDeleteItem,
69240
69129
  label: textOverride('remove', 'Remove') + " level " + (level + 1) + " " + value.type
@@ -69431,6 +69320,28 @@ var CustomMetric = function CustomMetric(props) {
69431
69320
  var deleteMetric = function deleteMetric() {
69432
69321
  updateMetric(undefined);
69433
69322
  };
69323
+ var _hasAggregate = function hasAggregate(value) {
69324
+ if (value.type === PropertyType.Aggregate) {
69325
+ return true;
69326
+ }
69327
+ if (value.type === PropertyType.Operator) {
69328
+ return value.values.some(function (v) {
69329
+ return _hasAggregate(v);
69330
+ });
69331
+ }
69332
+ return false;
69333
+ };
69334
+ var _hasField = function hasField(value) {
69335
+ if (value.type === PropertyType.Field) {
69336
+ return true;
69337
+ }
69338
+ if (value.type === PropertyType.Operator) {
69339
+ return value.values.some(function (v) {
69340
+ return _hasField(v);
69341
+ });
69342
+ }
69343
+ return false;
69344
+ };
69434
69345
  return jsx(Fragment, {
69435
69346
  children: jsxs("div", {
69436
69347
  children: [state.wipCustomMetric && jsx(_RecursiveMetric, {
@@ -69442,10 +69353,11 @@ var CustomMetric = function CustomMetric(props) {
69442
69353
  },
69443
69354
  index: 0,
69444
69355
  onDeleteItem: deleteMetric,
69445
- isEditing: props.isEditing,
69446
- supportedTypes: props.supportedTypes
69356
+ supportedTypes: props.supportedTypes,
69357
+ parentHasAggregate: _hasAggregate(state.wipCustomMetric),
69358
+ parentHasField: _hasField(state.wipCustomMetric)
69447
69359
  }), !state.wipCustomMetric && jsx(AddItem, {
69448
- items: getUsableItems(props.supportedTypes),
69360
+ items: getInitialUsableItems(props.supportedTypes, props.dataSet),
69449
69361
  onSelect: initialiseMetric
69450
69362
  }), jsx(View, {
69451
69363
  marginTop: 20,
@@ -69508,14 +69420,14 @@ var CustomMetricModal = function CustomMetricModal(props) {
69508
69420
  var componentInterface = getComponentInterface(props.componentType);
69509
69421
  var state = useCustomMetric(props.queryEngineConfig, props.initialValue || undefined, props.onNewCustomField);
69510
69422
  var _onChange = state.onChange;
69511
- if (componentInterface.supportedCustomFields.calculatedField === false) return null;
69423
+ if (componentInterface.supportedCustomFields.customBuild === false) return null;
69512
69424
  return jsxs(Modal, {
69513
69425
  width: "4xl",
69514
69426
  isOpen: props.show,
69515
69427
  onClose: props.onClose,
69516
69428
  disableDnD: true,
69517
69429
  children: [jsx(Modal.Header, {
69518
- title: "Calculated Field"
69430
+ title: "Custom Metric Builder"
69519
69431
  }), jsxs(Modal.Content, {
69520
69432
  children: [jsx(PanelProperty, {
69521
69433
  children: jsx(Input, {
@@ -69539,7 +69451,7 @@ var CustomMetricModal = function CustomMetricModal(props) {
69539
69451
  });
69540
69452
  },
69541
69453
  isEditing: state.isEditing,
69542
- supportedTypes: componentInterface.supportedCustomFields.calculatedField
69454
+ supportedTypes: componentInterface.supportedCustomFields.customBuild
69543
69455
  })
69544
69456
  })]
69545
69457
  }), jsx(Modal.Footer, {
@@ -69552,6 +69464,7 @@ var CustomMetricModal = function CustomMetricModal(props) {
69552
69464
  secondary: true,
69553
69465
  children: textOverride('cancel', 'Cancel')
69554
69466
  }), jsx(Button, {
69467
+ testId: state.isEditing ? 'update-custom-metric-builder' : 'create-custom-metric-builder',
69555
69468
  onClick: function onClick() {
69556
69469
  return state.handleUpsert();
69557
69470
  },
@@ -69703,117 +69616,6 @@ var ItemPicker = function ItemPicker(props) {
69703
69616
  });
69704
69617
  };
69705
69618
 
69706
- var emptyConditional$1 = {
69707
- publicName: '',
69708
- metric: undefined
69709
- };
69710
- var useCustomMetricBuilderModal = function useCustomMetricBuilderModal(queryEngineConfig, customField, onUpdateField) {
69711
- var isEditing = !!customField;
69712
- var _useState = useState(emptyConditional$1),
69713
- state = _useState[0],
69714
- setState = _useState[1];
69715
- useEffect(function () {
69716
- if (customField) {
69717
- setState({
69718
- publicName: customField.publicName,
69719
- metric: customField.metricAtrributes
69720
- });
69721
- } else {
69722
- setState(emptyConditional$1);
69723
- }
69724
- }, [JSON.stringify(customField)]);
69725
- var handleUpsertField = function handleUpsertField() {
69726
- if (state.metric) {
69727
- var _customField$id;
69728
- var newCustomField = init$8(state.publicName, state.metric, queryEngineConfig);
69729
- onUpdateField(_extends({}, newCustomField, {
69730
- id: (_customField$id = customField == null ? void 0 : customField.id) != null ? _customField$id : newCustomField.id
69731
- }));
69732
- }
69733
- };
69734
- useEffect(function () {
69735
- return logDebug(state.metric);
69736
- }, [JSON.stringify(state.metric)]);
69737
- var onChange = function onChange(partial) {
69738
- setState(_extends({}, state, partial));
69739
- };
69740
- return {
69741
- state: state,
69742
- handleUpsertField: handleUpsertField,
69743
- onChange: onChange,
69744
- isEditing: isEditing,
69745
- isValid: validate$2(queryEngineConfig, state.metric).isValid && state.publicName.length > 0
69746
- };
69747
- };
69748
-
69749
- var CustomMetricBuilderModal = function CustomMetricBuilderModal(props) {
69750
- var dataSet = props.dataSet;
69751
- var _useDashboardBehaviou = useDashboardBehaviourContext(),
69752
- textOverride = _useDashboardBehaviou.textOverride,
69753
- queryEngineConfig = _useDashboardBehaviou.queryEngineConfig;
69754
- var _useCustomMetricBuild = useCustomMetricBuilderModal(queryEngineConfig, props.initialValue, props.onNewCustomField),
69755
- handleUpsertField = _useCustomMetricBuild.handleUpsertField,
69756
- state = _useCustomMetricBuild.state,
69757
- _onChange = _useCustomMetricBuild.onChange,
69758
- isEditing = _useCustomMetricBuild.isEditing,
69759
- isValid = _useCustomMetricBuild.isValid;
69760
- var supportedTypes = function () {
69761
- var supportedLogicTypes = getComponentInterface(props.componentType).supportedCustomFields.customBuild;
69762
- if (typeof supportedLogicTypes !== 'boolean') return supportedLogicTypes;
69763
- return undefined;
69764
- }();
69765
- return jsxs(Modal, {
69766
- width: "4xl",
69767
- isOpen: props.show,
69768
- onClose: props.onClose,
69769
- disableDnD: true,
69770
- children: [jsx(Modal.Header, {
69771
- title: customMetricText('customBuildMetric', textOverride).title
69772
- }), jsxs(Modal.Content, {
69773
- children: [jsx(PanelProperty, {
69774
- children: jsx(Input, {
69775
- id: "custom-metric-name",
69776
- placeholder: textOverride('metric_name', 'Metric name'),
69777
- label: textOverride('metric_name', 'Metric name'),
69778
- value: state.publicName,
69779
- onChange: function onChange(event) {
69780
- return _onChange({
69781
- publicName: event.target.value
69782
- });
69783
- }
69784
- })
69785
- }), supportedTypes && jsx(CustomMetric, {
69786
- dataSet: dataSet,
69787
- metric: state.metric,
69788
- onChange: function onChange(metric) {
69789
- return _onChange({
69790
- metric: metric
69791
- });
69792
- },
69793
- supportedTypes: supportedTypes
69794
- }, isEditing + "-" + state.publicName)]
69795
- }), jsx(Modal.Footer, {
69796
- buttons: "end",
69797
- children: jsxs(ButtonGroup, {
69798
- children: [jsx(Button$2, {
69799
- onClick: function onClick() {
69800
- return props.onClose();
69801
- },
69802
- secondary: true,
69803
- children: textOverride('cancel', 'Cancel')
69804
- }), jsx(Button$2, {
69805
- onClick: function onClick() {
69806
- return handleUpsertField();
69807
- },
69808
- disabled: !isValid,
69809
- testId: (isEditing ? 'update' : 'create') + "-custom-metric-builder",
69810
- children: isEditing ? textOverride('update', 'Update') : textOverride('create', 'Create')
69811
- })]
69812
- })
69813
- })]
69814
- });
69815
- };
69816
-
69817
69619
  var ModalToShow = /*#__PURE__*/function (ModalToShow) {
69818
69620
  ModalToShow[ModalToShow["Neither"] = 0] = "Neither";
69819
69621
  ModalToShow[ModalToShow["Library"] = 1] = "Library";
@@ -69887,13 +69689,11 @@ var ModalRouting = function ModalRouting() {
69887
69689
  }), modalType);
69888
69690
  case ModalType.ConditionalCustomMetric:
69889
69691
  return jsx(ConditionalModal, _extends({}, attributes), modalType);
69890
- case ModalType.CustomMetricBuilder:
69891
- return jsx(CustomMetricBuilderModal, _extends({}, attributes), modalType);
69892
69692
  case ModalType.PercentageCustomMetric:
69893
69693
  return jsx(PercentageModal, _extends({}, attributes), modalType);
69894
69694
  case ModalType.MathCustomMetric:
69895
69695
  return jsx(MathModal, _extends({}, attributes), modalType);
69896
- case ModalType.CalculatedField:
69696
+ case ModalType.CustomMetricBuilder:
69897
69697
  return jsx(CustomMetricModal, _extends({}, attributes), modalType);
69898
69698
  case ModalType.RulesCustomMetric:
69899
69699
  return jsx(RulesModal, _extends({}, attributes), modalType);
@@ -70590,7 +70390,7 @@ var fromToken = function fromToken(token) {
70590
70390
  });
70591
70391
  };
70592
70392
 
70593
- var init$e = function init(dashboardSessionToken, dataAccessToken, queryEngineAccessToken, dashboardAdminOverrideToken) {
70393
+ var init$d = function init(dashboardSessionToken, dataAccessToken, queryEngineAccessToken, dashboardAdminOverrideToken) {
70594
70394
  var dashboardAccessContent = fromToken(dashboardSessionToken);
70595
70395
  if (!('scope' in dashboardAccessContent)) {
70596
70396
  dashboardAccessContent.scope = 'read_write';
@@ -70656,7 +70456,7 @@ var fetchIdentityConfig = /*#__PURE__*/function () {
70656
70456
  throw new FailedToLoadIdentity('Failed to fetch identity config.');
70657
70457
  case 6:
70658
70458
  dashboardAdminOverride = isClientSide() ? getDashboardAdminOverride(window.location.href) : null;
70659
- identityConfig = init$e(tokens.dashboardAccessToken, tokens.dataAccessToken, tokens.queryEngineAccessToken, dashboardAdminOverride);
70459
+ identityConfig = init$d(tokens.dashboardAccessToken, tokens.dataAccessToken, tokens.queryEngineAccessToken, dashboardAdminOverride);
70660
70460
  return _context.abrupt("return", {
70661
70461
  identityConfig: identityConfig,
70662
70462
  tokens: tokens
@@ -71283,7 +71083,7 @@ var Header = /*#__PURE__*/function () {
71283
71083
  function Header(title) {
71284
71084
  /** The header component. */
71285
71085
  this.component = undefined;
71286
- var newHeader = init$b('New Header');
71086
+ var newHeader = init$a('New Header');
71287
71087
  if (title) {
71288
71088
  newHeader = _extends({}, newHeader, {
71289
71089
  displayTitle: title
@@ -71993,7 +71793,7 @@ function getOptionsOrders(dataSetField) {
71993
71793
  }
71994
71794
 
71995
71795
  var commonToQueries = function commonToQueries(attributes, dataSet, queryEngineConfig, params) {
71996
- var _Query$build = build$b(dataSet, attributes.measure, attributes.order, attributes.dimension,
71796
+ var _Query$build = build$a(dataSet, attributes.measure, attributes.order, attributes.dimension,
71997
71797
  // @ts-ignore
71998
71798
  attributes.timeDimension || null, attributes.limit, attributes.offset, queryEngineConfig, params),
71999
71799
  query = _Query$build.query,
@@ -72018,8 +71818,8 @@ var toQueries$6 = commonToQueries;
72018
71818
  var toQueries$7 = commonToQueries;
72019
71819
 
72020
71820
  var buildMainQueries = function buildMainQueries(attributes, dataSet, queryEngineConfig, params) {
72021
- var line = build$b(dataSet, attributes.lineMeasure, attributes.order, attributes.lineDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
72022
- var bar = build$b(dataSet, attributes.barMeasure, attributes.order, attributes.barDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71821
+ var line = build$a(dataSet, attributes.lineMeasure, attributes.order, attributes.lineDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71822
+ var bar = build$a(dataSet, attributes.barMeasure, attributes.order, attributes.barDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
72023
71823
  return {
72024
71824
  bar: bar,
72025
71825
  line: line
@@ -72046,8 +71846,8 @@ var toQueries$b = commonToQueries;
72046
71846
  var toQueries$c = commonToQueries;
72047
71847
 
72048
71848
  var buildMainQueries$1 = function buildMainQueries(attributes, dataSet, queryEngineConfig, params) {
72049
- var line = build$b(dataSet, attributes.lineMeasure, attributes.order, attributes.lineDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
72050
- var bar = build$b(dataSet, attributes.barMeasure, attributes.order, attributes.barDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71849
+ var line = build$a(dataSet, attributes.lineMeasure, attributes.order, attributes.lineDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71850
+ var bar = build$a(dataSet, attributes.barMeasure, attributes.order, attributes.barDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
72051
71851
  return {
72052
71852
  bar: bar,
72053
71853
  line: line
@@ -72066,7 +71866,7 @@ var toQueries$d = function toQueries(attributes, dataSet, queryEngineConfig, par
72066
71866
  };
72067
71867
 
72068
71868
  var buildMainQuery = function buildMainQuery(attributes, dataSet, queryEngineConfig, params) {
72069
- var _Query$build = build$b(dataSet, attributes.measure, [], [], null, 1, attributes.offset, queryEngineConfig, params),
71869
+ var _Query$build = build$a(dataSet, attributes.measure, [], [], null, 1, attributes.offset, queryEngineConfig, params),
72070
71870
  query = _Query$build.query,
72071
71871
  measureDescription = _Query$build.measureDescription;
72072
71872
 
@@ -72094,7 +71894,7 @@ var buildMainQuery = function buildMainQuery(attributes, dataSet, queryEngineCon
72094
71894
  };
72095
71895
  var buildDeltaQuery = function buildDeltaQuery(dataSet, attributes, queryEngineConfig, params) {
72096
71896
  if (!attributes.deltaTimeDimension) return null;
72097
- return build$b(dataSet, attributes.measure, [{
71897
+ return build$a(dataSet, attributes.measure, [{
72098
71898
  field: attributes.deltaTimeDimension.field,
72099
71899
  direction: 'asc',
72100
71900
  "function": attributes.deltaTimeDimension.truncate
@@ -72126,7 +71926,7 @@ var toQueries$f = function toQueries(attributes, dataSet, queryEngineConfig, par
72126
71926
  var measures = [];
72127
71927
  attributes.xMeasure && measures.push(attributes.xMeasure);
72128
71928
  attributes.yMeasure && measures.push(attributes.yMeasure);
72129
- var _Query$build = build$b(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
71929
+ var _Query$build = build$a(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
72130
71930
  query = _Query$build.query,
72131
71931
  measureDescription = _Query$build.measureDescription;
72132
71932
  var resultFields = toResultFields([measureDescription], queryEngineConfig);
@@ -72140,7 +71940,7 @@ var toQueries$g = function toQueries(attributes, dataSet, queryEngineConfig, par
72140
71940
  var measures = [];
72141
71941
  attributes.xMeasure && measures.push(attributes.xMeasure);
72142
71942
  attributes.yMeasure && measures.push(attributes.yMeasure);
72143
- var _Query$build = build$b(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
71943
+ var _Query$build = build$a(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
72144
71944
  query = _Query$build.query,
72145
71945
  measureDescription = _Query$build.measureDescription;
72146
71946
  var resultFields = toResultFields([measureDescription], queryEngineConfig);
@@ -72152,7 +71952,7 @@ var toQueries$g = function toQueries(attributes, dataSet, queryEngineConfig, par
72152
71952
 
72153
71953
  var toQueries$h = function toQueries(attributes, dataSet, queryEngineConfig, params) {
72154
71954
  var measures = [].concat(attributes.measure || [], attributes.xMeasure || [], attributes.zMeasure || []);
72155
- var _Query$build = build$b(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
71955
+ var _Query$build = build$a(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
72156
71956
  query = _Query$build.query,
72157
71957
  measureDescription = _Query$build.measureDescription;
72158
71958
  var resultFields = toResultFields([measureDescription], queryEngineConfig);
@@ -73530,7 +73330,7 @@ var VizzlyServices = /*#__PURE__*/function () {
73530
73330
  }
73531
73331
  return undefined;
73532
73332
  }();
73533
- runQueriesCallback = getRunQueriesCallback(service.identityConfig, service.queryEngineConfig, build$d(defaultText, params == null ? void 0 : params.dateFilterOptions), (params == null ? void 0 : params.variables) || {}, params == null ? void 0 : params.runQueries, params == null ? void 0 : params.data, queryEngineEndpoint);
73333
+ runQueriesCallback = getRunQueriesCallback(service.identityConfig, service.queryEngineConfig, build$c(defaultText, params == null ? void 0 : params.dateFilterOptions), (params == null ? void 0 : params.variables) || {}, params == null ? void 0 : params.runQueries, params == null ? void 0 : params.data, queryEngineEndpoint);
73534
73334
  fetch = /*#__PURE__*/function () {
73535
73335
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
73536
73336
  var _params$abortControll;
@@ -76479,7 +76279,7 @@ var GlobalProviderContents = function GlobalProviderContents(props) {
76479
76279
  }
76480
76280
  };
76481
76281
  var resolvedDateFilterOptions = (_props$dateFilterOpti = props.dateFilterOptions) != null ? _props$dateFilterOpti : props.dateTimeFilterOptions;
76482
- var runQueriesCallback = getRunQueriesCallback(session.identityConfig, session.queryEngineConfig, build$d(textOverride, resolvedDateFilterOptions), variables.variables, props.runQueries, props.data, props.queryEngineEndpoint, props.timeZone);
76282
+ var runQueriesCallback = getRunQueriesCallback(session.identityConfig, session.queryEngineConfig, build$c(textOverride, resolvedDateFilterOptions), variables.variables, props.runQueries, props.data, props.queryEngineEndpoint, props.timeZone);
76483
76283
  var aiOnAction = /*#__PURE__*/function () {
76484
76284
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(conversationId, messageId, actionOptions) {
76485
76285
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {