drizzle-cube 0.1.14 → 0.1.16

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.
Files changed (47) hide show
  1. package/dist/adapters/compiler-Dec55JjO.js +19988 -0
  2. package/dist/adapters/express/index.js +29 -29
  3. package/dist/adapters/fastify/index.js +31 -31
  4. package/dist/adapters/hono/index.js +38 -38
  5. package/dist/adapters/nextjs/index.js +43 -43
  6. package/dist/adapters/utils.d.ts +4 -0
  7. package/dist/client/charts.d.ts +10 -0
  8. package/dist/client/charts.js +18 -0
  9. package/dist/client/charts.js.map +1 -0
  10. package/dist/client/chunks/charts-BadAUMmd.js +2285 -0
  11. package/dist/client/chunks/charts-BadAUMmd.js.map +1 -0
  12. package/dist/client/chunks/icons-D95augkg.js +1916 -0
  13. package/dist/client/chunks/icons-D95augkg.js.map +1 -0
  14. package/dist/client/chunks/providers-DI5zeeEU.js +211 -0
  15. package/dist/client/chunks/providers-DI5zeeEU.js.map +1 -0
  16. package/dist/client/components/AIAssistant/AIAssistantModal.d.ts +10 -0
  17. package/dist/client/components/AIAssistant/constants.d.ts +11 -0
  18. package/dist/client/components/AIAssistant/index.d.ts +7 -0
  19. package/dist/client/components/AIAssistant/types.d.ts +49 -0
  20. package/dist/client/components/AIAssistant/utils.d.ts +17 -0
  21. package/dist/client/components/QueryBuilder/DateRangeFilter.d.ts +4 -0
  22. package/dist/client/components/QueryBuilder/DateRangeSelector.d.ts +11 -0
  23. package/dist/client/components/QueryBuilder/types.d.ts +32 -0
  24. package/dist/client/components/QueryBuilder/utils.d.ts +70 -1
  25. package/dist/client/components.d.ts +16 -0
  26. package/dist/client/components.js +6191 -0
  27. package/dist/client/components.js.map +1 -0
  28. package/dist/client/hooks.d.ts +11 -0
  29. package/dist/client/hooks.js +132 -0
  30. package/dist/client/hooks.js.map +1 -0
  31. package/dist/client/index.d.ts +1 -1
  32. package/dist/client/index.js +29 -30132
  33. package/dist/client/index.js.map +1 -0
  34. package/dist/client/providers/CubeProvider.d.ts +5 -2
  35. package/dist/client/providers.d.ts +9 -0
  36. package/dist/client/providers.js +7 -0
  37. package/dist/client/providers.js.map +1 -0
  38. package/dist/client/styles.css +1 -1
  39. package/dist/client/types.d.ts +4 -0
  40. package/dist/client/utils.d.ts +8 -0
  41. package/dist/client/utils.js +2 -0
  42. package/dist/client/utils.js.map +1 -0
  43. package/dist/client-bundle-stats.html +4949 -0
  44. package/dist/server/index.d.ts +226 -365
  45. package/dist/server/index.js +18886 -1555
  46. package/package.json +26 -2
  47. package/dist/adapters/utils-C3A4JGFs.js +0 -3779
