@quillsql/react 2.12.52 → 2.12.53
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/cjs/Chart.js +1 -1
- package/dist/cjs/ChartBuilder.d.ts +7 -3
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +54 -18
- package/dist/cjs/ChartEditor.d.ts +3 -1
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +42 -7
- package/dist/cjs/Context.d.ts +4 -5
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +22 -34
- package/dist/cjs/Dashboard.d.ts +4 -3
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +24 -29
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.js +8 -10
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts +1 -0
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/cjs/QuillProvider.js +1 -1
- package/dist/cjs/ReportBuilder.d.ts +8 -12
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +157 -83
- package/dist/cjs/SQLEditor.d.ts +8 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +80 -28
- package/dist/cjs/Table.js +1 -1
- package/dist/cjs/assets/AdjustmentsIcon.d.ts +5 -0
- package/dist/cjs/assets/AdjustmentsIcon.d.ts.map +1 -0
- package/dist/cjs/assets/AdjustmentsIcon.js +5 -0
- package/dist/cjs/assets/ArrowDownHeadIcon.d.ts.map +1 -1
- package/dist/cjs/components/Chart/ChartError.js +2 -2
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts +2 -2
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +6 -6
- package/dist/cjs/components/Dashboard/DashboardTemplate.d.ts +2 -2
- package/dist/cjs/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +5 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +23 -4
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +2 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +2 -2
- package/dist/cjs/components/Dashboard/util.d.ts +2 -2
- package/dist/cjs/components/Dashboard/util.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/util.js +2 -2
- package/dist/cjs/components/QuillMultiSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelect.js +18 -13
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +67 -45
- package/dist/cjs/components/QuillSelect.d.ts +1 -1
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelect.js +28 -6
- package/dist/cjs/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelectWithCombo.js +45 -24
- package/dist/cjs/components/QuillTable.d.ts +2 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +7 -4
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +2 -2
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.js +17 -4
- package/dist/cjs/components/ReportBuilder/ui.d.ts +13 -7
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +14 -11
- package/dist/cjs/components/UiComponents.d.ts +15 -8
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +29 -23
- package/dist/cjs/hooks/useAstToFilterTree.d.ts +2 -2
- package/dist/cjs/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.d.ts +9 -4
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +61 -38
- package/dist/cjs/hooks/useExport.js +1 -1
- package/dist/cjs/hooks/useQuill.js +2 -2
- package/dist/cjs/hooks/useVirtualTables.d.ts +12 -3
- package/dist/cjs/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/cjs/hooks/useVirtualTables.js +105 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts +3 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.js +9 -9
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.js +21 -15
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +3 -2
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +9 -9
- package/dist/cjs/models/Client.d.ts +10 -2
- package/dist/cjs/models/Client.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.d.ts +3 -3
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/client.d.ts.map +1 -1
- package/dist/cjs/utils/client.js +2 -7
- package/dist/cjs/utils/dashboard.d.ts +5 -5
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +87 -7
- package/dist/cjs/utils/dataFetcher.d.ts +4 -4
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +1 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +2 -8
- package/dist/cjs/utils/paginationProcessing.js +1 -1
- package/dist/cjs/utils/pivotConstructor.d.ts +2 -2
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +1 -1
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +6 -2
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +12 -9
- package/dist/cjs/utils/report.d.ts +6 -5
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +69 -24
- package/dist/cjs/utils/schema.d.ts +3 -3
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +39 -35
- package/dist/cjs/utils/tableProcessing.d.ts +17 -10
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +42 -23
- package/dist/esm/Chart.js +2 -2
- package/dist/esm/ChartBuilder.d.ts +7 -3
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +51 -18
- package/dist/esm/ChartEditor.d.ts +3 -1
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +43 -8
- package/dist/esm/Context.d.ts +4 -5
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +23 -35
- package/dist/esm/Dashboard.d.ts +4 -3
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +24 -29
- package/dist/esm/DateRangePicker/QuillDateRangePicker.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/QuillDateRangePicker.js +8 -10
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts +1 -0
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/dateRangePickerUtils.js +1 -1
- package/dist/esm/QuillProvider.js +1 -1
- package/dist/esm/ReportBuilder.d.ts +8 -12
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +160 -86
- package/dist/esm/SQLEditor.d.ts +8 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +83 -31
- package/dist/esm/Table.js +2 -2
- package/dist/esm/assets/AdjustmentsIcon.d.ts +5 -0
- package/dist/esm/assets/AdjustmentsIcon.d.ts.map +1 -0
- package/dist/esm/assets/AdjustmentsIcon.js +3 -0
- package/dist/esm/assets/ArrowDownHeadIcon.d.ts.map +1 -1
- package/dist/esm/components/Chart/ChartError.js +2 -2
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts +2 -2
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +6 -6
- package/dist/esm/components/Dashboard/DashboardTemplate.d.ts +2 -2
- package/dist/esm/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts +5 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +25 -6
- package/dist/esm/components/Dashboard/TableComponent.d.ts +2 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +2 -2
- package/dist/esm/components/Dashboard/util.d.ts +2 -2
- package/dist/esm/components/Dashboard/util.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/util.js +2 -2
- package/dist/esm/components/QuillMultiSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelect.js +19 -14
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.js +68 -46
- package/dist/esm/components/QuillSelect.d.ts +1 -1
- package/dist/esm/components/QuillSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillSelect.js +29 -7
- package/dist/esm/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillSelectWithCombo.js +46 -25
- package/dist/esm/components/QuillTable.d.ts +2 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +7 -4
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +2 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +2 -2
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.js +17 -4
- package/dist/esm/components/ReportBuilder/ui.d.ts +13 -7
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +14 -11
- package/dist/esm/components/UiComponents.d.ts +15 -8
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +29 -23
- package/dist/esm/hooks/useAstToFilterTree.d.ts +2 -2
- package/dist/esm/hooks/useAstToFilterTree.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.d.ts +9 -4
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +62 -39
- package/dist/esm/hooks/useExport.js +1 -1
- package/dist/esm/hooks/useQuill.js +3 -3
- package/dist/esm/hooks/useVirtualTables.d.ts +12 -3
- package/dist/esm/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/esm/hooks/useVirtualTables.js +106 -2
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts +3 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.js +9 -9
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.js +21 -15
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +3 -2
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +9 -9
- package/dist/esm/models/Client.d.ts +10 -2
- package/dist/esm/models/Client.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.d.ts +3 -3
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/client.d.ts.map +1 -1
- package/dist/esm/utils/client.js +2 -7
- package/dist/esm/utils/dashboard.d.ts +5 -5
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +87 -7
- package/dist/esm/utils/dataFetcher.d.ts +4 -4
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +1 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +2 -8
- package/dist/esm/utils/paginationProcessing.js +1 -1
- package/dist/esm/utils/pivotConstructor.d.ts +2 -2
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +1 -1
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +6 -2
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +12 -9
- package/dist/esm/utils/report.d.ts +6 -5
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +68 -24
- package/dist/esm/utils/schema.d.ts +3 -3
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +39 -35
- package/dist/esm/utils/tableProcessing.d.ts +17 -10
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +39 -20
- package/package.json +1 -1
package/dist/cjs/utils/report.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchReportBuilderDataFromAST = exports.convertInternalReportToReport = exports.formatRowsFromReport = exports.saveReport = exports.fetchReport = exports.EMPTY_INTERNAL_REPORT = exports.EMPTY_REPORT = void 0;
|
|
3
|
+
exports.fetchReportBuilderDataFromAST = exports.convertInternalReportToReport = exports.formatRowsFromReport = exports.saveReport = exports.fetchReportRowCount = exports.fetchReport = exports.EMPTY_INTERNAL_REPORT = exports.EMPTY_REPORT = void 0;
|
|
4
4
|
const ChartBuilder_1 = require("../ChartBuilder");
|
|
5
5
|
const ast_1 = require("../components/ReportBuilder/ast");
|
|
6
6
|
const PivotModal_1 = require("../internals/ReportBuilder/PivotModal");
|
|
@@ -64,7 +64,7 @@ function extractAllReportValuesFromQuillInternalReport(reportInternal) {
|
|
|
64
64
|
template: reportInternal.template,
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
async function fetchReport(reportId, client, useReportTask = true, filters = [], additionalProcessing, dateBucket, customFields) {
|
|
67
|
+
async function fetchReport(reportId, client, useReportTask = true, filters = [], additionalProcessing, dateBucket, customFields, queryTask) {
|
|
68
68
|
let reportInfo = undefined;
|
|
69
69
|
let errorMessage = undefined;
|
|
70
70
|
try {
|
|
@@ -73,7 +73,7 @@ async function fetchReport(reportId, client, useReportTask = true, filters = [],
|
|
|
73
73
|
metadata: {
|
|
74
74
|
reportId,
|
|
75
75
|
dashboardItemId: reportId,
|
|
76
|
-
orgId: client.
|
|
76
|
+
orgId: client.organizationId || '*',
|
|
77
77
|
clientId: client.publicKey,
|
|
78
78
|
task: useReportTask ? 'report' : 'item',
|
|
79
79
|
databaseType: client.databaseType,
|
|
@@ -81,6 +81,7 @@ async function fetchReport(reportId, client, useReportTask = true, filters = [],
|
|
|
81
81
|
customFields,
|
|
82
82
|
additionalProcessing,
|
|
83
83
|
useNewNodeSql: true,
|
|
84
|
+
queryTask,
|
|
84
85
|
},
|
|
85
86
|
};
|
|
86
87
|
const cloudBody = {
|
|
@@ -116,8 +117,11 @@ async function fetchReport(reportId, client, useReportTask = true, filters = [],
|
|
|
116
117
|
// Ensure the report columns don't reference any columns that aren't present in the rows
|
|
117
118
|
const observedColumns = reportInfo?.rows[0]
|
|
118
119
|
? Object.keys(reportInfo.rows[0])
|
|
119
|
-
:
|
|
120
|
-
if (
|
|
120
|
+
: null;
|
|
121
|
+
if (observedColumns &&
|
|
122
|
+
reportInfo &&
|
|
123
|
+
!reportInfo.pivot &&
|
|
124
|
+
!reportInfo.pivotColumns &&
|
|
121
125
|
useReportTask &&
|
|
122
126
|
reportInfo.columns?.filter((col) => !observedColumns.includes(col.field))
|
|
123
127
|
?.length > 0) {
|
|
@@ -134,7 +138,7 @@ async function fetchReport(reportId, client, useReportTask = true, filters = [],
|
|
|
134
138
|
if (error instanceof error_1.DataLoadError) {
|
|
135
139
|
if (error.data.useReportTask) {
|
|
136
140
|
(0, logging_1.internalLog)('USING ITEM AS BACKUP');
|
|
137
|
-
const { report, error } = await fetchReport(reportId, client, false, filters, additionalProcessing, dateBucket, customFields);
|
|
141
|
+
const { report, error } = await fetchReport(reportId, client, false, filters, additionalProcessing, dateBucket, customFields, queryTask);
|
|
138
142
|
reportInfo = report;
|
|
139
143
|
errorMessage = error;
|
|
140
144
|
}
|
|
@@ -162,12 +166,38 @@ async function fetchReport(reportId, client, useReportTask = true, filters = [],
|
|
|
162
166
|
return { report: reportInfo || exports.EMPTY_INTERNAL_REPORT, error: errorMessage };
|
|
163
167
|
}
|
|
164
168
|
exports.fetchReport = fetchReport;
|
|
169
|
+
async function fetchReportRowCount(reportId, client, useReportTask = true, filters = [], additionalProcessing, customFields) {
|
|
170
|
+
// Remove extra fields on each filter so we don't confuse the backend.
|
|
171
|
+
const hostedBody = {
|
|
172
|
+
metadata: {
|
|
173
|
+
reportId,
|
|
174
|
+
dashboardItemId: reportId,
|
|
175
|
+
orgId: client.organizationId || '*',
|
|
176
|
+
clientId: client.publicKey,
|
|
177
|
+
task: useReportTask ? 'report' : 'item',
|
|
178
|
+
databaseType: client.databaseType,
|
|
179
|
+
filters: filters,
|
|
180
|
+
customFields,
|
|
181
|
+
additionalProcessing,
|
|
182
|
+
useNewNodeSql: true,
|
|
183
|
+
rowCountOnly: true,
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
const cloudBody = {
|
|
187
|
+
id: reportId,
|
|
188
|
+
filters: filters,
|
|
189
|
+
useNewNodeSql: true,
|
|
190
|
+
};
|
|
191
|
+
const resp = await (0, dataFetcher_1.getData)(client, 'itempost', 'omit', hostedBody, cloudBody, 'POST', 'fetch-data');
|
|
192
|
+
return resp.rowCount;
|
|
193
|
+
}
|
|
194
|
+
exports.fetchReportRowCount = fetchReportRowCount;
|
|
165
195
|
async function saveReport({ report, dashboardItemId, client, }) {
|
|
166
|
-
const { publicKey,
|
|
196
|
+
const { publicKey, organizationId, databaseType } = client;
|
|
167
197
|
const cloudBody = {
|
|
168
198
|
...report,
|
|
169
199
|
dashboardItemId,
|
|
170
|
-
customerId:
|
|
200
|
+
customerId: organizationId || '*',
|
|
171
201
|
useNewNodeSql: true,
|
|
172
202
|
};
|
|
173
203
|
// @ts-ignore
|
|
@@ -185,14 +215,14 @@ async function saveReport({ report, dashboardItemId, client, }) {
|
|
|
185
215
|
clientId: publicKey,
|
|
186
216
|
databaseType: databaseType,
|
|
187
217
|
...cloudBody,
|
|
188
|
-
orgId:
|
|
218
|
+
orgId: organizationId || '*',
|
|
189
219
|
useNewNodeSql: true,
|
|
190
220
|
},
|
|
191
221
|
};
|
|
192
|
-
const searchParams = new URLSearchParams(
|
|
222
|
+
const searchParams = new URLSearchParams(organizationId
|
|
193
223
|
? {
|
|
194
224
|
clientId: publicKey,
|
|
195
|
-
customerId:
|
|
225
|
+
customerId: organizationId,
|
|
196
226
|
}
|
|
197
227
|
: { clientId: publicKey }).toString();
|
|
198
228
|
return await (0, dataFetcher_1.getData)(client, `dashedit2?${searchParams}`, 'same-origin', hostedBody, cloudBody);
|
|
@@ -272,7 +302,7 @@ function convertInternalReportToReport(report) {
|
|
|
272
302
|
}
|
|
273
303
|
}
|
|
274
304
|
exports.convertInternalReportToReport = convertInternalReportToReport;
|
|
275
|
-
const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, client, pivot, previousFormData, currentTable, previousRelevant, report, customFields) => {
|
|
305
|
+
const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, client, pivot, previousFormData, currentTable, previousRelevant, report, customFields, skipUniqueValues, skipRowCount, processing) => {
|
|
276
306
|
let newRows = [];
|
|
277
307
|
let newColumns = [];
|
|
278
308
|
let newRowCount = 0;
|
|
@@ -283,7 +313,7 @@ const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, client,
|
|
|
283
313
|
let table = '';
|
|
284
314
|
let error;
|
|
285
315
|
const relevantInfo = previousRelevant ?? { uniqueStrings: {}, dateRanges: {} };
|
|
286
|
-
|
|
316
|
+
let query = '';
|
|
287
317
|
try {
|
|
288
318
|
const tables = (0, ast_1.getTableNames)(baseAst);
|
|
289
319
|
table = tables[0] ? tables[0] : '';
|
|
@@ -291,7 +321,7 @@ const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, client,
|
|
|
291
321
|
if (!table || !tableInfo) {
|
|
292
322
|
throw new Error('No table found;');
|
|
293
323
|
}
|
|
294
|
-
const tableData = await (0, tableProcessing_1.fetchTableByAST)({ ...baseAst, where: formData }, client, { page: paginationProcessing_1.DEFAULT_PAGINATION });
|
|
324
|
+
const tableData = await (0, tableProcessing_1.fetchTableByAST)({ ...baseAst, where: formData }, client, processing ?? { page: paginationProcessing_1.DEFAULT_PAGINATION }, undefined, skipRowCount);
|
|
295
325
|
if (tableData.error) {
|
|
296
326
|
throw new Error(tableData.error);
|
|
297
327
|
}
|
|
@@ -315,17 +345,32 @@ const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, client,
|
|
|
315
345
|
}),
|
|
316
346
|
columnInternal: tableData.columns,
|
|
317
347
|
};
|
|
318
|
-
const queryResult = await (0, dataFetcher_1.fetchSqlQuery)({
|
|
319
|
-
...(0, astProcessing_1.createBasicSelectASTFromColumns)(tableInfo.columns, table),
|
|
320
|
-
where: formData,
|
|
321
|
-
}, client, formData);
|
|
322
|
-
if (queryResult.error) {
|
|
323
|
-
throw new Error(queryResult.error);
|
|
324
|
-
}
|
|
325
348
|
if (table !== currentTable || previousFormData !== formData) {
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
349
|
+
const queryResult = await (0, dataFetcher_1.fetchSqlQuery)({
|
|
350
|
+
...(0, astProcessing_1.createBasicSelectASTFromColumns)(tableInfo.columns, table),
|
|
351
|
+
where: formData,
|
|
352
|
+
}, client, formData);
|
|
353
|
+
if (queryResult.error) {
|
|
354
|
+
throw new Error(queryResult.error);
|
|
355
|
+
}
|
|
356
|
+
query = queryResult.query;
|
|
357
|
+
if (!skipUniqueValues) {
|
|
358
|
+
const { uniqueStrings, dateRanges } = await (0, tableProcessing_1.getRelevantInfoFromQuery)(tableInfo.columns, client, queryResult.query, customFields);
|
|
359
|
+
relevantInfo.uniqueStrings[table] = uniqueStrings ?? {};
|
|
360
|
+
relevantInfo.dateRanges = dateRanges ?? {};
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
const dateColumns = tableInfo.columns.filter((column) => {
|
|
364
|
+
return column.fieldType === 'date';
|
|
365
|
+
});
|
|
366
|
+
if (dateColumns.length > 0) {
|
|
367
|
+
const dateRanges = await (0, tableProcessing_1.getDateRangeByColumns)(dateColumns, queryResult.query, client, customFields ?? []);
|
|
368
|
+
if (dateRanges === null) {
|
|
369
|
+
throw new Error("Couldn't fetch date ranges");
|
|
370
|
+
}
|
|
371
|
+
relevantInfo.dateRanges = dateRanges ?? {};
|
|
372
|
+
}
|
|
373
|
+
}
|
|
329
374
|
}
|
|
330
375
|
if (!!relevantInfo.error) {
|
|
331
376
|
throw new Error(relevantInfo.error);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QuillProviderClient } from '../models/Client';
|
|
2
2
|
import { Table } from '../models/Tables';
|
|
3
|
-
export declare const getCustomFieldInfo: (client:
|
|
4
|
-
export declare const getSchemaInfoWithCustomFields: (client:
|
|
3
|
+
export declare const getCustomFieldInfo: (client: QuillProviderClient, caller?: string) => Promise<any[]>;
|
|
4
|
+
export declare const getSchemaInfoWithCustomFields: (client: QuillProviderClient, caller?: string, tableIds?: string[]) => Promise<{
|
|
5
5
|
schemaData: Table[];
|
|
6
6
|
customFieldsByTable: any;
|
|
7
7
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAyDzC,eAAO,MAAM,kBAAkB,WACrB,mBAAmB,oCAqF5B,CAAC;AAEF,eAAO,MAAM,6BAA6B,WAChC,mBAAmB,8BAEhB,MAAM,EAAE,KAClB,QAAQ;IAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAAC,mBAAmB,EAAE,GAAG,CAAA;CAAE,CAoD3D,CAAC"}
|
package/dist/cjs/utils/schema.js
CHANGED
|
@@ -2,32 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSchemaInfoWithCustomFields = exports.getCustomFieldInfo = void 0;
|
|
4
4
|
const columnProcessing_1 = require("./columnProcessing");
|
|
5
|
-
const triggerSoftUpdate = async (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
5
|
+
// const triggerSoftUpdate = async (
|
|
6
|
+
// client: QuillProviderClient,
|
|
7
|
+
// tables: Table[],
|
|
8
|
+
// ) => {
|
|
9
|
+
// const { queryEndpoint, queryHeaders, publicKey, withCredentials } = client;
|
|
10
|
+
// tables.forEach(async (table: Table) => {
|
|
11
|
+
// // if (table.isSelectStar) {
|
|
12
|
+
// fetch(`${queryEndpoint}?update-view`, {
|
|
13
|
+
// method: 'POST',
|
|
14
|
+
// headers: {
|
|
15
|
+
// ...queryHeaders,
|
|
16
|
+
// 'Content-Type': 'application/json',
|
|
17
|
+
// },
|
|
18
|
+
// credentials: withCredentials ? 'include' : 'omit',
|
|
19
|
+
// body: JSON.stringify({
|
|
20
|
+
// metadata: {
|
|
21
|
+
// preQueries: [table.viewQuery.replace(/;/, '')],
|
|
22
|
+
// clientId: publicKey,
|
|
23
|
+
// publicKey: publicKey,
|
|
24
|
+
// task: 'update-view',
|
|
25
|
+
// name: table.name,
|
|
26
|
+
// id: table._id,
|
|
27
|
+
// runQueryConfig: { getColumns: true },
|
|
28
|
+
// },
|
|
29
|
+
// }),
|
|
30
|
+
// });
|
|
31
|
+
// // }
|
|
32
|
+
// });
|
|
33
|
+
// };
|
|
31
34
|
const parseResponse = (results) => {
|
|
32
35
|
if (results.data?.data) {
|
|
33
36
|
if (results.data.data.queries &&
|
|
@@ -52,7 +55,7 @@ const parseResponse = (results) => {
|
|
|
52
55
|
const getCustomFieldInfo = async (client, caller = 'se') => {
|
|
53
56
|
let customFieldsByTableUnique = [];
|
|
54
57
|
try {
|
|
55
|
-
const { queryEndpoint, queryHeaders, publicKey, databaseType,
|
|
58
|
+
const { queryEndpoint, queryHeaders, publicKey, databaseType, organizationId, } = client;
|
|
56
59
|
if ((databaseType && databaseType.toLowerCase() !== 'postgresql') ||
|
|
57
60
|
!['665610862cf7a3000be66453'].includes(publicKey)) {
|
|
58
61
|
throw new Error('CUSTOM FIELDS IS ONLY ALLOWED FOR POSTGRESQL DATABASES');
|
|
@@ -70,7 +73,7 @@ const getCustomFieldInfo = async (client, caller = 'se') => {
|
|
|
70
73
|
publicKey,
|
|
71
74
|
task: 'custom-field-records',
|
|
72
75
|
databaseType: databaseType,
|
|
73
|
-
orgId:
|
|
76
|
+
orgId: organizationId,
|
|
74
77
|
},
|
|
75
78
|
}),
|
|
76
79
|
});
|
|
@@ -115,11 +118,11 @@ const getCustomFieldInfo = async (client, caller = 'se') => {
|
|
|
115
118
|
return customFieldsByTableUnique;
|
|
116
119
|
};
|
|
117
120
|
exports.getCustomFieldInfo = getCustomFieldInfo;
|
|
118
|
-
const getSchemaInfoWithCustomFields = async (client, caller = 'se') => {
|
|
119
|
-
const { queryEndpoint, queryHeaders, publicKey,
|
|
121
|
+
const getSchemaInfoWithCustomFields = async (client, caller = 'se', tableIds) => {
|
|
122
|
+
const { queryEndpoint, queryHeaders, publicKey, organizationId, withCredentials, } = client;
|
|
120
123
|
let customFieldsByTableUnique = [];
|
|
121
124
|
let getCustomFields = true;
|
|
122
|
-
if (!
|
|
125
|
+
if (!organizationId || organizationId !== '*') {
|
|
123
126
|
try {
|
|
124
127
|
customFieldsByTableUnique = await (0, exports.getCustomFieldInfo)(client, caller);
|
|
125
128
|
}
|
|
@@ -140,12 +143,13 @@ const getSchemaInfoWithCustomFields = async (client, caller = 'se') => {
|
|
|
140
143
|
publicKey: publicKey,
|
|
141
144
|
task: 'schema',
|
|
142
145
|
removeCustomerField: true,
|
|
143
|
-
getCustomFields: !client.
|
|
144
|
-
client.
|
|
146
|
+
getCustomFields: !client.organizationId ||
|
|
147
|
+
client.organizationId === '*' ||
|
|
145
148
|
(customFieldsByTableUnique.length === 0 && !getCustomFields)
|
|
146
149
|
? false
|
|
147
150
|
: true,
|
|
148
|
-
orgId: client.
|
|
151
|
+
orgId: client.organizationId || '*',
|
|
152
|
+
tableIds,
|
|
149
153
|
customFieldsByTable: customFieldsByTableUnique,
|
|
150
154
|
gatherSchemaData: '665610862cf7a3000be66453' === publicKey ? true : false,
|
|
151
155
|
},
|
|
@@ -154,7 +158,7 @@ const getSchemaInfoWithCustomFields = async (client, caller = 'se') => {
|
|
|
154
158
|
const result = await response.json();
|
|
155
159
|
const parsedData = parseResponse(result);
|
|
156
160
|
const converted = convertSchemaInfoToTable(parsedData);
|
|
157
|
-
triggerSoftUpdate(client, converted);
|
|
161
|
+
// triggerSoftUpdate(client, converted);
|
|
158
162
|
return {
|
|
159
163
|
schemaData: converted,
|
|
160
164
|
customFieldsByTable: customFieldsByTableUnique,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NodeSQLParser } from '../components/ReportBuilder/ast';
|
|
2
|
-
import {
|
|
2
|
+
import { QuillProviderClient } from '../models/Client';
|
|
3
3
|
import { Column, ColumnInternal } from '../models/Columns';
|
|
4
|
+
import { Filter } from '../models/Filter';
|
|
4
5
|
import { Pagination } from '../models/Pagination';
|
|
5
6
|
import { DateRangesByColumn, UniqueValuesByColumn } from '../models/Tables';
|
|
6
7
|
export interface AdditionalProcessing {
|
|
@@ -12,19 +13,22 @@ export interface AdditionalProcessing {
|
|
|
12
13
|
last?: any;
|
|
13
14
|
}
|
|
14
15
|
export declare const hasColumnAlias: (columns: Column[], referencedColumns: string[]) => boolean;
|
|
15
|
-
export declare const getUniqueValuesByColumns: (columns: Column[], query: string, rows: any, client:
|
|
16
|
+
export declare const getUniqueValuesByColumns: (columns: Column[], query: string, rows: any, client: QuillProviderClient, customFields: any[]) => Promise<{
|
|
16
17
|
[column: string]: {
|
|
17
18
|
[value: string]: boolean;
|
|
18
19
|
};
|
|
19
20
|
} | null>;
|
|
20
|
-
export declare const getUniqueStringValues: (columns: ColumnInternal[], tableName: string, client: any, customFields?: any, previousUniqueValues?: any) => Promise<any>;
|
|
21
|
-
export declare const getRelevantInfoFromQuery: (columns: ColumnInternal[], client:
|
|
21
|
+
export declare const getUniqueStringValues: (columns: ColumnInternal[], tableName: string, client: any, customFields?: any, previousUniqueValues?: any, withExceededColumns?: boolean, query?: string) => Promise<any>;
|
|
22
|
+
export declare const getRelevantInfoFromQuery: (columns: ColumnInternal[], client: QuillProviderClient, query: string, customFields?: any) => Promise<{
|
|
22
23
|
uniqueStrings?: UniqueValuesByColumn | undefined;
|
|
23
24
|
dateRanges?: DateRangesByColumn | undefined;
|
|
24
25
|
error?: string | undefined;
|
|
25
26
|
}>;
|
|
26
|
-
export declare const getCountsByColumns: (columns: Column[], query: string, client:
|
|
27
|
-
|
|
27
|
+
export declare const getCountsByColumns: (columns: Column[], query: string, client: QuillProviderClient, customFields: any[]) => Promise<{
|
|
28
|
+
filteredColumns: Column[];
|
|
29
|
+
exceededColumns: Column[] | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const getDateRangeByColumns: (columns: Column[], query: string, client: QuillProviderClient, customFields: any[]) => Promise<{
|
|
28
32
|
[column: string]: {
|
|
29
33
|
dateRange: {
|
|
30
34
|
start: Date;
|
|
@@ -32,26 +36,29 @@ export declare const getDateRangeByColumns: (columns: Column[], query: string, c
|
|
|
32
36
|
};
|
|
33
37
|
};
|
|
34
38
|
} | null>;
|
|
35
|
-
export declare const getPaginatedRows: (client:
|
|
39
|
+
export declare const getPaginatedRows: (client: QuillProviderClient, query?: string, reportId?: string, processing?: AdditionalProcessing, filters?: any, customFields?: any) => Promise<{
|
|
36
40
|
columns: Column[];
|
|
37
41
|
rows: any[];
|
|
38
42
|
rowCount?: number;
|
|
39
43
|
error?: string;
|
|
40
44
|
}>;
|
|
41
|
-
export declare const
|
|
45
|
+
export declare const fetchResultsByQuery: (query: string, client: QuillProviderClient, processing?: AdditionalProcessing, customFields?: any, filters?: Filter[], dateField?: {
|
|
46
|
+
field: string;
|
|
47
|
+
table: string;
|
|
48
|
+
} | null, rowsOnly?: boolean, rowCountOnly?: boolean) => Promise<{
|
|
42
49
|
columns: ColumnInternal[];
|
|
43
50
|
rows: any[];
|
|
44
51
|
rowCount?: number | undefined;
|
|
45
52
|
error?: string | undefined;
|
|
46
53
|
itemQuery?: string[] | undefined;
|
|
47
54
|
}>;
|
|
48
|
-
export declare const
|
|
55
|
+
export declare const fetchResultsByReport: (reportId: string, client: QuillProviderClient, processing?: AdditionalProcessing, filters?: any, customFields?: any) => Promise<{
|
|
49
56
|
columns: Column[];
|
|
50
57
|
rows: any[];
|
|
51
58
|
rowCount?: number | undefined;
|
|
52
59
|
error?: string | undefined;
|
|
53
60
|
}>;
|
|
54
|
-
export declare const fetchTableByAST: (ast: NodeSQLParser.Select, client:
|
|
61
|
+
export declare const fetchTableByAST: (ast: NodeSQLParser.Select, client: QuillProviderClient, processing?: AdditionalProcessing, customFields?: any, rowsOnly?: boolean, rowCountOnly?: boolean) => Promise<{
|
|
55
62
|
columns: ColumnInternal[];
|
|
56
63
|
rows: any[];
|
|
57
64
|
rowCount?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/tableProcessing.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACd,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tableProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/tableProcessing.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACd,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAgB5E,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,eAAO,MAAM,cAAc,YAChB,MAAM,EAAE,qBACE,MAAM,EAAE,KAC1B,OAUF,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAC1B,MAAM,EAAE,SACV,MAAM,QACP,GAAG,UACD,mBAAmB,gBACb,GAAG,EAAE;;;;SAmEpB,CAAC;AAEF,eAAO,MAAM,qBAAqB,YACvB,cAAc,EAAE,aACd,MAAM,UACT,GAAG,iBACI,GAAG,yBACK,GAAG,wBACJ,OAAO,UACrB,MAAM,iBA2Cf,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAC1B,cAAc,EAAE,UACjB,mBAAmB,SACpB,MAAM,iBACE,GAAG;;;;EA6DnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,YACpB,MAAM,EAAE,SACV,MAAM,UACL,mBAAmB,gBACb,GAAG,EAAE,KAClB,QAAQ;IACT,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACvC,CAiDA,CAAC;AAkDF,eAAO,MAAM,qBAAqB,YACvB,MAAM,EAAE,SACV,MAAM,UACL,mBAAmB,gBACb,GAAG,EAAE;;mBAEY;YAAE,KAAK,EAAE,IAAI,CAAC;YAAC,GAAG,EAAE,IAAI,CAAA;SAAE;;SAiB1D,CAAC;AA2DF,eAAO,MAAM,gBAAgB,WACnB,mBAAmB,UACnB,MAAM,aACH,MAAM,eACJ,oBAAoB,YACvB,GAAG,iBACE,GAAG,KACjB,QAAQ;IACT,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAaA,CAAC;AAEF,eAAO,MAAM,mBAAmB,UACvB,MAAM,UACL,mBAAmB,eACd,oBAAoB,iBAClB,GAAG,YACR,MAAM,EAAE,cACN;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,aACxC,OAAO,iBACH,OAAO;aAEb,cAAc,EAAE;UACnB,GAAG,EAAE;;;;EA2DZ,CAAC;AAEF,eAAO,MAAM,oBAAoB,aACrB,MAAM,UACR,mBAAmB,eACd,oBAAoB,YACvB,GAAG,iBACE,GAAG;aAET,MAAM,EAAE;UACX,GAAG,EAAE;;;EAgFZ,CAAC;AAEF,eAAO,MAAM,eAAe,QACrB,cAAc,MAAM,UACjB,mBAAmB,eACd,oBAAoB,iBAClB,GAAG,aACP,OAAO,iBACH,OAAO;aAEb,cAAc,EAAE;UACnB,GAAG,EAAE;;;;EAyDZ,CAAC;AAEF,eAAO,MAAM,+CAA+C,0BACnC,oBAAoB;;CAU5C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertUniqueValuesByColumnToUniqueValueStrings = exports.fetchTableByAST = exports.
|
|
3
|
+
exports.convertUniqueValuesByColumnToUniqueValueStrings = exports.fetchTableByAST = exports.fetchResultsByReport = exports.fetchResultsByQuery = exports.getPaginatedRows = exports.getDateRangeByColumns = exports.getCountsByColumns = exports.getRelevantInfoFromQuery = exports.getUniqueStringValues = exports.getUniqueValuesByColumns = exports.hasColumnAlias = void 0;
|
|
4
4
|
const ast_1 = require("../components/ReportBuilder/ast");
|
|
5
5
|
const util_1 = require("../components/ReportBuilder/util");
|
|
6
6
|
const columnProcessing_1 = require("./columnProcessing");
|
|
@@ -34,7 +34,7 @@ const getUniqueValuesByColumns = async (columns, query, rows, client, customFiel
|
|
|
34
34
|
metadata: {
|
|
35
35
|
query: query,
|
|
36
36
|
task: 'query',
|
|
37
|
-
orgId: client.
|
|
37
|
+
orgId: client.organizationId || '*',
|
|
38
38
|
clientId: client.publicKey,
|
|
39
39
|
databaseType: client?.databaseType,
|
|
40
40
|
customFieldsByTable: customFields,
|
|
@@ -72,14 +72,21 @@ const getUniqueValuesByColumns = async (columns, query, rows, client, customFiel
|
|
|
72
72
|
return uniqueValues;
|
|
73
73
|
};
|
|
74
74
|
exports.getUniqueValuesByColumns = getUniqueValuesByColumns;
|
|
75
|
-
const getUniqueStringValues = async (columns, tableName, client, customFields, previousUniqueValues) => {
|
|
75
|
+
const getUniqueStringValues = async (columns, tableName, client, customFields, previousUniqueValues, withExceededColumns, query) => {
|
|
76
76
|
const convertedStringColumns = columns.filter((column) => {
|
|
77
77
|
return (0, ast_1.isTextColumnType)(column.fieldType);
|
|
78
78
|
});
|
|
79
79
|
const stringNames = convertedStringColumns.map((column) => (0, queryConstructor_1.processColumnReference)(column.field, client.databaseType));
|
|
80
|
-
const smallStringColumns = await (0, exports.getCountsByColumns)(convertedStringColumns, `Select ${stringNames.join(', ')} from ${tableName}`, client, customFields ?? []);
|
|
80
|
+
const { filteredColumns: smallStringColumns, exceededColumns } = await (0, exports.getCountsByColumns)(convertedStringColumns, query ?? `Select ${stringNames.join(', ')} from ${tableName}`, client, customFields ?? []);
|
|
81
81
|
const smallStringNames = smallStringColumns.map((column) => (0, queryConstructor_1.processColumnReference)(column.field, client.databaseType));
|
|
82
|
-
const newUniqueValues = await (0, exports.getUniqueValuesByColumns)(smallStringColumns, `Select ${smallStringNames.join(', ')} from ${tableName}`, [], client, customFields ?? []);
|
|
82
|
+
const newUniqueValues = await (0, exports.getUniqueValuesByColumns)(smallStringColumns, query ?? `Select ${smallStringNames.join(', ')} from ${tableName}`, [], client, customFields ?? []);
|
|
83
|
+
if (withExceededColumns) {
|
|
84
|
+
exceededColumns?.forEach((column) => {
|
|
85
|
+
if (newUniqueValues) {
|
|
86
|
+
newUniqueValues[column.field] = { EXCEEDS_LIMIT: true };
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
83
90
|
if (previousUniqueValues) {
|
|
84
91
|
// This logic was used in ReportBuilder before this function was extracted
|
|
85
92
|
// Not sure if it still accurate, but didn't want to remove in case
|
|
@@ -102,7 +109,7 @@ const getRelevantInfoFromQuery = async (columns, client, query, customFields) =>
|
|
|
102
109
|
});
|
|
103
110
|
const stringNames = convertedStringColumns.map((column) => column.field);
|
|
104
111
|
if (stringNames.length > 0) {
|
|
105
|
-
const smallStringColumns = await (0, exports.getCountsByColumns)(convertedStringColumns, query, client, customFields);
|
|
112
|
+
const { filteredColumns: smallStringColumns } = await (0, exports.getCountsByColumns)(convertedStringColumns, query, client, customFields);
|
|
106
113
|
uniqueStrings = await (0, exports.getUniqueValuesByColumns)(smallStringColumns, query, [], client, customFields);
|
|
107
114
|
}
|
|
108
115
|
const dateColumns = columns.filter((column) => {
|
|
@@ -133,7 +140,7 @@ const getCountsByColumns = async (columns, query, client, customFields) => {
|
|
|
133
140
|
metadata: {
|
|
134
141
|
query: countQuery,
|
|
135
142
|
task: 'query',
|
|
136
|
-
orgId: client.
|
|
143
|
+
orgId: client.organizationId || '*',
|
|
137
144
|
clientId: client.publicKey,
|
|
138
145
|
databaseType: client?.databaseType,
|
|
139
146
|
customFieldsByTable: customFields,
|
|
@@ -143,7 +150,7 @@ const getCountsByColumns = async (columns, query, client, customFields) => {
|
|
|
143
150
|
const cloudBody = { countQuery };
|
|
144
151
|
const data = await (0, dataFetcher_1.getData)(client, 'dashquery', 'same-origin', hostedBody, cloudBody);
|
|
145
152
|
if (data.errorMessage) {
|
|
146
|
-
return columns;
|
|
153
|
+
return { filteredColumns: columns, exceededColumns: undefined };
|
|
147
154
|
}
|
|
148
155
|
const results = data.rows.map((columnInfo) => {
|
|
149
156
|
return { field: columnInfo.field, count: columnInfo.count };
|
|
@@ -152,10 +159,14 @@ const getCountsByColumns = async (columns, query, client, customFields) => {
|
|
|
152
159
|
const columnInfo = results.find((result) => result.field === column.field);
|
|
153
160
|
return columnInfo.count <= constants_1.MAX_PIVOT_UNIQUE_VALUES;
|
|
154
161
|
});
|
|
155
|
-
|
|
162
|
+
const exceededColumns = columns.filter((column) => {
|
|
163
|
+
const columnInfo = results.find((result) => result.field === column.field);
|
|
164
|
+
return columnInfo.count > constants_1.MAX_PIVOT_UNIQUE_VALUES;
|
|
165
|
+
});
|
|
166
|
+
return { filteredColumns, exceededColumns };
|
|
156
167
|
}
|
|
157
168
|
catch (e) {
|
|
158
|
-
return columns;
|
|
169
|
+
return { filteredColumns: columns, exceededColumns: undefined };
|
|
159
170
|
}
|
|
160
171
|
};
|
|
161
172
|
exports.getCountsByColumns = getCountsByColumns;
|
|
@@ -165,7 +176,7 @@ const fetchDistinctStrings = async (query, client, customFields) => {
|
|
|
165
176
|
metadata: {
|
|
166
177
|
query,
|
|
167
178
|
task: 'query',
|
|
168
|
-
orgId: client.
|
|
179
|
+
orgId: client.organizationId || '*',
|
|
169
180
|
clientId: client.publicKey,
|
|
170
181
|
databaseType: client?.databaseType,
|
|
171
182
|
customFieldsByTable: customFields,
|
|
@@ -209,7 +220,7 @@ const fetchDateRanges = async (query, client, customFields) => {
|
|
|
209
220
|
metadata: {
|
|
210
221
|
query,
|
|
211
222
|
task: 'query',
|
|
212
|
-
orgId: client.
|
|
223
|
+
orgId: client.organizationId || '*',
|
|
213
224
|
clientId: client.publicKey,
|
|
214
225
|
databaseType: client?.databaseType,
|
|
215
226
|
customFieldsByTable: customFields,
|
|
@@ -238,15 +249,15 @@ const fetchDateRanges = async (query, client, customFields) => {
|
|
|
238
249
|
};
|
|
239
250
|
const getPaginatedRows = async (client, query, reportId, processing, filters, customFields) => {
|
|
240
251
|
if (query) {
|
|
241
|
-
return await (0, exports.
|
|
252
|
+
return await (0, exports.fetchResultsByQuery)(query, client, processing, customFields);
|
|
242
253
|
}
|
|
243
254
|
else if (reportId) {
|
|
244
|
-
return await (0, exports.
|
|
255
|
+
return await (0, exports.fetchResultsByReport)(reportId, client, processing, filters, customFields);
|
|
245
256
|
}
|
|
246
257
|
return { rows: [], columns: [] };
|
|
247
258
|
};
|
|
248
259
|
exports.getPaginatedRows = getPaginatedRows;
|
|
249
|
-
const
|
|
260
|
+
const fetchResultsByQuery = async (query, client, processing, customFields, filters, dateField, rowsOnly, rowCountOnly) => {
|
|
250
261
|
let rows = [];
|
|
251
262
|
let columns = [];
|
|
252
263
|
let error = undefined;
|
|
@@ -257,14 +268,20 @@ const fetchTableByQuery = async (query, client, processing, customFields) => {
|
|
|
257
268
|
metadata: {
|
|
258
269
|
query,
|
|
259
270
|
task: 'query',
|
|
260
|
-
orgId: client.
|
|
271
|
+
orgId: client.organizationId || '*',
|
|
261
272
|
clientId: client.publicKey,
|
|
262
273
|
databaseType: client?.databaseType,
|
|
263
|
-
getCustomFields: !client.
|
|
274
|
+
getCustomFields: !client.organizationId || client.organizationId === '*'
|
|
275
|
+
? false
|
|
276
|
+
: true,
|
|
264
277
|
customFieldsByTable: customFields,
|
|
265
278
|
additionalProcessing: processing,
|
|
266
279
|
useUpdatedDataGathering: processing ? true : false,
|
|
267
280
|
useNewNodeSql: true,
|
|
281
|
+
filters,
|
|
282
|
+
dateField: dateField ?? undefined,
|
|
283
|
+
rowsOnly,
|
|
284
|
+
rowCountOnly,
|
|
268
285
|
},
|
|
269
286
|
};
|
|
270
287
|
const cloudBody = { query };
|
|
@@ -289,8 +306,8 @@ const fetchTableByQuery = async (query, client, processing, customFields) => {
|
|
|
289
306
|
}
|
|
290
307
|
return { rows, columns, rowCount, error, itemQuery };
|
|
291
308
|
};
|
|
292
|
-
exports.
|
|
293
|
-
const
|
|
309
|
+
exports.fetchResultsByQuery = fetchResultsByQuery;
|
|
310
|
+
const fetchResultsByReport = async (reportId, client, processing, filters, customFields) => {
|
|
294
311
|
const updatedProcessing = { ...processing };
|
|
295
312
|
let rows = [];
|
|
296
313
|
let columns = [];
|
|
@@ -316,7 +333,7 @@ const fetchTableByReport = async (reportId, client, processing, filters, customF
|
|
|
316
333
|
const hostedBody = {
|
|
317
334
|
metadata: {
|
|
318
335
|
dashboardItemId: reportId,
|
|
319
|
-
orgId: client?.
|
|
336
|
+
orgId: client?.organizationId || '*',
|
|
320
337
|
task: 'item',
|
|
321
338
|
filters: minimalFilters,
|
|
322
339
|
clientId: client?.publicKey,
|
|
@@ -363,8 +380,8 @@ const fetchTableByReport = async (reportId, client, processing, filters, customF
|
|
|
363
380
|
}
|
|
364
381
|
return { rows, columns, rowCount, error };
|
|
365
382
|
};
|
|
366
|
-
exports.
|
|
367
|
-
const fetchTableByAST = async (ast, client, processing, customFields) => {
|
|
383
|
+
exports.fetchResultsByReport = fetchResultsByReport;
|
|
384
|
+
const fetchTableByAST = async (ast, client, processing, customFields, rowsOnly, rowCountOnly) => {
|
|
368
385
|
let rows = [];
|
|
369
386
|
let columns = [];
|
|
370
387
|
let rowCount;
|
|
@@ -376,13 +393,15 @@ const fetchTableByAST = async (ast, client, processing, customFields) => {
|
|
|
376
393
|
clientId: client.publicKey,
|
|
377
394
|
ast,
|
|
378
395
|
publicKey: client.publicKey,
|
|
379
|
-
orgId: client.
|
|
396
|
+
orgId: client.organizationId || '*',
|
|
380
397
|
task: 'patterns',
|
|
381
398
|
getCustomFields: false,
|
|
382
399
|
customFields,
|
|
383
400
|
additionalProcessing: processing,
|
|
384
401
|
useUpdatedDataGathering: true,
|
|
385
402
|
useNewNodeSql: true,
|
|
403
|
+
rowsOnly,
|
|
404
|
+
rowCountOnly,
|
|
386
405
|
},
|
|
387
406
|
};
|
|
388
407
|
const cloudBody = {};
|
package/dist/esm/Chart.js
CHANGED
|
@@ -18,7 +18,7 @@ import { QuillMultiSelectComponent } from './components/QuillMultiSelect';
|
|
|
18
18
|
import { QuillDateRangePicker } from './DateRangePicker/QuillDateRangePicker';
|
|
19
19
|
import { convertInternalReportToReport, EMPTY_REPORT, fetchReport, } from './utils/report';
|
|
20
20
|
import { shouldFetchMore, DEFAULT_PAGINATION, shouldSortInMemory, } from './utils/paginationProcessing';
|
|
21
|
-
import {
|
|
21
|
+
import { fetchResultsByReport } from './utils/tableProcessing';
|
|
22
22
|
import QuillMetricComponent from './components/Dashboard/MetricComponent';
|
|
23
23
|
const MAX_ROWS_FOR_GENERIC_TABLE = 500;
|
|
24
24
|
// @ts-ignore
|
|
@@ -173,7 +173,7 @@ export default function Chart({ colors, reportId, className, containerStyle, isA
|
|
|
173
173
|
setPaginating(true);
|
|
174
174
|
try {
|
|
175
175
|
const updatedProcessing = { ...additionalProcessing, ...processing };
|
|
176
|
-
const paginatedRows = await
|
|
176
|
+
const paginatedRows = await fetchResultsByReport(reportId, client, updatedProcessing, filters, schemaData.customFields);
|
|
177
177
|
if (paginatedRows.error) {
|
|
178
178
|
throw new Error('Error fetching chart');
|
|
179
179
|
}
|