drizzle-cube 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/compiler-Dec55JjO.js +19988 -0
- package/dist/adapters/express/index.js +29 -29
- package/dist/adapters/fastify/index.js +31 -31
- package/dist/adapters/hono/index.js +38 -38
- package/dist/adapters/nextjs/index.js +43 -43
- package/dist/adapters/utils.d.ts +4 -0
- package/dist/client/charts.d.ts +10 -0
- package/dist/client/charts.js +18 -0
- package/dist/client/charts.js.map +1 -0
- package/dist/client/chunks/charts-BadAUMmd.js +2285 -0
- package/dist/client/chunks/charts-BadAUMmd.js.map +1 -0
- package/dist/client/chunks/icons-D95augkg.js +1916 -0
- package/dist/client/chunks/icons-D95augkg.js.map +1 -0
- package/dist/client/chunks/providers-DI5zeeEU.js +211 -0
- package/dist/client/chunks/providers-DI5zeeEU.js.map +1 -0
- package/dist/client/components/AIAssistant/AIAssistantModal.d.ts +10 -0
- package/dist/client/components/AIAssistant/constants.d.ts +11 -0
- package/dist/client/components/AIAssistant/index.d.ts +7 -0
- package/dist/client/components/AIAssistant/types.d.ts +49 -0
- package/dist/client/components/AIAssistant/utils.d.ts +17 -0
- package/dist/client/components/QueryBuilder/DateRangeFilter.d.ts +4 -0
- package/dist/client/components/QueryBuilder/DateRangeSelector.d.ts +11 -0
- package/dist/client/components/QueryBuilder/types.d.ts +32 -0
- package/dist/client/components/QueryBuilder/utils.d.ts +70 -1
- package/dist/client/components.d.ts +16 -0
- package/dist/client/components.js +6191 -0
- package/dist/client/components.js.map +1 -0
- package/dist/client/hooks.d.ts +11 -0
- package/dist/client/hooks.js +132 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +29 -30132
- package/dist/client/index.js.map +1 -0
- package/dist/client/providers/CubeProvider.d.ts +5 -2
- package/dist/client/providers.d.ts +9 -0
- package/dist/client/providers.js +7 -0
- package/dist/client/providers.js.map +1 -0
- package/dist/client/styles.css +1 -1
- package/dist/client/types.d.ts +4 -0
- package/dist/client/utils.d.ts +8 -0
- package/dist/client/utils.js +2 -0
- package/dist/client/utils.js.map +1 -0
- package/dist/client-bundle-stats.html +4949 -0
- package/dist/server/index.d.ts +226 -365
- package/dist/server/index.js +18886 -1555
- package/package.json +26 -2
- package/dist/adapters/utils-C3A4JGFs.js +0 -3779
|
@@ -1,3779 +0,0 @@
|
|
|
1
|
-
var Ht = Object.defineProperty;
|
|
2
|
-
var Gt = (s, e, t) => e in s ? Ht(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
-
var g = (s, e, t) => Gt(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
const I = Symbol.for("drizzle:entityKind");
|
|
5
|
-
function E(s, e) {
|
|
6
|
-
if (!s || typeof s != "object")
|
|
7
|
-
return !1;
|
|
8
|
-
if (s instanceof e)
|
|
9
|
-
return !0;
|
|
10
|
-
if (!Object.prototype.hasOwnProperty.call(e, I))
|
|
11
|
-
throw new Error(
|
|
12
|
-
`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.`
|
|
13
|
-
);
|
|
14
|
-
let t = Object.getPrototypeOf(s).constructor;
|
|
15
|
-
if (t)
|
|
16
|
-
for (; t; ) {
|
|
17
|
-
if (I in t && t[I] === e[I])
|
|
18
|
-
return !0;
|
|
19
|
-
t = Object.getPrototypeOf(t);
|
|
20
|
-
}
|
|
21
|
-
return !1;
|
|
22
|
-
}
|
|
23
|
-
var rt;
|
|
24
|
-
rt = I;
|
|
25
|
-
class ee {
|
|
26
|
-
constructor(e, t) {
|
|
27
|
-
g(this, "name");
|
|
28
|
-
g(this, "keyAsName");
|
|
29
|
-
g(this, "primary");
|
|
30
|
-
g(this, "notNull");
|
|
31
|
-
g(this, "default");
|
|
32
|
-
g(this, "defaultFn");
|
|
33
|
-
g(this, "onUpdateFn");
|
|
34
|
-
g(this, "hasDefault");
|
|
35
|
-
g(this, "isUnique");
|
|
36
|
-
g(this, "uniqueName");
|
|
37
|
-
g(this, "uniqueType");
|
|
38
|
-
g(this, "dataType");
|
|
39
|
-
g(this, "columnType");
|
|
40
|
-
g(this, "enumValues");
|
|
41
|
-
g(this, "generated");
|
|
42
|
-
g(this, "generatedIdentity");
|
|
43
|
-
g(this, "config");
|
|
44
|
-
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;
|
|
45
|
-
}
|
|
46
|
-
mapFromDriverValue(e) {
|
|
47
|
-
return e;
|
|
48
|
-
}
|
|
49
|
-
mapToDriverValue(e) {
|
|
50
|
-
return e;
|
|
51
|
-
}
|
|
52
|
-
// ** @internal */
|
|
53
|
-
shouldDisableInsert() {
|
|
54
|
-
return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
g(ee, rt, "Column");
|
|
58
|
-
const Oe = Symbol.for("drizzle:Name"), Ze = Symbol.for("drizzle:isPgEnum");
|
|
59
|
-
function Xt(s) {
|
|
60
|
-
return !!s && typeof s == "function" && Ze in s && s[Ze] === !0;
|
|
61
|
-
}
|
|
62
|
-
var ot;
|
|
63
|
-
ot = I;
|
|
64
|
-
class Ue {
|
|
65
|
-
constructor(e, t, n, i = !1, r = []) {
|
|
66
|
-
this._ = {
|
|
67
|
-
brand: "Subquery",
|
|
68
|
-
sql: e,
|
|
69
|
-
selectedFields: t,
|
|
70
|
-
alias: n,
|
|
71
|
-
isWith: i,
|
|
72
|
-
usedTables: r
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
// getSQL(): SQL<unknown> {
|
|
76
|
-
// return new SQL([this]);
|
|
77
|
-
// }
|
|
78
|
-
}
|
|
79
|
-
g(Ue, ot, "Subquery");
|
|
80
|
-
const Zt = {
|
|
81
|
-
startActiveSpan(s, e) {
|
|
82
|
-
return e();
|
|
83
|
-
}
|
|
84
|
-
}, se = Symbol.for("drizzle:ViewBaseConfig"), Te = Symbol.for("drizzle:Schema"), qe = Symbol.for("drizzle:Columns"), ve = Symbol.for("drizzle:ExtraConfigColumns"), Me = Symbol.for("drizzle:OriginalName"), Le = Symbol.for("drizzle:BaseName"), pe = Symbol.for("drizzle:IsAlias"), xe = Symbol.for("drizzle:ExtraConfigBuilder"), qt = Symbol.for("drizzle:IsDrizzleTable");
|
|
85
|
-
var at, lt, ut, ct, ft, dt, mt, ht, pt, bt;
|
|
86
|
-
bt = I, pt = Oe, ht = Me, mt = Te, dt = qe, ft = ve, ct = Le, ut = pe, lt = qt, at = xe;
|
|
87
|
-
class F {
|
|
88
|
-
constructor(e, t, n) {
|
|
89
|
-
/**
|
|
90
|
-
* @internal
|
|
91
|
-
* Can be changed if the table is aliased.
|
|
92
|
-
*/
|
|
93
|
-
g(this, pt);
|
|
94
|
-
/**
|
|
95
|
-
* @internal
|
|
96
|
-
* Used to store the original name of the table, before any aliasing.
|
|
97
|
-
*/
|
|
98
|
-
g(this, ht);
|
|
99
|
-
/** @internal */
|
|
100
|
-
g(this, mt);
|
|
101
|
-
/** @internal */
|
|
102
|
-
g(this, dt);
|
|
103
|
-
/** @internal */
|
|
104
|
-
g(this, ft);
|
|
105
|
-
/**
|
|
106
|
-
* @internal
|
|
107
|
-
* Used to store the table name before the transformation via the `tableCreator` functions.
|
|
108
|
-
*/
|
|
109
|
-
g(this, ct);
|
|
110
|
-
/** @internal */
|
|
111
|
-
g(this, ut, !1);
|
|
112
|
-
/** @internal */
|
|
113
|
-
g(this, lt, !0);
|
|
114
|
-
/** @internal */
|
|
115
|
-
g(this, at);
|
|
116
|
-
this[Oe] = this[Me] = e, this[Te] = t, this[Le] = n;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
g(F, bt, "Table"), /** @internal */
|
|
120
|
-
g(F, "Symbol", {
|
|
121
|
-
Name: Oe,
|
|
122
|
-
Schema: Te,
|
|
123
|
-
OriginalName: Me,
|
|
124
|
-
Columns: qe,
|
|
125
|
-
ExtraConfigColumns: ve,
|
|
126
|
-
BaseName: Le,
|
|
127
|
-
IsAlias: pe,
|
|
128
|
-
ExtraConfigBuilder: xe
|
|
129
|
-
});
|
|
130
|
-
function At(s) {
|
|
131
|
-
return s != null && typeof s.getSQL == "function";
|
|
132
|
-
}
|
|
133
|
-
function vt(s) {
|
|
134
|
-
var t;
|
|
135
|
-
const e = { sql: "", params: [] };
|
|
136
|
-
for (const n of s)
|
|
137
|
-
e.sql += n.sql, e.params.push(...n.params), (t = n.typings) != null && t.length && (e.typings || (e.typings = []), e.typings.push(...n.typings));
|
|
138
|
-
return e;
|
|
139
|
-
}
|
|
140
|
-
var gt;
|
|
141
|
-
gt = I;
|
|
142
|
-
class T {
|
|
143
|
-
constructor(e) {
|
|
144
|
-
g(this, "value");
|
|
145
|
-
this.value = Array.isArray(e) ? e : [e];
|
|
146
|
-
}
|
|
147
|
-
getSQL() {
|
|
148
|
-
return new A([this]);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
g(T, gt, "StringChunk");
|
|
152
|
-
var yt;
|
|
153
|
-
yt = I;
|
|
154
|
-
const Y = class Y {
|
|
155
|
-
constructor(e) {
|
|
156
|
-
/** @internal */
|
|
157
|
-
g(this, "decoder", Et);
|
|
158
|
-
g(this, "shouldInlineParams", !1);
|
|
159
|
-
/** @internal */
|
|
160
|
-
g(this, "usedTables", []);
|
|
161
|
-
this.queryChunks = e;
|
|
162
|
-
for (const t of e)
|
|
163
|
-
if (E(t, F)) {
|
|
164
|
-
const n = t[F.Symbol.Schema];
|
|
165
|
-
this.usedTables.push(
|
|
166
|
-
n === void 0 ? t[F.Symbol.Name] : n + "." + t[F.Symbol.Name]
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
append(e) {
|
|
171
|
-
return this.queryChunks.push(...e.queryChunks), this;
|
|
172
|
-
}
|
|
173
|
-
toQuery(e) {
|
|
174
|
-
return Zt.startActiveSpan("drizzle.buildSQL", (t) => {
|
|
175
|
-
const n = this.buildQueryFromSourceParams(this.queryChunks, e);
|
|
176
|
-
return t == null || t.setAttributes({
|
|
177
|
-
"drizzle.query.text": n.sql,
|
|
178
|
-
"drizzle.query.params": JSON.stringify(n.params)
|
|
179
|
-
}), n;
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
buildQueryFromSourceParams(e, t) {
|
|
183
|
-
const n = Object.assign({}, t, {
|
|
184
|
-
inlineParams: t.inlineParams || this.shouldInlineParams,
|
|
185
|
-
paramStartIndex: t.paramStartIndex || { value: 0 }
|
|
186
|
-
}), {
|
|
187
|
-
casing: i,
|
|
188
|
-
escapeName: r,
|
|
189
|
-
escapeParam: o,
|
|
190
|
-
prepareTyping: a,
|
|
191
|
-
inlineParams: l,
|
|
192
|
-
paramStartIndex: u
|
|
193
|
-
} = n;
|
|
194
|
-
return vt(e.map((c) => {
|
|
195
|
-
var f;
|
|
196
|
-
if (E(c, T))
|
|
197
|
-
return { sql: c.value.join(""), params: [] };
|
|
198
|
-
if (E(c, be))
|
|
199
|
-
return { sql: r(c.value), params: [] };
|
|
200
|
-
if (c === void 0)
|
|
201
|
-
return { sql: "", params: [] };
|
|
202
|
-
if (Array.isArray(c)) {
|
|
203
|
-
const d = [new T("(")];
|
|
204
|
-
for (const [p, y] of c.entries())
|
|
205
|
-
d.push(y), p < c.length - 1 && d.push(new T(", "));
|
|
206
|
-
return d.push(new T(")")), this.buildQueryFromSourceParams(d, n);
|
|
207
|
-
}
|
|
208
|
-
if (E(c, Y))
|
|
209
|
-
return this.buildQueryFromSourceParams(c.queryChunks, {
|
|
210
|
-
...n,
|
|
211
|
-
inlineParams: l || c.shouldInlineParams
|
|
212
|
-
});
|
|
213
|
-
if (E(c, F)) {
|
|
214
|
-
const d = c[F.Symbol.Schema], p = c[F.Symbol.Name];
|
|
215
|
-
return {
|
|
216
|
-
sql: d === void 0 || c[pe] ? r(p) : r(d) + "." + r(p),
|
|
217
|
-
params: []
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
if (E(c, ee)) {
|
|
221
|
-
const d = i.getColumnCasing(c);
|
|
222
|
-
if (t.invokeSource === "indexes")
|
|
223
|
-
return { sql: r(d), params: [] };
|
|
224
|
-
const p = c.table[F.Symbol.Schema];
|
|
225
|
-
return {
|
|
226
|
-
sql: c.table[pe] || p === void 0 ? r(c.table[F.Symbol.Name]) + "." + r(d) : r(p) + "." + r(c.table[F.Symbol.Name]) + "." + r(d),
|
|
227
|
-
params: []
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
if (E(c, Ve)) {
|
|
231
|
-
const d = c[se].schema, p = c[se].name;
|
|
232
|
-
return {
|
|
233
|
-
sql: d === void 0 || c[se].isAlias ? r(p) : r(d) + "." + r(p),
|
|
234
|
-
params: []
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
if (E(c, oe)) {
|
|
238
|
-
if (E(c.value, ae))
|
|
239
|
-
return { sql: o(u.value++, c), params: [c], typings: ["none"] };
|
|
240
|
-
const d = c.value === null ? null : c.encoder.mapToDriverValue(c.value);
|
|
241
|
-
if (E(d, Y))
|
|
242
|
-
return this.buildQueryFromSourceParams([d], n);
|
|
243
|
-
if (l)
|
|
244
|
-
return { sql: this.mapInlineParam(d, n), params: [] };
|
|
245
|
-
let p = ["none"];
|
|
246
|
-
return a && (p = [a(c.encoder)]), { sql: o(u.value++, d), params: [d], typings: p };
|
|
247
|
-
}
|
|
248
|
-
return E(c, ae) ? { sql: o(u.value++, c), params: [c], typings: ["none"] } : E(c, Y.Aliased) && c.fieldAlias !== void 0 ? { sql: r(c.fieldAlias), params: [] } : E(c, Ue) ? c._.isWith ? { sql: r(c._.alias), params: [] } : this.buildQueryFromSourceParams([
|
|
249
|
-
new T("("),
|
|
250
|
-
c._.sql,
|
|
251
|
-
new T(") "),
|
|
252
|
-
new be(c._.alias)
|
|
253
|
-
], n) : Xt(c) ? c.schema ? { sql: r(c.schema) + "." + r(c.enumName), params: [] } : { sql: r(c.enumName), params: [] } : At(c) ? (f = c.shouldOmitSQLParens) != null && f.call(c) ? this.buildQueryFromSourceParams([c.getSQL()], n) : this.buildQueryFromSourceParams([
|
|
254
|
-
new T("("),
|
|
255
|
-
c.getSQL(),
|
|
256
|
-
new T(")")
|
|
257
|
-
], n) : l ? { sql: this.mapInlineParam(c, n), params: [] } : { sql: o(u.value++, c), params: [c], typings: ["none"] };
|
|
258
|
-
}));
|
|
259
|
-
}
|
|
260
|
-
mapInlineParam(e, { escapeString: t }) {
|
|
261
|
-
if (e === null)
|
|
262
|
-
return "null";
|
|
263
|
-
if (typeof e == "number" || typeof e == "boolean")
|
|
264
|
-
return e.toString();
|
|
265
|
-
if (typeof e == "string")
|
|
266
|
-
return t(e);
|
|
267
|
-
if (typeof e == "object") {
|
|
268
|
-
const n = e.toString();
|
|
269
|
-
return t(n === "[object Object]" ? JSON.stringify(e) : n);
|
|
270
|
-
}
|
|
271
|
-
throw new Error("Unexpected param value: " + e);
|
|
272
|
-
}
|
|
273
|
-
getSQL() {
|
|
274
|
-
return this;
|
|
275
|
-
}
|
|
276
|
-
as(e) {
|
|
277
|
-
return e === void 0 ? this : new Y.Aliased(this, e);
|
|
278
|
-
}
|
|
279
|
-
mapWith(e) {
|
|
280
|
-
return this.decoder = typeof e == "function" ? { mapFromDriverValue: e } : e, this;
|
|
281
|
-
}
|
|
282
|
-
inlineParams() {
|
|
283
|
-
return this.shouldInlineParams = !0, this;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* This method is used to conditionally include a part of the query.
|
|
287
|
-
*
|
|
288
|
-
* @param condition - Condition to check
|
|
289
|
-
* @returns itself if the condition is `true`, otherwise `undefined`
|
|
290
|
-
*/
|
|
291
|
-
if(e) {
|
|
292
|
-
return e ? this : void 0;
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
g(Y, yt, "SQL");
|
|
296
|
-
let A = Y;
|
|
297
|
-
var wt;
|
|
298
|
-
wt = I;
|
|
299
|
-
class be {
|
|
300
|
-
constructor(e) {
|
|
301
|
-
g(this, "brand");
|
|
302
|
-
this.value = e;
|
|
303
|
-
}
|
|
304
|
-
getSQL() {
|
|
305
|
-
return new A([this]);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
g(be, wt, "Name");
|
|
309
|
-
function xt(s) {
|
|
310
|
-
return typeof s == "object" && s !== null && "mapToDriverValue" in s && typeof s.mapToDriverValue == "function";
|
|
311
|
-
}
|
|
312
|
-
const Et = {
|
|
313
|
-
mapFromDriverValue: (s) => s
|
|
314
|
-
}, Ot = {
|
|
315
|
-
mapToDriverValue: (s) => s
|
|
316
|
-
};
|
|
317
|
-
({
|
|
318
|
-
...Et,
|
|
319
|
-
...Ot
|
|
320
|
-
});
|
|
321
|
-
var St;
|
|
322
|
-
St = I;
|
|
323
|
-
class oe {
|
|
324
|
-
/**
|
|
325
|
-
* @param value - Parameter value
|
|
326
|
-
* @param encoder - Encoder to convert the value to a driver parameter
|
|
327
|
-
*/
|
|
328
|
-
constructor(e, t = Ot) {
|
|
329
|
-
g(this, "brand");
|
|
330
|
-
this.value = e, this.encoder = t;
|
|
331
|
-
}
|
|
332
|
-
getSQL() {
|
|
333
|
-
return new A([this]);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
g(oe, St, "Param");
|
|
337
|
-
function m(s, ...e) {
|
|
338
|
-
const t = [];
|
|
339
|
-
(e.length > 0 || s.length > 0 && s[0] !== "") && t.push(new T(s[0]));
|
|
340
|
-
for (const [n, i] of e.entries())
|
|
341
|
-
t.push(i, new T(s[n + 1]));
|
|
342
|
-
return new A(t);
|
|
343
|
-
}
|
|
344
|
-
((s) => {
|
|
345
|
-
function e() {
|
|
346
|
-
return new A([]);
|
|
347
|
-
}
|
|
348
|
-
s.empty = e;
|
|
349
|
-
function t(l) {
|
|
350
|
-
return new A(l);
|
|
351
|
-
}
|
|
352
|
-
s.fromList = t;
|
|
353
|
-
function n(l) {
|
|
354
|
-
return new A([new T(l)]);
|
|
355
|
-
}
|
|
356
|
-
s.raw = n;
|
|
357
|
-
function i(l, u) {
|
|
358
|
-
const c = [];
|
|
359
|
-
for (const [f, d] of l.entries())
|
|
360
|
-
f > 0 && u !== void 0 && c.push(u), c.push(d);
|
|
361
|
-
return new A(c);
|
|
362
|
-
}
|
|
363
|
-
s.join = i;
|
|
364
|
-
function r(l) {
|
|
365
|
-
return new be(l);
|
|
366
|
-
}
|
|
367
|
-
s.identifier = r;
|
|
368
|
-
function o(l) {
|
|
369
|
-
return new ae(l);
|
|
370
|
-
}
|
|
371
|
-
s.placeholder = o;
|
|
372
|
-
function a(l, u) {
|
|
373
|
-
return new oe(l, u);
|
|
374
|
-
}
|
|
375
|
-
s.param = a;
|
|
376
|
-
})(m || (m = {}));
|
|
377
|
-
((s) => {
|
|
378
|
-
var t;
|
|
379
|
-
t = I;
|
|
380
|
-
const n = class n {
|
|
381
|
-
constructor(r, o) {
|
|
382
|
-
/** @internal */
|
|
383
|
-
g(this, "isSelectionField", !1);
|
|
384
|
-
this.sql = r, this.fieldAlias = o;
|
|
385
|
-
}
|
|
386
|
-
getSQL() {
|
|
387
|
-
return this.sql;
|
|
388
|
-
}
|
|
389
|
-
/** @internal */
|
|
390
|
-
clone() {
|
|
391
|
-
return new n(this.sql, this.fieldAlias);
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
g(n, t, "SQL.Aliased");
|
|
395
|
-
let e = n;
|
|
396
|
-
s.Aliased = e;
|
|
397
|
-
})(A || (A = {}));
|
|
398
|
-
var Nt;
|
|
399
|
-
Nt = I;
|
|
400
|
-
class ae {
|
|
401
|
-
constructor(e) {
|
|
402
|
-
this.name = e;
|
|
403
|
-
}
|
|
404
|
-
getSQL() {
|
|
405
|
-
return new A([this]);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
g(ae, Nt, "Placeholder");
|
|
409
|
-
const en = Symbol.for("drizzle:IsDrizzleView");
|
|
410
|
-
var Ct, Dt, $t;
|
|
411
|
-
$t = I, Dt = se, Ct = en;
|
|
412
|
-
class Ve {
|
|
413
|
-
constructor({ name: e, schema: t, selectedFields: n, query: i }) {
|
|
414
|
-
/** @internal */
|
|
415
|
-
g(this, Dt);
|
|
416
|
-
/** @internal */
|
|
417
|
-
g(this, Ct, !0);
|
|
418
|
-
this[se] = {
|
|
419
|
-
name: e,
|
|
420
|
-
originalName: e,
|
|
421
|
-
schema: t,
|
|
422
|
-
selectedFields: n,
|
|
423
|
-
query: i,
|
|
424
|
-
isExisting: !i,
|
|
425
|
-
isAlias: !1
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
getSQL() {
|
|
429
|
-
return new A([this]);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
g(Ve, $t, "View");
|
|
433
|
-
ee.prototype.getSQL = function() {
|
|
434
|
-
return new A([this]);
|
|
435
|
-
};
|
|
436
|
-
F.prototype.getSQL = function() {
|
|
437
|
-
return new A([this]);
|
|
438
|
-
};
|
|
439
|
-
Ue.prototype.getSQL = function() {
|
|
440
|
-
return new A([this]);
|
|
441
|
-
};
|
|
442
|
-
function V(s, e) {
|
|
443
|
-
return xt(e) && !At(s) && !E(s, oe) && !E(s, ae) && !E(s, ee) && !E(s, F) && !E(s, Ve) ? new oe(s, e) : s;
|
|
444
|
-
}
|
|
445
|
-
const Tt = (s, e) => m`${s} = ${V(e, s)}`, tn = (s, e) => m`${s} <> ${V(e, s)}`;
|
|
446
|
-
function j(...s) {
|
|
447
|
-
const e = s.filter(
|
|
448
|
-
(t) => t !== void 0
|
|
449
|
-
);
|
|
450
|
-
if (e.length !== 0)
|
|
451
|
-
return e.length === 1 ? new A(e) : new A([
|
|
452
|
-
new T("("),
|
|
453
|
-
m.join(e, new T(" and ")),
|
|
454
|
-
new T(")")
|
|
455
|
-
]);
|
|
456
|
-
}
|
|
457
|
-
function Mt(...s) {
|
|
458
|
-
const e = s.filter(
|
|
459
|
-
(t) => t !== void 0
|
|
460
|
-
);
|
|
461
|
-
if (e.length !== 0)
|
|
462
|
-
return e.length === 1 ? new A(e) : new A([
|
|
463
|
-
new T("("),
|
|
464
|
-
m.join(e, new T(" or ")),
|
|
465
|
-
new T(")")
|
|
466
|
-
]);
|
|
467
|
-
}
|
|
468
|
-
const ge = (s, e) => m`${s} > ${V(e, s)}`, R = (s, e) => m`${s} >= ${V(e, s)}`, ye = (s, e) => m`${s} < ${V(e, s)}`, W = (s, e) => m`${s} <= ${V(e, s)}`;
|
|
469
|
-
function nn(s, e) {
|
|
470
|
-
return Array.isArray(e) ? e.length === 0 ? m`false` : m`${s} in ${e.map((t) => V(t, s))}` : m`${s} in ${V(e, s)}`;
|
|
471
|
-
}
|
|
472
|
-
function sn(s, e) {
|
|
473
|
-
return Array.isArray(e) ? e.length === 0 ? m`true` : m`${s} not in ${e.map((t) => V(t, s))}` : m`${s} not in ${V(e, s)}`;
|
|
474
|
-
}
|
|
475
|
-
function Lt(s) {
|
|
476
|
-
return m`${s} is null`;
|
|
477
|
-
}
|
|
478
|
-
function Ft(s) {
|
|
479
|
-
return m`${s} is not null`;
|
|
480
|
-
}
|
|
481
|
-
function Fe(s) {
|
|
482
|
-
return m`count(${s || m.raw("*")})`.mapWith(Number);
|
|
483
|
-
}
|
|
484
|
-
function rn(s) {
|
|
485
|
-
return m`count(distinct ${s})`.mapWith(Number);
|
|
486
|
-
}
|
|
487
|
-
function on(s) {
|
|
488
|
-
return m`avg(${s})`.mapWith(String);
|
|
489
|
-
}
|
|
490
|
-
function an(s) {
|
|
491
|
-
return m`sum(${s})`.mapWith(String);
|
|
492
|
-
}
|
|
493
|
-
function ln(s) {
|
|
494
|
-
return m`max(${s})`.mapWith(E(s, ee) ? s : String);
|
|
495
|
-
}
|
|
496
|
-
function un(s) {
|
|
497
|
-
return m`min(${s})`.mapWith(E(s, ee) ? s : String);
|
|
498
|
-
}
|
|
499
|
-
class jt {
|
|
500
|
-
/**
|
|
501
|
-
* Helper method to build pattern for string matching
|
|
502
|
-
* Can be overridden by specific adapters if needed
|
|
503
|
-
*/
|
|
504
|
-
buildPattern(e, t) {
|
|
505
|
-
switch (e) {
|
|
506
|
-
case "contains":
|
|
507
|
-
case "notContains":
|
|
508
|
-
return `%${t}%`;
|
|
509
|
-
case "startsWith":
|
|
510
|
-
return `${t}%`;
|
|
511
|
-
case "endsWith":
|
|
512
|
-
return `%${t}`;
|
|
513
|
-
default:
|
|
514
|
-
return t;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
class cn extends jt {
|
|
519
|
-
getEngineType() {
|
|
520
|
-
return "postgres";
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Build PostgreSQL time dimension using DATE_TRUNC function
|
|
524
|
-
* Extracted from executor.ts:649-670 and multi-cube-builder.ts:306-320
|
|
525
|
-
*/
|
|
526
|
-
buildTimeDimension(e, t) {
|
|
527
|
-
switch (e) {
|
|
528
|
-
case "year":
|
|
529
|
-
return m`DATE_TRUNC('year', ${t}::timestamp)`;
|
|
530
|
-
case "quarter":
|
|
531
|
-
return m`DATE_TRUNC('quarter', ${t}::timestamp)`;
|
|
532
|
-
case "month":
|
|
533
|
-
return m`DATE_TRUNC('month', ${t}::timestamp)`;
|
|
534
|
-
case "week":
|
|
535
|
-
return m`DATE_TRUNC('week', ${t}::timestamp)`;
|
|
536
|
-
case "day":
|
|
537
|
-
return m`DATE_TRUNC('day', ${t}::timestamp)::timestamp`;
|
|
538
|
-
case "hour":
|
|
539
|
-
return m`DATE_TRUNC('hour', ${t}::timestamp)`;
|
|
540
|
-
case "minute":
|
|
541
|
-
return m`DATE_TRUNC('minute', ${t}::timestamp)`;
|
|
542
|
-
case "second":
|
|
543
|
-
return m`DATE_TRUNC('second', ${t}::timestamp)`;
|
|
544
|
-
default:
|
|
545
|
-
return t;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* Build PostgreSQL string matching conditions using ILIKE (case-insensitive)
|
|
550
|
-
* Extracted from executor.ts:807-813 and multi-cube-builder.ts:468-474
|
|
551
|
-
*/
|
|
552
|
-
buildStringCondition(e, t, n) {
|
|
553
|
-
const i = this.buildPattern(t, n);
|
|
554
|
-
switch (t) {
|
|
555
|
-
case "contains":
|
|
556
|
-
return m`${e} ILIKE ${i}`;
|
|
557
|
-
case "notContains":
|
|
558
|
-
return m`${e} NOT ILIKE ${i}`;
|
|
559
|
-
case "startsWith":
|
|
560
|
-
return m`${e} ILIKE ${i}`;
|
|
561
|
-
case "endsWith":
|
|
562
|
-
return m`${e} ILIKE ${i}`;
|
|
563
|
-
default:
|
|
564
|
-
throw new Error(`Unsupported string operator: ${t}`);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Build PostgreSQL type casting using :: syntax
|
|
569
|
-
* Extracted from various locations where ::timestamp was used
|
|
570
|
-
*/
|
|
571
|
-
castToType(e, t) {
|
|
572
|
-
switch (t) {
|
|
573
|
-
case "timestamp":
|
|
574
|
-
return m`${e}::timestamp`;
|
|
575
|
-
case "decimal":
|
|
576
|
-
return m`${e}::decimal`;
|
|
577
|
-
case "integer":
|
|
578
|
-
return m`${e}::integer`;
|
|
579
|
-
default:
|
|
580
|
-
throw new Error(`Unsupported cast type: ${t}`);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Build PostgreSQL COUNT aggregation
|
|
585
|
-
* Extracted from multi-cube-builder.ts:278
|
|
586
|
-
*/
|
|
587
|
-
buildCount(e) {
|
|
588
|
-
return m`COUNT(${e})`;
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Build PostgreSQL COUNT DISTINCT aggregation
|
|
592
|
-
* Extracted from multi-cube-builder.ts:280
|
|
593
|
-
*/
|
|
594
|
-
buildCountDistinct(e) {
|
|
595
|
-
return m`COUNT(DISTINCT ${e})`;
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Build PostgreSQL SUM aggregation
|
|
599
|
-
* Extracted from multi-cube-builder.ts:282
|
|
600
|
-
*/
|
|
601
|
-
buildSum(e) {
|
|
602
|
-
return m`SUM(${e})`;
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* Build PostgreSQL AVG aggregation with COALESCE for NULL handling
|
|
606
|
-
* PostgreSQL AVG returns NULL for empty sets, so we use COALESCE for consistent behavior
|
|
607
|
-
* Extracted from multi-cube-builder.ts:284
|
|
608
|
-
*/
|
|
609
|
-
buildAvg(e) {
|
|
610
|
-
return m`COALESCE(AVG(${e}), 0)`;
|
|
611
|
-
}
|
|
612
|
-
/**
|
|
613
|
-
* Build PostgreSQL MIN aggregation
|
|
614
|
-
* Extracted from multi-cube-builder.ts:286
|
|
615
|
-
*/
|
|
616
|
-
buildMin(e) {
|
|
617
|
-
return m`MIN(${e})`;
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Build PostgreSQL MAX aggregation
|
|
621
|
-
* Extracted from multi-cube-builder.ts:288
|
|
622
|
-
*/
|
|
623
|
-
buildMax(e) {
|
|
624
|
-
return m`MAX(${e})`;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
class fn extends jt {
|
|
628
|
-
getEngineType() {
|
|
629
|
-
return "mysql";
|
|
630
|
-
}
|
|
631
|
-
/**
|
|
632
|
-
* Build MySQL time dimension using DATE_FORMAT function
|
|
633
|
-
* MySQL equivalent to PostgreSQL's DATE_TRUNC
|
|
634
|
-
*/
|
|
635
|
-
buildTimeDimension(e, t) {
|
|
636
|
-
const n = {
|
|
637
|
-
year: "%Y-01-01 00:00:00",
|
|
638
|
-
quarter: "%Y-%q-01 00:00:00",
|
|
639
|
-
// %q gives quarter (1,2,3,4), but we need to map this properly
|
|
640
|
-
month: "%Y-%m-01 00:00:00",
|
|
641
|
-
week: "%Y-%u-01 00:00:00",
|
|
642
|
-
// %u gives week of year
|
|
643
|
-
day: "%Y-%m-%d 00:00:00",
|
|
644
|
-
hour: "%Y-%m-%d %H:00:00",
|
|
645
|
-
minute: "%Y-%m-%d %H:%i:00",
|
|
646
|
-
second: "%Y-%m-%d %H:%i:%s"
|
|
647
|
-
};
|
|
648
|
-
switch (e) {
|
|
649
|
-
case "quarter":
|
|
650
|
-
return m`DATE_ADD(MAKEDATE(YEAR(${t}), 1), INTERVAL (QUARTER(${t}) - 1) * 3 MONTH)`;
|
|
651
|
-
case "week":
|
|
652
|
-
return m`DATE_SUB(${t}, INTERVAL WEEKDAY(${t}) DAY)`;
|
|
653
|
-
default:
|
|
654
|
-
const i = n[e];
|
|
655
|
-
return i ? m`STR_TO_DATE(DATE_FORMAT(${t}, ${i}), '%Y-%m-%d %H:%i:%s')` : t;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
/**
|
|
659
|
-
* Build MySQL string matching conditions using LIKE
|
|
660
|
-
* MySQL LIKE is case-insensitive by default (depending on collation)
|
|
661
|
-
* For guaranteed case-insensitive matching, we use LOWER() functions
|
|
662
|
-
*/
|
|
663
|
-
buildStringCondition(e, t, n) {
|
|
664
|
-
const i = this.buildPattern(t, n.toLowerCase());
|
|
665
|
-
switch (t) {
|
|
666
|
-
case "contains":
|
|
667
|
-
return m`LOWER(${e}) LIKE ${i}`;
|
|
668
|
-
case "notContains":
|
|
669
|
-
return m`LOWER(${e}) NOT LIKE ${i}`;
|
|
670
|
-
case "startsWith":
|
|
671
|
-
return m`LOWER(${e}) LIKE ${i}`;
|
|
672
|
-
case "endsWith":
|
|
673
|
-
return m`LOWER(${e}) LIKE ${i}`;
|
|
674
|
-
default:
|
|
675
|
-
throw new Error(`Unsupported string operator: ${t}`);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
/**
|
|
679
|
-
* Build MySQL type casting using CAST() function
|
|
680
|
-
* MySQL equivalent to PostgreSQL's :: casting syntax
|
|
681
|
-
*/
|
|
682
|
-
castToType(e, t) {
|
|
683
|
-
switch (t) {
|
|
684
|
-
case "timestamp":
|
|
685
|
-
return m`CAST(${e} AS DATETIME)`;
|
|
686
|
-
case "decimal":
|
|
687
|
-
return m`CAST(${e} AS DECIMAL(10,2))`;
|
|
688
|
-
case "integer":
|
|
689
|
-
return m`CAST(${e} AS SIGNED INTEGER)`;
|
|
690
|
-
default:
|
|
691
|
-
throw new Error(`Unsupported cast type: ${t}`);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Build MySQL COUNT aggregation
|
|
696
|
-
* Standard SQL COUNT function
|
|
697
|
-
*/
|
|
698
|
-
buildCount(e) {
|
|
699
|
-
return m`COUNT(${e})`;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Build MySQL COUNT DISTINCT aggregation
|
|
703
|
-
* Standard SQL COUNT DISTINCT function
|
|
704
|
-
*/
|
|
705
|
-
buildCountDistinct(e) {
|
|
706
|
-
return m`COUNT(DISTINCT ${e})`;
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Build MySQL SUM aggregation
|
|
710
|
-
* Standard SQL SUM function
|
|
711
|
-
*/
|
|
712
|
-
buildSum(e) {
|
|
713
|
-
return m`SUM(${e})`;
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* Build MySQL AVG aggregation with IFNULL for NULL handling
|
|
717
|
-
* MySQL AVG returns NULL for empty sets, using IFNULL for consistency
|
|
718
|
-
*/
|
|
719
|
-
buildAvg(e) {
|
|
720
|
-
return m`IFNULL(AVG(${e}), 0)`;
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* Build MySQL MIN aggregation
|
|
724
|
-
* Standard SQL MIN function
|
|
725
|
-
*/
|
|
726
|
-
buildMin(e) {
|
|
727
|
-
return m`MIN(${e})`;
|
|
728
|
-
}
|
|
729
|
-
/**
|
|
730
|
-
* Build MySQL MAX aggregation
|
|
731
|
-
* Standard SQL MAX function
|
|
732
|
-
*/
|
|
733
|
-
buildMax(e) {
|
|
734
|
-
return m`MAX(${e})`;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
function dn(s) {
|
|
738
|
-
switch (s) {
|
|
739
|
-
case "postgres":
|
|
740
|
-
return new cn();
|
|
741
|
-
case "mysql":
|
|
742
|
-
return new fn();
|
|
743
|
-
case "sqlite":
|
|
744
|
-
throw new Error("SQLite adapter not yet implemented");
|
|
745
|
-
default:
|
|
746
|
-
throw new Error(`Unsupported database engine: ${s}`);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
class Je {
|
|
750
|
-
constructor(e, t, n) {
|
|
751
|
-
g(this, "databaseAdapter");
|
|
752
|
-
this.db = e, this.schema = t;
|
|
753
|
-
const i = n || this.getEngineType();
|
|
754
|
-
this.databaseAdapter = dn(i);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
class mn extends Je {
|
|
758
|
-
async execute(e, t) {
|
|
759
|
-
if (e && typeof e == "object") {
|
|
760
|
-
if (typeof e.execute == "function") {
|
|
761
|
-
const i = await e.execute();
|
|
762
|
-
return Array.isArray(i) ? i.map((r) => this.convertNumericFields(r, t)) : i;
|
|
763
|
-
}
|
|
764
|
-
if (this.db && typeof this.db.execute == "function")
|
|
765
|
-
try {
|
|
766
|
-
const i = await this.db.execute(e);
|
|
767
|
-
return Array.isArray(i) ? i.map((r) => this.convertNumericFields(r, t)) : i;
|
|
768
|
-
} catch (i) {
|
|
769
|
-
if (typeof e.getSQL == "function") {
|
|
770
|
-
const r = e.getSQL(), o = await this.db.execute(r);
|
|
771
|
-
return Array.isArray(o) ? o.map((a) => this.convertNumericFields(a, t)) : o;
|
|
772
|
-
}
|
|
773
|
-
throw i;
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
if (!this.db.execute)
|
|
777
|
-
throw new Error("PostgreSQL database instance must have an execute method");
|
|
778
|
-
const n = await this.db.execute(e);
|
|
779
|
-
return Array.isArray(n) ? n.map((i) => this.convertNumericFields(i, t)) : n;
|
|
780
|
-
}
|
|
781
|
-
/**
|
|
782
|
-
* Convert numeric string fields to numbers (only for measure fields)
|
|
783
|
-
*/
|
|
784
|
-
convertNumericFields(e, t) {
|
|
785
|
-
if (!e || typeof e != "object") return e;
|
|
786
|
-
const n = {};
|
|
787
|
-
for (const [i, r] of Object.entries(e))
|
|
788
|
-
t && t.includes(i) ? n[i] = this.coerceToNumber(r) : n[i] = r;
|
|
789
|
-
return n;
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* Coerce a value to a number if it represents a numeric type
|
|
793
|
-
*/
|
|
794
|
-
coerceToNumber(e) {
|
|
795
|
-
var t, n;
|
|
796
|
-
if (e == null || typeof e == "number") return e;
|
|
797
|
-
if (typeof e == "bigint") return Number(e);
|
|
798
|
-
if (e && typeof e == "object") {
|
|
799
|
-
if (typeof e.toString == "function") {
|
|
800
|
-
const i = e.toString();
|
|
801
|
-
if (/^-?\d+(\.\d+)?$/.test(i))
|
|
802
|
-
return i.includes(".") ? parseFloat(i) : parseInt(i, 10);
|
|
803
|
-
}
|
|
804
|
-
if (((t = e.constructor) == null ? void 0 : t.name) === "Numeric" || ((n = e.constructor) == null ? void 0 : n.name) === "Decimal" || "digits" in e || "sign" in e) {
|
|
805
|
-
const i = e.toString();
|
|
806
|
-
return parseFloat(i);
|
|
807
|
-
}
|
|
808
|
-
return e;
|
|
809
|
-
}
|
|
810
|
-
if (typeof e == "string") {
|
|
811
|
-
if (/^-?\d+(\.\d+)?$/.test(e))
|
|
812
|
-
return e.includes(".") ? parseFloat(e) : parseInt(e, 10);
|
|
813
|
-
if (!isNaN(parseFloat(e)) && isFinite(parseFloat(e)))
|
|
814
|
-
return parseFloat(e);
|
|
815
|
-
}
|
|
816
|
-
return e;
|
|
817
|
-
}
|
|
818
|
-
getEngineType() {
|
|
819
|
-
return "postgres";
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
class hn extends Je {
|
|
823
|
-
async execute(e, t) {
|
|
824
|
-
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
825
|
-
const n = await e.execute();
|
|
826
|
-
return Array.isArray(n) ? n.map((i) => this.convertNumericFields(i, t)) : n;
|
|
827
|
-
}
|
|
828
|
-
try {
|
|
829
|
-
if (this.db.all) {
|
|
830
|
-
const n = this.db.all(e);
|
|
831
|
-
return Array.isArray(n) ? n.map((i) => this.convertNumericFields(i, t)) : n;
|
|
832
|
-
} else {
|
|
833
|
-
if (this.db.run)
|
|
834
|
-
return this.db.run(e);
|
|
835
|
-
throw new Error("SQLite database instance must have an all() or run() method");
|
|
836
|
-
}
|
|
837
|
-
} catch (n) {
|
|
838
|
-
throw new Error(`SQLite execution failed: ${n instanceof Error ? n.message : "Unknown error"}`);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
/**
|
|
842
|
-
* Convert numeric string fields to numbers (only for measure fields)
|
|
843
|
-
*/
|
|
844
|
-
convertNumericFields(e, t) {
|
|
845
|
-
if (!e || typeof e != "object") return e;
|
|
846
|
-
const n = {};
|
|
847
|
-
for (const [i, r] of Object.entries(e))
|
|
848
|
-
t && t.includes(i) ? n[i] = this.coerceToNumber(r) : n[i] = r;
|
|
849
|
-
return n;
|
|
850
|
-
}
|
|
851
|
-
/**
|
|
852
|
-
* Coerce a value to a number if it represents a numeric type
|
|
853
|
-
*/
|
|
854
|
-
coerceToNumber(e) {
|
|
855
|
-
if (e == null || typeof e == "number") return e;
|
|
856
|
-
if (typeof e == "string") {
|
|
857
|
-
if (/^-?\d+(\.\d+)?$/.test(e))
|
|
858
|
-
return e.includes(".") ? parseFloat(e) : parseInt(e, 10);
|
|
859
|
-
if (!isNaN(parseFloat(e)) && isFinite(parseFloat(e)))
|
|
860
|
-
return parseFloat(e);
|
|
861
|
-
}
|
|
862
|
-
return e;
|
|
863
|
-
}
|
|
864
|
-
getEngineType() {
|
|
865
|
-
return "sqlite";
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
class pn extends Je {
|
|
869
|
-
async execute(e, t) {
|
|
870
|
-
if (e && typeof e == "object" && typeof e.execute == "function") {
|
|
871
|
-
const i = await e.execute();
|
|
872
|
-
return Array.isArray(i) ? i.map((r) => this.convertNumericFields(r, t)) : i;
|
|
873
|
-
}
|
|
874
|
-
if (!this.db.execute)
|
|
875
|
-
throw new Error("MySQL database instance must have an execute method");
|
|
876
|
-
const n = await this.db.execute(e);
|
|
877
|
-
return Array.isArray(n) ? n.map((i) => this.convertNumericFields(i, t)) : n;
|
|
878
|
-
}
|
|
879
|
-
/**
|
|
880
|
-
* Convert numeric string fields to numbers (measure fields + numeric dimensions)
|
|
881
|
-
*/
|
|
882
|
-
convertNumericFields(e, t) {
|
|
883
|
-
if (!e || typeof e != "object") return e;
|
|
884
|
-
const n = {};
|
|
885
|
-
for (const [i, r] of Object.entries(e))
|
|
886
|
-
t && t.includes(i) ? n[i] = this.coerceToNumber(r) : n[i] = r;
|
|
887
|
-
return n;
|
|
888
|
-
}
|
|
889
|
-
/**
|
|
890
|
-
* Coerce a value to a number if it represents a numeric type
|
|
891
|
-
*/
|
|
892
|
-
coerceToNumber(e) {
|
|
893
|
-
if (e == null || typeof e == "number") return e;
|
|
894
|
-
if (typeof e == "string") {
|
|
895
|
-
if (/^-?\d+(\.\d+)?$/.test(e))
|
|
896
|
-
return e.includes(".") ? parseFloat(e) : parseInt(e, 10);
|
|
897
|
-
if (!isNaN(parseFloat(e)) && isFinite(parseFloat(e)))
|
|
898
|
-
return parseFloat(e);
|
|
899
|
-
}
|
|
900
|
-
return e;
|
|
901
|
-
}
|
|
902
|
-
getEngineType() {
|
|
903
|
-
return "mysql";
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
function et(s, e) {
|
|
907
|
-
return new mn(s, e, "postgres");
|
|
908
|
-
}
|
|
909
|
-
function tt(s, e) {
|
|
910
|
-
return new hn(s, e, "sqlite");
|
|
911
|
-
}
|
|
912
|
-
function bn(s, e) {
|
|
913
|
-
return new pn(s, e, "mysql");
|
|
914
|
-
}
|
|
915
|
-
function nt(s, e, t) {
|
|
916
|
-
if (t)
|
|
917
|
-
switch (t) {
|
|
918
|
-
case "postgres":
|
|
919
|
-
return et(s, e);
|
|
920
|
-
case "mysql":
|
|
921
|
-
return bn(s, e);
|
|
922
|
-
case "sqlite":
|
|
923
|
-
return tt(s, e);
|
|
924
|
-
}
|
|
925
|
-
if (s.all && s.run)
|
|
926
|
-
return tt(s, e);
|
|
927
|
-
if (s.execute)
|
|
928
|
-
return et(s, e);
|
|
929
|
-
throw new Error("Unable to determine database engine type. Please specify engineType parameter.");
|
|
930
|
-
}
|
|
931
|
-
function P(s, e) {
|
|
932
|
-
return typeof s == "function" ? s(e) : s;
|
|
933
|
-
}
|
|
934
|
-
function gn(s, e, t) {
|
|
935
|
-
return {
|
|
936
|
-
...s,
|
|
937
|
-
cubes: e,
|
|
938
|
-
currentCube: t
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
class yn {
|
|
942
|
-
constructor(e) {
|
|
943
|
-
this.databaseAdapter = e;
|
|
944
|
-
}
|
|
945
|
-
/**
|
|
946
|
-
* Set the database adapter (for use when not provided in constructor)
|
|
947
|
-
*/
|
|
948
|
-
setDatabaseAdapter(e) {
|
|
949
|
-
this.databaseAdapter = e;
|
|
950
|
-
}
|
|
951
|
-
/**
|
|
952
|
-
* Analyze a semantic query to determine which cubes are involved
|
|
953
|
-
*/
|
|
954
|
-
analyzeCubeUsage(e) {
|
|
955
|
-
const t = /* @__PURE__ */ new Set();
|
|
956
|
-
if (e.measures)
|
|
957
|
-
for (const n of e.measures) {
|
|
958
|
-
const [i] = n.split(".");
|
|
959
|
-
t.add(i);
|
|
960
|
-
}
|
|
961
|
-
if (e.dimensions)
|
|
962
|
-
for (const n of e.dimensions) {
|
|
963
|
-
const [i] = n.split(".");
|
|
964
|
-
t.add(i);
|
|
965
|
-
}
|
|
966
|
-
if (e.timeDimensions)
|
|
967
|
-
for (const n of e.timeDimensions) {
|
|
968
|
-
const [i] = n.dimension.split(".");
|
|
969
|
-
t.add(i);
|
|
970
|
-
}
|
|
971
|
-
return t;
|
|
972
|
-
}
|
|
973
|
-
/**
|
|
974
|
-
* Build a multi-cube query plan
|
|
975
|
-
*/
|
|
976
|
-
buildMultiCubeQueryPlan(e, t, n) {
|
|
977
|
-
const i = this.analyzeCubeUsage(t), r = Array.from(i);
|
|
978
|
-
if (r.length === 1)
|
|
979
|
-
throw new Error("Single cube query should use QueryExecutor directly");
|
|
980
|
-
const o = this.choosePrimaryCube(r, t), a = e.get(o);
|
|
981
|
-
if (!a)
|
|
982
|
-
throw new Error(`Primary cube '${o}' not found`);
|
|
983
|
-
const l = this.buildJoinPlan(e, a, r, n), u = this.buildMultiCubeSelections(e, t, n.securityContext), c = this.buildMultiCubeWhereConditions(e, t, n), f = this.buildMultiCubeGroupByFields(e, t, n.securityContext);
|
|
984
|
-
return {
|
|
985
|
-
primaryCube: a,
|
|
986
|
-
joinCubes: l,
|
|
987
|
-
selections: u,
|
|
988
|
-
whereConditions: c,
|
|
989
|
-
groupByFields: f
|
|
990
|
-
};
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Choose the primary cube based on query analysis
|
|
994
|
-
*/
|
|
995
|
-
choosePrimaryCube(e, t) {
|
|
996
|
-
if (t.measures && t.measures.length > 0) {
|
|
997
|
-
const [n] = t.measures[0].split(".");
|
|
998
|
-
return n;
|
|
999
|
-
}
|
|
1000
|
-
if (t.dimensions && t.dimensions.length > 0) {
|
|
1001
|
-
const [n] = t.dimensions[0].split(".");
|
|
1002
|
-
return n;
|
|
1003
|
-
}
|
|
1004
|
-
return e[0];
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* Build join plan for multi-cube query
|
|
1008
|
-
*/
|
|
1009
|
-
buildJoinPlan(e, t, n, i) {
|
|
1010
|
-
var a;
|
|
1011
|
-
const r = [], o = n.filter((l) => l !== t.name);
|
|
1012
|
-
for (const l of o) {
|
|
1013
|
-
const u = e.get(l);
|
|
1014
|
-
if (!u)
|
|
1015
|
-
throw new Error(`Cube '${l}' not found`);
|
|
1016
|
-
const c = (a = t.joins) == null ? void 0 : a[l];
|
|
1017
|
-
if (!c)
|
|
1018
|
-
throw new Error(`No join definition found from '${t.name}' to '${l}'`);
|
|
1019
|
-
const f = gn(
|
|
1020
|
-
i,
|
|
1021
|
-
e,
|
|
1022
|
-
u
|
|
1023
|
-
), d = c.condition(f);
|
|
1024
|
-
r.push({
|
|
1025
|
-
cube: u,
|
|
1026
|
-
alias: `${l.toLowerCase()}_cube`,
|
|
1027
|
-
joinType: c.type || "left",
|
|
1028
|
-
joinCondition: d
|
|
1029
|
-
});
|
|
1030
|
-
}
|
|
1031
|
-
return r;
|
|
1032
|
-
}
|
|
1033
|
-
/**
|
|
1034
|
-
* Build selections across multiple cubes
|
|
1035
|
-
*/
|
|
1036
|
-
buildMultiCubeSelections(e, t, n) {
|
|
1037
|
-
const i = {}, r = {
|
|
1038
|
-
db: {},
|
|
1039
|
-
// Filled during execution
|
|
1040
|
-
schema: {},
|
|
1041
|
-
// Filled during execution
|
|
1042
|
-
securityContext: n
|
|
1043
|
-
};
|
|
1044
|
-
if (t.dimensions)
|
|
1045
|
-
for (const o of t.dimensions) {
|
|
1046
|
-
const [a, l] = o.split("."), u = e.get(a);
|
|
1047
|
-
if (u && u.dimensions[l]) {
|
|
1048
|
-
const c = u.dimensions[l], f = P(c.sql, r);
|
|
1049
|
-
i[o] = m`${f}`.as(o);
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
if (t.measures)
|
|
1053
|
-
for (const o of t.measures) {
|
|
1054
|
-
const [a, l] = o.split("."), u = e.get(a);
|
|
1055
|
-
if (u && u.measures[l]) {
|
|
1056
|
-
const c = u.measures[l], f = this.buildMeasureExpression(c, r);
|
|
1057
|
-
i[o] = m`${f}`.as(o);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
if (t.timeDimensions)
|
|
1061
|
-
for (const o of t.timeDimensions) {
|
|
1062
|
-
const [a, l] = o.dimension.split("."), u = e.get(a);
|
|
1063
|
-
if (u && u.dimensions[l]) {
|
|
1064
|
-
const c = u.dimensions[l], f = this.buildTimeDimensionExpression(
|
|
1065
|
-
c.sql,
|
|
1066
|
-
o.granularity,
|
|
1067
|
-
r
|
|
1068
|
-
);
|
|
1069
|
-
i[o.dimension] = m`${f}`.as(o.dimension);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
return i;
|
|
1073
|
-
}
|
|
1074
|
-
/**
|
|
1075
|
-
* Build measure expression with aggregation (similar to single-cube approach)
|
|
1076
|
-
*/
|
|
1077
|
-
buildMeasureExpression(e, t) {
|
|
1078
|
-
let n = P(e.sql, t);
|
|
1079
|
-
if (e.filters && e.filters.length > 0) {
|
|
1080
|
-
const i = e.filters.map((r) => r(t));
|
|
1081
|
-
n = m`CASE WHEN ${j(...i)} THEN ${n} END`;
|
|
1082
|
-
}
|
|
1083
|
-
if (!this.databaseAdapter)
|
|
1084
|
-
throw new Error("DatabaseAdapter is required for measure aggregation");
|
|
1085
|
-
switch (e.type) {
|
|
1086
|
-
case "count":
|
|
1087
|
-
return this.databaseAdapter.buildCount(n);
|
|
1088
|
-
case "countDistinct":
|
|
1089
|
-
return this.databaseAdapter.buildCountDistinct(n);
|
|
1090
|
-
case "sum":
|
|
1091
|
-
return this.databaseAdapter.buildSum(n);
|
|
1092
|
-
case "avg":
|
|
1093
|
-
return this.databaseAdapter.buildAvg(n);
|
|
1094
|
-
case "min":
|
|
1095
|
-
return this.databaseAdapter.buildMin(n);
|
|
1096
|
-
case "max":
|
|
1097
|
-
return this.databaseAdapter.buildMax(n);
|
|
1098
|
-
case "number":
|
|
1099
|
-
return n;
|
|
1100
|
-
default:
|
|
1101
|
-
return this.databaseAdapter.buildCount(n);
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
/**
|
|
1105
|
-
* Build time dimension expression (similar to single-cube approach)
|
|
1106
|
-
*/
|
|
1107
|
-
buildTimeDimensionExpression(e, t, n) {
|
|
1108
|
-
const i = P(e, n);
|
|
1109
|
-
if (!t)
|
|
1110
|
-
return i;
|
|
1111
|
-
if (!this.databaseAdapter)
|
|
1112
|
-
throw new Error("DatabaseAdapter is required for time dimension building");
|
|
1113
|
-
return this.databaseAdapter.buildTimeDimension(t, i);
|
|
1114
|
-
}
|
|
1115
|
-
/**
|
|
1116
|
-
* Build WHERE conditions for multi-cube query
|
|
1117
|
-
*/
|
|
1118
|
-
buildMultiCubeWhereConditions(e, t, n) {
|
|
1119
|
-
const i = [];
|
|
1120
|
-
if (t.filters)
|
|
1121
|
-
for (const r of t.filters) {
|
|
1122
|
-
const o = this.processMultiCubeFilter(r, e, n);
|
|
1123
|
-
o && i.push(o);
|
|
1124
|
-
}
|
|
1125
|
-
if (t.timeDimensions) {
|
|
1126
|
-
for (const r of t.timeDimensions)
|
|
1127
|
-
if (r.dateRange) {
|
|
1128
|
-
const [o, a] = r.dimension.split("."), l = e.get(o);
|
|
1129
|
-
if (l && l.dimensions[a]) {
|
|
1130
|
-
const u = l.dimensions[a], c = P(u.sql, n), f = this.buildDateRangeCondition(c, r.dateRange);
|
|
1131
|
-
f && i.push(f);
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
return i;
|
|
1136
|
-
}
|
|
1137
|
-
/**
|
|
1138
|
-
* Process a single filter for multi-cube queries (handles logical and simple filters)
|
|
1139
|
-
*/
|
|
1140
|
-
processMultiCubeFilter(e, t, n) {
|
|
1141
|
-
if ("and" in e || "or" in e) {
|
|
1142
|
-
if (e.and) {
|
|
1143
|
-
const i = e.and.map((r) => this.processMultiCubeFilter(r, t, n)).filter((r) => r !== null);
|
|
1144
|
-
return i.length > 0 ? j(...i) : null;
|
|
1145
|
-
}
|
|
1146
|
-
if (e.or) {
|
|
1147
|
-
const i = e.or.map((r) => this.processMultiCubeFilter(r, t, n)).filter((r) => r !== null);
|
|
1148
|
-
return i.length > 0 ? Mt(...i) : null;
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
if ("member" in e) {
|
|
1152
|
-
const [i] = e.member.split("."), r = t.get(i);
|
|
1153
|
-
if (r)
|
|
1154
|
-
return this.buildFilterCondition(e, r, n);
|
|
1155
|
-
}
|
|
1156
|
-
return null;
|
|
1157
|
-
}
|
|
1158
|
-
/**
|
|
1159
|
-
* Filter condition builder with comprehensive operator support
|
|
1160
|
-
*/
|
|
1161
|
-
buildFilterCondition(e, t, n) {
|
|
1162
|
-
if (!e.member || !e.operator)
|
|
1163
|
-
return null;
|
|
1164
|
-
const [i, r] = e.member.split(".");
|
|
1165
|
-
if (i !== t.name)
|
|
1166
|
-
return null;
|
|
1167
|
-
const o = t.dimensions[r] || t.measures[r];
|
|
1168
|
-
if (!o)
|
|
1169
|
-
return null;
|
|
1170
|
-
const a = P(o.sql, n), u = (e.values || []).filter((f) => f != null);
|
|
1171
|
-
if (u.length === 0 && !["set", "notSet"].includes(e.operator))
|
|
1172
|
-
return null;
|
|
1173
|
-
const c = u[0];
|
|
1174
|
-
switch (e.operator) {
|
|
1175
|
-
case "equals":
|
|
1176
|
-
if (u.length === 0)
|
|
1177
|
-
return m`1 = 0`;
|
|
1178
|
-
if (u.length === 1) {
|
|
1179
|
-
const f = o.type === "time" && this.normalizeDate(c) || c;
|
|
1180
|
-
return Tt(a, f);
|
|
1181
|
-
} else if (o.type === "time") {
|
|
1182
|
-
const f = u.map((d) => this.normalizeDate(d) || d);
|
|
1183
|
-
return m`${a} IN (${m.join(f.map((d) => m`${d}`), m`, `)})`;
|
|
1184
|
-
} else
|
|
1185
|
-
return m`${a} IN (${m.join(u.map((f) => m`${f}`), m`, `)})`;
|
|
1186
|
-
case "notEquals":
|
|
1187
|
-
return u.length === 1 ? m`${a} <> ${c}` : u.length > 1 ? m`${a} NOT IN (${m.join(u.map((f) => m`${f}`), m`, `)})` : null;
|
|
1188
|
-
case "contains":
|
|
1189
|
-
if (!this.databaseAdapter)
|
|
1190
|
-
throw new Error("DatabaseAdapter is required for string conditions");
|
|
1191
|
-
return this.databaseAdapter.buildStringCondition(a, "contains", c);
|
|
1192
|
-
case "notContains":
|
|
1193
|
-
if (!this.databaseAdapter)
|
|
1194
|
-
throw new Error("DatabaseAdapter is required for string conditions");
|
|
1195
|
-
return this.databaseAdapter.buildStringCondition(a, "notContains", c);
|
|
1196
|
-
case "startsWith":
|
|
1197
|
-
if (!this.databaseAdapter)
|
|
1198
|
-
throw new Error("DatabaseAdapter is required for string conditions");
|
|
1199
|
-
return this.databaseAdapter.buildStringCondition(a, "startsWith", c);
|
|
1200
|
-
case "endsWith":
|
|
1201
|
-
if (!this.databaseAdapter)
|
|
1202
|
-
throw new Error("DatabaseAdapter is required for string conditions");
|
|
1203
|
-
return this.databaseAdapter.buildStringCondition(a, "endsWith", c);
|
|
1204
|
-
case "gt":
|
|
1205
|
-
return ge(a, c);
|
|
1206
|
-
case "gte":
|
|
1207
|
-
return R(a, c);
|
|
1208
|
-
case "lt":
|
|
1209
|
-
return ye(a, c);
|
|
1210
|
-
case "lte":
|
|
1211
|
-
return W(a, c);
|
|
1212
|
-
case "set":
|
|
1213
|
-
return Ft(a);
|
|
1214
|
-
case "notSet":
|
|
1215
|
-
return Lt(a);
|
|
1216
|
-
case "inDateRange":
|
|
1217
|
-
if (u.length >= 2) {
|
|
1218
|
-
const f = this.normalizeDate(u[0]), d = this.normalizeDate(u[1]);
|
|
1219
|
-
if (f && d)
|
|
1220
|
-
return j(
|
|
1221
|
-
R(a, f),
|
|
1222
|
-
W(a, d)
|
|
1223
|
-
);
|
|
1224
|
-
}
|
|
1225
|
-
return null;
|
|
1226
|
-
case "beforeDate": {
|
|
1227
|
-
const f = this.normalizeDate(c);
|
|
1228
|
-
return f ? ye(a, f) : null;
|
|
1229
|
-
}
|
|
1230
|
-
case "afterDate": {
|
|
1231
|
-
const f = this.normalizeDate(c);
|
|
1232
|
-
return f ? ge(a, f) : null;
|
|
1233
|
-
}
|
|
1234
|
-
default:
|
|
1235
|
-
return null;
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
/**
|
|
1239
|
-
* Build date range condition for time dimensions
|
|
1240
|
-
*/
|
|
1241
|
-
buildDateRangeCondition(e, t) {
|
|
1242
|
-
if (!t) return null;
|
|
1243
|
-
if (Array.isArray(t) && t.length >= 2) {
|
|
1244
|
-
const n = this.normalizeDate(t[0]), i = this.normalizeDate(t[1]);
|
|
1245
|
-
return !n || !i ? null : j(
|
|
1246
|
-
R(e, n),
|
|
1247
|
-
W(e, i)
|
|
1248
|
-
);
|
|
1249
|
-
}
|
|
1250
|
-
if (typeof t == "string") {
|
|
1251
|
-
const n = this.normalizeDate(t);
|
|
1252
|
-
if (!n) return null;
|
|
1253
|
-
const i = new Date(n);
|
|
1254
|
-
i.setUTCHours(0, 0, 0, 0);
|
|
1255
|
-
const r = new Date(n);
|
|
1256
|
-
return r.setUTCHours(23, 59, 59, 999), j(
|
|
1257
|
-
R(e, i),
|
|
1258
|
-
W(e, r)
|
|
1259
|
-
);
|
|
1260
|
-
}
|
|
1261
|
-
return null;
|
|
1262
|
-
}
|
|
1263
|
-
/**
|
|
1264
|
-
* Normalize date values to handle both string and Date objects
|
|
1265
|
-
* For PostgreSQL timestamp fields, Drizzle expects Date objects
|
|
1266
|
-
*/
|
|
1267
|
-
normalizeDate(e) {
|
|
1268
|
-
if (!e) return null;
|
|
1269
|
-
if (e instanceof Date)
|
|
1270
|
-
return isNaN(e.getTime()) ? null : e;
|
|
1271
|
-
if (typeof e == "string") {
|
|
1272
|
-
const t = new Date(e);
|
|
1273
|
-
return isNaN(t.getTime()) ? null : t;
|
|
1274
|
-
}
|
|
1275
|
-
try {
|
|
1276
|
-
const t = new Date(e);
|
|
1277
|
-
if (!isNaN(t.getTime()))
|
|
1278
|
-
return t;
|
|
1279
|
-
} catch {
|
|
1280
|
-
}
|
|
1281
|
-
return null;
|
|
1282
|
-
}
|
|
1283
|
-
/**
|
|
1284
|
-
* Build GROUP BY fields for multi-cube query
|
|
1285
|
-
*/
|
|
1286
|
-
buildMultiCubeGroupByFields(e, t, n) {
|
|
1287
|
-
const i = [];
|
|
1288
|
-
if (!(t.measures && t.measures.length > 0))
|
|
1289
|
-
return [];
|
|
1290
|
-
const o = {
|
|
1291
|
-
db: {},
|
|
1292
|
-
schema: {},
|
|
1293
|
-
securityContext: n
|
|
1294
|
-
};
|
|
1295
|
-
if (t.dimensions)
|
|
1296
|
-
for (const a of t.dimensions) {
|
|
1297
|
-
const [l, u] = a.split("."), c = e.get(l);
|
|
1298
|
-
if (c && c.dimensions[u]) {
|
|
1299
|
-
const f = c.dimensions[u], d = P(f.sql, o);
|
|
1300
|
-
i.push(d);
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
if (t.timeDimensions)
|
|
1304
|
-
for (const a of t.timeDimensions) {
|
|
1305
|
-
const [l, u] = a.dimension.split("."), c = e.get(l);
|
|
1306
|
-
if (c && c.dimensions[u]) {
|
|
1307
|
-
const f = c.dimensions[u], d = this.buildTimeDimensionExpression(
|
|
1308
|
-
f.sql,
|
|
1309
|
-
a.granularity,
|
|
1310
|
-
o
|
|
1311
|
-
);
|
|
1312
|
-
i.push(d);
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
return i;
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
class je {
|
|
1319
|
-
constructor(e) {
|
|
1320
|
-
g(this, "multiCubeBuilder");
|
|
1321
|
-
g(this, "databaseAdapter");
|
|
1322
|
-
if (this.dbExecutor = e, this.databaseAdapter = e.databaseAdapter, !this.databaseAdapter)
|
|
1323
|
-
throw new Error("DatabaseExecutor must have a databaseAdapter property");
|
|
1324
|
-
this.multiCubeBuilder = new yn(this.databaseAdapter);
|
|
1325
|
-
}
|
|
1326
|
-
/**
|
|
1327
|
-
* Unified query execution method that handles both single and multi-cube queries
|
|
1328
|
-
*/
|
|
1329
|
-
async execute(e, t, n) {
|
|
1330
|
-
try {
|
|
1331
|
-
const i = It(e, t);
|
|
1332
|
-
if (!i.isValid)
|
|
1333
|
-
throw new Error(`Query validation failed: ${i.errors.join(", ")}`);
|
|
1334
|
-
const r = this.multiCubeBuilder.analyzeCubeUsage(t);
|
|
1335
|
-
if (r.size === 0)
|
|
1336
|
-
throw new Error("No cubes found for query");
|
|
1337
|
-
if (r.size === 1) {
|
|
1338
|
-
const o = Array.from(r)[0], a = e.get(o);
|
|
1339
|
-
if (!a)
|
|
1340
|
-
throw new Error(`Cube '${o}' not found`);
|
|
1341
|
-
return this.executeSingleCube(a, t, n);
|
|
1342
|
-
} else
|
|
1343
|
-
return this.executeMultiCube(e, t, n);
|
|
1344
|
-
} catch (i) {
|
|
1345
|
-
throw new Error(`Query execution failed: ${i instanceof Error ? i.message : "Unknown error"}`);
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
/**
|
|
1349
|
-
* Legacy interface for single cube queries
|
|
1350
|
-
*/
|
|
1351
|
-
async executeQuery(e, t, n) {
|
|
1352
|
-
const i = /* @__PURE__ */ new Map();
|
|
1353
|
-
return i.set(e.name, e), this.execute(i, t, n);
|
|
1354
|
-
}
|
|
1355
|
-
/**
|
|
1356
|
-
* Execute a single cube query
|
|
1357
|
-
*/
|
|
1358
|
-
async executeSingleCube(e, t, n) {
|
|
1359
|
-
return this.executeCube(e, t, n);
|
|
1360
|
-
}
|
|
1361
|
-
/**
|
|
1362
|
-
* Execute a Cube query (dynamic query building)
|
|
1363
|
-
*/
|
|
1364
|
-
async executeCube(e, t, n) {
|
|
1365
|
-
try {
|
|
1366
|
-
const i = {
|
|
1367
|
-
db: this.dbExecutor.db,
|
|
1368
|
-
schema: this.dbExecutor.schema,
|
|
1369
|
-
securityContext: n
|
|
1370
|
-
}, r = e.sql(i), o = this.buildSelections(e, t, i);
|
|
1371
|
-
let a = i.db.select(o).from(r.from);
|
|
1372
|
-
if (r.joins)
|
|
1373
|
-
for (const h of r.joins)
|
|
1374
|
-
switch (h.type || "left") {
|
|
1375
|
-
case "left":
|
|
1376
|
-
a = a.leftJoin(h.table, h.on);
|
|
1377
|
-
break;
|
|
1378
|
-
case "inner":
|
|
1379
|
-
a = a.innerJoin(h.table, h.on);
|
|
1380
|
-
break;
|
|
1381
|
-
case "right":
|
|
1382
|
-
a = a.rightJoin(h.table, h.on);
|
|
1383
|
-
break;
|
|
1384
|
-
case "full":
|
|
1385
|
-
a = a.fullJoin(h.table, h.on);
|
|
1386
|
-
break;
|
|
1387
|
-
}
|
|
1388
|
-
r.where && (a = a.where(r.where));
|
|
1389
|
-
const l = this.buildWhereConditions(e, t, i);
|
|
1390
|
-
if (l.length > 0) {
|
|
1391
|
-
const h = l.length === 1 ? l[0] : j(...l);
|
|
1392
|
-
a = a.where(h);
|
|
1393
|
-
}
|
|
1394
|
-
const u = this.buildGroupByFields(e, t, i);
|
|
1395
|
-
u.length > 0 && (a = a.groupBy(...u));
|
|
1396
|
-
const c = this.buildOrderBy(t);
|
|
1397
|
-
c.length > 0 && (a = a.orderBy(...c)), a = this.applyLimitAndOffset(a, t);
|
|
1398
|
-
const f = this.collectNumericFields(e, t), d = await this.dbExecutor.execute(a, f), p = Array.isArray(d) ? d.map((h) => {
|
|
1399
|
-
const b = { ...h };
|
|
1400
|
-
if (t.timeDimensions) {
|
|
1401
|
-
for (const S of t.timeDimensions)
|
|
1402
|
-
if (S.dimension in b) {
|
|
1403
|
-
let w = b[S.dimension];
|
|
1404
|
-
typeof w == "string" && w.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/) && (w = w.replace(" ", "T"), !w.endsWith("Z") && !w.includes("+") && (w = w + "Z")), b[S.dimension] = w;
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
return b;
|
|
1408
|
-
}) : [d], y = this.generateAnnotations(e, t);
|
|
1409
|
-
return {
|
|
1410
|
-
data: p,
|
|
1411
|
-
annotation: y
|
|
1412
|
-
};
|
|
1413
|
-
} catch (i) {
|
|
1414
|
-
throw new Error(`Cube query execution failed: ${i instanceof Error ? i.message : "Unknown error"}`);
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
/**
|
|
1418
|
-
* Execute multi-cube query using JOIN resolution
|
|
1419
|
-
*/
|
|
1420
|
-
async executeMultiCube(e, t, n) {
|
|
1421
|
-
const i = this.buildMultiCubeQuery(e, t, n), r = this.collectNumericFieldsMultiCube(e, t), o = await this.dbExecutor.execute(i, r), a = {
|
|
1422
|
-
db: this.dbExecutor.db,
|
|
1423
|
-
schema: this.dbExecutor.schema,
|
|
1424
|
-
securityContext: n
|
|
1425
|
-
}, l = this.multiCubeBuilder.buildMultiCubeQueryPlan(e, t, a), u = this.generateMultiCubeAnnotations(l, t);
|
|
1426
|
-
return {
|
|
1427
|
-
data: Array.isArray(o) ? o : [o],
|
|
1428
|
-
annotation: u
|
|
1429
|
-
};
|
|
1430
|
-
}
|
|
1431
|
-
/**
|
|
1432
|
-
* Generate raw SQL for debugging (without execution)
|
|
1433
|
-
*/
|
|
1434
|
-
async generateSQL(e, t, n) {
|
|
1435
|
-
return this.generateCubeSQL(e, t, n);
|
|
1436
|
-
}
|
|
1437
|
-
/**
|
|
1438
|
-
* Generate raw SQL for multi-cube queries without execution
|
|
1439
|
-
*/
|
|
1440
|
-
async generateMultiCubeSQL(e, t, n) {
|
|
1441
|
-
const r = this.buildMultiCubeQuery(e, t, n).toSQL();
|
|
1442
|
-
return {
|
|
1443
|
-
sql: r.sql,
|
|
1444
|
-
params: r.params
|
|
1445
|
-
};
|
|
1446
|
-
}
|
|
1447
|
-
/**
|
|
1448
|
-
* Build multi-cube query (extracted from executeMultiCube for reuse)
|
|
1449
|
-
*/
|
|
1450
|
-
buildMultiCubeQuery(e, t, n) {
|
|
1451
|
-
const i = {
|
|
1452
|
-
db: this.dbExecutor.db,
|
|
1453
|
-
schema: this.dbExecutor.schema,
|
|
1454
|
-
securityContext: n
|
|
1455
|
-
}, r = this.multiCubeBuilder.buildMultiCubeQueryPlan(e, t, i), o = r.primaryCube.sql(i);
|
|
1456
|
-
let a = i.db.select(r.selections).from(o.from);
|
|
1457
|
-
if (o.joins)
|
|
1458
|
-
for (const c of o.joins)
|
|
1459
|
-
switch (c.type || "left") {
|
|
1460
|
-
case "left":
|
|
1461
|
-
a = a.leftJoin(c.table, c.on);
|
|
1462
|
-
break;
|
|
1463
|
-
case "inner":
|
|
1464
|
-
a = a.innerJoin(c.table, c.on);
|
|
1465
|
-
break;
|
|
1466
|
-
case "right":
|
|
1467
|
-
a = a.rightJoin(c.table, c.on);
|
|
1468
|
-
break;
|
|
1469
|
-
case "full":
|
|
1470
|
-
a = a.fullJoin(c.table, c.on);
|
|
1471
|
-
break;
|
|
1472
|
-
default:
|
|
1473
|
-
a = a.leftJoin(c.table, c.on);
|
|
1474
|
-
}
|
|
1475
|
-
if (r.joinCubes && r.joinCubes.length > 0)
|
|
1476
|
-
for (const c of r.joinCubes) {
|
|
1477
|
-
const f = c.cube.sql(i);
|
|
1478
|
-
try {
|
|
1479
|
-
switch (c.joinType || "left") {
|
|
1480
|
-
case "left":
|
|
1481
|
-
a = a.leftJoin(f.from, c.joinCondition);
|
|
1482
|
-
break;
|
|
1483
|
-
case "inner":
|
|
1484
|
-
a = a.innerJoin(f.from, c.joinCondition);
|
|
1485
|
-
break;
|
|
1486
|
-
case "right":
|
|
1487
|
-
a = a.rightJoin(f.from, c.joinCondition);
|
|
1488
|
-
break;
|
|
1489
|
-
case "full":
|
|
1490
|
-
a = a.fullJoin(f.from, c.joinCondition);
|
|
1491
|
-
break;
|
|
1492
|
-
}
|
|
1493
|
-
} catch (d) {
|
|
1494
|
-
console.warn(`Multi-cube join failed for ${c.cube.name}: ${d instanceof Error ? d.message : "Unknown error"}`);
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
const l = [];
|
|
1498
|
-
if (o.where && l.push(o.where), r.whereConditions.length > 0 && l.push(...r.whereConditions), l.length > 0) {
|
|
1499
|
-
const c = l.length === 1 ? l[0] : j(...l);
|
|
1500
|
-
a = a.where(c);
|
|
1501
|
-
}
|
|
1502
|
-
r.groupByFields.length > 0 && (a = a.groupBy(...r.groupByFields));
|
|
1503
|
-
const u = this.buildOrderBy(t);
|
|
1504
|
-
return u.length > 0 && (a = a.orderBy(...u)), a = this.applyLimitAndOffset(a, t), a;
|
|
1505
|
-
}
|
|
1506
|
-
/**
|
|
1507
|
-
* Collect numeric field names (measures + numeric dimensions) for type conversion
|
|
1508
|
-
*/
|
|
1509
|
-
collectNumericFields(e, t) {
|
|
1510
|
-
const n = [];
|
|
1511
|
-
if (t.measures && n.push(...t.measures), t.dimensions)
|
|
1512
|
-
for (const i of t.dimensions) {
|
|
1513
|
-
const r = i.includes(".") ? i.split(".")[1] : i, o = e.dimensions[r];
|
|
1514
|
-
o && o.type === "number" && n.push(i);
|
|
1515
|
-
}
|
|
1516
|
-
return n;
|
|
1517
|
-
}
|
|
1518
|
-
/**
|
|
1519
|
-
* Collect numeric field names for multi-cube queries
|
|
1520
|
-
*/
|
|
1521
|
-
collectNumericFieldsMultiCube(e, t) {
|
|
1522
|
-
const n = [];
|
|
1523
|
-
if (t.measures && n.push(...t.measures), t.dimensions)
|
|
1524
|
-
for (const i of t.dimensions) {
|
|
1525
|
-
const r = i.includes(".") ? i.split(".")[1] : i;
|
|
1526
|
-
for (const o of e.values()) {
|
|
1527
|
-
const a = o.dimensions[r];
|
|
1528
|
-
if (a && a.type === "number") {
|
|
1529
|
-
n.push(i);
|
|
1530
|
-
break;
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
return n;
|
|
1535
|
-
}
|
|
1536
|
-
/**
|
|
1537
|
-
* Apply LIMIT and OFFSET to a query with validation
|
|
1538
|
-
* If offset is provided without limit, add a reasonable default limit
|
|
1539
|
-
*/
|
|
1540
|
-
applyLimitAndOffset(e, t) {
|
|
1541
|
-
let n = t.limit;
|
|
1542
|
-
t.offset !== void 0 && t.offset > 0 && n === void 0 && (n = 50);
|
|
1543
|
-
let i = e;
|
|
1544
|
-
if (n !== void 0) {
|
|
1545
|
-
if (n < 0)
|
|
1546
|
-
throw new Error("Limit must be non-negative");
|
|
1547
|
-
i = i.limit(n);
|
|
1548
|
-
}
|
|
1549
|
-
if (t.offset !== void 0) {
|
|
1550
|
-
if (t.offset < 0)
|
|
1551
|
-
throw new Error("Offset must be non-negative");
|
|
1552
|
-
i = i.offset(t.offset);
|
|
1553
|
-
}
|
|
1554
|
-
return i;
|
|
1555
|
-
}
|
|
1556
|
-
/**
|
|
1557
|
-
* Generate SQL for Cube
|
|
1558
|
-
*/
|
|
1559
|
-
async generateCubeSQL(e, t, n) {
|
|
1560
|
-
const i = {
|
|
1561
|
-
db: this.dbExecutor.db,
|
|
1562
|
-
schema: this.dbExecutor.schema,
|
|
1563
|
-
securityContext: n
|
|
1564
|
-
}, r = e.sql(i), o = this.buildSelections(e, t, i);
|
|
1565
|
-
let a = i.db.select(o).from(r.from);
|
|
1566
|
-
if (r.joins)
|
|
1567
|
-
for (const d of r.joins)
|
|
1568
|
-
switch (d.type || "left") {
|
|
1569
|
-
case "left":
|
|
1570
|
-
a = a.leftJoin(d.table, d.on);
|
|
1571
|
-
break;
|
|
1572
|
-
case "inner":
|
|
1573
|
-
a = a.innerJoin(d.table, d.on);
|
|
1574
|
-
break;
|
|
1575
|
-
case "right":
|
|
1576
|
-
a = a.rightJoin(d.table, d.on);
|
|
1577
|
-
break;
|
|
1578
|
-
case "full":
|
|
1579
|
-
a = a.fullJoin(d.table, d.on);
|
|
1580
|
-
break;
|
|
1581
|
-
}
|
|
1582
|
-
r.where && (a = a.where(r.where));
|
|
1583
|
-
const l = this.buildWhereConditions(e, t, i);
|
|
1584
|
-
if (l.length > 0) {
|
|
1585
|
-
const d = l.length === 1 ? l[0] : j(...l);
|
|
1586
|
-
a = a.where(d);
|
|
1587
|
-
}
|
|
1588
|
-
const u = this.buildGroupByFields(e, t, i);
|
|
1589
|
-
u.length > 0 && (a = a.groupBy(...u));
|
|
1590
|
-
const c = this.buildOrderBy(t);
|
|
1591
|
-
if (c.length > 0 && (a = a.orderBy(...c)), t.limit !== void 0) {
|
|
1592
|
-
if (t.limit < 0)
|
|
1593
|
-
throw new Error("Limit must be non-negative");
|
|
1594
|
-
a = a.limit(t.limit);
|
|
1595
|
-
}
|
|
1596
|
-
if (t.offset !== void 0) {
|
|
1597
|
-
if (t.offset < 0)
|
|
1598
|
-
throw new Error("Offset must be non-negative");
|
|
1599
|
-
a = a.offset(t.offset);
|
|
1600
|
-
}
|
|
1601
|
-
const f = a.toSQL();
|
|
1602
|
-
return {
|
|
1603
|
-
sql: f.sql,
|
|
1604
|
-
params: f.params
|
|
1605
|
-
};
|
|
1606
|
-
}
|
|
1607
|
-
/**
|
|
1608
|
-
* Build dynamic selections for Cube measures and dimensions
|
|
1609
|
-
*/
|
|
1610
|
-
buildSelections(e, t, n) {
|
|
1611
|
-
const i = {};
|
|
1612
|
-
if (t.dimensions)
|
|
1613
|
-
for (const r of t.dimensions) {
|
|
1614
|
-
const [o, a] = r.split(".");
|
|
1615
|
-
if (o === e.name && e.dimensions[a]) {
|
|
1616
|
-
const l = e.dimensions[a], u = P(l.sql, n);
|
|
1617
|
-
i[r] = m`${u}`.as(r);
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
if (t.measures)
|
|
1621
|
-
for (const r of t.measures) {
|
|
1622
|
-
const [o, a] = r.split(".");
|
|
1623
|
-
if (o === e.name && e.measures[a]) {
|
|
1624
|
-
const l = e.measures[a], u = this.buildMeasureExpression(l, n);
|
|
1625
|
-
i[r] = m`${u}`.as(r);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
if (t.timeDimensions)
|
|
1629
|
-
for (const r of t.timeDimensions) {
|
|
1630
|
-
const [o, a] = r.dimension.split(".");
|
|
1631
|
-
if (o === e.name && e.dimensions[a]) {
|
|
1632
|
-
const l = e.dimensions[a], u = this.buildTimeDimensionExpression(
|
|
1633
|
-
l.sql,
|
|
1634
|
-
r.granularity,
|
|
1635
|
-
n
|
|
1636
|
-
);
|
|
1637
|
-
i[r.dimension] = m`${u}`.as(r.dimension);
|
|
1638
|
-
}
|
|
1639
|
-
}
|
|
1640
|
-
return Object.keys(i).length === 0 && (i.count = Fe()), i;
|
|
1641
|
-
}
|
|
1642
|
-
/**
|
|
1643
|
-
* Build measure expression with aggregation and filters for Cube
|
|
1644
|
-
*/
|
|
1645
|
-
buildMeasureExpression(e, t) {
|
|
1646
|
-
let n = P(e.sql, t);
|
|
1647
|
-
if (e.filters && e.filters.length > 0) {
|
|
1648
|
-
const i = e.filters.map((r) => r(t));
|
|
1649
|
-
n = m`CASE WHEN ${j(...i)} THEN ${n} END`;
|
|
1650
|
-
}
|
|
1651
|
-
switch (e.type) {
|
|
1652
|
-
case "count":
|
|
1653
|
-
return Fe(n);
|
|
1654
|
-
case "countDistinct":
|
|
1655
|
-
return rn(n);
|
|
1656
|
-
case "sum":
|
|
1657
|
-
return an(n);
|
|
1658
|
-
case "avg":
|
|
1659
|
-
return on(n);
|
|
1660
|
-
case "min":
|
|
1661
|
-
return un(n);
|
|
1662
|
-
case "max":
|
|
1663
|
-
return ln(n);
|
|
1664
|
-
case "number":
|
|
1665
|
-
return n;
|
|
1666
|
-
default:
|
|
1667
|
-
return Fe(n);
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
/**
|
|
1671
|
-
* Build time dimension expression with granularity using database adapter
|
|
1672
|
-
*/
|
|
1673
|
-
buildTimeDimensionExpression(e, t, n) {
|
|
1674
|
-
const i = P(e, n);
|
|
1675
|
-
return t ? this.databaseAdapter.buildTimeDimension(t, i) : m`${i}`;
|
|
1676
|
-
}
|
|
1677
|
-
/**
|
|
1678
|
-
* Build WHERE conditions from semantic query filters (Cube)
|
|
1679
|
-
*/
|
|
1680
|
-
buildWhereConditions(e, t, n) {
|
|
1681
|
-
const i = [];
|
|
1682
|
-
if (t.filters && t.filters.length > 0)
|
|
1683
|
-
for (const r of t.filters) {
|
|
1684
|
-
const o = this.processFilter(r, e, n);
|
|
1685
|
-
o && i.push(o);
|
|
1686
|
-
}
|
|
1687
|
-
if (t.timeDimensions)
|
|
1688
|
-
for (const r of t.timeDimensions) {
|
|
1689
|
-
const [o, a] = r.dimension.split(".");
|
|
1690
|
-
if (o === e.name && e.dimensions[a] && r.dateRange) {
|
|
1691
|
-
const l = e.dimensions[a], u = P(l.sql, n), c = this.buildDateRangeCondition(u, r.dateRange);
|
|
1692
|
-
c && i.push(c);
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
return i;
|
|
1696
|
-
}
|
|
1697
|
-
/**
|
|
1698
|
-
* Process a single filter for Cube (basic or logical)
|
|
1699
|
-
*/
|
|
1700
|
-
processFilter(e, t, n) {
|
|
1701
|
-
if ("and" in e || "or" in e) {
|
|
1702
|
-
const u = e;
|
|
1703
|
-
if (u.and) {
|
|
1704
|
-
const c = u.and.map((f) => this.processFilter(f, t, n)).filter((f) => f !== null);
|
|
1705
|
-
return c.length > 0 ? j(...c) : null;
|
|
1706
|
-
}
|
|
1707
|
-
if (u.or) {
|
|
1708
|
-
const c = u.or.map((f) => this.processFilter(f, t, n)).filter((f) => f !== null);
|
|
1709
|
-
return c.length > 0 ? Mt(...c) : null;
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
const i = e, [r, o] = i.member.split(".");
|
|
1713
|
-
if (r !== t.name) return null;
|
|
1714
|
-
const a = t.dimensions[o] || t.measures[o];
|
|
1715
|
-
if (!a) return null;
|
|
1716
|
-
const l = P(a.sql, n);
|
|
1717
|
-
return this.buildFilterCondition(l, i.operator, i.values);
|
|
1718
|
-
}
|
|
1719
|
-
/**
|
|
1720
|
-
* Build filter condition using Drizzle operators
|
|
1721
|
-
*/
|
|
1722
|
-
buildFilterCondition(e, t, n) {
|
|
1723
|
-
if (!n || n.length === 0)
|
|
1724
|
-
return t === "equals" ? m`FALSE` : null;
|
|
1725
|
-
const i = n.filter((o) => !(o == null || o === "" || typeof o == "string" && o.includes("\0")));
|
|
1726
|
-
if (i.length === 0 && !["set", "notSet"].includes(t))
|
|
1727
|
-
return t === "equals" ? m`FALSE` : null;
|
|
1728
|
-
const r = i[0];
|
|
1729
|
-
switch (t) {
|
|
1730
|
-
case "equals":
|
|
1731
|
-
return i.length > 1 ? nn(e, i) : i.length === 1 ? Tt(e, r) : m`FALSE`;
|
|
1732
|
-
case "notEquals":
|
|
1733
|
-
return i.length > 1 ? sn(e, i) : i.length === 1 ? tn(e, r) : null;
|
|
1734
|
-
case "contains":
|
|
1735
|
-
return this.databaseAdapter.buildStringCondition(e, "contains", r);
|
|
1736
|
-
case "notContains":
|
|
1737
|
-
return this.databaseAdapter.buildStringCondition(e, "notContains", r);
|
|
1738
|
-
case "startsWith":
|
|
1739
|
-
return this.databaseAdapter.buildStringCondition(e, "startsWith", r);
|
|
1740
|
-
case "endsWith":
|
|
1741
|
-
return this.databaseAdapter.buildStringCondition(e, "endsWith", r);
|
|
1742
|
-
case "gt":
|
|
1743
|
-
return ge(e, r);
|
|
1744
|
-
case "gte":
|
|
1745
|
-
return R(e, r);
|
|
1746
|
-
case "lt":
|
|
1747
|
-
return ye(e, r);
|
|
1748
|
-
case "lte":
|
|
1749
|
-
return W(e, r);
|
|
1750
|
-
case "set":
|
|
1751
|
-
return Ft(e);
|
|
1752
|
-
case "notSet":
|
|
1753
|
-
return Lt(e);
|
|
1754
|
-
case "inDateRange":
|
|
1755
|
-
if (i.length >= 2) {
|
|
1756
|
-
const o = this.normalizeDate(i[0]), a = this.normalizeDate(i[1]);
|
|
1757
|
-
if (o && a)
|
|
1758
|
-
return j(
|
|
1759
|
-
R(e, o),
|
|
1760
|
-
W(e, a)
|
|
1761
|
-
);
|
|
1762
|
-
}
|
|
1763
|
-
return null;
|
|
1764
|
-
case "beforeDate": {
|
|
1765
|
-
const o = this.normalizeDate(r);
|
|
1766
|
-
return o ? ye(e, o) : null;
|
|
1767
|
-
}
|
|
1768
|
-
case "afterDate": {
|
|
1769
|
-
const o = this.normalizeDate(r);
|
|
1770
|
-
return o ? ge(e, o) : null;
|
|
1771
|
-
}
|
|
1772
|
-
default:
|
|
1773
|
-
return null;
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
/**
|
|
1777
|
-
* Build date range condition for time dimensions
|
|
1778
|
-
*/
|
|
1779
|
-
buildDateRangeCondition(e, t) {
|
|
1780
|
-
if (!t) return null;
|
|
1781
|
-
if (Array.isArray(t) && t.length >= 2) {
|
|
1782
|
-
const n = this.normalizeDate(t[0]), i = this.normalizeDate(t[1]);
|
|
1783
|
-
return !n || !i ? null : j(
|
|
1784
|
-
R(e, n),
|
|
1785
|
-
W(e, i)
|
|
1786
|
-
);
|
|
1787
|
-
}
|
|
1788
|
-
if (typeof t == "string") {
|
|
1789
|
-
const n = this.parseRelativeDateRange(t);
|
|
1790
|
-
if (n)
|
|
1791
|
-
return j(
|
|
1792
|
-
R(e, n.start),
|
|
1793
|
-
W(e, n.end)
|
|
1794
|
-
);
|
|
1795
|
-
const i = this.normalizeDate(t);
|
|
1796
|
-
if (!i) return null;
|
|
1797
|
-
const r = new Date(i);
|
|
1798
|
-
r.setUTCHours(0, 0, 0, 0);
|
|
1799
|
-
const o = new Date(i);
|
|
1800
|
-
return o.setUTCHours(23, 59, 59, 999), j(
|
|
1801
|
-
R(e, r),
|
|
1802
|
-
W(e, o)
|
|
1803
|
-
);
|
|
1804
|
-
}
|
|
1805
|
-
return null;
|
|
1806
|
-
}
|
|
1807
|
-
/**
|
|
1808
|
-
* Parse relative date range expressions like "last 7 days", "this month"
|
|
1809
|
-
*/
|
|
1810
|
-
parseRelativeDateRange(e) {
|
|
1811
|
-
const t = /* @__PURE__ */ new Date(), n = e.toLowerCase().trim(), i = n.match(/^last\s+(\d+)\s+days?$/);
|
|
1812
|
-
if (i) {
|
|
1813
|
-
const a = parseInt(i[1], 10), l = new Date(t);
|
|
1814
|
-
l.setDate(t.getDate() - a), l.setHours(0, 0, 0, 0);
|
|
1815
|
-
const u = new Date(t);
|
|
1816
|
-
return u.setHours(23, 59, 59, 999), { start: l, end: u };
|
|
1817
|
-
}
|
|
1818
|
-
if (n === "this month") {
|
|
1819
|
-
const a = new Date(t.getFullYear(), t.getMonth(), 1, 0, 0, 0, 0), l = new Date(t.getFullYear(), t.getMonth() + 1, 0, 23, 59, 59, 999);
|
|
1820
|
-
return { start: a, end: l };
|
|
1821
|
-
}
|
|
1822
|
-
const r = n.match(/^last\s+(\d+)\s+months?$/);
|
|
1823
|
-
if (r) {
|
|
1824
|
-
const a = parseInt(r[1], 10), l = new Date(t.getFullYear(), t.getMonth() - a, 1, 0, 0, 0, 0), u = new Date(t);
|
|
1825
|
-
return u.setHours(23, 59, 59, 999), { start: l, end: u };
|
|
1826
|
-
}
|
|
1827
|
-
if (n === "this year") {
|
|
1828
|
-
const a = new Date(t.getFullYear(), 0, 1, 0, 0, 0, 0), l = new Date(t.getFullYear(), 11, 31, 23, 59, 59, 999);
|
|
1829
|
-
return { start: a, end: l };
|
|
1830
|
-
}
|
|
1831
|
-
const o = n.match(/^last\s+(\d+)\s+years?$/);
|
|
1832
|
-
if (o) {
|
|
1833
|
-
const a = parseInt(o[1], 10), l = new Date(t.getFullYear() - a, 0, 1, 0, 0, 0, 0), u = new Date(t);
|
|
1834
|
-
return u.setHours(23, 59, 59, 999), { start: l, end: u };
|
|
1835
|
-
}
|
|
1836
|
-
return null;
|
|
1837
|
-
}
|
|
1838
|
-
/**
|
|
1839
|
-
* Normalize date values to handle both string and Date objects
|
|
1840
|
-
* For PostgreSQL timestamp fields, Drizzle expects Date objects
|
|
1841
|
-
*/
|
|
1842
|
-
normalizeDate(e) {
|
|
1843
|
-
if (!e) return null;
|
|
1844
|
-
if (e instanceof Date)
|
|
1845
|
-
return isNaN(e.getTime()) ? null : e;
|
|
1846
|
-
if (typeof e == "string") {
|
|
1847
|
-
const n = new Date(e);
|
|
1848
|
-
return isNaN(n.getTime()) ? null : n;
|
|
1849
|
-
}
|
|
1850
|
-
const t = new Date(e);
|
|
1851
|
-
return isNaN(t.getTime()) ? null : t;
|
|
1852
|
-
}
|
|
1853
|
-
/**
|
|
1854
|
-
* Build GROUP BY fields from dimensions and time dimensions (Cube)
|
|
1855
|
-
*/
|
|
1856
|
-
buildGroupByFields(e, t, n) {
|
|
1857
|
-
const i = [];
|
|
1858
|
-
if (t.dimensions)
|
|
1859
|
-
for (const r of t.dimensions) {
|
|
1860
|
-
const [o, a] = r.split(".");
|
|
1861
|
-
if (o === e.name && e.dimensions[a]) {
|
|
1862
|
-
const l = e.dimensions[a], u = P(l.sql, n);
|
|
1863
|
-
i.push(u);
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
if (t.timeDimensions)
|
|
1867
|
-
for (const r of t.timeDimensions) {
|
|
1868
|
-
const [o, a] = r.dimension.split(".");
|
|
1869
|
-
if (o === e.name && e.dimensions[a]) {
|
|
1870
|
-
const l = e.dimensions[a], u = this.buildTimeDimensionExpression(
|
|
1871
|
-
l.sql,
|
|
1872
|
-
r.granularity,
|
|
1873
|
-
n
|
|
1874
|
-
);
|
|
1875
|
-
i.push(u);
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
return i;
|
|
1879
|
-
}
|
|
1880
|
-
/**
|
|
1881
|
-
* Build ORDER BY clause with automatic time dimension sorting
|
|
1882
|
-
*/
|
|
1883
|
-
buildOrderBy(e, t) {
|
|
1884
|
-
var r;
|
|
1885
|
-
const n = [], i = t || [
|
|
1886
|
-
...e.measures || [],
|
|
1887
|
-
...e.dimensions || [],
|
|
1888
|
-
...((r = e.timeDimensions) == null ? void 0 : r.map((o) => o.dimension)) || []
|
|
1889
|
-
];
|
|
1890
|
-
if (e.order && Object.keys(e.order).length > 0)
|
|
1891
|
-
for (const [o, a] of Object.entries(e.order)) {
|
|
1892
|
-
if (!i.includes(o))
|
|
1893
|
-
throw new Error(`Cannot order by '${o}': field is not selected in the query`);
|
|
1894
|
-
const l = a === "desc" ? m`DESC` : m`ASC`;
|
|
1895
|
-
n.push(m`${m.identifier(o)} ${l}`);
|
|
1896
|
-
}
|
|
1897
|
-
if (e.timeDimensions && e.timeDimensions.length > 0) {
|
|
1898
|
-
const o = new Set(Object.keys(e.order || {})), a = [...e.timeDimensions].sort(
|
|
1899
|
-
(l, u) => l.dimension.localeCompare(u.dimension)
|
|
1900
|
-
);
|
|
1901
|
-
for (const l of a)
|
|
1902
|
-
o.has(l.dimension) || n.push(m`${m.identifier(l.dimension)} ASC`);
|
|
1903
|
-
}
|
|
1904
|
-
return n;
|
|
1905
|
-
}
|
|
1906
|
-
/**
|
|
1907
|
-
* Generate annotations for UI metadata
|
|
1908
|
-
*/
|
|
1909
|
-
generateAnnotations(e, t) {
|
|
1910
|
-
const n = {}, i = {}, r = {};
|
|
1911
|
-
if (t.measures)
|
|
1912
|
-
for (const o of t.measures) {
|
|
1913
|
-
const [a, l] = o.split(".");
|
|
1914
|
-
if (a === e.name && e.measures[l]) {
|
|
1915
|
-
const u = e.measures[l];
|
|
1916
|
-
n[o] = {
|
|
1917
|
-
title: u.title || l,
|
|
1918
|
-
shortTitle: u.title || l,
|
|
1919
|
-
type: u.type
|
|
1920
|
-
};
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
if (t.dimensions)
|
|
1924
|
-
for (const o of t.dimensions) {
|
|
1925
|
-
const [a, l] = o.split(".");
|
|
1926
|
-
if (a === e.name && e.dimensions[l]) {
|
|
1927
|
-
const u = e.dimensions[l];
|
|
1928
|
-
i[o] = {
|
|
1929
|
-
title: u.title || l,
|
|
1930
|
-
shortTitle: u.title || l,
|
|
1931
|
-
type: u.type
|
|
1932
|
-
};
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
if (t.timeDimensions)
|
|
1936
|
-
for (const o of t.timeDimensions) {
|
|
1937
|
-
const [a, l] = o.dimension.split(".");
|
|
1938
|
-
if (a === e.name && e.dimensions[l]) {
|
|
1939
|
-
const u = e.dimensions[l];
|
|
1940
|
-
r[o.dimension] = {
|
|
1941
|
-
title: u.title || l,
|
|
1942
|
-
shortTitle: u.title || l,
|
|
1943
|
-
type: u.type,
|
|
1944
|
-
granularity: o.granularity
|
|
1945
|
-
};
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
return {
|
|
1949
|
-
measures: n,
|
|
1950
|
-
dimensions: i,
|
|
1951
|
-
segments: {},
|
|
1952
|
-
timeDimensions: r
|
|
1953
|
-
};
|
|
1954
|
-
}
|
|
1955
|
-
/**
|
|
1956
|
-
* Generate annotations for multi-cube queries
|
|
1957
|
-
*/
|
|
1958
|
-
generateMultiCubeAnnotations(e, t) {
|
|
1959
|
-
const n = {}, i = {}, r = {}, o = [e.primaryCube];
|
|
1960
|
-
if (e.joinCubes && o.push(...e.joinCubes.map((a) => a.cube)), t.measures)
|
|
1961
|
-
for (const a of t.measures) {
|
|
1962
|
-
const [l, u] = a.split("."), c = o.find((f) => f.name === l);
|
|
1963
|
-
if (c && c.measures[u]) {
|
|
1964
|
-
const f = c.measures[u];
|
|
1965
|
-
n[a] = {
|
|
1966
|
-
title: f.title || u,
|
|
1967
|
-
shortTitle: f.title || u,
|
|
1968
|
-
type: f.type
|
|
1969
|
-
};
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
if (t.dimensions)
|
|
1973
|
-
for (const a of t.dimensions) {
|
|
1974
|
-
const [l, u] = a.split("."), c = o.find((f) => f.name === l);
|
|
1975
|
-
if (c && c.dimensions[u]) {
|
|
1976
|
-
const f = c.dimensions[u];
|
|
1977
|
-
i[a] = {
|
|
1978
|
-
title: f.title || u,
|
|
1979
|
-
shortTitle: f.title || u,
|
|
1980
|
-
type: f.type
|
|
1981
|
-
};
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
if (t.timeDimensions)
|
|
1985
|
-
for (const a of t.timeDimensions) {
|
|
1986
|
-
const [l, u] = a.dimension.split("."), c = o.find((f) => f.name === l);
|
|
1987
|
-
if (c && c.dimensions && c.dimensions[u]) {
|
|
1988
|
-
const f = c.dimensions[u];
|
|
1989
|
-
r[a.dimension] = {
|
|
1990
|
-
title: f.title || u,
|
|
1991
|
-
shortTitle: f.title || u,
|
|
1992
|
-
type: f.type,
|
|
1993
|
-
granularity: a.granularity
|
|
1994
|
-
};
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
return {
|
|
1998
|
-
measures: n,
|
|
1999
|
-
dimensions: i,
|
|
2000
|
-
segments: {},
|
|
2001
|
-
timeDimensions: r
|
|
2002
|
-
};
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
class wn {
|
|
2006
|
-
// 5 minutes in milliseconds
|
|
2007
|
-
constructor(e) {
|
|
2008
|
-
g(this, "cubes", /* @__PURE__ */ new Map());
|
|
2009
|
-
g(this, "dbExecutor");
|
|
2010
|
-
g(this, "metadataCache");
|
|
2011
|
-
g(this, "metadataCacheTimestamp");
|
|
2012
|
-
g(this, "METADATA_CACHE_TTL", 5 * 60 * 1e3);
|
|
2013
|
-
e != null && e.databaseExecutor ? this.dbExecutor = e.databaseExecutor : e != null && e.drizzle && (this.dbExecutor = nt(
|
|
2014
|
-
e.drizzle,
|
|
2015
|
-
e.schema,
|
|
2016
|
-
e.engineType
|
|
2017
|
-
));
|
|
2018
|
-
}
|
|
2019
|
-
/**
|
|
2020
|
-
* Set or update the database executor
|
|
2021
|
-
*/
|
|
2022
|
-
setDatabaseExecutor(e) {
|
|
2023
|
-
this.dbExecutor = e;
|
|
2024
|
-
}
|
|
2025
|
-
/**
|
|
2026
|
-
* Set Drizzle instance and schema directly
|
|
2027
|
-
*/
|
|
2028
|
-
setDrizzle(e, t, n) {
|
|
2029
|
-
this.dbExecutor = nt(e, t, n);
|
|
2030
|
-
}
|
|
2031
|
-
/**
|
|
2032
|
-
* Check if database executor is configured
|
|
2033
|
-
*/
|
|
2034
|
-
hasExecutor() {
|
|
2035
|
-
return !!this.dbExecutor;
|
|
2036
|
-
}
|
|
2037
|
-
/**
|
|
2038
|
-
* Register a simplified cube with dynamic query building
|
|
2039
|
-
*/
|
|
2040
|
-
registerCube(e) {
|
|
2041
|
-
this.cubes.set(e.name, e), this.invalidateMetadataCache();
|
|
2042
|
-
}
|
|
2043
|
-
/**
|
|
2044
|
-
* Get a cube by name
|
|
2045
|
-
*/
|
|
2046
|
-
getCube(e) {
|
|
2047
|
-
return this.cubes.get(e);
|
|
2048
|
-
}
|
|
2049
|
-
/**
|
|
2050
|
-
* Get all registered cubes
|
|
2051
|
-
*/
|
|
2052
|
-
getAllCubes() {
|
|
2053
|
-
return Array.from(this.cubes.values());
|
|
2054
|
-
}
|
|
2055
|
-
/**
|
|
2056
|
-
* Get all cubes as a Map for multi-cube queries
|
|
2057
|
-
*/
|
|
2058
|
-
getAllCubesMap() {
|
|
2059
|
-
return this.cubes;
|
|
2060
|
-
}
|
|
2061
|
-
/**
|
|
2062
|
-
* Unified query execution method that handles both single and multi-cube queries
|
|
2063
|
-
*/
|
|
2064
|
-
async execute(e, t) {
|
|
2065
|
-
if (!this.dbExecutor)
|
|
2066
|
-
throw new Error("Database executor not configured");
|
|
2067
|
-
return new je(this.dbExecutor).execute(this.cubes, e, t);
|
|
2068
|
-
}
|
|
2069
|
-
/**
|
|
2070
|
-
* Execute a multi-cube query
|
|
2071
|
-
*/
|
|
2072
|
-
async executeMultiCubeQuery(e, t) {
|
|
2073
|
-
return this.execute(e, t);
|
|
2074
|
-
}
|
|
2075
|
-
/**
|
|
2076
|
-
* Execute a single cube query
|
|
2077
|
-
*/
|
|
2078
|
-
async executeQuery(e, t, n) {
|
|
2079
|
-
if (!this.cubes.get(e))
|
|
2080
|
-
throw new Error(`Cube '${e}' not found`);
|
|
2081
|
-
return this.execute(t, n);
|
|
2082
|
-
}
|
|
2083
|
-
/**
|
|
2084
|
-
* Get metadata for all cubes (for API responses)
|
|
2085
|
-
* Uses caching to improve performance for repeated requests
|
|
2086
|
-
*/
|
|
2087
|
-
getMetadata() {
|
|
2088
|
-
const e = Date.now();
|
|
2089
|
-
if (this.metadataCache && this.metadataCacheTimestamp && e - this.metadataCacheTimestamp < this.METADATA_CACHE_TTL)
|
|
2090
|
-
return this.metadataCache;
|
|
2091
|
-
const t = Array.from(this.cubes.values()).map((n) => this.generateCubeMetadata(n));
|
|
2092
|
-
return this.metadataCache = t, this.metadataCacheTimestamp = e, t;
|
|
2093
|
-
}
|
|
2094
|
-
/**
|
|
2095
|
-
* Generate cube metadata for API responses from cubes
|
|
2096
|
-
* Optimized version that minimizes object iterations
|
|
2097
|
-
*/
|
|
2098
|
-
generateCubeMetadata(e) {
|
|
2099
|
-
const t = Object.keys(e.measures), n = Object.keys(e.dimensions), i = new Array(t.length), r = new Array(n.length);
|
|
2100
|
-
for (let o = 0; o < t.length; o++) {
|
|
2101
|
-
const a = t[o], l = e.measures[a];
|
|
2102
|
-
i[o] = {
|
|
2103
|
-
name: `${e.name}.${a}`,
|
|
2104
|
-
title: l.title || a,
|
|
2105
|
-
shortTitle: l.title || a,
|
|
2106
|
-
type: l.type,
|
|
2107
|
-
format: void 0,
|
|
2108
|
-
// Measure doesn't have format field
|
|
2109
|
-
description: l.description
|
|
2110
|
-
};
|
|
2111
|
-
}
|
|
2112
|
-
for (let o = 0; o < n.length; o++) {
|
|
2113
|
-
const a = n[o], l = e.dimensions[a];
|
|
2114
|
-
r[o] = {
|
|
2115
|
-
name: `${e.name}.${a}`,
|
|
2116
|
-
title: l.title || a,
|
|
2117
|
-
shortTitle: l.title || a,
|
|
2118
|
-
type: l.type,
|
|
2119
|
-
format: void 0,
|
|
2120
|
-
// Dimension doesn't have format field
|
|
2121
|
-
description: l.description
|
|
2122
|
-
};
|
|
2123
|
-
}
|
|
2124
|
-
return {
|
|
2125
|
-
name: e.name,
|
|
2126
|
-
title: e.title || e.name,
|
|
2127
|
-
description: e.description,
|
|
2128
|
-
measures: i,
|
|
2129
|
-
dimensions: r,
|
|
2130
|
-
segments: []
|
|
2131
|
-
// Add segments support later if needed
|
|
2132
|
-
};
|
|
2133
|
-
}
|
|
2134
|
-
/**
|
|
2135
|
-
* Get SQL for a query without executing it (debugging)
|
|
2136
|
-
*/
|
|
2137
|
-
async generateSQL(e, t, n) {
|
|
2138
|
-
const i = this.getCube(e);
|
|
2139
|
-
if (!i)
|
|
2140
|
-
throw new Error(`Cube '${e}' not found`);
|
|
2141
|
-
if (!this.dbExecutor)
|
|
2142
|
-
throw new Error("Database executor not configured");
|
|
2143
|
-
return new je(this.dbExecutor).generateSQL(i, t, n);
|
|
2144
|
-
}
|
|
2145
|
-
/**
|
|
2146
|
-
* Get SQL for a multi-cube query without executing it (debugging)
|
|
2147
|
-
*/
|
|
2148
|
-
async generateMultiCubeSQL(e, t) {
|
|
2149
|
-
if (!this.dbExecutor)
|
|
2150
|
-
throw new Error("Database executor not configured");
|
|
2151
|
-
return new je(this.dbExecutor).generateMultiCubeSQL(this.cubes, e, t);
|
|
2152
|
-
}
|
|
2153
|
-
/**
|
|
2154
|
-
* Check if a cube exists
|
|
2155
|
-
*/
|
|
2156
|
-
hasCube(e) {
|
|
2157
|
-
return this.cubes.has(e);
|
|
2158
|
-
}
|
|
2159
|
-
/**
|
|
2160
|
-
* Remove a cube
|
|
2161
|
-
*/
|
|
2162
|
-
removeCube(e) {
|
|
2163
|
-
const t = this.cubes.delete(e);
|
|
2164
|
-
return t && this.invalidateMetadataCache(), t;
|
|
2165
|
-
}
|
|
2166
|
-
/**
|
|
2167
|
-
* Clear all cubes
|
|
2168
|
-
*/
|
|
2169
|
-
clearCubes() {
|
|
2170
|
-
this.cubes.clear(), this.invalidateMetadataCache();
|
|
2171
|
-
}
|
|
2172
|
-
/**
|
|
2173
|
-
* Invalidate the metadata cache
|
|
2174
|
-
* Called whenever cubes are modified
|
|
2175
|
-
*/
|
|
2176
|
-
invalidateMetadataCache() {
|
|
2177
|
-
this.metadataCache = void 0, this.metadataCacheTimestamp = void 0;
|
|
2178
|
-
}
|
|
2179
|
-
/**
|
|
2180
|
-
* Get cube names
|
|
2181
|
-
*/
|
|
2182
|
-
getCubeNames() {
|
|
2183
|
-
return Array.from(this.cubes.keys());
|
|
2184
|
-
}
|
|
2185
|
-
/**
|
|
2186
|
-
* Validate a query against registered cubes
|
|
2187
|
-
* Ensures all referenced cubes and fields exist
|
|
2188
|
-
*/
|
|
2189
|
-
validateQuery(e) {
|
|
2190
|
-
return It(this.cubes, e);
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
function It(s, e) {
|
|
2194
|
-
const t = [], n = /* @__PURE__ */ new Set();
|
|
2195
|
-
if (e.measures)
|
|
2196
|
-
for (const i of e.measures) {
|
|
2197
|
-
const [r, o] = i.split(".");
|
|
2198
|
-
if (!r || !o) {
|
|
2199
|
-
t.push(`Invalid measure format: ${i}. Expected format: 'CubeName.fieldName'`);
|
|
2200
|
-
continue;
|
|
2201
|
-
}
|
|
2202
|
-
n.add(r);
|
|
2203
|
-
const a = s.get(r);
|
|
2204
|
-
if (!a) {
|
|
2205
|
-
t.push(`Cube '${r}' not found (referenced in measure '${i}')`);
|
|
2206
|
-
continue;
|
|
2207
|
-
}
|
|
2208
|
-
a.measures[o] || t.push(`Measure '${o}' not found on cube '${r}'`);
|
|
2209
|
-
}
|
|
2210
|
-
if (e.dimensions)
|
|
2211
|
-
for (const i of e.dimensions) {
|
|
2212
|
-
const [r, o] = i.split(".");
|
|
2213
|
-
if (!r || !o) {
|
|
2214
|
-
t.push(`Invalid dimension format: ${i}. Expected format: 'CubeName.fieldName'`);
|
|
2215
|
-
continue;
|
|
2216
|
-
}
|
|
2217
|
-
n.add(r);
|
|
2218
|
-
const a = s.get(r);
|
|
2219
|
-
if (!a) {
|
|
2220
|
-
t.push(`Cube '${r}' not found (referenced in dimension '${i}')`);
|
|
2221
|
-
continue;
|
|
2222
|
-
}
|
|
2223
|
-
a.dimensions[o] || t.push(`Dimension '${o}' not found on cube '${r}'`);
|
|
2224
|
-
}
|
|
2225
|
-
if (e.timeDimensions)
|
|
2226
|
-
for (const i of e.timeDimensions) {
|
|
2227
|
-
const [r, o] = i.dimension.split(".");
|
|
2228
|
-
if (!r || !o) {
|
|
2229
|
-
t.push(`Invalid timeDimension format: ${i.dimension}. Expected format: 'CubeName.fieldName'`);
|
|
2230
|
-
continue;
|
|
2231
|
-
}
|
|
2232
|
-
n.add(r);
|
|
2233
|
-
const a = s.get(r);
|
|
2234
|
-
if (!a) {
|
|
2235
|
-
t.push(`Cube '${r}' not found (referenced in timeDimension '${i.dimension}')`);
|
|
2236
|
-
continue;
|
|
2237
|
-
}
|
|
2238
|
-
a.dimensions[o] || t.push(`TimeDimension '${o}' not found on cube '${r}' (must be a dimension with time type)`);
|
|
2239
|
-
}
|
|
2240
|
-
if (e.filters)
|
|
2241
|
-
for (const i of e.filters)
|
|
2242
|
-
Qt(i, s, t, n);
|
|
2243
|
-
return n.size === 0 && t.push("Query must reference at least one cube through measures, dimensions, or filters"), {
|
|
2244
|
-
isValid: t.length === 0,
|
|
2245
|
-
errors: t
|
|
2246
|
-
};
|
|
2247
|
-
}
|
|
2248
|
-
function Qt(s, e, t, n) {
|
|
2249
|
-
if ("and" in s || "or" in s) {
|
|
2250
|
-
const a = s.and || s.or || [];
|
|
2251
|
-
for (const l of a)
|
|
2252
|
-
Qt(l, e, t, n);
|
|
2253
|
-
return;
|
|
2254
|
-
}
|
|
2255
|
-
if (!("member" in s)) {
|
|
2256
|
-
t.push("Filter must have a member field");
|
|
2257
|
-
return;
|
|
2258
|
-
}
|
|
2259
|
-
const [i, r] = s.member.split(".");
|
|
2260
|
-
if (!i || !r) {
|
|
2261
|
-
t.push(`Invalid filter member format: ${s.member}. Expected format: 'CubeName.fieldName'`);
|
|
2262
|
-
return;
|
|
2263
|
-
}
|
|
2264
|
-
n.add(i);
|
|
2265
|
-
const o = e.get(i);
|
|
2266
|
-
if (!o) {
|
|
2267
|
-
t.push(`Cube '${i}' not found (referenced in filter '${s.member}')`);
|
|
2268
|
-
return;
|
|
2269
|
-
}
|
|
2270
|
-
!o.dimensions[r] && !o.measures[r] && t.push(`Filter field '${r}' not found on cube '${i}' (must be a dimension or measure)`);
|
|
2271
|
-
}
|
|
2272
|
-
new wn();
|
|
2273
|
-
const Re = Symbol.for("yaml.alias"), Sn = Symbol.for("yaml.document"), G = Symbol.for("yaml.map"), Pt = Symbol.for("yaml.pair"), We = Symbol.for("yaml.scalar"), ue = Symbol.for("yaml.seq"), J = Symbol.for("yaml.node.type"), X = (s) => !!s && typeof s == "object" && s[J] === Re, Ce = (s) => !!s && typeof s == "object" && s[J] === Sn, zt = (s) => !!s && typeof s == "object" && s[J] === G, M = (s) => !!s && typeof s == "object" && s[J] === Pt, O = (s) => !!s && typeof s == "object" && s[J] === We, _e = (s) => !!s && typeof s == "object" && s[J] === ue;
|
|
2274
|
-
function Q(s) {
|
|
2275
|
-
if (s && typeof s == "object")
|
|
2276
|
-
switch (s[J]) {
|
|
2277
|
-
case G:
|
|
2278
|
-
case ue:
|
|
2279
|
-
return !0;
|
|
2280
|
-
}
|
|
2281
|
-
return !1;
|
|
2282
|
-
}
|
|
2283
|
-
function L(s) {
|
|
2284
|
-
if (s && typeof s == "object")
|
|
2285
|
-
switch (s[J]) {
|
|
2286
|
-
case Re:
|
|
2287
|
-
case G:
|
|
2288
|
-
case We:
|
|
2289
|
-
case ue:
|
|
2290
|
-
return !0;
|
|
2291
|
-
}
|
|
2292
|
-
return !1;
|
|
2293
|
-
}
|
|
2294
|
-
const Bt = (s) => (O(s) || Q(s)) && !!s.anchor, k = Symbol("break visit"), Nn = Symbol("skip children"), ie = Symbol("remove node");
|
|
2295
|
-
function De(s, e) {
|
|
2296
|
-
const t = Cn(e);
|
|
2297
|
-
Ce(s) ? q(null, s.contents, t, Object.freeze([s])) === ie && (s.contents = null) : q(null, s, t, Object.freeze([]));
|
|
2298
|
-
}
|
|
2299
|
-
De.BREAK = k;
|
|
2300
|
-
De.SKIP = Nn;
|
|
2301
|
-
De.REMOVE = ie;
|
|
2302
|
-
function q(s, e, t, n) {
|
|
2303
|
-
const i = Dn(s, e, t, n);
|
|
2304
|
-
if (L(i) || M(i))
|
|
2305
|
-
return $n(s, n, i), q(s, i, t, n);
|
|
2306
|
-
if (typeof i != "symbol") {
|
|
2307
|
-
if (Q(e)) {
|
|
2308
|
-
n = Object.freeze(n.concat(e));
|
|
2309
|
-
for (let r = 0; r < e.items.length; ++r) {
|
|
2310
|
-
const o = q(r, e.items[r], t, n);
|
|
2311
|
-
if (typeof o == "number")
|
|
2312
|
-
r = o - 1;
|
|
2313
|
-
else {
|
|
2314
|
-
if (o === k)
|
|
2315
|
-
return k;
|
|
2316
|
-
o === ie && (e.items.splice(r, 1), r -= 1);
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
} else if (M(e)) {
|
|
2320
|
-
n = Object.freeze(n.concat(e));
|
|
2321
|
-
const r = q("key", e.key, t, n);
|
|
2322
|
-
if (r === k)
|
|
2323
|
-
return k;
|
|
2324
|
-
r === ie && (e.key = null);
|
|
2325
|
-
const o = q("value", e.value, t, n);
|
|
2326
|
-
if (o === k)
|
|
2327
|
-
return k;
|
|
2328
|
-
o === ie && (e.value = null);
|
|
2329
|
-
}
|
|
2330
|
-
}
|
|
2331
|
-
return i;
|
|
2332
|
-
}
|
|
2333
|
-
function Cn(s) {
|
|
2334
|
-
return typeof s == "object" && (s.Collection || s.Node || s.Value) ? Object.assign({
|
|
2335
|
-
Alias: s.Node,
|
|
2336
|
-
Map: s.Node,
|
|
2337
|
-
Scalar: s.Node,
|
|
2338
|
-
Seq: s.Node
|
|
2339
|
-
}, s.Value && {
|
|
2340
|
-
Map: s.Value,
|
|
2341
|
-
Scalar: s.Value,
|
|
2342
|
-
Seq: s.Value
|
|
2343
|
-
}, s.Collection && {
|
|
2344
|
-
Map: s.Collection,
|
|
2345
|
-
Seq: s.Collection
|
|
2346
|
-
}, s) : s;
|
|
2347
|
-
}
|
|
2348
|
-
function Dn(s, e, t, n) {
|
|
2349
|
-
var i, r, o, a, l;
|
|
2350
|
-
if (typeof t == "function")
|
|
2351
|
-
return t(s, e, n);
|
|
2352
|
-
if (zt(e))
|
|
2353
|
-
return (i = t.Map) == null ? void 0 : i.call(t, s, e, n);
|
|
2354
|
-
if (_e(e))
|
|
2355
|
-
return (r = t.Seq) == null ? void 0 : r.call(t, s, e, n);
|
|
2356
|
-
if (M(e))
|
|
2357
|
-
return (o = t.Pair) == null ? void 0 : o.call(t, s, e, n);
|
|
2358
|
-
if (O(e))
|
|
2359
|
-
return (a = t.Scalar) == null ? void 0 : a.call(t, s, e, n);
|
|
2360
|
-
if (X(e))
|
|
2361
|
-
return (l = t.Alias) == null ? void 0 : l.call(t, s, e, n);
|
|
2362
|
-
}
|
|
2363
|
-
function $n(s, e, t) {
|
|
2364
|
-
const n = e[e.length - 1];
|
|
2365
|
-
if (Q(n))
|
|
2366
|
-
n.items[s] = t;
|
|
2367
|
-
else if (M(n))
|
|
2368
|
-
s === "key" ? n.key = t : n.value = t;
|
|
2369
|
-
else if (Ce(n))
|
|
2370
|
-
n.contents = t;
|
|
2371
|
-
else {
|
|
2372
|
-
const i = X(n) ? "alias" : "scalar";
|
|
2373
|
-
throw new Error(`Cannot replace node with ${i} parent`);
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
function Ut(s) {
|
|
2377
|
-
if (/[\x00-\x19\s,[\]{}]/.test(s)) {
|
|
2378
|
-
const t = `Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;
|
|
2379
|
-
throw new Error(t);
|
|
2380
|
-
}
|
|
2381
|
-
return !0;
|
|
2382
|
-
}
|
|
2383
|
-
function ne(s, e, t, n) {
|
|
2384
|
-
if (n && typeof n == "object")
|
|
2385
|
-
if (Array.isArray(n))
|
|
2386
|
-
for (let i = 0, r = n.length; i < r; ++i) {
|
|
2387
|
-
const o = n[i], a = ne(s, n, String(i), o);
|
|
2388
|
-
a === void 0 ? delete n[i] : a !== o && (n[i] = a);
|
|
2389
|
-
}
|
|
2390
|
-
else if (n instanceof Map)
|
|
2391
|
-
for (const i of Array.from(n.keys())) {
|
|
2392
|
-
const r = n.get(i), o = ne(s, n, i, r);
|
|
2393
|
-
o === void 0 ? n.delete(i) : o !== r && n.set(i, o);
|
|
2394
|
-
}
|
|
2395
|
-
else if (n instanceof Set)
|
|
2396
|
-
for (const i of Array.from(n)) {
|
|
2397
|
-
const r = ne(s, n, i, i);
|
|
2398
|
-
r === void 0 ? n.delete(i) : r !== i && (n.delete(i), n.add(r));
|
|
2399
|
-
}
|
|
2400
|
-
else
|
|
2401
|
-
for (const [i, r] of Object.entries(n)) {
|
|
2402
|
-
const o = ne(s, n, i, r);
|
|
2403
|
-
o === void 0 ? delete n[i] : o !== r && (n[i] = o);
|
|
2404
|
-
}
|
|
2405
|
-
return s.call(e, t, n);
|
|
2406
|
-
}
|
|
2407
|
-
function B(s, e, t) {
|
|
2408
|
-
if (Array.isArray(s))
|
|
2409
|
-
return s.map((n, i) => B(n, String(i), t));
|
|
2410
|
-
if (s && typeof s.toJSON == "function") {
|
|
2411
|
-
if (!t || !Bt(s))
|
|
2412
|
-
return s.toJSON(e, t);
|
|
2413
|
-
const n = { aliasCount: 0, count: 1, res: void 0 };
|
|
2414
|
-
t.anchors.set(s, n), t.onCreate = (r) => {
|
|
2415
|
-
n.res = r, delete t.onCreate;
|
|
2416
|
-
};
|
|
2417
|
-
const i = s.toJSON(e, t);
|
|
2418
|
-
return t.onCreate && t.onCreate(i), i;
|
|
2419
|
-
}
|
|
2420
|
-
return typeof s == "bigint" && !(t != null && t.keep) ? Number(s) : s;
|
|
2421
|
-
}
|
|
2422
|
-
class Ke {
|
|
2423
|
-
constructor(e) {
|
|
2424
|
-
Object.defineProperty(this, J, { value: e });
|
|
2425
|
-
}
|
|
2426
|
-
/** Create a copy of this node. */
|
|
2427
|
-
clone() {
|
|
2428
|
-
const e = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
2429
|
-
return this.range && (e.range = this.range.slice()), e;
|
|
2430
|
-
}
|
|
2431
|
-
/** A plain JavaScript representation of this node. */
|
|
2432
|
-
toJS(e, { mapAsMap: t, maxAliasCount: n, onAnchor: i, reviver: r } = {}) {
|
|
2433
|
-
if (!Ce(e))
|
|
2434
|
-
throw new TypeError("A document argument is required");
|
|
2435
|
-
const o = {
|
|
2436
|
-
anchors: /* @__PURE__ */ new Map(),
|
|
2437
|
-
doc: e,
|
|
2438
|
-
keep: !0,
|
|
2439
|
-
mapAsMap: t === !0,
|
|
2440
|
-
mapKeyWarned: !1,
|
|
2441
|
-
maxAliasCount: typeof n == "number" ? n : 100
|
|
2442
|
-
}, a = B(this, "", o);
|
|
2443
|
-
if (typeof i == "function")
|
|
2444
|
-
for (const { count: l, res: u } of o.anchors.values())
|
|
2445
|
-
i(u, l);
|
|
2446
|
-
return typeof r == "function" ? ne(r, { "": a }, "", a) : a;
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
class An extends Ke {
|
|
2450
|
-
constructor(e) {
|
|
2451
|
-
super(Re), this.source = e, Object.defineProperty(this, "tag", {
|
|
2452
|
-
set() {
|
|
2453
|
-
throw new Error("Alias nodes cannot have tags");
|
|
2454
|
-
}
|
|
2455
|
-
});
|
|
2456
|
-
}
|
|
2457
|
-
/**
|
|
2458
|
-
* Resolve the value of this alias within `doc`, finding the last
|
|
2459
|
-
* instance of the `source` anchor before this node.
|
|
2460
|
-
*/
|
|
2461
|
-
resolve(e, t) {
|
|
2462
|
-
let n;
|
|
2463
|
-
t != null && t.aliasResolveCache ? n = t.aliasResolveCache : (n = [], De(e, {
|
|
2464
|
-
Node: (r, o) => {
|
|
2465
|
-
(X(o) || Bt(o)) && n.push(o);
|
|
2466
|
-
}
|
|
2467
|
-
}), t && (t.aliasResolveCache = n));
|
|
2468
|
-
let i;
|
|
2469
|
-
for (const r of n) {
|
|
2470
|
-
if (r === this)
|
|
2471
|
-
break;
|
|
2472
|
-
r.anchor === this.source && (i = r);
|
|
2473
|
-
}
|
|
2474
|
-
return i;
|
|
2475
|
-
}
|
|
2476
|
-
toJSON(e, t) {
|
|
2477
|
-
if (!t)
|
|
2478
|
-
return { source: this.source };
|
|
2479
|
-
const { anchors: n, doc: i, maxAliasCount: r } = t, o = this.resolve(i, t);
|
|
2480
|
-
if (!o) {
|
|
2481
|
-
const l = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
2482
|
-
throw new ReferenceError(l);
|
|
2483
|
-
}
|
|
2484
|
-
let a = n.get(o);
|
|
2485
|
-
if (a || (B(o, null, t), a = n.get(o)), !a || a.res === void 0) {
|
|
2486
|
-
const l = "This should not happen: Alias anchor was not resolved?";
|
|
2487
|
-
throw new ReferenceError(l);
|
|
2488
|
-
}
|
|
2489
|
-
if (r >= 0 && (a.count += 1, a.aliasCount === 0 && (a.aliasCount = de(i, o, n)), a.count * a.aliasCount > r)) {
|
|
2490
|
-
const l = "Excessive alias count indicates a resource exhaustion attack";
|
|
2491
|
-
throw new ReferenceError(l);
|
|
2492
|
-
}
|
|
2493
|
-
return a.res;
|
|
2494
|
-
}
|
|
2495
|
-
toString(e, t, n) {
|
|
2496
|
-
const i = `*${this.source}`;
|
|
2497
|
-
if (e) {
|
|
2498
|
-
if (Ut(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source)) {
|
|
2499
|
-
const r = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
2500
|
-
throw new Error(r);
|
|
2501
|
-
}
|
|
2502
|
-
if (e.implicitKey)
|
|
2503
|
-
return `${i} `;
|
|
2504
|
-
}
|
|
2505
|
-
return i;
|
|
2506
|
-
}
|
|
2507
|
-
}
|
|
2508
|
-
function de(s, e, t) {
|
|
2509
|
-
if (X(e)) {
|
|
2510
|
-
const n = e.resolve(s), i = t && n && t.get(n);
|
|
2511
|
-
return i ? i.count * i.aliasCount : 0;
|
|
2512
|
-
} else if (Q(e)) {
|
|
2513
|
-
let n = 0;
|
|
2514
|
-
for (const i of e.items) {
|
|
2515
|
-
const r = de(s, i, t);
|
|
2516
|
-
r > n && (n = r);
|
|
2517
|
-
}
|
|
2518
|
-
return n;
|
|
2519
|
-
} else if (M(e)) {
|
|
2520
|
-
const n = de(s, e.key, t), i = de(s, e.value, t);
|
|
2521
|
-
return Math.max(n, i);
|
|
2522
|
-
}
|
|
2523
|
-
return 1;
|
|
2524
|
-
}
|
|
2525
|
-
const Vt = (s) => !s || typeof s != "function" && typeof s != "object";
|
|
2526
|
-
class D extends Ke {
|
|
2527
|
-
constructor(e) {
|
|
2528
|
-
super(We), this.value = e;
|
|
2529
|
-
}
|
|
2530
|
-
toJSON(e, t) {
|
|
2531
|
-
return t != null && t.keep ? this.value : B(this.value, e, t);
|
|
2532
|
-
}
|
|
2533
|
-
toString() {
|
|
2534
|
-
return String(this.value);
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
D.BLOCK_FOLDED = "BLOCK_FOLDED";
|
|
2538
|
-
D.BLOCK_LITERAL = "BLOCK_LITERAL";
|
|
2539
|
-
D.PLAIN = "PLAIN";
|
|
2540
|
-
D.QUOTE_DOUBLE = "QUOTE_DOUBLE";
|
|
2541
|
-
D.QUOTE_SINGLE = "QUOTE_SINGLE";
|
|
2542
|
-
function En(s, e, t) {
|
|
2543
|
-
return t.find((n) => {
|
|
2544
|
-
var i;
|
|
2545
|
-
return ((i = n.identify) == null ? void 0 : i.call(n, s)) && !n.format;
|
|
2546
|
-
});
|
|
2547
|
-
}
|
|
2548
|
-
function we(s, e, t) {
|
|
2549
|
-
var f, d, p;
|
|
2550
|
-
if (Ce(s) && (s = s.contents), L(s))
|
|
2551
|
-
return s;
|
|
2552
|
-
if (M(s)) {
|
|
2553
|
-
const y = (d = (f = t.schema[G]).createNode) == null ? void 0 : d.call(f, t.schema, null, t);
|
|
2554
|
-
return y.items.push(s), y;
|
|
2555
|
-
}
|
|
2556
|
-
(s instanceof String || s instanceof Number || s instanceof Boolean || typeof BigInt < "u" && s instanceof BigInt) && (s = s.valueOf());
|
|
2557
|
-
const { aliasDuplicateObjects: n, onAnchor: i, onTagObj: r, schema: o, sourceObjects: a } = t;
|
|
2558
|
-
let l;
|
|
2559
|
-
if (n && s && typeof s == "object") {
|
|
2560
|
-
if (l = a.get(s), l)
|
|
2561
|
-
return l.anchor ?? (l.anchor = i(s)), new An(l.anchor);
|
|
2562
|
-
l = { anchor: null, node: null }, a.set(s, l);
|
|
2563
|
-
}
|
|
2564
|
-
let u = En(s, e, o.tags);
|
|
2565
|
-
if (!u) {
|
|
2566
|
-
if (s && typeof s.toJSON == "function" && (s = s.toJSON()), !s || typeof s != "object") {
|
|
2567
|
-
const y = new D(s);
|
|
2568
|
-
return l && (l.node = y), y;
|
|
2569
|
-
}
|
|
2570
|
-
u = s instanceof Map ? o[G] : Symbol.iterator in Object(s) ? o[ue] : o[G];
|
|
2571
|
-
}
|
|
2572
|
-
r && (r(u), delete t.onTagObj);
|
|
2573
|
-
const c = u != null && u.createNode ? u.createNode(t.schema, s, t) : typeof ((p = u == null ? void 0 : u.nodeClass) == null ? void 0 : p.from) == "function" ? u.nodeClass.from(t.schema, s, t) : new D(s);
|
|
2574
|
-
return u.default || (c.tag = u.tag), l && (l.node = c), c;
|
|
2575
|
-
}
|
|
2576
|
-
function st(s, e, t) {
|
|
2577
|
-
let n = t;
|
|
2578
|
-
for (let i = e.length - 1; i >= 0; --i) {
|
|
2579
|
-
const r = e[i];
|
|
2580
|
-
if (typeof r == "number" && Number.isInteger(r) && r >= 0) {
|
|
2581
|
-
const o = [];
|
|
2582
|
-
o[r] = n, n = o;
|
|
2583
|
-
} else
|
|
2584
|
-
n = /* @__PURE__ */ new Map([[r, n]]);
|
|
2585
|
-
}
|
|
2586
|
-
return we(n, void 0, {
|
|
2587
|
-
aliasDuplicateObjects: !1,
|
|
2588
|
-
keepUndefined: !1,
|
|
2589
|
-
onAnchor: () => {
|
|
2590
|
-
throw new Error("This should not happen, please report a bug.");
|
|
2591
|
-
},
|
|
2592
|
-
schema: s,
|
|
2593
|
-
sourceObjects: /* @__PURE__ */ new Map()
|
|
2594
|
-
});
|
|
2595
|
-
}
|
|
2596
|
-
const On = (s) => s == null || typeof s == "object" && !!s[Symbol.iterator]().next().done;
|
|
2597
|
-
class Jt extends Ke {
|
|
2598
|
-
constructor(e, t) {
|
|
2599
|
-
super(e), Object.defineProperty(this, "schema", {
|
|
2600
|
-
value: t,
|
|
2601
|
-
configurable: !0,
|
|
2602
|
-
enumerable: !1,
|
|
2603
|
-
writable: !0
|
|
2604
|
-
});
|
|
2605
|
-
}
|
|
2606
|
-
/**
|
|
2607
|
-
* Create a copy of this collection.
|
|
2608
|
-
*
|
|
2609
|
-
* @param schema - If defined, overwrites the original's schema
|
|
2610
|
-
*/
|
|
2611
|
-
clone(e) {
|
|
2612
|
-
const t = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
2613
|
-
return e && (t.schema = e), t.items = t.items.map((n) => L(n) || M(n) ? n.clone(e) : n), this.range && (t.range = this.range.slice()), t;
|
|
2614
|
-
}
|
|
2615
|
-
/**
|
|
2616
|
-
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
|
2617
|
-
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
2618
|
-
* that already exists in the map.
|
|
2619
|
-
*/
|
|
2620
|
-
addIn(e, t) {
|
|
2621
|
-
if (On(e))
|
|
2622
|
-
this.add(t);
|
|
2623
|
-
else {
|
|
2624
|
-
const [n, ...i] = e, r = this.get(n, !0);
|
|
2625
|
-
if (Q(r))
|
|
2626
|
-
r.addIn(i, t);
|
|
2627
|
-
else if (r === void 0 && this.schema)
|
|
2628
|
-
this.set(n, st(this.schema, i, t));
|
|
2629
|
-
else
|
|
2630
|
-
throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
/**
|
|
2634
|
-
* Removes a value from the collection.
|
|
2635
|
-
* @returns `true` if the item was found and removed.
|
|
2636
|
-
*/
|
|
2637
|
-
deleteIn(e) {
|
|
2638
|
-
const [t, ...n] = e;
|
|
2639
|
-
if (n.length === 0)
|
|
2640
|
-
return this.delete(t);
|
|
2641
|
-
const i = this.get(t, !0);
|
|
2642
|
-
if (Q(i))
|
|
2643
|
-
return i.deleteIn(n);
|
|
2644
|
-
throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`);
|
|
2645
|
-
}
|
|
2646
|
-
/**
|
|
2647
|
-
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
2648
|
-
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
2649
|
-
* `true` (collections are always returned intact).
|
|
2650
|
-
*/
|
|
2651
|
-
getIn(e, t) {
|
|
2652
|
-
const [n, ...i] = e, r = this.get(n, !0);
|
|
2653
|
-
return i.length === 0 ? !t && O(r) ? r.value : r : Q(r) ? r.getIn(i, t) : void 0;
|
|
2654
|
-
}
|
|
2655
|
-
hasAllNullValues(e) {
|
|
2656
|
-
return this.items.every((t) => {
|
|
2657
|
-
if (!M(t))
|
|
2658
|
-
return !1;
|
|
2659
|
-
const n = t.value;
|
|
2660
|
-
return n == null || e && O(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
|
|
2661
|
-
});
|
|
2662
|
-
}
|
|
2663
|
-
/**
|
|
2664
|
-
* Checks if the collection includes a value with the key `key`.
|
|
2665
|
-
*/
|
|
2666
|
-
hasIn(e) {
|
|
2667
|
-
const [t, ...n] = e;
|
|
2668
|
-
if (n.length === 0)
|
|
2669
|
-
return this.has(t);
|
|
2670
|
-
const i = this.get(t, !0);
|
|
2671
|
-
return Q(i) ? i.hasIn(n) : !1;
|
|
2672
|
-
}
|
|
2673
|
-
/**
|
|
2674
|
-
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
2675
|
-
* boolean to add/remove the item from the set.
|
|
2676
|
-
*/
|
|
2677
|
-
setIn(e, t) {
|
|
2678
|
-
const [n, ...i] = e;
|
|
2679
|
-
if (i.length === 0)
|
|
2680
|
-
this.set(n, t);
|
|
2681
|
-
else {
|
|
2682
|
-
const r = this.get(n, !0);
|
|
2683
|
-
if (Q(r))
|
|
2684
|
-
r.setIn(i, t);
|
|
2685
|
-
else if (r === void 0 && this.schema)
|
|
2686
|
-
this.set(n, st(this.schema, i, t));
|
|
2687
|
-
else
|
|
2688
|
-
throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);
|
|
2689
|
-
}
|
|
2690
|
-
}
|
|
2691
|
-
}
|
|
2692
|
-
const Tn = (s) => s.replace(/^(?!$)(?: $)?/gm, "#");
|
|
2693
|
-
function le(s, e) {
|
|
2694
|
-
return /^\n+$/.test(s) ? s.substring(1) : e ? s.replace(/^(?! *$)/gm, e) : s;
|
|
2695
|
-
}
|
|
2696
|
-
const v = (s, e, t) => s.endsWith(`
|
|
2697
|
-
`) ? le(t, e) : t.includes(`
|
|
2698
|
-
`) ? `
|
|
2699
|
-
` + le(t, e) : (s.endsWith(" ") ? "" : " ") + t, Rt = "flow", Pe = "block", me = "quoted";
|
|
2700
|
-
function $e(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentWidth: r = 20, onFold: o, onOverflow: a } = {}) {
|
|
2701
|
-
if (!i || i < 0)
|
|
2702
|
-
return s;
|
|
2703
|
-
i < r && (r = 0);
|
|
2704
|
-
const l = Math.max(1 + r, 1 + i - e.length);
|
|
2705
|
-
if (s.length <= l)
|
|
2706
|
-
return s;
|
|
2707
|
-
const u = [], c = {};
|
|
2708
|
-
let f = i - e.length;
|
|
2709
|
-
typeof n == "number" && (n > i - Math.max(2, r) ? u.push(0) : f = i - n);
|
|
2710
|
-
let d, p, y = !1, h = -1, b = -1, S = -1;
|
|
2711
|
-
t === Pe && (h = it(s, h, e.length), h !== -1 && (f = h + l));
|
|
2712
|
-
for (let N; N = s[h += 1]; ) {
|
|
2713
|
-
if (t === me && N === "\\") {
|
|
2714
|
-
switch (b = h, s[h + 1]) {
|
|
2715
|
-
case "x":
|
|
2716
|
-
h += 3;
|
|
2717
|
-
break;
|
|
2718
|
-
case "u":
|
|
2719
|
-
h += 5;
|
|
2720
|
-
break;
|
|
2721
|
-
case "U":
|
|
2722
|
-
h += 9;
|
|
2723
|
-
break;
|
|
2724
|
-
default:
|
|
2725
|
-
h += 1;
|
|
2726
|
-
}
|
|
2727
|
-
S = h;
|
|
2728
|
-
}
|
|
2729
|
-
if (N === `
|
|
2730
|
-
`)
|
|
2731
|
-
t === Pe && (h = it(s, h, e.length)), f = h + e.length + l, d = void 0;
|
|
2732
|
-
else {
|
|
2733
|
-
if (N === " " && p && p !== " " && p !== `
|
|
2734
|
-
` && p !== " ") {
|
|
2735
|
-
const C = s[h + 1];
|
|
2736
|
-
C && C !== " " && C !== `
|
|
2737
|
-
` && C !== " " && (d = h);
|
|
2738
|
-
}
|
|
2739
|
-
if (h >= f)
|
|
2740
|
-
if (d)
|
|
2741
|
-
u.push(d), f = d + l, d = void 0;
|
|
2742
|
-
else if (t === me) {
|
|
2743
|
-
for (; p === " " || p === " "; )
|
|
2744
|
-
p = N, N = s[h += 1], y = !0;
|
|
2745
|
-
const C = h > S + 1 ? h - 2 : b - 1;
|
|
2746
|
-
if (c[C])
|
|
2747
|
-
return s;
|
|
2748
|
-
u.push(C), c[C] = !0, f = C + l, d = void 0;
|
|
2749
|
-
} else
|
|
2750
|
-
y = !0;
|
|
2751
|
-
}
|
|
2752
|
-
p = N;
|
|
2753
|
-
}
|
|
2754
|
-
if (y && a && a(), u.length === 0)
|
|
2755
|
-
return s;
|
|
2756
|
-
o && o();
|
|
2757
|
-
let w = s.slice(0, u[0]);
|
|
2758
|
-
for (let N = 0; N < u.length; ++N) {
|
|
2759
|
-
const C = u[N], $ = u[N + 1] || s.length;
|
|
2760
|
-
C === 0 ? w = `
|
|
2761
|
-
${e}${s.slice(0, $)}` : (t === me && c[C] && (w += `${s[C]}\\`), w += `
|
|
2762
|
-
${e}${s.slice(C + 1, $)}`);
|
|
2763
|
-
}
|
|
2764
|
-
return w;
|
|
2765
|
-
}
|
|
2766
|
-
function it(s, e, t) {
|
|
2767
|
-
let n = e, i = e + 1, r = s[i];
|
|
2768
|
-
for (; r === " " || r === " "; )
|
|
2769
|
-
if (e < i + t)
|
|
2770
|
-
r = s[++e];
|
|
2771
|
-
else {
|
|
2772
|
-
do
|
|
2773
|
-
r = s[++e];
|
|
2774
|
-
while (r && r !== `
|
|
2775
|
-
`);
|
|
2776
|
-
n = e, i = e + 1, r = s[i];
|
|
2777
|
-
}
|
|
2778
|
-
return n;
|
|
2779
|
-
}
|
|
2780
|
-
const Ae = (s, e) => ({
|
|
2781
|
-
indentAtStart: e ? s.indent.length : s.indentAtStart,
|
|
2782
|
-
lineWidth: s.options.lineWidth,
|
|
2783
|
-
minContentWidth: s.options.minContentWidth
|
|
2784
|
-
}), Ee = (s) => /^(%|---|\.\.\.)/m.test(s);
|
|
2785
|
-
function Mn(s, e, t) {
|
|
2786
|
-
if (!e || e < 0)
|
|
2787
|
-
return !1;
|
|
2788
|
-
const n = e - t, i = s.length;
|
|
2789
|
-
if (i <= n)
|
|
2790
|
-
return !1;
|
|
2791
|
-
for (let r = 0, o = 0; r < i; ++r)
|
|
2792
|
-
if (s[r] === `
|
|
2793
|
-
`) {
|
|
2794
|
-
if (r - o > n)
|
|
2795
|
-
return !0;
|
|
2796
|
-
if (o = r + 1, i - o <= n)
|
|
2797
|
-
return !1;
|
|
2798
|
-
}
|
|
2799
|
-
return !0;
|
|
2800
|
-
}
|
|
2801
|
-
function re(s, e) {
|
|
2802
|
-
const t = JSON.stringify(s);
|
|
2803
|
-
if (e.options.doubleQuotedAsJSON)
|
|
2804
|
-
return t;
|
|
2805
|
-
const { implicitKey: n } = e, i = e.options.doubleQuotedMinMultiLineLength, r = e.indent || (Ee(s) ? " " : "");
|
|
2806
|
-
let o = "", a = 0;
|
|
2807
|
-
for (let l = 0, u = t[l]; u; u = t[++l])
|
|
2808
|
-
if (u === " " && t[l + 1] === "\\" && t[l + 2] === "n" && (o += t.slice(a, l) + "\\ ", l += 1, a = l, u = "\\"), u === "\\")
|
|
2809
|
-
switch (t[l + 1]) {
|
|
2810
|
-
case "u":
|
|
2811
|
-
{
|
|
2812
|
-
o += t.slice(a, l);
|
|
2813
|
-
const c = t.substr(l + 2, 4);
|
|
2814
|
-
switch (c) {
|
|
2815
|
-
case "0000":
|
|
2816
|
-
o += "\\0";
|
|
2817
|
-
break;
|
|
2818
|
-
case "0007":
|
|
2819
|
-
o += "\\a";
|
|
2820
|
-
break;
|
|
2821
|
-
case "000b":
|
|
2822
|
-
o += "\\v";
|
|
2823
|
-
break;
|
|
2824
|
-
case "001b":
|
|
2825
|
-
o += "\\e";
|
|
2826
|
-
break;
|
|
2827
|
-
case "0085":
|
|
2828
|
-
o += "\\N";
|
|
2829
|
-
break;
|
|
2830
|
-
case "00a0":
|
|
2831
|
-
o += "\\_";
|
|
2832
|
-
break;
|
|
2833
|
-
case "2028":
|
|
2834
|
-
o += "\\L";
|
|
2835
|
-
break;
|
|
2836
|
-
case "2029":
|
|
2837
|
-
o += "\\P";
|
|
2838
|
-
break;
|
|
2839
|
-
default:
|
|
2840
|
-
c.substr(0, 2) === "00" ? o += "\\x" + c.substr(2) : o += t.substr(l, 6);
|
|
2841
|
-
}
|
|
2842
|
-
l += 5, a = l + 1;
|
|
2843
|
-
}
|
|
2844
|
-
break;
|
|
2845
|
-
case "n":
|
|
2846
|
-
if (n || t[l + 2] === '"' || t.length < i)
|
|
2847
|
-
l += 1;
|
|
2848
|
-
else {
|
|
2849
|
-
for (o += t.slice(a, l) + `
|
|
2850
|
-
|
|
2851
|
-
`; t[l + 2] === "\\" && t[l + 3] === "n" && t[l + 4] !== '"'; )
|
|
2852
|
-
o += `
|
|
2853
|
-
`, l += 2;
|
|
2854
|
-
o += r, t[l + 2] === " " && (o += "\\"), l += 1, a = l + 1;
|
|
2855
|
-
}
|
|
2856
|
-
break;
|
|
2857
|
-
default:
|
|
2858
|
-
l += 1;
|
|
2859
|
-
}
|
|
2860
|
-
return o = a ? o + t.slice(a) : t, n ? o : $e(o, r, me, Ae(e, !1));
|
|
2861
|
-
}
|
|
2862
|
-
function ze(s, e) {
|
|
2863
|
-
if (e.options.singleQuote === !1 || e.implicitKey && s.includes(`
|
|
2864
|
-
`) || /[ \t]\n|\n[ \t]/.test(s))
|
|
2865
|
-
return re(s, e);
|
|
2866
|
-
const t = e.indent || (Ee(s) ? " " : ""), n = "'" + s.replace(/'/g, "''").replace(/\n+/g, `$&
|
|
2867
|
-
${t}`) + "'";
|
|
2868
|
-
return e.implicitKey ? n : $e(n, t, Rt, Ae(e, !1));
|
|
2869
|
-
}
|
|
2870
|
-
function x(s, e) {
|
|
2871
|
-
const { singleQuote: t } = e.options;
|
|
2872
|
-
let n;
|
|
2873
|
-
if (t === !1)
|
|
2874
|
-
n = re;
|
|
2875
|
-
else {
|
|
2876
|
-
const i = s.includes('"'), r = s.includes("'");
|
|
2877
|
-
i && !r ? n = ze : r && !i ? n = re : n = t ? ze : re;
|
|
2878
|
-
}
|
|
2879
|
-
return n(s, e);
|
|
2880
|
-
}
|
|
2881
|
-
let Be;
|
|
2882
|
-
try {
|
|
2883
|
-
Be = new RegExp(`(^|(?<!
|
|
2884
|
-
))
|
|
2885
|
-
+(?!
|
|
2886
|
-
|$)`, "g");
|
|
2887
|
-
} catch {
|
|
2888
|
-
Be = /\n+(?!\n|$)/g;
|
|
2889
|
-
}
|
|
2890
|
-
function he({ comment: s, type: e, value: t }, n, i, r) {
|
|
2891
|
-
const { blockQuote: o, commentString: a, lineWidth: l } = n.options;
|
|
2892
|
-
if (!o || /\n[\t ]+$/.test(t))
|
|
2893
|
-
return x(t, n);
|
|
2894
|
-
const u = n.indent || (n.forceBlockIndent || Ee(t) ? " " : ""), c = o === "literal" ? !0 : o === "folded" || e === D.BLOCK_FOLDED ? !1 : e === D.BLOCK_LITERAL ? !0 : !Mn(t, l, u.length);
|
|
2895
|
-
if (!t)
|
|
2896
|
-
return c ? `|
|
|
2897
|
-
` : `>
|
|
2898
|
-
`;
|
|
2899
|
-
let f, d;
|
|
2900
|
-
for (d = t.length; d > 0; --d) {
|
|
2901
|
-
const $ = t[d - 1];
|
|
2902
|
-
if ($ !== `
|
|
2903
|
-
` && $ !== " " && $ !== " ")
|
|
2904
|
-
break;
|
|
2905
|
-
}
|
|
2906
|
-
let p = t.substring(d);
|
|
2907
|
-
const y = p.indexOf(`
|
|
2908
|
-
`);
|
|
2909
|
-
y === -1 ? f = "-" : t === p || y !== p.length - 1 ? (f = "+", r && r()) : f = "", p && (t = t.slice(0, -p.length), p[p.length - 1] === `
|
|
2910
|
-
` && (p = p.slice(0, -1)), p = p.replace(Be, `$&${u}`));
|
|
2911
|
-
let h = !1, b, S = -1;
|
|
2912
|
-
for (b = 0; b < t.length; ++b) {
|
|
2913
|
-
const $ = t[b];
|
|
2914
|
-
if ($ === " ")
|
|
2915
|
-
h = !0;
|
|
2916
|
-
else if ($ === `
|
|
2917
|
-
`)
|
|
2918
|
-
S = b;
|
|
2919
|
-
else
|
|
2920
|
-
break;
|
|
2921
|
-
}
|
|
2922
|
-
let w = t.substring(0, S < b ? S + 1 : b);
|
|
2923
|
-
w && (t = t.substring(w.length), w = w.replace(/\n+/g, `$&${u}`));
|
|
2924
|
-
let C = (h ? u ? "2" : "1" : "") + f;
|
|
2925
|
-
if (s && (C += " " + a(s.replace(/ ?[\r\n]+/g, " ")), i && i()), !c) {
|
|
2926
|
-
const $ = t.replace(/\n+/g, `
|
|
2927
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${u}`);
|
|
2928
|
-
let z = !1;
|
|
2929
|
-
const U = Ae(n, !0);
|
|
2930
|
-
o !== "folded" && e !== D.BLOCK_FOLDED && (U.onOverflow = () => {
|
|
2931
|
-
z = !0;
|
|
2932
|
-
});
|
|
2933
|
-
const te = $e(`${w}${$}${p}`, u, Pe, U);
|
|
2934
|
-
if (!z)
|
|
2935
|
-
return `>${C}
|
|
2936
|
-
${u}${te}`;
|
|
2937
|
-
}
|
|
2938
|
-
return t = t.replace(/\n+/g, `$&${u}`), `|${C}
|
|
2939
|
-
${u}${w}${t}${p}`;
|
|
2940
|
-
}
|
|
2941
|
-
function Ln(s, e, t, n) {
|
|
2942
|
-
const { type: i, value: r } = s, { actualString: o, implicitKey: a, indent: l, indentStep: u, inFlow: c } = e;
|
|
2943
|
-
if (a && r.includes(`
|
|
2944
|
-
`) || c && /[[\]{},]/.test(r))
|
|
2945
|
-
return x(r, e);
|
|
2946
|
-
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))
|
|
2947
|
-
return a || c || !r.includes(`
|
|
2948
|
-
`) ? x(r, e) : he(s, e, t, n);
|
|
2949
|
-
if (!a && !c && i !== D.PLAIN && r.includes(`
|
|
2950
|
-
`))
|
|
2951
|
-
return he(s, e, t, n);
|
|
2952
|
-
if (Ee(r)) {
|
|
2953
|
-
if (l === "")
|
|
2954
|
-
return e.forceBlockIndent = !0, he(s, e, t, n);
|
|
2955
|
-
if (a && l === u)
|
|
2956
|
-
return x(r, e);
|
|
2957
|
-
}
|
|
2958
|
-
const f = r.replace(/\n+/g, `$&
|
|
2959
|
-
${l}`);
|
|
2960
|
-
if (o) {
|
|
2961
|
-
const d = (h) => {
|
|
2962
|
-
var b;
|
|
2963
|
-
return h.default && h.tag !== "tag:yaml.org,2002:str" && ((b = h.test) == null ? void 0 : b.test(f));
|
|
2964
|
-
}, { compat: p, tags: y } = e.doc.schema;
|
|
2965
|
-
if (y.some(d) || p != null && p.some(d))
|
|
2966
|
-
return x(r, e);
|
|
2967
|
-
}
|
|
2968
|
-
return a ? f : $e(f, l, Rt, Ae(e, !1));
|
|
2969
|
-
}
|
|
2970
|
-
function Fn(s, e, t, n) {
|
|
2971
|
-
const { implicitKey: i, inFlow: r } = e, o = typeof s.value == "string" ? s : Object.assign({}, s, { value: String(s.value) });
|
|
2972
|
-
let { type: a } = s;
|
|
2973
|
-
a !== D.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (a = D.QUOTE_DOUBLE);
|
|
2974
|
-
const l = (c) => {
|
|
2975
|
-
switch (c) {
|
|
2976
|
-
case D.BLOCK_FOLDED:
|
|
2977
|
-
case D.BLOCK_LITERAL:
|
|
2978
|
-
return i || r ? x(o.value, e) : he(o, e, t, n);
|
|
2979
|
-
case D.QUOTE_DOUBLE:
|
|
2980
|
-
return re(o.value, e);
|
|
2981
|
-
case D.QUOTE_SINGLE:
|
|
2982
|
-
return ze(o.value, e);
|
|
2983
|
-
case D.PLAIN:
|
|
2984
|
-
return Ln(o, e, t, n);
|
|
2985
|
-
default:
|
|
2986
|
-
return null;
|
|
2987
|
-
}
|
|
2988
|
-
};
|
|
2989
|
-
let u = l(a);
|
|
2990
|
-
if (u === null) {
|
|
2991
|
-
const { defaultKeyType: c, defaultStringType: f } = e.options, d = i && c || f;
|
|
2992
|
-
if (u = l(d), u === null)
|
|
2993
|
-
throw new Error(`Unsupported default string type ${d}`);
|
|
2994
|
-
}
|
|
2995
|
-
return u;
|
|
2996
|
-
}
|
|
2997
|
-
function jn(s, e) {
|
|
2998
|
-
const t = Object.assign({
|
|
2999
|
-
blockQuote: !0,
|
|
3000
|
-
commentString: Tn,
|
|
3001
|
-
defaultKeyType: null,
|
|
3002
|
-
defaultStringType: "PLAIN",
|
|
3003
|
-
directives: null,
|
|
3004
|
-
doubleQuotedAsJSON: !1,
|
|
3005
|
-
doubleQuotedMinMultiLineLength: 40,
|
|
3006
|
-
falseStr: "false",
|
|
3007
|
-
flowCollectionPadding: !0,
|
|
3008
|
-
indentSeq: !0,
|
|
3009
|
-
lineWidth: 80,
|
|
3010
|
-
minContentWidth: 20,
|
|
3011
|
-
nullStr: "null",
|
|
3012
|
-
simpleKeys: !1,
|
|
3013
|
-
singleQuote: null,
|
|
3014
|
-
trueStr: "true",
|
|
3015
|
-
verifyAliasOrder: !0
|
|
3016
|
-
}, s.schema.toStringOptions, e);
|
|
3017
|
-
let n;
|
|
3018
|
-
switch (t.collectionStyle) {
|
|
3019
|
-
case "block":
|
|
3020
|
-
n = !1;
|
|
3021
|
-
break;
|
|
3022
|
-
case "flow":
|
|
3023
|
-
n = !0;
|
|
3024
|
-
break;
|
|
3025
|
-
default:
|
|
3026
|
-
n = null;
|
|
3027
|
-
}
|
|
3028
|
-
return {
|
|
3029
|
-
anchors: /* @__PURE__ */ new Set(),
|
|
3030
|
-
doc: s,
|
|
3031
|
-
flowCollectionPadding: t.flowCollectionPadding ? " " : "",
|
|
3032
|
-
indent: "",
|
|
3033
|
-
indentStep: typeof t.indent == "number" ? " ".repeat(t.indent) : " ",
|
|
3034
|
-
inFlow: n,
|
|
3035
|
-
options: t
|
|
3036
|
-
};
|
|
3037
|
-
}
|
|
3038
|
-
function In(s, e) {
|
|
3039
|
-
var i;
|
|
3040
|
-
if (e.tag) {
|
|
3041
|
-
const r = s.filter((o) => o.tag === e.tag);
|
|
3042
|
-
if (r.length > 0)
|
|
3043
|
-
return r.find((o) => o.format === e.format) ?? r[0];
|
|
3044
|
-
}
|
|
3045
|
-
let t, n;
|
|
3046
|
-
if (O(e)) {
|
|
3047
|
-
n = e.value;
|
|
3048
|
-
let r = s.filter((o) => {
|
|
3049
|
-
var a;
|
|
3050
|
-
return (a = o.identify) == null ? void 0 : a.call(o, n);
|
|
3051
|
-
});
|
|
3052
|
-
if (r.length > 1) {
|
|
3053
|
-
const o = r.filter((a) => a.test);
|
|
3054
|
-
o.length > 0 && (r = o);
|
|
3055
|
-
}
|
|
3056
|
-
t = r.find((o) => o.format === e.format) ?? r.find((o) => !o.format);
|
|
3057
|
-
} else
|
|
3058
|
-
n = e, t = s.find((r) => r.nodeClass && n instanceof r.nodeClass);
|
|
3059
|
-
if (!t) {
|
|
3060
|
-
const r = ((i = n == null ? void 0 : n.constructor) == null ? void 0 : i.name) ?? (n === null ? "null" : typeof n);
|
|
3061
|
-
throw new Error(`Tag not resolved for ${r} value`);
|
|
3062
|
-
}
|
|
3063
|
-
return t;
|
|
3064
|
-
}
|
|
3065
|
-
function Qn(s, e, { anchors: t, doc: n }) {
|
|
3066
|
-
if (!n.directives)
|
|
3067
|
-
return "";
|
|
3068
|
-
const i = [], r = (O(s) || Q(s)) && s.anchor;
|
|
3069
|
-
r && Ut(r) && (t.add(r), i.push(`&${r}`));
|
|
3070
|
-
const o = s.tag ?? (e.default ? null : e.tag);
|
|
3071
|
-
return o && i.push(n.directives.tagString(o)), i.join(" ");
|
|
3072
|
-
}
|
|
3073
|
-
function Se(s, e, t, n) {
|
|
3074
|
-
var l;
|
|
3075
|
-
if (M(s))
|
|
3076
|
-
return s.toString(e, t, n);
|
|
3077
|
-
if (X(s)) {
|
|
3078
|
-
if (e.doc.directives)
|
|
3079
|
-
return s.toString(e);
|
|
3080
|
-
if ((l = e.resolvedAliases) != null && l.has(s))
|
|
3081
|
-
throw new TypeError("Cannot stringify circular structure without alias nodes");
|
|
3082
|
-
e.resolvedAliases ? e.resolvedAliases.add(s) : e.resolvedAliases = /* @__PURE__ */ new Set([s]), s = s.resolve(e.doc);
|
|
3083
|
-
}
|
|
3084
|
-
let i;
|
|
3085
|
-
const r = L(s) ? s : e.doc.createNode(s, { onTagObj: (u) => i = u });
|
|
3086
|
-
i ?? (i = In(e.doc.schema.tags, r));
|
|
3087
|
-
const o = Qn(r, i, e);
|
|
3088
|
-
o.length > 0 && (e.indentAtStart = (e.indentAtStart ?? 0) + o.length + 1);
|
|
3089
|
-
const a = typeof i.stringify == "function" ? i.stringify(r, e, t, n) : O(r) ? Fn(r, e, t, n) : r.toString(e, t, n);
|
|
3090
|
-
return o ? O(r) || a[0] === "{" || a[0] === "[" ? `${o} ${a}` : `${o}
|
|
3091
|
-
${e.indent}${a}` : a;
|
|
3092
|
-
}
|
|
3093
|
-
function Pn({ key: s, value: e }, t, n, i) {
|
|
3094
|
-
const { allNullValues: r, doc: o, indent: a, indentStep: l, options: { commentString: u, indentSeq: c, simpleKeys: f } } = t;
|
|
3095
|
-
let d = L(s) && s.comment || null;
|
|
3096
|
-
if (f) {
|
|
3097
|
-
if (d)
|
|
3098
|
-
throw new Error("With simple keys, key nodes cannot have comments");
|
|
3099
|
-
if (Q(s) || !L(s) && typeof s == "object") {
|
|
3100
|
-
const U = "With simple keys, collection cannot be used as a key value";
|
|
3101
|
-
throw new Error(U);
|
|
3102
|
-
}
|
|
3103
|
-
}
|
|
3104
|
-
let p = !f && (!s || d && e == null && !t.inFlow || Q(s) || (O(s) ? s.type === D.BLOCK_FOLDED || s.type === D.BLOCK_LITERAL : typeof s == "object"));
|
|
3105
|
-
t = Object.assign({}, t, {
|
|
3106
|
-
allNullValues: !1,
|
|
3107
|
-
implicitKey: !p && (f || !r),
|
|
3108
|
-
indent: a + l
|
|
3109
|
-
});
|
|
3110
|
-
let y = !1, h = !1, b = Se(s, t, () => y = !0, () => h = !0);
|
|
3111
|
-
if (!p && !t.inFlow && b.length > 1024) {
|
|
3112
|
-
if (f)
|
|
3113
|
-
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
3114
|
-
p = !0;
|
|
3115
|
-
}
|
|
3116
|
-
if (t.inFlow) {
|
|
3117
|
-
if (r || e == null)
|
|
3118
|
-
return y && n && n(), b === "" ? "?" : p ? `? ${b}` : b;
|
|
3119
|
-
} else if (r && !f || e == null && p)
|
|
3120
|
-
return b = `? ${b}`, d && !y ? b += v(b, t.indent, u(d)) : h && i && i(), b;
|
|
3121
|
-
y && (d = null), p ? (d && (b += v(b, t.indent, u(d))), b = `? ${b}
|
|
3122
|
-
${a}:`) : (b = `${b}:`, d && (b += v(b, t.indent, u(d))));
|
|
3123
|
-
let S, w, N;
|
|
3124
|
-
L(e) ? (S = !!e.spaceBefore, w = e.commentBefore, N = e.comment) : (S = !1, w = null, N = null, e && typeof e == "object" && (e = o.createNode(e))), t.implicitKey = !1, !p && !d && O(e) && (t.indentAtStart = b.length + 1), h = !1, !c && l.length >= 2 && !t.inFlow && !p && _e(e) && !e.flow && !e.tag && !e.anchor && (t.indent = t.indent.substring(2));
|
|
3125
|
-
let C = !1;
|
|
3126
|
-
const $ = Se(e, t, () => C = !0, () => h = !0);
|
|
3127
|
-
let z = " ";
|
|
3128
|
-
if (d || S || w) {
|
|
3129
|
-
if (z = S ? `
|
|
3130
|
-
` : "", w) {
|
|
3131
|
-
const U = u(w);
|
|
3132
|
-
z += `
|
|
3133
|
-
${le(U, t.indent)}`;
|
|
3134
|
-
}
|
|
3135
|
-
$ === "" && !t.inFlow ? z === `
|
|
3136
|
-
` && (z = `
|
|
3137
|
-
|
|
3138
|
-
`) : z += `
|
|
3139
|
-
${t.indent}`;
|
|
3140
|
-
} else if (!p && Q(e)) {
|
|
3141
|
-
const U = $[0], te = $.indexOf(`
|
|
3142
|
-
`), Ge = te !== -1, Yt = t.inFlow ?? e.flow ?? e.items.length === 0;
|
|
3143
|
-
if (Ge || !Yt) {
|
|
3144
|
-
let Xe = !1;
|
|
3145
|
-
if (Ge && (U === "&" || U === "!")) {
|
|
3146
|
-
let K = $.indexOf(" ");
|
|
3147
|
-
U === "&" && K !== -1 && K < te && $[K + 1] === "!" && (K = $.indexOf(" ", K + 1)), (K === -1 || te < K) && (Xe = !0);
|
|
3148
|
-
}
|
|
3149
|
-
Xe || (z = `
|
|
3150
|
-
${t.indent}`);
|
|
3151
|
-
}
|
|
3152
|
-
} else ($ === "" || $[0] === `
|
|
3153
|
-
`) && (z = "");
|
|
3154
|
-
return b += z + $, t.inFlow ? C && n && n() : N && !C ? b += v(b, t.indent, u(N)) : h && i && i(), b;
|
|
3155
|
-
}
|
|
3156
|
-
function zn(s, e) {
|
|
3157
|
-
(s === "debug" || s === "warn") && console.warn(e);
|
|
3158
|
-
}
|
|
3159
|
-
const ce = "<<", Ie = {
|
|
3160
|
-
identify: (s) => s === ce || typeof s == "symbol" && s.description === ce,
|
|
3161
|
-
default: "key",
|
|
3162
|
-
tag: "tag:yaml.org,2002:merge",
|
|
3163
|
-
test: /^<<$/,
|
|
3164
|
-
resolve: () => Object.assign(new D(Symbol(ce)), {
|
|
3165
|
-
addToJSMap: Wt
|
|
3166
|
-
}),
|
|
3167
|
-
stringify: () => ce
|
|
3168
|
-
}, Bn = (s, e) => (Ie.identify(e) || O(e) && (!e.type || e.type === D.PLAIN) && Ie.identify(e.value)) && (s == null ? void 0 : s.doc.schema.tags.some((t) => t.tag === Ie.tag && t.default));
|
|
3169
|
-
function Wt(s, e, t) {
|
|
3170
|
-
if (t = s && X(t) ? t.resolve(s.doc) : t, _e(t))
|
|
3171
|
-
for (const n of t.items)
|
|
3172
|
-
Qe(s, e, n);
|
|
3173
|
-
else if (Array.isArray(t))
|
|
3174
|
-
for (const n of t)
|
|
3175
|
-
Qe(s, e, n);
|
|
3176
|
-
else
|
|
3177
|
-
Qe(s, e, t);
|
|
3178
|
-
}
|
|
3179
|
-
function Qe(s, e, t) {
|
|
3180
|
-
const n = s && X(t) ? t.resolve(s.doc) : t;
|
|
3181
|
-
if (!zt(n))
|
|
3182
|
-
throw new Error("Merge sources must be maps or map aliases");
|
|
3183
|
-
const i = n.toJSON(null, s, Map);
|
|
3184
|
-
for (const [r, o] of i)
|
|
3185
|
-
e instanceof Map ? e.has(r) || e.set(r, o) : e instanceof Set ? e.add(r) : Object.prototype.hasOwnProperty.call(e, r) || Object.defineProperty(e, r, {
|
|
3186
|
-
value: o,
|
|
3187
|
-
writable: !0,
|
|
3188
|
-
enumerable: !0,
|
|
3189
|
-
configurable: !0
|
|
3190
|
-
});
|
|
3191
|
-
return e;
|
|
3192
|
-
}
|
|
3193
|
-
function _t(s, e, { key: t, value: n }) {
|
|
3194
|
-
if (L(t) && t.addToJSMap)
|
|
3195
|
-
t.addToJSMap(s, e, n);
|
|
3196
|
-
else if (Bn(s, t))
|
|
3197
|
-
Wt(s, e, n);
|
|
3198
|
-
else {
|
|
3199
|
-
const i = B(t, "", s);
|
|
3200
|
-
if (e instanceof Map)
|
|
3201
|
-
e.set(i, B(n, i, s));
|
|
3202
|
-
else if (e instanceof Set)
|
|
3203
|
-
e.add(i);
|
|
3204
|
-
else {
|
|
3205
|
-
const r = Un(t, i, s), o = B(n, r, s);
|
|
3206
|
-
r in e ? Object.defineProperty(e, r, {
|
|
3207
|
-
value: o,
|
|
3208
|
-
writable: !0,
|
|
3209
|
-
enumerable: !0,
|
|
3210
|
-
configurable: !0
|
|
3211
|
-
}) : e[r] = o;
|
|
3212
|
-
}
|
|
3213
|
-
}
|
|
3214
|
-
return e;
|
|
3215
|
-
}
|
|
3216
|
-
function Un(s, e, t) {
|
|
3217
|
-
if (e === null)
|
|
3218
|
-
return "";
|
|
3219
|
-
if (typeof e != "object")
|
|
3220
|
-
return String(e);
|
|
3221
|
-
if (L(s) && (t != null && t.doc)) {
|
|
3222
|
-
const n = jn(t.doc, {});
|
|
3223
|
-
n.anchors = /* @__PURE__ */ new Set();
|
|
3224
|
-
for (const r of t.anchors.keys())
|
|
3225
|
-
n.anchors.add(r.anchor);
|
|
3226
|
-
n.inFlow = !0, n.inStringifyKey = !0;
|
|
3227
|
-
const i = s.toString(n);
|
|
3228
|
-
if (!t.mapKeyWarned) {
|
|
3229
|
-
let r = JSON.stringify(i);
|
|
3230
|
-
r.length > 40 && (r = r.substring(0, 36) + '..."'), zn(t.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`), t.mapKeyWarned = !0;
|
|
3231
|
-
}
|
|
3232
|
-
return i;
|
|
3233
|
-
}
|
|
3234
|
-
return JSON.stringify(e);
|
|
3235
|
-
}
|
|
3236
|
-
function ke(s, e, t) {
|
|
3237
|
-
const n = we(s, void 0, t), i = we(e, void 0, t);
|
|
3238
|
-
return new _(n, i);
|
|
3239
|
-
}
|
|
3240
|
-
class _ {
|
|
3241
|
-
constructor(e, t = null) {
|
|
3242
|
-
Object.defineProperty(this, J, { value: Pt }), this.key = e, this.value = t;
|
|
3243
|
-
}
|
|
3244
|
-
clone(e) {
|
|
3245
|
-
let { key: t, value: n } = this;
|
|
3246
|
-
return L(t) && (t = t.clone(e)), L(n) && (n = n.clone(e)), new _(t, n);
|
|
3247
|
-
}
|
|
3248
|
-
toJSON(e, t) {
|
|
3249
|
-
const n = t != null && t.mapAsMap ? /* @__PURE__ */ new Map() : {};
|
|
3250
|
-
return _t(t, n, this);
|
|
3251
|
-
}
|
|
3252
|
-
toString(e, t, n) {
|
|
3253
|
-
return e != null && e.doc ? Pn(this, e, t, n) : JSON.stringify(this);
|
|
3254
|
-
}
|
|
3255
|
-
}
|
|
3256
|
-
function Kt(s, e, t) {
|
|
3257
|
-
return (e.inFlow ?? s.flow ? Jn : Vn)(s, e, t);
|
|
3258
|
-
}
|
|
3259
|
-
function Vn({ comment: s, items: e }, t, { blockItemPrefix: n, flowChars: i, itemIndent: r, onChompKeep: o, onComment: a }) {
|
|
3260
|
-
const { indent: l, options: { commentString: u } } = t, c = Object.assign({}, t, { indent: r, type: null });
|
|
3261
|
-
let f = !1;
|
|
3262
|
-
const d = [];
|
|
3263
|
-
for (let y = 0; y < e.length; ++y) {
|
|
3264
|
-
const h = e[y];
|
|
3265
|
-
let b = null;
|
|
3266
|
-
if (L(h))
|
|
3267
|
-
!f && h.spaceBefore && d.push(""), Ne(t, d, h.commentBefore, f), h.comment && (b = h.comment);
|
|
3268
|
-
else if (M(h)) {
|
|
3269
|
-
const w = L(h.key) ? h.key : null;
|
|
3270
|
-
w && (!f && w.spaceBefore && d.push(""), Ne(t, d, w.commentBefore, f));
|
|
3271
|
-
}
|
|
3272
|
-
f = !1;
|
|
3273
|
-
let S = Se(h, c, () => b = null, () => f = !0);
|
|
3274
|
-
b && (S += v(S, r, u(b))), f && b && (f = !1), d.push(n + S);
|
|
3275
|
-
}
|
|
3276
|
-
let p;
|
|
3277
|
-
if (d.length === 0)
|
|
3278
|
-
p = i.start + i.end;
|
|
3279
|
-
else {
|
|
3280
|
-
p = d[0];
|
|
3281
|
-
for (let y = 1; y < d.length; ++y) {
|
|
3282
|
-
const h = d[y];
|
|
3283
|
-
p += h ? `
|
|
3284
|
-
${l}${h}` : `
|
|
3285
|
-
`;
|
|
3286
|
-
}
|
|
3287
|
-
}
|
|
3288
|
-
return s ? (p += `
|
|
3289
|
-
` + le(u(s), l), a && a()) : f && o && o(), p;
|
|
3290
|
-
}
|
|
3291
|
-
function Jn({ items: s }, e, { flowChars: t, itemIndent: n }) {
|
|
3292
|
-
const { indent: i, indentStep: r, flowCollectionPadding: o, options: { commentString: a } } = e;
|
|
3293
|
-
n += r;
|
|
3294
|
-
const l = Object.assign({}, e, {
|
|
3295
|
-
indent: n,
|
|
3296
|
-
inFlow: !0,
|
|
3297
|
-
type: null
|
|
3298
|
-
});
|
|
3299
|
-
let u = !1, c = 0;
|
|
3300
|
-
const f = [];
|
|
3301
|
-
for (let y = 0; y < s.length; ++y) {
|
|
3302
|
-
const h = s[y];
|
|
3303
|
-
let b = null;
|
|
3304
|
-
if (L(h))
|
|
3305
|
-
h.spaceBefore && f.push(""), Ne(e, f, h.commentBefore, !1), h.comment && (b = h.comment);
|
|
3306
|
-
else if (M(h)) {
|
|
3307
|
-
const w = L(h.key) ? h.key : null;
|
|
3308
|
-
w && (w.spaceBefore && f.push(""), Ne(e, f, w.commentBefore, !1), w.comment && (u = !0));
|
|
3309
|
-
const N = L(h.value) ? h.value : null;
|
|
3310
|
-
N ? (N.comment && (b = N.comment), N.commentBefore && (u = !0)) : h.value == null && (w != null && w.comment) && (b = w.comment);
|
|
3311
|
-
}
|
|
3312
|
-
b && (u = !0);
|
|
3313
|
-
let S = Se(h, l, () => b = null);
|
|
3314
|
-
y < s.length - 1 && (S += ","), b && (S += v(S, n, a(b))), !u && (f.length > c || S.includes(`
|
|
3315
|
-
`)) && (u = !0), f.push(S), c = f.length;
|
|
3316
|
-
}
|
|
3317
|
-
const { start: d, end: p } = t;
|
|
3318
|
-
if (f.length === 0)
|
|
3319
|
-
return d + p;
|
|
3320
|
-
if (!u) {
|
|
3321
|
-
const y = f.reduce((h, b) => h + b.length + 2, 2);
|
|
3322
|
-
u = e.options.lineWidth > 0 && y > e.options.lineWidth;
|
|
3323
|
-
}
|
|
3324
|
-
if (u) {
|
|
3325
|
-
let y = d;
|
|
3326
|
-
for (const h of f)
|
|
3327
|
-
y += h ? `
|
|
3328
|
-
${r}${i}${h}` : `
|
|
3329
|
-
`;
|
|
3330
|
-
return `${y}
|
|
3331
|
-
${i}${p}`;
|
|
3332
|
-
} else
|
|
3333
|
-
return `${d}${o}${f.join(" ")}${o}${p}`;
|
|
3334
|
-
}
|
|
3335
|
-
function Ne({ indent: s, options: { commentString: e } }, t, n, i) {
|
|
3336
|
-
if (n && i && (n = n.replace(/^\n+/, "")), n) {
|
|
3337
|
-
const r = le(e(n), s);
|
|
3338
|
-
t.push(r.trimStart());
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3341
|
-
function H(s, e) {
|
|
3342
|
-
const t = O(e) ? e.value : e;
|
|
3343
|
-
for (const n of s)
|
|
3344
|
-
if (M(n) && (n.key === e || n.key === t || O(n.key) && n.key.value === t))
|
|
3345
|
-
return n;
|
|
3346
|
-
}
|
|
3347
|
-
class Z extends Jt {
|
|
3348
|
-
static get tagName() {
|
|
3349
|
-
return "tag:yaml.org,2002:map";
|
|
3350
|
-
}
|
|
3351
|
-
constructor(e) {
|
|
3352
|
-
super(G, e), this.items = [];
|
|
3353
|
-
}
|
|
3354
|
-
/**
|
|
3355
|
-
* A generic collection parsing method that can be extended
|
|
3356
|
-
* to other node classes that inherit from YAMLMap
|
|
3357
|
-
*/
|
|
3358
|
-
static from(e, t, n) {
|
|
3359
|
-
const { keepUndefined: i, replacer: r } = n, o = new this(e), a = (l, u) => {
|
|
3360
|
-
if (typeof r == "function")
|
|
3361
|
-
u = r.call(t, l, u);
|
|
3362
|
-
else if (Array.isArray(r) && !r.includes(l))
|
|
3363
|
-
return;
|
|
3364
|
-
(u !== void 0 || i) && o.items.push(ke(l, u, n));
|
|
3365
|
-
};
|
|
3366
|
-
if (t instanceof Map)
|
|
3367
|
-
for (const [l, u] of t)
|
|
3368
|
-
a(l, u);
|
|
3369
|
-
else if (t && typeof t == "object")
|
|
3370
|
-
for (const l of Object.keys(t))
|
|
3371
|
-
a(l, t[l]);
|
|
3372
|
-
return typeof e.sortMapEntries == "function" && o.items.sort(e.sortMapEntries), o;
|
|
3373
|
-
}
|
|
3374
|
-
/**
|
|
3375
|
-
* Adds a value to the collection.
|
|
3376
|
-
*
|
|
3377
|
-
* @param overwrite - If not set `true`, using a key that is already in the
|
|
3378
|
-
* collection will throw. Otherwise, overwrites the previous value.
|
|
3379
|
-
*/
|
|
3380
|
-
add(e, t) {
|
|
3381
|
-
var o;
|
|
3382
|
-
let n;
|
|
3383
|
-
M(e) ? n = e : !e || typeof e != "object" || !("key" in e) ? n = new _(e, e == null ? void 0 : e.value) : n = new _(e.key, e.value);
|
|
3384
|
-
const i = H(this.items, n.key), r = (o = this.schema) == null ? void 0 : o.sortMapEntries;
|
|
3385
|
-
if (i) {
|
|
3386
|
-
if (!t)
|
|
3387
|
-
throw new Error(`Key ${n.key} already set`);
|
|
3388
|
-
O(i.value) && Vt(n.value) ? i.value.value = n.value : i.value = n.value;
|
|
3389
|
-
} else if (r) {
|
|
3390
|
-
const a = this.items.findIndex((l) => r(n, l) < 0);
|
|
3391
|
-
a === -1 ? this.items.push(n) : this.items.splice(a, 0, n);
|
|
3392
|
-
} else
|
|
3393
|
-
this.items.push(n);
|
|
3394
|
-
}
|
|
3395
|
-
delete(e) {
|
|
3396
|
-
const t = H(this.items, e);
|
|
3397
|
-
return t ? this.items.splice(this.items.indexOf(t), 1).length > 0 : !1;
|
|
3398
|
-
}
|
|
3399
|
-
get(e, t) {
|
|
3400
|
-
const n = H(this.items, e), i = n == null ? void 0 : n.value;
|
|
3401
|
-
return (!t && O(i) ? i.value : i) ?? void 0;
|
|
3402
|
-
}
|
|
3403
|
-
has(e) {
|
|
3404
|
-
return !!H(this.items, e);
|
|
3405
|
-
}
|
|
3406
|
-
set(e, t) {
|
|
3407
|
-
this.add(new _(e, t), !0);
|
|
3408
|
-
}
|
|
3409
|
-
/**
|
|
3410
|
-
* @param ctx - Conversion context, originally set in Document#toJS()
|
|
3411
|
-
* @param {Class} Type - If set, forces the returned collection type
|
|
3412
|
-
* @returns Instance of Type, Map, or Object
|
|
3413
|
-
*/
|
|
3414
|
-
toJSON(e, t, n) {
|
|
3415
|
-
const i = n ? new n() : t != null && t.mapAsMap ? /* @__PURE__ */ new Map() : {};
|
|
3416
|
-
t != null && t.onCreate && t.onCreate(i);
|
|
3417
|
-
for (const r of this.items)
|
|
3418
|
-
_t(t, i, r);
|
|
3419
|
-
return i;
|
|
3420
|
-
}
|
|
3421
|
-
toString(e, t, n) {
|
|
3422
|
-
if (!e)
|
|
3423
|
-
return JSON.stringify(this);
|
|
3424
|
-
for (const i of this.items)
|
|
3425
|
-
if (!M(i))
|
|
3426
|
-
throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);
|
|
3427
|
-
return !e.allNullValues && this.hasAllNullValues(!1) && (e = Object.assign({}, e, { allNullValues: !0 })), Kt(this, e, {
|
|
3428
|
-
blockItemPrefix: "",
|
|
3429
|
-
flowChars: { start: "{", end: "}" },
|
|
3430
|
-
itemIndent: e.indent || "",
|
|
3431
|
-
onChompKeep: n,
|
|
3432
|
-
onComment: t
|
|
3433
|
-
});
|
|
3434
|
-
}
|
|
3435
|
-
}
|
|
3436
|
-
class kt extends Jt {
|
|
3437
|
-
static get tagName() {
|
|
3438
|
-
return "tag:yaml.org,2002:seq";
|
|
3439
|
-
}
|
|
3440
|
-
constructor(e) {
|
|
3441
|
-
super(ue, e), this.items = [];
|
|
3442
|
-
}
|
|
3443
|
-
add(e) {
|
|
3444
|
-
this.items.push(e);
|
|
3445
|
-
}
|
|
3446
|
-
/**
|
|
3447
|
-
* Removes a value from the collection.
|
|
3448
|
-
*
|
|
3449
|
-
* `key` must contain a representation of an integer for this to succeed.
|
|
3450
|
-
* It may be wrapped in a `Scalar`.
|
|
3451
|
-
*
|
|
3452
|
-
* @returns `true` if the item was found and removed.
|
|
3453
|
-
*/
|
|
3454
|
-
delete(e) {
|
|
3455
|
-
const t = fe(e);
|
|
3456
|
-
return typeof t != "number" ? !1 : this.items.splice(t, 1).length > 0;
|
|
3457
|
-
}
|
|
3458
|
-
get(e, t) {
|
|
3459
|
-
const n = fe(e);
|
|
3460
|
-
if (typeof n != "number")
|
|
3461
|
-
return;
|
|
3462
|
-
const i = this.items[n];
|
|
3463
|
-
return !t && O(i) ? i.value : i;
|
|
3464
|
-
}
|
|
3465
|
-
/**
|
|
3466
|
-
* Checks if the collection includes a value with the key `key`.
|
|
3467
|
-
*
|
|
3468
|
-
* `key` must contain a representation of an integer for this to succeed.
|
|
3469
|
-
* It may be wrapped in a `Scalar`.
|
|
3470
|
-
*/
|
|
3471
|
-
has(e) {
|
|
3472
|
-
const t = fe(e);
|
|
3473
|
-
return typeof t == "number" && t < this.items.length;
|
|
3474
|
-
}
|
|
3475
|
-
/**
|
|
3476
|
-
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
3477
|
-
* boolean to add/remove the item from the set.
|
|
3478
|
-
*
|
|
3479
|
-
* If `key` does not contain a representation of an integer, this will throw.
|
|
3480
|
-
* It may be wrapped in a `Scalar`.
|
|
3481
|
-
*/
|
|
3482
|
-
set(e, t) {
|
|
3483
|
-
const n = fe(e);
|
|
3484
|
-
if (typeof n != "number")
|
|
3485
|
-
throw new Error(`Expected a valid index, not ${e}.`);
|
|
3486
|
-
const i = this.items[n];
|
|
3487
|
-
O(i) && Vt(t) ? i.value = t : this.items[n] = t;
|
|
3488
|
-
}
|
|
3489
|
-
toJSON(e, t) {
|
|
3490
|
-
const n = [];
|
|
3491
|
-
t != null && t.onCreate && t.onCreate(n);
|
|
3492
|
-
let i = 0;
|
|
3493
|
-
for (const r of this.items)
|
|
3494
|
-
n.push(B(r, String(i++), t));
|
|
3495
|
-
return n;
|
|
3496
|
-
}
|
|
3497
|
-
toString(e, t, n) {
|
|
3498
|
-
return e ? Kt(this, e, {
|
|
3499
|
-
blockItemPrefix: "- ",
|
|
3500
|
-
flowChars: { start: "[", end: "]" },
|
|
3501
|
-
itemIndent: (e.indent || "") + " ",
|
|
3502
|
-
onChompKeep: n,
|
|
3503
|
-
onComment: t
|
|
3504
|
-
}) : JSON.stringify(this);
|
|
3505
|
-
}
|
|
3506
|
-
static from(e, t, n) {
|
|
3507
|
-
const { replacer: i } = n, r = new this(e);
|
|
3508
|
-
if (t && Symbol.iterator in Object(t)) {
|
|
3509
|
-
let o = 0;
|
|
3510
|
-
for (let a of t) {
|
|
3511
|
-
if (typeof i == "function") {
|
|
3512
|
-
const l = t instanceof Set ? a : String(o++);
|
|
3513
|
-
a = i.call(t, l, a);
|
|
3514
|
-
}
|
|
3515
|
-
r.items.push(we(a, void 0, n));
|
|
3516
|
-
}
|
|
3517
|
-
}
|
|
3518
|
-
return r;
|
|
3519
|
-
}
|
|
3520
|
-
}
|
|
3521
|
-
function fe(s) {
|
|
3522
|
-
let e = O(s) ? s.value : s;
|
|
3523
|
-
return e && typeof e == "string" && (e = Number(e)), typeof e == "number" && Number.isInteger(e) && e >= 0 ? e : null;
|
|
3524
|
-
}
|
|
3525
|
-
function Rn(s, e, t) {
|
|
3526
|
-
const { replacer: n } = t, i = new kt(s);
|
|
3527
|
-
i.tag = "tag:yaml.org,2002:pairs";
|
|
3528
|
-
let r = 0;
|
|
3529
|
-
if (e && Symbol.iterator in Object(e))
|
|
3530
|
-
for (let o of e) {
|
|
3531
|
-
typeof n == "function" && (o = n.call(e, String(r++), o));
|
|
3532
|
-
let a, l;
|
|
3533
|
-
if (Array.isArray(o))
|
|
3534
|
-
if (o.length === 2)
|
|
3535
|
-
a = o[0], l = o[1];
|
|
3536
|
-
else
|
|
3537
|
-
throw new TypeError(`Expected [key, value] tuple: ${o}`);
|
|
3538
|
-
else if (o && o instanceof Object) {
|
|
3539
|
-
const u = Object.keys(o);
|
|
3540
|
-
if (u.length === 1)
|
|
3541
|
-
a = u[0], l = o[a];
|
|
3542
|
-
else
|
|
3543
|
-
throw new TypeError(`Expected tuple with one key, not ${u.length} keys`);
|
|
3544
|
-
} else
|
|
3545
|
-
a = o;
|
|
3546
|
-
i.items.push(ke(a, l, t));
|
|
3547
|
-
}
|
|
3548
|
-
return i;
|
|
3549
|
-
}
|
|
3550
|
-
class Ye extends kt {
|
|
3551
|
-
constructor() {
|
|
3552
|
-
super(), this.add = Z.prototype.add.bind(this), this.delete = Z.prototype.delete.bind(this), this.get = Z.prototype.get.bind(this), this.has = Z.prototype.has.bind(this), this.set = Z.prototype.set.bind(this), this.tag = Ye.tag;
|
|
3553
|
-
}
|
|
3554
|
-
/**
|
|
3555
|
-
* If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
|
|
3556
|
-
* but TypeScript won't allow widening the signature of a child method.
|
|
3557
|
-
*/
|
|
3558
|
-
toJSON(e, t) {
|
|
3559
|
-
if (!t)
|
|
3560
|
-
return super.toJSON(e);
|
|
3561
|
-
const n = /* @__PURE__ */ new Map();
|
|
3562
|
-
t != null && t.onCreate && t.onCreate(n);
|
|
3563
|
-
for (const i of this.items) {
|
|
3564
|
-
let r, o;
|
|
3565
|
-
if (M(i) ? (r = B(i.key, "", t), o = B(i.value, r, t)) : r = B(i, "", t), n.has(r))
|
|
3566
|
-
throw new Error("Ordered maps must not include duplicate keys");
|
|
3567
|
-
n.set(r, o);
|
|
3568
|
-
}
|
|
3569
|
-
return n;
|
|
3570
|
-
}
|
|
3571
|
-
static from(e, t, n) {
|
|
3572
|
-
const i = Rn(e, t, n), r = new this();
|
|
3573
|
-
return r.items = i.items, r;
|
|
3574
|
-
}
|
|
3575
|
-
}
|
|
3576
|
-
Ye.tag = "tag:yaml.org,2002:omap";
|
|
3577
|
-
class He extends Z {
|
|
3578
|
-
constructor(e) {
|
|
3579
|
-
super(e), this.tag = He.tag;
|
|
3580
|
-
}
|
|
3581
|
-
add(e) {
|
|
3582
|
-
let t;
|
|
3583
|
-
M(e) ? t = e : e && typeof e == "object" && "key" in e && "value" in e && e.value === null ? t = new _(e.key, null) : t = new _(e, null), H(this.items, t.key) || this.items.push(t);
|
|
3584
|
-
}
|
|
3585
|
-
/**
|
|
3586
|
-
* If `keepPair` is `true`, returns the Pair matching `key`.
|
|
3587
|
-
* Otherwise, returns the value of that Pair's key.
|
|
3588
|
-
*/
|
|
3589
|
-
get(e, t) {
|
|
3590
|
-
const n = H(this.items, e);
|
|
3591
|
-
return !t && M(n) ? O(n.key) ? n.key.value : n.key : n;
|
|
3592
|
-
}
|
|
3593
|
-
set(e, t) {
|
|
3594
|
-
if (typeof t != "boolean")
|
|
3595
|
-
throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);
|
|
3596
|
-
const n = H(this.items, e);
|
|
3597
|
-
n && !t ? this.items.splice(this.items.indexOf(n), 1) : !n && t && this.items.push(new _(e));
|
|
3598
|
-
}
|
|
3599
|
-
toJSON(e, t) {
|
|
3600
|
-
return super.toJSON(e, t, Set);
|
|
3601
|
-
}
|
|
3602
|
-
toString(e, t, n) {
|
|
3603
|
-
if (!e)
|
|
3604
|
-
return JSON.stringify(this);
|
|
3605
|
-
if (this.hasAllNullValues(!0))
|
|
3606
|
-
return super.toString(Object.assign({}, e, { allNullValues: !0 }), t, n);
|
|
3607
|
-
throw new Error("Set items must all have null values");
|
|
3608
|
-
}
|
|
3609
|
-
static from(e, t, n) {
|
|
3610
|
-
const { replacer: i } = n, r = new this(e);
|
|
3611
|
-
if (t && Symbol.iterator in Object(t))
|
|
3612
|
-
for (let o of t)
|
|
3613
|
-
typeof i == "function" && (o = i.call(t, o, o)), r.items.push(ke(o, null, n));
|
|
3614
|
-
return r;
|
|
3615
|
-
}
|
|
3616
|
-
}
|
|
3617
|
-
He.tag = "tag:yaml.org,2002:set";
|
|
3618
|
-
new Set("0123456789ABCDEFabcdef");
|
|
3619
|
-
new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()");
|
|
3620
|
-
new Set(",[]{}");
|
|
3621
|
-
new Set(` ,[]{}
|
|
3622
|
-
\r `);
|
|
3623
|
-
function Wn(s) {
|
|
3624
|
-
var t, n, i, r;
|
|
3625
|
-
let e = 0;
|
|
3626
|
-
return e += (((t = s.measures) == null ? void 0 : t.length) || 0) * 1, e += (((n = s.dimensions) == null ? void 0 : n.length) || 0) * 1, e += (((i = s.filters) == null ? void 0 : i.length) || 0) * 2, e += (((r = s.timeDimensions) == null ? void 0 : r.length) || 0) * 3, e <= 5 ? "low" : e <= 15 ? "medium" : "high";
|
|
3627
|
-
}
|
|
3628
|
-
function _n() {
|
|
3629
|
-
const s = Date.now(), e = Math.random().toString(36).substring(2, 9);
|
|
3630
|
-
return `${s}-${e}`;
|
|
3631
|
-
}
|
|
3632
|
-
function Kn(s) {
|
|
3633
|
-
const e = s.dimensions || [], t = s.timeDimensions || [], n = s.measures || [];
|
|
3634
|
-
return {
|
|
3635
|
-
sortedDimensions: e,
|
|
3636
|
-
sortedTimeDimensions: t,
|
|
3637
|
-
timeDimensions: t,
|
|
3638
|
-
measures: n,
|
|
3639
|
-
leafMeasureAdditive: !0,
|
|
3640
|
-
leafMeasures: n,
|
|
3641
|
-
measureToLeafMeasures: {},
|
|
3642
|
-
hasNoTimeDimensionsWithoutGranularity: !0,
|
|
3643
|
-
allFiltersWithinSelectedDimensions: !0,
|
|
3644
|
-
isAdditive: !0,
|
|
3645
|
-
granularityHierarchies: {},
|
|
3646
|
-
hasMultipliedMeasures: !1,
|
|
3647
|
-
hasCumulativeMeasures: !1,
|
|
3648
|
-
windowGranularity: null,
|
|
3649
|
-
filterDimensionsSingleValueEqual: {},
|
|
3650
|
-
ownedDimensions: e,
|
|
3651
|
-
ownedTimeDimensionsWithRollupGranularity: [],
|
|
3652
|
-
ownedTimeDimensionsAsIs: [],
|
|
3653
|
-
allBackAliasMembers: {},
|
|
3654
|
-
hasMultiStage: !1
|
|
3655
|
-
};
|
|
3656
|
-
}
|
|
3657
|
-
function kn(s) {
|
|
3658
|
-
if (s.hasExecutor()) {
|
|
3659
|
-
const e = s.databaseExecutor;
|
|
3660
|
-
if (e != null && e.engineType)
|
|
3661
|
-
return e.engineType;
|
|
3662
|
-
}
|
|
3663
|
-
return "postgres";
|
|
3664
|
-
}
|
|
3665
|
-
async function Hn(s, e, t) {
|
|
3666
|
-
var l, u, c, f;
|
|
3667
|
-
const n = t.validateQuery(s);
|
|
3668
|
-
if (!n.isValid)
|
|
3669
|
-
throw new Error(`Query validation failed: ${n.errors.join(", ")}`);
|
|
3670
|
-
const i = /* @__PURE__ */ new Set();
|
|
3671
|
-
(l = s.measures) == null || l.forEach((d) => {
|
|
3672
|
-
const p = d.split(".")[0];
|
|
3673
|
-
i.add(p);
|
|
3674
|
-
}), (u = s.dimensions) == null || u.forEach((d) => {
|
|
3675
|
-
const p = d.split(".")[0];
|
|
3676
|
-
i.add(p);
|
|
3677
|
-
}), (c = s.timeDimensions) == null || c.forEach((d) => {
|
|
3678
|
-
const p = d.dimension.split(".")[0];
|
|
3679
|
-
i.add(p);
|
|
3680
|
-
}), (f = s.filters) == null || f.forEach((d) => {
|
|
3681
|
-
if ("member" in d) {
|
|
3682
|
-
const p = d.member.split(".")[0];
|
|
3683
|
-
i.add(p);
|
|
3684
|
-
}
|
|
3685
|
-
});
|
|
3686
|
-
const r = i.size > 1;
|
|
3687
|
-
let o;
|
|
3688
|
-
if (r)
|
|
3689
|
-
o = await t.generateMultiCubeSQL(s, e);
|
|
3690
|
-
else {
|
|
3691
|
-
const d = Array.from(i)[0];
|
|
3692
|
-
o = await t.generateSQL(d, s, e);
|
|
3693
|
-
}
|
|
3694
|
-
const a = Array.from(i).map((d) => {
|
|
3695
|
-
var p, y;
|
|
3696
|
-
return {
|
|
3697
|
-
cube: d,
|
|
3698
|
-
query: {
|
|
3699
|
-
measures: ((p = s.measures) == null ? void 0 : p.filter((h) => h.startsWith(d + "."))) || [],
|
|
3700
|
-
dimensions: ((y = s.dimensions) == null ? void 0 : y.filter((h) => h.startsWith(d + "."))) || [],
|
|
3701
|
-
filters: s.filters || [],
|
|
3702
|
-
timeDimensions: s.timeDimensions || [],
|
|
3703
|
-
order: s.order || {},
|
|
3704
|
-
limit: s.limit,
|
|
3705
|
-
offset: s.offset
|
|
3706
|
-
}
|
|
3707
|
-
};
|
|
3708
|
-
});
|
|
3709
|
-
return {
|
|
3710
|
-
queryType: "regularQuery",
|
|
3711
|
-
normalizedQueries: a,
|
|
3712
|
-
queryOrder: Array.from(i),
|
|
3713
|
-
transformedQueries: a,
|
|
3714
|
-
pivotQuery: {
|
|
3715
|
-
query: s,
|
|
3716
|
-
cubes: Array.from(i)
|
|
3717
|
-
},
|
|
3718
|
-
sql: {
|
|
3719
|
-
sql: [o.sql],
|
|
3720
|
-
params: o.params || []
|
|
3721
|
-
},
|
|
3722
|
-
complexity: Wn(s),
|
|
3723
|
-
valid: !0,
|
|
3724
|
-
cubesUsed: Array.from(i),
|
|
3725
|
-
joinType: r ? "multi_cube_join" : "single_cube",
|
|
3726
|
-
query: s
|
|
3727
|
-
};
|
|
3728
|
-
}
|
|
3729
|
-
function Gn(s, e, t) {
|
|
3730
|
-
const n = kn(t), i = _n(), r = (/* @__PURE__ */ new Date()).toISOString(), o = Kn(s);
|
|
3731
|
-
return {
|
|
3732
|
-
queryType: "regularQuery",
|
|
3733
|
-
results: [{
|
|
3734
|
-
query: s,
|
|
3735
|
-
lastRefreshTime: r,
|
|
3736
|
-
usedPreAggregations: {},
|
|
3737
|
-
transformedQuery: o,
|
|
3738
|
-
requestId: i,
|
|
3739
|
-
annotation: e.annotation,
|
|
3740
|
-
dataSource: "default",
|
|
3741
|
-
dbType: n,
|
|
3742
|
-
extDbType: n,
|
|
3743
|
-
external: !1,
|
|
3744
|
-
slowQuery: !1,
|
|
3745
|
-
data: e.data
|
|
3746
|
-
}],
|
|
3747
|
-
pivotQuery: {
|
|
3748
|
-
...s,
|
|
3749
|
-
queryType: "regularQuery"
|
|
3750
|
-
},
|
|
3751
|
-
slowQuery: !1
|
|
3752
|
-
};
|
|
3753
|
-
}
|
|
3754
|
-
function Xn(s, e) {
|
|
3755
|
-
return {
|
|
3756
|
-
sql: e.sql,
|
|
3757
|
-
params: e.params || [],
|
|
3758
|
-
query: s
|
|
3759
|
-
};
|
|
3760
|
-
}
|
|
3761
|
-
function Zn(s) {
|
|
3762
|
-
return {
|
|
3763
|
-
cubes: s
|
|
3764
|
-
};
|
|
3765
|
-
}
|
|
3766
|
-
function qn(s, e = 500) {
|
|
3767
|
-
return {
|
|
3768
|
-
error: s instanceof Error ? s.message : s,
|
|
3769
|
-
status: e
|
|
3770
|
-
};
|
|
3771
|
-
}
|
|
3772
|
-
export {
|
|
3773
|
-
wn as S,
|
|
3774
|
-
Zn as a,
|
|
3775
|
-
Xn as b,
|
|
3776
|
-
qn as c,
|
|
3777
|
-
Gn as f,
|
|
3778
|
-
Hn as h
|
|
3779
|
-
};
|