drizzle-cube 0.1.42 → 0.1.44
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-B57cLx38.js → compiler-DdaSPwZs.js} +25 -8
- package/dist/adapters/express/index.js +84 -63
- package/dist/adapters/fastify/index.js +108 -73
- package/dist/adapters/hono/index.js +62 -44
- package/dist/adapters/nextjs/index.d.ts +6 -0
- package/dist/adapters/nextjs/index.js +145 -108
- package/dist/adapters/utils.d.ts +46 -0
- package/dist/client/charts.js +1 -1
- package/dist/client/chunks/{charts-VcPFhxyE.js → charts-CfbqkXfS.js} +415 -425
- package/dist/client/chunks/charts-CfbqkXfS.js.map +1 -0
- package/dist/client/chunks/{components-DzCsplX7.js → components-B0Wk5TCQ.js} +8814 -7851
- package/dist/client/chunks/components-B0Wk5TCQ.js.map +1 -0
- package/dist/client/chunks/{icons-MNJ50ahP.js → icons-oifcbJCc.js} +309 -255
- package/dist/client/chunks/icons-oifcbJCc.js.map +1 -0
- package/dist/client/chunks/providers-aaWIe5KD.js +304 -0
- package/dist/client/chunks/providers-aaWIe5KD.js.map +1 -0
- package/dist/client/client/BatchCoordinator.d.ts +35 -0
- package/dist/client/client/CubeClient.d.ts +5 -0
- package/dist/client/components/AnalyticsDashboard.d.ts +1 -1
- package/dist/client/components/DashboardFilterPanel.d.ts +15 -0
- package/dist/client/components/DashboardFilters/EditModeFilterList.d.ts +12 -0
- package/dist/client/components/DashboardFilters/FilterEditModal.d.ts +15 -0
- package/dist/client/components/DashboardFilters/ReadOnlyFilterList.d.ts +13 -0
- package/dist/client/components/DashboardGrid.d.ts +5 -2
- package/dist/client/components/PortletFilterConfigModal.d.ts +11 -0
- package/dist/client/components/QueryBuilder/DateRangeSelector.d.ts +2 -0
- package/dist/client/components/QueryBuilder/types.d.ts +3 -0
- package/dist/client/components.js +2 -2
- package/dist/client/hooks.js +61 -61
- package/dist/client/hooks.js.map +1 -1
- package/dist/client/index.js +3 -3
- package/dist/client/providers/CubeProvider.d.ts +5 -0
- package/dist/client/providers.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client/types.d.ts +14 -0
- package/dist/client/utils/filterUtils.d.ts +40 -0
- package/dist/client-bundle-stats.html +1 -1
- package/package.json +1 -1
- package/dist/client/chunks/charts-VcPFhxyE.js.map +0 -1
- package/dist/client/chunks/components-DzCsplX7.js.map +0 -1
- package/dist/client/chunks/icons-MNJ50ahP.js.map +0 -1
- package/dist/client/chunks/providers-DwDirAYo.js +0 -208
- package/dist/client/chunks/providers-DwDirAYo.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Hono as w } from "hono";
|
|
2
|
-
import { S as x, f as
|
|
3
|
-
var
|
|
2
|
+
import { S as x, f as j, h as Q, a as b, b as g, c as p } from "../compiler-DdaSPwZs.js";
|
|
3
|
+
var A = (y) => {
|
|
4
4
|
const u = {
|
|
5
5
|
...{
|
|
6
6
|
origin: "*",
|
|
@@ -8,8 +8,8 @@ var v = (d) => {
|
|
|
8
8
|
allowHeaders: [],
|
|
9
9
|
exposeHeaders: []
|
|
10
10
|
},
|
|
11
|
-
...
|
|
12
|
-
}, h = /* @__PURE__ */ ((
|
|
11
|
+
...y
|
|
12
|
+
}, h = /* @__PURE__ */ ((i) => typeof i == "string" ? i === "*" ? () => i : (o) => i === o ? o : null : typeof i == "function" ? i : (o) => i.includes(o) ? o : null)(u.origin), d = ((i) => typeof i == "function" ? i : Array.isArray(i) ? () => i : () => [])(u.allowMethods);
|
|
13
13
|
return async function(o, c) {
|
|
14
14
|
function n(r, e) {
|
|
15
15
|
o.res.headers.set(r, e);
|
|
@@ -17,7 +17,7 @@ var v = (d) => {
|
|
|
17
17
|
const s = await h(o.req.header("origin") || "", o);
|
|
18
18
|
if (s && n("Access-Control-Allow-Origin", s), u.credentials && n("Access-Control-Allow-Credentials", "true"), u.exposeHeaders?.length && n("Access-Control-Expose-Headers", u.exposeHeaders.join(",")), o.req.method === "OPTIONS") {
|
|
19
19
|
u.origin !== "*" && n("Vary", "Origin"), u.maxAge != null && n("Access-Control-Max-Age", u.maxAge.toString());
|
|
20
|
-
const r = await
|
|
20
|
+
const r = await d(o.req.header("origin") || "", o);
|
|
21
21
|
r.length && n("Access-Control-Allow-Methods", r.join(","));
|
|
22
22
|
let e = u.allowHeaders;
|
|
23
23
|
if (!e?.length) {
|
|
@@ -33,36 +33,36 @@ var v = (d) => {
|
|
|
33
33
|
await c(), u.origin !== "*" && o.header("Vary", "Origin", { append: !0 });
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
-
function
|
|
36
|
+
function v(y) {
|
|
37
37
|
const {
|
|
38
|
-
cubes:
|
|
38
|
+
cubes: f,
|
|
39
39
|
drizzle: u,
|
|
40
40
|
schema: h,
|
|
41
|
-
extractSecurityContext:
|
|
42
|
-
engineType:
|
|
41
|
+
extractSecurityContext: d,
|
|
42
|
+
engineType: i,
|
|
43
43
|
cors: o,
|
|
44
44
|
basePath: c = "/cubejs-api/v1"
|
|
45
|
-
} =
|
|
46
|
-
if (!
|
|
45
|
+
} = y;
|
|
46
|
+
if (!f || f.length === 0)
|
|
47
47
|
throw new Error("At least one cube must be provided in the cubes array");
|
|
48
48
|
const n = new w();
|
|
49
|
-
o && n.use("/*",
|
|
49
|
+
o && n.use("/*", A(o));
|
|
50
50
|
const s = new x({
|
|
51
51
|
drizzle: u,
|
|
52
52
|
schema: h,
|
|
53
|
-
engineType:
|
|
53
|
+
engineType: i
|
|
54
54
|
});
|
|
55
|
-
return
|
|
55
|
+
return f.forEach((r) => {
|
|
56
56
|
s.registerCube(r);
|
|
57
57
|
}), n.post(`${c}/load`, async (r) => {
|
|
58
58
|
try {
|
|
59
|
-
const e = await r.req.json(), t = e.query || e, l = await
|
|
60
|
-
if (!
|
|
59
|
+
const e = await r.req.json(), t = e.query || e, l = await d(r), a = s.validateQuery(t);
|
|
60
|
+
if (!a.isValid)
|
|
61
61
|
return r.json({
|
|
62
|
-
error: `Query validation failed: ${
|
|
62
|
+
error: `Query validation failed: ${a.errors.join(", ")}`
|
|
63
63
|
}, 400);
|
|
64
64
|
const m = await s.executeMultiCubeQuery(t, l);
|
|
65
|
-
return r.json(
|
|
65
|
+
return r.json(j(t, m, s));
|
|
66
66
|
} catch (e) {
|
|
67
67
|
return console.error("Query execution error:", e), r.json({
|
|
68
68
|
error: e instanceof Error ? e.message : "Query execution failed"
|
|
@@ -83,22 +83,40 @@ function A(d) {
|
|
|
83
83
|
error: "Invalid JSON in query parameter"
|
|
84
84
|
}, 400);
|
|
85
85
|
}
|
|
86
|
-
const l = await
|
|
87
|
-
if (!
|
|
86
|
+
const l = await d(r), a = s.validateQuery(t);
|
|
87
|
+
if (!a.isValid)
|
|
88
88
|
return r.json({
|
|
89
|
-
error: `Query validation failed: ${
|
|
89
|
+
error: `Query validation failed: ${a.errors.join(", ")}`
|
|
90
90
|
}, 400);
|
|
91
91
|
const m = await s.executeMultiCubeQuery(t, l);
|
|
92
|
-
return r.json(
|
|
92
|
+
return r.json(j(t, m, s));
|
|
93
93
|
} catch (e) {
|
|
94
94
|
return console.error("Query execution error:", e), r.json({
|
|
95
95
|
error: e instanceof Error ? e.message : "Query execution failed"
|
|
96
96
|
}, 500);
|
|
97
97
|
}
|
|
98
|
+
}), n.post(`${c}/batch`, async (r) => {
|
|
99
|
+
try {
|
|
100
|
+
const e = await r.req.json(), { queries: t } = e;
|
|
101
|
+
if (!t || !Array.isArray(t))
|
|
102
|
+
return r.json({
|
|
103
|
+
error: 'Request body must contain a "queries" array'
|
|
104
|
+
}, 400);
|
|
105
|
+
if (t.length === 0)
|
|
106
|
+
return r.json({
|
|
107
|
+
error: "Queries array cannot be empty"
|
|
108
|
+
}, 400);
|
|
109
|
+
const l = await d(r), a = await Q(t, l, s);
|
|
110
|
+
return r.json(a);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
return console.error("Batch execution error:", e), r.json({
|
|
113
|
+
error: e instanceof Error ? e.message : "Batch execution failed"
|
|
114
|
+
}, 500);
|
|
115
|
+
}
|
|
98
116
|
}), n.get(`${c}/meta`, (r) => {
|
|
99
117
|
try {
|
|
100
118
|
const e = s.getMetadata();
|
|
101
|
-
return r.json(
|
|
119
|
+
return r.json(b(e));
|
|
102
120
|
} catch (e) {
|
|
103
121
|
return console.error("Metadata error:", e), r.json({
|
|
104
122
|
error: e instanceof Error ? e.message : "Failed to fetch metadata"
|
|
@@ -106,18 +124,18 @@ function A(d) {
|
|
|
106
124
|
}
|
|
107
125
|
}), n.post(`${c}/sql`, async (r) => {
|
|
108
126
|
try {
|
|
109
|
-
const e = await r.req.json(), t = await
|
|
127
|
+
const e = await r.req.json(), t = await d(r), l = s.validateQuery(e);
|
|
110
128
|
if (!l.isValid)
|
|
111
129
|
return r.json({
|
|
112
130
|
error: `Query validation failed: ${l.errors.join(", ")}`
|
|
113
131
|
}, 400);
|
|
114
|
-
const
|
|
115
|
-
if (!
|
|
132
|
+
const a = e.measures?.[0] || e.dimensions?.[0];
|
|
133
|
+
if (!a)
|
|
116
134
|
return r.json({
|
|
117
135
|
error: "No measures or dimensions specified"
|
|
118
136
|
}, 400);
|
|
119
|
-
const m =
|
|
120
|
-
return r.json(
|
|
137
|
+
const m = a.split(".")[0], q = await s.generateSQL(m, e, t);
|
|
138
|
+
return r.json(g(e, q));
|
|
121
139
|
} catch (e) {
|
|
122
140
|
return console.error("SQL generation error:", e), r.json({
|
|
123
141
|
error: e instanceof Error ? e.message : "SQL generation failed"
|
|
@@ -130,10 +148,10 @@ function A(d) {
|
|
|
130
148
|
return r.json({
|
|
131
149
|
error: "Query parameter is required"
|
|
132
150
|
}, 400);
|
|
133
|
-
const t = JSON.parse(e), l = await
|
|
134
|
-
if (!
|
|
151
|
+
const t = JSON.parse(e), l = await d(r), a = s.validateQuery(t);
|
|
152
|
+
if (!a.isValid)
|
|
135
153
|
return r.json({
|
|
136
|
-
error: `Query validation failed: ${
|
|
154
|
+
error: `Query validation failed: ${a.errors.join(", ")}`
|
|
137
155
|
}, 400);
|
|
138
156
|
const m = t.measures?.[0] || t.dimensions?.[0];
|
|
139
157
|
if (!m)
|
|
@@ -141,7 +159,7 @@ function A(d) {
|
|
|
141
159
|
error: "No measures or dimensions specified"
|
|
142
160
|
}, 400);
|
|
143
161
|
const q = m.split(".")[0], C = await s.generateSQL(q, t, l);
|
|
144
|
-
return r.json(
|
|
162
|
+
return r.json(g(t, C));
|
|
145
163
|
} catch (e) {
|
|
146
164
|
return console.error("SQL generation error:", e), r.json({
|
|
147
165
|
error: e instanceof Error ? e.message : "SQL generation failed"
|
|
@@ -149,8 +167,8 @@ function A(d) {
|
|
|
149
167
|
}
|
|
150
168
|
}), n.post(`${c}/dry-run`, async (r) => {
|
|
151
169
|
try {
|
|
152
|
-
const e = await r.req.json(), t = e.query || e, l = await
|
|
153
|
-
return r.json(
|
|
170
|
+
const e = await r.req.json(), t = e.query || e, l = await d(r), a = await p(t, l, s);
|
|
171
|
+
return r.json(a);
|
|
154
172
|
} catch (e) {
|
|
155
173
|
return console.error("Dry-run error:", e), r.json({
|
|
156
174
|
error: e instanceof Error ? e.message : "Dry-run validation failed",
|
|
@@ -165,8 +183,8 @@ function A(d) {
|
|
|
165
183
|
error: "Query parameter is required",
|
|
166
184
|
valid: !1
|
|
167
185
|
}, 400);
|
|
168
|
-
const t = JSON.parse(e), l = await
|
|
169
|
-
return r.json(
|
|
186
|
+
const t = JSON.parse(e), l = await d(r), a = await p(t, l, s);
|
|
187
|
+
return r.json(a);
|
|
170
188
|
} catch (e) {
|
|
171
189
|
return console.error("Dry-run error:", e), r.json({
|
|
172
190
|
error: e instanceof Error ? e.message : "Dry-run validation failed",
|
|
@@ -175,16 +193,16 @@ function A(d) {
|
|
|
175
193
|
}
|
|
176
194
|
}), n;
|
|
177
195
|
}
|
|
178
|
-
function
|
|
179
|
-
const u =
|
|
180
|
-
return
|
|
196
|
+
function E(y, f) {
|
|
197
|
+
const u = v(f);
|
|
198
|
+
return y.route("/", u), y;
|
|
181
199
|
}
|
|
182
|
-
function H(
|
|
183
|
-
const
|
|
184
|
-
return
|
|
200
|
+
function H(y) {
|
|
201
|
+
const f = new w();
|
|
202
|
+
return E(f, y);
|
|
185
203
|
}
|
|
186
204
|
export {
|
|
187
205
|
H as createCubeApp,
|
|
188
|
-
|
|
189
|
-
|
|
206
|
+
v as createCubeRoutes,
|
|
207
|
+
E as mountCubeRoutes
|
|
190
208
|
};
|
|
@@ -85,6 +85,7 @@ export interface CubeHandlers {
|
|
|
85
85
|
meta: RouteHandler;
|
|
86
86
|
sql: RouteHandler;
|
|
87
87
|
dryRun: RouteHandler;
|
|
88
|
+
batch: RouteHandler;
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
90
91
|
* Create OPTIONS handler for CORS preflight requests
|
|
@@ -106,6 +107,11 @@ export declare function createSqlHandler(options: NextAdapterOptions): RouteHand
|
|
|
106
107
|
* Create dry-run handler - Validate queries without execution
|
|
107
108
|
*/
|
|
108
109
|
export declare function createDryRunHandler(options: NextAdapterOptions): RouteHandler;
|
|
110
|
+
/**
|
|
111
|
+
* Create batch handler - Execute multiple queries in a single request
|
|
112
|
+
* Optimizes network overhead for dashboards with many portlets
|
|
113
|
+
*/
|
|
114
|
+
export declare function createBatchHandler(options: NextAdapterOptions): RouteHandler;
|
|
109
115
|
/**
|
|
110
116
|
* Convenience function to create all route handlers
|
|
111
117
|
*
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { NextResponse as
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
4
|
-
const { cubes:
|
|
5
|
-
if (!
|
|
1
|
+
import { NextResponse as n } from "next/server";
|
|
2
|
+
import { d as i, f as x, a as E, b as N, c as S, h as b, S as C } from "../compiler-DdaSPwZs.js";
|
|
3
|
+
function j(a) {
|
|
4
|
+
const { cubes: t, drizzle: s, schema: o, engineType: y } = a;
|
|
5
|
+
if (!t || t.length === 0)
|
|
6
6
|
throw new Error("At least one cube must be provided in the cubes array");
|
|
7
|
-
const
|
|
8
|
-
drizzle:
|
|
9
|
-
schema:
|
|
10
|
-
engineType:
|
|
7
|
+
const r = new C({
|
|
8
|
+
drizzle: s,
|
|
9
|
+
schema: o,
|
|
10
|
+
engineType: y
|
|
11
11
|
});
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
}),
|
|
12
|
+
return t.forEach((c) => {
|
|
13
|
+
r.registerCube(c);
|
|
14
|
+
}), r;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
return
|
|
16
|
+
function m(a, t) {
|
|
17
|
+
const s = a.headers.get("origin"), o = {};
|
|
18
|
+
return t.origin && (typeof t.origin == "string" ? o["Access-Control-Allow-Origin"] = t.origin : Array.isArray(t.origin) ? s && t.origin.includes(s) && (o["Access-Control-Allow-Origin"] = s) : typeof t.origin == "function" && s && t.origin(s) && (o["Access-Control-Allow-Origin"] = s)), t.methods && (o["Access-Control-Allow-Methods"] = t.methods.join(", ")), t.allowedHeaders && (o["Access-Control-Allow-Headers"] = t.allowedHeaders.join(", ")), t.credentials && (o["Access-Control-Allow-Credentials"] = "true"), o;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return async function(
|
|
22
|
-
const
|
|
20
|
+
function M(a) {
|
|
21
|
+
return async function(s) {
|
|
22
|
+
const o = m(s, a);
|
|
23
23
|
return new Response(null, {
|
|
24
24
|
status: 200,
|
|
25
|
-
headers:
|
|
25
|
+
headers: o
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function v(
|
|
30
|
-
const { extractSecurityContext:
|
|
31
|
-
return async function(
|
|
29
|
+
function v(a) {
|
|
30
|
+
const { extractSecurityContext: t, cors: s } = a, o = j(a);
|
|
31
|
+
return async function(r, c) {
|
|
32
32
|
try {
|
|
33
33
|
let e;
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
e =
|
|
37
|
-
} else if (
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
40
|
-
return
|
|
41
|
-
|
|
34
|
+
if (r.method === "POST") {
|
|
35
|
+
const f = await r.json();
|
|
36
|
+
e = f.query || f;
|
|
37
|
+
} else if (r.method === "GET") {
|
|
38
|
+
const f = r.nextUrl.searchParams.get("query");
|
|
39
|
+
if (!f)
|
|
40
|
+
return n.json(
|
|
41
|
+
i("Query parameter is required", 400),
|
|
42
42
|
{ status: 400 }
|
|
43
43
|
);
|
|
44
44
|
try {
|
|
45
|
-
e = JSON.parse(
|
|
45
|
+
e = JSON.parse(f);
|
|
46
46
|
} catch {
|
|
47
|
-
return
|
|
48
|
-
|
|
47
|
+
return n.json(
|
|
48
|
+
i("Invalid JSON in query parameter", 400),
|
|
49
49
|
{ status: 400 }
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
} else
|
|
53
|
-
return
|
|
54
|
-
|
|
53
|
+
return n.json(
|
|
54
|
+
i("Method not allowed", 405),
|
|
55
55
|
{ status: 405 }
|
|
56
56
|
);
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
59
|
-
return
|
|
60
|
-
|
|
57
|
+
const l = await t(r, c), d = o.validateQuery(e);
|
|
58
|
+
if (!d.isValid)
|
|
59
|
+
return n.json(
|
|
60
|
+
i(`Query validation failed: ${d.errors.join(", ")}`, 400),
|
|
61
61
|
{ status: 400 }
|
|
62
62
|
);
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
headers:
|
|
63
|
+
const u = await o.executeMultiCubeQuery(e, l), g = x(e, u, o);
|
|
64
|
+
return n.json(g, {
|
|
65
|
+
headers: s ? m(r, s) : {}
|
|
66
66
|
});
|
|
67
67
|
} catch (e) {
|
|
68
|
-
return process.env.NODE_ENV !== "test" && console.error("Next.js load handler error:", e),
|
|
69
|
-
|
|
68
|
+
return process.env.NODE_ENV !== "test" && console.error("Next.js load handler error:", e), n.json(
|
|
69
|
+
i(
|
|
70
70
|
e instanceof Error ? e.message : "Query execution failed",
|
|
71
71
|
500
|
|
72
72
|
),
|
|
@@ -75,18 +75,18 @@ function v(n) {
|
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
const { cors:
|
|
80
|
-
return async function(
|
|
78
|
+
function p(a) {
|
|
79
|
+
const { cors: t } = a, s = j(a);
|
|
80
|
+
return async function(y, r) {
|
|
81
81
|
try {
|
|
82
|
-
const
|
|
83
|
-
return
|
|
84
|
-
headers:
|
|
82
|
+
const c = s.getMetadata(), e = E(c);
|
|
83
|
+
return n.json(e, {
|
|
84
|
+
headers: t ? m(y, t) : {}
|
|
85
85
|
});
|
|
86
|
-
} catch (
|
|
87
|
-
return process.env.NODE_ENV !== "test" && console.error("Next.js meta handler error:",
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
} catch (c) {
|
|
87
|
+
return process.env.NODE_ENV !== "test" && console.error("Next.js meta handler error:", c), n.json(
|
|
88
|
+
i(
|
|
89
|
+
c instanceof Error ? c.message : "Failed to fetch metadata",
|
|
90
90
|
500
|
|
91
91
|
),
|
|
92
92
|
{ status: 500 }
|
|
@@ -94,53 +94,53 @@ function C(n) {
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
function H(
|
|
98
|
-
const { extractSecurityContext:
|
|
99
|
-
return async function(
|
|
97
|
+
function H(a) {
|
|
98
|
+
const { extractSecurityContext: t, cors: s } = a, o = j(a);
|
|
99
|
+
return async function(r, c) {
|
|
100
100
|
try {
|
|
101
101
|
let e;
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
e =
|
|
105
|
-
} else if (
|
|
106
|
-
const
|
|
107
|
-
if (!
|
|
108
|
-
return
|
|
109
|
-
|
|
102
|
+
if (r.method === "POST") {
|
|
103
|
+
const h = await r.json();
|
|
104
|
+
e = h.query || h;
|
|
105
|
+
} else if (r.method === "GET") {
|
|
106
|
+
const h = r.nextUrl.searchParams.get("query");
|
|
107
|
+
if (!h)
|
|
108
|
+
return n.json(
|
|
109
|
+
i("Query parameter is required", 400),
|
|
110
110
|
{ status: 400 }
|
|
111
111
|
);
|
|
112
112
|
try {
|
|
113
|
-
e = JSON.parse(
|
|
113
|
+
e = JSON.parse(h);
|
|
114
114
|
} catch {
|
|
115
|
-
return
|
|
116
|
-
|
|
115
|
+
return n.json(
|
|
116
|
+
i("Invalid JSON in query parameter", 400),
|
|
117
117
|
{ status: 400 }
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
} else
|
|
121
|
-
return
|
|
122
|
-
|
|
121
|
+
return n.json(
|
|
122
|
+
i("Method not allowed", 405),
|
|
123
123
|
{ status: 405 }
|
|
124
124
|
);
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
127
|
-
return
|
|
128
|
-
|
|
125
|
+
const l = await t(r, c), d = o.validateQuery(e);
|
|
126
|
+
if (!d.isValid)
|
|
127
|
+
return n.json(
|
|
128
|
+
i(`Query validation failed: ${d.errors.join(", ")}`, 400),
|
|
129
129
|
{ status: 400 }
|
|
130
130
|
);
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
133
|
-
return
|
|
134
|
-
|
|
131
|
+
const u = e.measures?.[0] || e.dimensions?.[0];
|
|
132
|
+
if (!u)
|
|
133
|
+
return n.json(
|
|
134
|
+
i("No measures or dimensions specified", 400),
|
|
135
135
|
{ status: 400 }
|
|
136
136
|
);
|
|
137
|
-
const
|
|
138
|
-
return
|
|
139
|
-
headers:
|
|
137
|
+
const g = u.split(".")[0], f = await o.generateSQL(g, e, l), w = N(e, f);
|
|
138
|
+
return n.json(w, {
|
|
139
|
+
headers: s ? m(r, s) : {}
|
|
140
140
|
});
|
|
141
141
|
} catch (e) {
|
|
142
|
-
return process.env.NODE_ENV !== "test" && console.error("Next.js SQL handler error:", e),
|
|
143
|
-
|
|
142
|
+
return process.env.NODE_ENV !== "test" && console.error("Next.js SQL handler error:", e), n.json(
|
|
143
|
+
i(
|
|
144
144
|
e instanceof Error ? e.message : "SQL generation failed",
|
|
145
145
|
500
|
|
146
146
|
),
|
|
@@ -149,40 +149,40 @@ function H(n) {
|
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
function A(
|
|
153
|
-
const { extractSecurityContext:
|
|
154
|
-
return async function(
|
|
152
|
+
function A(a) {
|
|
153
|
+
const { extractSecurityContext: t, cors: s } = a, o = j(a);
|
|
154
|
+
return async function(r, c) {
|
|
155
155
|
try {
|
|
156
156
|
let e;
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
e =
|
|
160
|
-
} else if (
|
|
161
|
-
const
|
|
162
|
-
if (!
|
|
163
|
-
return
|
|
157
|
+
if (r.method === "POST") {
|
|
158
|
+
const u = await r.json();
|
|
159
|
+
e = u.query || u;
|
|
160
|
+
} else if (r.method === "GET") {
|
|
161
|
+
const u = r.nextUrl.searchParams.get("query");
|
|
162
|
+
if (!u)
|
|
163
|
+
return n.json(
|
|
164
164
|
{ error: "Query parameter is required", valid: !1 },
|
|
165
165
|
{ status: 400 }
|
|
166
166
|
);
|
|
167
167
|
try {
|
|
168
|
-
e = JSON.parse(
|
|
168
|
+
e = JSON.parse(u);
|
|
169
169
|
} catch {
|
|
170
|
-
return
|
|
170
|
+
return n.json(
|
|
171
171
|
{ error: "Invalid JSON in query parameter", valid: !1 },
|
|
172
172
|
{ status: 400 }
|
|
173
173
|
);
|
|
174
174
|
}
|
|
175
175
|
} else
|
|
176
|
-
return
|
|
176
|
+
return n.json(
|
|
177
177
|
{ error: "Method not allowed", valid: !1 },
|
|
178
178
|
{ status: 405 }
|
|
179
179
|
);
|
|
180
|
-
const
|
|
181
|
-
return
|
|
182
|
-
headers:
|
|
180
|
+
const l = await t(r, c), d = await S(e, l, o);
|
|
181
|
+
return n.json(d, {
|
|
182
|
+
headers: s ? m(r, s) : {}
|
|
183
183
|
});
|
|
184
184
|
} catch (e) {
|
|
185
|
-
return process.env.NODE_ENV !== "test" && console.error("Next.js dry-run handler error:", e),
|
|
185
|
+
return process.env.NODE_ENV !== "test" && console.error("Next.js dry-run handler error:", e), n.json(
|
|
186
186
|
{
|
|
187
187
|
error: e instanceof Error ? e.message : "Dry-run validation failed",
|
|
188
188
|
valid: !1
|
|
@@ -192,19 +192,56 @@ function A(n) {
|
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function R(a) {
|
|
196
|
+
const { extractSecurityContext: t, cors: s } = a, o = j(a);
|
|
197
|
+
return async function(r, c) {
|
|
198
|
+
try {
|
|
199
|
+
if (r.method !== "POST")
|
|
200
|
+
return n.json(
|
|
201
|
+
i("Method not allowed - use POST", 405),
|
|
202
|
+
{ status: 405 }
|
|
203
|
+
);
|
|
204
|
+
const e = await r.json(), { queries: l } = e;
|
|
205
|
+
if (!l || !Array.isArray(l))
|
|
206
|
+
return n.json(
|
|
207
|
+
i('Request body must contain a "queries" array', 400),
|
|
208
|
+
{ status: 400 }
|
|
209
|
+
);
|
|
210
|
+
if (l.length === 0)
|
|
211
|
+
return n.json(
|
|
212
|
+
i("Queries array cannot be empty", 400),
|
|
213
|
+
{ status: 400 }
|
|
214
|
+
);
|
|
215
|
+
const d = await t(r, c), u = await b(l, d, o);
|
|
216
|
+
return n.json(u, {
|
|
217
|
+
headers: s ? m(r, s) : {}
|
|
218
|
+
});
|
|
219
|
+
} catch (e) {
|
|
220
|
+
return process.env.NODE_ENV !== "test" && console.error("Next.js batch handler error:", e), n.json(
|
|
221
|
+
i(
|
|
222
|
+
e instanceof Error ? e.message : "Batch execution failed",
|
|
223
|
+
500
|
|
224
|
+
),
|
|
225
|
+
{ status: 500 }
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function q(a) {
|
|
196
231
|
return {
|
|
197
|
-
load: v(
|
|
198
|
-
meta:
|
|
199
|
-
sql: H(
|
|
200
|
-
dryRun: A(
|
|
232
|
+
load: v(a),
|
|
233
|
+
meta: p(a),
|
|
234
|
+
sql: H(a),
|
|
235
|
+
dryRun: A(a),
|
|
236
|
+
batch: R(a)
|
|
201
237
|
};
|
|
202
238
|
}
|
|
203
239
|
export {
|
|
204
|
-
|
|
240
|
+
R as createBatchHandler,
|
|
241
|
+
q as createCubeHandlers,
|
|
205
242
|
A as createDryRunHandler,
|
|
206
243
|
v as createLoadHandler,
|
|
207
|
-
|
|
208
|
-
|
|
244
|
+
p as createMetaHandler,
|
|
245
|
+
M as createOptionsHandler,
|
|
209
246
|
H as createSqlHandler
|
|
210
247
|
};
|
package/dist/adapters/utils.d.ts
CHANGED
|
@@ -121,3 +121,49 @@ export declare function formatErrorResponse(error: string | Error, status?: numb
|
|
|
121
121
|
error: string;
|
|
122
122
|
status: number;
|
|
123
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Handle batch query requests - wrapper around existing single query execution
|
|
126
|
+
* Executes multiple queries in parallel and returns partial success results
|
|
127
|
+
*
|
|
128
|
+
* @param queries - Array of semantic queries to execute
|
|
129
|
+
* @param securityContext - Security context (extracted once, shared across all queries)
|
|
130
|
+
* @param semanticLayer - Semantic layer compiler instance
|
|
131
|
+
* @returns Array of results matching input query order (successful or error results)
|
|
132
|
+
*/
|
|
133
|
+
export declare function handleBatchRequest(queries: SemanticQuery[], securityContext: SecurityContext, semanticLayer: SemanticLayerCompiler): Promise<{
|
|
134
|
+
results: ({
|
|
135
|
+
queryType: string;
|
|
136
|
+
results: {
|
|
137
|
+
query: SemanticQuery;
|
|
138
|
+
lastRefreshTime: string;
|
|
139
|
+
usedPreAggregations: {};
|
|
140
|
+
transformedQuery: any;
|
|
141
|
+
requestId: string;
|
|
142
|
+
annotation: any;
|
|
143
|
+
dataSource: string;
|
|
144
|
+
dbType: string;
|
|
145
|
+
extDbType: string;
|
|
146
|
+
external: boolean;
|
|
147
|
+
slowQuery: boolean;
|
|
148
|
+
data: any[];
|
|
149
|
+
}[];
|
|
150
|
+
pivotQuery: {
|
|
151
|
+
queryType: string;
|
|
152
|
+
measures?: string[];
|
|
153
|
+
dimensions?: string[];
|
|
154
|
+
filters?: Array<import('../server').Filter>;
|
|
155
|
+
timeDimensions?: Array<import('../server').TimeDimension>;
|
|
156
|
+
limit?: number;
|
|
157
|
+
offset?: number;
|
|
158
|
+
order?: Record<string, "asc" | "desc">;
|
|
159
|
+
};
|
|
160
|
+
slowQuery: boolean;
|
|
161
|
+
success: boolean;
|
|
162
|
+
error?: undefined;
|
|
163
|
+
query?: undefined;
|
|
164
|
+
} | {
|
|
165
|
+
success: boolean;
|
|
166
|
+
error: string;
|
|
167
|
+
query: SemanticQuery;
|
|
168
|
+
})[];
|
|
169
|
+
}>;
|
package/dist/client/charts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as t, C as s, D as h, N as R, F as e, A as C, B as c, L as O, P as T, R as A, a as L, S, T as I, f as _ } from "./chunks/charts-
|
|
1
|
+
import { r as t, C as s, D as h, N as R, F as e, A as C, B as c, L as O, P as T, R as A, a as L, S, T as I, f as _ } from "./chunks/charts-CfbqkXfS.js";
|
|
2
2
|
export {
|
|
3
3
|
t as CHART_COLORS,
|
|
4
4
|
s as CHART_MARGINS,
|