@object-ui/plugin-report 6.2.3 → 7.0.0

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/dist/DatasetReportRenderer.d.ts +93 -0
  3. package/dist/{packages/plugin-report/src/LiveReportExporter.d.ts → LiveReportExporter.d.ts} +1 -1
  4. package/dist/{packages/plugin-report/src/ReportExportEngine.d.ts → ReportExportEngine.d.ts} +1 -1
  5. package/dist/ReportRenderer.d.ts +45 -0
  6. package/dist/{packages/plugin-report/src/ReportViewer.d.ts → ReportViewer.d.ts} +1 -1
  7. package/dist/{packages/plugin-report/src/formatValue.d.ts → formatValue.d.ts} +1 -1
  8. package/dist/index.d.ts +13 -2
  9. package/dist/index.js +532 -3684
  10. package/dist/index.umd.cjs +18 -18
  11. package/dist/mergeFilters.d.ts +10 -0
  12. package/package.json +15 -15
  13. package/dist/packages/plugin-report/src/ChartConfig.d.ts +0 -8
  14. package/dist/packages/plugin-report/src/ColumnsEditor.d.ts +0 -16
  15. package/dist/packages/plugin-report/src/FieldPickerDialog.d.ts +0 -36
  16. package/dist/packages/plugin-report/src/GroupingsBuilder.d.ts +0 -8
  17. package/dist/packages/plugin-report/src/JoinedBlocksEditor.d.ts +0 -31
  18. package/dist/packages/plugin-report/src/JoinedReportRenderer.d.ts +0 -47
  19. package/dist/packages/plugin-report/src/MatrixRenderer.d.ts +0 -51
  20. package/dist/packages/plugin-report/src/MatrixRenderer.stories.d.ts +0 -24
  21. package/dist/packages/plugin-report/src/ReportBuilder.d.ts +0 -10
  22. package/dist/packages/plugin-report/src/ReportConfigPanel.d.ts +0 -24
  23. package/dist/packages/plugin-report/src/ReportRenderer.d.ts +0 -44
  24. package/dist/packages/plugin-report/src/ScheduleConfig.d.ts +0 -7
  25. package/dist/packages/plugin-report/src/SpecReportGrid.d.ts +0 -49
  26. package/dist/packages/plugin-report/src/SpecReportGrid.stories.d.ts +0 -31
  27. package/dist/packages/plugin-report/src/buildChartData.d.ts +0 -38
  28. package/dist/packages/plugin-report/src/drill.d.ts +0 -63
  29. package/dist/packages/plugin-report/src/editorTypes.d.ts +0 -20
  30. package/dist/packages/plugin-report/src/hooks/useReportData.d.ts +0 -131
  31. package/dist/packages/plugin-report/src/index.d.ts +0 -26
  32. package/dist/packages/plugin-report/src/specFilterAdapter.d.ts +0 -38
  33. /package/dist/{packages/plugin-report/src/LegacyReportRenderer.d.ts → LegacyReportRenderer.d.ts} +0 -0
