@sisense/mcp-server 0.2.6 → 0.2.8
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/{ai-qt2rw4p0.js → ai-3wz11tv8.js} +414 -414
- package/dist/{index-mxkgxy04.js → index-c0zk3ctc.js} +25524 -21921
- package/dist/{sse-server-kpkj0hbc.js → sse-server-dkaznf2x.js} +24223 -23378
- package/dist/sse-server-tg36wntb.js +2814 -0
- package/dist/sse-server-xfrv5734.js +6406 -0
- package/dist/sse-server.js +21 -13
- package/dist/view.html +591 -538
- package/dist/{widget-renderer-wjrpnwpy.js → widget-renderer-56n3m26y.js} +6 -7
- package/package.json +4 -4
- package/dist/sse-server-22mq7fhc.js +0 -2254
- package/dist/sse-server-d3yx2z0r.js +0 -6296
|
@@ -1,2254 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Bi,
|
|
3
|
-
C,
|
|
4
|
-
Cd,
|
|
5
|
-
Dr,
|
|
6
|
-
E,
|
|
7
|
-
Ed,
|
|
8
|
-
Fi,
|
|
9
|
-
Gh,
|
|
10
|
-
Hh,
|
|
11
|
-
Ii,
|
|
12
|
-
Jh,
|
|
13
|
-
Kh,
|
|
14
|
-
Nd,
|
|
15
|
-
Ni,
|
|
16
|
-
Nr,
|
|
17
|
-
Od,
|
|
18
|
-
Oe,
|
|
19
|
-
Or,
|
|
20
|
-
Qh,
|
|
21
|
-
Ui,
|
|
22
|
-
Ve,
|
|
23
|
-
Vh,
|
|
24
|
-
Vt,
|
|
25
|
-
Wh,
|
|
26
|
-
Xh,
|
|
27
|
-
Y,
|
|
28
|
-
Yh,
|
|
29
|
-
Z,
|
|
30
|
-
Zh,
|
|
31
|
-
_d,
|
|
32
|
-
ap,
|
|
33
|
-
be,
|
|
34
|
-
bh,
|
|
35
|
-
bp,
|
|
36
|
-
br,
|
|
37
|
-
dp,
|
|
38
|
-
ep,
|
|
39
|
-
fp,
|
|
40
|
-
ft,
|
|
41
|
-
g,
|
|
42
|
-
h1 as h,
|
|
43
|
-
ip,
|
|
44
|
-
ji,
|
|
45
|
-
kh,
|
|
46
|
-
m,
|
|
47
|
-
me,
|
|
48
|
-
mp,
|
|
49
|
-
ne,
|
|
50
|
-
pp,
|
|
51
|
-
qh,
|
|
52
|
-
rp,
|
|
53
|
-
tp,
|
|
54
|
-
wd,
|
|
55
|
-
wr,
|
|
56
|
-
wt,
|
|
57
|
-
xd,
|
|
58
|
-
xt,
|
|
59
|
-
ye,
|
|
60
|
-
ys,
|
|
61
|
-
zh
|
|
62
|
-
} from "./sse-server-d3yx2z0r.js";
|
|
63
|
-
|
|
64
|
-
// node_modules/@sisense/sdk-ui/dist/dimensions-BiLyFpCg.js
|
|
65
|
-
class c extends br {
|
|
66
|
-
constructor(e, t, s, r, u, m2, l, d, y, a) {
|
|
67
|
-
if (super(e, u || E.Dimension, m2, d, y), this.__serializable = "DimensionalDimension", this._dimensions = [], this._attributes = [], this._sort = C.None, !y && t) {
|
|
68
|
-
const { table: g2, column: b } = Oe(t);
|
|
69
|
-
this.composeCode = `${Ni}.${ft(g2)}.${ft(b)}`;
|
|
70
|
-
}
|
|
71
|
-
this._sort = l || C.None, this._expression = t, this.setDimensions(r || []), this.setAttributes(s), a && (this.defaultAttribute = a);
|
|
72
|
-
}
|
|
73
|
-
static parseType(e) {
|
|
74
|
-
switch (e) {
|
|
75
|
-
case "datetime":
|
|
76
|
-
case E.DateDimension:
|
|
77
|
-
return E.DateDimension;
|
|
78
|
-
case "text":
|
|
79
|
-
case E.TextDimension:
|
|
80
|
-
return E.TextDimension;
|
|
81
|
-
case "numeric":
|
|
82
|
-
case E.NumericDimension:
|
|
83
|
-
return E.NumericDimension;
|
|
84
|
-
}
|
|
85
|
-
return E.TextDimension;
|
|
86
|
-
}
|
|
87
|
-
getAttachedName(e, t) {
|
|
88
|
-
let s = e;
|
|
89
|
-
const r = me(e);
|
|
90
|
-
return (r === "id" || r === "name" || Object.getOwnPropertyDescriptor(this, r) !== undefined || this[r] !== undefined) && (s = t), s;
|
|
91
|
-
}
|
|
92
|
-
setDimensions(e) {
|
|
93
|
-
this._dimensions = e;
|
|
94
|
-
for (let t = 0;t < e.length; t++) {
|
|
95
|
-
const s = this.getAttachedName(e[t].name, e[t].attributes[0].expression);
|
|
96
|
-
this[me(s)] = e[t], s != e[t].name && (e[t].name = s);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
setAttributes(e) {
|
|
100
|
-
this._attributes = e || [];
|
|
101
|
-
for (let t = 0;t < e.length; t++) {
|
|
102
|
-
const s = this.getAttachedName(e[t].name, e[t].expression);
|
|
103
|
-
this[me(s)] = e[t], e[t].name != s && (e[t].name = s);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
get id() {
|
|
107
|
-
return this._expression;
|
|
108
|
-
}
|
|
109
|
-
get attributes() {
|
|
110
|
-
return this._attributes;
|
|
111
|
-
}
|
|
112
|
-
get dimensions() {
|
|
113
|
-
return this._dimensions;
|
|
114
|
-
}
|
|
115
|
-
get expression() {
|
|
116
|
-
return this._expression;
|
|
117
|
-
}
|
|
118
|
-
getSort() {
|
|
119
|
-
return this._sort;
|
|
120
|
-
}
|
|
121
|
-
sort(e) {
|
|
122
|
-
return new c(this.name, this.expression, this.attributes, this.dimensions, this.type, this.description, e, this.dataSource, this.composeCode, this.defaultAttribute);
|
|
123
|
-
}
|
|
124
|
-
serialize() {
|
|
125
|
-
const e = super.serialize();
|
|
126
|
-
return e.expression = this.expression, this.getSort() !== undefined && (e.sort = this.getSort()), e.attributes = this._attributes.map((t) => t.serialize()), e.dimensions = this._dimensions.map((t) => t.serialize()), this.defaultAttribute && (e.defaultAttribute = this.defaultAttribute.serialize()), e;
|
|
127
|
-
}
|
|
128
|
-
jaql(e) {
|
|
129
|
-
if (this.defaultAttribute)
|
|
130
|
-
return this.defaultAttribute.jaql(e);
|
|
131
|
-
if (this.dimensions.length > 0)
|
|
132
|
-
return this.dimensions[0].jaql(e);
|
|
133
|
-
const t = {
|
|
134
|
-
jaql: {
|
|
135
|
-
title: this.name,
|
|
136
|
-
dim: this.expression,
|
|
137
|
-
datatype: ys(this.type)
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
return this._sort != C.None && (t.jaql.sort = this._sort == C.Ascending ? "asc" : "desc"), e === true ? t.jaql : t;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
var z = (i) => i && i.__serializable === "DimensionalDimension";
|
|
144
|
-
|
|
145
|
-
class p extends c {
|
|
146
|
-
constructor(e, t, s, r, u, m2) {
|
|
147
|
-
super(e, t, [], [], E.DateDimension, s, r, u, m2), this.__serializable = "DimensionalDateDimension", this.defaultLevel = g.Years, this.Years = new Y(g.Years, t, g.Years, "yyyy", s, r, u), this.Quarters = new Y(g.Quarters, t, g.Quarters, "Q yyyy", s, r, u), this.Months = new Y(g.Months, t, g.Months, "yyyy-MM", s, r, u), this.Weeks = new Y(g.Weeks, t, g.Weeks, "ww yyyy", s, r, u), this.Days = new Y(g.Days, t, g.Days, "yyyy-MM-dd", s, r, u), this.Hours = new Y(g.Hours, t, g.Hours, "yyyy-MM-dd HH:mm", s, r, u), this.MinutesRoundTo30 = new Y(g.MinutesRoundTo30, t, g.MinutesRoundTo30, "yyyy-MM-dd HH:mm", s, r, u), this.MinutesRoundTo15 = new Y(g.MinutesRoundTo15, t, g.MinutesRoundTo15, "yyyy-MM-dd HH:mm", s, r, u), this.Minutes = new Y(g.Minutes, t, g.Minutes, "yyyy-MM-dd HH:mm", s, r, u), this.Seconds = new Y(g.Seconds, t, g.Seconds, "yyyy-MM-dd HH:mm:ss", s, r, u), this.AggHours = new Y(g.AggHours, t, g.AggHours, "HH:mm", s, r, u), this.AggMinutesRoundTo30 = new Y(g.AggMinutesRoundTo30, t, g.AggMinutesRoundTo30, "HH:mm", s, r, u), this.AggMinutesRoundTo15 = new Y(g.AggMinutesRoundTo15, t, g.AggMinutesRoundTo15, "HH:mm", s, r, u), this.AggMinutesRoundTo1 = new Y(g.AggMinutesRoundTo1, t, g.AggMinutesRoundTo1, "HH:mm", s, r, u), this.setAttributes([
|
|
148
|
-
this.Years,
|
|
149
|
-
this.Quarters,
|
|
150
|
-
this.Months,
|
|
151
|
-
this.Weeks,
|
|
152
|
-
this.Days,
|
|
153
|
-
this.Hours,
|
|
154
|
-
this.MinutesRoundTo30,
|
|
155
|
-
this.MinutesRoundTo15,
|
|
156
|
-
this.Minutes,
|
|
157
|
-
this.Seconds,
|
|
158
|
-
this.AggHours,
|
|
159
|
-
this.AggMinutesRoundTo30,
|
|
160
|
-
this.AggMinutesRoundTo15,
|
|
161
|
-
this.AggMinutesRoundTo1
|
|
162
|
-
]);
|
|
163
|
-
}
|
|
164
|
-
get id() {
|
|
165
|
-
return this.expression;
|
|
166
|
-
}
|
|
167
|
-
setDimensions() {}
|
|
168
|
-
setAttributes(e) {
|
|
169
|
-
this._attributes = e;
|
|
170
|
-
}
|
|
171
|
-
getSort() {
|
|
172
|
-
return this._sort;
|
|
173
|
-
}
|
|
174
|
-
sort(e) {
|
|
175
|
-
return new p(this.name, this.expression, this.description, e, this.dataSource, this.composeCode);
|
|
176
|
-
}
|
|
177
|
-
serialize() {
|
|
178
|
-
return super.serialize();
|
|
179
|
-
}
|
|
180
|
-
jaql(e) {
|
|
181
|
-
const t = this[this.defaultLevel].jaql();
|
|
182
|
-
return t.jaql.title = this.name, e ? t.jaql : t;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
var q = (i) => i && i.__serializable === "DimensionalDateDimension";
|
|
186
|
-
function R(i) {
|
|
187
|
-
const e = i.name || i.title, t = i.desc || i.description, s = i.expression || i.dim, r = c.parseType(i.dimtype || i.type), u = i.sort, m2 = i.dataSource;
|
|
188
|
-
if (r == E.DateDimension)
|
|
189
|
-
return new p(e, s, t, u, m2);
|
|
190
|
-
const l = Object.getOwnPropertyNames(i).map((a) => i[a]).filter((a) => E.isAttribute(a == null ? undefined : a.type));
|
|
191
|
-
if (l.length == 0)
|
|
192
|
-
if (i.attributes) {
|
|
193
|
-
let a;
|
|
194
|
-
for (let g2 = 0;g2 < i.attributes.length; g2++)
|
|
195
|
-
a = i.attributes[g2], l.push(new Ve(a.name, a.expression, a.type, a.description, a.sort, a.dataSource));
|
|
196
|
-
} else
|
|
197
|
-
s && l.push(new Ve(e, s, r, t, u, m2));
|
|
198
|
-
const d = Object.getOwnPropertyNames(i).map((a) => i[a]).filter((a) => E.isDimension(a == null ? undefined : a.type));
|
|
199
|
-
if (d.length == 0 && i.dimensions)
|
|
200
|
-
for (let a = 0;a < i.dimensions.length; a++)
|
|
201
|
-
d.push(R(i.dimensions[a]));
|
|
202
|
-
const y = new c(e, s, l, d, r, t, u, m2);
|
|
203
|
-
return i.defaultAttribute && (y.defaultAttribute = l.find((a) => a.name === i.defaultAttribute)), y;
|
|
204
|
-
}
|
|
205
|
-
function x(i) {
|
|
206
|
-
const e = i.name || i.title, t = i.expression || i.dim, s = i.desc || i.description, r = i.sort, u = i.dataSource;
|
|
207
|
-
return new p(e, t, s, r, u);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// node_modules/@sisense/sdk-ui/dist/analytics-composer/node.js
|
|
211
|
-
var er = Object.defineProperty;
|
|
212
|
-
var rr = Object.defineProperties;
|
|
213
|
-
var tr = Object.getOwnPropertyDescriptors;
|
|
214
|
-
var ye2 = Object.getOwnPropertySymbols;
|
|
215
|
-
var sr = Object.prototype.hasOwnProperty;
|
|
216
|
-
var nr = Object.prototype.propertyIsEnumerable;
|
|
217
|
-
var ge = (e, r, t) => (r in e) ? er(e, r, { enumerable: true, configurable: true, writable: true, value: t }) : e[r] = t;
|
|
218
|
-
var g2 = (e, r) => {
|
|
219
|
-
for (var t in r || (r = {}))
|
|
220
|
-
sr.call(r, t) && ge(e, t, r[t]);
|
|
221
|
-
if (ye2)
|
|
222
|
-
for (var t of ye2(r))
|
|
223
|
-
nr.call(r, t) && ge(e, t, r[t]);
|
|
224
|
-
return e;
|
|
225
|
-
};
|
|
226
|
-
var h2 = (e, r) => rr(e, tr(r));
|
|
227
|
-
|
|
228
|
-
class st {
|
|
229
|
-
constructor() {
|
|
230
|
-
this.keyToValue = /* @__PURE__ */ new Map, this.valueToKey = /* @__PURE__ */ new Map;
|
|
231
|
-
}
|
|
232
|
-
set(r, t) {
|
|
233
|
-
this.keyToValue.set(r, t), this.valueToKey.set(t, r);
|
|
234
|
-
}
|
|
235
|
-
getByKey(r) {
|
|
236
|
-
return this.keyToValue.get(r);
|
|
237
|
-
}
|
|
238
|
-
getByValue(r) {
|
|
239
|
-
return this.valueToKey.get(r);
|
|
240
|
-
}
|
|
241
|
-
clear() {
|
|
242
|
-
this.keyToValue.clear(), this.valueToKey.clear();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
class De {
|
|
247
|
-
constructor(r) {
|
|
248
|
-
this.generateIdentifier = r, this.kv = new st;
|
|
249
|
-
}
|
|
250
|
-
register(r, t) {
|
|
251
|
-
this.kv.getByValue(r) || (t || (t = this.generateIdentifier(r)), this.kv.set(t, r));
|
|
252
|
-
}
|
|
253
|
-
clear() {
|
|
254
|
-
this.kv.clear();
|
|
255
|
-
}
|
|
256
|
-
getIdentifier(r) {
|
|
257
|
-
return this.kv.getByValue(r);
|
|
258
|
-
}
|
|
259
|
-
getValue(r) {
|
|
260
|
-
return this.kv.getByKey(r);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
class nt extends De {
|
|
265
|
-
constructor() {
|
|
266
|
-
super((r) => r.name), this.classToAllowedProps = /* @__PURE__ */ new Map;
|
|
267
|
-
}
|
|
268
|
-
register(r, t) {
|
|
269
|
-
typeof t == "object" ? (t.allowProps && this.classToAllowedProps.set(r, t.allowProps), super.register(r, t.identifier)) : super.register(r, t);
|
|
270
|
-
}
|
|
271
|
-
getAllowedProps(r) {
|
|
272
|
-
return this.classToAllowedProps.get(r);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
function it(e) {
|
|
276
|
-
if ("values" in Object)
|
|
277
|
-
return Object.values(e);
|
|
278
|
-
const r = [];
|
|
279
|
-
for (const t in e)
|
|
280
|
-
e.hasOwnProperty(t) && r.push(e[t]);
|
|
281
|
-
return r;
|
|
282
|
-
}
|
|
283
|
-
function ot(e, r) {
|
|
284
|
-
const t = it(e);
|
|
285
|
-
if ("find" in t)
|
|
286
|
-
return t.find(r);
|
|
287
|
-
const s = t;
|
|
288
|
-
for (let n = 0;n < s.length; n++) {
|
|
289
|
-
const o = s[n];
|
|
290
|
-
if (r(o))
|
|
291
|
-
return o;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
function z2(e, r) {
|
|
295
|
-
Object.entries(e).forEach(([t, s]) => r(s, t));
|
|
296
|
-
}
|
|
297
|
-
function j2(e, r) {
|
|
298
|
-
return e.indexOf(r) !== -1;
|
|
299
|
-
}
|
|
300
|
-
function be2(e, r) {
|
|
301
|
-
for (let t = 0;t < e.length; t++) {
|
|
302
|
-
const s = e[t];
|
|
303
|
-
if (r(s))
|
|
304
|
-
return s;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
class at {
|
|
309
|
-
constructor() {
|
|
310
|
-
this.transfomers = {};
|
|
311
|
-
}
|
|
312
|
-
register(r) {
|
|
313
|
-
this.transfomers[r.name] = r;
|
|
314
|
-
}
|
|
315
|
-
findApplicable(r) {
|
|
316
|
-
return ot(this.transfomers, (t) => t.isApplicable(r));
|
|
317
|
-
}
|
|
318
|
-
findByName(r) {
|
|
319
|
-
return this.transfomers[r];
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
var ut = (e) => Object.prototype.toString.call(e).slice(8, -1);
|
|
323
|
-
var Me = (e) => typeof e == "undefined";
|
|
324
|
-
var ct = (e) => e === null;
|
|
325
|
-
var k = (e) => typeof e != "object" || e === null || e === Object.prototype ? false : Object.getPrototypeOf(e) === null ? true : Object.getPrototypeOf(e) === Object.prototype;
|
|
326
|
-
var X = (e) => k(e) && Object.keys(e).length === 0;
|
|
327
|
-
var S = (e) => Array.isArray(e);
|
|
328
|
-
var lt = (e) => typeof e == "string";
|
|
329
|
-
var ft2 = (e) => typeof e == "number" && !isNaN(e);
|
|
330
|
-
var dt = (e) => typeof e == "boolean";
|
|
331
|
-
var mt = (e) => e instanceof RegExp;
|
|
332
|
-
var L = (e) => e instanceof Map;
|
|
333
|
-
var V = (e) => e instanceof Set;
|
|
334
|
-
var Se = (e) => ut(e) === "Symbol";
|
|
335
|
-
var pt = (e) => e instanceof Date && !isNaN(e.valueOf());
|
|
336
|
-
var yt = (e) => e instanceof Error;
|
|
337
|
-
var Fe = (e) => typeof e == "number" && isNaN(e);
|
|
338
|
-
var gt = (e) => dt(e) || ct(e) || Me(e) || ft2(e) || lt(e) || Se(e);
|
|
339
|
-
var ht = (e) => typeof e == "bigint";
|
|
340
|
-
var bt = (e) => e === 1 / 0 || e === -1 / 0;
|
|
341
|
-
var Ft = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView);
|
|
342
|
-
var wt2 = (e) => e instanceof URL;
|
|
343
|
-
var Te = (e) => e.replace(/\./g, "\\.");
|
|
344
|
-
var Y2 = (e) => e.map(String).map(Te).join(".");
|
|
345
|
-
var P = (e) => {
|
|
346
|
-
const r = [];
|
|
347
|
-
let t = "";
|
|
348
|
-
for (let n = 0;n < e.length; n++) {
|
|
349
|
-
let o = e.charAt(n);
|
|
350
|
-
if (o === "\\" && e.charAt(n + 1) === ".") {
|
|
351
|
-
t += ".", n++;
|
|
352
|
-
continue;
|
|
353
|
-
}
|
|
354
|
-
if (o === ".") {
|
|
355
|
-
r.push(t), t = "";
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
t += o;
|
|
359
|
-
}
|
|
360
|
-
const s = t;
|
|
361
|
-
return r.push(s), r;
|
|
362
|
-
};
|
|
363
|
-
function A(e, r, t, s) {
|
|
364
|
-
return {
|
|
365
|
-
isApplicable: e,
|
|
366
|
-
annotation: r,
|
|
367
|
-
transform: t,
|
|
368
|
-
untransform: s
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
var Ne = [
|
|
372
|
-
A(Me, "undefined", () => null, () => {}),
|
|
373
|
-
A(ht, "bigint", (e) => e.toString(), (e) => typeof BigInt != "undefined" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
|
|
374
|
-
A(pt, "Date", (e) => e.toISOString(), (e) => new Date(e)),
|
|
375
|
-
A(yt, "Error", (e, r) => {
|
|
376
|
-
const t = {
|
|
377
|
-
name: e.name,
|
|
378
|
-
message: e.message
|
|
379
|
-
};
|
|
380
|
-
return r.allowedErrorProps.forEach((s) => {
|
|
381
|
-
t[s] = e[s];
|
|
382
|
-
}), t;
|
|
383
|
-
}, (e, r) => {
|
|
384
|
-
const t = new Error(e.message);
|
|
385
|
-
return t.name = e.name, t.stack = e.stack, r.allowedErrorProps.forEach((s) => {
|
|
386
|
-
t[s] = e[s];
|
|
387
|
-
}), t;
|
|
388
|
-
}),
|
|
389
|
-
A(mt, "regexp", (e) => "" + e, (e) => {
|
|
390
|
-
const r = e.slice(1, e.lastIndexOf("/")), t = e.slice(e.lastIndexOf("/") + 1);
|
|
391
|
-
return new RegExp(r, t);
|
|
392
|
-
}),
|
|
393
|
-
A(V, "set", (e) => [...e.values()], (e) => new Set(e)),
|
|
394
|
-
A(L, "map", (e) => [...e.entries()], (e) => new Map(e)),
|
|
395
|
-
A((e) => Fe(e) || bt(e), "number", (e) => Fe(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
|
|
396
|
-
A((e) => e === 0 && 1 / e === -1 / 0, "number", () => "-0", Number),
|
|
397
|
-
A(wt2, "URL", (e) => e.toString(), (e) => new URL(e))
|
|
398
|
-
];
|
|
399
|
-
function J(e, r, t, s) {
|
|
400
|
-
return {
|
|
401
|
-
isApplicable: e,
|
|
402
|
-
annotation: r,
|
|
403
|
-
transform: t,
|
|
404
|
-
untransform: s
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
var Re = J((e, r) => Se(e) ? !!r.symbolRegistry.getIdentifier(e) : false, (e, r) => ["symbol", r.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, r, t) => {
|
|
408
|
-
const s = t.symbolRegistry.getValue(r[1]);
|
|
409
|
-
if (!s)
|
|
410
|
-
throw new Error("Trying to deserialize unknown symbol");
|
|
411
|
-
return s;
|
|
412
|
-
});
|
|
413
|
-
var qt = [
|
|
414
|
-
Int8Array,
|
|
415
|
-
Uint8Array,
|
|
416
|
-
Int16Array,
|
|
417
|
-
Uint16Array,
|
|
418
|
-
Int32Array,
|
|
419
|
-
Uint32Array,
|
|
420
|
-
Float32Array,
|
|
421
|
-
Float64Array,
|
|
422
|
-
Uint8ClampedArray
|
|
423
|
-
].reduce((e, r) => (e[r.name] = r, e), {});
|
|
424
|
-
var Oe2 = J(Ft, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, r) => {
|
|
425
|
-
const t = qt[r[1]];
|
|
426
|
-
if (!t)
|
|
427
|
-
throw new Error("Trying to deserialize unknown typed array");
|
|
428
|
-
return new t(e);
|
|
429
|
-
});
|
|
430
|
-
function Ie(e, r) {
|
|
431
|
-
return e != null && e.constructor ? !!r.classRegistry.getIdentifier(e.constructor) : false;
|
|
432
|
-
}
|
|
433
|
-
var ze = J(Ie, (e, r) => ["class", r.classRegistry.getIdentifier(e.constructor)], (e, r) => {
|
|
434
|
-
const t = r.classRegistry.getAllowedProps(e.constructor);
|
|
435
|
-
if (!t)
|
|
436
|
-
return g2({}, e);
|
|
437
|
-
const s = {};
|
|
438
|
-
return t.forEach((n) => {
|
|
439
|
-
s[n] = e[n];
|
|
440
|
-
}), s;
|
|
441
|
-
}, (e, r, t) => {
|
|
442
|
-
const s = t.classRegistry.getValue(r[1]);
|
|
443
|
-
if (!s)
|
|
444
|
-
throw new Error(`Trying to deserialize unknown class '${r[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
|
|
445
|
-
return Object.assign(Object.create(s.prototype), e);
|
|
446
|
-
});
|
|
447
|
-
var Be = J((e, r) => !!r.customTransformerRegistry.findApplicable(e), (e, r) => ["custom", r.customTransformerRegistry.findApplicable(e).name], (e, r) => r.customTransformerRegistry.findApplicable(e).serialize(e), (e, r, t) => {
|
|
448
|
-
const s = t.customTransformerRegistry.findByName(r[1]);
|
|
449
|
-
if (!s)
|
|
450
|
-
throw new Error("Trying to deserialize unknown custom value");
|
|
451
|
-
return s.deserialize(e);
|
|
452
|
-
});
|
|
453
|
-
var Et = [ze, Re, Be, Oe2];
|
|
454
|
-
var we = (e, r) => {
|
|
455
|
-
const t = be2(Et, (n) => n.isApplicable(e, r));
|
|
456
|
-
if (t)
|
|
457
|
-
return {
|
|
458
|
-
value: t.transform(e, r),
|
|
459
|
-
type: t.annotation(e, r)
|
|
460
|
-
};
|
|
461
|
-
const s = be2(Ne, (n) => n.isApplicable(e, r));
|
|
462
|
-
if (s)
|
|
463
|
-
return {
|
|
464
|
-
value: s.transform(e, r),
|
|
465
|
-
type: s.annotation
|
|
466
|
-
};
|
|
467
|
-
};
|
|
468
|
-
var Pe = {};
|
|
469
|
-
Ne.forEach((e) => {
|
|
470
|
-
Pe[e.annotation] = e;
|
|
471
|
-
});
|
|
472
|
-
var Ct = (e, r, t) => {
|
|
473
|
-
if (S(r))
|
|
474
|
-
switch (r[0]) {
|
|
475
|
-
case "symbol":
|
|
476
|
-
return Re.untransform(e, r, t);
|
|
477
|
-
case "class":
|
|
478
|
-
return ze.untransform(e, r, t);
|
|
479
|
-
case "custom":
|
|
480
|
-
return Be.untransform(e, r, t);
|
|
481
|
-
case "typed-array":
|
|
482
|
-
return Oe2.untransform(e, r, t);
|
|
483
|
-
default:
|
|
484
|
-
throw new Error("Unknown transformation: " + r);
|
|
485
|
-
}
|
|
486
|
-
else {
|
|
487
|
-
const s = Pe[r];
|
|
488
|
-
if (!s)
|
|
489
|
-
throw new Error("Unknown transformation: " + r);
|
|
490
|
-
return s.untransform(e, t);
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
var O = (e, r) => {
|
|
494
|
-
if (r > e.size)
|
|
495
|
-
throw new Error("index out of bounds");
|
|
496
|
-
const t = e.keys();
|
|
497
|
-
for (;r > 0; )
|
|
498
|
-
t.next(), r--;
|
|
499
|
-
return t.next().value;
|
|
500
|
-
};
|
|
501
|
-
function ke(e) {
|
|
502
|
-
if (j2(e, "__proto__"))
|
|
503
|
-
throw new Error("__proto__ is not allowed as a property");
|
|
504
|
-
if (j2(e, "prototype"))
|
|
505
|
-
throw new Error("prototype is not allowed as a property");
|
|
506
|
-
if (j2(e, "constructor"))
|
|
507
|
-
throw new Error("constructor is not allowed as a property");
|
|
508
|
-
}
|
|
509
|
-
var $t = (e, r) => {
|
|
510
|
-
ke(r);
|
|
511
|
-
for (let t = 0;t < r.length; t++) {
|
|
512
|
-
const s = r[t];
|
|
513
|
-
if (V(e))
|
|
514
|
-
e = O(e, +s);
|
|
515
|
-
else if (L(e)) {
|
|
516
|
-
const n = +s, o = +r[++t] == 0 ? "key" : "value", i = O(e, n);
|
|
517
|
-
switch (o) {
|
|
518
|
-
case "key":
|
|
519
|
-
e = i;
|
|
520
|
-
break;
|
|
521
|
-
case "value":
|
|
522
|
-
e = e.get(i);
|
|
523
|
-
break;
|
|
524
|
-
}
|
|
525
|
-
} else
|
|
526
|
-
e = e[s];
|
|
527
|
-
}
|
|
528
|
-
return e;
|
|
529
|
-
};
|
|
530
|
-
var v = (e, r, t) => {
|
|
531
|
-
if (ke(r), r.length === 0)
|
|
532
|
-
return t(e);
|
|
533
|
-
let s = e;
|
|
534
|
-
for (let o = 0;o < r.length - 1; o++) {
|
|
535
|
-
const i = r[o];
|
|
536
|
-
if (S(s)) {
|
|
537
|
-
const a = +i;
|
|
538
|
-
s = s[a];
|
|
539
|
-
} else if (k(s))
|
|
540
|
-
s = s[i];
|
|
541
|
-
else if (V(s)) {
|
|
542
|
-
const a = +i;
|
|
543
|
-
s = O(s, a);
|
|
544
|
-
} else if (L(s)) {
|
|
545
|
-
if (o === r.length - 2)
|
|
546
|
-
break;
|
|
547
|
-
const u = +i, c2 = +r[++o] == 0 ? "key" : "value", p2 = O(s, u);
|
|
548
|
-
switch (c2) {
|
|
549
|
-
case "key":
|
|
550
|
-
s = p2;
|
|
551
|
-
break;
|
|
552
|
-
case "value":
|
|
553
|
-
s = s.get(p2);
|
|
554
|
-
break;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
const n = r[r.length - 1];
|
|
559
|
-
if (S(s) ? s[+n] = t(s[+n]) : k(s) && (s[n] = t(s[n])), V(s)) {
|
|
560
|
-
const o = O(s, +n), i = t(o);
|
|
561
|
-
o !== i && (s.delete(o), s.add(i));
|
|
562
|
-
}
|
|
563
|
-
if (L(s)) {
|
|
564
|
-
const o = +r[r.length - 2], i = O(s, o);
|
|
565
|
-
switch (+n == 0 ? "key" : "value") {
|
|
566
|
-
case "key": {
|
|
567
|
-
const u = t(i);
|
|
568
|
-
s.set(u, s.get(i)), u !== i && s.delete(i);
|
|
569
|
-
break;
|
|
570
|
-
}
|
|
571
|
-
case "value": {
|
|
572
|
-
s.set(i, t(s.get(i)));
|
|
573
|
-
break;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
return e;
|
|
578
|
-
};
|
|
579
|
-
function ee(e, r, t = []) {
|
|
580
|
-
if (!e)
|
|
581
|
-
return;
|
|
582
|
-
if (!S(e)) {
|
|
583
|
-
z2(e, (o, i) => ee(o, r, [...t, ...P(i)]));
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
const [s, n] = e;
|
|
587
|
-
n && z2(n, (o, i) => {
|
|
588
|
-
ee(o, r, [...t, ...P(i)]);
|
|
589
|
-
}), r(s, t);
|
|
590
|
-
}
|
|
591
|
-
function At(e, r, t) {
|
|
592
|
-
return ee(r, (s, n) => {
|
|
593
|
-
e = v(e, n, (o) => Ct(o, s, t));
|
|
594
|
-
}), e;
|
|
595
|
-
}
|
|
596
|
-
function xt2(e, r) {
|
|
597
|
-
function t(s, n) {
|
|
598
|
-
const o = $t(e, P(n));
|
|
599
|
-
s.map(P).forEach((i) => {
|
|
600
|
-
e = v(e, i, () => o);
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
if (S(r)) {
|
|
604
|
-
const [s, n] = r;
|
|
605
|
-
s.forEach((o) => {
|
|
606
|
-
e = v(e, P(o), () => e);
|
|
607
|
-
}), n && z2(n, t);
|
|
608
|
-
} else
|
|
609
|
-
z2(r, t);
|
|
610
|
-
return e;
|
|
611
|
-
}
|
|
612
|
-
var Dt = (e, r) => k(e) || S(e) || L(e) || V(e) || Ie(e, r);
|
|
613
|
-
function Mt(e, r, t) {
|
|
614
|
-
const s = t.get(e);
|
|
615
|
-
s ? s.push(r) : t.set(e, [r]);
|
|
616
|
-
}
|
|
617
|
-
function St(e, r) {
|
|
618
|
-
const t = {};
|
|
619
|
-
let s;
|
|
620
|
-
return e.forEach((n) => {
|
|
621
|
-
if (n.length <= 1)
|
|
622
|
-
return;
|
|
623
|
-
r || (n = n.map((a) => a.map(String)).sort((a, u) => a.length - u.length));
|
|
624
|
-
const [o, ...i] = n;
|
|
625
|
-
o.length === 0 ? s = i.map(Y2) : t[Y2(o)] = i.map(Y2);
|
|
626
|
-
}), s ? X(t) ? [s] : [s, t] : X(t) ? undefined : t;
|
|
627
|
-
}
|
|
628
|
-
var Le = (e, r, t, s, n = [], o = [], i = /* @__PURE__ */ new Map) => {
|
|
629
|
-
var x2;
|
|
630
|
-
const a = gt(e);
|
|
631
|
-
if (!a) {
|
|
632
|
-
Mt(e, n, r);
|
|
633
|
-
const f2 = i.get(e);
|
|
634
|
-
if (f2)
|
|
635
|
-
return s ? {
|
|
636
|
-
transformedValue: null
|
|
637
|
-
} : f2;
|
|
638
|
-
}
|
|
639
|
-
if (!Dt(e, t)) {
|
|
640
|
-
const f2 = we(e, t), d = f2 ? {
|
|
641
|
-
transformedValue: f2.value,
|
|
642
|
-
annotations: [f2.type]
|
|
643
|
-
} : {
|
|
644
|
-
transformedValue: e
|
|
645
|
-
};
|
|
646
|
-
return a || i.set(e, d), d;
|
|
647
|
-
}
|
|
648
|
-
if (j2(o, e))
|
|
649
|
-
return {
|
|
650
|
-
transformedValue: null
|
|
651
|
-
};
|
|
652
|
-
const u = we(e, t), c2 = (x2 = u == null ? undefined : u.value) != null ? x2 : e, p2 = S(c2) ? [] : {}, m2 = {};
|
|
653
|
-
z2(c2, (f2, d) => {
|
|
654
|
-
if (d === "__proto__" || d === "constructor" || d === "prototype")
|
|
655
|
-
throw new Error(`Detected property ${d}. This is a prototype pollution risk, please remove it from your object.`);
|
|
656
|
-
const w = Le(f2, r, t, s, [...n, d], [...o, e], i);
|
|
657
|
-
p2[d] = w.transformedValue, S(w.annotations) ? m2[d] = w.annotations : k(w.annotations) && z2(w.annotations, ($, D) => {
|
|
658
|
-
m2[Te(d) + "." + D] = $;
|
|
659
|
-
});
|
|
660
|
-
});
|
|
661
|
-
const y = X(m2) ? {
|
|
662
|
-
transformedValue: p2,
|
|
663
|
-
annotations: u ? [u.type] : undefined
|
|
664
|
-
} : {
|
|
665
|
-
transformedValue: p2,
|
|
666
|
-
annotations: u ? [u.type, m2] : m2
|
|
667
|
-
};
|
|
668
|
-
return a || i.set(e, y), y;
|
|
669
|
-
};
|
|
670
|
-
function Ve2(e) {
|
|
671
|
-
return Object.prototype.toString.call(e).slice(8, -1);
|
|
672
|
-
}
|
|
673
|
-
function qe(e) {
|
|
674
|
-
return Ve2(e) === "Array";
|
|
675
|
-
}
|
|
676
|
-
function Tt(e) {
|
|
677
|
-
if (Ve2(e) !== "Object")
|
|
678
|
-
return false;
|
|
679
|
-
const r = Object.getPrototypeOf(e);
|
|
680
|
-
return !!r && r.constructor === Object && r === Object.prototype;
|
|
681
|
-
}
|
|
682
|
-
function Nt(e, r, t, s, n) {
|
|
683
|
-
const o = {}.propertyIsEnumerable.call(s, r) ? "enumerable" : "nonenumerable";
|
|
684
|
-
o === "enumerable" && (e[r] = t), n && o === "nonenumerable" && Object.defineProperty(e, r, {
|
|
685
|
-
value: t,
|
|
686
|
-
enumerable: false,
|
|
687
|
-
writable: true,
|
|
688
|
-
configurable: true
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
function re(e, r = {}) {
|
|
692
|
-
if (qe(e))
|
|
693
|
-
return e.map((n) => re(n, r));
|
|
694
|
-
if (!Tt(e))
|
|
695
|
-
return e;
|
|
696
|
-
const t = Object.getOwnPropertyNames(e), s = Object.getOwnPropertySymbols(e);
|
|
697
|
-
return [...t, ...s].reduce((n, o) => {
|
|
698
|
-
if (qe(r.props) && !r.props.includes(o))
|
|
699
|
-
return n;
|
|
700
|
-
const i = e[o], a = re(i, r);
|
|
701
|
-
return Nt(n, o, a, e, r.nonenumerable), n;
|
|
702
|
-
}, {});
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
class l {
|
|
706
|
-
constructor({ dedupe: r = false } = {}) {
|
|
707
|
-
this.classRegistry = new nt, this.symbolRegistry = new De((t) => {
|
|
708
|
-
var s;
|
|
709
|
-
return (s = t.description) != null ? s : "";
|
|
710
|
-
}), this.customTransformerRegistry = new at, this.allowedErrorProps = [], this.dedupe = r;
|
|
711
|
-
}
|
|
712
|
-
serialize(r) {
|
|
713
|
-
const t = /* @__PURE__ */ new Map, s = Le(r, t, this, this.dedupe), n = {
|
|
714
|
-
json: s.transformedValue
|
|
715
|
-
};
|
|
716
|
-
s.annotations && (n.meta = h2(g2({}, n.meta), {
|
|
717
|
-
values: s.annotations
|
|
718
|
-
}));
|
|
719
|
-
const o = St(t, this.dedupe);
|
|
720
|
-
return o && (n.meta = h2(g2({}, n.meta), {
|
|
721
|
-
referentialEqualities: o
|
|
722
|
-
})), n;
|
|
723
|
-
}
|
|
724
|
-
deserialize(r) {
|
|
725
|
-
const { json: t, meta: s } = r;
|
|
726
|
-
let n = re(t);
|
|
727
|
-
return s != null && s.values && (n = At(n, s.values, this)), s != null && s.referentialEqualities && (n = xt2(n, s.referentialEqualities)), n;
|
|
728
|
-
}
|
|
729
|
-
stringify(r) {
|
|
730
|
-
return JSON.stringify(this.serialize(r));
|
|
731
|
-
}
|
|
732
|
-
parse(r) {
|
|
733
|
-
return this.deserialize(JSON.parse(r));
|
|
734
|
-
}
|
|
735
|
-
registerClass(r, t) {
|
|
736
|
-
this.classRegistry.register(r, t);
|
|
737
|
-
}
|
|
738
|
-
registerSymbol(r, t) {
|
|
739
|
-
this.symbolRegistry.register(r, t);
|
|
740
|
-
}
|
|
741
|
-
registerCustom(r, t) {
|
|
742
|
-
this.customTransformerRegistry.register(g2({
|
|
743
|
-
name: t
|
|
744
|
-
}, r));
|
|
745
|
-
}
|
|
746
|
-
allowErrorProps(...r) {
|
|
747
|
-
this.allowedErrorProps.push(...r);
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
l.defaultInstance = new l;
|
|
751
|
-
l.serialize = l.defaultInstance.serialize.bind(l.defaultInstance);
|
|
752
|
-
l.deserialize = l.defaultInstance.deserialize.bind(l.defaultInstance);
|
|
753
|
-
l.stringify = l.defaultInstance.stringify.bind(l.defaultInstance);
|
|
754
|
-
l.parse = l.defaultInstance.parse.bind(l.defaultInstance);
|
|
755
|
-
l.registerClass = l.defaultInstance.registerClass.bind(l.defaultInstance);
|
|
756
|
-
l.registerSymbol = l.defaultInstance.registerSymbol.bind(l.defaultInstance);
|
|
757
|
-
l.registerCustom = l.defaultInstance.registerCustom.bind(l.defaultInstance);
|
|
758
|
-
l.allowErrorProps = l.defaultInstance.allowErrorProps.bind(l.defaultInstance);
|
|
759
|
-
var R2 = (e) => e === undefined ? C.None : e;
|
|
760
|
-
var Rt = (e) => new m(e.metadataItem, e.type);
|
|
761
|
-
var ae = (e) => new Ve(e.name, e.expression, e.type, e.description, R2(e.sort), e.dataSource, e.composeCode);
|
|
762
|
-
var ue = (e) => new Y(e.name, e.expression, e.granularity, e.format, e.description, R2(e.sort), e.dataSource, e.composeCode);
|
|
763
|
-
var q3 = (e) => {
|
|
764
|
-
switch (e.__serializable) {
|
|
765
|
-
case "DimensionalAttribute":
|
|
766
|
-
return ae(e);
|
|
767
|
-
case "DimensionalLevelAttribute":
|
|
768
|
-
return ue(e);
|
|
769
|
-
default:
|
|
770
|
-
return e;
|
|
771
|
-
}
|
|
772
|
-
};
|
|
773
|
-
var _e = (e) => new c(e.name, e.expression, e.attributes.map(q3), e.dimensions.map(Ot), e.type, e.description, R2(e.sort), e.dataSource, e.composeCode, e.defaultAttribute ? q3(e.defaultAttribute) : undefined);
|
|
774
|
-
var Ue = (e) => new p(e.name, e.expression, e.description, R2(e.sort), e.dataSource, e.composeCode);
|
|
775
|
-
var Ot = (e) => {
|
|
776
|
-
switch (e.__serializable) {
|
|
777
|
-
case "DimensionalDimension":
|
|
778
|
-
return _e(e);
|
|
779
|
-
case "DimensionalDateDimension":
|
|
780
|
-
return Ue(e);
|
|
781
|
-
default:
|
|
782
|
-
return e;
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
var ce = (e) => new be(e.name, q3(e.attribute), e.aggregation, e.format, e.description, R2(e.sort), e.dataSource, e.composeCode);
|
|
786
|
-
var le = (e) => {
|
|
787
|
-
const r = Object.fromEntries(Object.entries(e.context).map(([t, s]) => {
|
|
788
|
-
if (s && typeof s == "object" && "__serializable" in s)
|
|
789
|
-
switch (s.__serializable) {
|
|
790
|
-
case "DimensionalAttribute":
|
|
791
|
-
return [t, ae(s)];
|
|
792
|
-
case "DimensionalLevelAttribute":
|
|
793
|
-
return [t, ue(s)];
|
|
794
|
-
case "DimensionalBaseMeasure":
|
|
795
|
-
return [t, ce(s)];
|
|
796
|
-
case "DimensionalCalculatedMeasure":
|
|
797
|
-
return [t, le(s)];
|
|
798
|
-
default:
|
|
799
|
-
return [t, s];
|
|
800
|
-
}
|
|
801
|
-
return [t, s];
|
|
802
|
-
}));
|
|
803
|
-
return new Z(e.name, e.expression, r, e.format, e.description, R2(e.sort), e.dataSource, e.composeCode);
|
|
804
|
-
};
|
|
805
|
-
var We = (e) => new Vt(e.name, q3(e.attribute), e.format, e.description, R2(e.sort), e.dataSource, e.composeCode);
|
|
806
|
-
var H = (e) => {
|
|
807
|
-
switch (e.__serializable) {
|
|
808
|
-
case "DimensionalBaseMeasure":
|
|
809
|
-
return ce(e);
|
|
810
|
-
case "DimensionalCalculatedMeasure":
|
|
811
|
-
return le(e);
|
|
812
|
-
case "DimensionalMeasureTemplate":
|
|
813
|
-
return We(e);
|
|
814
|
-
default:
|
|
815
|
-
return e;
|
|
816
|
-
}
|
|
817
|
-
};
|
|
818
|
-
var b2 = (e) => {
|
|
819
|
-
switch (e.__serializable) {
|
|
820
|
-
case "MembersFilter":
|
|
821
|
-
return new Ed(q3(e.attribute), e.members, e.config.backgroundFilter ? h2(g2({}, e.config), { backgroundFilter: b2(e.config.backgroundFilter) }) : e.config, e.composeCode);
|
|
822
|
-
case "LogicalAttributeFilter":
|
|
823
|
-
return new Fi(e.filters.map((t) => b2(t)), e.operator, e.config, e.composeCode);
|
|
824
|
-
case "CascadingFilter":
|
|
825
|
-
return new Od(e._filters.map((t) => b2(t)), e.config, e.composeCode);
|
|
826
|
-
case "ExcludeFilter":
|
|
827
|
-
return new _d(b2(e.filter), e.input ? b2(e.input) : undefined, e.config, e.composeCode);
|
|
828
|
-
case "MeasureFilter":
|
|
829
|
-
return new xd(q3(e.attribute), H(e.measure), e.operatorA, e.valueA, e.operatorB, e.valueB, e.config, e.composeCode);
|
|
830
|
-
case "RankingFilter":
|
|
831
|
-
return new Ui(q3(e.attribute), H(e.measure), e.operator, e.count, e.config, e.composeCode);
|
|
832
|
-
case "MeasureRankingFilter":
|
|
833
|
-
return new Bi(H(e.measure), e.operator, e.count, e.config, e.composeCode);
|
|
834
|
-
case "NumericFilter":
|
|
835
|
-
return new wd(q3(e.attribute), e.operatorA, e.valueA, e.operatorB, e.valueB, e.config, e.composeCode);
|
|
836
|
-
case "TextFilter":
|
|
837
|
-
return new ne(q3(e.attribute), e.operatorA, e.valueA, e.config, e.composeCode);
|
|
838
|
-
case "DateRangeFilter": {
|
|
839
|
-
const { valueA: t, valueB: s } = e;
|
|
840
|
-
return new Nd(q3(e.attribute), t, s, e.config, e.composeCode);
|
|
841
|
-
}
|
|
842
|
-
case "RelativeDateFilter":
|
|
843
|
-
return new Or(q3(e.attribute), e.offset, e.count, e.operator, e.anchor, e.config, e.composeCode);
|
|
844
|
-
case "CustomFilter":
|
|
845
|
-
return new Cd(q3(e.attribute), e.jaqlExpression, e.config, e.composeCode);
|
|
846
|
-
default:
|
|
847
|
-
return e;
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
l.registerCustom({
|
|
851
|
-
isApplicable: h,
|
|
852
|
-
serialize: (e) => e.serialize(),
|
|
853
|
-
deserialize: (e) => Rt(e)
|
|
854
|
-
}, "JaqlElement");
|
|
855
|
-
l.registerCustom({
|
|
856
|
-
isApplicable: fp,
|
|
857
|
-
serialize: (e) => e.serialize(),
|
|
858
|
-
deserialize: (e) => ae(e)
|
|
859
|
-
}, "DimensionalAttribute");
|
|
860
|
-
l.registerCustom({
|
|
861
|
-
isApplicable: dp,
|
|
862
|
-
serialize: (e) => e.serialize(),
|
|
863
|
-
deserialize: (e) => ue(e)
|
|
864
|
-
}, "DimensionalLevelAttribute");
|
|
865
|
-
l.registerCustom({
|
|
866
|
-
isApplicable: z,
|
|
867
|
-
serialize: (e) => e.serialize(),
|
|
868
|
-
deserialize: (e) => _e(e)
|
|
869
|
-
}, "DimensionalDimension");
|
|
870
|
-
l.registerCustom({
|
|
871
|
-
isApplicable: q,
|
|
872
|
-
serialize: (e) => e.serialize(),
|
|
873
|
-
deserialize: (e) => Ue(e)
|
|
874
|
-
}, "DimensionalDateDimension");
|
|
875
|
-
l.registerCustom({
|
|
876
|
-
isApplicable: Ii,
|
|
877
|
-
serialize: (e) => e.serialize(),
|
|
878
|
-
deserialize: (e) => ce(e)
|
|
879
|
-
}, "DimensionalBaseMeasure");
|
|
880
|
-
l.registerCustom({
|
|
881
|
-
isApplicable: Hh,
|
|
882
|
-
serialize: (e) => e.serialize(),
|
|
883
|
-
deserialize: (e) => le(e)
|
|
884
|
-
}, "DimensionalCalculatedMeasure");
|
|
885
|
-
l.registerCustom({
|
|
886
|
-
isApplicable: kh,
|
|
887
|
-
serialize: (e) => e.serialize(),
|
|
888
|
-
deserialize: (e) => We(e)
|
|
889
|
-
}, "DimensionalMeasureTemplate");
|
|
890
|
-
l.registerCustom({
|
|
891
|
-
isApplicable: Wh,
|
|
892
|
-
serialize: (e) => e.serialize(),
|
|
893
|
-
deserialize: (e) => b2(e)
|
|
894
|
-
}, "MembersFilter");
|
|
895
|
-
l.registerCustom({
|
|
896
|
-
isApplicable: Yh,
|
|
897
|
-
serialize: (e) => e.serialize(),
|
|
898
|
-
deserialize: (e) => b2(e)
|
|
899
|
-
}, "LogicalAttributeFilter");
|
|
900
|
-
l.registerCustom({
|
|
901
|
-
isApplicable: xt,
|
|
902
|
-
serialize: (e) => e.serialize(),
|
|
903
|
-
deserialize: (e) => b2(e)
|
|
904
|
-
}, "CascadingFilter");
|
|
905
|
-
l.registerCustom({
|
|
906
|
-
isApplicable: Jh,
|
|
907
|
-
serialize: (e) => e.serialize(),
|
|
908
|
-
deserialize: (e) => b2(e)
|
|
909
|
-
}, "ExcludeFilter");
|
|
910
|
-
l.registerCustom({
|
|
911
|
-
isApplicable: Kh,
|
|
912
|
-
serialize: (e) => e.serialize(),
|
|
913
|
-
deserialize: (e) => b2(e)
|
|
914
|
-
}, "MeasureFilter");
|
|
915
|
-
l.registerCustom({
|
|
916
|
-
isApplicable: Vh,
|
|
917
|
-
serialize: (e) => e.serialize(),
|
|
918
|
-
deserialize: (e) => b2(e)
|
|
919
|
-
}, "RankingFilter");
|
|
920
|
-
l.registerCustom({
|
|
921
|
-
isApplicable: Qh,
|
|
922
|
-
serialize: (e) => e.serialize(),
|
|
923
|
-
deserialize: (e) => b2(e)
|
|
924
|
-
}, "MeasureRankingFilter");
|
|
925
|
-
l.registerCustom({
|
|
926
|
-
isApplicable: Gh,
|
|
927
|
-
serialize: (e) => e.serialize(),
|
|
928
|
-
deserialize: (e) => b2(e)
|
|
929
|
-
}, "NumericFilter");
|
|
930
|
-
l.registerCustom({
|
|
931
|
-
isApplicable: Xh,
|
|
932
|
-
serialize: (e) => e.serialize(),
|
|
933
|
-
deserialize: (e) => b2(e)
|
|
934
|
-
}, "TextFilter");
|
|
935
|
-
l.registerCustom({
|
|
936
|
-
isApplicable: ep,
|
|
937
|
-
serialize: (e) => e.serialize(),
|
|
938
|
-
deserialize: (e) => b2(e)
|
|
939
|
-
}, "DateRangeFilter");
|
|
940
|
-
l.registerCustom({
|
|
941
|
-
isApplicable: Zh,
|
|
942
|
-
serialize: (e) => e.serialize(),
|
|
943
|
-
deserialize: (e) => b2(e)
|
|
944
|
-
}, "RelativeDateFilter");
|
|
945
|
-
l.registerCustom({
|
|
946
|
-
isApplicable: qh,
|
|
947
|
-
serialize: (e) => e.serialize(),
|
|
948
|
-
deserialize: (e) => b2(e)
|
|
949
|
-
}, "CustomFilter");
|
|
950
|
-
var Ps = l;
|
|
951
|
-
var F = "DM.";
|
|
952
|
-
function E3(e) {
|
|
953
|
-
return typeof e == "object" && e !== null && "function" in e && "args" in e;
|
|
954
|
-
}
|
|
955
|
-
function je(e) {
|
|
956
|
-
return e.every(E3);
|
|
957
|
-
}
|
|
958
|
-
function K(e) {
|
|
959
|
-
return "attribute" in e && "config" in e;
|
|
960
|
-
}
|
|
961
|
-
function U(e) {
|
|
962
|
-
return "left" in e && "right" in e && "operator" in e;
|
|
963
|
-
}
|
|
964
|
-
function fe(e) {
|
|
965
|
-
return !K(e) && !U(e);
|
|
966
|
-
}
|
|
967
|
-
function It(e) {
|
|
968
|
-
return typeof e == "object" && e !== null && "column" in e && typeof e.column == "string" && !(("function" in e) && ("args" in e));
|
|
969
|
-
}
|
|
970
|
-
function zt(e) {
|
|
971
|
-
const r = e;
|
|
972
|
-
return typeof e != "object" || e === null || r === null || !("column" in r) ? false : E3(r.column);
|
|
973
|
-
}
|
|
974
|
-
function Bt(e) {
|
|
975
|
-
const r = [...e].sort((o, i) => i.name.length - o.name.length), t = /* @__PURE__ */ new Map, s = /* @__PURE__ */ new Map, n = /* @__PURE__ */ new Map;
|
|
976
|
-
for (const o of e) {
|
|
977
|
-
t.set(o.name, o);
|
|
978
|
-
const i = [...o.columns].sort((u, c2) => c2.name.length - u.name.length);
|
|
979
|
-
n.set(o.name, i);
|
|
980
|
-
const a = /* @__PURE__ */ new Map;
|
|
981
|
-
for (const u of o.columns)
|
|
982
|
-
a.set(u.name, u);
|
|
983
|
-
s.set(o.name, a);
|
|
984
|
-
}
|
|
985
|
-
return {
|
|
986
|
-
sortedTables: r,
|
|
987
|
-
tableColumnMap: n,
|
|
988
|
-
tableMap: t,
|
|
989
|
-
columnMap: s
|
|
990
|
-
};
|
|
991
|
-
}
|
|
992
|
-
function Je(e, r) {
|
|
993
|
-
if (!e.startsWith(F))
|
|
994
|
-
throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
|
|
995
|
-
const t = e.slice(F.length);
|
|
996
|
-
if (!t)
|
|
997
|
-
throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
|
|
998
|
-
let s, n;
|
|
999
|
-
for (const m2 of r.sortedTables)
|
|
1000
|
-
if (t.startsWith(m2.name + ".")) {
|
|
1001
|
-
const y = t.slice(m2.name.length + 1);
|
|
1002
|
-
if (!y)
|
|
1003
|
-
throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
|
|
1004
|
-
s = m2, n = y;
|
|
1005
|
-
break;
|
|
1006
|
-
}
|
|
1007
|
-
if (!s) {
|
|
1008
|
-
const m2 = t.indexOf(".");
|
|
1009
|
-
if (m2 === -1)
|
|
1010
|
-
throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
|
|
1011
|
-
const y = t.slice(0, m2);
|
|
1012
|
-
throw new Error(`Table "${y}" not found in the data model`);
|
|
1013
|
-
}
|
|
1014
|
-
const o = r.tableColumnMap.get(s.name);
|
|
1015
|
-
if (!o)
|
|
1016
|
-
throw new Error(`Table "${s.name}" found but has no columns`);
|
|
1017
|
-
let i, a;
|
|
1018
|
-
const u = g.all;
|
|
1019
|
-
for (const m2 of o) {
|
|
1020
|
-
if (n === m2.name)
|
|
1021
|
-
return { table: s, column: m2 };
|
|
1022
|
-
if (!n.startsWith(m2.name + "."))
|
|
1023
|
-
continue;
|
|
1024
|
-
const y = n.slice(m2.name.length + 1);
|
|
1025
|
-
if (!y)
|
|
1026
|
-
continue;
|
|
1027
|
-
const x2 = u.includes(y), f2 = wr(m2.dataType);
|
|
1028
|
-
if (x2) {
|
|
1029
|
-
if (f2)
|
|
1030
|
-
return { table: s, column: m2, level: y };
|
|
1031
|
-
i || (i = m2, a = y);
|
|
1032
|
-
continue;
|
|
1033
|
-
}
|
|
1034
|
-
f2 && !i && (i = m2, a = y);
|
|
1035
|
-
}
|
|
1036
|
-
if (i && a)
|
|
1037
|
-
throw u.includes(a) ? new Error(`Invalid date level "${a}" in dimensional element "${e}". Column "${s.name}.${i.name}" is not a datetime column`) : new Error(`Invalid date level "${a}" in dimensional element "${e}". Valid levels are: ${u.join(", ")}`);
|
|
1038
|
-
const c2 = n.indexOf("."), p2 = c2 === -1 ? n : n.slice(0, c2);
|
|
1039
|
-
throw new Error(`Column "${p2}" not found in table "${s.name}"`);
|
|
1040
|
-
}
|
|
1041
|
-
function Pt(e, r) {
|
|
1042
|
-
const { table: t, column: s, level: n } = Je(e, r);
|
|
1043
|
-
if (n) {
|
|
1044
|
-
if (!wr(s.dataType))
|
|
1045
|
-
throw new Error(`Invalid date level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is not a datetime column`);
|
|
1046
|
-
const o = g.all;
|
|
1047
|
-
if (!o.includes(n))
|
|
1048
|
-
throw new Error(`Invalid date level "${n}" in dimensional element "${e}". Valid levels are: ${o.join(", ")}`);
|
|
1049
|
-
const i = g.dateOnly;
|
|
1050
|
-
if (s.dataType === "date" && !i.includes(n))
|
|
1051
|
-
throw new Error(`Invalid level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is only a date column, not a datetime column`);
|
|
1052
|
-
const a = g.timeOnly;
|
|
1053
|
-
if (s.dataType === "time" && !a.includes(n))
|
|
1054
|
-
throw new Error(`Invalid level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is only a time column, not a date column`);
|
|
1055
|
-
}
|
|
1056
|
-
return { column: s, level: n };
|
|
1057
|
-
}
|
|
1058
|
-
function Ke(e) {
|
|
1059
|
-
return e.type === E.TextAttribute;
|
|
1060
|
-
}
|
|
1061
|
-
function Ge(e) {
|
|
1062
|
-
return e.type === E.NumericAttribute;
|
|
1063
|
-
}
|
|
1064
|
-
function kt(e) {
|
|
1065
|
-
return e.type === E.DateLevel;
|
|
1066
|
-
}
|
|
1067
|
-
function Lt(e) {
|
|
1068
|
-
return Ke(e) || Ge(e);
|
|
1069
|
-
}
|
|
1070
|
-
function G(e) {
|
|
1071
|
-
return e.type === E.TextAttribute ? "text" : e.type === E.NumericAttribute ? "numeric" : e.type === E.DateLevel ? "date/datetime" : "unknown";
|
|
1072
|
-
}
|
|
1073
|
-
function Q(e, r, t) {
|
|
1074
|
-
const { column: s, level: n } = Pt(e, t);
|
|
1075
|
-
return Nr({
|
|
1076
|
-
expression: s.expression,
|
|
1077
|
-
dataType: s.dataType,
|
|
1078
|
-
granularity: n,
|
|
1079
|
-
format: undefined,
|
|
1080
|
-
sort: undefined,
|
|
1081
|
-
dataSource: r
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
function Vt2(e, r, t) {
|
|
1085
|
-
const { column: s, level: n } = Je(e, t);
|
|
1086
|
-
if (n)
|
|
1087
|
-
throw new Error(`Invalid DateDimension name format: "${e}". Expected format: "${F}TableName.ColumnName"`);
|
|
1088
|
-
if (!wr(s.dataType))
|
|
1089
|
-
throw new Error(`Invalid DateDimension name "${e}". Column "${s.name}" is not a datetime column (got ${s.dataType}).`);
|
|
1090
|
-
return x({
|
|
1091
|
-
name: s.name,
|
|
1092
|
-
expression: s.expression,
|
|
1093
|
-
dataSource: r
|
|
1094
|
-
});
|
|
1095
|
-
}
|
|
1096
|
-
function M(e, r) {
|
|
1097
|
-
const t = e();
|
|
1098
|
-
return t.success ? t.data : (r.push(...t.errors), null);
|
|
1099
|
-
}
|
|
1100
|
-
var _t = (e, r, t) => {
|
|
1101
|
-
if (!r)
|
|
1102
|
-
return { attribute: e };
|
|
1103
|
-
const s = typeof r == "object" ? r.direction : r;
|
|
1104
|
-
return mp(s) ? { attribute: e.sort(ap(s)) } : {
|
|
1105
|
-
attribute: e,
|
|
1106
|
-
error: h2(g2({}, t), {
|
|
1107
|
-
message: `Invalid sort type. Expected "sortAsc", "sortDesc", or "sortNone". Got: "${s}".`
|
|
1108
|
-
})
|
|
1109
|
-
};
|
|
1110
|
-
};
|
|
1111
|
-
var Ut = (e, r, t, s) => {
|
|
1112
|
-
const n = Q(e.column, r, t);
|
|
1113
|
-
return _t(n, e.sortType, s);
|
|
1114
|
-
};
|
|
1115
|
-
var Wt = (e, r, t, s) => typeof e == "string" ? { attribute: Q(e, r, t) } : It(e) ? Ut(e, r, t, s) : {
|
|
1116
|
-
error: h2(g2({}, s), {
|
|
1117
|
-
message: 'Invalid dimension item. Expected a string (composeCode) or object with "column" and optional "sortType".'
|
|
1118
|
-
})
|
|
1119
|
-
};
|
|
1120
|
-
var jt = (e) => {
|
|
1121
|
-
const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
|
|
1122
|
-
if (!r)
|
|
1123
|
-
return { success: true, data: [] };
|
|
1124
|
-
if (!Array.isArray(r))
|
|
1125
|
-
return {
|
|
1126
|
-
success: false,
|
|
1127
|
-
errors: [
|
|
1128
|
-
{
|
|
1129
|
-
category: "dimensions",
|
|
1130
|
-
index: -1,
|
|
1131
|
-
input: r,
|
|
1132
|
-
message: "Invalid dimensions JSON. Expected an array."
|
|
1133
|
-
}
|
|
1134
|
-
]
|
|
1135
|
-
};
|
|
1136
|
-
const n = [], o = [];
|
|
1137
|
-
return r.forEach((i, a) => {
|
|
1138
|
-
const u = {
|
|
1139
|
-
category: "dimensions",
|
|
1140
|
-
index: a,
|
|
1141
|
-
input: i
|
|
1142
|
-
};
|
|
1143
|
-
try {
|
|
1144
|
-
const c2 = Wt(i, t, s, u);
|
|
1145
|
-
if (c2.error) {
|
|
1146
|
-
o.push(c2.error);
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
c2.attribute && n.push(c2.attribute);
|
|
1150
|
-
} catch (c2) {
|
|
1151
|
-
const p2 = c2 instanceof Error ? c2.message : "Unknown error";
|
|
1152
|
-
o.push(h2(g2({}, u), { message: p2 }));
|
|
1153
|
-
}
|
|
1154
|
-
}), o.length > 0 ? { success: false, errors: o } : { success: true, data: n };
|
|
1155
|
-
};
|
|
1156
|
-
function de(e, r) {
|
|
1157
|
-
const t = Reflect.get(e, r);
|
|
1158
|
-
if (typeof t != "function")
|
|
1159
|
-
throw new Error(`Function "${r}" not found or is not a function`);
|
|
1160
|
-
return t;
|
|
1161
|
-
}
|
|
1162
|
-
function Jt2(e, r) {
|
|
1163
|
-
const t = e.replace("measureFactory.", ""), n = de(zh, t)(...r);
|
|
1164
|
-
if (!fe(n))
|
|
1165
|
-
throw new Error(`Function "${e}" did not return a valid Measure`);
|
|
1166
|
-
return n;
|
|
1167
|
-
}
|
|
1168
|
-
function Kt(e, r) {
|
|
1169
|
-
const t = e.replace("filterFactory.logic.", ""), n = de(ye, t)(...r);
|
|
1170
|
-
if (!U(n))
|
|
1171
|
-
throw new Error(`Function "${e}" did not return a valid FilterRelations`);
|
|
1172
|
-
return n;
|
|
1173
|
-
}
|
|
1174
|
-
function Gt(e, r) {
|
|
1175
|
-
if (e.startsWith("filterFactory.logic."))
|
|
1176
|
-
return Kt(e, r);
|
|
1177
|
-
const t = e.replace("filterFactory.", ""), n = de(tp, t)(...r);
|
|
1178
|
-
if (!K(n) && !U(n))
|
|
1179
|
-
throw new Error(`Function "${e}" did not return a valid Filter or FilterRelations`);
|
|
1180
|
-
return n;
|
|
1181
|
-
}
|
|
1182
|
-
function Qt(e, r) {
|
|
1183
|
-
const s = e.split(".")[0];
|
|
1184
|
-
if (s === "measureFactory")
|
|
1185
|
-
return Jt2(e, r);
|
|
1186
|
-
if (s === "filterFactory")
|
|
1187
|
-
return Gt(e, r);
|
|
1188
|
-
throw new Error(`Unsupported factory: "${s}". Supported factories: measureFactory, filterFactory`);
|
|
1189
|
-
}
|
|
1190
|
-
var Yt = /\[(\w[\w.-]*)\]/g;
|
|
1191
|
-
var Qe = /* @__PURE__ */ new Set([
|
|
1192
|
-
"AVG",
|
|
1193
|
-
"COUNT",
|
|
1194
|
-
"DUPCOUNT",
|
|
1195
|
-
"LARGEST",
|
|
1196
|
-
"MAX",
|
|
1197
|
-
"MEDIAN",
|
|
1198
|
-
"MIN",
|
|
1199
|
-
"MODE",
|
|
1200
|
-
"SUM",
|
|
1201
|
-
"WTDAVG",
|
|
1202
|
-
"WTDSUM",
|
|
1203
|
-
"MTDAVG",
|
|
1204
|
-
"MTDSUM",
|
|
1205
|
-
"QTDAVG",
|
|
1206
|
-
"QTDSUM",
|
|
1207
|
-
"YTDAVG",
|
|
1208
|
-
"YTDSUM",
|
|
1209
|
-
"CORREL",
|
|
1210
|
-
"COVARP",
|
|
1211
|
-
"COVAR",
|
|
1212
|
-
"SKEWP",
|
|
1213
|
-
"SKEW",
|
|
1214
|
-
"SLOPE"
|
|
1215
|
-
]);
|
|
1216
|
-
var Ht = new RegExp(`\\b(${Array.from(Qe).join("|")})\\s*\\(`, "i");
|
|
1217
|
-
function Zt(e) {
|
|
1218
|
-
return E3(e) ? true : typeof e == "string" && e.startsWith(F) ? false : e && typeof e == "object" && ("kind" in e) ? e.kind === "measure" : true;
|
|
1219
|
-
}
|
|
1220
|
-
function Xt(e) {
|
|
1221
|
-
const r = /\b(\w+)\s*\(/g, t = /* @__PURE__ */ new Set;
|
|
1222
|
-
let s;
|
|
1223
|
-
for (;(s = r.exec(e)) !== null; ) {
|
|
1224
|
-
const n = s[1];
|
|
1225
|
-
Qe.has(n.toUpperCase()) || t.add(n);
|
|
1226
|
-
}
|
|
1227
|
-
return Array.from(t);
|
|
1228
|
-
}
|
|
1229
|
-
function vt(e) {
|
|
1230
|
-
return e.length === 1 ? `[${e[0]}]` : e.map((r) => `[${r}]`).join(", ");
|
|
1231
|
-
}
|
|
1232
|
-
function es(e) {
|
|
1233
|
-
return e.length === 0 ? "" : e.length === 1 ? `${e[0]} is not an aggregative function. ` : `${e.join(", ")} are not aggregative functions. `;
|
|
1234
|
-
}
|
|
1235
|
-
var B = (e) => e.startsWith("[") ? e : `[${e}]`;
|
|
1236
|
-
var Ee = (e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e;
|
|
1237
|
-
function rs(e, r, t = {}) {
|
|
1238
|
-
const {
|
|
1239
|
-
warnUnusedContext: s = true,
|
|
1240
|
-
errorOnUnusedContext: n = true,
|
|
1241
|
-
allowEmptyFormula: o = false,
|
|
1242
|
-
errorPrefix: i = "customFormula validation"
|
|
1243
|
-
} = t, a = {
|
|
1244
|
-
isValid: true,
|
|
1245
|
-
errors: [],
|
|
1246
|
-
warnings: [],
|
|
1247
|
-
references: [],
|
|
1248
|
-
unusedContextKeys: []
|
|
1249
|
-
};
|
|
1250
|
-
if (!e || e.trim().length === 0)
|
|
1251
|
-
return o || (a.errors.push(`${i}args[1]: Formula cannot be empty`), a.isValid = false), a;
|
|
1252
|
-
const u = /\b\w+\s*\[/gi, c2 = e.match(u);
|
|
1253
|
-
if (c2) {
|
|
1254
|
-
const f2 = c2[0].replace(/\s*\[.*$/, "");
|
|
1255
|
-
a.errors.push(`${i}args[1]: Invalid syntax: '${f2}' - operator cannot be used before bracket reference without parentheses`), a.isValid = false;
|
|
1256
|
-
}
|
|
1257
|
-
a.references = [
|
|
1258
|
-
...new Set([...e.matchAll(new RegExp(Yt.source, "g"))].map((f2) => f2[1]))
|
|
1259
|
-
];
|
|
1260
|
-
const p2 = Object.keys(r);
|
|
1261
|
-
if (a.references.length === 0)
|
|
1262
|
-
return a.warnings.push(`${i}args[1]: No bracket references found in formula - ensure this is intentional`), a;
|
|
1263
|
-
if (p2.length === 0)
|
|
1264
|
-
return a.errors.push(`${i}args[2]: Context cannot be empty - custom formulas require context definitions`), a.isValid = false, a;
|
|
1265
|
-
const m2 = new Set(p2.map(B)), y = a.references.filter((f2) => !m2.has(B(f2)));
|
|
1266
|
-
if (y.length > 0) {
|
|
1267
|
-
a.isValid = false;
|
|
1268
|
-
const f2 = p2.map((d) => `[${Ee(d)}]`).join(", ");
|
|
1269
|
-
y.length === 1 ? a.errors.push(`${i}args[1]: Reference [${y[0]}] not found in context. Available keys: ${f2}`) : a.errors.push(`${i}args[1]: References [${y.join("], [")}] not found in context. Available keys: ${f2}`);
|
|
1270
|
-
}
|
|
1271
|
-
if (!Ht.test(e)) {
|
|
1272
|
-
const f2 = a.references.filter((d) => {
|
|
1273
|
-
var $;
|
|
1274
|
-
const w = ($ = r[B(d)]) != null ? $ : r[d];
|
|
1275
|
-
return w !== undefined && !Zt(w);
|
|
1276
|
-
});
|
|
1277
|
-
f2.length > 0 && (a.errors.push(`${i}args[1]: ${es(Xt(e))}Bracket reference(s) ${vt(f2)} point to raw attributes and must be wrapped in an aggregative function (e.g. SUM, AVG)`), a.isValid = false);
|
|
1278
|
-
}
|
|
1279
|
-
if ((s || n) && p2.length > 0) {
|
|
1280
|
-
const f2 = new Set(a.references.map(B)), d = p2.filter((w) => !f2.has(B(w)));
|
|
1281
|
-
if (a.unusedContextKeys = d, d.length > 0) {
|
|
1282
|
-
const w = d.map((D) => `[${Ee(D)}]`).join(", "), $ = `${i}args[2]: Context keys ${w} are defined but not used in formula`;
|
|
1283
|
-
n ? (a.errors.push($), a.isValid = false) : s && a.warnings.push($);
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
return a;
|
|
1287
|
-
}
|
|
1288
|
-
function ts(e, r, t = {}) {
|
|
1289
|
-
const s = rs(e, r, t);
|
|
1290
|
-
if (!s.isValid)
|
|
1291
|
-
throw new Error(s.errors.join("; "));
|
|
1292
|
-
s.warnings.length > 0 && console.warn("Formula validation warnings:", s.warnings.join("; "));
|
|
1293
|
-
}
|
|
1294
|
-
function ss(e, r) {
|
|
1295
|
-
if (e.length < 3 || e.length > 5)
|
|
1296
|
-
throw new Error(`${r.pathPrefix}Expected 3, 4, or 5 arguments for customFormula (title, formula, context, format?, description?)`);
|
|
1297
|
-
const t = e[1], s = e[2];
|
|
1298
|
-
ts(t, s, {
|
|
1299
|
-
errorPrefix: `${r.pathPrefix}`,
|
|
1300
|
-
errorOnUnusedContext: true,
|
|
1301
|
-
allowEmptyFormula: false
|
|
1302
|
-
});
|
|
1303
|
-
const n = {};
|
|
1304
|
-
for (const [o, i] of Object.entries(s)) {
|
|
1305
|
-
const a = `args[2].${o}`;
|
|
1306
|
-
if (E3(i))
|
|
1307
|
-
n[`${o}`] = C2({
|
|
1308
|
-
data: i,
|
|
1309
|
-
context: {
|
|
1310
|
-
dataSource: r.dataSource,
|
|
1311
|
-
schemaIndex: r.schemaIndex,
|
|
1312
|
-
pathPrefix: a
|
|
1313
|
-
}
|
|
1314
|
-
});
|
|
1315
|
-
else if (typeof i == "string" && i.startsWith(F))
|
|
1316
|
-
try {
|
|
1317
|
-
n[`${o}`] = Q(i, r.dataSource, r.schemaIndex);
|
|
1318
|
-
} catch (u) {
|
|
1319
|
-
const c2 = u instanceof Error ? u.message : "Unknown error";
|
|
1320
|
-
throw new Error(`${a}: ${c2}`);
|
|
1321
|
-
}
|
|
1322
|
-
else if (i && typeof i == "object" && "kind" in i)
|
|
1323
|
-
n[`${o}`] = i;
|
|
1324
|
-
else
|
|
1325
|
-
throw new Error(`${a}: Invalid context value for key '${o}'. Expected a function call or attribute reference (${F}...), but got: ${typeof i}`);
|
|
1326
|
-
}
|
|
1327
|
-
e[2] = n;
|
|
1328
|
-
}
|
|
1329
|
-
function me2(e, r) {
|
|
1330
|
-
const t = e[0];
|
|
1331
|
-
if (!t || typeof t != "object" || !("type" in t))
|
|
1332
|
-
throw new Error(`${r.pathPrefix}args[0]: Expected attribute as first argument`);
|
|
1333
|
-
return t;
|
|
1334
|
-
}
|
|
1335
|
-
function Ce(e, r) {
|
|
1336
|
-
const t = me2(e, r);
|
|
1337
|
-
if (!Lt(t))
|
|
1338
|
-
throw new Error(`${r.pathPrefix}args[0]: Attribute must be string or numeric type, got ${G(t)} attribute`);
|
|
1339
|
-
}
|
|
1340
|
-
function T2(e, r) {
|
|
1341
|
-
const t = me2(e, r);
|
|
1342
|
-
if (!Ge(t))
|
|
1343
|
-
throw new Error(`${r.pathPrefix}args[0]: Attribute must be numeric type, got ${G(t)} attribute`);
|
|
1344
|
-
}
|
|
1345
|
-
function N(e, r) {
|
|
1346
|
-
const t = me2(e, r);
|
|
1347
|
-
if (!Ke(t))
|
|
1348
|
-
throw new Error(`${r.pathPrefix}args[0]: Attribute must be string type, got ${G(t)} attribute`);
|
|
1349
|
-
}
|
|
1350
|
-
function ns(e, r) {
|
|
1351
|
-
const t = e[0];
|
|
1352
|
-
if (!t || typeof t != "object" || !("attribute" in t))
|
|
1353
|
-
throw new Error(`${r.pathPrefix}args[0]: Expected filter as first argument`);
|
|
1354
|
-
return t;
|
|
1355
|
-
}
|
|
1356
|
-
function is(e, r) {
|
|
1357
|
-
const t = ns(e, r);
|
|
1358
|
-
if (!Wh(t))
|
|
1359
|
-
throw new Error(`${r.pathPrefix}args[0]: exclude filter only accepts members filter, got ${t.__serializable || "unknown"} filter`);
|
|
1360
|
-
}
|
|
1361
|
-
var os = {
|
|
1362
|
-
"measureFactory.customFormula": ss,
|
|
1363
|
-
"filterFactory.equals": Ce,
|
|
1364
|
-
"filterFactory.doesntEqual": Ce,
|
|
1365
|
-
"filterFactory.greaterThan": T2,
|
|
1366
|
-
"filterFactory.greaterThanOrEqual": T2,
|
|
1367
|
-
"filterFactory.lessThan": T2,
|
|
1368
|
-
"filterFactory.lessThanOrEqual": T2,
|
|
1369
|
-
"filterFactory.between": T2,
|
|
1370
|
-
"filterFactory.betweenNotEqual": T2,
|
|
1371
|
-
"filterFactory.numeric": T2,
|
|
1372
|
-
"filterFactory.contains": N,
|
|
1373
|
-
"filterFactory.doesntContain": N,
|
|
1374
|
-
"filterFactory.startsWith": N,
|
|
1375
|
-
"filterFactory.doesntStartWith": N,
|
|
1376
|
-
"filterFactory.endsWith": N,
|
|
1377
|
-
"filterFactory.doesntEndWith": N,
|
|
1378
|
-
"filterFactory.like": N,
|
|
1379
|
-
"filterFactory.exclude": is
|
|
1380
|
-
};
|
|
1381
|
-
function as(e) {
|
|
1382
|
-
return os[`${e}`];
|
|
1383
|
-
}
|
|
1384
|
-
var us = {
|
|
1385
|
-
"measureFactory.sum": [
|
|
1386
|
-
{ type: "Attribute", required: true },
|
|
1387
|
-
{ type: "string", required: false },
|
|
1388
|
-
{ type: "string", required: false }
|
|
1389
|
-
],
|
|
1390
|
-
"measureFactory.average": [
|
|
1391
|
-
{ type: "Attribute", required: true },
|
|
1392
|
-
{ type: "string", required: false },
|
|
1393
|
-
{ type: "string", required: false }
|
|
1394
|
-
],
|
|
1395
|
-
"measureFactory.avg": [
|
|
1396
|
-
{ type: "Attribute", required: true },
|
|
1397
|
-
{ type: "string", required: false },
|
|
1398
|
-
{ type: "string", required: false }
|
|
1399
|
-
],
|
|
1400
|
-
"measureFactory.min": [
|
|
1401
|
-
{ type: "Attribute", required: true },
|
|
1402
|
-
{ type: "string", required: false },
|
|
1403
|
-
{ type: "string", required: false }
|
|
1404
|
-
],
|
|
1405
|
-
"measureFactory.max": [
|
|
1406
|
-
{ type: "Attribute", required: true },
|
|
1407
|
-
{ type: "string", required: false },
|
|
1408
|
-
{ type: "string", required: false }
|
|
1409
|
-
],
|
|
1410
|
-
"measureFactory.median": [
|
|
1411
|
-
{ type: "Attribute", required: true },
|
|
1412
|
-
{ type: "string", required: false },
|
|
1413
|
-
{ type: "string", required: false }
|
|
1414
|
-
],
|
|
1415
|
-
"measureFactory.count": [
|
|
1416
|
-
{ type: "Attribute", required: true },
|
|
1417
|
-
{ type: "string", required: false },
|
|
1418
|
-
{ type: "string", required: false }
|
|
1419
|
-
],
|
|
1420
|
-
"measureFactory.countDistinct": [
|
|
1421
|
-
{ type: "Attribute", required: true },
|
|
1422
|
-
{ type: "string", required: false },
|
|
1423
|
-
{ type: "string", required: false }
|
|
1424
|
-
],
|
|
1425
|
-
"measureFactory.aggregate": [
|
|
1426
|
-
{ type: "Attribute", required: true },
|
|
1427
|
-
{ type: "string", required: true },
|
|
1428
|
-
{ type: "string", required: false },
|
|
1429
|
-
{ type: "string", required: false }
|
|
1430
|
-
],
|
|
1431
|
-
"measureFactory.constant": [{ type: "number", required: true }],
|
|
1432
|
-
"measureFactory.customFormula": [
|
|
1433
|
-
{ type: "string", required: true },
|
|
1434
|
-
{ type: "string", required: true },
|
|
1435
|
-
{ type: "CustomFormulaContext", required: true },
|
|
1436
|
-
{ type: "string", required: false },
|
|
1437
|
-
{ type: "string", required: false }
|
|
1438
|
-
],
|
|
1439
|
-
"measureFactory.add": [
|
|
1440
|
-
{ type: "Measure | number", required: true },
|
|
1441
|
-
{ type: "Measure | number", required: true },
|
|
1442
|
-
{ type: "string", required: false },
|
|
1443
|
-
{ type: "boolean", required: false }
|
|
1444
|
-
],
|
|
1445
|
-
"measureFactory.subtract": [
|
|
1446
|
-
{ type: "Measure | number", required: true },
|
|
1447
|
-
{ type: "Measure | number", required: true },
|
|
1448
|
-
{ type: "string", required: false },
|
|
1449
|
-
{ type: "boolean", required: false }
|
|
1450
|
-
],
|
|
1451
|
-
"measureFactory.multiply": [
|
|
1452
|
-
{ type: "Measure | number", required: true },
|
|
1453
|
-
{ type: "Measure | number", required: true },
|
|
1454
|
-
{ type: "string", required: false },
|
|
1455
|
-
{ type: "boolean", required: false }
|
|
1456
|
-
],
|
|
1457
|
-
"measureFactory.divide": [
|
|
1458
|
-
{ type: "Measure | number", required: true },
|
|
1459
|
-
{ type: "Measure | number", required: true },
|
|
1460
|
-
{ type: "string", required: false },
|
|
1461
|
-
{ type: "boolean", required: false }
|
|
1462
|
-
],
|
|
1463
|
-
"measureFactory.measuredValue": [
|
|
1464
|
-
{ type: "Measure", required: true },
|
|
1465
|
-
{ type: "Filter[]", required: true },
|
|
1466
|
-
{ type: "string", required: false },
|
|
1467
|
-
{ type: "string", required: false }
|
|
1468
|
-
],
|
|
1469
|
-
"measureFactory.rank": [
|
|
1470
|
-
{ type: "Measure", required: true },
|
|
1471
|
-
{ type: "string", required: false },
|
|
1472
|
-
{ type: "string", required: false },
|
|
1473
|
-
{ type: "string", required: false },
|
|
1474
|
-
{ type: "Attribute[]", required: false }
|
|
1475
|
-
],
|
|
1476
|
-
"measureFactory.trend": [
|
|
1477
|
-
{ type: "Measure", required: true },
|
|
1478
|
-
{ type: "string", required: false },
|
|
1479
|
-
{ type: "any", required: false }
|
|
1480
|
-
],
|
|
1481
|
-
"measureFactory.forecast": [
|
|
1482
|
-
{ type: "Measure", required: true },
|
|
1483
|
-
{ type: "string", required: false },
|
|
1484
|
-
{ type: "any", required: false }
|
|
1485
|
-
],
|
|
1486
|
-
"measureFactory.yearToDateSum": [
|
|
1487
|
-
{ type: "Measure", required: true },
|
|
1488
|
-
{ type: "string", required: false }
|
|
1489
|
-
],
|
|
1490
|
-
"measureFactory.quarterToDateSum": [
|
|
1491
|
-
{ type: "Measure", required: true },
|
|
1492
|
-
{ type: "string", required: false }
|
|
1493
|
-
],
|
|
1494
|
-
"measureFactory.monthToDateSum": [
|
|
1495
|
-
{ type: "Measure", required: true },
|
|
1496
|
-
{ type: "string", required: false }
|
|
1497
|
-
],
|
|
1498
|
-
"measureFactory.weekToDateSum": [
|
|
1499
|
-
{ type: "Measure", required: true },
|
|
1500
|
-
{ type: "string", required: false }
|
|
1501
|
-
],
|
|
1502
|
-
"measureFactory.runningSum": [
|
|
1503
|
-
{ type: "Measure", required: true },
|
|
1504
|
-
{ type: "boolean", required: false },
|
|
1505
|
-
{ type: "string", required: false }
|
|
1506
|
-
],
|
|
1507
|
-
"measureFactory.growth": [
|
|
1508
|
-
{ type: "Measure", required: true },
|
|
1509
|
-
{ type: "string", required: false }
|
|
1510
|
-
],
|
|
1511
|
-
"measureFactory.growthRate": [
|
|
1512
|
-
{ type: "Measure", required: true },
|
|
1513
|
-
{ type: "string", required: false }
|
|
1514
|
-
],
|
|
1515
|
-
"measureFactory.growthPastWeek": [
|
|
1516
|
-
{ type: "Measure", required: true },
|
|
1517
|
-
{ type: "string", required: false }
|
|
1518
|
-
],
|
|
1519
|
-
"measureFactory.growthPastMonth": [
|
|
1520
|
-
{ type: "Measure", required: true },
|
|
1521
|
-
{ type: "string", required: false }
|
|
1522
|
-
],
|
|
1523
|
-
"measureFactory.growthPastQuarter": [
|
|
1524
|
-
{ type: "Measure", required: true },
|
|
1525
|
-
{ type: "string", required: false }
|
|
1526
|
-
],
|
|
1527
|
-
"measureFactory.growthPastYear": [
|
|
1528
|
-
{ type: "Measure", required: true },
|
|
1529
|
-
{ type: "string", required: false }
|
|
1530
|
-
],
|
|
1531
|
-
"measureFactory.difference": [
|
|
1532
|
-
{ type: "Measure", required: true },
|
|
1533
|
-
{ type: "string", required: false }
|
|
1534
|
-
],
|
|
1535
|
-
"measureFactory.diffPastWeek": [
|
|
1536
|
-
{ type: "Measure", required: true },
|
|
1537
|
-
{ type: "string", required: false }
|
|
1538
|
-
],
|
|
1539
|
-
"measureFactory.diffPastMonth": [
|
|
1540
|
-
{ type: "Measure", required: true },
|
|
1541
|
-
{ type: "string", required: false }
|
|
1542
|
-
],
|
|
1543
|
-
"measureFactory.diffPastQuarter": [
|
|
1544
|
-
{ type: "Measure", required: true },
|
|
1545
|
-
{ type: "string", required: false }
|
|
1546
|
-
],
|
|
1547
|
-
"measureFactory.diffPastYear": [
|
|
1548
|
-
{ type: "Measure", required: true },
|
|
1549
|
-
{ type: "string", required: false }
|
|
1550
|
-
],
|
|
1551
|
-
"measureFactory.pastDay": [
|
|
1552
|
-
{ type: "Measure", required: true },
|
|
1553
|
-
{ type: "string", required: false }
|
|
1554
|
-
],
|
|
1555
|
-
"measureFactory.pastWeek": [
|
|
1556
|
-
{ type: "Measure", required: true },
|
|
1557
|
-
{ type: "string", required: false }
|
|
1558
|
-
],
|
|
1559
|
-
"measureFactory.pastMonth": [
|
|
1560
|
-
{ type: "Measure", required: true },
|
|
1561
|
-
{ type: "string", required: false }
|
|
1562
|
-
],
|
|
1563
|
-
"measureFactory.pastQuarter": [
|
|
1564
|
-
{ type: "Measure", required: true },
|
|
1565
|
-
{ type: "string", required: false }
|
|
1566
|
-
],
|
|
1567
|
-
"measureFactory.pastYear": [
|
|
1568
|
-
{ type: "Measure", required: true },
|
|
1569
|
-
{ type: "string", required: false }
|
|
1570
|
-
],
|
|
1571
|
-
"measureFactory.contribution": [
|
|
1572
|
-
{ type: "Measure", required: true },
|
|
1573
|
-
{ type: "string", required: false }
|
|
1574
|
-
],
|
|
1575
|
-
"filterFactory.union": [
|
|
1576
|
-
{ type: "Filter[]", required: true },
|
|
1577
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1578
|
-
],
|
|
1579
|
-
"filterFactory.intersection": [
|
|
1580
|
-
{ type: "Filter[]", required: true },
|
|
1581
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1582
|
-
],
|
|
1583
|
-
"filterFactory.exclude": [
|
|
1584
|
-
{ type: "Filter", required: true },
|
|
1585
|
-
{ type: "Filter", required: false },
|
|
1586
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1587
|
-
],
|
|
1588
|
-
"filterFactory.contains": [
|
|
1589
|
-
{ type: "Attribute", required: true },
|
|
1590
|
-
{ type: "string", required: true },
|
|
1591
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1592
|
-
],
|
|
1593
|
-
"filterFactory.doesntContain": [
|
|
1594
|
-
{ type: "Attribute", required: true },
|
|
1595
|
-
{ type: "string", required: true },
|
|
1596
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1597
|
-
],
|
|
1598
|
-
"filterFactory.startsWith": [
|
|
1599
|
-
{ type: "Attribute", required: true },
|
|
1600
|
-
{ type: "string", required: true },
|
|
1601
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1602
|
-
],
|
|
1603
|
-
"filterFactory.doesntStartWith": [
|
|
1604
|
-
{ type: "Attribute", required: true },
|
|
1605
|
-
{ type: "string", required: true },
|
|
1606
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1607
|
-
],
|
|
1608
|
-
"filterFactory.endsWith": [
|
|
1609
|
-
{ type: "Attribute", required: true },
|
|
1610
|
-
{ type: "string", required: true },
|
|
1611
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1612
|
-
],
|
|
1613
|
-
"filterFactory.doesntEndWith": [
|
|
1614
|
-
{ type: "Attribute", required: true },
|
|
1615
|
-
{ type: "string", required: true },
|
|
1616
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1617
|
-
],
|
|
1618
|
-
"filterFactory.like": [
|
|
1619
|
-
{ type: "Attribute", required: true },
|
|
1620
|
-
{ type: "string", required: true },
|
|
1621
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1622
|
-
],
|
|
1623
|
-
"filterFactory.equals": [
|
|
1624
|
-
{ type: "Attribute", required: true },
|
|
1625
|
-
{ type: "string | number", required: true },
|
|
1626
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1627
|
-
],
|
|
1628
|
-
"filterFactory.doesntEqual": [
|
|
1629
|
-
{ type: "Attribute", required: true },
|
|
1630
|
-
{ type: "string | number", required: true },
|
|
1631
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1632
|
-
],
|
|
1633
|
-
"filterFactory.greaterThan": [
|
|
1634
|
-
{ type: "Attribute", required: true },
|
|
1635
|
-
{ type: "number", required: true },
|
|
1636
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1637
|
-
],
|
|
1638
|
-
"filterFactory.greaterThanOrEqual": [
|
|
1639
|
-
{ type: "Attribute", required: true },
|
|
1640
|
-
{ type: "number", required: true },
|
|
1641
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1642
|
-
],
|
|
1643
|
-
"filterFactory.lessThan": [
|
|
1644
|
-
{ type: "Attribute", required: true },
|
|
1645
|
-
{ type: "number", required: true },
|
|
1646
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1647
|
-
],
|
|
1648
|
-
"filterFactory.lessThanOrEqual": [
|
|
1649
|
-
{ type: "Attribute", required: true },
|
|
1650
|
-
{ type: "number", required: true },
|
|
1651
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1652
|
-
],
|
|
1653
|
-
"filterFactory.between": [
|
|
1654
|
-
{ type: "Attribute", required: true },
|
|
1655
|
-
{ type: "number", required: true },
|
|
1656
|
-
{ type: "number", required: true },
|
|
1657
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1658
|
-
],
|
|
1659
|
-
"filterFactory.betweenNotEqual": [
|
|
1660
|
-
{ type: "Attribute", required: true },
|
|
1661
|
-
{ type: "number", required: true },
|
|
1662
|
-
{ type: "number", required: true },
|
|
1663
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1664
|
-
],
|
|
1665
|
-
"filterFactory.numeric": [
|
|
1666
|
-
{ type: "Attribute", required: true },
|
|
1667
|
-
{ type: "string", required: false },
|
|
1668
|
-
{ type: "number", required: false },
|
|
1669
|
-
{ type: "string", required: false },
|
|
1670
|
-
{ type: "number", required: false },
|
|
1671
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1672
|
-
],
|
|
1673
|
-
"filterFactory.members": [
|
|
1674
|
-
{ type: "Attribute", required: true },
|
|
1675
|
-
{ type: "string[]", required: true },
|
|
1676
|
-
{ type: "MembersFilterConfig", required: false }
|
|
1677
|
-
],
|
|
1678
|
-
"filterFactory.dateFrom": [
|
|
1679
|
-
{ type: "LevelAttribute", required: true },
|
|
1680
|
-
{ type: "Date | string", required: true },
|
|
1681
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1682
|
-
],
|
|
1683
|
-
"filterFactory.dateTo": [
|
|
1684
|
-
{ type: "LevelAttribute", required: true },
|
|
1685
|
-
{ type: "Date | string", required: true },
|
|
1686
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1687
|
-
],
|
|
1688
|
-
"filterFactory.dateRange": [
|
|
1689
|
-
{ type: "LevelAttribute", required: true },
|
|
1690
|
-
{ type: "Date | string", required: false },
|
|
1691
|
-
{ type: "Date | string", required: false },
|
|
1692
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1693
|
-
],
|
|
1694
|
-
"filterFactory.dateRelative": [
|
|
1695
|
-
{ type: "LevelAttribute", required: true },
|
|
1696
|
-
{ type: "number", required: true },
|
|
1697
|
-
{ type: "number", required: true },
|
|
1698
|
-
{ type: "Date | string", required: false },
|
|
1699
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1700
|
-
],
|
|
1701
|
-
"filterFactory.dateRelativeFrom": [
|
|
1702
|
-
{ type: "LevelAttribute", required: true },
|
|
1703
|
-
{ type: "number", required: true },
|
|
1704
|
-
{ type: "number", required: true },
|
|
1705
|
-
{ type: "Date | string", required: false },
|
|
1706
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1707
|
-
],
|
|
1708
|
-
"filterFactory.dateRelativeTo": [
|
|
1709
|
-
{ type: "LevelAttribute", required: true },
|
|
1710
|
-
{ type: "number", required: true },
|
|
1711
|
-
{ type: "number", required: true },
|
|
1712
|
-
{ type: "Date | string", required: false },
|
|
1713
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1714
|
-
],
|
|
1715
|
-
"filterFactory.thisYear": [
|
|
1716
|
-
{ type: "DateDimension", required: true },
|
|
1717
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1718
|
-
],
|
|
1719
|
-
"filterFactory.thisMonth": [
|
|
1720
|
-
{ type: "DateDimension", required: true },
|
|
1721
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1722
|
-
],
|
|
1723
|
-
"filterFactory.thisQuarter": [
|
|
1724
|
-
{ type: "DateDimension", required: true },
|
|
1725
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1726
|
-
],
|
|
1727
|
-
"filterFactory.today": [
|
|
1728
|
-
{ type: "DateDimension", required: true },
|
|
1729
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1730
|
-
],
|
|
1731
|
-
"filterFactory.measureEquals": [
|
|
1732
|
-
{ type: "BaseMeasure", required: true },
|
|
1733
|
-
{ type: "number", required: true },
|
|
1734
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1735
|
-
],
|
|
1736
|
-
"filterFactory.measureGreaterThan": [
|
|
1737
|
-
{ type: "BaseMeasure", required: true },
|
|
1738
|
-
{ type: "number", required: true },
|
|
1739
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1740
|
-
],
|
|
1741
|
-
"filterFactory.measureGreaterThanOrEqual": [
|
|
1742
|
-
{ type: "BaseMeasure", required: true },
|
|
1743
|
-
{ type: "number", required: true },
|
|
1744
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1745
|
-
],
|
|
1746
|
-
"filterFactory.measureLessThan": [
|
|
1747
|
-
{ type: "BaseMeasure", required: true },
|
|
1748
|
-
{ type: "number", required: true },
|
|
1749
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1750
|
-
],
|
|
1751
|
-
"filterFactory.measureLessThanOrEqual": [
|
|
1752
|
-
{ type: "BaseMeasure", required: true },
|
|
1753
|
-
{ type: "number", required: true },
|
|
1754
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1755
|
-
],
|
|
1756
|
-
"filterFactory.measureBetween": [
|
|
1757
|
-
{ type: "BaseMeasure", required: true },
|
|
1758
|
-
{ type: "number", required: true },
|
|
1759
|
-
{ type: "number", required: true },
|
|
1760
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1761
|
-
],
|
|
1762
|
-
"filterFactory.measureBetweenNotEqual": [
|
|
1763
|
-
{ type: "BaseMeasure", required: true },
|
|
1764
|
-
{ type: "number", required: true },
|
|
1765
|
-
{ type: "number", required: true },
|
|
1766
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1767
|
-
],
|
|
1768
|
-
"filterFactory.topRanking": [
|
|
1769
|
-
{ type: "Attribute", required: true },
|
|
1770
|
-
{ type: "Measure", required: true },
|
|
1771
|
-
{ type: "number", required: true },
|
|
1772
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1773
|
-
],
|
|
1774
|
-
"filterFactory.bottomRanking": [
|
|
1775
|
-
{ type: "Attribute", required: true },
|
|
1776
|
-
{ type: "Measure", required: true },
|
|
1777
|
-
{ type: "number", required: true },
|
|
1778
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1779
|
-
],
|
|
1780
|
-
"filterFactory.measureTopRanking": [
|
|
1781
|
-
{ type: "BaseMeasure", required: true },
|
|
1782
|
-
{ type: "number", required: true },
|
|
1783
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1784
|
-
],
|
|
1785
|
-
"filterFactory.measureBottomRanking": [
|
|
1786
|
-
{ type: "BaseMeasure", required: true },
|
|
1787
|
-
{ type: "number", required: true },
|
|
1788
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1789
|
-
],
|
|
1790
|
-
"filterFactory.cascading": [
|
|
1791
|
-
{ type: "Filter[]", required: true },
|
|
1792
|
-
{ type: "BaseFilterConfig", required: false }
|
|
1793
|
-
],
|
|
1794
|
-
"filterFactory.logic.and": [
|
|
1795
|
-
{ type: "FilterRelationsNode", required: true },
|
|
1796
|
-
{ type: "FilterRelationsNode", required: true }
|
|
1797
|
-
],
|
|
1798
|
-
"filterFactory.logic.or": [
|
|
1799
|
-
{ type: "FilterRelationsNode", required: true },
|
|
1800
|
-
{ type: "FilterRelationsNode", required: true }
|
|
1801
|
-
]
|
|
1802
|
-
};
|
|
1803
|
-
function pe(e) {
|
|
1804
|
-
return us[`${e}`];
|
|
1805
|
-
}
|
|
1806
|
-
function cs(e) {
|
|
1807
|
-
const r = pe(e);
|
|
1808
|
-
return r ? r.filter((t) => t.required).length : 0;
|
|
1809
|
-
}
|
|
1810
|
-
function ls(e) {
|
|
1811
|
-
const r = pe(e);
|
|
1812
|
-
return r ? r.length : 0;
|
|
1813
|
-
}
|
|
1814
|
-
function fs(e) {
|
|
1815
|
-
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}/.test(e))
|
|
1816
|
-
return false;
|
|
1817
|
-
const t = Date.parse(e);
|
|
1818
|
-
if (isNaN(t) || e.length < 10)
|
|
1819
|
-
return false;
|
|
1820
|
-
const s = new Date(e);
|
|
1821
|
-
return !isNaN(s.getTime());
|
|
1822
|
-
}
|
|
1823
|
-
function Z2(e, r, t, s) {
|
|
1824
|
-
if (e.startsWith(F))
|
|
1825
|
-
try {
|
|
1826
|
-
return Q(e, r, t);
|
|
1827
|
-
} catch (n) {
|
|
1828
|
-
const o = n instanceof Error ? n.message : "Unknown error";
|
|
1829
|
-
throw new Error(`${s}: ${o}`);
|
|
1830
|
-
}
|
|
1831
|
-
throw new Error(`${s}: Invalid attribute "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
|
|
1832
|
-
}
|
|
1833
|
-
function ds(e, r, t, s) {
|
|
1834
|
-
if (e.startsWith(F))
|
|
1835
|
-
try {
|
|
1836
|
-
return Vt2(e, r, t);
|
|
1837
|
-
} catch (n) {
|
|
1838
|
-
const o = n instanceof Error ? n.message : "Unknown error";
|
|
1839
|
-
throw new Error(`${s}: ${o}`);
|
|
1840
|
-
}
|
|
1841
|
-
throw new Error(`${s}: Invalid date dimension string "${e}". Expected format: "${F}TableName.ColumnName"`);
|
|
1842
|
-
}
|
|
1843
|
-
function ms(e) {
|
|
1844
|
-
const r = e.data, { argSchema: t, dataSource: s, schemaIndex: n, pathPrefix: o } = e.context, i = o;
|
|
1845
|
-
if (r === undefined) {
|
|
1846
|
-
if (t.required)
|
|
1847
|
-
throw new Error(`${i}: Required argument is missing (expected ${t.type})`);
|
|
1848
|
-
return;
|
|
1849
|
-
}
|
|
1850
|
-
if (!(r === null && !t.required))
|
|
1851
|
-
switch (t.type) {
|
|
1852
|
-
case "string":
|
|
1853
|
-
if (typeof r != "string")
|
|
1854
|
-
throw new Error(`${i}: Expected string, got ${typeof r}`);
|
|
1855
|
-
return r;
|
|
1856
|
-
case "number":
|
|
1857
|
-
if (typeof r != "number")
|
|
1858
|
-
throw new Error(`${i}: Expected number, got ${typeof r}`);
|
|
1859
|
-
return r;
|
|
1860
|
-
case "boolean":
|
|
1861
|
-
if (typeof r != "boolean")
|
|
1862
|
-
throw new Error(`${i}: Expected boolean, got ${typeof r}`);
|
|
1863
|
-
return r;
|
|
1864
|
-
case "string[]":
|
|
1865
|
-
if (!Array.isArray(r))
|
|
1866
|
-
throw new Error(`${i}: Expected array of strings, got ${typeof r}. Example: ["value1", "value2"]`);
|
|
1867
|
-
if (!r.every((a) => typeof a == "string"))
|
|
1868
|
-
throw new Error(`${i}: Expected array of strings, but contains non-string values`);
|
|
1869
|
-
return r;
|
|
1870
|
-
case "number[]":
|
|
1871
|
-
if (!Array.isArray(r))
|
|
1872
|
-
throw new Error(`${i}: Expected array of numbers, got ${typeof r}. Example: [10, 20]`);
|
|
1873
|
-
if (!r.every((a) => typeof a == "number"))
|
|
1874
|
-
throw new Error(`${i}: Expected array of numbers, but contains non-number values`);
|
|
1875
|
-
return r;
|
|
1876
|
-
case "Attribute":
|
|
1877
|
-
if (typeof r != "string")
|
|
1878
|
-
throw new Error(`${i}: Expected attribute string, got ${typeof r}. Example: "DM.Commerce.Revenue"`);
|
|
1879
|
-
return Z2(r, s, n, i);
|
|
1880
|
-
case "Attribute[]":
|
|
1881
|
-
if (!Array.isArray(r))
|
|
1882
|
-
throw new Error(`${i}: Expected array of attributes, got ${typeof r}. Example: ["DM.Commerce.AgeRange"]`);
|
|
1883
|
-
return r.map((a, u) => {
|
|
1884
|
-
if (typeof a != "string")
|
|
1885
|
-
throw new Error(`${i}[${u}]: Expected attribute string, got ${typeof a}`);
|
|
1886
|
-
return Z2(a, s, n, `${i}[${u}]`);
|
|
1887
|
-
});
|
|
1888
|
-
case "Measure":
|
|
1889
|
-
case "BaseMeasure":
|
|
1890
|
-
if (!E3(r))
|
|
1891
|
-
throw new Error(`${i}: Expected measure function call, got ${typeof r}. Example: {"function": "measureFactory.sum", "args": ["DM.Commerce.Revenue"]}`);
|
|
1892
|
-
return C2({
|
|
1893
|
-
data: r,
|
|
1894
|
-
context: { dataSource: s, schemaIndex: n, pathPrefix: i }
|
|
1895
|
-
});
|
|
1896
|
-
case "Measure[]":
|
|
1897
|
-
if (!Array.isArray(r))
|
|
1898
|
-
throw new Error(`${i}: Expected array of measure function calls, got ${typeof r}`);
|
|
1899
|
-
return r.map((a, u) => {
|
|
1900
|
-
if (!E3(a))
|
|
1901
|
-
throw new Error(`${i}[${u}]: Expected measure function call, got ${typeof a}`);
|
|
1902
|
-
return C2({
|
|
1903
|
-
data: a,
|
|
1904
|
-
context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
|
|
1905
|
-
});
|
|
1906
|
-
});
|
|
1907
|
-
case "Filter":
|
|
1908
|
-
if (!E3(r))
|
|
1909
|
-
throw new Error(`${i}: Expected filter function call, got ${typeof r}. Example: {"function": "filterFactory.contains", "args": ["DM.Brand.Brand", "Apple"]}`);
|
|
1910
|
-
return C2({
|
|
1911
|
-
data: r,
|
|
1912
|
-
context: { dataSource: s, schemaIndex: n, pathPrefix: i }
|
|
1913
|
-
});
|
|
1914
|
-
case "Filter[]":
|
|
1915
|
-
if (!Array.isArray(r))
|
|
1916
|
-
throw new Error(`${i}: Expected array of filter function calls, got ${typeof r}`);
|
|
1917
|
-
return r.map((a, u) => {
|
|
1918
|
-
if (!E3(a))
|
|
1919
|
-
throw new Error(`${i}[${u}]: Expected filter function call, got ${typeof a}`);
|
|
1920
|
-
return C2({
|
|
1921
|
-
data: a,
|
|
1922
|
-
context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
|
|
1923
|
-
});
|
|
1924
|
-
});
|
|
1925
|
-
case "FilterRelationsNode":
|
|
1926
|
-
if (Array.isArray(r))
|
|
1927
|
-
return r.map((a, u) => {
|
|
1928
|
-
if (!E3(a))
|
|
1929
|
-
throw new Error(`${i}[${u}]: Expected filter function call, got ${typeof a}`);
|
|
1930
|
-
return C2({
|
|
1931
|
-
data: a,
|
|
1932
|
-
context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
|
|
1933
|
-
});
|
|
1934
|
-
});
|
|
1935
|
-
if (E3(r))
|
|
1936
|
-
return C2({
|
|
1937
|
-
data: r,
|
|
1938
|
-
context: { dataSource: s, schemaIndex: n, pathPrefix: i }
|
|
1939
|
-
});
|
|
1940
|
-
throw new Error(`${i}: Expected filter function call or array of filters, got ${typeof r}`);
|
|
1941
|
-
case "DateDimension":
|
|
1942
|
-
if (typeof r != "string")
|
|
1943
|
-
throw new Error(`${i}: Expected date dimension string, got ${typeof r}. Example: "DM.Commerce.Date"`);
|
|
1944
|
-
return ds(r, s, n, i);
|
|
1945
|
-
case "LevelAttribute": {
|
|
1946
|
-
if (typeof r != "string")
|
|
1947
|
-
throw new Error(`${i}: Expected date attribute string, got ${typeof r}. Example: "DM.Commerce.Date.Years"`);
|
|
1948
|
-
const a = Z2(r, s, n, i);
|
|
1949
|
-
if (!kt(a))
|
|
1950
|
-
throw new Error(`${i}: Attribute must be date/datetime type, got ${G(a)} attribute`);
|
|
1951
|
-
return a;
|
|
1952
|
-
}
|
|
1953
|
-
case "Measure | number":
|
|
1954
|
-
if (typeof r == "number")
|
|
1955
|
-
return r;
|
|
1956
|
-
if (E3(r))
|
|
1957
|
-
return C2({
|
|
1958
|
-
data: r,
|
|
1959
|
-
context: { dataSource: s, schemaIndex: n, pathPrefix: i }
|
|
1960
|
-
});
|
|
1961
|
-
throw new Error(`${i}: Expected measure function call or number, got ${typeof r}`);
|
|
1962
|
-
case "Date | string":
|
|
1963
|
-
if (typeof r == "string") {
|
|
1964
|
-
if (fs(r))
|
|
1965
|
-
return r;
|
|
1966
|
-
throw new Error(`${i}: Expected valid ISO date string or Date object, got invalid date string "${r}"`);
|
|
1967
|
-
} else {
|
|
1968
|
-
if (r instanceof Date)
|
|
1969
|
-
return r;
|
|
1970
|
-
throw new Error(`${i}: Expected date string or Date object, got ${typeof r}`);
|
|
1971
|
-
}
|
|
1972
|
-
case "string | number":
|
|
1973
|
-
if (typeof r == "string" || typeof r == "number")
|
|
1974
|
-
return r;
|
|
1975
|
-
throw new Error(`${i}: Expected string or number, got ${typeof r}`);
|
|
1976
|
-
case "BaseFilterConfig":
|
|
1977
|
-
case "MembersFilterConfig":
|
|
1978
|
-
case "CustomFormulaContext":
|
|
1979
|
-
case "any":
|
|
1980
|
-
if (r == null && t.required)
|
|
1981
|
-
throw new Error(`${i}: Required argument is null/undefined`);
|
|
1982
|
-
return r;
|
|
1983
|
-
default:
|
|
1984
|
-
return r;
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
function C2(e) {
|
|
1988
|
-
const { data: r } = e, { dataSource: t, schemaIndex: s, pathPrefix: n } = e.context, { function: o, args: i } = r, a = n ? `${n}.` : "", u = pe(o);
|
|
1989
|
-
if (!u)
|
|
1990
|
-
throw new Error(`${a}function: Unknown function "${o}"`);
|
|
1991
|
-
const c2 = cs(o), p2 = ls(o);
|
|
1992
|
-
if (i.length < c2)
|
|
1993
|
-
throw new Error(`${a}function: Expected at least ${c2} arguments, got ${i.length}`);
|
|
1994
|
-
if (i.length > p2)
|
|
1995
|
-
throw new Error(`${a}function: Expected at most ${p2} arguments, got ${i.length}`);
|
|
1996
|
-
const m2 = [], y = [];
|
|
1997
|
-
for (let f2 = 0;f2 < Math.max(i.length, u.length); f2++) {
|
|
1998
|
-
const d = u[`${f2}`], w = i[`${f2}`], $ = a ? `${a}args[${f2}]` : `args[${f2}]`;
|
|
1999
|
-
if (w === undefined) {
|
|
2000
|
-
d != null && d.required && y.push(`${$}: Missing required argument (expected ${d.type})`);
|
|
2001
|
-
continue;
|
|
2002
|
-
}
|
|
2003
|
-
if (!d) {
|
|
2004
|
-
y.push(`${$}: Unexpected argument`);
|
|
2005
|
-
continue;
|
|
2006
|
-
}
|
|
2007
|
-
try {
|
|
2008
|
-
const D = ms({
|
|
2009
|
-
data: w,
|
|
2010
|
-
context: {
|
|
2011
|
-
dataSource: t,
|
|
2012
|
-
schemaIndex: s,
|
|
2013
|
-
pathPrefix: $,
|
|
2014
|
-
argSchema: d
|
|
2015
|
-
}
|
|
2016
|
-
});
|
|
2017
|
-
m2.push(D);
|
|
2018
|
-
} catch (D) {
|
|
2019
|
-
const ve = D instanceof Error ? D.message : "Unknown error";
|
|
2020
|
-
y.push(ve);
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
if (y.length > 0) {
|
|
2024
|
-
const f2 = y.join("; ");
|
|
2025
|
-
throw new Error(f2);
|
|
2026
|
-
}
|
|
2027
|
-
const x2 = as(o);
|
|
2028
|
-
if (x2)
|
|
2029
|
-
try {
|
|
2030
|
-
x2(m2, {
|
|
2031
|
-
dataSource: t,
|
|
2032
|
-
schemaIndex: s,
|
|
2033
|
-
pathPrefix: a
|
|
2034
|
-
});
|
|
2035
|
-
} catch (f2) {
|
|
2036
|
-
const d = f2 instanceof Error ? f2.message : "Unknown validation error";
|
|
2037
|
-
throw new Error(d);
|
|
2038
|
-
}
|
|
2039
|
-
return Qt(o, m2);
|
|
2040
|
-
}
|
|
2041
|
-
function Ye(e) {
|
|
2042
|
-
const { attribute: r, config: t } = e;
|
|
2043
|
-
if (Wh(e) && pp(r)) {
|
|
2044
|
-
const { granularity: s } = r, n = e.members.map((a) => s === "Years" && !isNaN(Number(a)) ? `${a}-01-01T00:00:00` : a), o = ji(t), i = Object.keys(o).length === 0 ? undefined : o;
|
|
2045
|
-
return wt(r, n, i);
|
|
2046
|
-
}
|
|
2047
|
-
return e;
|
|
2048
|
-
}
|
|
2049
|
-
function ps(e) {
|
|
2050
|
-
let r = [];
|
|
2051
|
-
for (const t of e)
|
|
2052
|
-
U(t) ? r = bp(t, r) : r = bp([Ye(t)], r);
|
|
2053
|
-
return r != null ? r : [];
|
|
2054
|
-
}
|
|
2055
|
-
var ys2 = (e) => {
|
|
2056
|
-
const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], o = [];
|
|
2057
|
-
return r.forEach((i, a) => {
|
|
2058
|
-
const u = {
|
|
2059
|
-
category: "filters",
|
|
2060
|
-
index: a,
|
|
2061
|
-
input: i
|
|
2062
|
-
};
|
|
2063
|
-
try {
|
|
2064
|
-
const c2 = C2({
|
|
2065
|
-
data: i,
|
|
2066
|
-
context: { dataSource: t, schemaIndex: s, pathPrefix: "" }
|
|
2067
|
-
});
|
|
2068
|
-
!U(c2) && !K(c2) ? o.push(h2(g2({}, u), { message: "Invalid filter JSON" })) : n.push(c2);
|
|
2069
|
-
} catch (c2) {
|
|
2070
|
-
const p2 = c2 instanceof Error ? c2.message : "Unknown error";
|
|
2071
|
-
o.push(h2(g2({}, u), { message: p2 }));
|
|
2072
|
-
}
|
|
2073
|
-
}), o.length > 0 ? { success: false, errors: o } : { success: true, data: ps(n) };
|
|
2074
|
-
};
|
|
2075
|
-
var gs = (e) => {
|
|
2076
|
-
const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
|
|
2077
|
-
return r ? je(r) ? ys2({
|
|
2078
|
-
data: r,
|
|
2079
|
-
context: { dataSource: t, schemaIndex: s }
|
|
2080
|
-
}) : {
|
|
2081
|
-
success: false,
|
|
2082
|
-
errors: [
|
|
2083
|
-
{
|
|
2084
|
-
category: "filters",
|
|
2085
|
-
index: -1,
|
|
2086
|
-
input: r,
|
|
2087
|
-
message: 'Invalid filters JSON. Expected an array of function calls with "function" and "args" properties.'
|
|
2088
|
-
}
|
|
2089
|
-
]
|
|
2090
|
-
} : { success: true, data: [] };
|
|
2091
|
-
};
|
|
2092
|
-
var hs = (e) => {
|
|
2093
|
-
const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], o = [];
|
|
2094
|
-
return r.forEach((i, a) => {
|
|
2095
|
-
const u = {
|
|
2096
|
-
category: "highlights",
|
|
2097
|
-
index: a,
|
|
2098
|
-
input: i
|
|
2099
|
-
};
|
|
2100
|
-
try {
|
|
2101
|
-
const c2 = C2({
|
|
2102
|
-
data: i,
|
|
2103
|
-
context: { dataSource: t, schemaIndex: s, pathPrefix: "" }
|
|
2104
|
-
});
|
|
2105
|
-
K(c2) ? n.push(Ye(c2)) : o.push(h2(g2({}, u), { message: "Invalid filter JSON" }));
|
|
2106
|
-
} catch (c2) {
|
|
2107
|
-
const p2 = c2 instanceof Error ? c2.message : "Unknown error";
|
|
2108
|
-
o.push(h2(g2({}, u), { message: p2 }));
|
|
2109
|
-
}
|
|
2110
|
-
}), o.length > 0 ? { success: false, errors: o } : { success: true, data: n };
|
|
2111
|
-
};
|
|
2112
|
-
var bs = (e) => {
|
|
2113
|
-
const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
|
|
2114
|
-
return r ? je(r) ? hs({
|
|
2115
|
-
data: r,
|
|
2116
|
-
context: { dataSource: t, schemaIndex: s }
|
|
2117
|
-
}) : {
|
|
2118
|
-
success: false,
|
|
2119
|
-
errors: [
|
|
2120
|
-
{
|
|
2121
|
-
category: "highlights",
|
|
2122
|
-
index: -1,
|
|
2123
|
-
input: r,
|
|
2124
|
-
message: 'Invalid highlights JSON. Expected an array of function calls with "function" and "args" properties.'
|
|
2125
|
-
}
|
|
2126
|
-
]
|
|
2127
|
-
} : { success: true, data: [] };
|
|
2128
|
-
};
|
|
2129
|
-
var Fs = (e, r, t) => {
|
|
2130
|
-
const { dataSource: s, schemaIndex: n } = r;
|
|
2131
|
-
try {
|
|
2132
|
-
const o = C2({
|
|
2133
|
-
data: e,
|
|
2134
|
-
context: { dataSource: s, schemaIndex: n, pathPrefix: "" }
|
|
2135
|
-
});
|
|
2136
|
-
return fe(o) ? { success: true, data: o } : {
|
|
2137
|
-
success: false,
|
|
2138
|
-
errors: [h2(g2({}, t), { message: "Invalid measure JSON" })]
|
|
2139
|
-
};
|
|
2140
|
-
} catch (o) {
|
|
2141
|
-
const i = o instanceof Error ? o.message : "Unknown error";
|
|
2142
|
-
return {
|
|
2143
|
-
success: false,
|
|
2144
|
-
errors: [h2(g2({}, t), { message: i })]
|
|
2145
|
-
};
|
|
2146
|
-
}
|
|
2147
|
-
};
|
|
2148
|
-
var ws = (e, r, t) => r ? mp(r) ? { measure: e.sort(ap(r)) } : {
|
|
2149
|
-
measure: e,
|
|
2150
|
-
error: h2(g2({}, t), {
|
|
2151
|
-
message: `Invalid sort type. Expected "sortAsc", "sortDesc", or "sortNone". Got: "${r}".`
|
|
2152
|
-
})
|
|
2153
|
-
} : { measure: e };
|
|
2154
|
-
var qs = (e, r, t, s) => {
|
|
2155
|
-
const n = C2({
|
|
2156
|
-
data: e.column,
|
|
2157
|
-
context: { dataSource: r, schemaIndex: t, pathPrefix: "" }
|
|
2158
|
-
});
|
|
2159
|
-
return fe(n) ? ws(n, e.sortType, s) : { error: h2(g2({}, s), { message: "Invalid measure JSON" }) };
|
|
2160
|
-
};
|
|
2161
|
-
var Es = (e, r, t, s) => {
|
|
2162
|
-
if (zt(e))
|
|
2163
|
-
return qs(e, r, t, s);
|
|
2164
|
-
if (E3(e)) {
|
|
2165
|
-
const n = Fs(e, { dataSource: r, schemaIndex: t }, s);
|
|
2166
|
-
return n.success ? { measure: n.data } : { error: n.errors[0] };
|
|
2167
|
-
}
|
|
2168
|
-
return {
|
|
2169
|
-
error: h2(g2({}, s), {
|
|
2170
|
-
message: 'Invalid measure item. Expected a function call (function/args) or object with "column" and optional "sortType".'
|
|
2171
|
-
})
|
|
2172
|
-
};
|
|
2173
|
-
};
|
|
2174
|
-
var Cs = (e) => {
|
|
2175
|
-
const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
|
|
2176
|
-
if (!r)
|
|
2177
|
-
return { success: true, data: [] };
|
|
2178
|
-
if (!Array.isArray(r))
|
|
2179
|
-
return {
|
|
2180
|
-
success: false,
|
|
2181
|
-
errors: [
|
|
2182
|
-
{
|
|
2183
|
-
category: "measures",
|
|
2184
|
-
index: -1,
|
|
2185
|
-
input: r,
|
|
2186
|
-
message: "Invalid measures JSON. Expected an array."
|
|
2187
|
-
}
|
|
2188
|
-
]
|
|
2189
|
-
};
|
|
2190
|
-
const n = [], o = [];
|
|
2191
|
-
return r.forEach((i, a) => {
|
|
2192
|
-
const u = {
|
|
2193
|
-
category: "measures",
|
|
2194
|
-
index: a,
|
|
2195
|
-
input: i
|
|
2196
|
-
};
|
|
2197
|
-
try {
|
|
2198
|
-
const c2 = Es(i, t, s, u);
|
|
2199
|
-
if (c2.error) {
|
|
2200
|
-
o.push(c2.error);
|
|
2201
|
-
return;
|
|
2202
|
-
}
|
|
2203
|
-
c2.measure && n.push(c2.measure);
|
|
2204
|
-
} catch (c2) {
|
|
2205
|
-
const p2 = c2 instanceof Error ? c2.message : "Unknown error";
|
|
2206
|
-
o.push(h2(g2({}, u), { message: p2 }));
|
|
2207
|
-
}
|
|
2208
|
-
}), o.length > 0 ? { success: false, errors: o } : { success: true, data: n };
|
|
2209
|
-
};
|
|
2210
|
-
var ks = (e) => {
|
|
2211
|
-
const { data: r } = e, { dataSource: t, tables: s } = e.context, n = Bt(s), o = [], i = M(() => jt({
|
|
2212
|
-
data: r.dimensions || [],
|
|
2213
|
-
context: { dataSource: t, schemaIndex: n }
|
|
2214
|
-
}), o), a = M(() => Cs({
|
|
2215
|
-
data: r.measures || [],
|
|
2216
|
-
context: { dataSource: t, schemaIndex: n }
|
|
2217
|
-
}), o), u = M(() => gs({
|
|
2218
|
-
data: r.filters || [],
|
|
2219
|
-
context: { dataSource: t, schemaIndex: n }
|
|
2220
|
-
}), o);
|
|
2221
|
-
let c2 = null;
|
|
2222
|
-
return r.highlights && (c2 = M(() => bs({
|
|
2223
|
-
data: r.highlights || [],
|
|
2224
|
-
context: { dataSource: t, schemaIndex: n }
|
|
2225
|
-
}), o)), o.length > 0 ? {
|
|
2226
|
-
success: false,
|
|
2227
|
-
errors: o
|
|
2228
|
-
} : {
|
|
2229
|
-
success: true,
|
|
2230
|
-
data: g2({
|
|
2231
|
-
dataSource: ip(t),
|
|
2232
|
-
dimensions: i || [],
|
|
2233
|
-
measures: a || [],
|
|
2234
|
-
filters: u || []
|
|
2235
|
-
}, c2 && { highlights: c2 })
|
|
2236
|
-
};
|
|
2237
|
-
};
|
|
2238
|
-
function Rs(e) {
|
|
2239
|
-
const { filters: r, relations: t } = rp(e.filters || []);
|
|
2240
|
-
return {
|
|
2241
|
-
dataSource: e.dataSource,
|
|
2242
|
-
dimensions: e.dimensions,
|
|
2243
|
-
measures: e.measures,
|
|
2244
|
-
filters: r,
|
|
2245
|
-
filterRelations: t,
|
|
2246
|
-
highlights: e.highlights
|
|
2247
|
-
};
|
|
2248
|
-
}
|
|
2249
|
-
function Vs(e, r, t = false) {
|
|
2250
|
-
const s = Rs(e), n = Dr(s, r);
|
|
2251
|
-
return bh(n, t);
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2254
|
-
export { c, R, x, Ps, ks, Vs };
|