drizzle-cube 0.2.26 → 0.2.28

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 (89) hide show
  1. package/dist/client/charts.js +2 -2
  2. package/dist/client/chunks/{charts-BsXrHSCm.js → charts-BfXEKIrq.js} +44 -44
  3. package/dist/client/chunks/{charts-BsXrHSCm.js.map → charts-BfXEKIrq.js.map} +1 -1
  4. package/dist/client/chunks/charts-DQuOI5HA.js +9465 -0
  5. package/dist/client/chunks/charts-DQuOI5HA.js.map +1 -0
  6. package/dist/client/chunks/components-CWMeA5e-.js +14872 -0
  7. package/dist/client/chunks/components-CWMeA5e-.js.map +1 -0
  8. package/dist/client/chunks/core-DrhYtHHa.js +6 -0
  9. package/dist/client/chunks/core-DrhYtHHa.js.map +1 -0
  10. package/dist/client/chunks/hooks-CAKGR-w0.js +828 -0
  11. package/dist/client/chunks/hooks-CAKGR-w0.js.map +1 -0
  12. package/dist/client/components/AIAssistant/index.d.ts +5 -2
  13. package/dist/client/components/AnalysisBuilder/index.d.ts +6 -0
  14. package/dist/client/components/AnalysisBuilder/types.d.ts +9 -7
  15. package/dist/client/components/AnalysisBuilder/utils/fieldUtils.d.ts +46 -0
  16. package/dist/client/components/AnalysisBuilder/utils/filterUtils.d.ts +19 -0
  17. package/dist/client/components/AnalysisBuilder/utils/idUtils.d.ts +11 -0
  18. package/dist/client/components/AnalysisBuilder/utils/index.d.ts +11 -0
  19. package/dist/client/components/AnalysisBuilder/utils/queryUtils.d.ts +11 -0
  20. package/dist/client/components/AnalysisBuilder/utils/recentFieldsUtils.d.ts +14 -0
  21. package/dist/client/components/AnalysisBuilder/utils/storageUtils.d.ts +42 -0
  22. package/dist/client/components/ConfirmModal.d.ts +30 -0
  23. package/dist/client/components/DashboardFilters/DashboardFilterConfigModal.d.ts +20 -0
  24. package/dist/client/components/DashboardFilters/DashboardFilterItem.d.ts +14 -0
  25. package/dist/client/components/DashboardPortletCard.d.ts +13 -34
  26. package/dist/client/components/PortletAnalysisModal.d.ts +4 -2
  27. package/dist/client/components/QueryBuilder/types.d.ts +0 -17
  28. package/dist/client/components/shared/utils.d.ts +2 -112
  29. package/dist/client/components.d.ts +0 -1
  30. package/dist/client/components.js +12 -13
  31. package/dist/client/hooks/queries/index.d.ts +15 -0
  32. package/dist/client/hooks/queries/useCubeLoadQuery.d.ts +67 -0
  33. package/dist/client/hooks/queries/useCubeMetaQuery.d.ts +51 -0
  34. package/dist/client/hooks/queries/useDryRunQuery.d.ts +103 -0
  35. package/dist/client/hooks/queries/useMultiCubeLoadQuery.d.ts +68 -0
  36. package/dist/client/hooks/useAnalysisAI.d.ts +44 -0
  37. package/dist/client/hooks/useAnalysisBuilderHook.d.ts +113 -0
  38. package/dist/client/hooks/useAnalysisChartDefaults.d.ts +35 -0
  39. package/dist/client/hooks/useAnalysisCombinedFields.d.ts +18 -0
  40. package/dist/client/hooks/useAnalysisInitialization.d.ts +25 -0
  41. package/dist/client/hooks/useAnalysisQueryBuilder.d.ts +32 -0
  42. package/dist/client/hooks/useAnalysisQueryExecution.d.ts +38 -0
  43. package/dist/client/hooks/useAnalysisShare.d.ts +23 -0
  44. package/dist/client/hooks/useAnalysisUIState.d.ts +24 -0
  45. package/dist/client/hooks/useDashboardHook.d.ts +108 -0
  46. package/dist/client/hooks/useDebounceQuery.d.ts +48 -0
  47. package/dist/client/hooks/useDirtyStateTracking.d.ts +37 -0
  48. package/dist/client/hooks/useFilterValues.d.ts +4 -1
  49. package/dist/client/hooks.d.ts +4 -2
  50. package/dist/client/hooks.js +13 -170
  51. package/dist/client/hooks.js.map +1 -1
  52. package/dist/client/icons.js +1 -1
  53. package/dist/client/index.d.ts +11 -4
  54. package/dist/client/index.js +100 -70
  55. package/dist/client/providers/CubeMetaProvider.d.ts +1 -1
  56. package/dist/client/providers/CubeProvider.d.ts +7 -3
  57. package/dist/client/providers.js +1 -1
  58. package/dist/client/shared/queryKey.d.ts +1 -0
  59. package/dist/client/shared/utils.d.ts +5 -0
  60. package/dist/client/stores/analysisBuilderStore.d.ts +271 -0
  61. package/dist/client/stores/dashboardStore.d.ts +267 -0
  62. package/dist/client/stores/index.d.ts +13 -0
  63. package/dist/client/styles.css +1 -1
  64. package/dist/client/types.d.ts +27 -1
  65. package/dist/client/utils/chartUtils.d.ts +1 -2
  66. package/dist/client/utils/filterUtils.d.ts +15 -10
  67. package/dist/client/utils/pivotUtils.d.ts +1 -2
  68. package/dist/client-bundle-stats.html +1 -1
  69. package/package.json +14 -20
  70. package/dist/client/chunks/charts-BvLb1eub.js +0 -7427
  71. package/dist/client/chunks/charts-BvLb1eub.js.map +0 -1
  72. package/dist/client/chunks/components-BGWiuXqQ.js +0 -15831
  73. package/dist/client/chunks/components-BGWiuXqQ.js.map +0 -1
  74. package/dist/client/chunks/core-CX7kEAYO.js +0 -6
  75. package/dist/client/chunks/core-CX7kEAYO.js.map +0 -1
  76. package/dist/client/chunks/index-9x0R-Fme.js +0 -551
  77. package/dist/client/chunks/index-9x0R-Fme.js.map +0 -1
  78. package/dist/client/components/AIAssistant/AIAssistantModal.d.ts +0 -10
  79. package/dist/client/components/AnalysisBuilder/utils.d.ts +0 -103
  80. package/dist/client/components/CubeRelationshipDiagram/CubeNode.d.ts +0 -13
  81. package/dist/client/components/CubeRelationshipDiagram/ERDControls.d.ts +0 -7
  82. package/dist/client/components/CubeRelationshipDiagram/RelationshipEdge.d.ts +0 -11
  83. package/dist/client/components/CubeRelationshipDiagram/index.d.ts +0 -10
  84. package/dist/client/components/CubeRelationshipDiagram/useERDLayout.d.ts +0 -21
  85. package/dist/client/components/PortletEditModal.d.ts +0 -12
  86. package/dist/client/components/shared/CubeMetaExplorer.d.ts +0 -4
  87. package/dist/client/hooks/useCubeMeta.d.ts +0 -39
  88. package/dist/client/hooks/useCubeQuery.d.ts +0 -9
  89. package/dist/client/hooks/useMultiCubeQuery.d.ts +0 -36
