autoql-fe-utils 1.11.19 → 1.11.21

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
@@ -5487,13 +5487,20 @@ var formatElement = ({
5487
5487
  const validatedQuantityDecimals = !isNaN(quantityDecimals) ? quantityDecimals : 2;
5488
5488
  const elementNumber = parseFloat(`${element}`);
5489
5489
  if (!isNaN(elementNumber)) {
5490
- const numDecimals = elementNumber % 1 !== 0 ? validatedQuantityDecimals : 0;
5490
+ let numDecimals;
5491
+ if ((column == null ? void 0 : column.quantity_type) === "integer") {
5492
+ numDecimals = 0;
5493
+ } else if ((column == null ? void 0 : column.quantity_type) === "float") {
5494
+ numDecimals = validatedQuantityDecimals;
5495
+ } else {
5496
+ numDecimals = elementNumber % 1 !== 0 ? validatedQuantityDecimals : 0;
5497
+ }
5491
5498
  formattedElement = new Intl.NumberFormat(languageCode, {
5492
5499
  minimumFractionDigits: numDecimals,
5493
5500
  maximumFractionDigits: numDecimals
5494
5501
  }).format(elementNumber);
5495
- if (formattedElement.endsWith(".00")) {
5496
- formattedElement = formattedElement.replace(".00", "");
5502
+ if ((column == null ? void 0 : column.quantity_type) !== "float" && `${formattedElement}`.endsWith(".00")) {
5503
+ formattedElement = `${formattedElement}`.replace(".00", "");
5497
5504
  }
5498
5505
  }
5499
5506
  break;
@@ -10480,16 +10487,27 @@ var transformQueryResponse = (response, originalQueryID, isDrilldown2 = false, n
10480
10487
  }
10481
10488
  return transformedResponse;
10482
10489
  };
10490
+ var detectQuantityType = (rows, colIndex) => {
10491
+ if (!(rows == null ? void 0 : rows.length)) return "float";
10492
+ for (const row of rows) {
10493
+ const val = row == null ? void 0 : row[colIndex];
10494
+ if (val === null || val === void 0) continue;
10495
+ const num = typeof val === "number" ? val : parseFloat(val);
10496
+ if (!isNaN(num) && num % 1 !== 0) return "float";
10497
+ }
10498
+ return "integer";
10499
+ };
10483
10500
  var transformQueryResponseColumns = (response, addedColumns) => {
10484
- var _a2, _b2;
10501
+ var _a2, _b2, _c, _d;
10485
10502
  const columns = (_b2 = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.data) == null ? void 0 : _b2.columns;
10503
+ const rows = (_d = (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.data) == null ? void 0 : _d.rows;
10486
10504
  if (!(columns == null ? void 0 : columns.length)) {
10487
10505
  return columns;
10488
10506
  }
10489
10507
  const isSingleValue = isSingleValueResponse(response);
10490
10508
  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];
10509
+ var _a3;
10510
+ const dataSample = (_a3 = rows == null ? void 0 : rows.find((row) => row[i])) == null ? void 0 : _a3[i];
10493
10511
  const drilldownGroupby = getDrilldownGroupby(response, col);
10494
10512
  let additional = false;
10495
10513
  let is_timestamp = false;
@@ -10506,6 +10524,7 @@ var transformQueryResponseColumns = (response, addedColumns) => {
10506
10524
  if (isSingleValue) {
10507
10525
  is_visible = true;
10508
10526
  }
10527
+ const quantity_type = col.type === "QUANTITY" /* QUANTITY */ ? detectQuantityType(rows, i) : void 0;
10509
10528
  return new Column({
10510
10529
  ...col,
10511
10530
  field: `${i}`,
@@ -10513,7 +10532,8 @@ var transformQueryResponseColumns = (response, addedColumns) => {
10513
10532
  drilldownGroupby,
10514
10533
  additional,
10515
10534
  is_visible,
10516
- is_timestamp
10535
+ is_timestamp,
10536
+ quantity_type
10517
10537
  });
10518
10538
  });
10519
10539
  return transformedColumns;
@@ -10963,7 +10983,9 @@ var exportCSV = ({
10963
10983
  token,
10964
10984
  filters,
10965
10985
  tableFilters,
10966
- csvProgressCallback
10986
+ csvProgressCallback,
10987
+ source = DEFAULT_SOURCE,
10988
+ scope = "null"
10967
10989
  } = {}) => {
10968
10990
  if (!token || !domain || !apiKey) {
10969
10991
  return Promise.reject(new Error("Unauthenticated" /* UNAUTHENTICATED */));
@@ -10971,7 +10993,9 @@ var exportCSV = ({
10971
10993
  const url = `${domain}/autoql/api/v1/query/${queryId}/export?key=${apiKey}`;
10972
10994
  const data = {
10973
10995
  session_filter_locks: filters,
10974
- filters: tableFilters
10996
+ filters: tableFilters,
10997
+ source,
10998
+ scope
10975
10999
  };
10976
11000
  const config = {
10977
11001
  headers: {