drizzle-cube 0.1.14 → 0.1.16

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 (47) hide show
  1. package/dist/adapters/compiler-Dec55JjO.js +19988 -0
  2. package/dist/adapters/express/index.js +29 -29
  3. package/dist/adapters/fastify/index.js +31 -31
  4. package/dist/adapters/hono/index.js +38 -38
  5. package/dist/adapters/nextjs/index.js +43 -43
  6. package/dist/adapters/utils.d.ts +4 -0
  7. package/dist/client/charts.d.ts +10 -0
  8. package/dist/client/charts.js +18 -0
  9. package/dist/client/charts.js.map +1 -0
  10. package/dist/client/chunks/charts-BadAUMmd.js +2285 -0
  11. package/dist/client/chunks/charts-BadAUMmd.js.map +1 -0
  12. package/dist/client/chunks/icons-D95augkg.js +1916 -0
  13. package/dist/client/chunks/icons-D95augkg.js.map +1 -0
  14. package/dist/client/chunks/providers-DI5zeeEU.js +211 -0
  15. package/dist/client/chunks/providers-DI5zeeEU.js.map +1 -0
  16. package/dist/client/components/AIAssistant/AIAssistantModal.d.ts +10 -0
  17. package/dist/client/components/AIAssistant/constants.d.ts +11 -0
  18. package/dist/client/components/AIAssistant/index.d.ts +7 -0
  19. package/dist/client/components/AIAssistant/types.d.ts +49 -0
  20. package/dist/client/components/AIAssistant/utils.d.ts +17 -0
  21. package/dist/client/components/QueryBuilder/DateRangeFilter.d.ts +4 -0
  22. package/dist/client/components/QueryBuilder/DateRangeSelector.d.ts +11 -0
  23. package/dist/client/components/QueryBuilder/types.d.ts +32 -0
  24. package/dist/client/components/QueryBuilder/utils.d.ts +70 -1
  25. package/dist/client/components.d.ts +16 -0
  26. package/dist/client/components.js +6191 -0
  27. package/dist/client/components.js.map +1 -0
  28. package/dist/client/hooks.d.ts +11 -0
  29. package/dist/client/hooks.js +132 -0
  30. package/dist/client/hooks.js.map +1 -0
  31. package/dist/client/index.d.ts +1 -1
  32. package/dist/client/index.js +29 -30132
  33. package/dist/client/index.js.map +1 -0
  34. package/dist/client/providers/CubeProvider.d.ts +5 -2
  35. package/dist/client/providers.d.ts +9 -0
  36. package/dist/client/providers.js +7 -0
  37. package/dist/client/providers.js.map +1 -0
  38. package/dist/client/styles.css +1 -1
  39. package/dist/client/types.d.ts +4 -0
  40. package/dist/client/utils.d.ts +8 -0
  41. package/dist/client/utils.js +2 -0
  42. package/dist/client/utils.js.map +1 -0
  43. package/dist/client-bundle-stats.html +4949 -0
  44. package/dist/server/index.d.ts +226 -365
  45. package/dist/server/index.js +18886 -1555
  46. package/package.json +26 -2
  47. package/dist/adapters/utils-C3A4JGFs.js +0 -3779
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Constants for AI Assistant
3
+ */
4
+ export declare const AI_PROXY_BASE_URL = "/api/ai";
5
+ export declare const GEMINI_MODEL = "gemini-2.0-flash";
6
+ export declare const DEFAULT_SYSTEM_PROMPT_TEMPLATE = "You are a SQL query builder assistant for a semantic layer using Cube.js format.\n\nAvailable cube schema (JSON):\n{CUBE_SCHEMA}\n\nA valid Cube schema can contain things such as below (this is only an example of possible options):\n\n{\n \"measures\": [\"stories.count\"],\n \"dimensions\": [\"stories.category\"],\n \"filters\": [\n {\n \"member\": \"stories.isDraft\",\n \"operator\": \"equals\",\n \"values\": [\"No\"]\n }\n ],\n \"timeDimensions\": [\n {\n \"dimension\": \"stories.time\",\n \"dateRange\": [\"2015-01-01\", \"2015-12-31\"],\n \"granularity\": \"month\"\n }\n ],\n \"limit\": 100,\n \"offset\": 50,\n \"order\": {\n \"stories.time\": \"asc\",\n \"stories.count\": \"desc\"\n }\n}\n\nUser request: {USER_PROMPT}\n\nCRITICAL: You MUST only use field names that exist in the schema above. Do NOT create or invent field names.\n\nGenerate a JSON query object with this structure:\n{\n \"measures\": [\"CubeName.measureName\"],\n \"dimensions\": [\"CubeName.dimensionName\"], \n \"timeDimensions\": [{\n \"dimension\": \"CubeName.timeDimensionName\",\n \"granularity\": \"day|week|month|quarter|year\",\n \"dateRange\": \"last 30 days\"\n }],\n \"filters\": [{\n \"member\": \"CubeName.fieldName\",\n \"operator\": \"equals|contains|gt|gte|lt|lte|inDateRange\",\n \"values\": [\"value1\", \"value2\"]\n }]\n}\n\nRules:\n1. Only use cube names, measure names, and dimension names from the schema\n2. All field references must be in \"CubeName.fieldName\" format\n3. Verify every field exists in the provided schema before using it\n\nRespond with only the JSON query object, no explanation, no markdown formatting, no code blocks, no backtick wrapper.";
7
+ export declare const AI_STORAGE_KEY = "drizzle-cube-ai-config";
8
+ export declare const DEFAULT_AI_CONFIG: {
9
+ provider: "gemini";
10
+ apiKey: string;
11
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * AI Assistant components export
3
+ */
4
+ export { default as AIAssistantModal } from './AIAssistantModal';
5
+ export * from './types';
6
+ export * from './constants';
7
+ export * from './utils';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Types for AI Assistant functionality
3
+ */
4
+ export interface AIQueryRequest {
5
+ text: string;
6
+ }
7
+ export interface GeminiMessageResponse {
8
+ candidates: Array<{
9
+ content: {
10
+ parts: Array<{
11
+ text: string;
12
+ }>;
13
+ };
14
+ finishReason: string;
15
+ index: number;
16
+ }>;
17
+ usageMetadata: {
18
+ promptTokenCount: number;
19
+ candidatesTokenCount: number;
20
+ totalTokenCount: number;
21
+ };
22
+ }
23
+ export interface AIQueryResponse {
24
+ query: string;
25
+ rateLimit?: {
26
+ usingServerKey: boolean;
27
+ dailyLimit: number;
28
+ };
29
+ }
30
+ export interface AIConfig {
31
+ provider: 'gemini';
32
+ apiKey: string;
33
+ }
34
+ export interface AIAssistantState {
35
+ step: 'api-key' | 'query';
36
+ apiKey: string;
37
+ systemPromptTemplate: string;
38
+ userPrompt: string;
39
+ isSubmitting: boolean;
40
+ response: string | null;
41
+ responseError: string | null;
42
+ isValidating: boolean;
43
+ validationResult: 'valid' | 'invalid' | null;
44
+ validationError: string | null;
45
+ }
46
+ export interface SystemPromptVariables {
47
+ CUBE_SCHEMA: string;
48
+ USER_PROMPT: string;
49
+ }
@@ -0,0 +1,17 @@
1
+ import { AIQueryResponse, AIConfig } from './types';
2
+ /**
3
+ * Send a user prompt to AI proxy (server builds system prompt)
4
+ */
5
+ export declare function sendGeminiMessage(apiKey: string, userPrompt: string, endpoint?: string): Promise<AIQueryResponse>;
6
+ /**
7
+ * Save AI configuration to localStorage
8
+ */
9
+ export declare function saveAIConfig(config: AIConfig): void;
10
+ /**
11
+ * Load AI configuration from localStorage
12
+ */
13
+ export declare function loadAIConfig(): AIConfig;
14
+ /**
15
+ * Extract query text from simplified AI response and clean up formatting
16
+ */
17
+ export declare function extractTextFromResponse(response: AIQueryResponse): string;
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { DateRangeFilterProps } from './types';
3
+ declare const DateRangeFilter: React.FC<DateRangeFilterProps>;
4
+ export default DateRangeFilter;
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ interface DateRangeSelectorProps {
3
+ timeDimension: string;
4
+ availableTimeDimensions: string[];
5
+ currentDateRange?: string | string[];
6
+ onDateRangeChange: (timeDimension: string, dateRange: string | string[]) => void;
7
+ onTimeDimensionChange: (oldTimeDimension: string, newTimeDimension: string) => void;
8
+ onRemove: (timeDimension: string) => void;
9
+ }
10
+ declare const DateRangeSelector: React.FC<DateRangeSelectorProps>;
11
+ export default DateRangeSelector;
@@ -100,9 +100,13 @@ export interface QueryPanelProps {
100
100
  onRemoveField: (fieldName: string, fieldType: 'measures' | 'dimensions' | 'timeDimensions') => void;
101
101
  onTimeDimensionGranularityChange: (dimensionName: string, granularity: string) => void;
102
102
  onFiltersChange: (filters: Filter[]) => void;
103
+ onDateRangeChange: (timeDimension: string, dateRange: string | string[]) => void;
104
+ onDateRangeRemove: (timeDimension: string) => void;
105
+ onOrderChange: (fieldName: string, direction: 'asc' | 'desc' | null) => void;
103
106
  onClearQuery?: () => void;
104
107
  showSettings?: boolean;
105
108
  onSettingsClick?: () => void;
109
+ onAIAssistantClick?: () => void;
106
110
  }
107
111
  export interface ResultsPanelProps {
108
112
  executionStatus: ExecutionStatus;
@@ -171,3 +175,31 @@ export interface FilterValueSelectorProps {
171
175
  onValuesChange: (values: any[]) => void;
172
176
  schema: MetaResponse | null;
173
177
  }
178
+ export type DateRangeType = 'custom' | 'today' | 'yesterday' | 'this_week' | 'this_month' | 'this_quarter' | 'this_year' | 'last_7_days' | 'last_30_days' | 'last_week' | 'last_month' | 'last_quarter' | 'last_year' | 'last_12_months' | 'last_n_days' | 'last_n_weeks' | 'last_n_months' | 'last_n_quarters' | 'last_n_years';
179
+ export interface DateRangeOption {
180
+ value: DateRangeType;
181
+ label: string;
182
+ }
183
+ export declare const DATE_RANGE_OPTIONS: DateRangeOption[];
184
+ export interface DateRangeFilter {
185
+ id: string;
186
+ timeDimension: string;
187
+ rangeType: DateRangeType;
188
+ startDate?: string;
189
+ endDate?: string;
190
+ }
191
+ export interface DateRangeSelectorProps {
192
+ timeDimensions: string[];
193
+ onDateRangeChange: (timeDimension: string, dateRange: string | string[]) => void;
194
+ onDateRangeRemove: (timeDimension: string) => void;
195
+ currentDateRanges: Record<string, string | string[]>;
196
+ }
197
+ export interface DateRangeFilterProps {
198
+ timeDimensions: Array<{
199
+ dimension: string;
200
+ granularity?: string;
201
+ dateRange?: string | string[];
202
+ }>;
203
+ onDateRangeChange: (timeDimension: string, dateRange: string | string[]) => void;
204
+ onDateRangeRemove: (timeDimension: string) => void;
205
+ }
@@ -70,8 +70,20 @@ export declare function isOrFilter(filter: Filter): filter is GroupFilter;
70
70
  export declare function flattenFilters(filters: Filter[]): SimpleFilter[];
71
71
  /**
72
72
  * Get all filterable fields from schema (measures, dimensions, and time dimensions)
73
+ * Returns ALL fields if no query provided, or only query fields if query provided
73
74
  */
74
75
  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
+ /**
81
+ * Get organized filter field options with query fields prioritized at top
82
+ */
83
+ export declare function getOrganizedFilterFields(schema: MetaResponse, query?: CubeQuery): {
84
+ queryFields: MetaField[];
85
+ allFields: MetaField[];
86
+ };
75
87
  /**
76
88
  * Get available operators for a field type
77
89
  */
@@ -108,10 +120,67 @@ export declare function createAndFilter(filters?: Filter[]): GroupFilter;
108
120
  export declare function createOrFilter(filters?: Filter[]): GroupFilter;
109
121
  /**
110
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
111
124
  */
112
- export declare function cleanupFilters(filters: Filter[], query: CubeQuery): Filter[];
125
+ export declare function cleanupFilters(filters: Filter[], _query?: CubeQuery): Filter[];
126
+ /**
127
+ * Clean up filters by removing any that reference fields not in the current query (legacy)
128
+ * Only used for backward compatibility - filters on non-query fields are now supported
129
+ */
130
+ export declare function cleanupFiltersLegacy(filters: Filter[], query: CubeQuery): Filter[];
113
131
  /**
114
132
  * Transform filters from new GroupFilter format to legacy server format
115
133
  * Server expects { and: [...] } and { or: [...] } instead of { type: 'and', filters: [...] }
116
134
  */
117
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
+ /**
152
+ * Get the time dimensions that have date ranges applied
153
+ */
154
+ export declare function getTimeDimensionsWithDateRanges(query: CubeQuery): Record<string, string | string[]>;
155
+ /**
156
+ * Check if a query has any time dimensions
157
+ */
158
+ 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
+ /**
172
+ * Clean up order object by removing fields that are no longer in the query
173
+ */
174
+ export declare function cleanupOrder(order: Record<string, 'asc' | 'desc'> | undefined, query: CubeQuery): Record<string, 'asc' | 'desc'> | undefined;
175
+ /**
176
+ * Get sort direction for a field from the order object
177
+ */
178
+ export declare function getSortDirection(fieldName: string, order: Record<string, 'asc' | 'desc'> | undefined): 'asc' | 'desc' | null;
179
+ /**
180
+ * Get tooltip text for sort button based on current direction
181
+ */
182
+ export declare function getSortTooltip(direction: 'asc' | 'desc' | null): string;
183
+ /**
184
+ * Get next sort direction in the cycle: null -> asc -> desc -> null
185
+ */
186
+ export declare function getNextSortDirection(current: 'asc' | 'desc' | null): 'asc' | 'desc' | null;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Drizzle Cube UI Components
3
+ *
4
+ * UI components without charts - for applications that need dashboards,
5
+ * query builders, and layout components but provide their own charts.
6
+ */
7
+ export { default as AnalyticsPortlet } from './components/AnalyticsPortlet';
8
+ export { default as AnalyticsDashboard } from './components/AnalyticsDashboard';
9
+ export { default as DashboardGrid } from './components/DashboardGrid';
10
+ export { default as PortletContainer } from './components/PortletContainer';
11
+ export { default as PortletEditModal } from './components/PortletEditModal';
12
+ export { default as DashboardEditModal } from './components/DashboardEditModal';
13
+ export { default as Modal } from './components/Modal';
14
+ export { default as QueryBuilder } from './components/QueryBuilder';
15
+ export { createDashboardLayout, generateResponsiveLayouts, generatePortletId, findNextPosition, validateCubeQuery, createSamplePortlet } from './utils/index';
16
+ export type { PortletConfig, DashboardConfig } from './types';