autoql-fe-utils 1.11.13 → 1.11.15

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.
@@ -14653,6 +14653,14 @@
14653
14653
  fn: max,
14654
14654
  sqlFn: (columnName) => `max(${columnName})`
14655
14655
  }),
14656
+ MEDIAN: new AggType({
14657
+ type: "MEDIAN" /* MEDIAN */,
14658
+ displayName: "Median",
14659
+ tooltip: "<strong>Median:</strong> The median (middle) value will be shown for all data points with same label.",
14660
+ // symbol: 'Median',
14661
+ icon: "median",
14662
+ fn: median
14663
+ }),
14656
14664
  COUNT: new AggType({
14657
14665
  type: "COUNT" /* COUNT */,
14658
14666
  displayName: "Count",
@@ -14679,14 +14687,6 @@
14679
14687
  },
14680
14688
  sqlFn: (columnName) => `count(distinct ${columnName})`
14681
14689
  }),
14682
- MEDIAN: new AggType({
14683
- type: "MEDIAN" /* MEDIAN */,
14684
- displayName: "Median",
14685
- tooltip: "The median (middle) value will be shown for all data points with same label.",
14686
- // symbol: 'Median',
14687
- icon: "median",
14688
- fn: median
14689
- }),
14690
14690
  STD_DEV: new AggType({
14691
14691
  type: "STD_DEV" /* STD_DEV */,
14692
14692
  displayName: "Std Dev",
@@ -15318,8 +15318,15 @@
15318
15318
  return date2.replace(/\'/g, "");
15319
15319
  };
15320
15320
  var isISODate = (str) => {
15321
+ if (!str) {
15322
+ return false;
15323
+ }
15321
15324
  var dateString = str;
15322
15325
  dateString = getDateNoQuotes(dateString);
15326
+ dateString = dateString.trim();
15327
+ if (/^\d{4}-\d{2}-\d{2}$/.test(dateString)) {
15328
+ return false;
15329
+ }
15323
15330
  if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d{1,3})?$/.test(dateString)) {
15324
15331
  return true;
15325
15332
  }
@@ -16030,6 +16037,41 @@
16030
16037
  return array3.slice(0, index).concat(array3.slice(index + 1));
16031
16038
  };
16032
16039
 
16040
+ // src/safeRegex.ts
16041
+ var MAX_PATTERN_LENGTH = Number(process.env.REGEXP_GUARD_MAX_LEN) || 2e3;
16042
+ function isSimpleLiteral(pattern) {
16043
+ return typeof pattern === "string" && /^[A-Za-z0-9 _\-\.,:\/]+$/.test(pattern);
16044
+ }
16045
+ function escapeRegExp(str) {
16046
+ return String(str).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16047
+ }
16048
+ function compileSafeRegex(pattern, flags = "") {
16049
+ if (typeof pattern !== "string") return null;
16050
+ if (pattern.length > MAX_PATTERN_LENGTH) return null;
16051
+ try {
16052
+ return new RegExp(pattern, flags);
16053
+ } catch (e) {
16054
+ return null;
16055
+ }
16056
+ }
16057
+ function safeTest(pattern, input, flags = "") {
16058
+ if (pattern == null || input == null) return false;
16059
+ const strInput = String(input);
16060
+ const re2 = compileSafeRegex(String(pattern), flags);
16061
+ if (re2) {
16062
+ try {
16063
+ return re2.test(strInput);
16064
+ } catch (e) {
16065
+ return false;
16066
+ }
16067
+ }
16068
+ if (isSimpleLiteral(pattern)) {
16069
+ const needle = String(pattern);
16070
+ return flags.includes("i") ? strInput.toLowerCase().includes(needle.toLowerCase()) : strInput.includes(needle);
16071
+ }
16072
+ return false;
16073
+ }
16074
+
16033
16075
  // src/HelperFns/filterEngine.ts