@@ -1,4 +1,4 @@
1
- import { PortletConfig, ColorPalette } from '../types';
1
+ import { PortletConfig, ColorPalette, DashboardFilter } from '../types';
2
2
  interface PortletAnalysisModalProps {
3
3
  isOpen: boolean;
4
4
  onClose: () => void;
@@ -9,6 +9,8 @@ interface PortletAnalysisModalProps {
9
9
  title: string;
10
10
  submitText: string;
11
11
  colorPalette?: ColorPalette;
12
+ /** Dashboard filters to apply to preview (when editing portlet in dashboard context) */
13
+ dashboardFilters?: DashboardFilter[];
12
14
  }
13
15
  /**
14
16
  * PortletAnalysisModal - A modal wrapper around AnalysisBuilder for portlet editing
@@ -21,5 +23,5 @@ interface PortletAnalysisModalProps {
21
23
  * - Title input in header
22
24
  * - Initial data support (no re-fetch when editing)
23
25
  */
24
- export default function PortletAnalysisModal({ isOpen, onClose, onSave, portlet, initialData, title: modalTitle, submitText, colorPalette }: PortletAnalysisModalProps): import("react/jsx-runtime").JSX.Element;
26
+ export default function PortletAnalysisModal({ isOpen, onClose, onSave, portlet, initialData, title: modalTitle, submitText, colorPalette, dashboardFilters }: PortletAnalysisModalProps): import("react/jsx-runtime").JSX.Element;
25
27
  export {};
@@ -40,23 +40,6 @@ export interface QueryBuilderRef {
40
40
  };
41
41
  getValidationResult: () => ValidationResult | null;
42
42
  }
