@vizzly/dashboard 0.14.4-dev-7cba24e151ef9b87b5980bb4d617335aa42d5fc5 → 0.14.4-dev-62d05e92c038ece2db481a3184d969602622fcc5

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
@@ -2187,6 +2187,20 @@ var build$7 = function build(measureAttribute, customField) {
2187
2187
  }
2188
2188
  };
2189
2189
 
2190
+ var init$7 = function init(publicName, metric, queryEngineConfig) {
2191
+ return {
2192
+ id: generateId(),
2193
+ publicName: publicName,
2194
+ metric: metric,
2195
+ dataType: 'number',
2196
+ canBeDimension: false,
2197
+ canBeMeasure: true,
2198
+ allowedOperators: validOperatorsForField({
2199
+ dataType: 'number'
2200
+ }, queryEngineConfig)
2201
+ };
2202
+ };
2203
+
2190
2204
  var PropertyType = /*#__PURE__*/function (PropertyType) {
2191
2205
  PropertyType["Operator"] = "operator";
2192
2206
  PropertyType["IfLogic"] = "ifLogic";
@@ -2204,41 +2218,20 @@ var OperatorType = /*#__PURE__*/function (OperatorType) {
2204
2218
  return OperatorType;
2205
2219
  }({});
2206
2220
 
2207
- var buildOperator = function buildOperator(operator, dataSet, params, measureAttribute) {
2208
- var _operator$values = operator.values,
2209
- firstMetric = _operator$values[0],
2210
- secondMetric = _operator$values[1],
2211
- restMetrics = _operator$values.slice(2);
2212
- var left = buildMetric(firstMetric, dataSet, params);
2213
- var right = buildMetric(secondMetric, dataSet, params);
2214
- if (restMetrics.length > 0) {
2215
- right = restMetrics.reduce(function (acc, currMetric) {
2216
- return {
2217
- type: 'maths',
2218
- op: operator.op,
2219
- left: acc,
2220
- right: buildMetric(currMetric, dataSet, params)
2221
- };
2222
- }, right);
2221
+ var build$8 = function build(measureAttribute, customField, dataSet, queryEngineConfig, params) {
2222
+ if (customField.metric.type === PropertyType.IfLogic) {
2223
+ return buildIfLogic(customField.metric, dataSet, fromFilterConfig(params.filterConfig, dataSet, params.timeRangeOptions), queryEngineConfig, params, measureAttribute);
2223
2224
  }
2224
- if (measureAttribute && measureAttribute["function"] != 'none') {
2225
- return {
2226
- type: 'function',
2227
- "function": measureAttribute["function"],
2228
- value: {
2229
- type: 'maths',
2230
- op: operator.op,
2231
- left: left,
2232
- right: right
2233
- }
2234
- };
2225
+ if (customField.metric.type === PropertyType.Aggregate) {
2226
+ return buildAggregate(customField.metric);
2235
2227
  }
2236
- return {
2237
- type: 'maths',
2238
- op: operator.op,
2239
- left: left,
2240
- right: right
2241
- };
2228
+ if (customField.metric.type === PropertyType.Field) {
2229
+ return buildField(customField.metric, measureAttribute);
2230
+ }
2231
+ if (customField.metric.type === PropertyType.NumberInput) {
2232
+ return buildNumber(customField.metric);
2233
+ }
2234
+ return buildOperator(customField.metric, dataSet, params, measureAttribute, false);
2242
2235
  };
2243
2236
  var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilters, queryEngineConfig, params, measureAttribute) {
2244
2237
  var alwaysTrueFilter = [[{
@@ -2254,7 +2247,7 @@ var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilt
2254
2247
  var _params$filterConfig$, _params$filterConfig;
2255
2248
  var customMetricFilter = combineForCustomMetricFilters(addAndFilters((_params$filterConfig$ = params == null || (_params$filterConfig = params.filterConfig) == null ? void 0 : _params$filterConfig.advancedFilter) != null ? _params$filterConfig$ : [], localAndDashboardFilters), c.filter);
2256
2249
  return {
2257
- returns: buildMetric(c.returns, dataSet, params),
2250
+ returns: buildMetric(c.returns, dataSet, params, measureAttribute),
2258
2251
  filter: filterAttributeToQueryFilter(customMetricFilter, queryEngineConfig, dataSet, params)
2259
2252
  };
2260
2253
  });
@@ -2262,11 +2255,11 @@ var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilt
2262
2255
  returns: {
2263
2256
  type: 'null'
2264
2257
  },
2265
- filter: alwaysTrueFilter
2258
+ filter: alwaysTrueFilter // Do not remove
2266
2259
  }]);
2267
2260
  var elseCase = {
2268
- returns: buildMetric(ifLogic["else"], dataSet, params),
2269
- filter: alwaysTrueFilter
2261
+ returns: buildMetric(ifLogic["else"], dataSet, params, measureAttribute),
2262
+ filter: alwaysTrueFilter // Do not remove
2270
2263
  };
2271
2264
  return [].concat(thenCases, [elseCase]);
2272
2265
  }();
@@ -2275,7 +2268,7 @@ var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilt
2275
2268
  }
2276
2269
  return {
2277
2270
  type: 'function',
2278
- "function": measureAttribute == null ? void 0 : measureAttribute["function"],
2271
+ "function": measureAttribute["function"],
2279
2272
  value: {
2280
2273
  type: 'switchField',
2281
2274
  value: {
@@ -2284,7 +2277,56 @@ var buildIfLogic = function buildIfLogic(ifLogic, dataSet, localAndDashboardFilt
2284
2277
  }
2285
2278
  };
2286
2279
  };
2287
- var buildMetric = function buildMetric(metric, dataSet, params) {
2280
+ var buildAggregate = function buildAggregate(aggregate) {
2281
+ var _aggregate$function;
2282
+ return {
2283
+ type: 'field',
2284
+ value: aggregate.fieldId,
2285
+ "function": (_aggregate$function = aggregate["function"]) != null ? _aggregate$function : ''
2286
+ };
2287
+ };
2288
+ var buildOperator = function buildOperator(operator, dataSet, params, measureAttribute, internal) {
2289
+ var _operator$values = operator.values,
2290
+ firstMetric = _operator$values[0],
2291
+ secondMetric = _operator$values[1],
2292
+ restMetrics = _operator$values.slice(2);
2293
+ var left = buildMetric(firstMetric, dataSet, params, measureAttribute);
2294
+ var right = buildMetric(secondMetric, dataSet, params, measureAttribute);
2295
+ if (restMetrics.length > 0) {
2296
+ right = restMetrics.reduce(function (acc, currMetric) {
2297
+ return {
2298
+ type: 'maths',
2299
+ op: operator.op,
2300
+ left: acc,
2301
+ right: buildMetric(currMetric, dataSet, params, measureAttribute)
2302
+ };
2303
+ }, right);
2304
+ }
2305
+ if (!internal) {
2306
+ var hasFieldValue = operator.values.some(function (value) {
2307
+ return value.type === PropertyType.Field;
2308
+ });
2309
+ if (hasFieldValue) {
2310
+ return {
2311
+ type: 'function',
2312
+ "function": measureAttribute["function"],
2313
+ value: {
2314
+ type: 'maths',
2315
+ op: operator.op,
2316
+ left: left,
2317
+ right: right
2318
+ }
2319
+ };
2320
+ }
2321
+ }
2322
+ return {
2323
+ type: 'maths',
2324
+ op: operator.op,
2325
+ left: left,
2326
+ right: right
2327
+ };
2328
+ };
2329
+ var buildMetric = function buildMetric(metric, dataSet, params, measureAttribute) {
2288
2330
  if (!metric) {
2289
2331
  throw new Error('Invalid metric: undefined metric received');
2290
2332
  }
@@ -2294,9 +2336,11 @@ var buildMetric = function buildMetric(metric, dataSet, params) {
2294
2336
  case PropertyType.Variable:
2295
2337
  return buildVariable(metric, params.variables);
2296
2338
  case PropertyType.Operator:
2297
- return buildOperator(metric, dataSet, params);
2339
+ return buildOperator(metric, dataSet, params, measureAttribute, true);
2298
2340
  case PropertyType.Field:
2299
2341
  return buildField(metric);
2342
+ case PropertyType.Aggregate:
2343
+ return buildAggregate(metric);
2300
2344
  default:
2301
2345
  throw new Error("Unsupported metric type: " + metric.type);
2302
2346
  }
@@ -2326,350 +2370,39 @@ var buildNumber = function buildNumber(numberInput) {
2326
2370
  value: valueAsNumber
2327
2371
  };
2328
2372
  };
2329
- var buildField = function buildField(field) {
2373
+ var buildField = function buildField(field, measureAttribute) {
2330
2374
  return {
2331
2375
  type: 'field',
2332
2376
  value: field.fieldId,
2333
- "function": 'none'
2377
+ "function": measureAttribute ? measureAttribute["function"] : 'none'
2334
2378
  };
2335
2379
  };
2336
2380
 
2337
- var init$7 = function init(publicName, metric, queryEngineConfig) {
2338
- return {
2339
- id: generateId(),
2340
- publicName: publicName,
2341
- metric: metric,
2342
- dataType: 'number',
2343
- canBeDimension: false,
2344
- canBeMeasure: true,
2345
- allowedOperators: validOperatorsForField({
2346
- dataType: 'number'
2347
- }, queryEngineConfig)
2348
- };
2349
- };
2350
- var build$8 = function build(measureAttribute, customField, dataSet, queryEngineConfig, params) {
2351
- if (customField.metric.type === PropertyType.IfLogic) {
2352
- return buildIfLogic(customField.metric, dataSet, fromFilterConfig(params.filterConfig, dataSet, params.timeRangeOptions), queryEngineConfig, params, measureAttribute);
2353
- }
2354
- return buildOperator(customField.metric, dataSet, params, measureAttribute);
2355
- };
2356
2381
  var validate$1 = function validate(field) {
2357
2382
  if (field.publicName.length === 0) return false;
2358
- if (field.publicName === undefined) return false;
2359
- if (field.metric === undefined) return false;
2360
- if (field.metric.type === undefined) return false;
2383
+ if (!field.metric) return false;
2361
2384
  if (field.metric.type === PropertyType.Operator && 'values' in field.metric && field.metric.values.length === 0) return false;
2362
2385
  if (field.metric.type === PropertyType.IfLogic && 'cases' in field.metric && field.metric.cases.length === 0) return false;
2363
- return true;
2364
- };
2365
-
2366
- var tagSchema = function tagSchema() {
2367
- return Joi.object({
2368
- key: Joi.string().required()
2369
- });
2370
- };
2371
- var tagsSchema = function tagsSchema() {
2372
- return Joi.array().items(tagSchema()).min(0);
2373
- };
2374
-
2375
- var measureSchema = function measureSchema(supportedAggregates, attributeSchemaOptions) {
2376
- var buildMeasureJoi = function buildMeasureJoi(fieldJoi, functionJoi) {
2377
- return Joi.object({
2378
- field: fieldJoi.required(),
2379
- "function": functionJoi.required().description('Which if any, aggregate function should be applied to the field?')
2380
- });
2381
- };
2382
-
2383
- // Return an enum using the restriction fields
2384
- if (attributeSchemaOptions != null && attributeSchemaOptions.restrictFields) {
2385
- return Joi.alternatives.apply(Joi, attributeSchemaOptions.restrictFields.filter(function (f) {
2386
- return f.canBeMeasure;
2387
- }).map(function (restrictedField) {
2388
- var _Joi$string;
2389
- var supportedFunctionsForField = listValidFunctionsForDataType(restrictedField, supportedAggregates);
2390
- return buildMeasureJoi(Joi.string().valid(restrictedField.id).description(restrictedField.publicName + ", " + (restrictedField.description || '') + "."), (_Joi$string = Joi.string()).valid.apply(_Joi$string, supportedFunctionsForField.concat(['none'])));
2391
- }));
2386
+ if (field.metric.type === PropertyType.Aggregate && (!field.metric["function"] || field.metric["function"] === 'none')) return false;
2387
+ if (field.metric.type === PropertyType.NumberInput && field.metric.value === undefined) return false;
2388
+ if ('values' in field.metric) {
2389
+ return !_hasAggregatesWithEmptyFunctions(field.metric.values);
2392
2390
  }
2393
- 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'])));
2394
- };
2395
- var orderSchema = function orderSchema(queryEngineConfig) {
2396
- var _Joi$string2;
2397
- return Joi.object({
2398
- field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2399
- direction: Joi.string().valid('asc', 'desc').required().description('In which direction should the results be ordered?'),
2400
- "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?')
2401
- });
2402
- };
2403
- var timeDimensionSchema = function timeDimensionSchema(supportedTimeTruncFunctions) {
2404
- return Joi.object({
2405
- field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2406
- truncate: Joi.valid.apply(Joi, Object.keys(supportedTimeTruncFunctions).concat(['none'])),
2407
- bucketFill: Joi["boolean"]()
2408
- });
2409
- };
2410
- var dimensionSchema = function dimensionSchema(supportedTimeTruncFunctions, attributeSchemaOptions) {
2411
- var buildDimensionJoi = function buildDimensionJoi(fieldJoi, isDate) {
2412
- return Joi.object({
2413
- field: fieldJoi.required(),
2414
- pivot: Joi.string().valid('x', 'y').optional(),
2415
- "function": isDate ? Joi.valid.apply(Joi, Object.keys(supportedTimeTruncFunctions).concat(['none'])).required() : Joi.valid('none').required()
2416
- });
2417
- };
2418
-
2419
- // Return an enum using the restriction fields
2420
- if (attributeSchemaOptions != null && attributeSchemaOptions.restrictFields) {
2421
- return Joi.array().items(Joi.alternatives.apply(Joi, attributeSchemaOptions.restrictFields.filter(function (f) {
2422
- return f.canBeDimension;
2423
- }).map(function (restrictedField) {
2424
- return buildDimensionJoi(Joi.string().valid(restrictedField.id).description(restrictedField.publicName + ", " + (restrictedField.description || '') + "."), restrictedField.dataType === 'date_time');
2425
- }))).description('Fields to group the data by');
2426
- }
2427
- 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');
2428
- };
2429
- var filterSchema = function filterSchema(queryEngineConfig) {
2430
- var _Joi$string3, _Joi$string4;
2431
- return Joi.object({
2432
- field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2433
- op: (_Joi$string3 = Joi.string()).valid.apply(_Joi$string3, Object.keys(queryEngineConfig.supportedOperators)).required(),
2434
- 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(),
2435
- "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?')
2436
- });
2437
- };
2438
- var queryAttributesFilter = function queryAttributesFilter(queryEngineConfig) {
2439
- return Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig)));
2440
- };
2441
- var queryAttributesLimit = function queryAttributesLimit() {
2442
- return Joi.number().description('Limit the number of results returned after the query has been ran.');
2443
- };
2444
- var baseAttributesSchema = function baseAttributesSchema(attributeSchemaOptions) {
2445
- var _Joi$string5;
2446
- var dataSetIdSchema = attributeSchemaOptions != null && attributeSchemaOptions.restrictDataSetIds ? (_Joi$string5 = Joi.string()).valid.apply(_Joi$string5, attributeSchemaOptions.restrictDataSetIds) : Joi.string();
2447
- return {
2448
- viewId: Joi.string().allow('').optional().description('__vizzly_hide_from_docs'),
2449
- displayTitle: Joi.string().allow('').description('A title that explains what is being displayed.'),
2450
- displaySubject: Joi.string().allow('').description('A chance to add a more detailed description of what is being shown.'),
2451
- dataSetId: dataSetIdSchema.description('The ID of the data set that is being used by the view.'),
2452
- protectedByOrganisation: Joi["boolean"]().optional().description('Has the view been created by your organisation, and therefore cannot be modified by your users?')
2453
- };
2454
- };
2455
- var approxAxisLabelCountSchema = /*#__PURE__*/Joi.valid('auto', 2, 0).description('Determine how many axis labels should be shown on the axis');
2456
- var querySchema = function querySchema(queryEngineConfig, attributeSchemaOptions) {
2457
- return {
2458
- 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.'),
2459
- dimension: dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions).required(),
2460
- order: Joi.array().items(orderSchema(queryEngineConfig)),
2461
- limit: queryAttributesLimit(),
2462
- offset: Joi.number().min(0).description('Paginate results by using this property with limit.')
2463
- };
2464
- };
2465
- var timeDimensionQuerySchema = function timeDimensionQuerySchema(queryEngineConfig, attributeSchemaOptions) {
2466
- return _extends({}, querySchema(queryEngineConfig, attributeSchemaOptions), {
2467
- filter: Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig))),
2468
- timeDimension: Joi.alternatives(timeDimensionSchema(queryEngineConfig.supportedTimeTruncFunctions), Joi.valid(null)).required(),
2469
- drilldown: Joi.alternatives(dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions).required(), Joi.string()),
2470
- xAxisPrefix: Joi.string().allow('').description('Add a prefix to the X Axis'),
2471
- yAxisPrefix: Joi.string().allow('').description('Add a prefix to the Y Axis'),
2472
- xAxisPostfix: Joi.string().allow('').description('Add a postfix to the X Axis'),
2473
- yAxisPostfix: Joi.string().allow('').description('Add a postfix to the Y Axis'),
2474
- yAxisFormat: Joi.alternatives(Joi.string(), Joi.valid(null)).description('ID of the formatting function to apply to the Y Axis values'),
2475
- xAxisFormat: Joi.alternatives(Joi.string(), Joi.valid(null)).description('ID of the formatting function to apply to the X Axis values'),
2476
- approxYAxisLabelCount: approxAxisLabelCountSchema,
2477
- approxXAxisLabelCount: approxAxisLabelCountSchema
2478
- });
2479
- };
2480
- var lineCurveSchema = /*#__PURE__*/Joi.string().valid('natural', 'straight', 'step', 'stepBefore', 'stepAfter', 'dotted');
2481
- var areaCurveSchema = /*#__PURE__*/Joi.string().valid('natural', 'straight', 'step');
2482
- var protectedFieldsMeasure = function protectedFieldsMeasure(queryEngineConfig) {
2483
- var _Joi$string6;
2484
- return Joi.array().items(Joi.object({
2485
- "function": (_Joi$string6 = Joi.string()).valid.apply(_Joi$string6, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])),
2486
- field: Joi.string().required().description('The ID of the field from the data set to reference.')
2487
- }));
2488
- };
2489
- var protectedFieldsDimension = function protectedFieldsDimension(queryEngineConfig) {
2490
- var _Joi$string7;
2491
- return Joi.array().items(Joi.object({
2492
- "function": (_Joi$string7 = Joi.string()).valid.apply(_Joi$string7, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])),
2493
- truncate: Joi.string(),
2494
- field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2495
- bucketFill: Joi["boolean"]().optional(),
2496
- pivot: Joi.string().valid('x', 'y').optional()
2497
- }));
2498
- };
2499
- var parameterGroupSchema = function parameterGroupSchema(queryEngineConfig, attributeSchemaOptions) {
2500
- return Joi.object().pattern(Joi.string(), Joi.alternatives()["try"](Joi.array().items(timeDimensionSchema(queryEngineConfig.supportedTimeTruncFunctions)).min(1), dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions))).unknown(true);
2501
- };
2502
- var parameterMeasureSchema = function parameterMeasureSchema(queryEngineConfig, attributeSchemaOptions) {
2503
- return Joi.object().pattern(Joi.string(), Joi.array().items(measureSchema(queryEngineConfig.supportedAggregates, attributeSchemaOptions)).min(1)).unknown(true);
2504
- };
2505
- var parametersSchema = function parametersSchema(queryEngineConfig, attributeSchemaOptions) {
2506
- return Joi.object({
2507
- measure: parameterMeasureSchema(queryEngineConfig, attributeSchemaOptions),
2508
- group: parameterGroupSchema(queryEngineConfig, attributeSchemaOptions)
2509
- });
2510
- };
2511
- var goalLineValueSchema = /*#__PURE__*/Joi.alternatives()["try"]( /*#__PURE__*/Joi.number().required(), /*#__PURE__*/Joi.string().pattern(/^\{\{.*\}\}$/).required());
2512
- var goalLineSchema = function goalLineSchema() {
2513
- return Joi.object({
2514
- color: Joi.string().required(),
2515
- value: goalLineValueSchema,
2516
- strokeWidth: Joi.number().required(),
2517
- strokeStyle: Joi.string().valid('dashed', 'solid').required(),
2518
- label: Joi["boolean"]().optional()
2519
- });
2520
- };
2521
- var goalLinesSchema = function goalLinesSchema() {
2522
- return Joi.array().items(goalLineSchema());
2523
- };
2524
- var headlineSchema = function headlineSchema() {
2525
- return Joi.object({
2526
- func: Joi.string().valid('mean', 'sum', 'current').allow(null).optional()
2527
- });
2528
- };
2529
- var axisTitleSchema = function axisTitleSchema() {
2530
- return Joi.object({
2531
- x: Joi.string().allow(''),
2532
- y: Joi.string().allow('')
2533
- });
2391
+ return true;
2534
2392
  };
