drizzle-cube 0.1.35 → 0.1.37

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.
@@ -1,6 +1,6 @@
1
1
  import p, { Router as w } from "express";
2
2
  import S from "cors";
3
- import { S as E, c as s, f as g, a as R, b as q, h as v } from "../compiler-Ce33cdy6.js";
3
+ import { S as E, c as s, f as g, a as R, b as q, h as v } from "../compiler-CiUqnN3l.js";
4
4
  function $(l) {
5
5
  const {
6
6
  cubes: c,
@@ -1,4 +1,4 @@
1
- import { S as j, c as i, f as q, a as $, b as h, h as v } from "../compiler-Ce33cdy6.js";
1
+ import { S as j, c as i, f as q, a as $, b as h, h as v } from "../compiler-CiUqnN3l.js";
2
2
  const Q = function(a, C, p) {
3
3
  const {
4
4
  cubes: g,
@@ -1,5 +1,5 @@
1
1
  import { Hono as w } from "hono";
2
- import { S as x, f as j, a as Q, b as g, h as p } from "../compiler-Ce33cdy6.js";
2
+ import { S as x, f as g, a as Q, b as j, h as p } from "../compiler-CiUqnN3l.js";
3
3
  var v = (d) => {
4
4
  const u = {
5
5
  ...{
@@ -11,30 +11,26 @@ var v = (d) => {
11
11
  ...d
12
12
  }, h = /* @__PURE__ */ ((a) => typeof a == "string" ? a === "*" ? () => a : (o) => a === o ? o : null : typeof a == "function" ? a : (o) => a.includes(o) ? o : null)(u.origin), f = ((a) => typeof a == "function" ? a : Array.isArray(a) ? () => a : () => [])(u.allowMethods);
13
13
  return async function(o, c) {
14
- function s(r, e) {
14
+ function n(r, e) {
15
15
  o.res.headers.set(r, e);
16
16
  }
17
- const n = await h(o.req.header("origin") || "", o);
18
- if (n && s("Access-Control-Allow-Origin", n), u.origin !== "*") {
19
- const r = o.req.header("Vary");
20
- r ? s("Vary", r) : s("Vary", "Origin");
21
- }
22
- if (u.credentials && s("Access-Control-Allow-Credentials", "true"), u.exposeHeaders?.length && s("Access-Control-Expose-Headers", u.exposeHeaders.join(",")), o.req.method === "OPTIONS") {
23
- u.maxAge != null && s("Access-Control-Max-Age", u.maxAge.toString());
17
+ const s = await h(o.req.header("origin") || "", o);
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
+ u.origin !== "*" && n("Vary", "Origin"), u.maxAge != null && n("Access-Control-Max-Age", u.maxAge.toString());
24
20
  const r = await f(o.req.header("origin") || "", o);
25
- r.length && s("Access-Control-Allow-Methods", r.join(","));
21
+ r.length && n("Access-Control-Allow-Methods", r.join(","));
26
22
  let e = u.allowHeaders;
27
23
  if (!e?.length) {
28
24
  const t = o.req.header("Access-Control-Request-Headers");
29
25
  t && (e = t.split(/\s*,\s*/));
30
26
  }
31
- return e?.length && (s("Access-Control-Allow-Headers", e.join(",")), o.res.headers.append("Vary", "Access-Control-Request-Headers")), o.res.headers.delete("Content-Length"), o.res.headers.delete("Content-Type"), new Response(null, {
27
+ return e?.length && (n("Access-Control-Allow-Headers", e.join(",")), o.res.headers.append("Vary", "Access-Control-Request-Headers")), o.res.headers.delete("Content-Length"), o.res.headers.delete("Content-Type"), new Response(null, {
32
28
  headers: o.res.headers,
33
29
  status: 204,
34
30
  statusText: "No Content"
35
31
  });
36
32
  }
37
- await c();
33
+ await c(), u.origin !== "*" && o.header("Vary", "Origin", { append: !0 });
38
34
  };
39
35
  };
40
36
  function A(d) {
@@ -49,30 +45,30 @@ function A(d) {
49
45
  } = d;
50
46
  if (!y || y.length === 0)
51
47
  throw new Error("At least one cube must be provided in the cubes array");
52
- const s = new w();
53
- o && s.use("/*", v(o));
54
- const n = new x({
48
+ const n = new w();
49
+ o && n.use("/*", v(o));
50
+ const s = new x({
55
51
  drizzle: u,
56
52
  schema: h,
57
53
  engineType: a
58
54
  });
59
55
  return y.forEach((r) => {
60
- n.registerCube(r);
61
- }), s.post(`${c}/load`, async (r) => {
56
+ s.registerCube(r);
57
+ }), n.post(`${c}/load`, async (r) => {
62
58
  try {
63
- const e = await r.req.json(), t = e.query || e, l = await f(r), i = n.validateQuery(t);
59
+ const e = await r.req.json(), t = e.query || e, l = await f(r), i = s.validateQuery(t);
64
60
  if (!i.isValid)
65
61
  return r.json({
66
62
  error: `Query validation failed: ${i.errors.join(", ")}`
67
63
  }, 400);
68
- const m = await n.executeMultiCubeQuery(t, l);
69
- return r.json(j(t, m, n));
64
+ const m = await s.executeMultiCubeQuery(t, l);
65
+ return r.json(g(t, m, s));
70
66
  } catch (e) {
71
67
  return console.error("Query execution error:", e), r.json({
72
68
  error: e instanceof Error ? e.message : "Query execution failed"
73
69
  }, 500);
74
70
  }
75
- }), s.get(`${c}/load`, async (r) => {
71
+ }), n.get(`${c}/load`, async (r) => {
76
72
  try {
77
73
  const e = r.req.query("query");
78
74
  if (!e)
@@ -87,30 +83,30 @@ function A(d) {
87
83
  error: "Invalid JSON in query parameter"
88
84
  }, 400);
89
85
  }
90
- const l = await f(r), i = n.validateQuery(t);
86
+ const l = await f(r), i = s.validateQuery(t);
91
87
  if (!i.isValid)
92
88
  return r.json({
93
89
  error: `Query validation failed: ${i.errors.join(", ")}`
94
90
  }, 400);
95
- const m = await n.executeMultiCubeQuery(t, l);
96
- return r.json(j(t, m, n));
91
+ const m = await s.executeMultiCubeQuery(t, l);
92
+ return r.json(g(t, m, s));
97
93
  } catch (e) {
98
94
  return console.error("Query execution error:", e), r.json({
99
95
  error: e instanceof Error ? e.message : "Query execution failed"
100
96
  }, 500);
101
97
  }
102
- }), s.get(`${c}/meta`, (r) => {
98
+ }), n.get(`${c}/meta`, (r) => {
103
99
  try {
104
- const e = n.getMetadata();
100
+ const e = s.getMetadata();
105
101
  return r.json(Q(e));
106
102
  } catch (e) {
107
103
  return console.error("Metadata error:", e), r.json({
108
104
  error: e instanceof Error ? e.message : "Failed to fetch metadata"
109
105
  }, 500);
110
106
  }
111
- }), s.post(`${c}/sql`, async (r) => {
107
+ }), n.post(`${c}/sql`, async (r) => {
112
108
  try {
113
- const e = await r.req.json(), t = await f(r), l = n.validateQuery(e);
109
+ const e = await r.req.json(), t = await f(r), l = s.validateQuery(e);
114
110
  if (!l.isValid)
115
111
  return r.json({
116
112
  error: `Query validation failed: ${l.errors.join(", ")}`
@@ -120,21 +116,21 @@ function A(d) {
120
116
  return r.json({
121
117
  error: "No measures or dimensions specified"
122
118
  }, 400);
123
- const m = i.split(".")[0], q = await n.generateSQL(m, e, t);
124
- return r.json(g(e, q));
119
+ const m = i.split(".")[0], q = await s.generateSQL(m, e, t);
120
+ return r.json(j(e, q));
125
121
  } catch (e) {
126
122
  return console.error("SQL generation error:", e), r.json({
127
123
  error: e instanceof Error ? e.message : "SQL generation failed"
128
124
  }, 500);
129
125
  }
130
- }), s.get(`${c}/sql`, async (r) => {
126
+ }), n.get(`${c}/sql`, async (r) => {
131
127
  try {
132
128
  const e = r.req.query("query");
133
129
  if (!e)
134
130
  return r.json({
135
131
  error: "Query parameter is required"
136
132
  }, 400);
137
- const t = JSON.parse(e), l = await f(r), i = n.validateQuery(t);
133
+ const t = JSON.parse(e), l = await f(r), i = s.validateQuery(t);
138
134
  if (!i.isValid)
139
135
  return r.json({
140
136
  error: `Query validation failed: ${i.errors.join(", ")}`
@@ -144,16 +140,16 @@ function A(d) {
144
140
  return r.json({
145
141
  error: "No measures or dimensions specified"
146
142
  }, 400);
147
- const q = m.split(".")[0], C = await n.generateSQL(q, t, l);
148
- return r.json(g(t, C));
143
+ const q = m.split(".")[0], C = await s.generateSQL(q, t, l);
144
+ return r.json(j(t, C));
149
145
  } catch (e) {
150
146
  return console.error("SQL generation error:", e), r.json({
151
147
  error: e instanceof Error ? e.message : "SQL generation failed"
152
148
  }, 500);
153
149
  }
154
- }), s.post(`${c}/dry-run`, async (r) => {
150
+ }), n.post(`${c}/dry-run`, async (r) => {
155
151
  try {
156
- const e = await r.req.json(), t = e.query || e, l = await f(r), i = await p(t, l, n);
152
+ const e = await r.req.json(), t = e.query || e, l = await f(r), i = await p(t, l, s);
157
153
  return r.json(i);
158
154
  } catch (e) {
159
155
  return console.error("Dry-run error:", e), r.json({
@@ -161,7 +157,7 @@ function A(d) {
161
157
  valid: !1
162
158
  }, 400);
163
159
  }
164
- }), s.get(`${c}/dry-run`, async (r) => {
160
+ }), n.get(`${c}/dry-run`, async (r) => {
165
161
  try {
166
162
  const e = r.req.query("query");
167
163
  if (!e)
@@ -169,7 +165,7 @@ function A(d) {
169
165
  error: "Query parameter is required",
170
166
  valid: !1
171
167
  }, 400);
172
- const t = JSON.parse(e), l = await f(r), i = await p(t, l, n);
168
+ const t = JSON.parse(e), l = await f(r), i = await p(t, l, s);
173
169
  return r.json(i);
174
170
  } catch (e) {
175
171
  return console.error("Dry-run error:", e), r.json({
@@ -177,7 +173,7 @@ function A(d) {
177
173
  valid: !1
178
174
  }, 400);
179
175
  }
180
- }), s;
176
+ }), n;
181
177
  }
182
178
  function b(d, y) {
183
179
  const u = A(y);
@@ -1,5 +1,5 @@
1
1
  import { NextResponse as o } from "next/server";
2
- import { c, f as x, a as E, b as N, h as S, S as p } from "../compiler-Ce33cdy6.js";
2
+ import { c, f as x, a as E, b as N, h as S, S as p } from "../compiler-CiUqnN3l.js";
3
3
  function g(n) {
4
4
  const { cubes: r, drizzle: a, schema: s, engineType: f } = n;
5
5
  if (!r || r.length === 0)
@@ -4759,15 +4759,6 @@ function Hy(e) {
4759
4759
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4760
4760
  }
4761
4761
  var qr = { exports: {} }, Bn = {}, Dr = { exports: {} }, Hn = {};
4762
- /**
4763
- * @license React
4764
- * use-sync-external-store-shim.production.js
4765
- *
4766
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4767
- *
4768
- * This source code is licensed under the MIT license found in the
4769
- * LICENSE file in the root directory of this source tree.
4770
- */
4771
4762
  var Xu;
4772
4763
  function yN() {
4773
4764
  if (Xu) return Hn;
@@ -4810,15 +4801,6 @@ function yN() {
4810
4801
  return Hn.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : l, Hn;
4811
4802
  }
4812
4803
  var jn = {};
4813
- /**
4814
- * @license React
4815
- * use-sync-external-store-shim.development.js
4816
- *
4817
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4818
- *
4819
- * This source code is licensed under the MIT license found in the
4820
- * LICENSE file in the root directory of this source tree.
4821
- */
4822
4804
  var Zu;
4823
4805
  function bN() {
4824
4806
  return Zu || (Zu = 1, process.env.NODE_ENV !== "production" && (function() {
@@ -4876,15 +4858,6 @@ var Ju;
4876
4858
  function jy() {
4877
4859
  return Ju || (Ju = 1, process.env.NODE_ENV === "production" ? Dr.exports = /* @__PURE__ */ yN() : Dr.exports = /* @__PURE__ */ bN()), Dr.exports;
4878
4860
  }
4879
- /**
4880
- * @license React
4881
- * use-sync-external-store-shim/with-selector.production.js
4882
- *
4883
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4884
- *
4885
- * This source code is licensed under the MIT license found in the
4886
- * LICENSE file in the root directory of this source tree.
4887
- */
4888
4861
  var ed;
4889
4862
  function vN() {
4890
4863
  if (ed) return Bn;
@@ -4937,15 +4910,6 @@ function vN() {
4937
4910
  }, Bn;
4938
4911
  }
4939
4912
  var Gn = {};
4940
- /**
4941
- * @license React
4942
- * use-sync-external-store-shim/with-selector.development.js
4943
- *
4944
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4945
- *
4946
- * This source code is licensed under the MIT license found in the
4947
- * LICENSE file in the root directory of this source tree.
4948
- */
4949
4913
  var td;
4950
4914
  function xN() {
4951
4915
  return td || (td = 1, process.env.NODE_ENV !== "production" && (function() {
@@ -16738,7 +16702,7 @@ const $T = ({
16738
16702
  /* @__PURE__ */ d("div", { className: "flex-1", onClick: () => N(!1) })
16739
16703
  ] }),
16740
16704
  /* @__PURE__ */ E("div", { className: "flex-1 flex flex-col md:flex-row gap-4 p-4 min-h-0", style: { paddingTop: n ? "1rem" : "0rem" }, children: [
16741
- /* @__PURE__ */ d("div", { className: `hidden md:flex shrink-0 flex-col min-w-0 ${_ === "diagram" ? "w-full max-w-[600px]" : "md:w-1/3 max-w-[500px]"}`, children: /* @__PURE__ */ d(
16705
+ /* @__PURE__ */ d("div", { className: `hidden md:flex shrink-0 flex-col min-w-0 ${_ === "diagram" ? "w-full" : "md:w-1/3 max-w-[500px]"}`, children: /* @__PURE__ */ d(
16742
16706
  Qg,
16743
16707
  {
16744
16708
  schema: l.schema,
@@ -19960,4 +19924,4 @@ export {
19960
19924
  cN as s,
19961
19925
  zy as w
19962
19926
  };
19963
- //# sourceMappingURL=components-D3Bl_BuN.js.map
19927
+ //# sourceMappingURL=components-BeCaouWH.js.map