drizzle-cube 0.1.29 → 0.1.31
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 +1 -1
- package/dist/adapters/{compiler-BibS3bXd.js → compiler-CVega_Gv.js} +1786 -1820
- package/dist/adapters/express/index.js +87 -89
- package/dist/adapters/fastify/index.js +81 -83
- package/dist/adapters/hono/index.js +113 -116
- package/dist/adapters/nextjs/index.js +101 -102
- package/dist/client/charts.js +1 -1
- package/dist/client/chunks/charts-MTxju0dv.js +2402 -0
- package/dist/client/chunks/charts-MTxju0dv.js.map +1 -0
- package/dist/client/chunks/{icons-B_0yoGjv.js → icons-C_McHd9z.js} +10 -1
- package/dist/client/chunks/{icons-B_0yoGjv.js.map → icons-C_McHd9z.js.map} +1 -1
- package/dist/client/chunks/providers-DwDirAYo.js +208 -0
- package/dist/client/chunks/{providers-B7MVnAAt.js.map → providers-DwDirAYo.js.map} +1 -1
- package/dist/client/components.js +9741 -9616
- package/dist/client/components.js.map +1 -1
- package/dist/client/hooks.js +2 -2
- package/dist/client/index.js +2 -2
- package/dist/client/providers.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.js +1479 -1485
- package/package.json +29 -20
- package/dist/client/chunks/charts-BM1k01Jw.js +0 -2404
- package/dist/client/chunks/charts-BM1k01Jw.js.map +0 -1
- package/dist/client/chunks/providers-B7MVnAAt.js +0 -211
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
var O = Object.defineProperty;
|
|
2
|
-
var $ = (a, e, r) => e in a ? O(a, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : a[e] = r;
|
|
3
|
-
var p = (a, e, r) => $(a, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { jsx as x } from "react/jsx-runtime";
|
|
5
|
-
import { useState as f, useCallback as w, useEffect as j, useContext as D, createContext as T, useMemo as U } from "react";
|
|
6
|
-
class S {
|
|
7
|
-
constructor(e, r = {}) {
|
|
8
|
-
p(this, "apiUrl");
|
|
9
|
-
p(this, "headers");
|
|
10
|
-
this.apiUrl = r.apiUrl || "/cubejs-api/v1", this.headers = {
|
|
11
|
-
"Content-Type": "application/json",
|
|
12
|
-
...r.headers
|
|
13
|
-
}, e && (this.headers.Authorization = e);
|
|
14
|
-
}
|
|
15
|
-
async load(e) {
|
|
16
|
-
const r = encodeURIComponent(JSON.stringify(e)), t = `${this.apiUrl}/load?query=${r}`, s = await fetch(t, {
|
|
17
|
-
method: "GET",
|
|
18
|
-
headers: {
|
|
19
|
-
// Remove Content-Type for GET request
|
|
20
|
-
...Object.fromEntries(
|
|
21
|
-
Object.entries(this.headers).filter(([n]) => n !== "Content-Type")
|
|
22
|
-
)
|
|
23
|
-
},
|
|
24
|
-
credentials: "include"
|
|
25
|
-
// Include cookies for session auth
|
|
26
|
-
});
|
|
27
|
-
if (!s.ok) {
|
|
28
|
-
let n = `Cube query failed: ${s.status}`;
|
|
29
|
-
try {
|
|
30
|
-
const l = await s.text();
|
|
31
|
-
try {
|
|
32
|
-
const c = JSON.parse(l);
|
|
33
|
-
c.error ? n = c.error : n += ` ${l}`;
|
|
34
|
-
} catch {
|
|
35
|
-
n += ` ${l}`;
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
}
|
|
39
|
-
throw new Error(n);
|
|
40
|
-
}
|
|
41
|
-
const i = await s.json();
|
|
42
|
-
return new L(i);
|
|
43
|
-
}
|
|
44
|
-
async meta() {
|
|
45
|
-
const e = `${this.apiUrl}/meta`, r = await fetch(e, {
|
|
46
|
-
method: "GET",
|
|
47
|
-
headers: this.headers,
|
|
48
|
-
credentials: "include"
|
|
49
|
-
});
|
|
50
|
-
if (!r.ok)
|
|
51
|
-
throw new Error(`Failed to fetch meta: ${r.status}`);
|
|
52
|
-
return r.json();
|
|
53
|
-
}
|
|
54
|
-
async sql(e) {
|
|
55
|
-
const r = encodeURIComponent(JSON.stringify(e)), t = `${this.apiUrl}/sql?query=${r}`, s = await fetch(t, {
|
|
56
|
-
method: "GET",
|
|
57
|
-
headers: {
|
|
58
|
-
// Remove Content-Type for GET request
|
|
59
|
-
...Object.fromEntries(
|
|
60
|
-
Object.entries(this.headers).filter(([i]) => i !== "Content-Type")
|
|
61
|
-
)
|
|
62
|
-
},
|
|
63
|
-
credentials: "include"
|
|
64
|
-
});
|
|
65
|
-
if (!s.ok)
|
|
66
|
-
throw new Error(`SQL generation failed: ${s.status}`);
|
|
67
|
-
return s.json();
|
|
68
|
-
}
|
|
69
|
-
async dryRun(e) {
|
|
70
|
-
const r = `${this.apiUrl}/dry-run`, t = await fetch(r, {
|
|
71
|
-
method: "POST",
|
|
72
|
-
headers: this.headers,
|
|
73
|
-
credentials: "include",
|
|
74
|
-
body: JSON.stringify({ query: e })
|
|
75
|
-
});
|
|
76
|
-
if (!t.ok) {
|
|
77
|
-
let s = `Dry run failed: ${t.status}`;
|
|
78
|
-
try {
|
|
79
|
-
const i = await t.text();
|
|
80
|
-
try {
|
|
81
|
-
const n = JSON.parse(i);
|
|
82
|
-
n.error ? s = n.error : s += ` ${i}`;
|
|
83
|
-
} catch {
|
|
84
|
-
s += ` ${i}`;
|
|
85
|
-
}
|
|
86
|
-
} catch {
|
|
87
|
-
}
|
|
88
|
-
throw new Error(s);
|
|
89
|
-
}
|
|
90
|
-
return t.json();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
class L {
|
|
94
|
-
constructor(e) {
|
|
95
|
-
p(this, "loadResponse");
|
|
96
|
-
this.loadResponse = e;
|
|
97
|
-
}
|
|
98
|
-
rawData() {
|
|
99
|
-
return this.loadResponse.results && this.loadResponse.results[0] ? this.loadResponse.results[0].data || [] : this.loadResponse.data || [];
|
|
100
|
-
}
|
|
101
|
-
tablePivot() {
|
|
102
|
-
return this.rawData();
|
|
103
|
-
}
|
|
104
|
-
series() {
|
|
105
|
-
return this.rawData();
|
|
106
|
-
}
|
|
107
|
-
annotation() {
|
|
108
|
-
return this.loadResponse.results && this.loadResponse.results[0] ? this.loadResponse.results[0].annotation || {} : this.loadResponse.annotation || {};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function k(a, e = {}) {
|
|
112
|
-
return new S(a, e);
|
|
113
|
-
}
|
|
114
|
-
const q = 15 * 60 * 1e3;
|
|
115
|
-
let h = null;
|
|
116
|
-
function v(a) {
|
|
117
|
-
const e = {};
|
|
118
|
-
return a.cubes.forEach((r) => {
|
|
119
|
-
r.measures.forEach((t) => {
|
|
120
|
-
e[t.name] = t.title || t.shortTitle || t.name;
|
|
121
|
-
}), r.dimensions.forEach((t) => {
|
|
122
|
-
e[t.name] = t.title || t.shortTitle || t.name;
|
|
123
|
-
}), r.segments.forEach((t) => {
|
|
124
|
-
e[t.name] = t.title || t.shortTitle || t.name;
|
|
125
|
-
});
|
|
126
|
-
}), e;
|
|
127
|
-
}
|
|
128
|
-
function P() {
|
|
129
|
-
return h ? Date.now() - h.timestamp < q : !1;
|
|
130
|
-
}
|
|
131
|
-
function F(a) {
|
|
132
|
-
const [e, r] = f(null), [t, s] = f({}), [i, n] = f(!0), [l, c] = f(null), u = w(async () => {
|
|
133
|
-
if (P() && h) {
|
|
134
|
-
r(h.data), s(h.labelMap), n(!1), c(null);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
n(!0), c(null);
|
|
139
|
-
const o = await a.meta(), d = v(o);
|
|
140
|
-
h = {
|
|
141
|
-
data: o,
|
|
142
|
-
labelMap: d,
|
|
143
|
-
timestamp: Date.now()
|
|
144
|
-
}, r(o), s(d);
|
|
145
|
-
} catch (o) {
|
|
146
|
-
const d = o instanceof Error ? o.message : "Failed to fetch metadata";
|
|
147
|
-
c(d), console.error("Failed to fetch cube metadata:", o);
|
|
148
|
-
} finally {
|
|
149
|
-
n(!1);
|
|
150
|
-
}
|
|
151
|
-
}, [a]);
|
|
152
|
-
j(() => {
|
|
153
|
-
u();
|
|
154
|
-
}, [u]);
|
|
155
|
-
const m = w((o) => t[o] || o, [t]), b = w(() => {
|
|
156
|
-
h = null, u();
|
|
157
|
-
}, [u]);
|
|
158
|
-
return {
|
|
159
|
-
meta: e,
|
|
160
|
-
labelMap: t,
|
|
161
|
-
loading: i,
|
|
162
|
-
error: l,
|
|
163
|
-
refetch: b,
|
|
164
|
-
getFieldLabel: m
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
const C = T(null);
|
|
168
|
-
function G({
|
|
169
|
-
cubeApi: a,
|
|
170
|
-
apiOptions: e,
|
|
171
|
-
token: r,
|
|
172
|
-
options: t = {},
|
|
173
|
-
features: s = { enableAI: !0, aiEndpoint: "/api/ai/generate" },
|
|
174
|
-
// Default to AI enabled for backward compatibility
|
|
175
|
-
children: i
|
|
176
|
-
}) {
|
|
177
|
-
const [n, l] = f(null), c = n || {
|
|
178
|
-
apiOptions: e || { apiUrl: "/cubejs-api/v1" },
|
|
179
|
-
token: r
|
|
180
|
-
}, u = U(() => a && !e && !r ? a : k(c.token, c.apiOptions), [a, e, r, c.apiOptions, c.token]), { meta: m, labelMap: b, loading: o, error: d, getFieldLabel: y, refetch: E } = F(u), g = {
|
|
181
|
-
cubeApi: u,
|
|
182
|
-
options: t,
|
|
183
|
-
meta: m,
|
|
184
|
-
labelMap: b,
|
|
185
|
-
metaLoading: o,
|
|
186
|
-
metaError: d,
|
|
187
|
-
getFieldLabel: y,
|
|
188
|
-
refetchMeta: E,
|
|
189
|
-
updateApiConfig: (M, R) => {
|
|
190
|
-
l({
|
|
191
|
-
apiOptions: M,
|
|
192
|
-
token: R
|
|
193
|
-
});
|
|
194
|
-
},
|
|
195
|
-
features: s
|
|
196
|
-
};
|
|
197
|
-
return /* @__PURE__ */ x(C.Provider, { value: g, children: i });
|
|
198
|
-
}
|
|
199
|
-
function V() {
|
|
200
|
-
const a = D(C);
|
|
201
|
-
if (!a)
|
|
202
|
-
throw new Error("useCubeContext must be used within a CubeProvider");
|
|
203
|
-
return a;
|
|
204
|
-
}
|
|
205
|
-
export {
|
|
206
|
-
G as C,
|
|
207
|
-
F as a,
|
|
208
|
-
k as c,
|
|
209
|
-
V as u
|
|
210
|
-
};
|
|
211
|
-
//# sourceMappingURL=providers-B7MVnAAt.js.map
|