drizzle-cube 0.3.31 → 0.3.32
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/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/{mcp-transport-D4KrudfS.js → mcp-transport-B2rGcu1X.js} +780 -751
- package/dist/adapters/mcp-transport-DeD7YevT.cjs +257 -0
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/server/index.cjs +31 -31
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +1532 -1503
- package/package.json +1 -1
- package/dist/adapters/mcp-transport-Dn7sKoBD.cjs +0 -257
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { formatSqlString as
|
|
2
|
-
const
|
|
1
|
+
import { formatSqlString as te, handleLoad as Ze, handleValidate as et, handleDiscover as tt, generateRequestId as Ct } from "./utils.js";
|
|
2
|
+
const k = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
|
|
3
3
|
function L(d, e) {
|
|
4
4
|
if (!d || typeof d != "object")
|
|
5
5
|
return !1;
|
|
6
6
|
if (d instanceof e)
|
|
7
7
|
return !0;
|
|
8
|
-
if (!Object.prototype.hasOwnProperty.call(e,
|
|
8
|
+
if (!Object.prototype.hasOwnProperty.call(e, k))
|
|
9
9
|
throw new Error(
|
|
10
10
|
`Class "${e.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`
|
|
11
11
|
);
|
|
12
12
|
let t = Object.getPrototypeOf(d).constructor;
|
|
13
13
|
if (t)
|
|
14
14
|
for (; t; ) {
|
|
15
|
-
if (
|
|
15
|
+
if (k in t && t[k] === e[k])
|
|
16
16
|
return !0;
|
|
17
17
|
t = Object.getPrototypeOf(t);
|
|
18
18
|
}
|
|
19
19
|
return !1;
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class se {
|
|
22
22
|
constructor(e, t) {
|
|
23
23
|
this.table = e, this.config = t, this.name = t.name, this.keyAsName = t.keyAsName, this.notNull = t.notNull, this.default = t.default, this.defaultFn = t.defaultFn, this.onUpdateFn = t.onUpdateFn, this.hasDefault = t.hasDefault, this.primary = t.primaryKey, this.isUnique = t.isUnique, this.uniqueName = t.uniqueName, this.uniqueType = t.uniqueType, this.dataType = t.dataType, this.columnType = t.columnType, this.generated = t.generated, this.generatedIdentity = t.generatedIdentity;
|
|
24
24
|
}
|
|
25
|
-
static [
|
|
25
|
+
static [k] = "Column";
|
|
26
26
|
name;
|
|
27
27
|
keyAsName;
|
|
28
28
|
primary;
|
|
@@ -51,12 +51,12 @@ class te {
|
|
|
51
51
|
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
function
|
|
56
|
-
return !!d && typeof d == "function" &&
|
|
54
|
+
const be = /* @__PURE__ */ Symbol.for("drizzle:Name"), Le = /* @__PURE__ */ Symbol.for("drizzle:isPgEnum");
|
|
55
|
+
function wt(d) {
|
|
56
|
+
return !!d && typeof d == "function" && Le in d && d[Le] === !0;
|
|
57
57
|
}
|
|
58
|
-
class
|
|
59
|
-
static [
|
|
58
|
+
class nt {
|
|
59
|
+
static [k] = "Subquery";
|
|
60
60
|
constructor(e, t, n, s = !1, i = []) {
|
|
61
61
|
this._ = {
|
|
62
62
|
brand: "Subquery",
|
|
@@ -71,66 +71,66 @@ class Ze {
|
|
|
71
71
|
// return new SQL([this]);
|
|
72
72
|
// }
|
|
73
73
|
}
|
|
74
|
-
const
|
|
74
|
+
const $t = {
|
|
75
75
|
startActiveSpan(d, e) {
|
|
76
76
|
return e();
|
|
77
77
|
}
|
|
78
|
-
},
|
|
79
|
-
class
|
|
80
|
-
static [
|
|
78
|
+
}, ne = /* @__PURE__ */ Symbol.for("drizzle:ViewBaseConfig"), ye = /* @__PURE__ */ Symbol.for("drizzle:Schema"), Me = /* @__PURE__ */ Symbol.for("drizzle:Columns"), je = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigColumns"), Ce = /* @__PURE__ */ Symbol.for("drizzle:OriginalName"), we = /* @__PURE__ */ Symbol.for("drizzle:BaseName"), le = /* @__PURE__ */ Symbol.for("drizzle:IsAlias"), Ue = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigBuilder"), Tt = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleTable");
|
|
79
|
+
class P {
|
|
80
|
+
static [k] = "Table";
|
|
81
81
|
/** @internal */
|
|
82
82
|
static Symbol = {
|
|
83
|
-
Name:
|
|
84
|
-
Schema:
|
|
85
|
-
OriginalName:
|
|
86
|
-
Columns:
|
|
87
|
-
ExtraConfigColumns:
|
|
88
|
-
BaseName:
|
|
89
|
-
IsAlias:
|
|
90
|
-
ExtraConfigBuilder:
|
|
83
|
+
Name: be,
|
|
84
|
+
Schema: ye,
|
|
85
|
+
OriginalName: Ce,
|
|
86
|
+
Columns: Me,
|
|
87
|
+
ExtraConfigColumns: je,
|
|
88
|
+
BaseName: we,
|
|
89
|
+
IsAlias: le,
|
|
90
|
+
ExtraConfigBuilder: Ue
|
|
91
91
|
};
|
|
92
92
|
/**
|
|
93
93
|
* @internal
|
|
94
94
|
* Can be changed if the table is aliased.
|
|
95
95
|
*/
|
|
96
|
-
[
|
|
96
|
+
[be];
|
|
97
97
|
/**
|
|
98
98
|
* @internal
|
|
99
99
|
* Used to store the original name of the table, before any aliasing.
|
|
100
100
|
*/
|
|
101
|
-
[
|
|
101
|
+
[Ce];
|
|
102
102
|
/** @internal */
|
|
103
|
-
[
|
|
103
|
+
[ye];
|
|
104
104
|
/** @internal */
|
|
105
|
-
[
|
|
105
|
+
[Me];
|
|
106
106
|
/** @internal */
|
|
107
|
-
[
|
|
107
|
+
[je];
|
|
108
108
|
/**
|
|
109
109
|
* @internal
|
|
110
110
|
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
111
111
|
*/
|
|
112
|
-
[
|
|
112
|
+
[we];
|
|
113
113
|
/** @internal */
|
|
114
|
-
[
|
|
114
|
+
[le] = !1;
|
|
115
115
|
/** @internal */
|
|
116
|
-
[
|
|
116
|
+
[Tt] = !0;
|
|
117
117
|
/** @internal */
|
|
118
|
-
[
|
|
118
|
+
[Ue] = void 0;
|
|
119
119
|
constructor(e, t, n) {
|
|
120
|
-
this[
|
|
120
|
+
this[be] = this[Ce] = e, this[ye] = t, this[we] = n;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function st(d) {
|
|
124
124
|
return d != null && typeof d.getSQL == "function";
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function Et(d) {
|
|
127
127
|
const e = { sql: "", params: [] };
|
|
128
128
|
for (const t of d)
|
|
129
129
|
e.sql += t.sql, e.params.push(...t.params), t.typings?.length && (e.typings || (e.typings = []), e.typings.push(...t.typings));
|
|
130
130
|
return e;
|
|
131
131
|
}
|
|
132
|
-
class
|
|
133
|
-
static [
|
|
132
|
+
class M {
|
|
133
|
+
static [k] = "StringChunk";
|
|
134
134
|
value;
|
|
135
135
|
constructor(e) {
|
|
136
136
|
this.value = Array.isArray(e) ? e : [e];
|
|
@@ -143,16 +143,16 @@ class O {
|
|
|
143
143
|
constructor(e) {
|
|
144
144
|
this.queryChunks = e;
|
|
145
145
|
for (const t of e)
|
|
146
|
-
if (L(t,
|
|
147
|
-
const n = t[
|
|
146
|
+
if (L(t, P)) {
|
|
147
|
+
const n = t[P.Symbol.Schema];
|
|
148
148
|
this.usedTables.push(
|
|
149
|
-
n === void 0 ? t[
|
|
149
|
+
n === void 0 ? t[P.Symbol.Name] : n + "." + t[P.Symbol.Name]
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
static [
|
|
153
|
+
static [k] = "SQL";
|
|
154
154
|
/** @internal */
|
|
155
|
-
decoder =
|
|
155
|
+
decoder = it;
|
|
156
156
|
shouldInlineParams = !1;
|
|
157
157
|
/** @internal */
|
|
158
158
|
usedTables = [];
|
|
@@ -160,7 +160,7 @@ class O {
|
|
|
160
160
|
return this.queryChunks.push(...e.queryChunks), this;
|
|
161
161
|
}
|
|
162
162
|
toQuery(e) {
|
|
163
|
-
return
|
|
163
|
+
return $t.startActiveSpan("drizzle.buildSQL", (t) => {
|
|
164
164
|
const n = this.buildQueryFromSourceParams(this.queryChunks, e);
|
|
165
165
|
return t?.setAttributes({
|
|
166
166
|
"drizzle.query.text": n.sql,
|
|
@@ -180,50 +180,50 @@ class O {
|
|
|
180
180
|
inlineParams: u,
|
|
181
181
|
paramStartIndex: c
|
|
182
182
|
} = n;
|
|
183
|
-
return
|
|
184
|
-
if (L(l,
|
|
183
|
+
return Et(e.map((l) => {
|
|
184
|
+
if (L(l, M))
|
|
185
185
|
return { sql: l.value.join(""), params: [] };
|
|
186
|
-
if (L(l,
|
|
186
|
+
if (L(l, De))
|
|
187
187
|
return { sql: i(l.value), params: [] };
|
|
188
188
|
if (l === void 0)
|
|
189
189
|
return { sql: "", params: [] };
|
|
190
190
|
if (Array.isArray(l)) {
|
|
191
|
-
const m = [new
|
|
191
|
+
const m = [new M("(")];
|
|
192
192
|
for (const [p, f] of l.entries())
|
|
193
|
-
m.push(f), p < l.length - 1 && m.push(new
|
|
194
|
-
return m.push(new
|
|
193
|
+
m.push(f), p < l.length - 1 && m.push(new M(", "));
|
|
194
|
+
return m.push(new M(")")), this.buildQueryFromSourceParams(m, n);
|
|
195
195
|
}
|
|
196
196
|
if (L(l, O))
|
|
197
197
|
return this.buildQueryFromSourceParams(l.queryChunks, {
|
|
198
198
|
...n,
|
|
199
199
|
inlineParams: u || l.shouldInlineParams
|
|
200
200
|
});
|
|
201
|
-
if (L(l,
|
|
202
|
-
const m = l[
|
|
201
|
+
if (L(l, P)) {
|
|
202
|
+
const m = l[P.Symbol.Schema], p = l[P.Symbol.Name];
|
|
203
203
|
return {
|
|
204
|
-
sql: m === void 0 || l[
|
|
204
|
+
sql: m === void 0 || l[le] ? i(p) : i(m) + "." + i(p),
|
|
205
205
|
params: []
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
|
-
if (L(l,
|
|
208
|
+
if (L(l, se)) {
|
|
209
209
|
const m = s.getColumnCasing(l);
|
|
210
210
|
if (t.invokeSource === "indexes")
|
|
211
211
|
return { sql: i(m), params: [] };
|
|
212
|
-
const p = l.table[
|
|
212
|
+
const p = l.table[P.Symbol.Schema];
|
|
213
213
|
return {
|
|
214
|
-
sql: l.table[
|
|
214
|
+
sql: l.table[le] || p === void 0 ? i(l.table[P.Symbol.Name]) + "." + i(m) : i(p) + "." + i(l.table[P.Symbol.Name]) + "." + i(m),
|
|
215
215
|
params: []
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
|
-
if (L(l,
|
|
219
|
-
const m = l[
|
|
218
|
+
if (L(l, ot)) {
|
|
219
|
+
const m = l[ne].schema, p = l[ne].name;
|
|
220
220
|
return {
|
|
221
|
-
sql: m === void 0 || l[
|
|
221
|
+
sql: m === void 0 || l[ne].isAlias ? i(p) : i(m) + "." + i(p),
|
|
222
222
|
params: []
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
|
-
if (L(l,
|
|
226
|
-
if (L(l.value,
|
|
225
|
+
if (L(l, ce)) {
|
|
226
|
+
if (L(l.value, de))
|
|
227
227
|
return { sql: r(c.value++, l), params: [l], typings: ["none"] };
|
|
228
228
|
const m = l.value === null ? null : l.encoder.mapToDriverValue(l.value);
|
|
229
229
|
if (L(m, O))
|
|
@@ -233,15 +233,15 @@ class O {
|
|
|
233
233
|
let p = ["none"];
|
|
234
234
|
return a && (p = [a(l.encoder)]), { sql: r(c.value++, m), params: [m], typings: p };
|
|
235
235
|
}
|
|
236
|
-
return L(l,
|
|
237
|
-
new
|
|
236
|
+
return L(l, de) ? { sql: r(c.value++, l), params: [l], typings: ["none"] } : L(l, O.Aliased) && l.fieldAlias !== void 0 ? { sql: i(l.fieldAlias), params: [] } : L(l, nt) ? l._.isWith ? { sql: i(l._.alias), params: [] } : this.buildQueryFromSourceParams([
|
|
237
|
+
new M("("),
|
|
238
238
|
l._.sql,
|
|
239
|
-
new
|
|
240
|
-
new
|
|
241
|
-
], n) :
|
|
242
|
-
new
|
|
239
|
+
new M(") "),
|
|
240
|
+
new De(l._.alias)
|
|
241
|
+
], n) : wt(l) ? l.schema ? { sql: i(l.schema) + "." + i(l.enumName), params: [] } : { sql: i(l.enumName), params: [] } : st(l) ? l.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([l.getSQL()], n) : this.buildQueryFromSourceParams([
|
|
242
|
+
new M("("),
|
|
243
243
|
l.getSQL(),
|
|
244
|
-
new
|
|
244
|
+
new M(")")
|
|
245
245
|
], n) : u ? { sql: this.mapInlineParam(l, n), params: [] } : { sql: r(c.value++, l), params: [l], typings: ["none"] };
|
|
246
246
|
}));
|
|
247
247
|
}
|
|
@@ -280,37 +280,37 @@ class O {
|
|
|
280
280
|
return e ? this : void 0;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
class
|
|
283
|
+
class De {
|
|
284
284
|
constructor(e) {
|
|
285
285
|
this.value = e;
|
|
286
286
|
}
|
|
287
|
-
static [
|
|
287
|
+
static [k] = "Name";
|
|
288
288
|
brand;
|
|
289
289
|
getSQL() {
|
|
290
290
|
return new O([this]);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function St(d) {
|
|
294
294
|
return typeof d == "object" && d !== null && "mapToDriverValue" in d && typeof d.mapToDriverValue == "function";
|
|
295
295
|
}
|
|
296
|
-
const
|
|
296
|
+
const it = {
|
|
297
297
|
mapFromDriverValue: (d) => d
|
|
298
|
-
},
|
|
298
|
+
}, rt = {
|
|
299
299
|
mapToDriverValue: (d) => d
|
|
300
300
|
};
|
|
301
301
|
({
|
|
302
|
-
...
|
|
303
|
-
...
|
|
302
|
+
...it,
|
|
303
|
+
...rt
|
|
304
304
|
});
|
|
305
|
-
class
|
|
305
|
+
class ce {
|
|
306
306
|
/**
|
|
307
307
|
* @param value - Parameter value
|
|
308
308
|
* @param encoder - Encoder to convert the value to a driver parameter
|
|
309
309
|
*/
|
|
310
|
-
constructor(e, t =
|
|
310
|
+
constructor(e, t = rt) {
|
|
311
311
|
this.value = e, this.encoder = t;
|
|
312
312
|
}
|
|
313
|
-
static [
|
|
313
|
+
static [k] = "Param";
|
|
314
314
|
brand;
|
|
315
315
|
getSQL() {
|
|
316
316
|
return new O([this]);
|
|
@@ -318,9 +318,9 @@ class le {
|
|
|
318
318
|
}
|
|
319
319
|
function o(d, ...e) {
|
|
320
320
|
const t = [];
|
|
321
|
-
(e.length > 0 || d.length > 0 && d[0] !== "") && t.push(new
|
|
321
|
+
(e.length > 0 || d.length > 0 && d[0] !== "") && t.push(new M(d[0]));
|
|
322
322
|
for (const [n, s] of e.entries())
|
|
323
|
-
t.push(s, new
|
|
323
|
+
t.push(s, new M(d[n + 1]));
|
|
324
324
|
return new O(t);
|
|
325
325
|
}
|
|
326
326
|
((d) => {
|
|
@@ -333,7 +333,7 @@ function o(d, ...e) {
|
|
|
333
333
|
}
|
|
334
334
|
d.fromList = t;
|
|
335
335
|
function n(u) {
|
|
336
|
-
return new O([new
|
|
336
|
+
return new O([new M(u)]);
|
|
337
337
|
}
|
|
338
338
|
d.raw = n;
|
|
339
339
|
function s(u, c) {
|
|
@@ -344,15 +344,15 @@ function o(d, ...e) {
|
|
|
344
344
|
}
|
|
345
345
|
d.join = s;
|
|
346
346
|
function i(u) {
|
|
347
|
-
return new
|
|
347
|
+
return new De(u);
|
|
348
348
|
}
|
|
349
349
|
d.identifier = i;
|
|
350
350
|
function r(u) {
|
|
351
|
-
return new
|
|
351
|
+
return new de(u);
|
|
352
352
|
}
|
|
353
353
|
d.placeholder = r;
|
|
354
354
|
function a(u, c) {
|
|
355
|
-
return new
|
|
355
|
+
return new ce(u, c);
|
|
356
356
|
}
|
|
357
357
|
d.param = a;
|
|
358
358
|
})(o || (o = {}));
|
|
@@ -361,7 +361,7 @@ function o(d, ...e) {
|
|
|
361
361
|
constructor(n, s) {
|
|
362
362
|
this.sql = n, this.fieldAlias = s;
|
|
363
363
|
}
|
|
364
|
-
static [
|
|
364
|
+
static [k] = "SQL.Aliased";
|
|
365
365
|
/** @internal */
|
|
366
366
|
isSelectionField = !1;
|
|
367
367
|
getSQL() {
|
|
@@ -374,24 +374,24 @@ function o(d, ...e) {
|
|
|
374
374
|
}
|
|
375
375
|
d.Aliased = e;
|
|
376
376
|
})(O || (O = {}));
|
|
377
|
-
class
|
|
377
|
+
class de {
|
|
378
378
|
constructor(e) {
|
|
379
379
|
this.name = e;
|
|
380
380
|
}
|
|
381
|
-
static [
|
|
381
|
+
static [k] = "Placeholder";
|
|
382
382
|
getSQL() {
|
|
383
383
|
return new O([this]);
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
const
|
|
387
|
-
class
|
|
388
|
-
static [
|
|
386
|
+
const Nt = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleView");
|
|
387
|
+
class ot {
|
|
388
|
+
static [k] = "View";
|
|
389
389
|
/** @internal */
|
|
390
|
-
[
|
|
390
|
+
[ne];
|
|
391
391
|
/** @internal */
|
|
392
|
-
[
|
|
392
|
+
[Nt] = !0;
|
|
393
393
|
constructor({ name: e, schema: t, selectedFields: n, query: s }) {
|
|
394
|
-
this[
|
|
394
|
+
this[ne] = {
|
|
395
395
|
name: e,
|
|
396
396
|
originalName: e,
|
|
397
397
|
schema: t,
|
|
@@ -405,103 +405,103 @@ class st {
|
|
|
405
405
|
return new O([this]);
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
|
|
408
|
+
se.prototype.getSQL = function() {
|
|
409
409
|
return new O([this]);
|
|
410
410
|
};
|
|
411
|
-
|
|
411
|
+
P.prototype.getSQL = function() {
|
|
412
412
|
return new O([this]);
|
|
413
413
|
};
|
|
414
|
-
|
|
414
|
+
nt.prototype.getSQL = function() {
|
|
415
415
|
return new O([this]);
|
|
416
416
|
};
|
|
417
|
-
function
|
|
418
|
-
return
|
|
417
|
+
function x(d, e) {
|
|
418
|
+
return St(e) && !st(d) && !L(d, ce) && !L(d, de) && !L(d, se) && !L(d, P) && !L(d, ot) ? new ce(d, e) : d;
|
|
419
419
|
}
|
|
420
|
-
const Q = (d, e) => o`${d} = ${
|
|
421
|
-
function
|
|
420
|
+
const Q = (d, e) => o`${d} = ${x(e, d)}`, xe = (d, e) => o`${d} <> ${x(e, d)}`;
|
|
421
|
+
function A(...d) {
|
|
422
422
|
const e = d.filter(
|
|
423
423
|
(t) => t !== void 0
|
|
424
424
|
);
|
|
425
425
|
if (e.length !== 0)
|
|
426
426
|
return e.length === 1 ? new O(e) : new O([
|
|
427
|
-
new
|
|
428
|
-
o.join(e, new
|
|
429
|
-
new
|
|
427
|
+
new M("("),
|
|
428
|
+
o.join(e, new M(" and ")),
|
|
429
|
+
new M(")")
|
|
430
430
|
]);
|
|
431
431
|
}
|
|
432
|
-
function
|
|
432
|
+
function re(...d) {
|
|
433
433
|
const e = d.filter(
|
|
434
434
|
(t) => t !== void 0
|
|
435
435
|
);
|
|
436
436
|
if (e.length !== 0)
|
|
437
437
|
return e.length === 1 ? new O(e) : new O([
|
|
438
|
-
new
|
|
439
|
-
o.join(e, new
|
|
440
|
-
new
|
|
438
|
+
new M("("),
|
|
439
|
+
o.join(e, new M(" or ")),
|
|
440
|
+
new M(")")
|
|
441
441
|
]);
|
|
442
442
|
}
|
|
443
|
-
const
|
|
444
|
-
function
|
|
445
|
-
return Array.isArray(e) ? e.length === 0 ? o`false` : o`${d} in ${e.map((t) =>
|
|
443
|
+
const $e = (d, e) => o`${d} > ${x(e, d)}`, Z = (d, e) => o`${d} >= ${x(e, d)}`, Te = (d, e) => o`${d} < ${x(e, d)}`, ee = (d, e) => o`${d} <= ${x(e, d)}`;
|
|
444
|
+
function Ee(d, e) {
|
|
445
|
+
return Array.isArray(e) ? e.length === 0 ? o`false` : o`${d} in ${e.map((t) => x(t, d))}` : o`${d} in ${x(e, d)}`;
|
|
446
446
|
}
|
|
447
|
-
function
|
|
448
|
-
return Array.isArray(e) ? e.length === 0 ? o`true` : o`${d} not in ${e.map((t) =>
|
|
447
|
+
function ke(d, e) {
|
|
448
|
+
return Array.isArray(e) ? e.length === 0 ? o`true` : o`${d} not in ${e.map((t) => x(t, d))}` : o`${d} not in ${x(e, d)}`;
|
|
449
449
|
}
|
|
450
|
-
function
|
|
450
|
+
function Be(d) {
|
|
451
451
|
return o`${d} is null`;
|
|
452
452
|
}
|
|
453
|
-
function
|
|
453
|
+
function Pe(d) {
|
|
454
454
|
return o`${d} is not null`;
|
|
455
455
|
}
|
|
456
|
-
function
|
|
456
|
+
function Dt(d, e) {
|
|
457
457
|
if (Array.isArray(e)) {
|
|
458
458
|
if (e.length === 0)
|
|
459
459
|
throw new Error("arrayContains requires at least one value");
|
|
460
|
-
const t = o`${
|
|
460
|
+
const t = o`${x(e, d)}`;
|
|
461
461
|
return o`${d} @> ${t}`;
|
|
462
462
|
}
|
|
463
|
-
return o`${d} @> ${
|
|
463
|
+
return o`${d} @> ${x(e, d)}`;
|
|
464
464
|
}
|
|
465
|
-
function
|
|
465
|
+
function At(d, e) {
|
|
466
466
|
if (Array.isArray(e)) {
|
|
467
467
|
if (e.length === 0)
|
|
468
468
|
throw new Error("arrayContained requires at least one value");
|
|
469
|
-
const t = o`${
|
|
469
|
+
const t = o`${x(e, d)}`;
|
|
470
470
|
return o`${d} <@ ${t}`;
|
|
471
471
|
}
|
|
472
|
-
return o`${d} <@ ${
|
|
472
|
+
return o`${d} <@ ${x(e, d)}`;
|
|
473
473
|
}
|
|
474
|
-
function
|
|
474
|
+
function _t(d, e) {
|
|
475
475
|
if (Array.isArray(e)) {
|
|
476
476
|
if (e.length === 0)
|
|
477
477
|
throw new Error("arrayOverlaps requires at least one value");
|
|
478
|
-
const t = o`${
|
|
478
|
+
const t = o`${x(e, d)}`;
|
|
479
479
|
return o`${d} && ${t}`;
|
|
480
480
|
}
|
|
481
|
-
return o`${d} && ${
|
|
481
|
+
return o`${d} && ${x(e, d)}`;
|
|
482
482
|
}
|
|
483
|
-
function
|
|
483
|
+
function Qe(d) {
|
|
484
484
|
return o`${d} asc`;
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function vt(d) {
|
|
487
487
|
return o`${d} desc`;
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function Ae(d) {
|
|
490
490
|
return o`count(${d || o.raw("*")})`.mapWith(Number);
|
|
491
491
|
}
|
|
492
|
-
function
|
|
492
|
+
function Rt(d) {
|
|
493
493
|
return o`count(distinct ${d})`.mapWith(Number);
|
|
494
494
|
}
|
|
495
|
-
function
|
|
495
|
+
function z(d) {
|
|
496
496
|
return o`sum(${d})`.mapWith(String);
|
|
497
497
|
}
|
|
498
|
-
function
|
|
499
|
-
return o`max(${d})`.mapWith(L(d,
|
|
498
|
+
function G(d) {
|
|
499
|
+
return o`max(${d})`.mapWith(L(d, se) ? d : String);
|
|
500
500
|
}
|
|
501
|
-
function
|
|
502
|
-
return o`min(${d})`.mapWith(L(d,
|
|
501
|
+
function oe(d) {
|
|
502
|
+
return o`min(${d})`.mapWith(L(d, se) ? d : String);
|
|
503
503
|
}
|
|
504
|
-
class
|
|
504
|
+
class pe {
|
|
505
505
|
/**
|
|
506
506
|
* Default implementation returns template unchanged
|
|
507
507
|
* Override in specific adapters for database-specific preprocessing
|
|
@@ -549,7 +549,7 @@ class fe {
|
|
|
549
549
|
return t.years * 365 * 24 * 60 * 60 + t.months * 30 * 24 * 60 * 60 + t.days * 24 * 60 * 60 + t.hours * 60 * 60 + t.minutes * 60 + t.seconds;
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
class
|
|
552
|
+
class Ft extends pe {
|
|
553
553
|
getEngineType() {
|
|
554
554
|
return "postgres";
|
|
555
555
|
}
|
|
@@ -820,7 +820,7 @@ class At extends fe {
|
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
|
-
class
|
|
823
|
+
class at extends pe {
|
|
824
824
|
getEngineType() {
|
|
825
825
|
return "mysql";
|
|
826
826
|
}
|
|
@@ -1098,7 +1098,7 @@ class it extends fe {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
|
-
class
|
|
1101
|
+
class Ot extends pe {
|
|
1102
1102
|
getEngineType() {
|
|
1103
1103
|
return "sqlite";
|
|
1104
1104
|
}
|
|
@@ -1415,7 +1415,7 @@ class _t extends fe {
|
|
|
1415
1415
|
}
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
|
-
class
|
|
1418
|
+
class It extends at {
|
|
1419
1419
|
getEngineType() {
|
|
1420
1420
|
return "singlestore";
|
|
1421
1421
|
}
|
|
@@ -1428,7 +1428,7 @@ class vt extends it {
|
|
|
1428
1428
|
// These limitations are typically handled at the query building level
|
|
1429
1429
|
// rather than in the adapter, but can be addressed here if needed
|
|
1430
1430
|
}
|
|
1431
|
-
class
|
|
1431
|
+
class Lt extends pe {
|
|
1432
1432
|
getEngineType() {
|
|
1433
1433
|
return "duckdb";
|
|
1434
1434
|
}
|
|
@@ -1693,31 +1693,31 @@ class Rt extends fe {
|
|
|
1693
1693
|
}
|
|
1694
1694
|
}
|
|
1695
1695
|
}
|
|
1696
|
-
function
|
|
1696
|
+
function Mt(d) {
|
|
1697
1697
|
switch (d) {
|
|
1698
1698
|
case "postgres":
|
|
1699
|
-
return new
|
|
1699
|
+
return new Ft();
|
|
1700
1700
|
case "mysql":
|
|
1701
|
-
return new
|
|
1701
|
+
return new at();
|
|
1702
1702
|
case "sqlite":
|
|
1703
|
-
return new
|
|
1703
|
+
return new Ot();
|
|
1704
1704
|
case "singlestore":
|
|
1705
|
-
return new
|
|
1705
|
+
return new It();
|
|
1706
1706
|
case "duckdb":
|
|
1707
|
-
return new
|
|
1707
|
+
return new Lt();
|
|
1708
1708
|
default:
|
|
1709
1709
|
throw new Error(`Unsupported database engine: ${d}`);
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
|
-
class
|
|
1712
|
+
class he {
|
|
1713
1713
|
constructor(e, t, n) {
|
|
1714
1714
|
this.db = e, this.schema = t;
|
|
1715
1715
|
const s = n || this.getEngineType();
|
|
1716
|
-
this.databaseAdapter =
|
|
1716
|
+
this.databaseAdapter = Mt(s);
|
|
1717
1717
|
}
|
|
1718
1718
|
databaseAdapter;
|
|
1719
1719
|
}
|
|
1720
|
-
function
|
|
1720
|
+
function jt(d, e) {
|
|
1721
1721
|
const t = [], n = [];
|
|
1722
1722
|
let s = !1, i, r, a;
|
|
1723
1723
|
const u = [];
|
|
@@ -1732,7 +1732,7 @@ function Ot(d, e) {
|
|
|
1732
1732
|
r = parseFloat(p[1]);
|
|
1733
1733
|
continue;
|
|
1734
1734
|
}
|
|
1735
|
-
const f =
|
|
1735
|
+
const f = Ut(l);
|
|
1736
1736
|
if (f) {
|
|
1737
1737
|
f.type.includes("Seq Scan") && (s = !0), f.index && n.push(f.index), t.length === 0 && f.estimatedCost !== void 0 && (a = f.estimatedCost);
|
|
1738
1738
|
const h = l.search(/\S/);
|
|
@@ -1764,7 +1764,7 @@ function Ot(d, e) {
|
|
|
1764
1764
|
sql: e
|
|
1765
1765
|
};
|
|
1766
1766
|
}
|
|
1767
|
-
function
|
|
1767
|
+
function Ut(d) {
|
|
1768
1768
|
const e = d.replace(/^[\s->]+/, "").trim();
|
|
1769
1769
|
if (!e) return null;
|
|
1770
1770
|
const t = e.match(
|
|
@@ -1784,7 +1784,7 @@ function It(d) {
|
|
|
1784
1784
|
const l = d.match(/Filter:\s*(.+?)(?:\)|$)/i);
|
|
1785
1785
|
return l && (c.filter = l[1].trim()), c;
|
|
1786
1786
|
}
|
|
1787
|
-
class
|
|
1787
|
+
class xt extends he {
|
|
1788
1788
|
async execute(e, t) {
|
|
1789
1789
|
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
1790
1790
|
const s = await e.execute();
|
|
@@ -1854,7 +1854,7 @@ class Lt extends pe {
|
|
|
1854
1854
|
typeof u == "string" && r.push(u);
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
1857
|
-
return
|
|
1857
|
+
return jt(r, { sql: e, params: t });
|
|
1858
1858
|
}
|
|
1859
1859
|
/**
|
|
1860
1860
|
* Get existing indexes for the specified tables
|
|
@@ -1895,10 +1895,10 @@ class Lt extends pe {
|
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
1897
|
}
|
|
1898
|
-
function
|
|
1899
|
-
return new
|
|
1898
|
+
function We(d, e) {
|
|
1899
|
+
return new xt(d, e, "postgres");
|
|
1900
1900
|
}
|
|
1901
|
-
function
|
|
1901
|
+
function kt(d, e) {
|
|
1902
1902
|
const t = e?.toLowerCase() || "";
|
|
1903
1903
|
switch (d.toLowerCase()) {
|
|
1904
1904
|
case "all":
|
|
@@ -1920,11 +1920,11 @@ function Mt(d, e) {
|
|
|
1920
1920
|
return `MySQL ${d}`;
|
|
1921
1921
|
}
|
|
1922
1922
|
}
|
|
1923
|
-
function
|
|
1923
|
+
function Bt(d, e) {
|
|
1924
1924
|
const t = [], n = [];
|
|
1925
1925
|
let s = !1, i = 0;
|
|
1926
1926
|
for (const u of d) {
|
|
1927
|
-
const c =
|
|
1927
|
+
const c = kt(u.type, u.Extra);
|
|
1928
1928
|
u.type.toLowerCase() === "all" && (s = !0), u.key && n.push(u.key);
|
|
1929
1929
|
const l = {
|
|
1930
1930
|
type: c,
|
|
@@ -1963,7 +1963,7 @@ function jt(d, e) {
|
|
|
1963
1963
|
sql: e
|
|
1964
1964
|
};
|
|
1965
1965
|
}
|
|
1966
|
-
class
|
|
1966
|
+
class ut extends he {
|
|
1967
1967
|
async execute(e, t) {
|
|
1968
1968
|
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
1969
1969
|
const s = await e.execute();
|
|
@@ -2031,7 +2031,7 @@ class rt extends pe {
|
|
|
2031
2031
|
filtered: Number(c.filtered) || 100,
|
|
2032
2032
|
Extra: c.Extra || null
|
|
2033
2033
|
});
|
|
2034
|
-
return
|
|
2034
|
+
return Bt(u, { sql: e, params: t });
|
|
2035
2035
|
}
|
|
2036
2036
|
/**
|
|
2037
2037
|
* Get existing indexes for the specified tables
|
|
@@ -2067,10 +2067,10 @@ class rt extends pe {
|
|
|
2067
2067
|
}
|
|
2068
2068
|
}
|
|
2069
2069
|
}
|
|
2070
|
-
function
|
|
2071
|
-
return new
|
|
2070
|
+
function Pt(d, e) {
|
|
2071
|
+
return new ut(d, e, "mysql");
|
|
2072
2072
|
}
|
|
2073
|
-
function
|
|
2073
|
+
function Qt(d) {
|
|
2074
2074
|
const e = d.toLowerCase(), t = d.match(/^SCAN\s+(\S+)/i);
|
|
2075
2075
|
if (t)
|
|
2076
2076
|
return {
|
|
@@ -2102,12 +2102,12 @@ function kt(d) {
|
|
|
2102
2102
|
table: i[1]
|
|
2103
2103
|
} : e.includes("temp b-tree") ? e.includes("order by") ? { type: "Sort" } : e.includes("group by") ? { type: "Group" } : e.includes("distinct") ? { type: "Distinct" } : { type: "Temp B-Tree" } : e.includes("compound") ? { type: "Compound Query" } : e.includes("subquery") ? { type: "Subquery" } : e.includes("co-routine") ? { type: "Coroutine" } : { type: d };
|
|
2104
2104
|
}
|
|
2105
|
-
function
|
|
2105
|
+
function Wt(d, e) {
|
|
2106
2106
|
const t = [], n = [];
|
|
2107
2107
|
let s = !1;
|
|
2108
2108
|
const i = /* @__PURE__ */ new Map();
|
|
2109
2109
|
for (const u of d) {
|
|
2110
|
-
const c =
|
|
2110
|
+
const c = Qt(u.detail);
|
|
2111
2111
|
c.type === "Seq Scan" && (s = !0), c.index && n.push(c.index);
|
|
2112
2112
|
const l = {
|
|
2113
2113
|
type: c.type,
|
|
@@ -2145,7 +2145,7 @@ function xt(d, e) {
|
|
|
2145
2145
|
sql: e
|
|
2146
2146
|
};
|
|
2147
2147
|
}
|
|
2148
|
-
class
|
|
2148
|
+
class Kt extends he {
|
|
2149
2149
|
async execute(e, t) {
|
|
2150
2150
|
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
2151
2151
|
const n = await e.execute();
|
|
@@ -2215,7 +2215,7 @@ class Bt extends pe {
|
|
|
2215
2215
|
notused: Number(c.notused) || 0,
|
|
2216
2216
|
detail: String(c.detail || "")
|
|
2217
2217
|
});
|
|
2218
|
-
return
|
|
2218
|
+
return Wt(u, { sql: e, params: t });
|
|
2219
2219
|
}
|
|
2220
2220
|
/**
|
|
2221
2221
|
* Get existing indexes for the specified tables
|
|
@@ -2256,10 +2256,10 @@ class Bt extends pe {
|
|
|
2256
2256
|
}
|
|
2257
2257
|
}
|
|
2258
2258
|
}
|
|
2259
|
-
function
|
|
2260
|
-
return new
|
|
2259
|
+
function Ke(d, e) {
|
|
2260
|
+
return new Kt(d, e, "sqlite");
|
|
2261
2261
|
}
|
|
2262
|
-
class
|
|
2262
|
+
class qt extends ut {
|
|
2263
2263
|
getEngineType() {
|
|
2264
2264
|
return "singlestore";
|
|
2265
2265
|
}
|
|
@@ -2267,19 +2267,19 @@ class Pt extends rt {
|
|
|
2267
2267
|
// For now, we inherit all behavior from MySQLExecutor since
|
|
2268
2268
|
// SingleStore is largely MySQL-compatible
|
|
2269
2269
|
}
|
|
2270
|
-
function
|
|
2271
|
-
return new
|
|
2270
|
+
function zt(d, e) {
|
|
2271
|
+
return new qt(d, e);
|
|
2272
2272
|
}
|
|
2273
|
-
function
|
|
2273
|
+
function Vt(d, e) {
|
|
2274
2274
|
const t = [], n = [];
|
|
2275
2275
|
let s = !1, i;
|
|
2276
2276
|
const r = [];
|
|
2277
2277
|
for (const u of d) {
|
|
2278
2278
|
if (/^[┌├└│─┐┤┘]+$/.test(u.trim()) || /EXPLANATION|QUERY PLAN/i.test(u)) continue;
|
|
2279
|
-
const c =
|
|
2279
|
+
const c = Gt(u);
|
|
2280
2280
|
if (c) {
|
|
2281
2281
|
(c.type.includes("SEQ_SCAN") || c.type.includes("TABLE_SCAN")) && (s = !0), c.type.includes("INDEX_SCAN") && c.index && n.push(c.index), t.length === 0 && c.estimatedCost !== void 0 && (i = c.estimatedCost);
|
|
2282
|
-
const l =
|
|
2282
|
+
const l = Jt(u);
|
|
2283
2283
|
for (; r.length > 0 && r[r.length - 1].indent >= l; )
|
|
2284
2284
|
r.pop();
|
|
2285
2285
|
if (r.length === 0)
|
|
@@ -2307,7 +2307,7 @@ function Wt(d, e) {
|
|
|
2307
2307
|
sql: e
|
|
2308
2308
|
};
|
|
2309
2309
|
}
|
|
2310
|
-
function
|
|
2310
|
+
function Jt(d) {
|
|
2311
2311
|
let e = 0;
|
|
2312
2312
|
for (const t of d)
|
|
2313
2313
|
if (t === " " || t === "│" || t === "├" || t === "└" || t === "─")
|
|
@@ -2316,7 +2316,7 @@ function Kt(d) {
|
|
|
2316
2316
|
break;
|
|
2317
2317
|
return e;
|
|
2318
2318
|
}
|
|
2319
|
-
function
|
|
2319
|
+
function Gt(d) {
|
|
2320
2320
|
const e = d.replace(/[┌├└│─┐┤┘]/g, "").replace(/^\s*/, "").trim();
|
|
2321
2321
|
if (!e || e.match(/^\(cost=([\d.]+)\s+rows=(\d+)\)$/i))
|
|
2322
2322
|
return null;
|
|
@@ -2345,7 +2345,7 @@ function qt(d) {
|
|
|
2345
2345
|
estimatedCost: a
|
|
2346
2346
|
};
|
|
2347
2347
|
}
|
|
2348
|
-
class
|
|
2348
|
+
class Ht extends he {
|
|
2349
2349
|
async execute(e, t) {
|
|
2350
2350
|
if (e && typeof e == "object" && typeof e.execute == "function")
|
|
2351
2351
|
try {
|
|
@@ -2450,7 +2450,7 @@ class zt extends pe {
|
|
|
2450
2450
|
typeof u == "string" && r.push(u);
|
|
2451
2451
|
}
|
|
2452
2452
|
}
|
|
2453
|
-
return
|
|
2453
|
+
return Vt(r, { sql: e, params: t });
|
|
2454
2454
|
}
|
|
2455
2455
|
/**
|
|
2456
2456
|
* Get existing indexes for the specified tables
|
|
@@ -2486,33 +2486,33 @@ class zt extends pe {
|
|
|
2486
2486
|
}
|
|
2487
2487
|
}
|
|
2488
2488
|
}
|
|
2489
|
-
function
|
|
2490
|
-
return new
|
|
2489
|
+
function Yt(d, e) {
|
|
2490
|
+
return new Ht(d, e, "duckdb");
|
|
2491
2491
|
}
|
|
2492
|
-
function
|
|
2492
|
+
function qe(d, e, t) {
|
|
2493
2493
|
if (t)
|
|
2494
2494
|
switch (t) {
|
|
2495
2495
|
case "postgres":
|
|
2496
|
-
return
|
|
2496
|
+
return We(d, e);
|
|
2497
2497
|
case "mysql":
|
|
2498
|
-
return
|
|
2498
|
+
return Pt(d, e);
|
|
2499
2499
|
case "sqlite":
|
|
2500
|
-
return
|
|
2500
|
+
return Ke(d, e);
|
|
2501
2501
|
case "singlestore":
|
|
2502
|
-
return
|
|
2502
|
+
return zt(d, e);
|
|
2503
2503
|
case "duckdb":
|
|
2504
|
-
return
|
|
2504
|
+
return Yt(d, e);
|
|
2505
2505
|
}
|
|
2506
2506
|
if (d.all && d.run)
|
|
2507
|
-
return
|
|
2507
|
+
return Ke(d, e);
|
|
2508
2508
|
if (d.execute)
|
|
2509
|
-
return
|
|
2509
|
+
return We(d, e);
|
|
2510
2510
|
throw new Error("Unable to determine database engine type. Please specify engineType parameter.");
|
|
2511
2511
|
}
|
|
2512
|
-
function
|
|
2512
|
+
function W(d) {
|
|
2513
2513
|
return typeof d == "function" ? d() : d;
|
|
2514
2514
|
}
|
|
2515
|
-
function
|
|
2515
|
+
function _e(d, e) {
|
|
2516
2516
|
if (e) return e;
|
|
2517
2517
|
switch (d) {
|
|
2518
2518
|
case "belongsTo":
|
|
@@ -2531,14 +2531,14 @@ function Ae(d, e) {
|
|
|
2531
2531
|
return "left";
|
|
2532
2532
|
}
|
|
2533
2533
|
}
|
|
2534
|
-
function
|
|
2534
|
+
function ve(d) {
|
|
2535
2535
|
return d && typeof d == "object" ? o`${o`${d}`}` : d;
|
|
2536
2536
|
}
|
|
2537
|
-
function
|
|
2537
|
+
function R(d, e) {
|
|
2538
2538
|
const t = typeof d == "function" ? d(e) : d;
|
|
2539
|
-
return
|
|
2539
|
+
return ve(t);
|
|
2540
2540
|
}
|
|
2541
|
-
function
|
|
2541
|
+
function Xt(d, e) {
|
|
2542
2542
|
if (d.relationship !== "belongsToMany" || !d.through)
|
|
2543
2543
|
throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
|
|
2544
2544
|
const { table: t, sourceKey: n, targetKey: s, securitySql: i } = d.through, r = [];
|
|
@@ -2556,38 +2556,38 @@ function Jt(d, e) {
|
|
|
2556
2556
|
const l = i(e);
|
|
2557
2557
|
u = Array.isArray(l) ? l : [l];
|
|
2558
2558
|
}
|
|
2559
|
-
const c =
|
|
2559
|
+
const c = _e("belongsToMany", d.sqlJoinType);
|
|
2560
2560
|
return {
|
|
2561
2561
|
junctionJoins: [
|
|
2562
2562
|
{
|
|
2563
2563
|
joinType: c,
|
|
2564
2564
|
table: t,
|
|
2565
|
-
condition:
|
|
2565
|
+
condition: A(...r)
|
|
2566
2566
|
},
|
|
2567
2567
|
{
|
|
2568
2568
|
joinType: c,
|
|
2569
2569
|
table: t,
|
|
2570
2570
|
// This will be replaced with target cube table in query planner
|
|
2571
|
-
condition:
|
|
2571
|
+
condition: A(...a)
|
|
2572
2572
|
}
|
|
2573
2573
|
],
|
|
2574
2574
|
junctionSecurityConditions: u
|
|
2575
2575
|
};
|
|
2576
2576
|
}
|
|
2577
|
-
function
|
|
2577
|
+
function me(d) {
|
|
2578
2578
|
if ("and" in d)
|
|
2579
|
-
return `and:[${d.and.map(
|
|
2579
|
+
return `and:[${d.and.map(me).sort().join(",")}]`;
|
|
2580
2580
|
if ("or" in d)
|
|
2581
|
-
return `or:[${d.or.map(
|
|
2581
|
+
return `or:[${d.or.map(me).sort().join(",")}]`;
|
|
2582
2582
|
const e = d, t = JSON.stringify(
|
|
2583
2583
|
Array.isArray(e.values) ? [...e.values].sort() : e.values
|
|
2584
2584
|
), n = e.dateRange ? `:dr:${JSON.stringify(e.dateRange)}` : "";
|
|
2585
2585
|
return `${e.member}:${e.operator}:${t}${n}`;
|
|
2586
2586
|
}
|
|
2587
|
-
function
|
|
2587
|
+
function lt(d, e) {
|
|
2588
2588
|
return `timeDim:${d}:${JSON.stringify(e)}`;
|
|
2589
2589
|
}
|
|
2590
|
-
class
|
|
2590
|
+
class ze {
|
|
2591
2591
|
cache = /* @__PURE__ */ new Map();
|
|
2592
2592
|
stats = { hits: 0, misses: 0 };
|
|
2593
2593
|
/**
|
|
@@ -2644,40 +2644,40 @@ class We {
|
|
|
2644
2644
|
this.cache.clear(), this.stats = { hits: 0, misses: 0 };
|
|
2645
2645
|
}
|
|
2646
2646
|
}
|
|
2647
|
-
function
|
|
2647
|
+
function Re(d) {
|
|
2648
2648
|
const e = [];
|
|
2649
2649
|
for (const t of d)
|
|
2650
|
-
"and" in t && t.and ? e.push(...
|
|
2650
|
+
"and" in t && t.and ? e.push(...Re(t.and)) : "or" in t && t.or ? e.push(...Re(t.or)) : "member" in t && e.push(t);
|
|
2651
2651
|
return e;
|
|
2652
2652
|
}
|
|
2653
|
-
function
|
|
2654
|
-
const n = t.keyPrefix ?? "drizzle-cube:", s =
|
|
2653
|
+
function Zt(d, e, t = {}) {
|
|
2654
|
+
const n = t.keyPrefix ?? "drizzle-cube:", s = en(d), i = Ve(JSON.stringify(s));
|
|
2655
2655
|
let r = `${n}query:${i}`;
|
|
2656
2656
|
if (t.includeSecurityContext !== !1) {
|
|
2657
|
-
const a = t.securityContextSerializer ? t.securityContextSerializer(e) : JSON.stringify(
|
|
2657
|
+
const a = t.securityContextSerializer ? t.securityContextSerializer(e) : JSON.stringify(fe(e)), u = Ve(a);
|
|
2658
2658
|
r += `:ctx:${u}`;
|
|
2659
2659
|
}
|
|
2660
2660
|
return r;
|
|
2661
2661
|
}
|
|
2662
|
-
function
|
|
2662
|
+
function en(d) {
|
|
2663
2663
|
return {
|
|
2664
2664
|
measures: d.measures ? [...d.measures].sort() : void 0,
|
|
2665
2665
|
dimensions: d.dimensions ? [...d.dimensions].sort() : void 0,
|
|
2666
|
-
filters: d.filters ?
|
|
2667
|
-
timeDimensions: d.timeDimensions ?
|
|
2666
|
+
filters: d.filters ? K(d.filters) : void 0,
|
|
2667
|
+
timeDimensions: d.timeDimensions ? rn(d.timeDimensions) : void 0,
|
|
2668
2668
|
limit: d.limit,
|
|
2669
2669
|
offset: d.offset,
|
|
2670
|
-
order: d.order ?
|
|
2670
|
+
order: d.order ? fe(d.order) : void 0,
|
|
2671
2671
|
fillMissingDatesValue: d.fillMissingDatesValue,
|
|
2672
2672
|
// Include funnel config in cache key for proper cache invalidation
|
|
2673
|
-
funnel: d.funnel ?
|
|
2673
|
+
funnel: d.funnel ? tn(d.funnel) : void 0,
|
|
2674
2674
|
// Include flow config in cache key for proper cache invalidation
|
|
2675
|
-
flow: d.flow ?
|
|
2675
|
+
flow: d.flow ? nn(d.flow) : void 0,
|
|
2676
2676
|
// Include retention config in cache key for proper cache invalidation
|
|
2677
|
-
retention: d.retention ?
|
|
2677
|
+
retention: d.retention ? sn(d.retention) : void 0
|
|
2678
2678
|
};
|
|
2679
2679
|
}
|
|
2680
|
-
function
|
|
2680
|
+
function tn(d) {
|
|
2681
2681
|
return {
|
|
2682
2682
|
bindingKey: d.bindingKey,
|
|
2683
2683
|
timeDimension: d.timeDimension,
|
|
@@ -2685,7 +2685,7 @@ function Yt(d) {
|
|
|
2685
2685
|
steps: d.steps.map((e) => {
|
|
2686
2686
|
const t = {
|
|
2687
2687
|
name: e.name,
|
|
2688
|
-
filter: e.filter ? Array.isArray(e.filter) ?
|
|
2688
|
+
filter: e.filter ? Array.isArray(e.filter) ? K(e.filter) : K([e.filter])[0] : void 0,
|
|
2689
2689
|
timeToConvert: e.timeToConvert
|
|
2690
2690
|
};
|
|
2691
2691
|
return "cube" in e && e.cube && (t.cube = e.cube), t;
|
|
@@ -2694,7 +2694,7 @@ function Yt(d) {
|
|
|
2694
2694
|
globalTimeWindow: d.globalTimeWindow
|
|
2695
2695
|
};
|
|
2696
2696
|
}
|
|
2697
|
-
function
|
|
2697
|
+
function nn(d) {
|
|
2698
2698
|
return {
|
|
2699
2699
|
bindingKey: d.bindingKey,
|
|
2700
2700
|
timeDimension: d.timeDimension,
|
|
@@ -2702,7 +2702,7 @@ function Xt(d) {
|
|
|
2702
2702
|
// Normalize starting step - sort filters for consistent hashing
|
|
2703
2703
|
startingStep: {
|
|
2704
2704
|
name: d.startingStep.name,
|
|
2705
|
-
filter: d.startingStep.filter ? Array.isArray(d.startingStep.filter) ?
|
|
2705
|
+
filter: d.startingStep.filter ? Array.isArray(d.startingStep.filter) ? K(d.startingStep.filter) : K([d.startingStep.filter])[0] : void 0
|
|
2706
2706
|
},
|
|
2707
2707
|
// CRITICAL: Include step counts in cache key
|
|
2708
2708
|
stepsBefore: d.stepsBefore,
|
|
@@ -2715,7 +2715,7 @@ function Xt(d) {
|
|
|
2715
2715
|
joinStrategy: d.joinStrategy
|
|
2716
2716
|
};
|
|
2717
2717
|
}
|
|
2718
|
-
function
|
|
2718
|
+
function sn(d) {
|
|
2719
2719
|
return {
|
|
2720
2720
|
timeDimension: d.timeDimension,
|
|
2721
2721
|
bindingKey: d.bindingKey,
|
|
@@ -2724,18 +2724,18 @@ function Zt(d) {
|
|
|
2724
2724
|
periods: d.periods,
|
|
2725
2725
|
retentionType: d.retentionType,
|
|
2726
2726
|
// Normalize filters for consistent hashing
|
|
2727
|
-
cohortFilters: d.cohortFilters ? Array.isArray(d.cohortFilters) ?
|
|
2728
|
-
activityFilters: d.activityFilters ? Array.isArray(d.activityFilters) ?
|
|
2727
|
+
cohortFilters: d.cohortFilters ? Array.isArray(d.cohortFilters) ? K(d.cohortFilters) : K([d.cohortFilters])[0] : void 0,
|
|
2728
|
+
activityFilters: d.activityFilters ? Array.isArray(d.activityFilters) ? K(d.activityFilters) : K([d.activityFilters])[0] : void 0,
|
|
2729
2729
|
// Include breakdown dimensions for cache key
|
|
2730
2730
|
breakdownDimensions: d.breakdownDimensions
|
|
2731
2731
|
};
|
|
2732
2732
|
}
|
|
2733
|
-
function
|
|
2733
|
+
function K(d) {
|
|
2734
2734
|
return [...d].map((e) => {
|
|
2735
2735
|
if ("and" in e && e.and)
|
|
2736
|
-
return { and:
|
|
2736
|
+
return { and: K(e.and) };
|
|
2737
2737
|
if ("or" in e && e.or)
|
|
2738
|
-
return { or:
|
|
2738
|
+
return { or: K(e.or) };
|
|
2739
2739
|
const t = e;
|
|
2740
2740
|
return {
|
|
2741
2741
|
...t,
|
|
@@ -2743,7 +2743,7 @@ function W(d) {
|
|
|
2743
2743
|
};
|
|
2744
2744
|
}).sort((e, t) => JSON.stringify(e).localeCompare(JSON.stringify(t)));
|
|
2745
2745
|
}
|
|
2746
|
-
function
|
|
2746
|
+
function rn(d) {
|
|
2747
2747
|
return [...d].map((e) => ({
|
|
2748
2748
|
dimension: e.dimension,
|
|
2749
2749
|
granularity: e.granularity,
|
|
@@ -2755,18 +2755,18 @@ function en(d) {
|
|
|
2755
2755
|
}) : void 0
|
|
2756
2756
|
})).sort((e, t) => e.dimension.localeCompare(t.dimension));
|
|
2757
2757
|
}
|
|
2758
|
-
function
|
|
2759
|
-
return d === null || typeof d != "object" ? d : Array.isArray(d) ? d.map(
|
|
2758
|
+
function fe(d) {
|
|
2759
|
+
return d === null || typeof d != "object" ? d : Array.isArray(d) ? d.map(fe) : Object.keys(d).sort().reduce((e, t) => (e[t] = fe(
|
|
2760
2760
|
d[t]
|
|
2761
2761
|
), e), {});
|
|
2762
2762
|
}
|
|
2763
|
-
function
|
|
2763
|
+
function Ve(d) {
|
|
2764
2764
|
let e = 2166136261;
|
|
2765
2765
|
for (let t = 0; t < d.length; t++)
|
|
2766
2766
|
e ^= d.charCodeAt(t), e = e * 16777619 >>> 0;
|
|
2767
2767
|
return e.toString(16).padStart(8, "0");
|
|
2768
2768
|
}
|
|
2769
|
-
class
|
|
2769
|
+
class ie {
|
|
2770
2770
|
constructor(e) {
|
|
2771
2771
|
this.databaseAdapter = e;
|
|
2772
2772
|
}
|
|
@@ -2774,7 +2774,7 @@ class ne {
|
|
|
2774
2774
|
* Build time dimension expression with granularity using database adapter
|
|
2775
2775
|
*/
|
|
2776
2776
|
buildTimeDimensionExpression(e, t, n) {
|
|
2777
|
-
const s =
|
|
2777
|
+
const s = R(e, n);
|
|
2778
2778
|
return t ? this.databaseAdapter.buildTimeDimension(t, s) : s instanceof O ? s : o`${s}`;
|
|
2779
2779
|
}
|
|
2780
2780
|
/**
|
|
@@ -2790,18 +2790,18 @@ class ne {
|
|
|
2790
2790
|
const i = typeof s == "number" ? new Date(s * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(s), r = new Date(i);
|
|
2791
2791
|
r.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? s = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(r.getTime() / 1e3) : r.getTime() : s = r.toISOString();
|
|
2792
2792
|
}
|
|
2793
|
-
return
|
|
2794
|
-
|
|
2795
|
-
|
|
2793
|
+
return A(
|
|
2794
|
+
Z(e, n),
|
|
2795
|
+
ee(e, s)
|
|
2796
2796
|
);
|
|
2797
2797
|
}
|
|
2798
2798
|
if (typeof t == "string") {
|
|
2799
2799
|
const n = this.parseRelativeDateRange(t);
|
|
2800
2800
|
if (n) {
|
|
2801
2801
|
let l, m;
|
|
2802
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (l = Math.floor(n.start.getTime() / 1e3), m = Math.floor(n.end.getTime() / 1e3)) : (l = n.start.getTime(), m = n.end.getTime()) : (l = n.start.toISOString(), m = n.end.toISOString()),
|
|
2803
|
-
|
|
2804
|
-
|
|
2802
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (l = Math.floor(n.start.getTime() / 1e3), m = Math.floor(n.end.getTime() / 1e3)) : (l = n.start.getTime(), m = n.end.getTime()) : (l = n.start.toISOString(), m = n.end.toISOString()), A(
|
|
2803
|
+
Z(e, l),
|
|
2804
|
+
ee(e, m)
|
|
2805
2805
|
);
|
|
2806
2806
|
}
|
|
2807
2807
|
const s = this.normalizeDate(t);
|
|
@@ -2811,9 +2811,9 @@ class ne {
|
|
|
2811
2811
|
const a = new Date(i);
|
|
2812
2812
|
a.setUTCHours(23, 59, 59, 999);
|
|
2813
2813
|
let u, c;
|
|
2814
|
-
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (u = Math.floor(r.getTime() / 1e3), c = Math.floor(a.getTime() / 1e3)) : (u = r.getTime(), c = a.getTime()) : (u = r.toISOString(), c = a.toISOString()),
|
|
2815
|
-
|
|
2816
|
-
|
|
2814
|
+
return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (u = Math.floor(r.getTime() / 1e3), c = Math.floor(a.getTime() / 1e3)) : (u = r.getTime(), c = a.getTime()) : (u = r.toISOString(), c = a.toISOString()), A(
|
|
2815
|
+
Z(e, u),
|
|
2816
|
+
ee(e, c)
|
|
2817
2817
|
);
|
|
2818
2818
|
}
|
|
2819
2819
|
return null;
|
|
@@ -2927,7 +2927,7 @@ class ne {
|
|
|
2927
2927
|
return isNaN(t.getTime()) ? null : this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(t.getTime() / 1e3) : t.getTime() : t.toISOString();
|
|
2928
2928
|
}
|
|
2929
2929
|
}
|
|
2930
|
-
class
|
|
2930
|
+
class ge {
|
|
2931
2931
|
constructor(e, t) {
|
|
2932
2932
|
this.databaseAdapter = e, this.dateTimeBuilder = t;
|
|
2933
2933
|
}
|
|
@@ -2957,16 +2957,16 @@ class he {
|
|
|
2957
2957
|
if (r.length > 1) {
|
|
2958
2958
|
if (s?.type === "time") {
|
|
2959
2959
|
const u = r.map((c) => this.dateTimeBuilder.normalizeDate(c) || c);
|
|
2960
|
-
return
|
|
2960
|
+
return Ee(e, u);
|
|
2961
2961
|
}
|
|
2962
|
-
return
|
|
2962
|
+
return Ee(e, r);
|
|
2963
2963
|
} else if (r.length === 1) {
|
|
2964
2964
|
const u = s?.type === "time" && this.dateTimeBuilder.normalizeDate(a) || a;
|
|
2965
2965
|
return Q(e, u);
|
|
2966
2966
|
}
|
|
2967
2967
|
return this.databaseAdapter.buildBooleanLiteral(!1);
|
|
2968
2968
|
case "notEquals":
|
|
2969
|
-
return r.length > 1 ?
|
|
2969
|
+
return r.length > 1 ? ke(e, r) : r.length === 1 ? xe(e, a) : null;
|
|
2970
2970
|
case "contains":
|
|
2971
2971
|
return this.databaseAdapter.buildStringCondition(e, "contains", a);
|
|
2972
2972
|
case "notContains":
|
|
@@ -2976,17 +2976,17 @@ class he {
|
|
|
2976
2976
|
case "endsWith":
|
|
2977
2977
|
return this.databaseAdapter.buildStringCondition(e, "endsWith", a);
|
|
2978
2978
|
case "gt":
|
|
2979
|
-
return
|
|
2979
|
+
return $e(e, a);
|
|
2980
2980
|
case "gte":
|
|
2981
|
-
return
|
|
2981
|
+
return Z(e, a);
|
|
2982
2982
|
case "lt":
|
|
2983
|
-
return
|
|
2983
|
+
return Te(e, a);
|
|
2984
2984
|
case "lte":
|
|
2985
|
-
return
|
|
2985
|
+
return ee(e, a);
|
|
2986
2986
|
case "set":
|
|
2987
|
-
return
|
|
2987
|
+
return Pe(e);
|
|
2988
2988
|
case "notSet":
|
|
2989
|
-
return
|
|
2989
|
+
return Be(e);
|
|
2990
2990
|
case "inDateRange":
|
|
2991
2991
|
if (r.length >= 2) {
|
|
2992
2992
|
const u = this.dateTimeBuilder.normalizeDate(r[0]);
|
|
@@ -2997,35 +2997,35 @@ class he {
|
|
|
2997
2997
|
const m = typeof c == "number" ? new Date(c * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(c), p = new Date(m);
|
|
2998
2998
|
p.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? c = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(p.getTime() / 1e3) : p.getTime() : c = p.toISOString();
|
|
2999
2999
|
}
|
|
3000
|
-
return
|
|
3001
|
-
|
|
3002
|
-
|
|
3000
|
+
return A(
|
|
3001
|
+
Z(e, u),
|
|
3002
|
+
ee(e, c)
|
|
3003
3003
|
);
|
|
3004
3004
|
}
|
|
3005
3005
|
}
|
|
3006
3006
|
return null;
|
|
3007
3007
|
case "beforeDate": {
|
|
3008
3008
|
const u = this.dateTimeBuilder.normalizeDate(a);
|
|
3009
|
-
return u ?
|
|
3009
|
+
return u ? Te(e, u) : null;
|
|
3010
3010
|
}
|
|
3011
3011
|
case "afterDate": {
|
|
3012
3012
|
const u = this.dateTimeBuilder.normalizeDate(a);
|
|
3013
|
-
return u ?
|
|
3013
|
+
return u ? $e(e, u) : null;
|
|
3014
3014
|
}
|
|
3015
3015
|
case "between":
|
|
3016
|
-
return r.length >= 2 ?
|
|
3017
|
-
|
|
3018
|
-
|
|
3016
|
+
return r.length >= 2 ? A(
|
|
3017
|
+
Z(e, r[0]),
|
|
3018
|
+
ee(e, r[1])
|
|
3019
3019
|
) : null;
|
|
3020
3020
|
case "notBetween":
|
|
3021
|
-
return r.length >= 2 ?
|
|
3022
|
-
|
|
3023
|
-
|
|
3021
|
+
return r.length >= 2 ? re(
|
|
3022
|
+
Te(e, r[0]),
|
|
3023
|
+
$e(e, r[1])
|
|
3024
3024
|
) : null;
|
|
3025
3025
|
case "in":
|
|
3026
|
-
return r.length > 0 ?
|
|
3026
|
+
return r.length > 0 ? Ee(e, r) : null;
|
|
3027
3027
|
case "notIn":
|
|
3028
|
-
return r.length > 0 ?
|
|
3028
|
+
return r.length > 0 ? ke(e, r) : null;
|
|
3029
3029
|
case "like":
|
|
3030
3030
|
return this.databaseAdapter.buildStringCondition(e, "like", a);
|
|
3031
3031
|
case "notLike":
|
|
@@ -3037,23 +3037,23 @@ class he {
|
|
|
3037
3037
|
case "notRegex":
|
|
3038
3038
|
return this.databaseAdapter.buildStringCondition(e, "notRegex", a);
|
|
3039
3039
|
case "isEmpty":
|
|
3040
|
-
return
|
|
3041
|
-
|
|
3040
|
+
return re(
|
|
3041
|
+
Be(e),
|
|
3042
3042
|
Q(e, "")
|
|
3043
3043
|
);
|
|
3044
3044
|
case "isNotEmpty":
|
|
3045
|
-
return
|
|
3046
|
-
|
|
3047
|
-
|
|
3045
|
+
return A(
|
|
3046
|
+
Pe(e),
|
|
3047
|
+
xe(e, "")
|
|
3048
3048
|
);
|
|
3049
3049
|
// PostgreSQL array operators - silent no-op for other databases
|
|
3050
3050
|
// These use Drizzle's built-in array operator functions
|
|
3051
3051
|
case "arrayContains":
|
|
3052
|
-
return this.databaseAdapter.getEngineType() === "postgres" ?
|
|
3052
|
+
return this.databaseAdapter.getEngineType() === "postgres" ? Dt(e, r) : null;
|
|
3053
3053
|
case "arrayOverlaps":
|
|
3054
|
-
return this.databaseAdapter.getEngineType() === "postgres" ?
|
|
3054
|
+
return this.databaseAdapter.getEngineType() === "postgres" ? _t(e, r) : null;
|
|
3055
3055
|
case "arrayContained":
|
|
3056
|
-
return this.databaseAdapter.getEngineType() === "postgres" ?
|
|
3056
|
+
return this.databaseAdapter.getEngineType() === "postgres" ? At(e, r) : null;
|
|
3057
3057
|
default:
|
|
3058
3058
|
return null;
|
|
3059
3059
|
}
|
|
@@ -3065,11 +3065,11 @@ class he {
|
|
|
3065
3065
|
buildLogicalFilter(e, t, n) {
|
|
3066
3066
|
if ("and" in e && e.and) {
|
|
3067
3067
|
const s = e.and.map((i) => this.buildSingleFilter(i, t, n)).filter((i) => i !== null);
|
|
3068
|
-
return s.length > 0 ? s.length === 1 ? s[0] :
|
|
3068
|
+
return s.length > 0 ? s.length === 1 ? s[0] : A(...s) : null;
|
|
3069
3069
|
}
|
|
3070
3070
|
if ("or" in e && e.or) {
|
|
3071
3071
|
const s = e.or.map((i) => this.buildSingleFilter(i, t, n)).filter((i) => i !== null);
|
|
3072
|
-
return s.length > 0 ? s.length === 1 ? s[0] :
|
|
3072
|
+
return s.length > 0 ? s.length === 1 ? s[0] : re(...s) : null;
|
|
3073
3073
|
}
|
|
3074
3074
|
return null;
|
|
3075
3075
|
}
|
|
@@ -3084,7 +3084,7 @@ class he {
|
|
|
3084
3084
|
if (!a) return null;
|
|
3085
3085
|
const u = a.dimensions?.[r];
|
|
3086
3086
|
if (!u) return null;
|
|
3087
|
-
const c =
|
|
3087
|
+
const c = R(u.sql, n);
|
|
3088
3088
|
return this.buildFilterCondition(
|
|
3089
3089
|
c,
|
|
3090
3090
|
s.operator,
|
|
@@ -3094,7 +3094,7 @@ class he {
|
|
|
3094
3094
|
);
|
|
3095
3095
|
}
|
|
3096
3096
|
}
|
|
3097
|
-
class
|
|
3097
|
+
class X {
|
|
3098
3098
|
dependencyGraph;
|
|
3099
3099
|
cubes;
|
|
3100
3100
|
constructor(e) {
|
|
@@ -3314,21 +3314,21 @@ class G {
|
|
|
3314
3314
|
return e.type === "calculated" && !!e.calculatedSql;
|
|
3315
3315
|
}
|
|
3316
3316
|
}
|
|
3317
|
-
function
|
|
3318
|
-
const { cube: t, allCubes: n, resolvedMeasures: s } = e, i =
|
|
3317
|
+
function on(d, e) {
|
|
3318
|
+
const { cube: t, allCubes: n, resolvedMeasures: s } = e, i = Fe(d), r = /* @__PURE__ */ new Map();
|
|
3319
3319
|
for (const m of i) {
|
|
3320
3320
|
const { originalRef: p, cubeName: f, fieldName: h } = m, g = f || t.name;
|
|
3321
3321
|
if (!n.get(g))
|
|
3322
3322
|
throw new Error(
|
|
3323
3323
|
`Cannot substitute {${p}}: cube '${g}' not found`
|
|
3324
3324
|
);
|
|
3325
|
-
const b = `${g}.${h}`,
|
|
3326
|
-
if (
|
|
3325
|
+
const b = `${g}.${h}`, $ = s.get(b);
|
|
3326
|
+
if (!$)
|
|
3327
3327
|
throw new Error(
|
|
3328
3328
|
`Cannot substitute {${p}}: measure '${b}' not resolved yet. Ensure measures are resolved in dependency order.`
|
|
3329
3329
|
);
|
|
3330
|
-
const
|
|
3331
|
-
r.set(p,
|
|
3330
|
+
const D = $(), w = o`${D}`;
|
|
3331
|
+
r.set(p, w);
|
|
3332
3332
|
}
|
|
3333
3333
|
const a = [], u = [];
|
|
3334
3334
|
let c = 0;
|
|
@@ -3344,10 +3344,10 @@ function tn(d, e) {
|
|
|
3344
3344
|
return o.raw(d);
|
|
3345
3345
|
const l = [];
|
|
3346
3346
|
for (let m = 0; m < a.length; m++)
|
|
3347
|
-
a[m] && l.push(new
|
|
3347
|
+
a[m] && l.push(new M(a[m])), m < u.length && l.push(u[m]);
|
|
3348
3348
|
return o.join(l, o.raw(""));
|
|
3349
3349
|
}
|
|
3350
|
-
function
|
|
3350
|
+
function Fe(d) {
|
|
3351
3351
|
const e = /\{([^}]+)\}/g, t = d.matchAll(e), n = [];
|
|
3352
3352
|
for (const s of t) {
|
|
3353
3353
|
const i = s[1].trim();
|
|
@@ -3367,7 +3367,7 @@ function Re(d) {
|
|
|
3367
3367
|
}
|
|
3368
3368
|
return n;
|
|
3369
3369
|
}
|
|
3370
|
-
function
|
|
3370
|
+
function an(d) {
|
|
3371
3371
|
const e = [];
|
|
3372
3372
|
let t = 0;
|
|
3373
3373
|
for (let r = 0; r < d.length; r++)
|
|
@@ -3378,7 +3378,7 @@ function nn(d) {
|
|
|
3378
3378
|
break;
|
|
3379
3379
|
}
|
|
3380
3380
|
t > 0 && e.push("Unmatched opening brace in template"), /\{\s*\}/.test(d) && e.push("Empty member reference {} found in template"), /\{[^}]*\{/.test(d) && e.push("Nested braces are not allowed in member references");
|
|
3381
|
-
const i =
|
|
3381
|
+
const i = Fe(d);
|
|
3382
3382
|
for (const r of i) {
|
|
3383
3383
|
const a = r.cubeName ? `${r.cubeName}.${r.fieldName}` : r.fieldName;
|
|
3384
3384
|
/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(a) || e.push(
|
|
@@ -3392,8 +3392,8 @@ function nn(d) {
|
|
|
3392
3392
|
errors: e
|
|
3393
3393
|
};
|
|
3394
3394
|
}
|
|
3395
|
-
function
|
|
3396
|
-
const t =
|
|
3395
|
+
function Se(d, e) {
|
|
3396
|
+
const t = Fe(d), n = /* @__PURE__ */ new Set();
|
|
3397
3397
|
for (const s of t) {
|
|
3398
3398
|
const r = `${s.cubeName || e}.${s.fieldName}`;
|
|
3399
3399
|
n.add(r);
|
|
@@ -3416,7 +3416,7 @@ class I {
|
|
|
3416
3416
|
* @returns Map of measure names to SQL builder functions
|
|
3417
3417
|
*/
|
|
3418
3418
|
buildResolvedMeasures(e, t, n, s) {
|
|
3419
|
-
const i = /* @__PURE__ */ new Map(), r = [], a = [], u = new Set(e), c = new
|
|
3419
|
+
const i = /* @__PURE__ */ new Map(), r = [], a = [], u = new Set(e), c = new X(t);
|
|
3420
3420
|
for (const l of t.values())
|
|
3421
3421
|
c.buildGraph(l);
|
|
3422
3422
|
for (const l of e) {
|
|
@@ -3428,11 +3428,11 @@ class I {
|
|
|
3428
3428
|
g && u.add(g);
|
|
3429
3429
|
continue;
|
|
3430
3430
|
}
|
|
3431
|
-
|
|
3432
|
-
const [
|
|
3433
|
-
if (
|
|
3434
|
-
const C =
|
|
3435
|
-
|
|
3431
|
+
X.isCalculatedMeasure(h) ? (a.push(l), Se(h.calculatedSql, m).forEach((b) => u.add(b)), c.getAllDependencies(l).forEach((b) => {
|
|
3432
|
+
const [$, D] = b.split("."), w = t.get($);
|
|
3433
|
+
if (w && w.measures[D]) {
|
|
3434
|
+
const C = w.measures[D];
|
|
3435
|
+
X.isCalculatedMeasure(C) && Se(C.calculatedSql, $).forEach((E) => u.add(E));
|
|
3436
3436
|
}
|
|
3437
3437
|
})) : r.push(l);
|
|
3438
3438
|
}
|
|
@@ -3443,7 +3443,7 @@ class I {
|
|
|
3443
3443
|
const h = f.measures[p];
|
|
3444
3444
|
if (I.isPostAggregationWindow(h))
|
|
3445
3445
|
continue;
|
|
3446
|
-
|
|
3446
|
+
X.isCalculatedMeasure(h) ? a.includes(l) || a.push(l) : r.includes(l) || r.push(l);
|
|
3447
3447
|
}
|
|
3448
3448
|
}
|
|
3449
3449
|
for (const l of r) {
|
|
@@ -3479,7 +3479,7 @@ class I {
|
|
|
3479
3479
|
`Calculated measure '${t.name}.${e.name}' missing calculatedSql property`
|
|
3480
3480
|
);
|
|
3481
3481
|
const r = this.databaseAdapter.preprocessCalculatedTemplate(e.calculatedSql);
|
|
3482
|
-
return
|
|
3482
|
+
return on(r, {
|
|
3483
3483
|
cube: t,
|
|
3484
3484
|
allCubes: n,
|
|
3485
3485
|
resolvedMeasures: s
|
|
@@ -3504,7 +3504,7 @@ class I {
|
|
|
3504
3504
|
throw new Error(
|
|
3505
3505
|
`Calculated measure '${t.name}.${e.name || "unknown"}' missing calculatedSql property`
|
|
3506
3506
|
);
|
|
3507
|
-
const r = /* @__PURE__ */ new Map(), a =
|
|
3507
|
+
const r = /* @__PURE__ */ new Map(), a = Se(e.calculatedSql, t.name);
|
|
3508
3508
|
for (const u of a) {
|
|
3509
3509
|
const [c, l] = u.split("."), m = s.get(c);
|
|
3510
3510
|
if (m && m.measures[l]) {
|
|
@@ -3516,22 +3516,22 @@ class I {
|
|
|
3516
3516
|
case "count":
|
|
3517
3517
|
case "countDistinct":
|
|
3518
3518
|
case "sum":
|
|
3519
|
-
h =
|
|
3519
|
+
h = z(f);
|
|
3520
3520
|
break;
|
|
3521
3521
|
case "avg":
|
|
3522
3522
|
h = this.databaseAdapter.buildAvg(f);
|
|
3523
3523
|
break;
|
|
3524
3524
|
case "min":
|
|
3525
|
-
h =
|
|
3525
|
+
h = oe(f);
|
|
3526
3526
|
break;
|
|
3527
3527
|
case "max":
|
|
3528
|
-
h =
|
|
3528
|
+
h = G(f);
|
|
3529
3529
|
break;
|
|
3530
3530
|
case "number":
|
|
3531
|
-
h =
|
|
3531
|
+
h = z(f);
|
|
3532
3532
|
break;
|
|
3533
3533
|
default:
|
|
3534
|
-
h =
|
|
3534
|
+
h = z(f);
|
|
3535
3535
|
}
|
|
3536
3536
|
r.set(u, () => h);
|
|
3537
3537
|
}
|
|
@@ -3573,17 +3573,17 @@ class I {
|
|
|
3573
3573
|
case "count":
|
|
3574
3574
|
case "countDistinct":
|
|
3575
3575
|
case "sum":
|
|
3576
|
-
return
|
|
3576
|
+
return z(a);
|
|
3577
3577
|
case "avg":
|
|
3578
3578
|
return this.databaseAdapter.buildAvg(a);
|
|
3579
3579
|
case "min":
|
|
3580
|
-
return
|
|
3580
|
+
return oe(a);
|
|
3581
3581
|
case "max":
|
|
3582
|
-
return
|
|
3582
|
+
return G(a);
|
|
3583
3583
|
case "number":
|
|
3584
|
-
return
|
|
3584
|
+
return z(a);
|
|
3585
3585
|
default:
|
|
3586
|
-
return
|
|
3586
|
+
return z(a);
|
|
3587
3587
|
}
|
|
3588
3588
|
}
|
|
3589
3589
|
}
|
|
@@ -3610,14 +3610,14 @@ class I {
|
|
|
3610
3610
|
throw new Error(
|
|
3611
3611
|
`Measure '${e.name}' of type '${e.type}' is missing required 'sql' property. Only calculated measures and post-aggregation window functions can omit 'sql'.`
|
|
3612
3612
|
);
|
|
3613
|
-
let s =
|
|
3613
|
+
let s = R(e.sql, t);
|
|
3614
3614
|
if (e.filters && e.filters.length > 0) {
|
|
3615
3615
|
const i = e.filters.map((r) => {
|
|
3616
3616
|
const a = r(t);
|
|
3617
3617
|
return a ? o`(${a})` : void 0;
|
|
3618
3618
|
}).filter(Boolean);
|
|
3619
3619
|
if (i.length > 0) {
|
|
3620
|
-
const r = i.length === 1 ? i[0] :
|
|
3620
|
+
const r = i.length === 1 ? i[0] : A(...i);
|
|
3621
3621
|
s = this.databaseAdapter.buildCaseWhen([
|
|
3622
3622
|
{ when: r, then: s }
|
|
3623
3623
|
]);
|
|
@@ -3625,17 +3625,17 @@ class I {
|
|
|
3625
3625
|
}
|
|
3626
3626
|
switch (e.type) {
|
|
3627
3627
|
case "count":
|
|
3628
|
-
return
|
|
3628
|
+
return Ae(s);
|
|
3629
3629
|
case "countDistinct":
|
|
3630
|
-
return
|
|
3630
|
+
return Rt(s);
|
|
3631
3631
|
case "sum":
|
|
3632
|
-
return
|
|
3632
|
+
return z(s);
|
|
3633
3633
|
case "avg":
|
|
3634
3634
|
return this.databaseAdapter.buildAvg(s);
|
|
3635
3635
|
case "min":
|
|
3636
|
-
return
|
|
3636
|
+
return oe(s);
|
|
3637
3637
|
case "max":
|
|
3638
|
-
return
|
|
3638
|
+
return G(s);
|
|
3639
3639
|
case "number":
|
|
3640
3640
|
return s;
|
|
3641
3641
|
// Statistical functions (Phase 1)
|
|
@@ -3686,7 +3686,7 @@ class I {
|
|
|
3686
3686
|
if (i.partitionBy && i.partitionBy.length > 0 && n) {
|
|
3687
3687
|
const c = i.partitionBy.map((l) => {
|
|
3688
3688
|
const m = l.includes(".") ? l.split(".")[1] : l, p = n.dimensions?.[m];
|
|
3689
|
-
return p ?
|
|
3689
|
+
return p ? R(p.sql, t) : (console.warn(`[drizzle-cube] Window function partition dimension '${l}' not found in cube '${n.name}'`), null);
|
|
3690
3690
|
}).filter((l) => l !== null);
|
|
3691
3691
|
c.length > 0 && (r = c);
|
|
3692
3692
|
}
|
|
@@ -3696,12 +3696,12 @@ class I {
|
|
|
3696
3696
|
const m = l.field.includes(".") ? l.field.split(".")[1] : l.field, p = n.dimensions?.[m];
|
|
3697
3697
|
if (p)
|
|
3698
3698
|
return {
|
|
3699
|
-
field:
|
|
3699
|
+
field: R(p.sql, t),
|
|
3700
3700
|
direction: l.direction
|
|
3701
3701
|
};
|
|
3702
3702
|
const f = n.measures?.[m];
|
|
3703
3703
|
return f && f.sql ? {
|
|
3704
|
-
field:
|
|
3704
|
+
field: R(f.sql, t),
|
|
3705
3705
|
direction: l.direction
|
|
3706
3706
|
} : (console.warn(`[drizzle-cube] Window function order field '${l.field}' not found in cube '${n.name}'`), null);
|
|
3707
3707
|
}).filter((l) => l !== null);
|
|
@@ -3722,7 +3722,7 @@ class I {
|
|
|
3722
3722
|
return u === null ? (console.warn(`[drizzle-cube] ${e.type} not supported on ${this.databaseAdapter.getEngineType()}, returning NULL`), o`NULL`) : u;
|
|
3723
3723
|
}
|
|
3724
3724
|
default:
|
|
3725
|
-
return
|
|
3725
|
+
return Ae(s);
|
|
3726
3726
|
}
|
|
3727
3727
|
}
|
|
3728
3728
|
/**
|
|
@@ -3868,7 +3868,7 @@ class I {
|
|
|
3868
3868
|
return n.length > 0;
|
|
3869
3869
|
}
|
|
3870
3870
|
}
|
|
3871
|
-
class
|
|
3871
|
+
class un {
|
|
3872
3872
|
constructor(e) {
|
|
3873
3873
|
this.dateTimeBuilder = e;
|
|
3874
3874
|
}
|
|
@@ -3936,8 +3936,8 @@ class sn {
|
|
|
3936
3936
|
if (I.isPostAggregationWindow(g)) {
|
|
3937
3937
|
const y = I.getWindowBaseMeasure(g, p);
|
|
3938
3938
|
if (y) {
|
|
3939
|
-
const [b,
|
|
3940
|
-
if (
|
|
3939
|
+
const [b, $] = y.split("."), w = r.get(b)?.measures?.[$];
|
|
3940
|
+
if (w && this.isAggregateFunctionType(w.type)) {
|
|
3941
3941
|
l = !0;
|
|
3942
3942
|
break;
|
|
3943
3943
|
}
|
|
@@ -3952,15 +3952,15 @@ class sn {
|
|
|
3952
3952
|
const [p, f] = m.split("."), h = r.get(p);
|
|
3953
3953
|
if (h && h.dimensions && h.dimensions[f])
|
|
3954
3954
|
if (s?.preAggregationCTEs?.some((y) => y.cube.name === p)) {
|
|
3955
|
-
const y = s.preAggregationCTEs.find((
|
|
3955
|
+
const y = s.preAggregationCTEs.find(($) => $.cube.name === p), b = y.joinKeys.find(($) => $.targetColumn === f);
|
|
3956
3956
|
if (b && b.sourceColumnObj)
|
|
3957
3957
|
i.push(b.sourceColumnObj);
|
|
3958
3958
|
else {
|
|
3959
|
-
const
|
|
3960
|
-
i.push(
|
|
3959
|
+
const $ = o`${o.identifier(y.cteAlias)}.${o.identifier(f)}`;
|
|
3960
|
+
i.push($);
|
|
3961
3961
|
}
|
|
3962
3962
|
} else {
|
|
3963
|
-
const y = h.dimensions[f], b =
|
|
3963
|
+
const y = h.dimensions[f], b = R(y.sql, n);
|
|
3964
3964
|
i.push(b);
|
|
3965
3965
|
}
|
|
3966
3966
|
}
|
|
@@ -3969,17 +3969,17 @@ class sn {
|
|
|
3969
3969
|
const [p, f] = m.dimension.split("."), h = r.get(p);
|
|
3970
3970
|
if (h && h.dimensions && h.dimensions[f])
|
|
3971
3971
|
if (s?.preAggregationCTEs?.some((y) => y.cube.name === p)) {
|
|
3972
|
-
const y = s.preAggregationCTEs.find((
|
|
3972
|
+
const y = s.preAggregationCTEs.find(($) => $.cube.name === p), b = y.joinKeys.find(($) => $.targetColumn === f);
|
|
3973
3973
|
if (b && b.sourceColumnObj) {
|
|
3974
|
-
const
|
|
3974
|
+
const $ = this.dateTimeBuilder.buildTimeDimensionExpression(
|
|
3975
3975
|
b.sourceColumnObj,
|
|
3976
3976
|
m.granularity,
|
|
3977
3977
|
n
|
|
3978
3978
|
);
|
|
3979
|
-
i.push(
|
|
3979
|
+
i.push($);
|
|
3980
3980
|
} else {
|
|
3981
|
-
const
|
|
3982
|
-
i.push(
|
|
3981
|
+
const $ = o`${o.identifier(y.cteAlias)}.${o.identifier(f)}`;
|
|
3982
|
+
i.push($);
|
|
3983
3983
|
}
|
|
3984
3984
|
} else {
|
|
3985
3985
|
const y = h.dimensions[f], b = this.dateTimeBuilder.buildTimeDimensionExpression(
|
|
@@ -3993,13 +3993,13 @@ class sn {
|
|
|
3993
3993
|
return i;
|
|
3994
3994
|
}
|
|
3995
3995
|
}
|
|
3996
|
-
class
|
|
3996
|
+
class ln {
|
|
3997
3997
|
dateTimeBuilder;
|
|
3998
3998
|
filterBuilder;
|
|
3999
3999
|
groupByBuilder;
|
|
4000
4000
|
measureBuilder;
|
|
4001
4001
|
constructor(e) {
|
|
4002
|
-
this.dateTimeBuilder = new
|
|
4002
|
+
this.dateTimeBuilder = new ie(e), this.filterBuilder = new ge(e, this.dateTimeBuilder), this.groupByBuilder = new un(this.dateTimeBuilder), this.measureBuilder = new I(e);
|
|
4003
4003
|
}
|
|
4004
4004
|
/**
|
|
4005
4005
|
* Build resolvedMeasures map for a set of measures
|
|
@@ -4019,7 +4019,7 @@ class rn {
|
|
|
4019
4019
|
for (const r of t.dimensions) {
|
|
4020
4020
|
const [a, u] = r.split("."), c = i.get(a);
|
|
4021
4021
|
if (c && c.dimensions && c.dimensions[u]) {
|
|
4022
|
-
const l = c.dimensions[u], m =
|
|
4022
|
+
const l = c.dimensions[u], m = R(l.sql, n);
|
|
4023
4023
|
s[r] = o`${m}`.as(r);
|
|
4024
4024
|
}
|
|
4025
4025
|
}
|
|
@@ -4049,7 +4049,7 @@ class rn {
|
|
|
4049
4049
|
s[r.dimension] = o`${m}`.as(r.dimension);
|
|
4050
4050
|
}
|
|
4051
4051
|
}
|
|
4052
|
-
return Object.keys(s).length === 0 && (s.count =
|
|
4052
|
+
return Object.keys(s).length === 0 && (s.count = Ae()), s;
|
|
4053
4053
|
}
|
|
4054
4054
|
/**
|
|
4055
4055
|
* Build calculated measure expression by substituting {member} references
|
|
@@ -4114,13 +4114,13 @@ class rn {
|
|
|
4114
4114
|
if (s?.preAggregationCTEs && s.preAggregationCTEs.some((b) => b.cube.name === l))
|
|
4115
4115
|
continue;
|
|
4116
4116
|
if (n.filterCache) {
|
|
4117
|
-
const y =
|
|
4117
|
+
const y = lt(c.dimension, c.dateRange), b = n.filterCache.get(y);
|
|
4118
4118
|
if (b) {
|
|
4119
4119
|
r.push(b);
|
|
4120
4120
|
continue;
|
|
4121
4121
|
}
|
|
4122
4122
|
}
|
|
4123
|
-
const f = p.dimensions[m], h =
|
|
4123
|
+
const f = p.dimensions[m], h = R(f.sql, n), g = this.buildDateRangeCondition(h, c.dateRange);
|
|
4124
4124
|
g && r.push(g);
|
|
4125
4125
|
}
|
|
4126
4126
|
}
|
|
@@ -4148,11 +4148,11 @@ class rn {
|
|
|
4148
4148
|
const f = e;
|
|
4149
4149
|
if (f.and) {
|
|
4150
4150
|
const h = f.and.map((g) => this.processFilter(g, t, n, s, i)).filter((g) => g !== null);
|
|
4151
|
-
return h.length > 0 ?
|
|
4151
|
+
return h.length > 0 ? A(...h) : null;
|
|
4152
4152
|
}
|
|
4153
4153
|
if (f.or) {
|
|
4154
4154
|
const h = f.or.map((g) => this.processFilter(g, t, n, s, i)).filter((g) => g !== null);
|
|
4155
|
-
return h.length > 0 ?
|
|
4155
|
+
return h.length > 0 ? re(...h) : null;
|
|
4156
4156
|
}
|
|
4157
4157
|
}
|
|
4158
4158
|
const r = e, [a, u] = r.member.split("."), c = t.get(a);
|
|
@@ -4164,11 +4164,11 @@ class rn {
|
|
|
4164
4164
|
return null;
|
|
4165
4165
|
const f = ["arrayContains", "arrayOverlaps", "arrayContained"].includes(r.operator);
|
|
4166
4166
|
if (!f && n.filterCache) {
|
|
4167
|
-
const g =
|
|
4167
|
+
const g = me(e), y = n.filterCache.get(g);
|
|
4168
4168
|
if (y)
|
|
4169
4169
|
return y;
|
|
4170
4170
|
}
|
|
4171
|
-
const h = f ? typeof l.sql == "function" ? l.sql(n) : l.sql :
|
|
4171
|
+
const h = f ? typeof l.sql == "function" ? l.sql(n) : l.sql : R(l.sql, n);
|
|
4172
4172
|
return this.buildFilterCondition(
|
|
4173
4173
|
h,
|
|
4174
4174
|
r.operator,
|
|
@@ -4226,7 +4226,7 @@ class rn {
|
|
|
4226
4226
|
for (const [i, r] of Object.entries(e.order)) {
|
|
4227
4227
|
if (!s.includes(i))
|
|
4228
4228
|
throw new Error(`Cannot order by '${i}': field is not selected in the query`);
|
|
4229
|
-
const a = r === "desc" ?
|
|
4229
|
+
const a = r === "desc" ? vt(o.identifier(i)) : Qe(o.identifier(i));
|
|
4230
4230
|
n.push(a);
|
|
4231
4231
|
}
|
|
4232
4232
|
if (e.timeDimensions && e.timeDimensions.length > 0) {
|
|
@@ -4234,7 +4234,7 @@ class rn {
|
|
|
4234
4234
|
(a, u) => a.dimension.localeCompare(u.dimension)
|
|
4235
4235
|
);
|
|
4236
4236
|
for (const a of r)
|
|
4237
|
-
i.has(a.dimension) || n.push(
|
|
4237
|
+
i.has(a.dimension) || n.push(Qe(o.identifier(a.dimension)));
|
|
4238
4238
|
}
|
|
4239
4239
|
return n;
|
|
4240
4240
|
}
|
|
@@ -4290,7 +4290,7 @@ class rn {
|
|
|
4290
4290
|
return this.filterBuilder.buildLogicalFilter(e, t, n);
|
|
4291
4291
|
}
|
|
4292
4292
|
}
|
|
4293
|
-
class
|
|
4293
|
+
class ae {
|
|
4294
4294
|
cubes;
|
|
4295
4295
|
connectivityCache = /* @__PURE__ */ new Map();
|
|
4296
4296
|
/**
|
|
@@ -4321,7 +4321,7 @@ class oe {
|
|
|
4321
4321
|
const { cube: u, path: c } = r.shift(), l = this.cubes.get(u);
|
|
4322
4322
|
if (l?.joins)
|
|
4323
4323
|
for (const [, m] of Object.entries(l.joins)) {
|
|
4324
|
-
const f =
|
|
4324
|
+
const f = W(m.targetCube).name;
|
|
4325
4325
|
if (a.has(f))
|
|
4326
4326
|
continue;
|
|
4327
4327
|
const h = [
|
|
@@ -4401,7 +4401,7 @@ class oe {
|
|
|
4401
4401
|
const l = this.cubes.get(a);
|
|
4402
4402
|
if (l?.joins)
|
|
4403
4403
|
for (const [, m] of Object.entries(l.joins)) {
|
|
4404
|
-
const f =
|
|
4404
|
+
const f = W(m.targetCube).name;
|
|
4405
4405
|
if (c.has(f))
|
|
4406
4406
|
continue;
|
|
4407
4407
|
const h = [
|
|
@@ -4449,10 +4449,10 @@ class oe {
|
|
|
4449
4449
|
buildJoinCondition(e, t, n) {
|
|
4450
4450
|
const s = [];
|
|
4451
4451
|
for (const i of e.on) {
|
|
4452
|
-
const r = t ? o`${o.identifier(t)}.${o.identifier(i.source.name)}` :
|
|
4452
|
+
const r = t ? o`${o.identifier(t)}.${o.identifier(i.source.name)}` : ve(i.source), a = n ? o`${o.identifier(n)}.${o.identifier(i.target.name)}` : ve(i.target), u = i.as || Q;
|
|
4453
4453
|
s.push(u(r, a));
|
|
4454
4454
|
}
|
|
4455
|
-
return
|
|
4455
|
+
return A(...s);
|
|
4456
4456
|
}
|
|
4457
4457
|
/**
|
|
4458
4458
|
* Get all reachable cubes from a starting cube
|
|
@@ -4467,7 +4467,7 @@ class oe {
|
|
|
4467
4467
|
const s = n.shift(), i = this.cubes.get(s);
|
|
4468
4468
|
if (i?.joins)
|
|
4469
4469
|
for (const [, r] of Object.entries(i.joins)) {
|
|
4470
|
-
const u =
|
|
4470
|
+
const u = W(r.targetCube).name;
|
|
4471
4471
|
t.has(u) || (t.add(u), n.push(u));
|
|
4472
4472
|
}
|
|
4473
4473
|
}
|
|
@@ -4487,7 +4487,7 @@ class oe {
|
|
|
4487
4487
|
this.connectivityCache.set(e, { path: t });
|
|
4488
4488
|
}
|
|
4489
4489
|
}
|
|
4490
|
-
class
|
|
4490
|
+
class ct {
|
|
4491
4491
|
// Cache resolver per cubes map to avoid repeated instantiation
|
|
4492
4492
|
resolverCache = /* @__PURE__ */ new WeakMap();
|
|
4493
4493
|
/**
|
|
@@ -4495,7 +4495,7 @@ class at {
|
|
|
4495
4495
|
*/
|
|
4496
4496
|
getResolver(e) {
|
|
4497
4497
|
let t = this.resolverCache.get(e);
|
|
4498
|
-
return t || (t = new
|
|
4498
|
+
return t || (t = new ae(e), this.resolverCache.set(e, t)), t;
|
|
4499
4499
|
}
|
|
4500
4500
|
/**
|
|
4501
4501
|
* Analyze a semantic query to determine which cubes are involved
|
|
@@ -4644,45 +4644,46 @@ class at {
|
|
|
4644
4644
|
);
|
|
4645
4645
|
if (!h || h.length === 0)
|
|
4646
4646
|
throw new Error(`No join path found from '${t.name}' to '${p}'`);
|
|
4647
|
-
for (const {
|
|
4648
|
-
if (u.has(
|
|
4647
|
+
for (const { fromCube: g, toCube: y, joinDef: b } of h) {
|
|
4648
|
+
if (u.has(y))
|
|
4649
4649
|
continue;
|
|
4650
|
-
const
|
|
4651
|
-
if (
|
|
4652
|
-
throw new Error(`Cube '${
|
|
4653
|
-
if (
|
|
4654
|
-
const
|
|
4650
|
+
const $ = e.get(y);
|
|
4651
|
+
if (!$)
|
|
4652
|
+
throw new Error(`Cube '${y}' not found`);
|
|
4653
|
+
if (b.relationship === "belongsToMany" && b.through) {
|
|
4654
|
+
const D = Xt(b, s.securityContext);
|
|
4655
4655
|
a.push({
|
|
4656
|
-
cube:
|
|
4657
|
-
alias: `${
|
|
4658
|
-
joinType:
|
|
4656
|
+
cube: $,
|
|
4657
|
+
alias: `${y.toLowerCase()}_cube`,
|
|
4658
|
+
joinType: D.junctionJoins[1].joinType,
|
|
4659
4659
|
// Use the target join type
|
|
4660
|
-
joinCondition:
|
|
4660
|
+
joinCondition: D.junctionJoins[1].condition,
|
|
4661
4661
|
// Target join condition
|
|
4662
4662
|
junctionTable: {
|
|
4663
|
-
table:
|
|
4664
|
-
alias: `junction_${
|
|
4665
|
-
joinType:
|
|
4666
|
-
joinCondition:
|
|
4667
|
-
securitySql:
|
|
4663
|
+
table: b.through.table,
|
|
4664
|
+
alias: `junction_${y.toLowerCase()}`,
|
|
4665
|
+
joinType: D.junctionJoins[0].joinType,
|
|
4666
|
+
joinCondition: D.junctionJoins[0].condition,
|
|
4667
|
+
securitySql: b.through.securitySql,
|
|
4668
|
+
sourceCubeName: g
|
|
4668
4669
|
}
|
|
4669
4670
|
});
|
|
4670
4671
|
} else {
|
|
4671
|
-
const
|
|
4672
|
-
|
|
4672
|
+
const D = r.buildJoinCondition(
|
|
4673
|
+
b,
|
|
4673
4674
|
null,
|
|
4674
4675
|
// No source alias needed - use the actual column
|
|
4675
4676
|
null
|
|
4676
4677
|
// No target alias needed - use the actual column
|
|
4677
|
-
),
|
|
4678
|
+
), w = _e(b.relationship, b.sqlJoinType);
|
|
4678
4679
|
a.push({
|
|
4679
|
-
cube:
|
|
4680
|
-
alias: `${
|
|
4681
|
-
joinType:
|
|
4682
|
-
joinCondition:
|
|
4680
|
+
cube: $,
|
|
4681
|
+
alias: `${y.toLowerCase()}_cube`,
|
|
4682
|
+
joinType: w,
|
|
4683
|
+
joinCondition: D
|
|
4683
4684
|
});
|
|
4684
4685
|
}
|
|
4685
|
-
u.add(
|
|
4686
|
+
u.add(y);
|
|
4686
4687
|
}
|
|
4687
4688
|
}
|
|
4688
4689
|
return a;
|
|
@@ -4738,26 +4739,31 @@ class at {
|
|
|
4738
4739
|
if (y.length === 0)
|
|
4739
4740
|
continue;
|
|
4740
4741
|
const b = this.analyzeJoinPathToPrimary(e, t, l.name, i);
|
|
4741
|
-
let
|
|
4742
|
+
let $, D;
|
|
4742
4743
|
if (b?.hasIntermediateHasMany && b.intermediateJoins.length > 0)
|
|
4743
|
-
|
|
4744
|
+
$ = b.correctJoinKeys, D = b.intermediateJoins;
|
|
4744
4745
|
else {
|
|
4745
4746
|
const S = p ? this.findJoinInfoToCube(e, t.name) : this.findJoinInfoForCube(e, t, l.name);
|
|
4746
4747
|
if (!S)
|
|
4747
4748
|
continue;
|
|
4748
|
-
|
|
4749
|
+
S.joinDef.relationship === "belongsToMany" && S.joinDef.through ? $ = S.joinDef.through.sourceKey.map((_) => ({
|
|
4749
4750
|
sourceColumn: _.target.name,
|
|
4750
4751
|
targetColumn: _.source.name,
|
|
4751
4752
|
sourceColumnObj: _.target,
|
|
4752
4753
|
targetColumnObj: _.source
|
|
4753
|
-
})) : S.joinDef.on.map((
|
|
4754
|
-
sourceColumn:
|
|
4755
|
-
targetColumn:
|
|
4756
|
-
sourceColumnObj:
|
|
4757
|
-
targetColumnObj:
|
|
4758
|
-
}))
|
|
4759
|
-
|
|
4760
|
-
|
|
4754
|
+
})) : $ = p || "reversed" in S && S.reversed ? S.joinDef.on.map((v) => ({
|
|
4755
|
+
sourceColumn: v.target.name,
|
|
4756
|
+
targetColumn: v.source.name,
|
|
4757
|
+
sourceColumnObj: v.target,
|
|
4758
|
+
targetColumnObj: v.source
|
|
4759
|
+
})) : S.joinDef.on.map((v) => ({
|
|
4760
|
+
sourceColumn: v.source.name,
|
|
4761
|
+
targetColumn: v.target.name,
|
|
4762
|
+
sourceColumnObj: v.source,
|
|
4763
|
+
targetColumnObj: v.target
|
|
4764
|
+
})), D = void 0;
|
|
4765
|
+
}
|
|
4766
|
+
const w = this.findPropagatingFilters(s, l, e), C = /* @__PURE__ */ new Map([[l.name, l]]), { aggregateMeasures: T, requiredBaseMeasures: E } = I.categorizeForPostAggregation(
|
|
4761
4767
|
y,
|
|
4762
4768
|
C
|
|
4763
4769
|
), N = [.../* @__PURE__ */ new Set([
|
|
@@ -4768,7 +4774,7 @@ class at {
|
|
|
4768
4774
|
const S = this.expandCalculatedMeasureDependencies(
|
|
4769
4775
|
l,
|
|
4770
4776
|
N
|
|
4771
|
-
),
|
|
4777
|
+
), _ = this.findDownstreamJoinKeys(
|
|
4772
4778
|
l,
|
|
4773
4779
|
s,
|
|
4774
4780
|
e
|
|
@@ -4777,11 +4783,11 @@ class at {
|
|
|
4777
4783
|
cube: l,
|
|
4778
4784
|
alias: m,
|
|
4779
4785
|
cteAlias: `${l.name.toLowerCase()}_agg`,
|
|
4780
|
-
joinKeys:
|
|
4786
|
+
joinKeys: $,
|
|
4781
4787
|
measures: S,
|
|
4782
|
-
propagatingFilters:
|
|
4783
|
-
downstreamJoinKeys:
|
|
4784
|
-
intermediateJoins:
|
|
4788
|
+
propagatingFilters: w.length > 0 ? w : void 0,
|
|
4789
|
+
downstreamJoinKeys: _.length > 0 ? _ : void 0,
|
|
4790
|
+
intermediateJoins: D && D.length > 0 ? D : void 0,
|
|
4785
4791
|
cteType: "aggregate",
|
|
4786
4792
|
cteReason: f
|
|
4787
4793
|
});
|
|
@@ -4797,7 +4803,7 @@ class at {
|
|
|
4797
4803
|
for (const [, n] of e)
|
|
4798
4804
|
if (n.name !== t && n.joins) {
|
|
4799
4805
|
for (const [, s] of Object.entries(n.joins))
|
|
4800
|
-
if (
|
|
4806
|
+
if (W(s.targetCube).name === t)
|
|
4801
4807
|
return { sourceCube: n, joinDef: s };
|
|
4802
4808
|
}
|
|
4803
4809
|
return null;
|
|
@@ -4837,13 +4843,13 @@ class at {
|
|
|
4837
4843
|
for (let f = 0; f < a.length - 1; f++) {
|
|
4838
4844
|
const h = a[f], g = a[f + 1], y = e.get(h.toCube);
|
|
4839
4845
|
if (!y) continue;
|
|
4840
|
-
const
|
|
4846
|
+
const $ = y.sql(s).where, D = g.joinDef.on[0]?.source, w = h.joinDef.on[0]?.target;
|
|
4841
4847
|
l.push({
|
|
4842
4848
|
cube: y,
|
|
4843
4849
|
joinDef: g.joinDef,
|
|
4844
|
-
securityFilter:
|
|
4845
|
-
primaryJoinColumn:
|
|
4846
|
-
cteJoinColumn:
|
|
4850
|
+
securityFilter: $,
|
|
4851
|
+
primaryJoinColumn: w,
|
|
4852
|
+
cteJoinColumn: D
|
|
4847
4853
|
});
|
|
4848
4854
|
}
|
|
4849
4855
|
const p = a[0].joinDef.on.map((f) => ({
|
|
@@ -4882,7 +4888,7 @@ class at {
|
|
|
4882
4888
|
if (!i.has(a) && (i.add(a), !!u.joins)) {
|
|
4883
4889
|
for (const [, c] of Object.entries(u.joins))
|
|
4884
4890
|
if (c.relationship === "hasMany") {
|
|
4885
|
-
const l =
|
|
4891
|
+
const l = W(c.targetCube);
|
|
4886
4892
|
(r.has(a) || r.has(l.name)) && s.push({
|
|
4887
4893
|
fromCube: a,
|
|
4888
4894
|
toCube: l.name,
|
|
@@ -4923,19 +4929,19 @@ class at {
|
|
|
4923
4929
|
findJoinInfoForCube(e, t, n) {
|
|
4924
4930
|
if (t.joins) {
|
|
4925
4931
|
for (const [, i] of Object.entries(t.joins))
|
|
4926
|
-
if (
|
|
4932
|
+
if (W(i.targetCube).name === n)
|
|
4927
4933
|
return { sourceCube: t, joinDef: i };
|
|
4928
4934
|
}
|
|
4929
4935
|
const s = e.get(n);
|
|
4930
4936
|
if (s?.joins) {
|
|
4931
4937
|
for (const [, i] of Object.entries(s.joins))
|
|
4932
|
-
if (
|
|
4938
|
+
if (W(i.targetCube).name === t.name)
|
|
4933
4939
|
return { sourceCube: s, joinDef: i, reversed: !0 };
|
|
4934
4940
|
}
|
|
4935
4941
|
for (const [, i] of e)
|
|
4936
4942
|
if (!(i.name === t.name || i.name === n) && i.joins) {
|
|
4937
4943
|
for (const [, r] of Object.entries(i.joins))
|
|
4938
|
-
if (
|
|
4944
|
+
if (W(r.targetCube).name === n)
|
|
4939
4945
|
return { sourceCube: i, joinDef: r };
|
|
4940
4946
|
}
|
|
4941
4947
|
return null;
|
|
@@ -4967,15 +4973,20 @@ class at {
|
|
|
4967
4973
|
}
|
|
4968
4974
|
if (e.joins)
|
|
4969
4975
|
for (const [, r] of Object.entries(e.joins)) {
|
|
4970
|
-
const u =
|
|
4976
|
+
const u = W(r.targetCube).name;
|
|
4971
4977
|
if (i.has(u)) {
|
|
4972
|
-
|
|
4978
|
+
let c;
|
|
4979
|
+
r.relationship === "belongsToMany" && r.through ? c = r.through.sourceKey.map((l) => ({
|
|
4973
4980
|
sourceColumn: l.source.name,
|
|
4974
4981
|
targetColumn: l.target.name,
|
|
4975
4982
|
sourceColumnObj: l.source,
|
|
4976
4983
|
targetColumnObj: l.target
|
|
4977
|
-
}))
|
|
4978
|
-
|
|
4984
|
+
})) : c = r.on.map((l) => ({
|
|
4985
|
+
sourceColumn: l.source.name,
|
|
4986
|
+
targetColumn: l.target.name,
|
|
4987
|
+
sourceColumnObj: l.source,
|
|
4988
|
+
targetColumnObj: l.target
|
|
4989
|
+
})), s.push({
|
|
4979
4990
|
targetCubeName: u,
|
|
4980
4991
|
joinKeys: c
|
|
4981
4992
|
});
|
|
@@ -5023,7 +5034,7 @@ class at {
|
|
|
5023
5034
|
if (!e.joins)
|
|
5024
5035
|
return null;
|
|
5025
5036
|
for (const [, n] of Object.entries(e.joins))
|
|
5026
|
-
if (
|
|
5037
|
+
if (W(n.targetCube).name === t && n.relationship === "hasMany")
|
|
5027
5038
|
return n;
|
|
5028
5039
|
return null;
|
|
5029
5040
|
}
|
|
@@ -5051,7 +5062,7 @@ class at {
|
|
|
5051
5062
|
const a = n.get(r);
|
|
5052
5063
|
if (a?.joins) {
|
|
5053
5064
|
for (const [, u] of Object.entries(a.joins))
|
|
5054
|
-
if (
|
|
5065
|
+
if (W(u.targetCube).name === t.name && u.relationship === "hasMany") {
|
|
5055
5066
|
const l = this.extractFiltersForCube(e.filters, r), m = this.extractTimeDimensionFiltersForCube(e, r), p = [...l, ...m];
|
|
5056
5067
|
p.length > 0 && u.on.length > 0 && s.push({
|
|
5057
5068
|
sourceCube: a,
|
|
@@ -5307,7 +5318,7 @@ class at {
|
|
|
5307
5318
|
visitedCubes: r
|
|
5308
5319
|
};
|
|
5309
5320
|
const a = i.map((u) => {
|
|
5310
|
-
const c =
|
|
5321
|
+
const c = _e(u.joinDef.relationship, u.joinDef.sqlJoinType), l = u.joinDef.on.map((p) => ({
|
|
5311
5322
|
sourceColumn: p.source.name,
|
|
5312
5323
|
targetColumn: p.target.name
|
|
5313
5324
|
})), m = {
|
|
@@ -5351,26 +5362,26 @@ class at {
|
|
|
5351
5362
|
if (!u)
|
|
5352
5363
|
continue;
|
|
5353
5364
|
const c = s.measures.filter(
|
|
5354
|
-
(
|
|
5365
|
+
($) => $.startsWith(r + ".")
|
|
5355
5366
|
), l = this.extractMeasuresFromFilters(s, u), m = [.../* @__PURE__ */ new Set([...c, ...l])];
|
|
5356
5367
|
if (m.length === 0)
|
|
5357
5368
|
continue;
|
|
5358
|
-
const p = a.on.map((
|
|
5359
|
-
sourceColumn:
|
|
5360
|
-
targetColumn:
|
|
5369
|
+
const p = a.on.map(($) => ({
|
|
5370
|
+
sourceColumn: $.source.name,
|
|
5371
|
+
targetColumn: $.target.name
|
|
5361
5372
|
})), f = /* @__PURE__ */ new Map([[r, u]]), { aggregateMeasures: h, postAggWindowMeasures: g, requiredBaseMeasures: y } = I.categorizeForPostAggregation(
|
|
5362
5373
|
m,
|
|
5363
5374
|
f
|
|
5364
5375
|
), b = [.../* @__PURE__ */ new Set([
|
|
5365
5376
|
...h,
|
|
5366
|
-
...Array.from(y).filter((
|
|
5377
|
+
...Array.from(y).filter(($) => $.startsWith(r + "."))
|
|
5367
5378
|
])];
|
|
5368
5379
|
if (b.length > 0) {
|
|
5369
|
-
const
|
|
5380
|
+
const $ = g.length > 0;
|
|
5370
5381
|
i.push({
|
|
5371
5382
|
cubeName: r,
|
|
5372
5383
|
cteAlias: `${r.toLowerCase()}_agg`,
|
|
5373
|
-
reason:
|
|
5384
|
+
reason: $ ? `hasMany relationship from ${t.name} - requires pre-aggregation; includes base measures for post-aggregation window functions` : `hasMany relationship from ${t.name} - requires pre-aggregation to prevent row duplication (fan-out)`,
|
|
5374
5385
|
reasonType: "hasMany",
|
|
5375
5386
|
measures: b,
|
|
5376
5387
|
joinKeys: p,
|
|
@@ -5428,7 +5439,7 @@ class at {
|
|
|
5428
5439
|
};
|
|
5429
5440
|
}
|
|
5430
5441
|
}
|
|
5431
|
-
class
|
|
5442
|
+
class cn {
|
|
5432
5443
|
constructor(e) {
|
|
5433
5444
|
this.queryBuilder = e;
|
|
5434
5445
|
}
|
|
@@ -5497,7 +5508,7 @@ class on {
|
|
|
5497
5508
|
const T = C.cube.sql(n), N = [Q(C.cteJoinColumn, C.joinDef.on[0]?.target)];
|
|
5498
5509
|
C.securityFilter && N.push(C.securityFilter), f = f.leftJoin(
|
|
5499
5510
|
T.from,
|
|
5500
|
-
|
|
5511
|
+
A(...N)
|
|
5501
5512
|
);
|
|
5502
5513
|
}
|
|
5503
5514
|
const h = s ? {
|
|
@@ -5508,8 +5519,8 @@ class on {
|
|
|
5508
5519
|
for (const C of t.timeDimensions) {
|
|
5509
5520
|
const [T, E] = C.dimension.split(".");
|
|
5510
5521
|
if (T === l && r.dimensions && r.dimensions[E] && C.dateRange) {
|
|
5511
|
-
const N = r.dimensions[E], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n),
|
|
5512
|
-
|
|
5522
|
+
const N = r.dimensions[E], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n), _ = this.queryBuilder.buildDateRangeCondition(S, C.dateRange);
|
|
5523
|
+
_ && y.push(_);
|
|
5513
5524
|
}
|
|
5514
5525
|
}
|
|
5515
5526
|
if (t.filters) {
|
|
@@ -5519,8 +5530,8 @@ class on {
|
|
|
5519
5530
|
if (E === l && r.dimensions && r.dimensions[N]) {
|
|
5520
5531
|
const S = r.dimensions[N];
|
|
5521
5532
|
if (T.operator === "inDateRange") {
|
|
5522
|
-
const
|
|
5523
|
-
|
|
5533
|
+
const _ = this.queryBuilder.buildMeasureExpression({ sql: S.sql, type: "number" }, n), v = this.queryBuilder.buildDateRangeCondition(_, T.values);
|
|
5534
|
+
v && y.push(v);
|
|
5524
5535
|
}
|
|
5525
5536
|
}
|
|
5526
5537
|
}
|
|
@@ -5535,29 +5546,29 @@ class on {
|
|
|
5535
5546
|
}
|
|
5536
5547
|
const b = [];
|
|
5537
5548
|
if (a.where && b.push(a.where), b.push(...g, ...y), b.length > 0) {
|
|
5538
|
-
const C = b.length === 1 ? b[0] :
|
|
5549
|
+
const C = b.length === 1 ? b[0] : A(...b);
|
|
5539
5550
|
f = f.where(C);
|
|
5540
5551
|
}
|
|
5541
|
-
const
|
|
5552
|
+
const $ = [], D = /* @__PURE__ */ new Set(), w = (C) => {
|
|
5542
5553
|
const T = C?.name || (typeof C == "string" ? C : null);
|
|
5543
|
-
T && !
|
|
5554
|
+
T && !D.has(T) ? (D.add(T), $.push(C)) : T || $.push(C);
|
|
5544
5555
|
};
|
|
5545
5556
|
if (u && e.intermediateJoins) {
|
|
5546
5557
|
const C = e.intermediateJoins[0];
|
|
5547
|
-
C.primaryJoinColumn &&
|
|
5558
|
+
C.primaryJoinColumn && w(C.primaryJoinColumn);
|
|
5548
5559
|
} else
|
|
5549
5560
|
for (const C of e.joinKeys)
|
|
5550
|
-
C.targetColumnObj &&
|
|
5561
|
+
C.targetColumnObj && w(C.targetColumnObj);
|
|
5551
5562
|
if (e.downstreamJoinKeys)
|
|
5552
5563
|
for (const C of e.downstreamJoinKeys)
|
|
5553
5564
|
for (const T of C.joinKeys)
|
|
5554
|
-
T.sourceColumnObj &&
|
|
5565
|
+
T.sourceColumnObj && w(T.sourceColumnObj);
|
|
5555
5566
|
if (t.dimensions)
|
|
5556
5567
|
for (const C of t.dimensions) {
|
|
5557
5568
|
const [T, E] = C.split(".");
|
|
5558
5569
|
if (T === l && r.dimensions && r.dimensions[E]) {
|
|
5559
|
-
const N = r.dimensions[E], S =
|
|
5560
|
-
|
|
5570
|
+
const N = r.dimensions[E], S = R(N.sql, n);
|
|
5571
|
+
$.push(S);
|
|
5561
5572
|
}
|
|
5562
5573
|
}
|
|
5563
5574
|
if (t.timeDimensions)
|
|
@@ -5565,10 +5576,10 @@ class on {
|
|
|
5565
5576
|
const [T, E] = C.dimension.split(".");
|
|
5566
5577
|
if (T === l && r.dimensions && r.dimensions[E]) {
|
|
5567
5578
|
const N = r.dimensions[E], S = this.queryBuilder.buildTimeDimensionExpression(N.sql, C.granularity, n);
|
|
5568
|
-
|
|
5579
|
+
$.push(S);
|
|
5569
5580
|
}
|
|
5570
5581
|
}
|
|
5571
|
-
return
|
|
5582
|
+
return $.length > 0 && (f = f.groupBy(...$)), n.db.$with(e.cteAlias).as(f);
|
|
5572
5583
|
}
|
|
5573
5584
|
/**
|
|
5574
5585
|
* Build join condition for CTE
|
|
@@ -5594,7 +5605,7 @@ class on {
|
|
|
5594
5605
|
const a = r.sourceColumnObj || o.identifier(r.sourceColumn), u = o`${o.identifier(t)}.${o.identifier(r.targetColumn)}`;
|
|
5595
5606
|
i.push(Q(a, u));
|
|
5596
5607
|
}
|
|
5597
|
-
return i.length === 1 ? i[0] :
|
|
5608
|
+
return i.length === 1 ? i[0] : A(...i);
|
|
5598
5609
|
}
|
|
5599
5610
|
/**
|
|
5600
5611
|
* Build a subquery filter for propagating filters from related cubes.
|
|
@@ -5623,12 +5634,12 @@ class on {
|
|
|
5623
5634
|
}
|
|
5624
5635
|
if (i.length === 0)
|
|
5625
5636
|
return null;
|
|
5626
|
-
const r = i.length === 1 ? i[0] :
|
|
5637
|
+
const r = i.length === 1 ? i[0] : A(...i), a = e.joinConditions;
|
|
5627
5638
|
if (a.length === 1) {
|
|
5628
5639
|
const { source: u, target: c } = a[0], l = t.db.select({ pk: u }).from(s.from).where(r);
|
|
5629
5640
|
return o`${c} IN ${l}`;
|
|
5630
5641
|
} else {
|
|
5631
|
-
const u = a.map((m) => Q(m.source, m.target)), c =
|
|
5642
|
+
const u = a.map((m) => Q(m.source, m.target)), c = A(
|
|
5632
5643
|
...u,
|
|
5633
5644
|
r
|
|
5634
5645
|
), l = t.db.select({ one: o`1` }).from(s.from).where(c);
|
|
@@ -5636,15 +5647,15 @@ class on {
|
|
|
5636
5647
|
}
|
|
5637
5648
|
}
|
|
5638
5649
|
}
|
|
5639
|
-
function
|
|
5650
|
+
function dn(d, e, t) {
|
|
5640
5651
|
const n = [];
|
|
5641
|
-
let s =
|
|
5642
|
-
const i =
|
|
5652
|
+
let s = Je(new Date(d), t);
|
|
5653
|
+
const i = Je(new Date(e), t), r = 1e4;
|
|
5643
5654
|
for (; s <= i && n.length < r; )
|
|
5644
|
-
n.push(new Date(s)), s =
|
|
5655
|
+
n.push(new Date(s)), s = mn(s, t);
|
|
5645
5656
|
return n;
|
|
5646
5657
|
}
|
|
5647
|
-
function
|
|
5658
|
+
function Je(d, e) {
|
|
5648
5659
|
const t = new Date(d);
|
|
5649
5660
|
switch (e) {
|
|
5650
5661
|
case "second":
|
|
@@ -5678,7 +5689,7 @@ function qe(d, e) {
|
|
|
5678
5689
|
}
|
|
5679
5690
|
return t;
|
|
5680
5691
|
}
|
|
5681
|
-
function
|
|
5692
|
+
function mn(d, e) {
|
|
5682
5693
|
const t = new Date(d);
|
|
5683
5694
|
switch (e) {
|
|
5684
5695
|
case "second":
|
|
@@ -5708,7 +5719,7 @@ function un(d, e) {
|
|
|
5708
5719
|
}
|
|
5709
5720
|
return t;
|
|
5710
5721
|
}
|
|
5711
|
-
function
|
|
5722
|
+
function fn(d) {
|
|
5712
5723
|
if (d instanceof Date)
|
|
5713
5724
|
return d.toISOString();
|
|
5714
5725
|
if (typeof d == "string") {
|
|
@@ -5718,16 +5729,16 @@ function ln(d) {
|
|
|
5718
5729
|
}
|
|
5719
5730
|
return String(d);
|
|
5720
5731
|
}
|
|
5721
|
-
function
|
|
5732
|
+
function pn(d, e) {
|
|
5722
5733
|
return e.length === 0 ? "__all__" : e.map((t) => String(d[t] ?? "")).join("|||");
|
|
5723
5734
|
}
|
|
5724
|
-
function
|
|
5725
|
-
const { timeDimensionKey: t, granularity: n, dateRange: s, fillValue: i, measures: r, dimensions: a } = e, u =
|
|
5735
|
+
function hn(d, e) {
|
|
5736
|
+
const { timeDimensionKey: t, granularity: n, dateRange: s, fillValue: i, measures: r, dimensions: a } = e, u = dn(s[0], s[1], n);
|
|
5726
5737
|
if (u.length === 0)
|
|
5727
5738
|
return d;
|
|
5728
5739
|
const c = /* @__PURE__ */ new Map();
|
|
5729
5740
|
for (const m of d) {
|
|
5730
|
-
const p =
|
|
5741
|
+
const p = pn(m, a), f = fn(m[t]);
|
|
5731
5742
|
c.has(p) || c.set(p, /* @__PURE__ */ new Map()), c.get(p).set(f, m);
|
|
5732
5743
|
}
|
|
5733
5744
|
c.size === 0 && a.length === 0 && c.set("__all__", /* @__PURE__ */ new Map());
|
|
@@ -5743,17 +5754,17 @@ function dn(d, e) {
|
|
|
5743
5754
|
[t]: g
|
|
5744
5755
|
};
|
|
5745
5756
|
if (f)
|
|
5746
|
-
for (const
|
|
5747
|
-
b[
|
|
5748
|
-
for (const
|
|
5749
|
-
b[
|
|
5757
|
+
for (const $ of a)
|
|
5758
|
+
b[$] = f[$];
|
|
5759
|
+
for (const $ of r)
|
|
5760
|
+
b[$] = i;
|
|
5750
5761
|
l.push(b);
|
|
5751
5762
|
}
|
|
5752
5763
|
}
|
|
5753
5764
|
}
|
|
5754
5765
|
return l;
|
|
5755
5766
|
}
|
|
5756
|
-
function
|
|
5767
|
+
function gn(d) {
|
|
5757
5768
|
if (!d)
|
|
5758
5769
|
return null;
|
|
5759
5770
|
if (Array.isArray(d)) {
|
|
@@ -5765,7 +5776,7 @@ function mn(d) {
|
|
|
5765
5776
|
const e = new Date(d);
|
|
5766
5777
|
return isNaN(e.getTime()) ? null : [e, e];
|
|
5767
5778
|
}
|
|
5768
|
-
function
|
|
5779
|
+
function Ge(d, e, t) {
|
|
5769
5780
|
if (!e.timeDimensions || e.timeDimensions.length === 0)
|
|
5770
5781
|
return d;
|
|
5771
5782
|
const n = e.timeDimensions.filter((u) => {
|
|
@@ -5777,7 +5788,7 @@ function ze(d, e, t) {
|
|
|
5777
5788
|
const s = e.fillMissingDatesValue === void 0 ? 0 : e.fillMissingDatesValue, i = new Set(e.timeDimensions.map((u) => u.dimension)), r = (e.dimensions || []).filter((u) => !i.has(u));
|
|
5778
5789
|
let a = d;
|
|
5779
5790
|
for (const u of n) {
|
|
5780
|
-
const c =
|
|
5791
|
+
const c = gn(u.dateRange);
|
|
5781
5792
|
if (!c)
|
|
5782
5793
|
continue;
|
|
5783
5794
|
const l = {
|
|
@@ -5788,14 +5799,14 @@ function ze(d, e, t) {
|
|
|
5788
5799
|
measures: t,
|
|
5789
5800
|
dimensions: r
|
|
5790
5801
|
};
|
|
5791
|
-
a =
|
|
5802
|
+
a = hn(a, l);
|
|
5792
5803
|
}
|
|
5793
5804
|
return a;
|
|
5794
5805
|
}
|
|
5795
|
-
class
|
|
5806
|
+
class bn {
|
|
5796
5807
|
dateTimeBuilder;
|
|
5797
5808
|
constructor(e) {
|
|
5798
|
-
this.dateTimeBuilder = new
|
|
5809
|
+
this.dateTimeBuilder = new ie(e);
|
|
5799
5810
|
}
|
|
5800
5811
|
/**
|
|
5801
5812
|
* Check if a query contains compareDateRange
|
|
@@ -5976,9 +5987,9 @@ class fn {
|
|
|
5976
5987
|
});
|
|
5977
5988
|
}
|
|
5978
5989
|
}
|
|
5979
|
-
class
|
|
5990
|
+
class yn {
|
|
5980
5991
|
constructor(e) {
|
|
5981
|
-
this.databaseAdapter = e, this.dateTimeBuilder = new
|
|
5992
|
+
this.databaseAdapter = e, this.dateTimeBuilder = new ie(e), this.filterBuilder = new ge(e, this.dateTimeBuilder);
|
|
5982
5993
|
}
|
|
5983
5994
|
filterBuilder;
|
|
5984
5995
|
dateTimeBuilder;
|
|
@@ -6025,7 +6036,7 @@ class pn {
|
|
|
6025
6036
|
if (i.name || n.push(`Step ${s} must have a name`), "cube" in i && i.cube && (t.get(i.cube) || n.push(`Step ${s} cube not found: ${i.cube}`)), i.filter) {
|
|
6026
6037
|
let r;
|
|
6027
6038
|
"cube" in i && i.cube ? r = i.cube : typeof e.bindingKey == "string" && ([r] = e.bindingKey.split("."));
|
|
6028
|
-
const a = r ? new
|
|
6039
|
+
const a = r ? new ae(t) : null, u = Array.isArray(i.filter) ? i.filter : [i.filter];
|
|
6029
6040
|
for (const c of u)
|
|
6030
6041
|
if ("member" in c) {
|
|
6031
6042
|
const [l, m] = c.member.split("."), p = t.get(l);
|
|
@@ -6113,7 +6124,7 @@ class pn {
|
|
|
6113
6124
|
* Resolve steps with their cube, SQL expressions, and filter conditions
|
|
6114
6125
|
*/
|
|
6115
6126
|
resolveSteps(e, t, n) {
|
|
6116
|
-
const s = new
|
|
6127
|
+
const s = new ae(t);
|
|
6117
6128
|
return e.steps.map((i, r) => {
|
|
6118
6129
|
const a = this.resolveCubeForStep(i, e, t), u = this.resolveBindingKey(e, a, n), c = this.resolveTimeDimension(e, a, n), l = this.buildStepFilters(i, a, t, n), m = this.extractFilterCubeNames(i), p = [];
|
|
6119
6130
|
for (const f of m)
|
|
@@ -6162,7 +6173,7 @@ class pn {
|
|
|
6162
6173
|
const [, a] = e.bindingKey.split("."), u = t.dimensions?.[a];
|
|
6163
6174
|
if (!u)
|
|
6164
6175
|
throw new Error(`Binding key dimension not found: ${e.bindingKey}`);
|
|
6165
|
-
return
|
|
6176
|
+
return R(u.sql, n);
|
|
6166
6177
|
}
|
|
6167
6178
|
const s = e.bindingKey.find((a) => a.cube === t.name);
|
|
6168
6179
|
if (!s)
|
|
@@ -6170,7 +6181,7 @@ class pn {
|
|
|
6170
6181
|
const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
|
|
6171
6182
|
if (!r)
|
|
6172
6183
|
throw new Error(`Binding key dimension not found: ${s.dimension}`);
|
|
6173
|
-
return
|
|
6184
|
+
return R(r.sql, n);
|
|
6174
6185
|
}
|
|
6175
6186
|
/**
|
|
6176
6187
|
* Resolve time dimension expression for a cube
|
|
@@ -6180,7 +6191,7 @@ class pn {
|
|
|
6180
6191
|
const [, a] = e.timeDimension.split("."), u = t.dimensions?.[a];
|
|
6181
6192
|
if (!u)
|
|
6182
6193
|
throw new Error(`Time dimension not found: ${e.timeDimension}`);
|
|
6183
|
-
return
|
|
6194
|
+
return R(u.sql, n);
|
|
6184
6195
|
}
|
|
6185
6196
|
const s = e.timeDimension.find((a) => a.cube === t.name);
|
|
6186
6197
|
if (!s)
|
|
@@ -6188,7 +6199,7 @@ class pn {
|
|
|
6188
6199
|
const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
|
|
6189
6200
|
if (!r)
|
|
6190
6201
|
throw new Error(`Time dimension not found: ${s.dimension}`);
|
|
6191
|
-
return
|
|
6202
|
+
return R(r.sql, n);
|
|
6192
6203
|
}
|
|
6193
6204
|
/**
|
|
6194
6205
|
* Build filter conditions for a step
|
|
@@ -6222,20 +6233,20 @@ class pn {
|
|
|
6222
6233
|
if (r) {
|
|
6223
6234
|
const b = e;
|
|
6224
6235
|
y = b.type === "and";
|
|
6225
|
-
for (const
|
|
6226
|
-
const
|
|
6227
|
-
|
|
6236
|
+
for (const $ of b.filters || []) {
|
|
6237
|
+
const D = this.buildFilterCondition($, t, n, s);
|
|
6238
|
+
D && g.push(D);
|
|
6228
6239
|
}
|
|
6229
6240
|
} else {
|
|
6230
6241
|
const b = e;
|
|
6231
6242
|
y = "and" in b && !!b.and;
|
|
6232
|
-
const
|
|
6233
|
-
for (const
|
|
6234
|
-
const
|
|
6235
|
-
|
|
6243
|
+
const $ = b.and || b.or || [];
|
|
6244
|
+
for (const D of $) {
|
|
6245
|
+
const w = this.buildFilterCondition(D, t, n, s);
|
|
6246
|
+
w && g.push(w);
|
|
6236
6247
|
}
|
|
6237
6248
|
}
|
|
6238
|
-
return g.length === 0 ? null : g.length === 1 ? g[0] : y ?
|
|
6249
|
+
return g.length === 0 ? null : g.length === 1 ? g[0] : y ? A(...g) : o`(${o.join(g, o` OR `)})`;
|
|
6239
6250
|
}
|
|
6240
6251
|
const a = e, [u, c] = a.member.split("."), l = a.dateRange !== void 0;
|
|
6241
6252
|
if (a.operator !== "set" && a.operator !== "notSet" && !l && (!a.values || a.values.length === 0 || a.values[0] === void 0 || a.values[0] === ""))
|
|
@@ -6244,7 +6255,7 @@ class pn {
|
|
|
6244
6255
|
if (!p)
|
|
6245
6256
|
return null;
|
|
6246
6257
|
if (u !== t.name) {
|
|
6247
|
-
const y = new
|
|
6258
|
+
const y = new ae(n).findPath(t.name, u);
|
|
6248
6259
|
if (!y || y.length === 0)
|
|
6249
6260
|
return console.warn(
|
|
6250
6261
|
`Funnel filter: Cannot filter by '${u}.${c}' in step using '${t.name}'. No join path found. Filter will be skipped.`
|
|
@@ -6252,7 +6263,7 @@ class pn {
|
|
|
6252
6263
|
}
|
|
6253
6264
|
const f = p.dimensions?.[c];
|
|
6254
6265
|
if (!f) return null;
|
|
6255
|
-
const h =
|
|
6266
|
+
const h = R(f.sql, s);
|
|
6256
6267
|
return this.filterBuilder.buildFilterCondition(
|
|
6257
6268
|
h,
|
|
6258
6269
|
a.operator,
|
|
@@ -6291,7 +6302,7 @@ class pn {
|
|
|
6291
6302
|
step_time: o`MIN(${e.timeExpr})`.as("step_time")
|
|
6292
6303
|
}).from(s.from);
|
|
6293
6304
|
if (r = this.addCrossJoinsToQuery(r, e, t, i), i.length > 0) {
|
|
6294
|
-
const a = i.length === 1 ? i[0] :
|
|
6305
|
+
const a = i.length === 1 ? i[0] : A(...i);
|
|
6295
6306
|
r = r.where(a);
|
|
6296
6307
|
}
|
|
6297
6308
|
return r = r.groupBy(e.bindingKeyExpr), t.db.$with(n).as(r);
|
|
@@ -6324,7 +6335,7 @@ class pn {
|
|
|
6324
6335
|
o`${e.bindingKeyExpr} = ${o.identifier(i)}.binding_key`
|
|
6325
6336
|
);
|
|
6326
6337
|
if (l = this.addCrossJoinsToQuery(l, e, t, a), a.length > 0) {
|
|
6327
|
-
const m = a.length === 1 ? a[0] :
|
|
6338
|
+
const m = a.length === 1 ? a[0] : A(...a);
|
|
6328
6339
|
l = l.where(m);
|
|
6329
6340
|
}
|
|
6330
6341
|
return l = l.groupBy(e.bindingKeyExpr), t.db.$with(s).as(l);
|
|
@@ -6341,7 +6352,7 @@ class pn {
|
|
|
6341
6352
|
const a = r.joinDef, u = [];
|
|
6342
6353
|
for (const p of a.on)
|
|
6343
6354
|
p.as ? u.push(p.as(p.source, p.target)) : u.push(Q(p.source, p.target));
|
|
6344
|
-
const c = u.length === 1 ? u[0] :
|
|
6355
|
+
const c = u.length === 1 ? u[0] : A(...u), m = i.cube.sql(n);
|
|
6345
6356
|
e = e.leftJoin(m.from, c), m.where && s.push(m.where);
|
|
6346
6357
|
}
|
|
6347
6358
|
return e;
|
|
@@ -6414,12 +6425,12 @@ class pn {
|
|
|
6414
6425
|
return i.db.$with("funnel_metrics").as(a);
|
|
6415
6426
|
}
|
|
6416
6427
|
}
|
|
6417
|
-
class
|
|
6428
|
+
class Cn {
|
|
6418
6429
|
filterBuilder;
|
|
6419
6430
|
dateTimeBuilder;
|
|
6420
6431
|
databaseAdapter;
|
|
6421
6432
|
constructor(e) {
|
|
6422
|
-
this.databaseAdapter = e, this.dateTimeBuilder = new
|
|
6433
|
+
this.databaseAdapter = e, this.dateTimeBuilder = new ie(e), this.filterBuilder = new ge(e, this.dateTimeBuilder);
|
|
6423
6434
|
}
|
|
6424
6435
|
/**
|
|
6425
6436
|
* Check if query contains flow configuration
|
|
@@ -6590,7 +6601,7 @@ class hn {
|
|
|
6590
6601
|
const [, a] = e.bindingKey.split("."), u = t.dimensions?.[a];
|
|
6591
6602
|
if (!u)
|
|
6592
6603
|
throw new Error(`Binding key dimension not found: ${e.bindingKey}`);
|
|
6593
|
-
return
|
|
6604
|
+
return R(u.sql, n);
|
|
6594
6605
|
}
|
|
6595
6606
|
const s = e.bindingKey.find((a) => a.cube === t.name);
|
|
6596
6607
|
if (!s)
|
|
@@ -6598,7 +6609,7 @@ class hn {
|
|
|
6598
6609
|
const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
|
|
6599
6610
|
if (!r)
|
|
6600
6611
|
throw new Error(`Binding key dimension not found: ${s.dimension}`);
|
|
6601
|
-
return
|
|
6612
|
+
return R(r.sql, n);
|
|
6602
6613
|
}
|
|
6603
6614
|
/**
|
|
6604
6615
|
* Resolve time dimension expression
|
|
@@ -6608,7 +6619,7 @@ class hn {
|
|
|
6608
6619
|
const [, a] = e.timeDimension.split("."), u = t.dimensions?.[a];
|
|
6609
6620
|
if (!u)
|
|
6610
6621
|
throw new Error(`Time dimension not found: ${e.timeDimension}`);
|
|
6611
|
-
return
|
|
6622
|
+
return R(u.sql, n);
|
|
6612
6623
|
}
|
|
6613
6624
|
const s = e.timeDimension.find((a) => a.cube === t.name);
|
|
6614
6625
|
if (!s)
|
|
@@ -6616,7 +6627,7 @@ class hn {
|
|
|
6616
6627
|
const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
|
|
6617
6628
|
if (!r)
|
|
6618
6629
|
throw new Error(`Time dimension not found: ${s.dimension}`);
|
|
6619
|
-
return
|
|
6630
|
+
return R(r.sql, n);
|
|
6620
6631
|
}
|
|
6621
6632
|
/**
|
|
6622
6633
|
* Resolve event dimension expression
|
|
@@ -6625,7 +6636,7 @@ class hn {
|
|
|
6625
6636
|
const [, s] = e.eventDimension.split("."), i = t.dimensions?.[s];
|
|
6626
6637
|
if (!i)
|
|
6627
6638
|
throw new Error(`Event dimension not found: ${e.eventDimension}`);
|
|
6628
|
-
return
|
|
6639
|
+
return R(i.sql, n);
|
|
6629
6640
|
}
|
|
6630
6641
|
/**
|
|
6631
6642
|
* Build filter conditions for the starting step
|
|
@@ -6650,7 +6661,7 @@ class hn {
|
|
|
6650
6661
|
const p = this.buildFilterCondition(m, t, n);
|
|
6651
6662
|
p && c.push(p);
|
|
6652
6663
|
}
|
|
6653
|
-
return c.length === 0 ? null : c.length === 1 ? c[0] : "and" in e ?
|
|
6664
|
+
return c.length === 0 ? null : c.length === 1 ? c[0] : "and" in e ? A(...c) : o`(${o.join(c, o` OR `)})`;
|
|
6654
6665
|
}
|
|
6655
6666
|
if ("type" in e && "filters" in e) {
|
|
6656
6667
|
const u = e, c = [];
|
|
@@ -6658,11 +6669,11 @@ class hn {
|
|
|
6658
6669
|
const m = this.buildFilterCondition(l, t, n);
|
|
6659
6670
|
m && c.push(m);
|
|
6660
6671
|
}
|
|
6661
|
-
return c.length === 0 ? null : c.length === 1 ? c[0] : u.type === "and" ?
|
|
6672
|
+
return c.length === 0 ? null : c.length === 1 ? c[0] : u.type === "and" ? A(...c) : o`(${o.join(c, o` OR `)})`;
|
|
6662
6673
|
}
|
|
6663
6674
|
const s = e, [, i] = s.member.split("."), r = t.dimensions?.[i];
|
|
6664
6675
|
if (!r) return null;
|
|
6665
|
-
const a =
|
|
6676
|
+
const a = R(r.sql, n);
|
|
6666
6677
|
return this.filterBuilder.buildFilterCondition(
|
|
6667
6678
|
a,
|
|
6668
6679
|
s.operator,
|
|
@@ -6690,7 +6701,7 @@ class hn {
|
|
|
6690
6701
|
event_path: o`${a}`.as("event_path")
|
|
6691
6702
|
}).from(s.from);
|
|
6692
6703
|
if (c.length > 0) {
|
|
6693
|
-
const m = c.length === 1 ? c[0] :
|
|
6704
|
+
const m = c.length === 1 ? c[0] : A(...c);
|
|
6694
6705
|
l = l.where(m);
|
|
6695
6706
|
}
|
|
6696
6707
|
return l = l.groupBy(i, a), e.entityLimit && (l = l.limit(e.entityLimit)), n.db.$with("starting_entities").as(l);
|
|
@@ -6707,12 +6718,12 @@ class hn {
|
|
|
6707
6718
|
o`${i} = ${o.identifier(m)}.binding_key`,
|
|
6708
6719
|
o`${r} < ${o.identifier(m)}.${o.identifier(p)}`
|
|
6709
6720
|
);
|
|
6710
|
-
const g = h.length === 1 ? h[0] :
|
|
6721
|
+
const g = h.length === 1 ? h[0] : A(...h), y = c ? o`${a} || ${"→"} || ${o.identifier(m)}.event_path` : o`${a}`, b = n.db.select({
|
|
6711
6722
|
binding_key: o`${i}`.as("binding_key"),
|
|
6712
6723
|
step_time: o`${r}`.as("step_time"),
|
|
6713
6724
|
event_type: o`${a}`.as("event_type"),
|
|
6714
6725
|
event_path: y.as("event_path")
|
|
6715
|
-
}).from(s.from).where(g).orderBy(o`${r} DESC`).limit(1),
|
|
6726
|
+
}).from(s.from).where(g).orderBy(o`${r} DESC`).limit(1), $ = n.db.$with(f).as(
|
|
6716
6727
|
n.db.select({
|
|
6717
6728
|
binding_key: o`e.binding_key`.as("binding_key"),
|
|
6718
6729
|
step_time: o`e.step_time`.as("step_time"),
|
|
@@ -6720,7 +6731,7 @@ class hn {
|
|
|
6720
6731
|
event_path: o`e.event_path`.as("event_path")
|
|
6721
6732
|
}).from(o`${o.identifier(m)}`).crossJoinLateral(b.as("e"))
|
|
6722
6733
|
);
|
|
6723
|
-
u.push(
|
|
6734
|
+
u.push($);
|
|
6724
6735
|
}
|
|
6725
6736
|
return u;
|
|
6726
6737
|
}
|
|
@@ -6736,12 +6747,12 @@ class hn {
|
|
|
6736
6747
|
o`${i} = ${o.identifier(m)}.binding_key`,
|
|
6737
6748
|
o`${r} > ${o.identifier(m)}.${o.identifier(p)}`
|
|
6738
6749
|
);
|
|
6739
|
-
const g = h.length === 1 ? h[0] :
|
|
6750
|
+
const g = h.length === 1 ? h[0] : A(...h), y = c ? o`${o.identifier(m)}.event_path || ${"→"} || ${a}` : o`${a}`, b = n.db.select({
|
|
6740
6751
|
binding_key: o`${i}`.as("binding_key"),
|
|
6741
6752
|
step_time: o`${r}`.as("step_time"),
|
|
6742
6753
|
event_type: o`${a}`.as("event_type"),
|
|
6743
6754
|
event_path: y.as("event_path")
|
|
6744
|
-
}).from(s.from).where(g).orderBy(o`${r} ASC`).limit(1),
|
|
6755
|
+
}).from(s.from).where(g).orderBy(o`${r} ASC`).limit(1), $ = n.db.$with(f).as(
|
|
6745
6756
|
n.db.select({
|
|
6746
6757
|
binding_key: o`e.binding_key`.as("binding_key"),
|
|
6747
6758
|
step_time: o`e.step_time`.as("step_time"),
|
|
@@ -6749,7 +6760,7 @@ class hn {
|
|
|
6749
6760
|
event_path: o`e.event_path`.as("event_path")
|
|
6750
6761
|
}).from(o`${o.identifier(m)}`).crossJoinLateral(b.as("e"))
|
|
6751
6762
|
);
|
|
6752
|
-
u.push(
|
|
6763
|
+
u.push($);
|
|
6753
6764
|
}
|
|
6754
6765
|
return u;
|
|
6755
6766
|
}
|
|
@@ -6767,7 +6778,7 @@ class hn {
|
|
|
6767
6778
|
s.where && h.push(s.where), h.push(
|
|
6768
6779
|
o`${r} < ${o.identifier(m)}.${o.identifier(p)}`
|
|
6769
6780
|
);
|
|
6770
|
-
const g = h.length === 1 ? h[0] :
|
|
6781
|
+
const g = h.length === 1 ? h[0] : A(...h), y = c ? o`${a} || ${"→"} || ${o.identifier(m)}.event_path` : o`${a}`, b = n.db.select({
|
|
6771
6782
|
binding_key: o`${i}`.as("binding_key"),
|
|
6772
6783
|
step_time: o`${r}`.as("step_time"),
|
|
6773
6784
|
event_type: o`${a}`.as("event_type"),
|
|
@@ -6776,13 +6787,13 @@ class hn {
|
|
|
6776
6787
|
}).from(s.from).innerJoin(
|
|
6777
6788
|
o`${o.identifier(m)}`,
|
|
6778
6789
|
o`${i} = ${o.identifier(m)}.binding_key`
|
|
6779
|
-
).where(g),
|
|
6790
|
+
).where(g), $ = n.db.select({
|
|
6780
6791
|
binding_key: o`binding_key`.as("binding_key"),
|
|
6781
6792
|
step_time: o`step_time`.as("step_time"),
|
|
6782
6793
|
event_type: o`event_type`.as("event_type"),
|
|
6783
6794
|
event_path: o`event_path`.as("event_path")
|
|
6784
6795
|
}).from(b.as("ranked")).where(o`rn = 1`);
|
|
6785
|
-
u.push(n.db.$with(f).as(
|
|
6796
|
+
u.push(n.db.$with(f).as($));
|
|
6786
6797
|
}
|
|
6787
6798
|
return u;
|
|
6788
6799
|
}
|
|
@@ -6800,7 +6811,7 @@ class hn {
|
|
|
6800
6811
|
s.where && h.push(s.where), h.push(
|
|
6801
6812
|
o`${r} > ${o.identifier(m)}.${o.identifier(p)}`
|
|
6802
6813
|
);
|
|
6803
|
-
const g = h.length === 1 ? h[0] :
|
|
6814
|
+
const g = h.length === 1 ? h[0] : A(...h), y = c ? o`${o.identifier(m)}.event_path || ${"→"} || ${a}` : o`${a}`, b = n.db.select({
|
|
6804
6815
|
binding_key: o`${i}`.as("binding_key"),
|
|
6805
6816
|
step_time: o`${r}`.as("step_time"),
|
|
6806
6817
|
event_type: o`${a}`.as("event_type"),
|
|
@@ -6809,13 +6820,13 @@ class hn {
|
|
|
6809
6820
|
}).from(s.from).innerJoin(
|
|
6810
6821
|
o`${o.identifier(m)}`,
|
|
6811
6822
|
o`${i} = ${o.identifier(m)}.binding_key`
|
|
6812
|
-
).where(g),
|
|
6823
|
+
).where(g), $ = n.db.select({
|
|
6813
6824
|
binding_key: o`binding_key`.as("binding_key"),
|
|
6814
6825
|
step_time: o`step_time`.as("step_time"),
|
|
6815
6826
|
event_type: o`event_type`.as("event_type"),
|
|
6816
6827
|
event_path: o`event_path`.as("event_path")
|
|
6817
6828
|
}).from(b.as("ranked")).where(o`rn = 1`);
|
|
6818
|
-
u.push(n.db.$with(f).as(
|
|
6829
|
+
u.push(n.db.$with(f).as($));
|
|
6819
6830
|
}
|
|
6820
6831
|
return u;
|
|
6821
6832
|
}
|
|
@@ -7016,31 +7027,31 @@ class hn {
|
|
|
7016
7027
|
return e.db.$with("final_result").as(n);
|
|
7017
7028
|
}
|
|
7018
7029
|
}
|
|
7019
|
-
function
|
|
7030
|
+
function He(d) {
|
|
7020
7031
|
return Array.isArray(d);
|
|
7021
7032
|
}
|
|
7022
|
-
function
|
|
7033
|
+
function dt(d) {
|
|
7023
7034
|
return typeof d == "object" && d !== null && "cube" in d;
|
|
7024
7035
|
}
|
|
7025
|
-
function
|
|
7026
|
-
if (
|
|
7036
|
+
function Ye(d) {
|
|
7037
|
+
if (dt(d))
|
|
7027
7038
|
return d.cube;
|
|
7028
7039
|
const e = d.indexOf(".");
|
|
7029
7040
|
if (e === -1)
|
|
7030
7041
|
throw new Error(`Invalid time dimension format: ${d}. Expected 'CubeName.dimensionName'`);
|
|
7031
7042
|
return d.substring(0, e);
|
|
7032
7043
|
}
|
|
7033
|
-
function
|
|
7034
|
-
if (
|
|
7044
|
+
function Xe(d) {
|
|
7045
|
+
if (dt(d))
|
|
7035
7046
|
return d.dimension;
|
|
7036
7047
|
const e = d.indexOf(".");
|
|
7037
7048
|
if (e === -1)
|
|
7038
7049
|
throw new Error(`Invalid time dimension format: ${d}. Expected 'CubeName.dimensionName'`);
|
|
7039
7050
|
return d.substring(e + 1);
|
|
7040
7051
|
}
|
|
7041
|
-
class
|
|
7052
|
+
class wn {
|
|
7042
7053
|
constructor(e) {
|
|
7043
|
-
this.databaseAdapter = e, this.dateTimeBuilder = new
|
|
7054
|
+
this.databaseAdapter = e, this.dateTimeBuilder = new ie(e), this.filterBuilder = new ge(e, this.dateTimeBuilder);
|
|
7044
7055
|
}
|
|
7045
7056
|
filterBuilder;
|
|
7046
7057
|
dateTimeBuilder;
|
|
@@ -7056,12 +7067,12 @@ class gn {
|
|
|
7056
7067
|
validateConfig(e, t) {
|
|
7057
7068
|
const n = [];
|
|
7058
7069
|
try {
|
|
7059
|
-
const r =
|
|
7070
|
+
const r = Ye(e.timeDimension), a = Xe(e.timeDimension), u = t.get(r);
|
|
7060
7071
|
u ? u.dimensions?.[a] || n.push(`Time dimension not found: ${a} in cube ${r}`) : n.push(`Cube not found: ${r}`);
|
|
7061
7072
|
} catch {
|
|
7062
7073
|
n.push(`Invalid time dimension format: ${e.timeDimension}`);
|
|
7063
7074
|
}
|
|
7064
|
-
if (
|
|
7075
|
+
if (He(e.bindingKey))
|
|
7065
7076
|
for (const r of e.bindingKey) {
|
|
7066
7077
|
const a = t.get(r.cube);
|
|
7067
7078
|
if (!a)
|
|
@@ -7173,18 +7184,18 @@ class gn {
|
|
|
7173
7184
|
* Same cube/dimension used for both cohort entry and activity detection
|
|
7174
7185
|
*/
|
|
7175
7186
|
resolveConfig(e, t, n) {
|
|
7176
|
-
const s =
|
|
7187
|
+
const s = Ye(e.timeDimension), i = Xe(e.timeDimension), r = t.get(s);
|
|
7177
7188
|
if (!r)
|
|
7178
7189
|
throw new Error(`Cube not found: ${s}`);
|
|
7179
7190
|
const a = r.dimensions?.[i];
|
|
7180
7191
|
if (!a)
|
|
7181
7192
|
throw new Error(`Time dimension not found: ${i}`);
|
|
7182
|
-
const u =
|
|
7193
|
+
const u = R(a.sql, n), c = this.resolveBindingKey(e.bindingKey, r, t, n), l = this.buildFilterConditions(e.cohortFilters, r, t, n), m = this.buildFilterConditions(e.activityFilters, r, t, n), p = [];
|
|
7183
7194
|
if (e.breakdownDimensions && e.breakdownDimensions.length > 0)
|
|
7184
7195
|
for (const f of e.breakdownDimensions) {
|
|
7185
7196
|
const [h, g] = f.split("."), y = t.get(h);
|
|
7186
7197
|
if (y && y.dimensions?.[g]) {
|
|
7187
|
-
const b =
|
|
7198
|
+
const b = R(y.dimensions[g].sql, n);
|
|
7188
7199
|
p.push({ dimension: f, expr: b });
|
|
7189
7200
|
}
|
|
7190
7201
|
}
|
|
@@ -7194,7 +7205,7 @@ class gn {
|
|
|
7194
7205
|
* Resolve binding key expression for a cube
|
|
7195
7206
|
*/
|
|
7196
7207
|
resolveBindingKey(e, t, n, s) {
|
|
7197
|
-
if (
|
|
7208
|
+
if (He(e)) {
|
|
7198
7209
|
const c = e.find((f) => f.cube === t.name);
|
|
7199
7210
|
if (!c)
|
|
7200
7211
|
throw new Error(`No binding key mapping found for cube: ${t.name}`);
|
|
@@ -7204,7 +7215,7 @@ class gn {
|
|
|
7204
7215
|
const p = m.dimensions?.[l];
|
|
7205
7216
|
if (!p)
|
|
7206
7217
|
throw new Error(`Binding key dimension not found: ${c.dimension}`);
|
|
7207
|
-
return
|
|
7218
|
+
return R(p.sql, s);
|
|
7208
7219
|
}
|
|
7209
7220
|
const [i, r] = e.split("."), a = n.get(i);
|
|
7210
7221
|
if (!a)
|
|
@@ -7212,7 +7223,7 @@ class gn {
|
|
|
7212
7223
|
const u = a.dimensions?.[r];
|
|
7213
7224
|
if (!u)
|
|
7214
7225
|
throw new Error(`Binding key dimension not found: ${e}`);
|
|
7215
|
-
return
|
|
7226
|
+
return R(u.sql, s);
|
|
7216
7227
|
}
|
|
7217
7228
|
/**
|
|
7218
7229
|
* Build filter conditions from config filters
|
|
@@ -7236,13 +7247,13 @@ class gn {
|
|
|
7236
7247
|
const y = this.buildSingleFilterCondition(g, t, n, s);
|
|
7237
7248
|
y && p.push(y);
|
|
7238
7249
|
}
|
|
7239
|
-
return p.length === 0 ? null : p.length === 1 ? p[0] : f ?
|
|
7250
|
+
return p.length === 0 ? null : p.length === 1 ? p[0] : f ? A(...p) : o`(${o.join(p, o` OR `)})`;
|
|
7240
7251
|
}
|
|
7241
7252
|
const i = e, [r, a] = i.member.split("."), u = n.get(r);
|
|
7242
7253
|
if (!u) return null;
|
|
7243
7254
|
const c = u.dimensions?.[a];
|
|
7244
7255
|
if (!c) return null;
|
|
7245
|
-
const l =
|
|
7256
|
+
const l = R(c.sql, s);
|
|
7246
7257
|
return this.filterBuilder.buildFilterCondition(
|
|
7247
7258
|
l,
|
|
7248
7259
|
i.operator,
|
|
@@ -7278,7 +7289,7 @@ class gn {
|
|
|
7278
7289
|
}
|
|
7279
7290
|
let u = n.db.select(a).from(s.from);
|
|
7280
7291
|
if (i.length > 0) {
|
|
7281
|
-
const l = i.length === 1 ? i[0] :
|
|
7292
|
+
const l = i.length === 1 ? i[0] : A(...i);
|
|
7282
7293
|
u = u.where(l);
|
|
7283
7294
|
}
|
|
7284
7295
|
const c = [t.bindingKeyExpr];
|
|
@@ -7333,7 +7344,7 @@ class gn {
|
|
|
7333
7344
|
o`${t.bindingKeyExpr} = cohort_base.binding_key`
|
|
7334
7345
|
);
|
|
7335
7346
|
if (i.length > 0) {
|
|
7336
|
-
const m = i.length === 1 ? i[0] :
|
|
7347
|
+
const m = i.length === 1 ? i[0] : A(...i);
|
|
7337
7348
|
c = c.where(m);
|
|
7338
7349
|
}
|
|
7339
7350
|
const l = [
|
|
@@ -7426,11 +7437,11 @@ class gn {
|
|
|
7426
7437
|
return t.length > 1 ? t[1] : t[0];
|
|
7427
7438
|
}
|
|
7428
7439
|
}
|
|
7429
|
-
class
|
|
7440
|
+
class Y {
|
|
7430
7441
|
constructor(e, t) {
|
|
7431
7442
|
if (this.dbExecutor = e, this.databaseAdapter = e.databaseAdapter, !this.databaseAdapter)
|
|
7432
7443
|
throw new Error("DatabaseExecutor must have a databaseAdapter property");
|
|
7433
|
-
this.queryBuilder = new
|
|
7444
|
+
this.queryBuilder = new ln(this.databaseAdapter), this.queryPlanner = new ct(), this.cteBuilder = new cn(this.queryBuilder), this.comparisonQueryBuilder = new bn(this.databaseAdapter), this.funnelQueryBuilder = new yn(this.databaseAdapter), this.flowQueryBuilder = new Cn(this.databaseAdapter), this.retentionQueryBuilder = new wn(this.databaseAdapter), this.cacheConfig = t;
|
|
7434
7445
|
}
|
|
7435
7446
|
queryBuilder;
|
|
7436
7447
|
queryPlanner;
|
|
@@ -7460,13 +7471,13 @@ class J {
|
|
|
7460
7471
|
if (!b.isValid)
|
|
7461
7472
|
throw new Error(`Retention validation failed: ${b.errors.join(", ")}`);
|
|
7462
7473
|
} else {
|
|
7463
|
-
const b =
|
|
7474
|
+
const b = ft(e, t);
|
|
7464
7475
|
if (!b.isValid)
|
|
7465
7476
|
throw new Error(`Query validation failed: ${b.errors.join(", ")}`);
|
|
7466
7477
|
}
|
|
7467
7478
|
let i;
|
|
7468
7479
|
if (this.cacheConfig?.enabled !== !1 && this.cacheConfig?.provider)
|
|
7469
|
-
if (i =
|
|
7480
|
+
if (i = Zt(t, n, this.cacheConfig), s?.skipCache)
|
|
7470
7481
|
this.cacheConfig.onCacheEvent?.({
|
|
7471
7482
|
type: "miss",
|
|
7472
7483
|
key: i,
|
|
@@ -7474,19 +7485,19 @@ class J {
|
|
|
7474
7485
|
});
|
|
7475
7486
|
else
|
|
7476
7487
|
try {
|
|
7477
|
-
const b = Date.now(),
|
|
7478
|
-
if (
|
|
7488
|
+
const b = Date.now(), $ = await this.cacheConfig.provider.get(i);
|
|
7489
|
+
if ($)
|
|
7479
7490
|
return this.cacheConfig.onCacheEvent?.({
|
|
7480
7491
|
type: "hit",
|
|
7481
7492
|
key: i,
|
|
7482
7493
|
durationMs: Date.now() - b
|
|
7483
7494
|
}), {
|
|
7484
|
-
|
|
7485
|
-
cache:
|
|
7495
|
+
...$.value,
|
|
7496
|
+
cache: $.metadata ? {
|
|
7486
7497
|
hit: !0,
|
|
7487
|
-
cachedAt: new Date(
|
|
7488
|
-
ttlMs:
|
|
7489
|
-
ttlRemainingMs:
|
|
7498
|
+
cachedAt: new Date($.metadata.cachedAt).toISOString(),
|
|
7499
|
+
ttlMs: $.metadata.ttlMs,
|
|
7500
|
+
ttlRemainingMs: $.metadata.ttlRemainingMs
|
|
7490
7501
|
} : {
|
|
7491
7502
|
hit: !0,
|
|
7492
7503
|
cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -7510,7 +7521,7 @@ class J {
|
|
|
7510
7521
|
return this.executeFlowQueryWithCache(e, t, n, i);
|
|
7511
7522
|
if (this.retentionQueryBuilder.hasRetention(t))
|
|
7512
7523
|
return this.executeRetentionQueryWithCache(e, t, n, i);
|
|
7513
|
-
const r = new
|
|
7524
|
+
const r = new ze(), a = {
|
|
7514
7525
|
db: this.dbExecutor.db,
|
|
7515
7526
|
schema: this.dbExecutor.schema,
|
|
7516
7527
|
securityContext: n,
|
|
@@ -7520,20 +7531,20 @@ class J {
|
|
|
7520
7531
|
const u = this.queryPlanner.createQueryPlan(e, t, a);
|
|
7521
7532
|
this.validateSecurityContext(u, a);
|
|
7522
7533
|
const c = this.buildUnifiedQuery(u, t, a), l = this.queryBuilder.collectNumericFields(e, t), m = await this.dbExecutor.execute(c, l), p = Array.isArray(m) ? m.map((b) => {
|
|
7523
|
-
const
|
|
7534
|
+
const $ = { ...b };
|
|
7524
7535
|
if (t.timeDimensions) {
|
|
7525
|
-
for (const
|
|
7526
|
-
if (
|
|
7527
|
-
let
|
|
7528
|
-
if (typeof
|
|
7529
|
-
const C =
|
|
7530
|
-
|
|
7536
|
+
for (const D of t.timeDimensions)
|
|
7537
|
+
if (D.dimension in $) {
|
|
7538
|
+
let w = $[D.dimension];
|
|
7539
|
+
if (typeof w == "string" && w.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
7540
|
+
const C = w.replace(" ", "T"), T = !C.endsWith("Z") && !C.includes("+") ? C + "Z" : C;
|
|
7541
|
+
w = new Date(T);
|
|
7531
7542
|
}
|
|
7532
|
-
|
|
7543
|
+
w = this.databaseAdapter.convertTimeDimensionResult(w), $[D.dimension] = w;
|
|
7533
7544
|
}
|
|
7534
7545
|
}
|
|
7535
|
-
return
|
|
7536
|
-
}) : [m], f = t.measures || [], h =
|
|
7546
|
+
return $;
|
|
7547
|
+
}) : [m], f = t.measures || [], h = Ge(p, t, f), g = this.generateAnnotations(u, t), y = {
|
|
7537
7548
|
data: h,
|
|
7538
7549
|
annotation: g,
|
|
7539
7550
|
// Include warnings from query planning (e.g., fan-out without dimensions)
|
|
@@ -7797,7 +7808,7 @@ class J {
|
|
|
7797
7808
|
* This is the core execution logic extracted for use by comparison queries
|
|
7798
7809
|
*/
|
|
7799
7810
|
async executeStandardQuery(e, t, n) {
|
|
7800
|
-
const s = new
|
|
7811
|
+
const s = new ze(), i = {
|
|
7801
7812
|
db: this.dbExecutor.db,
|
|
7802
7813
|
schema: this.dbExecutor.schema,
|
|
7803
7814
|
securityContext: n,
|
|
@@ -7811,14 +7822,14 @@ class J {
|
|
|
7811
7822
|
if (y.dimension in g) {
|
|
7812
7823
|
let b = g[y.dimension];
|
|
7813
7824
|
if (typeof b == "string" && b.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
7814
|
-
const
|
|
7815
|
-
b = new Date(
|
|
7825
|
+
const $ = b.replace(" ", "T"), D = !$.endsWith("Z") && !$.includes("+") ? $ + "Z" : $;
|
|
7826
|
+
b = new Date(D);
|
|
7816
7827
|
}
|
|
7817
7828
|
b = this.databaseAdapter.convertTimeDimensionResult(b), g[y.dimension] = b;
|
|
7818
7829
|
}
|
|
7819
7830
|
}
|
|
7820
7831
|
return g;
|
|
7821
|
-
}) : [c], m = t.measures || [], p =
|
|
7832
|
+
}) : [c], m = t.measures || [], p = Ge(l, t, m), f = this.generateAnnotations(r, t);
|
|
7822
7833
|
return {
|
|
7823
7834
|
data: p,
|
|
7824
7835
|
annotation: f
|
|
@@ -7859,32 +7870,32 @@ class J {
|
|
|
7859
7870
|
buildUnifiedQuery(e, t, n) {
|
|
7860
7871
|
const s = /* @__PURE__ */ new Map();
|
|
7861
7872
|
if (e.preAggregationCTEs && e.preAggregationCTEs.length > 0) {
|
|
7862
|
-
for (const
|
|
7863
|
-
if (
|
|
7864
|
-
for (const C of
|
|
7873
|
+
for (const w of e.preAggregationCTEs)
|
|
7874
|
+
if (w.propagatingFilters && w.propagatingFilters.length > 0)
|
|
7875
|
+
for (const C of w.propagatingFilters) {
|
|
7865
7876
|
const T = C.sourceCube.name;
|
|
7866
7877
|
if (!s.has(T)) {
|
|
7867
7878
|
const N = {
|
|
7868
7879
|
filters: C.filters
|
|
7869
|
-
}, S = /* @__PURE__ */ new Map([[T, C.sourceCube]]),
|
|
7880
|
+
}, S = /* @__PURE__ */ new Map([[T, C.sourceCube]]), _ = this.queryBuilder.buildWhereConditions(
|
|
7870
7881
|
S,
|
|
7871
7882
|
N,
|
|
7872
7883
|
n
|
|
7873
7884
|
);
|
|
7874
|
-
s.set(T,
|
|
7885
|
+
s.set(T, _);
|
|
7875
7886
|
}
|
|
7876
7887
|
const E = s.get(T);
|
|
7877
|
-
E && E.length > 0 && (C.preBuiltFilterSQL = E.length === 1 ? E[0] :
|
|
7888
|
+
E && E.length > 0 && (C.preBuiltFilterSQL = E.length === 1 ? E[0] : A(...E));
|
|
7878
7889
|
}
|
|
7879
7890
|
}
|
|
7880
7891
|
const i = [], r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
7881
7892
|
if (e.preAggregationCTEs && e.preAggregationCTEs.length > 0)
|
|
7882
|
-
for (const
|
|
7883
|
-
const C = this.cteBuilder.buildPreAggregationCTE(
|
|
7884
|
-
if (C && (i.push(C), r.set(
|
|
7885
|
-
for (const T of
|
|
7893
|
+
for (const w of e.preAggregationCTEs) {
|
|
7894
|
+
const C = this.cteBuilder.buildPreAggregationCTE(w, t, n, e, s);
|
|
7895
|
+
if (C && (i.push(C), r.set(w.cube.name, w.cteAlias), w.downstreamJoinKeys))
|
|
7896
|
+
for (const T of w.downstreamJoinKeys)
|
|
7886
7897
|
a.set(T.targetCubeName, {
|
|
7887
|
-
cteAlias:
|
|
7898
|
+
cteAlias: w.cteAlias,
|
|
7888
7899
|
joinKeys: T.joinKeys
|
|
7889
7900
|
});
|
|
7890
7901
|
}
|
|
@@ -7895,97 +7906,97 @@ class J {
|
|
|
7895
7906
|
n
|
|
7896
7907
|
) };
|
|
7897
7908
|
if (e.preAggregationCTEs)
|
|
7898
|
-
for (const
|
|
7899
|
-
const C =
|
|
7900
|
-
for (const T of
|
|
7909
|
+
for (const w of e.preAggregationCTEs) {
|
|
7910
|
+
const C = w.cube.name;
|
|
7911
|
+
for (const T of w.measures)
|
|
7901
7912
|
if (m[T]) {
|
|
7902
7913
|
const [, E] = T.split("."), N = c.get(C);
|
|
7903
7914
|
if (N && N.measures && N.measures[E]) {
|
|
7904
|
-
const S = N.measures[E],
|
|
7905
|
-
let
|
|
7915
|
+
const S = N.measures[E], _ = o`${o.identifier(w.cteAlias)}.${o.identifier(E)}`;
|
|
7916
|
+
let v;
|
|
7906
7917
|
if (S.type === "calculated" && S.calculatedSql)
|
|
7907
|
-
|
|
7918
|
+
v = this.queryBuilder.buildCTECalculatedMeasure(
|
|
7908
7919
|
S,
|
|
7909
7920
|
N,
|
|
7910
|
-
|
|
7921
|
+
w,
|
|
7911
7922
|
c,
|
|
7912
7923
|
n
|
|
7913
7924
|
);
|
|
7914
7925
|
else {
|
|
7915
|
-
const F =
|
|
7916
|
-
|
|
7926
|
+
const F = w.cteReason === "fanOutPrevention", U = this.shouldUseMaxForHasManyAtJoinKeyGrain(
|
|
7927
|
+
w,
|
|
7917
7928
|
t,
|
|
7918
7929
|
c
|
|
7919
|
-
),
|
|
7930
|
+
), j = F || U;
|
|
7920
7931
|
switch (S.type) {
|
|
7921
7932
|
case "count":
|
|
7922
7933
|
case "countDistinct":
|
|
7923
7934
|
case "sum":
|
|
7924
|
-
|
|
7935
|
+
v = j ? G(_) : z(_);
|
|
7925
7936
|
break;
|
|
7926
7937
|
case "avg":
|
|
7927
|
-
|
|
7938
|
+
v = j ? G(_) : this.databaseAdapter.buildAvg(_);
|
|
7928
7939
|
break;
|
|
7929
7940
|
case "min":
|
|
7930
|
-
|
|
7941
|
+
v = oe(_);
|
|
7931
7942
|
break;
|
|
7932
7943
|
case "max":
|
|
7933
|
-
|
|
7944
|
+
v = G(_);
|
|
7934
7945
|
break;
|
|
7935
7946
|
case "number":
|
|
7936
|
-
|
|
7947
|
+
v = j ? G(_) : z(_);
|
|
7937
7948
|
break;
|
|
7938
7949
|
default:
|
|
7939
|
-
|
|
7950
|
+
v = j ? G(_) : z(_);
|
|
7940
7951
|
}
|
|
7941
7952
|
}
|
|
7942
|
-
m[T] = o`${
|
|
7953
|
+
m[T] = o`${v}`.as(T);
|
|
7943
7954
|
}
|
|
7944
7955
|
}
|
|
7945
7956
|
for (const T in m) {
|
|
7946
7957
|
const [E, N] = T.split(".");
|
|
7947
7958
|
if (E === C) {
|
|
7948
|
-
const S = c.get(C),
|
|
7949
|
-
if (
|
|
7950
|
-
let F =
|
|
7959
|
+
const S = c.get(C), _ = S && S.dimensions?.[N], v = T.startsWith(C + ".");
|
|
7960
|
+
if (_ || v) {
|
|
7961
|
+
let F = w.joinKeys.find((U) => U.targetColumn === N);
|
|
7951
7962
|
if (!F && S?.dimensions?.[N]) {
|
|
7952
|
-
const
|
|
7953
|
-
F =
|
|
7963
|
+
const U = S.dimensions[N].sql;
|
|
7964
|
+
F = w.joinKeys.find((j) => j.targetColumnObj === U);
|
|
7954
7965
|
}
|
|
7955
|
-
F ? m[T] = o`${o.identifier(
|
|
7966
|
+
F ? m[T] = o`${o.identifier(w.cteAlias)}.${o.identifier(N)}`.as(T) : v && S?.dimensions?.[N] && (m[T] = o`${o.identifier(w.cteAlias)}.${o.identifier(N)}`.as(T));
|
|
7956
7967
|
}
|
|
7957
7968
|
}
|
|
7958
7969
|
}
|
|
7959
7970
|
}
|
|
7960
7971
|
if (t.measures)
|
|
7961
|
-
for (const
|
|
7962
|
-
const [C, T] =
|
|
7972
|
+
for (const w of t.measures) {
|
|
7973
|
+
const [C, T] = w.split("."), E = c.get(C);
|
|
7963
7974
|
if (E?.measures?.[T]) {
|
|
7964
7975
|
const N = E.measures[T];
|
|
7965
7976
|
if (I.isPostAggregationWindow(N)) {
|
|
7966
7977
|
const S = I.getWindowBaseMeasure(N, C);
|
|
7967
7978
|
if (S) {
|
|
7968
|
-
const [
|
|
7969
|
-
if (F?.measures?.[
|
|
7970
|
-
const
|
|
7971
|
-
(
|
|
7979
|
+
const [_, v] = S.split("."), F = c.get(_);
|
|
7980
|
+
if (F?.measures?.[v]) {
|
|
7981
|
+
const U = F.measures[v], j = e.preAggregationCTEs?.find(
|
|
7982
|
+
(q) => q.cube?.name === _ && q.measures?.includes(S)
|
|
7972
7983
|
);
|
|
7973
|
-
let
|
|
7974
|
-
if (
|
|
7975
|
-
const
|
|
7976
|
-
|
|
7984
|
+
let B;
|
|
7985
|
+
if (j) {
|
|
7986
|
+
const q = o`${o.identifier(j.cteAlias)}.${o.identifier(v)}`;
|
|
7987
|
+
B = o`sum(${q})`;
|
|
7977
7988
|
} else
|
|
7978
|
-
|
|
7979
|
-
m[S] || (m[S] = o`${
|
|
7980
|
-
const
|
|
7989
|
+
B = this.queryBuilder.buildMeasureExpression(U, n, F);
|
|
7990
|
+
m[S] || (m[S] = o`${B}`.as(S));
|
|
7991
|
+
const V = this.buildPostAggregationWindowExpression(
|
|
7981
7992
|
N,
|
|
7982
|
-
|
|
7993
|
+
B,
|
|
7983
7994
|
t,
|
|
7984
7995
|
n,
|
|
7985
7996
|
E,
|
|
7986
7997
|
e
|
|
7987
7998
|
);
|
|
7988
|
-
|
|
7999
|
+
V && (m[w] = o`${V}`.as(w));
|
|
7989
8000
|
}
|
|
7990
8001
|
}
|
|
7991
8002
|
}
|
|
@@ -7994,99 +8005,117 @@ class J {
|
|
|
7994
8005
|
const p = [];
|
|
7995
8006
|
let f = n.db.select(m).from(u.from);
|
|
7996
8007
|
if (i.length > 0 && (f = n.db.with(...i).select(m).from(u.from)), u.joins)
|
|
7997
|
-
for (const
|
|
7998
|
-
switch (
|
|
8008
|
+
for (const w of u.joins)
|
|
8009
|
+
switch (w.type || "left") {
|
|
7999
8010
|
case "left":
|
|
8000
|
-
f = f.leftJoin(
|
|
8011
|
+
f = f.leftJoin(w.table, w.on);
|
|
8001
8012
|
break;
|
|
8002
8013
|
case "inner":
|
|
8003
|
-
f = f.innerJoin(
|
|
8014
|
+
f = f.innerJoin(w.table, w.on);
|
|
8004
8015
|
break;
|
|
8005
8016
|
case "right":
|
|
8006
|
-
f = f.rightJoin(
|
|
8017
|
+
f = f.rightJoin(w.table, w.on);
|
|
8007
8018
|
break;
|
|
8008
8019
|
case "full":
|
|
8009
|
-
f = f.fullJoin(
|
|
8020
|
+
f = f.fullJoin(w.table, w.on);
|
|
8010
8021
|
break;
|
|
8011
8022
|
}
|
|
8012
8023
|
const h = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set();
|
|
8013
8024
|
if (e.preAggregationCTEs) {
|
|
8014
|
-
for (const
|
|
8015
|
-
if (
|
|
8016
|
-
for (const C of
|
|
8025
|
+
for (const w of e.preAggregationCTEs)
|
|
8026
|
+
if (w.intermediateJoins && w.intermediateJoins.length > 0)
|
|
8027
|
+
for (const C of w.intermediateJoins)
|
|
8017
8028
|
g.add(C.cube.name);
|
|
8018
8029
|
}
|
|
8019
8030
|
if (e.joinCubes && e.joinCubes.length > 0)
|
|
8020
|
-
for (const
|
|
8021
|
-
const C =
|
|
8031
|
+
for (const w of e.joinCubes) {
|
|
8032
|
+
const C = w.cube.name;
|
|
8022
8033
|
if (g.has(C) && !r.has(C))
|
|
8023
8034
|
continue;
|
|
8024
|
-
const T = r.get(
|
|
8025
|
-
if (
|
|
8026
|
-
const F =
|
|
8035
|
+
const T = r.get(w.cube.name);
|
|
8036
|
+
if (w.junctionTable) {
|
|
8037
|
+
const F = w.junctionTable;
|
|
8038
|
+
let U = F.joinCondition;
|
|
8039
|
+
const j = F.sourceCubeName ? r.get(F.sourceCubeName) : void 0;
|
|
8040
|
+
if (j) {
|
|
8041
|
+
const q = e.preAggregationCTEs?.find(
|
|
8042
|
+
(H) => H.cube.name === F.sourceCubeName
|
|
8043
|
+
)?.downstreamJoinKeys?.find(
|
|
8044
|
+
(H) => H.targetCubeName === w.cube.name
|
|
8045
|
+
);
|
|
8046
|
+
if (q && q.joinKeys.length > 0) {
|
|
8047
|
+
const H = [];
|
|
8048
|
+
for (const Oe of q.joinKeys) {
|
|
8049
|
+
const yt = o`${o.identifier(j)}.${o.identifier(Oe.sourceColumn)}`, Ie = Oe.targetColumnObj;
|
|
8050
|
+
Ie && H.push(Q(Ie, yt));
|
|
8051
|
+
}
|
|
8052
|
+
H.length > 0 && (U = A(...H));
|
|
8053
|
+
}
|
|
8054
|
+
}
|
|
8055
|
+
const B = [];
|
|
8027
8056
|
if (F.securitySql) {
|
|
8028
|
-
const
|
|
8029
|
-
Array.isArray(
|
|
8057
|
+
const V = F.securitySql(n.securityContext);
|
|
8058
|
+
Array.isArray(V) ? B.push(...V) : B.push(V);
|
|
8030
8059
|
}
|
|
8031
8060
|
try {
|
|
8032
8061
|
switch (F.joinType || "left") {
|
|
8033
8062
|
case "left":
|
|
8034
|
-
f = f.leftJoin(F.table,
|
|
8063
|
+
f = f.leftJoin(F.table, U);
|
|
8035
8064
|
break;
|
|
8036
8065
|
case "inner":
|
|
8037
|
-
f = f.innerJoin(F.table,
|
|
8066
|
+
f = f.innerJoin(F.table, U);
|
|
8038
8067
|
break;
|
|
8039
8068
|
case "right":
|
|
8040
|
-
f = f.rightJoin(F.table,
|
|
8069
|
+
f = f.rightJoin(F.table, U);
|
|
8041
8070
|
break;
|
|
8042
8071
|
case "full":
|
|
8043
|
-
f = f.fullJoin(F.table,
|
|
8072
|
+
f = f.fullJoin(F.table, U);
|
|
8044
8073
|
break;
|
|
8045
8074
|
}
|
|
8046
|
-
|
|
8075
|
+
B.length > 0 && p.push(...B);
|
|
8047
8076
|
} catch {
|
|
8048
8077
|
}
|
|
8049
8078
|
}
|
|
8050
8079
|
let E, N, S;
|
|
8051
8080
|
if (T)
|
|
8052
|
-
E = o`${o.identifier(T)}`, N = this.cteBuilder.buildCTEJoinCondition(
|
|
8081
|
+
E = o`${o.identifier(T)}`, N = this.cteBuilder.buildCTEJoinCondition(w, T, e), S = void 0;
|
|
8053
8082
|
else {
|
|
8054
|
-
const F = a.get(
|
|
8055
|
-
if (E =
|
|
8056
|
-
const
|
|
8057
|
-
for (const
|
|
8058
|
-
const
|
|
8059
|
-
|
|
8083
|
+
const F = a.get(w.cube.name), U = w.cube.sql(n);
|
|
8084
|
+
if (E = U.from, S = U.where, F && !w.junctionTable) {
|
|
8085
|
+
const j = [];
|
|
8086
|
+
for (const B of F.joinKeys) {
|
|
8087
|
+
const V = o`${o.identifier(F.cteAlias)}.${o.identifier(B.sourceColumn)}`, q = B.targetColumnObj || o.identifier(B.targetColumn);
|
|
8088
|
+
j.push(Q(V, q));
|
|
8060
8089
|
}
|
|
8061
|
-
N =
|
|
8090
|
+
N = j.length === 1 ? j[0] : A(...j);
|
|
8062
8091
|
} else
|
|
8063
|
-
N =
|
|
8092
|
+
N = w.joinCondition;
|
|
8064
8093
|
}
|
|
8065
|
-
const
|
|
8094
|
+
const _ = w.joinType || "left", v = _ !== "inner" && S ? A(N, S) : N;
|
|
8066
8095
|
try {
|
|
8067
|
-
switch (
|
|
8096
|
+
switch (_) {
|
|
8068
8097
|
case "left":
|
|
8069
|
-
f = f.leftJoin(E,
|
|
8098
|
+
f = f.leftJoin(E, v), S && h.add(w.cube.name);
|
|
8070
8099
|
break;
|
|
8071
8100
|
case "inner":
|
|
8072
8101
|
f = f.innerJoin(E, N);
|
|
8073
8102
|
break;
|
|
8074
8103
|
case "right":
|
|
8075
|
-
f = f.rightJoin(E,
|
|
8104
|
+
f = f.rightJoin(E, v), S && h.add(w.cube.name);
|
|
8076
8105
|
break;
|
|
8077
8106
|
case "full":
|
|
8078
|
-
f = f.fullJoin(E,
|
|
8107
|
+
f = f.fullJoin(E, v), S && h.add(w.cube.name);
|
|
8079
8108
|
break;
|
|
8080
8109
|
}
|
|
8081
8110
|
} catch {
|
|
8082
8111
|
}
|
|
8083
8112
|
}
|
|
8084
8113
|
if (u.where && p.push(u.where), e.joinCubes && e.joinCubes.length > 0)
|
|
8085
|
-
for (const
|
|
8086
|
-
const C =
|
|
8114
|
+
for (const w of e.joinCubes) {
|
|
8115
|
+
const C = w.cube.name;
|
|
8087
8116
|
if (r.get(C) || g.has(C) || h.has(C))
|
|
8088
8117
|
continue;
|
|
8089
|
-
const E =
|
|
8118
|
+
const E = w.cube.sql(n);
|
|
8090
8119
|
E.where && p.push(E.where);
|
|
8091
8120
|
}
|
|
8092
8121
|
const y = this.queryBuilder.buildWhereConditions(
|
|
@@ -8100,8 +8129,8 @@ class J {
|
|
|
8100
8129
|
// Reuse pre-built filters for parameter deduplication
|
|
8101
8130
|
);
|
|
8102
8131
|
if (y.length > 0 && p.push(...y), p.length > 0) {
|
|
8103
|
-
const
|
|
8104
|
-
f = f.where(
|
|
8132
|
+
const w = p.length === 1 ? p[0] : A(...p);
|
|
8133
|
+
f = f.where(w);
|
|
8105
8134
|
}
|
|
8106
8135
|
const b = this.queryBuilder.buildGroupByFields(
|
|
8107
8136
|
e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
|
|
@@ -8112,7 +8141,7 @@ class J {
|
|
|
8112
8141
|
// Pass the queryPlan to handle CTE scenarios
|
|
8113
8142
|
);
|
|
8114
8143
|
b.length > 0 && (f = f.groupBy(...b));
|
|
8115
|
-
const
|
|
8144
|
+
const $ = this.queryBuilder.buildHavingConditions(
|
|
8116
8145
|
e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
|
|
8117
8146
|
// Single cube
|
|
8118
8147
|
t,
|
|
@@ -8120,12 +8149,12 @@ class J {
|
|
|
8120
8149
|
e
|
|
8121
8150
|
// Pass the queryPlan to handle CTE scenarios
|
|
8122
8151
|
);
|
|
8123
|
-
if (
|
|
8124
|
-
const
|
|
8125
|
-
f = f.having(
|
|
8152
|
+
if ($.length > 0) {
|
|
8153
|
+
const w = $.length === 1 ? $[0] : A(...$);
|
|
8154
|
+
f = f.having(w);
|
|
8126
8155
|
}
|
|
8127
|
-
const
|
|
8128
|
-
return
|
|
8156
|
+
const D = this.queryBuilder.buildOrderBy(t);
|
|
8157
|
+
return D.length > 0 && (f = f.orderBy(...D)), f = this.queryBuilder.applyLimitAndOffset(f, t), f;
|
|
8129
8158
|
}
|
|
8130
8159
|
/**
|
|
8131
8160
|
* Convert query plan to cube map for QueryBuilder methods
|
|
@@ -8323,16 +8352,16 @@ class J {
|
|
|
8323
8352
|
*/
|
|
8324
8353
|
preloadFilterCache(e, t, n, s) {
|
|
8325
8354
|
if (e.filters && e.filters.length > 0) {
|
|
8326
|
-
const i =
|
|
8355
|
+
const i = Re(e.filters);
|
|
8327
8356
|
for (const r of i) {
|
|
8328
|
-
const a =
|
|
8357
|
+
const a = me(r);
|
|
8329
8358
|
if (t.has(a)) continue;
|
|
8330
8359
|
const [u, c] = r.member.split("."), l = n.get(u);
|
|
8331
8360
|
if (!l) continue;
|
|
8332
8361
|
const m = l.dimensions?.[c];
|
|
8333
8362
|
if (!m || ["arrayContains", "arrayOverlaps", "arrayContained"].includes(r.operator))
|
|
8334
8363
|
continue;
|
|
8335
|
-
const f =
|
|
8364
|
+
const f = R(m.sql, s), h = this.queryBuilder.buildFilterConditionPublic(
|
|
8336
8365
|
f,
|
|
8337
8366
|
r.operator,
|
|
8338
8367
|
r.values,
|
|
@@ -8345,13 +8374,13 @@ class J {
|
|
|
8345
8374
|
if (e.timeDimensions) {
|
|
8346
8375
|
for (const i of e.timeDimensions)
|
|
8347
8376
|
if (i.dateRange) {
|
|
8348
|
-
const r =
|
|
8377
|
+
const r = lt(i.dimension, i.dateRange);
|
|
8349
8378
|
if (t.has(r)) continue;
|
|
8350
8379
|
const [a, u] = i.dimension.split("."), c = n.get(a);
|
|
8351
8380
|
if (!c) continue;
|
|
8352
8381
|
const l = c.dimensions?.[u];
|
|
8353
8382
|
if (!l) continue;
|
|
8354
|
-
const m =
|
|
8383
|
+
const m = R(l.sql, s), p = this.queryBuilder.buildDateRangeCondition(m, i.dateRange);
|
|
8355
8384
|
p && t.set(r, p);
|
|
8356
8385
|
}
|
|
8357
8386
|
}
|
|
@@ -8383,15 +8412,15 @@ class J {
|
|
|
8383
8412
|
const h = f.field.includes(".") ? f.field.split(".")[1] : f.field;
|
|
8384
8413
|
if (n.timeDimensions)
|
|
8385
8414
|
for (const b of n.timeDimensions) {
|
|
8386
|
-
const [
|
|
8387
|
-
if (
|
|
8388
|
-
const
|
|
8389
|
-
if (
|
|
8415
|
+
const [$, D] = b.dimension.split(".");
|
|
8416
|
+
if (D === h) {
|
|
8417
|
+
const w = u($, h);
|
|
8418
|
+
if (w)
|
|
8390
8419
|
return {
|
|
8391
|
-
field:
|
|
8420
|
+
field: w,
|
|
8392
8421
|
direction: f.direction
|
|
8393
8422
|
};
|
|
8394
|
-
const C = i.dimensions?.[
|
|
8423
|
+
const C = i.dimensions?.[D];
|
|
8395
8424
|
if (C)
|
|
8396
8425
|
return {
|
|
8397
8426
|
field: this.queryBuilder.buildTimeDimensionExpression(
|
|
@@ -8406,7 +8435,7 @@ class J {
|
|
|
8406
8435
|
const g = i.dimensions?.[h];
|
|
8407
8436
|
if (g)
|
|
8408
8437
|
return {
|
|
8409
|
-
field:
|
|
8438
|
+
field: R(g.sql, s),
|
|
8410
8439
|
direction: f.direction
|
|
8411
8440
|
};
|
|
8412
8441
|
const y = a.measure?.includes(".") ? a.measure.split(".")[1] : a.measure;
|
|
@@ -8425,10 +8454,10 @@ class J {
|
|
|
8425
8454
|
else {
|
|
8426
8455
|
const b = i.name === h ? i : void 0;
|
|
8427
8456
|
if (b?.dimensions?.[g]) {
|
|
8428
|
-
const
|
|
8457
|
+
const $ = b.dimensions[g];
|
|
8429
8458
|
c = [{
|
|
8430
8459
|
field: this.queryBuilder.buildTimeDimensionExpression(
|
|
8431
|
-
|
|
8460
|
+
$.sql,
|
|
8432
8461
|
f.granularity,
|
|
8433
8462
|
s
|
|
8434
8463
|
),
|
|
@@ -8440,7 +8469,7 @@ class J {
|
|
|
8440
8469
|
let l;
|
|
8441
8470
|
a.partitionBy && a.partitionBy.length > 0 && (l = a.partitionBy.map((f) => {
|
|
8442
8471
|
const h = f.includes(".") ? f.split(".")[1] : f, g = i.dimensions?.[h];
|
|
8443
|
-
return g ?
|
|
8472
|
+
return g ? R(g.sql, s) : null;
|
|
8444
8473
|
}).filter((f) => f !== null));
|
|
8445
8474
|
const m = this.databaseAdapter.buildWindowFunction(
|
|
8446
8475
|
e.type,
|
|
@@ -8468,7 +8497,7 @@ class J {
|
|
|
8468
8497
|
}
|
|
8469
8498
|
}
|
|
8470
8499
|
}
|
|
8471
|
-
const
|
|
8500
|
+
const $n = {
|
|
8472
8501
|
name: "drizzle-cube-mcp-guide",
|
|
8473
8502
|
description: "How to use drizzle-cube MCP tools to generate and run queries",
|
|
8474
8503
|
messages: [
|
|
@@ -8510,7 +8539,7 @@ const bn = {
|
|
|
8510
8539
|
}
|
|
8511
8540
|
}
|
|
8512
8541
|
]
|
|
8513
|
-
},
|
|
8542
|
+
}, Tn = {
|
|
8514
8543
|
name: "drizzle-cube-query-rules",
|
|
8515
8544
|
description: "Key generation rules aligned with Gemini single-step prompt",
|
|
8516
8545
|
messages: [
|
|
@@ -8533,7 +8562,7 @@ const bn = {
|
|
|
8533
8562
|
}
|
|
8534
8563
|
}
|
|
8535
8564
|
]
|
|
8536
|
-
},
|
|
8565
|
+
}, En = {
|
|
8537
8566
|
name: "drizzle-cube-query-building",
|
|
8538
8567
|
description: "CRITICAL: Complete guide for building valid queries of all types with examples",
|
|
8539
8568
|
messages: [
|
|
@@ -8719,7 +8748,7 @@ const bn = {
|
|
|
8719
8748
|
}
|
|
8720
8749
|
}
|
|
8721
8750
|
]
|
|
8722
|
-
},
|
|
8751
|
+
}, Sn = {
|
|
8723
8752
|
name: "drizzle-cube-date-filtering",
|
|
8724
8753
|
description: "CRITICAL: How to correctly filter by date vs group by time period - the #1 source of query mistakes",
|
|
8725
8754
|
messages: [
|
|
@@ -8812,22 +8841,22 @@ const bn = {
|
|
|
8812
8841
|
}
|
|
8813
8842
|
}
|
|
8814
8843
|
]
|
|
8815
|
-
},
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8844
|
+
}, Nn = [
|
|
8845
|
+
$n,
|
|
8846
|
+
Tn,
|
|
8847
|
+
En,
|
|
8848
|
+
Sn
|
|
8820
8849
|
];
|
|
8821
|
-
function
|
|
8822
|
-
return
|
|
8850
|
+
function Dn() {
|
|
8851
|
+
return Nn;
|
|
8823
8852
|
}
|
|
8824
|
-
class
|
|
8853
|
+
class mt {
|
|
8825
8854
|
cubes = /* @__PURE__ */ new Map();
|
|
8826
8855
|
dbExecutor;
|
|
8827
8856
|
metadataCache;
|
|
8828
8857
|
cacheConfig;
|
|
8829
8858
|
constructor(e) {
|
|
8830
|
-
e?.databaseExecutor ? this.dbExecutor = e.databaseExecutor : e?.drizzle && (this.dbExecutor =
|
|
8859
|
+
e?.databaseExecutor ? this.dbExecutor = e.databaseExecutor : e?.drizzle && (this.dbExecutor = qe(
|
|
8831
8860
|
e.drizzle,
|
|
8832
8861
|
e.schema,
|
|
8833
8862
|
e.engineType
|
|
@@ -8849,7 +8878,7 @@ class lt {
|
|
|
8849
8878
|
* Set Drizzle instance and schema directly
|
|
8850
8879
|
*/
|
|
8851
8880
|
setDrizzle(e, t, n) {
|
|
8852
|
-
this.dbExecutor =
|
|
8881
|
+
this.dbExecutor = qe(e, t, n);
|
|
8853
8882
|
}
|
|
8854
8883
|
/**
|
|
8855
8884
|
* Check if database executor is configured
|
|
@@ -8862,7 +8891,7 @@ class lt {
|
|
|
8862
8891
|
* Validates calculated measures during registration
|
|
8863
8892
|
*/
|
|
8864
8893
|
registerCube(e) {
|
|
8865
|
-
this.validateCalculatedMeasures(e), new
|
|
8894
|
+
this.validateCalculatedMeasures(e), new X(this.cubes).populateDependencies(e), this.cubes.set(e.name, e), this.invalidateMetadataCache();
|
|
8866
8895
|
}
|
|
8867
8896
|
/**
|
|
8868
8897
|
* Validate calculated measures in a cube
|
|
@@ -8878,7 +8907,7 @@ class lt {
|
|
|
8878
8907
|
);
|
|
8879
8908
|
continue;
|
|
8880
8909
|
}
|
|
8881
|
-
const i =
|
|
8910
|
+
const i = an(s.calculatedSql);
|
|
8882
8911
|
if (!i.isValid) {
|
|
8883
8912
|
t.push(
|
|
8884
8913
|
`Invalid calculatedSql syntax in '${e.name}.${n}': ${i.errors.join(", ")}`
|
|
@@ -8887,7 +8916,7 @@ class lt {
|
|
|
8887
8916
|
}
|
|
8888
8917
|
const r = new Map(this.cubes);
|
|
8889
8918
|
r.set(e.name, e);
|
|
8890
|
-
const a = new
|
|
8919
|
+
const a = new X(r);
|
|
8891
8920
|
try {
|
|
8892
8921
|
a.validateDependencies(e);
|
|
8893
8922
|
} catch (u) {
|
|
@@ -8897,7 +8926,7 @@ class lt {
|
|
|
8897
8926
|
if (t.length === 0) {
|
|
8898
8927
|
const n = new Map(this.cubes);
|
|
8899
8928
|
n.set(e.name, e);
|
|
8900
|
-
const s = new
|
|
8929
|
+
const s = new X(n);
|
|
8901
8930
|
s.buildGraph(e);
|
|
8902
8931
|
const i = s.detectCycle();
|
|
8903
8932
|
i && t.push(
|
|
@@ -8936,7 +8965,7 @@ ${t.join(`
|
|
|
8936
8965
|
async execute(e, t, n) {
|
|
8937
8966
|
if (!this.dbExecutor)
|
|
8938
8967
|
throw new Error("Database executor not configured");
|
|
8939
|
-
return new
|
|
8968
|
+
return new Y(this.dbExecutor, this.cacheConfig).execute(this.cubes, e, t, n);
|
|
8940
8969
|
}
|
|
8941
8970
|
/**
|
|
8942
8971
|
* Execute a multi-cube query
|
|
@@ -9014,7 +9043,7 @@ ${t.join(`
|
|
|
9014
9043
|
for (let c = 0; c < n.length; c++) {
|
|
9015
9044
|
const l = n[c], m = e.dimensions[l];
|
|
9016
9045
|
let p;
|
|
9017
|
-
m.type === "time" && (p = m.granularities ||
|
|
9046
|
+
m.type === "time" && (p = m.granularities || mt.DEFAULT_TIME_GRANULARITIES), i[c] = {
|
|
9018
9047
|
name: `${e.name}.${l}`,
|
|
9019
9048
|
title: m.title || l,
|
|
9020
9049
|
shortTitle: m.title || l,
|
|
@@ -9072,9 +9101,9 @@ ${t.join(`
|
|
|
9072
9101
|
throw new Error(`Cube '${e}' not found`);
|
|
9073
9102
|
if (!this.dbExecutor)
|
|
9074
9103
|
throw new Error("Database executor not configured");
|
|
9075
|
-
const r = await new
|
|
9104
|
+
const r = await new Y(this.dbExecutor).generateSQL(s, t, n), a = this.dbExecutor.getEngineType();
|
|
9076
9105
|
return {
|
|
9077
|
-
sql:
|
|
9106
|
+
sql: te(r.sql, a),
|
|
9078
9107
|
params: r.params
|
|
9079
9108
|
};
|
|
9080
9109
|
}
|
|
@@ -9084,9 +9113,9 @@ ${t.join(`
|
|
|
9084
9113
|
async generateMultiCubeSQL(e, t) {
|
|
9085
9114
|
if (!this.dbExecutor)
|
|
9086
9115
|
throw new Error("Database executor not configured");
|
|
9087
|
-
const s = await new
|
|
9116
|
+
const s = await new Y(this.dbExecutor).generateMultiCubeSQL(this.cubes, e, t), i = this.dbExecutor.getEngineType();
|
|
9088
9117
|
return {
|
|
9089
|
-
sql:
|
|
9118
|
+
sql: te(s.sql, i),
|
|
9090
9119
|
params: s.params
|
|
9091
9120
|
};
|
|
9092
9121
|
}
|
|
@@ -9097,9 +9126,9 @@ ${t.join(`
|
|
|
9097
9126
|
async dryRunFunnel(e, t) {
|
|
9098
9127
|
if (!this.dbExecutor)
|
|
9099
9128
|
throw new Error("Database executor not configured");
|
|
9100
|
-
const s = await new
|
|
9129
|
+
const s = await new Y(this.dbExecutor).dryRunFunnel(this.cubes, e, t), i = this.dbExecutor.getEngineType();
|
|
9101
9130
|
return {
|
|
9102
|
-
sql:
|
|
9131
|
+
sql: te(s.sql, i),
|
|
9103
9132
|
params: s.params
|
|
9104
9133
|
};
|
|
9105
9134
|
}
|
|
@@ -9110,9 +9139,9 @@ ${t.join(`
|
|
|
9110
9139
|
async dryRunFlow(e, t) {
|
|
9111
9140
|
if (!this.dbExecutor)
|
|
9112
9141
|
throw new Error("Database executor not configured");
|
|
9113
|
-
const s = await new
|
|
9142
|
+
const s = await new Y(this.dbExecutor).dryRunFlow(this.cubes, e, t), i = this.dbExecutor.getEngineType();
|
|
9114
9143
|
return {
|
|
9115
|
-
sql:
|
|
9144
|
+
sql: te(s.sql, i),
|
|
9116
9145
|
params: s.params
|
|
9117
9146
|
};
|
|
9118
9147
|
}
|
|
@@ -9123,9 +9152,9 @@ ${t.join(`
|
|
|
9123
9152
|
async dryRunRetention(e, t) {
|
|
9124
9153
|
if (!this.dbExecutor)
|
|
9125
9154
|
throw new Error("Database executor not configured");
|
|
9126
|
-
const s = await new
|
|
9155
|
+
const s = await new Y(this.dbExecutor).dryRunRetention(this.cubes, e, t), i = this.dbExecutor.getEngineType();
|
|
9127
9156
|
return {
|
|
9128
|
-
sql:
|
|
9157
|
+
sql: te(s.sql, i),
|
|
9129
9158
|
params: s.params
|
|
9130
9159
|
};
|
|
9131
9160
|
}
|
|
@@ -9137,7 +9166,7 @@ ${t.join(`
|
|
|
9137
9166
|
async explainQuery(e, t, n) {
|
|
9138
9167
|
if (!this.dbExecutor)
|
|
9139
9168
|
throw new Error("Database executor not configured");
|
|
9140
|
-
return new
|
|
9169
|
+
return new Y(this.dbExecutor).explainQuery(this.cubes, e, t, n);
|
|
9141
9170
|
}
|
|
9142
9171
|
/**
|
|
9143
9172
|
* Check if a cube exists
|
|
@@ -9176,7 +9205,7 @@ ${t.join(`
|
|
|
9176
9205
|
* Ensures all referenced cubes and fields exist
|
|
9177
9206
|
*/
|
|
9178
9207
|
validateQuery(e) {
|
|
9179
|
-
return
|
|
9208
|
+
return ft(this.cubes, e);
|
|
9180
9209
|
}
|
|
9181
9210
|
/**
|
|
9182
9211
|
* Analyze query planning decisions for debugging and transparency
|
|
@@ -9186,7 +9215,7 @@ ${t.join(`
|
|
|
9186
9215
|
analyzeQuery(e, t) {
|
|
9187
9216
|
if (!this.dbExecutor)
|
|
9188
9217
|
throw new Error("Database executor not configured");
|
|
9189
|
-
const n = new
|
|
9218
|
+
const n = new ct(), s = {
|
|
9190
9219
|
db: this.dbExecutor.db,
|
|
9191
9220
|
schema: this.dbExecutor.schema,
|
|
9192
9221
|
securityContext: t
|
|
@@ -9194,7 +9223,7 @@ ${t.join(`
|
|
|
9194
9223
|
return n.analyzeQueryPlan(this.cubes, e, s);
|
|
9195
9224
|
}
|
|
9196
9225
|
}
|
|
9197
|
-
function
|
|
9226
|
+
function ft(d, e) {
|
|
9198
9227
|
const t = [];
|
|
9199
9228
|
if (e.funnel !== void 0 && e.funnel.steps?.length >= 2) {
|
|
9200
9229
|
const s = e.funnel.bindingKey;
|
|
@@ -9215,7 +9244,7 @@ function ct(d, e) {
|
|
|
9215
9244
|
return { isValid: t.length === 0, errors: t };
|
|
9216
9245
|
}
|
|
9217
9246
|
if (e.retention !== void 0 && e.retention.timeDimension != null && e.retention.bindingKey != null) {
|
|
9218
|
-
const s =
|
|
9247
|
+
const s = An(e.retention.timeDimension);
|
|
9219
9248
|
s && !d.has(s) && t.push(`Retention cube not found: ${s}`);
|
|
9220
9249
|
const i = e.retention.bindingKey;
|
|
9221
9250
|
if (typeof i == "string") {
|
|
@@ -9279,17 +9308,17 @@ function ct(d, e) {
|
|
|
9279
9308
|
}
|
|
9280
9309
|
if (e.filters)
|
|
9281
9310
|
for (const s of e.filters)
|
|
9282
|
-
|
|
9311
|
+
pt(s, d, t, n);
|
|
9283
9312
|
return n.size === 0 && t.push("Query must reference at least one cube through measures, dimensions, or filters"), {
|
|
9284
9313
|
isValid: t.length === 0,
|
|
9285
9314
|
errors: t
|
|
9286
9315
|
};
|
|
9287
9316
|
}
|
|
9288
|
-
function
|
|
9317
|
+
function pt(d, e, t, n) {
|
|
9289
9318
|
if ("and" in d || "or" in d) {
|
|
9290
9319
|
const a = d.and || d.or || [];
|
|
9291
9320
|
for (const u of a)
|
|
9292
|
-
|
|
9321
|
+
pt(u, e, t, n);
|
|
9293
9322
|
return;
|
|
9294
9323
|
}
|
|
9295
9324
|
if (!("member" in d)) {
|
|
@@ -9309,34 +9338,34 @@ function dt(d, e, t, n) {
|
|
|
9309
9338
|
}
|
|
9310
9339
|
!r.dimensions[i] && !r.measures[i] && t.push(`Filter field '${i}' not found on cube '${s}' (must be a dimension or measure)`);
|
|
9311
9340
|
}
|
|
9312
|
-
function
|
|
9341
|
+
function An(d) {
|
|
9313
9342
|
if (typeof d == "string") {
|
|
9314
9343
|
const [e] = d.split(".");
|
|
9315
9344
|
return e || null;
|
|
9316
9345
|
}
|
|
9317
9346
|
return d.cube;
|
|
9318
9347
|
}
|
|
9319
|
-
const
|
|
9320
|
-
function
|
|
9321
|
-
const t =
|
|
9348
|
+
const ue = ["2025-11-25", "2025-06-18", "2025-03-26"], ht = "2025-11-25";
|
|
9349
|
+
function In(d) {
|
|
9350
|
+
const t = _n(d["mcp-protocol-version"]) || ht;
|
|
9322
9351
|
return {
|
|
9323
|
-
ok:
|
|
9324
|
-
negotiated:
|
|
9325
|
-
supported:
|
|
9352
|
+
ok: ue.includes(t),
|
|
9353
|
+
negotiated: ue.includes(t) ? t : null,
|
|
9354
|
+
supported: ue
|
|
9326
9355
|
};
|
|
9327
9356
|
}
|
|
9328
|
-
function
|
|
9357
|
+
function Ln(d) {
|
|
9329
9358
|
if (!d) return !1;
|
|
9330
9359
|
const e = d.split(",").map((s) => s.trim().toLowerCase()), t = e.includes("text/event-stream"), n = e.includes("application/json");
|
|
9331
9360
|
return t && !n;
|
|
9332
9361
|
}
|
|
9333
|
-
const
|
|
9334
|
-
function
|
|
9362
|
+
const Mn = "mcp-session-id";
|
|
9363
|
+
function jn(d) {
|
|
9335
9364
|
if (!d) return !1;
|
|
9336
9365
|
const e = d.split(",").map((s) => s.trim().toLowerCase().split(";")[0]), t = e.some((s) => s === "application/json"), n = e.some((s) => s === "text/event-stream");
|
|
9337
9366
|
return t && n;
|
|
9338
9367
|
}
|
|
9339
|
-
function
|
|
9368
|
+
function Un(d, e = {}) {
|
|
9340
9369
|
const { allowMissingOrigin: t = !0, allowedOrigins: n } = e;
|
|
9341
9370
|
if (!d)
|
|
9342
9371
|
return t ? { valid: !0 } : { valid: !1, reason: "Origin header is required" };
|
|
@@ -9356,26 +9385,26 @@ function In(d, e = {}) {
|
|
|
9356
9385
|
}
|
|
9357
9386
|
}).includes(s.origin) ? { valid: !0 } : { valid: !1, reason: "Origin not in allowed list" };
|
|
9358
9387
|
}
|
|
9359
|
-
function
|
|
9388
|
+
function xn(d, e, t) {
|
|
9360
9389
|
const n = [];
|
|
9361
9390
|
return e && n.push(`id: ${e}`), t && t > 0 && n.push(`retry: ${t}`), n.push("event: message"), n.push(`data: ${JSON.stringify(d)}`), n.push(""), n.join(`
|
|
9362
9391
|
`);
|
|
9363
9392
|
}
|
|
9364
|
-
function
|
|
9393
|
+
function kn(d, e, t, n) {
|
|
9365
9394
|
return {
|
|
9366
9395
|
jsonrpc: "2.0",
|
|
9367
9396
|
id: d ?? null,
|
|
9368
9397
|
error: { code: e, message: t, ...n !== void 0 ? { data: n } : {} }
|
|
9369
9398
|
};
|
|
9370
9399
|
}
|
|
9371
|
-
function
|
|
9400
|
+
function Bn(d, e) {
|
|
9372
9401
|
return {
|
|
9373
9402
|
jsonrpc: "2.0",
|
|
9374
9403
|
id: d ?? null,
|
|
9375
9404
|
result: e
|
|
9376
9405
|
};
|
|
9377
9406
|
}
|
|
9378
|
-
function
|
|
9407
|
+
function Pn(d) {
|
|
9379
9408
|
if (!d || typeof d != "object") return null;
|
|
9380
9409
|
const e = d;
|
|
9381
9410
|
return e.jsonrpc !== "2.0" || typeof e.method != "string" ? null : {
|
|
@@ -9385,13 +9414,13 @@ function Un(d) {
|
|
|
9385
9414
|
params: e.params
|
|
9386
9415
|
};
|
|
9387
9416
|
}
|
|
9388
|
-
async function
|
|
9389
|
-
const { semanticLayer: n, extractSecurityContext: s, rawRequest: i, rawResponse: r } = t, a = t.prompts ??
|
|
9417
|
+
async function Qn(d, e, t) {
|
|
9418
|
+
const { semanticLayer: n, extractSecurityContext: s, rawRequest: i, rawResponse: r } = t, a = t.prompts ?? gt, u = t.resources ?? bt;
|
|
9390
9419
|
switch (d) {
|
|
9391
9420
|
case "initialize": {
|
|
9392
9421
|
const c = e?.protocolVersion;
|
|
9393
9422
|
let l;
|
|
9394
|
-
return c &&
|
|
9423
|
+
return c && ue.includes(c) ? l = c : l = ht, {
|
|
9395
9424
|
protocolVersion: l,
|
|
9396
9425
|
capabilities: {
|
|
9397
9426
|
tools: {
|
|
@@ -9405,7 +9434,7 @@ async function kn(d, e, t) {
|
|
|
9405
9434
|
},
|
|
9406
9435
|
sampling: {}
|
|
9407
9436
|
},
|
|
9408
|
-
sessionId:
|
|
9437
|
+
sessionId: vn(),
|
|
9409
9438
|
serverInfo: {
|
|
9410
9439
|
name: "drizzle-cube",
|
|
9411
9440
|
// Use safe check for process.env to support edge runtimes (Cloudflare Workers, etc.)
|
|
@@ -9415,10 +9444,10 @@ async function kn(d, e, t) {
|
|
|
9415
9444
|
}
|
|
9416
9445
|
case "list_tools":
|
|
9417
9446
|
case "tools/list":
|
|
9418
|
-
return { tools:
|
|
9447
|
+
return { tools: Rn(), nextCursor: "" };
|
|
9419
9448
|
case "call_tool":
|
|
9420
9449
|
case "tools/call":
|
|
9421
|
-
return
|
|
9450
|
+
return Fn(e, t);
|
|
9422
9451
|
case "resources/list":
|
|
9423
9452
|
return {
|
|
9424
9453
|
resources: u.map(({ uri: c, name: l, description: m, mimeType: p }) => ({
|
|
@@ -9433,7 +9462,7 @@ async function kn(d, e, t) {
|
|
|
9433
9462
|
return { resourceTemplates: [], nextCursor: "" };
|
|
9434
9463
|
case "resources/read": {
|
|
9435
9464
|
const c = e?.uri, l = u.find((m) => m.uri === c) || u[0];
|
|
9436
|
-
if (!l) throw
|
|
9465
|
+
if (!l) throw J(-32602, "resource not found");
|
|
9437
9466
|
return {
|
|
9438
9467
|
contents: [
|
|
9439
9468
|
{
|
|
@@ -9456,7 +9485,7 @@ async function kn(d, e, t) {
|
|
|
9456
9485
|
return {};
|
|
9457
9486
|
case "prompts/get": {
|
|
9458
9487
|
const c = e?.name, l = a.find((m) => m.name === c) || a[0];
|
|
9459
|
-
if (!l) throw
|
|
9488
|
+
if (!l) throw J(-32602, "prompt not found");
|
|
9460
9489
|
return {
|
|
9461
9490
|
name: l.name,
|
|
9462
9491
|
description: l.description,
|
|
@@ -9464,38 +9493,38 @@ async function kn(d, e, t) {
|
|
|
9464
9493
|
};
|
|
9465
9494
|
}
|
|
9466
9495
|
case "discover":
|
|
9467
|
-
return
|
|
9496
|
+
return tt(n, e || {});
|
|
9468
9497
|
case "validate": {
|
|
9469
9498
|
const c = e || {};
|
|
9470
9499
|
if (!c.query)
|
|
9471
|
-
throw
|
|
9472
|
-
return
|
|
9500
|
+
throw J(-32602, "query is required");
|
|
9501
|
+
return et(n, c);
|
|
9473
9502
|
}
|
|
9474
9503
|
case "load": {
|
|
9475
9504
|
const c = e || {};
|
|
9476
9505
|
if (!c.query)
|
|
9477
|
-
throw
|
|
9506
|
+
throw J(-32602, "query is required");
|
|
9478
9507
|
const l = await s(i, r);
|
|
9479
|
-
return
|
|
9508
|
+
return Ze(n, l, c);
|
|
9480
9509
|
}
|
|
9481
9510
|
default:
|
|
9482
|
-
throw
|
|
9511
|
+
throw J(-32601, `Unknown MCP method: ${d}`);
|
|
9483
9512
|
}
|
|
9484
9513
|
}
|
|
9485
|
-
function
|
|
9514
|
+
function J(d, e, t) {
|
|
9486
9515
|
const n = new Error(e);
|
|
9487
9516
|
return n.code = d, n;
|
|
9488
9517
|
}
|
|
9489
|
-
function
|
|
9518
|
+
function _n(d) {
|
|
9490
9519
|
return d ? Array.isArray(d) ? d[0] || null : d : null;
|
|
9491
9520
|
}
|
|
9492
|
-
function
|
|
9521
|
+
function Wn(d) {
|
|
9493
9522
|
return d.id === void 0 || d.id === null;
|
|
9494
9523
|
}
|
|
9495
|
-
function
|
|
9496
|
-
return `evt-${
|
|
9524
|
+
function vn() {
|
|
9525
|
+
return `evt-${Ct()}`;
|
|
9497
9526
|
}
|
|
9498
|
-
function
|
|
9527
|
+
function Rn() {
|
|
9499
9528
|
return [
|
|
9500
9529
|
{
|
|
9501
9530
|
name: "discover",
|
|
@@ -9594,30 +9623,30 @@ QUERY CONSTRUCTION RULES:
|
|
|
9594
9623
|
}
|
|
9595
9624
|
];
|
|
9596
9625
|
}
|
|
9597
|
-
async function
|
|
9626
|
+
async function Fn(d, e) {
|
|
9598
9627
|
const { semanticLayer: t, extractSecurityContext: n, rawRequest: s, rawResponse: i } = e, r = d || {};
|
|
9599
9628
|
if (!r.name)
|
|
9600
|
-
throw
|
|
9629
|
+
throw J(-32602, "name is required for tools/call");
|
|
9601
9630
|
const a = r.arguments;
|
|
9602
9631
|
switch (r.name) {
|
|
9603
9632
|
case "discover":
|
|
9604
|
-
return
|
|
9633
|
+
return Ne(await tt(t, a || {}));
|
|
9605
9634
|
case "validate": {
|
|
9606
9635
|
const u = a || {};
|
|
9607
|
-
if (!u.query) throw
|
|
9608
|
-
return
|
|
9636
|
+
if (!u.query) throw J(-32602, "query is required");
|
|
9637
|
+
return Ne(await et(t, u));
|
|
9609
9638
|
}
|
|
9610
9639
|
case "load": {
|
|
9611
9640
|
const u = a || {};
|
|
9612
|
-
if (!u.query) throw
|
|
9641
|
+
if (!u.query) throw J(-32602, "query is required");
|
|
9613
9642
|
const c = await n(s, i);
|
|
9614
|
-
return
|
|
9643
|
+
return Ne(await Ze(t, c, u));
|
|
9615
9644
|
}
|
|
9616
9645
|
default:
|
|
9617
|
-
throw
|
|
9646
|
+
throw J(-32601, `Unknown tool: ${r.name}`);
|
|
9618
9647
|
}
|
|
9619
9648
|
}
|
|
9620
|
-
function
|
|
9649
|
+
function Ne(d) {
|
|
9621
9650
|
return {
|
|
9622
9651
|
content: [
|
|
9623
9652
|
{
|
|
@@ -9628,7 +9657,7 @@ function Se(d) {
|
|
|
9628
9657
|
isError: !1
|
|
9629
9658
|
};
|
|
9630
9659
|
}
|
|
9631
|
-
const
|
|
9660
|
+
const gt = Dn(), bt = [
|
|
9632
9661
|
{
|
|
9633
9662
|
uri: "drizzle-cube://quickstart",
|
|
9634
9663
|
name: "Drizzle Cube MCP Quickstart",
|
|
@@ -9734,26 +9763,26 @@ const ft = Tn(), pt = [
|
|
|
9734
9763
|
`)
|
|
9735
9764
|
}
|
|
9736
9765
|
];
|
|
9737
|
-
function
|
|
9738
|
-
return
|
|
9766
|
+
function Kn() {
|
|
9767
|
+
return bt;
|
|
9739
9768
|
}
|
|
9740
|
-
function
|
|
9741
|
-
return
|
|
9769
|
+
function qn() {
|
|
9770
|
+
return gt;
|
|
9742
9771
|
}
|
|
9743
9772
|
export {
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9773
|
+
Mn as M,
|
|
9774
|
+
mt as S,
|
|
9775
|
+
jn as a,
|
|
9776
|
+
kn as b,
|
|
9777
|
+
Bn as c,
|
|
9778
|
+
Qn as d,
|
|
9779
|
+
vn as e,
|
|
9780
|
+
Kn as f,
|
|
9781
|
+
qn as g,
|
|
9782
|
+
Wn as i,
|
|
9783
|
+
In as n,
|
|
9784
|
+
Pn as p,
|
|
9785
|
+
xn as s,
|
|
9786
|
+
Un as v,
|
|
9787
|
+
Ln as w
|
|
9759
9788
|
};
|