@@ -1,29 +1,29 @@
1
- import g, { Router as $ } from "express";
2
- import E from "cors";
3
- import { S as R, c as a, f as v, a as L, b as x, h as C } from "../utils-C3A4JGFs.js";
4
- function N(y) {
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-Dec55JjO.js";
4
+ function N(l) {
5
5
  const {
6
6
  cubes: c,
7
7
  drizzle: p,
8
- schema: w,
8
+ schema: C,
9
9
  extractSecurityContext: d,
10
- engineType: Q,
11
- cors: h,
12
- basePath: l = "/cubejs-api/v1",
10
+ engineType: w,
11
+ cors: g,
12
+ basePath: y = "/cubejs-api/v1",
13
13
  jsonLimit: q = "10mb"
14
- } = y;
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
- h && u.use(E(h)), u.use(g.json({ limit: q })), u.use(g.urlencoded({ extended: !0, limit: q }));
19
- const n = new R({
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: w,
22
- engineType: Q
21
+ schema: C,
22
+ engineType: w
23
23
  });
24
24
  return c.forEach((t) => {
25
25
  n.registerCube(t);
26
- }), console.log(`🚀 Drizzle Cube: Registered ${c.length} cube(s) with ${Q || "auto-detected"} engine`), u.post(`${l}/load`, async (t, r) => {
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(`${l}/load`, async (t, r) => {
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(`${l}/meta`, (t, r) => {
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(`${l}/sql`, async (t, r) => {
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(`${l}/sql`, async (t, r) => {
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(`${l}/dry-run`, async (t, r) => {
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 C(e, s, n);
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(`${l}/dry-run`, async (t, r) => {
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 C(s, o, n);
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(y, c) {
165
+ function M(l, c) {
166
166
  const p = N(c);
167
- return y.use("/", p), y;
167
+ return l.use("/", p), l;
168
168
  }
169
- function O(y) {
170
- const c = g();
171
- return M(c, y);
169
+ function P(l) {
170
+ const c = Q();
171
+ return M(c, l);
172
172
  }
173
173
  export {
174
- O as createCubeApp,
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 Q, a as R, b as C, h as w } from "../utils-C3A4JGFs.js";
2
- const x = function(o, S, h) {
1
+ import { S as P, c as u, f as v, a as L, b as Q, h as C } from "../compiler-Dec55JjO.js";
2
+ const w = function(o, x, q) {
3
3
  const {
4
- cubes: m,
5
- drizzle: $,
4
+ cubes: b,
5
+ drizzle: S,
6
6
  schema: E,
7
7
  extractSecurityContext: y,
8
- engineType: q,
9
- cors: v,
8
+ engineType: j,
9
+ cors: h,
10
10
  basePath: d = "/cubejs-api/v1",
11
11
  bodyLimit: p = 10485760
12
12
  // 10MB
13
- } = S;
14
- if (!m || m.length === 0)
15
- return h(new Error("At least one cube must be provided in the cubes array"));
16
- v && o.register(import("@fastify/cors"), v), o.addHook("onRequest", async (r, t) => {
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: q
22
+ engineType: j
23
23
  });
24
- m.forEach((r) => {
24
+ b.forEach((r) => {
25
25
  i.registerCube(r);
26
- }), console.log(`🚀 Drizzle Cube: Registered ${m.length} cube(s) with ${q || "auto-detected"} engine`), o.post(`${d}/load`, {
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 Q(a, c, i);
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 Q(a, c, i);
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 R(e);
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 b = l.split(".")[0], f = await i.generateSQL(b, s, n);
120
- return C(s, f);
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 b = ((e = n.measures) == null ? void 0 : e[0]) || ((a = n.dimensions) == null ? void 0 : a[0]);
147
- if (!b)
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 = b.split(".")[0], j = await i.generateSQL(f, n, c);
153
- return C(n, j);
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 w(a, s, i);
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 w(a, s, i);
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))), h();
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(g, o) {
201
- await g.register(x, o);
200
+ async function N(m, o) {
201
+ await m.register(w, o);
202
202
  }
203
- function M(g) {
203
+ function M(m) {
204
204
  const o = require("fastify")({
205
205
  logger: !0
206
206
  });
207
- return o.register(x, g), o;
207
+ return o.register(w, m), o;
208
208
  }
209
209
  export {
210
210
  M as createCubeApp,
211
- x as cubePlugin,
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 b, f as p, a as v, b as w, h as C } from "../utils-C3A4JGFs.js";
3
- var A = (y) => {
2
+ import { S as v, f as h, a as A, b as w, h as C } from "../compiler-Dec55JjO.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
- ...y
12
- }, j = /* @__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, d) {
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 = j(n.req.header("origin") || "", n);
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 d();
38
+ await c();
39
39
  };
40
40
  };
41
- function S(y) {
41
+ function S(d) {
42
42
  const {
43
- cubes: c,
43
+ cubes: y,
44
44
  drizzle: l,
45
- schema: j,
45
+ schema: g,
46
46
  extractSecurityContext: f,
47
47
  engineType: u,
48
48
  cors: n,
49
- basePath: d = "/cubejs-api/v1"
50
- } = y;
51
- if (!c || c.length === 0)
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("/*", A(n));
55
- const a = new b({
54
+ n && s.use("/*", b(n));
55
+ const a = new v({
56
56
  drizzle: l,
57
- schema: j,
57
+ schema: g,
58
58
  engineType: u
59
59
  });
60
- return c.forEach((e) => {
60
+ return y.forEach((e) => {
61
61
  a.registerCube(e);
62
- }), console.log(`🚀 Drizzle Cube: Registered ${c.length} cube(s) with ${u || "auto-detected"} engine`), s.post(`${d}/load`, async (e) => {
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(p(t, m, a));
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(`${d}/load`, async (e) => {
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(p(t, m, a));
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(`${d}/meta`, (e) => {
103
+ }), s.get(`${c}/meta`, (e) => {
104
104
  try {
105
105
  const r = a.getMetadata();
106
- return e.json(v(r));
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(`${d}/sql`, async (e) => {
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 g = q.split(".")[0], h = await a.generateSQL(g, o, i);
126
- return e.json(w(o, h));
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(`${d}/sql`, async (e) => {
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 g = ((r = i.measures) == null ? void 0 : r[0]) || ((t = i.dimensions) == null ? void 0 : t[0]);
146
- if (!g)
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 h = g.split(".")[0], Q = await a.generateSQL(h, i, m);
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(`${d}/dry-run`, async (e) => {
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(`${d}/dry-run`, async (e) => {
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(y, c) {
186
- const l = S(c);
187
- return y.route("/", l), y;
185
+ function E(d, y) {
186
+ const l = S(y);
187
+ return d.route("/", l), d;
188
188
  }
189
- function $(y) {
190
- const c = new x();
191
- return E(c, y);
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 S, a as b, b as H, h as p, S as v } from "../utils-C3A4JGFs.js";
3
- function j(t) {
4
- const { cubes: e, drizzle: a, schema: s, engineType: y } = t;
2
+ import { c as l, f as C, a as H, b as p, h as v, S as A } from "../compiler-Dec55JjO.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 v({
8
- drizzle: a,
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
- }), console.log(`🚀 Drizzle Cube: Registered ${e.length} cube(s) with ${y || "auto-detected"} engine`), r;
14
+ }), r;
15
15
  }
16
- function g(t, e) {
17
- const a = t.headers.get("origin"), s = {};
18
- return e.origin && (typeof e.origin == "string" ? s["Access-Control-Allow-Origin"] = e.origin : Array.isArray(e.origin) ? a && e.origin.includes(a) && (s["Access-Control-Allow-Origin"] = a) : typeof e.origin == "function" && a && e.origin(a) && (s["Access-Control-Allow-Origin"] = a)), 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;
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(a) {
22
- const s = g(a, t);
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 A(t) {
30
- const { extractSecurityContext: e, cors: a } = t, s = j(t);
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 n;
33
+ let a;
34
34
  if (r.method === "POST") {
35
35
  const d = await r.json();
36
- n = d.query || d;
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
- n = JSON.parse(d);
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(n);
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(n, f), m = S(n, u, s);
63
+ const u = await s.executeMultiCubeQuery(a, f), m = C(a, u, s);
64
64
  return o.json(m, {
65
- headers: a ? g(r, a) : {}
65
+ headers: n ? j(r, n) : {}
66
66
  });
67
- } catch (n) {
68
- return console.error("Next.js load handler error:", n), o.json(
67
+ } catch (a) {
68
+ return console.error("Next.js load handler error:", a), o.json(
69
69
  l(
70
- n instanceof Error ? n.message : "Query execution failed",
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, a = j(t);
79
+ const { cors: e } = t, n = g(t);
80
80
  return async function(y, r) {
81
81
  try {
82
- const c = a.getMetadata(), n = b(c);
83
- return o.json(n, {
84
- headers: e ? g(y, 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: a } = t, s = j(t);
98
+ const { extractSecurityContext: e, cors: n } = t, s = g(t);
99
99
  return async function(r, c) {
100
- var n, f;
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 = ((n = i.measures) == null ? void 0 : n[0]) || ((f = i.dimensions) == null ? void 0 : f[0]);
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), C = H(i, x);
139
- return o.json(C, {
140
- headers: a ? g(r, a) : {}
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: a } = t, s = j(t);
154
+ const { extractSecurityContext: e, cors: n } = t, s = g(t);
155
155
  return async function(r, c) {
156
156
  try {
157
- let n;
157
+ let a;
158
158
  if (r.method === "POST") {
159
159
  const u = await r.json();
160
- n = u.query || u;
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
- n = JSON.parse(u);
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 p(n, f, s);
181
+ const f = await e(r, c), i = await v(a, f, s);
182
182
  return o.json(i, {
183
- headers: a ? g(r, a) : {}
183
+ headers: n ? j(r, n) : {}
184
184
  });
185
- } catch (n) {
186
- return console.error("Next.js dry-run handler error:", n), o.json(
185
+ } catch (a) {
186
+ return console.error("Next.js dry-run handler error:", a), o.json(
187
187
  {
188
- error: n instanceof Error ? n.message : "Dry-run validation failed",
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: A(t),
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
- A as createLoadHandler,
207
+ b as createLoadHandler,
208
208
  E as createMetaHandler,
209
209
  P as createOptionsHandler,
210
210
  N as createSqlHandler
@@ -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
  */