drizzle-cube 0.1.43 → 0.1.45
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-DgmZAw3A.js → charts-CC85023I.js} +758 -738
- package/dist/client/chunks/charts-CC85023I.js.map +1 -0
- package/dist/client/chunks/{components-BI1Xc4js.js → components-BExII4Ww.js} +6806 -6652
- package/dist/client/chunks/components-BExII4Ww.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/DashboardFilterPanel.d.ts +1 -1
- 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/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 +62 -62
- 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 +4 -0
- package/dist/client/utils/chartUtils.d.ts +2 -0
- package/dist/client-bundle-stats.html +1 -1
- package/package.json +1 -1
- package/dist/client/chunks/charts-DgmZAw3A.js.map +0 -1
- package/dist/client/chunks/components-BI1Xc4js.js.map +0 -1
- package/dist/client/chunks/providers-ChcxFwXu.js +0 -210
- package/dist/client/chunks/providers-ChcxFwXu.js.map +0 -1
|
@@ -20338,7 +20338,7 @@ function HN(T) {
|
|
|
20338
20338
|
}
|
|
20339
20339
|
return "postgres";
|
|
20340
20340
|
}
|
|
20341
|
-
async function
|
|
20341
|
+
async function pN(T, E, e) {
|
|
20342
20342
|
const R = e.validateQuery(T);
|
|
20343
20343
|
if (!R.isValid)
|
|
20344
20344
|
throw new Error(`Query validation failed: ${R.errors.join(", ")}`);
|
|
@@ -20398,7 +20398,7 @@ async function BN(T, E, e) {
|
|
|
20398
20398
|
query: T
|
|
20399
20399
|
};
|
|
20400
20400
|
}
|
|
20401
|
-
function
|
|
20401
|
+
function dN(T, E, e) {
|
|
20402
20402
|
const R = HN(e), A = GN(), S = (/* @__PURE__ */ new Date()).toISOString(), I = mN(T);
|
|
20403
20403
|
return {
|
|
20404
20404
|
queryType: "regularQuery",
|
|
@@ -20459,7 +20459,23 @@ function fN(T, E = 500) {
|
|
|
20459
20459
|
status: E
|
|
20460
20460
|
};
|
|
20461
20461
|
}
|
|
20462
|
-
|
|
20462
|
+
async function hN(T, E, e) {
|
|
20463
|
+
return { results: (await Promise.allSettled(
|
|
20464
|
+
T.map(async (S) => {
|
|
20465
|
+
const I = await e.executeMultiCubeQuery(S, E);
|
|
20466
|
+
return dN(S, I, e);
|
|
20467
|
+
})
|
|
20468
|
+
)).map((S, I) => S.status === "fulfilled" ? {
|
|
20469
|
+
success: !0,
|
|
20470
|
+
...S.value
|
|
20471
|
+
} : {
|
|
20472
|
+
success: !1,
|
|
20473
|
+
error: S.reason instanceof Error ? S.reason.message : String(S.reason),
|
|
20474
|
+
query: T[I]
|
|
20475
|
+
// Include the query that failed for debugging
|
|
20476
|
+
}) };
|
|
20477
|
+
}
|
|
20478
|
+
class BN {
|
|
20463
20479
|
cubes = /* @__PURE__ */ new Map();
|
|
20464
20480
|
dbExecutor;
|
|
20465
20481
|
metadataCache;
|
|
@@ -20818,12 +20834,13 @@ function ne(T, E, e, R) {
|
|
|
20818
20834
|
}
|
|
20819
20835
|
!I.dimensions[S] && !I.measures[S] && e.push(`Filter field '${S}' not found on cube '${A}' (must be a dimension or measure)`);
|
|
20820
20836
|
}
|
|
20821
|
-
new
|
|
20837
|
+
new BN();
|
|
20822
20838
|
export {
|
|
20823
|
-
|
|
20839
|
+
BN as S,
|
|
20824
20840
|
YN as a,
|
|
20825
20841
|
FN as b,
|
|
20826
|
-
|
|
20827
|
-
|
|
20828
|
-
|
|
20842
|
+
pN as c,
|
|
20843
|
+
fN as d,
|
|
20844
|
+
dN as f,
|
|
20845
|
+
hN as h
|
|
20829
20846
|
};
|
|
@@ -1,138 +1,159 @@
|
|
|
1
|
-
import p, { Router as
|
|
1
|
+
import p, { Router as C } from "express";
|
|
2
2
|
import S from "cors";
|
|
3
|
-
import { S as
|
|
4
|
-
function
|
|
3
|
+
import { S as R, d as o, f as g, h as E, a as $, b as Q, c as q } from "../compiler-DdaSPwZs.js";
|
|
4
|
+
function L(d) {
|
|
5
5
|
const {
|
|
6
|
-
cubes:
|
|
6
|
+
cubes: y,
|
|
7
7
|
drizzle: j,
|
|
8
8
|
schema: x,
|
|
9
|
-
extractSecurityContext:
|
|
10
|
-
engineType:
|
|
9
|
+
extractSecurityContext: l,
|
|
10
|
+
engineType: v,
|
|
11
11
|
cors: b,
|
|
12
|
-
basePath:
|
|
13
|
-
jsonLimit:
|
|
14
|
-
} =
|
|
15
|
-
if (!
|
|
12
|
+
basePath: c = "/cubejs-api/v1",
|
|
13
|
+
jsonLimit: h = "10mb"
|
|
14
|
+
} = d;
|
|
15
|
+
if (!y || y.length === 0)
|
|
16
16
|
throw new Error("At least one cube must be provided in the cubes array");
|
|
17
|
-
const i =
|
|
18
|
-
b && i.use(S(b)), i.use(p.json({ limit:
|
|
19
|
-
const a = new
|
|
17
|
+
const i = C();
|
|
18
|
+
b && i.use(S(b)), i.use(p.json({ limit: h })), i.use(p.urlencoded({ extended: !0, limit: h }));
|
|
19
|
+
const a = new R({
|
|
20
20
|
drizzle: j,
|
|
21
21
|
schema: x,
|
|
22
|
-
engineType:
|
|
22
|
+
engineType: v
|
|
23
23
|
});
|
|
24
|
-
return
|
|
24
|
+
return y.forEach((t) => {
|
|
25
25
|
a.registerCube(t);
|
|
26
|
-
}), i.post(`${
|
|
26
|
+
}), i.post(`${c}/load`, async (t, r) => {
|
|
27
27
|
try {
|
|
28
|
-
const e = t.body.query || t.body,
|
|
28
|
+
const e = t.body.query || t.body, s = await l(t, r), n = a.validateQuery(e);
|
|
29
29
|
if (!n.isValid)
|
|
30
|
-
return r.status(400).json(
|
|
30
|
+
return r.status(400).json(o(
|
|
31
31
|
`Query validation failed: ${n.errors.join(", ")}`,
|
|
32
32
|
400
|
|
33
33
|
));
|
|
34
|
-
const u = await a.executeMultiCubeQuery(e,
|
|
34
|
+
const u = await a.executeMultiCubeQuery(e, s);
|
|
35
35
|
r.json(g(e, u, a));
|
|
36
36
|
} catch (e) {
|
|
37
|
-
console.error("Query execution error:", e), r.status(500).json(
|
|
37
|
+
console.error("Query execution error:", e), r.status(500).json(o(
|
|
38
38
|
e instanceof Error ? e.message : "Query execution failed",
|
|
39
39
|
500
|
|
40
40
|
));
|
|
41
41
|
}
|
|
42
|
-
}), i.get(`${
|
|
42
|
+
}), i.get(`${c}/load`, async (t, r) => {
|
|
43
43
|
try {
|
|
44
44
|
const e = t.query.query;
|
|
45
45
|
if (!e)
|
|
46
|
-
return r.status(400).json(
|
|
46
|
+
return r.status(400).json(o(
|
|
47
47
|
"Query parameter is required",
|
|
48
48
|
400
|
|
49
49
|
));
|
|
50
|
-
let
|
|
50
|
+
let s;
|
|
51
51
|
try {
|
|
52
|
-
|
|
52
|
+
s = JSON.parse(e);
|
|
53
53
|
} catch {
|
|
54
|
-
return r.status(400).json(
|
|
54
|
+
return r.status(400).json(o(
|
|
55
55
|
"Invalid JSON in query parameter",
|
|
56
56
|
400
|
|
57
57
|
));
|
|
58
58
|
}
|
|
59
|
-
const n = await
|
|
59
|
+
const n = await l(t, r), u = a.validateQuery(s);
|
|
60
60
|
if (!u.isValid)
|
|
61
|
-
return r.status(400).json(
|
|
61
|
+
return r.status(400).json(o(
|
|
62
62
|
`Query validation failed: ${u.errors.join(", ")}`,
|
|
63
63
|
400
|
|
64
64
|
));
|
|
65
|
-
const f = await a.executeMultiCubeQuery(
|
|
66
|
-
r.json(g(
|
|
65
|
+
const f = await a.executeMultiCubeQuery(s, n);
|
|
66
|
+
r.json(g(s, f, a));
|
|
67
67
|
} catch (e) {
|
|
68
|
-
console.error("Query execution error:", e), r.status(500).json(
|
|
68
|
+
console.error("Query execution error:", e), r.status(500).json(o(
|
|
69
69
|
e instanceof Error ? e.message : "Query execution failed",
|
|
70
70
|
500
|
|
71
71
|
));
|
|
72
72
|
}
|
|
73
|
-
}), i.
|
|
73
|
+
}), i.post(`${c}/batch`, async (t, r) => {
|
|
74
|
+
try {
|
|
75
|
+
const { queries: e } = t.body;
|
|
76
|
+
if (!e || !Array.isArray(e))
|
|
77
|
+
return r.status(400).json(o(
|
|
78
|
+
'Request body must contain a "queries" array',
|
|
79
|
+
400
|
|
80
|
+
));
|
|
81
|
+
if (e.length === 0)
|
|
82
|
+
return r.status(400).json(o(
|
|
83
|
+
"Queries array cannot be empty",
|
|
84
|
+
400
|
|
85
|
+
));
|
|
86
|
+
const s = await l(t, r), n = await E(e, s, a);
|
|
87
|
+
r.json(n);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error("Batch execution error:", e), r.status(500).json(o(
|
|
90
|
+
e instanceof Error ? e.message : "Batch execution failed",
|
|
91
|
+
500
|
|
92
|
+
));
|
|
93
|
+
}
|
|
94
|
+
}), i.get(`${c}/meta`, (t, r) => {
|
|
74
95
|
try {
|
|
75
96
|
const e = a.getMetadata();
|
|
76
|
-
r.json(
|
|
97
|
+
r.json($(e));
|
|
77
98
|
} catch (e) {
|
|
78
|
-
console.error("Metadata error:", e), r.status(500).json(
|
|
99
|
+
console.error("Metadata error:", e), r.status(500).json(o(
|
|
79
100
|
e instanceof Error ? e.message : "Failed to fetch metadata",
|
|
80
101
|
500
|
|
81
102
|
));
|
|
82
103
|
}
|
|
83
|
-
}), i.post(`${
|
|
104
|
+
}), i.post(`${c}/sql`, async (t, r) => {
|
|
84
105
|
try {
|
|
85
|
-
const e = t.body,
|
|
106
|
+
const e = t.body, s = await l(t, r), n = a.validateQuery(e);
|
|
86
107
|
if (!n.isValid)
|
|
87
|
-
return r.status(400).json(
|
|
108
|
+
return r.status(400).json(o(
|
|
88
109
|
`Query validation failed: ${n.errors.join(", ")}`,
|
|
89
110
|
400
|
|
90
111
|
));
|
|
91
112
|
const u = e.measures?.[0] || e.dimensions?.[0];
|
|
92
113
|
if (!u)
|
|
93
|
-
return r.status(400).json(
|
|
114
|
+
return r.status(400).json(o(
|
|
94
115
|
"No measures or dimensions specified",
|
|
95
116
|
400
|
|
96
117
|
));
|
|
97
|
-
const f = u.split(".")[0], m = await a.generateSQL(f, e,
|
|
98
|
-
r.json(
|
|
118
|
+
const f = u.split(".")[0], m = await a.generateSQL(f, e, s);
|
|
119
|
+
r.json(Q(e, m));
|
|
99
120
|
} catch (e) {
|
|
100
|
-
console.error("SQL generation error:", e), r.status(500).json(
|
|
121
|
+
console.error("SQL generation error:", e), r.status(500).json(o(
|
|
101
122
|
e instanceof Error ? e.message : "SQL generation failed",
|
|
102
123
|
500
|
|
103
124
|
));
|
|
104
125
|
}
|
|
105
|
-
}), i.get(`${
|
|
126
|
+
}), i.get(`${c}/sql`, async (t, r) => {
|
|
106
127
|
try {
|
|
107
128
|
const e = t.query.query;
|
|
108
129
|
if (!e)
|
|
109
|
-
return r.status(400).json(
|
|
130
|
+
return r.status(400).json(o(
|
|
110
131
|
"Query parameter is required",
|
|
111
132
|
400
|
|
112
133
|
));
|
|
113
|
-
const
|
|
134
|
+
const s = JSON.parse(e), n = await l(t, r), u = a.validateQuery(s);
|
|
114
135
|
if (!u.isValid)
|
|
115
|
-
return r.status(400).json(
|
|
136
|
+
return r.status(400).json(o(
|
|
116
137
|
`Query validation failed: ${u.errors.join(", ")}`,
|
|
117
138
|
400
|
|
118
139
|
));
|
|
119
|
-
const f =
|
|
140
|
+
const f = s.measures?.[0] || s.dimensions?.[0];
|
|
120
141
|
if (!f)
|
|
121
|
-
return r.status(400).json(
|
|
142
|
+
return r.status(400).json(o(
|
|
122
143
|
"No measures or dimensions specified",
|
|
123
144
|
400
|
|
124
145
|
));
|
|
125
|
-
const m = f.split(".")[0],
|
|
126
|
-
r.json(
|
|
146
|
+
const m = f.split(".")[0], w = await a.generateSQL(m, s, n);
|
|
147
|
+
r.json(Q(s, w));
|
|
127
148
|
} catch (e) {
|
|
128
|
-
console.error("SQL generation error:", e), r.status(500).json(
|
|
149
|
+
console.error("SQL generation error:", e), r.status(500).json(o(
|
|
129
150
|
e instanceof Error ? e.message : "SQL generation failed",
|
|
130
151
|
500
|
|
131
152
|
));
|
|
132
153
|
}
|
|
133
|
-
}), i.post(`${
|
|
154
|
+
}), i.post(`${c}/dry-run`, async (t, r) => {
|
|
134
155
|
try {
|
|
135
|
-
const e = t.body.query || t.body,
|
|
156
|
+
const e = t.body.query || t.body, s = await l(t, r), n = await q(e, s, a);
|
|
136
157
|
r.json(n);
|
|
137
158
|
} catch (e) {
|
|
138
159
|
console.error("Dry-run error:", e), r.status(400).json({
|
|
@@ -140,7 +161,7 @@ function $(l) {
|
|
|
140
161
|
valid: !1
|
|
141
162
|
});
|
|
142
163
|
}
|
|
143
|
-
}), i.get(`${
|
|
164
|
+
}), i.get(`${c}/dry-run`, async (t, r) => {
|
|
144
165
|
try {
|
|
145
166
|
const e = t.query.query;
|
|
146
167
|
if (!e)
|
|
@@ -148,7 +169,7 @@ function $(l) {
|
|
|
148
169
|
error: "Query parameter is required",
|
|
149
170
|
valid: !1
|
|
150
171
|
});
|
|
151
|
-
const
|
|
172
|
+
const s = JSON.parse(e), n = await l(t, r), u = await q(s, n, a);
|
|
152
173
|
r.json(u);
|
|
153
174
|
} catch (e) {
|
|
154
175
|
console.error("Dry-run error:", e), r.status(400).json({
|
|
@@ -156,20 +177,20 @@ function $(l) {
|
|
|
156
177
|
valid: !1
|
|
157
178
|
});
|
|
158
179
|
}
|
|
159
|
-
}), i.use((t, r, e,
|
|
160
|
-
console.error("Express adapter error:", t), e.headersSent || e.status(500).json(
|
|
180
|
+
}), i.use((t, r, e, s) => {
|
|
181
|
+
console.error("Express adapter error:", t), e.headersSent || e.status(500).json(o(t, 500));
|
|
161
182
|
}), i;
|
|
162
183
|
}
|
|
163
|
-
function
|
|
164
|
-
const j =
|
|
165
|
-
return
|
|
184
|
+
function N(d, y) {
|
|
185
|
+
const j = L(y);
|
|
186
|
+
return d.use("/", j), d;
|
|
166
187
|
}
|
|
167
|
-
function J(
|
|
168
|
-
const
|
|
169
|
-
return
|
|
188
|
+
function J(d) {
|
|
189
|
+
const y = p();
|
|
190
|
+
return N(y, d);
|
|
170
191
|
}
|
|
171
192
|
export {
|
|
172
193
|
J as createCubeApp,
|
|
173
|
-
|
|
174
|
-
|
|
194
|
+
L as createCubeRouter,
|
|
195
|
+
N as mountCubeRoutes
|
|
175
196
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
const
|
|
1
|
+
import { S as E, d as o, f, h as R, a as $, b as q, c as Q } from "../compiler-DdaSPwZs.js";
|
|
2
|
+
const v = function(a, x, p) {
|
|
3
3
|
const {
|
|
4
|
-
cubes:
|
|
5
|
-
drizzle:
|
|
6
|
-
schema:
|
|
4
|
+
cubes: b,
|
|
5
|
+
drizzle: C,
|
|
6
|
+
schema: w,
|
|
7
7
|
extractSecurityContext: y,
|
|
8
8
|
engineType: S,
|
|
9
|
-
cors:
|
|
10
|
-
basePath:
|
|
11
|
-
bodyLimit:
|
|
9
|
+
cors: h,
|
|
10
|
+
basePath: c = "/cubejs-api/v1",
|
|
11
|
+
bodyLimit: m = 10485760
|
|
12
12
|
// 10MB
|
|
13
|
-
} =
|
|
14
|
-
if (!
|
|
13
|
+
} = x;
|
|
14
|
+
if (!b || b.length === 0)
|
|
15
15
|
return p(new Error("At least one cube must be provided in the cubes array"));
|
|
16
|
-
|
|
16
|
+
h && a.register(import("@fastify/cors"), h), a.addHook("onRequest", async (r, t) => {
|
|
17
17
|
r.method === "POST" && (r.body = void 0);
|
|
18
18
|
});
|
|
19
|
-
const
|
|
20
|
-
drizzle:
|
|
21
|
-
schema:
|
|
19
|
+
const n = new E({
|
|
20
|
+
drizzle: C,
|
|
21
|
+
schema: w,
|
|
22
22
|
engineType: S
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}), a.post(`${
|
|
27
|
-
bodyLimit:
|
|
24
|
+
b.forEach((r) => {
|
|
25
|
+
n.registerCube(r);
|
|
26
|
+
}), a.post(`${c}/load`, {
|
|
27
|
+
bodyLimit: m,
|
|
28
28
|
schema: {
|
|
29
29
|
body: {
|
|
30
30
|
type: "object",
|
|
@@ -33,21 +33,21 @@ const Q = function(a, C, p) {
|
|
|
33
33
|
}
|
|
34
34
|
}, async (r, t) => {
|
|
35
35
|
try {
|
|
36
|
-
const e = r.body, s = e.query || e,
|
|
37
|
-
if (!
|
|
38
|
-
return t.status(400).send(
|
|
39
|
-
`Query validation failed: ${
|
|
36
|
+
const e = r.body, s = e.query || e, i = await y(r), u = n.validateQuery(s);
|
|
37
|
+
if (!u.isValid)
|
|
38
|
+
return t.status(400).send(o(
|
|
39
|
+
`Query validation failed: ${u.errors.join(", ")}`,
|
|
40
40
|
400
|
|
41
41
|
));
|
|
42
|
-
const
|
|
43
|
-
return
|
|
42
|
+
const d = await n.executeMultiCubeQuery(s, i);
|
|
43
|
+
return f(s, d, n);
|
|
44
44
|
} catch (e) {
|
|
45
|
-
return r.log.error(e, "Query execution error"), t.status(500).send(
|
|
45
|
+
return r.log.error(e, "Query execution error"), t.status(500).send(o(
|
|
46
46
|
e instanceof Error ? e.message : "Query execution failed",
|
|
47
47
|
500
|
|
48
48
|
));
|
|
49
49
|
}
|
|
50
|
-
}), a.get(`${
|
|
50
|
+
}), a.get(`${c}/load`, {
|
|
51
51
|
schema: {
|
|
52
52
|
querystring: {
|
|
53
53
|
type: "object",
|
|
@@ -64,37 +64,72 @@ const Q = function(a, C, p) {
|
|
|
64
64
|
try {
|
|
65
65
|
s = JSON.parse(e);
|
|
66
66
|
} catch {
|
|
67
|
-
return t.status(400).send(
|
|
67
|
+
return t.status(400).send(o(
|
|
68
68
|
"Invalid JSON in query parameter",
|
|
69
69
|
400
|
|
70
70
|
));
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
74
|
-
return t.status(400).send(
|
|
75
|
-
`Query validation failed: ${
|
|
72
|
+
const i = await y(r), u = n.validateQuery(s);
|
|
73
|
+
if (!u.isValid)
|
|
74
|
+
return t.status(400).send(o(
|
|
75
|
+
`Query validation failed: ${u.errors.join(", ")}`,
|
|
76
76
|
400
|
|
77
77
|
));
|
|
78
|
-
const
|
|
79
|
-
return
|
|
78
|
+
const d = await n.executeMultiCubeQuery(s, i);
|
|
79
|
+
return f(s, d, n);
|
|
80
80
|
} catch (e) {
|
|
81
|
-
return r.log.error(e, "Query execution error"), t.status(500).send(
|
|
81
|
+
return r.log.error(e, "Query execution error"), t.status(500).send(o(
|
|
82
82
|
e instanceof Error ? e.message : "Query execution failed",
|
|
83
83
|
500
|
|
84
84
|
));
|
|
85
85
|
}
|
|
86
|
-
}), a.
|
|
86
|
+
}), a.post(`${c}/batch`, {
|
|
87
|
+
bodyLimit: m,
|
|
88
|
+
schema: {
|
|
89
|
+
body: {
|
|
90
|
+
type: "object",
|
|
91
|
+
required: ["queries"],
|
|
92
|
+
properties: {
|
|
93
|
+
queries: {
|
|
94
|
+
type: "array",
|
|
95
|
+
items: { type: "object" }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, async (r, t) => {
|
|
101
|
+
try {
|
|
102
|
+
const { queries: e } = r.body;
|
|
103
|
+
if (!e || !Array.isArray(e))
|
|
104
|
+
return t.status(400).send(o(
|
|
105
|
+
'Request body must contain a "queries" array',
|
|
106
|
+
400
|
|
107
|
+
));
|
|
108
|
+
if (e.length === 0)
|
|
109
|
+
return t.status(400).send(o(
|
|
110
|
+
"Queries array cannot be empty",
|
|
111
|
+
400
|
|
112
|
+
));
|
|
113
|
+
const s = await y(r);
|
|
114
|
+
return await R(e, s, n);
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return r.log.error(e, "Batch execution error"), t.status(500).send(o(
|
|
117
|
+
e instanceof Error ? e.message : "Batch execution failed",
|
|
118
|
+
500
|
|
119
|
+
));
|
|
120
|
+
}
|
|
121
|
+
}), a.get(`${c}/meta`, async (r, t) => {
|
|
87
122
|
try {
|
|
88
|
-
const e =
|
|
123
|
+
const e = n.getMetadata();
|
|
89
124
|
return $(e);
|
|
90
125
|
} catch (e) {
|
|
91
|
-
return r.log.error(e, "Metadata error"), t.status(500).send(
|
|
126
|
+
return r.log.error(e, "Metadata error"), t.status(500).send(o(
|
|
92
127
|
e instanceof Error ? e.message : "Failed to fetch metadata",
|
|
93
128
|
500
|
|
94
129
|
));
|
|
95
130
|
}
|
|
96
|
-
}), a.post(`${
|
|
97
|
-
bodyLimit:
|
|
131
|
+
}), a.post(`${c}/sql`, {
|
|
132
|
+
bodyLimit: m,
|
|
98
133
|
schema: {
|
|
99
134
|
body: {
|
|
100
135
|
type: "object",
|
|
@@ -103,27 +138,27 @@ const Q = function(a, C, p) {
|
|
|
103
138
|
}
|
|
104
139
|
}, async (r, t) => {
|
|
105
140
|
try {
|
|
106
|
-
const e = r.body, s = await y(r),
|
|
107
|
-
if (!
|
|
108
|
-
return t.status(400).send(
|
|
109
|
-
`Query validation failed: ${
|
|
141
|
+
const e = r.body, s = await y(r), i = n.validateQuery(e);
|
|
142
|
+
if (!i.isValid)
|
|
143
|
+
return t.status(400).send(o(
|
|
144
|
+
`Query validation failed: ${i.errors.join(", ")}`,
|
|
110
145
|
400
|
|
111
146
|
));
|
|
112
|
-
const
|
|
113
|
-
if (!
|
|
114
|
-
return t.status(400).send(
|
|
147
|
+
const u = e.measures?.[0] || e.dimensions?.[0];
|
|
148
|
+
if (!u)
|
|
149
|
+
return t.status(400).send(o(
|
|
115
150
|
"No measures or dimensions specified",
|
|
116
151
|
400
|
|
117
152
|
));
|
|
118
|
-
const
|
|
119
|
-
return
|
|
153
|
+
const d = u.split(".")[0], g = await n.generateSQL(d, e, s);
|
|
154
|
+
return q(e, g);
|
|
120
155
|
} catch (e) {
|
|
121
|
-
return r.log.error(e, "SQL generation error"), t.status(500).send(
|
|
156
|
+
return r.log.error(e, "SQL generation error"), t.status(500).send(o(
|
|
122
157
|
e instanceof Error ? e.message : "SQL generation failed",
|
|
123
158
|
500
|
|
124
159
|
));
|
|
125
160
|
}
|
|
126
|
-
}), a.get(`${
|
|
161
|
+
}), a.get(`${c}/sql`, {
|
|
127
162
|
schema: {
|
|
128
163
|
querystring: {
|
|
129
164
|
type: "object",
|
|
@@ -135,28 +170,28 @@ const Q = function(a, C, p) {
|
|
|
135
170
|
}
|
|
136
171
|
}, async (r, t) => {
|
|
137
172
|
try {
|
|
138
|
-
const { query: e } = r.query, s = JSON.parse(e),
|
|
139
|
-
if (!
|
|
140
|
-
return t.status(400).send(
|
|
141
|
-
`Query validation failed: ${
|
|
173
|
+
const { query: e } = r.query, s = JSON.parse(e), i = await y(r), u = n.validateQuery(s);
|
|
174
|
+
if (!u.isValid)
|
|
175
|
+
return t.status(400).send(o(
|
|
176
|
+
`Query validation failed: ${u.errors.join(", ")}`,
|
|
142
177
|
400
|
|
143
178
|
));
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
146
|
-
return t.status(400).send(
|
|
179
|
+
const d = s.measures?.[0] || s.dimensions?.[0];
|
|
180
|
+
if (!d)
|
|
181
|
+
return t.status(400).send(o(
|
|
147
182
|
"No measures or dimensions specified",
|
|
148
183
|
400
|
|
149
184
|
));
|
|
150
|
-
const
|
|
151
|
-
return
|
|
185
|
+
const g = d.split(".")[0], j = await n.generateSQL(g, s, i);
|
|
186
|
+
return q(s, j);
|
|
152
187
|
} catch (e) {
|
|
153
|
-
return r.log.error(e, "SQL generation error"), t.status(500).send(
|
|
188
|
+
return r.log.error(e, "SQL generation error"), t.status(500).send(o(
|
|
154
189
|
e instanceof Error ? e.message : "SQL generation failed",
|
|
155
190
|
500
|
|
156
191
|
));
|
|
157
192
|
}
|
|
158
|
-
}), a.post(`${
|
|
159
|
-
bodyLimit:
|
|
193
|
+
}), a.post(`${c}/dry-run`, {
|
|
194
|
+
bodyLimit: m,
|
|
160
195
|
schema: {
|
|
161
196
|
body: {
|
|
162
197
|
type: "object",
|
|
@@ -165,15 +200,15 @@ const Q = function(a, C, p) {
|
|
|
165
200
|
}
|
|
166
201
|
}, async (r, t) => {
|
|
167
202
|
try {
|
|
168
|
-
const e = r.body, s = e.query || e,
|
|
169
|
-
return await
|
|
203
|
+
const e = r.body, s = e.query || e, i = await y(r);
|
|
204
|
+
return await Q(s, i, n);
|
|
170
205
|
} catch (e) {
|
|
171
206
|
return r.log.error(e, "Dry-run error"), t.status(400).send({
|
|
172
207
|
error: e instanceof Error ? e.message : "Dry-run validation failed",
|
|
173
208
|
valid: !1
|
|
174
209
|
});
|
|
175
210
|
}
|
|
176
|
-
}), a.get(`${
|
|
211
|
+
}), a.get(`${c}/dry-run`, {
|
|
177
212
|
schema: {
|
|
178
213
|
querystring: {
|
|
179
214
|
type: "object",
|
|
@@ -185,27 +220,27 @@ const Q = function(a, C, p) {
|
|
|
185
220
|
}
|
|
186
221
|
}, async (r, t) => {
|
|
187
222
|
try {
|
|
188
|
-
const { query: e } = r.query, s = JSON.parse(e),
|
|
189
|
-
return await
|
|
223
|
+
const { query: e } = r.query, s = JSON.parse(e), i = await y(r);
|
|
224
|
+
return await Q(s, i, n);
|
|
190
225
|
} catch (e) {
|
|
191
226
|
return r.log.error(e, "Dry-run error"), t.status(400).send({
|
|
192
227
|
error: e instanceof Error ? e.message : "Dry-run validation failed",
|
|
193
228
|
valid: !1
|
|
194
229
|
});
|
|
195
230
|
}
|
|
196
|
-
}), a.setErrorHandler(async (r, t, e) => (t.log.error(r, "Fastify cube adapter error"), e.statusCode < 400 && e.status(500),
|
|
231
|
+
}), a.setErrorHandler(async (r, t, e) => (t.log.error(r, "Fastify cube adapter error"), e.statusCode < 400 && e.status(500), o(r, e.statusCode))), p();
|
|
197
232
|
};
|
|
198
233
|
async function L(l, a) {
|
|
199
|
-
await l.register(
|
|
234
|
+
await l.register(v, a);
|
|
200
235
|
}
|
|
201
|
-
function
|
|
236
|
+
function N(l) {
|
|
202
237
|
const a = require("fastify")({
|
|
203
238
|
logger: !0
|
|
204
239
|
});
|
|
205
|
-
return a.register(
|
|
240
|
+
return a.register(v, l), a;
|
|
206
241
|
}
|
|
207
242
|
export {
|
|
208
|
-
|
|
209
|
-
|
|
243
|
+
N as createCubeApp,
|
|
244
|
+
v as cubePlugin,
|
|
210
245
|
L as registerCubeRoutes
|
|
211
246
|
};
|