autoql-fe-utils 1.0.21 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1035,7 +1035,7 @@ __export(src_exports, {
1035
1035
  COMPARE_TYPE: () => COMPARE_TYPE,
1036
1036
  CONTINUOUS_TYPE: () => CONTINUOUS_TYPE,
1037
1037
  CUSTOM_TYPE: () => CUSTOM_TYPE,
1038
- ColumnObj: () => Column2,
1038
+ ColumnObj: () => Column,
1039
1039
  ColumnType: () => ColumnType,
1040
1040
  ColumnTypes: () => ColumnTypes,
1041
1041
  DATA_ALERT_CONDITION_TYPES: () => DATA_ALERT_CONDITION_TYPES,
@@ -1055,8 +1055,10 @@ __export(src_exports, {
1055
1055
  DEFAULT_LEGEND_PADDING_TOP: () => DEFAULT_LEGEND_PADDING_TOP,
1056
1056
  DEFAULT_MAX_LEGEND_WIDTH: () => DEFAULT_MAX_LEGEND_WIDTH,
1057
1057
  DEFAULT_SOURCE: () => DEFAULT_SOURCE,
1058
+ DISPLAY_TYPES: () => DISPLAY_TYPES,
1058
1059
  DOUBLE_AXIS_CHART_TYPES: () => DOUBLE_AXIS_CHART_TYPES,
1059
1060
  DOW_STYLES: () => DOW_STYLES,
1061
+ DataExplorerSubject: () => DataExplorerSubject,
1060
1062
  DataExplorerTypes: () => DataExplorerTypes,
1061
1063
  DateUTC: () => DateUTC,
1062
1064
  DisplayTypes: () => DisplayTypes,
@@ -1085,7 +1087,6 @@ __export(src_exports, {
1085
1087
  NUMBER_TERM_TYPE: () => NUMBER_TERM_TYPE,
1086
1088
  PATH_SMOOTHING: () => PATH_SMOOTHING,
1087
1089
  PERIODIC_TYPE: () => PERIODIC_TYPE,
1088
- PRECISION_TYPES: () => PRECISION_TYPES,
1089
1090
  PROJECT_TYPE: () => PROJECT_TYPE,
1090
1091
  PrecisionTypes: () => PrecisionTypes,
1091
1092
  QUERY_TERM_TYPE: () => QUERY_TERM_TYPE,
@@ -1095,6 +1096,7 @@ __export(src_exports, {
1095
1096
  SCHEDULE_FREQUENCY_OPTIONS: () => SCHEDULE_FREQUENCY_OPTIONS,
1096
1097
  SCHEDULE_INTERVAL_OPTIONS: () => SCHEDULE_INTERVAL_OPTIONS,
1097
1098
  SEASON_NAMES: () => SEASON_NAMES,
1099
+ SampleQueryReplacementTypes: () => SampleQueryReplacementTypes,
1098
1100
  TABLE_TYPES: () => TABLE_TYPES,
1099
1101
  TITLE_FONT_SIZE: () => TITLE_FONT_SIZE,
1100
1102
  ThemeType: () => ThemeType,
@@ -1134,6 +1136,7 @@ __export(src_exports, {
1134
1136
  dataStructureChanged: () => dataStructureChanged,
1135
1137
  dateSortFn: () => dateSortFn,
1136
1138
  dateStringSortFn: () => dateStringSortFn,
1139
+ dayjs: () => dayjsWithPlugins_default,
1137
1140
  deepEqual: () => deepEqual,
1138
1141
  deleteDataAlert: () => deleteDataAlert,
1139
1142
  deleteNotification: () => deleteNotification,
@@ -1147,6 +1150,7 @@ __export(src_exports, {
1147
1150
  fetchDataAlerts: () => fetchDataAlerts,
1148
1151
  fetchDataExplorerAutocomplete: () => fetchDataExplorerAutocomplete,
1149
1152
  fetchDataExplorerSuggestions: () => fetchDataExplorerSuggestions,
1153
+ fetchDataExplorerSuggestionsV2: () => fetchDataExplorerSuggestionsV2,
1150
1154
  fetchDataPreview: () => fetchDataPreview,
1151
1155
  fetchExploreQueries: () => fetchExploreQueries,
1152
1156
  fetchFilters: () => fetchFilters,
@@ -1272,6 +1276,8 @@ __export(src_exports, {
1272
1276
  getRangeForAxis: () => getRangeForAxis,
1273
1277
  getRowNumberListForPopover: () => getRowNumberListForPopover,
1274
1278
  getSVGBase64: () => getSVGBase64,
1279
+ getSampleQueryRegex: () => getSampleQueryRegex,
1280
+ getSampleQueryText: () => getSampleQueryText,
1275
1281
  getScheduleFrequencyObject: () => getScheduleFrequencyObject,
1276
1282
  getStartAndEndDateFromDateStrs: () => getStartAndEndDateFromDateStrs,
1277
1283
  getStringColumnIndices: () => getStringColumnIndices,
@@ -1287,6 +1293,7 @@ __export(src_exports, {
1287
1293
  getTimeRangeFromDateArray: () => getTimeRangeFromDateArray,
1288
1294
  getTimeRangeFromRT: () => getTimeRangeFromRT,
1289
1295
  getTimeScale: () => getTimeScale,
1296
+ getTitleCase: () => getTitleCase,
1290
1297
  getTooltipContent: () => getTooltipContent,
1291
1298
  getTotalBottomPadding: () => getTotalBottomPadding,
1292
1299
  getTotalHorizontalPadding: () => getTotalHorizontalPadding,
@@ -1342,6 +1349,7 @@ __export(src_exports, {
1342
1349
  onTableCellClick: () => onTableCellClick,
1343
1350
  onlySeriesVisibilityChanged: () => onlySeriesVisibilityChanged,
1344
1351
  onlyUnique: () => onlyUnique,
1352
+ parseJwt: () => parseJwt,
1345
1353
  potentiallySupportsDatePivot: () => potentiallySupportsDatePivot,
1346
1354
  potentiallySupportsPivot: () => potentiallySupportsPivot,
1347
1355
  removeElementAtIndex: () => removeElementAtIndex,
@@ -1392,24 +1400,11 @@ __export(src_exports, {
1392
1400
  updateDataAlert: () => updateDataAlert,
1393
1401
  updateDataAlertStatus: () => updateDataAlertStatus,
1394
1402
  usePivotDataForChart: () => usePivotDataForChart,
1403
+ uuidv4: () => uuidv4,
1395
1404
  validateExpression: () => validateExpression
1396
1405
  });
1397
1406
  module.exports = __toCommonJS(src_exports);
1398
1407
 
1399
- // src/HelperFns/stringHelpers.ts
1400
- var capitalizeFirstChar = (string) => {
1401
- let capitalized = string;
1402
- try {
1403
- capitalized = string.charAt(0).toUpperCase() + string.slice(1);
1404
- } catch (error) {
1405
- console.error(error);
1406
- }
1407
- return capitalized;
1408
- };
1409
- var isNumber = (str) => {
1410
- return /^\d+$/.test(str);
1411
- };
1412
-
1413
1408
  // src/dayjsWithPlugins.ts
1414
1409
  var import_dayjs = __toESM(require("dayjs"));
1415
1410
  var import_advancedFormat = __toESM(require("dayjs/plugin/advancedFormat.js"));
@@ -1448,6 +1443,26 @@ import_dayjs.default.extend(import_customParseFormat.default);
1448
1443
  })();
1449
1444
  var dayjsWithPlugins_default = import_dayjs.default;
1450
1445
 
1446
+ // src/HelperFns/stringHelpers.ts
1447
+ var capitalizeFirstChar = (string) => {
1448
+ let capitalized = string;
1449
+ try {
1450
+ capitalized = string.charAt(0).toUpperCase() + string.slice(1);
1451
+ } catch (error) {
1452
+ console.error(error);
1453
+ }
1454
+ return capitalized;
1455
+ };
1456
+ var isNumber = (str) => {
1457
+ return /^\d+$/.test(str);
1458
+ };
1459
+ var getTitleCase = (str) => {
1460
+ if ((str == null ? void 0 : str.length) < 2) {
1461
+ return str;
1462
+ }
1463
+ return str[0].toUpperCase() + str.substring(1);
1464
+ };
1465
+
1451
1466
  // src/HelperFns/columnHelpers.ts
1452
1467
  var import_uuid = require("uuid");
1453
1468
  var import_lodash2 = __toESM(require("lodash.clonedeep"));
@@ -1488,11 +1503,19 @@ var ColumnTypes = /* @__PURE__ */ ((ColumnTypes2) => {
1488
1503
  ColumnTypes2["DATE_STRING"] = "DATE_STRING";
1489
1504
  return ColumnTypes2;
1490
1505
  })(ColumnTypes || {});
1491
- var DataExplorerTypes = /* @__PURE__ */ ((DataExplorerTypes2) => {
1492
- DataExplorerTypes2["SUBJECT_TYPE"] = "subject";
1493
- DataExplorerTypes2["VL_TYPE"] = "VL";
1494
- return DataExplorerTypes2;
1506
+ var DataExplorerTypes = /* @__PURE__ */ ((DataExplorerTypes3) => {
1507
+ DataExplorerTypes3["SUBJECT_TYPE"] = "SUBJECT";
1508
+ DataExplorerTypes3["VL_TYPE"] = "VL";
1509
+ DataExplorerTypes3["TEXT_TYPE"] = "TEXT";
1510
+ return DataExplorerTypes3;
1495
1511
  })(DataExplorerTypes || {});
1512
+ var SampleQueryReplacementTypes = /* @__PURE__ */ ((SampleQueryReplacementTypes2) => {
1513
+ SampleQueryReplacementTypes2["SAMPLE_QUERY_TEXT_TYPE"] = "TEXT";
1514
+ SampleQueryReplacementTypes2["SAMPLE_QUERY_VL_TYPE"] = "VL";
1515
+ SampleQueryReplacementTypes2["SAMPLE_QUERY_TIME_TYPE"] = "DUCKLING_TIME";
1516
+ SampleQueryReplacementTypes2["SAMPLE_QUERY_AMOUNT_TYPE"] = "DUCKLING_AMOUNT";
1517
+ return SampleQueryReplacementTypes2;
1518
+ })(SampleQueryReplacementTypes || {});
1496
1519
  var DisplayTypes = /* @__PURE__ */ ((DisplayTypes2) => {
1497
1520
  DisplayTypes2["TABLE"] = "table";
1498
1521
  DisplayTypes2["PIVOT_TABLE"] = "pivot_table";
@@ -1511,7 +1534,48 @@ var DisplayTypes = /* @__PURE__ */ ((DisplayTypes2) => {
1511
1534
  return DisplayTypes2;
1512
1535
  })(DisplayTypes || {});
1513
1536
 
1514
- // src/Constants/types.ts
1537
+ // src/Classes/ColumnType.ts
1538
+ var ColumnType = class {
1539
+ constructor({
1540
+ type,
1541
+ description,
1542
+ continuous,
1543
+ ordinal,
1544
+ aggOptions,
1545
+ aggregable,
1546
+ isNumber: isNumber2,
1547
+ icon,
1548
+ unit
1549
+ }) {
1550
+ var _a, _b;
1551
+ this.type = (_a = type != null ? type : description) != null ? _a : "";
1552
+ this.description = (_b = description != null ? description : type) != null ? _b : "";
1553
+ this.continuous = !!continuous;
1554
+ this.ordinal = !!ordinal;
1555
+ this.aggOptions = aggOptions != null ? aggOptions : aggregable ? Object.values(AggTypes) : [];
1556
+ this.aggregable = !!this.aggOptions.length;
1557
+ this.isNumber = !!isNumber2;
1558
+ this.icon = icon;
1559
+ this.unit = this.isNumber ? unit != null ? unit : "none" : void 0;
1560
+ }
1561
+ };
1562
+
1563
+ // src/Classes/Column.ts
1564
+ var { DOLLAR_AMT, QUANTITY, PERCENT, RATIO, STRING, DATE, DATE_STRING } = ColumnTypes;
1565
+ var Column = class {
1566
+ constructor(options) {
1567
+ Object.assign(this, options);
1568
+ this.isNumberType = [DOLLAR_AMT, QUANTITY, PERCENT, RATIO].includes(this.type);
1569
+ this.isStringType = [STRING, DATE, DATE_STRING].includes(this.type);
1570
+ this.isDateType = [STRING, DATE].includes(this.type);
1571
+ this.title = this.display_name;
1572
+ if (this.drilldownGroupby) {
1573
+ this.title = `${this.title} <em>(Clicked: "${this.drilldownGroupby.value}")</em>`;
1574
+ }
1575
+ }
1576
+ };
1577
+
1578
+ // src/Classes/AggType.ts
1515
1579
  var AggType = class {
1516
1580
  constructor({ type, displayName, tooltip, unit, supportsStrings = false, symbol: symbol2, fn = () => {
1517
1581
  } }) {
@@ -1525,35 +1589,73 @@ var AggType = class {
1525
1589
  }
1526
1590
  };
1527
1591
 
1592
+ // src/Classes/DataExplorerSubject.ts
1593
+ function isSubject(obj) {
1594
+ return obj.query !== void 0;
1595
+ }
1596
+ function isValueLabel(obj) {
1597
+ return obj.canonical !== void 0;
1598
+ }
1599
+ function isPlainText(obj) {
1600
+ return obj.type === "TEXT" /* TEXT_TYPE */;
1601
+ }
1602
+ var DataExplorerSubject = class {
1603
+ constructor(obj) {
1604
+ if (isSubject(obj)) {
1605
+ const { display_name, name, query } = obj;
1606
+ this.id = name;
1607
+ this.type = "SUBJECT" /* SUBJECT_TYPE */;
1608
+ this.query = query;
1609
+ this.formattedType = "Topic";
1610
+ this.displayName = display_name;
1611
+ this.context = name;
1612
+ } else if (isValueLabel(obj)) {
1613
+ const { canonical, keyword, show_message, format_txt } = obj;
1614
+ this.id = canonical;
1615
+ this.type = "VL" /* VL_TYPE */;
1616
+ this.displayName = format_txt != null ? format_txt : keyword;
1617
+ this.formattedType = show_message;
1618
+ this.valueLabel = obj;
1619
+ } else if (isPlainText(obj)) {
1620
+ const { displayName, type } = obj;
1621
+ this.id = displayName;
1622
+ this.type = type;
1623
+ this.text = displayName;
1624
+ this.displayName = displayName;
1625
+ }
1626
+ this.isSubject = () => isSubject(obj);
1627
+ this.isValueLabel = () => isValueLabel(obj);
1628
+ this.isPlainText = () => isPlainText(obj);
1629
+ }
1630
+ };
1631
+
1528
1632
  // src/Constants/visualizationConstants.ts
1529
- var TABLE_TYPES = [
1530
- "pivot_table",
1531
- "pivot_column",
1532
- "date_pivot",
1533
- "table",
1534
- "compare_table",
1535
- "compare_table_budget"
1536
- ];
1633
+ var TABLE_TYPES = ["pivot_table" /* PIVOT_TABLE */, "table" /* TABLE */];
1537
1634
  var CHART_TYPES = [
1538
- "bar",
1539
- "bubble",
1540
- "chart",
1541
- "column",
1542
- "heatmap",
1543
- "line",
1544
- "pie",
1545
- "stacked_bar",
1546
- "stacked_column",
1547
- "stacked_line",
1548
- "column_line",
1549
- "histogram",
1550
- "scatterplot"
1635
+ "bar" /* BAR */,
1636
+ "bubble" /* BUBBLE */,
1637
+ "column" /* COLUMN */,
1638
+ "heatmap" /* HEATMAP */,
1639
+ "line" /* LINE */,
1640
+ "pie" /* PIE */,
1641
+ "stacked_bar" /* STACKED_BAR */,
1642
+ "stacked_column" /* STACKED_COLUMN */,
1643
+ "stacked_line" /* STACKED_LINE */,
1644
+ "column_line" /* COLUMN_LINE */,
1645
+ "histogram" /* HISTOGRAM */,
1646
+ "scatterplot" /* SCATTERPLOT */
1551
1647
  ];
1552
- var CHARTS_WITHOUT_LEGENDS = ["pie", "heatmap", "bubble", "scatterplot", "histogram"];
1553
- var CHARTS_WITHOUT_AGGREGATED_DATA = ["histogram", "scatterplot"];
1554
- var DATE_ONLY_CHART_TYPES = ["line", "stacked_line"];
1555
- var DOUBLE_AXIS_CHART_TYPES = ["column_line"];
1556
- var CHARTS_WITHOUT_AXES = ["pie"];
1648
+ var CHARTS_WITHOUT_LEGENDS = [
1649
+ "pie" /* PIE */,
1650
+ "heatmap" /* HEATMAP */,
1651
+ "bubble" /* BUBBLE */,
1652
+ "scatterplot" /* SCATTERPLOT */,
1653
+ "histogram" /* HISTOGRAM */
1654
+ ];
1655
+ var CHARTS_WITHOUT_AGGREGATED_DATA = ["histogram" /* HISTOGRAM */, "scatterplot" /* SCATTERPLOT */];
1656
+ var DATE_ONLY_CHART_TYPES = ["line" /* LINE */, "stacked_line" /* STACKED_LINE */];
1657
+ var DOUBLE_AXIS_CHART_TYPES = ["column_line" /* COLUMN_LINE */];
1658
+ var CHARTS_WITHOUT_AXES = ["pie" /* PIE */];
1557
1659
  var DEFAULT_CHART_CONFIG = {
1558
1660
  isScaled: false
1559
1661
  };
@@ -1584,17 +1686,6 @@ var DAYJS_PRECISION_FORMATS = {
1584
1686
  DATE_HOUR: "ll h:00A",
1585
1687
  DATE_MINUTE: "ll h:mmA"
1586
1688
  };
1587
- var PRECISION_TYPES = {
1588
- DAY: "DAY",
1589
- MONTH: "MONTH",
1590
- YEAR: "YEAR",
1591
- WEEK: "WEEK",
1592
- QUARTER: "QUARTER",
1593
- DATE_HOUR: "DATE_HOUR",
1594
- DATE_MINUTE: "DATE_MINUTE",
1595
- HOUR: "HOUR",
1596
- MINUTE: "MINUTE"
1597
- };
1598
1689
  var MAX_LEGEND_LABELS = 22;
1599
1690
  var MIN_HISTOGRAM_SAMPLE = 20;
1600
1691
  var DEFAULT_AGG_TYPE = "SUM" /* SUM */;
@@ -1664,6 +1755,124 @@ var AGG_TYPES = {
1664
1755
  // tooltip: 'The variance will be shown for all data points with the same label.',
1665
1756
  // }),
1666
1757
  };
1758
+ var DISPLAY_TYPES = {
1759
+ TABLE: {
1760
+ type: "table" /* TABLE */,
1761
+ isTableType: true
1762
+ },
1763
+ PIVOT_TABLE: {
1764
+ type: "pivot_table" /* PIVOT_TABLE */,
1765
+ isTableType: true
1766
+ },
1767
+ BAR: {
1768
+ type: "bar" /* BAR */,
1769
+ isChartType: true,
1770
+ allowLegend: true,
1771
+ allowAgg: true,
1772
+ hasAxes: true,
1773
+ datesOnly: false,
1774
+ multiAxis: false
1775
+ },
1776
+ COLUMN: {
1777
+ type: "column" /* COLUMN */,
1778
+ isChartType: true,
1779
+ allowLegend: true,
1780
+ allowAgg: true,
1781
+ hasAxes: true,
1782
+ datesOnly: false,
1783
+ multiAxis: false
1784
+ },
1785
+ LINE: {
1786
+ type: "line" /* LINE */,
1787
+ isChartType: true,
1788
+ allowLegend: true,
1789
+ allowAgg: true,
1790
+ hasAxes: true,
1791
+ datesOnly: true,
1792
+ multiAxis: false
1793
+ },
1794
+ STACKED_COLUMN: {
1795
+ type: "stacked_column" /* STACKED_COLUMN */,
1796
+ isChartType: true,
1797
+ allowLegend: true,
1798
+ allowAgg: true,
1799
+ hasAxes: true,
1800
+ dateOnly: false,
1801
+ multiAxis: false
1802
+ },
1803
+ STACKED_BAR: {
1804
+ type: "stacked_bar" /* STACKED_BAR */,
1805
+ isChartType: true,
1806
+ allowLegend: true,
1807
+ allowAgg: true,
1808
+ hasAxes: true,
1809
+ dateOnly: false,
1810
+ multiAxis: false
1811
+ },
1812
+ STACKED_LINE: {
1813
+ type: "stacked_line" /* STACKED_LINE */,
1814
+ isChartType: true,
1815
+ allowLegend: true,
1816
+ allowAgg: true,
1817
+ hasAxes: true,
1818
+ dateOnly: false,
1819
+ multiAxis: false
1820
+ },
1821
+ BUBBLE: {
1822
+ type: "bubble" /* BUBBLE */,
1823
+ isChartType: true,
1824
+ allowLegend: false,
1825
+ allowAgg: true,
1826
+ hasAxes: true,
1827
+ dateOnly: false,
1828
+ multiAxis: false
1829
+ },
1830
+ HEATMAP: {
1831
+ type: "heatmap" /* HEATMAP */,
1832
+ isChartType: true,
1833
+ allowLegend: false,
1834
+ allowAgg: true,
1835
+ hasAxes: true,
1836
+ dateOnly: false,
1837
+ multiAxis: false
1838
+ },
1839
+ PIE: {
1840
+ type: "pie" /* PIE */,
1841
+ isChartType: true,
1842
+ allowLegend: false,
1843
+ allowAgg: true,
1844
+ hasAxes: false,
1845
+ dateOnly: false,
1846
+ multiAxis: false
1847
+ },
1848
+ HISTOGRAM: {
1849
+ type: "histogram" /* HISTOGRAM */,
1850
+ isChartType: true,
1851
+ allowLegend: false,
1852
+ allowAgg: false,
1853
+ hasAxes: true,
1854
+ dateOnly: false,
1855
+ multiAxis: false
1856
+ },
1857
+ SCATTERPLOT: {
1858
+ type: "scatterplot" /* SCATTERPLOT */,
1859
+ isChartType: true,
1860
+ allowLegend: false,
1861
+ allowAgg: false,
1862
+ hasAxes: true,
1863
+ dateOnly: false,
1864
+ multiAxis: false
1865
+ },
1866
+ COLUMN_LINE: {
1867
+ type: "column_line" /* COLUMN_LINE */,
1868
+ isChartType: true,
1869
+ allowLegend: true,
1870
+ allowAgg: true,
1871
+ hasAxes: true,
1872
+ dateOnly: false,
1873
+ multiAxis: true
1874
+ }
1875
+ };
1667
1876
 
1668
1877
  // src/HelperFns/arrayHelpers.ts
1669
1878
  var import_lodash = __toESM(require("lodash.isequal"));
@@ -2463,47 +2672,6 @@ var EVALUATION_FREQUENCY_OPTIONS = {
2463
2672
  }
2464
2673
  };
2465
2674
 
2466
- // src/Classes/ColumnType.ts
2467
- var ColumnType = class {
2468
- constructor({
2469
- type,
2470
- description,
2471
- continuous,
2472
- ordinal,
2473
- aggOptions,
2474
- aggregable,
2475
- isNumber: isNumber2,
2476
- icon,
2477
- unit
2478
- }) {
2479
- var _a, _b;
2480
- this.type = (_a = type != null ? type : description) != null ? _a : "";
2481
- this.description = (_b = description != null ? description : type) != null ? _b : "";
2482
- this.continuous = !!continuous;
2483
- this.ordinal = !!ordinal;
2484
- this.aggOptions = aggOptions != null ? aggOptions : aggregable ? Object.values(AggTypes) : [];
2485
- this.aggregable = !!this.aggOptions.length;
2486
- this.isNumber = !!isNumber2;
2487
- this.icon = icon;
2488
- this.unit = this.isNumber ? unit != null ? unit : "none" : void 0;
2489
- }
2490
- };
2491
-
2492
- // src/Classes/Column.ts
2493
- var { DOLLAR_AMT, QUANTITY, PERCENT, RATIO, STRING, DATE, DATE_STRING } = ColumnTypes;
2494
- var Column2 = class {
2495
- constructor(options) {
2496
- Object.assign(this, options);
2497
- this.isNumberType = [DOLLAR_AMT, QUANTITY, PERCENT, RATIO].includes(this.type);
2498
- this.isStringType = [STRING, DATE, DATE_STRING].includes(this.type);
2499
- this.isDateType = [STRING, DATE].includes(this.type);
2500
- this.title = this.display_name;
2501
- if (this.drilldownGroupby) {
2502
- this.title = `${this.title} <em>(Clicked: "${this.drilldownGroupby.value}")</em>`;
2503
- }
2504
- }
2505
- };
2506
-
2507
2675
  // src/Constants/columnConstants.ts
2508
2676
  var COLUMN_TYPES = {
2509
2677
  DOLLAR_AMT: new ColumnType({
@@ -3507,7 +3675,7 @@ var isColumnIndexConfigValid = ({ response, columnIndexConfig, columns, displayT
3507
3675
  console.debug("Table config invalid: Some of the string columns were hidden.");
3508
3676
  return false;
3509
3677
  }
3510
- if (displayType === "column_line" || displayType === "scatterplot") {
3678
+ if (displayType === "column_line" /* COLUMN_LINE */ || displayType === "scatterplot" /* SCATTERPLOT */) {
3511
3679
  if (!isColumnIndexValid(columnIndexConfig.numberColumnIndex, columns) || !isColumnIndexValid(columnIndexConfig.numberColumnIndex2, columns) || columnIndexConfig.numberColumnIndex === columnIndexConfig.numberColumnIndex2) {
3512
3680
  console.debug(
3513
3681
  `Two unique number column indices were not found. This is required for display type: ${displayType}`,
@@ -4164,13 +4332,23 @@ var formatChartLabel = ({
4164
4332
  formattedLabel = formatDateStringType(d, col, config);
4165
4333
  break;
4166
4334
  }
4335
+ case "RATIO" /* RATIO */: {
4336
+ const dNumber = parseFloat(`${d}`);
4337
+ if (!isNaN(dNumber)) {
4338
+ formattedLabel = new Intl.NumberFormat(languageCode, {
4339
+ minimumFractionDigits,
4340
+ maximumFractionDigits
4341
+ }).format(dNumber);
4342
+ }
4343
+ break;
4344
+ }
4167
4345
  case "PERCENT" /* PERCENT */: {
4168
4346
  if (Number(d) || Number(d) === 0) {
4169
4347
  const p = Number(d) / 100;
4170
4348
  formattedLabel = new Intl.NumberFormat(languageCode, {
4171
4349
  style: "percent",
4172
- minimumFractionDigits: 1,
4173
- maximumFractionDigits: 1
4350
+ minimumFractionDigits,
4351
+ maximumFractionDigits
4174
4352
  }).format(p);
4175
4353
  }
4176
4354
  break;
@@ -4528,6 +4706,7 @@ var LIGHT_THEME = {
4528
4706
  "table-border-color": "#EFEFEF",
4529
4707
  "hover-color": "#F6F7F9",
4530
4708
  "text-color-primary": "#343434",
4709
+ "text-color-secondary": "#8b8b8b",
4531
4710
  "text-color-accent": "#FFFFFF",
4532
4711
  "text-color-placeholder": "#0000004D",
4533
4712
  "dashboard-title-color": "#28A8E0",
@@ -4562,6 +4741,7 @@ var DARK_THEME = {
4562
4741
  "border-color": "#53565c",
4563
4742
  "hover-color": "#4a4f56",
4564
4743
  "text-color-primary": "#ececec",
4744
+ "text-color-secondary": "#bababa",
4565
4745
  "text-color-accent": "#ffffff",
4566
4746
  "text-color-placeholder": "#ffffff6e",
4567
4747
  "dashboard-title-color": "#193a48",
@@ -4594,6 +4774,7 @@ var defaultThemeConfig = {
4594
4774
  accentColor: "#26A7E9",
4595
4775
  fontFamily: "sans-serif",
4596
4776
  textColor: void 0,
4777
+ textColorSecondary: void 0,
4597
4778
  accentTextColor: void 0,
4598
4779
  dashboardTitleColor: void 0,
4599
4780
  backgroundColorPrimary: void 0,
@@ -4605,7 +4786,7 @@ var getThemeConfig = (customThemeConfig = {}) => {
4605
4786
  ...customThemeConfig
4606
4787
  };
4607
4788
  };
4608
- var getYIQFromHex = (hex) => {
4789
+ var getRBGFromHex = (hex) => {
4609
4790
  let color2 = hex;
4610
4791
  if (color2.slice(0, 1) === "#") {
4611
4792
  color2 = color2.slice(1);
@@ -4616,6 +4797,10 @@ var getYIQFromHex = (hex) => {
4616
4797
  const r = parseInt(color2.substr(0, 2), 16);
4617
4798
  const g = parseInt(color2.substr(2, 2), 16);
4618
4799
  const b = parseInt(color2.substr(4, 2), 16);
4800
+ return { r, g, b };
4801
+ };
4802
+ var getYIQFromHex = (hex) => {
4803
+ const { r, g, b } = getRBGFromHex(hex);
4619
4804
  const yiq = (r * 299 + g * 587 + b * 114) / 1e3;
4620
4805
  return yiq;
4621
4806
  };
@@ -4703,11 +4888,11 @@ var setChartColors = (providedChartColors, themeStyles) => {
4703
4888
  }
4704
4889
  chartColors.forEach((color2, i) => {
4705
4890
  themeStyles[`chart-color-${i}`] = color2;
4706
- const darkerColor = lightenDarkenColor(color2, -10);
4891
+ const darkerColor = lightenDarkenColor(color2, -50);
4707
4892
  themeStyles[`chart-color-dark-${i}`] = darkerColor;
4708
4893
  });
4709
4894
  };
4710
- var configureTheme = (customThemeConfig = {}) => {
4895
+ var configureTheme = (customThemeConfig = {}, prefix = "react-autoql") => {
4711
4896
  const {
4712
4897
  theme,
4713
4898
  textColor,
@@ -4715,6 +4900,7 @@ var configureTheme = (customThemeConfig = {}) => {
4715
4900
  chartColors,
4716
4901
  accentColor,
4717
4902
  accentTextColor,
4903
+ textColorSecondary,
4718
4904
  dashboardTitleColor,
4719
4905
  backgroundColorPrimary,
4720
4906
  backgroundColorSecondary
@@ -4723,6 +4909,9 @@ var configureTheme = (customThemeConfig = {}) => {
4723
4909
  if (textColor) {
4724
4910
  themeStyles["text-color-primary"] = textColor;
4725
4911
  }
4912
+ if (textColorSecondary) {
4913
+ themeStyles["text-color-secondary"] = textColorSecondary;
4914
+ }
4726
4915
  if (accentTextColor) {
4727
4916
  themeStyles["text-color-accent"] = accentTextColor;
4728
4917
  } else {
@@ -4743,7 +4932,15 @@ var configureTheme = (customThemeConfig = {}) => {
4743
4932
  }
4744
4933
  setChartColors(chartColors, themeStyles);
4745
4934
  for (const property in themeStyles) {
4746
- document.documentElement.style.setProperty(`--react-autoql-${property}`, themeStyles[property]);
4935
+ document.documentElement.style.setProperty(`--${prefix}-${property}`, themeStyles[property]);
4936
+ }
4937
+ try {
4938
+ const { r, g, b } = getRBGFromHex(themeStyles["accent-color"]);
4939
+ document.documentElement.style.setProperty(`--${prefix}-accent-color-R`, `${r}`);
4940
+ document.documentElement.style.setProperty(`--${prefix}-accent-color-G`, `${g}`);
4941
+ document.documentElement.style.setProperty(`--${prefix}-accent-color-B`, `${b}`);
4942
+ } catch (error) {
4943
+ console.error(error);
4747
4944
  }
4748
4945
  };
4749
4946
 
@@ -5166,7 +5363,7 @@ var generateDatePivotData = ({ rows, columns, tableConfig, dataFormatting } = {}
5166
5363
  headerFilter: false,
5167
5364
  headerFilterPlaceholder: "filter..."
5168
5365
  };
5169
- const firstPivotColumn = new Column2({
5366
+ const firstPivotColumn = new Column({
5170
5367
  ...pivotMonthColumn,
5171
5368
  formatter: (cell) => formatElement({
5172
5369
  element: cell.getValue(),
@@ -5177,7 +5374,7 @@ var generateDatePivotData = ({ rows, columns, tableConfig, dataFormatting } = {}
5177
5374
  });
5178
5375
  const pivotTableColumns = [firstPivotColumn];
5179
5376
  Object.keys(uniqueYears).forEach((year, i) => {
5180
- const pivotColumn = new Column2({
5377
+ const pivotColumn = new Column({
5181
5378
  ...columns[numberColumnIndex],
5182
5379
  origColumn: columns[numberColumnIndex],
5183
5380
  origValues: {},
@@ -5256,6 +5453,22 @@ var generateFilterDrilldownResponse = ({ response, rows, index, value }) => {
5256
5453
  console.error(error);
5257
5454
  }
5258
5455
  };
5456
+ var uuidv4 = () => {
5457
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
5458
+ var r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
5459
+ return v.toString(16);
5460
+ });
5461
+ };
5462
+ var parseJwt = (token) => {
5463
+ var base64Url = token.split(".")[1];
5464
+ var base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
5465
+ var jsonPayload = decodeURIComponent(
5466
+ window.atob(base64).split("").map(function(c) {
5467
+ return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
5468
+ }).join("")
5469
+ );
5470
+ return JSON.parse(jsonPayload);
5471
+ };
5259
5472
 
5260
5473
  // src/HelperFns/tableHelpers.ts
5261
5474
  var formatTableParams = (params, columns) => {
@@ -7863,7 +8076,7 @@ var transformQueryResponseColumns = (response) => {
7863
8076
  }
7864
8077
  const transformedColumns = columns.map((col, i) => {
7865
8078
  const drilldownGroupby = getDrilldownGroupby(response, col);
7866
- return new Column2({
8079
+ return new Column({
7867
8080
  ...col,
7868
8081
  field: `${i}`,
7869
8082
  index: i,
@@ -8498,53 +8711,125 @@ var reportProblem = ({
8498
8711
  return Promise.reject((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data);
8499
8712
  });
8500
8713
  };
8501
- var fetchSubjectList = ({ domain, apiKey, token }) => {
8502
- if (!token || !domain || !apiKey) {
8503
- return Promise.reject(new Error("Unauthenticated"));
8714
+
8715
+ // src/Api/dataExplorerService.ts
8716
+ var getSampleQueryRegex = (suggestionValues) => {
8717
+ const valueArray = Object.keys(suggestionValues);
8718
+ const valueRegexArray = valueArray.map((value) => `(${value})`);
8719
+ const valueRegex = new RegExp(valueRegexArray.join("|"), "gm");
8720
+ return valueRegex;
8721
+ };
8722
+ var getSampleQueryText = (query, values) => {
8723
+ try {
8724
+ const valueArray = Object.keys(values);
8725
+ let queryText = query;
8726
+ valueArray.forEach((valueKey) => {
8727
+ var _a;
8728
+ const valueRegex = new RegExp(`${valueKey}`, "gm");
8729
+ if (values[valueKey]) {
8730
+ queryText = query.replace(valueRegex, (_a = values[valueKey]) == null ? void 0 : _a.value);
8731
+ }
8732
+ });
8733
+ return queryText;
8734
+ } catch (error) {
8735
+ console.error(error);
8736
+ return void 0;
8504
8737
  }
8505
- const url = `${domain}/autoql/api/v1/query/subjects?key=${apiKey}`;
8506
- const config = {
8507
- headers: {
8508
- Authorization: `Bearer ${token}`
8509
- }
8510
- };
8511
- return import_axios.default.get(url, config).then((response) => Promise.resolve(response)).catch((error) => {
8738
+ };
8739
+ var transformSuggestionResponse = (suggestions) => {
8740
+ const newSuggestions = [];
8741
+ suggestions.forEach((suggestion) => {
8742
+ const initialQuery = suggestion.query;
8743
+ const initialValues = transformSampleQueryValues(suggestion.values);
8744
+ const chunked = getSampleQueryChunk(suggestion.query, initialValues);
8745
+ const queryText = getSampleQueryText(suggestion.query, initialValues);
8746
+ const newSuggestion = {
8747
+ initialQuery,
8748
+ initialValues,
8749
+ chunked,
8750
+ queryText
8751
+ };
8752
+ newSuggestions.push(newSuggestion);
8753
+ });
8754
+ return newSuggestions;
8755
+ };
8756
+ var transformSampleQueryValues = (originalValues) => {
8757
+ const newValues = {};
8758
+ Object.keys(originalValues).forEach((key) => {
8512
8759
  var _a;
8513
- return Promise.reject((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data);
8760
+ newValues[key] = {
8761
+ replacement: originalValues[key],
8762
+ value: (_a = originalValues[key]) == null ? void 0 : _a.format_txt,
8763
+ type: getSampleQueryReplacementType(key, originalValues[key])
8764
+ };
8514
8765
  });
8766
+ return newValues;
8767
+ };
8768
+ var getSampleQueryReplacementType = (key, replacement) => {
8769
+ if (!replacement) {
8770
+ return "TEXT" /* SAMPLE_QUERY_TEXT_TYPE */;
8771
+ } else if (key === "DUCKLING_TIME") {
8772
+ return "DUCKLING_TIME" /* SAMPLE_QUERY_TIME_TYPE */;
8773
+ } else if (key === "DUCKLING_AMOUNT") {
8774
+ return "DUCKLING_AMOUNT" /* SAMPLE_QUERY_AMOUNT_TYPE */;
8775
+ } else if (replacement == null ? void 0 : replacement.canonical) {
8776
+ return "VL" /* SAMPLE_QUERY_VL_TYPE */;
8777
+ } else {
8778
+ console.warn("There was a sample query replacement item but we didnt recognize its type: ", replacement);
8779
+ return;
8780
+ }
8515
8781
  };
8516
- var fetchDataPreview = ({
8517
- subject,
8518
- domain,
8519
- apiKey,
8520
- token,
8521
- source = DEFAULT_SOURCE,
8522
- numRows = 10,
8523
- cancelToken
8524
- } = {}) => {
8525
- if (!subject) {
8526
- return Promise.reject(new Error("No subject supplied for data preview"));
8782
+ var getSampleQueryChunk = (query, values) => {
8783
+ const valueArray = Object.keys(values);
8784
+ const valueRegexArray = valueArray.map((value) => `(${value})`);
8785
+ const valueRegex = new RegExp(valueRegexArray.join("|"), "gm");
8786
+ const splitStrArray = query.split(valueRegex);
8787
+ const chunkedSuggestion = splitStrArray.map((key) => {
8788
+ var _a;
8789
+ const replacement = (_a = values[key]) == null ? void 0 : _a.replacement;
8790
+ const type = getSampleQueryReplacementType(key, replacement);
8791
+ if (type == "DUCKLING_TIME" /* SAMPLE_QUERY_TIME_TYPE */) {
8792
+ return {
8793
+ type: "TEXT" /* SAMPLE_QUERY_TEXT_TYPE */,
8794
+ value: replacement == null ? void 0 : replacement.format_txt
8795
+ };
8796
+ } else if (type == "DUCKLING_AMOUNT" /* SAMPLE_QUERY_AMOUNT_TYPE */) {
8797
+ return {
8798
+ type: "DUCKLING_AMOUNT" /* SAMPLE_QUERY_AMOUNT_TYPE */,
8799
+ value: replacement == null ? void 0 : replacement.format_txt,
8800
+ name: key,
8801
+ replacement
8802
+ };
8803
+ } else if (type == "VL" /* SAMPLE_QUERY_VL_TYPE */) {
8804
+ return {
8805
+ type: "VL" /* SAMPLE_QUERY_VL_TYPE */,
8806
+ value: replacement == null ? void 0 : replacement.format_txt,
8807
+ name: key,
8808
+ replacement
8809
+ };
8810
+ } else if (type == "TEXT" /* SAMPLE_QUERY_TEXT_TYPE */) {
8811
+ return {
8812
+ type: "TEXT" /* SAMPLE_QUERY_TEXT_TYPE */,
8813
+ value: key
8814
+ };
8815
+ }
8816
+ });
8817
+ return chunkedSuggestion;
8818
+ };
8819
+ var transformDataExplorerAutocompleteResponse = (response) => {
8820
+ var _a, _b, _c, _d, _e, _f, _g, _h;
8821
+ let vlMatches = [];
8822
+ if ((_d = (_c = (_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.suggestions) == null ? void 0 : _c.value_labels) == null ? void 0 : _d.length) {
8823
+ const vlMatchesTrimmed = response.data.data.suggestions.value_labels.slice(0, 10);
8824
+ vlMatches = vlMatchesTrimmed.map((vl) => new DataExplorerSubject(vl));
8527
8825
  }
8528
- if (!token || !domain || !apiKey) {
8529
- return Promise.reject(new Error("Unauthenticated"));
8826
+ let subjectMatches = [];
8827
+ if ((_h = (_g = (_f = (_e = response == null ? void 0 : response.data) == null ? void 0 : _e.data) == null ? void 0 : _f.suggestions) == null ? void 0 : _g.subjects) == null ? void 0 : _h.length) {
8828
+ subjectMatches = response.data.data.suggestions.subjects.map((subject) => new DataExplorerSubject(subject));
8530
8829
  }
8531
- const url = `${domain}/autoql/api/v1/query/preview?key=${apiKey}`;
8532
- const config = {
8533
- headers: {
8534
- Authorization: `Bearer ${token}`
8535
- },
8536
- cancelToken
8537
- };
8538
- const data = {
8539
- subject,
8540
- page_size: numRows,
8541
- source,
8542
- date_format: "ISO8601"
8543
- };
8544
- return import_axios.default.post(url, data, config).then((response) => Promise.resolve(response)).catch((error) => Promise.reject(error));
8830
+ const allMatches = [...subjectMatches, ...vlMatches];
8831
+ return Promise.resolve(allMatches);
8545
8832
  };
8546
-
8547
- // src/Api/dataExplorerService.ts
8548
8833
  var fetchDataExplorerAutocomplete = ({
8549
8834
  suggestion,
8550
8835
  domain,
@@ -8566,29 +8851,7 @@ var fetchDataExplorerAutocomplete = ({
8566
8851
  cancelToken
8567
8852
  };
8568
8853
  return import_axios2.default.get(url, config).then((response) => {
8569
- var _a, _b, _c, _d, _e, _f, _g, _h;
8570
- let vlMatches = [];
8571
- if ((_d = (_c = (_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.suggestions) == null ? void 0 : _c.value_labels) == null ? void 0 : _d.length) {
8572
- const vlMatchesTrimmed = response.data.data.suggestions.value_labels.slice(0, 10);
8573
- vlMatches = vlMatchesTrimmed.map((vl) => {
8574
- return {
8575
- ...vl,
8576
- display_name: `${vl.keyword} (${vl.show_message})`,
8577
- type: "VL" /* VL_TYPE */
8578
- };
8579
- });
8580
- }
8581
- let subjectMatches = [];
8582
- if ((_h = (_g = (_f = (_e = response == null ? void 0 : response.data) == null ? void 0 : _e.data) == null ? void 0 : _f.suggestions) == null ? void 0 : _g.subjects) == null ? void 0 : _h.length) {
8583
- subjectMatches = response.data.data.suggestions.subjects.map((subject) => {
8584
- return {
8585
- ...subject,
8586
- type: "subject" /* SUBJECT_TYPE */
8587
- };
8588
- });
8589
- }
8590
- const allMatches = [...subjectMatches, ...vlMatches];
8591
- return Promise.resolve(allMatches);
8854
+ return transformDataExplorerAutocompleteResponse(response);
8592
8855
  }).catch((error) => {
8593
8856
  var _a;
8594
8857
  if ((error == null ? void 0 : error.message) === REQUEST_CANCELLED_ERROR) {
@@ -8606,6 +8869,109 @@ var transformVLForDataExplorerSuggestions = (vl) => {
8606
8869
  canonical: vl.canonical
8607
8870
  };
8608
8871
  };
8872
+ var fetchDataExplorerSuggestionsV2 = async ({
8873
+ pageSize,
8874
+ pageNumber,
8875
+ domain,
8876
+ apiKey,
8877
+ token,
8878
+ text,
8879
+ context,
8880
+ selectedVL,
8881
+ userVLSelection = [],
8882
+ skipQueryValidation,
8883
+ columns
8884
+ } = {}) => {
8885
+ var _a, _b, _c;
8886
+ if (!skipQueryValidation && text) {
8887
+ const queryValidationResponse = await runQueryValidation({
8888
+ text,
8889
+ domain,
8890
+ apiKey,
8891
+ token
8892
+ });
8893
+ if (((_c = (_b = (_a = queryValidationResponse == null ? void 0 : queryValidationResponse.data) == null ? void 0 : _a.data) == null ? void 0 : _b.replacements) == null ? void 0 : _c.length) > 0) {
8894
+ return Promise.resolve(queryValidationResponse);
8895
+ }
8896
+ }
8897
+ const exploreQueriesUrl = `${domain}/autoql/api/v1/query/query-builder?key=${apiKey}`;
8898
+ const config = {
8899
+ headers: {
8900
+ Authorization: `Bearer ${token}`
8901
+ }
8902
+ };
8903
+ let vlInfo = [];
8904
+ if (selectedVL) {
8905
+ vlInfo.push(transformVLForDataExplorerSuggestions(selectedVL));
8906
+ }
8907
+ if (userVLSelection) {
8908
+ const transformedVLs = userVLSelection.map((vl) => transformVLForDataExplorerSuggestions(vl));
8909
+ vlInfo = [...vlInfo, ...transformedVLs];
8910
+ }
8911
+ const data = {
8912
+ page: pageNumber,
8913
+ page_size: pageSize,
8914
+ search_terms: text,
8915
+ context,
8916
+ value_label_info: vlInfo
8917
+ };
8918
+ const suggestionsMock = [
8919
+ {
8920
+ query: "total units sold above DUCKLING_AMOUNT",
8921
+ values: {
8922
+ DUCKLING_AMOUNT: {
8923
+ canonical: "DUCKLING_AMOUNT",
8924
+ format_txt: "100",
8925
+ keyword: "100",
8926
+ display_name: "100"
8927
+ }
8928
+ }
8929
+ },
8930
+ {
8931
+ query: "total sales DUCKLING_TIME",
8932
+ values: {
8933
+ DUCKLING_TIME: {
8934
+ canonical: "DUCKLING_TIME",
8935
+ format_txt: "last year",
8936
+ keyword: "last year",
8937
+ display_name: "last year"
8938
+ }
8939
+ }
8940
+ },
8941
+ {
8942
+ query: "all sales for PUBLIC_0_CUSTOMER_DIMENSION_0_CUSTOMER_NAME_VALUE_LABEL",
8943
+ values: {
8944
+ PUBLIC_0_CUSTOMER_DIMENSION_0_CUSTOMER_NAME_VALUE_LABEL: {
8945
+ show_message: "PUBLIC_0_CUSTOMER_DIMENSION_0_CUSTOMER_NAME_VALUE_LABEL",
8946
+ keyword: "Jack . Li",
8947
+ format_txt: "Jack . Li",
8948
+ canonical: "PUBLIC_0_CUSTOMER_DIMENSION_0_CUSTOMER_NAME_VALUE_LABEL"
8949
+ }
8950
+ }
8951
+ }
8952
+ ];
8953
+ const promise = new Promise((res, rej) => {
8954
+ setTimeout(() => {
8955
+ var _a2, _b2;
8956
+ try {
8957
+ const testResponse = {
8958
+ data: {
8959
+ data: {
8960
+ suggestions: suggestionsMock
8961
+ }
8962
+ }
8963
+ };
8964
+ const suggestions = transformSuggestionResponse((_b2 = (_a2 = testResponse == null ? void 0 : testResponse.data) == null ? void 0 : _a2.data) == null ? void 0 : _b2.suggestions);
8965
+ testResponse.data.data.suggestions = suggestions;
8966
+ res(testResponse);
8967
+ } catch (error) {
8968
+ console.error(error);
8969
+ rej(error);
8970
+ }
8971
+ }, 500);
8972
+ });
8973
+ return promise;
8974
+ };
8609
8975
  var fetchDataExplorerSuggestions = async ({
8610
8976
  pageSize,
8611
8977
  pageNumber,
@@ -8622,7 +8988,7 @@ var fetchDataExplorerSuggestions = async ({
8622
8988
  if (!token || !domain || !apiKey) {
8623
8989
  return Promise.reject(new Error("Unauthenticated"));
8624
8990
  }
8625
- if (!skipQueryValidation) {
8991
+ if (!skipQueryValidation && text) {
8626
8992
  const queryValidationResponse = await runQueryValidation({
8627
8993
  text,
8628
8994
  domain,
@@ -8659,6 +9025,62 @@ var fetchDataExplorerSuggestions = async ({
8659
9025
  return Promise.reject((_a2 = error == null ? void 0 : error.response) == null ? void 0 : _a2.data);
8660
9026
  });
8661
9027
  };
9028
+ var fetchSubjectList = ({ domain, apiKey, token }) => {
9029
+ if (!token || !domain || !apiKey) {
9030
+ return Promise.reject(new Error("Unauthenticated"));
9031
+ }
9032
+ const url = `${domain}/autoql/api/v1/query/subjects?key=${apiKey}`;
9033
+ const config = {
9034
+ headers: {
9035
+ Authorization: `Bearer ${token}`
9036
+ }
9037
+ };
9038
+ return import_axios2.default.get(url, config).then((response) => {
9039
+ var _a, _b;
9040
+ let subjectList = [];
9041
+ if ((_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.subjects) {
9042
+ subjectList = response.data.data.subjects.map((subject) => new DataExplorerSubject(subject)).sort((a, b) => {
9043
+ const aName = a.displayName;
9044
+ const bName = b.displayName;
9045
+ aName.localeCompare(bName);
9046
+ });
9047
+ }
9048
+ return Promise.resolve(subjectList);
9049
+ }).catch((error) => {
9050
+ var _a;
9051
+ return Promise.reject((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data);
9052
+ });
9053
+ };
9054
+ var fetchDataPreview = ({
9055
+ subject,
9056
+ domain,
9057
+ apiKey,
9058
+ token,
9059
+ source = DEFAULT_SOURCE,
9060
+ numRows = 10,
9061
+ cancelToken
9062
+ } = {}) => {
9063
+ if (!subject) {
9064
+ return Promise.reject(new Error("No subject supplied for data preview"));
9065
+ }
9066
+ if (!token || !domain || !apiKey) {
9067
+ return Promise.reject(new Error("Unauthenticated"));
9068
+ }
9069
+ const url = `${domain}/autoql/api/v1/query/preview?key=${apiKey}`;
9070
+ const config = {
9071
+ headers: {
9072
+ Authorization: `Bearer ${token}`
9073
+ },
9074
+ cancelToken
9075
+ };
9076
+ const data = {
9077
+ subject,
9078
+ page_size: numRows,
9079
+ source,
9080
+ date_format: "ISO8601"
9081
+ };
9082
+ return import_axios2.default.post(url, data, config).then((response) => Promise.resolve(response)).catch((error) => Promise.reject(error));
9083
+ };
8662
9084
 
8663
9085
  // src/Api/notificationService.ts
8664
9086
  var import_axios3 = __toESM(require("axios"));
@@ -8675,10 +9097,18 @@ var fetchNotificationData = ({ id, domain, apiKey, token }) => {
8675
9097
  return axiosInstance.get(url).then((response) => {
8676
9098
  var _a, _b;
8677
9099
  const queryResult = (_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.query_result;
8678
- if (queryResult) {
9100
+ let hasQueryResult = false;
9101
+ for (let key in queryResult) {
9102
+ if (queryResult.hasOwnProperty(key)) {
9103
+ hasQueryResult = true;
9104
+ break;
9105
+ }
9106
+ }
9107
+ if (hasQueryResult) {
8679
9108
  return Promise.resolve({ data: queryResult });
9109
+ } else {
9110
+ return Promise.reject({ response: { data: { message: GENERAL_ERROR, hasQueryResult } } });
8680
9111
  }
8681
- return Promise.reject({ response: { data: { message: GENERAL_ERROR } } });
8682
9112
  }).catch((error) => {
8683
9113
  var _a;
8684
9114
  return Promise.reject({ data: (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data });
@@ -9807,8 +10237,10 @@ function color() {
9807
10237
  DEFAULT_LEGEND_PADDING_TOP,
9808
10238
  DEFAULT_MAX_LEGEND_WIDTH,
9809
10239
  DEFAULT_SOURCE,
10240
+ DISPLAY_TYPES,
9810
10241
  DOUBLE_AXIS_CHART_TYPES,
9811
10242
  DOW_STYLES,
10243
+ DataExplorerSubject,
9812
10244
  DataExplorerTypes,
9813
10245
  DateUTC,
9814
10246
  DisplayTypes,
@@ -9837,7 +10269,6 @@ function color() {
9837
10269
  NUMBER_TERM_TYPE,
9838
10270
  PATH_SMOOTHING,
9839
10271
  PERIODIC_TYPE,
9840
- PRECISION_TYPES,
9841
10272
  PROJECT_TYPE,
9842
10273
  PrecisionTypes,
9843
10274
  QUERY_TERM_TYPE,
@@ -9847,6 +10278,7 @@ function color() {
9847
10278
  SCHEDULE_FREQUENCY_OPTIONS,
9848
10279
  SCHEDULE_INTERVAL_OPTIONS,
9849
10280
  SEASON_NAMES,
10281
+ SampleQueryReplacementTypes,
9850
10282
  TABLE_TYPES,
9851
10283
  TITLE_FONT_SIZE,
9852
10284
  ThemeType,
@@ -9886,6 +10318,7 @@ function color() {
9886
10318
  dataStructureChanged,
9887
10319
  dateSortFn,
9888
10320
  dateStringSortFn,
10321
+ dayjs,
9889
10322
  deepEqual,
9890
10323
  deleteDataAlert,
9891
10324
  deleteNotification,
@@ -9899,6 +10332,7 @@ function color() {
9899
10332
  fetchDataAlerts,
9900
10333
  fetchDataExplorerAutocomplete,
9901
10334
  fetchDataExplorerSuggestions,
10335
+ fetchDataExplorerSuggestionsV2,
9902
10336
  fetchDataPreview,
9903
10337
  fetchExploreQueries,
9904
10338
  fetchFilters,
@@ -10024,6 +10458,8 @@ function color() {
10024
10458
  getRangeForAxis,
10025
10459
  getRowNumberListForPopover,
10026
10460
  getSVGBase64,
10461
+ getSampleQueryRegex,
10462
+ getSampleQueryText,
10027
10463
  getScheduleFrequencyObject,
10028
10464
  getStartAndEndDateFromDateStrs,
10029
10465
  getStringColumnIndices,
@@ -10039,6 +10475,7 @@ function color() {
10039
10475
  getTimeRangeFromDateArray,
10040
10476
  getTimeRangeFromRT,
10041
10477
  getTimeScale,
10478
+ getTitleCase,
10042
10479
  getTooltipContent,
10043
10480
  getTotalBottomPadding,
10044
10481
  getTotalHorizontalPadding,
@@ -10094,6 +10531,7 @@ function color() {
10094
10531
  onTableCellClick,
10095
10532
  onlySeriesVisibilityChanged,
10096
10533
  onlyUnique,
10534
+ parseJwt,
10097
10535
  potentiallySupportsDatePivot,
10098
10536
  potentiallySupportsPivot,
10099
10537
  removeElementAtIndex,
@@ -10144,6 +10582,7 @@ function color() {
10144
10582
  updateDataAlert,
10145
10583
  updateDataAlertStatus,
10146
10584
  usePivotDataForChart,
10585
+ uuidv4,
10147
10586
  validateExpression
10148
10587
  });
10149
10588
  //# sourceMappingURL=index.js.map