drizzle-cube 0.1.14 → 0.1.15
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/adapters/compiler-CQNna-Ig.js +19982 -0
- package/dist/adapters/express/index.js +29 -29
- package/dist/adapters/fastify/index.js +31 -31
- package/dist/adapters/hono/index.js +38 -38
- package/dist/adapters/nextjs/index.js +43 -43
- package/dist/adapters/utils.d.ts +4 -0
- package/dist/client/charts.d.ts +10 -0
- package/dist/client/charts.js +18 -0
- package/dist/client/charts.js.map +1 -0
- package/dist/client/chunks/charts-CM4y1xw4.js +2285 -0
- package/dist/client/chunks/charts-CM4y1xw4.js.map +1 -0
- package/dist/client/chunks/icons-D95augkg.js +1916 -0
- package/dist/client/chunks/icons-D95augkg.js.map +1 -0
- package/dist/client/chunks/providers-DdBep5JR.js +208 -0
- package/dist/client/chunks/providers-DdBep5JR.js.map +1 -0
- package/dist/client/components/AIAssistant/AIAssistantModal.d.ts +9 -0
- package/dist/client/components/AIAssistant/constants.d.ts +11 -0
- package/dist/client/components/AIAssistant/index.d.ts +7 -0
- package/dist/client/components/AIAssistant/types.d.ts +47 -0
- package/dist/client/components/AIAssistant/utils.d.ts +17 -0
- package/dist/client/components/QueryBuilder/DateRangeFilter.d.ts +4 -0
- package/dist/client/components/QueryBuilder/DateRangeSelector.d.ts +11 -0
- package/dist/client/components/QueryBuilder/types.d.ts +32 -0
- package/dist/client/components/QueryBuilder/utils.d.ts +70 -1
- package/dist/client/components.d.ts +16 -0
- package/dist/client/components.js +6290 -0
- package/dist/client/components.js.map +1 -0
- package/dist/client/hooks.d.ts +11 -0
- package/dist/client/hooks.js +132 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +29 -30132
- package/dist/client/index.js.map +1 -0
- package/dist/client/providers.d.ts +9 -0
- package/dist/client/providers.js +7 -0
- package/dist/client/providers.js.map +1 -0
- package/dist/client/styles.css +1 -1
- package/dist/client/utils.d.ts +8 -0
- package/dist/client/utils.js +2 -0
- package/dist/client/utils.js.map +1 -0
- package/dist/client-bundle-stats.html +4949 -0
- package/dist/server/index.d.ts +226 -365
- package/dist/server/index.js +18880 -1555
- package/package.json +26 -2
- 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,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for AI Assistant functionality
|
|
3
|
+
*/
|
|
4
|
+
export interface GeminiMessageRequest {
|
|
5
|
+
text?: string;
|
|
6
|
+
contents?: Array<{
|
|
7
|
+
parts: Array<{
|
|
8
|
+
text: string;
|
|
9
|
+
}>;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export interface GeminiMessageResponse {
|
|
13
|
+
candidates: Array<{
|
|
14
|
+
content: {
|
|
15
|
+
parts: Array<{
|
|
16
|
+
text: string;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
finishReason: string;
|
|
20
|
+
index: number;
|
|
21
|
+
}>;
|
|
22
|
+
usageMetadata: {
|
|
23
|
+
promptTokenCount: number;
|
|
24
|
+
candidatesTokenCount: number;
|
|
25
|
+
totalTokenCount: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface AIConfig {
|
|
29
|
+
provider: 'gemini';
|
|
30
|
+
apiKey: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AIAssistantState {
|
|
33
|
+
step: 'api-key' | 'query';
|
|
34
|
+
apiKey: string;
|
|
35
|
+
systemPromptTemplate: string;
|
|
36
|
+
userPrompt: string;
|
|
37
|
+
isSubmitting: boolean;
|
|
38
|
+
response: string | null;
|
|
39
|
+
responseError: string | null;
|
|
40
|
+
isValidating: boolean;
|
|
41
|
+
validationResult: 'valid' | 'invalid' | null;
|
|
42
|
+
validationError: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface SystemPromptVariables {
|
|
45
|
+
CUBE_SCHEMA: string;
|
|
46
|
+
USER_PROMPT: string;
|
|
47
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GeminiMessageResponse, 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): Promise<GeminiMessageResponse>;
|
|
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 text from Gemini message response and clean up formatting
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractTextFromResponse(response: GeminiMessageResponse): string;
|
|
@@ -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[],
|
|
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';
|