2535
- var sizingSchema = /*#__PURE__*/Joi.object().pattern( /*#__PURE__*/Joi.string(), /*#__PURE__*/Joi.object({
2536
- width: /*#__PURE__*/Joi.number().min(0),
2537
- height: /*#__PURE__*/Joi.number().min(0)
2538
- }));
2539
- var joiDate = /*#__PURE__*/Joi.custom(function (value, helpers) {
2540
- if (Object.prototype.toString.call(value) === '[object Date]') {
2541
- return value;
2542
- }
2543
- return helpers.error('any.invalid');
2544
- }, 'Date object validation');
2545
-
2546
- // Aggregate schema
2547
- var aggregateSchema = /*#__PURE__*/Joi.object({
2548
- type: /*#__PURE__*/Joi.string().valid('aggregate').required(),
2549
- fieldId: /*#__PURE__*/Joi.string().required(),
2550
- "function": /*#__PURE__*/Joi.string().required()
2551
- });
2552
-
2553
- // Field schema
2554
- var fieldSchema = /*#__PURE__*/Joi.object({
2555
- type: /*#__PURE__*/Joi.string().valid('field').required(),
2556
- fieldId: /*#__PURE__*/Joi.string().required(),
2557
- "function": /*#__PURE__*/Joi.string().valid('none').required()
2558
- });
2559
-
2560
- // Variable schema
2561
- var variableSchema = /*#__PURE__*/Joi.object({
2562
- type: /*#__PURE__*/Joi.string().valid('variable').required(),
2563
- value: /*#__PURE__*/Joi.string().required()
2564
- });
2565
-
2566
- // Number schema
2567
- var numberSchema = /*#__PURE__*/Joi.object({
2568
- type: /*#__PURE__*/Joi.string().valid('number').required(),
2569
- value: /*#__PURE__*/Joi.number().required()
2570
- });
2571
-
2572
- // Recursive operator schema (prevents empty values)
2573
- var operatorSchema = /*#__PURE__*/Joi.object({
2574
- type: Joi.string().valid('operator').required(),
2575
- op: Joi.string().valid('+', '-', '*', '/').required(),
2576
- values: Joi.array().items(Joi.when('type', {
2577
- is: 'operator',
2578
- then: Joi.link('#operatorSchema'),
2579
- otherwise: Joi.alternatives()["try"](aggregateSchema, fieldSchema, variableSchema, numberSchema)
2580
- })).min(2).custom(function (values, helpers) {
2581
- var hasAggregate = values.some(function (v) {
2582
- return v.type === 'aggregate';
2583
- });
2584
- var hasField = values.some(function (v) {
2585
- return v.type === 'field';
2586
- });
2587
- var hasEmptyOperator = values.some(function (v) {
2588
- return v.type === 'operator' && (!v.values || v.values.length === 0);
2589
- });
2590
- if (hasAggregate && hasField) {
2591
- return helpers.error('any.invalid', {
2592
- message: 'Field type cannot be mixed with Aggregate type in the same array'
2593
- });
2393
+ var _hasAggregatesWithEmptyFunctions = function hasAggregatesWithEmptyFunctions(values) {
2394
+ return values.some(function (value) {
2395
+ if (value.type === PropertyType.Aggregate) {
2396
+ return !value["function"] || value["function"] === 'none';
2594
2397
  }
2595
- if (hasEmptyOperator) {
2596
- return helpers.error('any.invalid', {
2597
- message: 'Nested operators must have at least two values'
2598
- });
2398
+ if ('values' in value) {
2399
+ return _hasAggregatesWithEmptyFunctions(value.values);
2599
2400
  }
2600
- return values;
2601
- })
2602
- }).meta({
2603
- id: 'operatorSchema'
2604
- });
2605
- var ifLogicSchema = function ifLogicSchema(queryEngineConfig) {
2606
- return Joi.object({
2607
- type: Joi.string().valid('ifLogic').required(),
2608
- cases: Joi.array().items(Joi.object({
2609
- filter: Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig)).min(1)).min(1).required(),
2610
- returns: Joi.alternatives()["try"](fieldSchema, variableSchema, numberSchema, aggregateSchema, operatorSchema).required()
2611
- })).min(1).required(),
2612
- "else": Joi.alternatives()["try"](fieldSchema, variableSchema, numberSchema, aggregateSchema, operatorSchema).optional()
2401
+ return false;
2613
2402
  });
2614
2403
  };
2615
2404
 
2616
- var validate$2 = function validate(queryEngineConfig, metric) {
2617
- if (!metric) return {
2618
- isValid: false
2619
- };
2620
- var schema = null;
2621
-
2622
- // Determine which schema to use based on the metric type
2623
- if (metric.type === 'operator') {
2624
- schema = operatorSchema;
2625
- } else if (metric.type === 'ifLogic') {
2626
- schema = ifLogicSchema(queryEngineConfig);
2627
- } else {
2628
- return {
2629
- isValid: false,
2630
- errors: ['Unsupported metric type']
2631
- };
2632
- }
2633
-
2634
- // Perform validation
2635
- var _schema$validate = schema.validate(metric, {
2636
- abortEarly: false
2637
- }),
2638
- error = _schema$validate.error;
2639
- if (error) {
2640
- return {
2641
- isValid: false,
2642
- errors: error.details.map(function (detail) {
2643
- return detail.message;
2644
- })
2645
- };
2646
- }
2647
- return {
2648
- isValid: true
2649
- };
2650
- };
2651
-
2652
- var init$8 = function init(publicName, metric, queryEngineConfig) {
2653
- return {
2654
- id: generateId(),
2655
- publicName: publicName,
2656
- metricAtrributes: metric,
2657
- canBeDimension: false,
2658
- canBeMeasure: true,
2659
- allowedOperators: validOperatorsForField({
2660
- dataType: 'number'
2661
- }, queryEngineConfig),
2662
- dataType: 'number'
2663
- };
2664
- };
2665
- var build$9 = function build() {
2666
- return {
2667
- type: 'number',
2668
- value: 0
2669
- };
2670
- };
2671
-
2672
- var init$9 = function init(publicName, fieldId, roundToDecimalPlaces, queryEngineConfig) {
2405
+ var init$8 = function init(publicName, fieldId, roundToDecimalPlaces, queryEngineConfig) {
2673
2406
  return {
2674
2407
  id: generateId(),
2675
2408
  publicName: publicName,
@@ -2683,7 +2416,7 @@ var init$9 = function init(publicName, fieldId, roundToDecimalPlaces, queryEngin
2683
2416
  }, queryEngineConfig)
2684
2417
  };
2685
2418
  };
2686
- var build$a = function build(measureAttribute, customField) {
2419
+ var build$9 = function build(measureAttribute, customField) {
2687
2420
  var builtRoundedNumber = {
2688
2421
  type: 'field',
2689
2422
  "function": "round_to_" + customField.roundToDecimalPlaces + "_dp",
@@ -2715,11 +2448,8 @@ var isRules = function isRules(field) {
2715
2448
  var isConditional = function isConditional(field) {
2716
2449
  return 'rule' in field;
2717
2450
  };
2718
- var isMetric = function isMetric(field) {
2719
- return 'metric' in field;
2720
- };
2721
2451
  var isCustomBuildMetric = function isCustomBuildMetric(field) {
2722
- return 'metricAtrributes' in field;
2452
+ return 'metric' in field;
2723
2453
  };
2724
2454
  var isDateCalculation = function isDateCalculation(field) {
2725
2455
  return 'dateCalculationFunction' in field;
@@ -2732,12 +2462,11 @@ var getCustomFieldCategory = function getCustomFieldCategory(field) {
2732
2462
  if (isRoundedNumberField(field)) return 'roundedNumber';
2733
2463
  if (isDateCalculation(field)) return 'dateCalculation';
2734
2464
  if (isConditional(field)) return 'conditional';
2735
- if (isMetric(field)) return 'calculatedField';
2736
2465
  if (isCustomBuildMetric(field)) return 'customBuildMetric';
2737
2466
  throw "Unrecognised custom field type for custom field; " + JSON.stringify(field);
2738
2467
  };
2739
2468
  var isCustomField = function isCustomField(field) {
2740
- return isPercentageField(field) || isSimpleMathField(field) || isAggregateMathField(field) || isRules(field) || isRoundedNumberField(field) || isDateCalculation(field) || isConditional(field) || isMetric(field) || isCustomBuildMetric(field);
2469
+ return isPercentageField(field) || isSimpleMathField(field) || isAggregateMathField(field) || isRules(field) || isRoundedNumberField(field) || isDateCalculation(field) || isConditional(field) || isCustomBuildMetric(field);
2741
2470
  };
2742
2471
 
2743
2472
  /**
@@ -2758,7 +2487,7 @@ var toQueryMeasure = function toQueryMeasure(measureAttribute, customField, quer
2758
2487
  return build$3(measureAttribute, customField, dataSet, params);
2759
2488
  }
2760
2489
  if (isRoundedNumberField(customField)) {
2761
- return build$a(measureAttribute, customField);
2490
+ return build$9(measureAttribute, customField);
2762
2491
  }
2763
2492
  if (isConditional(customField)) {
2764
2493
  return build$5(customField, queryEngineConfig, dataSet, params);
@@ -2766,11 +2495,8 @@ var toQueryMeasure = function toQueryMeasure(measureAttribute, customField, quer
2766
2495
  if (isDateCalculation(customField)) {
2767
2496
  return build$7(measureAttribute, customField);
2768
2497
  }
2769
- if (isMetric(customField)) {
2770
- return build$8(measureAttribute, customField, dataSet, queryEngineConfig, params);
2771
- }
2772
2498
  if (isCustomBuildMetric(customField)) {
2773
- return build$9();
2499
+ return build$8(measureAttribute, customField, dataSet, queryEngineConfig, params);
2774
2500
  }
2775
2501
  throw "Unsupported custom field type; " + JSON.stringify(customField);
2776
2502
  };
@@ -2936,7 +2662,187 @@ var fromDashboardRequiredFilterGroups = function fromDashboardRequiredFilterGrou
2936
2662
  });
2937
2663
  };
2938
2664
 
2939
- var fieldSchema$1 = /*#__PURE__*/Joi.object({
2665
+ var tagSchema = function tagSchema() {
2666
+ return Joi.object({
2667
+ key: Joi.string().required()
2668
+ });
2669
+ };
2670
+ var tagsSchema = function tagsSchema() {
2671
+ return Joi.array().items(tagSchema()).min(0);
2672
+ };
2673
+
2674
+ var measureSchema = function measureSchema(supportedAggregates, attributeSchemaOptions) {
2675
+ var buildMeasureJoi = function buildMeasureJoi(fieldJoi, functionJoi) {
2676
+ return Joi.object({
2677
+ field: fieldJoi.required(),
2678
+ "function": functionJoi.required().description('Which if any, aggregate function should be applied to the field?')
2679
+ });
2680
+ };
2681
+
2682
+ // Return an enum using the restriction fields
2683
+ if (attributeSchemaOptions != null && attributeSchemaOptions.restrictFields) {
2684
+ return Joi.alternatives.apply(Joi, attributeSchemaOptions.restrictFields.filter(function (f) {
2685
+ return f.canBeMeasure;
2686
+ }).map(function (restrictedField) {
2687
+ var _Joi$string;
2688
+ var supportedFunctionsForField = listValidFunctionsForDataType(restrictedField, supportedAggregates);
2689
+ return buildMeasureJoi(Joi.string().valid(restrictedField.id).description(restrictedField.publicName + ", " + (restrictedField.description || '') + "."), (_Joi$string = Joi.string()).valid.apply(_Joi$string, supportedFunctionsForField.concat(['none'])));
2690
+ }));
2691
+ }
2692
+ 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'])));
2693
+ };
2694
+ var orderSchema = function orderSchema(queryEngineConfig) {
2695
+ var _Joi$string2;
2696
+ return Joi.object({
2697
+ field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2698
+ direction: Joi.string().valid('asc', 'desc').required().description('In which direction should the results be ordered?'),
2699
+ "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?')
2700
+ });
2701
+ };
2702
+ var timeDimensionSchema = function timeDimensionSchema(supportedTimeTruncFunctions) {
2703
+ return Joi.object({
2704
+ field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2705
+ truncate: Joi.valid.apply(Joi, Object.keys(supportedTimeTruncFunctions).concat(['none'])),
2706
+ bucketFill: Joi["boolean"]()
2707
+ });
2708
+ };
2709
+ var dimensionSchema = function dimensionSchema(supportedTimeTruncFunctions, attributeSchemaOptions) {
2710
+ var buildDimensionJoi = function buildDimensionJoi(fieldJoi, isDate) {
2711
+ return Joi.object({
2712
+ field: fieldJoi.required(),
2713
+ pivot: Joi.string().valid('x', 'y').optional(),
2714
+ "function": isDate ? Joi.valid.apply(Joi, Object.keys(supportedTimeTruncFunctions).concat(['none'])).required() : Joi.valid('none').required()
2715
+ });
2716
+ };
2717
+
2718
+ // Return an enum using the restriction fields
2719
+ if (attributeSchemaOptions != null && attributeSchemaOptions.restrictFields) {
2720
+ return Joi.array().items(Joi.alternatives.apply(Joi, attributeSchemaOptions.restrictFields.filter(function (f) {
2721
+ return f.canBeDimension;
2722
+ }).map(function (restrictedField) {
2723
+ return buildDimensionJoi(Joi.string().valid(restrictedField.id).description(restrictedField.publicName + ", " + (restrictedField.description || '') + "."), restrictedField.dataType === 'date_time');
2724
+ }))).description('Fields to group the data by');
2725
+ }
2726
+ 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');
2727
+ };
2728
+ var filterSchema = function filterSchema(queryEngineConfig) {
2729
+ var _Joi$string3, _Joi$string4;
2730
+ return Joi.object({
2731
+ field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2732
+ op: (_Joi$string3 = Joi.string()).valid.apply(_Joi$string3, Object.keys(queryEngineConfig.supportedOperators)).required(),
2733
+ 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(),
2734
+ "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?')
2735
+ });
2736
+ };
2737
+ var queryAttributesFilter = function queryAttributesFilter(queryEngineConfig) {
2738
+ return Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig)));
2739
+ };
2740
+ var queryAttributesLimit = function queryAttributesLimit() {
2741
+ return Joi.number().description('Limit the number of results returned after the query has been ran.');
2742
+ };
2743
+ var baseAttributesSchema = function baseAttributesSchema(attributeSchemaOptions) {
2744
+ var _Joi$string5;
2745
+ var dataSetIdSchema = attributeSchemaOptions != null && attributeSchemaOptions.restrictDataSetIds ? (_Joi$string5 = Joi.string()).valid.apply(_Joi$string5, attributeSchemaOptions.restrictDataSetIds) : Joi.string();
2746
+ return {
2747
+ viewId: Joi.string().allow('').optional().description('__vizzly_hide_from_docs'),
2748
+ displayTitle: Joi.string().allow('').description('A title that explains what is being displayed.'),
2749
+ displaySubject: Joi.string().allow('').description('A chance to add a more detailed description of what is being shown.'),
2750
+ dataSetId: dataSetIdSchema.description('The ID of the data set that is being used by the view.'),
2751
+ protectedByOrganisation: Joi["boolean"]().optional().description('Has the view been created by your organisation, and therefore cannot be modified by your users?')
2752
+ };
2753
+ };
2754
+ var approxAxisLabelCountSchema = /*#__PURE__*/Joi.valid('auto', 2, 0).description('Determine how many axis labels should be shown on the axis');
2755
+ var querySchema = function querySchema(queryEngineConfig, attributeSchemaOptions) {
2756
+ return {
2757
+ 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.'),
2758
+ dimension: dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions).required(),
2759
+ order: Joi.array().items(orderSchema(queryEngineConfig)),
2760
+ limit: queryAttributesLimit(),
2761
+ offset: Joi.number().min(0).description('Paginate results by using this property with limit.')
2762
+ };
2763
+ };
2764
+ var timeDimensionQuerySchema = function timeDimensionQuerySchema(queryEngineConfig, attributeSchemaOptions) {
2765
+ return _extends({}, querySchema(queryEngineConfig, attributeSchemaOptions), {
2766
+ filter: Joi.array().items(Joi.array().items(filterSchema(queryEngineConfig))),
2767
+ timeDimension: Joi.alternatives(timeDimensionSchema(queryEngineConfig.supportedTimeTruncFunctions), Joi.valid(null)).required(),
2768
+ drilldown: Joi.alternatives(dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions).required(), Joi.string()),
2769
+ xAxisPrefix: Joi.string().allow('').description('Add a prefix to the X Axis'),
2770
+ yAxisPrefix: Joi.string().allow('').description('Add a prefix to the Y Axis'),
2771
+ xAxisPostfix: Joi.string().allow('').description('Add a postfix to the X Axis'),
2772
+ yAxisPostfix: Joi.string().allow('').description('Add a postfix to the Y Axis'),
2773
+ yAxisFormat: Joi.alternatives(Joi.string(), Joi.valid(null)).description('ID of the formatting function to apply to the Y Axis values'),
2774
+ xAxisFormat: Joi.alternatives(Joi.string(), Joi.valid(null)).description('ID of the formatting function to apply to the X Axis values'),
2775
+ approxYAxisLabelCount: approxAxisLabelCountSchema,
2776
+ approxXAxisLabelCount: approxAxisLabelCountSchema
2777
+ });
2778
+ };
2779
+ var lineCurveSchema = /*#__PURE__*/Joi.string().valid('natural', 'straight', 'step', 'stepBefore', 'stepAfter', 'dotted');
2780
+ var areaCurveSchema = /*#__PURE__*/Joi.string().valid('natural', 'straight', 'step');
2781
+ var protectedFieldsMeasure = function protectedFieldsMeasure(queryEngineConfig) {
2782
+ var _Joi$string6;
2783
+ return Joi.array().items(Joi.object({
2784
+ "function": (_Joi$string6 = Joi.string()).valid.apply(_Joi$string6, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])),
2785
+ field: Joi.string().required().description('The ID of the field from the data set to reference.')
2786
+ }));
2787
+ };
2788
+ var protectedFieldsDimension = function protectedFieldsDimension(queryEngineConfig) {
2789
+ var _Joi$string7;
2790
+ return Joi.array().items(Joi.object({
2791
+ "function": (_Joi$string7 = Joi.string()).valid.apply(_Joi$string7, Object.keys(queryEngineConfig.supportedAggregates).concat(Object.keys(queryEngineConfig.supportedTimeTruncFunctions), ['none'])),
2792
+ truncate: Joi.string(),
2793
+ field: Joi.string().required().description('The ID of the field from the data set to reference.'),
2794
+ bucketFill: Joi["boolean"]().optional(),
2795
+ pivot: Joi.string().valid('x', 'y').optional()
2796
+ }));
2797
+ };
2798
+ var parameterGroupSchema = function parameterGroupSchema(queryEngineConfig, attributeSchemaOptions) {
2799
+ return Joi.object().pattern(Joi.string(), Joi.alternatives()["try"](Joi.array().items(timeDimensionSchema(queryEngineConfig.supportedTimeTruncFunctions)).min(1), dimensionSchema(queryEngineConfig.supportedTimeTruncFunctions, attributeSchemaOptions))).unknown(true);
2800
+ };
2801
+ var parameterMeasureSchema = function parameterMeasureSchema(queryEngineConfig, attributeSchemaOptions) {
2802
+ return Joi.object().pattern(Joi.string(), Joi.array().items(measureSchema(queryEngineConfig.supportedAggregates, attributeSchemaOptions)).min(1)).unknown(true);
2803
+ };
2804
+ var parametersSchema = function parametersSchema(queryEngineConfig, attributeSchemaOptions) {
2805
+ return Joi.object({
2806
+ measure: parameterMeasureSchema(queryEngineConfig, attributeSchemaOptions),
2807
+ group: parameterGroupSchema(queryEngineConfig, attributeSchemaOptions)
2808
+ });
2809
+ };
2810
+ var goalLineValueSchema = /*#__PURE__*/Joi.alternatives()["try"]( /*#__PURE__*/Joi.number().required(), /*#__PURE__*/Joi.string().pattern(/^\{\{.*\}\}$/).required());
2811
+ var goalLineSchema = function goalLineSchema() {
2812
+ return Joi.object({
2813
+ color: Joi.string().required(),
2814
+ value: goalLineValueSchema,
2815
+ strokeWidth: Joi.number().required(),
2816
+ strokeStyle: Joi.string().valid('dashed', 'solid').required(),
2817
+ label: Joi["boolean"]().optional()
2818
+ });
2819
+ };
2820
+ var goalLinesSchema = function goalLinesSchema() {
2821
+ return Joi.array().items(goalLineSchema());
2822
+ };
2823
+ var headlineSchema = function headlineSchema() {
2824
+ return Joi.object({
2825
+ func: Joi.string().valid('mean', 'sum', 'current').allow(null).optional()
2826
+ });
2827
+ };
2828
+ var axisTitleSchema = function axisTitleSchema() {
2829
+ return Joi.object({
2830
+ x: Joi.string().allow(''),
2831
+ y: Joi.string().allow('')
2832
+ });
2833
+ };
2834
+ var sizingSchema = /*#__PURE__*/Joi.object().pattern( /*#__PURE__*/Joi.string(), /*#__PURE__*/Joi.object({
2835
+ width: /*#__PURE__*/Joi.number().min(0),
2836
+ height: /*#__PURE__*/Joi.number().min(0)
2837
+ }));
2838
+ var joiDate = /*#__PURE__*/Joi.custom(function (value, helpers) {
2839
+ if (Object.prototype.toString.call(value) === '[object Date]') {
2840
+ return value;
2841
+ }
2842
+ return helpers.error('any.invalid');
2843
+ }, 'Date object validation');
2844
+
2845
+ var fieldSchema = /*#__PURE__*/Joi.object({
2940
2846
  fieldId: /*#__PURE__*/Joi.string().required(),
2941
2847
  dataSetId: /*#__PURE__*/Joi.string().required()
2942
2848
  });
@@ -2951,8 +2857,8 @@ var sharedAdditionalFilterSchema = function sharedAdditionalFilterSchema(queryEn
2951
2857
  managedByConfiguration: Joi["boolean"]().optional(),
2952
2858
  requiresValue: Joi["boolean"]().optional(),
2953
2859
  optionsFilters: optionsFiltersSchema(queryEngineConfig).optional(),
2954
- appliesToFields: Joi.array().items(fieldSchema$1).required(),
2955
- optionsPulledFrom: Joi.array().items(fieldSchema$1).optional(),
2860
+ appliesToFields: Joi.array().items(fieldSchema).required(),
2861
+ optionsPulledFrom: Joi.array().items(fieldSchema).optional(),
2956
2862
  hidden: Joi["boolean"](),
2957
2863
  options: Joi.array().items(Joi.object({
2958
2864
  value: Joi.allow(Joi.number(), Joi.string()),
@@ -3311,7 +3217,7 @@ var buildFilters = function buildFilters(dataSet, queryEngineConfig, params, pre
3311
3217
  return [];
3312
3218
  };
3313
3219
 
3314
- var build$b = buildFromQueryAttributes;
3220
+ var build$a = buildFromQueryAttributes;
3315
3221
  var hasDimensions = function hasDimensions(query) {
3316
3222
  return query.group.length > 0;
3317
3223
  };
@@ -4199,10 +4105,6 @@ var upcastHeadline = function upcastHeadline(headline, timeDimension) {
4199
4105
  return undefined;
4200
4106
  };
4201
4107
 
4202
- /** @deprecated */
4203
-
4204
- /** @deprecated */
4205
-
4206
4108
  var AcceptedTypes = /*#__PURE__*/function (AcceptedTypes) {
4207
4109
  AcceptedTypes["Maths"] = "maths";
4208
4110
  AcceptedTypes["IfStatement"] = "ifStatement";
@@ -4340,8 +4242,7 @@ var BarChart = function BarChart(config) {
4340
4242
  aggregateMaths: true,
4341
4243
  roundedNumbers: true,
4342
4244
  conditional: true,
4343
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
4344
- customBuild: false
4245
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
4345
4246
  },
4346
4247
  supportedFeatures: {
4347
4248
  parameters: true,
@@ -4736,8 +4637,7 @@ var LineChart = function LineChart(config) {
4736
4637
  aggregateMaths: true,
4737
4638
  roundedNumbers: true,
4738
4639
  conditional: true,
4739
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
4740
- customBuild: false
4640
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
4741
4641
  },
4742
4642
  supportedFeatures: {
4743
4643
  parameters: true,
@@ -5098,7 +4998,6 @@ var LineChart$1 = function LineChart(config) {
5098
4998
  ];
5099
4999
  },
5100
5000
  supportedCustomFields: {
5101
- calculatedField: false,
5102
5001
  percentages: true,
5103
5002
  dateCalculations: true,
5104
5003
  simpleMaths: true,
@@ -5106,7 +5005,7 @@ var LineChart$1 = function LineChart(config) {
5106
5005
  aggregateMaths: true,
5107
5006
  roundedNumbers: true,
5108
5007
  conditional: true,
5109
- customBuild: false
5008
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
5110
5009
  },
5111
5010
  supportedFeatures: {
5112
5011
  parameters: true,
@@ -5380,8 +5279,7 @@ var PieChart = function PieChart(config) {
5380
5279
  aggregateMaths: true,
5381
5280
  roundedNumbers: true,
5382
5281
  conditional: true,
5383
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
5384
- customBuild: false
5282
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
5385
5283
  },
5386
5284
  supportedFeatures: {
5387
5285
  parameters: true,
@@ -5652,8 +5550,7 @@ var SunburstChart = function SunburstChart(config) {
5652
5550
  aggregateMaths: true,
5653
5551
  roundedNumbers: true,
5654
5552
  conditional: true,
5655
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
5656
- customBuild: false
5553
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
5657
5554
  },
5658
5555
  supportedFeatures: {
5659
5556
  parameters: true,
@@ -6007,8 +5904,7 @@ var ScatterChart = function ScatterChart(config) {
6007
5904
  aggregateMaths: true,
6008
5905
  roundedNumbers: true,
6009
5906
  conditional: true,
6010
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
6011
- customBuild: false
5907
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
6012
5908
  },
6013
5909
  supportedFeatures: {
6014
5910
  parameters: false,
@@ -6380,8 +6276,7 @@ var ComboChart = function ComboChart(config) {
6380
6276
  aggregateMaths: true,
6381
6277
  roundedNumbers: true,
6382
6278
  conditional: true,
6383
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
6384
- customBuild: false
6279
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
6385
6280
  },
6386
6281
  supportedFeatures: {
6387
6282
  parameters: false,
@@ -6716,8 +6611,7 @@ var DataTable = function DataTable(config) {
6716
6611
  aggregateMaths: true,
6717
6612
  roundedNumbers: true,
6718
6613
  conditional: true,
6719
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
6720
- customBuild: false
6614
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
6721
6615
  },
6722
6616
  supportedFeatures: {
6723
6617
  parameters: false,
@@ -6962,8 +6856,7 @@ var BasicTable = function BasicTable(config) {
6962
6856
  roundedNumbers: true,
6963
6857
  dateCalculations: true,
6964
6858
  conditional: true,
6965
- calculatedField: [AcceptedTypes.Maths],
6966
- customBuild: [AcceptedTypes.Maths]
6859
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement]
6967
6860
  },
6968
6861
  supportedFeatures: {
6969
6862
  parameters: false,
@@ -7275,8 +7168,7 @@ var HorizontalBarChart = function HorizontalBarChart(config) {
7275
7168
  aggregateMaths: true,
7276
7169
  roundedNumbers: true,
7277
7170
  conditional: true,
7278
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
7279
- customBuild: false
7171
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
7280
7172
  },
7281
7173
  supportedFeatures: {
7282
7174
  parameters: true,
@@ -7637,8 +7529,7 @@ var AreaChart = function AreaChart(config) {
7637
7529
  aggregateMaths: true,
7638
7530
  roundedNumbers: true,
7639
7531
  conditional: true,
7640
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
7641
- customBuild: false
7532
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
7642
7533
  },
7643
7534
  supportedFeatures: {
7644
7535
  parameters: true,
@@ -7928,7 +7819,6 @@ var SingleStat = function SingleStat(config) {
7928
7819
  rules: true,
7929
7820
  roundedNumbers: true,
7930
7821
  conditional: true,
7931
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
7932
7822
  customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
7933
7823
  },
7934
7824
  supportedFeatures: {
@@ -8064,8 +7954,7 @@ var CustomChart = function CustomChart(config) {
8064
7954
  roundedNumbers: false,
8065
7955
  dateCalculations: false,
8066
7956
  conditional: false,
8067
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
8068
- customBuild: false
7957
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
8069
7958
  },
8070
7959
  supportedFeatures: {
8071
7960
  colorGradient: false,
@@ -8301,8 +8190,7 @@ var MercatorMap = function MercatorMap(config) {
8301
8190
  aggregateMaths: true,
8302
8191
  roundedNumbers: true,
8303
8192
  conditional: true,
8304
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
8305
- customBuild: false
8193
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
8306
8194
  },
8307
8195
  supportedFeatures: {
8308
8196
  parameters: false,
@@ -8613,8 +8501,7 @@ var RichText = function RichText(config) {
8613
8501
  aggregateMaths: true,
8614
8502
  roundedNumbers: true,
8615
8503
  conditional: true,
8616
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
8617
- customBuild: false
8504
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
8618
8505
  },
8619
8506
  supportedFeatures: {
8620
8507
  parameters: false,
@@ -8915,7 +8802,6 @@ var RadarChart = function RadarChart(config) {
8915
8802
  return [headingConstant(CONSTANTS$f), chartStylesConstant(CONSTANTS$f, false, false), axisLabelsConstants(CONSTANTS$f)];
8916
8803
  },
8917
8804
  supportedCustomFields: {
8918
- calculatedField: false,
8919
8805
  percentages: true,
8920
8806
  dateCalculations: true,
8921
8807
  simpleMaths: true,
@@ -8923,7 +8809,7 @@ var RadarChart = function RadarChart(config) {
8923
8809
  aggregateMaths: true,
8924
8810
  roundedNumbers: true,
8925
8811
  conditional: true,
8926
- customBuild: false
8812
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
8927
8813
  },
8928
8814
  supportedFeatures: {
8929
8815
  parameters: true,
@@ -9141,7 +9027,6 @@ var Progress = function Progress(config) {
9141
9027
  rules: true,
9142
9028
  roundedNumbers: true,
9143
9029
  conditional: true,
9144
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
9145
9030
  customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
9146
9031
  },
9147
9032
  supportedFeatures: {
@@ -9445,8 +9330,7 @@ var FunnelChart = function FunnelChart(config) {
9445
9330
  aggregateMaths: true,
9446
9331
  roundedNumbers: true,
9447
9332
  conditional: true,
9448
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
9449
- customBuild: false
9333
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
9450
9334
  },
9451
9335
  supportedFeatures: {
9452
9336
  parameters: true,
@@ -10093,8 +9977,7 @@ var BubbleChart = function BubbleChart(config) {
10093
9977
  aggregateMaths: true,
10094
9978
  roundedNumbers: true,
10095
9979
  conditional: true,
10096
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
10097
- customBuild: false
9980
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
10098
9981
  },
10099
9982
  supportedFeatures: {
10100
9983
  parameters: false,
@@ -10509,7 +10392,6 @@ var BubbleChartV2 = function BubbleChartV2(config) {
10509
10392
  ];
10510
10393
  },
10511
10394
  supportedCustomFields: {
10512
- calculatedField: false,
10513
10395
  percentages: true,
10514
10396
  dateCalculations: true,
10515
10397
  simpleMaths: true,
@@ -10517,7 +10399,7 @@ var BubbleChartV2 = function BubbleChartV2(config) {
10517
10399
  aggregateMaths: true,
10518
10400
  roundedNumbers: true,
10519
10401
  conditional: true,
10520
- customBuild: false
10402
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
10521
10403
  },
10522
10404
  supportedFeatures: {
10523
10405
  parameters: true,
@@ -10872,7 +10754,6 @@ var BarChart$1 = function BarChart(config) {
10872
10754
  }), namespace(CONSTANTS$k, 'goal_line')];
10873
10755
  },
10874
10756
  supportedCustomFields: {
10875
- calculatedField: false,
10876
10757
  percentages: true,
10877
10758
  dateCalculations: true,
10878
10759
  simpleMaths: true,
@@ -10880,7 +10761,7 @@ var BarChart$1 = function BarChart(config) {
10880
10761
  aggregateMaths: true,
10881
10762
  roundedNumbers: true,
10882
10763
  conditional: true,
10883
- customBuild: false
10764
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
10884
10765
  },
10885
10766
  supportedFeatures: {
10886
10767
  parameters: true,
@@ -11211,8 +11092,7 @@ var WaterfallChart = function WaterfallChart(config) {
11211
11092
  aggregateMaths: true,
11212
11093
  roundedNumbers: true,
11213
11094
  conditional: true,
11214
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
11215
- customBuild: false
11095
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
11216
11096
  },
11217
11097
  supportedFeatures: {
11218
11098
  parameters: true,
@@ -11578,7 +11458,6 @@ var AreaChart$1 = function AreaChart(config) {
11578
11458
  }), namespace(CONSTANTS$m, 'goal_line')];
11579
11459
  },
11580
11460
  supportedCustomFields: {
11581
- calculatedField: false,
11582
11461
  percentages: true,
11583
11462
  dateCalculations: true,
11584
11463
  simpleMaths: true,
@@ -11586,7 +11465,7 @@ var AreaChart$1 = function AreaChart(config) {
11586
11465
  aggregateMaths: true,
11587
11466
  roundedNumbers: true,
11588
11467
  conditional: true,
11589
- customBuild: false
11468
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
11590
11469
  },
11591
11470
  supportedFeatures: {
11592
11471
  parameters: true,
@@ -11941,8 +11820,7 @@ var ComboChartV2 = function ComboChartV2(config) {
11941
11820
  aggregateMaths: true,
11942
11821
  roundedNumbers: true,
11943
11822
  conditional: true,
11944
- calculatedField: [AcceptedTypes.Maths, AcceptedTypes.IfStatement],
11945
- customBuild: false
11823
+ customBuild: [AcceptedTypes.Maths, AcceptedTypes.IfStatement, AcceptedTypes.Aggregates]
11946
11824
  },
11947
11825
  supportedFeatures: {
11948
11826
  parameters: false,
@@ -13274,7 +13152,7 @@ function linearForecast(data, forecastUnits, key, timeUnit, includeForecast // N
13274
13152
  return trendlineWithForecast;
13275
13153
  }
13276
13154
 
13277
- var init$a = function init(_ref) {
13155
+ var init$9 = function init(_ref) {
13278
13156
  var pivotConfig = _ref.pivotConfig,
13279
13157
  measures = _ref.measures,
13280
13158
  resultSet = _ref.resultSet,
@@ -15023,13 +14901,12 @@ var ADMIN_FEATURE_TOGGLES = {
15023
14901
  canEditCustomMetrics: true,
15024
14902
  allowPercentagesCustomField: true,
15025
14903
  allowDateCalculationsCustomField: true,
15026
- allowCalculatedField: false,
15027
14904
  allowConditionalCustomField: true,
15028
14905
  allowSimpleMathsCustomField: true,
15029
14906
  allowAggregateMathsCustomField: true,
15030
14907
  allowRoundedNumberCustomField: true,
15031
14908
  allowRulesCustomField: true,
15032
- allowCustomBuildField: false,
14909
+ allowCustomBuildField: true,
15033
14910
  showDateAndTimeFilter: true,
15034
14911
  showDateFilter: true,
15035
14912
  canSeeEmptyState: false,
@@ -15065,9 +14942,8 @@ var END_USER_DEFAULT_FEATURE_TOGGLES = {
15065
14942
  allowSimpleMathsCustomField: true,
15066
14943
  allowAggregateMathsCustomField: true,
15067
14944
  allowRoundedNumberCustomField: true,
15068
- allowCalculatedField: false,
15069
14945
  allowRulesCustomField: true,
15070
- allowCustomBuildField: false,
14946
+ allowCustomBuildField: true,
15071
14947
  showDateAndTimeFilter: true,
15072
14948
  showDateFilter: true,
15073
14949
  canSeeEmptyState: false,
@@ -15080,7 +14956,7 @@ var END_USER_DEFAULT_FEATURE_TOGGLES = {
15080
14956
  showSavingIndicator: true,
15081
14957
  disablePersistingGlobalFiltersLocally: false
15082
14958
  };
15083
- var build$c = function build(partialFeatureToggles, queryEngineConfig, mode, scope) {
14959
+ var build$b = function build(partialFeatureToggles, queryEngineConfig, mode, scope) {
15084
14960
  var featureToggles = {};
15085
14961
  featureToggles = _extends({}, featureToggles, END_USER_DEFAULT_FEATURE_TOGGLES, partialFeatureToggles);
15086
14962
  if (mode == 'admin') {
@@ -15146,7 +15022,7 @@ var buildDefaults = function buildDefaults(partialFeatureToggles) {
15146
15022
  canDownloadViewAsPNG: partialFeatureToggles.canDownloadViewAsPNG !== undefined ? partialFeatureToggles.canDownloadViewAsPNG : true,
15147
15023
  forceMobile: partialFeatureToggles.forceMobile !== undefined ? partialFeatureToggles.forceMobile : false,
15148
15024
  unloadOffScreenViews: partialFeatureToggles.unloadOffScreenViews !== undefined ? partialFeatureToggles.unloadOffScreenViews : false,
15149
- allowCalculatedField: (_partialFeatureToggle2 = partialFeatureToggles.allowCalculatedField) != null ? _partialFeatureToggle2 : false
15025
+ allowCustomBuildField: (_partialFeatureToggle2 = partialFeatureToggles.allowCustomBuildField) != null ? _partialFeatureToggle2 : true
15150
15026
  };
15151
15027
  };
15152
15028
 
@@ -15174,7 +15050,7 @@ var removeField$3 = function removeField(component, fieldId) {
15174
15050
  return newComponent;
15175
15051
  };
15176
15052
 
15177
- var init$b = function init(displayTitle) {
15053
+ var init$a = function init(displayTitle) {
15178
15054
  return {
15179
15055
  displayTitle: displayTitle,
15180
15056
  colSpan: 12
@@ -15186,7 +15062,7 @@ var isComponent = function isComponent(component) {
15186
15062
  var HEADER_ROW_HEIGHT$1 = 52;
15187
15063
  var add = function add(display, rowIndex, initialTitle) {
15188
15064
  var updatedDisplay = [].concat(display);
15189
- var newHeader = init$b(initialTitle);
15065
+ var newHeader = init$a(initialTitle);
15190
15066
  var newRow = initRow([newHeader], HEADER_ROW_HEIGHT$1);
15191
15067
  updatedDisplay.splice(rowIndex, 0, newRow);
15192
15068
  return updatedDisplay;
@@ -15661,7 +15537,7 @@ var defaultDateFilterOptions = function defaultDateFilterOptions() {
15661
15537
  }
15662
15538
  return defaultDateFilterOptions;
15663
15539
  };
15664
- var build$d = function build(textOverride, overrides) {
15540
+ var build$c = function build(textOverride, overrides) {
15665
15541
  var timeRangeMapping = defaultTimeRangeMapping(textOverride);
15666
15542
  var orderedKeys = Object.keys(DEFAULT_DATETIME_FILTER_OPTIONS).map(function (key) {
15667
15543
  return key in timeRangeMapping ? "_vizzly_" + key : key;
@@ -15955,7 +15831,7 @@ var base = {
15955
15831
  return undefined;
15956
15832
  }
15957
15833
  };
15958
- var init$c = function init(overrides, includeComponentTypes, excludeComponentTypes, textOverride, featureToggles) {
15834
+ var init$b = function init(overrides, includeComponentTypes, excludeComponentTypes, textOverride, featureToggles) {
15959
15835
  var _overrides$developerT;
15960
15836
  var onlyViewTypes = function onlyViewTypes(dataSet) {
15961
15837
  var allowedView = filterIncludedAndExcludedViews(ALL_VIZZLY_COMPONENT_TYPES, includeComponentTypes,
@@ -15993,7 +15869,7 @@ var init$c = function init(overrides, includeComponentTypes, excludeComponentTyp
15993
15869
  return _extends({}, defaultFormatMapping, overrides.defaultFormats ? overrides.defaultFormats() : {});
15994
15870
  },
15995
15871
  onEditorUpdate: overrides.onEditorUpdate ? overrides.onEditorUpdate : base.onEditorUpdate,
15996
- dateFilterOptions: build$d(textOverride, overrides.dateFilterOptions),
15872
+ dateFilterOptions: build$c(textOverride, overrides.dateFilterOptions),
15997
15873
  onSave: overrides.onSave ? overrides.onSave : base.onSave,
15998
15874
  onScheduledReportChange: overrides.onScheduledReportChange || base.onScheduledReportChange,
15999
15875
  dashboardFilters: overrides.dashboardFilters ? overrides.dashboardFilters : base.dashboardFilters,
@@ -16047,7 +15923,7 @@ function useSubscription(callback, idOverride) {
16047
15923
  var useFeatureTogglesSetup = function useFeatureTogglesSetup(mode, overrideFeatureToggles, queryEngineConfig, scope, id) {
16048
15924
  var base$1 = base;
16049
15925
  var buildInitialFeatureToggles = function () {
16050
- var updatedFeatureToggles = build$c(___default.merge({}, base$1.featureToggles, overrideFeatureToggles), queryEngineConfig != null ? queryEngineConfig : base$1.queryEngineConfig, mode || base$1.mode, scope || base$1.scope);
15926
+ var updatedFeatureToggles = build$b(___default.merge({}, base$1.featureToggles, overrideFeatureToggles), queryEngineConfig != null ? queryEngineConfig : base$1.queryEngineConfig, mode || base$1.mode, scope || base$1.scope);
16051
15927
  return updatedFeatureToggles;
16052
15928
  }();
16053
15929
  var _useState = React.useState(buildInitialFeatureToggles),
@@ -16077,7 +15953,7 @@ var DashboardBehaviourContextProvider = function DashboardBehaviourContextProvid
16077
15953
  var _useState = React.useState(null),
16078
15954
  overrideDeveloperInfo = _useState[0],
16079
15955
  setOverrideDeveloperInfo = _useState[1];
16080
- var dashboardBehaviour = init$c(_extends({}, props.dashboardBehaviour || {}, {
15956
+ var dashboardBehaviour = init$b(_extends({}, props.dashboardBehaviour || {}, {
16081
15957
  mode: props.mode
16082
15958
  }), props.includeComponentTypes, props.excludeComponentTypes, textOverride, featureToggles);
16083
15959
  return jsxRuntime.jsx(DashboardBehaviourContext.Provider, {
@@ -34802,7 +34678,7 @@ var AreaChart$3 = /*#__PURE__*/React.forwardRef(function (props, ref) {
34802
34678
  });
34803
34679
  });
34804
34680
 
34805
- var init$d = function init(attributes) {
34681
+ var init$c = function init(attributes) {
34806
34682
  var dimension = [];
34807
34683
  if ('dimension' in attributes) {
34808
34684
  dimension = [].concat(dimension, attributes.dimension || []);
@@ -35694,7 +35570,7 @@ var AreaChartView = function AreaChartView(props) {
35694
35570
  if (isLoading(props.result)) return jsxRuntime.jsx(LoadingComponent, {});
35695
35571
  if (hasFailed(props.result)) return jsxRuntime.jsx(FailedToLoadDataNotice, {});
35696
35572
  if (isEmpty(props.result)) return jsxRuntime.jsx(NoResultContentToShowNotice, _extends({}, headerProps));
35697
- var pivotConfig = init$d(props);
35573
+ var pivotConfig = init$c(props);
35698
35574
  var series$1 = series(pivotConfig, props.measure, props.result);
35699
35575
  var resultSet$1 = resultSet(props.result, props.measure, pivotConfig, props.stacked == '100%', checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
35700
35576
  var showHeadline = headlineAvailable(props.order, props.headline, props.timeDimension);
@@ -36981,7 +36857,7 @@ var BarChartView = function BarChartView(props) {
36981
36857
  if (isLoading(props.result)) return jsxRuntime.jsx(LoadingComponent, {});
36982
36858
  if (hasFailed(props.result)) return jsxRuntime.jsx(FailedToLoadDataNotice, {});
36983
36859
  if (isEmpty(props.result)) return jsxRuntime.jsx(NoResultContentToShowNotice, _extends({}, headerProps));
36984
- var pivotConfig = init$d(props);
36860
+ var pivotConfig = init$c(props);
36985
36861
  var series$1 = series(pivotConfig, props.measure, props.result);
36986
36862
  var resultSet$1 = resultSet(props.result, props.measure, pivotConfig, props.stacked == '100%', checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
36987
36863
  var showHeadline = headlineAvailable(props.order, props.headline, props.timeDimension);
@@ -37386,12 +37262,12 @@ var LineChartView = function LineChartView(props) {
37386
37262
  if (isLoading(props.result)) return jsxRuntime.jsx(LoadingComponent, {});
37387
37263
  if (hasFailed(props.result)) return jsxRuntime.jsx(FailedToLoadDataNotice, {});
37388
37264
  if (isEmpty(props.result)) return jsxRuntime.jsx(NoResultContentToShowNotice, _extends({}, headerProps));
37389
- var pivotConfig = init$d(props);
37265
+ var pivotConfig = init$c(props);
37390
37266
  var series$1 = series(pivotConfig, props.measure, props.result);
37391
37267
  var resultSet$1 = resultSet(props.result, props.measure, pivotConfig, props.stacked == '100%', checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
37392
37268
  var buildTrends = function buildTrends() {
37393
37269
  if (props.order.length > 0 && props.trends && props.trends.length > 0 && acceptedTimeDimensions(props.timeDimension)) {
37394
- var trends = init$a({
37270
+ var trends = init$9({
37395
37271
  pivotConfig: pivotConfig,
37396
37272
  measures: props.measure,
37397
37273
  resultSet: resultSet$1,
@@ -37631,7 +37507,7 @@ var ScatterChartView = function ScatterChartView(props) {
37631
37507
  var measure = [];
37632
37508
  if (props.xMeasure) measure.push(props.xMeasure);
37633
37509
  if (props.yMeasure) measure.push(props.yMeasure);
37634
- var pivotConfig = init$d(props);
37510
+ var pivotConfig = init$c(props);
37635
37511
  var scatterData = props.result ? resultSet(props.result, measure, pivotConfig) : [];
37636
37512
  var xField = key([], [], props.xMeasure.field, props.xMeasure["function"]);
37637
37513
  scatterData.map(function (d) {
@@ -38997,7 +38873,7 @@ var PieChartView = function PieChartView(props) {
38997
38873
  }
38998
38874
  if (hasFailed(props.result)) return jsxRuntime.jsx(FailedToLoadDataNotice, {});
38999
38875
  if (isEmpty(props.result)) return jsxRuntime.jsx(NoResultContentToShowNotice, _extends({}, headerProps));
39000
- var pivotConfig = init$d({
38876
+ var pivotConfig = init$c({
39001
38877
  dimension: props.dimension
39002
38878
  });
39003
38879
  var rS = resultSet$1(props.result, pivotConfig, fakeQuery, false, checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
@@ -43155,7 +43031,7 @@ var BubbleChartView = function BubbleChartView(props) {
43155
43031
  var measure = [];
43156
43032
  measure.push(props.xMeasure);
43157
43033
  measure.push(props.yMeasure);
43158
- var pivotConfig = init$d(props);
43034
+ var pivotConfig = init$c(props);
43159
43035
  var bubbleData = props.result ? resultSet(props.result, measure, pivotConfig) : [];
43160
43036
  var xField = key([], [], props.xMeasure.field, props.xMeasure["function"]);
43161
43037
  var zField = props.zMeasure ? key([], [], props.zMeasure.field, props.zMeasure["function"]) : '';
@@ -46975,7 +46851,7 @@ var BubbleChartV2View = function BubbleChartV2View(props) {
46975
46851
  var showHeadline = headlineAvailable(props.attributes.order, props.attributes.headline, null);
46976
46852
  var theme = useTheme();
46977
46853
  var BubbleChartV2Component = getComponentInterface(props.attributes.type);
46978
- var pivotConfig = init$d(props.attributes);
46854
+ var pivotConfig = init$c(props.attributes);
46979
46855
  var chartRepresentation = null;
46980
46856
  if (!isLoading(props.result) && !hasFailed(props.result) && !isEmpty(props.result) && BubbleChartV2Component.isRunnable(props.attributes)) {
46981
46857
  var _theme$charts$colors, _theme$charts, _props$attributes$goa;
@@ -47935,7 +47811,7 @@ var LineChartV2View = function LineChartV2View(props) {
47935
47811
  var showHeadline = headlineAvailable(props.attributes.order, props.attributes.headline, null);
47936
47812
  var theme = useTheme();
47937
47813
  var LineChartV2Component = getComponentInterface(props.attributes.type);
47938
- var pivotConfig = init$d(props.attributes);
47814
+ var pivotConfig = init$c(props.attributes);
47939
47815
  var chartRepresentation = null;
47940
47816
  if (!isLoading(props.result) && !hasFailed(props.result) && !isEmpty(props.result) && LineChartV2Component.isRunnable(props.attributes)) {
47941
47817
  var _theme$charts$colors, _theme$charts, _props$attributes$goa;
@@ -48452,13 +48328,13 @@ var ComboChartView = function ComboChartView(props) {
48452
48328
  }
48453
48329
  if (isLoading(props.lineResult) || isLoading(props.barResult)) return jsxRuntime.jsx(LoadingComponent, {});
48454
48330
  if (hasFailed(props.lineResult) && hasFailed(props.barResult)) return jsxRuntime.jsx(FailedToLoadDataNotice, {});
48455
- var barPivotConfig = init$d({
48331
+ var barPivotConfig = init$c({
48456
48332
  dimension: props.barDimension,
48457
48333
  timeDimension: props.timeDimension
48458
48334
  });
48459
48335
  var barSeries = props.barResult ? series(barPivotConfig, props.barMeasure, props.barResult) : [];
48460
48336
  var barTimeseriesResultSet = props.barResult ? resultSet(props.barResult, props.barMeasure, barPivotConfig, props.stacked == '100%', checkForNullValue(props.dataSetId, props.barDimension, props.timeDimension, textOverride, valueAlias)) : [];
48461
- var linePivotConfig = init$d({
48337
+ var linePivotConfig = init$c({
48462
48338
  dimension: props.lineDimension,
48463
48339
  timeDimension: props.timeDimension
48464
48340
  });
@@ -48749,7 +48625,7 @@ var FunnelChartView = function FunnelChartView(props) {
48749
48625
  if (isLoading(props.result)) return jsxRuntime.jsx(LoadingComponent, {});
48750
48626
  if (hasFailed(props.result)) return jsxRuntime.jsx(FailedToLoadDataNotice, {});
48751
48627
  if (isEmpty(props.result)) return jsxRuntime.jsx(NoResultContentToShowNotice, _extends({}, headerProps));
48752
- var pivotConfig = init$d(props);
48628
+ var pivotConfig = init$c(props);
48753
48629
  var series$1 = series(pivotConfig, props.measure, props.result);
48754
48630
  var resultSet$1 = resultSet(props.result, props.measure, pivotConfig, false, checkForNullValue(props.dataSetId, props.dimension, props.timeDimension, textOverride, valueAlias));
48755
48631
  var showHeadline = headlineAvailable(props.order, props.headline, props.timeDimension);
@@ -51402,7 +51278,7 @@ var DataTable$2 = function DataTable(props) {
51402
51278
  }));
51403
51279
  };
51404
51280
 
51405
- var validate$3 = function validate(component, dataSets, dashboardBehaviour) {
51281
+ var validate$2 = function validate(component, dataSets, dashboardBehaviour) {
51406
51282
  try {
51407
51283
  var dataSet = find(dataSets, component.attributes.dataSetId);
51408
51284
  if (!dataSet) throw new DataSetNotFound(dataSets, component.attributes.dataSetId);
@@ -51928,7 +51804,7 @@ var BarChartV2View = function BarChartV2View(props) {
51928
51804
  var showHeadline = headlineAvailable(props.attributes.order, props.attributes.headline, null);
51929
51805
  var theme = useTheme();
51930
51806
  var BarChartV2Component = getComponentInterface(props.attributes.type);
51931
- var pivotConfig = init$d(props.attributes);
51807
+ var pivotConfig = init$c(props.attributes);
51932
51808
  var numberOfDimensions = props.attributes.dimension.length;
51933
51809
  var chartRepresentation = React.useMemo(function () {
51934
51810
  if (!isLoading(props.result) && !hasFailed(props.result) && !isEmpty(props.result) && BarChartV2Component.isRunnable(props.attributes)) {
@@ -52984,7 +52860,7 @@ var WaterfallChartView = function WaterfallChartView(props) {
52984
52860
  if (hasFailed(result)) return jsxRuntime.jsx(FailedToLoadDataNotice, {});
52985
52861
  if (isEmpty(result)) return jsxRuntime.jsx(NoResultContentToShowNotice, _extends({}, headerProps));
52986
52862
  var showHeadline = headlineAvailable(order, headline, timeDimension);
52987
- var pivotConfig = init$d(props);
52863
+ var pivotConfig = init$c(props);
52988
52864
  var _buildWaterfallChartR = buildWaterfallChartRepresentation({
52989
52865
  approxYAxisLabelCount: approxYAxisLabelCount === 'auto' ? 10 : approxYAxisLabelCount,
52990
52866
  axisTitles: axisTitles,
@@ -53312,7 +53188,7 @@ var AreaChartV2View = function AreaChartV2View(props) {
53312
53188
  var showHeadline = headlineAvailable(props.attributes.order, props.attributes.headline, null);
53313
53189
  var theme = useTheme();
53314
53190
  var AreaChartV2Component = getComponentInterface(props.attributes.type);
53315
- var pivotConfig = init$d(props.attributes);
53191
+ var pivotConfig = init$c(props.attributes);
53316
53192
  console.log(props.attributes, pivotConfig);
53317
53193
  var chartRepresentation = null;
53318
53194
  if (!isLoading(props.result) && !hasFailed(props.result) && !isEmpty(props.result) && AreaChartV2Component.isRunnable(props.attributes)) {
@@ -53810,7 +53686,7 @@ var RadarChartView = function RadarChartView(props) {
53810
53686
  if (hasFailed(result)) return jsxRuntime.jsx(FailedToLoadDataNotice, {});
53811
53687
  if (isEmpty(result)) return jsxRuntime.jsx(NoResultContentToShowNotice, _extends({}, headerProps));
53812
53688
  var showHeadline = headlineAvailable(order, headline, timeDimension);
53813
- var pivotConfig = init$d(props);
53689
+ var pivotConfig = init$c(props);
53814
53690
  var chartRepresentation = buildRadarChartRepresentation({
53815
53691
  result: result,
53816
53692
  xAxisFormat: xAxisFormat,
@@ -54247,7 +54123,7 @@ var ComboChartViewV2 = function ComboChartViewV2(props) {
54247
54123
  queryEngineConfig = _useDashboardBehaviou.queryEngineConfig;
54248
54124
  var theme = useTheme();
54249
54125
  var ComboChartComponent = getComponentInterface(props.attributes.type);
54250
- var barPivotConfig = init$d({
54126
+ var barPivotConfig = init$c({
54251
54127
  dimension: props.attributes.barDimension,
54252
54128
  timeDimension: props.attributes.timeDimension
54253
54129
  });
@@ -54311,7 +54187,7 @@ var ComboChartViewV2 = function ComboChartViewV2(props) {
54311
54187
  }
54312
54188
  return null;
54313
54189
  }, [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]);
54314
- var linePivotConfig = init$d({
54190
+ var linePivotConfig = init$c({
54315
54191
  dimension: props.attributes.lineDimension,
54316
54192
  timeDimension: props.attributes.timeDimension
54317
54193
  });
@@ -54478,7 +54354,7 @@ var Component = function Component(props) {
54478
54354
  var setPartialAttributes = function setPartialAttributes(changes) {
54479
54355
  return props.updateComponentAttributes(componentInterface.setAttributes(props.component.attributes, changes));
54480
54356
  };
54481
- var validationError = validate$3(props.component, dashboard.dataSets, dashboardBehaviour);
54357
+ var validationError = validate$2(props.component, dashboard.dataSets, dashboardBehaviour);
54482
54358
  if (validationError) {
54483
54359
  if (validationError instanceof DataSetNotFound) {
54484
54360
  return jsxRuntime.jsx(Empty, {
@@ -55319,7 +55195,7 @@ var PopulatedComponentOptions = function PopulatedComponentOptions(props) {
55319
55195
  var theme = useTheme();
55320
55196
  var dashboardBehaviour = useDashboardBehaviourContext();
55321
55197
  var componentInterface = getComponentInterface(props.component.attributes.type);
55322
- var validationError = validate$3(props.component, dashboard.dataSets, dashboardBehaviour);
55198
+ var validationError = validate$2(props.component, dashboard.dataSets, dashboardBehaviour);
55323
55199
  var dataSet = find(dashboard.dataSets, props.component.attributes.dataSetId);
55324
55200
  var populatedCellOptions = [];
55325
55201
  var isCustomComponent = props.component.attributes.type === 'custom';
@@ -57719,10 +57595,6 @@ function customMetricText(key, textOverride) {
57719
57595
  title: textOverride('custom_metric_title.conditional', 'Conditional'),
57720
57596
  subtext: textOverride('custom_metric_description.conditional', 'Create a conditional field')
57721
57597
  },
57722
- calculatedField: {
57723
- title: textOverride('custom_metric_title.caclulated_field', 'Calculated Field'),
57724
- subtext: textOverride('custom_metric_description.caclulated_field', 'Create a calculated field')
57725
- },
57726
57598
  customBuildMetric: {
57727
57599
  title: textOverride('custom_metric_title.caclulated_field', 'Custom Metric Builder'),
57728
57600
  subtext: textOverride('custom_metric_description.caclulated_field', 'Create a custom build field')
@@ -57752,11 +57624,6 @@ var buildInitOptions = function buildInitOptions(featureToggles, componentType,
57752
57624
  logDebug("Simple math custom field not made available, because it is not supported for the view " + componentInterface.title + ".");
57753
57625
  }
57754
57626
  }
57755
- if (featureToggles.allowCustomBuildField && componentInterface.supportedCustomFields.customBuild) {
57756
- initValues.push(_extends({}, customMetricText('customBuildMetric', textOverride), {
57757
- value: 'customBuildMetric'
57758
- }));
57759
- }
57760
57627
  if (featureToggles.allowRoundedNumberCustomField && componentInterface.supportedCustomFields.roundedNumbers) {
57761
57628
  initValues.push(_extends({}, customMetricText('roundedNumber', textOverride), {
57762
57629
  value: 'roundedNumber'
@@ -57820,16 +57687,16 @@ var buildInitOptions = function buildInitOptions(featureToggles, componentType,
57820
57687
  logDebug("Conditional custom field not made available, because it is not supported for the view " + componentInterface.title + ".");
57821
57688
  }
57822
57689
  }
57823
- if (featureToggles.allowCalculatedField && componentInterface.supportedCustomFields.calculatedField) {
57824
- initValues.push(_extends({}, customMetricText('calculatedField', textOverride), {
57825
- value: 'calculatedField'
57690
+ if (featureToggles.allowCustomBuildField && componentInterface.supportedCustomFields.customBuild) {
57691
+ initValues.push(_extends({}, customMetricText('customBuildMetric', textOverride), {
57692
+ value: 'customBuildMetric'
57826
57693
  }));
57827
57694
  } else {
57828
- if (!featureToggles.allowCalculatedField) {
57829
- logDebug('Calculated custom field not made available, because of a feature toggle.');
57695
+ if (!featureToggles.allowCustomBuildField) {
57696
+ logDebug('Custom metric build field not made available, because of a feature toggle.');
57830
57697
  }
57831
- if (!componentInterface.supportedCustomFields.calculatedField) {
57832
- logDebug("Calculated custom field not made available, because it is not supported for the view " + componentInterface.title + ".");
57698
+ if (!componentInterface.supportedCustomFields.customBuild) {
57699
+ logDebug("Custom metric build field not made available, because it is not supported for the view " + componentInterface.title + ".");
57833
57700
  }
57834
57701
  }
57835
57702
  return initValues;
@@ -57851,7 +57718,6 @@ var ModalType = /*#__PURE__*/function (ModalType) {
57851
57718
  ModalType["ConditionalFormatting"] = "conditionalFormatting";
57852
57719
  ModalType["TrendLines"] = "trendLines";
57853
57720
  ModalType["GoalLines"] = "goalLines";
57854
- ModalType["CalculatedField"] = "calculatedField";
57855
57721
  ModalType["ItemPicker"] = "itemPicker";
57856
57722
  ModalType["CustomMetricBuilder"] = "customMetricBuilder";
57857
57723
  return ModalType;
@@ -58127,9 +57993,6 @@ function getSubtext(customField, textOverride) {
58127
57993
  if (isRoundedNumberField(customField)) {
58128
57994
  return customMetricText('roundedNumber', textOverride).title;
58129
57995
  }
58130
- if (isMetric(customField)) {
58131
- return customMetricText('calculatedField', textOverride).title;
58132
- }
58133
57996
  if (isCustomBuildMetric(customField)) {
58134
57997
  return customMetricText('customBuildMetric', textOverride).title;
58135
57998
  }
@@ -58149,8 +58012,6 @@ var mapCategoryToModalType = function mapCategoryToModalType(category) {
58149
58012
  return ModalType.RoundedNumberCustomMetric;
58150
58013
  case 'dateCalculation':
58151
58014
  return ModalType.DateCalculationCustomMetric;
58152
- case 'calculatedField':
58153
- return ModalType.CalculatedField;
58154
58015
  case 'customBuildMetric':
58155
58016
  return ModalType.CustomMetricBuilder;
58156
58017
  default:
@@ -58183,18 +58044,33 @@ var removeHiddenFieldsFromAttributes = function removeHiddenFieldsFromAttributes
58183
58044
  return [];
58184
58045
  };
58185
58046
 
58186
- /*
58047
+ function metricValuesHaveAggregates(values) {
58048
+ if (!values) {
58049
+ return false;
58050
+ }
58051
+ return values.some(function (value) {
58052
+ if (value.type === PropertyType.Aggregate) {
58053
+ return true;
58054
+ }
58055
+ if ('values' in value) {
58056
+ return metricValuesHaveAggregates(value.values);
58057
+ }
58058
+ return false;
58059
+ });
58060
+ }
58061
+
58062
+ /*
58187
58063
  NOTES
58188
58064
  -----
58189
58065
  - Most important thing is to find out how to remove the limit of 1 timeDimension
58190
58066
  - This is introduced by the timeDimension being an object in attributes, so, we need to move the timeDimension object into the dimension array
58191
58067
  - We also need to prevent timeDimension being replaced onClick
58192
58068
 
58193
- ----
58069
+ ----
58194
58070
  - Both the above issues stem from preSetPartialAttributes and the value of attributes being passed to it
58195
58071
  1. What is actually passed to preSetPartialAttributes?
58196
58072
  - [Answer] the output of getValues, why is this necessary?
58197
- -
58073
+ -
58198
58074
  2. How can we amend the function call to put timeDimension into the dimension array?
58199
58075
  */
58200
58076
 
@@ -58212,7 +58088,6 @@ var FieldCollectorInput = function FieldCollectorInput(inputProps) {
58212
58088
  preventDuplicates = inputProps.preventDuplicates;
58213
58089
  var purpose = fieldFilterOptions != null && fieldFilterOptions.onlyDimensions ? 'grouping' : 'metric';
58214
58090
  var values = getValues(attributes);
58215
- console.log('inputProps', JSON.parse(JSON.stringify(inputProps)), values);
58216
58091
 
58217
58092
  // Allow the list of new values to be formatted before calling setPartialAttributes...
58218
58093
  var onChange = function onChange(values) {
@@ -58323,6 +58198,11 @@ function buildDimensionFromField(purpose, field, queryEngineConfig) {
58323
58198
  field: field.id,
58324
58199
  "function": 'none'
58325
58200
  };
58201
+ } else if (isCustomBuildMetric(field) && (field.metric.type === PropertyType.Aggregate || metricValuesHaveAggregates(field.metric.values))) {
58202
+ newValue = {
58203
+ field: field.id,
58204
+ "function": 'none'
58205
+ };
58326
58206
  } else {
58327
58207
  newValue = {
58328
58208
  field: field.id,
@@ -58347,7 +58227,6 @@ function buildFieldsToPickFrom(dataSet, fieldFilterOptions, preventDuplicates, v
58347
58227
  return initValues;
58348
58228
  }
58349
58229
  function buildFieldCollectorItems(values, dataSet, purpose, queryEngineConfig, _onChange) {
58350
- console.log('buildFieldCollectorItems', values, purpose);
58351
58230
  return [].concat(values).map(function (value, valueIndex) {
58352
58231
  var field = findField(dataSet, value.field);
58353
58232
  var selectOptions = [];
@@ -66093,7 +65972,7 @@ var useSimpleMathModal = function useSimpleMathModal(queryEngineConfig, initialM
66093
65972
  }
66094
65973
  if (state.mathType === 'aggregate') {
66095
65974
  if (state.left && state.right && state.operator) {
66096
- var _buildAggregate = buildAggregate(state),
65975
+ var _buildAggregate = buildAggregate$1(state),
66097
65976
  nestedLeft = _buildAggregate.nestedLeft,
66098
65977
  nestedRight = _buildAggregate.nestedRight,
66099
65978
  leftField = _buildAggregate.leftField,
@@ -66164,7 +66043,7 @@ var extractFields = function extractFields(field) {
66164
66043
  nested: nested
66165
66044
  };
66166
66045
  };
66167
- var buildAggregate = function buildAggregate(args) {
66046
+ var buildAggregate$1 = function buildAggregate(args) {
66168
66047
  var left = args.left,
66169
66048
  right = args.right;
66170
66049
  var _extractFields = extractFields(left),
@@ -67438,7 +67317,7 @@ var useRoundedNumberBuilder = function useRoundedNumberBuilder(initialValue, que
67438
67317
  var onCreateNewRoundedNumber = function onCreateNewRoundedNumber() {
67439
67318
  if (selected && selected.dataSetField) {
67440
67319
  var _selected$dataSetFiel;
67441
- var newCustomField = init$9(metricName, (_selected$dataSetFiel = selected.dataSetField) == null ? void 0 : _selected$dataSetFiel.id, selected.transformationFunctionKey == 'round_to_0_dp' ? 0 : 2, queryEngineConfig);
67320
+ var newCustomField = init$8(metricName, (_selected$dataSetFiel = selected.dataSetField) == null ? void 0 : _selected$dataSetFiel.id, selected.transformationFunctionKey == 'round_to_0_dp' ? 0 : 2, queryEngineConfig);
67442
67321
  onNewCustomField(_extends({}, newCustomField, {
67443
67322
  id: isEditing ? initialValue.id : newCustomField.id
67444
67323
  }));
@@ -68491,13 +68370,23 @@ var CustomMetricVariable = function CustomMetricVariable(_ref) {
68491
68370
  };
68492
68371
 
68493
68372
  var initMetric = function initMetric(selected) {
68494
- 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) {
68373
+ if (!selected) return;
68374
+ if (selected.id === OperatorType.Add || selected.id === OperatorType.Divide || selected.id === OperatorType.Subtract || selected.id === OperatorType.Multiply) {
68495
68375
  return initOperator(selected.id);
68496
68376
  }
68497
- if ((selected == null ? void 0 : selected.id) === PropertyType.IfLogic) {
68377
+ if (selected.id === PropertyType.IfLogic) {
68498
68378
  return initIfLogic();
68499
68379
  }
68500
- return undefined;
68380
+ if (selected.type === PropertyType.Aggregate) {
68381
+ return initAggregate(selected.id);
68382
+ }
68383
+ if (selected.type === PropertyType.Field) {
68384
+ return initField(selected.id);
68385
+ }
68386
+ if (selected.type === PropertyType.NumberInput) {
68387
+ return initNumberInput();
68388
+ }
68389
+ return;
68501
68390
  };
68502
68391
  var initIfLogic = function initIfLogic() {
68503
68392
  return {
@@ -68516,6 +68405,26 @@ var initOperator = function initOperator(op) {
68516
68405
  values: []
68517
68406
  };
68518
68407
  };
68408
+ var initAggregate = function initAggregate(fieldId) {
68409
+ return {
68410
+ type: PropertyType.Aggregate,
68411
+ fieldId: fieldId,
68412
+ "function": undefined
68413
+ };
68414
+ };
68415
+ var initField = function initField(fieldId) {
68416
+ return {
68417
+ type: PropertyType.Field,
68418
+ fieldId: fieldId,
68419
+ "function": 'none'
68420
+ };
68421
+ };
68422
+ var initNumberInput = function initNumberInput() {
68423
+ return {
68424
+ type: PropertyType.NumberInput,
68425
+ value: undefined
68426
+ };
68427
+ };
68519
68428
 
68520
68429
  function updateOperatorValue(value, index, item) {
68521
68430
  var newValue = _extends({}, value);
@@ -68566,11 +68475,7 @@ function createNewValueFromSelected(selected) {
68566
68475
  "function": 'none'
68567
68476
  };
68568
68477
  case PropertyType.Aggregate:
68569
- return {
68570
- type: PropertyType.Aggregate,
68571
- fieldId: selected.id,
68572
- "function": undefined
68573
- };
68478
+ return initAggregate(selected.id);
68574
68479
  case PropertyType.Operator:
68575
68480
  return initOperator(selected.id);
68576
68481
  case PropertyType.IfLogic:
@@ -68669,7 +68574,7 @@ var _formatFormula = function formatFormula(obj, isNested, textOverride, dataSet
68669
68574
  case PropertyType.Aggregate:
68670
68575
  return findField(dataSet, obj.fieldId).publicName + " " + (obj["function"] ? "(" + obj["function"] + ")" : '');
68671
68576
  case PropertyType.Field:
68672
- return obj.fieldId;
68577
+ return findField(dataSet, obj.fieldId).publicName;
68673
68578
  case PropertyType.Operator:
68674
68579
  {
68675
68580
  var op = obj.op,
@@ -68697,7 +68602,7 @@ var _formatFormula = function formatFormula(obj, isNested, textOverride, dataSet
68697
68602
  var then = c.returns ? "then " + _formatFormula(c.returns, true, textOverride, dataSet) : '';
68698
68603
  if (c.filter.length === 0) return toBeDefined;
68699
68604
  return "if (" + c.filter.map(function (f) {
68700
- return filterCondition(f, c.filter.length > 1, textOverride);
68605
+ return filterCondition(f, c.filter.length > 1, textOverride, dataSet);
68701
68606
  }).join(' || ') + ") " + then;
68702
68607
  }).join(' else ');
68703
68608
  var elsePart = obj["else"] ? " else " + _formatFormula(obj["else"], true, textOverride, dataSet) : '';
@@ -68707,7 +68612,7 @@ var _formatFormula = function formatFormula(obj, isNested, textOverride, dataSet
68707
68612
  return '';
68708
68613
  }
68709
68614
  };
68710
- var filterCondition = function filterCondition(filter, nested, textOverride) {
68615
+ var filterCondition = function filterCondition(filter, nested, textOverride, dataSet) {
68711
68616
  var filterString = filter.map(function (f) {
68712
68617
  var op = f.op,
68713
68618
  value = f.value,
@@ -68719,7 +68624,7 @@ var filterCondition = function filterCondition(filter, nested, textOverride) {
68719
68624
  var duration = defaultDurationOptions(textOverride)[relativeValue.unit].description.toLowerCase();
68720
68625
  var timeframe = defaultTimeframeOptions(textOverride)[relativeValue.timeFrame].description.toLowerCase();
68721
68626
  return textOverride('metric_overview.relative_date', '[[field]] [[op]] [[value]] [[duration]] in [[timeframe]]', {
68722
- field: field,
68627
+ field: findField(dataSet, field).publicName,
68723
68628
  op: op,
68724
68629
  value: (_value$value = value.value) != null ? _value$value : '',
68725
68630
  duration: duration,
@@ -68727,7 +68632,7 @@ var filterCondition = function filterCondition(filter, nested, textOverride) {
68727
68632
  });
68728
68633
  }
68729
68634
  }
68730
- return field + " " + op + " \u201C" + value + "\u201C";
68635
+ return findField(dataSet, field).publicName + " " + op + " \u201C" + value + "\u201C";
68731
68636
  }).join(', ');
68732
68637
  return nested ? "(" + filterString + ")" : filterString;
68733
68638
  };
@@ -68763,34 +68668,8 @@ var code$1 = /*#__PURE__*/styles({
68763
68668
  fontSize: 11
68764
68669
  });
68765
68670
 
68766
- var getUsableItems = function getUsableItems(supportedTypes) {
68767
- var possibleItems = {};
68768
- if (supportedTypes.includes(AcceptedTypes.Maths)) {
68769
- possibleItems = _extends({}, possibleItems, {
68770
- operator: [OperatorType.Add, OperatorType.Divide, OperatorType.Subtract, OperatorType.Multiply]
68771
- });
68772
- }
68773
- if (supportedTypes.includes(AcceptedTypes.IfStatement)) {
68774
- possibleItems = _extends({}, possibleItems, {
68775
- logic: [PropertyType.IfLogic]
68776
- });
68777
- }
68778
- return pickAvailableItems(possibleItems);
68779
- };
68780
- var pickAvailableItems = function pickAvailableItems(selection) {
68781
- return availableItems().map(function (group) {
68782
- return _extends({}, group, {
68783
- things: group.things.filter(function (thing) {
68784
- var _selection$group$id$i, _selection$group$id;
68785
- 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;
68786
- })
68787
- });
68788
- }).filter(function (group) {
68789
- return group.things.length > 0;
68790
- });
68791
- };
68792
- var availableItems = function availableItems() {
68793
- return [{
68671
+ var buildOperatorItems = function buildOperatorItems() {
68672
+ return {
68794
68673
  title: 'Operators',
68795
68674
  id: 'operator',
68796
68675
  things: [{
@@ -68826,79 +68705,7 @@ var availableItems = function availableItems() {
68826
68705
  }),
68827
68706
  subtext: 'Returns the product of two or more numbers.'
68828
68707
  }]
68829
- }, {
68830
- title: 'Logic',
68831
- id: 'logic',
68832
- things: [{
68833
- id: PropertyType.IfLogic,
68834
- type: PropertyType.IfLogic,
68835
- title: 'If Statement',
68836
- icon: jsxRuntime.jsx("svg", {
68837
- version: "1.1",
68838
- id: "Layer_1",
68839
- xmlns: "http://www.w3.org/2000/svg",
68840
- viewBox: "0 0 121.83 122.88",
68841
- children: jsxRuntime.jsx("g", {
68842
- children: jsxRuntime.jsx("path", {
68843
- 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"
68844
- })
68845
- })
68846
- }),
68847
- subtext: 'Returns the first value if the condition is true; otherwise, returns the second value.'
68848
- }, {
68849
- id: PropertyType.NumberInput,
68850
- type: PropertyType.NumberInput,
68851
- title: 'Number',
68852
- icon: jsxRuntime.jsx("svg", {
68853
- version: "1.1",
68854
- id: "Layer_1",
68855
- viewBox: "0 0 122.88 102.06",
68856
- children: jsxRuntime.jsx("g", {
68857
- children: jsxRuntime.jsx("path", {
68858
- 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"
68859
- })
68860
- })
68861
- }),
68862
- subtext: 'Assign a static number'
68863
- }]
68864
- }];
68865
- };
68866
-
68867
- var CustomMetricAggregate = function CustomMetricAggregate(props) {
68868
- var dashboardBehaviour = useDashboardBehaviourContext();
68869
- var numberFieldsOptions = {
68870
- onlyFieldTypes: ['number'],
68871
- removePercentage: true,
68872
- removeSimpleMaths: true,
68873
- removeAggregateMaths: true,
68874
- removeDateCalculations: true,
68875
- removeConditional: true,
68876
- removeCustomBuildMetric: true
68877
68708
  };
68878
- return jsxRuntime.jsx(MeasuresInput, {
68879
- id: props.id,
68880
- testId: props.id,
68881
- componentType: props.componentType,
68882
- maxAllowed: 1,
68883
- allowsMultiple: false,
68884
- setPartialAttributes: function setPartialAttributes(_ref) {
68885
- var measure = _ref.measure;
68886
- return props.onChange(_extends({}, props.measure, {
68887
- fieldId: measure.field,
68888
- "function": measure["function"]
68889
- }));
68890
- },
68891
- supportedAggregates: dashboardBehaviour.queryEngineConfig.supportedAggregates,
68892
- attributes: {
68893
- measure: {
68894
- field: props.measure.fieldId,
68895
- "function": props.measure["function"] || undefined
68896
- }
68897
- },
68898
- dataSet: props.dataSet,
68899
- fieldFilterOptions: numberFieldsOptions,
68900
- onDeleteItem: props.onDeleteItem
68901
- });
68902
68709
  };
68903
68710
 
68904
68711
  var buildAggregateItems = function buildAggregateItems(dataSet) {
@@ -68930,6 +68737,51 @@ var buildAggregateItems = function buildAggregateItems(dataSet) {
68930
68737
  };
68931
68738
  };
68932
68739
 
68740
+ var buildLogicItems = function buildLogicItems(onlyNumber) {
68741
+ if (onlyNumber === void 0) {
68742
+ onlyNumber = false;
68743
+ }
68744
+ var ifLogicThings = {
68745
+ id: PropertyType.IfLogic,
68746
+ type: PropertyType.IfLogic,
68747
+ title: 'If Statement',
68748
+ icon: jsxRuntime.jsx("svg", {
68749
+ version: "1.1",
68750
+ id: "Layer_1",
68751
+ xmlns: "http://www.w3.org/2000/svg",
68752
+ viewBox: "0 0 121.83 122.88",
68753
+ children: jsxRuntime.jsx("g", {
68754
+ children: jsxRuntime.jsx("path", {
68755
+ 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"
68756
+ })
68757
+ })
68758
+ }),
68759
+ subtext: 'Returns the first value if the condition is true; otherwise, returns the second value.'
68760
+ };
68761
+ var numberInputThings = {
68762
+ id: PropertyType.NumberInput,
68763
+ type: PropertyType.NumberInput,
68764
+ title: 'Number',
68765
+ icon: jsxRuntime.jsx("svg", {
68766
+ version: "1.1",
68767
+ id: "Layer_1",
68768
+ viewBox: "0 0 122.88 102.06",
68769
+ children: jsxRuntime.jsx("g", {
68770
+ children: jsxRuntime.jsx("path", {
68771
+ 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"
68772
+ })
68773
+ })
68774
+ }),
68775
+ subtext: 'Assign a static number'
68776
+ };
68777
+ var things = onlyNumber ? [numberInputThings] : [ifLogicThings, numberInputThings];
68778
+ return {
68779
+ title: 'Logic',
68780
+ id: 'logic',
68781
+ things: things
68782
+ };
68783
+ };
68784
+
68933
68785
  var buildFieldItems = function buildFieldItems(dataSet) {
68934
68786
  var numberFieldsOptions = {
68935
68787
  onlyFieldTypes: ['number'],
@@ -68958,55 +68810,93 @@ var buildFieldItems = function buildFieldItems(dataSet) {
68958
68810
  };
68959
68811
  };
68960
68812
 
68813
+ var getInitialUsableItems = function getInitialUsableItems(supportedTypes, dataSet) {
68814
+ var possibleItems = [];
68815
+ possibleItems.push(getUsableMathItems(supportedTypes));
68816
+ possibleItems.push(getUsableAggregateItems(supportedTypes, dataSet));
68817
+ possibleItems.push(getUsableFieldItems(dataSet));
68818
+ possibleItems.push(getUsableLogicItems(supportedTypes));
68819
+ return possibleItems.filter(function (item) {
68820
+ return item !== undefined;
68821
+ });
68822
+ };
68823
+ var getUsableMathItems = function getUsableMathItems(supportedTypes) {
68824
+ if (supportedTypes.includes(AcceptedTypes.Maths)) {
68825
+ return buildOperatorItems();
68826
+ }
68827
+ return undefined;
68828
+ };
68829
+ var getUsableAggregateItems = function getUsableAggregateItems(supportedTypes, dataSet) {
68830
+ if (supportedTypes.includes(AcceptedTypes.Aggregates)) {
68831
+ return buildAggregateItems(dataSet);
68832
+ }
68833
+ return undefined;
68834
+ };
68835
+ var getUsableFieldItems = function getUsableFieldItems(dataSet) {
68836
+ return buildFieldItems(dataSet);
68837
+ };
68838
+ var getUsableLogicItems = function getUsableLogicItems(supportedTypes) {
68839
+ if (supportedTypes.includes(AcceptedTypes.IfStatement)) {
68840
+ return buildLogicItems();
68841
+ }
68842
+ return undefined;
68843
+ };
68844
+
68845
+ var CustomMetricAggregate = function CustomMetricAggregate(props) {
68846
+ var dashboardBehaviour = useDashboardBehaviourContext();
68847
+ var numberFieldsOptions = {
68848
+ onlyFieldTypes: ['number'],
68849
+ removePercentage: true,
68850
+ removeSimpleMaths: true,
68851
+ removeAggregateMaths: true,
68852
+ removeDateCalculations: true,
68853
+ removeConditional: true,
68854
+ removeCustomBuildMetric: true
68855
+ };
68856
+ return jsxRuntime.jsx(MeasuresInput, {
68857
+ id: props.id,
68858
+ testId: props.id,
68859
+ componentType: props.componentType,
68860
+ maxAllowed: 1,
68861
+ allowsMultiple: false,
68862
+ setPartialAttributes: function setPartialAttributes(_ref) {
68863
+ var measure = _ref.measure;
68864
+ return props.onChange(_extends({}, props.measure, {
68865
+ fieldId: measure.field,
68866
+ "function": measure["function"]
68867
+ }));
68868
+ },
68869
+ supportedAggregates: dashboardBehaviour.queryEngineConfig.supportedAggregates,
68870
+ attributes: {
68871
+ measure: {
68872
+ field: props.measure.fieldId,
68873
+ "function": props.measure["function"] || undefined
68874
+ }
68875
+ },
68876
+ dataSet: props.dataSet,
68877
+ fieldFilterOptions: numberFieldsOptions,
68878
+ onDeleteItem: props.onDeleteItem
68879
+ });
68880
+ };
68881
+
68961
68882
  function buildFieldsAndAggregates(value, dataSet, supportedTypes, parentHasAggregate, parentHasField) {
68962
68883
  var isOperator = value.type === PropertyType.Operator;
68963
- var isIfLogic = value.type === PropertyType.IfLogic;
68964
68884
  var hasAggregate = isOperator && value.values.some(function (v) {
68965
68885
  return v.type === PropertyType.Aggregate;
68966
68886
  });
68967
68887
  var hasField = isOperator && value.values.some(function (v) {
68968
68888
  return v.type === PropertyType.Field;
68969
68889
  });
68970
- var hasAggregateCase = isIfLogic && value.cases.some(function (c) {
68971
- var _c$returns;
68972
- return ((_c$returns = c.returns) == null ? void 0 : _c$returns.type) === 'aggregate';
68973
- });
68974
- var hasFieldCase = isIfLogic && value.cases.some(function (c) {
68975
- var _c$returns2;
68976
- return ((_c$returns2 = c.returns) == null ? void 0 : _c$returns2.type) === 'field';
68977
- });
68978
- var hasNoReturns = isIfLogic && value.cases.every(function (c) {
68979
- return !c.returns;
68980
- });
68981
68890
  var updatedItems = [];
68982
- var updatedParentHasAggregate = parentHasAggregate != null ? parentHasAggregate : false;
68983
- var updatedParentHasField = parentHasField != null ? parentHasField : false;
68984
- if (hasAggregate && supportedTypes.includes(AcceptedTypes.Aggregates)) {
68985
- updatedParentHasAggregate = true;
68986
- }
68987
- if (hasField) {
68988
- updatedParentHasField = true;
68989
- }
68990
- if (isOperator) {
68991
- if (!updatedParentHasField && supportedTypes.includes(AcceptedTypes.Aggregates)) {
68992
- updatedItems.push(buildAggregateItems(dataSet));
68993
- }
68994
- if (!updatedParentHasAggregate) updatedItems.push(buildFieldItems(dataSet));
68891
+ var updatedParentHasAggregate = parentHasAggregate != null ? parentHasAggregate : hasAggregate && supportedTypes.includes(AcceptedTypes.Aggregates);
68892
+ var updatedParentHasField = parentHasField != null ? parentHasField : hasField;
68893
+ if (isOperator && !updatedParentHasField && supportedTypes.includes(AcceptedTypes.Aggregates)) {
68894
+ updatedItems.push(buildAggregateItems(dataSet));
68995
68895
  }
68996
- if (isIfLogic) {
68997
- if (!updatedParentHasField && hasAggregateCase && supportedTypes.includes(AcceptedTypes.Aggregates)) {
68998
- updatedItems.push(buildAggregateItems(dataSet));
68999
- }
69000
- if (!updatedParentHasAggregate && hasFieldCase) {
69001
- updatedItems.push(buildFieldItems(dataSet));
69002
- }
69003
- if (hasNoReturns) {
69004
- if (supportedTypes.includes(AcceptedTypes.Aggregates)) {
69005
- updatedItems.push(buildAggregateItems(dataSet));
69006
- }
69007
- updatedItems.push(buildFieldItems(dataSet));
69008
- }
68896
+ if (!updatedParentHasAggregate) {
68897
+ updatedItems.push(buildFieldItems(dataSet));
69009
68898
  }
68899
+ updatedItems.push(buildLogicItems(true));
69010
68900
  return {
69011
68901
  updatedItems: updatedItems,
69012
68902
  updatedParentHasAggregate: updatedParentHasAggregate,
@@ -69101,7 +68991,6 @@ var _RecursiveMetric = function RecursiveMetric(_ref) {
69101
68991
  index = _ref.index,
69102
68992
  onDeleteItem = _ref.onDeleteItem,
69103
68993
  parentIsIfLogic = _ref.parentIsIfLogic,
69104
- isEditing = _ref.isEditing,
69105
68994
  parentHasAggregate = _ref.parentHasAggregate,
69106
68995
  parentHasField = _ref.parentHasField,
69107
68996
  supportedTypes = _ref.supportedTypes;
@@ -69149,10 +69038,8 @@ var _RecursiveMetric = function RecursiveMetric(_ref) {
69149
69038
  id: level + "-" + index + "-field"
69150
69039
  });
69151
69040
  }
69152
- var items = [].concat(pickAvailableItems({
69153
- operator: [OperatorType.Add, OperatorType.Divide, OperatorType.Subtract, OperatorType.Multiply],
69154
- logic: [PropertyType.NumberInput]
69155
- }));
69041
+ var usableMathItems = getUsableMathItems(supportedTypes);
69042
+ var items = usableMathItems ? [usableMathItems] : [];
69156
69043
  if (!parentIsIfLogic) {
69157
69044
  var _buildFieldsAndAggreg = buildFieldsAndAggregates(value, dataSet, supportedTypes, parentHasAggregate, parentHasField),
69158
69045
  updatedItems = _buildFieldsAndAggreg.updatedItems,
@@ -69161,6 +69048,9 @@ var _RecursiveMetric = function RecursiveMetric(_ref) {
69161
69048
  items.push.apply(items, updatedItems);
69162
69049
  parentHasAggregate = updatedParentHasAggregate;
69163
69050
  parentHasField = updatedParentHasField;
69051
+ } else {
69052
+ items.push(buildFieldItems(dataSet));
69053
+ items.push(buildLogicItems(true));
69164
69054
  }
69165
69055
  if (variables != null && variables.variables) {
69166
69056
  var builtVariables = buildVariableItems(variables.variables, 'numbers');
@@ -69171,12 +69061,11 @@ var _RecursiveMetric = function RecursiveMetric(_ref) {
69171
69061
  if (value.type === PropertyType.IfLogic) {
69172
69062
  parentIsIfLogic = true;
69173
69063
  }
69174
- var enableRemove = isEditing ? false : true;
69175
69064
  return jsxRuntime.jsxs("div", {
69176
69065
  className: styles({
69177
69066
  position: 'relative'
69178
69067
  }),
69179
- children: [enableRemove && jsxRuntime.jsx(DeleteAction, {
69068
+ children: [jsxRuntime.jsx(DeleteAction, {
69180
69069
  id: level + "-block-" + index,
69181
69070
  onDeleteItem: onDeleteItem,
69182
69071
  label: textOverride('remove', 'Remove') + " level " + (level + 1) + " " + value.type
@@ -69373,6 +69262,28 @@ var CustomMetric = function CustomMetric(props) {
69373
69262
  var deleteMetric = function deleteMetric() {
69374
69263
  updateMetric(undefined);
69375
69264
  };
69265
+ var _hasAggregate = function hasAggregate(value) {
69266
+ if (value.type === PropertyType.Aggregate) {
69267
+ return true;
69268
+ }
69269
+ if (value.type === PropertyType.Operator) {
69270
+ return value.values.some(function (v) {
69271
+ return _hasAggregate(v);
69272
+ });
69273
+ }
69274
+ return false;
69275
+ };
69276
+ var _hasField = function hasField(value) {
69277
+ if (value.type === PropertyType.Field) {
69278
+ return true;
69279
+ }
69280
+ if (value.type === PropertyType.Operator) {
69281
+ return value.values.some(function (v) {
69282
+ return _hasField(v);
69283
+ });
69284
+ }
69285
+ return false;
69286
+ };
69376
69287
  return jsxRuntime.jsx(React.Fragment, {
69377
69288
  children: jsxRuntime.jsxs("div", {
69378
69289
  children: [state.wipCustomMetric && jsxRuntime.jsx(_RecursiveMetric, {
@@ -69384,10 +69295,11 @@ var CustomMetric = function CustomMetric(props) {
69384
69295
  },
69385
69296
  index: 0,
69386
69297
  onDeleteItem: deleteMetric,
69387
- isEditing: props.isEditing,
69388
- supportedTypes: props.supportedTypes
69298
+ supportedTypes: props.supportedTypes,
69299
+ parentHasAggregate: _hasAggregate(state.wipCustomMetric),
69300
+ parentHasField: _hasField(state.wipCustomMetric)
69389
69301
  }), !state.wipCustomMetric && jsxRuntime.jsx(AddItem, {
69390
- items: getUsableItems(props.supportedTypes),
69302
+ items: getInitialUsableItems(props.supportedTypes, props.dataSet),
69391
69303
  onSelect: initialiseMetric
69392
69304
  }), jsxRuntime.jsx(View, {
69393
69305
  marginTop: 20,
@@ -69450,14 +69362,14 @@ var CustomMetricModal = function CustomMetricModal(props) {
69450
69362
  var componentInterface = getComponentInterface(props.componentType);
69451
69363
  var state = useCustomMetric(props.queryEngineConfig, props.initialValue || undefined, props.onNewCustomField);
69452
69364
  var _onChange = state.onChange;
69453
- if (componentInterface.supportedCustomFields.calculatedField === false) return null;
69365
+ if (componentInterface.supportedCustomFields.customBuild === false) return null;
69454
69366
  return jsxRuntime.jsxs(Modal, {
69455
69367
  width: "4xl",
69456
69368
  isOpen: props.show,
69457
69369
  onClose: props.onClose,
69458
69370
  disableDnD: true,
69459
69371
  children: [jsxRuntime.jsx(Modal.Header, {
69460
- title: "Calculated Field"
69372
+ title: "Custom Metric Builder"
69461
69373
  }), jsxRuntime.jsxs(Modal.Content, {
69462
69374
  children: [jsxRuntime.jsx(PanelProperty, {
69463
69375
  children: jsxRuntime.jsx(Input, {
@@ -69481,7 +69393,7 @@ var CustomMetricModal = function CustomMetricModal(props) {
69481
69393
  });
69482
69394
  },
69483
69395
  isEditing: state.isEditing,
69484
- supportedTypes: componentInterface.supportedCustomFields.calculatedField
69396
+ supportedTypes: componentInterface.supportedCustomFields.customBuild
69485
69397
  })
69486
69398
  })]
69487
69399
  }), jsxRuntime.jsx(Modal.Footer, {
@@ -69494,6 +69406,7 @@ var CustomMetricModal = function CustomMetricModal(props) {
69494
69406
  secondary: true,
69495
69407
  children: textOverride('cancel', 'Cancel')
69496
69408
  }), jsxRuntime.jsx(Button, {
69409
+ testId: state.isEditing ? 'update-custom-metric-builder' : 'create-custom-metric-builder',
69497
69410
  onClick: function onClick() {
69498
69411
  return state.handleUpsert();
69499
69412
  },
@@ -69645,117 +69558,6 @@ var ItemPicker = function ItemPicker(props) {
69645
69558
  });
69646
69559
  };
69647
69560
 
69648
- var emptyConditional$1 = {
69649
- publicName: '',
69650
- metric: undefined
69651
- };
69652
- var useCustomMetricBuilderModal = function useCustomMetricBuilderModal(queryEngineConfig, customField, onUpdateField) {
69653
- var isEditing = !!customField;
69654
- var _useState = React.useState(emptyConditional$1),
69655
- state = _useState[0],
69656
- setState = _useState[1];
69657
- React.useEffect(function () {
69658
- if (customField) {
69659
- setState({
69660
- publicName: customField.publicName,
69661
- metric: customField.metricAtrributes
69662
- });
69663
- } else {
69664
- setState(emptyConditional$1);
69665
- }
69666
- }, [JSON.stringify(customField)]);
69667
- var handleUpsertField = function handleUpsertField() {
69668
- if (state.metric) {
69669
- var _customField$id;
69670
- var newCustomField = init$8(state.publicName, state.metric, queryEngineConfig);
69671
- onUpdateField(_extends({}, newCustomField, {
69672
- id: (_customField$id = customField == null ? void 0 : customField.id) != null ? _customField$id : newCustomField.id
69673
- }));
69674
- }
69675
- };
69676
- React.useEffect(function () {
69677
- return logDebug(state.metric);
69678
- }, [JSON.stringify(state.metric)]);
69679
- var onChange = function onChange(partial) {
69680
- setState(_extends({}, state, partial));
69681
- };
69682
- return {
69683
- state: state,
69684
- handleUpsertField: handleUpsertField,
69685
- onChange: onChange,
69686
- isEditing: isEditing,
69687
- isValid: validate$2(queryEngineConfig, state.metric).isValid && state.publicName.length > 0
69688
- };
69689
- };
69690
-
69691
- var CustomMetricBuilderModal = function CustomMetricBuilderModal(props) {
69692
- var dataSet = props.dataSet;
69693
- var _useDashboardBehaviou = useDashboardBehaviourContext(),
69694
- textOverride = _useDashboardBehaviou.textOverride,
69695
- queryEngineConfig = _useDashboardBehaviou.queryEngineConfig;
69696
- var _useCustomMetricBuild = useCustomMetricBuilderModal(queryEngineConfig, props.initialValue, props.onNewCustomField),
69697
- handleUpsertField = _useCustomMetricBuild.handleUpsertField,
69698
- state = _useCustomMetricBuild.state,
69699
- _onChange = _useCustomMetricBuild.onChange,
69700
- isEditing = _useCustomMetricBuild.isEditing,
69701
- isValid = _useCustomMetricBuild.isValid;
69702
- var supportedTypes = function () {
69703
- var supportedLogicTypes = getComponentInterface(props.componentType).supportedCustomFields.customBuild;
69704
- if (typeof supportedLogicTypes !== 'boolean') return supportedLogicTypes;
69705
- return undefined;
69706
- }();
69707
- return jsxRuntime.jsxs(Modal, {
69708
- width: "4xl",
69709
- isOpen: props.show,
69710
- onClose: props.onClose,
69711
- disableDnD: true,
69712
- children: [jsxRuntime.jsx(Modal.Header, {
69713
- title: customMetricText('customBuildMetric', textOverride).title
69714
- }), jsxRuntime.jsxs(Modal.Content, {
69715
- children: [jsxRuntime.jsx(PanelProperty, {
69716
- children: jsxRuntime.jsx(Input, {
69717
- id: "custom-metric-name",
69718
- placeholder: textOverride('metric_name', 'Metric name'),
69719
- label: textOverride('metric_name', 'Metric name'),
69720
- value: state.publicName,
69721
- onChange: function onChange(event) {
69722
- return _onChange({
69723
- publicName: event.target.value
69724
- });
69725
- }
69726
- })
69727
- }), supportedTypes && jsxRuntime.jsx(CustomMetric, {
69728
- dataSet: dataSet,
69729
- metric: state.metric,
69730
- onChange: function onChange(metric) {
69731
- return _onChange({
69732
- metric: metric
69733
- });
69734
- },
69735
- supportedTypes: supportedTypes
69736
- }, isEditing + "-" + state.publicName)]
69737
- }), jsxRuntime.jsx(Modal.Footer, {
69738
- buttons: "end",
69739
- children: jsxRuntime.jsxs(ButtonGroup, {
69740
- children: [jsxRuntime.jsx(Button$2, {
69741
- onClick: function onClick() {
69742
- return props.onClose();
69743
- },
69744
- secondary: true,
69745
- children: textOverride('cancel', 'Cancel')
69746
- }), jsxRuntime.jsx(Button$2, {
69747
- onClick: function onClick() {
69748
- return handleUpsertField();
69749
- },
69750
- disabled: !isValid,
69751
- testId: (isEditing ? 'update' : 'create') + "-custom-metric-builder",
69752
- children: isEditing ? textOverride('update', 'Update') : textOverride('create', 'Create')
69753
- })]
69754
- })
69755
- })]
69756
- });
69757
- };
69758
-
69759
69561
  var ModalToShow = /*#__PURE__*/function (ModalToShow) {
69760
69562
  ModalToShow[ModalToShow["Neither"] = 0] = "Neither";
69761
69563
  ModalToShow[ModalToShow["Library"] = 1] = "Library";
@@ -69829,13 +69631,11 @@ var ModalRouting = function ModalRouting() {
69829
69631
  }), modalType);
69830
69632
  case ModalType.ConditionalCustomMetric:
69831
69633
  return jsxRuntime.jsx(ConditionalModal, _extends({}, attributes), modalType);
69832
- case ModalType.CustomMetricBuilder:
69833
- return jsxRuntime.jsx(CustomMetricBuilderModal, _extends({}, attributes), modalType);
69834
69634
  case ModalType.PercentageCustomMetric:
69835
69635
  return jsxRuntime.jsx(PercentageModal, _extends({}, attributes), modalType);
69836
69636
  case ModalType.MathCustomMetric:
69837
69637
  return jsxRuntime.jsx(MathModal, _extends({}, attributes), modalType);
69838
- case ModalType.CalculatedField:
69638
+ case ModalType.CustomMetricBuilder:
69839
69639
  return jsxRuntime.jsx(CustomMetricModal, _extends({}, attributes), modalType);
69840
69640
  case ModalType.RulesCustomMetric:
69841
69641
  return jsxRuntime.jsx(RulesModal, _extends({}, attributes), modalType);
@@ -70532,7 +70332,7 @@ var fromToken = function fromToken(token) {
70532
70332
  });
70533
70333
  };
70534
70334
 
70535
- var init$e = function init(dashboardSessionToken, dataAccessToken, queryEngineAccessToken, dashboardAdminOverrideToken) {
70335
+ var init$d = function init(dashboardSessionToken, dataAccessToken, queryEngineAccessToken, dashboardAdminOverrideToken) {
70536
70336
  var dashboardAccessContent = fromToken(dashboardSessionToken);
70537
70337
  if (!('scope' in dashboardAccessContent)) {
70538
70338
  dashboardAccessContent.scope = 'read_write';
@@ -70598,7 +70398,7 @@ var fetchIdentityConfig = /*#__PURE__*/function () {
70598
70398
  throw new FailedToLoadIdentity('Failed to fetch identity config.');
70599
70399
  case 6:
70600
70400
  dashboardAdminOverride = isClientSide() ? getDashboardAdminOverride(window.location.href) : null;
70601
- identityConfig = init$e(tokens.dashboardAccessToken, tokens.dataAccessToken, tokens.queryEngineAccessToken, dashboardAdminOverride);
70401
+ identityConfig = init$d(tokens.dashboardAccessToken, tokens.dataAccessToken, tokens.queryEngineAccessToken, dashboardAdminOverride);
70602
70402
  return _context.abrupt("return", {
70603
70403
  identityConfig: identityConfig,
70604
70404
  tokens: tokens
@@ -71225,7 +71025,7 @@ var Header = /*#__PURE__*/function () {
71225
71025
  function Header(title) {
71226
71026
  /** The header component. */
71227
71027
  this.component = undefined;
71228
- var newHeader = init$b('New Header');
71028
+ var newHeader = init$a('New Header');
71229
71029
  if (title) {
71230
71030
  newHeader = _extends({}, newHeader, {
71231
71031
  displayTitle: title
@@ -71935,7 +71735,7 @@ function getOptionsOrders(dataSetField) {
71935
71735
  }
71936
71736
 
71937
71737
  var commonToQueries = function commonToQueries(attributes, dataSet, queryEngineConfig, params) {
71938
- var _Query$build = build$b(dataSet, attributes.measure, attributes.order, attributes.dimension,
71738
+ var _Query$build = build$a(dataSet, attributes.measure, attributes.order, attributes.dimension,
71939
71739
  // @ts-ignore
71940
71740
  attributes.timeDimension || null, attributes.limit, attributes.offset, queryEngineConfig, params),
71941
71741
  query = _Query$build.query,
@@ -71960,8 +71760,8 @@ var toQueries$6 = commonToQueries;
71960
71760
  var toQueries$7 = commonToQueries;
71961
71761
 
71962
71762
  var buildMainQueries = function buildMainQueries(attributes, dataSet, queryEngineConfig, params) {
71963
- var line = build$b(dataSet, attributes.lineMeasure, attributes.order, attributes.lineDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71964
- var bar = build$b(dataSet, attributes.barMeasure, attributes.order, attributes.barDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71763
+ var line = build$a(dataSet, attributes.lineMeasure, attributes.order, attributes.lineDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71764
+ var bar = build$a(dataSet, attributes.barMeasure, attributes.order, attributes.barDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71965
71765
  return {
71966
71766
  bar: bar,
71967
71767
  line: line
@@ -71988,8 +71788,8 @@ var toQueries$b = commonToQueries;
71988
71788
  var toQueries$c = commonToQueries;
71989
71789
 
71990
71790
  var buildMainQueries$1 = function buildMainQueries(attributes, dataSet, queryEngineConfig, params) {
71991
- var line = build$b(dataSet, attributes.lineMeasure, attributes.order, attributes.lineDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71992
- var bar = build$b(dataSet, attributes.barMeasure, attributes.order, attributes.barDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71791
+ var line = build$a(dataSet, attributes.lineMeasure, attributes.order, attributes.lineDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71792
+ var bar = build$a(dataSet, attributes.barMeasure, attributes.order, attributes.barDimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params);
71993
71793
  return {
71994
71794
  bar: bar,
71995
71795
  line: line
@@ -72008,7 +71808,7 @@ var toQueries$d = function toQueries(attributes, dataSet, queryEngineConfig, par
72008
71808
  };
72009
71809
 
72010
71810
  var buildMainQuery = function buildMainQuery(attributes, dataSet, queryEngineConfig, params) {
72011
- var _Query$build = build$b(dataSet, attributes.measure, [], [], null, 1, attributes.offset, queryEngineConfig, params),
71811
+ var _Query$build = build$a(dataSet, attributes.measure, [], [], null, 1, attributes.offset, queryEngineConfig, params),
72012
71812
  query = _Query$build.query,
72013
71813
  measureDescription = _Query$build.measureDescription;
72014
71814
 
@@ -72036,7 +71836,7 @@ var buildMainQuery = function buildMainQuery(attributes, dataSet, queryEngineCon
72036
71836
  };
72037
71837
  var buildDeltaQuery = function buildDeltaQuery(dataSet, attributes, queryEngineConfig, params) {
72038
71838
  if (!attributes.deltaTimeDimension) return null;
72039
- return build$b(dataSet, attributes.measure, [{
71839
+ return build$a(dataSet, attributes.measure, [{
72040
71840
  field: attributes.deltaTimeDimension.field,
72041
71841
  direction: 'asc',
72042
71842
  "function": attributes.deltaTimeDimension.truncate
@@ -72068,7 +71868,7 @@ var toQueries$f = function toQueries(attributes, dataSet, queryEngineConfig, par
72068
71868
  var measures = [];
72069
71869
  attributes.xMeasure && measures.push(attributes.xMeasure);
72070
71870
  attributes.yMeasure && measures.push(attributes.yMeasure);
72071
- var _Query$build = build$b(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
71871
+ var _Query$build = build$a(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
72072
71872
  query = _Query$build.query,
72073
71873
  measureDescription = _Query$build.measureDescription;
72074
71874
  var resultFields = toResultFields([measureDescription], queryEngineConfig);
@@ -72082,7 +71882,7 @@ var toQueries$g = function toQueries(attributes, dataSet, queryEngineConfig, par
72082
71882
  var measures = [];
72083
71883
  attributes.xMeasure && measures.push(attributes.xMeasure);
72084
71884
  attributes.yMeasure && measures.push(attributes.yMeasure);
72085
- var _Query$build = build$b(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
71885
+ var _Query$build = build$a(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
72086
71886
  query = _Query$build.query,
72087
71887
  measureDescription = _Query$build.measureDescription;
72088
71888
  var resultFields = toResultFields([measureDescription], queryEngineConfig);
@@ -72094,7 +71894,7 @@ var toQueries$g = function toQueries(attributes, dataSet, queryEngineConfig, par
72094
71894
 
72095
71895
  var toQueries$h = function toQueries(attributes, dataSet, queryEngineConfig, params) {
72096
71896
  var measures = [].concat(attributes.measure || [], attributes.xMeasure || [], attributes.zMeasure || []);
72097
- var _Query$build = build$b(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
71897
+ var _Query$build = build$a(dataSet, measures, attributes.order, attributes.dimension, attributes.timeDimension, attributes.limit, attributes.offset, queryEngineConfig, params),
72098
71898
  query = _Query$build.query,
72099
71899
  measureDescription = _Query$build.measureDescription;
72100
71900
  var resultFields = toResultFields([measureDescription], queryEngineConfig);
@@ -73472,7 +73272,7 @@ var VizzlyServices = /*#__PURE__*/function () {
73472
73272
  }
73473
73273
  return undefined;
73474
73274
  }();
73475
- 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);
73275
+ 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);
73476
73276
  fetch = /*#__PURE__*/function () {
73477
73277
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
73478
73278
  var _params$abortControll;
@@ -76421,7 +76221,7 @@ var GlobalProviderContents = function GlobalProviderContents(props) {
76421
76221
  }
76422
76222
  };
76423
76223
  var resolvedDateFilterOptions = (_props$dateFilterOpti = props.dateFilterOptions) != null ? _props$dateFilterOpti : props.dateTimeFilterOptions;
76424
- var runQueriesCallback = getRunQueriesCallback(session.identityConfig, session.queryEngineConfig, build$d(textOverride, resolvedDateFilterOptions), variables.variables, props.runQueries, props.data, props.queryEngineEndpoint, props.timeZone);
76224
+ var runQueriesCallback = getRunQueriesCallback(session.identityConfig, session.queryEngineConfig, build$c(textOverride, resolvedDateFilterOptions), variables.variables, props.runQueries, props.data, props.queryEngineEndpoint, props.timeZone);
76425
76225
  var aiOnAction = /*#__PURE__*/function () {
76426
76226
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(conversationId, messageId, actionOptions) {
76427
76227
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {