drizzle-cube 0.1.9 → 0.1.11
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/hono/index.js +39 -31
- package/dist/client/charts/chartConfigRegistry.d.ts +5 -0
- package/dist/client/charts/chartConfigs.d.ts +60 -0
- package/dist/client/components/AxisDropZone.d.ts +20 -0
- package/dist/client/components/ChartConfigPanel.d.ts +15 -0
- package/dist/client/components/ChartTypeSelector.d.ts +8 -0
- package/dist/client/components/DebugModal.d.ts +9 -0
- package/dist/client/components/Modal.d.ts +1 -1
- package/dist/client/components/charts/AreaChart.config.d.ts +5 -0
- package/dist/client/components/charts/BarChart.config.d.ts +5 -0
- package/dist/client/components/charts/BubbleChart.config.d.ts +5 -0
- package/dist/client/components/charts/BubbleChart.d.ts +2 -0
- package/dist/client/components/charts/DataTable.config.d.ts +5 -0
- package/dist/client/components/charts/DataTable.d.ts +1 -1
- package/dist/client/components/charts/LineChart.config.d.ts +5 -0
- package/dist/client/components/charts/PieChart.config.d.ts +5 -0
- package/dist/client/components/charts/RadarChart.config.d.ts +5 -0
- package/dist/client/components/charts/RadialBarChart.config.d.ts +5 -0
- package/dist/client/components/charts/ScatterChart.config.d.ts +5 -0
- package/dist/client/components/charts/TreeMapChart.config.d.ts +5 -0
- package/dist/client/components/charts/index.d.ts +1 -0
- package/dist/client/hooks/useCubeMeta.d.ts +29 -0
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +13735 -10142
- package/dist/client/providers/CubeProvider.d.ts +7 -0
- package/dist/client/styles.css +1 -1
- package/dist/client/types.d.ts +14 -2
- package/dist/client/utils/chartConstants.d.ts +1 -0
- package/dist/client/utils/chartUtils.d.ts +6 -2
- package/dist/server/index.d.ts +96 -8
- package/dist/server/index.js +894 -632
- package/package.json +10 -3
- package/dist/client/components/ChartConfigEditor.d.ts +0 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Hono as D } from "hono";
|
|
2
2
|
var S = (q) => {
|
|
3
|
-
const
|
|
3
|
+
const c = {
|
|
4
4
|
...{
|
|
5
5
|
origin: "*",
|
|
6
6
|
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"],
|
|
@@ -8,22 +8,22 @@ var S = (q) => {
|
|
|
8
8
|
exposeHeaders: []
|
|
9
9
|
},
|
|
10
10
|
...q
|
|
11
|
-
},
|
|
11
|
+
}, v = /* @__PURE__ */ ((u) => typeof u == "string" ? u === "*" ? () => u : (n) => u === n ? n : null : typeof u == "function" ? u : (n) => u.includes(n) ? n : null)(c.origin), j = ((u) => typeof u == "function" ? u : Array.isArray(u) ? () => u : () => [])(c.allowMethods);
|
|
12
12
|
return async function(n, m) {
|
|
13
13
|
var x;
|
|
14
14
|
function p(h, f) {
|
|
15
15
|
n.res.headers.set(h, f);
|
|
16
16
|
}
|
|
17
|
-
const b =
|
|
18
|
-
if (b && p("Access-Control-Allow-Origin", b),
|
|
17
|
+
const b = v(n.req.header("origin") || "", n);
|
|
18
|
+
if (b && p("Access-Control-Allow-Origin", b), c.origin !== "*") {
|
|
19
19
|
const h = n.req.header("Vary");
|
|
20
20
|
h ? p("Vary", h) : p("Vary", "Origin");
|
|
21
21
|
}
|
|
22
|
-
if (
|
|
23
|
-
|
|
22
|
+
if (c.credentials && p("Access-Control-Allow-Credentials", "true"), (x = c.exposeHeaders) != null && x.length && p("Access-Control-Expose-Headers", c.exposeHeaders.join(",")), n.req.method === "OPTIONS") {
|
|
23
|
+
c.maxAge != null && p("Access-Control-Max-Age", c.maxAge.toString());
|
|
24
24
|
const h = j(n.req.header("origin") || "", n);
|
|
25
25
|
h.length && p("Access-Control-Allow-Methods", h.join(","));
|
|
26
|
-
let f =
|
|
26
|
+
let f = c.allowHeaders;
|
|
27
27
|
if (!(f != null && f.length)) {
|
|
28
28
|
const e = n.req.header("Access-Control-Request-Headers");
|
|
29
29
|
e && (f = e.split(/\s*,\s*/));
|
|
@@ -40,13 +40,13 @@ var S = (q) => {
|
|
|
40
40
|
function E(q) {
|
|
41
41
|
const {
|
|
42
42
|
semanticLayer: a,
|
|
43
|
-
drizzle:
|
|
44
|
-
schema:
|
|
43
|
+
drizzle: c,
|
|
44
|
+
schema: v,
|
|
45
45
|
getSecurityContext: j,
|
|
46
46
|
cors: u,
|
|
47
47
|
basePath: n = "/cubejs-api/v1"
|
|
48
48
|
} = q, m = new D();
|
|
49
|
-
u && m.use("/*", S(u)), a.hasExecutor() || a.setDrizzle(
|
|
49
|
+
u && m.use("/*", S(u)), a.hasExecutor() || a.setDrizzle(c, v), m.post(`${n}/load`, async (e) => {
|
|
50
50
|
try {
|
|
51
51
|
const r = await e.req.json(), s = r.query || r, t = await j(e), o = a.validateQuery(s);
|
|
52
52
|
if (!o.isValid)
|
|
@@ -88,7 +88,15 @@ function E(q) {
|
|
|
88
88
|
return e.json({
|
|
89
89
|
error: "Query parameter is required"
|
|
90
90
|
}, 400);
|
|
91
|
-
|
|
91
|
+
let s;
|
|
92
|
+
try {
|
|
93
|
+
s = JSON.parse(r);
|
|
94
|
+
} catch {
|
|
95
|
+
return e.json({
|
|
96
|
+
error: "Invalid JSON in query parameter"
|
|
97
|
+
}, 400);
|
|
98
|
+
}
|
|
99
|
+
const t = await j(e), o = a.validateQuery(s);
|
|
92
100
|
if (!o.isValid)
|
|
93
101
|
return e.json({
|
|
94
102
|
error: `Query validation failed: ${o.errors.join(", ")}`
|
|
@@ -229,23 +237,23 @@ function E(q) {
|
|
|
229
237
|
return "postgres";
|
|
230
238
|
}
|
|
231
239
|
async function f(e, r) {
|
|
232
|
-
var y, g, Q,
|
|
240
|
+
var y, g, Q, A;
|
|
233
241
|
const s = a.validateQuery(e);
|
|
234
242
|
if (!s.isValid)
|
|
235
243
|
throw new Error(`Query validation failed: ${s.errors.join(", ")}`);
|
|
236
244
|
const t = /* @__PURE__ */ new Set();
|
|
237
|
-
(y = e.measures) == null || y.forEach((
|
|
238
|
-
const w =
|
|
245
|
+
(y = e.measures) == null || y.forEach((d) => {
|
|
246
|
+
const w = d.split(".")[0];
|
|
239
247
|
t.add(w);
|
|
240
|
-
}), (g = e.dimensions) == null || g.forEach((
|
|
241
|
-
const w =
|
|
248
|
+
}), (g = e.dimensions) == null || g.forEach((d) => {
|
|
249
|
+
const w = d.split(".")[0];
|
|
242
250
|
t.add(w);
|
|
243
|
-
}), (Q = e.timeDimensions) == null || Q.forEach((
|
|
244
|
-
const w =
|
|
251
|
+
}), (Q = e.timeDimensions) == null || Q.forEach((d) => {
|
|
252
|
+
const w = d.dimension.split(".")[0];
|
|
245
253
|
t.add(w);
|
|
246
|
-
}), (
|
|
247
|
-
if ("member" in
|
|
248
|
-
const w =
|
|
254
|
+
}), (A = e.filters) == null || A.forEach((d) => {
|
|
255
|
+
if ("member" in d) {
|
|
256
|
+
const w = d.member.split(".")[0];
|
|
249
257
|
t.add(w);
|
|
250
258
|
}
|
|
251
259
|
});
|
|
@@ -254,16 +262,16 @@ function E(q) {
|
|
|
254
262
|
if (o)
|
|
255
263
|
i = await a.generateMultiCubeSQL(e, r);
|
|
256
264
|
else {
|
|
257
|
-
const
|
|
258
|
-
i = await a.generateSQL(
|
|
265
|
+
const d = Array.from(t)[0];
|
|
266
|
+
i = await a.generateSQL(d, e, r);
|
|
259
267
|
}
|
|
260
|
-
const l = Array.from(t).map((
|
|
268
|
+
const l = Array.from(t).map((d) => {
|
|
261
269
|
var w, T;
|
|
262
270
|
return {
|
|
263
|
-
cube:
|
|
271
|
+
cube: d,
|
|
264
272
|
query: {
|
|
265
|
-
measures: ((w = e.measures) == null ? void 0 : w.filter((C) => C.startsWith(
|
|
266
|
-
dimensions: ((T = e.dimensions) == null ? void 0 : T.filter((C) => C.startsWith(
|
|
273
|
+
measures: ((w = e.measures) == null ? void 0 : w.filter((C) => C.startsWith(d + "."))) || [],
|
|
274
|
+
dimensions: ((T = e.dimensions) == null ? void 0 : T.filter((C) => C.startsWith(d + "."))) || [],
|
|
267
275
|
filters: e.filters || [],
|
|
268
276
|
timeDimensions: e.timeDimensions || [],
|
|
269
277
|
order: e.order || {},
|
|
@@ -321,15 +329,15 @@ function E(q) {
|
|
|
321
329
|
}), m;
|
|
322
330
|
}
|
|
323
331
|
function M(q, a) {
|
|
324
|
-
const
|
|
325
|
-
return q.route("/",
|
|
332
|
+
const c = E(a);
|
|
333
|
+
return q.route("/", c), q;
|
|
326
334
|
}
|
|
327
|
-
function
|
|
335
|
+
function N(q) {
|
|
328
336
|
const a = new D();
|
|
329
337
|
return M(a, q);
|
|
330
338
|
}
|
|
331
339
|
export {
|
|
332
|
-
|
|
340
|
+
N as createCubeApp,
|
|
333
341
|
E as createCubeRoutes,
|
|
334
342
|
M as mountCubeRoutes
|
|
335
343
|
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for a single axis drop zone in the chart configuration UI
|
|
4
|
+
*/
|
|
5
|
+
export interface AxisDropZoneConfig {
|
|
6
|
+
/** The key to store this field in chartConfig (e.g., 'xAxis', 'yAxis', 'sizeField') */
|
|
7
|
+
key: string;
|
|
8
|
+
/** Display label for the drop zone */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Optional description/help text shown below the label */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** Whether at least one field is required in this drop zone */
|
|
13
|
+
mandatory?: boolean;
|
|
14
|
+
/** Maximum number of items allowed in this drop zone */
|
|
15
|
+
maxItems?: number;
|
|
16
|
+
/** Which field types this drop zone accepts */
|
|
17
|
+
acceptTypes?: ('dimension' | 'timeDimension' | 'measure')[];
|
|
18
|
+
/** Optional icon component to display */
|
|
19
|
+
icon?: ComponentType<{
|
|
20
|
+
className?: string;
|
|
21
|
+
}>;
|
|
22
|
+
/** Placeholder text when drop zone is empty */
|
|
23
|
+
emptyText?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Complete configuration for a chart type
|
|
27
|
+
*/
|
|
28
|
+
export interface ChartTypeConfig {
|
|
29
|
+
/** Configuration for each drop zone */
|
|
30
|
+
dropZones: AxisDropZoneConfig[];
|
|
31
|
+
/** Which display options to show for this chart type */
|
|
32
|
+
displayOptions?: string[];
|
|
33
|
+
/** Optional custom validation function */
|
|
34
|
+
validate?: (config: any) => {
|
|
35
|
+
isValid: boolean;
|
|
36
|
+
message?: string;
|
|
37
|
+
};
|
|
38
|
+
/** Icon component for the chart type */
|
|
39
|
+
icon?: ComponentType<{
|
|
40
|
+
className?: string;
|
|
41
|
+
}>;
|
|
42
|
+
/** Brief description of the chart */
|
|
43
|
+
description?: string;
|
|
44
|
+
/** When to use this chart type */
|
|
45
|
+
useCase?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Registry of all chart type configurations
|
|
49
|
+
*/
|
|
50
|
+
export interface ChartConfigRegistry {
|
|
51
|
+
[chartType: string]: ChartTypeConfig;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Default configuration for charts without specific requirements
|
|
55
|
+
*/
|
|
56
|
+
export declare const defaultChartConfig: ChartTypeConfig;
|
|
57
|
+
/**
|
|
58
|
+
* Helper function to get configuration for a chart type
|
|
59
|
+
*/
|
|
60
|
+
export declare function getChartConfig(chartType: string, registry: ChartConfigRegistry): ChartTypeConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AxisDropZoneConfig } from '../charts/chartConfigs';
|
|
3
|
+
interface FieldStyling {
|
|
4
|
+
IconComponent: React.ComponentType<{
|
|
5
|
+
className?: string;
|
|
6
|
+
}>;
|
|
7
|
+
baseClasses: string;
|
|
8
|
+
hoverClasses: string;
|
|
9
|
+
}
|
|
10
|
+
interface AxisDropZoneProps {
|
|
11
|
+
config: AxisDropZoneConfig;
|
|
12
|
+
fields: string[];
|
|
13
|
+
onDrop: (e: React.DragEvent<HTMLDivElement>, toKey: string) => void;
|
|
14
|
+
onRemove: (field: string, fromKey: string) => void;
|
|
15
|
+
onDragStart: (e: React.DragEvent<HTMLDivElement>, field: string, fromKey: string) => void;
|
|
16
|
+
onDragOver: (e: React.DragEvent<HTMLDivElement>) => void;
|
|
17
|
+
getFieldStyling: (field: string) => FieldStyling;
|
|
18
|
+
}
|
|
19
|
+
export default function AxisDropZone({ config, fields, onDrop, onRemove, onDragStart, onDragOver, getFieldStyling }: AxisDropZoneProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChartType, ChartAxisConfig, ChartDisplayConfig } from '../types';
|
|
2
|
+
interface ChartConfigPanelProps {
|
|
3
|
+
chartType: ChartType;
|
|
4
|
+
chartConfig: ChartAxisConfig;
|
|
5
|
+
displayConfig: ChartDisplayConfig;
|
|
6
|
+
availableFields: {
|
|
7
|
+
dimensions: string[];
|
|
8
|
+
timeDimensions: string[];
|
|
9
|
+
measures: string[];
|
|
10
|
+
} | null;
|
|
11
|
+
onChartConfigChange: (config: ChartAxisConfig) => void;
|
|
12
|
+
onDisplayConfigChange: (config: ChartDisplayConfig) => void;
|
|
13
|
+
}
|
|
14
|
+
export default function ChartConfigPanel({ chartType, chartConfig, displayConfig, availableFields, onChartConfigChange, onDisplayConfigChange }: ChartConfigPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChartType } from '../types';
|
|
2
|
+
interface ChartTypeSelectorProps {
|
|
3
|
+
selectedType: ChartType;
|
|
4
|
+
onTypeChange: (type: ChartType) => void;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export default function ChartTypeSelector({ selectedType, onTypeChange, className }: ChartTypeSelectorProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface DebugModalProps {
|
|
2
|
+
chartConfig: any;
|
|
3
|
+
displayConfig: any;
|
|
4
|
+
queryObject: any;
|
|
5
|
+
data: any[];
|
|
6
|
+
chartType: string;
|
|
7
|
+
}
|
|
8
|
+
export default function DebugModal({ chartConfig, displayConfig, queryObject, data, chartType }: DebugModalProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -3,7 +3,7 @@ export interface ModalProps {
|
|
|
3
3
|
isOpen: boolean;
|
|
4
4
|
onClose: () => void;
|
|
5
5
|
title?: string;
|
|
6
|
-
size?: 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'fullscreen';
|
|
6
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'fullscreen' | 'fullscreen-mobile';
|
|
7
7
|
closeOnBackdropClick?: boolean;
|
|
8
8
|
closeOnEscape?: boolean;
|
|
9
9
|
showCloseButton?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ChartProps } from '../../types';
|
|
2
|
-
export default function DataTable({ data, height }: ChartProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export default function DataTable({ data, chartConfig, height }: ChartProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,4 +10,5 @@ export { default as RechartsScatterChart } from './ScatterChart';
|
|
|
10
10
|
export { default as RechartsRadarChart } from './RadarChart';
|
|
11
11
|
export { default as RechartsRadialBarChart } from './RadialBarChart';
|
|
12
12
|
export { default as RechartsTreeMapChart } from './TreeMapChart';
|
|
13
|
+
export { default as BubbleChart } from './BubbleChart';
|
|
13
14
|
export { default as DataTable } from './DataTable';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CubeClient } from '../client/CubeClient';
|
|
2
|
+
export interface CubeMetaField {
|
|
3
|
+
name: string;
|
|
4
|
+
title: string;
|
|
5
|
+
shortTitle: string;
|
|
6
|
+
type: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CubeMetaCube {
|
|
9
|
+
name: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
measures: CubeMetaField[];
|
|
13
|
+
dimensions: CubeMetaField[];
|
|
14
|
+
segments: CubeMetaField[];
|
|
15
|
+
}
|
|
16
|
+
export interface CubeMeta {
|
|
17
|
+
cubes: CubeMetaCube[];
|
|
18
|
+
}
|
|
19
|
+
export type FieldLabelMap = Record<string, string>;
|
|
20
|
+
interface UseCubeMetaResult {
|
|
21
|
+
meta: CubeMeta | null;
|
|
22
|
+
labelMap: FieldLabelMap;
|
|
23
|
+
loading: boolean;
|
|
24
|
+
error: string | null;
|
|
25
|
+
refetch: () => void;
|
|
26
|
+
getFieldLabel: (fieldName: string) => string;
|
|
27
|
+
}
|
|
28
|
+
export declare function useCubeMeta(cubeApi: CubeClient): UseCubeMetaResult;
|
|
29
|
+
export {};
|
package/dist/client/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export { default as PortletContainer } from './components/PortletContainer';
|
|
|
6
6
|
export { default as PortletEditModal } from './components/PortletEditModal';
|
|
7
7
|
export { default as DashboardEditModal } from './components/DashboardEditModal';
|
|
8
8
|
export { default as Modal } from './components/Modal';
|
|
9
|
-
export { default as ChartConfigEditor } from './components/ChartConfigEditor';
|
|
10
9
|
export { default as QueryBuilder } from './components/QueryBuilder';
|
|
11
10
|
export { CubeProvider } from './providers/CubeProvider';
|
|
12
11
|
export { useCubeQuery } from './hooks/useCubeQuery';
|