tsv2-library 1.0.61-alpha.62 → 1.0.61-alpha.63

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.
@@ -1,8 +1,4 @@
1
1
  export declare const buildFileURL: (name?: string, width?: number, height?: number) => string;
2
- export declare const fetchFile: (url: string, token: string) => Promise<{
3
- blob: Blob;
4
- fetchFileName: string | null;
5
- }>;
6
2
  /**
7
3
  *
8
4
  * @param fileUrl The full URL
@@ -19186,11 +19186,11 @@ function generateXlsxFile(data30, _ref2) {
19186
19186
  }
19187
19187
  const prepareRows = (headers, data30) => {
19188
19188
  const rows3 = [];
19189
+ if (headers) {
19190
+ rows3.push(headers.map((h2) => ({ value: h2 })));
19191
+ }
19189
19192
  const isObjectArray = Array.isArray(data30) && data30.length > 0 && !Array.isArray(data30[0]);
19190
19193
  if (isObjectArray) {
19191
- if (headers) {
19192
- rows3.push(headers.map((h2) => ({ value: h2 })));
19193
- }
19194
19194
  if (data30.length > 0) {
19195
19195
  const keys2 = Object.keys(data30[0]);
19196
19196
  data30.forEach((row2) => {
@@ -19204,9 +19204,6 @@ const prepareRows = (headers, data30) => {
19204
19204
  }
19205
19205
  } else if (Array.isArray(data30) && Array.isArray(data30[0])) {
19206
19206
  const arrayData = data30;
19207
- if (headers) {
19208
- rows3.push(headers.map((h2) => ({ value: h2 })));
19209
- }
19210
19207
  arrayData.forEach((row2) => {
19211
19208
  if (row2.length === 0) {
19212
19209
  rows3.push([{ value: "" }]);
@@ -19606,7 +19603,7 @@ const buildFileURL = (name, width2, height) => {
19606
19603
  return url;
19607
19604
  };
19608
19605
  const getFilenameFromResponse = (response) => {
19609
- const contentDisposition = response.headers.get("Content-Disposition");
19606
+ const contentDisposition = response.headers["Content-Disposition"];
19610
19607
  if (!contentDisposition)
19611
19608
  return null;
19612
19609
  const quotedFilenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
@@ -19618,25 +19615,22 @@ const getAuthToken = () => {
19618
19615
  return user.jwt ?? user.token ?? "";
19619
19616
  };
19620
19617
  const fetchFile = async (url, token) => {
19621
- const res = await fetch(url, {
19618
+ const res = await axios.get(url, {
19619
+ responseType: "blob",
19622
19620
  headers: {
19623
19621
  Authorization: `Bearer ${token}`
19624
19622
  }
19625
19623
  });
19626
- if (!res.ok) {
19627
- throw new Error(`Image fetch failed: ${res.status} ${res.statusText}`);
19628
- }
19629
- const arrayBuffer = await res.arrayBuffer();
19630
19624
  return {
19631
- blob: new Blob([arrayBuffer], {
19632
- type: res.headers.get("Content-Type") || "image/webp"
19625
+ blob: new Blob([res.data], {
19626
+ type: res.headers["Content-Type"] || "image/webp"
19633
19627
  }),
19634
- fetchFileName: getFilenameFromResponse(res)
19628
+ fileName: getFilenameFromResponse(res)
19635
19629
  };
19636
19630
  };
19637
19631
  const downloadFile = async (fileUrl, customFileName, immediateRevoke = true) => {
19638
19632
  const token = getAuthToken();
19639
- const { blob: blob2, fetchFileName } = await fetchFile(fileUrl, token);
19633
+ const { blob: blob2, fileName: fetchFileName } = await fetchFile(fileUrl, token);
19640
19634
  let objectUrl = "";
19641
19635
  const isViewable = /^(image|application\/pdf)/i.test(blob2.type);
19642
19636
  const fileName = customFileName ?? fetchFileName;