@quillsql/react 2.16.68 → 2.16.70
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/index.cjs +85 -36
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +85 -36
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17269,6 +17269,7 @@ async function generatePivotWithSQL({
|
|
|
17269
17269
|
sort: pivot.sort,
|
|
17270
17270
|
sortDirection: pivot.sortDirection,
|
|
17271
17271
|
sortField: pivot.sortField,
|
|
17272
|
+
sortFieldTable: pivot.sortFieldTable,
|
|
17272
17273
|
sortFieldType: pivot.sortFieldType,
|
|
17273
17274
|
rowLimit: pivot.rowLimit,
|
|
17274
17275
|
dateBucket: resolvedDateBucket
|
|
@@ -17306,10 +17307,15 @@ async function generatePivotWithSQL({
|
|
|
17306
17307
|
const queryResponseFields = resp.data?.fields || resp.queries?.queryResults?.[0]?.fields || [];
|
|
17307
17308
|
const rowCount = resp.queries?.queryResults?.[1]?.rows?.[0]?.row_count || 0;
|
|
17308
17309
|
parseValueFromBigQueryDates(queryResponseRows, queryResponseFields);
|
|
17310
|
+
const resultRowField = processColumnName(
|
|
17311
|
+
String(
|
|
17312
|
+
resp.data?.config?.rowField ?? pivot.rowField ?? ""
|
|
17313
|
+
)
|
|
17314
|
+
);
|
|
17309
17315
|
const responseRows = queryResponseRows;
|
|
17310
17316
|
const responseFields = queryResponseFields;
|
|
17311
|
-
const rows =
|
|
17312
|
-
(row) => !row[
|
|
17317
|
+
const rows = resultRowField ? responseRows.map(
|
|
17318
|
+
(row) => !row[resultRowField] ? { ...row, [resultRowField]: "-" } : row
|
|
17313
17319
|
) : responseRows;
|
|
17314
17320
|
if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
|
|
17315
17321
|
rows.forEach((row) => {
|
|
@@ -17329,27 +17335,27 @@ async function generatePivotWithSQL({
|
|
|
17329
17335
|
(field.field || field.name).replace("comparison_", "comparison ")
|
|
17330
17336
|
)
|
|
17331
17337
|
),
|
|
17332
|
-
format: (field.field || field.name) ===
|
|
17338
|
+
format: processColumnName(field.field || field.name) === resultRowField ? "string" : pivot.aggregations?.find(
|
|
17333
17339
|
(agg) => agg.valueField === (field.field || field.name) || `${agg.valueField}_percentage` === (field.field || field.name) || !agg.valueField && agg.aggregationType === "percentage" && (field.field || field.name)?.endsWith("percentage")
|
|
17334
17340
|
)?.aggregationType === "percentage" ? "percent" : "whole_number",
|
|
17335
17341
|
fieldType: field.fieldType,
|
|
17336
17342
|
jsType: field.jsType,
|
|
17337
17343
|
dataTypeID: field.dataTypeID
|
|
17338
17344
|
})).filter(
|
|
17339
|
-
(field, index) => field.field !== "comparison_" +
|
|
17345
|
+
(field, index) => field.field !== "comparison_" + resultRowField || index === 0
|
|
17340
17346
|
).sort((a, b) => {
|
|
17341
|
-
if (a.field ===
|
|
17347
|
+
if (a.field === resultRowField) {
|
|
17342
17348
|
return -1;
|
|
17343
17349
|
}
|
|
17344
|
-
if (b.field ===
|
|
17350
|
+
if (b.field === resultRowField) {
|
|
17345
17351
|
return 1;
|
|
17346
17352
|
}
|
|
17347
17353
|
return 0;
|
|
17348
17354
|
});
|
|
17349
|
-
if (
|
|
17355
|
+
if (resultRowField && !isStringType(pivot.rowFieldType || "")) {
|
|
17350
17356
|
rows.forEach((row) => {
|
|
17351
|
-
row.__quillRawDate = typeof row[
|
|
17352
|
-
let value = typeof row[
|
|
17357
|
+
row.__quillRawDate = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
|
|
17358
|
+
let value = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
|
|
17353
17359
|
if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17354
17360
|
const rowDate = new Date(value);
|
|
17355
17361
|
if (rowDate < dateFilter.startDate) {
|
|
@@ -17364,12 +17370,10 @@ async function generatePivotWithSQL({
|
|
|
17364
17370
|
dateBucket,
|
|
17365
17371
|
databaseType
|
|
17366
17372
|
);
|
|
17367
|
-
row[
|
|
17373
|
+
row[resultRowField] = dateString;
|
|
17368
17374
|
});
|
|
17369
|
-
if (
|
|
17370
|
-
const dateSet = new Set(
|
|
17371
|
-
rows.map((row) => row[pivot.rowField || ""])
|
|
17372
|
-
);
|
|
17375
|
+
if (resultRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17376
|
+
const dateSet = new Set(rows.map((row) => row[resultRowField]));
|
|
17373
17377
|
for (let date = dateFilter.startDate; date <= dateFilter.endDate; date = new Date(date.getTime() + 24 * 60 * 60 * 1e3)) {
|
|
17374
17378
|
const formattedDate = getDateString(
|
|
17375
17379
|
date.toISOString(),
|
|
@@ -17379,7 +17383,7 @@ async function generatePivotWithSQL({
|
|
|
17379
17383
|
);
|
|
17380
17384
|
if (!dateSet.has(formattedDate)) {
|
|
17381
17385
|
const newRow = {};
|
|
17382
|
-
newRow[
|
|
17386
|
+
newRow[resultRowField] = formattedDate;
|
|
17383
17387
|
newRow.__quillRawDate = date.toISOString();
|
|
17384
17388
|
rows.push(newRow);
|
|
17385
17389
|
dateSet.add(formattedDate);
|
|
@@ -17416,6 +17420,7 @@ async function generatePivotWithSQL({
|
|
|
17416
17420
|
rows,
|
|
17417
17421
|
columns: columns ?? [],
|
|
17418
17422
|
rowCount: rowCount || rows.length,
|
|
17423
|
+
rowField: resultRowField || void 0,
|
|
17419
17424
|
pivotQuery: report?.queryString || "",
|
|
17420
17425
|
comparisonPivotQuery: comparisonPivotQuery || ""
|
|
17421
17426
|
};
|
|
@@ -17515,14 +17520,18 @@ function processPivotData({
|
|
|
17515
17520
|
rows: responseRows,
|
|
17516
17521
|
fields: responseFields,
|
|
17517
17522
|
pivot,
|
|
17523
|
+
resultRowField,
|
|
17518
17524
|
dateBucket,
|
|
17519
17525
|
dateFilter,
|
|
17520
17526
|
client,
|
|
17521
17527
|
rowCount
|
|
17522
17528
|
}) {
|
|
17523
17529
|
const databaseType = client.databaseType || "postgresql";
|
|
17524
|
-
const
|
|
17525
|
-
(
|
|
17530
|
+
const pivotRowField = processColumnName(
|
|
17531
|
+
String(resultRowField ?? pivot.rowField ?? "")
|
|
17532
|
+
);
|
|
17533
|
+
const rows = pivotRowField ? responseRows.map(
|
|
17534
|
+
(row) => !row[pivotRowField] ? { ...row, [pivotRowField]: "-" } : row
|
|
17526
17535
|
) : responseRows;
|
|
17527
17536
|
if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
|
|
17528
17537
|
rows.forEach((row) => {
|
|
@@ -17542,27 +17551,27 @@ function processPivotData({
|
|
|
17542
17551
|
(field.field || field.name).replace("comparison_", "comparison ")
|
|
17543
17552
|
)
|
|
17544
17553
|
),
|
|
17545
|
-
format: (field.field || field.name) ===
|
|
17554
|
+
format: processColumnName(field.field || field.name) === pivotRowField ? "string" : pivot.aggregations?.find(
|
|
17546
17555
|
(agg) => agg.valueField === (field.field || field.name) || `${agg.valueField}_percentage` === (field.field || field.name) || !agg.valueField && agg.aggregationType === "percentage" && (field.field || field.name)?.endsWith("percentage")
|
|
17547
17556
|
)?.aggregationType === "percentage" ? "percent" : "whole_number",
|
|
17548
17557
|
fieldType: field.fieldType,
|
|
17549
17558
|
jsType: field.jsType,
|
|
17550
17559
|
dataTypeID: field.dataTypeID
|
|
17551
17560
|
})).filter(
|
|
17552
|
-
(field, index) => field.field !== "comparison_" +
|
|
17561
|
+
(field, index) => field.field !== "comparison_" + pivotRowField || index === 0
|
|
17553
17562
|
).sort((a, b) => {
|
|
17554
|
-
if (a.field ===
|
|
17563
|
+
if (a.field === pivotRowField) {
|
|
17555
17564
|
return -1;
|
|
17556
17565
|
}
|
|
17557
|
-
if (b.field ===
|
|
17566
|
+
if (b.field === pivotRowField) {
|
|
17558
17567
|
return 1;
|
|
17559
17568
|
}
|
|
17560
17569
|
return 0;
|
|
17561
17570
|
});
|
|
17562
|
-
if (
|
|
17571
|
+
if (pivotRowField && !isStringType(pivot.rowFieldType || "")) {
|
|
17563
17572
|
rows.forEach((row) => {
|
|
17564
|
-
row.__quillRawDate = typeof row[
|
|
17565
|
-
let value = typeof row[
|
|
17573
|
+
row.__quillRawDate = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
|
|
17574
|
+
let value = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
|
|
17566
17575
|
if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17567
17576
|
const rowDate = new Date(value);
|
|
17568
17577
|
if (rowDate < dateFilter.startDate) {
|
|
@@ -17577,12 +17586,10 @@ function processPivotData({
|
|
|
17577
17586
|
dateBucket,
|
|
17578
17587
|
databaseType
|
|
17579
17588
|
);
|
|
17580
|
-
row[
|
|
17589
|
+
row[pivotRowField] = dateString;
|
|
17581
17590
|
});
|
|
17582
|
-
if (
|
|
17583
|
-
const dateSet = new Set(
|
|
17584
|
-
rows.map((row) => row[pivot.rowField || ""])
|
|
17585
|
-
);
|
|
17591
|
+
if (pivotRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17592
|
+
const dateSet = new Set(rows.map((row) => row[pivotRowField]));
|
|
17586
17593
|
for (let date = dateFilter.startDate; date <= dateFilter.endDate; date = new Date(date.getTime() + 24 * 60 * 60 * 1e3)) {
|
|
17587
17594
|
const formattedDate = getDateString(
|
|
17588
17595
|
date.toISOString(),
|
|
@@ -17592,7 +17599,7 @@ function processPivotData({
|
|
|
17592
17599
|
);
|
|
17593
17600
|
if (!dateSet.has(formattedDate)) {
|
|
17594
17601
|
const newRow = {};
|
|
17595
|
-
newRow[
|
|
17602
|
+
newRow[pivotRowField] = formattedDate;
|
|
17596
17603
|
newRow.__quillRawDate = date.toISOString();
|
|
17597
17604
|
rows.push(newRow);
|
|
17598
17605
|
dateSet.add(formattedDate);
|
|
@@ -17629,6 +17636,7 @@ function processPivotData({
|
|
|
17629
17636
|
rows,
|
|
17630
17637
|
columns: columns ?? [],
|
|
17631
17638
|
rowCount: rowCount || rows.length,
|
|
17639
|
+
rowField: pivotRowField || void 0,
|
|
17632
17640
|
pivotQuery: "",
|
|
17633
17641
|
comparisonPivotQuery: ""
|
|
17634
17642
|
};
|
|
@@ -21988,12 +21996,14 @@ function buildPivotOnlyReportFromResponse({
|
|
|
21988
21996
|
}
|
|
21989
21997
|
let pivotRows = rawPivotRows;
|
|
21990
21998
|
let pivotColumns = Array.isArray(response?.pivotColumns) ? response.pivotColumns : fallbackBaseReport.pivotColumns ?? [];
|
|
21999
|
+
let pivotResultRowField;
|
|
21991
22000
|
let pivotRowCount = typeof response?.pivotRowCount === "number" ? response.pivotRowCount : typeof response?.rowCount === "number" ? response.rowCount : rawPivotRows.length;
|
|
21992
22001
|
if (effectivePivot && rawPivotFields.length > 0) {
|
|
21993
22002
|
const pivotData = processPivotData({
|
|
21994
22003
|
rows: rawPivotRows,
|
|
21995
22004
|
fields: rawPivotFields,
|
|
21996
22005
|
pivot: effectivePivot,
|
|
22006
|
+
resultRowField: response?.config?.rowField,
|
|
21997
22007
|
...effectivePivot.dateBucket ? { dateBucket: effectivePivot.dateBucket } : {},
|
|
21998
22008
|
client,
|
|
21999
22009
|
rowCount: typeof response?.rowCount === "number" ? response.rowCount : void 0
|
|
@@ -22001,6 +22011,7 @@ function buildPivotOnlyReportFromResponse({
|
|
|
22001
22011
|
pivotRows = pivotData.rows;
|
|
22002
22012
|
pivotColumns = pivotData.columns;
|
|
22003
22013
|
pivotRowCount = pivotData.rowCount;
|
|
22014
|
+
pivotResultRowField = pivotData.rowField;
|
|
22004
22015
|
}
|
|
22005
22016
|
const pivotOnlyReport = {
|
|
22006
22017
|
...responseReport,
|
|
@@ -22012,7 +22023,9 @@ function buildPivotOnlyReportFromResponse({
|
|
|
22012
22023
|
pivot: effectivePivot,
|
|
22013
22024
|
pivotRows,
|
|
22014
22025
|
pivotColumns,
|
|
22015
|
-
pivotRowCount
|
|
22026
|
+
pivotRowCount,
|
|
22027
|
+
pivotResultRowField,
|
|
22028
|
+
pivotResultSourceRowField: effectivePivot?.rowField
|
|
22016
22029
|
};
|
|
22017
22030
|
if (additionalProcessing) {
|
|
22018
22031
|
pivotOnlyReport.pagination = additionalProcessing.page;
|
|
@@ -59991,12 +60004,13 @@ var QUERY_BUILDER_MULTI_VALUE_OPERATORS = /* @__PURE__ */ new Set(["in", "notin"
|
|
|
59991
60004
|
var TABLE_FORMAT_CACHE_MAX_ENTRIES = 5e3;
|
|
59992
60005
|
var PIVOT_DATE_BUCKET_FORMAT_OPTIONS = ["date"];
|
|
59993
60006
|
var PIVOT_DATE_BUCKET_OPTIONS = [
|
|
59994
|
-
{ label: "
|
|
60007
|
+
{ label: "Dynamic", value: "" },
|
|
59995
60008
|
{ label: "Daily", value: "day" },
|
|
59996
60009
|
{ label: "Weekly", value: "week" },
|
|
59997
60010
|
{ label: "Monthly", value: "month" },
|
|
59998
60011
|
{ label: "Yearly", value: "year" }
|
|
59999
60012
|
];
|
|
60013
|
+
var STANDARD_PIVOT_DATE_BUCKET_OPTIONS = PIVOT_DATE_BUCKET_OPTIONS.slice(1);
|
|
60000
60014
|
var AXIS_FORMAT_OPTIONS = [
|
|
60001
60015
|
{ value: "string", label: "string" },
|
|
60002
60016
|
{ value: "whole_number", label: "whole number" },
|
|
@@ -60474,17 +60488,26 @@ function buildPivotAggregationsWithFieldTables({
|
|
|
60474
60488
|
columnFieldTable
|
|
60475
60489
|
};
|
|
60476
60490
|
}
|
|
60491
|
+
function resolvePivotSortFieldTable(pivot, sortField) {
|
|
60492
|
+
const explicitTable = String(pivot?.sortFieldTable ?? "").trim();
|
|
60493
|
+
if (explicitTable && sortField === pivot?.sortField) return explicitTable;
|
|
60494
|
+
if (sortField === pivot?.rowField) return pivot?.rowFieldTable;
|
|
60495
|
+
if (sortField === pivot?.columnField) return pivot?.columnFieldTable;
|
|
60496
|
+
return void 0;
|
|
60497
|
+
}
|
|
60477
60498
|
function normalizePivotForRefreshComparison(pivot) {
|
|
60478
60499
|
if (pivot == null) return pivot;
|
|
60479
60500
|
const record = pivot;
|
|
60480
60501
|
const {
|
|
60481
60502
|
rowFieldTable: _pivotRowTable,
|
|
60482
60503
|
columnFieldTable: _pivotColumnTable,
|
|
60504
|
+
sortFieldTable: _pivotSortTable,
|
|
60483
60505
|
rowFilter: _rowFilter,
|
|
60484
60506
|
columnFilter: _columnFilter,
|
|
60485
60507
|
aggregations,
|
|
60486
60508
|
...pivotRest
|
|
60487
60509
|
} = record;
|
|
60510
|
+
void _pivotSortTable;
|
|
60488
60511
|
const next = { ...pivotRest };
|
|
60489
60512
|
if (Array.isArray(aggregations)) {
|
|
60490
60513
|
next.aggregations = aggregations.map((entry) => {
|
|
@@ -63149,6 +63172,8 @@ async function loadViaReportBuilderState({
|
|
|
63149
63172
|
pivotRows: refreshedPivotData?.rows ?? compatibleReportPivotRows ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotRows : []) ?? [],
|
|
63150
63173
|
pivotColumns: refreshedPivotData?.columns ?? compatibleReportPivotColumns ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotColumns : []) ?? [],
|
|
63151
63174
|
pivotRowCount: refreshedPivotData?.rowCount ?? compatibleReportPivotRowCount ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotRowCount : void 0) ?? 0,
|
|
63175
|
+
pivotResultRowField: refreshedPivotData?.rowField ?? reportBuilderInfo.report.pivotResultRowField ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotResultRowField : void 0),
|
|
63176
|
+
pivotResultSourceRowField: refreshedPivotData?.rowField && requestedPivotRowField ? requestedPivotRowField : reportBuilderInfo.report.pivotResultSourceRowField ? reportBuilderInfo.report.pivotResultSourceRowField : canReuseBasePivotRowsAndColumns ? baseReport.pivotResultSourceRowField : void 0,
|
|
63152
63177
|
uniqueStringsByTable: reportBuilderInfo.uniqueStringsByTable,
|
|
63153
63178
|
uniqueStringsByColumn: reportBuilderInfo.uniqueStringsByColumn,
|
|
63154
63179
|
columnUniqueValues: reportBuilderInfo.uniqueStringsByColumn,
|
|
@@ -63286,6 +63311,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63286
63311
|
const { eventTracking } = (0, import_react61.useContext)(EventTrackingContext);
|
|
63287
63312
|
const [draftSessionId, setDraftSessionId] = (0, import_react61.useState)(generateDraftSessionId);
|
|
63288
63313
|
const useInMemoryEngines = options.useInMemoryEngines ?? false;
|
|
63314
|
+
const dateBucketMode = options.dateBucketMode ?? "dynamic";
|
|
63289
63315
|
const restrictFieldOptionsToSelectedDatasources = options.restrictFieldOptionsToSelectedDatasources ?? true;
|
|
63290
63316
|
const reportOverride = options.reportOverride ?? null;
|
|
63291
63317
|
const initialReportBuilderState = options.initialReportBuilderState ?? null;
|
|
@@ -64834,17 +64860,24 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64834
64860
|
rowTableHint,
|
|
64835
64861
|
columnTableHint
|
|
64836
64862
|
});
|
|
64863
|
+
const configuredDateBucket = chartPivotHydratedFromSourceRef.current ? dateBucket : dateBucket ?? priorPivot?.dateBucket;
|
|
64837
64864
|
const built = {
|
|
64838
64865
|
...priorPivot ?? {},
|
|
64839
64866
|
rowField: effectiveRowField,
|
|
64840
64867
|
rowFieldType,
|
|
64841
64868
|
columnField: effectiveColumnField,
|
|
64842
64869
|
columnFieldType,
|
|
64843
|
-
dateBucket:
|
|
64870
|
+
dateBucket: configuredDateBucket,
|
|
64844
64871
|
aggregations,
|
|
64845
64872
|
...rowFieldTable ? { rowFieldTable } : {},
|
|
64846
64873
|
...columnFieldTable ? { columnFieldTable } : {}
|
|
64847
64874
|
};
|
|
64875
|
+
if (dateBucketMode === "standard" && effectiveRowField && isDateType(String(rowFieldType ?? ""))) {
|
|
64876
|
+
built.dateBucket = resolvePivotDateBucket({
|
|
64877
|
+
pivot: built,
|
|
64878
|
+
filters: internalFilters
|
|
64879
|
+
}) ?? "month";
|
|
64880
|
+
}
|
|
64848
64881
|
return built;
|
|
64849
64882
|
}, [
|
|
64850
64883
|
aggregationState,
|
|
@@ -64852,8 +64885,10 @@ function useReport(reportIdArg, options = {}) {
|
|
|
64852
64885
|
appliedAggregationState,
|
|
64853
64886
|
baseReportBuilderTables,
|
|
64854
64887
|
dateBucket,
|
|
64888
|
+
dateBucketMode,
|
|
64855
64889
|
groupColumnsBy,
|
|
64856
64890
|
groupRowsBy,
|
|
64891
|
+
internalFilters,
|
|
64857
64892
|
schemaForReportBuilderState,
|
|
64858
64893
|
sourceReport?.columnInternal,
|
|
64859
64894
|
sourceReport?.columns,
|
|
@@ -65197,6 +65232,10 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65197
65232
|
...pivotState,
|
|
65198
65233
|
sort: Boolean(pivotSort?.sortField),
|
|
65199
65234
|
sortField: pivotSort?.sortField,
|
|
65235
|
+
sortFieldTable: resolvePivotSortFieldTable(
|
|
65236
|
+
pivotState,
|
|
65237
|
+
pivotSort?.sortField
|
|
65238
|
+
),
|
|
65200
65239
|
sortDirection: pivotSort?.sortDirection,
|
|
65201
65240
|
sortFieldType: resolvedSortFieldType,
|
|
65202
65241
|
rowLimit: limit?.value
|
|
@@ -65854,6 +65893,10 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65854
65893
|
...pivotState,
|
|
65855
65894
|
sort: Boolean(pivotSort?.sortField),
|
|
65856
65895
|
sortField: pivotSort?.sortField,
|
|
65896
|
+
sortFieldTable: resolvePivotSortFieldTable(
|
|
65897
|
+
pivotState,
|
|
65898
|
+
pivotSort?.sortField
|
|
65899
|
+
),
|
|
65857
65900
|
sortDirection: pivotSort?.sortDirection,
|
|
65858
65901
|
sortFieldType: resolvedSortFieldType,
|
|
65859
65902
|
rowLimit: limit?.value
|
|
@@ -66170,6 +66213,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66170
66213
|
pivotRows: mergedPivotRows,
|
|
66171
66214
|
pivotColumns: report.pivotColumns,
|
|
66172
66215
|
pivotRowCount: mergedPivotRowCount,
|
|
66216
|
+
pivotResultRowField: report.pivotResultRowField,
|
|
66217
|
+
pivotResultSourceRowField: report.pivotResultSourceRowField,
|
|
66173
66218
|
pivotQuery: report.pivotQuery,
|
|
66174
66219
|
comparisonPivotQuery: report.comparisonPivotQuery,
|
|
66175
66220
|
reportBuilderState: mergedReportBuilderState ? {
|
|
@@ -66189,7 +66234,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66189
66234
|
const chartData = (0, import_react61.useMemo)(() => {
|
|
66190
66235
|
if (!sourceReport) return void 0;
|
|
66191
66236
|
const rowsForChart = Array.isArray(sourceReport.rows) ? sourceReport.rows : [];
|
|
66192
|
-
const
|
|
66237
|
+
const chartPivot = nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
|
|
66238
|
+
const chartPivotForDisplay = chartPivot && sourceReport.pivotResultRowField && sourceReport.pivotResultSourceRowField === chartPivot.rowField ? {
|
|
66239
|
+
...chartPivot,
|
|
66240
|
+
rowField: sourceReport.pivotResultRowField
|
|
66241
|
+
} : chartPivot;
|
|
66193
66242
|
const rowCountForChart = chartPivotForDisplay ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
|
|
66194
66243
|
const referencedTablesForChart = effectiveReportBuilderState?.tables.map((table2) => table2.name).filter((name2) => Boolean(name2));
|
|
66195
66244
|
const pivotRowsForChart = Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows : void 0;
|
|
@@ -68156,8 +68205,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
68156
68205
|
groupRowsByOptions,
|
|
68157
68206
|
groupColumnsBy,
|
|
68158
68207
|
groupColumnsByOptions,
|
|
68159
|
-
dateBucket,
|
|
68160
|
-
dateBucketOptions: hasDatePivotRow ? PIVOT_DATE_BUCKET_OPTIONS : [],
|
|
68208
|
+
dateBucket: dateBucketMode === "standard" ? pivotState?.dateBucket : dateBucket,
|
|
68209
|
+
dateBucketOptions: hasDatePivotRow ? dateBucketMode === "standard" ? STANDARD_PIVOT_DATE_BUCKET_OPTIONS : PIVOT_DATE_BUCKET_OPTIONS : [],
|
|
68161
68210
|
/** Encoded selection per aggregation slot (`'sum:transactions::amount'`, `'count:transactions'`, `''` = placeholder). Update via `setReport({ aggregations: nextStringArray })`. */
|
|
68162
68211
|
aggregations: aggregationValues,
|
|
68163
68212
|
/** Flat aggregation pick list shared by all slots; always contains every non-empty `aggregations` entry. */
|
package/dist/index.d.cts
CHANGED
|
@@ -558,6 +558,8 @@ interface BasePivot {
|
|
|
558
558
|
sort?: boolean;
|
|
559
559
|
sortDirection?: 'ASC' | 'DESC';
|
|
560
560
|
sortField?: string;
|
|
561
|
+
/** Source table for sortField when it references a pivot dimension. */
|
|
562
|
+
sortFieldTable?: string;
|
|
561
563
|
sortFieldType?: string;
|
|
562
564
|
title?: string;
|
|
563
565
|
triggerButtonText?: string;
|
|
@@ -618,6 +620,8 @@ type PivotData = {
|
|
|
618
620
|
rows: any[];
|
|
619
621
|
columns: ColumnInternal[];
|
|
620
622
|
rowCount: number;
|
|
623
|
+
/** Row field name returned by the pivot query after backend disambiguation. */
|
|
624
|
+
rowField?: string;
|
|
621
625
|
pivotQuery: string;
|
|
622
626
|
comparisonPivotQuery?: string;
|
|
623
627
|
};
|
|
@@ -789,6 +793,10 @@ interface QuillReport {
|
|
|
789
793
|
pivotRows?: {
|
|
790
794
|
[key: string]: string;
|
|
791
795
|
}[];
|
|
796
|
+
/** Row field name returned by the pivot query after backend disambiguation. */
|
|
797
|
+
pivotResultRowField?: string;
|
|
798
|
+
/** Logical row field used to request pivotResultRowField. */
|
|
799
|
+
pivotResultSourceRowField?: string;
|
|
792
800
|
/**
|
|
793
801
|
* A list of metadata about the pivot yAxes of this report.
|
|
794
802
|
*/
|
|
@@ -3053,6 +3061,12 @@ interface UseReportOptions {
|
|
|
3053
3061
|
useInMemoryEngines?: boolean;
|
|
3054
3062
|
reportOverride?: QuillReportInternal | null;
|
|
3055
3063
|
initialReportBuilderState?: ReportBuilderState | null;
|
|
3064
|
+
/**
|
|
3065
|
+
* `dynamic` exposes an empty "Dynamic" selection when the bucket is inferred.
|
|
3066
|
+
* `standard` exposes only concrete buckets and returns the currently resolved
|
|
3067
|
+
* bucket from `useReport().dateBucket`. Defaults to `dynamic`.
|
|
3068
|
+
*/
|
|
3069
|
+
dateBucketMode?: 'dynamic' | 'standard';
|
|
3056
3070
|
/**
|
|
3057
3071
|
* When the report payload has no `dashboardName` and the client has no
|
|
3058
3072
|
* `defaultDashboard`, use this for engine tasks that require a dashboard
|
|
@@ -3184,6 +3198,8 @@ declare function useReport(reportIdArg?: string, options?: UseReportOptions): {
|
|
|
3184
3198
|
pivotRows?: {
|
|
3185
3199
|
[key: string]: string;
|
|
3186
3200
|
}[];
|
|
3201
|
+
pivotResultRowField?: string;
|
|
3202
|
+
pivotResultSourceRowField?: string;
|
|
3187
3203
|
pivotColumns?: ColumnInternal[];
|
|
3188
3204
|
pivotRowCount?: number;
|
|
3189
3205
|
} | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -558,6 +558,8 @@ interface BasePivot {
|
|
|
558
558
|
sort?: boolean;
|
|
559
559
|
sortDirection?: 'ASC' | 'DESC';
|
|
560
560
|
sortField?: string;
|
|
561
|
+
/** Source table for sortField when it references a pivot dimension. */
|
|
562
|
+
sortFieldTable?: string;
|
|
561
563
|
sortFieldType?: string;
|
|
562
564
|
title?: string;
|
|
563
565
|
triggerButtonText?: string;
|
|
@@ -618,6 +620,8 @@ type PivotData = {
|
|
|
618
620
|
rows: any[];
|
|
619
621
|
columns: ColumnInternal[];
|
|
620
622
|
rowCount: number;
|
|
623
|
+
/** Row field name returned by the pivot query after backend disambiguation. */
|
|
624
|
+
rowField?: string;
|
|
621
625
|
pivotQuery: string;
|
|
622
626
|
comparisonPivotQuery?: string;
|
|
623
627
|
};
|
|
@@ -789,6 +793,10 @@ interface QuillReport {
|
|
|
789
793
|
pivotRows?: {
|
|
790
794
|
[key: string]: string;
|
|
791
795
|
}[];
|
|
796
|
+
/** Row field name returned by the pivot query after backend disambiguation. */
|
|
797
|
+
pivotResultRowField?: string;
|
|
798
|
+
/** Logical row field used to request pivotResultRowField. */
|
|
799
|
+
pivotResultSourceRowField?: string;
|
|
792
800
|
/**
|
|
793
801
|
* A list of metadata about the pivot yAxes of this report.
|
|
794
802
|
*/
|
|
@@ -3053,6 +3061,12 @@ interface UseReportOptions {
|
|
|
3053
3061
|
useInMemoryEngines?: boolean;
|
|
3054
3062
|
reportOverride?: QuillReportInternal | null;
|
|
3055
3063
|
initialReportBuilderState?: ReportBuilderState | null;
|
|
3064
|
+
/**
|
|
3065
|
+
* `dynamic` exposes an empty "Dynamic" selection when the bucket is inferred.
|
|
3066
|
+
* `standard` exposes only concrete buckets and returns the currently resolved
|
|
3067
|
+
* bucket from `useReport().dateBucket`. Defaults to `dynamic`.
|
|
3068
|
+
*/
|
|
3069
|
+
dateBucketMode?: 'dynamic' | 'standard';
|
|
3056
3070
|
/**
|
|
3057
3071
|
* When the report payload has no `dashboardName` and the client has no
|
|
3058
3072
|
* `defaultDashboard`, use this for engine tasks that require a dashboard
|
|
@@ -3184,6 +3198,8 @@ declare function useReport(reportIdArg?: string, options?: UseReportOptions): {
|
|
|
3184
3198
|
pivotRows?: {
|
|
3185
3199
|
[key: string]: string;
|
|
3186
3200
|
}[];
|
|
3201
|
+
pivotResultRowField?: string;
|
|
3202
|
+
pivotResultSourceRowField?: string;
|
|
3187
3203
|
pivotColumns?: ColumnInternal[];
|
|
3188
3204
|
pivotRowCount?: number;
|
|
3189
3205
|
} | undefined;
|
package/dist/index.js
CHANGED
|
@@ -17315,6 +17315,7 @@ async function generatePivotWithSQL({
|
|
|
17315
17315
|
sort: pivot.sort,
|
|
17316
17316
|
sortDirection: pivot.sortDirection,
|
|
17317
17317
|
sortField: pivot.sortField,
|
|
17318
|
+
sortFieldTable: pivot.sortFieldTable,
|
|
17318
17319
|
sortFieldType: pivot.sortFieldType,
|
|
17319
17320
|
rowLimit: pivot.rowLimit,
|
|
17320
17321
|
dateBucket: resolvedDateBucket
|
|
@@ -17352,10 +17353,15 @@ async function generatePivotWithSQL({
|
|
|
17352
17353
|
const queryResponseFields = resp.data?.fields || resp.queries?.queryResults?.[0]?.fields || [];
|
|
17353
17354
|
const rowCount = resp.queries?.queryResults?.[1]?.rows?.[0]?.row_count || 0;
|
|
17354
17355
|
parseValueFromBigQueryDates(queryResponseRows, queryResponseFields);
|
|
17356
|
+
const resultRowField = processColumnName(
|
|
17357
|
+
String(
|
|
17358
|
+
resp.data?.config?.rowField ?? pivot.rowField ?? ""
|
|
17359
|
+
)
|
|
17360
|
+
);
|
|
17355
17361
|
const responseRows = queryResponseRows;
|
|
17356
17362
|
const responseFields = queryResponseFields;
|
|
17357
|
-
const rows =
|
|
17358
|
-
(row) => !row[
|
|
17363
|
+
const rows = resultRowField ? responseRows.map(
|
|
17364
|
+
(row) => !row[resultRowField] ? { ...row, [resultRowField]: "-" } : row
|
|
17359
17365
|
) : responseRows;
|
|
17360
17366
|
if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
|
|
17361
17367
|
rows.forEach((row) => {
|
|
@@ -17375,27 +17381,27 @@ async function generatePivotWithSQL({
|
|
|
17375
17381
|
(field.field || field.name).replace("comparison_", "comparison ")
|
|
17376
17382
|
)
|
|
17377
17383
|
),
|
|
17378
|
-
format: (field.field || field.name) ===
|
|
17384
|
+
format: processColumnName(field.field || field.name) === resultRowField ? "string" : pivot.aggregations?.find(
|
|
17379
17385
|
(agg) => agg.valueField === (field.field || field.name) || `${agg.valueField}_percentage` === (field.field || field.name) || !agg.valueField && agg.aggregationType === "percentage" && (field.field || field.name)?.endsWith("percentage")
|
|
17380
17386
|
)?.aggregationType === "percentage" ? "percent" : "whole_number",
|
|
17381
17387
|
fieldType: field.fieldType,
|
|
17382
17388
|
jsType: field.jsType,
|
|
17383
17389
|
dataTypeID: field.dataTypeID
|
|
17384
17390
|
})).filter(
|
|
17385
|
-
(field, index) => field.field !== "comparison_" +
|
|
17391
|
+
(field, index) => field.field !== "comparison_" + resultRowField || index === 0
|
|
17386
17392
|
).sort((a, b) => {
|
|
17387
|
-
if (a.field ===
|
|
17393
|
+
if (a.field === resultRowField) {
|
|
17388
17394
|
return -1;
|
|
17389
17395
|
}
|
|
17390
|
-
if (b.field ===
|
|
17396
|
+
if (b.field === resultRowField) {
|
|
17391
17397
|
return 1;
|
|
17392
17398
|
}
|
|
17393
17399
|
return 0;
|
|
17394
17400
|
});
|
|
17395
|
-
if (
|
|
17401
|
+
if (resultRowField && !isStringType(pivot.rowFieldType || "")) {
|
|
17396
17402
|
rows.forEach((row) => {
|
|
17397
|
-
row.__quillRawDate = typeof row[
|
|
17398
|
-
let value = typeof row[
|
|
17403
|
+
row.__quillRawDate = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
|
|
17404
|
+
let value = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
|
|
17399
17405
|
if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17400
17406
|
const rowDate = new Date(value);
|
|
17401
17407
|
if (rowDate < dateFilter.startDate) {
|
|
@@ -17410,12 +17416,10 @@ async function generatePivotWithSQL({
|
|
|
17410
17416
|
dateBucket,
|
|
17411
17417
|
databaseType
|
|
17412
17418
|
);
|
|
17413
|
-
row[
|
|
17419
|
+
row[resultRowField] = dateString;
|
|
17414
17420
|
});
|
|
17415
|
-
if (
|
|
17416
|
-
const dateSet = new Set(
|
|
17417
|
-
rows.map((row) => row[pivot.rowField || ""])
|
|
17418
|
-
);
|
|
17421
|
+
if (resultRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17422
|
+
const dateSet = new Set(rows.map((row) => row[resultRowField]));
|
|
17419
17423
|
for (let date = dateFilter.startDate; date <= dateFilter.endDate; date = new Date(date.getTime() + 24 * 60 * 60 * 1e3)) {
|
|
17420
17424
|
const formattedDate = getDateString(
|
|
17421
17425
|
date.toISOString(),
|
|
@@ -17425,7 +17429,7 @@ async function generatePivotWithSQL({
|
|
|
17425
17429
|
);
|
|
17426
17430
|
if (!dateSet.has(formattedDate)) {
|
|
17427
17431
|
const newRow = {};
|
|
17428
|
-
newRow[
|
|
17432
|
+
newRow[resultRowField] = formattedDate;
|
|
17429
17433
|
newRow.__quillRawDate = date.toISOString();
|
|
17430
17434
|
rows.push(newRow);
|
|
17431
17435
|
dateSet.add(formattedDate);
|
|
@@ -17462,6 +17466,7 @@ async function generatePivotWithSQL({
|
|
|
17462
17466
|
rows,
|
|
17463
17467
|
columns: columns ?? [],
|
|
17464
17468
|
rowCount: rowCount || rows.length,
|
|
17469
|
+
rowField: resultRowField || void 0,
|
|
17465
17470
|
pivotQuery: report?.queryString || "",
|
|
17466
17471
|
comparisonPivotQuery: comparisonPivotQuery || ""
|
|
17467
17472
|
};
|
|
@@ -17561,14 +17566,18 @@ function processPivotData({
|
|
|
17561
17566
|
rows: responseRows,
|
|
17562
17567
|
fields: responseFields,
|
|
17563
17568
|
pivot,
|
|
17569
|
+
resultRowField,
|
|
17564
17570
|
dateBucket,
|
|
17565
17571
|
dateFilter,
|
|
17566
17572
|
client,
|
|
17567
17573
|
rowCount
|
|
17568
17574
|
}) {
|
|
17569
17575
|
const databaseType = client.databaseType || "postgresql";
|
|
17570
|
-
const
|
|
17571
|
-
(
|
|
17576
|
+
const pivotRowField = processColumnName(
|
|
17577
|
+
String(resultRowField ?? pivot.rowField ?? "")
|
|
17578
|
+
);
|
|
17579
|
+
const rows = pivotRowField ? responseRows.map(
|
|
17580
|
+
(row) => !row[pivotRowField] ? { ...row, [pivotRowField]: "-" } : row
|
|
17572
17581
|
) : responseRows;
|
|
17573
17582
|
if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
|
|
17574
17583
|
rows.forEach((row) => {
|
|
@@ -17588,27 +17597,27 @@ function processPivotData({
|
|
|
17588
17597
|
(field.field || field.name).replace("comparison_", "comparison ")
|
|
17589
17598
|
)
|
|
17590
17599
|
),
|
|
17591
|
-
format: (field.field || field.name) ===
|
|
17600
|
+
format: processColumnName(field.field || field.name) === pivotRowField ? "string" : pivot.aggregations?.find(
|
|
17592
17601
|
(agg) => agg.valueField === (field.field || field.name) || `${agg.valueField}_percentage` === (field.field || field.name) || !agg.valueField && agg.aggregationType === "percentage" && (field.field || field.name)?.endsWith("percentage")
|
|
17593
17602
|
)?.aggregationType === "percentage" ? "percent" : "whole_number",
|
|
17594
17603
|
fieldType: field.fieldType,
|
|
17595
17604
|
jsType: field.jsType,
|
|
17596
17605
|
dataTypeID: field.dataTypeID
|
|
17597
17606
|
})).filter(
|
|
17598
|
-
(field, index) => field.field !== "comparison_" +
|
|
17607
|
+
(field, index) => field.field !== "comparison_" + pivotRowField || index === 0
|
|
17599
17608
|
).sort((a, b) => {
|
|
17600
|
-
if (a.field ===
|
|
17609
|
+
if (a.field === pivotRowField) {
|
|
17601
17610
|
return -1;
|
|
17602
17611
|
}
|
|
17603
|
-
if (b.field ===
|
|
17612
|
+
if (b.field === pivotRowField) {
|
|
17604
17613
|
return 1;
|
|
17605
17614
|
}
|
|
17606
17615
|
return 0;
|
|
17607
17616
|
});
|
|
17608
|
-
if (
|
|
17617
|
+
if (pivotRowField && !isStringType(pivot.rowFieldType || "")) {
|
|
17609
17618
|
rows.forEach((row) => {
|
|
17610
|
-
row.__quillRawDate = typeof row[
|
|
17611
|
-
let value = typeof row[
|
|
17619
|
+
row.__quillRawDate = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
|
|
17620
|
+
let value = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
|
|
17612
17621
|
if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17613
17622
|
const rowDate = new Date(value);
|
|
17614
17623
|
if (rowDate < dateFilter.startDate) {
|
|
@@ -17623,12 +17632,10 @@ function processPivotData({
|
|
|
17623
17632
|
dateBucket,
|
|
17624
17633
|
databaseType
|
|
17625
17634
|
);
|
|
17626
|
-
row[
|
|
17635
|
+
row[pivotRowField] = dateString;
|
|
17627
17636
|
});
|
|
17628
|
-
if (
|
|
17629
|
-
const dateSet = new Set(
|
|
17630
|
-
rows.map((row) => row[pivot.rowField || ""])
|
|
17631
|
-
);
|
|
17637
|
+
if (pivotRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
|
|
17638
|
+
const dateSet = new Set(rows.map((row) => row[pivotRowField]));
|
|
17632
17639
|
for (let date = dateFilter.startDate; date <= dateFilter.endDate; date = new Date(date.getTime() + 24 * 60 * 60 * 1e3)) {
|
|
17633
17640
|
const formattedDate = getDateString(
|
|
17634
17641
|
date.toISOString(),
|
|
@@ -17638,7 +17645,7 @@ function processPivotData({
|
|
|
17638
17645
|
);
|
|
17639
17646
|
if (!dateSet.has(formattedDate)) {
|
|
17640
17647
|
const newRow = {};
|
|
17641
|
-
newRow[
|
|
17648
|
+
newRow[pivotRowField] = formattedDate;
|
|
17642
17649
|
newRow.__quillRawDate = date.toISOString();
|
|
17643
17650
|
rows.push(newRow);
|
|
17644
17651
|
dateSet.add(formattedDate);
|
|
@@ -17675,6 +17682,7 @@ function processPivotData({
|
|
|
17675
17682
|
rows,
|
|
17676
17683
|
columns: columns ?? [],
|
|
17677
17684
|
rowCount: rowCount || rows.length,
|
|
17685
|
+
rowField: pivotRowField || void 0,
|
|
17678
17686
|
pivotQuery: "",
|
|
17679
17687
|
comparisonPivotQuery: ""
|
|
17680
17688
|
};
|
|
@@ -21985,12 +21993,14 @@ function buildPivotOnlyReportFromResponse({
|
|
|
21985
21993
|
}
|
|
21986
21994
|
let pivotRows = rawPivotRows;
|
|
21987
21995
|
let pivotColumns = Array.isArray(response?.pivotColumns) ? response.pivotColumns : fallbackBaseReport.pivotColumns ?? [];
|
|
21996
|
+
let pivotResultRowField;
|
|
21988
21997
|
let pivotRowCount = typeof response?.pivotRowCount === "number" ? response.pivotRowCount : typeof response?.rowCount === "number" ? response.rowCount : rawPivotRows.length;
|
|
21989
21998
|
if (effectivePivot && rawPivotFields.length > 0) {
|
|
21990
21999
|
const pivotData = processPivotData({
|
|
21991
22000
|
rows: rawPivotRows,
|
|
21992
22001
|
fields: rawPivotFields,
|
|
21993
22002
|
pivot: effectivePivot,
|
|
22003
|
+
resultRowField: response?.config?.rowField,
|
|
21994
22004
|
...effectivePivot.dateBucket ? { dateBucket: effectivePivot.dateBucket } : {},
|
|
21995
22005
|
client,
|
|
21996
22006
|
rowCount: typeof response?.rowCount === "number" ? response.rowCount : void 0
|
|
@@ -21998,6 +22008,7 @@ function buildPivotOnlyReportFromResponse({
|
|
|
21998
22008
|
pivotRows = pivotData.rows;
|
|
21999
22009
|
pivotColumns = pivotData.columns;
|
|
22000
22010
|
pivotRowCount = pivotData.rowCount;
|
|
22011
|
+
pivotResultRowField = pivotData.rowField;
|
|
22001
22012
|
}
|
|
22002
22013
|
const pivotOnlyReport = {
|
|
22003
22014
|
...responseReport,
|
|
@@ -22009,7 +22020,9 @@ function buildPivotOnlyReportFromResponse({
|
|
|
22009
22020
|
pivot: effectivePivot,
|
|
22010
22021
|
pivotRows,
|
|
22011
22022
|
pivotColumns,
|
|
22012
|
-
pivotRowCount
|
|
22023
|
+
pivotRowCount,
|
|
22024
|
+
pivotResultRowField,
|
|
22025
|
+
pivotResultSourceRowField: effectivePivot?.rowField
|
|
22013
22026
|
};
|
|
22014
22027
|
if (additionalProcessing) {
|
|
22015
22028
|
pivotOnlyReport.pagination = additionalProcessing.page;
|
|
@@ -60203,12 +60216,13 @@ var QUERY_BUILDER_MULTI_VALUE_OPERATORS = /* @__PURE__ */ new Set(["in", "notin"
|
|
|
60203
60216
|
var TABLE_FORMAT_CACHE_MAX_ENTRIES = 5e3;
|
|
60204
60217
|
var PIVOT_DATE_BUCKET_FORMAT_OPTIONS = ["date"];
|
|
60205
60218
|
var PIVOT_DATE_BUCKET_OPTIONS = [
|
|
60206
|
-
{ label: "
|
|
60219
|
+
{ label: "Dynamic", value: "" },
|
|
60207
60220
|
{ label: "Daily", value: "day" },
|
|
60208
60221
|
{ label: "Weekly", value: "week" },
|
|
60209
60222
|
{ label: "Monthly", value: "month" },
|
|
60210
60223
|
{ label: "Yearly", value: "year" }
|
|
60211
60224
|
];
|
|
60225
|
+
var STANDARD_PIVOT_DATE_BUCKET_OPTIONS = PIVOT_DATE_BUCKET_OPTIONS.slice(1);
|
|
60212
60226
|
var AXIS_FORMAT_OPTIONS = [
|
|
60213
60227
|
{ value: "string", label: "string" },
|
|
60214
60228
|
{ value: "whole_number", label: "whole number" },
|
|
@@ -60686,17 +60700,26 @@ function buildPivotAggregationsWithFieldTables({
|
|
|
60686
60700
|
columnFieldTable
|
|
60687
60701
|
};
|
|
60688
60702
|
}
|
|
60703
|
+
function resolvePivotSortFieldTable(pivot, sortField) {
|
|
60704
|
+
const explicitTable = String(pivot?.sortFieldTable ?? "").trim();
|
|
60705
|
+
if (explicitTable && sortField === pivot?.sortField) return explicitTable;
|
|
60706
|
+
if (sortField === pivot?.rowField) return pivot?.rowFieldTable;
|
|
60707
|
+
if (sortField === pivot?.columnField) return pivot?.columnFieldTable;
|
|
60708
|
+
return void 0;
|
|
60709
|
+
}
|
|
60689
60710
|
function normalizePivotForRefreshComparison(pivot) {
|
|
60690
60711
|
if (pivot == null) return pivot;
|
|
60691
60712
|
const record = pivot;
|
|
60692
60713
|
const {
|
|
60693
60714
|
rowFieldTable: _pivotRowTable,
|
|
60694
60715
|
columnFieldTable: _pivotColumnTable,
|
|
60716
|
+
sortFieldTable: _pivotSortTable,
|
|
60695
60717
|
rowFilter: _rowFilter,
|
|
60696
60718
|
columnFilter: _columnFilter,
|
|
60697
60719
|
aggregations,
|
|
60698
60720
|
...pivotRest
|
|
60699
60721
|
} = record;
|
|
60722
|
+
void _pivotSortTable;
|
|
60700
60723
|
const next = { ...pivotRest };
|
|
60701
60724
|
if (Array.isArray(aggregations)) {
|
|
60702
60725
|
next.aggregations = aggregations.map((entry) => {
|
|
@@ -63361,6 +63384,8 @@ async function loadViaReportBuilderState({
|
|
|
63361
63384
|
pivotRows: refreshedPivotData?.rows ?? compatibleReportPivotRows ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotRows : []) ?? [],
|
|
63362
63385
|
pivotColumns: refreshedPivotData?.columns ?? compatibleReportPivotColumns ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotColumns : []) ?? [],
|
|
63363
63386
|
pivotRowCount: refreshedPivotData?.rowCount ?? compatibleReportPivotRowCount ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotRowCount : void 0) ?? 0,
|
|
63387
|
+
pivotResultRowField: refreshedPivotData?.rowField ?? reportBuilderInfo.report.pivotResultRowField ?? (canReuseBasePivotRowsAndColumns ? baseReport.pivotResultRowField : void 0),
|
|
63388
|
+
pivotResultSourceRowField: refreshedPivotData?.rowField && requestedPivotRowField ? requestedPivotRowField : reportBuilderInfo.report.pivotResultSourceRowField ? reportBuilderInfo.report.pivotResultSourceRowField : canReuseBasePivotRowsAndColumns ? baseReport.pivotResultSourceRowField : void 0,
|
|
63364
63389
|
uniqueStringsByTable: reportBuilderInfo.uniqueStringsByTable,
|
|
63365
63390
|
uniqueStringsByColumn: reportBuilderInfo.uniqueStringsByColumn,
|
|
63366
63391
|
columnUniqueValues: reportBuilderInfo.uniqueStringsByColumn,
|
|
@@ -63498,6 +63523,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
63498
63523
|
const { eventTracking } = useContext36(EventTrackingContext);
|
|
63499
63524
|
const [draftSessionId, setDraftSessionId] = useState41(generateDraftSessionId);
|
|
63500
63525
|
const useInMemoryEngines = options.useInMemoryEngines ?? false;
|
|
63526
|
+
const dateBucketMode = options.dateBucketMode ?? "dynamic";
|
|
63501
63527
|
const restrictFieldOptionsToSelectedDatasources = options.restrictFieldOptionsToSelectedDatasources ?? true;
|
|
63502
63528
|
const reportOverride = options.reportOverride ?? null;
|
|
63503
63529
|
const initialReportBuilderState = options.initialReportBuilderState ?? null;
|
|
@@ -65046,17 +65072,24 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65046
65072
|
rowTableHint,
|
|
65047
65073
|
columnTableHint
|
|
65048
65074
|
});
|
|
65075
|
+
const configuredDateBucket = chartPivotHydratedFromSourceRef.current ? dateBucket : dateBucket ?? priorPivot?.dateBucket;
|
|
65049
65076
|
const built = {
|
|
65050
65077
|
...priorPivot ?? {},
|
|
65051
65078
|
rowField: effectiveRowField,
|
|
65052
65079
|
rowFieldType,
|
|
65053
65080
|
columnField: effectiveColumnField,
|
|
65054
65081
|
columnFieldType,
|
|
65055
|
-
dateBucket:
|
|
65082
|
+
dateBucket: configuredDateBucket,
|
|
65056
65083
|
aggregations,
|
|
65057
65084
|
...rowFieldTable ? { rowFieldTable } : {},
|
|
65058
65085
|
...columnFieldTable ? { columnFieldTable } : {}
|
|
65059
65086
|
};
|
|
65087
|
+
if (dateBucketMode === "standard" && effectiveRowField && isDateType(String(rowFieldType ?? ""))) {
|
|
65088
|
+
built.dateBucket = resolvePivotDateBucket({
|
|
65089
|
+
pivot: built,
|
|
65090
|
+
filters: internalFilters
|
|
65091
|
+
}) ?? "month";
|
|
65092
|
+
}
|
|
65060
65093
|
return built;
|
|
65061
65094
|
}, [
|
|
65062
65095
|
aggregationState,
|
|
@@ -65064,8 +65097,10 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65064
65097
|
appliedAggregationState,
|
|
65065
65098
|
baseReportBuilderTables,
|
|
65066
65099
|
dateBucket,
|
|
65100
|
+
dateBucketMode,
|
|
65067
65101
|
groupColumnsBy,
|
|
65068
65102
|
groupRowsBy,
|
|
65103
|
+
internalFilters,
|
|
65069
65104
|
schemaForReportBuilderState,
|
|
65070
65105
|
sourceReport?.columnInternal,
|
|
65071
65106
|
sourceReport?.columns,
|
|
@@ -65409,6 +65444,10 @@ function useReport(reportIdArg, options = {}) {
|
|
|
65409
65444
|
...pivotState,
|
|
65410
65445
|
sort: Boolean(pivotSort?.sortField),
|
|
65411
65446
|
sortField: pivotSort?.sortField,
|
|
65447
|
+
sortFieldTable: resolvePivotSortFieldTable(
|
|
65448
|
+
pivotState,
|
|
65449
|
+
pivotSort?.sortField
|
|
65450
|
+
),
|
|
65412
65451
|
sortDirection: pivotSort?.sortDirection,
|
|
65413
65452
|
sortFieldType: resolvedSortFieldType,
|
|
65414
65453
|
rowLimit: limit?.value
|
|
@@ -66066,6 +66105,10 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66066
66105
|
...pivotState,
|
|
66067
66106
|
sort: Boolean(pivotSort?.sortField),
|
|
66068
66107
|
sortField: pivotSort?.sortField,
|
|
66108
|
+
sortFieldTable: resolvePivotSortFieldTable(
|
|
66109
|
+
pivotState,
|
|
66110
|
+
pivotSort?.sortField
|
|
66111
|
+
),
|
|
66069
66112
|
sortDirection: pivotSort?.sortDirection,
|
|
66070
66113
|
sortFieldType: resolvedSortFieldType,
|
|
66071
66114
|
rowLimit: limit?.value
|
|
@@ -66382,6 +66425,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66382
66425
|
pivotRows: mergedPivotRows,
|
|
66383
66426
|
pivotColumns: report.pivotColumns,
|
|
66384
66427
|
pivotRowCount: mergedPivotRowCount,
|
|
66428
|
+
pivotResultRowField: report.pivotResultRowField,
|
|
66429
|
+
pivotResultSourceRowField: report.pivotResultSourceRowField,
|
|
66385
66430
|
pivotQuery: report.pivotQuery,
|
|
66386
66431
|
comparisonPivotQuery: report.comparisonPivotQuery,
|
|
66387
66432
|
reportBuilderState: mergedReportBuilderState ? {
|
|
@@ -66401,7 +66446,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66401
66446
|
const chartData = useMemo33(() => {
|
|
66402
66447
|
if (!sourceReport) return void 0;
|
|
66403
66448
|
const rowsForChart = Array.isArray(sourceReport.rows) ? sourceReport.rows : [];
|
|
66404
|
-
const
|
|
66449
|
+
const chartPivot = nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
|
|
66450
|
+
const chartPivotForDisplay = chartPivot && sourceReport.pivotResultRowField && sourceReport.pivotResultSourceRowField === chartPivot.rowField ? {
|
|
66451
|
+
...chartPivot,
|
|
66452
|
+
rowField: sourceReport.pivotResultRowField
|
|
66453
|
+
} : chartPivot;
|
|
66405
66454
|
const rowCountForChart = chartPivotForDisplay ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
|
|
66406
66455
|
const referencedTablesForChart = effectiveReportBuilderState?.tables.map((table2) => table2.name).filter((name2) => Boolean(name2));
|
|
66407
66456
|
const pivotRowsForChart = Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows : void 0;
|
|
@@ -68368,8 +68417,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
68368
68417
|
groupRowsByOptions,
|
|
68369
68418
|
groupColumnsBy,
|
|
68370
68419
|
groupColumnsByOptions,
|
|
68371
|
-
dateBucket,
|
|
68372
|
-
dateBucketOptions: hasDatePivotRow ? PIVOT_DATE_BUCKET_OPTIONS : [],
|
|
68420
|
+
dateBucket: dateBucketMode === "standard" ? pivotState?.dateBucket : dateBucket,
|
|
68421
|
+
dateBucketOptions: hasDatePivotRow ? dateBucketMode === "standard" ? STANDARD_PIVOT_DATE_BUCKET_OPTIONS : PIVOT_DATE_BUCKET_OPTIONS : [],
|
|
68373
68422
|
/** Encoded selection per aggregation slot (`'sum:transactions::amount'`, `'count:transactions'`, `''` = placeholder). Update via `setReport({ aggregations: nextStringArray })`. */
|
|
68374
68423
|
aggregations: aggregationValues,
|
|
68375
68424
|
/** Flat aggregation pick list shared by all slots; always contains every non-empty `aggregations` entry. */
|