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.
package/dist/index.js CHANGED
@@ -813,6 +813,7 @@ __export(index_exports, {
813
813
  areAllColumnsHidden: () => areAllColumnsHidden,
814
814
  areSomeColumnsHidden: () => areSomeColumnsHidden,
815
815
  assignLabelToManagementDataAlert: () => assignLabelToManagementDataAlert,
816
+ attachCancelToConfig: () => attachCancelToConfig,
816
817
  authenticationDefault: () => authenticationDefault,
817
818
  autoQLConfigDefault: () => autoQLConfigDefault,
818
819
  bezierCommand: () => bezierCommand,
@@ -831,6 +832,7 @@ __export(index_exports, {
831
832
  createManagementDataAlert: () => createManagementDataAlert,
832
833
  createMutatorFn: () => createMutatorFn,
833
834
  createNotificationChannel: () => createNotificationChannel,
835
+ createRequestController: () => createRequestController,
834
836
  createSVGPath: () => createSVGPath,
835
837
  currentEventLoopEnd: () => currentEventLoopEnd,
836
838
  dataConfigDefault: () => dataConfigDefault,
@@ -1143,6 +1145,7 @@ __export(index_exports, {
1143
1145
  roundToNearestMultiple: () => roundToNearestMultiple,
1144
1146
  roundUpToNearestMultiple: () => roundUpToNearestMultiple,
1145
1147
  runCachedDashboardQuery: () => runCachedDashboardQuery,
1148
+ runCachedDashboardQueryPost: () => runCachedDashboardQueryPost,
1146
1149
  runDrilldown: () => runDrilldown,
1147
1150
  runQuery: () => runQuery,
1148
1151
  runQueryNewPage: () => runQueryNewPage,
@@ -1644,6 +1647,14 @@ var AGG_TYPES = {
1644
1647
  fn: import_d3_array2.max,
1645
1648
  sqlFn: (columnName) => `max(${columnName})`
1646
1649
  }),
1650
+ MEDIAN: new AggType({
1651
+ type: "MEDIAN" /* MEDIAN */,
1652
+ displayName: "Median",
1653
+ tooltip: "<strong>Median:</strong> The median (middle) value will be shown for all data points with same label.",
1654
+ // symbol: 'Median',
1655
+ icon: "median",
1656
+ fn: import_d3_array2.median
1657
+ }),
1647
1658
  COUNT: new AggType({
1648
1659
  type: "COUNT" /* COUNT */,
1649
1660
  displayName: "Count",
@@ -1670,14 +1681,6 @@ var AGG_TYPES = {
1670
1681
  },
1671
1682
  sqlFn: (columnName) => `count(distinct ${columnName})`
1672
1683
  }),
1673
- MEDIAN: new AggType({
1674
- type: "MEDIAN" /* MEDIAN */,
1675
- displayName: "Median",
1676
- tooltip: "The median (middle) value will be shown for all data points with same label.",
1677
- // symbol: 'Median',
1678
- icon: "median",
1679
- fn: import_d3_array2.median
1680
- }),
1681
1684
  STD_DEV: new AggType({
1682
1685
  type: "STD_DEV" /* STD_DEV */,
1683
1686
  displayName: "Std Dev",
@@ -2309,8 +2312,15 @@ var getDateNoQuotes = (date) => {
2309
2312
  return date.replace(/\'/g, "");
2310
2313
  };
2311
2314
  var isISODate = (str) => {
2315
+ if (!str) {
2316
+ return false;
2317
+ }
2312
2318
  var dateString = str;
2313
2319
  dateString = getDateNoQuotes(dateString);
2320
+ dateString = dateString.trim();
2321
+ if (/^\d{4}-\d{2}-\d{2}$/.test(dateString)) {
2322
+ return false;
2323
+ }
2314
2324
  if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(\.\d{1,3})?$/.test(dateString)) {
2315
2325
  return true;
2316
2326
  }
@@ -3021,6 +3031,41 @@ var removeElementAtIndex = (array, index) => {
3021
3031
  return array.slice(0, index).concat(array.slice(index + 1));
3022
3032
  };
3023
3033
 
3034
+ // src/safeRegex.ts
3035
+ var MAX_PATTERN_LENGTH = Number(process.env.REGEXP_GUARD_MAX_LEN) || 2e3;
3036
+ function isSimpleLiteral(pattern) {
3037
+ return typeof pattern === "string" && /^[A-Za-z0-9 _\-\.,:\/]+$/.test(pattern);
3038
+ }
3039
+ function escapeRegExp(str) {
3040
+ return String(str).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3041
+ }
3042
+ function compileSafeRegex(pattern, flags = "") {
3043
+ if (typeof pattern !== "string") return null;
3044
+ if (pattern.length > MAX_PATTERN_LENGTH) return null;
3045
+ try {
3046
+ return new RegExp(pattern, flags);
3047
+ } catch (e) {
3048
+ return null;
3049
+ }
3050
+ }
3051
+ function safeTest(pattern, input, flags = "") {
3052
+ if (pattern == null || input == null) return false;
3053
+ const strInput = String(input);
3054
+ const re2 = compileSafeRegex(String(pattern), flags);
3055
+ if (re2) {
3056
+ try {
3057
+ return re2.test(strInput);
3058
+ } catch (e) {
3059
+ return false;
3060
+ }
3061
+ }
3062
+ if (isSimpleLiteral(pattern)) {
3063
+ const needle = String(pattern);
3064
+ return flags.includes("i") ? strInput.toLowerCase().includes(needle.toLowerCase()) : strInput.includes(needle);
3065
+ }
3066
+ return false;
3067
+ }
3068
+
3024
3069
  // src/HelperFns/filterEngine.ts
3025
3070
  var FilterOperatorEnum = /* @__PURE__ */ ((FilterOperatorEnum2) => {
3026
3071
  FilterOperatorEnum2["LIKE"] = "like";
@@ -3069,8 +3114,7 @@ var lessThanEqMatcher = (cell, cond) => Number(cell) <= Number(cond.value);
3069
3114
  var greaterThanMatcher = (cell, cond) => Number(cell) > Number(cond.value);
3070
3115
  var greaterThanEqMatcher = (cell, cond) => Number(cell) >= Number(cond.value);
3071
3116
  var regexMatcher = (cell, cond) => {
3072
- const reg = new RegExp(String(cond.value));
3073
- return reg.test(String(cell));
3117
+ return safeTest(cond.value, cell);
3074
3118
  };
3075
3119
  var betweenMatcher = (cell, cond) => {
3076
3120
  if (cell == null) return false;
@@ -3126,9 +3170,6 @@ var FILTER_TYPES = ["string", "number", "date", "boolean"];
3126
3170
  function isValidFilterType(t) {
3127
3171
  return FILTER_TYPES.includes(t);
3128
3172
  }
3129
- function escapeRegExp(str) {
3130
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3131
- }
3132
3173
  function parseLocaleNumber(value, locale2) {
3133
3174
  var _a, _b;
3134
3175
  if (typeof value === "number") return value;
@@ -3140,10 +3181,20 @@ function parseLocaleNumber(value, locale2) {
3140
3181
  const group = (_a = parts.find((p) => p.type === "group")) == null ? void 0 : _a.value;
3141
3182
  const decimal = (_b = parts.find((p) => p.type === "decimal")) == null ? void 0 : _b.value;
3142
3183
  if (group) {
3143
- str = str.replace(new RegExp(escapeRegExp(group), "g"), "");
3184
+ const grpRe = compileSafeRegex(escapeRegExp(group), "g");
3185
+ if (grpRe) {
3186
+ str = str.replace(grpRe, "");
3187
+ } else {
3188
+ str = str.split(group).join("");
3189
+ }
3144
3190
  }
3145
3191
  if (decimal && decimal !== ".") {
3146
- str = str.replace(new RegExp(escapeRegExp(decimal), "g"), ".");
3192
+ const decRe = compileSafeRegex(escapeRegExp(decimal), "g");
3193
+ if (decRe) {
3194
+ str = str.replace(decRe, ".");
3195
+ } else {
3196
+ str = str.split(decimal).join(".");
3197
+ }
3147
3198
  }
3148
3199
  } catch (e) {
3149
3200
  str = str.replace(/[,']/g, "");
@@ -3164,7 +3215,9 @@ function parseFilter(raw, type, defaultOperator = "like" /* LIKE */) {
3164
3215
  const trimmed = raw.trim();
3165
3216
  if (trimmed.length === 0) return { operator: defaultOperator, value: "", type };
3166
3217
  const opToken = `${"between" /* BETWEEN */}|[<>!=]=?|not_like`;
3167
- const opMatch = new RegExp(`^(${opToken})\\s*(.*)$`, "i").exec(trimmed);
3218
+ const opPattern = `^(${opToken})\\s*(.*)$`;
3219
+ const opRe = compileSafeRegex(opPattern, "i");
3220
+ const opMatch = opRe ? opRe.exec(trimmed) : null;
3168
3221
  if (opMatch) {
3169
3222
  let op = String((_a = opMatch[1]) != null ? _a : "").toLowerCase();
3170
3223
  const rest = (_b = opMatch[2]) != null ? _b : "";
@@ -4292,6 +4345,16 @@ var isColumnIndexConfigValid = ({ response, columnIndexConfig, columns, displayT
4292
4345
  columnIndexConfig.numberColumnIndices2 = numberColumnIndices2;
4293
4346
  columnIndexConfig.numberColumnIndex2 = numberColumnIndex2;
4294
4347
  }
4348
+ if (usePivotData && isNumber(columnIndexConfig.legendColumnIndex) && isNumber(columnIndexConfig.numberColumnIndex) && columnIndexConfig.legendColumnIndex === columnIndexConfig.numberColumnIndex) {
4349
+ console.debug(
4350
+ "Table config invalid: legendColumnIndex and numberColumnIndex are the same.",
4351
+ {
4352
+ legendColumnIndex: columnIndexConfig.legendColumnIndex,
4353
+ numberColumnIndex: columnIndexConfig.numberColumnIndex
4354
+ }
4355
+ );
4356
+ return false;
4357
+ }
4295
4358
  return true;
4296
4359
  } catch (error) {
4297
4360
  console.debug("Saved table config was not valid for response:", error == null ? void 0 : error.message);
@@ -6047,16 +6110,16 @@ var LIGHT_THEME = {
6047
6110
  var DARK_THEME = {
6048
6111
  "accent-color": "#193a48",
6049
6112
  "accent-color-secondary": "#1ea0d8",
6050
- "background-color-primary": "#20252A",
6051
- "background-color-secondary": "#3B3F46",
6113
+ "background-color-primary": "#15191c",
6114
+ "background-color-secondary": "#1d222b",
6052
6115
  "background-color-tertiary": "#292929",
6053
6116
  "background-color-switch-input": "#252525",
6054
6117
  "background-color-switch-thumb": "#ececec",
6055
6118
  "background-color-checkbox": "#292929",
6056
6119
  "background-color-disabled": "#5d6167",
6057
6120
  "background-color-disabled-dark": "#857d83",
6058
- "table-border-color": "#53565c",
6059
- "border-color": "#53565c",
6121
+ "table-border-color": "#2c2e32",
6122
+ "border-color": "#43464b",
6060
6123
  "hover-color": "#4a4f56",
6061
6124
  "text-color-primary": "#ececec",
6062
6125
  "text-color-secondary": "#bababa",
@@ -10202,6 +10265,33 @@ var UNAUTHENTICATED_ERROR = "Uh oh.. It looks like you don't have access to this
10202
10265
  var REQUEST_CANCELLED_ERROR = "Request cancelled";
10203
10266
  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.";
10204
10267
 
10268
+ // src/Api/axiosUtils.ts
10269
+ var createRequestController = () => {
10270
+ if (typeof AbortController !== "undefined") return new AbortController();
10271
+ return { abort: () => {
10272
+ }, signal: void 0 };
10273
+ };
10274
+ var attachCancelToConfig = (config = {}, cancelToken) => {
10275
+ if (!cancelToken) return config;
10276
+ if (typeof AbortController !== "undefined" && cancelToken instanceof AbortController)
10277
+ return { ...config, signal: cancelToken.signal };
10278
+ if (typeof AbortSignal !== "undefined" && cancelToken instanceof AbortSignal)
10279
+ return { ...config, signal: cancelToken };
10280
+ if (cancelToken && cancelToken.constructor && cancelToken.constructor.name === "AbortSignal")
10281
+ return { ...config, signal: cancelToken };
10282
+ if (cancelToken && cancelToken.promise && typeof cancelToken.promise.then === "function") {
10283
+ try {
10284
+ const controller = new AbortController();
10285
+ cancelToken.promise.then(() => controller.abort());
10286
+ return { ...config, signal: controller.signal, cancelToken };
10287
+ } catch (e) {
10288
+ return { ...config, cancelToken };
10289
+ }
10290
+ }
10291
+ return { ...config, cancelToken };
10292
+ };
10293
+ var axiosUtils_default = attachCancelToConfig;
10294
+
10205
10295
  // src/Api/dataExplorerService.ts
10206
10296
  var import_axios2 = __toESM(require("axios"));
10207
10297
 
@@ -10284,7 +10374,10 @@ var transformQueryResponseColumns = (response, addedColumns) => {
10284
10374
  const drilldownGroupby = getDrilldownGroupby(response, col);
10285
10375
  let additional = false;
10286
10376
  let is_timestamp = false;
10287
- if (addedColumns == null ? void 0 : addedColumns.find((select5) => select5.columns.includes(col.alt_name || col.name))) {
10377
+ if (addedColumns == null ? void 0 : addedColumns.find((select5) => {
10378
+ var _a3;
10379
+ return select5.columns.includes((_a3 = col.alt_name) != null ? _a3 : col.name);
10380
+ })) {
10288
10381
  additional = true;
10289
10382
  }
10290
10383
  if (isColumnDateType(col) && isISODate(dataSample)) {
@@ -10358,7 +10451,7 @@ var transformUserSelection = (userSelection) => {
10358
10451
  };
10359
10452
  var isError500Type = (referenceId) => {
10360
10453
  try {
10361
- const parsedReferenceId = referenceId == null ? void 0 : referenceId.split(".");
10454
+ const parsedReferenceId = typeof referenceId === "string" ? referenceId.split(".") : String(referenceId != null ? referenceId : "").split(".");
10362
10455
  const errorCode = Number(parsedReferenceId == null ? void 0 : parsedReferenceId[2]);
10363
10456
  if (errorCode >= 500 && errorCode < 600) {
10364
10457
  return true;
@@ -10401,12 +10494,14 @@ var fetchSuggestions = ({
10401
10494
  if (queryId) {
10402
10495
  relatedQueriesUrl = `${relatedQueriesUrl}&query_id=${queryId}`;
10403
10496
  }
10404
- const config = {
10405
- headers: {
10406
- Authorization: `Bearer ${token}`
10497
+ const config = axiosUtils_default(
10498
+ {
10499
+ headers: {
10500
+ Authorization: `Bearer ${token}`
10501
+ }
10407
10502
  },
10408
10503
  cancelToken
10409
- };
10504
+ );
10410
10505
  return import_axios.default.get(relatedQueriesUrl, config).then((response) => Promise.resolve(response)).catch((error) => Promise.reject(error == null ? void 0 : error.response));
10411
10506
  };
10412
10507
  var runQueryNewPage = ({
@@ -10427,12 +10522,14 @@ var runQueryNewPage = ({
10427
10522
  const data = {
10428
10523
  date_format: "ISO8601"
10429
10524
  };
10430
- const config = {
10431
- headers: {
10432
- Authorization: `Bearer ${token}`
10525
+ const config = axiosUtils_default(
10526
+ {
10527
+ headers: {
10528
+ Authorization: `Bearer ${token}`
10529
+ }
10433
10530
  },
10434
10531
  cancelToken
10435
- };
10532
+ );
10436
10533
  return import_axios.default.post(url, data, config).then((response) => {
10437
10534
  var _a, _b;
10438
10535
  if (response.data && typeof response.data === "string") {
@@ -10494,12 +10591,14 @@ var runQueryOnly = ({
10494
10591
  console.error("authentication invalid for request");
10495
10592
  return Promise.reject({ error: "Unauthenticated" /* UNAUTHENTICATED */ });
10496
10593
  }
10497
- const config = {
10498
- headers: {
10499
- Authorization: `Bearer ${token}`
10594
+ const config = axiosUtils_default(
10595
+ {
10596
+ headers: {
10597
+ Authorization: `Bearer ${token}`
10598
+ }
10500
10599
  },
10501
10600
  cancelToken
10502
- };
10601
+ );
10503
10602
  return import_axios.default.post(url, data, config).then((response) => {
10504
10603
  var _a;
10505
10604
  if (!((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data)) {
@@ -10532,12 +10631,14 @@ var runQueryValidation = ({
10532
10631
  return Promise.reject(new Error("Unauthenticated" /* UNAUTHENTICATED */));
10533
10632
  }
10534
10633
  const url = `${domain}/autoql/api/v1/query/validate?text=${encodeURIComponent(text)}&key=${apiKey}`;
10535
- const config = {
10536
- headers: {
10537
- Authorization: `Bearer ${token}`
10634
+ const config = axiosUtils_default(
10635
+ {
10636
+ headers: {
10637
+ Authorization: `Bearer ${token}`
10638
+ }
10538
10639
  },
10539
10640
  cancelToken
10540
- };
10641
+ );
10541
10642
  return import_axios.default.get(url, config).then((response) => Promise.resolve(response)).catch((error) => formatErrorResponse(error));
10542
10643
  };
10543
10644
  var runQuery = async ({
@@ -10669,6 +10770,73 @@ var runCachedDashboardQuery = async ({
10669
10770
  return formatErrorResponse(error);
10670
10771
  });
10671
10772
  };
10773
+ var runCachedDashboardQueryPost = async ({
10774
+ query,
10775
+ domain,
10776
+ apiKey,
10777
+ token,
10778
+ source,
10779
+ orders,
10780
+ filters,
10781
+ tableFilters,
10782
+ allowSuggestions,
10783
+ cancelToken,
10784
+ scope,
10785
+ newColumns,
10786
+ queryIndex,
10787
+ tileKey,
10788
+ dashboardId,
10789
+ force
10790
+ } = {}) => {
10791
+ if (!dashboardId) {
10792
+ console.error("No dashboard ID supplied in request");
10793
+ return Promise.reject({ error: "Dashboard ID not supplied" });
10794
+ }
10795
+ if (!tileKey) {
10796
+ console.error("No tile key supplied in request");
10797
+ return Promise.reject({ error: "Tile key not supplied" });
10798
+ }
10799
+ if (!apiKey || !domain || !token) {
10800
+ console.error("authentication invalid for request");
10801
+ return Promise.reject({ error: "authentication invalid for request" });
10802
+ }
10803
+ let finalScope = scope;
10804
+ if (!!(source == null ? void 0 : source.includes) && source.includes("data_messenger")) {
10805
+ finalScope = "data_messenger";
10806
+ }
10807
+ const queryParams = new URLSearchParams({
10808
+ key: apiKey
10809
+ });
10810
+ const data = {
10811
+ query_index: (queryIndex || 0).toString(),
10812
+ force,
10813
+ session_filter_locks: filters
10814
+ };
10815
+ const url = `${domain}/autoql/api/v1/dashboards/${dashboardId}/tiles/${tileKey}/query?${queryParams.toString()}`;
10816
+ const config = {
10817
+ headers: {
10818
+ Authorization: `Bearer ${token}`
10819
+ }
10820
+ };
10821
+ const finalConfig = axiosUtils_default(config, cancelToken);
10822
+ return import_axios.default.post(url, data, finalConfig).then((response) => {
10823
+ var _a;
10824
+ if (!((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data)) {
10825
+ throw new Error("Parse error" /* PARSE_ERROR */);
10826
+ }
10827
+ return Promise.resolve(transformQueryResponse(response, void 0, void 0, newColumns));
10828
+ }).catch((error) => {
10829
+ var _a, _b, _c, _d, _e;
10830
+ const referenceId = (_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.reference_id;
10831
+ const isSubquery = (tableFilters == null ? void 0 : tableFilters.length) || (orders == null ? void 0 : orders.length);
10832
+ const needsSuggestions = referenceId === "1.1.430" || referenceId === "1.1.431" || isError500Type(referenceId);
10833
+ if (needsSuggestions && allowSuggestions && !isSubquery) {
10834
+ 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;
10835
+ return fetchSuggestions({ query, queryId, domain, apiKey, token, cancelToken });
10836
+ }
10837
+ return formatErrorResponse(error);
10838
+ });
10839
+ };
10672
10840
  var exportCSV = ({
10673
10841
  queryId,
10674
10842
  domain,
@@ -10731,12 +10899,14 @@ var runDrilldown = ({
10731
10899
  additional_selects: newColumns,
10732
10900
  display_overrides: displayOverrides
10733
10901
  };
10734
- const config = {
10735
- headers: {
10736
- Authorization: `Bearer ${token}`
10902
+ const config = axiosUtils_default(
10903
+ {
10904
+ headers: {
10905
+ Authorization: `Bearer ${token}`
10906
+ }
10737
10907
  },
10738
10908
  cancelToken
10739
- };
10909
+ );
10740
10910
  const url = `${domain}/autoql/api/v1/query/${queryID}/drilldown?key=${apiKey}`;
10741
10911
  return import_axios.default.post(url, requestData, config).then((response) => transformQueryResponse(response, queryID, true)).catch(formatErrorResponse);
10742
10912
  };
@@ -10811,12 +10981,14 @@ var fetchVLAutocomplete = ({
10811
10981
  if (filter) {
10812
10982
  url = `${url}&filter=${filter}`;
10813
10983
  }
10814
- const config = {
10815
- headers: {
10816
- Authorization: `Bearer ${token}`
10984
+ const config = axiosUtils_default(
10985
+ {
10986
+ headers: {
10987
+ Authorization: `Bearer ${token}`
10988
+ }
10817
10989
  },
10818
10990
  cancelToken
10819
- };
10991
+ );
10820
10992
  return import_axios.default.get(url, config).then((response) => Promise.resolve(response)).catch((error) => {
10821
10993
  var _a2;
10822
10994
  if ((error == null ? void 0 : error.message) === REQUEST_CANCELLED_ERROR) {
@@ -10986,7 +11158,8 @@ var reportProblem = ({
10986
11158
  queryId,
10987
11159
  domain,
10988
11160
  apiKey,
10989
- token
11161
+ token,
11162
+ isCorrect = false
10990
11163
  } = {}) => {
10991
11164
  if (!queryId) {
10992
11165
  return Promise.reject(new Error("No query ID supplied" /* NO_QUERY_ID_SUPPLIED */));
@@ -11001,7 +11174,7 @@ var reportProblem = ({
11001
11174
  }
11002
11175
  };
11003
11176
  const data = {
11004
- is_correct: false,
11177
+ is_correct: isCorrect,
11005
11178
  message
11006
11179
  };
11007
11180
  return import_axios.default.put(url, data, config).then((response) => Promise.resolve(response)).catch((error) => {
@@ -11040,8 +11213,12 @@ var isAggSeed = (subject) => {
11040
11213
  };
11041
11214
  var getSampleQueryRegex = (suggestionValues) => {
11042
11215
  const valueArray = Object.keys(suggestionValues);
11043
- const valueRegexArray = valueArray.map((value) => `\\b${value}\\b`);
11044
- const valueRegex = new RegExp(valueRegexArray.join("|"), "gm");
11216
+ const valueRegexArray = valueArray.map((value) => {
11217
+ const esc = String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11218
+ return `\\b${esc}\\b`;
11219
+ });
11220
+ const pattern = valueRegexArray.join("|");
11221
+ const valueRegex = compileSafeRegex(pattern, "gm");
11045
11222
  return valueRegex;
11046
11223
  };
11047
11224
  var getSampleQueryText = (query, values = {}) => {
@@ -11055,9 +11232,14 @@ var getSampleQueryText = (query, values = {}) => {
11055
11232
  var _a;
11056
11233
  const chunk = values[valueKey];
11057
11234
  const replacementText = (_a = chunk == null ? void 0 : chunk.replacement) == null ? void 0 : _a.format_txt;
11058
- const valueKeyRegex = new RegExp(`\\b${valueKey}\\b`);
11235
+ const pattern = `\\b${valueKey}\\b`;
11236
+ const valueKeyRegex = compileSafeRegex(pattern);
11059
11237
  if (replacementText) {
11060
- queryText = queryText.replace(valueKeyRegex, replacementText);
11238
+ if (valueKeyRegex) {
11239
+ queryText = queryText.replace(valueKeyRegex, replacementText);
11240
+ } else if (isSimpleLiteral(valueKey)) {
11241
+ queryText = String(queryText).split(valueKey).join(replacementText);
11242
+ }
11061
11243
  }
11062
11244
  });
11063
11245
  return queryText;
@@ -11149,6 +11331,7 @@ var getSampleQueryReplacementType = (key, replacement) => {
11149
11331
  }
11150
11332
  };
11151
11333
  var getSampleQueryChunks = (query, values = {}) => {
11334
+ var _a, _b;
11152
11335
  try {
11153
11336
  const valueArray = Object.keys(values);
11154
11337
  if (!(valueArray == null ? void 0 : valueArray.length)) {
@@ -11160,22 +11343,57 @@ var getSampleQueryChunks = (query, values = {}) => {
11160
11343
  }
11161
11344
  ];
11162
11345
  }
11163
- const valueRegexArray = valueArray.map((value) => `(\\b${value}\\b)`);
11164
- const valueRegex = new RegExp(valueRegexArray.join("|"), "gm");
11165
11346
  let splitStrArray = [query];
11166
- if (valueArray == null ? void 0 : valueArray.length) {
11167
- splitStrArray = query.split(valueRegex);
11347
+ if (valueArray.length < 500) {
11348
+ const valueRegexArray = valueArray.map((value) => {
11349
+ const esc = String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11350
+ return `(\\b${esc}\\b)`;
11351
+ });
11352
+ const pattern = valueRegexArray.join("|");
11353
+ const valueRegex = compileSafeRegex(pattern, "gm");
11354
+ if (valueRegex) {
11355
+ splitStrArray = query.split(valueRegex);
11356
+ }
11357
+ }
11358
+ if (splitStrArray.length === 1) {
11359
+ const result = [];
11360
+ let remaining = query;
11361
+ const sortedValues = [...valueArray].sort((a, b) => b.length - a.length);
11362
+ for (const value of sortedValues) {
11363
+ const escaped = String(value).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11364
+ const re2 = compileSafeRegex(`\\b${escaped}\\b`, "i");
11365
+ let match = null;
11366
+ let matchedText = "";
11367
+ if (re2) {
11368
+ match = re2.exec(remaining);
11369
+ matchedText = (_a = match == null ? void 0 : match[0]) != null ? _a : "";
11370
+ } else if (isSimpleLiteral(value)) {
11371
+ const idx = remaining.toLowerCase().indexOf(String(value).toLowerCase());
11372
+ if (idx >= 0) {
11373
+ match = [String(value)];
11374
+ matchedText = remaining.substr(idx, String(value).length);
11375
+ match.index = idx;
11376
+ }
11377
+ }
11378
+ if (match) {
11379
+ const matchIndex = (_b = match.index) != null ? _b : 0;
11380
+ result.push(remaining.substring(0, matchIndex), matchedText || match[0]);
11381
+ remaining = remaining.substring(matchIndex + (matchedText || match[0]).length);
11382
+ }
11383
+ }
11384
+ if (remaining) result.push(remaining);
11385
+ splitStrArray = result;
11168
11386
  }
11169
11387
  const chunkedSuggestion = [];
11170
11388
  splitStrArray.forEach((key) => {
11171
- var _a, _b;
11172
- const replacement = (_a = values[key]) == null ? void 0 : _a.replacement;
11389
+ var _a2, _b2;
11390
+ const replacement = (_a2 = values[key]) == null ? void 0 : _a2.replacement;
11173
11391
  const type = getSampleQueryReplacementType(key, replacement);
11174
11392
  const name = key == null ? void 0 : key.trim();
11175
11393
  if (!type || !name) {
11176
11394
  return;
11177
11395
  }
11178
- let value = (_b = replacement == null ? void 0 : replacement.format_txt) == null ? void 0 : _b.trim();
11396
+ let value = (_b2 = replacement == null ? void 0 : replacement.format_txt) == null ? void 0 : _b2.trim();
11179
11397
  if (type == "TEXT" /* SAMPLE_QUERY_TEXT_TYPE */) {
11180
11398
  value = name;
11181
11399
  }
@@ -11228,12 +11446,14 @@ var fetchDataExplorerAutocomplete = ({
11228
11446
  if (timezone2) {
11229
11447
  url = `${url}&time_zone=${timezone2}`;
11230
11448
  }
11231
- const config = {
11232
- headers: {
11233
- Authorization: `Bearer ${token}`
11449
+ const config = axiosUtils_default(
11450
+ {
11451
+ headers: {
11452
+ Authorization: `Bearer ${token}`
11453
+ }
11234
11454
  },
11235
11455
  cancelToken
11236
- };
11456
+ );
11237
11457
  return import_axios2.default.get(url, config).then((response) => {
11238
11458
  return transformDataExplorerAutocompleteResponse(response);
11239
11459
  }).catch((error) => {
@@ -11247,10 +11467,11 @@ var fetchDataExplorerAutocomplete = ({
11247
11467
  });
11248
11468
  };
11249
11469
  var transformVLForDataExplorerSuggestions = (vl) => {
11470
+ var _a;
11250
11471
  return {
11251
11472
  name: vl.keyword,
11252
11473
  alias_name: vl.show_message,
11253
- column_name: vl.column_name
11474
+ column_name: (_a = vl.column_name) != null ? _a : ""
11254
11475
  };
11255
11476
  };
11256
11477
  var fetchDataExplorerSampleQueries = async ({
@@ -11268,12 +11489,14 @@ var fetchDataExplorerSampleQueries = async ({
11268
11489
  context,
11269
11490
  columns
11270
11491
  };
11271
- const config = {
11272
- headers: {
11273
- Authorization: `Bearer ${token}`
11492
+ const config = axiosUtils_default(
11493
+ {
11494
+ headers: {
11495
+ Authorization: `Bearer ${token}`
11496
+ }
11274
11497
  },
11275
11498
  cancelToken
11276
- };
11499
+ );
11277
11500
  return import_axios2.default.post(url, data, config).then((response) => {
11278
11501
  var _a, _b, _c, _d;
11279
11502
  if ((_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.data) == null ? void 0 : _b.suggestions) {
@@ -11339,7 +11562,13 @@ var fetchDataExplorerSuggestions = async ({
11339
11562
  return Promise.reject((_a2 = error == null ? void 0 : error.response) == null ? void 0 : _a2.data);
11340
11563
  });
11341
11564
  };
11342
- var fetchSubjectListV2 = ({ domain, apiKey, token, valueLabel, cancelToken }) => {
11565
+ var fetchSubjectListV2 = ({
11566
+ domain,
11567
+ apiKey,
11568
+ token,
11569
+ valueLabel,
11570
+ cancelToken
11571
+ }) => {
11343
11572
  if (!token || !domain || !apiKey) {
11344
11573
  return Promise.reject(new Error("Unauthenticated"));
11345
11574
  }
@@ -11347,12 +11576,14 @@ var fetchSubjectListV2 = ({ domain, apiKey, token, valueLabel, cancelToken }) =>
11347
11576
  if (valueLabel) {
11348
11577
  url += `&value_label=${valueLabel}`;
11349
11578
  }
11350
- const config = {
11351
- headers: {
11352
- Authorization: `Bearer ${token}`
11579
+ const config = axiosUtils_default(
11580
+ {
11581
+ headers: {
11582
+ Authorization: `Bearer ${token}`
11583
+ }
11353
11584
  },
11354
11585
  cancelToken
11355
- };
11586
+ );
11356
11587
  return import_axios2.default.get(url, config).then((response) => {
11357
11588
  var _a, _b;
11358
11589
  let subjectList = [];
@@ -11414,12 +11645,14 @@ var fetchDataPreview = ({
11414
11645
  return Promise.reject(new Error("Unauthenticated"));
11415
11646
  }
11416
11647
  const url = `${domain}/autoql/api/v1/query/preview?key=${apiKey}`;
11417
- const config = {
11418
- headers: {
11419
- Authorization: `Bearer ${token}`
11648
+ const config = axiosUtils_default(
11649
+ {
11650
+ headers: {
11651
+ Authorization: `Bearer ${token}`
11652
+ }
11420
11653
  },
11421
11654
  cancelToken
11422
- };
11655
+ );
11423
11656
  const data = {
11424
11657
  subject,
11425
11658
  page_size: numRows,
@@ -12279,8 +12512,8 @@ function formatDecimal_default(x) {
12279
12512
  return Math.abs(x = Math.round(x)) >= 1e21 ? x.toLocaleString("en").replace(/,/g, "") : x.toString(10);
12280
12513
  }
12281
12514
  function formatDecimalParts(x, p) {
12282
- if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null;
12283
- var i, coefficient = x.slice(0, i);
12515
+ if (!isFinite(x) || x === 0) return null;
12516
+ var i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e"), coefficient = x.slice(0, i);
12284
12517
  return [
12285
12518
  coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
12286
12519
  +x.slice(i + 1)
@@ -12374,7 +12607,7 @@ function formatTrim_default(s) {
12374
12607
  var prefixExponent;
12375
12608
  function formatPrefixAuto_default(x, p) {
12376
12609
  var d = formatDecimalParts(x, p);
12377
- if (!d) return x + "";
12610
+ if (!d) return prefixExponent = void 0, x.toPrecision(p);
12378
12611
  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;
12379
12612
  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];
12380
12613
  }
@@ -12414,13 +12647,13 @@ var map = Array.prototype.map;
12414
12647
  var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
12415
12648
  function locale_default(locale2) {
12416
12649
  var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity_default : formatGroup_default(map.call(locale2.grouping, Number), locale2.thousands + ""), currencyPrefix = locale2.currency === void 0 ? "" : locale2.currency[0] + "", currencySuffix = locale2.currency === void 0 ? "" : locale2.currency[1] + "", decimal = locale2.decimal === void 0 ? "." : locale2.decimal + "", numerals = locale2.numerals === void 0 ? identity_default : formatNumerals_default(map.call(locale2.numerals, String)), percent = locale2.percent === void 0 ? "%" : locale2.percent + "", minus = locale2.minus === void 0 ? "\u2212" : locale2.minus + "", nan = locale2.nan === void 0 ? "NaN" : locale2.nan + "";
12417
- function newFormat(specifier) {
12650
+ function newFormat(specifier, options) {
12418
12651
  specifier = formatSpecifier(specifier);
12419
12652
  var fill = specifier.fill, align = specifier.align, sign = specifier.sign, symbol2 = specifier.symbol, zero = specifier.zero, width = specifier.width, comma = specifier.comma, precision = specifier.precision, trim = specifier.trim, type = specifier.type;
12420
12653
  if (type === "n") comma = true, type = "g";
12421
12654
  else if (!formatTypes_default[type]) precision === void 0 && (precision = 12), trim = true, type = "g";
12422
12655
  if (zero || fill === "0" && align === "=") zero = true, fill = "0", align = "=";
12423
- var prefix = symbol2 === "$" ? currencyPrefix : symbol2 === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", suffix = symbol2 === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "";
12656
+ var prefix = (options && options.prefix !== void 0 ? options.prefix : "") + (symbol2 === "$" ? currencyPrefix : symbol2 === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : ""), suffix = (symbol2 === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "") + (options && options.suffix !== void 0 ? options.suffix : "");
12424
12657
  var formatType = formatTypes_default[type], maybeSuffix = /[defgprs%]/.test(type);
12425
12658
  precision = precision === void 0 ? 6 : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) : Math.max(0, Math.min(20, precision));
12426
12659
  function format2(value) {
@@ -12435,7 +12668,7 @@ function locale_default(locale2) {
12435
12668
  if (trim) value = formatTrim_default(value);
12436
12669
  if (valueNegative && +value === 0 && sign !== "+") valueNegative = false;
12437
12670
  valuePrefix = (valueNegative ? sign === "(" ? sign : minus : sign === "-" || sign === "(" ? "" : sign) + valuePrefix;
12438
- valueSuffix = (type === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
12671
+ valueSuffix = (type === "s" && !isNaN(value) && prefixExponent !== void 0 ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : "");
12439
12672
  if (maybeSuffix) {
12440
12673
  i = -1, n = value.length;
12441
12674
  while (++i < n) {
@@ -12472,9 +12705,9 @@ function locale_default(locale2) {
12472
12705
  return format2;
12473
12706
  }
12474
12707
  function formatPrefix2(specifier, value) {
12475
- 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), prefix = prefixes[8 + e / 3];
12708
+ 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] });
12476
12709
  return function(value2) {
12477
- return f(k * value2) + prefix;
12710
+ return f(k * value2);
12478
12711
  };
12479
12712
  }
12480
12713
  return {
@@ -13044,6 +13277,7 @@ function color() {
13044
13277
  areAllColumnsHidden,
13045
13278
  areSomeColumnsHidden,
13046
13279
  assignLabelToManagementDataAlert,
13280
+ attachCancelToConfig,
13047
13281
  authenticationDefault,
13048
13282
  autoQLConfigDefault,
13049
13283
  bezierCommand,
@@ -13062,6 +13296,7 @@ function color() {
13062
13296
  createManagementDataAlert,
13063
13297
  createMutatorFn,
13064
13298
  createNotificationChannel,
13299
+ createRequestController,
13065
13300
  createSVGPath,
13066
13301
  currentEventLoopEnd,
13067
13302
  dataConfigDefault,
@@ -13374,6 +13609,7 @@ function color() {
13374
13609
  roundToNearestMultiple,
13375
13610
  roundUpToNearestMultiple,
13376
13611
  runCachedDashboardQuery,
13612
+ runCachedDashboardQueryPost,
13377
13613
  runDrilldown,
13378
13614
  runQuery,
13379
13615
  runQueryNewPage,