16034
16076
  var FilterOperatorEnum = /* @__PURE__ */ ((FilterOperatorEnum2) => {
16035
16077
  FilterOperatorEnum2["LIKE"] = "like";
@@ -16078,8 +16120,7 @@
16078
16120
  var greaterThanMatcher = (cell, cond) => Number(cell) > Number(cond.value);
16079
16121
  var greaterThanEqMatcher = (cell, cond) => Number(cell) >= Number(cond.value);
16080
16122
  var regexMatcher = (cell, cond) => {
16081
- const reg = new RegExp(String(cond.value));
16082
- return reg.test(String(cell));
16123
+ return safeTest(cond.value, cell);
16083
16124
  };
16084
16125
  var betweenMatcher = (cell, cond) => {
16085
16126
  if (cell == null) return false;
@@ -16135,9 +16176,6 @@
16135
16176
  function isValidFilterType(t) {
16136
16177
  return FILTER_TYPES.includes(t);
16137
16178
  }
16138
- function escapeRegExp(str) {
16139
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16140
- }
16141
16179
  function parseLocaleNumber(value, locale3) {
16142
16180
  var _a, _b;
16143
16181
  if (typeof value === "number") return value;
@@ -16149,10 +16187,20 @@
16149
16187
  const group = (_a = parts.find((p) => p.type === "group")) == null ? void 0 : _a.value;
16150
16188
  const decimal = (_b = parts.find((p) => p.type === "decimal")) == null ? void 0 : _b.value;
16151
16189
  if (group) {
16152
- str = str.replace(new RegExp(escapeRegExp(group), "g"), "");
16190
+ const grpRe = compileSafeRegex(escapeRegExp(group), "g");
16191
+ if (grpRe) {
16192
+ str = str.replace(grpRe, "");
16193
+ } else {
16194
+ str = str.split(group).join("");
16195
+ }
16153
16196
  }
16154
16197
  if (decimal && decimal !== ".") {
16155
- str = str.replace(new RegExp(escapeRegExp(decimal), "g"), ".");
16198
+ const decRe = compileSafeRegex(escapeRegExp(decimal), "g");
16199
+ if (decRe) {
16200
+ str = str.replace(decRe, ".");
16201
+ } else {
16202
+ str = str.split(decimal).join(".");
16203
+ }
16156
16204
  }
16157
16205
  } catch (e) {
16158
16206
  str = str.replace(/[,']/g, "");
@@ -16173,7 +16221,9 @@
16173
16221
  const trimmed = raw.trim();
16174
16222
  if (trimmed.length === 0) return { operator: defaultOperator, value: "", type };
16175
16223
  const opToken = `${"between" /* BETWEEN */}|[<>!=]=?|not_like`;
16176
- const opMatch = new RegExp(`^(${opToken})\\s*(.*)$`, "i").exec(trimmed);
16224
+ const opPattern = `^(${opToken})\\s*(.*)$`;
16225
+ const opRe = compileSafeRegex(opPattern, "i");
16226
+ const opMatch = opRe ? opRe.exec(trimmed) : null;
16177
16227
  if (opMatch) {
16178
16228
  let op = String((_a = opMatch[1]) != null ? _a : "").toLowerCase();
16179
16229
  const rest = (_b = opMatch[2]) != null ? _b : "";
@@ -17301,6 +17351,16 @@
17301
17351
  columnIndexConfig.numberColumnIndices2 = numberColumnIndices2;
17302
17352
  columnIndexConfig.numberColumnIndex2 = numberColumnIndex2;
17303
17353
  }
17354
+ if (usePivotData && isNumber(columnIndexConfig.legendColumnIndex) && isNumber(columnIndexConfig.numberColumnIndex) && columnIndexConfig.legendColumnIndex === columnIndexConfig.numberColumnIndex) {
17355
+ console.debug(
17356
+ "Table config invalid: legendColumnIndex and numberColumnIndex are the same.",
17357
+ {
17358
+ legendColumnIndex: columnIndexConfig.legendColumnIndex,
17359
+ numberColumnIndex: columnIndexConfig.numberColumnIndex
17360
+ }
17361
+ );
17362
+ return false;
17363
+ }
17304
17364
  return true;
17305
17365
  } catch (error) {
17306
17366
  console.debug("Saved table config was not valid for response:", error == null ? void 0 : error.message);
@@ -19056,16 +19116,16 @@
19056
19116
  var DARK_THEME = {
19057
19117
  "accent-color": "#193a48",
19058
19118
  "accent-color-secondary": "#1ea0d8",
19059
- "background-color-primary": "#20252A",
19060
- "background-color-secondary": "#3B3F46",
19119
+ "background-color-primary": "#15191c",
19120
+ "background-color-secondary": "#1d222b",
19061
19121
  "background-color-tertiary": "#292929",
19062
19122
  "background-color-switch-input": "#252525",
19063
19123
  "background-color-switch-thumb": "#ececec",
19064
19124
  "background-color-checkbox": "#292929",
19065
19125
  "background-color-disabled": "#5d6167",
19066
19126
  "background-color-disabled-dark": "#857d83",
19067
- "table-border-color": "#53565c",
19068
- "border-color": "#53565c",
19127
+ "table-border-color": "#2c2e32",
19128
+ "border-color": "#43464b",
19069
19129
  "hover-color": "#4a4f56",
19070
19130
  "text-color-primary": "#ececec",
19071
19131
  "text-color-secondary": "#bababa",
@@ -22293,8 +22353,8 @@
22293
22353
  return Math.abs(x = Math.round(x)) >= 1e21 ? x.toLocaleString("en").replace(/,/g, "") : x.toString(10);
22294
22354
  }
22295
22355
  function formatDecimalParts(x, p) {
22296
- if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null;
22297
- var i, coefficient = x.slice(0, i);
22356
+ if (!isFinite(x) || x === 0) return null;
22357
+ var i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e"), coefficient = x.slice(0, i);
22298
22358
  return [
22299
22359
  coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
22300
22360
  +x.slice(i + 1)
@@ -22388,7 +22448,7 @@
22388
22448
  var prefixExponent;
22389
22449
  function formatPrefixAuto_default(x, p) {
22390
22450
  var d = formatDecimalParts(x, p);
22391
- if (!d) return x + "";
22451
+ if (!d) return prefixExponent = void 0, x.toPrecision(p);
22392
22452
  var coefficient = d[0], exponent = d[1], i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n = coefficient.length;
22393
22453
  return i === n ? coefficient : i > n ? coefficient + new Array(i - n + 1).join("0") : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0];
22394
22454
  }
@@ -22428,13 +22488,13 @@
22428
22488
  var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
22429
22489
  function locale_default(locale3) {
22430
22490
  var group = locale3.grouping === void 0 || locale3.thousands === void 0 ? identity_default : formatGroup_default(map2.call(locale3.grouping, Number), locale3.thousands + ""), currencyPrefix = locale3.currency === void 0 ? "" : locale3.currency[0] + "", currencySuffix = locale3.currency === void 0 ? "" : locale3.currency[1] + "", decimal = locale3.decimal === void 0 ? "." : locale3.decimal + "", numerals = locale3.numerals === void 0 ? identity_default : formatNumerals_default(map2.call(locale3.numerals, String)), percent = locale3.percent === void 0 ? "%" : locale3.percent + "", minus = locale3.minus === void 0 ? "\u2212" : locale3.minus + "", nan = locale3.nan === void 0 ? "NaN" : locale3.nan + "";
22431
- function newFormat(specifier) {
22491
+ function newFormat(specifier, options) {
22432
22492
  specifier = formatSpecifier(specifier);
22433
22493
  var fill = specifier.fill, align = specifier.align, sign = specifier.sign, symbol = specifier.symbol, zero3 = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim2 = specifier.trim, type = specifier.type;
22434
22494
  if (type === "n") comma = true, type = "g";
22435
22495
  else if (!formatTypes_default[type]) precision === void 0 && (precision = 12), trim2 = true, type = "g";
22436
22496
  if (zero3 || fill === "0" && align === "=") zero3 = true, fill = "0", align = "=";
22437
- var prefix2 = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
22497
+ var prefix2 = (options && options.prefix !== void 0 ? options.prefix : "") + (symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : ""), suffix = (symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "") + (options && options.suffix !== void 0 ? options.suffix : "");
22438
22498
  var formatType = formatTypes_default[type], maybeSuffix = /[defgprs%]/.test(type);
22439
22499
  precision = precision === void 0 ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision));
22440
22500
  function format2(value) {
@@ -22449,7 +22509,7 @@
22449
22509
  if (trim2) value = formatTrim_default(value);
22450
22510
  if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
22451
22511
  valuePrefix = (valueNegative ? sign === "(" ? sign : minus : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
22452
- valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
22512
+ valueSuffix = (type === "s" && !isNaN(value) && prefixExponent !== void 0 ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
22453
22513
  if (maybeSuffix) {
22454
22514
  i = -1, n = value.length;
22455
22515
  while (++i < n) {
@@ -22486,9 +22546,9 @@
22486
22546
  return format2;
22487
22547
  }
22488
22548
  function formatPrefix2(specifier, value) {
22489
- var f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), e = Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3, k = Math.pow(10, -e), prefix2 = prefixes[8 + e / 3];
22549
+ var e = Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3, k = Math.pow(10, -e), f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier), { suffix: prefixes[8 + e / 3] });
22490
22550
  return function(value2) {
22491
- return f(k * value2) + prefix2;
22551
+ return f(k * value2);
22492
22552
  };
22493
22553
  }
22494
22554
  return {
@@ -26447,6 +26507,33 @@
26447
26507
  var REQUEST_CANCELLED_ERROR = "Request cancelled";
26448
26508
  var QUERY_TIMEOUT_ERROR = "Database Timeout Error: Your query has exceeded the time limit. To receive a response, try narrowing your query down to a specific time range (e.g., today, this week, this month), or contact your database administrator.";
26449
26509
 
26510
+ // src/Api/axiosUtils.ts
26511
+ var createRequestController = () => {
26512
+ if (typeof AbortController !== "undefined") return new AbortController();
26513
+ return { abort: () => {
26514
+ }, signal: void 0 };
26515
+ };
26516
+ var attachCancelToConfig = (config = {}, cancelToken) => {
26517
+ if (!cancelToken) return config;
26518
+ if (typeof AbortController !== "undefined" && cancelToken instanceof AbortController)
26519
+ return { ...config, signal: cancelToken.signal };
26520
+ if (typeof AbortSignal !== "undefined" && cancelToken instanceof AbortSignal)
26521
+ return { ...config, signal: cancelToken };
26522
+ if (cancelToken && cancelToken.constructor && cancelToken.constructor.name === "AbortSignal")
26523
+ return { ...config, signal: cancelToken };
26524
+ if (cancelToken && cancelToken.promise && typeof cancelToken.promise.then === "function") {
26525
+ try {
26526
+ const controller = new AbortController();
26527
+ cancelToken.promise.then(() => controller.abort());
26528
+ return { ...config, signal: controller.signal, cancelToken };
26529
+ } catch (e) {
26530
+ return { ...config, cancelToken };
26531
+ }
26532
+ }
26533
+ return { ...config, cancelToken };
26534
+ };
26535
+ var axiosUtils_default = attachCancelToConfig;
26536
+
26450
26537
  // node_modules/axios/lib/helpers/bind.js
26451
26538
  function bind(fn, thisArg) {
26452
26539
  return function wrap() {
@@ -30176,7 +30263,10 @@
30176
30263
  const drilldownGroupby = getDrilldownGroupby(response, col);
30177
30264
  let additional = false;
30178
30265
  let is_timestamp = false;
30179
- if (addedColumns == null ? void 0 : addedColumns.find((select) => select.columns.includes(col.alt_name || col.name))) {
30266
+ if (addedColumns == null ? void 0 : addedColumns.find((select) => {
30267
+ var _a3;
30268
+ return select.columns.includes((_a3 = col.alt_name) != null ? _a3 : col.name);
30269
+ })) {
30180
30270
  additional = true;
30181
30271
  }
30182
30272
  if (isColumnDateType(col) && isISODate(dataSample)) {
@@ -30250,7 +30340,7 @@
30250
30340
  };
30251
30341
  var isError500Type = (referenceId) => {
30252
30342
  try {
30253
- const parsedReferenceId = referenceId == null ? void 0 : referenceId.split(".");
30343
+ const parsedReferenceId = typeof referenceId === "string" ? referenceId.split(".") : String(referenceId != null ? referenceId : "").split(".");
30254
30344
  const errorCode = Number(parsedReferenceId == null ? void 0 : parsedReferenceId[2]);
30255
30345
  if (errorCode >= 500 && errorCode < 600) {
30256
30346
  return true;
@@ -30293,12 +30383,14 @@
30293
30383
  if (queryId) {
30294
30384
  relatedQueriesUrl = `${relatedQueriesUrl}&query_id=${queryId}`;
30295
30385
  }
30296
- const config = {
30297
- headers: {
30298
- Authorization: `Bearer ${token}`
30386
+ const config = axiosUtils_default(
30387
+ {
30388
+ headers: {
30389
+ Authorization: `Bearer ${token}`
30390
+ }
30299
30391
  },
30300
30392
  cancelToken
30301
- };
30393
+ );
30302
30394
  return axios_default.get(relatedQueriesUrl, config).then((response) => Promise.resolve(response)).catch((error) => Promise.reject(error == null ? void 0 : error.response));
30303
30395
  };
30304
30396
  var runQueryNewPage = ({
@@ -30319,12 +30411,14 @@
30319
30411
  const data = {
30320
30412
  date_format: "ISO8601"
30321
30413
  };
30322
- const config = {
30323
- headers: {
30324
- Authorization: `Bearer ${token}`
30414
+ const config = axiosUtils_default(
30415
+ {
30416
+ headers: {
30417
+ Authorization: `Bearer ${token}`
30418
+ }
30325
30419
  },
30326
30420
  cancelToken
30327
- };
30421
+ );
30328
30422
  return axios_default.post(url2, data, config).then((response) => {
30329
30423
  var _a, _b;
30330
30424
  if (response.data && typeof response.data === "string") {
@@ -30386,12 +30480,14 @@
30386
30480
  console.error("authentication invalid for request");
30387
30481
  return Promise.reject({ error: "Unauthenticated" /* UNAUTHENTICATED */ });
30388
30482
  }
30389
- const config = {
30390
- headers: {
30391
- Authorization: `Bearer ${token}`
30483
+ const config = axiosUtils_default(
30484
+ {
30485
+ headers: {
30486
+ Authorization: `Bearer ${token}`
30487
+ }
30392
30488
  },
30393
30489
  cancelToken
30394
- };
30490
+ );
30395
30491
  return axios_default.post(url2, data, config).then((response) => {
30396
30492
  var _a;
30397
30493
  if (!((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data)) {
@@ -30424,12 +30520,14 @@
30424
30520
  return Promise.reject(new Error("Unauthenticated" /* UNAUTHENTICATED */));
30425
30521
  }
30426
30522
  const url2 = `${domain}/autoql/api/v1/query/validate?text=${encodeURIComponent(text)}&key=${apiKey}`;
30427
- const config = {
30428
- headers: {
30429
- Authorization: `Bearer ${token}`
30523
+ const config = axiosUtils_default(
30524
+ {
30525
+ headers: {
30526
+ Authorization: `Bearer ${token}`
30527
+ }
30430
30528
  },
30431
30529
  cancelToken
30432
- };
30530
+ );
30433
30531
  return axios_default.get(url2, config).then((response) => Promise.resolve(response)).catch((error) => formatErrorResponse(error));
30434
30532
  };
30435
30533
  var runQuery = async ({
@@ -30561,6 +30659,73 @@
30561
30659
  return formatErrorResponse(error);
30562
30660
  });
30563
30661
  };
30662
+ var runCachedDashboardQueryPost = async ({
30663
+ query,
30664
+ domain,
30665
+ apiKey,
30666
+ token,
30667
+ source,
30668
+ orders,
30669
+ filters,
30670
+ tableFilters,
30671
+ allowSuggestions,
30672
+ cancelToken,
30673
+ scope,
30674
+ newColumns,
30675
+ queryIndex,
30676
+ tileKey,
30677
+ dashboardId,
30678
+ force
30679
+ } = {}) => {
30680
+ if (!dashboardId) {
30681
+ console.error("No dashboard ID supplied in request");
30682
+ return Promise.reject({ error: "Dashboard ID not supplied" });
30683
+ }
30684
+ if (!tileKey) {
30685
+ console.error("No tile key supplied in request");
30686
+ return Promise.reject({ error: "Tile key not supplied" });
30687
+ }
30688
+ if (!apiKey || !domain || !token) {
30689
+ console.error("authentication invalid for request");
30690
+ return Promise.reject({ error: "authentication invalid for request" });
30691
+ }
30692
+ let finalScope = scope;
30693
+ if (!!(source == null ? void 0 : source.includes) && source.includes("data_messenger")) {
30694
+ finalScope = "data_messenger";
30695
+ }
30696
+ const queryParams = new URLSearchParams({
30697
+ key: apiKey
30698
+ });
30699
+ const data = {
30700
+ query_index: (queryIndex || 0).toString(),
30701
+ force,
30702
+ session_filter_locks: filters
30703
+ };
30704
+ const url2 = `${domain}/autoql/api/v1/dashboards/${dashboardId}/tiles/${tileKey}/query?${queryParams.toString()}`;
30705
+ const config = {
30706
+ headers: {
30707
+ Authorization: `Bearer ${token}`
30708
+ }
30709
+ };
30710
+ const finalConfig = axiosUtils_default(config, cancelToken);
30711
+ return axios_default.post(url2, data, finalConfig).then((response) => {
30712
+ var _a;
30713
+ if (!((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data)) {
30714
+ throw new Error("Parse error" /* PARSE_ERROR */);
30715
+ }
30716
+ return Promise.resolve(transformQueryResponse(response, void 0, void 0, newColumns));
30717
+ }).catch((error) => {
30718
+ var _a, _b, _c, _d, _e;
30719
+ const referenceId = (_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.reference_id;
30720
+ const isSubquery = (tableFilters == null ? void 0 : tableFilters.length) || (orders == null ? void 0 : orders.length);
30721
+ const needsSuggestions = referenceId === "1.1.430" || referenceId === "1.1.431" || isError500Type(referenceId);
30722
+ if (needsSuggestions && allowSuggestions && !isSubquery) {
30723
+ const queryId = (_e = (_d = (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.data) == null ? void 0 : _e.query_id;
30724
+ return fetchSuggestions({ query, queryId, domain, apiKey, token, cancelToken });
30725
+ }
30726
+ return formatErrorResponse(error);
30727
+ });
30728
+ };
30564
30729
  var exportCSV = ({
30565
30730
  queryId,
30566
30731
  domain,
@@ -30623,12 +30788,14 @@
30623
30788
  additional_selects: newColumns,
30624
30789
  display_overrides: displayOverrides
30625
30790
  };
30626
- const config = {
30627
- headers: {
30628
- Authorization: `Bearer ${token}`
30791
+ const config = axiosUtils_default(
30792
+ {
30793
+ headers: {
30794
+ Authorization: `Bearer ${token}`
30795
+ }
30629
30796
  },
30630
30797
  cancelToken
30631
- };
30798
+ );
30632
30799
  const url2 = `${domain}/autoql/api/v1/query/${queryID}/drilldown?key=${apiKey}`;
30633
30800
  return axios_default.post(url2, requestData, config).then((response) => transformQueryResponse(response, queryID, true)).catch(formatErrorResponse);
30634
30801
  };
@@ -30703,12 +30870,14 @@
30703
30870
  if (filter3) {
30704
30871
  url2 = `${url2}&filter=${filter3}`;
30705
30872
  }
30706
- const config = {
30707
- headers: {
30708
- Authorization: `Bearer ${token}`
30873
+ const config = axiosUtils_default(
30874
+ {
30875
+ headers: {
30876
+ Authorization: `Bearer ${token}`
30877
+ }
30709
30878
  },
30710
30879
  cancelToken
30711
- };
30880
+ );
30712
30881
  return axios_default.get(url2, config).then((response) => Promise.resolve(response)).catch((error) => {
30713
30882
  var _a2;
30714
30883
  if ((error == null ? void 0 : error.message) === REQUEST_CANCELLED_ERROR) {
@@ -30878,7 +31047,8 @@
30878
31047
  queryId,
30879
31048
  domain,
30880
31049
  apiKey,
30881
- token
31050
+ token,
31051
+ isCorrect = false
30882
31052
  } = {}) => {
30883
31053
  if (!queryId) {
30884
31054
  return Promise.reject(new Error("No query ID supplied" /* NO_QUERY_ID_SUPPLIED */));
@@ -30893,7 +31063,7 @@
30893
31063
  }
30894
31064
  };
30895
31065
  const data = {
30896
- is_correct: false,
31066
+ is_correct: isCorrect,
30897
31067
  message
30898
31068
  };
30899
31069
  return axios_default.put(url2, data, config).then((response) => Promise.resolve(response)).catch((error) => {
@@ -30932,8 +31102,12 @@
30932
31102
  };
30933
31103
  var getSampleQueryRegex = (suggestionValues) => {
30934
31104
  const valueArray = Object.keys(suggestionValues);
30935
- const valueRegexArray = valueArray.map((value) => `\\b${value}\\b`);
30936
- const valueRegex = new RegExp(valueRegexArray.join("|"), "gm");
31105
+ const valueRegexArray = valueArray.map((value) => {
31106
+ const esc = String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
31107
+ return `\\b${esc}\\b`;
31108
+ });
31109
+ const pattern = valueRegexArray.join("|");
31110
+ const valueRegex = compileSafeRegex(pattern, "gm");
30937
31111
  return valueRegex;
30938
31112
  };
30939
31113
  var getSampleQueryText = (query, values = {}) => {
@@ -30947,9 +31121,14 @@
30947
31121
  var _a;
30948
31122
  const chunk = values[valueKey];
30949
31123
  const replacementText = (_a = chunk == null ? void 0 : chunk.replacement) == null ? void 0 : _a.format_txt;
30950
- const valueKeyRegex = new RegExp(`\\b${valueKey}\\b`);
31124
+ const pattern = `\\b${valueKey}\\b`;
31125
+ const valueKeyRegex = compileSafeRegex(pattern);
30951
31126
  if (replacementText) {
30952
- queryText = queryText.replace(valueKeyRegex, replacementText);
31127
+ if (valueKeyRegex) {
31128
+ queryText = queryText.replace(valueKeyRegex, replacementText);
31129
+ } else if (isSimpleLiteral(valueKey)) {
31130
+ queryText = String(queryText).split(valueKey).join(replacementText);
31131
+ }
30953
31132
  }
30954
31133
  });
30955
31134
  return queryText;
@@ -31041,6 +31220,7 @@
31041
31220
  }
31042
31221
  };
31043
31222
  var getSampleQueryChunks = (query, values = {}) => {
31223
+ var _a, _b;
31044
31224
  try {
31045
31225
  const valueArray = Object.keys(values);
31046
31226
  if (!(valueArray == null ? void 0 : valueArray.length)) {
@@ -31052,22 +31232,57 @@
31052
31232
  }
31053
31233
  ];
31054
31234
  }
31055
- const valueRegexArray = valueArray.map((value) => `(\\b${value}\\b)`);
31056
- const valueRegex = new RegExp(valueRegexArray.join("|"), "gm");
31057
31235
  let splitStrArray = [query];
31058
- if (valueArray == null ? void 0 : valueArray.length) {
31059
- splitStrArray = query.split(valueRegex);
31236
+ if (valueArray.length < 500) {
31237
+ const valueRegexArray = valueArray.map((value) => {
31238
+ const esc = String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
31239
+ return `(\\b${esc}\\b)`;
31240
+ });
31241
+ const pattern = valueRegexArray.join("|");
31242
+ const valueRegex = compileSafeRegex(pattern, "gm");
31243
+ if (valueRegex) {
31244
+ splitStrArray = query.split(valueRegex);
31245
+ }
31246
+ }
31247
+ if (splitStrArray.length === 1) {
31248
+ const result = [];
31249
+ let remaining = query;
31250
+ const sortedValues = [...valueArray].sort((a, b) => b.length - a.length);
31251
+ for (const value of sortedValues) {
31252
+ const escaped = String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
31253
+ const re2 = compileSafeRegex(`\\b${escaped}\\b`, "i");
31254
+ let match = null;
31255
+ let matchedText = "";
31256
+ if (re2) {
31257
+ match = re2.exec(remaining);
31258
+ matchedText = (_a = match == null ? void 0 : match[0]) != null ? _a : "";
31259
+ } else if (isSimpleLiteral(value)) {
31260
+ const idx = remaining.toLowerCase().indexOf(String(value).toLowerCase());
31261
+ if (idx >= 0) {
31262
+ match = [String(value)];
31263
+ matchedText = remaining.substr(idx, String(value).length);
31264
+ match.index = idx;
31265
+ }
31266
+ }
31267
+ if (match) {
31268
+ const matchIndex = (_b = match.index) != null ? _b : 0;
31269
+ result.push(remaining.substring(0, matchIndex), matchedText || match[0]);
31270
+ remaining = remaining.substring(matchIndex + (matchedText || match[0]).length);
31271
+ }
31272
+ }
31273
+ if (remaining) result.push(remaining);
31274
+ splitStrArray = result;
31060
31275
  }
31061
31276
  const chunkedSuggestion = [];
31062
31277
  splitStrArray.forEach((key) => {
31063
- var _a, _b;
31064
- const replacement = (_a = values[key]) == null ? void 0 : _a.replacement;
31278
+ var _a2, _b2;
31279
+ const replacement = (_a2 = values[key]) == null ? void 0 : _a2.replacement;
31065
31280
  const type = getSampleQueryReplacementType(key, replacement);
31066
31281
  const name = key == null ? void 0 : key.trim();
31067
31282
  if (!type || !name) {
31068
31283
  return;
31069
31284
  }
31070
- let value = (_b = replacement == null ? void 0 : replacement.format_txt) == null ? void 0 : _b.trim();
31285
+ let value = (_b2 = replacement == null ? void 0 : replacement.format_txt) == null ? void 0 : _b2.trim();
31071
31286
  if (type == "TEXT" /* SAMPLE_QUERY_TEXT_TYPE */) {
31072
31287
  value = name;
31073
31288
  }
@@ -31120,12 +31335,14 @@
31120
31335
  if (timezone2) {
31121
31336
  url2 = `${url2}&time_zone=${timezone2}`;
31122
31337
  }
31123
- const config = {
31124
- headers: {
31125
- Authorization: `Bearer ${token}`
31338
+ const config = axiosUtils_default(
31339
+ {
31340
+ headers: {
31341
+ Authorization: `Bearer ${token}`
31342
+ }
31126
31343
  },
31127
31344
  cancelToken
31128
- };
31345
+ );
31129
31346
  return axios_default.get(url2, config).then((response) => {
31130
31347
  return transformDataExplorerAutocompleteResponse(response);
31131
31348
  }).catch((error) => {
@@ -31139,10 +31356,11 @@
31139
31356
  });
31140
31357
  };
31141
31358
  var transformVLForDataExplorerSuggestions = (vl) => {
31359
+ var _a;
31142
31360
  return {
31143
31361
  name: vl.keyword,
31144
31362
  alias_name: vl.show_message,
31145
- column_name: vl.column_name
31363
+ column_name: (_a = vl.column_name) != null ? _a : ""
31146
31364
  };
31147
31365
  };
31148
31366
  var fetchDataExplorerSampleQueries = async ({
@@ -31160,12 +31378,14 @@
31160
31378
  context,
31161
31379
  columns
31162
31380
  };
31163
- const config = {
31164
- headers: {
31165
- Authorization: `Bearer ${token}`
31381
+ const config = axiosUtils_default(
31382
+ {
31383
+ headers: {
31384
+ Authorization: `Bearer ${token}`
31385
+ }
31166
31386
  },
31167
31387
  cancelToken
31168
- };
31388
+ );
31169
31389
  return axios_default.post(url2, data, config).then((response) => {
31170
31390
  var _a, _b, _c, _d;
31171
31391
  if ((_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.suggestions) {
@@ -31231,7 +31451,13 @@
31231
31451
  return Promise.reject((_a2 = error == null ? void 0 : error.response) == null ? void 0 : _a2.data);
31232
31452
  });
31233
31453
  };
31234
- var fetchSubjectListV2 = ({ domain, apiKey, token, valueLabel, cancelToken }) => {
31454
+ var fetchSubjectListV2 = ({
31455
+ domain,
31456
+ apiKey,
31457
+ token,
31458
+ valueLabel,
31459
+ cancelToken
31460
+ }) => {
31235
31461
  if (!token || !domain || !apiKey) {
31236
31462
  return Promise.reject(new Error("Unauthenticated"));
31237
31463
  }
@@ -31239,12 +31465,14 @@
31239
31465
  if (valueLabel) {
31240
31466
  url2 += `&value_label=${valueLabel}`;
31241
31467
  }
31242
- const config = {
31243
- headers: {
31244
- Authorization: `Bearer ${token}`
31468
+ const config = axiosUtils_default(
31469
+ {
31470
+ headers: {
31471
+ Authorization: `Bearer ${token}`
31472
+ }
31245
31473
  },
31246
31474
  cancelToken
31247
- };
31475
+ );
31248
31476
  return axios_default.get(url2, config).then((response) => {
31249
31477
  var _a, _b;
31250
31478
  let subjectList = [];
@@ -31306,12 +31534,14 @@
31306
31534
  return Promise.reject(new Error("Unauthenticated"));
31307
31535
  }
31308
31536
  const url2 = `${domain}/autoql/api/v1/query/preview?key=${apiKey}`;
31309
- const config = {
31310
- headers: {
31311
- Authorization: `Bearer ${token}`
31537
+ const config = axiosUtils_default(
31538
+ {
31539
+ headers: {
31540
+ Authorization: `Bearer ${token}`
31541
+ }
31312
31542
  },
31313
31543
  cancelToken
31314
- };
31544
+ );
31315
31545
  const data = {
31316
31546
  subject,
31317
31547
  page_size: numRows,