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.mjs CHANGED
@@ -4963,13 +4963,20 @@ var formatElement = ({
4963
4963
  const validatedQuantityDecimals = !isNaN(quantityDecimals) ? quantityDecimals : 2;
4964
4964
  const elementNumber = parseFloat(`${element}`);
4965
4965
  if (!isNaN(elementNumber)) {
4966
- const numDecimals = elementNumber % 1 !== 0 ? validatedQuantityDecimals : 0;
4966
+ let numDecimals;
4967
+ if ((column == null ? void 0 : column.quantity_type) === "integer") {
4968
+ numDecimals = 0;
4969
+ } else if ((column == null ? void 0 : column.quantity_type) === "float") {
4970
+ numDecimals = validatedQuantityDecimals;
4971
+ } else {
4972
+ numDecimals = elementNumber % 1 !== 0 ? validatedQuantityDecimals : 0;
4973
+ }
4967
4974
  formattedElement = new Intl.NumberFormat(languageCode, {
4968
4975
  minimumFractionDigits: numDecimals,
4969
4976
  maximumFractionDigits: numDecimals
4970
4977
  }).format(elementNumber);
4971
- if (formattedElement.endsWith(".00")) {
4972
- formattedElement = formattedElement.replace(".00", "");
4978
+ if ((column == null ? void 0 : column.quantity_type) !== "float" && `${formattedElement}`.endsWith(".00")) {
4979
+ formattedElement = `${formattedElement}`.replace(".00", "");
4973
4980
  }
4974
4981
  }
4975
4982
  break;
@@ -9956,16 +9963,27 @@ var transformQueryResponse = (response, originalQueryID, isDrilldown2 = false, n
9956
9963
  }
9957
9964
  return transformedResponse;
9958
9965
  };
9966
+ var detectQuantityType = (rows, colIndex) => {
9967
+ if (!(rows == null ? void 0 : rows.length)) return "float";
9968
+ for (const row of rows) {
9969
+ const val = row == null ? void 0 : row[colIndex];
9970
+ if (val === null || val === void 0) continue;
9971
+ const num = typeof val === "number" ? val : parseFloat(val);
9972
+ if (!isNaN(num) && num % 1 !== 0) return "float";
9973
+ }
9974
+ return "integer";
9975
+ };
9959
9976
  var transformQueryResponseColumns = (response, addedColumns) => {
9960
- var _a2, _b2;
9977
+ var _a2, _b2, _c, _d;
9961
9978
  const columns = (_b2 = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.data) == null ? void 0 : _b2.columns;
9979
+ const rows = (_d = (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.data) == null ? void 0 : _d.rows;
9962
9980
  if (!(columns == null ? void 0 : columns.length)) {
9963
9981
  return columns;
9964
9982
  }
9965
9983
  const isSingleValue = isSingleValueResponse(response);
9966
9984
  const transformedColumns = columns.map((col, i) => {
9967
- var _a3, _b3, _c, _d;
9968
- 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];
9985
+ var _a3;
9986
+ const dataSample = (_a3 = rows == null ? void 0 : rows.find((row) => row[i])) == null ? void 0 : _a3[i];
9969
9987
  const drilldownGroupby = getDrilldownGroupby(response, col);
9970
9988
  let additional = false;
9971
9989
  let is_timestamp = false;
@@ -9982,6 +10000,7 @@ var transformQueryResponseColumns = (response, addedColumns) => {
9982
10000
  if (isSingleValue) {
9983
10001
  is_visible = true;
9984
10002
  }
10003
+ const quantity_type = col.type === "QUANTITY" /* QUANTITY */ ? detectQuantityType(rows, i) : void 0;
9985
10004
  return new Column({
9986
10005
  ...col,
9987
10006
  field: `${i}`,
@@ -9989,7 +10008,8 @@ var transformQueryResponseColumns = (response, addedColumns) => {
9989
10008
  drilldownGroupby,
9990
10009
  additional,
9991
10010
  is_visible,
9992
- is_timestamp
10011
+ is_timestamp,
10012
+ quantity_type
9993
10013
  });
9994
10014
  });
9995
10015
  return transformedColumns;
@@ -10439,7 +10459,9 @@ var exportCSV = ({
10439
10459
  token,
10440
10460
  filters,
10441
10461
  tableFilters,
10442
- csvProgressCallback
10462
+ csvProgressCallback,
10463
+ source = DEFAULT_SOURCE,
10464
+ scope = "null"
10443
10465
  } = {}) => {
10444
10466
  if (!token || !domain || !apiKey) {
10445
10467
  return Promise.reject(new Error("Unauthenticated" /* UNAUTHENTICATED */));
@@ -10447,7 +10469,9 @@ var exportCSV = ({
10447
10469
  const url = `${domain}/autoql/api/v1/query/${queryId}/export?key=${apiKey}`;
10448
10470
  const data = {
10449
10471
  session_filter_locks: filters,
10450
- filters: tableFilters
10472
+ filters: tableFilters,
10473
+ source,
10474
+ scope
10451
10475
  };
10452
10476
  const config = {
10453
10477
  headers: {