@quillsql/react 2.16.99 → 2.16.100

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 CHANGED
@@ -62437,14 +62437,48 @@ function createUseFormInitialLoadQueryKey(input) {
62437
62437
  ];
62438
62438
  }
62439
62439
  var DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
62440
+ var DASHBOARD_REPORT_RESULT_FIELDS = [
62441
+ "rows",
62442
+ "compareRows",
62443
+ "pivotRows",
62444
+ "pivotColumns",
62445
+ "pivotRowCount"
62446
+ ];
62447
+ function dashboardReportQueryKey(reportId) {
62448
+ return ["quill", "dashboard-report", reportId];
62449
+ }
62450
+ function mergeSavedReportIntoDashboardQueryData(previous, saved) {
62451
+ const previousReport = previous?.report && typeof previous.report === "object" ? previous.report : void 0;
62452
+ const savedId = String(saved.id ?? saved._id ?? "").trim();
62453
+ const merged = {
62454
+ ...previousReport,
62455
+ ...saved,
62456
+ ...savedId ? { id: savedId } : {}
62457
+ };
62458
+ for (const field of DASHBOARD_REPORT_RESULT_FIELDS) {
62459
+ if (merged[field] == null && previousReport?.[field] != null) {
62460
+ merged[field] = previousReport[field];
62461
+ }
62462
+ }
62463
+ return { report: merged, error: void 0 };
62464
+ }
62440
62465
  function findCachedDashboardReportQuery(queryClient, reportId) {
62441
62466
  const id = String(reportId ?? "").trim();
62442
62467
  if (!id) return void 0;
62443
- return queryClient.getQueryCache().findAll({ queryKey: ["quill", "dashboard-report", id] }).find((query) => {
62468
+ return queryClient.getQueryCache().findAll({ queryKey: dashboardReportQueryKey(id) }).find((query) => {
62469
+ if (query.state.isInvalidated) return false;
62444
62470
  const data = query.state.data;
62445
62471
  return Boolean(data?.report) && !data?.error;
62446
62472
  });
62447
62473
  }
62474
+ function syncDashboardReportQueryCacheAfterSave(queryClient, reportId, saved) {
62475
+ const id = String(reportId ?? "").trim();
62476
+ if (!id) return;
62477
+ queryClient.setQueriesData(
62478
+ { queryKey: dashboardReportQueryKey(id) },
62479
+ (previous) => mergeSavedReportIntoDashboardQueryData(previous, saved)
62480
+ );
62481
+ }
62448
62482
  function shouldBootstrapUseFormInitialLoad(input) {
62449
62483
  return !input.hasInitialReportBuilderState && input.previouslyBootstrappedIdentity !== input.currentIdentity;
62450
62484
  }
@@ -69408,6 +69442,7 @@ function useReport(reportIdArg, options = {}) {
69408
69442
  ...report,
69409
69443
  // Keep chart axis metadata from the pivot load; detail fetch is flat
69410
69444
  // (`pivot: null`) and must supply wide `columns` for the detail table.
69445
+ xAxisLabel: previousReport.xAxisLabel,
69411
69446
  xAxisFormat: previousReport.xAxisFormat,
69412
69447
  yAxisFields: previousReport.yAxisFields,
69413
69448
  pivot: previousReport.pivot,
@@ -71422,13 +71457,14 @@ function useReport(reportIdArg, options = {}) {
71422
71457
  }
71423
71458
  );
71424
71459
  const columnsSelectedForSave = table.columns.length > 0 ? table.columns : fallbackDetailColumns;
71460
+ const persistedName = overriddenName || (String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
71461
+ String(effectiveReportBuilderState.tables[0].name)
71462
+ ) : "New report");
71425
71463
  const resp = await saveReport({
71426
71464
  report: {
71427
71465
  ...EMPTY_INTERNAL_REPORT,
71428
71466
  ...sourceRest,
71429
- name: overriddenName || (String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
71430
- String(effectiveReportBuilderState.tables[0].name)
71431
- ) : "New report"),
71467
+ name: persistedName,
71432
71468
  chartType: resolvedChartType,
71433
71469
  dashboardName: resolvedDashboardName,
71434
71470
  ...isAdmin ? { adminMode: true } : {},
@@ -71466,11 +71502,27 @@ function useReport(reportIdArg, options = {}) {
71466
71502
  if (savedReportId && resp && resp.name !== "error" && !resp.error) {
71467
71503
  await cacheCab.evictReport(savedReportId, tenants);
71468
71504
  evictSharedReportRequests(savedReportId);
71469
- await queryClient.invalidateQueries({
71470
- queryKey: ["quill", "dashboard-report", savedReportId],
71471
- refetchType: "none"
71505
+ const savedReport = {
71506
+ id: savedReportId,
71507
+ name: persistedName,
71508
+ chartType: resolvedChartType,
71509
+ xAxisField: resolvedXAxisField,
71510
+ xAxisFormat: resolvedXAxisFormat,
71511
+ xAxisLabel: resolvedXAxisLabel,
71512
+ yAxisFields: yAxisMeasures,
71513
+ pivot: effectiveReportBuilderState.pivot ?? null,
71514
+ reportBuilderState: effectiveReportBuilderState,
71515
+ columns: columnsSelectedForSave
71516
+ };
71517
+ syncDashboardReportQueryCacheAfterSave(
71518
+ queryClient,
71519
+ savedReportId,
71520
+ savedReport
71521
+ );
71522
+ await loadDashboard(resolvedDashboardName, true, {
71523
+ report: { ...sourceRest, ...savedReport },
71524
+ action: "upsert"
71472
71525
  });
71473
- await loadDashboard(resolvedDashboardName, true);
71474
71526
  }
71475
71527
  return resp;
71476
71528
  },
package/dist/index.js CHANGED
@@ -62645,14 +62645,48 @@ function createUseFormInitialLoadQueryKey(input) {
62645
62645
  ];
62646
62646
  }
62647
62647
  var DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
62648
+ var DASHBOARD_REPORT_RESULT_FIELDS = [
62649
+ "rows",
62650
+ "compareRows",
62651
+ "pivotRows",
62652
+ "pivotColumns",
62653
+ "pivotRowCount"
62654
+ ];
62655
+ function dashboardReportQueryKey(reportId) {
62656
+ return ["quill", "dashboard-report", reportId];
62657
+ }
62658
+ function mergeSavedReportIntoDashboardQueryData(previous, saved) {
62659
+ const previousReport = previous?.report && typeof previous.report === "object" ? previous.report : void 0;
62660
+ const savedId = String(saved.id ?? saved._id ?? "").trim();
62661
+ const merged = {
62662
+ ...previousReport,
62663
+ ...saved,
62664
+ ...savedId ? { id: savedId } : {}
62665
+ };
62666
+ for (const field of DASHBOARD_REPORT_RESULT_FIELDS) {
62667
+ if (merged[field] == null && previousReport?.[field] != null) {
62668
+ merged[field] = previousReport[field];
62669
+ }
62670
+ }
62671
+ return { report: merged, error: void 0 };
62672
+ }
62648
62673
  function findCachedDashboardReportQuery(queryClient, reportId) {
62649
62674
  const id = String(reportId ?? "").trim();
62650
62675
  if (!id) return void 0;
62651
- return queryClient.getQueryCache().findAll({ queryKey: ["quill", "dashboard-report", id] }).find((query) => {
62676
+ return queryClient.getQueryCache().findAll({ queryKey: dashboardReportQueryKey(id) }).find((query) => {
62677
+ if (query.state.isInvalidated) return false;
62652
62678
  const data = query.state.data;
62653
62679
  return Boolean(data?.report) && !data?.error;
62654
62680
  });
62655
62681
  }
62682
+ function syncDashboardReportQueryCacheAfterSave(queryClient, reportId, saved) {
62683
+ const id = String(reportId ?? "").trim();
62684
+ if (!id) return;
62685
+ queryClient.setQueriesData(
62686
+ { queryKey: dashboardReportQueryKey(id) },
62687
+ (previous) => mergeSavedReportIntoDashboardQueryData(previous, saved)
62688
+ );
62689
+ }
62656
62690
  function shouldBootstrapUseFormInitialLoad(input) {
62657
62691
  return !input.hasInitialReportBuilderState && input.previouslyBootstrappedIdentity !== input.currentIdentity;
62658
62692
  }
@@ -69616,6 +69650,7 @@ function useReport(reportIdArg, options = {}) {
69616
69650
  ...report,
69617
69651
  // Keep chart axis metadata from the pivot load; detail fetch is flat
69618
69652
  // (`pivot: null`) and must supply wide `columns` for the detail table.
69653
+ xAxisLabel: previousReport.xAxisLabel,
69619
69654
  xAxisFormat: previousReport.xAxisFormat,
69620
69655
  yAxisFields: previousReport.yAxisFields,
69621
69656
  pivot: previousReport.pivot,
@@ -71630,13 +71665,14 @@ function useReport(reportIdArg, options = {}) {
71630
71665
  }
71631
71666
  );
71632
71667
  const columnsSelectedForSave = table.columns.length > 0 ? table.columns : fallbackDetailColumns;
71668
+ const persistedName = overriddenName || (String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
71669
+ String(effectiveReportBuilderState.tables[0].name)
71670
+ ) : "New report");
71633
71671
  const resp = await saveReport({
71634
71672
  report: {
71635
71673
  ...EMPTY_INTERNAL_REPORT,
71636
71674
  ...sourceRest,
71637
- name: overriddenName || (String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
71638
- String(effectiveReportBuilderState.tables[0].name)
71639
- ) : "New report"),
71675
+ name: persistedName,
71640
71676
  chartType: resolvedChartType,
71641
71677
  dashboardName: resolvedDashboardName,
71642
71678
  ...isAdmin ? { adminMode: true } : {},
@@ -71674,11 +71710,27 @@ function useReport(reportIdArg, options = {}) {
71674
71710
  if (savedReportId && resp && resp.name !== "error" && !resp.error) {
71675
71711
  await cacheCab.evictReport(savedReportId, tenants);
71676
71712
  evictSharedReportRequests(savedReportId);
71677
- await queryClient.invalidateQueries({
71678
- queryKey: ["quill", "dashboard-report", savedReportId],
71679
- refetchType: "none"
71713
+ const savedReport = {
71714
+ id: savedReportId,
71715
+ name: persistedName,
71716
+ chartType: resolvedChartType,
71717
+ xAxisField: resolvedXAxisField,
71718
+ xAxisFormat: resolvedXAxisFormat,
71719
+ xAxisLabel: resolvedXAxisLabel,
71720
+ yAxisFields: yAxisMeasures,
71721
+ pivot: effectiveReportBuilderState.pivot ?? null,
71722
+ reportBuilderState: effectiveReportBuilderState,
71723
+ columns: columnsSelectedForSave
71724
+ };
71725
+ syncDashboardReportQueryCacheAfterSave(
71726
+ queryClient,
71727
+ savedReportId,
71728
+ savedReport
71729
+ );
71730
+ await loadDashboard(resolvedDashboardName, true, {
71731
+ report: { ...sourceRest, ...savedReport },
71732
+ action: "upsert"
71680
71733
  });
71681
- await loadDashboard(resolvedDashboardName, true);
71682
71734
  }
71683
71735
  return resp;
71684
71736
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.16.99",
3
+ "version": "2.16.100",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {