autoql-fe-utils 1.11.19 → 1.11.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
@@ -861,6 +861,7 @@ __export(index_exports, {
861
861
  fetchDataPreview: () => fetchDataPreview,
862
862
  fetchExploreQueries: () => fetchExploreQueries,
863
863
  fetchFilters: () => fetchFilters,
864
+ fetchFollowOnQuery: () => fetchFollowOnQuery,
864
865
  fetchLLMSummary: () => fetchLLMSummary,
865
866
  fetchLLMSummaryEstimate: () => fetchLLMSummaryEstimate,
866
867
  fetchLLMSummaryQuote: () => fetchLLMSummaryQuote,
@@ -3199,6 +3200,7 @@ var FilterOperatorEnum = /* @__PURE__ */ ((FilterOperatorEnum2) => {
3199
3200
  FilterOperatorEnum2["REGEX"] = "regex";
3200
3201
  FilterOperatorEnum2["STARTS_WITH"] = "starts_with";
3201
3202
  FilterOperatorEnum2["ENDS_WITH"] = "ends_with";
3203
+ FilterOperatorEnum2["IN"] = "in";
3202
3204
  return FilterOperatorEnum2;
3203
3205
  })(FilterOperatorEnum || {});
3204
3206
  var FilterTypeEnum = {
@@ -3268,6 +3270,15 @@ var betweenMatcher = (cell, cond) => {
3268
3270
  getLogger().warn("betweenMatcher: unsupported types for between fallback", { cell, low, high, type: cond.type });
3269
3271
  return false;
3270
3272
  };
3273
+ var inMatcher = (cell, cond) => {
3274
+ var _a2;
3275
+ if (cell == null) return false;
3276
+ const raw = String((_a2 = cond.value) != null ? _a2 : "");
3277
+ if (raw.length === 0) return true;
3278
+ const items = raw.split(",").map((s) => s.trim().toLowerCase());
3279
+ const set = new Set(items);
3280
+ return set.has(String(cell).toLowerCase());
3281
+ };
3271
3282
  var FILTER_MATCHERS = {
3272
3283
  ["like" /* LIKE */]: likeMatcher,
3273
3284
  ["not_like" /* NOT_LIKE */]: notLikeMatcher,
@@ -3280,7 +3291,8 @@ var FILTER_MATCHERS = {
3280
3291
  ["regex" /* REGEX */]: regexMatcher,
3281
3292
  ["between" /* BETWEEN */]: betweenMatcher,
3282
3293
  ["starts_with" /* STARTS_WITH */]: (cell, cond) => String(cell).startsWith(String(cond.value)),
3283
- ["ends_with" /* ENDS_WITH */]: (cell, cond) => String(cell).endsWith(String(cond.value))
3294
+ ["ends_with" /* ENDS_WITH */]: (cell, cond) => String(cell).endsWith(String(cond.value)),
3295
+ ["in" /* IN */]: inMatcher
3284
3296
  };
3285
3297
  function isValidOperator(op) {
3286
3298
  return Object.values(FilterOperatorEnum).includes(op);
@@ -3333,7 +3345,7 @@ function parseFilter(raw, type, defaultOperator = "like" /* LIKE */) {
3333
3345
  if (typeof raw !== "string") return { operator: defaultOperator, value: raw, type };
3334
3346
  const trimmed = raw.trim();
3335
3347
  if (trimmed.length === 0) return { operator: defaultOperator, value: "", type };
3336
- const opToken = `${"between" /* BETWEEN */}|[<>!=]=?|not_like`;
3348
+ const opToken = `${"between" /* BETWEEN */}|${"in" /* IN */}|[<>!=]=?|not_like`;
3337
3349
  const opPattern = `^(${opToken})\\s*(.*)$`;
3338
3350
  const opRe = compileSafeRegex(opPattern, "i");
3339
3351
  const opMatch = opRe ? opRe.exec(trimmed) : null;
@@ -3341,7 +3353,11 @@ function parseFilter(raw, type, defaultOperator = "like" /* LIKE */) {
3341
3353
  let op = String((_a2 = opMatch[1]) != null ? _a2 : "").toLowerCase();
3342
3354
  const rest = (_b2 = opMatch[2]) != null ? _b2 : "";
3343
3355
  if (op === "!") op = "not_like" /* NOT_LIKE */;
3356
+ if (op === "==") op = "=" /* EQ */;
3344
3357
  if (type === FilterTypeEnum.STRING && op === "!=") op = "not_like" /* NOT_LIKE */;
3358
+ if (op === "in" /* IN */) {
3359
+ return { operator: "in" /* IN */, value: rest, type };
3360
+ }
3345
3361
  if (op === "between" /* BETWEEN */) {
3346
3362
  let parts = (_c = rest.split(/\s+to\s+|,/)) == null ? void 0 : _c.map((s) => s.trim()).filter((s) => s.length);
3347
3363
  if ((!parts || parts.length < 2) && type === FilterTypeEnum.NUMBER) {
@@ -3901,10 +3917,7 @@ var createFilterFunction = ({
3901
3917
  return false;
3902
3918
  }
3903
3919
  const raw = String(headerValue != null ? headerValue : "").trim();
3904
- if (!raw) {
3905
- getLogger().warn("date filter: header value empty", { column });
3906
- return false;
3907
- }
3920
+ if (!raw) return true;
3908
3921
  const parts = raw.split(" to ").map((s) => String(s).trim()).filter((s) => s.length > 0);
3909
3922
  if (!parts.length) {
3910
3923
  getLogger().warn("date filter: could not parse date range", { raw, column });
@@ -3931,24 +3944,23 @@ var createFilterFunction = ({
3931
3944
  };
3932
3945
  } else if ((column == null ? void 0 : column.type) === "DATE_STRING" /* DATE_STRING */) {
3933
3946
  return (headerValue, rowValue) => {
3934
- if (rowValue === void 0 || rowValue === null) {
3935
- return false;
3936
- }
3947
+ const raw = String(headerValue != null ? headerValue : "").trim();
3948
+ if (!raw) return true;
3949
+ if (rowValue === void 0 || rowValue === null) return false;
3937
3950
  const formattedElement = formatElement({
3938
3951
  element: rowValue,
3939
3952
  column,
3940
3953
  config: dataFormatting
3941
3954
  });
3942
- const raw = String(headerValue != null ? headerValue : "").trim();
3943
3955
  const lowerElement = String(formattedElement != null ? formattedElement : "").toLowerCase();
3944
3956
  return matchesStringFilter(raw, lowerElement);
3945
3957
  };
3946
3958
  } else if (isColumnNumberType(column)) {
3947
3959
  return (headerValue, rowValue) => {
3948
3960
  try {
3949
- if (rowValue === void 0 || rowValue === null) return false;
3950
3961
  const raw = String(headerValue != null ? headerValue : "").trim();
3951
- if (raw.length === 0) return false;
3962
+ if (raw.length === 0) return true;
3963
+ if (rowValue === void 0 || rowValue === null) return false;
3952
3964
  const cond = parseFilter(raw, "number", "=");
3953
3965
  return matchCell(rowValue, cond);
3954
3966
  } catch (error) {
@@ -3958,10 +3970,9 @@ var createFilterFunction = ({
3958
3970
  };
3959
3971
  } else {
3960
3972
  return (headerValue, rowValue) => {
3961
- if (rowValue === void 0 || rowValue === null) {
3962
- return false;
3963
- }
3964
3973
  const raw = String(headerValue != null ? headerValue : "").trim();
3974
+ if (!raw) return true;
3975
+ if (rowValue === void 0 || rowValue === null) return false;
3965
3976
  const lowerValue = String(rowValue != null ? rowValue : "").toLowerCase();
3966
3977
  const cond = parseFilter(raw, "string", "like" /* LIKE */);
3967
3978
  return matchCell(lowerValue, { ...cond, type: "string", value: String(cond.value).toLowerCase() });
@@ -5487,13 +5498,20 @@ var formatElement = ({
5487
5498
  const validatedQuantityDecimals = !isNaN(quantityDecimals) ? quantityDecimals : 2;
5488
5499
  const elementNumber = parseFloat(`${element}`);
5489
5500
  if (!isNaN(elementNumber)) {
5490
- const numDecimals = elementNumber % 1 !== 0 ? validatedQuantityDecimals : 0;
5501
+ let numDecimals;
5502
+ if ((column == null ? void 0 : column.quantity_type) === "integer") {
5503
+ numDecimals = 0;
5504
+ } else if ((column == null ? void 0 : column.quantity_type) === "float") {
5505
+ numDecimals = validatedQuantityDecimals;
5506
+ } else {
5507
+ numDecimals = elementNumber % 1 !== 0 ? validatedQuantityDecimals : 0;
5508
+ }
5491
5509
  formattedElement = new Intl.NumberFormat(languageCode, {
5492
5510
  minimumFractionDigits: numDecimals,
5493
5511
  maximumFractionDigits: numDecimals
5494
5512
  }).format(elementNumber);
5495
- if (formattedElement.endsWith(".00")) {
5496
- formattedElement = formattedElement.replace(".00", "");
5513
+ if ((column == null ? void 0 : column.quantity_type) !== "float" && `${formattedElement}`.endsWith(".00")) {
5514
+ formattedElement = `${formattedElement}`.replace(".00", "");
5497
5515
  }
5498
5516
  }
5499
5517
  break;
@@ -10480,16 +10498,27 @@ var transformQueryResponse = (response, originalQueryID, isDrilldown2 = false, n
10480
10498
  }
10481
10499
  return transformedResponse;
10482
10500
  };
10501
+ var detectQuantityType = (rows, colIndex) => {
10502
+ if (!(rows == null ? void 0 : rows.length)) return "float";
10503
+ for (const row of rows) {
10504
+ const val = row == null ? void 0 : row[colIndex];
10505
+ if (val === null || val === void 0) continue;
10506
+ const num = typeof val === "number" ? val : parseFloat(val);
10507
+ if (!isNaN(num) && num % 1 !== 0) return "float";
10508
+ }
10509
+ return "integer";
10510
+ };
10483
10511
  var transformQueryResponseColumns = (response, addedColumns) => {
10484
- var _a2, _b2;
10512
+ var _a2, _b2, _c, _d;
10485
10513
  const columns = (_b2 = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.data) == null ? void 0 : _b2.columns;
10514
+ const rows = (_d = (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.data) == null ? void 0 : _d.rows;
10486
10515
  if (!(columns == null ? void 0 : columns.length)) {
10487
10516
  return columns;
10488
10517
  }
10489
10518
  const isSingleValue = isSingleValueResponse(response);
10490
10519
  const transformedColumns = columns.map((col, i) => {
10491
- var _a3, _b3, _c, _d;
10492
- const dataSample = (_d = (_c = (_b3 = (_a3 = response == null ? void 0 : response.data) == null ? void 0 : _a3.data) == null ? void 0 : _b3.rows) == null ? void 0 : _c.find((row) => row[i])) == null ? void 0 : _d[i];
10520
+ var _a3;
10521
+ const dataSample = (_a3 = rows == null ? void 0 : rows.find((row) => row[i])) == null ? void 0 : _a3[i];
10493
10522
  const drilldownGroupby = getDrilldownGroupby(response, col);
10494
10523
  let additional = false;
10495
10524
  let is_timestamp = false;
@@ -10506,6 +10535,7 @@ var transformQueryResponseColumns = (response, addedColumns) => {
10506
10535
  if (isSingleValue) {
10507
10536
  is_visible = true;
10508
10537
  }
10538
+ const quantity_type = col.type === "QUANTITY" /* QUANTITY */ ? detectQuantityType(rows, i) : void 0;
10509
10539
  return new Column({
10510
10540
  ...col,
10511
10541
  field: `${i}`,
@@ -10513,7 +10543,8 @@ var transformQueryResponseColumns = (response, addedColumns) => {
10513
10543
  drilldownGroupby,
10514
10544
  additional,
10515
10545
  is_visible,
10516
- is_timestamp
10546
+ is_timestamp,
10547
+ quantity_type
10517
10548
  });
10518
10549
  });
10519
10550
  return transformedColumns;
@@ -10963,7 +10994,9 @@ var exportCSV = ({
10963
10994
  token,
10964
10995
  filters,
10965
10996
  tableFilters,
10966
- csvProgressCallback
10997
+ csvProgressCallback,
10998
+ source = DEFAULT_SOURCE,
10999
+ scope = "null"
10967
11000
  } = {}) => {
10968
11001
  if (!token || !domain || !apiKey) {
10969
11002
  return Promise.reject(new Error("Unauthenticated" /* UNAUTHENTICATED */));
@@ -10971,7 +11004,9 @@ var exportCSV = ({
10971
11004
  const url = `${domain}/autoql/api/v1/query/${queryId}/export?key=${apiKey}`;
10972
11005
  const data = {
10973
11006
  session_filter_locks: filters,
10974
- filters: tableFilters
11007
+ filters: tableFilters,
11008
+ source,
11009
+ scope
10975
11010
  };
10976
11011
  const config = {
10977
11012
  headers: {
@@ -11331,6 +11366,30 @@ var fetchLLMSummary = ({
11331
11366
  return Promise.reject((_a2 = error == null ? void 0 : error.response) == null ? void 0 : _a2.data);
11332
11367
  });
11333
11368
  };
11369
+ var fetchFollowOnQuery = ({
11370
+ data,
11371
+ queryID,
11372
+ domain,
11373
+ apiKey,
11374
+ token
11375
+ } = {}) => {
11376
+ if (!data) {
11377
+ return Promise.reject(new Error("No data supplied" /* NO_DATA_SUPPLIED */));
11378
+ }
11379
+ if (!token || !domain || !apiKey) {
11380
+ return Promise.reject(new Error("Unauthenticated" /* UNAUTHENTICATED */));
11381
+ }
11382
+ const url = `${domain}/autoql/api/v1/query/${queryID}/follow?key=${apiKey}`;
11383
+ const config = {
11384
+ headers: {
11385
+ Authorization: `Bearer ${token}`
11386
+ }
11387
+ };
11388
+ return import_axios.default.post(url, data, config).then((response) => Promise.resolve(response.data)).catch((error) => {
11389
+ var _a2;
11390
+ return Promise.reject((_a2 = error == null ? void 0 : error.response) == null ? void 0 : _a2.data);
11391
+ });
11392
+ };
11334
11393
  var fetchLLMSummaryQuote = ({
11335
11394
  data,
11336
11395
  queryID,
@@ -13498,6 +13557,7 @@ function color() {
13498
13557
  fetchDataPreview,
13499
13558
  fetchExploreQueries,
13500
13559
  fetchFilters,
13560
+ fetchFollowOnQuery,
13501
13561
  fetchLLMSummary,
13502
13562
  fetchLLMSummaryEstimate,
13503
13563
  fetchLLMSummaryQuote,