@quillsql/react 2.12.40 → 2.12.41
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 +1 -1
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +6 -6
- package/dist/cjs/Dashboard.js +5 -5
- package/dist/cjs/ReportBuilder.d.ts +1 -1
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +111 -1588
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +0 -9
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +1 -11
- package/dist/cjs/components/Dashboard/DataLoader.js +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.js +32 -32
- package/dist/cjs/components/ReportBuilder/convert.d.ts +5 -31
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +1 -1
- package/dist/cjs/hooks/useAskQuill.d.ts +27 -0
- package/dist/cjs/hooks/useAskQuill.d.ts.map +1 -0
- package/dist/cjs/hooks/useAskQuill.js +177 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts +3 -3
- package/dist/cjs/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotForm.js +4 -2
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +1 -15
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +24 -24
- package/dist/cjs/models/Filter.d.ts +25 -19
- package/dist/cjs/models/Filter.d.ts.map +1 -1
- package/dist/cjs/models/Filter.js +2 -2
- package/dist/cjs/{components/ReportBuilder/pivot.d.ts → models/Pivot.d.ts} +13 -4
- package/dist/cjs/models/Pivot.d.ts.map +1 -0
- package/dist/cjs/models/Report.d.ts +1 -1
- package/dist/cjs/models/Report.d.ts.map +1 -1
- package/dist/cjs/models/Tables.d.ts +16 -0
- package/dist/cjs/models/Tables.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.js +27 -27
- package/dist/cjs/utils/astProcessing.d.ts +42 -0
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +210 -1
- package/dist/cjs/utils/constants.d.ts +1 -0
- package/dist/cjs/utils/constants.d.ts.map +1 -1
- package/dist/cjs/utils/constants.js +2 -1
- package/dist/cjs/utils/dataFetcher.d.ts +4 -0
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +24 -1
- package/dist/cjs/utils/dates.d.ts +1 -1
- package/dist/cjs/utils/filterProcessing.d.ts +2 -2
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +6 -6
- package/dist/cjs/utils/pivotConstructor.d.ts +1 -1
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +7 -4
- package/dist/cjs/utils/pivotProcessing.d.ts +4 -4
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +21 -2
- package/dist/cjs/utils/queryConstructor.d.ts +1 -1
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +3 -3
- package/dist/cjs/utils/report.d.ts +25 -0
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +114 -2
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +1 -1
- package/dist/cjs/utils/tableProcessing.d.ts +18 -0
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +94 -1
- package/dist/esm/Chart.js +1 -1
- package/dist/esm/ChartBuilder.d.ts +1 -1
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +6 -6
- package/dist/esm/Dashboard.js +5 -5
- package/dist/esm/ReportBuilder.d.ts +1 -1
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +121 -1598
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.js +0 -9
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +1 -11
- package/dist/esm/components/Dashboard/DataLoader.js +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.js +32 -32
- package/dist/esm/components/ReportBuilder/convert.d.ts +5 -31
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +1 -1
- package/dist/esm/hooks/useAskQuill.d.ts +27 -0
- package/dist/esm/hooks/useAskQuill.d.ts.map +1 -0
- package/dist/esm/hooks/useAskQuill.js +173 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts +3 -3
- package/dist/esm/internals/ReportBuilder/PivotForm.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotForm.js +4 -2
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +1 -15
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +24 -24
- package/dist/esm/models/Filter.d.ts +25 -19
- package/dist/esm/models/Filter.d.ts.map +1 -1
- package/dist/esm/models/Filter.js +2 -2
- package/dist/esm/{components/ReportBuilder/pivot.d.ts → models/Pivot.d.ts} +13 -4
- package/dist/esm/models/Pivot.d.ts.map +1 -0
- package/dist/esm/models/Report.d.ts +1 -1
- package/dist/esm/models/Report.d.ts.map +1 -1
- package/dist/esm/models/Tables.d.ts +16 -0
- package/dist/esm/models/Tables.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.js +27 -27
- package/dist/esm/utils/astProcessing.d.ts +42 -0
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +204 -0
- package/dist/esm/utils/constants.d.ts +1 -0
- package/dist/esm/utils/constants.d.ts.map +1 -1
- package/dist/esm/utils/constants.js +1 -0
- package/dist/esm/utils/dataFetcher.d.ts +4 -0
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +22 -0
- package/dist/esm/utils/dates.d.ts +1 -1
- package/dist/esm/utils/filterProcessing.d.ts +2 -2
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +7 -7
- package/dist/esm/utils/pivotConstructor.d.ts +1 -1
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +7 -4
- package/dist/esm/utils/pivotProcessing.d.ts +4 -4
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +19 -1
- package/dist/esm/utils/queryConstructor.d.ts +1 -1
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +3 -3
- package/dist/esm/utils/report.d.ts +25 -0
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +114 -3
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +1 -1
- package/dist/esm/utils/tableProcessing.d.ts +18 -0
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +91 -1
- package/package.json +1 -1
- package/dist/cjs/components/ReportBuilder/pivot.d.ts.map +0 -1
- package/dist/cjs/models/Pivots.d.ts +0 -2
- package/dist/cjs/models/Pivots.d.ts.map +0 -1
- package/dist/cjs/models/Pivots.js +0 -2
- package/dist/esm/components/ReportBuilder/pivot.d.ts.map +0 -1
- package/dist/esm/models/Pivots.d.ts +0 -2
- package/dist/esm/models/Pivots.d.ts.map +0 -1
- package/dist/esm/models/Pivots.js +0 -1
- /package/dist/cjs/{components/ReportBuilder/pivot.js → models/Pivot.js} +0 -0
- /package/dist/esm/{components/ReportBuilder/pivot.js → models/Pivot.js} +0 -0
package/dist/esm/utils/report.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { createInitialFormData } from '../ChartBuilder';
|
|
2
|
+
import { getTableNames } from '../components/ReportBuilder/ast';
|
|
3
|
+
import { generatePivotTable } from '../internals/ReportBuilder/PivotModal';
|
|
4
|
+
import { createBasicSelectASTFromColumns } from './astProcessing';
|
|
1
5
|
import { getYAxisFields } from './columnProcessing';
|
|
2
6
|
import { cleanDashboardItem } from './dashboard';
|
|
3
|
-
import { getData } from './dataFetcher';
|
|
7
|
+
import { fetchSqlQuery, getData } from './dataFetcher';
|
|
4
8
|
import { parseValueFromBigQueryDates } from './dataProcessing';
|
|
9
|
+
import { getDateBucketFromRange } from './dates';
|
|
5
10
|
import { DataLoadError } from './error';
|
|
6
11
|
import { processFilterErrorList } from './errorProcessing';
|
|
7
12
|
import { internalLog } from './logging';
|
|
8
13
|
import { mergeComparisonRange } from './merge';
|
|
9
|
-
import {
|
|
14
|
+
import { DEFAULT_PAGINATION } from './paginationProcessing';
|
|
15
|
+
import { isPivotPossible, isValidPivot } from './pivotProcessing';
|
|
16
|
+
import { fetchTableByAST, getRelevantInfoFromQuery, } from './tableProcessing';
|
|
10
17
|
import { quillFormat } from './valueFormatter';
|
|
11
18
|
export const EMPTY_REPORT = {
|
|
12
19
|
id: '',
|
|
@@ -110,7 +117,7 @@ export async function fetchReport(reportId, client, useReportTask = true, filter
|
|
|
110
117
|
errorMessage = error.message;
|
|
111
118
|
}
|
|
112
119
|
}
|
|
113
|
-
return { report: reportInfo, error: errorMessage };
|
|
120
|
+
return { report: reportInfo || EMPTY_REPORT, error: errorMessage };
|
|
114
121
|
}
|
|
115
122
|
export const formatRowsFromReport = (report) => {
|
|
116
123
|
if (!report.rows || !report.columns) {
|
|
@@ -184,3 +191,107 @@ export function convertInternalReportToReport(report) {
|
|
|
184
191
|
return EMPTY_REPORT;
|
|
185
192
|
}
|
|
186
193
|
}
|
|
194
|
+
export const fetchReportBuilderDataFromAST = async (baseAst, formData, schema, client, pivot, previousFormData, currentTable, previousRelevant, report, customFields) => {
|
|
195
|
+
let newRows = [];
|
|
196
|
+
let newColumns = [];
|
|
197
|
+
let newRowCount = 0;
|
|
198
|
+
let newPivot = null;
|
|
199
|
+
let newPivotData = null;
|
|
200
|
+
let formattedRows = [];
|
|
201
|
+
let curReport = report;
|
|
202
|
+
let table = '';
|
|
203
|
+
let error;
|
|
204
|
+
const relevantInfo = previousRelevant ?? { uniqueStrings: {}, dateRanges: {} };
|
|
205
|
+
let query = '';
|
|
206
|
+
try {
|
|
207
|
+
const tables = getTableNames(baseAst);
|
|
208
|
+
table = tables[0] ? tables[0] : '';
|
|
209
|
+
const tableInfo = schema.find((tableInfo) => tableInfo.name === table);
|
|
210
|
+
if (!table || !tableInfo) {
|
|
211
|
+
throw new Error('No table found;');
|
|
212
|
+
}
|
|
213
|
+
const tableData = await fetchTableByAST({ ...baseAst, where: formData }, client, { page: DEFAULT_PAGINATION });
|
|
214
|
+
if (tableData.error) {
|
|
215
|
+
throw new Error(tableData.error);
|
|
216
|
+
}
|
|
217
|
+
const processedFormData = report
|
|
218
|
+
? report
|
|
219
|
+
: createInitialFormData(tableData.columns);
|
|
220
|
+
curReport = {
|
|
221
|
+
...formData,
|
|
222
|
+
...processedFormData,
|
|
223
|
+
pivot: pivot,
|
|
224
|
+
itemQuery: tableData.itemQuery,
|
|
225
|
+
rowCount: tableData.rowCount,
|
|
226
|
+
filtersApplied: [],
|
|
227
|
+
rows: tableData.rows,
|
|
228
|
+
columns: tableData.columns,
|
|
229
|
+
};
|
|
230
|
+
const queryResult = await fetchSqlQuery({
|
|
231
|
+
...createBasicSelectASTFromColumns(tableInfo.columns, table),
|
|
232
|
+
where: formData,
|
|
233
|
+
}, client, formData);
|
|
234
|
+
if (queryResult.error) {
|
|
235
|
+
throw new Error(queryResult.error);
|
|
236
|
+
}
|
|
237
|
+
query = queryResult.query;
|
|
238
|
+
if (table !== currentTable || previousFormData !== formData) {
|
|
239
|
+
const { uniqueStrings, dateRanges } = await getRelevantInfoFromQuery(tableInfo.columns, client, queryResult.query, customFields);
|
|
240
|
+
relevantInfo.uniqueStrings[table] = uniqueStrings ?? {};
|
|
241
|
+
relevantInfo.dateRanges = dateRanges ?? {};
|
|
242
|
+
}
|
|
243
|
+
if (!!relevantInfo.error) {
|
|
244
|
+
throw new Error(relevantInfo.error);
|
|
245
|
+
}
|
|
246
|
+
if (pivot) {
|
|
247
|
+
if (isPivotPossible(tableData.columns, pivot)) {
|
|
248
|
+
let dateBucket = undefined;
|
|
249
|
+
const rowFieldDateRange = relevantInfo.dateRanges[pivot.rowField ?? ''] ?? undefined;
|
|
250
|
+
if (rowFieldDateRange) {
|
|
251
|
+
dateBucket = getDateBucketFromRange(rowFieldDateRange.dateRange);
|
|
252
|
+
}
|
|
253
|
+
newPivotData = await generatePivotTable(pivot, tableData.rows, undefined, false, -1, undefined, dateBucket, curReport, client, relevantInfo.uniqueStrings[table]);
|
|
254
|
+
newPivot = pivot;
|
|
255
|
+
}
|
|
256
|
+
if (!newPivotData) {
|
|
257
|
+
newPivot = null;
|
|
258
|
+
formattedRows = formatRowsFromReport({
|
|
259
|
+
rows: tableData.rows,
|
|
260
|
+
columns: tableData.columns,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
formattedRows = formatRowsFromReport({
|
|
265
|
+
rows: newPivotData.rows,
|
|
266
|
+
columns: newPivotData.columns,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
formattedRows = formatRowsFromReport({
|
|
272
|
+
rows: tableData.rows,
|
|
273
|
+
columns: tableData.columns,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
newRowCount = tableData.rowCount ?? tableData.rows.length;
|
|
277
|
+
newRows = tableData.rows;
|
|
278
|
+
newColumns = tableData.columns;
|
|
279
|
+
}
|
|
280
|
+
catch (e) {
|
|
281
|
+
error = e.message;
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
rows: newRows,
|
|
285
|
+
columns: newColumns,
|
|
286
|
+
rowCount: newRowCount,
|
|
287
|
+
pivot: newPivot,
|
|
288
|
+
pivotData: newPivotData,
|
|
289
|
+
formattedRows,
|
|
290
|
+
report: curReport ?? EMPTY_REPORT,
|
|
291
|
+
table,
|
|
292
|
+
uniqueValues: relevantInfo.uniqueStrings,
|
|
293
|
+
dateRanges: relevantInfo.dateRanges,
|
|
294
|
+
query,
|
|
295
|
+
error: error,
|
|
296
|
+
};
|
|
297
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AAmDA,eAAO,MAAM,kBAAkB,WAAkB,GAAG,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AAmDA,eAAO,MAAM,kBAAkB,WAAkB,GAAG,oCA8EnD,CAAC;AAEF,eAAO,MAAM,6BAA6B,WAChC,GAAG;;;EAoDZ,CAAC"}
|
package/dist/esm/utils/schema.js
CHANGED
|
@@ -50,7 +50,7 @@ export const getCustomFieldInfo = async (client, caller = 'se') => {
|
|
|
50
50
|
try {
|
|
51
51
|
const { queryEndpoint, queryHeaders, publicKey, databaseType, customerId } = client;
|
|
52
52
|
if (databaseType.toLowerCase() !== 'postgresql' ||
|
|
53
|
-
!['
|
|
53
|
+
!['665610862cf7a3000be66453'].includes(publicKey)) {
|
|
54
54
|
throw new Error('CUSTOM FIELDS IS ONLY ALLOWED FOR POSTGRESQL DATABASES');
|
|
55
55
|
}
|
|
56
56
|
const response = await fetch(`${queryEndpoint}?cfr-${caller}`, {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { NodeSQLParser } from '../components/ReportBuilder/ast';
|
|
2
|
+
import { ColumnInfo } from '../components/ReportBuilder/schema';
|
|
1
3
|
import { Column, ColumnInternal } from '../models/Columns';
|
|
2
4
|
import { Pagination } from '../models/Pagination';
|
|
5
|
+
import { DateRangesByColumn, UniqueValuesByColumn } from '../models/Tables';
|
|
3
6
|
export interface AdditionalProcessing {
|
|
4
7
|
sort?: {
|
|
5
8
|
field: string;
|
|
@@ -14,6 +17,11 @@ export declare const getUniqueValuesByColumns: (columns: Column[], query: string
|
|
|
14
17
|
[value: string]: boolean;
|
|
15
18
|
};
|
|
16
19
|
} | null>;
|
|
20
|
+
export declare const getRelevantInfoFromQuery: (columns: ColumnInfo[], client: any, query: string, customFields?: any) => Promise<{
|
|
21
|
+
uniqueStrings?: UniqueValuesByColumn | undefined;
|
|
22
|
+
dateRanges?: DateRangesByColumn | undefined;
|
|
23
|
+
error?: string | undefined;
|
|
24
|
+
}>;
|
|
17
25
|
export declare const getCountsByColumns: (columns: Column[], query: string, client: any, customFields: any[]) => Promise<Column[]>;
|
|
18
26
|
export declare const getDateRangeByColumns: (columns: Column[], query: string, client: any, customFields: any[]) => Promise<{
|
|
19
27
|
[column: string]: {
|
|
@@ -42,4 +50,14 @@ export declare const fetchTableByReport: (reportId: string, client: any, process
|
|
|
42
50
|
rowCount?: number | undefined;
|
|
43
51
|
error?: string | undefined;
|
|
44
52
|
}>;
|
|
53
|
+
export declare const fetchTableByAST: (ast: NodeSQLParser.Select, client: any, processing?: AdditionalProcessing, customFields?: any) => Promise<{
|
|
54
|
+
columns: ColumnInternal[];
|
|
55
|
+
rows: any[];
|
|
56
|
+
rowCount?: number | undefined;
|
|
57
|
+
error?: string | undefined;
|
|
58
|
+
itemQuery?: string[] | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
export declare const convertUniqueValuesByColumnToUniqueValueStrings: (uniqueValuesByColumns: UniqueValuesByColumn) => {
|
|
61
|
+
[columnName: string]: string[];
|
|
62
|
+
};
|
|
45
63
|
//# sourceMappingURL=tableProcessing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/tableProcessing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"tableProcessing.d.ts","sourceRoot":"","sources":["../../../src/utils/tableProcessing.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAkB5E,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,GAAG,gBACG,GAAG,EAAE;;;;SAkEpB,CAAC;AAEF,eAAO,MAAM,wBAAwB,YAC1B,UAAU,EAAE,UACb,GAAG,SACJ,MAAM,iBACE,GAAG;;;;EAiEnB,CAAC;AAEF,eAAO,MAAM,kBAAkB,YACpB,MAAM,EAAE,SACV,MAAM,UACL,GAAG,gBACG,GAAG,EAAE,KAClB,QAAQ,MAAM,EAAE,CA2ClB,CAAC;AAkDF,eAAO,MAAM,qBAAqB,YACvB,MAAM,EAAE,SACV,MAAM,UACL,GAAG,gBACG,GAAG,EAAE;;mBAEY;YAAE,KAAK,EAAE,IAAI,CAAC;YAAC,GAAG,EAAE,IAAI,CAAA;SAAE;;SAiB1D,CAAC;AA2DF,eAAO,MAAM,gBAAgB,WACnB,GAAG,UACH,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,iBAAiB,UACrB,MAAM,UACL,GAAG,eACE,oBAAoB,iBAClB,GAAG;aAET,cAAc,EAAE;UACnB,GAAG,EAAE;;;;EAqDZ,CAAC;AAEF,eAAO,MAAM,kBAAkB,aACnB,MAAM,UACR,GAAG,eACE,oBAAoB,YACvB,GAAG,iBACE,GAAG;aAET,MAAM,EAAE;UACX,GAAG,EAAE;;;EAgFZ,CAAC;AAEF,eAAO,MAAM,eAAe,QACrB,cAAc,MAAM,UACjB,GAAG,eACE,oBAAoB,iBAClB,GAAG;aAET,cAAc,EAAE;UACnB,GAAG,EAAE;;;;EAuDZ,CAAC;AAEF,eAAO,MAAM,+CAA+C,0BACnC,oBAAoB;;CAU5C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isTextColumnType, } from '../components/ReportBuilder/ast';
|
|
2
|
+
import { convertColumnInfoToColumnInternal, convertPostgresColumn, } from './columnProcessing';
|
|
2
3
|
import { MAX_PIVOT_UNIQUE_VALUES } from './constants';
|
|
3
4
|
import { getData } from './dataFetcher';
|
|
4
5
|
import { parseValueFromBigQueryDates } from './dataProcessing';
|
|
@@ -65,6 +66,42 @@ export const getUniqueValuesByColumns = async (columns, query, rows, client, cus
|
|
|
65
66
|
}
|
|
66
67
|
return uniqueValues;
|
|
67
68
|
};
|
|
69
|
+
export const getRelevantInfoFromQuery = async (columns, client, query, customFields) => {
|
|
70
|
+
let dateRanges = {};
|
|
71
|
+
let uniqueStrings = {};
|
|
72
|
+
let error = undefined;
|
|
73
|
+
try {
|
|
74
|
+
const convertedStringColumns = columns
|
|
75
|
+
.filter((column) => {
|
|
76
|
+
return isTextColumnType(column.fieldType);
|
|
77
|
+
})
|
|
78
|
+
.map((column) => convertColumnInfoToColumnInternal(column));
|
|
79
|
+
const stringNames = convertedStringColumns.map((column) => column.field);
|
|
80
|
+
if (stringNames.length > 0) {
|
|
81
|
+
const smallStringColumns = await getCountsByColumns(convertedStringColumns, query, client, customFields);
|
|
82
|
+
uniqueStrings = await getUniqueValuesByColumns(smallStringColumns, query, [], client, customFields);
|
|
83
|
+
}
|
|
84
|
+
const dateColumns = columns
|
|
85
|
+
.filter((column) => {
|
|
86
|
+
return column.fieldType === 'date';
|
|
87
|
+
})
|
|
88
|
+
.map((column) => convertColumnInfoToColumnInternal(column));
|
|
89
|
+
if (dateColumns.length > 0) {
|
|
90
|
+
dateRanges = await getDateRangeByColumns(dateColumns, query, client, customFields);
|
|
91
|
+
if (dateRanges === null) {
|
|
92
|
+
throw new Error("Couldn't fetch date ranges");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
error = "Couldn't fetch pivot info";
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
uniqueStrings: uniqueStrings ?? undefined,
|
|
101
|
+
dateRanges: dateRanges ?? undefined,
|
|
102
|
+
error,
|
|
103
|
+
};
|
|
104
|
+
};
|
|
68
105
|
export const getCountsByColumns = async (columns, query, client, customFields) => {
|
|
69
106
|
const stringNames = columns.map((column) => column.field);
|
|
70
107
|
const countQuery = generateCountQuery(stringNames, query, client.databaseType);
|
|
@@ -299,3 +336,56 @@ export const fetchTableByReport = async (reportId, client, processing, filters,
|
|
|
299
336
|
}
|
|
300
337
|
return { rows, columns, rowCount, error };
|
|
301
338
|
};
|
|
339
|
+
export const fetchTableByAST = async (ast, client, processing, customFields) => {
|
|
340
|
+
let rows = [];
|
|
341
|
+
let columns = [];
|
|
342
|
+
let rowCount;
|
|
343
|
+
let error;
|
|
344
|
+
let itemQuery;
|
|
345
|
+
try {
|
|
346
|
+
const hostedBody = {
|
|
347
|
+
metadata: {
|
|
348
|
+
clientId: client.publicKey,
|
|
349
|
+
ast,
|
|
350
|
+
publicKey: client.publicKey,
|
|
351
|
+
orgId: client.customerId,
|
|
352
|
+
task: 'patterns',
|
|
353
|
+
getCustomFields: false,
|
|
354
|
+
customFields,
|
|
355
|
+
additionalProcessing: processing,
|
|
356
|
+
useUpdatedDataGathering: true,
|
|
357
|
+
useNewNodeSql: true,
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
const cloudBody = {};
|
|
361
|
+
const resp = await getData(client, 'dashquery', 'same-origin', hostedBody, cloudBody);
|
|
362
|
+
if (resp.errorMessage || resp.name === 'error') {
|
|
363
|
+
throw new Error(resp.errorMessage);
|
|
364
|
+
}
|
|
365
|
+
processFilterErrorList(resp);
|
|
366
|
+
if (resp.rowCount) {
|
|
367
|
+
rowCount = resp.rowCount;
|
|
368
|
+
}
|
|
369
|
+
const gatheredRows = resp.rows && resp.rows.length ? resp.rows : [];
|
|
370
|
+
columns = resp.fields.map((elem) => convertPostgresColumn(elem));
|
|
371
|
+
rows = gatheredRows;
|
|
372
|
+
itemQuery = resp.itemQuery;
|
|
373
|
+
}
|
|
374
|
+
catch (e) {
|
|
375
|
+
rows = [];
|
|
376
|
+
columns = [];
|
|
377
|
+
rowCount = 0;
|
|
378
|
+
error = e.message;
|
|
379
|
+
}
|
|
380
|
+
if (client.databaseType && client.databaseType.toLowerCase() === 'bigquery') {
|
|
381
|
+
parseValueFromBigQueryDates(rows, columns);
|
|
382
|
+
}
|
|
383
|
+
return { rows, columns, rowCount, error, itemQuery };
|
|
384
|
+
};
|
|
385
|
+
export const convertUniqueValuesByColumnToUniqueValueStrings = (uniqueValuesByColumns) => {
|
|
386
|
+
return Object.keys(uniqueValuesByColumns).reduce((acc, column) => {
|
|
387
|
+
const uniqueValues = uniqueValuesByColumns[column] ?? [];
|
|
388
|
+
acc[column] = Object.keys(uniqueValues);
|
|
389
|
+
return acc;
|
|
390
|
+
}, {});
|
|
391
|
+
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pivot.d.ts","sourceRoot":"","sources":["../../../../src/components/ReportBuilder/pivot.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,eAAe,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,CAAC;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,aAAa,EAAE,KAAK,GAAG,MAAM,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,IAAI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Pivots.d.ts","sourceRoot":"","sources":["../../../src/models/Pivots.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pivot.d.ts","sourceRoot":"","sources":["../../../../src/components/ReportBuilder/pivot.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,eAAe,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,CAAC;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,aAAa,EAAE,KAAK,GAAG,MAAM,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,IAAI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Pivots.d.ts","sourceRoot":"","sources":["../../../src/models/Pivots.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|