@quillsql/react 1.5.3 → 1.5.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.
@@ -68,24 +68,57 @@ export const useQuill = (
68
68
  return;
69
69
  }
70
70
  // @ts-ignore
71
- const { publicKey, customerId, environment } = client;
71
+ const {
72
+ publicKey,
73
+ customerId,
74
+ environment,
75
+ queryEndpoint,
76
+ queryHeaders,
77
+ } = client;
72
78
  try {
73
- const resp = await axios.get(
74
- 'https://quill-344421.uc.r.appspot.com/item',
75
- {
76
- params: {
77
- id: chartId,
78
- orgId: customerId,
79
- publicKey: publicKey,
80
- },
81
- headers: {
79
+ if (queryEndpoint) {
80
+ const resp = await axios.get(
81
+ 'https://quill-344421.uc.r.appspot.com/selfhostitem',
82
+ {
83
+ params: {
84
+ id: chartId,
85
+ orgId: customerId,
86
+ publicKey: publicKey,
87
+ },
82
88
  environment: environment || undefined,
83
- },
84
- }
85
- );
86
- setLoading(false);
87
- setData(resp.data);
88
- dispatch({ type: 'UPDATE_DASHBOARD_ITEM', id, data: resp.data });
89
+ }
90
+ );
91
+
92
+ const resp1 = await axios.post(
93
+ queryEndpoint,
94
+ { query: resp.data.queryString },
95
+ { headers: queryHeaders }
96
+ );
97
+ setLoading(false);
98
+ setData({
99
+ ...resp.data,
100
+ rows: resp1.data.rows,
101
+ fields: resp1.data.fields,
102
+ });
103
+ dispatch({ type: 'UPDATE_DASHBOARD_ITEM', id, data: resp.data });
104
+ } else {
105
+ const resp = await axios.get(
106
+ 'https://quill-344421.uc.r.appspot.com/item',
107
+ {
108
+ params: {
109
+ id: chartId,
110
+ orgId: customerId,
111
+ publicKey: publicKey,
112
+ },
113
+ headers: {
114
+ environment: environment || undefined,
115
+ },
116
+ }
117
+ );
118
+ setLoading(false);
119
+ setData(resp.data);
120
+ dispatch({ type: 'UPDATE_DASHBOARD_ITEM', id, data: resp.data });
121
+ }
89
122
  } catch (e) {
90
123
  if (typeof e === 'string' || (typeof e === 'object' && e !== null)) {
91
124
  setError(stringifyIfObject(e));
package/src/index.ts CHANGED
@@ -3,4 +3,6 @@ export { default as Dashboard } from './Dashboard';
3
3
  export { default as QuillProvider } from './QuillProvider';
4
4
  export { default as Chart } from './Chart';
5
5
  export { default as Table } from './Table';
6
+ export { default as SQLEditor } from './SQLEditor';
7
+ export { default as ReportBuilder } from './ReportBuilder';
6
8
  export { useQuill } from './hooks/useQuill';