@databrainhq/plugin 0.14.4 → 0.14.5

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.
@@ -28076,17 +28076,28 @@ const xq = ({
28076
28076
  ) : new RegExp(
28077
28077
  `FROM\\s*${M}\\s*AS\\s*['"]?[^"'\\s]+['"]?\\s*`,
28078
28078
  "gi"
28079
- ), g = o.test(n), l = N.test(n), j = D.test(n);
28080
- if (g || l)
28079
+ ), g = a ? new RegExp(
28080
+ `FROM\\s*${r}\\s*AS\\s*['"]?[^"'\\s]+['"]?\\s*(?:\\s*[^"'\\s]+)?\\s*?JOIN`,
28081
+ "gi"
28082
+ ) : new RegExp(
28083
+ `FROM\\s*${r}\\s*AS\\s*['"]?[^"'\\s]+['"]?\\s*(?:\\s*[^"'\\s]+)?\\s*?JOIN`,
28084
+ "gi"
28085
+ ), l = o.test(n), j = N.test(n), T = D.test(n), y = g.test(n);
28086
+ if (l || j)
28087
+ n = n.replace(
28088
+ j ? N : o,
28089
+ (z) => `${z} ${t.condition} AND `
28090
+ );
28091
+ else if (y)
28081
28092
  n = n.replace(
28082
- l ? N : o,
28083
- (T) => `${T} ${t.condition} AND `
28093
+ u ? M : r,
28094
+ (z) => `( SELECT * from ${z} WHERE ${t.condition} )`
28084
28095
  );
28085
28096
  else {
28086
- const T = j ? D : u ? M : r;
28097
+ const z = T ? D : u ? M : r;
28087
28098
  n = n.replace(
28088
- T,
28089
- (y) => `${y} WHERE ${t.condition}`
28099
+ z,
28100
+ (A) => `${A} WHERE ${t.condition}`
28090
28101
  );
28091
28102
  }
28092
28103
  }
@@ -79744,22 +79755,92 @@ const g8e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty(
79744
79755
  const [a, u] = De.useState(!1), o = De.useCallback(async () => {
79745
79756
  try {
79746
79757
  u(!0);
79747
- const s = await fetch(sze, {
79748
- method: "POST",
79758
+ const s = window.open("", "_blank");
79759
+ if (s) {
79760
+ s.document.write(`<html>
79761
+ <body>
79762
+
79763
+ <p id="progress-text">Downloading...</p>
79764
+
79765
+ </body></html>`);
79766
+ const N = s.document.createElement("script");
79767
+ N.innerHTML = `
79768
+ async function downloadCsv() {
79769
+ try {
79770
+ // Add the code for downloading the CSV file here
79771
+ const res = await fetch(\`${sze}\`, {
79772
+ method: 'POST',
79749
79773
  body: JSON.stringify({
79750
- companyIntegrationId: i,
79751
- integrationName: e,
79752
- query: n,
79753
- name: t
79774
+ companyIntegrationId: \`${i}\`,
79775
+ integrationName: \`${e}\`,
79776
+ query: \`${n}\`,
79777
+ name: \`${t}\`,
79754
79778
  }),
79755
79779
  headers: {
79756
- "Content-Type": "application/json"
79757
- }
79780
+ 'Content-Type': 'application/json',
79781
+ },
79758
79782
  });
79759
- if (!s.ok)
79760
- throw new Error("Network response was not ok");
79761
- const N = await s.blob(), D = URL.createObjectURL(N), g = document.createElement("a");
79762
- g.href = D, g.download = `${t}.zip`, g.style.display = "none", document.body.appendChild(g), u(!1), g.click(), URL.revokeObjectURL(D), document.body.removeChild(g);
79783
+
79784
+ if (!res.ok) {
79785
+ throw new Error('Network response was not ok');
79786
+ }
79787
+
79788
+ // Read the response body as a Blob (binary data)
79789
+ const zipData = await res.blob();
79790
+
79791
+ // Create a temporary URL for the Blob
79792
+ const zipUrl = URL.createObjectURL(zipData);
79793
+
79794
+ // Create a link element to trigger the download
79795
+ const downloadLink = document.createElement('a');
79796
+ downloadLink.href = zipUrl;
79797
+ downloadLink.download = \`${t}.zip\`; // Specify the filename here
79798
+ downloadLink.style.display = 'none';
79799
+
79800
+ // Append the link to the document and trigger the click event
79801
+ document.body.appendChild(downloadLink);
79802
+ downloadLink.click();
79803
+
79804
+ // Clean up the temporary URL
79805
+ URL.revokeObjectURL(zipUrl);
79806
+
79807
+ document.getElementById('progress-text').textContent = 'Download complete';
79808
+
79809
+ // Remove the link from the document
79810
+ document.body.removeChild(downloadLink);
79811
+ // Close the new tab/window
79812
+ window.close();
79813
+
79814
+ } catch (error) {
79815
+ // Handle errors as needed
79816
+ // eslint-disable-next-line no-alert
79817
+ alert('Error downloading the file. Please try later.');
79818
+ }
79819
+ }
79820
+ // Create a button in the new tab's HTML
79821
+ const button = document.createElement('button');
79822
+ button.textContent = 'Download CSV';
79823
+ button.id = 'downcsv_button';
79824
+ button.style.display = 'none'
79825
+
79826
+ // Attach the event listener within the script
79827
+ button.addEventListener('click', () => {
79828
+ // Call the downloadCsv function when the button is clicked
79829
+ downloadCsv();
79830
+ });
79831
+
79832
+ // Append the button to the document
79833
+ document.body.appendChild(button);
79834
+
79835
+ button.click();
79836
+
79837
+
79838
+
79839
+
79840
+
79841
+ `, s.document.body.appendChild(N);
79842
+ }
79843
+ u(!1);
79763
79844
  } catch {
79764
79845
  u(!1), alert("Error downloading the file. Please try later.");
79765
79846
  }