drizzle-cube 0.1.13 → 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/README.md +48 -213
- 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/AnalyticsDashboard.d.ts +1 -1
- package/dist/client/components/DashboardGrid.d.ts +1 -2
- package/dist/client/components/PortletEditModal.d.ts +1 -2
- 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 -1
- 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 +3 -3
- package/dist/client/index.js +29 -30100
- package/dist/client/index.js.map +1 -0
- package/dist/client/providers/CubeProvider.d.ts +6 -3
- 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/types.d.ts +0 -2
- 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
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { S as
|
|
4
|
-
function N(
|
|
1
|
+
import Q, { Router as E } from "express";
|
|
2
|
+
import R from "cors";
|
|
3
|
+
import { S as $, c as a, f as v, a as L, b as x, h } from "../compiler-CQNna-Ig.js";
|
|
4
|
+
function N(l) {
|
|
5
5
|
const {
|
|
6
6
|
cubes: c,
|
|
7
7
|
drizzle: p,
|
|
8
|
-
schema:
|
|
8
|
+
schema: C,
|
|
9
9
|
extractSecurityContext: d,
|
|
10
|
-
engineType:
|
|
11
|
-
cors:
|
|
12
|
-
basePath:
|
|
10
|
+
engineType: w,
|
|
11
|
+
cors: g,
|
|
12
|
+
basePath: y = "/cubejs-api/v1",
|
|
13
13
|
jsonLimit: q = "10mb"
|
|
14
|
-
} =
|
|
14
|
+
} = l;
|
|
15
15
|
if (!c || c.length === 0)
|
|
16
16
|
throw new Error("At least one cube must be provided in the cubes array");
|
|
17
|
-
const u =
|
|
18
|
-
|
|
19
|
-
const n = new
|
|
17
|
+
const u = E();
|
|
18
|
+
g && u.use(R(g)), u.use(Q.json({ limit: q })), u.use(Q.urlencoded({ extended: !0, limit: q }));
|
|
19
|
+
const n = new $({
|
|
20
20
|
drizzle: p,
|
|
21
|
-
schema:
|
|
22
|
-
engineType:
|
|
21
|
+
schema: C,
|
|
22
|
+
engineType: w
|
|
23
23
|
});
|
|
24
24
|
return c.forEach((t) => {
|
|
25
25
|
n.registerCube(t);
|
|
26
|
-
}),
|
|
26
|
+
}), u.post(`${y}/load`, async (t, r) => {
|
|
27
27
|
try {
|
|
28
28
|
const e = t.body.query || t.body, s = await d(t, r), o = n.validateQuery(e);
|
|
29
29
|
if (!o.isValid)
|
|
@@ -39,7 +39,7 @@ function N(y) {
|
|
|
39
39
|
500
|
|
40
40
|
));
|
|
41
41
|
}
|
|
42
|
-
}), u.get(`${
|
|
42
|
+
}), u.get(`${y}/load`, async (t, r) => {
|
|
43
43
|
try {
|
|
44
44
|
const e = t.query.query;
|
|
45
45
|
if (!e)
|
|
@@ -70,7 +70,7 @@ function N(y) {
|
|
|
70
70
|
500
|
|
71
71
|
));
|
|
72
72
|
}
|
|
73
|
-
}), u.get(`${
|
|
73
|
+
}), u.get(`${y}/meta`, (t, r) => {
|
|
74
74
|
try {
|
|
75
75
|
const e = n.getMetadata();
|
|
76
76
|
r.json(L(e));
|
|
@@ -80,7 +80,7 @@ function N(y) {
|
|
|
80
80
|
500
|
|
81
81
|
));
|
|
82
82
|
}
|
|
83
|
-
}), u.post(`${
|
|
83
|
+
}), u.post(`${y}/sql`, async (t, r) => {
|
|
84
84
|
var e, s;
|
|
85
85
|
try {
|
|
86
86
|
const o = t.body, i = await d(t, r), f = n.validateQuery(o);
|
|
@@ -103,7 +103,7 @@ function N(y) {
|
|
|
103
103
|
500
|
|
104
104
|
));
|
|
105
105
|
}
|
|
106
|
-
}), u.get(`${
|
|
106
|
+
}), u.get(`${y}/sql`, async (t, r) => {
|
|
107
107
|
var e, s;
|
|
108
108
|
try {
|
|
109
109
|
const o = t.query.query;
|
|
@@ -132,9 +132,9 @@ function N(y) {
|
|
|
132
132
|
500
|
|
133
133
|
));
|
|
134
134
|
}
|
|
135
|
-
}), u.post(`${
|
|
135
|
+
}), u.post(`${y}/dry-run`, async (t, r) => {
|
|
136
136
|
try {
|
|
137
|
-
const e = t.body.query || t.body, s = await d(t, r), o = await
|
|
137
|
+
const e = t.body.query || t.body, s = await d(t, r), o = await h(e, s, n);
|
|
138
138
|
r.json(o);
|
|
139
139
|
} catch (e) {
|
|
140
140
|
console.error("Dry-run error:", e), r.status(400).json({
|
|
@@ -142,7 +142,7 @@ function N(y) {
|
|
|
142
142
|
valid: !1
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
-
}), u.get(`${
|
|
145
|
+
}), u.get(`${y}/dry-run`, async (t, r) => {
|
|
146
146
|
try {
|
|
147
147
|
const e = t.query.query;
|
|
148
148
|
if (!e)
|
|
@@ -150,7 +150,7 @@ function N(y) {
|
|
|
150
150
|
error: "Query parameter is required",
|
|
151
151
|
valid: !1
|
|
152
152
|
});
|
|
153
|
-
const s = JSON.parse(e), o = await d(t, r), i = await
|
|
153
|
+
const s = JSON.parse(e), o = await d(t, r), i = await h(s, o, n);
|
|
154
154
|
r.json(i);
|
|
155
155
|
} catch (e) {
|
|
156
156
|
console.error("Dry-run error:", e), r.status(400).json({
|
|
@@ -162,16 +162,16 @@ function N(y) {
|
|
|
162
162
|
console.error("Express adapter error:", t), e.headersSent || e.status(500).json(a(t, 500));
|
|
163
163
|
}), u;
|
|
164
164
|
}
|
|
165
|
-
function M(
|
|
165
|
+
function M(l, c) {
|
|
166
166
|
const p = N(c);
|
|
167
|
-
return
|
|
167
|
+
return l.use("/", p), l;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
const c =
|
|
171
|
-
return M(c,
|
|
169
|
+
function P(l) {
|
|
170
|
+
const c = Q();
|
|
171
|
+
return M(c, l);
|
|
172
172
|
}
|
|
173
173
|
export {
|
|
174
|
-
|
|
174
|
+
P as createCubeApp,
|
|
175
175
|
N as createCubeRouter,
|
|
176
176
|
M as mountCubeRoutes
|
|
177
177
|
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { S as P, c as u, f as
|
|
2
|
-
const
|
|
1
|
+
import { S as P, c as u, f as v, a as L, b as Q, h as C } from "../compiler-CQNna-Ig.js";
|
|
2
|
+
const w = function(o, x, q) {
|
|
3
3
|
const {
|
|
4
|
-
cubes:
|
|
5
|
-
drizzle:
|
|
4
|
+
cubes: b,
|
|
5
|
+
drizzle: S,
|
|
6
6
|
schema: E,
|
|
7
7
|
extractSecurityContext: y,
|
|
8
|
-
engineType:
|
|
9
|
-
cors:
|
|
8
|
+
engineType: j,
|
|
9
|
+
cors: h,
|
|
10
10
|
basePath: d = "/cubejs-api/v1",
|
|
11
11
|
bodyLimit: p = 10485760
|
|
12
12
|
// 10MB
|
|
13
|
-
} =
|
|
14
|
-
if (!
|
|
15
|
-
return
|
|
16
|
-
|
|
13
|
+
} = x;
|
|
14
|
+
if (!b || b.length === 0)
|
|
15
|
+
return q(new Error("At least one cube must be provided in the cubes array"));
|
|
16
|
+
h && o.register(import("@fastify/cors"), h), o.addHook("onRequest", async (r, t) => {
|
|
17
17
|
r.method === "POST" && (r.body = void 0);
|
|
18
18
|
});
|
|
19
19
|
const i = new P({
|
|
20
|
-
drizzle:
|
|
20
|
+
drizzle: S,
|
|
21
21
|
schema: E,
|
|
22
|
-
engineType:
|
|
22
|
+
engineType: j
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
b.forEach((r) => {
|
|
25
25
|
i.registerCube(r);
|
|
26
|
-
}),
|
|
26
|
+
}), o.post(`${d}/load`, {
|
|
27
27
|
bodyLimit: p,
|
|
28
28
|
schema: {
|
|
29
29
|
body: {
|
|
@@ -40,7 +40,7 @@ const x = function(o, S, h) {
|
|
|
40
40
|
400
|
|
41
41
|
));
|
|
42
42
|
const c = await i.executeMultiCubeQuery(a, s);
|
|
43
|
-
return
|
|
43
|
+
return v(a, c, i);
|
|
44
44
|
} catch (e) {
|
|
45
45
|
return r.log.error(e, "Query execution error"), t.status(500).send(u(
|
|
46
46
|
e instanceof Error ? e.message : "Query execution failed",
|
|
@@ -76,7 +76,7 @@ const x = function(o, S, h) {
|
|
|
76
76
|
400
|
|
77
77
|
));
|
|
78
78
|
const c = await i.executeMultiCubeQuery(a, s);
|
|
79
|
-
return
|
|
79
|
+
return v(a, c, i);
|
|
80
80
|
} catch (e) {
|
|
81
81
|
return r.log.error(e, "Query execution error"), t.status(500).send(u(
|
|
82
82
|
e instanceof Error ? e.message : "Query execution failed",
|
|
@@ -86,7 +86,7 @@ const x = function(o, S, h) {
|
|
|
86
86
|
}), o.get(`${d}/meta`, async (r, t) => {
|
|
87
87
|
try {
|
|
88
88
|
const e = i.getMetadata();
|
|
89
|
-
return
|
|
89
|
+
return L(e);
|
|
90
90
|
} catch (e) {
|
|
91
91
|
return r.log.error(e, "Metadata error"), t.status(500).send(u(
|
|
92
92
|
e instanceof Error ? e.message : "Failed to fetch metadata",
|
|
@@ -116,8 +116,8 @@ const x = function(o, S, h) {
|
|
|
116
116
|
"No measures or dimensions specified",
|
|
117
117
|
400
|
|
118
118
|
));
|
|
119
|
-
const
|
|
120
|
-
return
|
|
119
|
+
const g = l.split(".")[0], f = await i.generateSQL(g, s, n);
|
|
120
|
+
return Q(s, f);
|
|
121
121
|
} catch (s) {
|
|
122
122
|
return r.log.error(s, "SQL generation error"), t.status(500).send(u(
|
|
123
123
|
s instanceof Error ? s.message : "SQL generation failed",
|
|
@@ -143,14 +143,14 @@ const x = function(o, S, h) {
|
|
|
143
143
|
`Query validation failed: ${l.errors.join(", ")}`,
|
|
144
144
|
400
|
|
145
145
|
));
|
|
146
|
-
const
|
|
147
|
-
if (!
|
|
146
|
+
const g = ((e = n.measures) == null ? void 0 : e[0]) || ((a = n.dimensions) == null ? void 0 : a[0]);
|
|
147
|
+
if (!g)
|
|
148
148
|
return t.status(400).send(u(
|
|
149
149
|
"No measures or dimensions specified",
|
|
150
150
|
400
|
|
151
151
|
));
|
|
152
|
-
const f =
|
|
153
|
-
return
|
|
152
|
+
const f = g.split(".")[0], $ = await i.generateSQL(f, n, c);
|
|
153
|
+
return Q(n, $);
|
|
154
154
|
} catch (s) {
|
|
155
155
|
return r.log.error(s, "SQL generation error"), t.status(500).send(u(
|
|
156
156
|
s instanceof Error ? s.message : "SQL generation failed",
|
|
@@ -168,7 +168,7 @@ const x = function(o, S, h) {
|
|
|
168
168
|
}, async (r, t) => {
|
|
169
169
|
try {
|
|
170
170
|
const e = r.body, a = e.query || e, s = await y(r);
|
|
171
|
-
return await
|
|
171
|
+
return await C(a, s, i);
|
|
172
172
|
} catch (e) {
|
|
173
173
|
return r.log.error(e, "Dry-run error"), t.status(400).send({
|
|
174
174
|
error: e instanceof Error ? e.message : "Dry-run validation failed",
|
|
@@ -188,26 +188,26 @@ const x = function(o, S, h) {
|
|
|
188
188
|
}, async (r, t) => {
|
|
189
189
|
try {
|
|
190
190
|
const { query: e } = r.query, a = JSON.parse(e), s = await y(r);
|
|
191
|
-
return await
|
|
191
|
+
return await C(a, s, i);
|
|
192
192
|
} catch (e) {
|
|
193
193
|
return r.log.error(e, "Dry-run error"), t.status(400).send({
|
|
194
194
|
error: e instanceof Error ? e.message : "Dry-run validation failed",
|
|
195
195
|
valid: !1
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
|
-
}), o.setErrorHandler(async (r, t, e) => (t.log.error(r, "Fastify cube adapter error"), e.statusCode < 400 && e.status(500), u(r, e.statusCode))),
|
|
198
|
+
}), o.setErrorHandler(async (r, t, e) => (t.log.error(r, "Fastify cube adapter error"), e.statusCode < 400 && e.status(500), u(r, e.statusCode))), q();
|
|
199
199
|
};
|
|
200
|
-
async function N(
|
|
201
|
-
await
|
|
200
|
+
async function N(m, o) {
|
|
201
|
+
await m.register(w, o);
|
|
202
202
|
}
|
|
203
|
-
function M(
|
|
203
|
+
function M(m) {
|
|
204
204
|
const o = require("fastify")({
|
|
205
205
|
logger: !0
|
|
206
206
|
});
|
|
207
|
-
return o.register(
|
|
207
|
+
return o.register(w, m), o;
|
|
208
208
|
}
|
|
209
209
|
export {
|
|
210
210
|
M as createCubeApp,
|
|
211
|
-
|
|
211
|
+
w as cubePlugin,
|
|
212
212
|
N as registerCubeRoutes
|
|
213
213
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Hono as x } from "hono";
|
|
2
|
-
import { S as
|
|
3
|
-
var
|
|
2
|
+
import { S as v, f as h, a as A, b as w, h as C } from "../compiler-CQNna-Ig.js";
|
|
3
|
+
var b = (d) => {
|
|
4
4
|
const l = {
|
|
5
5
|
...{
|
|
6
6
|
origin: "*",
|
|
@@ -8,14 +8,14 @@ var A = (y) => {
|
|
|
8
8
|
allowHeaders: [],
|
|
9
9
|
exposeHeaders: []
|
|
10
10
|
},
|
|
11
|
-
...
|
|
12
|
-
},
|
|
13
|
-
return async function(n,
|
|
11
|
+
...d
|
|
12
|
+
}, g = /* @__PURE__ */ ((u) => typeof u == "string" ? u === "*" ? () => u : (n) => u === n ? n : null : typeof u == "function" ? u : (n) => u.includes(n) ? n : null)(l.origin), f = ((u) => typeof u == "function" ? u : Array.isArray(u) ? () => u : () => [])(l.allowMethods);
|
|
13
|
+
return async function(n, c) {
|
|
14
14
|
var e;
|
|
15
15
|
function s(r, t) {
|
|
16
16
|
n.res.headers.set(r, t);
|
|
17
17
|
}
|
|
18
|
-
const a =
|
|
18
|
+
const a = g(n.req.header("origin") || "", n);
|
|
19
19
|
if (a && s("Access-Control-Allow-Origin", a), l.origin !== "*") {
|
|
20
20
|
const r = n.req.header("Vary");
|
|
21
21
|
r ? s("Vary", r) : s("Vary", "Origin");
|
|
@@ -35,31 +35,31 @@ var A = (y) => {
|
|
|
35
35
|
statusText: "No Content"
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
await
|
|
38
|
+
await c();
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
function S(
|
|
41
|
+
function S(d) {
|
|
42
42
|
const {
|
|
43
|
-
cubes:
|
|
43
|
+
cubes: y,
|
|
44
44
|
drizzle: l,
|
|
45
|
-
schema:
|
|
45
|
+
schema: g,
|
|
46
46
|
extractSecurityContext: f,
|
|
47
47
|
engineType: u,
|
|
48
48
|
cors: n,
|
|
49
|
-
basePath:
|
|
50
|
-
} =
|
|
51
|
-
if (!
|
|
49
|
+
basePath: c = "/cubejs-api/v1"
|
|
50
|
+
} = d;
|
|
51
|
+
if (!y || y.length === 0)
|
|
52
52
|
throw new Error("At least one cube must be provided in the cubes array");
|
|
53
53
|
const s = new x();
|
|
54
|
-
n && s.use("/*",
|
|
55
|
-
const a = new
|
|
54
|
+
n && s.use("/*", b(n));
|
|
55
|
+
const a = new v({
|
|
56
56
|
drizzle: l,
|
|
57
|
-
schema:
|
|
57
|
+
schema: g,
|
|
58
58
|
engineType: u
|
|
59
59
|
});
|
|
60
|
-
return
|
|
60
|
+
return y.forEach((e) => {
|
|
61
61
|
a.registerCube(e);
|
|
62
|
-
}),
|
|
62
|
+
}), s.post(`${c}/load`, async (e) => {
|
|
63
63
|
try {
|
|
64
64
|
const r = await e.req.json(), t = r.query || r, o = await f(e), i = a.validateQuery(t);
|
|
65
65
|
if (!i.isValid)
|
|
@@ -67,13 +67,13 @@ function S(y) {
|
|
|
67
67
|
error: `Query validation failed: ${i.errors.join(", ")}`
|
|
68
68
|
}, 400);
|
|
69
69
|
const m = await a.executeMultiCubeQuery(t, o);
|
|
70
|
-
return e.json(
|
|
70
|
+
return e.json(h(t, m, a));
|
|
71
71
|
} catch (r) {
|
|
72
72
|
return console.error("Query execution error:", r), e.json({
|
|
73
73
|
error: r instanceof Error ? r.message : "Query execution failed"
|
|
74
74
|
}, 500);
|
|
75
75
|
}
|
|
76
|
-
}), s.get(`${
|
|
76
|
+
}), s.get(`${c}/load`, async (e) => {
|
|
77
77
|
try {
|
|
78
78
|
const r = e.req.query("query");
|
|
79
79
|
if (!r)
|
|
@@ -94,22 +94,22 @@ function S(y) {
|
|
|
94
94
|
error: `Query validation failed: ${i.errors.join(", ")}`
|
|
95
95
|
}, 400);
|
|
96
96
|
const m = await a.executeMultiCubeQuery(t, o);
|
|
97
|
-
return e.json(
|
|
97
|
+
return e.json(h(t, m, a));
|
|
98
98
|
} catch (r) {
|
|
99
99
|
return console.error("Query execution error:", r), e.json({
|
|
100
100
|
error: r instanceof Error ? r.message : "Query execution failed"
|
|
101
101
|
}, 500);
|
|
102
102
|
}
|
|
103
|
-
}), s.get(`${
|
|
103
|
+
}), s.get(`${c}/meta`, (e) => {
|
|
104
104
|
try {
|
|
105
105
|
const r = a.getMetadata();
|
|
106
|
-
return e.json(
|
|
106
|
+
return e.json(A(r));
|
|
107
107
|
} catch (r) {
|
|
108
108
|
return console.error("Metadata error:", r), e.json({
|
|
109
109
|
error: r instanceof Error ? r.message : "Failed to fetch metadata"
|
|
110
110
|
}, 500);
|
|
111
111
|
}
|
|
112
|
-
}), s.post(`${
|
|
112
|
+
}), s.post(`${c}/sql`, async (e) => {
|
|
113
113
|
var r, t;
|
|
114
114
|
try {
|
|
115
115
|
const o = await e.req.json(), i = await f(e), m = a.validateQuery(o);
|
|
@@ -122,14 +122,14 @@ function S(y) {
|
|
|
122
122
|
return e.json({
|
|
123
123
|
error: "No measures or dimensions specified"
|
|
124
124
|
}, 400);
|
|
125
|
-
const
|
|
126
|
-
return e.json(w(o,
|
|
125
|
+
const j = q.split(".")[0], p = await a.generateSQL(j, o, i);
|
|
126
|
+
return e.json(w(o, p));
|
|
127
127
|
} catch (o) {
|
|
128
128
|
return console.error("SQL generation error:", o), e.json({
|
|
129
129
|
error: o instanceof Error ? o.message : "SQL generation failed"
|
|
130
130
|
}, 500);
|
|
131
131
|
}
|
|
132
|
-
}), s.get(`${
|
|
132
|
+
}), s.get(`${c}/sql`, async (e) => {
|
|
133
133
|
var r, t;
|
|
134
134
|
try {
|
|
135
135
|
const o = e.req.query("query");
|
|
@@ -142,19 +142,19 @@ function S(y) {
|
|
|
142
142
|
return e.json({
|
|
143
143
|
error: `Query validation failed: ${q.errors.join(", ")}`
|
|
144
144
|
}, 400);
|
|
145
|
-
const
|
|
146
|
-
if (!
|
|
145
|
+
const j = ((r = i.measures) == null ? void 0 : r[0]) || ((t = i.dimensions) == null ? void 0 : t[0]);
|
|
146
|
+
if (!j)
|
|
147
147
|
return e.json({
|
|
148
148
|
error: "No measures or dimensions specified"
|
|
149
149
|
}, 400);
|
|
150
|
-
const
|
|
150
|
+
const p = j.split(".")[0], Q = await a.generateSQL(p, i, m);
|
|
151
151
|
return e.json(w(i, Q));
|
|
152
152
|
} catch (o) {
|
|
153
153
|
return console.error("SQL generation error:", o), e.json({
|
|
154
154
|
error: o instanceof Error ? o.message : "SQL generation failed"
|
|
155
155
|
}, 500);
|
|
156
156
|
}
|
|
157
|
-
}), s.post(`${
|
|
157
|
+
}), s.post(`${c}/dry-run`, async (e) => {
|
|
158
158
|
try {
|
|
159
159
|
const r = await e.req.json(), t = r.query || r, o = await f(e), i = await C(t, o, a);
|
|
160
160
|
return e.json(i);
|
|
@@ -164,7 +164,7 @@ function S(y) {
|
|
|
164
164
|
valid: !1
|
|
165
165
|
}, 400);
|
|
166
166
|
}
|
|
167
|
-
}), s.get(`${
|
|
167
|
+
}), s.get(`${c}/dry-run`, async (e) => {
|
|
168
168
|
try {
|
|
169
169
|
const r = e.req.query("query");
|
|
170
170
|
if (!r)
|
|
@@ -182,13 +182,13 @@ function S(y) {
|
|
|
182
182
|
}
|
|
183
183
|
}), s;
|
|
184
184
|
}
|
|
185
|
-
function E(
|
|
186
|
-
const l = S(
|
|
187
|
-
return
|
|
185
|
+
function E(d, y) {
|
|
186
|
+
const l = S(y);
|
|
187
|
+
return d.route("/", l), d;
|
|
188
188
|
}
|
|
189
|
-
function $(
|
|
190
|
-
const
|
|
191
|
-
return E(
|
|
189
|
+
function $(d) {
|
|
190
|
+
const y = new x();
|
|
191
|
+
return E(y, d);
|
|
192
192
|
}
|
|
193
193
|
export {
|
|
194
194
|
$ as createCubeApp,
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { NextResponse as o } from "next/server";
|
|
2
|
-
import { c as l, f as
|
|
3
|
-
function
|
|
4
|
-
const { cubes: e, drizzle:
|
|
2
|
+
import { c as l, f as C, a as H, b as p, h as v, S as A } from "../compiler-CQNna-Ig.js";
|
|
3
|
+
function g(t) {
|
|
4
|
+
const { cubes: e, drizzle: n, schema: s, engineType: y } = t;
|
|
5
5
|
if (!e || e.length === 0)
|
|
6
6
|
throw new Error("At least one cube must be provided in the cubes array");
|
|
7
|
-
const r = new
|
|
8
|
-
drizzle:
|
|
7
|
+
const r = new A({
|
|
8
|
+
drizzle: n,
|
|
9
9
|
schema: s,
|
|
10
10
|
engineType: y
|
|
11
11
|
});
|
|
12
12
|
return e.forEach((c) => {
|
|
13
13
|
r.registerCube(c);
|
|
14
|
-
}),
|
|
14
|
+
}), r;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
return e.origin && (typeof e.origin == "string" ? s["Access-Control-Allow-Origin"] = e.origin : Array.isArray(e.origin) ?
|
|
16
|
+
function j(t, e) {
|
|
17
|
+
const n = t.headers.get("origin"), s = {};
|
|
18
|
+
return e.origin && (typeof e.origin == "string" ? s["Access-Control-Allow-Origin"] = e.origin : Array.isArray(e.origin) ? n && e.origin.includes(n) && (s["Access-Control-Allow-Origin"] = n) : typeof e.origin == "function" && n && e.origin(n) && (s["Access-Control-Allow-Origin"] = n)), e.methods && (s["Access-Control-Allow-Methods"] = e.methods.join(", ")), e.allowedHeaders && (s["Access-Control-Allow-Headers"] = e.allowedHeaders.join(", ")), e.credentials && (s["Access-Control-Allow-Credentials"] = "true"), s;
|
|
19
19
|
}
|
|
20
20
|
function P(t) {
|
|
21
|
-
return async function(
|
|
22
|
-
const s =
|
|
21
|
+
return async function(n) {
|
|
22
|
+
const s = j(n, t);
|
|
23
23
|
return new Response(null, {
|
|
24
24
|
status: 200,
|
|
25
25
|
headers: s
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
const { extractSecurityContext: e, cors:
|
|
29
|
+
function b(t) {
|
|
30
|
+
const { extractSecurityContext: e, cors: n } = t, s = g(t);
|
|
31
31
|
return async function(r, c) {
|
|
32
32
|
try {
|
|
33
|
-
let
|
|
33
|
+
let a;
|
|
34
34
|
if (r.method === "POST") {
|
|
35
35
|
const d = await r.json();
|
|
36
|
-
|
|
36
|
+
a = d.query || d;
|
|
37
37
|
} else if (r.method === "GET") {
|
|
38
38
|
const d = r.nextUrl.searchParams.get("query");
|
|
39
39
|
if (!d)
|
|
@@ -42,7 +42,7 @@ function A(t) {
|
|
|
42
42
|
{ status: 400 }
|
|
43
43
|
);
|
|
44
44
|
try {
|
|
45
|
-
|
|
45
|
+
a = JSON.parse(d);
|
|
46
46
|
} catch {
|
|
47
47
|
return o.json(
|
|
48
48
|
l("Invalid JSON in query parameter", 400),
|
|
@@ -54,20 +54,20 @@ function A(t) {
|
|
|
54
54
|
l("Method not allowed", 405),
|
|
55
55
|
{ status: 405 }
|
|
56
56
|
);
|
|
57
|
-
const f = await e(r, c), i = s.validateQuery(
|
|
57
|
+
const f = await e(r, c), i = s.validateQuery(a);
|
|
58
58
|
if (!i.isValid)
|
|
59
59
|
return o.json(
|
|
60
60
|
l(`Query validation failed: ${i.errors.join(", ")}`, 400),
|
|
61
61
|
{ status: 400 }
|
|
62
62
|
);
|
|
63
|
-
const u = await s.executeMultiCubeQuery(
|
|
63
|
+
const u = await s.executeMultiCubeQuery(a, f), m = C(a, u, s);
|
|
64
64
|
return o.json(m, {
|
|
65
|
-
headers:
|
|
65
|
+
headers: n ? j(r, n) : {}
|
|
66
66
|
});
|
|
67
|
-
} catch (
|
|
68
|
-
return console.error("Next.js load handler error:",
|
|
67
|
+
} catch (a) {
|
|
68
|
+
return console.error("Next.js load handler error:", a), o.json(
|
|
69
69
|
l(
|
|
70
|
-
|
|
70
|
+
a instanceof Error ? a.message : "Query execution failed",
|
|
71
71
|
500
|
|
72
72
|
),
|
|
73
73
|
{ status: 500 }
|
|
@@ -76,12 +76,12 @@ function A(t) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
function E(t) {
|
|
79
|
-
const { cors: e } = t,
|
|
79
|
+
const { cors: e } = t, n = g(t);
|
|
80
80
|
return async function(y, r) {
|
|
81
81
|
try {
|
|
82
|
-
const c =
|
|
83
|
-
return o.json(
|
|
84
|
-
headers: e ?
|
|
82
|
+
const c = n.getMetadata(), a = H(c);
|
|
83
|
+
return o.json(a, {
|
|
84
|
+
headers: e ? j(y, e) : {}
|
|
85
85
|
});
|
|
86
86
|
} catch (c) {
|
|
87
87
|
return console.error("Next.js meta handler error:", c), o.json(
|
|
@@ -95,9 +95,9 @@ function E(t) {
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
function N(t) {
|
|
98
|
-
const { extractSecurityContext: e, cors:
|
|
98
|
+
const { extractSecurityContext: e, cors: n } = t, s = g(t);
|
|
99
99
|
return async function(r, c) {
|
|
100
|
-
var
|
|
100
|
+
var a, f;
|
|
101
101
|
try {
|
|
102
102
|
let i;
|
|
103
103
|
if (r.method === "POST") {
|
|
@@ -129,15 +129,15 @@ function N(t) {
|
|
|
129
129
|
l(`Query validation failed: ${m.errors.join(", ")}`, 400),
|
|
130
130
|
{ status: 400 }
|
|
131
131
|
);
|
|
132
|
-
const d = ((
|
|
132
|
+
const d = ((a = i.measures) == null ? void 0 : a[0]) || ((f = i.dimensions) == null ? void 0 : f[0]);
|
|
133
133
|
if (!d)
|
|
134
134
|
return o.json(
|
|
135
135
|
l("No measures or dimensions specified", 400),
|
|
136
136
|
{ status: 400 }
|
|
137
137
|
);
|
|
138
|
-
const w = d.split(".")[0], x = await s.generateSQL(w, i, u),
|
|
139
|
-
return o.json(
|
|
140
|
-
headers:
|
|
138
|
+
const w = d.split(".")[0], x = await s.generateSQL(w, i, u), S = p(i, x);
|
|
139
|
+
return o.json(S, {
|
|
140
|
+
headers: n ? j(r, n) : {}
|
|
141
141
|
});
|
|
142
142
|
} catch (i) {
|
|
143
143
|
return console.error("Next.js SQL handler error:", i), o.json(
|
|
@@ -151,13 +151,13 @@ function N(t) {
|
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
function Q(t) {
|
|
154
|
-
const { extractSecurityContext: e, cors:
|
|
154
|
+
const { extractSecurityContext: e, cors: n } = t, s = g(t);
|
|
155
155
|
return async function(r, c) {
|
|
156
156
|
try {
|
|
157
|
-
let
|
|
157
|
+
let a;
|
|
158
158
|
if (r.method === "POST") {
|
|
159
159
|
const u = await r.json();
|
|
160
|
-
|
|
160
|
+
a = u.query || u;
|
|
161
161
|
} else if (r.method === "GET") {
|
|
162
162
|
const u = r.nextUrl.searchParams.get("query");
|
|
163
163
|
if (!u)
|
|
@@ -166,7 +166,7 @@ function Q(t) {
|
|
|
166
166
|
{ status: 400 }
|
|
167
167
|
);
|
|
168
168
|
try {
|
|
169
|
-
|
|
169
|
+
a = JSON.parse(u);
|
|
170
170
|
} catch {
|
|
171
171
|
return o.json(
|
|
172
172
|
{ error: "Invalid JSON in query parameter", valid: !1 },
|
|
@@ -178,14 +178,14 @@ function Q(t) {
|
|
|
178
178
|
{ error: "Method not allowed", valid: !1 },
|
|
179
179
|
{ status: 405 }
|
|
180
180
|
);
|
|
181
|
-
const f = await e(r, c), i = await
|
|
181
|
+
const f = await e(r, c), i = await v(a, f, s);
|
|
182
182
|
return o.json(i, {
|
|
183
|
-
headers:
|
|
183
|
+
headers: n ? j(r, n) : {}
|
|
184
184
|
});
|
|
185
|
-
} catch (
|
|
186
|
-
return console.error("Next.js dry-run handler error:",
|
|
185
|
+
} catch (a) {
|
|
186
|
+
return console.error("Next.js dry-run handler error:", a), o.json(
|
|
187
187
|
{
|
|
188
|
-
error:
|
|
188
|
+
error: a instanceof Error ? a.message : "Dry-run validation failed",
|
|
189
189
|
valid: !1
|
|
190
190
|
},
|
|
191
191
|
{ status: 400 }
|
|
@@ -195,7 +195,7 @@ function Q(t) {
|
|
|
195
195
|
}
|
|
196
196
|
function q(t) {
|
|
197
197
|
return {
|
|
198
|
-
load:
|
|
198
|
+
load: b(t),
|
|
199
199
|
meta: E(t),
|
|
200
200
|
sql: N(t),
|
|
201
201
|
dryRun: Q(t)
|
|
@@ -204,7 +204,7 @@ function q(t) {
|
|
|
204
204
|
export {
|
|
205
205
|
q as createCubeHandlers,
|
|
206
206
|
Q as createDryRunHandler,
|
|
207
|
-
|
|
207
|
+
b as createLoadHandler,
|
|
208
208
|
E as createMetaHandler,
|
|
209
209
|
P as createOptionsHandler,
|
|
210
210
|
N as createSqlHandler
|
package/dist/adapters/utils.d.ts
CHANGED
|
@@ -93,6 +93,10 @@ export declare function formatCubeResponse(query: SemanticQuery, result: {
|
|
|
93
93
|
};
|
|
94
94
|
slowQuery: boolean;
|
|
95
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Format SQL string using sql-formatter with appropriate dialect
|
|
98
|
+
*/
|
|
99
|
+
export declare function formatSqlString(sqlString: string, engineType: 'postgres' | 'mysql' | 'sqlite'): string;
|
|
96
100
|
/**
|
|
97
101
|
* Format SQL generation response
|
|
98
102
|
*/
|