@@ -1,51 +0,0 @@
1
- import { ActionRunner } from '../../core/src';
2
- import { SpecReport, DataSource } from '../../types/src';
3
- import { DrillOpenIn, DrillView } from './drill';
4
- /**
5
- * MatrixRenderer
6
- *
7
- * Renders a spec `Report` of type `'matrix'` as a 2D pivot table.
8
- *
9
- * - Drives data via {@link useReportData}, which returns a {@link PivotMatrix}
10
- * when `report.groupingsAcross` is non-empty.
11
- * - Headers: row headers down the left, column headers across the top.
12
- * Multi-level groupings are shown as concatenated path segments.
13
- * - Body cells display one row per column-definition (e.g. `amount sum`).
14
- * When `report.columns` has more than one entry, each cell shows the
15
- * values stacked vertically with their labels.
16
- * - Totals: row total column on the right, column total row at the bottom,
17
- * and grand-total in the bottom-right corner.
18
- * - Drill-down: clicking a body cell fires `onCellClick` with both the row
19
- * key and column key; if an `actionRunner` is supplied, it also dispatches
20
- * a {@link buildDrillAction} carrying both keys merged.
21
- *
22
- * We intentionally don't use ObjectGrid here — its tree model is single-axis
23
- * and bolting a 2D matrix onto grid header groups would be heavier than a
24
- * direct table. The pivot dataset is already small (rows × cols are
25
- * dimensions, not raw records).
26
- */
27
- import * as React from 'react';
28
- export interface MatrixCellClickArgs {
29
- rowKey: Record<string, unknown>;
30
- colKey: Record<string, unknown>;
31
- /** Pre-merged key combining row + col — convenient for drill construction. */
32
- combinedKey: Record<string, unknown>;
33
- /** Pre-aggregated values for the clicked cell (may be undefined for empty cells). */
34
- values?: Record<string, unknown>;
35
- }
36
- export interface MatrixRendererProps {
37
- report: SpecReport;
38
- dataSource?: DataSource;
39
- rows?: Array<Record<string, unknown>>;
40
- runtimeFilter?: Record<string, unknown>;
41
- /** Imperative drill callback. */
42
- onCellClick?: (args: MatrixCellClickArgs) => void;
43
- /** Declarative drill: dispatch a `type: 'drill'` action when a cell is clicked. */
44
- actionRunner?: ActionRunner;
45
- drillView?: DrillView;
46
- drillOpenIn?: DrillOpenIn;
47
- className?: string;
48
- /** Render text for an empty cell. Defaults to "—". */
49
- emptyCellText?: string;
50
- }
51
- export declare const MatrixRenderer: React.FC<MatrixRendererProps>;
@@ -1,24 +0,0 @@
1
- import { StoryObj } from '@storybook/react';
2
- /**
3
- * MatrixRenderer stories — region × quarter pivot for M2 demo.
4
- *
5
- * Showcases:
6
- * - `groupingsAcross` rendering as columns
7
- * - `dateGranularity: 'quarter'` bucketing on close_date
8
- * - Server-side aggregation path: stories supply a mock `dataSource.aggregate`
9
- * that returns pre-bucketed rows so the hook skips client aggregation,
10
- * mirroring what objectql's engine fallback now does end-to-end.
11
- * - Cell click → drill action with combined (region, quarter) filter.
12
- */
13
- import * as React from 'react';
14
- declare const meta: {
15
- title: string;
16
- component: React.FC<import('./MatrixRenderer').MatrixRendererProps>;
17
- parameters: {
18
- layout: string;
19
- };
20
- tags: string[];
21
- };
22
- export default meta;
23
- type Story = StoryObj<typeof meta>;
24
- export declare const RegionByQuarterServerAggregated: Story;
@@ -1,10 +0,0 @@
1
- import { default as React } from 'react';
2
- import { ReportBuilderSchema } from '../../types/src';
3
- export interface ReportBuilderProps {
4
- schema: ReportBuilderSchema;
5
- }
6
- /**
7
- * ReportBuilder - Interactive report builder component
8
- * Allows users to configure report fields, filters, grouping, sections, and export settings
9
- */
10
- export declare const ReportBuilder: React.FC<ReportBuilderProps>;
@@ -1,24 +0,0 @@
1
- import { AvailableField } from './editorTypes';
2
- export type { AvailableField } from './editorTypes';
3
- export { specFilterToUIGroup, uiGroupToSpecFilter, SpecFilterAdapter, } from './specFilterAdapter';
4
- export type { SpecFilterParseResult } from './specFilterAdapter';
5
- export { ColumnsEditor, normalizeColumns } from './ColumnsEditor';
6
- export { GroupingsBuilder } from './GroupingsBuilder';
7
- export { ChartConfig } from './ChartConfig';
8
- export interface ReportConfigPanelProps {
9
- open: boolean;
10
- onClose: () => void;
11
- config: Record<string, any> | null;
12
- onSave: (config: Record<string, any>) => void;
13
- onFieldChange?: (key: string, value: any, draft: Record<string, any>) => void;
14
- availableFields?: AvailableField[];
15
- /**
16
- * Optional resolver that returns the field list for a given object name.
17
- * Used by `JoinedBlocksEditor` so blocks with an `objectName` override
18
- * pick their fields from the right object schema instead of the container's.
19
- * If omitted, blocks fall back to `availableFields`.
20
- */
21
- getFieldsForObject?: (objectName: string | undefined) => AvailableField[] | undefined;
22
- }
23
- export declare function ReportConfigPanel({ open, onClose, config, onSave, onFieldChange, availableFields, getFieldsForObject, }: ReportConfigPanelProps): import("react/jsx-runtime").JSX.Element | null;
24
- export default ReportConfigPanel;
@@ -1,44 +0,0 @@
1
- import { ActionRunner } from '../../core/src';
2
- import { SpecReport, DataSource } from '../../types/src';
3
- import { LegacyReportRendererProps } from './LegacyReportRenderer';
4
- import { DrillOpenIn, DrillView } from './drill';
5
- /**
6
- * ReportRenderer
7
- *
8
- * Thin dispatcher that routes a report schema to the correct renderer based
9
- * on whether it is a spec-native `SpecReport` (preferred) or a legacy
10
- * presentation-layer schema (`data`/`columns`/`chart`).
11
- *
12
- * Dispatch table:
13
- * | report.type | Renderer |
14
- * |------------------------|-----------------------------------|
15
- * | tabular | summary | <SpecReportGrid> |
16
- * | matrix | placeholder (M2) |
17
- * | joined | placeholder (M3) |
18
- * | (legacy / no type) | <LegacyReportRenderer> |
19
- *
20
- * Host apps can:
21
- * - Pass a `SpecReport` plus a `dataSource` to drive a live, drillable report.
22
- * - Pass a legacy `{ data, columns, chart }` schema for backwards compatibility.
23
- */
24
- import * as React from 'react';
25
- export type ReportRendererSchema = SpecReport | LegacyReportRendererProps['schema'];
26
- export interface ReportRendererProps {
27
- /** Either a spec-native `SpecReport` or a legacy presentation schema. */
28
- schema: ReportRendererSchema;
29
- /** Required for spec reports unless `rows` is provided. */
30
- dataSource?: DataSource | Record<string, unknown>;
31
- /** Pre-fetched rows (skips data fetch). */
32
- rows?: Array<Record<string, unknown>>;
33
- /** Runtime filter merged on top of `report.filter`. */
34
- runtimeFilter?: Record<string, unknown>;
35
- /** Action runner used to dispatch `drill` actions on row click. */
36
- actionRunner?: ActionRunner;
37
- /** Default view for drill targets. */
38
- drillView?: DrillView;
39
- /** Where the drill target should open. */
40
- drillOpenIn?: DrillOpenIn;
41
- /** Optional class for the outer container. */
42
- className?: string;
43
- }
44
- export declare const ReportRenderer: React.FC<ReportRendererProps>;
@@ -1,7 +0,0 @@
1
- import { default as React } from 'react';
2
- import { ReportSchedule } from '../../types/src';
3
- export interface ScheduleConfigProps {
4
- schedule?: ReportSchedule;
5
- onChange?: (schedule: ReportSchedule) => void;
6
- }
7
- export declare const ScheduleConfig: React.FC<ScheduleConfigProps>;
@@ -1,49 +0,0 @@
1
- import { SpecReport, DataSource } from '../../types/src';
2
- import { ActionRunner } from '../../core/src';
3
- import { DrillOpenIn, DrillView } from './drill';
4
- /**
5
- * SpecReportGrid
6
- *
7
- * Bridge between the spec `Report` (definition) and `ObjectGrid` (renderer).
8
- *
9
- * - Drives data fetch via {@link useReportData}.
10
- * - For `tabular` reports, renders a flat grid with columns mapped from `report.columns`.
11
- * - For `summary` reports, applies `report.groupingsDown` as ObjectGrid grouping and
12
- * passes per-group aggregations so collapsible group headers show subtotals.
13
- * - `matrix` reports fall through to a "not supported" notice (handled by M2).
14
- *
15
- * The grand total is rendered as a footer-style row above the grid; per-column
16
- * `summary` on the grid handles classic SQL `GRAND TOTAL` semantics.
17
- */
18
- import * as React from 'react';
19
- export interface SpecReportGridProps {
20
- report: SpecReport;
21
- /** Optional DataSource adapter. When omitted, `rows` must be supplied. */
22
- dataSource?: DataSource;
23
- /** Optional pre-fetched rows (skips dataSource.find). */
24
- rows?: Record<string, unknown>[];
25
- /** Optional runtime filter merged with report.filter via `$and`. */
26
- runtimeFilter?: Record<string, unknown>;
27
- /** Drill-down callback. Receives the group key for the clicked row. */
28
- onDrillDown?: (groupKey: Record<string, unknown>, rawRows: Record<string, unknown>[]) => void;
29
- /**
30
- * Optional `ActionRunner` used to dispatch a `type: 'drill'` action on row
31
- * click. When set, the grid builds the drill action via {@link buildDrillAction}
32
- * and runs it through the engine — the host must register a `drill` handler
33
- * (see {@link registerDrillHandler}) for the navigation to take effect.
34
- * `onDrillDown` still fires (after dispatch) so consumers can observe.
35
- */
36
- actionRunner?: ActionRunner;
37
- /** Drill view override (default `'list'`). */
38
- drillView?: DrillView;
39
- /** Drill open-in override (default `'current'`). */
40
- drillOpenIn?: DrillOpenIn;
41
- className?: string;
42
- }
43
- /**
44
- * Render a spec `Report` as an `ObjectGrid` (Summary/Tabular only).
45
- *
46
- * For `matrix`/`joined` types this returns a placeholder; M2/M3 will
47
- * provide dedicated renderers.
48
- */
49
- export declare const SpecReportGrid: React.FC<SpecReportGridProps>;
@@ -1,31 +0,0 @@
1
- import { StoryObj } from '@storybook/react';
2
- /**
3
- * SpecReportGrid stories — CRM-flavoured demos for M1.
4
- *
5
- * - Sales funnel by stage (summary report, sum amount, count opportunities)
6
- * - Sales funnel by owner → stage (multi-level grouping)
7
- * - Pipeline by region × quarter (matrix placeholder — M2 will render this)
8
- *
9
- * Stories supply rows inline so they work without a backend; the drill action
10
- * is wired to a console-logging ActionRunner so clicks demonstrate the
11
- * declarative drill protocol.
12
- */
13
- import * as React from 'react';
14
- declare const meta: {
15
- title: string;
16
- component: React.FC<import('./SpecReportGrid').SpecReportGridProps>;
17
- parameters: {
18
- layout: string;
19
- };
20
- tags: string[];
21
- };
22
- export default meta;
23
- type Story = StoryObj<typeof meta>;
24
- /** Funnel by stage — classic CRM "summary by status" view. */
25
- export declare const FunnelByStage: Story;
26
- /** Two-level funnel: owner → stage. Click a row to dispatch a drill action. */
27
- export declare const FunnelByOwnerAndStage: Story;
28
- /** Tabular detail report — flat opportunity list with totals. */
29
- export declare const TabularOpportunityList: Story;
30
- /** Matrix report placeholder — region × quarter pivot will land in M2. */
31
- export declare const MatrixRegionByQuarter: Story;
@@ -1,38 +0,0 @@
1
- import { ReportRow } from './hooks/useReportData';
2
- import { SpecReport, SpecReportColumn } from '../../types/src';
3
- export interface ChartAdapterLabelResolvers {
4
- /** Resolve a friendly label for a measure column. Used for the chart's y-axis legend. */
5
- resolveColumnLabel?: (col: SpecReportColumn) => string | undefined;
6
- /** Resolve a friendly label for an implicit `count` measure given the yAxis field. */
7
- resolveCountLabel?: (yField: string) => string | undefined;
8
- /** Resolve a friendly display label for an x-axis bucket value (e.g. translate picklist values). */
9
- resolveAxisValue?: (field: string, rawValue: unknown) => string | undefined;
10
- }
11
- export interface ChartAdapterInput {
12
- report: SpecReport;
13
- rows: ReportRow[];
14
- labels?: ChartAdapterLabelResolvers;
15
- }
16
- export interface ChartAdapterOutput {
17
- /** `{ data, xAxisKey, series, chartType }` ready for `<SchemaRenderer type="chart">`. */
18
- schema: ChartSchema | null;
19
- /** Human-readable diagnostic when we can't build a chart (missing xAxis, etc.). */
20
- diagnostic?: string;
21
- }
22
- type ChartType = 'bar' | 'column' | 'horizontal-bar' | 'line' | 'area' | 'pie' | 'donut' | 'funnel' | 'radar' | 'scatter';
23
- export interface ChartSchema {
24
- type: 'chart';
25
- chartType: ChartType;
26
- data: Array<Record<string, unknown>>;
27
- xAxisKey: string;
28
- series: Array<{
29
- dataKey: string;
30
- label?: string;
31
- }>;
32
- title?: string;
33
- showLegend?: boolean;
34
- showDataLabels?: boolean;
35
- className?: string;
36
- }
37
- export declare function buildChartData({ report, rows, labels }: ChartAdapterInput): ChartAdapterOutput;
38
- export {};
@@ -1,63 +0,0 @@
1
- import { ActionDef, ActionHandler, ActionRunner } from '../../core/src';
2
- import { SpecReport } from '../../types/src';
3
- /** Open-target for a drill. */
4
- export type DrillOpenIn = 'current' | 'modal' | 'new-tab';
5
- /** Drill target — either a list filtered down to the group, or a specific record. */
6
- export type DrillView = 'list' | 'detail' | (string & {});
7
- /** Serializable shape of a `type: 'drill'` action. */
8
- export interface DrillActionDef extends ActionDef {
9
- type: 'drill';
10
- objectName: string;
11
- filter?: Record<string, unknown>;
12
- view?: DrillView;
13
- recordId?: string | number;
14
- openIn?: DrillOpenIn;
15
- }
16
- /** Resolved navigation target produced by a drill handler. */
17
- export interface DrillNavigateTarget {
18
- objectName: string;
19
- filter?: Record<string, unknown>;
20
- view?: DrillView;
21
- recordId?: string | number;
22
- openIn?: DrillOpenIn;
23
- }
24
- /** Options passed when creating a drill handler. */
25
- export interface DrillHandlerOptions {
26
- /**
27
- * Host-supplied navigation callback. The handler invokes this with a
28
- * fully-resolved target so the host can decide whether to push to
29
- * router, open a modal, or open a new tab.
30
- */
31
- navigate: (target: DrillNavigateTarget) => void | Promise<void>;
32
- }
33
- /**
34
- * Compose a `drill` action from a spec report + group key.
35
- *
36
- * Filter precedence (later overrides earlier where keys conflict):
37
- * 1. `report.filter` (definition-time)
38
- * 2. `runtimeFilter` (URL / user selection)
39
- * 3. `groupKey` (the row/cell the user actually clicked)
40
- *
41
- * All three are combined via `$and` so backend filter engines see the
42
- * full intersection.
43
- */
44
- export declare function buildDrillAction(report: SpecReport, groupKey: Record<string, unknown>, options?: {
45
- runtimeFilter?: Record<string, unknown>;
46
- view?: DrillView;
47
- recordId?: string | number;
48
- openIn?: DrillOpenIn;
49
- }): DrillActionDef;
50
- /** Type guard for drill actions. */
51
- export declare function isDrillAction(action: ActionDef | undefined | null): action is DrillActionDef;
52
- /**
53
- * Build an `ActionHandler` for the `drill` action type.
54
- *
55
- * Register it on an `ActionRunner` (or `ActionEngine`'s runner) via
56
- * `runner.registerHandler('drill', createDrillHandler({ navigate }))`.
57
- */
58
- export declare function createDrillHandler(opts: DrillHandlerOptions): ActionHandler;
59
- /**
60
- * Register the drill handler on an `ActionRunner` instance. Returns an
61
- * unregister function for cleanup (useful in React effects).
62
- */
63
- export declare function registerDrillHandler(runner: ActionRunner, opts: DrillHandlerOptions): () => void;
@@ -1,20 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- export type AvailableField = {
9
- value: string;
10
- label: string;
11
- type?: string;
12
- options?: Array<{
13
- value: string;
14
- label: string;
15
- }>;
16
- };
17
- export type Translator = (key: string, defaultValue?: string, options?: any) => string;
18
- export declare const DATE_TYPES: Set<string>;
19
- export declare const NUMERIC_TYPES: Set<string>;
20
- export declare const NONE: "";
@@ -1,131 +0,0 @@
1
- import { SpecReport, SpecReportColumn, SpecReportGrouping, SpecReportDateGranularity } from '../../../types/src';
2
- export interface ReportRow {
3
- /** Group key path, e.g. `{ region: 'East', quarter: '2024-Q1' }`. Empty `{}` for the grand-total row. */
4
- groupKey: Record<string, unknown>;
5
- /** Display labels for the key path, in `[down..., across...]` order. */
6
- groupPath: string[];
7
- /** Aggregated values, keyed as `${field}__${aggregate}` (or just `${field}` for passthrough columns). */
8
- values: Record<string, unknown>;
9
- /** Number of underlying raw rows in this group. */
10
- count: number;
11
- /** Child rows for nested groupings. Undefined at the leaf level. */
12
- children?: ReportRow[];
13
- }
14
- export interface UseReportDataResult {
15
- rows: ReportRow[];
16
- rawRows: Record<string, unknown>[];
17
- totals: Record<string, unknown>;
18
- /** Pivoted matrix shape — populated when `report.groupingsAcross` is non-empty. */
19
- pivot: PivotMatrix | null;
20
- loading: boolean;
21
- error: Error | null;
22
- refetch: () => Promise<void>;
23
- drillDown: (groupKey: Record<string, unknown>) => Record<string, unknown>[];
24
- }
25
- /**
26
- * 2D pivot output. `rowHeaders` × `colHeaders` form the matrix; `cells[rowId][colId]`
27
- * holds the per-cell aggregated values keyed by `columnKey()`. Totals are
28
- * pre-computed so the renderer doesn't need to re-aggregate.
29
- */
30
- export interface PivotHeader {
31
- /** Group key path, e.g. `{ region: 'EMEA' }` (row) or `{ closeQuarter: '2024-Q1' }` (col). */
32
- key: Record<string, unknown>;
33
- /** Display labels in nesting order. */
34
- path: string[];
35
- /** Stable id derived from `path` — use as React key + lookup key into `cells`. */
36
- id: string;
37
- }
38
- export interface PivotMatrix {
39
- rowHeaders: PivotHeader[];
40
- colHeaders: PivotHeader[];
41
- /** `cells[rowId][colId] = { 'amount__sum': 1200, ... }`. Missing cells are absent (renderer fills with 0/—). */
42
- cells: Record<string, Record<string, Record<string, unknown>>>;
43
- /** Row totals across all columns, keyed by `rowId`. */
44
- rowTotals: Record<string, Record<string, unknown>>;
45
- /** Column totals across all rows, keyed by `colId`. */
46
- colTotals: Record<string, Record<string, unknown>>;
47
- /** Grand total across the entire matrix. */
48
- grandTotal: Record<string, unknown>;
49
- columns: readonly SpecReportColumn[];
50
- downGroupings: readonly SpecReportGrouping[];
51
- acrossGroupings: readonly SpecReportGrouping[];
52
- }
53
- export interface UseReportDataOptions {
54
- /**
55
- * Adapter exposing `find(resource, params)` and optionally `aggregate(resource, query)`.
56
- * - When `.aggregate` is present, the hook prefers it for reports with date
57
- * bucketing or pure aggregations — the server then runs DATE_TRUNC + GROUP
58
- * BY natively and returns one row per bucket.
59
- * - When only `.find` is present, the hook falls back to raw rows + client
60
- * bucketing (see `bucketDate` / `groupingValue`).
61
- * If the hook stays idle, no fetch happens.
62
- */
63
- dataSource?: {
64
- find?: (resource: string, params?: Record<string, unknown>) => Promise<unknown>;
65
- aggregate?: (resource: string, query: Record<string, unknown>) => Promise<unknown>;
66
- };
67
- /** Filter merged on top of `report.filter` via `$and` (e.g., URL params, user selections). */
68
- runtimeFilter?: Record<string, unknown>;
69
- /** Optional `$top` cap for the raw fetch. Defaults to 5000. */
70
- maxRows?: number;
71
- /** When `false`, skips fetching. Defaults to `true`. */
72
- enabled?: boolean;
73
- /** Pre-fetched rows. When provided, bypasses `dataSource` entirely. */
74
- rows?: Record<string, unknown>[];
75
- /**
76
- * When true (default), prefer `dataSource.aggregate()` for reports that
77
- * carry date granularity or any aggregating column. Set false to force the
78
- * client-side path (useful for tests / debugging).
79
- */
80
- preferServerAggregation?: boolean;
81
- }
82
- /** Stable key for a column's aggregated output: `field__aggregate` (or just `field`). */
83
- export declare function columnKey(col: SpecReportColumn): string;
84
- /** Format a Date into a string bucket according to a date granularity. */
85
- export declare function bucketDate(value: unknown, granularity: SpecReportDateGranularity): string | null;
86
- /** Extract the group value for a single grouping, applying dateGranularity if set. */
87
- export declare function groupingValue(row: Record<string, unknown>, grouping: SpecReportGrouping): string;
88
- /**
89
- * Compute aggregates for an array of rows against a list of columns.
90
- * `unique` returns the count of distinct non-null values; `count` includes nulls.
91
- */
92
- export declare function aggregateRows(rows: Record<string, unknown>[], columns: readonly SpecReportColumn[]): Record<string, unknown>;
93
- /**
94
- * Recursive grouping. Each grouping level produces a nested `ReportRow[]`.
95
- * The final leaf level still aggregates over the bucket so callers always have
96
- * `values` available without re-walking children.
97
- */
98
- export declare function groupAndAggregate(rows: Record<string, unknown>[], groupings: readonly SpecReportGrouping[], columns: readonly SpecReportColumn[], parentKey?: Record<string, unknown>, parentPath?: string[]): ReportRow[];
99
- /**
100
- * Build a 2D pivot matrix from raw rows. Rows are bucketed by every
101
- * `downGroupings` field path; columns by every `acrossGroupings` field path.
102
- * Each cell is then aggregated independently with the report's columns.
103
- *
104
- * - When either dimension is empty, the matrix degenerates: a single header
105
- * with empty path is emitted so the renderer can still display a 1×N or
106
- * N×1 strip without special-casing.
107
- * - Header ordering honours each grouping's `sort` ('asc' default, 'desc' opt-in).
108
- * - `limit` on the *head* grouping of each dimension is respected (matches
109
- * `groupAndAggregate`); deeper limits are ignored to preserve totals.
110
- */
111
- export declare function pivotRows(rows: Record<string, unknown>[], columns: readonly SpecReportColumn[], downGroupings: readonly SpecReportGrouping[], acrossGroupings: readonly SpecReportGrouping[]): PivotMatrix;
112
- /** Combine two FilterCondition objects via `$and`, dropping empty ones. */
113
- export declare function mergeFilters(a: Record<string, unknown> | undefined, b: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
114
- /** Collect all fields referenced by groupings + columns + sort + filter (for $select). */
115
- export declare function collectFields(report: SpecReport): string[];
116
- /**
117
- * Build a `QueryAST`-style payload for `dataSource.aggregate()`. Groupings
118
- * with `dateGranularity` are emitted as structured objects so spec-aware
119
- * backends can do server-side DATE_TRUNC; backends that don't recognise the
120
- * field gracefully treat them as the bare field name (the engine's
121
- * in-memory fallback handles the rest).
122
- *
123
- * Returns `null` when the report has no groupings *and* no aggregating
124
- * columns — in that case there's no work for `aggregate()` to do and the
125
- * hook should stick with `find()`.
126
- */
127
- export declare function buildAggregateQuery(report: SpecReport, runtimeFilter: Record<string, unknown> | undefined, maxRows: number): Record<string, unknown> | null;
128
- /**
129
- * Run a spec `Report` and return its rows, totals, and a drill-down helper.
130
- */
131
- export declare function useReportData(report: SpecReport | undefined, options?: UseReportDataOptions): UseReportDataResult;
@@ -1,26 +0,0 @@
1
- import { ReportRenderer } from './ReportRenderer';
2
- import { LegacyReportRenderer } from './LegacyReportRenderer';
3
- import { ReportViewer } from './ReportViewer';
4
- import { ReportBuilder } from './ReportBuilder';
5
- import { ReportConfigPanel } from './ReportConfigPanel';
6
- import { SpecReportGrid } from './SpecReportGrid';
7
- import { MatrixRenderer } from './MatrixRenderer';
8
- import { JoinedReportRenderer } from './JoinedReportRenderer';
9
- export { ReportRenderer, LegacyReportRenderer, ReportViewer, ReportBuilder, ReportConfigPanel, SpecReportGrid, MatrixRenderer, JoinedReportRenderer };
10
- export type { ReportRendererProps, ReportRendererSchema } from './ReportRenderer';
11
- export type { LegacyReportRendererProps } from './LegacyReportRenderer';
12
- export type { SpecReportGridProps } from './SpecReportGrid';
13
- export type { MatrixRendererProps, MatrixCellClickArgs } from './MatrixRenderer';
14
- export type { JoinedReportRendererProps } from './JoinedReportRenderer';
15
- export { buildDrillAction, createDrillHandler, registerDrillHandler, isDrillAction, } from './drill';
16
- export type { DrillActionDef, DrillHandlerOptions, DrillNavigateTarget, DrillOpenIn, DrillView, } from './drill';
17
- export type { AvailableField } from './ReportConfigPanel';
18
- export { JoinedBlocksEditor, validateJoinedBlocks } from './JoinedBlocksEditor';
19
- export type { JoinedBlocksEditorProps } from './JoinedBlocksEditor';
20
- export { formatValue } from './formatValue';
21
- export { exportReport, exportAsCSV, exportAsJSON, exportAsHTML, exportAsPDF, exportAsExcel } from './ReportExportEngine';
22
- export { ScheduleConfig } from './ScheduleConfig';
23
- export { exportWithLiveData, exportExcelWithFormulas, createScheduleTrigger, } from './LiveReportExporter';
24
- export type { LiveExportOptions, LiveExportResult, ExcelColumnConfig, ScheduleTriggerCallback, } from './LiveReportExporter';
25
- export { useReportData, columnKey, bucketDate, groupingValue, aggregateRows, groupAndAggregate, pivotRows, buildAggregateQuery, mergeFilters, collectFields, } from './hooks/useReportData';
26
- export type { ReportRow, PivotHeader, PivotMatrix, UseReportDataResult, UseReportDataOptions, } from './hooks/useReportData';
@@ -1,38 +0,0 @@
1
- import { AvailableField, Translator } from './editorTypes';
2
- type UICondition = {
3
- id: string;
4
- field: string;
5
- operator: string;
6
- value: any;
7
- };
8
- type UIGroup = {
9
- id: string;
10
- logic: 'and' | 'or';
11
- conditions: UICondition[];
12
- };
13
- export interface SpecFilterParseResult {
14
- group: UIGroup;
15
- /** When true the spec filter could not be fully represented in the UI. */
16
- complex: boolean;
17
- }
18
- /**
19
- * Convert a spec `FilterCondition` into a UI `FilterGroup`.
20
- * Falsy / non-object input yields an empty AND group.
21
- * Nested `$and` / `$or`, `$not`, or any unrecognized shape sets `complex: true`.
22
- */
23
- export declare function specFilterToUIGroup(spec: unknown): SpecFilterParseResult;
24
- /**
25
- * Convert a UI `FilterGroup` back into a spec `FilterCondition`.
26
- * - Empty group → `undefined` (drop the key).
27
- * - Single condition (equals + simple value) → `{field: value}` shorthand.
28
- * - Single condition (other operator) → `{field: {$op: value}}`.
29
- * - Multiple conditions → `{$and: [...]}` or `{$or: [...]}`.
30
- */
31
- export declare function uiGroupToSpecFilter(group: UIGroup | undefined): any;
32
- export declare function SpecFilterAdapter({ availableFields, value, onChange, t, }: {
33
- availableFields: AvailableField[];
34
- value: any;
35
- onChange: (v: any) => void;
36
- t: Translator;
37
- }): import("react/jsx-runtime").JSX.Element;
38
- export {};