43
- export interface CubeMetaExplorerProps {
44
- schema: MetaResponse | null;
45
- schemaStatus: SchemaStatus;
46
- schemaError: string | null;
47
- selectedFields: {
48
- measures: string[];
49
- dimensions: string[];
50
- timeDimensions: string[];
51
- };
52
- onFieldSelect: (fieldName: string, fieldType: 'measures' | 'dimensions' | 'timeDimensions') => void;
53
- onFieldDeselect: (fieldName: string, fieldType: 'measures' | 'dimensions' | 'timeDimensions') => void;
54
- onRetrySchema?: () => void;
55
- onOpenSettings?: () => void;
56
- onExpandSchema?: (expanded: boolean) => void;
57
- onViewTypeChange?: (viewType: 'tree' | 'diagram') => void;
58
- isExpanded?: boolean;
59
- }
60
43
  export type ShareButtonState = 'idle' | 'copied' | 'copied-no-chart';
61
44
  export interface QueryPanelProps {
62
45
  query: CubeQuery;
@@ -1,5 +1,6 @@
1
- import { CubeQuery, Filter, SimpleFilter, GroupFilter } from '../../types';
1
+ import { CubeQuery, Filter, SimpleFilter } from '../../types';
2
2
  import { MetaField, MetaResponse } from '../QueryBuilder/types';
3
+ export { isSimpleFilter, isGroupFilter, isAndFilter, isOrFilter, flattenFilters, countFilters, createSimpleFilter, createAndFilter, createOrFilter, cleanupFilters, transformFiltersForServer, transformFiltersFromServer, hasQueryContent, cleanQuery, cleanQueryForServer, transformQueryForUI, getCubeNameFromField, getFieldType, getFieldTitle, getAvailableOperators, getAllFilterableFields, convertDateRangeTypeToValue, requiresNumberInput, formatDateForCube, } from '../../shared/utils';
3
4
  /**
4
5
  * Check if a field is selected in the current query
5
6
  */
@@ -16,67 +17,23 @@ export declare function getRegularDimensionFields(schema: MetaResponse): MetaFie
16
17
  * Get all measure fields from schema
17
18
  */
18
19
  export declare function getMeasureFields(schema: MetaResponse): MetaField[];
19
- /**
20
- * Check if query has any content (measures, dimensions, or timeDimensions)
21
- */
22
- export declare function hasQueryContent(query: CubeQuery): boolean;
23
20
  /**
24
21
  * Get count of selected fields across all types
25
22
  */
26
23
  export declare function getSelectedFieldsCount(query: CubeQuery): number;
27
- /**
28
- * Get cube name from field name (e.g., "Employees.count" -> "Employees")
29
- */
30
- export declare function getCubeNameFromField(fieldName: string): string;
31
24
  /**
32
25
  * Group fields by cube name
33
26
  */
34
27
  export declare function groupFieldsByCube(fields: MetaField[]): Record<string, MetaField[]>;
35
- /**
36
- * Clean query object by removing empty arrays
37
- */
38
- export declare function cleanQuery(query: CubeQuery): CubeQuery;
39
- /**
40
- * Clean a query and transform filters for server compatibility
41
- * This version transforms GroupFilter to legacy and/or format
42
- */
43
- export declare function cleanQueryForServer(query: CubeQuery): CubeQuery;
44
28
  /**
45
29
  * Create an empty query object
46
30
  */
47
31
  export declare function createEmptyQuery(): CubeQuery;
48
- /**
49
- * Filter utility functions
50
- */
51
- /**
52
- * Check if a filter is a simple filter
53
- */
54
- export declare function isSimpleFilter(filter: Filter): filter is SimpleFilter;
55
- /**
56
- * Check if a filter is a group filter
57
- */
58
- export declare function isGroupFilter(filter: Filter): filter is GroupFilter;
59
- /**
60
- * Check if a filter is an AND filter
61
- */
62
- export declare function isAndFilter(filter: Filter): filter is GroupFilter;
63
- /**
64
- * Check if a filter is an OR filter
65
- */
66
- export declare function isOrFilter(filter: Filter): filter is GroupFilter;
67
- /**
68
- * Flatten all simple filters from a hierarchical filter structure
69
- */
70
- export declare function flattenFilters(filters: Filter[]): SimpleFilter[];
71
32
  /**
72
33
  * Get all filterable fields from schema (measures, dimensions, and time dimensions)
73
34
  * Returns ALL fields if no query provided, or only query fields if query provided
74
35
  */
75
36
  export declare function getFilterableFields(schema: MetaResponse, query?: CubeQuery): MetaField[];
76
- /**
77
- * Get ALL filterable fields from schema, regardless of query selection
78
- */
79
- export declare function getAllFilterableFields(schema: MetaResponse): MetaField[];
80
37
  /**
81
38
  * Get organized filter field options with query fields prioritized at top
82
39
  */
@@ -84,17 +41,6 @@ export declare function getOrganizedFilterFields(schema: MetaResponse, query?: C
84
41
  queryFields: MetaField[];
85
42
  allFields: MetaField[];
86
43
  };
87
- /**
88
- * Get available operators for a field type
89
- */
90
- export declare function getAvailableOperators(fieldType: string): Array<{
91
- operator: string;
92
- label: string;
93
- }>;
94
- /**
95
- * Get field type from schema
96
- */
97
- export declare function getFieldType(fieldName: string, schema: MetaResponse): string;
98
44
  /**
99
45
  * Validate a filter
100
46
  */
@@ -102,52 +48,11 @@ export declare function validateFilter(filter: SimpleFilter, schema: MetaRespons
102
48
  isValid: boolean;
103
49
  errors: string[];
104
50
  };
105
- /**
106
- * Count total filters in hierarchical structure
107
- */
108
- export declare function countFilters(filters: Filter[]): number;
109
- /**
110
- * Create a new simple filter
111
- */
112
- export declare function createSimpleFilter(member: string, operator?: string, values?: any[]): SimpleFilter;
113
- /**
114
- * Create a new AND filter group
115
- */
116
- export declare function createAndFilter(filters?: Filter[]): GroupFilter;
117
- /**
118
- * Create a new OR filter group
119
- */
120
- export declare function createOrFilter(filters?: Filter[]): GroupFilter;
121
- /**
122
- * Clean up filters by removing any that reference fields not in the current query
123
- * @deprecated This function is no longer used as we now support filtering on any schema field
124
- */
125
- export declare function cleanupFilters(filters: Filter[], _query?: CubeQuery): Filter[];
126
51
  /**
127
52
  * Clean up filters by removing any that reference fields not in the current query (legacy)
128
53
  * Only used for backward compatibility - filters on non-query fields are now supported
129
54
  */
130
55
  export declare function cleanupFiltersLegacy(filters: Filter[], query: CubeQuery): Filter[];
131
- /**
132
- * Transform filters from new GroupFilter format to legacy server format
133
- * Server expects { and: [...] } and { or: [...] } instead of { type: 'and', filters: [...] }
134
- */
135
- export declare function transformFiltersForServer(filters: Filter[]): any[];
136
- /**
137
- * Date range utility functions
138
- */
139
- /**
140
- * Convert DateRangeType to Cube.js compatible date range format
141
- */
142
- export declare function convertDateRangeTypeToValue(rangeType: string, number?: number): string;
143
- /**
144
- * Check if a date range type requires a number input
145
- */
146
- export declare function requiresNumberInput(rangeType: string): boolean;
147
- /**
148
- * Format date for Cube.js (YYYY-MM-DD)
149
- */
150
- export declare function formatDateForCube(date: Date): string;
151
56
  /**
152
57
  * Get the time dimensions that have date ranges applied
153
58
  */
@@ -156,18 +61,6 @@ export declare function getTimeDimensionsWithDateRanges(query: CubeQuery): Recor
156
61
  * Check if a query has any time dimensions
157
62
  */
158
63
  export declare function hasTimeDimensions(query: CubeQuery): boolean;
159
- /**
160
- * Transform a Cube.js query from external format to UI internal format
161
- * This handles format differences between server/API queries and QueryBuilder state
162
- */
163
- export declare function transformQueryForUI(query: any): CubeQuery;
164
- /**
165
- * Sorting utility functions
166
- */
167
- /**
168
- * Get field title from schema metadata, falling back to field name
169
- */
170
- export declare function getFieldTitle(fieldName: string, schema: MetaResponse | null): string;
171
64
  /**
172
65
  * Clean up order object by removing fields that are no longer in the query
173
66
  */
@@ -184,9 +77,6 @@ export declare function getSortTooltip(direction: 'asc' | 'desc' | null): string
184
77
  * Get next sort direction in the cycle: null -> asc -> desc -> null
185
78
  */
186
79
  export declare function getNextSortDirection(current: 'asc' | 'desc' | null): 'asc' | 'desc' | null;
187
- /**
188
- * Compact filter bar date utilities
189
- */
190
80
  /**
191
81
  * Date preset configuration for compact filter bar
192
82
  */
@@ -8,7 +8,6 @@ export { default as AnalyticsPortlet } from './components/AnalyticsPortlet';
8
8
  export { default as AnalyticsDashboard } from './components/AnalyticsDashboard';
9
9
  export { default as DashboardGrid } from './components/DashboardGrid';
10
10
  export { default as PortletContainer } from './components/PortletContainer';
11
- export { default as PortletEditModal } from './components/PortletEditModal';
12
11
  export { default as DashboardEditModal } from './components/DashboardEditModal';
13
12
  export { default as Modal } from './components/Modal';
14
13
  export { default as QueryBuilder } from './components/QueryBuilderShim';
@@ -1,19 +1,18 @@
1
- import { a as t, A as s, d as o, D as r, M as d, P as l, b as i, Q as n } from "./chunks/components-BGWiuXqQ.js";
2
- import { c as b, j as u, h as y, e as c, d as h, v as D } from "./chunks/charts-BsXrHSCm.js";
1
+ import { a as s, A as t, c as r, D as o, M as d, P as i, Q as l } from "./chunks/components-CWMeA5e-.js";
2
+ import { c, j as u, h as y, e as P, d as b, v as h } from "./chunks/charts-BfXEKIrq.js";
3
3
  export {
4
- t as AnalyticsDashboard,
5
- s as AnalyticsPortlet,
6
- o as DashboardEditModal,
7
- r as DashboardGrid,
4
+ s as AnalyticsDashboard,
5
+ t as AnalyticsPortlet,
6
+ r as DashboardEditModal,
7
+ o as DashboardGrid,
8
8
  d as Modal,
9
- l as PortletContainer,
10
- i as PortletEditModal,
11
- n as QueryBuilder,
12
- b as createDashboardLayout,
9
+ i as PortletContainer,
10
+ l as QueryBuilder,
11
+ c as createDashboardLayout,
13
12
  u as createSamplePortlet,
14
13
  y as findNextPosition,
15
- c as generatePortletId,
16
- h as generateResponsiveLayouts,
17
- D as validateCubeQuery
14
+ P as generatePortletId,
15
+ b as generateResponsiveLayouts,
16
+ h as validateCubeQuery
18
17
  };
19
18
  //# sourceMappingURL=components.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * TanStack Query Hooks - Barrel Export
3
+ *
4
+ * These hooks provide TanStack Query-based data fetching for:
5
+ * - Cube metadata (useCubeMetaQuery)
6
+ * - Single cube data loading (useCubeLoadQuery)
7
+ * - Multi-cube data loading (useMultiCubeLoadQuery)
8
+ * - Dry-run/debug data (useDryRunQuery, useMultiDryRunQueries)
9
+ *
10
+ * All hooks include built-in debouncing, caching, and error handling.
11
+ */
12
+ export { useCubeMetaQuery, prefetchCubeMeta, CUBE_META_QUERY_KEY, type UseCubeMetaQueryOptions, type UseCubeMetaQueryResult, } from './useCubeMetaQuery';
13
+ export { useCubeLoadQuery, useCubeLoadQuery as useCubeQuery, createQueryKey, type UseCubeLoadQueryOptions, type UseCubeLoadQueryResult, } from './useCubeLoadQuery';
14
+ export { useMultiCubeLoadQuery, createMultiQueryKey, type UseMultiCubeLoadQueryOptions, type UseMultiCubeLoadQueryResult, } from './useMultiCubeLoadQuery';
15
+ export { useDryRunQuery, useMultiDryRunQueries, useDryRunQueries, createDryRunQueryKey, type DebugDataEntry, type UseDryRunQueryOptions, type UseDryRunQueryResult, type UseMultiDryRunQueriesOptions, type UseMultiDryRunQueriesResult, } from './useDryRunQuery';
@@ -0,0 +1,67 @@
1
+ import { CubeQuery, CubeResultSet } from '../../types';
2
+ /**
3
+ * Create a stable query key from a CubeQuery
4
+ * The key includes all query parameters to ensure proper caching
5
+ */
6
+ export declare function createQueryKey(query: CubeQuery | null): readonly unknown[];
7
+ export interface UseCubeLoadQueryOptions {
8
+ /**
9
+ * Whether to skip the query
10
+ * @default false
11
+ */
12
+ skip?: boolean;
13
+ /**
14
+ * Debounce delay in milliseconds
15
+ * @default 300
16
+ */
17
+ debounceMs?: number;
18
+ /**
19
+ * Whether to reset result set when query changes
20
+ * @default true
21
+ */
22
+ resetResultSetOnChange?: boolean;
23
+ /**
24
+ * Stale time in milliseconds
25
+ * @default 60 * 1000 (1 minute)
26
+ */
27
+ staleTime?: number;
28
+ /**
29
+ * Whether to keep previous data while loading new data
30
+ * @default true
31
+ */
32
+ keepPreviousData?: boolean;
33
+ }
34
+ export interface UseCubeLoadQueryResult {
35
+ /** The result set from the query */
36
+ resultSet: CubeResultSet | null;
37
+ /** Raw data from the result set */
38
+ rawData: unknown[] | null;
39
+ /** Whether the query is loading (initial load) */
40
+ isLoading: boolean;
41
+ /** Whether the query is fetching (includes refetch) */
42
+ isFetching: boolean;
43
+ /** Whether query is debouncing (waiting for user to stop typing) */
44
+ isDebouncing: boolean;
45
+ /** Error if the query failed */
46
+ error: Error | null;
47
+ /** The debounced query that was executed */
48
+ debouncedQuery: CubeQuery | null;
49
+ /** Whether the current query is valid */
50
+ isValidQuery: boolean;
51
+ /** Manually refetch the data */
52
+ refetch: () => void;
53
+ /** Clear the query cache */
54
+ clearCache: () => void;
55
+ }
56
+ /**
57
+ * TanStack Query hook for loading cube data with debouncing
58
+ *
59
+ * Usage:
60
+ * ```tsx
61
+ * const { resultSet, rawData, isLoading, error } = useCubeLoadQuery(query, {
62
+ * debounceMs: 300,
63
+ * skip: !isReady
64
+ * })
65
+ * ```
66
+ */
67
+ export declare function useCubeLoadQuery(query: CubeQuery | null, options?: UseCubeLoadQueryOptions): UseCubeLoadQueryResult;
@@ -0,0 +1,51 @@
1
+ import { useQueryClient } from '@tanstack/react-query';
2
+ import { useCubeApi } from '../../providers/CubeApiProvider';
3
+ import { CubeMeta, FieldLabelMap } from '../../types';
4
+ export declare const CUBE_META_QUERY_KEY: readonly ["cube", "meta"];
5
+ export interface UseCubeMetaQueryOptions {
6
+ /**
7
+ * Whether to skip the query (useful for conditional fetching)
8
+ * @default false
9
+ */
10
+ enabled?: boolean;
11
+ /**
12
+ * Stale time in milliseconds (how long before data is considered stale)
13
+ * @default 5 * 60 * 1000 (5 minutes)
14
+ */
15
+ staleTime?: number;
16
+ }
17
+ export interface UseCubeMetaQueryResult {
18
+ /** Cube metadata */
19
+ meta: CubeMeta | null;
20
+ /** Field label map for quick lookups */
21
+ labelMap: FieldLabelMap;
22
+ /** Whether the query is loading */
23
+ isLoading: boolean;
24
+ /** Whether the query is fetching (includes background refetch) */
25
+ isFetching: boolean;
26
+ /** Error if the query failed */
27
+ error: Error | null;
28
+ /** Manually refetch the metadata */
29
+ refetch: () => void;
30
+ /** Get a field's display label */
31
+ getFieldLabel: (fieldName: string) => string;
32
+ }
33
+ /**
34
+ * TanStack Query hook for fetching cube metadata
35
+ *
36
+ * Usage:
37
+ * ```tsx
38
+ * const { meta, labelMap, isLoading, error, refetch } = useCubeMetaQuery()
39
+ * ```
40
+ */
41
+ export declare function useCubeMetaQuery(options?: UseCubeMetaQueryOptions): UseCubeMetaQueryResult;
42
+ /**
43
+ * Prefetch cube metadata - useful for eager loading
44
+ *
45
+ * Usage:
46
+ * ```tsx
47
+ * const queryClient = useQueryClient()
48
+ * await prefetchCubeMeta(queryClient, cubeApi)
49
+ * ```
50
+ */
51
+ export declare function prefetchCubeMeta(queryClient: ReturnType<typeof useQueryClient>, cubeApi: ReturnType<typeof useCubeApi>['cubeApi']): Promise<void>;
@@ -0,0 +1,103 @@
1
+ import { CubeQuery } from '../../types';
2
+ import { QueryAnalysis } from '../../components/AnalysisBuilder/types';
3
+ /**
4
+ * Debug data entry for a single query
5
+ */
6
+ export interface DebugDataEntry {
7
+ /** Generated SQL and parameters */
8
+ sql: {
9
+ sql: string;
10
+ params: unknown[];
11
+ } | null;
12
+ /** Query analysis (dimensions, measures, complexity, etc.) */
13
+ analysis: QueryAnalysis | null;
14
+ /** Whether this entry is loading */
15
+ loading: boolean;
16
+ /** Error if fetch failed */
17
+ error: Error | null;
18
+ }
19
+ /**
20
+ * Create a stable query key for dry-run
21
+ */
22
+ export declare function createDryRunQueryKey(query: CubeQuery | null): readonly unknown[];
23
+ export interface UseDryRunQueryOptions {
24
+ /**
25
+ * Whether to skip the query
26
+ * @default false
27
+ */
28
+ skip?: boolean;
29
+ /**
30
+ * Stale time in milliseconds
31
+ * @default 5 * 60 * 1000 (5 minutes)
32
+ */
33
+ staleTime?: number;
34
+ }
35
+ export interface UseDryRunQueryResult {
36
+ /** Debug data for the query */
37
+ debugData: DebugDataEntry;
38
+ /** Manually refetch */
39
+ refetch: () => void;
40
+ }
41
+ /**
42
+ * TanStack Query hook for single query dry-run (debug) data
43
+ *
44
+ * Usage:
45
+ * ```tsx
46
+ * const { debugData } = useDryRunQuery(query, { skip: !isValidQuery })
47
+ * ```
48
+ */
49
+ export declare function useDryRunQuery(query: CubeQuery | null, options?: UseDryRunQueryOptions): UseDryRunQueryResult;
50
+ export interface UseMultiDryRunQueriesOptions {
51
+ /**
52
+ * Whether to skip all queries
53
+ * @default false
54
+ */
55
+ skip?: boolean;
56
+ /**
57
+ * Stale time in milliseconds
58
+ * @default 5 * 60 * 1000 (5 minutes)
59
+ */
60
+ staleTime?: number;
61
+ }
62
+ export interface UseMultiDryRunQueriesResult {
63
+ /** Debug data for each query */
64
+ debugDataPerQuery: DebugDataEntry[];
65
+ /** Whether any query is loading */
66
+ isLoading: boolean;
67
+ /** Manually refetch all */
68
+ refetchAll: () => void;
69
+ }
70
+ /**
71
+ * TanStack Query hook for multiple query dry-runs (debug) data
72
+ *
73
+ * Fetches debug data for multiple queries in parallel.
74
+ *
75
+ * Usage:
76
+ * ```tsx
77
+ * const { debugDataPerQuery, isLoading } = useMultiDryRunQueries(queries, {
78
+ * skip: !isMultiQueryMode
79
+ * })
80
+ * ```
81
+ */
82
+ export declare function useMultiDryRunQueries(queries: CubeQuery[], options?: UseMultiDryRunQueriesOptions): UseMultiDryRunQueriesResult;
83
+ /**
84
+ * Combined hook for single or multi-query dry-run based on mode
85
+ *
86
+ * This is a convenience wrapper that automatically chooses between
87
+ * single and multi-query dry-run based on the number of queries.
88
+ *
89
+ * Usage:
90
+ * ```tsx
91
+ * const { debugDataPerQuery } = useDryRunQueries({
92
+ * queries: isMultiQueryMode ? allQueries : [currentQuery],
93
+ * isMultiQueryMode,
94
+ * skip: !isValidQuery
95
+ * })
96
+ * ```
97
+ */
98
+ export declare function useDryRunQueries(options: {
99
+ queries: CubeQuery[];
100
+ isMultiQueryMode: boolean;
101
+ skip?: boolean;
102
+ staleTime?: number;
103
+ }): UseMultiDryRunQueriesResult;
@@ -0,0 +1,68 @@
1
+ import { MultiQueryConfig, CubeResultSet } from '../../types';
2
+ /**
3
+ * Create a stable query key for multi-query
4
+ */
5
+ export declare function createMultiQueryKey(config: MultiQueryConfig | null): readonly unknown[];
6
+ export interface UseMultiCubeLoadQueryOptions {
7
+ /**
8
+ * Whether to skip the query
9
+ * @default false
10
+ */
11
+ skip?: boolean;
12
+ /**
13
+ * Debounce delay in milliseconds
14
+ * @default 300
15
+ */
16
+ debounceMs?: number;
17
+ /**
18
+ * Whether to reset result set when query changes
19
+ * @default true
20
+ */
21
+ resetResultSetOnChange?: boolean;
22
+ /**
23
+ * Stale time in milliseconds
24
+ * @default 60 * 1000 (1 minute)
25
+ */
26
+ staleTime?: number;
27
+ /**
28
+ * Whether to keep previous data while loading new data
29
+ * @default true
30
+ */
31
+ keepPreviousData?: boolean;
32
+ }
33
+ export interface UseMultiCubeLoadQueryResult {
34
+ /** Merged data from all queries */
35
+ data: unknown[] | null;
36
+ /** Individual result sets from each query */
37
+ resultSets: (CubeResultSet | null)[] | null;
38
+ /** Per-query raw data */
39
+ perQueryData: (unknown[] | null)[] | null;
40
+ /** Whether any query is still loading (initial load) */
41
+ isLoading: boolean;
42
+ /** Whether any query is fetching (includes refetch) */
43
+ isFetching: boolean;
44
+ /** Whether query is debouncing (waiting for user to stop typing) */
45
+ isDebouncing: boolean;
46
+ /** First error encountered */
47
+ error: Error | null;
48
+ /** Per-query errors */
49
+ errors: (Error | null)[];
50
+ /** The debounced config that was executed */
51
+ debouncedConfig: MultiQueryConfig | null;
52
+ /** Whether the current config is valid */
53
+ isValidConfig: boolean;
54
+ /** Manually refetch the data */
55
+ refetch: () => void;
56
+ }
57
+ /**
58
+ * TanStack Query hook for loading multi-cube data with debouncing
59
+ *
60
+ * Usage:
61
+ * ```tsx
62
+ * const { data, isLoading, error } = useMultiCubeLoadQuery(config, {
63
+ * debounceMs: 300,
64
+ * skip: !isMultiQueryMode
65
+ * })
66
+ * ```
67
+ */
68
+ export declare function useMultiCubeLoadQuery(config: MultiQueryConfig | null, options?: UseMultiCubeLoadQueryOptions): UseMultiCubeLoadQueryResult;
@@ -0,0 +1,44 @@
1
+ import { AnalysisBuilderState, AIState } from '../components/AnalysisBuilder/types';
2
+ import { ChartType, ChartAxisConfig, ChartDisplayConfig } from '../types';
3
+ interface UseAnalysisAIOptions {
4
+ /** Current state for snapshotting */
5
+ state: AnalysisBuilderState;
6
+ /** Set state function for applying AI-generated queries */
7
+ setState: (updater: (prev: AnalysisBuilderState) => AnalysisBuilderState) => void;
8
+ /** Current chart type */
9
+ chartType: ChartType;
10
+ /** Set chart type */
11
+ setChartType: (type: ChartType) => void;
12
+ /** Current chart config */
13
+ chartConfig: ChartAxisConfig;
14
+ /** Set chart config */
15
+ setChartConfig: (config: ChartAxisConfig) => void;
16
+ /** Current display config */
17
+ displayConfig: ChartDisplayConfig;
18
+ /** Set display config */
19
+ setDisplayConfig: (config: ChartDisplayConfig) => void;
20
+ /** Set whether user manually selected chart */
21
+ setUserManuallySelectedChart: (value: boolean) => void;
22
+ /** Set active view */
23
+ setActiveView: (view: 'table' | 'chart') => void;
24
+ /** AI endpoint URL */
25
+ aiEndpoint?: string;
26
+ }
27
+ interface UseAnalysisAIResult {
28
+ /** Current AI state */
29
+ aiState: AIState;
30
+ /** Open the AI panel */
31
+ handleOpenAI: () => void;
32
+ /** Close the AI panel */
33
+ handleCloseAI: () => void;
34
+ /** Update the AI prompt */
35
+ handleAIPromptChange: (prompt: string) => void;
36
+ /** Generate query from AI */
37
+ handleGenerateAI: () => Promise<void>;
38
+ /** Accept the AI-generated query */
39
+ handleAcceptAI: () => void;
40
+ /** Cancel and restore previous state */
41
+ handleCancelAI: () => void;
42
+ }
43
+ export declare function useAnalysisAI({ state, setState, chartType, setChartType, chartConfig, setChartConfig, displayConfig, setDisplayConfig, setUserManuallySelectedChart, setActiveView, aiEndpoint }: UseAnalysisAIOptions): UseAnalysisAIResult;
44
+ export {};