drizzle-cube 0.1.3 → 0.1.4
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/README.md +24 -2
- package/dist/adapters/hono/index.d.ts +5 -1
- package/dist/adapters/hono/index.js +187 -93
- package/dist/client/client/CubeClient.d.ts +14 -0
- package/dist/client/components/AnalyticsDashboard.d.ts +2 -0
- package/dist/client/components/AnalyticsPage.d.ts +1 -0
- package/dist/client/components/AnalyticsPortlet.d.ts +6 -0
- package/dist/client/components/ChartConfigEditor.d.ts +8 -0
- package/dist/client/components/ChartErrorBoundary.d.ts +21 -0
- package/dist/client/components/DashboardEditModal.d.ts +14 -0
- package/dist/client/components/DashboardGrid.d.ts +11 -0
- package/dist/client/components/Modal.d.ts +15 -0
- package/dist/client/components/PortletContainer.d.ts +10 -0
- package/dist/client/components/PortletEditModal.d.ts +12 -0
- package/dist/client/components/charts/AreaChart.d.ts +2 -0
- package/dist/client/components/charts/BarChart.d.ts +2 -0
- package/dist/client/components/charts/ChartContainer.d.ts +7 -0
- package/dist/client/components/charts/ChartLegend.d.ts +7 -0
- package/dist/client/components/charts/ChartTooltip.d.ts +7 -0
- package/dist/client/components/charts/DataTable.d.ts +2 -0
- package/dist/client/components/charts/LineChart.d.ts +2 -0
- package/dist/client/components/charts/PieChart.d.ts +2 -0
- package/dist/client/components/charts/RadarChart.d.ts +2 -0
- package/dist/client/components/charts/RadialBarChart.d.ts +2 -0
- package/dist/client/components/charts/ScatterChart.d.ts +2 -0
- package/dist/client/components/charts/TreeMapChart.d.ts +2 -0
- package/dist/client/components/charts/index.d.ts +13 -0
- package/dist/client/hooks/useCubeQuery.d.ts +8 -0
- package/dist/client/index.d.ts +14 -0
- package/dist/client/index.js +23813 -4
- package/dist/client/providers/CubeProvider.d.ts +15 -0
- package/dist/client/styles.css +1 -0
- package/dist/client/types.d.ts +111 -0
- package/dist/client/utils/chartConstants.d.ts +15 -0
- package/dist/client/utils/chartUtils.d.ts +9 -0
- package/dist/client/utils/index.d.ts +87 -0
- package/dist/server/index.d.ts +74 -1155
- package/dist/server/index.js +1036 -2842
- package/package.json +10 -3
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CubeClient } from '../client/CubeClient';
|
|
3
|
+
import { CubeQueryOptions } from '../types';
|
|
4
|
+
interface CubeContextValue {
|
|
5
|
+
cubeApi: CubeClient;
|
|
6
|
+
options?: CubeQueryOptions;
|
|
7
|
+
}
|
|
8
|
+
interface CubeProviderProps {
|
|
9
|
+
cubeApi: CubeClient;
|
|
10
|
+
options?: CubeQueryOptions;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare function CubeProvider({ cubeApi, options, children }: CubeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function useCubeContext(): CubeContextValue;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.react-grid-layout{position:relative;transition:height .2s ease}.react-grid-item{transition:all .2s ease;transition-property:left,top,width,height}.react-grid-item img{pointer-events:none;-webkit-user-select:none;user-select:none}.react-grid-item.cssTransforms{transition-property:transform,width,height}.react-grid-item.resizing{transition:none;z-index:1;will-change:width,height}.react-grid-item.react-draggable-dragging{transition:none;z-index:3;will-change:transform}.react-grid-item.dropping{visibility:hidden}.react-grid-item.react-grid-placeholder.placeholder-resizing{transition:none}.react-grid-item>.react-resizable-handle{position:absolute;width:20px;height:20px}.react-grid-item>.react-resizable-handle:after{content:"";position:absolute;right:3px;bottom:3px;width:5px;height:5px;border-right:2px solid rgba(0,0,0,.4);border-bottom:2px solid rgba(0,0,0,.4)}.react-resizable-hide>.react-resizable-handle{display:none}.react-grid-item>.react-resizable-handle.react-resizable-handle-sw{bottom:0;left:0;cursor:sw-resize;transform:rotate(90deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-se{bottom:0;right:0;cursor:se-resize}.react-grid-item>.react-resizable-handle.react-resizable-handle-nw{top:0;left:0;cursor:nw-resize;transform:rotate(180deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-ne{top:0;right:0;cursor:ne-resize;transform:rotate(270deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-w,.react-grid-item>.react-resizable-handle.react-resizable-handle-e{top:50%;margin-top:-10px;cursor:ew-resize}.react-grid-item>.react-resizable-handle.react-resizable-handle-w{left:0;transform:rotate(135deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-e{right:0;transform:rotate(315deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-n,.react-grid-item>.react-resizable-handle.react-resizable-handle-s{left:50%;margin-left:-10px;cursor:ns-resize}.react-grid-item>.react-resizable-handle.react-resizable-handle-n{top:0;transform:rotate(225deg)}.react-grid-item>.react-resizable-handle.react-resizable-handle-s{bottom:0;transform:rotate(45deg)}.react-resizable{position:relative}.react-resizable-handle{position:absolute;width:20px;height:20px;background-repeat:no-repeat;background-origin:content-box;box-sizing:border-box;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+);background-position:bottom right;padding:0 3px 3px 0}.react-resizable-handle-sw{bottom:0;left:0;cursor:sw-resize;transform:rotate(90deg)}.react-resizable-handle-se{bottom:0;right:0;cursor:se-resize}.react-resizable-handle-nw{top:0;left:0;cursor:nw-resize;transform:rotate(180deg)}.react-resizable-handle-ne{top:0;right:0;cursor:ne-resize;transform:rotate(270deg)}.react-resizable-handle-w,.react-resizable-handle-e{top:50%;margin-top:-10px;cursor:ew-resize}.react-resizable-handle-w{left:0;transform:rotate(135deg)}.react-resizable-handle-e{right:0;transform:rotate(315deg)}.react-resizable-handle-n,.react-resizable-handle-s{left:50%;margin-left:-10px;cursor:ns-resize}.react-resizable-handle-n{top:0;transform:rotate(225deg)}.react-resizable-handle-s{bottom:0;transform:rotate(45deg)}.react-grid-layout{position:relative}.react-grid-item{transition:all .2s ease;transition-property:left,top}.react-grid-item.cssTransforms{transition-property:transform}.react-grid-item>.react-resizable-handle{position:absolute;width:20px;height:20px;bottom:0;right:0;background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNiIgaGVpZ2h0PSI2IiB2aWV3Qm94PSIwIDAgNiA2IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxnIGZpbGw9IiM0NDRDY2MiIGZpbGwtb3BhY2l0eT0iLjMiIGZpbGwtcnVsZT0iZXZlbm9kZCI+PHBhdGggZD0ibTUgNWgtNHYtNGg0eiIvPjwvZz48L3N2Zz4=);background-position:bottom right;padding:0 3px 3px 0;background-repeat:no-repeat;background-origin:content-box;box-sizing:border-box;cursor:se-resize}.react-grid-item.react-grid-placeholder{background:red;opacity:.2;transition-duration:.1s;z-index:2;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.drizzle-cube-portlet{background:#fff;border:1px solid #e5e7eb;border-radius:.5rem;box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f;display:flex;flex-direction:column}.drizzle-cube-portlet-header{display:flex;align-items:center;justify-content:space-between;padding:.75rem;border-bottom:1px solid #e5e7eb;flex-shrink:0;background:#f9fafb;border-radius:.5rem .5rem 0 0;margin:-1px -1px 0}.drizzle-cube-portlet-drag-handle{display:flex;align-items:center;gap:.5rem;cursor:move;flex:1;min-width:0}.drizzle-cube-portlet-title{font-weight:600;font-size:.875rem;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.drizzle-cube-portlet-controls{display:flex;align-items:center;gap:.25rem;flex-shrink:0}.drizzle-cube-portlet-control-button{padding:.25rem;background:transparent;border:none;border-radius:.25rem;color:#6b7280;cursor:pointer;transition:background-color .15s ease-in-out}.drizzle-cube-portlet-control-button:hover{background:#e5e7eb}.drizzle-cube-portlet-content{padding:.75rem;flex:1;min-height:0;display:flex;flex-direction:column}.drizzle-cube-spinner{border:2px solid #f3f4f6;border-top:2px solid #3b82f6;border-radius:50%;width:2rem;height:2rem;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.drizzle-cube-error{color:#dc2626;text-align:center;padding:1rem}.drizzle-cube-empty-state{color:#6b7280;text-align:center;padding:2rem}.drizzle-cube-modal-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;background-color:#00000080;z-index:9999;display:flex;align-items:center;justify-content:center;padding:1rem}.drizzle-cube-modal{background:#fff;border-radius:.5rem;box-shadow:0 25px 50px -12px #00000040;max-height:90vh;max-width:90vw;width:100%;display:flex;flex-direction:column;overflow:hidden;padding:1.5rem}.drizzle-cube-modal-sm{max-width:24rem}.drizzle-cube-modal-md{max-width:42rem}.drizzle-cube-modal-lg{max-width:56rem}.drizzle-cube-modal-xl{max-width:72rem}.drizzle-cube-modal-full{max-width:none;width:100%;height:100%;max-height:none}.drizzle-cube-modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem;flex-shrink:0}.drizzle-cube-modal-title{font-weight:600;font-size:1.25rem;margin:0;color:#111827}.drizzle-cube-modal-close{background:transparent;border:none;color:#9ca3af;cursor:pointer;padding:.25rem;border-radius:.25rem;transition:color .15s ease-in-out}.drizzle-cube-modal-close:hover{color:#4b5563}.drizzle-cube-modal-content{flex:1;overflow-y:auto}.drizzle-cube-modal-footer{display:flex;justify-content:flex-end;gap:.75rem;margin-top:1.5rem;flex-shrink:0}.drizzle-cube-portlet-content>div{flex:1;min-height:0}@media (max-width: 768px){.drizzle-cube-portlet-header,.drizzle-cube-portlet-content{padding:.5rem}.drizzle-cube-portlet-title{font-size:.8125rem}.drizzle-cube-modal-backdrop{padding:.5rem}.drizzle-cube-modal{padding:1rem}}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for drizzle-cube client components
|
|
3
|
+
*/
|
|
4
|
+
export type ChartType = 'line' | 'bar' | 'pie' | 'table' | 'area' | 'scatter' | 'radar' | 'radialBar' | 'treemap';
|
|
5
|
+
export interface ChartAxisConfig {
|
|
6
|
+
xAxis?: string[];
|
|
7
|
+
yAxis?: string[];
|
|
8
|
+
series?: string[];
|
|
9
|
+
x?: string;
|
|
10
|
+
y?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface ChartDisplayConfig {
|
|
13
|
+
showLegend?: boolean;
|
|
14
|
+
showGrid?: boolean;
|
|
15
|
+
showTooltip?: boolean;
|
|
16
|
+
colors?: string[];
|
|
17
|
+
orientation?: 'horizontal' | 'vertical';
|
|
18
|
+
stacked?: boolean;
|
|
19
|
+
stackedBarChart?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface PortletConfig {
|
|
22
|
+
id: string;
|
|
23
|
+
title: string;
|
|
24
|
+
query: string;
|
|
25
|
+
chartType: ChartType;
|
|
26
|
+
chartConfig?: ChartAxisConfig;
|
|
27
|
+
displayConfig?: ChartDisplayConfig;
|
|
28
|
+
w: number;
|
|
29
|
+
h: number;
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}
|
|
33
|
+
export interface DashboardConfig {
|
|
34
|
+
portlets: PortletConfig[];
|
|
35
|
+
layouts?: {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface CubeQuery {
|
|
40
|
+
measures?: string[];
|
|
41
|
+
dimensions?: string[];
|
|
42
|
+
timeDimensions?: Array<{
|
|
43
|
+
dimension: string;
|
|
44
|
+
granularity?: string;
|
|
45
|
+
dateRange?: string[] | string;
|
|
46
|
+
}>;
|
|
47
|
+
filters?: Array<{
|
|
48
|
+
member: string;
|
|
49
|
+
operator: string;
|
|
50
|
+
values: any[];
|
|
51
|
+
}>;
|
|
52
|
+
order?: {
|
|
53
|
+
[key: string]: 'asc' | 'desc';
|
|
54
|
+
};
|
|
55
|
+
limit?: number;
|
|
56
|
+
offset?: number;
|
|
57
|
+
segments?: string[];
|
|
58
|
+
}
|
|
59
|
+
export interface CubeQueryOptions {
|
|
60
|
+
skip?: boolean;
|
|
61
|
+
resetResultSetOnChange?: boolean;
|
|
62
|
+
subscribe?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface CubeApiOptions {
|
|
65
|
+
apiUrl?: string;
|
|
66
|
+
token?: string;
|
|
67
|
+
headers?: Record<string, string>;
|
|
68
|
+
}
|
|
69
|
+
export interface CubeResultSet {
|
|
70
|
+
rawData(): any[];
|
|
71
|
+
tablePivot(): any[];
|
|
72
|
+
series(): any[];
|
|
73
|
+
annotation(): any;
|
|
74
|
+
loadResponse?: any;
|
|
75
|
+
}
|
|
76
|
+
export interface AnalyticsPortletProps {
|
|
77
|
+
query: string;
|
|
78
|
+
chartType: ChartType;
|
|
79
|
+
chartConfig?: ChartAxisConfig;
|
|
80
|
+
displayConfig?: ChartDisplayConfig;
|
|
81
|
+
height?: string | number;
|
|
82
|
+
title?: string;
|
|
83
|
+
}
|
|
84
|
+
export interface AnalyticsDashboardProps {
|
|
85
|
+
config: DashboardConfig;
|
|
86
|
+
apiUrl?: string;
|
|
87
|
+
apiOptions?: CubeApiOptions;
|
|
88
|
+
editable?: boolean;
|
|
89
|
+
onConfigChange?: (config: DashboardConfig) => void;
|
|
90
|
+
onSave?: (config: DashboardConfig) => Promise<void> | void;
|
|
91
|
+
onDirtyStateChange?: (isDirty: boolean) => void;
|
|
92
|
+
}
|
|
93
|
+
export interface ChartProps {
|
|
94
|
+
data: any[];
|
|
95
|
+
chartConfig?: ChartAxisConfig;
|
|
96
|
+
displayConfig?: ChartDisplayConfig;
|
|
97
|
+
queryObject?: CubeQuery;
|
|
98
|
+
height?: string | number;
|
|
99
|
+
}
|
|
100
|
+
export interface GridLayout {
|
|
101
|
+
i: string;
|
|
102
|
+
x: number;
|
|
103
|
+
y: number;
|
|
104
|
+
w: number;
|
|
105
|
+
h: number;
|
|
106
|
+
minW?: number;
|
|
107
|
+
minH?: number;
|
|
108
|
+
}
|
|
109
|
+
export interface ResponsiveLayout {
|
|
110
|
+
[breakpoint: string]: GridLayout[];
|
|
111
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const CHART_COLORS: string[];
|
|
2
|
+
export declare const POSITIVE_COLOR = "#10b981";
|
|
3
|
+
export declare const NEGATIVE_COLOR = "#ef4444";
|
|
4
|
+
export declare const CHART_MARGINS: {
|
|
5
|
+
top: number;
|
|
6
|
+
right: number;
|
|
7
|
+
left: number;
|
|
8
|
+
bottom: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const RESPONSIVE_CHART_MARGINS: {
|
|
11
|
+
top: number;
|
|
12
|
+
right: number;
|
|
13
|
+
left: number;
|
|
14
|
+
bottom: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function formatTimeValue(value: any, granularity?: string): string;
|
|
2
|
+
export declare function getFieldGranularity(queryObject: any, fieldName: string): string | undefined;
|
|
3
|
+
export declare function transformChartData(data: any[], xAxisField: string, yAxisFields: string[], queryObject: any): any[];
|
|
4
|
+
export interface ChartSeriesResult {
|
|
5
|
+
data: any[];
|
|
6
|
+
seriesKeys: string[];
|
|
7
|
+
hasDimensions: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function transformChartDataWithSeries(data: any[], xAxisField: string, yAxisFields: string[], queryObject: any, seriesFields?: string[]): ChartSeriesResult;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { PortletConfig, DashboardConfig } from '../types';
|
|
2
|
+
export * from './chartUtils';
|
|
3
|
+
export * from './chartConstants';
|
|
4
|
+
/**
|
|
5
|
+
* Create a dashboard layout from portlet configurations
|
|
6
|
+
*/
|
|
7
|
+
export declare function createDashboardLayout(portlets: PortletConfig[]): DashboardConfig;
|
|
8
|
+
/**
|
|
9
|
+
* Generate responsive layouts for different breakpoints
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateResponsiveLayouts(portlets: PortletConfig[]): {
|
|
12
|
+
lg: {
|
|
13
|
+
i: string;
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
w: number;
|
|
17
|
+
h: number;
|
|
18
|
+
minW: number;
|
|
19
|
+
minH: number;
|
|
20
|
+
}[];
|
|
21
|
+
md: {
|
|
22
|
+
w: number;
|
|
23
|
+
i: string;
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
h: number;
|
|
27
|
+
minW: number;
|
|
28
|
+
minH: number;
|
|
29
|
+
}[];
|
|
30
|
+
sm: {
|
|
31
|
+
w: number;
|
|
32
|
+
i: string;
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
h: number;
|
|
36
|
+
minW: number;
|
|
37
|
+
minH: number;
|
|
38
|
+
}[];
|
|
39
|
+
xs: {
|
|
40
|
+
w: number;
|
|
41
|
+
i: string;
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
h: number;
|
|
45
|
+
minW: number;
|
|
46
|
+
minH: number;
|
|
47
|
+
}[];
|
|
48
|
+
xxs: {
|
|
49
|
+
w: number;
|
|
50
|
+
i: string;
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
h: number;
|
|
54
|
+
minW: number;
|
|
55
|
+
minH: number;
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Format chart data for display
|
|
60
|
+
*/
|
|
61
|
+
export declare function formatChartData(data: any[], options?: {
|
|
62
|
+
formatNumbers?: boolean;
|
|
63
|
+
precision?: number;
|
|
64
|
+
}): any[];
|
|
65
|
+
/**
|
|
66
|
+
* Generate a unique ID for new portlets
|
|
67
|
+
*/
|
|
68
|
+
export declare function generatePortletId(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Find the next available position in a grid
|
|
71
|
+
*/
|
|
72
|
+
export declare function findNextPosition(existingPortlets: PortletConfig[], _w?: number, _h?: number): {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Validate a cube query JSON string
|
|
78
|
+
*/
|
|
79
|
+
export declare function validateCubeQuery(queryString: string): {
|
|
80
|
+
valid: boolean;
|
|
81
|
+
error?: string;
|
|
82
|
+
query?: any;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Create a sample portlet configuration
|
|
86
|
+
*/
|
|
87
|
+
export declare function createSamplePortlet(): Omit<PortletConfig, 'id'>;
|